elseware-docs-engine 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +27 -15
- package/dist/index.d.ts +27 -15
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
3
4
|
import * as elseware_ui from 'elseware-ui';
|
|
5
|
+
import { MenuNode } from 'elseware-ui';
|
|
4
6
|
import { RouteObject } from 'react-router-dom';
|
|
5
7
|
|
|
8
|
+
interface DocsPageRendererProps {
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
declare function DocsPageRenderer({ content, }: DocsPageRendererProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
6
13
|
interface DocsPage {
|
|
7
14
|
title: string;
|
|
8
15
|
path: string;
|
|
@@ -15,35 +22,35 @@ interface DocsCategory {
|
|
|
15
22
|
}
|
|
16
23
|
type DocsNode = DocsCategory | DocsPage;
|
|
17
24
|
|
|
18
|
-
interface
|
|
25
|
+
interface DocsContextType {
|
|
19
26
|
docs: DocsCategory[];
|
|
20
|
-
basePath
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
|
|
24
|
-
|
|
25
|
-
interface DocsPageRendererProps {
|
|
26
|
-
content: string;
|
|
27
|
+
basePath: string;
|
|
27
28
|
}
|
|
28
|
-
declare
|
|
29
|
+
declare const DocsContext: React.Context<DocsContextType | undefined>;
|
|
29
30
|
|
|
30
|
-
interface
|
|
31
|
+
interface DocsEngineProps {
|
|
31
32
|
docs: DocsCategory[];
|
|
32
|
-
basePath
|
|
33
|
+
basePath?: string;
|
|
34
|
+
children: React__default.ReactNode;
|
|
33
35
|
}
|
|
36
|
+
declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
|
|
34
37
|
|
|
35
|
-
declare function
|
|
38
|
+
declare function useCurrentDocsSection(): DocsCategory | undefined;
|
|
36
39
|
|
|
37
40
|
interface UseCurrentPageProps {
|
|
38
41
|
debug?: boolean;
|
|
39
42
|
}
|
|
40
43
|
declare function useCurrentPage({ debug }?: UseCurrentPageProps): DocsPage | null;
|
|
41
44
|
|
|
45
|
+
declare function useDocs(): DocsContextType;
|
|
46
|
+
|
|
47
|
+
declare function useScopedSidebar(): elseware_ui.MenuNode[];
|
|
48
|
+
|
|
42
49
|
declare function useSidebar(): elseware_ui.MenuNode[];
|
|
43
50
|
|
|
44
51
|
interface GenerateDocsRoutesProps {
|
|
45
52
|
basePath?: string;
|
|
46
|
-
element:
|
|
53
|
+
element: React__default.ReactNode;
|
|
47
54
|
}
|
|
48
55
|
declare function generateDocsRoutes({ basePath, element, }: GenerateDocsRoutesProps): RouteObject[];
|
|
49
56
|
|
|
@@ -56,4 +63,9 @@ declare function findPageByPath(nodes: DocsNode[], targetPath: string, parentPat
|
|
|
56
63
|
declare function resolveDocs(nodes: DocsNode[], parentPath?: string): ResolvedDocsPage[];
|
|
57
64
|
declare function findFirstPage(nodes: DocsNode[], parentPath?: string): string | null;
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
declare function normalizePath(path: string): string;
|
|
67
|
+
declare function normalizeRoutePath(path: string): string;
|
|
68
|
+
|
|
69
|
+
declare function generateSidebar(docs: DocsCategory[], basePath: string): MenuNode[];
|
|
70
|
+
|
|
71
|
+
export { type DocsCategory, DocsContext, type DocsContextType, DocsEngine, type DocsNode, type DocsPage, DocsPageRenderer, type ResolvedDocsPage, findFirstPage, findPageByPath, generateDocsRoutes, generateSidebar, isPage, normalizePath, normalizeRoutePath, resolveDocs, useCurrentDocsSection, useCurrentPage, useDocs, useScopedSidebar, useSidebar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
3
4
|
import * as elseware_ui from 'elseware-ui';
|
|
5
|
+
import { MenuNode } from 'elseware-ui';
|
|
4
6
|
import { RouteObject } from 'react-router-dom';
|
|
5
7
|
|
|
8
|
+
interface DocsPageRendererProps {
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
declare function DocsPageRenderer({ content, }: DocsPageRendererProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
6
13
|
interface DocsPage {
|
|
7
14
|
title: string;
|
|
8
15
|
path: string;
|
|
@@ -15,35 +22,35 @@ interface DocsCategory {
|
|
|
15
22
|
}
|
|
16
23
|
type DocsNode = DocsCategory | DocsPage;
|
|
17
24
|
|
|
18
|
-
interface
|
|
25
|
+
interface DocsContextType {
|
|
19
26
|
docs: DocsCategory[];
|
|
20
|
-
basePath
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
|
|
24
|
-
|
|
25
|
-
interface DocsPageRendererProps {
|
|
26
|
-
content: string;
|
|
27
|
+
basePath: string;
|
|
27
28
|
}
|
|
28
|
-
declare
|
|
29
|
+
declare const DocsContext: React.Context<DocsContextType | undefined>;
|
|
29
30
|
|
|
30
|
-
interface
|
|
31
|
+
interface DocsEngineProps {
|
|
31
32
|
docs: DocsCategory[];
|
|
32
|
-
basePath
|
|
33
|
+
basePath?: string;
|
|
34
|
+
children: React__default.ReactNode;
|
|
33
35
|
}
|
|
36
|
+
declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
|
|
34
37
|
|
|
35
|
-
declare function
|
|
38
|
+
declare function useCurrentDocsSection(): DocsCategory | undefined;
|
|
36
39
|
|
|
37
40
|
interface UseCurrentPageProps {
|
|
38
41
|
debug?: boolean;
|
|
39
42
|
}
|
|
40
43
|
declare function useCurrentPage({ debug }?: UseCurrentPageProps): DocsPage | null;
|
|
41
44
|
|
|
45
|
+
declare function useDocs(): DocsContextType;
|
|
46
|
+
|
|
47
|
+
declare function useScopedSidebar(): elseware_ui.MenuNode[];
|
|
48
|
+
|
|
42
49
|
declare function useSidebar(): elseware_ui.MenuNode[];
|
|
43
50
|
|
|
44
51
|
interface GenerateDocsRoutesProps {
|
|
45
52
|
basePath?: string;
|
|
46
|
-
element:
|
|
53
|
+
element: React__default.ReactNode;
|
|
47
54
|
}
|
|
48
55
|
declare function generateDocsRoutes({ basePath, element, }: GenerateDocsRoutesProps): RouteObject[];
|
|
49
56
|
|
|
@@ -56,4 +63,9 @@ declare function findPageByPath(nodes: DocsNode[], targetPath: string, parentPat
|
|
|
56
63
|
declare function resolveDocs(nodes: DocsNode[], parentPath?: string): ResolvedDocsPage[];
|
|
57
64
|
declare function findFirstPage(nodes: DocsNode[], parentPath?: string): string | null;
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
declare function normalizePath(path: string): string;
|
|
67
|
+
declare function normalizeRoutePath(path: string): string;
|
|
68
|
+
|
|
69
|
+
declare function generateSidebar(docs: DocsCategory[], basePath: string): MenuNode[];
|
|
70
|
+
|
|
71
|
+
export { type DocsCategory, DocsContext, type DocsContextType, DocsEngine, type DocsNode, type DocsPage, DocsPageRenderer, type ResolvedDocsPage, findFirstPage, findPageByPath, generateDocsRoutes, generateSidebar, isPage, normalizePath, normalizeRoutePath, resolveDocs, useCurrentDocsSection, useCurrentPage, useDocs, useScopedSidebar, useSidebar };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';require('elseware-ui/styles.css');var
|
|
2
|
-
exports.DocsEngine=
|
|
1
|
+
'use strict';require('elseware-ui/styles.css');var elsewareUi=require('elseware-ui'),jsxRuntime=require('react/jsx-runtime'),react=require('react'),reactRouterDom=require('react-router-dom');function w({content:e}){return jsxRuntime.jsx(elsewareUi.DocumentationPanel,{value:e})}var y=w;var c=react.createContext(void 0);function P({docs:e,basePath:t,children:o}){return jsxRuntime.jsx(c.Provider,{value:{docs:e,basePath:t},children:o})}var g=P;function k({docs:e,basePath:t="/",children:o}){let r=t.startsWith("/")?t:`/${t}`;return jsxRuntime.jsx(g,{docs:e,basePath:r,children:o})}var z=k;function a(){let e=react.useContext(c);if(!e)throw new Error("useDocs must be used within DocsProvider");return e}function h(){let{docs:e}=a(),t=reactRouterDom.useLocation();return e.find(o=>t.pathname.startsWith(o.path))}function n(e){return "/"+e.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function f(e){return e.replace(/^\/+/,"").replace(/\/+$/,"")}function s(e){return "content"in e}function l(e,t,o=""){let r=n(t);for(let i of e){let p=n(`${o}/${i.path}`);if(s(i)){if(p===r)return i}else {let m=l(i.children,t,p);if(m)return m}}return null}function N(e,t=""){let o=[];return e.forEach(r=>{let i=n(`${t}/${r.path}`);if(s(r)){o.push({...r,id:i.replace(/\//g,"-").replace(/^-/,""),fullPath:i});return}o.push(...N(r.children,i));}),o}function $(e,t=""){for(let o of e){let r=n(`${t}/${o.path}`);if(s(o))return r;let i=$(o.children,r);if(i)return i}return null}function u(e,t,o=""){return e.map(r=>{let i=n(`${o}/${r.path}`);return s(r)?{type:"item",name:r.title,to:n(`${t}/${i}`)}:{type:"group",name:r.title,items:u(r.children,t,i)}})}function d(e,t){return u(e,t)}function le({debug:e=false}={}){let{docs:t,basePath:o}=a(),r=reactRouterDom.useLocation(),i=n(r.pathname.replace(new RegExp(`^${o}`),""));return e&&(console.log("location.pathname",r.pathname),console.log("basePath",o),console.log("pagePath",i)),l(t,i)}function he(){let e=h();return e?d([e],"/"):[]}function we(){let{docs:e,basePath:t}=a();return d(e,t)}function ve({basePath:e="/docs",element:t}){return [{path:`${f(e)}/*`,element:t}]}
|
|
2
|
+
exports.DocsContext=c;exports.DocsEngine=z;exports.DocsPageRenderer=y;exports.findFirstPage=$;exports.findPageByPath=l;exports.generateDocsRoutes=ve;exports.generateSidebar=d;exports.isPage=s;exports.normalizePath=n;exports.normalizeRoutePath=f;exports.resolveDocs=N;exports.useCurrentDocsSection=h;exports.useCurrentPage=le;exports.useDocs=a;exports.useScopedSidebar=he;exports.useSidebar=we;//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/engine/DocsEngine.tsx","../src/components/DocsPageRenderer.tsx","../src/hooks/useDocs.ts","../src/utils/page.ts","../src/hooks/useCurrentPage.ts","../src/utils/generateSidebar.ts","../src/hooks/useSidebar.ts","../src/utils/generateRoutes.tsx"],"names":["DocsContext","createContext","DocsProvider","docs","basePath","children","jsx","DocsProvider_default","DocsEngine","normalizedBasePath","DocsEngine_default","DocsPageRenderer","content","DocumentationPanel","DocsPageRenderer_default","useDocs","context","useContext","normalizePath","path","isPage","node","findPageByPath","nodes","targetPath","parentPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","useCurrentPage","debug","location","useLocation","pagePath","mapNodes","fullPath","generateSidebar","useSidebar","normalizeRoutePath","generateDocsRoutes","element"],"mappings":"+LAQO,IAAMA,CAAAA,CAAcC,mBAAAA,CACzB,MACF,CAAA,CCEA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,CAAAA,CAAM,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,CAAA,CAAsB,CACrE,OACEC,cAAAA,CAACN,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO,CAAE,IAAA,CAAAG,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAC3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C,CACF,CACF,CACF","file":"index.js","sourcesContent":["import { createContext } from \"react\";\nimport { DocsCategory } from \"../types/docs\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import React from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { DocsCategory } from \"../types/docs\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: React.ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","import React from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { DocsCategory } from \"../types/docs\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: React.ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/docs\", children }: DocsEngineProps) {\n const normalizedBasePath = basePath.startsWith(\"/\")\n ? basePath\n : `/${basePath}`;\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import React from \"react\";\n\nimport { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({\n content,\n}: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context/DocsContext\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { DocsNode, DocsPage } from \"../types/docs\";\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath } from \"../utils/page\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n /**\n * Remove docs base path\n */\n const pagePath = normalizePath(\n location.pathname.replace(new RegExp(`^${basePath}`), \"\"),\n );\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n\n console.log(\"basePath\", basePath);\n\n console.log(\"pagePath\", pagePath);\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { MenuNode } from \"elseware-ui\";\n\nimport { DocsCategory, DocsNode } from \"../types/docs\";\n\nimport { isPage } from \"./page\";\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n\n name: node.title,\n\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n\n name: node.title,\n\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import { generateSidebar } from \"../utils/generateSidebar\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}","import React from \"react\";\n\nimport { RouteObject } from \"react-router-dom\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: React.ReactNode;\n}\n\nfunction normalizeRoutePath(path: string) {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","doc","normalizePath","path","normalizeRoutePath","isPage","node","findPageByPath","nodes","targetPath","parentPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","useCurrentPage","debug","pagePath","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"+LAQA,SAASA,CAAAA,CAAiB,CACxB,OAAA,CAAAC,CACF,CAAA,CAA0B,CACxB,OAAOC,cAAAA,CAACC,6BAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAAA,CAAS,CAC7C,CAEA,IAAOG,CAAAA,CAAQJ,ECLR,IAAMK,CAAAA,CAAcC,mBAAAA,CACzB,MACF,ECCA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,CAAAA,CAAM,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,CAAA,CAAsB,CACrE,OACER,cAAAA,CAACG,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO,CAAE,IAAA,CAAAG,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAC3C,QAAA,CAAAC,CAAAA,CACH,CAEJ,CAEA,IAAOC,CAAAA,CAAQJ,CAAAA,CCRf,SAASK,CAAAA,CAAW,CAAE,IAAA,CAAAJ,CAAAA,CAAM,QAAA,CAAAC,CAAAA,CAAW,GAAA,CAAK,QAAA,CAAAC,CAAS,CAAA,CAAoB,CACvE,IAAMG,CAAAA,CAAqBJ,CAAAA,CAAS,UAAA,CAAW,GAAG,CAAA,CAC9CA,CAAAA,CACA,CAAA,CAAA,EAAIA,CAAQ,CAAA,CAAA,CAEhB,OACEP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AA,CAAS,QAAQ,CAAA,CAClD,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAYV,CAAQ,CAAA,CAChC,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAYkC,CAAQ,CAAA,CAAA,CAG3BhB,CAAAA,CAAenB,CAAAA,CAAMmC,CAAQ,CACtC,CCvBO,SAASC,EAAAA,EAAmB,CACjC,IAAMC,CAAAA,CAAU3B,GAAsB,CAEtC,OAAK2B,CAAAA,CAIEL,CAAAA,CAAgB,CAACK,CAAO,CAAA,CAAG,GAAG,CAAA,CAH5B,EAIX,CCRO,SAASC,EAAAA,EAAa,CAC3B,GAAM,CAAE,IAAA,CAAAtC,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAAIM,CAAAA,EAAQ,CAEnC,OAAOyB,CAAAA,CAAgBhC,CAAAA,CAAMC,CAAQ,CACvC,CCGO,SAASsC,EAAAA,CAAmB,CACjC,SAAAtC,CAAAA,CAAW,OAAA,CACX,OAAA,CAAAuC,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJaxB,CAAAA,CAAmBf,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAAuC,CACF,CACF,CACF","file":"index.js","sourcesContent":["import React from \"react\";\n\nimport { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({\n content,\n}: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;","import { createContext } from \"react\";\n\nimport { DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import React from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: React.ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","import React from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { DocsCategory } from \"../types\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: React.ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = basePath.startsWith(\"/\")\n ? basePath\n : `/${basePath}`;\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useCurrentDocsSection() {\n const { docs } = useDocs();\n\n const location = useLocation();\n\n return docs.find((doc) => location.pathname.startsWith(doc.path));\n}\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n","import { DocsNode, DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { MenuNode } from \"elseware-ui\";\n\nimport { DocsCategory, DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, normalizePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n // Remove docs base path\n const pagePath = normalizePath(\n location.pathname.replace(new RegExp(`^${basePath}`), \"\"),\n );\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\n\nexport function useScopedSidebar() {\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], \"/\");\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}","import React from \"react\";\n\nimport { RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: React.ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import'elseware-ui/styles.css';import {
|
|
2
|
-
export{
|
|
1
|
+
import'elseware-ui/styles.css';import {DocumentationPanel}from'elseware-ui';import {jsx}from'react/jsx-runtime';import {createContext,useContext}from'react';import {useLocation}from'react-router-dom';function w({content:e}){return jsx(DocumentationPanel,{value:e})}var y=w;var c=createContext(void 0);function P({docs:e,basePath:t,children:o}){return jsx(c.Provider,{value:{docs:e,basePath:t},children:o})}var g=P;function k({docs:e,basePath:t="/",children:o}){let r=t.startsWith("/")?t:`/${t}`;return jsx(g,{docs:e,basePath:r,children:o})}var z=k;function a(){let e=useContext(c);if(!e)throw new Error("useDocs must be used within DocsProvider");return e}function h(){let{docs:e}=a(),t=useLocation();return e.find(o=>t.pathname.startsWith(o.path))}function n(e){return "/"+e.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function f(e){return e.replace(/^\/+/,"").replace(/\/+$/,"")}function s(e){return "content"in e}function l(e,t,o=""){let r=n(t);for(let i of e){let p=n(`${o}/${i.path}`);if(s(i)){if(p===r)return i}else {let m=l(i.children,t,p);if(m)return m}}return null}function N(e,t=""){let o=[];return e.forEach(r=>{let i=n(`${t}/${r.path}`);if(s(r)){o.push({...r,id:i.replace(/\//g,"-").replace(/^-/,""),fullPath:i});return}o.push(...N(r.children,i));}),o}function $(e,t=""){for(let o of e){let r=n(`${t}/${o.path}`);if(s(o))return r;let i=$(o.children,r);if(i)return i}return null}function u(e,t,o=""){return e.map(r=>{let i=n(`${o}/${r.path}`);return s(r)?{type:"item",name:r.title,to:n(`${t}/${i}`)}:{type:"group",name:r.title,items:u(r.children,t,i)}})}function d(e,t){return u(e,t)}function le({debug:e=false}={}){let{docs:t,basePath:o}=a(),r=useLocation(),i=n(r.pathname.replace(new RegExp(`^${o}`),""));return e&&(console.log("location.pathname",r.pathname),console.log("basePath",o),console.log("pagePath",i)),l(t,i)}function he(){let e=h();return e?d([e],"/"):[]}function we(){let{docs:e,basePath:t}=a();return d(e,t)}function ve({basePath:e="/docs",element:t}){return [{path:`${f(e)}/*`,element:t}]}
|
|
2
|
+
export{c as DocsContext,z as DocsEngine,y as DocsPageRenderer,$ as findFirstPage,l as findPageByPath,ve as generateDocsRoutes,d as generateSidebar,s as isPage,n as normalizePath,f as normalizeRoutePath,N as resolveDocs,h as useCurrentDocsSection,le as useCurrentPage,a as useDocs,he as useScopedSidebar,we as useSidebar};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/engine/DocsEngine.tsx","../src/components/DocsPageRenderer.tsx","../src/hooks/useDocs.ts","../src/utils/page.ts","../src/hooks/useCurrentPage.ts","../src/utils/generateSidebar.ts","../src/hooks/useSidebar.ts","../src/utils/generateRoutes.tsx"],"names":["DocsContext","createContext","DocsProvider","docs","basePath","children","jsx","DocsProvider_default","DocsEngine","normalizedBasePath","DocsEngine_default","DocsPageRenderer","content","DocumentationPanel","DocsPageRenderer_default","useDocs","context","useContext","normalizePath","path","isPage","node","findPageByPath","nodes","targetPath","parentPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","useCurrentPage","debug","location","useLocation","pagePath","mapNodes","fullPath","generateSidebar","useSidebar","normalizeRoutePath","generateDocsRoutes","element"],"mappings":"wMAQO,IAAMA,CAAAA,CAAcC,aAAAA,CACzB,MACF,CAAA,CCEA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,CAAAA,CAAM,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,CAAA,CAAsB,CACrE,OACEC,GAAAA,CAACN,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO,CAAE,IAAA,CAAAG,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAC3C,QAAA,CAAAC,CAAAA,CACH,CAEJ,CAEA,IAAOE,CAAAA,CAAQL,CAAAA,CCRf,SAASM,CAAAA,CAAW,CAAE,IAAA,CAAAL,CAAAA,CAAM,QAAA,CAAAC,CAAAA,CAAW,OAAA,CAAS,QAAA,CAAAC,CAAS,CAAA,CAAoB,CAC3E,IAAMI,CAAAA,CAAqBL,CAAAA,CAAS,UAAA,CAAW,GAAG,CAAA,CAC9CA,CAAAA,CACA,CAAA,CAAA,EAAIA,CAAQ,CAAA,CAAA,CAEhB,OACEE,GAAAA,CAACC,CAAAA,CAAA,CAAa,IAAA,CAAMJ,CAAAA,CAAM,QAAA,CAAUM,CAAAA,CACjC,QAAA,CAAAJ,CAAAA,CACH,CAEJ,CAEA,IAAOK,CAAAA,CAAQF,EChBf,SAASG,CAAAA,CAAiB,CACxB,OAAA,CAAAC,CACF,EAA0B,CACxB,OA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CAAQ,CACnD,CACF,CAAC,CACH,CAEO,SAASC,CAAAA,CACdrC,CAAAA,CACAC,CAAAA,CACY,CACZ,OAAOkC,CAAAA,CAASnC,CAAAA,CAAMC,CAAQ,CAChC,CCvCO,SAASqC,EAAAA,EAAa,CAC3B,GAAM,CAAE,IAAA,CAAAtC,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAAIW,CAAAA,EAAQ,CAEnC,OAAOyB,CAAAA,CAAgBrC,CAAAA,CAAMC,CAAQ,CACvC,CCCA,SAASsC,CAAAA,CAAmBvB,EAAc,CACxC,OAAOA,CAAAA,CAAK,OAAA,CAAQ,MAAA,CAAQ,EAAE,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAQ,EAAE,CACpD,CAEO,SAASwB,EAAAA,CAAmB,CACjC,QAAA,CAAAvC,EAAW,OAAA,CACX,OAAA,CAAAwC,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJaF,CAAAA,CAAmBtC,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAAwC,CACF,CACF,CACF","file":"index.mjs","sourcesContent":["import { createContext } from \"react\";\nimport { DocsCategory } from \"../types/docs\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import React from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { DocsCategory } from \"../types/docs\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: React.ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","import React from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { DocsCategory } from \"../types/docs\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: React.ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/docs\", children }: DocsEngineProps) {\n const normalizedBasePath = basePath.startsWith(\"/\")\n ? basePath\n : `/${basePath}`;\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import React from \"react\";\n\nimport { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({\n content,\n}: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context/DocsContext\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { DocsNode, DocsPage } from \"../types/docs\";\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath } from \"../utils/page\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n /**\n * Remove docs base path\n */\n const pagePath = normalizePath(\n location.pathname.replace(new RegExp(`^${basePath}`), \"\"),\n );\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n\n console.log(\"basePath\", basePath);\n\n console.log(\"pagePath\", pagePath);\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { MenuNode } from \"elseware-ui\";\n\nimport { DocsCategory, DocsNode } from \"../types/docs\";\n\nimport { isPage } from \"./page\";\n\nfunction normalizePath(path: string) {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n\n name: node.title,\n\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n\n name: node.title,\n\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import { generateSidebar } from \"../utils/generateSidebar\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}","import React from \"react\";\n\nimport { RouteObject } from \"react-router-dom\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: React.ReactNode;\n}\n\nfunction normalizeRoutePath(path: string) {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","doc","normalizePath","path","normalizeRoutePath","isPage","node","findPageByPath","nodes","targetPath","parentPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","useCurrentPage","debug","pagePath","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"wMAQA,SAASA,CAAAA,CAAiB,CACxB,OAAA,CAAAC,CACF,CAAA,CAA0B,CACxB,OAAOC,GAAAA,CAACC,kBAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAA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AAmB,CACjC,SAAAtC,CAAAA,CAAW,OAAA,CACX,OAAA,CAAAuC,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJaxB,CAAAA,CAAmBf,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAAuC,CACF,CACF,CACF","file":"index.mjs","sourcesContent":["import React from \"react\";\n\nimport { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({\n content,\n}: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;","import { createContext } from \"react\";\n\nimport { DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import React from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: React.ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","import React from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { DocsCategory } from \"../types\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: React.ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = basePath.startsWith(\"/\")\n ? basePath\n : `/${basePath}`;\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useCurrentDocsSection() {\n const { docs } = useDocs();\n\n const location = useLocation();\n\n return docs.find((doc) => location.pathname.startsWith(doc.path));\n}\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n","import { DocsNode, DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { MenuNode } from \"elseware-ui\";\n\nimport { DocsCategory, DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, normalizePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n // Remove docs base path\n const pagePath = normalizePath(\n location.pathname.replace(new RegExp(`^${basePath}`), \"\"),\n );\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\n\nexport function useScopedSidebar() {\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], \"/\");\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}","import React from \"react\";\n\nimport { RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: React.ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
|