diff --git a/documentation/plugins/blog-plugin.js b/documentation/plugins/blog-plugin.js index 07ce448572a7..031d2fdae719 100644 --- a/documentation/plugins/blog-plugin.js +++ b/documentation/plugins/blog-plugin.js @@ -5,363 +5,345 @@ const path = require("path"); const defaultBlogPlugin = blogPluginExports.default; const pluginDataDirRoot = path.join( - ".docusaurus", - "docusaurus-plugin-content-blog", + ".docusaurus", + "docusaurus-plugin-content-blog", ); const aliasedSource = (source) => - `~blog/${utils.posixPath(path.relative(pluginDataDirRoot, source))}`; + `~blog/${utils.posixPath(path.relative(pluginDataDirRoot, source))}`; function paginateBlogPosts({ - blogPosts, - basePageUrl, - blogTitle, - blogDescription, - postsPerPageOption, + blogPosts, + basePageUrl, + blogTitle, + blogDescription, + postsPerPageOption, }) { - const totalCount = blogPosts.length; - const postsPerPage = - postsPerPageOption === "ALL" ? totalCount : postsPerPageOption; - - const numberOfPages = Math.ceil(totalCount / postsPerPage); - - const pages = []; - - function permalink(page) { - return page > 0 - ? utils.normalizeUrl([basePageUrl, `page/${page + 1}`]) - : basePageUrl; - } - - for (let page = 0; page < numberOfPages; page += 1) { - pages.push({ - items: blogPosts - .slice(page * postsPerPage, (page + 1) * postsPerPage) - .map((item) => item.id), - metadata: { - permalink: permalink(page), - page: page + 1, - postsPerPage, - totalPages: numberOfPages, - totalCount, - previousPage: page !== 0 ? permalink(page - 1) : undefined, - nextPage: - page < numberOfPages - 1 ? permalink(page + 1) : undefined, - blogDescription, - blogTitle, - }, - }); - } + const totalCount = blogPosts.length; + const postsPerPage = + postsPerPageOption === "ALL" ? totalCount : postsPerPageOption; + + const numberOfPages = Math.ceil(totalCount / postsPerPage); + + const pages = []; + + function permalink(page) { + return page > 0 + ? utils.normalizeUrl([basePageUrl, `page/${page + 1}`]) + : basePageUrl; + } + + for (let page = 0; page < numberOfPages; page += 1) { + pages.push({ + items: blogPosts + .slice(page * postsPerPage, (page + 1) * postsPerPage) + .map((item) => item.id), + metadata: { + permalink: permalink(page), + page: page + 1, + postsPerPage, + totalPages: numberOfPages, + totalCount, + previousPage: page !== 0 ? permalink(page - 1) : undefined, + nextPage: page < numberOfPages - 1 ? permalink(page + 1) : undefined, + blogDescription, + blogTitle, + }, + }); + } - return pages; + return pages; } function getMultipleRandomElement(arr, num) { - const shuffled = [...arr].sort(() => 0.5 - Math.random()); + const shuffled = [...arr].sort(() => 0.5 - Math.random()); - return shuffled.slice(0, num); + return shuffled.slice(0, num); } function getReletadPosts(allBlogPosts, metadata) { - const relatedPosts = allBlogPosts.filter( - (post) => - post.metadata.frontMatter.tags?.some((tag) => - metadata.frontMatter.tags?.includes(tag), - ) && post.metadata.title !== metadata.title, - ); - - const randomThreeRelatedPosts = getMultipleRandomElement(relatedPosts, 3); - - const filteredPostInfos = randomThreeRelatedPosts.map((post) => { - return { - title: post.metadata.title, - description: post.metadata.description, - permalink: post.metadata.permalink, - formattedDate: post.metadata.formattedDate, - authors: post.metadata.authors, - readingTime: post.metadata.readingTime, - date: post.metadata.date, - }; - }); + const relatedPosts = allBlogPosts.filter( + (post) => + post.metadata.frontMatter.tags?.some((tag) => + metadata.frontMatter.tags?.includes(tag), + ) && post.metadata.title !== metadata.title, + ); + + const randomThreeRelatedPosts = getMultipleRandomElement(relatedPosts, 3); + + const filteredPostInfos = randomThreeRelatedPosts.map((post) => { + return { + title: post.metadata.title, + description: post.metadata.description, + permalink: post.metadata.permalink, + formattedDate: post.metadata.formattedDate, + authors: post.metadata.authors, + readingTime: post.metadata.readingTime, + date: post.metadata.date, + }; + }); - return filteredPostInfos; + return filteredPostInfos; } function getAuthorPosts(allBlogPosts, metadata) { - const authorPosts = allBlogPosts.filter( - (post) => - post.metadata.frontMatter.authors === - metadata.frontMatter.authors && - post.metadata.title !== metadata.title, - ); - - const randomThreeAuthorPosts = getMultipleRandomElement(authorPosts, 3); - - const filteredPostInfos = randomThreeAuthorPosts.map((post) => { - return { - title: post.metadata.title, - description: post.metadata.description, - permalink: post.metadata.permalink, - formattedDate: post.metadata.formattedDate, - authors: post.metadata.authors, - readingTime: post.metadata.readingTime, - date: post.metadata.date, - }; - }); + const authorPosts = allBlogPosts.filter( + (post) => + post.metadata.frontMatter.authors === metadata.frontMatter.authors && + post.metadata.title !== metadata.title, + ); - return filteredPostInfos; + const randomThreeAuthorPosts = getMultipleRandomElement(authorPosts, 3); + + const filteredPostInfos = randomThreeAuthorPosts.map((post) => { + return { + title: post.metadata.title, + description: post.metadata.description, + permalink: post.metadata.permalink, + formattedDate: post.metadata.formattedDate, + authors: post.metadata.authors, + readingTime: post.metadata.readingTime, + date: post.metadata.date, + }; + }); + + return filteredPostInfos; } async function blogPluginExtended(...pluginArgs) { - const blogPluginInstance = await defaultBlogPlugin(...pluginArgs); + const blogPluginInstance = await defaultBlogPlugin(...pluginArgs); + + const { blogTitle, blogDescription, postsPerPage } = pluginArgs[1]; + + return { + // Add all properties of the default blog plugin so existing functionality is preserved + ...blogPluginInstance, + /** + * Override the default `contentLoaded` hook to access blog posts data + */ + contentLoaded: async function (data) { + const { content: blogContents, actions } = data; + const { addRoute, createData } = actions; + const { + blogPosts: allBlogPosts, + blogTags, + blogTagsListPath, + } = blogContents; + + const blogItemsToMetadata = {}; + + function blogPostItemsModule(items) { + return items.map((postId) => { + const blogPostMetadata = blogItemsToMetadata[postId]; + + return { + content: { + __import: true, + path: blogPostMetadata.source, + query: { + truncated: true, + }, + }, + }; + }); + } + + const featuredBlogPosts = allBlogPosts.filter( + (post) => post.metadata.frontMatter.is_featured === true, + ); + + const blogPosts = allBlogPosts.filter( + (post) => post.metadata.frontMatter.is_featured !== true, + ); + + const blogListPaginated = paginateBlogPosts({ + blogPosts, + basePageUrl: "/blog", + blogTitle, + blogDescription, + postsPerPageOption: postsPerPage, + }); + + // Create routes for blog entries. + await Promise.all( + allBlogPosts.map(async (blogPost) => { + const { id, metadata } = blogPost; + + const relatedPosts = getReletadPosts(allBlogPosts, metadata); + + const authorPosts = getAuthorPosts(allBlogPosts, metadata); + + await createData( + // Note that this created data path must be in sync with + // metadataPath provided to mdx-loader. + `${utils.docuHash(metadata.source)}.json`, + JSON.stringify({ ...metadata, relatedPosts, authorPosts }, null, 2), + ); + + addRoute({ + path: metadata.permalink, + component: "@theme/BlogPostPage", + exact: true, + modules: { + content: metadata.source, + }, + }); + + blogItemsToMetadata[id] = metadata; + }), + ); + + // Create routes for blog's paginated list entries. + await Promise.all( + blogListPaginated.map(async (listPage) => { + const { metadata, items } = listPage; + const { permalink } = metadata; + + const pageMetadataPath = await createData( + `${utils.docuHash(permalink)}.json`, + JSON.stringify(metadata, null, 2), + ); + + const tagsProp = Object.values(blogTags).map((tag) => ({ + label: tag.label, + permalink: tag.permalink, + count: tag.items.length, + })); + + const tagsPropPath = await createData( + `${utils.docuHash(`${blogTagsListPath}-tags`)}.json`, + JSON.stringify(tagsProp, null, 2), + ); + + addRoute({ + path: permalink, + component: "@theme/BlogListPage", + exact: true, + modules: { + items: blogPostItemsModule( + permalink === "/blog" + ? [...items, ...featuredBlogPosts.map((post) => post.id)] + : items, + ), + metadata: aliasedSource(pageMetadataPath), + tags: aliasedSource(tagsPropPath), + }, + }); + }), + ); + + const authorsArray = allBlogPosts + .map((post) => post.metadata.frontMatter.authors) + .filter((authorName) => authorName !== undefined); + const uniqueAuthors = [...new Set(authorsArray)]; + + uniqueAuthors.map(async (author) => { + const authorPosts = allBlogPosts.filter( + (post) => post.metadata.frontMatter.authors === author, + ); + + const authorListPaginated = paginateBlogPosts({ + blogPosts: authorPosts, + basePageUrl: "/blog/author/" + author, + blogTitle, + blogDescription, + postsPerPageOption: "ALL", + }); - const { blogTitle, blogDescription, postsPerPage } = pluginArgs[1]; + authorListPaginated.map((authorListPage) => { + const { metadata, items } = authorListPage; + const { permalink } = metadata; - return { - // Add all properties of the default blog plugin so existing functionality is preserved - ...blogPluginInstance, - /** - * Override the default `contentLoaded` hook to access blog posts data - */ - contentLoaded: async function (data) { - const { content: blogContents, actions } = data; - const { addRoute, createData } = actions; - const { - blogPosts: allBlogPosts, - blogTags, - blogTagsListPath, - } = blogContents; - - const blogItemsToMetadata = {}; - - function blogPostItemsModule(items) { - return items.map((postId) => { - const blogPostMetadata = blogItemsToMetadata[postId]; - - return { - content: { - __import: true, - path: blogPostMetadata.source, - query: { - truncated: true, - }, - }, - }; - }); - } - - const featuredBlogPosts = allBlogPosts.filter( - (post) => post.metadata.frontMatter.is_featured === true, + addRoute({ + path: permalink, + component: "@site/src/components/blog/author-page", + exact: true, + modules: { + items: blogPostItemsModule(items), + }, + }); + }); + }); + + // Tags. This is the last part so we early-return if there are no tags. + if (Object.keys(blogTags).length === 0) { + return; + } + + async function createTagsListPage() { + const tagsProp = Object.values(blogTags).map((tag) => ({ + label: tag.label, + permalink: tag.permalink, + count: tag.items.length, + })); + + const tagsPropPath = await createData( + `${utils.docuHash(`${blogTagsListPath}-tags`)}.json`, + JSON.stringify(tagsProp, null, 2), + ); + + addRoute({ + path: blogTagsListPath, + component: "@theme/BlogTagsListPage", + exact: true, + modules: { + tags: aliasedSource(tagsPropPath), + }, + }); + } + + async function createTagPostsListPage(tag) { + await Promise.all( + tag.pages.map(async (blogPaginated) => { + const { metadata, items } = blogPaginated; + const tagProp = { + label: tag.label, + permalink: tag.permalink, + allTagsPath: blogTagsListPath, + count: tag.items.length, + }; + const tagPropPath = await createData( + `${utils.docuHash(metadata.permalink)}.json`, + JSON.stringify(tagProp, null, 2), ); - const blogPosts = allBlogPosts.filter( - (post) => post.metadata.frontMatter.is_featured !== true, + const listMetadataPath = await createData( + `${utils.docuHash(metadata.permalink)}-list.json`, + JSON.stringify(metadata, null, 2), ); - const blogListPaginated = paginateBlogPosts({ - blogPosts, - basePageUrl: "/blog", - blogTitle, - blogDescription, - postsPerPageOption: postsPerPage, - }); - - // Create routes for blog entries. - await Promise.all( - allBlogPosts.map(async (blogPost) => { - const { id, metadata } = blogPost; - - const relatedPosts = getReletadPosts( - allBlogPosts, - metadata, - ); - - const authorPosts = getAuthorPosts(allBlogPosts, metadata); - - await createData( - // Note that this created data path must be in sync with - // metadataPath provided to mdx-loader. - `${utils.docuHash(metadata.source)}.json`, - JSON.stringify( - { ...metadata, relatedPosts, authorPosts }, - null, - 2, - ), - ); - - addRoute({ - path: metadata.permalink, - component: "@theme/BlogPostPage", - exact: true, - modules: { - content: metadata.source, - }, - }); - - blogItemsToMetadata[id] = metadata; - }), - ); + const tagsProp = Object.values(blogTags).map((tag) => ({ + label: tag.label, + permalink: tag.permalink, + count: tag.items.length, + })); - // Create routes for blog's paginated list entries. - await Promise.all( - blogListPaginated.map(async (listPage) => { - const { metadata, items } = listPage; - const { permalink } = metadata; - - const pageMetadataPath = await createData( - `${utils.docuHash(permalink)}.json`, - JSON.stringify(metadata, null, 2), - ); - - const tagsProp = Object.values(blogTags).map((tag) => ({ - label: tag.label, - permalink: tag.permalink, - count: tag.items.length, - })); - - const tagsPropPath = await createData( - `${utils.docuHash(`${blogTagsListPath}-tags`)}.json`, - JSON.stringify(tagsProp, null, 2), - ); - - addRoute({ - path: permalink, - component: "@theme/BlogListPage", - exact: true, - modules: { - items: blogPostItemsModule( - permalink === "/blog" - ? [ - ...items, - ...featuredBlogPosts.map( - (post) => post.id, - ), - ] - : items, - ), - metadata: aliasedSource(pageMetadataPath), - tags: aliasedSource(tagsPropPath), - }, - }); - }), + const tagsPropPath = await createData( + `${utils.docuHash(`${blogTagsListPath}-tags`)}.json`, + JSON.stringify(tagsProp, null, 2), ); - const authorsArray = allBlogPosts - .map((post) => post.metadata.frontMatter.authors) - .filter((authorName) => authorName !== undefined); - const uniqueAuthors = [...new Set(authorsArray)]; - - uniqueAuthors.map(async (author) => { - const authorPosts = allBlogPosts.filter( - (post) => post.metadata.frontMatter.authors === author, - ); - - const authorListPaginated = paginateBlogPosts({ - blogPosts: authorPosts, - basePageUrl: "/blog/author/" + author, - blogTitle, - blogDescription, - postsPerPageOption: "ALL", - }); - - authorListPaginated.map((authorListPage) => { - const { metadata, items } = authorListPage; - const { permalink } = metadata; - - addRoute({ - path: permalink, - component: "@site/src/components/blog/author-page", - exact: true, - modules: { - items: blogPostItemsModule(items), - }, - }); - }); + addRoute({ + path: metadata.permalink, + component: "@theme/BlogTagsPostsPage", + exact: true, + modules: { + items: blogPostItemsModule(items), + tag: aliasedSource(tagPropPath), + tags: aliasedSource(tagsPropPath), + listMetadata: aliasedSource(listMetadataPath), + }, }); - - // Tags. This is the last part so we early-return if there are no tags. - if (Object.keys(blogTags).length === 0) { - return; - } - - async function createTagsListPage() { - const tagsProp = Object.values(blogTags).map((tag) => ({ - label: tag.label, - permalink: tag.permalink, - count: tag.items.length, - })); - - const tagsPropPath = await createData( - `${utils.docuHash(`${blogTagsListPath}-tags`)}.json`, - JSON.stringify(tagsProp, null, 2), - ); - - addRoute({ - path: blogTagsListPath, - component: "@theme/BlogTagsListPage", - exact: true, - modules: { - tags: aliasedSource(tagsPropPath), - }, - }); - } - - async function createTagPostsListPage(tag) { - await Promise.all( - tag.pages.map(async (blogPaginated) => { - const { metadata, items } = blogPaginated; - const tagProp = { - label: tag.label, - permalink: tag.permalink, - allTagsPath: blogTagsListPath, - count: tag.items.length, - }; - const tagPropPath = await createData( - `${utils.docuHash(metadata.permalink)}.json`, - JSON.stringify(tagProp, null, 2), - ); - - const listMetadataPath = await createData( - `${utils.docuHash(metadata.permalink)}-list.json`, - JSON.stringify(metadata, null, 2), - ); - - const tagsProp = Object.values(blogTags).map((tag) => ({ - label: tag.label, - permalink: tag.permalink, - count: tag.items.length, - })); - - const tagsPropPath = await createData( - `${utils.docuHash( - `${blogTagsListPath}-tags`, - )}.json`, - JSON.stringify(tagsProp, null, 2), - ); - - addRoute({ - path: metadata.permalink, - component: "@theme/BlogTagsPostsPage", - exact: true, - modules: { - items: blogPostItemsModule(items), - tag: aliasedSource(tagPropPath), - tags: aliasedSource(tagsPropPath), - listMetadata: aliasedSource(listMetadataPath), - }, - }); - }), - ); - } - - await createTagsListPage(); - await Promise.all( - Object.values(blogTags).map(createTagPostsListPage), - ); - }, - }; + }), + ); + } + + await createTagsListPage(); + await Promise.all(Object.values(blogTags).map(createTagPostsListPage)); + }, + }; } module.exports = { - ...blogPluginExports, - default: blogPluginExtended, + ...blogPluginExports, + default: blogPluginExtended, }; diff --git a/documentation/plugins/clarity.js b/documentation/plugins/clarity.js index 90a36119dd15..4434f557ca92 100644 --- a/documentation/plugins/clarity.js +++ b/documentation/plugins/clarity.js @@ -2,30 +2,30 @@ Object.defineProperty(exports, "__esModule", { value: true }); async function microsoftClarity() { - return { - name: "docusaurus-plugin-refine-clarity", - injectHtmlTags() { - return { - headTags: [ - { - tagName: "link", - attributes: { - rel: "preconnect", - href: "https://www.clarity.ms", - }, - }, - { - tagName: "script", - innerHTML: ` + return { + name: "docusaurus-plugin-refine-clarity", + injectHtmlTags() { + return { + headTags: [ + { + tagName: "link", + attributes: { + rel: "preconnect", + href: "https://www.clarity.ms", + }, + }, + { + tagName: "script", + innerHTML: ` (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "jquujqps85");`, - }, - ], - }; - }, - }; + }, + ], + }; + }, + }; } exports.default = microsoftClarity; diff --git a/documentation/plugins/clarity.ts b/documentation/plugins/clarity.ts index 07529fa843c8..70c7e8d34a59 100644 --- a/documentation/plugins/clarity.ts +++ b/documentation/plugins/clarity.ts @@ -1,29 +1,29 @@ import type { Plugin } from "@docusaurus/types"; export default async function microsoftClarity(): Promise { - return { - name: "docusaurus-plugin-refine-clarity", - injectHtmlTags() { - return { - headTags: [ - { - tagName: "link", - attributes: { - rel: "preconnect", - href: "https://www.clarity.ms", - }, - }, - { - tagName: "script", - innerHTML: ` + return { + name: "docusaurus-plugin-refine-clarity", + injectHtmlTags() { + return { + headTags: [ + { + tagName: "link", + attributes: { + rel: "preconnect", + href: "https://www.clarity.ms", + }, + }, + { + tagName: "script", + innerHTML: ` (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "jquujqps85");`, - }, - ], - }; - }, - }; + }, + ], + }; + }, + }; } diff --git a/documentation/plugins/docgen.js b/documentation/plugins/docgen.js index 9f631c8b800e..990c63d56a23 100644 --- a/documentation/plugins/docgen.js +++ b/documentation/plugins/docgen.js @@ -1,31 +1,28 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; + return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { - let lastAccessLHS = undefined; - let value = ops[0]; - let i = 1; - while (i < ops.length) { - const op = ops[i]; - const fn = ops[i + 1]; - i += 2; - if ( - (op === "optionalAccess" || op === "optionalCall") && - value == null - ) { - return undefined; - } - if (op === "access" || op === "optionalAccess") { - lastAccessLHS = value; - value = fn(value); - } else if (op === "call" || op === "optionalCall") { - value = fn((...args) => value.call(lastAccessLHS, ...args)); - lastAccessLHS = undefined; - } + let lastAccessLHS = undefined; + let value = ops[0]; + let i = 1; + while (i < ops.length) { + const op = ops[i]; + const fn = ops[i + 1]; + i += 2; + if ((op === "optionalAccess" || op === "optionalCall") && value == null) { + return undefined; + } + if (op === "access" || op === "optionalAccess") { + lastAccessLHS = value; + value = fn(value); + } else if (op === "call" || op === "optionalCall") { + value = fn((...args) => value.call(lastAccessLHS, ...args)); + lastAccessLHS = undefined; } - return value; + } + return value; } // var _fsextra = require("fs-extra"); @@ -45,10 +42,10 @@ const packagesDir = _path2.default.join(__dirname, "./../..", "./packages"); const sourceDir = "./src"; const excludedFilePatterns = [ - "node_modules", - "tsup.config.ts", - ".test.", - ".spec.", + "node_modules", + "tsup.config.ts", + ".test.", + ".spec.", ]; const excludedValueDeclarationPatterns = ["node_modules/antd/lib/list/"]; @@ -56,398 +53,386 @@ const excludedValueDeclarationPatterns = ["node_modules/antd/lib/list/"]; const excludePropPatterns = [/^__.*/]; const excludedProps = [ - "className", - "classNames", - "styles", - "unstyled", - "component", - "key", - "ref", - "style", - "sx", - "m", - "mx", - "my", - "mt", - "ml", - "mr", - "mb", - "p", - "px", - "py", - "pt", - "pl", - "pr", - "pb", + "className", + "classNames", + "styles", + "unstyled", + "component", + "key", + "ref", + "style", + "sx", + "m", + "mx", + "my", + "mt", + "ml", + "mr", + "mb", + "p", + "px", + "py", + "pt", + "pl", + "pr", + "pb", ]; const replacementProps = { - // "null | string | number | false | true | ReactElement> | ReactFragment | ReactPortal": "ReactNode", - ReactElement: - "ReactElement ReactElement) | (new (props: any) => Component)>", - "ReactNode | (value: number) => ReactNode": - "string | number | boolean | {} | ReactElement ReactElement) | (new (props: any) => Component)> | ReactNodeArray | ReactPortal | ((value: number) => ReactNode)", - ActionButtonRenderer: - "ReactNode | ({ defaultButtons: ReactNode }) => ReactNode", - "DetailedHTMLProps, HTMLDivElement>": - "DetailedHTMLProps", - "false | OpenNotificationParams | ((data?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": - "false | OpenNotificationParams | (data, values, resource) => OpenNotificationParams", - "false | OpenNotificationParams | ((error?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": - "false | OpenNotificationParams | (error, values, resource) => OpenNotificationParams", - 'SvgIconProps<"svg", {}>': "SvgIconProps", - SpaceProps: "[`SpaceProps`](https://styled-system.com/api#space)", - "((value: DeleteOneResponse) => void)": - "(value: DeleteOneResponse) => void", - "{ [key: string]: any; ids?: BaseKey[]; }": - "{ [key]: any; ids?: BaseKey[]; }", - "BaseKey | BaseKey[]": - "[BaseKey](/docs/core/interface-references/#basekey) | [BaseKey[]](/docs/core/interface-references/#basekey)", - BaseKey: "[BaseKey](/docs/core/interface-references/#basekey)", - MetaDataQuery: - "[MetaDataQuery](/docs/core/interface-references/#metadataquery)", - CrudFilters: "[CrudFilters](/docs/core/interface-references/#crudfilters)", - CrudSorting: "[CrudSorting](/docs/core/interface-references/#crudsorting)", + // "null | string | number | false | true | ReactElement> | ReactFragment | ReactPortal": "ReactNode", + ReactElement: + "ReactElement ReactElement) | (new (props: any) => Component)>", + "ReactNode | (value: number) => ReactNode": + "string | number | boolean | {} | ReactElement ReactElement) | (new (props: any) => Component)> | ReactNodeArray | ReactPortal | ((value: number) => ReactNode)", + ActionButtonRenderer: + "ReactNode | ({ defaultButtons: ReactNode }) => ReactNode", + "DetailedHTMLProps, HTMLDivElement>": + "DetailedHTMLProps", + "false | OpenNotificationParams | ((data?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": + "false | OpenNotificationParams | (data, values, resource) => OpenNotificationParams", + "false | OpenNotificationParams | ((error?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": + "false | OpenNotificationParams | (error, values, resource) => OpenNotificationParams", + 'SvgIconProps<"svg", {}>': "SvgIconProps", + SpaceProps: "[`SpaceProps`](https://styled-system.com/api#space)", + "((value: DeleteOneResponse) => void)": + "(value: DeleteOneResponse) => void", + "{ [key: string]: any; ids?: BaseKey[]; }": + "{ [key]: any; ids?: BaseKey[]; }", + "BaseKey | BaseKey[]": + "[BaseKey](/docs/core/interface-references/#basekey) | [BaseKey[]](/docs/core/interface-references/#basekey)", + BaseKey: "[BaseKey](/docs/core/interface-references/#basekey)", + MetaDataQuery: + "[MetaDataQuery](/docs/core/interface-references/#metadataquery)", + CrudFilters: "[CrudFilters](/docs/core/interface-references/#crudfilters)", + CrudSorting: "[CrudSorting](/docs/core/interface-references/#crudsorting)", }; const spinner = _ora2.default.call(void 0, "Generating Refine declarations..."); /** HELPERS */ const getPackageNamePathMap = async (directory) => { - const packages = await _fsextra2.default.readdir(directory); - const packageNamePathMap = {}; - - const includedPackages = - _optionalChain([ - process, - "access", - (_2) => _2.env, - "access", - (_3) => _3.INCLUDED_PACKAGES, - "optionalAccess", - (_4) => _4.split, - "call", - (_5) => _5(","), - ]) || []; - - await Promise.all( - packages.map(async (packageName) => { - const packagePath = _path2.default.join( - directory, - packageName, - "package.json", - ); + const packages = await _fsextra2.default.readdir(directory); + const packageNamePathMap = {}; + + const includedPackages = + _optionalChain([ + process, + "access", + (_2) => _2.env, + "access", + (_3) => _3.INCLUDED_PACKAGES, + "optionalAccess", + (_4) => _4.split, + "call", + (_5) => _5(","), + ]) || []; + + await Promise.all( + packages.map(async (packageName) => { + const packagePath = _path2.default.join( + directory, + packageName, + "package.json", + ); + + if (_fsextra2.default.existsSync(packagePath)) { + const packageJson = await _fsextra2.default.readJSON(packagePath); - if (_fsextra2.default.existsSync(packagePath)) { - const packageJson = await _fsextra2.default.readJSON( - packagePath, - ); + if ( + includedPackages.length == 0 || + includedPackages.some((p) => packageName.includes(p)) + ) { + packageNamePathMap[packageJson.name] = _path2.default.join( + packagePath, + "..", + ); + } + } - if ( - includedPackages.length == 0 || - includedPackages.some((p) => packageName.includes(p)) - ) { - packageNamePathMap[packageJson.name] = _path2.default.join( - packagePath, - "..", - ); - } - } - - return packageName; - }), - ); + return packageName; + }), + ); - return packageNamePathMap; + return packageNamePathMap; }; const getPaths = async (packageDir, excludedPatterns) => { - const dir = await _fsextra2.default.readdir(packageDir); - const filtered = []; - await Promise.all( - dir.map(async (file) => { - const result = await _fsextra2.default.pathExists( - _path2.default.join(packageDir, file), - ); - if (result) { - filtered.push(file); - } - }), - ); - - return filtered - .map((p) => _path2.default.join(packageDir, p)) - .filter( - (p) => !excludedPatterns.some((pattern) => p.includes(pattern)), - ); + const dir = await _fsextra2.default.readdir(packageDir); + const filtered = []; + await Promise.all( + dir.map(async (file) => { + const result = await _fsextra2.default.pathExists( + _path2.default.join(packageDir, file), + ); + if (result) { + filtered.push(file); + } + }), + ); + + return filtered + .map((p) => _path2.default.join(packageDir, p)) + .filter((p) => !excludedPatterns.some((pattern) => p.includes(pattern))); }; const _getPrefixFromDeclarationPath = async (path) => { - const map = await getPackageNamePathMap(packagesDir); - const packageName = Object.keys(map).find((key) => path.includes(map[key])); - return packageName; + const map = await getPackageNamePathMap(packagesDir); + const packageName = Object.keys(map).find((key) => path.includes(map[key])); + return packageName; }; const getComponentName = (name, _fileName) => { - return name; - // return `${getPrefixFromDeclarationPath(fileName)}#${name}`; + return name; + // return `${getPrefixFromDeclarationPath(fileName)}#${name}`; }; const getOutputName = (packageName) => { - return packageName; + return packageName; }; const declarationFilter = (declaration) => { - return ( - !declaration.fileName.includes("node_modules") || - declaration.fileName.includes("@refinedev") - ); + return ( + !declaration.fileName.includes("node_modules") || + declaration.fileName.includes("@refinedev") + ); }; const valueDeclarationFilter = (tsDeclaration) => { - // excludedValueDeclarationPatterns includes fileNames of source files to be ignored (partially) - const sourceFileName = _optionalChain([ - tsDeclaration, - "optionalAccess", - (_6) => _6.getSourceFile, - "call", - (_7) => _7(), - "access", - (_8) => _8.fileName, - ]); - // if sourceFileName includes any of the excludedValueDeclarationPatterns then ignore it - const isIgnored = excludedValueDeclarationPatterns.some((pattern) => - _optionalChain([ - sourceFileName, - "optionalAccess", - (_9) => _9.includes, - "call", - (_10) => _10(pattern), - ]), - ); - - return !isIgnored; + // excludedValueDeclarationPatterns includes fileNames of source files to be ignored (partially) + const sourceFileName = _optionalChain([ + tsDeclaration, + "optionalAccess", + (_6) => _6.getSourceFile, + "call", + (_7) => _7(), + "access", + (_8) => _8.fileName, + ]); + // if sourceFileName includes any of the excludedValueDeclarationPatterns then ignore it + const isIgnored = excludedValueDeclarationPatterns.some((pattern) => + _optionalChain([ + sourceFileName, + "optionalAccess", + (_9) => _9.includes, + "call", + (_10) => _10(pattern), + ]), + ); + + return !isIgnored; }; const createParser = (configPath) => { - const docgenParser = _reactdocgentypescript.withCustomConfig.call( - void 0, - _path2.default.join(configPath), - { - savePropValueAsString: true, - shouldExtractLiteralValuesFromEnum: true, - shouldRemoveUndefinedFromOptional: true, - shouldIncludePropTagMap: true, - componentNameResolver: (exp, source) => { - const name = getComponentName(exp.getName(), source.fileName); - if (valueDeclarationFilter(exp.valueDeclaration)) { - return name; - } - return `IGNORED_${name}`; - }, - propFilter: (prop) => { - const isExcluded = - excludedProps.includes(prop.name) || - excludePropPatterns.some((pattern) => - pattern.test(prop.name), - ); - - const isExternal = - prop.declarations && - prop.declarations.length > 0 && - !Boolean(prop.declarations.find(declarationFilter)); - - const isUnknown = typeof prop.declarations === "undefined"; - - if (isExcluded || isExternal || isUnknown) { - return false; - } - return true; - }, - }, - ); + const docgenParser = _reactdocgentypescript.withCustomConfig.call( + void 0, + _path2.default.join(configPath), + { + savePropValueAsString: true, + shouldExtractLiteralValuesFromEnum: true, + shouldRemoveUndefinedFromOptional: true, + shouldIncludePropTagMap: true, + componentNameResolver: (exp, source) => { + const name = getComponentName(exp.getName(), source.fileName); + if (valueDeclarationFilter(exp.valueDeclaration)) { + return name; + } + return `IGNORED_${name}`; + }, + propFilter: (prop) => { + const isExcluded = + excludedProps.includes(prop.name) || + excludePropPatterns.some((pattern) => pattern.test(prop.name)); + + const isExternal = + prop.declarations && + prop.declarations.length > 0 && + !Boolean(prop.declarations.find(declarationFilter)); + + const isUnknown = typeof prop.declarations === "undefined"; + + if (isExcluded || isExternal || isUnknown) { + return false; + } + return true; + }, + }, + ); - return docgenParser; + return docgenParser; }; const normalizeMarkdownLinks = (value) => { - return value.replace(/\[(.*?)\]\s{1}\((.*?)\)/g, (_, p1, p2) => { - return `[${p1}](${p2})`; - }); + return value.replace(/\[(.*?)\]\s{1}\((.*?)\)/g, (_, p1, p2) => { + return `[${p1}](${p2})`; + }); }; const prepareDeclaration = (declaration) => { - const data = { ...declaration }; - delete data.methods; - delete data.tags; + const data = { ...declaration }; + delete data.methods; + delete data.tags; - data.generatedAt = Date.now(); + data.generatedAt = Date.now(); - Object.keys(data.props).forEach((prop) => { - data.props[prop].type.name = normalizeMarkdownLinks( - data.props[prop].type.name, - ); + Object.keys(data.props).forEach((prop) => { + data.props[prop].type.name = normalizeMarkdownLinks( + data.props[prop].type.name, + ); - delete data.props[prop].parent; - delete data.props[prop].declarations; + delete data.props[prop].parent; + delete data.props[prop].declarations; - if (data.props[prop].type.raw === "ReactNode") { - data.props[prop].type.name = "ReactNode"; - } + if (data.props[prop].type.raw === "ReactNode") { + data.props[prop].type.name = "ReactNode"; + } - if (data.props[prop].type.name in replacementProps) { - data.props[prop].type.name = - replacementProps[data.props[prop].type.name]; - } + if (data.props[prop].type.name in replacementProps) { + data.props[prop].type.name = replacementProps[data.props[prop].type.name]; + } - if (data.props[prop].type.name === "enum") { - data.props[prop].type.name = data.props[prop].type.value - .map((val) => val.value) - .join(" | "); - } - }); + if (data.props[prop].type.name === "enum") { + data.props[prop].type.name = data.props[prop].type.value + .map((val) => val.value) + .join(" | "); + } + }); - const ordered = Object.keys(data.props) - // .sort() - .reduce((obj, key) => { - obj[key] = data.props[key]; - return obj; - }, {}); + const ordered = Object.keys(data.props) + // .sort() + .reduce((obj, key) => { + obj[key] = data.props[key]; + return obj; + }, {}); - data.props = ordered; + data.props = ordered; - return data; + return data; }; const transposeDeclarations = (declarations) => { - const transposed = {}; + const transposed = {}; - declarations.forEach((declaration) => { - transposed[declaration.displayName] = declaration; - }); + declarations.forEach((declaration) => { + transposed[declaration.displayName] = declaration; + }); - return transposed; + return transposed; }; const generateDeclarations = async (packagePaths) => { - const generated = {}; + const generated = {}; - await Promise.all( - packagePaths.map(async ([packageName, packagePath]) => { - const parser = createParser( - _path2.default.join(packagePath, "./tsconfig.json"), - ); + await Promise.all( + packagePaths.map(async ([packageName, packagePath]) => { + const parser = createParser( + _path2.default.join(packagePath, "./tsconfig.json"), + ); - const sourcePath = _path2.default.join(packagePath, sourceDir); + const sourcePath = _path2.default.join(packagePath, sourceDir); - if (!(await _fsextra2.default.pathExists(sourcePath))) { - spinner.fail("Component path does not exist", sourcePath); - process.exit(1); - } + if (!(await _fsextra2.default.pathExists(sourcePath))) { + spinner.fail("Component path does not exist", sourcePath); + process.exit(1); + } - const declarationPaths = await getPaths( - sourcePath, - excludedFilePatterns, - ); + const declarationPaths = await getPaths(sourcePath, excludedFilePatterns); - const parsed = parser - .parse(declarationPaths) - .map(prepareDeclaration); + const parsed = parser.parse(declarationPaths).map(prepareDeclaration); - const transposed = transposeDeclarations(parsed); + const transposed = transposeDeclarations(parsed); - const outputName = getOutputName(packageName); + const outputName = getOutputName(packageName); - generated[outputName] = transposed; + generated[outputName] = transposed; - spinner.stop(); - spinner.start(`- Generated declarations - ${packageName}`); + spinner.stop(); + spinner.start(`- Generated declarations - ${packageName}`); - return [packageName, packagePath]; - }), - ); + return [packageName, packagePath]; + }), + ); - return generated; + return generated; }; /** DOCGEN */ const handleDocgen = async () => { - const packagePathMap = await getPackageNamePathMap(packagesDir); - const packagePathMapArray = Object.entries(packagePathMap); + const packagePathMap = await getPackageNamePathMap(packagesDir); + const packagePathMapArray = Object.entries(packagePathMap); - spinner.stop(); - spinner.start(`- Found ${packagePathMapArray.length} packages`); + spinner.stop(); + spinner.start(`- Found ${packagePathMapArray.length} packages`); - const res = await generateDeclarations(packagePathMapArray); + const res = await generateDeclarations(packagePathMapArray); - spinner.succeed("Generated declarations"); + spinner.succeed("Generated declarations"); - return res; + return res; }; function plugin() { - return { - name: "docusaurus-plugin-refine-docgen", - getPathsToWatch: function () { - return [packagesDir]; - }, - async loadContent() { - if (!process.env.DISABLE_DOCGEN) { - spinner.start(); - return await handleDocgen(); - } - - return {}; + return { + name: "docusaurus-plugin-refine-docgen", + getPathsToWatch: function () { + return [packagesDir]; + }, + async loadContent() { + if (!process.env.DISABLE_DOCGEN) { + spinner.start(); + return await handleDocgen(); + } + + return {}; + }, + configureWebpack(config) { + return { + resolve: { + alias: { + "@docgen": _path2.default.join( + _optionalChain([ + config, + "access", + (_11) => _11.resolve, + "optionalAccess", + (_12) => _12.alias, + "optionalAccess", + (_13) => _13["@generated"], + ]), + "docusaurus-plugin-refine-docgen", + "default", + ), + }, }, - configureWebpack(config) { - return { - resolve: { - alias: { - "@docgen": _path2.default.join( - _optionalChain([ - config, - "access", - (_11) => _11.resolve, - "optionalAccess", - (_12) => _12.alias, - "optionalAccess", - (_13) => _13["@generated"], - ]), - "docusaurus-plugin-refine-docgen", - "default", - ), - }, - }, - }; - }, - async contentLoaded({ content, actions }) { - if (!process.env.DISABLE_DOCGEN) { - _ora2.default - .call(void 0, "Creating Refine declaration files...") - .succeed(); - - const { createData } = actions; - - const data = []; - - Object.entries(content).forEach( - ([packageName, packageDeclarations]) => { - Object.entries(packageDeclarations).forEach( - ([componentName, declaration]) => { - data.push( - createData( - `${packageName}/${componentName}.json`, - JSON.stringify(declaration), - ), - ); - }, - ); - }, + }; + }, + async contentLoaded({ content, actions }) { + if (!process.env.DISABLE_DOCGEN) { + _ora2.default + .call(void 0, "Creating Refine declaration files...") + .succeed(); + + const { createData } = actions; + + const data = []; + + Object.entries(content).forEach( + ([packageName, packageDeclarations]) => { + Object.entries(packageDeclarations).forEach( + ([componentName, declaration]) => { + data.push( + createData( + `${packageName}/${componentName}.json`, + JSON.stringify(declaration), + ), ); + }, + ); + }, + ); - await Promise.all(data); - } - }, - }; + await Promise.all(data); + } + }, + }; } exports.default = plugin; diff --git a/documentation/plugins/docgen.ts b/documentation/plugins/docgen.ts index f041635d268e..75c8711e989f 100644 --- a/documentation/plugins/docgen.ts +++ b/documentation/plugins/docgen.ts @@ -4,18 +4,18 @@ import fs from "fs-extra"; import ora from "ora"; import path from "path"; import { - ComponentDoc, - PropItem, - withCustomConfig, + ComponentDoc, + PropItem, + withCustomConfig, } from "react-docgen-typescript"; import { ParentType, Props } from "react-docgen-typescript/lib/parser"; import ts from "typescript"; /** TYPES */ type DeclarationType = Omit & - Partial> & { - generatedAt?: number; - }; + Partial> & { + generatedAt?: number; + }; type DocgenContent = Record>; @@ -25,10 +25,10 @@ const packagesDir = path.join(__dirname, "./../..", "./packages"); const sourceDir = "./src"; const excludedFilePatterns = [ - "node_modules", - "tsup.config.ts", - ".test.", - ".spec.", + "node_modules", + "tsup.config.ts", + ".test.", + ".spec.", ]; const excludedValueDeclarationPatterns = ["node_modules/antd/lib/list/"]; @@ -36,352 +36,335 @@ const excludedValueDeclarationPatterns = ["node_modules/antd/lib/list/"]; const excludePropPatterns = [/^__.*/]; const excludedProps = [ - "className", - "classNames", - "styles", - "unstyled", - "component", - "key", - "ref", - "style", - "sx", - "m", - "mx", - "my", - "mt", - "ml", - "mr", - "mb", - "p", - "px", - "py", - "pt", - "pl", - "pr", - "pb", + "className", + "classNames", + "styles", + "unstyled", + "component", + "key", + "ref", + "style", + "sx", + "m", + "mx", + "my", + "mt", + "ml", + "mr", + "mb", + "p", + "px", + "py", + "pt", + "pl", + "pr", + "pb", ]; const replacementProps: Record = { - // "null | string | number | false | true | ReactElement> | ReactFragment | ReactPortal": "ReactNode", - ReactElement: - "ReactElement ReactElement) | (new (props: any) => Component)>", - "ReactNode | (value: number) => ReactNode": - "string | number | boolean | {} | ReactElement ReactElement) | (new (props: any) => Component)> | ReactNodeArray | ReactPortal | ((value: number) => ReactNode)", - ActionButtonRenderer: - "ReactNode | ({ defaultButtons: ReactNode }) => ReactNode", - "DetailedHTMLProps, HTMLDivElement>": - "DetailedHTMLProps", - "false | OpenNotificationParams | ((data?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": - "false | OpenNotificationParams | (data, values, resource) => OpenNotificationParams", - "false | OpenNotificationParams | ((error?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": - "false | OpenNotificationParams | (error, values, resource) => OpenNotificationParams", - 'SvgIconProps<"svg", {}>': "SvgIconProps", - SpaceProps: "[`SpaceProps`](https://styled-system.com/api#space)", - "((value: DeleteOneResponse) => void)": - "(value: DeleteOneResponse) => void", - "{ [key: string]: any; ids?: BaseKey[]; }": - "{ [key]: any; ids?: BaseKey[]; }", - "BaseKey | BaseKey[]": - "[BaseKey](/docs/core/interface-references/#basekey) | [BaseKey[]](/docs/core/interface-references/#basekey)", - BaseKey: "[BaseKey](/docs/core/interface-references/#basekey)", - MetaDataQuery: - "[MetaDataQuery](/docs/core/interface-references/#metadataquery)", - CrudFilters: "[CrudFilters](/docs/core/interface-references/#crudfilters)", - CrudSorting: "[CrudSorting](/docs/core/interface-references/#crudsorting)", + // "null | string | number | false | true | ReactElement> | ReactFragment | ReactPortal": "ReactNode", + ReactElement: + "ReactElement ReactElement) | (new (props: any) => Component)>", + "ReactNode | (value: number) => ReactNode": + "string | number | boolean | {} | ReactElement ReactElement) | (new (props: any) => Component)> | ReactNodeArray | ReactPortal | ((value: number) => ReactNode)", + ActionButtonRenderer: + "ReactNode | ({ defaultButtons: ReactNode }) => ReactNode", + "DetailedHTMLProps, HTMLDivElement>": + "DetailedHTMLProps", + "false | OpenNotificationParams | ((data?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": + "false | OpenNotificationParams | (data, values, resource) => OpenNotificationParams", + "false | OpenNotificationParams | ((error?: unknown, values?: unknown, resource?: string) => OpenNotificationParams)": + "false | OpenNotificationParams | (error, values, resource) => OpenNotificationParams", + 'SvgIconProps<"svg", {}>': "SvgIconProps", + SpaceProps: "[`SpaceProps`](https://styled-system.com/api#space)", + "((value: DeleteOneResponse) => void)": + "(value: DeleteOneResponse) => void", + "{ [key: string]: any; ids?: BaseKey[]; }": + "{ [key]: any; ids?: BaseKey[]; }", + "BaseKey | BaseKey[]": + "[BaseKey](/docs/core/interface-references/#basekey) | [BaseKey[]](/docs/core/interface-references/#basekey)", + BaseKey: "[BaseKey](/docs/core/interface-references/#basekey)", + MetaDataQuery: + "[MetaDataQuery](/docs/core/interface-references/#metadataquery)", + CrudFilters: "[CrudFilters](/docs/core/interface-references/#crudfilters)", + CrudSorting: "[CrudSorting](/docs/core/interface-references/#crudsorting)", }; const spinner = ora("Generating Refine declarations..."); /** HELPERS */ const getPackageNamePathMap = async (directory: string) => { - const packages = await fs.readdir(directory); - const packageNamePathMap: Record = {}; + const packages = await fs.readdir(directory); + const packageNamePathMap: Record = {}; - const includedPackages = process.env.INCLUDED_PACKAGES?.split(",") || []; + const includedPackages = process.env.INCLUDED_PACKAGES?.split(",") || []; - await Promise.all( - packages.map(async (packageName) => { - const packagePath = path.join( - directory, - packageName, - "package.json", - ); + await Promise.all( + packages.map(async (packageName) => { + const packagePath = path.join(directory, packageName, "package.json"); - if (fs.existsSync(packagePath)) { - const packageJson = await fs.readJSON(packagePath); - - if ( - includedPackages.length == 0 || - includedPackages.some((p) => packageName.includes(p)) - ) { - packageNamePathMap[packageJson.name] = path.join( - packagePath, - "..", - ); - } - } - - return packageName; - }), - ); + if (fs.existsSync(packagePath)) { + const packageJson = await fs.readJSON(packagePath); + + if ( + includedPackages.length == 0 || + includedPackages.some((p) => packageName.includes(p)) + ) { + packageNamePathMap[packageJson.name] = path.join(packagePath, ".."); + } + } - return packageNamePathMap; + return packageName; + }), + ); + + return packageNamePathMap; }; const getPaths = async (packageDir: string, excludedPatterns: string[]) => { - const dir = await fs.readdir(packageDir); - const filtered: string[] = []; - await Promise.all( - dir.map(async (file) => { - const result = await fs.pathExists(path.join(packageDir, file)); - if (result) { - filtered.push(file); - } - }), - ); - - return filtered - .map((p) => path.join(packageDir, p)) - .filter( - (p) => !excludedPatterns.some((pattern) => p.includes(pattern)), - ); + const dir = await fs.readdir(packageDir); + const filtered: string[] = []; + await Promise.all( + dir.map(async (file) => { + const result = await fs.pathExists(path.join(packageDir, file)); + if (result) { + filtered.push(file); + } + }), + ); + + return filtered + .map((p) => path.join(packageDir, p)) + .filter((p) => !excludedPatterns.some((pattern) => p.includes(pattern))); }; const _getPrefixFromDeclarationPath = async (path: string) => { - const map = await getPackageNamePathMap(packagesDir); - const packageName = Object.keys(map).find((key) => path.includes(map[key])); - return packageName; + const map = await getPackageNamePathMap(packagesDir); + const packageName = Object.keys(map).find((key) => path.includes(map[key])); + return packageName; }; const getComponentName = (name: string, _fileName: string) => { - return name; - // return `${getPrefixFromDeclarationPath(fileName)}#${name}`; + return name; + // return `${getPrefixFromDeclarationPath(fileName)}#${name}`; }; const getOutputName = (packageName: string) => { - return packageName; + return packageName; }; const declarationFilter = (declaration: ParentType) => { - return ( - !declaration.fileName.includes("node_modules") || - declaration.fileName.includes("@refinedev") - ); + return ( + !declaration.fileName.includes("node_modules") || + declaration.fileName.includes("@refinedev") + ); }; const valueDeclarationFilter = (tsDeclaration?: ts.Declaration) => { - // excludedValueDeclarationPatterns includes fileNames of source files to be ignored (partially) - const sourceFileName = tsDeclaration?.getSourceFile().fileName; - // if sourceFileName includes any of the excludedValueDeclarationPatterns then ignore it - const isIgnored = excludedValueDeclarationPatterns.some((pattern) => - sourceFileName?.includes(pattern), - ); - - return !isIgnored; + // excludedValueDeclarationPatterns includes fileNames of source files to be ignored (partially) + const sourceFileName = tsDeclaration?.getSourceFile().fileName; + // if sourceFileName includes any of the excludedValueDeclarationPatterns then ignore it + const isIgnored = excludedValueDeclarationPatterns.some((pattern) => + sourceFileName?.includes(pattern), + ); + + return !isIgnored; }; const createParser = (configPath: string) => { - const docgenParser = withCustomConfig(path.join(configPath), { - savePropValueAsString: true, - shouldExtractLiteralValuesFromEnum: true, - shouldRemoveUndefinedFromOptional: true, - shouldIncludePropTagMap: true, - componentNameResolver: (exp, source) => { - const name = getComponentName(exp.getName(), source.fileName); - if (valueDeclarationFilter(exp.valueDeclaration)) { - return name; - } - return `IGNORED_${name}`; - }, - propFilter: (prop: PropItem) => { - const isExcluded = - excludedProps.includes(prop.name) || - excludePropPatterns.some((pattern) => pattern.test(prop.name)); - - const isExternal = - prop.declarations && - prop.declarations.length > 0 && - !Boolean(prop.declarations.find(declarationFilter)); - - const isUnknown = typeof prop.declarations === "undefined"; - - if (isExcluded || isExternal || isUnknown) { - return false; - } - return true; - }, - }); - - return docgenParser; + const docgenParser = withCustomConfig(path.join(configPath), { + savePropValueAsString: true, + shouldExtractLiteralValuesFromEnum: true, + shouldRemoveUndefinedFromOptional: true, + shouldIncludePropTagMap: true, + componentNameResolver: (exp, source) => { + const name = getComponentName(exp.getName(), source.fileName); + if (valueDeclarationFilter(exp.valueDeclaration)) { + return name; + } + return `IGNORED_${name}`; + }, + propFilter: (prop: PropItem) => { + const isExcluded = + excludedProps.includes(prop.name) || + excludePropPatterns.some((pattern) => pattern.test(prop.name)); + + const isExternal = + prop.declarations && + prop.declarations.length > 0 && + !Boolean(prop.declarations.find(declarationFilter)); + + const isUnknown = typeof prop.declarations === "undefined"; + + if (isExcluded || isExternal || isUnknown) { + return false; + } + return true; + }, + }); + + return docgenParser; }; const normalizeMarkdownLinks = (value: string) => { - return value.replace(/\[(.*?)\]\s{1}\((.*?)\)/g, (_, p1, p2) => { - return `[${p1}](${p2})`; - }); + return value.replace(/\[(.*?)\]\s{1}\((.*?)\)/g, (_, p1, p2) => { + return `[${p1}](${p2})`; + }); }; const prepareDeclaration = (declaration: ComponentDoc) => { - const data: DeclarationType = { ...declaration }; - delete data.methods; - delete data.tags; + const data: DeclarationType = { ...declaration }; + delete data.methods; + delete data.tags; - data.generatedAt = Date.now(); + data.generatedAt = Date.now(); - Object.keys(data.props).forEach((prop) => { - data.props[prop].type.name = normalizeMarkdownLinks( - data.props[prop].type.name, - ); + Object.keys(data.props).forEach((prop) => { + data.props[prop].type.name = normalizeMarkdownLinks( + data.props[prop].type.name, + ); - delete data.props[prop].parent; - delete data.props[prop].declarations; + delete data.props[prop].parent; + delete data.props[prop].declarations; - if (data.props[prop].type.raw === "ReactNode") { - data.props[prop].type.name = "ReactNode"; - } + if (data.props[prop].type.raw === "ReactNode") { + data.props[prop].type.name = "ReactNode"; + } - if (data.props[prop].type.name in replacementProps) { - data.props[prop].type.name = - replacementProps[data.props[prop].type.name]; - } + if (data.props[prop].type.name in replacementProps) { + data.props[prop].type.name = replacementProps[data.props[prop].type.name]; + } - if (data.props[prop].type.name === "enum") { - data.props[prop].type.name = data.props[prop].type.value - .map((val: { value: string }) => val.value) - .join(" | "); - } - }); + if (data.props[prop].type.name === "enum") { + data.props[prop].type.name = data.props[prop].type.value + .map((val: { value: string }) => val.value) + .join(" | "); + } + }); - const ordered = Object.keys(data.props) - // .sort() - .reduce((obj, key) => { - obj[key] = data.props[key]; - return obj; - }, {} as Props); + const ordered = Object.keys(data.props) + // .sort() + .reduce((obj, key) => { + obj[key] = data.props[key]; + return obj; + }, {} as Props); - data.props = ordered; + data.props = ordered; - return data; + return data; }; const transposeDeclarations = (declarations: DeclarationType[]) => { - const transposed: Record = {}; + const transposed: Record = {}; - declarations.forEach((declaration) => { - transposed[declaration.displayName] = declaration; - }); + declarations.forEach((declaration) => { + transposed[declaration.displayName] = declaration; + }); - return transposed; + return transposed; }; const generateDeclarations = async (packagePaths: [string, string][]) => { - const generated: Record> = {}; + const generated: Record> = {}; - await Promise.all( - packagePaths.map(async ([packageName, packagePath]) => { - const parser = createParser( - path.join(packagePath, "./tsconfig.json"), - ); + await Promise.all( + packagePaths.map(async ([packageName, packagePath]) => { + const parser = createParser(path.join(packagePath, "./tsconfig.json")); - const sourcePath = path.join(packagePath, sourceDir); + const sourcePath = path.join(packagePath, sourceDir); - if (!(await fs.pathExists(sourcePath))) { - spinner.fail("Component path does not exist", sourcePath); - process.exit(1); - } + if (!(await fs.pathExists(sourcePath))) { + spinner.fail("Component path does not exist", sourcePath); + process.exit(1); + } - const declarationPaths = await getPaths( - sourcePath, - excludedFilePatterns, - ); + const declarationPaths = await getPaths(sourcePath, excludedFilePatterns); - const parsed = parser - .parse(declarationPaths) - .map(prepareDeclaration); + const parsed = parser.parse(declarationPaths).map(prepareDeclaration); - const transposed = transposeDeclarations(parsed); + const transposed = transposeDeclarations(parsed); - const outputName = getOutputName(packageName); + const outputName = getOutputName(packageName); - generated[outputName] = transposed; + generated[outputName] = transposed; - spinner.stop(); - spinner.start(`- Generated declarations - ${packageName}`); + spinner.stop(); + spinner.start(`- Generated declarations - ${packageName}`); - return [packageName, packagePath]; - }), - ); + return [packageName, packagePath]; + }), + ); - return generated; + return generated; }; /** DOCGEN */ const handleDocgen = async () => { - const packagePathMap = await getPackageNamePathMap(packagesDir); - const packagePathMapArray = Object.entries(packagePathMap); + const packagePathMap = await getPackageNamePathMap(packagesDir); + const packagePathMapArray = Object.entries(packagePathMap); - spinner.stop(); - spinner.start(`- Found ${packagePathMapArray.length} packages`); + spinner.stop(); + spinner.start(`- Found ${packagePathMapArray.length} packages`); - const res = await generateDeclarations(packagePathMapArray); + const res = await generateDeclarations(packagePathMapArray); - spinner.succeed("Generated declarations"); + spinner.succeed("Generated declarations"); - return res; + return res; }; export default function plugin(): Plugin { - return { - name: "docusaurus-plugin-refine-docgen", - getPathsToWatch: function () { - return [packagesDir]; - }, - async loadContent() { - if (!process.env.DISABLE_DOCGEN) { - spinner.start(); - return await handleDocgen(); - } - - return {}; - }, - configureWebpack(config) { - return { - resolve: { - alias: { - "@docgen": path.join( - config.resolve?.alias?.["@generated"], - "docusaurus-plugin-refine-docgen", - "default", - ), - }, - }, - }; + return { + name: "docusaurus-plugin-refine-docgen", + getPathsToWatch: function () { + return [packagesDir]; + }, + async loadContent() { + if (!process.env.DISABLE_DOCGEN) { + spinner.start(); + return await handleDocgen(); + } + + return {}; + }, + configureWebpack(config) { + return { + resolve: { + alias: { + "@docgen": path.join( + config.resolve?.alias?.["@generated"], + "docusaurus-plugin-refine-docgen", + "default", + ), + }, }, - async contentLoaded({ content, actions }): Promise { - if (!process.env.DISABLE_DOCGEN) { - ora("Creating Refine declaration files...").succeed(); - - const { createData } = actions; - - const data: Promise[] = []; - - Object.entries(content).forEach( - ([packageName, packageDeclarations]) => { - Object.entries(packageDeclarations).forEach( - ([componentName, declaration]) => { - data.push( - createData( - `${packageName}/${componentName}.json`, - JSON.stringify(declaration), - ), - ); - }, - ); - }, + }; + }, + async contentLoaded({ content, actions }): Promise { + if (!process.env.DISABLE_DOCGEN) { + ora("Creating Refine declaration files...").succeed(); + + const { createData } = actions; + + const data: Promise[] = []; + + Object.entries(content).forEach( + ([packageName, packageDeclarations]) => { + Object.entries(packageDeclarations).forEach( + ([componentName, declaration]) => { + data.push( + createData( + `${packageName}/${componentName}.json`, + JSON.stringify(declaration), + ), ); + }, + ); + }, + ); - await Promise.all(data); - } - }, - }; + await Promise.all(data); + } + }, + }; } diff --git a/documentation/plugins/example-redirects.js b/documentation/plugins/example-redirects.js index 621eb5d259ff..f2aa292b1b9c 100644 --- a/documentation/plugins/example-redirects.js +++ b/documentation/plugins/example-redirects.js @@ -1,78 +1,73 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; + return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { - if (lhs != null) { - return lhs; - } else { - return rhsFn(); - } + if (lhs != null) { + return lhs; + } else { + return rhsFn(); + } } function _optionalChain(ops) { - let lastAccessLHS = undefined; - let value = ops[0]; - let i = 1; - while (i < ops.length) { - const op = ops[i]; - const fn = ops[i + 1]; - i += 2; - if ( - (op === "optionalAccess" || op === "optionalCall") && - value == null - ) { - return undefined; - } - if (op === "access" || op === "optionalAccess") { - lastAccessLHS = value; - value = fn(value); - } else if (op === "call" || op === "optionalCall") { - value = fn((...args) => value.call(lastAccessLHS, ...args)); - lastAccessLHS = undefined; - } + let lastAccessLHS = undefined; + let value = ops[0]; + let i = 1; + while (i < ops.length) { + const op = ops[i]; + const fn = ops[i + 1]; + i += 2; + if ((op === "optionalAccess" || op === "optionalCall") && value == null) { + return undefined; + } + if (op === "access" || op === "optionalAccess") { + lastAccessLHS = value; + value = fn(value); + } else if (op === "call" || op === "optionalCall") { + value = fn((...args) => value.call(lastAccessLHS, ...args)); + lastAccessLHS = undefined; } - return value; + } + return value; } var _fsextra = require("fs-extra"); var _fsextra2 = _interopRequireDefault(_fsextra); function pluginExampleRedirectsPages() { - return { - name: "refine-plugin-handle-example-redirects", - async postBuild() { - const redirects = collectRedirects(); + return { + name: "refine-plugin-handle-example-redirects", + async postBuild() { + const redirects = collectRedirects(); - const redirectFiles = generateRedirectFiles(redirects); + const redirectFiles = generateRedirectFiles(redirects); - // Write files only at the end: make code more easy to test without IO - await Promise.all( - redirectFiles.map((file) => writeRedirectFile(file)), - ); - }, - }; + // Write files only at the end: make code more easy to test without IO + await Promise.all(redirectFiles.map((file) => writeRedirectFile(file))); + }, + }; } exports.default = pluginExampleRedirectsPages; async function writeRedirectFile(file) { - try { - // User-friendly security to prevent file overrides - if (await _fsextra2.default.pathExists(file.fileAbsolutePath)) { - throw new Error( - "The redirect plugin is not supposed to override existing files.", - ); - } - await _fsextra2.default.outputFile( - file.fileAbsolutePath, - file.fileContent, - // Hard security to prevent file overrides - // See https://stackoverflow.com/a/34187712/82609 - { flag: "wx" }, - ); - } catch (err) { - // logger.error`Redirect file creation error for path=${file.fileAbsolutePath}.`; - throw err; + try { + // User-friendly security to prevent file overrides + if (await _fsextra2.default.pathExists(file.fileAbsolutePath)) { + throw new Error( + "The redirect plugin is not supposed to override existing files.", + ); } + await _fsextra2.default.outputFile( + file.fileAbsolutePath, + file.fileContent, + // Hard security to prevent file overrides + // See https://stackoverflow.com/a/34187712/82609 + { flag: "wx" }, + ); + } catch (err) { + // logger.error`Redirect file creation error for path=${file.fileAbsolutePath}.`; + throw err; + } } const htmlTemplate = (to) => ` @@ -88,23 +83,21 @@ const htmlTemplate = (to) => ` `; const collectRedirects = () => { - const redirects = _fsextra2.default.readJSONSync( - "./example-redirects.json", - ); + const redirects = _fsextra2.default.readJSONSync("./example-redirects.json"); - return _nullishCoalesce( - _optionalChain([redirects, "optionalAccess", (_) => _.redirects]), - () => [], - ); + return _nullishCoalesce( + _optionalChain([redirects, "optionalAccess", (_) => _.redirects]), + () => [], + ); }; const generateRedirectFiles = (redirects) => { - return redirects.map((redirect) => { - const path = `${redirect.from}/index.html`; + return redirects.map((redirect) => { + const path = `${redirect.from}/index.html`; - return { - fileAbsolutePath: `./build/${path}`, - fileContent: htmlTemplate(redirect.to), - }; - }); + return { + fileAbsolutePath: `./build/${path}`, + fileContent: htmlTemplate(redirect.to), + }; + }); }; diff --git a/documentation/plugins/example-redirects.ts b/documentation/plugins/example-redirects.ts index 9683aa1c52a7..81af634b3988 100644 --- a/documentation/plugins/example-redirects.ts +++ b/documentation/plugins/example-redirects.ts @@ -2,40 +2,38 @@ import fs from "fs-extra"; import type { Plugin } from "@docusaurus/types"; export default function pluginExampleRedirectsPages(): Plugin { - return { - name: "refine-plugin-handle-example-redirects", - async postBuild() { - const redirects: RedirectItem[] = collectRedirects(); + return { + name: "refine-plugin-handle-example-redirects", + async postBuild() { + const redirects: RedirectItem[] = collectRedirects(); - const redirectFiles = generateRedirectFiles(redirects); + const redirectFiles = generateRedirectFiles(redirects); - // Write files only at the end: make code more easy to test without IO - await Promise.all( - redirectFiles.map((file) => writeRedirectFile(file)), - ); - }, - }; + // Write files only at the end: make code more easy to test without IO + await Promise.all(redirectFiles.map((file) => writeRedirectFile(file))); + }, + }; } async function writeRedirectFile(file: RedirectFile): Promise { - try { - // User-friendly security to prevent file overrides - if (await fs.pathExists(file.fileAbsolutePath)) { - throw new Error( - "The redirect plugin is not supposed to override existing files.", - ); - } - await fs.outputFile( - file.fileAbsolutePath, - file.fileContent, - // Hard security to prevent file overrides - // See https://stackoverflow.com/a/34187712/82609 - { flag: "wx" }, - ); - } catch (err) { - // logger.error`Redirect file creation error for path=${file.fileAbsolutePath}.`; - throw err; + try { + // User-friendly security to prevent file overrides + if (await fs.pathExists(file.fileAbsolutePath)) { + throw new Error( + "The redirect plugin is not supposed to override existing files.", + ); } + await fs.outputFile( + file.fileAbsolutePath, + file.fileContent, + // Hard security to prevent file overrides + // See https://stackoverflow.com/a/34187712/82609 + { flag: "wx" }, + ); + } catch (err) { + // logger.error`Redirect file creation error for path=${file.fileAbsolutePath}.`; + throw err; + } } const htmlTemplate = (to: string) => ` @@ -51,28 +49,28 @@ const htmlTemplate = (to: string) => ` `; const collectRedirects = () => { - const redirects = fs.readJSONSync("./example-redirects.json"); + const redirects = fs.readJSONSync("./example-redirects.json"); - return redirects?.redirects ?? []; + return redirects?.redirects ?? []; }; const generateRedirectFiles = (redirects: RedirectItem[]) => { - return redirects.map((redirect) => { - const path = `${redirect.from}/index.html`; + return redirects.map((redirect) => { + const path = `${redirect.from}/index.html`; - return { - fileAbsolutePath: `./build/${path}`, - fileContent: htmlTemplate(redirect.to), - }; - }); + return { + fileAbsolutePath: `./build/${path}`, + fileContent: htmlTemplate(redirect.to), + }; + }); }; type RedirectFile = { - fileAbsolutePath: string; - fileContent: string; + fileAbsolutePath: string; + fileContent: string; }; type RedirectItem = { - from: string; - to: string; + from: string; + to: string; }; diff --git a/documentation/plugins/templates.js b/documentation/plugins/templates.js index 4dd0cbccd943..5060f75ff41c 100644 --- a/documentation/plugins/templates.js +++ b/documentation/plugins/templates.js @@ -55,8 +55,6 @@ The app connected to GraphQL API through Refine's Nestjs-query data provider, an We built this template to demonstrate how the Refine framework simplifies and speeds up development. It is a valuable resource, offering insights into Refine's best practices and modern development techniques. -The source code of the CRM app is also open-source; feel free to use or inspect it to discover how Refine works. Being production-ready, you can either build your own CRM internal tool using it as a code base or directly implement it as is. - ### Key Features: @@ -89,6 +87,62 @@ This CRM app template can be used in for various app requirements like B2B appli - Patient Management Systems - Health Information Exchange (HIE) Systems - Pharmacy Management Systems +`, + }, + { + slug: "hr-application", + title: "HR Management App Example", + images: [ + "https://refine.ams3.cdn.digitaloceanspaces.com/templates/detail-refine-hr.png", + ], + runOnYourLocalPath: null, + github: null, + liveDemo: "https://refine-hr.netlify.app", + reactPlatform: "Vite", + uiFramework: "Material UI", + dataProvider: "Nestjsx-CRUD", + edition: "Enterprise", + authProvider: "Custom", + description: `Demonstrating Refine's Capabilities for Building Enterprise-Level HR Management App + +This HR management app, built with Refine, is an example designed to showcase the framework’s flexibility and power in creating enterprise-level internal tools like managing employee information, leave requests, polls, and more. + +While not a product, this template demonstrates how quickly and efficiently similar complex apps can be developed using Refine, serving as both a learning resource and inspiration for building your own applications. + +### Enterprise Needs in Focus + +Our HR app example is designed for enterprise companies needs, which is why its source code is only available to Refine enterprise users. + +Even if you don’t have access to the HR app's source code, you can still explore the capabilities of Refine through our other complete app examples. + +### Key Features: + +- **Leave Management**: Track and assign annual, sick, and casual leave, with options for requesting time off via a calendar interface. +- **Employee Directory**: Visualize organizational hierarchies and manage employee details with ease. +- **Expense Management**: Submit and manage expense requests for travel, training, meals, and more. +- **Polls and Surveys**: Conduct employee surveys and collect valuable insights on benefits and company policies. +- **Calendar Integration**: View and manage time off and upcoming events in an easy-to-use calendar format. +- **Notifications**: Receive real-time notifications on leave approvals, expense status, and important company announcements. + +### Suitable for Internal HR Tool-Oriented Needs + +This HR app template can be used in for various app requirements like B2B applications, internal tools, admin panel, dashboard. Such as: + +- **Recruitment and Applicant Tracking Systems (ATS)** +- **Employee Engagement Platforms** +- **Compensation and Benefits Management Tools** +- **Workforce Planning and Time Tracking Solutions** +- **Compliance Management Systems** +- **Employee Self-Service Portals** +- **Succession Planning Tools** +- **Employee Wellness and Assistance Programs** +- **HR Analytics and Reporting Tools** +- **Performance Review and Incentive Management Systems** +- **Training and Development Management** +- **Onboarding and Offboarding Solutions** +- **Payroll Management Tools** + +By using this app as a starting point, companies can build a customized HR platform that suits their specific internal processes, speeding up development and reducing the complexity of building from scratch. `, }, { diff --git a/documentation/plugins/templates.ts b/documentation/plugins/templates.ts index 1c6905059a09..fbc07a95c227 100644 --- a/documentation/plugins/templates.ts +++ b/documentation/plugins/templates.ts @@ -53,8 +53,6 @@ The app connected to GraphQL API through Refine's Nestjs-query data provider, an We built this template to demonstrate how the Refine framework simplifies and speeds up development. It is a valuable resource, offering insights into Refine's best practices and modern development techniques. -The source code of the CRM app is also open-source; feel free to use or inspect it to discover how Refine works. Being production-ready, you can either build your own CRM internal tool using it as a code base or directly implement it as is. - ### Key Features: @@ -87,6 +85,62 @@ This CRM app template can be used in for various app requirements like B2B appli - Patient Management Systems - Health Information Exchange (HIE) Systems - Pharmacy Management Systems +`, + }, + { + slug: "hr-application", + title: "HR Management App Example", + images: [ + "https://refine.ams3.cdn.digitaloceanspaces.com/templates/detail-refine-hr.png", + ], + runOnYourLocalPath: null, + github: null, + liveDemo: "https://refine-hr.netlify.app", + reactPlatform: "Vite", + uiFramework: "Material UI", + dataProvider: "Nestjsx-CRUD", + edition: "Enterprise", + authProvider: "Custom", + description: `Demonstrating Refine's Capabilities for Building Enterprise-Level HR Management App + +This HR management app, built with Refine, is an example designed to showcase the framework’s flexibility and power in creating enterprise-level internal tools like managing employee information, leave requests, polls, and more. + +While not a product, this template demonstrates how quickly and efficiently similar complex apps can be developed using Refine, serving as both a learning resource and inspiration for building your own applications. + +### Enterprise Needs in Focus + +Our HR app example is designed for enterprise companies needs, which is why its source code is only available to Refine enterprise users. + +Even if you don’t have access to the HR app's source code, you can still explore the capabilities of Refine through our other complete app examples. + +### Key Features: + +- **Leave Management**: Track and assign annual, sick, and casual leave, with options for requesting time off via a calendar interface. +- **Employee Directory**: Visualize organizational hierarchies and manage employee details with ease. +- **Expense Management**: Submit and manage expense requests for travel, training, meals, and more. +- **Polls and Surveys**: Conduct employee surveys and collect valuable insights on benefits and company policies. +- **Calendar Integration**: View and manage time off and upcoming events in an easy-to-use calendar format. +- **Notifications**: Receive real-time notifications on leave approvals, expense status, and important company announcements. + +### Suitable for Internal HR Tool-Oriented Needs + +This HR app template can be used in for various app requirements like B2B applications, internal tools, admin panel, dashboard. Such as: + +- **Recruitment and Applicant Tracking Systems (ATS)** +- **Employee Engagement Platforms** +- **Compensation and Benefits Management Tools** +- **Workforce Planning and Time Tracking Solutions** +- **Compliance Management Systems** +- **Employee Self-Service Portals** +- **Succession Planning Tools** +- **Employee Wellness and Assistance Programs** +- **HR Analytics and Reporting Tools** +- **Performance Review and Incentive Management Systems** +- **Training and Development Management** +- **Onboarding and Offboarding Solutions** +- **Payroll Management Tools** + +By using this app as a starting point, companies can build a customized HR platform that suits their specific internal processes, speeding up development and reducing the complexity of building from scratch. `, }, { diff --git a/documentation/plugins/tutorial-navigation.js b/documentation/plugins/tutorial-navigation.js index c9003c102d65..95bbf9af807d 100644 --- a/documentation/plugins/tutorial-navigation.js +++ b/documentation/plugins/tutorial-navigation.js @@ -1,93 +1,90 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } else { - var newObj = {}; - if (obj != null) { - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - newObj[key] = obj[key]; - } - } + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + newObj[key] = obj[key]; } - newObj.default = obj; - return newObj; + } } + newObj.default = obj; + return newObj; + } } function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; + return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { - let lastAccessLHS = undefined; - let value = ops[0]; - let i = 1; - while (i < ops.length) { - const op = ops[i]; - const fn = ops[i + 1]; - i += 2; - if ( - (op === "optionalAccess" || op === "optionalCall") && - value == null - ) { - return undefined; - } - if (op === "access" || op === "optionalAccess") { - lastAccessLHS = value; - value = fn(value); - } else if (op === "call" || op === "optionalCall") { - value = fn((...args) => value.call(lastAccessLHS, ...args)); - lastAccessLHS = undefined; - } + let lastAccessLHS = undefined; + let value = ops[0]; + let i = 1; + while (i < ops.length) { + const op = ops[i]; + const fn = ops[i + 1]; + i += 2; + if ((op === "optionalAccess" || op === "optionalCall") && value == null) { + return undefined; + } + if (op === "access" || op === "optionalAccess") { + lastAccessLHS = value; + value = fn(value); + } else if (op === "call" || op === "optionalCall") { + value = fn((...args) => value.call(lastAccessLHS, ...args)); + lastAccessLHS = undefined; } - return value; + } + return value; } var _path = require("path"); var _path2 = _interopRequireDefault(_path); function plugin() { - return { - name: "docusaurus-plugin-refine-tutorial-navigation", - configureWebpack(config) { - return { - resolve: { - alias: { - "@tutorial-navigation": _path2.default.join( - _optionalChain([ - config, - "access", - (_) => _.resolve, - "optionalAccess", - (_2) => _2.alias, - "optionalAccess", - (_3) => _3["@generated"], - ]), - "docusaurus-plugin-refine-tutorial-navigation", - "default", - ), - }, - }, - }; + return { + name: "docusaurus-plugin-refine-tutorial-navigation", + configureWebpack(config) { + return { + resolve: { + alias: { + "@tutorial-navigation": _path2.default.join( + _optionalChain([ + config, + "access", + (_) => _.resolve, + "optionalAccess", + (_2) => _2.alias, + "optionalAccess", + (_3) => _3["@generated"], + ]), + "docusaurus-plugin-refine-tutorial-navigation", + "default", + ), + }, }, - getPathsToWatch() { - return [_path2.default.join(__dirname, "../tutorials.js")]; - }, - async loadContent() { - const tutorials = await Promise.resolve().then(() => - _interopRequireWildcard(require("../tutorials.js")), - ); + }; + }, + getPathsToWatch() { + return [_path2.default.join(__dirname, "../tutorials.js")]; + }, + async loadContent() { + const tutorials = await Promise.resolve().then(() => + _interopRequireWildcard(require("../tutorials.js")), + ); - return tutorials.tutorial; - }, - async contentLoaded({ content, allContent, actions }) { - const { createData } = actions; + return tutorials.tutorial; + }, + async contentLoaded({ content, allContent, actions }) { + const { createData } = actions; - await createData( - `tutorial-navigation-data.json`, - JSON.stringify(content), - ); - }, - }; + await createData( + `tutorial-navigation-data.json`, + JSON.stringify(content), + ); + }, + }; } exports.default = plugin; diff --git a/documentation/plugins/tutorial-navigation.ts b/documentation/plugins/tutorial-navigation.ts index 6382f28d7fac..e7e1f93e7bd2 100644 --- a/documentation/plugins/tutorial-navigation.ts +++ b/documentation/plugins/tutorial-navigation.ts @@ -2,36 +2,36 @@ import { Plugin } from "@docusaurus/types"; import path from "path"; export default function plugin(): Plugin { - return { - name: "docusaurus-plugin-refine-tutorial-navigation", - configureWebpack(config) { - return { - resolve: { - alias: { - "@tutorial-navigation": path.join( - config.resolve?.alias?.["@generated"], - "docusaurus-plugin-refine-tutorial-navigation", - "default", - ), - }, - }, - }; + return { + name: "docusaurus-plugin-refine-tutorial-navigation", + configureWebpack(config) { + return { + resolve: { + alias: { + "@tutorial-navigation": path.join( + config.resolve?.alias?.["@generated"], + "docusaurus-plugin-refine-tutorial-navigation", + "default", + ), + }, }, - getPathsToWatch() { - return [path.join(__dirname, "../tutorials.js")]; - }, - async loadContent() { - const tutorials = await import("../tutorials.js"); + }; + }, + getPathsToWatch() { + return [path.join(__dirname, "../tutorials.js")]; + }, + async loadContent() { + const tutorials = await import("../tutorials.js"); - return tutorials.tutorial; - }, - async contentLoaded({ content, allContent, actions }): Promise { - const { createData } = actions; + return tutorials.tutorial; + }, + async contentLoaded({ content, allContent, actions }): Promise { + const { createData } = actions; - await createData( - `tutorial-navigation-data.json`, - JSON.stringify(content), - ); - }, - }; + await createData( + `tutorial-navigation-data.json`, + JSON.stringify(content), + ); + }, + }; } diff --git a/documentation/src/pages/templates/index.tsx b/documentation/src/pages/templates/index.tsx index a9b9d96337c7..92b59492d8d8 100644 --- a/documentation/src/pages/templates/index.tsx +++ b/documentation/src/pages/templates/index.tsx @@ -343,6 +343,29 @@ const dataTemplates: { }, ], }, + { + to: "/templates/hr-application", + title: "HR Management App Example", + description: + "HR management app example built with Refine, demonstrating how quickly enterprise-level tools can be developed. This template features leave management, employee directory, and expense tracking.", + image: + "https://refine.ams3.cdn.digitaloceanspaces.com/templates/refine-hr.png", + edition: TemplateEdition.Enterprise, + integrations: [ + { + label: "Material UI", + icon: (props: SVGProps) => ( + + ), + }, + { + label: "Rest API", + icon: (props: SVGProps) => ( + + ), + }, + ], + }, { to: "/templates/next-js-tailwind", title: "E-Commerce Application Storefront",