robindoc 3.2.1 → 3.3.1
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/LICENSE +1 -1
- package/README.md +2 -1
- package/lib/components/blocks/anchor-heading/index.js.map +1 -1
- package/lib/components/blocks/breadcrumbs/index.js +1 -1
- package/lib/components/blocks/breadcrumbs/index.js.map +1 -1
- package/lib/components/blocks/code-section/index.js.map +1 -1
- package/lib/components/blocks/contents/index.js +1 -1
- package/lib/components/blocks/contents/index.js.map +1 -1
- package/lib/components/blocks/header-menu/index.d.ts.map +1 -1
- package/lib/components/blocks/header-menu/index.js +1 -1
- package/lib/components/blocks/header-menu/index.js.map +1 -1
- package/lib/components/blocks/header-social/index.js +1 -1
- package/lib/components/blocks/header-social/index.js.map +1 -1
- package/lib/components/blocks/last-modified/index.js +1 -1
- package/lib/components/blocks/last-modified/index.js.map +1 -1
- package/lib/components/blocks/nav-content-link/index.js +1 -1
- package/lib/components/blocks/nav-content-link/index.js.map +1 -1
- package/lib/components/blocks/nav-link/index.d.ts +5 -18
- package/lib/components/blocks/nav-link/index.d.ts.map +1 -1
- package/lib/components/blocks/nav-link/index.js +1 -1
- package/lib/components/blocks/nav-link/index.js.map +1 -1
- package/lib/components/blocks/no-js/index.d.ts.map +1 -1
- package/lib/components/blocks/no-js/index.js +1 -1
- package/lib/components/blocks/no-js/index.js.map +1 -1
- package/lib/components/blocks/pagination/index.d.ts.map +1 -1
- package/lib/components/blocks/pagination/index.js +1 -1
- package/lib/components/blocks/pagination/index.js.map +1 -1
- package/lib/components/blocks/search/index.js +1 -1
- package/lib/components/blocks/search/index.js.map +1 -1
- package/lib/components/blocks/search/search-modal/index.js +1 -1
- package/lib/components/blocks/search/search-modal/index.js.map +1 -1
- package/lib/components/blocks/section-dropdown/index.js +1 -1
- package/lib/components/blocks/section-dropdown/index.js.map +1 -1
- package/lib/components/blocks/theme-detector/index.d.ts.map +1 -1
- package/lib/components/blocks/theme-detector/index.js +1 -1
- package/lib/components/blocks/theme-detector/index.js.map +1 -1
- package/lib/components/blocks/theme-styles/index.js +1 -1
- package/lib/components/blocks/theme-styles/index.js.map +1 -1
- package/lib/components/blocks/theme-switcher/index.d.ts.map +1 -1
- package/lib/components/blocks/theme-switcher/index.js +1 -1
- package/lib/components/blocks/theme-switcher/index.js.map +1 -1
- package/lib/components/contexts/contents/context.d.ts +0 -1
- package/lib/components/contexts/contents/context.d.ts.map +1 -1
- package/lib/components/contexts/contents/context.js.map +1 -1
- package/lib/components/contexts/contents/provider.d.ts.map +1 -1
- package/lib/components/contexts/contents/provider.js +1 -1
- package/lib/components/contexts/contents/provider.js.map +1 -1
- package/lib/components/contexts/contents/use-heading-index.js.map +1 -1
- package/lib/components/contexts/contents/use-heading-register.js +1 -1
- package/lib/components/contexts/contents/use-heading-register.js.map +1 -1
- package/lib/components/contexts/navigate/context.d.ts +0 -1
- package/lib/components/contexts/navigate/context.d.ts.map +1 -1
- package/lib/components/contexts/navigate/context.js.map +1 -1
- package/lib/components/contexts/navigate/provider.js +1 -1
- package/lib/components/contexts/navigate/provider.js.map +1 -1
- package/lib/components/contexts/navigate/use-navigate.js +1 -1
- package/lib/components/contexts/navigate/use-navigate.js.map +1 -1
- package/lib/components/contexts/reference/context.d.ts +0 -1
- package/lib/components/contexts/reference/context.d.ts.map +1 -1
- package/lib/components/contexts/reference/context.js.map +1 -1
- package/lib/components/contexts/reference/provider.js.map +1 -1
- package/lib/components/contexts/reference/use-reference.js.map +1 -1
- package/lib/components/elements/article/document.d.ts.map +1 -1
- package/lib/components/elements/article/document.js +1 -1
- package/lib/components/elements/article/document.js.map +1 -1
- package/lib/components/elements/article/index.js.map +1 -1
- package/lib/components/elements/article/utils.d.ts +1 -1
- package/lib/components/elements/article/utils.d.ts.map +1 -1
- package/lib/components/elements/article/utils.js +1 -1
- package/lib/components/elements/article/utils.js.map +1 -1
- package/lib/components/elements/footer/index.js.map +1 -1
- package/lib/components/elements/header/index.js +1 -1
- package/lib/components/elements/header/index.js.map +1 -1
- package/lib/components/elements/keylink-to-content/index.js.map +1 -1
- package/lib/components/elements/keylink-to-navigation/index.js.map +1 -1
- package/lib/components/elements/robin-provider/index.d.ts +2 -0
- package/lib/components/elements/robin-provider/index.d.ts.map +1 -1
- package/lib/components/elements/robin-provider/index.js +1 -1
- package/lib/components/elements/robin-provider/index.js.map +1 -1
- package/lib/components/elements/sidebar/index.js +1 -1
- package/lib/components/elements/sidebar/index.js.map +1 -1
- package/lib/components/elements/sidebar/sidebar-drop/index.js +1 -1
- package/lib/components/elements/sidebar/sidebar-drop/index.js.map +1 -1
- package/lib/components/elements/sidebar/sidebar-link/index.js.map +1 -1
- package/lib/components/elements/sidebar/sidebar-menu/index.d.ts.map +1 -1
- package/lib/components/elements/sidebar/sidebar-menu/index.js +1 -1
- package/lib/components/elements/sidebar/sidebar-menu/index.js.map +1 -1
- package/lib/components/elements/sidebar/tools.d.ts.map +1 -1
- package/lib/components/elements/sidebar/tools.js +1 -1
- package/lib/components/elements/sidebar/tools.js.map +1 -1
- package/lib/components/ui/backdrop/index.js.map +1 -1
- package/lib/components/ui/block/index.js.map +1 -1
- package/lib/components/ui/blockquote/data.d.ts +0 -1
- package/lib/components/ui/blockquote/data.d.ts.map +1 -1
- package/lib/components/ui/blockquote/data.js +1 -1
- package/lib/components/ui/blockquote/data.js.map +1 -1
- package/lib/components/ui/blockquote/icons.js.map +1 -1
- package/lib/components/ui/blockquote/index.js.map +1 -1
- package/lib/components/ui/code-block/index.d.ts.map +1 -1
- package/lib/components/ui/code-block/index.js +1 -1
- package/lib/components/ui/code-block/index.js.map +1 -1
- package/lib/components/ui/code-block/theme.js.map +1 -1
- package/lib/components/ui/code-span/index.js.map +1 -1
- package/lib/components/ui/container/index.js.map +1 -1
- package/lib/components/ui/content-link/index.d.ts.map +1 -1
- package/lib/components/ui/content-link/index.js.map +1 -1
- package/lib/components/ui/copy-button/index.d.ts.map +1 -1
- package/lib/components/ui/copy-button/index.js +1 -1
- package/lib/components/ui/copy-button/index.js.map +1 -1
- package/lib/components/ui/copy-text/index.js +1 -1
- package/lib/components/ui/copy-text/index.js.map +1 -1
- package/lib/components/ui/del/index.js.map +1 -1
- package/lib/components/ui/em/index.js.map +1 -1
- package/lib/components/ui/external-mark/index.js.map +1 -1
- package/lib/components/ui/git-logos/index.d.ts +1 -0
- package/lib/components/ui/git-logos/index.d.ts.map +1 -1
- package/lib/components/ui/git-logos/index.js +1 -1
- package/lib/components/ui/git-logos/index.js.map +1 -1
- package/lib/components/ui/heading/index.js +1 -1
- package/lib/components/ui/heading/index.js.map +1 -1
- package/lib/components/ui/hr/index.js.map +1 -1
- package/lib/components/ui/img/index.js.map +1 -1
- package/lib/components/ui/list/list-item/index.js.map +1 -1
- package/lib/components/ui/list/ordered-list/index.js.map +1 -1
- package/lib/components/ui/list/unordered-list/index.js.map +1 -1
- package/lib/components/ui/modal/index.js.map +1 -1
- package/lib/components/ui/modal/use-modal.js +1 -1
- package/lib/components/ui/modal/use-modal.js.map +1 -1
- package/lib/components/ui/paragraph/index.js.map +1 -1
- package/lib/components/ui/strong/index.js.map +1 -1
- package/lib/components/ui/table/table/index.js.map +1 -1
- package/lib/components/ui/table/tbody/index.js.map +1 -1
- package/lib/components/ui/table/td/index.js.map +1 -1
- package/lib/components/ui/table/th/index.js.map +1 -1
- package/lib/components/ui/table/thead/index.js.map +1 -1
- package/lib/components/ui/table/tr/index.js.map +1 -1
- package/lib/components/ui/tabs/index.js +1 -1
- package/lib/components/ui/tabs/index.js.map +1 -1
- package/lib/components/ui/tabs/tabs-header/index.d.ts.map +1 -1
- package/lib/components/ui/tabs/tabs-header/index.js +1 -1
- package/lib/components/ui/tabs/tabs-header/index.js.map +1 -1
- package/lib/components/ui/tabs/tabs-styles/index.js +1 -1
- package/lib/components/ui/tabs/tabs-styles/index.js.map +1 -1
- package/lib/components/ui/task-list/task-list-item/index.js.map +1 -1
- package/lib/components/ui/task-list/task-unordered-list/index.js.map +1 -1
- package/lib/components/ui/tooltip/index.js.map +1 -1
- package/lib/core/data/contents.js.map +1 -1
- package/lib/core/hooks/use-debouncer.d.ts.map +1 -1
- package/lib/core/hooks/use-debouncer.js +1 -1
- package/lib/core/hooks/use-debouncer.js.map +1 -1
- package/lib/core/hooks/use-system-type.js +1 -1
- package/lib/core/hooks/use-system-type.js.map +1 -1
- package/lib/core/providers/base.js +1 -1
- package/lib/core/providers/base.js.map +1 -1
- package/lib/core/providers/file-system.js +1 -1
- package/lib/core/providers/file-system.js.map +1 -1
- package/lib/core/providers/github.js +1 -1
- package/lib/core/providers/github.js.map +1 -1
- package/lib/core/types/content.d.ts +0 -1
- package/lib/core/types/content.d.ts.map +1 -1
- package/lib/core/utils/content-tools.d.ts.map +1 -1
- package/lib/core/utils/content-tools.js +1 -1
- package/lib/core/utils/content-tools.js.map +1 -1
- package/lib/core/utils/create-base-searcher.d.ts.map +1 -1
- package/lib/core/utils/create-base-searcher.js +1 -1
- package/lib/core/utils/create-base-searcher.js.map +1 -1
- package/lib/core/utils/detect-provider.d.ts.map +1 -1
- package/lib/core/utils/detect-provider.js.map +1 -1
- package/lib/core/utils/get-configuration.d.ts.map +1 -1
- package/lib/core/utils/get-configuration.js.map +1 -1
- package/lib/core/utils/get-metadata.d.ts.map +1 -1
- package/lib/core/utils/get-metadata.js +1 -1
- package/lib/core/utils/get-metadata.js.map +1 -1
- package/lib/core/utils/git-tools.d.ts.map +1 -1
- package/lib/core/utils/git-tools.js.map +1 -1
- package/lib/core/utils/initialize-robindoc.d.ts.map +1 -1
- package/lib/core/utils/initialize-robindoc.js +1 -1
- package/lib/core/utils/initialize-robindoc.js.map +1 -1
- package/lib/core/utils/load-content.d.ts.map +1 -1
- package/lib/core/utils/load-content.js.map +1 -1
- package/lib/core/utils/parse-structure.d.ts.map +1 -1
- package/lib/core/utils/parse-structure.js.map +1 -1
- package/lib/core/utils/path-tools.d.ts.map +1 -1
- package/lib/core/utils/path-tools.js +1 -1
- package/lib/core/utils/path-tools.js.map +1 -1
- package/lib/core/utils/tabs-tools.d.ts.map +1 -1
- package/lib/core/utils/tabs-tools.js +1 -1
- package/lib/core/utils/tabs-tools.js.map +1 -1
- package/lib/styles.css +2103 -2
- package/package.json +28 -28
- package/lib/assets/index.d.ts +0 -2
- package/lib/assets/index.d.ts.map +0 -1
- package/lib/assets/index.js +0 -2
- package/lib/assets/index.js.map +0 -1
- package/lib/styles.css.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AnchorHeading as e}from"../../blocks/anchor-heading/index.js";import{CodeSection as t}from"../../blocks/code-section/index.js";import{NavContentLink as n}from"../../blocks/nav-content-link/index.js";import{Block as r}from"../../ui/block/index.js";import{Blockquote as o}from"../../ui/blockquote/index.js";import{CodeBlock as a}from"../../ui/code-block/index.js";import{CodeSpan as s}from"../../ui/code-span/index.js";import{Del as i}from"../../ui/del/index.js";import{Em as l}from"../../ui/em/index.js";import{Heading as m}from"../../ui/heading/index.js";import{Hr as c}from"../../ui/hr/index.js";import{Img as u}from"../../ui/img/index.js";import{ListItem as p}from"../../ui/list/list-item/index.js";import{OrderedList as d}from"../../ui/list/ordered-list/index.js";import{UnorderedList as k}from"../../ui/list/unordered-list/index.js";import{Paragraph as f}from"../../ui/paragraph/index.js";import{Strong as
|
|
1
|
+
import{AnchorHeading as e}from"../../blocks/anchor-heading/index.js";import{CodeSection as t}from"../../blocks/code-section/index.js";import{NavContentLink as n}from"../../blocks/nav-content-link/index.js";import{Block as r}from"../../ui/block/index.js";import{Blockquote as o}from"../../ui/blockquote/index.js";import{CodeBlock as a}from"../../ui/code-block/index.js";import{CodeSpan as s}from"../../ui/code-span/index.js";import{Del as i}from"../../ui/del/index.js";import{Em as l}from"../../ui/em/index.js";import{Heading as m}from"../../ui/heading/index.js";import{Hr as c}from"../../ui/hr/index.js";import{Img as u}from"../../ui/img/index.js";import{ListItem as p}from"../../ui/list/list-item/index.js";import{OrderedList as d}from"../../ui/list/ordered-list/index.js";import{UnorderedList as k}from"../../ui/list/unordered-list/index.js";import{Paragraph as f}from"../../ui/paragraph/index.js";import{Strong as h}from"../../ui/strong/index.js";import{Table as E}from"../../ui/table/table/index.js";import{Tbody as x}from"../../ui/table/tbody/index.js";import{Td as y}from"../../ui/table/td/index.js";import{Th as g}from"../../ui/table/th/index.js";import{Thead as b}from"../../ui/table/thead/index.js";import{Tr as w}from"../../ui/table/tr/index.js";import{Tabs as j}from"../../ui/tabs/index.js";import{TaskListItem as $}from"../../ui/task-list/task-list-item/index.js";import{TaskOrderedList as v}from"../../ui/task-list/task-ordered-list/index.js";import{TaskUnorderedList as A}from"../../ui/task-list/task-unordered-list/index.js";import N,{Text as T,attributesToProps as C,domToReact as U}from"html-react-parser";import D from"react";import{isNewCodeToken as F,validateComponentName as P,parseCodeLang as S,formatId as W,parseBlockqoute as q,formatLinkHref as z,parseMarkdown as I}from"./utils.js";const K=({raw:e,components:t,...r})=>{const o={replace(e){if(e instanceof T&&e.data){const{headings:n,tokens:o}=I(e.data);return D.createElement(O,{headings:n,tokens:o,components:t,subtree:!0,...r})}if(!("name"in e))return D.createElement(D.Fragment,null);if("a"===e.name&&"attribs"in e){const{href:t,external:a}=z(e.attribs.href,r.pathname,r.pages);return D.createElement(n,{...C(e.attribs),href:t,external:a},U(e.children,o))}if(!P(e.name))return e;if(!t||!(e.name in t))return console.warn(`Unknown component: "${e.name}"`),D.createElement(D.Fragment,null);const a="attribs"in e?C(e.attribs):{},s=t[e.name],i="children"in e?e.children:null;return D.createElement(s,{...a},i?U(i,o):null)},htmlparser2:{lowerCaseTags:!1,lowerCaseAttributeNames:!1}};return N(e,o)},O=({pathname:N,components:T,uri:C,targetProvider:U,tokens:I,headings:O,config:R={},subtree:Z,pages:B})=>{const{publicDirs:G}=R;let H=null,J={};const L=[],M=({token:I})=>{if(!I)return null;if(F(I,J)){const e=J;J={};const t=Object.keys(e).sort().join("-"),n=L.includes(t);return n||L.push(t),D.createElement(D.Fragment,null,D.createElement(j,{type:"code",tabsData:e,insertStyles:!n,blockKey:t}),D.createElement(M,{token:I}))}if(H){if(Array.isArray(I)||"html"!==I.type||"\x3c!---/robin--\x3e"!==I.raw.trim())return"dummy"===H.type||(Array.isArray(I)?H.childTokens.push(...I):H.childTokens.push(I)),null;{if("dummy"===H.type)return H=null,null;const{componentName:e,childTokens:t,props:n}=H,r=T[e];return H=null,D.createElement(r,{...n},D.createElement(M,{token:t}))}}if(Array.isArray(I))return I.map((e,t)=>D.createElement(M,{token:e,key:e.raw+t}));switch(I.type){case"heading":const j=`h${I.depth}`,F=O.find(e=>e.token===I);return F?.id?D.createElement(e,{component:j,id:F.id},I.tokens?D.createElement(M,{token:I.tokens}):I.raw):D.createElement(m,{component:j,id:1===I.depth?"main-content":void 0},I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"table":return D.createElement(r,null,D.createElement(E,null,D.createElement(b,null,D.createElement(w,null,I.header.map((e,t)=>D.createElement(g,{key:e.text+t},e.tokens?D.createElement(M,{token:e.tokens}):e.text)))),D.createElement(x,null,I.rows.map((e,t)=>D.createElement(w,{key:t},e.map((e,t)=>D.createElement(y,{key:e.text+t},e.tokens?D.createElement(M,{token:e.tokens}):e.text)))))));case"link":const{href:L,external:Q}=z(I.href,N,B);return D.createElement(n,{href:L,external:Q},I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"space":case"def":return null;case"hr":return D.createElement(c,null);case"image":return D.createElement(u,{src:I.href,publicDirs:G,provider:U,uri:C,alt:I.title||""});case"paragraph":return Z?I.tokens?D.createElement(M,{token:I.tokens}):I.raw:I.tokens?.some(e=>"html"===e.type)&&I.tokens?.every(e=>"html"===e.type||"text"===e.type||"\n"===e.raw)?D.createElement(M,{token:{...I,type:"html"}}):D.createElement(f,null,I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"strong":return D.createElement(h,null,I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"del":return D.createElement(i,null,I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"em":return D.createElement(l,null,I.tokens?D.createElement(M,{token:I.tokens}):I.raw);case"blockquote":const{token:V,type:X}=q(I);return D.createElement(o,{type:X},V.tokens?D.createElement(M,{token:V.tokens}):V.raw);case"codespan":const Y=I.raw.replace(/^`|`$/g,""),_=Y.match(/(.+){:([a-zA-Z]+)}$/);if(_){const[,e,t]=_;return D.createElement(a,{code:e,lang:t,inline:!0})}return D.createElement(s,{code:Y});case"code":const{lang:ee,configuration:te}=S(I.lang);if(te.switcher&&ee){const e="string"==typeof te.tab?W(te.tab):ee;if(J[e]={tabName:(te.tab||ee).toString(),element:D.createElement(t,{lang:ee,code:I.text,...te})},"string"==typeof te.clone){te.clone.split(",").forEach(e=>{const[n,r,o]=e.split("|"),a="string"==typeof r?W(r):n;J[a]={tabName:(r||n).toString(),element:D.createElement(t,{lang:n,code:I.text,...te,filename:o||te.filename})}})}return null}return D.createElement(t,{lang:ee,code:I.text,...te});case"escape":return I.text;case"list":if(I.items.every(e=>e.task)){const e=I.ordered?v:A;return D.createElement(e,{start:I.start},I.items.map((e,t)=>{const n=1===e.tokens?.length&&"paragraph"===e.tokens[0].type?e.tokens[0].tokens:e.tokens;return D.createElement($,{key:e.raw+t,defaultChecked:e.checked},n?D.createElement(M,{token:n}):e.raw)}))}const ne=I.ordered?d:k;return D.createElement(ne,{start:I.start},I.items.map((e,t)=>{const n=1===e.tokens?.length&&"paragraph"===e.tokens[0].type?e.tokens[0].tokens:e.tokens;return D.createElement(p,{key:e.raw+t},n?D.createElement(M,{token:n}):e.raw)}));case"html":const re=I.raw.trim();if(re.startsWith("\x3c!---robin")&&re.endsWith("--\x3e")){const e=re.endsWith("/--\x3e"),t=re.match(/<!---robin ([\w]+)/)?.[1];if(!t)return e||(H={type:"dummy"}),null;if(!P(t))return console.warn(`"${t}" is using incorrect casing. Use PascalCase for Robin components`),e||(H={type:"dummy"}),null;if(!T||!(t in T))return console.warn(`Unknown component: "${t}"`),e||(H={type:"dummy"}),null;const n=re.split(/\r?\n/).slice(1,-1).reduce((e,t)=>{const[n,r,o]=t.match(/^([\w]+)(?:="(.+)")?$/)||[];return n?(e[r]=o??!0,e):(console.warn(`Invalid component attribute: "${t}"`),e)},{});if(e){const e=T[t];return D.createElement(e,{...n})}return H={props:n,componentName:t,childTokens:[],type:"base"},null}return D.createElement(K,{raw:I.raw,components:T,config:R,targetProvider:U,pathname:N,uri:C,pages:B});case"text":return"tokens"in I?D.createElement(M,{token:I.tokens||[]}):I.raw;default:return!I.type&&"raw"in I?I.raw:(console.warn(`Unknown token ${I.type}`,I),null)}};return I.push({type:"text",raw:""}),D.createElement(M,{token:I})};export{O as Document,K as DocumentJSX};
|
|
2
2
|
//# sourceMappingURL=document.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sources":["../../../../src/components/elements/article/document.tsx"],"sourcesContent":["import { AnchorHeading } from \"@src/components/blocks/anchor-heading\";\nimport { CodeSection } from \"@src/components/blocks/code-section\";\nimport { NavContentLink } from \"@src/components/blocks/nav-content-link\";\nimport { Block } from \"@src/components/ui/block\";\nimport { Blockquote } from \"@src/components/ui/blockquote\";\nimport { CodeBlock } from \"@src/components/ui/code-block\";\nimport { CodeSpan } from \"@src/components/ui/code-span\";\nimport { Del } from \"@src/components/ui/del\";\nimport { Em } from \"@src/components/ui/em\";\nimport { Heading } from \"@src/components/ui/heading\";\nimport { Hr } from \"@src/components/ui/hr\";\nimport { Img } from \"@src/components/ui/img\";\nimport { ListItem, OrderedList, UnorderedList } from \"@src/components/ui/list\";\nimport { Paragraph } from \"@src/components/ui/paragraph\";\nimport { Strong } from \"@src/components/ui/strong\";\nimport { Table, Tbody, Td, Th, Thead, Tr } from \"@src/components/ui/table\";\nimport { Tabs } from \"@src/components/ui/tabs\";\nimport { TaskListItem, TaskOrderedList, TaskUnorderedList } from \"@src/components/ui/task-list\";\nimport { type BaseProvider } from \"@src/core/providers/base\";\nimport { type Components, type RobinProps } from \"@src/core/types/content\";\nimport parse, { attributesToProps, DOMNode, domToReact, HTMLReactParserOptions, Text } from \"html-react-parser\";\nimport { type Token, type Tokens, type TokensList } from \"marked\";\nimport React from \"react\";\nimport { type BundledLanguage } from \"shiki/langs\";\n\nimport { type PagesType } from \"./types\";\nimport {\n formatId,\n formatLinkHref,\n isNewCodeToken,\n parseBlockqoute,\n parseCodeLang,\n parseMarkdown,\n validateComponentName,\n type AnchorData,\n} from \"./utils\";\n\ninterface DocumentJSXProps extends Omit<ContentProps, \"tokens\" | \"headings\"> {\n raw: string;\n pages?: PagesType;\n}\n\nexport const DocumentJSX: React.FC<DocumentJSXProps> = ({ raw, components, ...baseProps }) => {\n const parseOptions: HTMLReactParserOptions = {\n replace(domNode) {\n if (domNode instanceof Text && domNode.data) {\n const { headings, tokens } = parseMarkdown(domNode.data);\n\n return <Document headings={headings} tokens={tokens} components={components} subtree {...baseProps} />;\n }\n\n if (!(\"name\" in domNode)) return <></>;\n\n if (domNode.name === \"a\" && \"attribs\" in domNode) {\n const { href, external } = formatLinkHref(domNode.attribs.href, baseProps.pathname, baseProps.pages);\n return (\n <NavContentLink {...attributesToProps(domNode.attribs)} href={href} external={external}>\n {domToReact(domNode.children as DOMNode[], parseOptions)}\n </NavContentLink>\n );\n }\n\n if (!validateComponentName(domNode.name)) return domNode;\n\n if (!components || !(domNode.name in components)) {\n console.warn(`Unknown component: \"${domNode.name}\"`);\n return <></>;\n }\n\n const props = \"attribs\" in domNode ? attributesToProps(domNode.attribs) : {};\n const Component = components[domNode.name];\n const children = \"children\" in domNode ? domNode.children : null;\n\n return (\n <Component {...props}>{children ? domToReact(children as DOMNode[], parseOptions) : null}</Component>\n );\n },\n htmlparser2: {\n lowerCaseTags: false,\n lowerCaseAttributeNames: false,\n },\n };\n return parse(raw, parseOptions);\n};\n\nexport type ContentProps = {\n pathname: string;\n components?: Components;\n config?: {\n publicDirs?: string[];\n };\n uri?: string;\n targetProvider?: BaseProvider | null;\n tokens: TokensList;\n headings: AnchorData[];\n subtree?: boolean;\n pages?: PagesType;\n};\n\nexport const Document: React.FC<ContentProps> = ({\n pathname,\n components,\n uri,\n targetProvider,\n tokens,\n headings,\n config = {},\n subtree,\n pages,\n}) => {\n const { publicDirs } = config;\n\n let robin:\n | null\n | { props: RobinProps; childTokens: Token[]; componentName: string; type: \"base\" }\n | { type: \"dummy\" } = null;\n let codeQueue: { [lang: string]: { element: React.ReactNode; tabName: string } } = {};\n const insertedCodeKeys: string[] = [];\n const DocumentToken: React.FC<{ token: Token | Token[] }> = ({ token }) => {\n if (!token) return null;\n\n if (isNewCodeToken(token, codeQueue)) {\n const tabsData = codeQueue;\n codeQueue = {};\n const tabsKey = Object.keys(tabsData).sort().join(\"-\");\n const isInsertedKey = insertedCodeKeys.includes(tabsKey);\n if (!isInsertedKey) insertedCodeKeys.push(tabsKey);\n\n return (\n <>\n <Tabs type=\"code\" tabsData={tabsData} insertStyles={!isInsertedKey} blockKey={tabsKey} />\n <DocumentToken token={token} />\n </>\n );\n }\n\n if (robin) {\n if (!Array.isArray(token) && token.type === \"html\" && token.raw.trim() === \"<!---/robin-->\") {\n if (robin.type === \"dummy\") {\n robin = null;\n return null;\n }\n\n const { componentName, childTokens, props } = robin;\n const RobinComponent = components![componentName];\n robin = null;\n return (\n <RobinComponent {...props}>\n <DocumentToken token={childTokens} />\n </RobinComponent>\n );\n } else {\n if (robin.type === \"dummy\") return null;\n\n if (Array.isArray(token)) {\n robin.childTokens.push(...token);\n } else {\n robin.childTokens.push(token);\n }\n return null;\n }\n }\n\n if (Array.isArray(token)) {\n return token.map((t, index) => <DocumentToken token={t} key={(t as Tokens.Text).raw + index} />);\n }\n\n switch (token.type) {\n case \"heading\":\n const Component = `h${token.depth}` as \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n const predefinedData = headings.find((heading) => heading.token === token);\n if (predefinedData?.id) {\n return (\n <AnchorHeading component={Component} id={predefinedData.id}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </AnchorHeading>\n );\n } else {\n return (\n <Heading component={Component} id={token.depth === 1 ? \"main-content\" : undefined}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </Heading>\n );\n }\n case \"table\":\n return (\n <Block>\n <Table>\n <Thead>\n <Tr>\n {token.header.map((t: Tokens.Text, index: number) => (\n <Th key={t.text + index}>\n {t.tokens ? <DocumentToken token={t.tokens} /> : t.text}\n </Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {token.rows.map((row: Tokens.Text[], rowIndex: number) => (\n <Tr key={rowIndex}>\n {row.map((elem, elemIndex) => (\n <Td key={elem.text + elemIndex}>\n {elem.tokens ? <DocumentToken token={elem.tokens} /> : elem.text}\n </Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </Block>\n );\n case \"link\":\n const { href, external } = formatLinkHref(token.href, pathname, pages);\n\n return (\n <NavContentLink href={href} external={external}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </NavContentLink>\n );\n case \"space\":\n return null;\n case \"hr\":\n return <Hr />;\n case \"image\":\n return (\n <Img\n src={token.href}\n publicDirs={publicDirs}\n provider={targetProvider}\n uri={uri}\n alt={token.title || \"\"}\n />\n );\n case \"paragraph\":\n if (subtree) return token.tokens ? <DocumentToken token={token.tokens} /> : token.raw;\n if (\n token.tokens?.some((t) => t.type === \"html\") &&\n token.tokens?.every((t) => t.type === \"html\" || t.type === \"text\" || t.raw === \"\\n\")\n ) {\n return <DocumentToken token={{ ...token, type: \"html\" }} />;\n }\n\n return <Paragraph>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Paragraph>;\n case \"strong\":\n return <Strong>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Strong>;\n case \"del\":\n return <Del>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Del>;\n case \"em\":\n return <Em>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Em>;\n case \"blockquote\":\n const { token: blockquoteToken, type } = parseBlockqoute(token);\n\n return (\n <Blockquote type={type}>\n {blockquoteToken.tokens ? (\n <DocumentToken token={blockquoteToken.tokens} />\n ) : (\n blockquoteToken.raw\n )}\n </Blockquote>\n );\n case \"codespan\":\n const inlineCode = token.raw.replace(/^`|`$/g, \"\");\n const hightlightMatch = inlineCode.match(/(.+){:([a-zA-Z]+)}$/);\n if (hightlightMatch) {\n const [, raw, lang] = hightlightMatch;\n return <CodeBlock code={raw} lang={lang as BundledLanguage} inline />;\n }\n\n return <CodeSpan code={inlineCode} />;\n case \"code\":\n const { lang, configuration } = parseCodeLang(token.lang);\n if (configuration.switcher && lang) {\n const tabKey = typeof configuration.tab === \"string\" ? formatId(configuration.tab) : lang;\n codeQueue[tabKey] = {\n tabName: (configuration.tab || lang).toString(),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n element: <CodeSection lang={lang as any} code={token.text} {...configuration} />,\n };\n\n if (typeof configuration.clone === \"string\") {\n const copies = configuration.clone.split(\",\");\n\n copies.forEach((copy) => {\n const [copyLang, copyTab, copyFileName] = copy.split(\"|\");\n const copyTabKey = typeof copyTab === \"string\" ? formatId(copyTab) : copyLang;\n\n codeQueue[copyTabKey] = {\n tabName: (copyTab || copyLang).toString(),\n element: (\n <CodeSection\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n lang={copyLang as any}\n code={token.text}\n {...configuration}\n filename={copyFileName || (configuration.filename as string)}\n />\n ),\n };\n });\n }\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <CodeSection lang={lang as any} code={token.text} {...configuration} />;\n case \"escape\":\n return token.text;\n case \"list\":\n const isTaskList = token.items.every((i: Tokens.ListItem) => i.task);\n if (isTaskList) {\n const ListComponent = token.ordered ? TaskOrderedList : TaskUnorderedList;\n return (\n <ListComponent start={token.start}>\n {token.items.map((elem: Tokens.ListItem, index: number) => (\n <TaskListItem key={elem.raw + index} defaultChecked={elem.checked}>\n {elem.tokens ? <DocumentToken token={elem.tokens} /> : elem.raw}\n </TaskListItem>\n ))}\n </ListComponent>\n );\n }\n\n const ListComponent = token.ordered ? OrderedList : UnorderedList;\n return (\n <ListComponent start={token.start}>\n {token.items.map((elem: Tokens.ListItem, index: number) => (\n <ListItem key={elem.raw + index}>\n {elem.tokens ? <DocumentToken token={elem.tokens} /> : elem.raw}\n </ListItem>\n ))}\n </ListComponent>\n );\n case \"html\":\n const text = token.raw.trim();\n\n if (text.startsWith(\"<!---robin\") && text.endsWith(\"-->\")) {\n const selfClosed = text.endsWith(\"/-->\");\n const componentName = text.match(/<!---robin ([\\w]+)/)?.[1];\n\n if (!componentName) {\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n\n if (!validateComponentName(componentName)) {\n console.warn(\n `\"${componentName}\" is using incorrect casing. Use PascalCase for Robin components`,\n );\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n\n if (!components || !(componentName in components)) {\n console.warn(`Unknown component: \"${componentName}\"`);\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n const propRows = text.split(/\\r?\\n/).slice(1, -1);\n const props = propRows.reduce<{ [key: string]: string | true }>((acc, cur) => {\n const [_match, key, value] = cur.match(/^([\\w]+)(?:=\"(.+)\")?$/) || [];\n\n if (!_match) {\n console.warn(`Invalid component attribute: \"${cur}\"`);\n return acc;\n }\n\n acc[key] = value ?? true;\n return acc;\n }, {});\n\n if (selfClosed) {\n const Component = components[componentName as keyof typeof components];\n return <Component {...props} />;\n }\n\n robin = { props, componentName, childTokens: [], type: \"base\" };\n return null;\n }\n\n return (\n <DocumentJSX\n raw={token.raw}\n components={components}\n config={config}\n targetProvider={targetProvider}\n pathname={pathname}\n uri={uri}\n pages={pages}\n />\n );\n case \"text\":\n if (\"tokens\" in token) {\n return <DocumentToken token={token.tokens || []} />;\n }\n return token.raw;\n default:\n if (!token.type && \"raw\" in token) return token.raw;\n\n console.warn(`Unknown token ${token.type}`, token);\n return null;\n }\n };\n\n tokens.push({ type: \"text\", raw: \"\" });\n return <DocumentToken token={tokens} />;\n};\n"],"names":["DocumentJSX","raw","components","baseProps","parseOptions","replace","domNode","Text","data","headings","tokens","parseMarkdown","React","Document","subtree","name","href","external","formatLinkHref","attribs","pathname","pages","createElement","NavContentLink","attributesToProps","domToReact","children","validateComponentName","console","warn","props","Component","htmlparser2","lowerCaseTags","lowerCaseAttributeNames","parse","uri","targetProvider","config","publicDirs","robin","codeQueue","insertedCodeKeys","DocumentToken","token","isNewCodeToken","tabsData","tabsKey","Object","keys","sort","join","isInsertedKey","includes","push","Fragment","Tabs","type","insertStyles","blockKey","Array","isArray","trim","childTokens","componentName","RobinComponent","map","t","index","key","depth","predefinedData","find","heading","id","AnchorHeading","component","Heading","undefined","Block","Table","Thead","Tr","header","Th","text","Tbody","rows","row","rowIndex","elem","elemIndex","Td","Hr","Img","src","provider","alt","title","some","every","Paragraph","Strong","Del","Em","blockquoteToken","parseBlockqoute","Blockquote","inlineCode","hightlightMatch","match","lang","CodeBlock","code","inline","CodeSpan","configuration","parseCodeLang","switcher","tabKey","tab","formatId","tabName","toString","element","CodeSection","clone","split","forEach","copy","copyLang","copyTab","copyFileName","copyTabKey","filename","items","i","task","ListComponent","ordered","TaskOrderedList","TaskUnorderedList","start","TaskListItem","defaultChecked","checked","OrderedList","UnorderedList","ListItem","startsWith","endsWith","selfClosed","slice","reduce","acc","cur","_match","value"],"mappings":"gxDA0CO,MAAMA,EAA0C,EAAGC,MAAKC,gBAAeC,MAC1E,MAAMC,EAAuC,CACzC,OAAAC,CAAQC,GACJ,GAAIA,aAAmBC,GAAQD,EAAQE,KAAM,CACzC,MAAMC,SAAEA,EAAQC,OAAEA,GAAWC,EAAcL,EAAQE,MAEnD,OAAOI,gBAACC,EAAQ,CAACJ,SAAUA,EAAUC,OAAQA,EAAQR,WAAYA,EAAYY,SAAY,KAAAX,GAC5F,CAED,KAAM,SAAUG,GAAU,OAAOM,iCAEjC,GAAqB,MAAjBN,EAAQS,MAAgB,YAAaT,EAAS,CAC9C,MAAMU,KAAEA,EAAIC,SAAEA,GAAaC,EAAeZ,E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AQxD,IAAK,KAC1BW,gBAAC+B,EAAa,CAACC,MAAOlC,GAAU"}
|
|
1
|
+
{"version":3,"file":"document.js","sources":["../../../../src/components/elements/article/document.tsx"],"sourcesContent":["import { AnchorHeading } from \"@src/components/blocks/anchor-heading\";\nimport { CodeSection } from \"@src/components/blocks/code-section\";\nimport { NavContentLink } from \"@src/components/blocks/nav-content-link\";\nimport { Block } from \"@src/components/ui/block\";\nimport { Blockquote } from \"@src/components/ui/blockquote\";\nimport { CodeBlock } from \"@src/components/ui/code-block\";\nimport { CodeSpan } from \"@src/components/ui/code-span\";\nimport { Del } from \"@src/components/ui/del\";\nimport { Em } from \"@src/components/ui/em\";\nimport { Heading } from \"@src/components/ui/heading\";\nimport { Hr } from \"@src/components/ui/hr\";\nimport { Img } from \"@src/components/ui/img\";\nimport { ListItem, OrderedList, UnorderedList } from \"@src/components/ui/list\";\nimport { Paragraph } from \"@src/components/ui/paragraph\";\nimport { Strong } from \"@src/components/ui/strong\";\nimport { Table, Tbody, Td, Th, Thead, Tr } from \"@src/components/ui/table\";\nimport { Tabs } from \"@src/components/ui/tabs\";\nimport { TaskListItem, TaskOrderedList, TaskUnorderedList } from \"@src/components/ui/task-list\";\nimport { type BaseProvider } from \"@src/core/providers/base\";\nimport { type Components, type RobinProps } from \"@src/core/types/content\";\nimport parse, { attributesToProps, DOMNode, domToReact, HTMLReactParserOptions, Text } from \"html-react-parser\";\nimport { type Token, type Tokens, type TokensList } from \"marked\";\nimport React from \"react\";\nimport { type BundledLanguage } from \"shiki\";\n\nimport { type PagesType } from \"./types\";\nimport {\n formatId,\n formatLinkHref,\n isNewCodeToken,\n parseBlockqoute,\n parseCodeLang,\n parseMarkdown,\n validateComponentName,\n type AnchorData,\n} from \"./utils\";\n\ninterface DocumentJSXProps extends Omit<ContentProps, \"tokens\" | \"headings\"> {\n raw: string;\n pages?: PagesType;\n}\n\nexport const DocumentJSX: React.FC<DocumentJSXProps> = ({ raw, components, ...baseProps }) => {\n const parseOptions: HTMLReactParserOptions = {\n replace(domNode) {\n if (domNode instanceof Text && domNode.data) {\n const { headings, tokens } = parseMarkdown(domNode.data);\n\n return <Document headings={headings} tokens={tokens} components={components} subtree {...baseProps} />;\n }\n\n if (!(\"name\" in domNode)) return <></>;\n\n if (domNode.name === \"a\" && \"attribs\" in domNode) {\n const { href, external } = formatLinkHref(domNode.attribs.href, baseProps.pathname, baseProps.pages);\n return (\n <NavContentLink {...attributesToProps(domNode.attribs)} href={href} external={external}>\n {domToReact(domNode.children as DOMNode[], parseOptions)}\n </NavContentLink>\n );\n }\n\n if (!validateComponentName(domNode.name)) return domNode;\n\n if (!components || !(domNode.name in components)) {\n console.warn(`Unknown component: \"${domNode.name}\"`);\n return <></>;\n }\n\n const props = \"attribs\" in domNode ? attributesToProps(domNode.attribs) : {};\n const Component = components[domNode.name];\n const children = \"children\" in domNode ? domNode.children : null;\n\n return (\n <Component {...props}>{children ? domToReact(children as DOMNode[], parseOptions) : null}</Component>\n );\n },\n htmlparser2: {\n lowerCaseTags: false,\n lowerCaseAttributeNames: false,\n },\n };\n return parse(raw, parseOptions);\n};\n\nexport type ContentProps = {\n pathname: string;\n components?: Components;\n config?: {\n publicDirs?: string[];\n };\n uri?: string;\n targetProvider?: BaseProvider | null;\n tokens: TokensList;\n headings: AnchorData[];\n subtree?: boolean;\n pages?: PagesType;\n};\n\nexport const Document: React.FC<ContentProps> = ({\n pathname,\n components,\n uri,\n targetProvider,\n tokens,\n headings,\n config = {},\n subtree,\n pages,\n}) => {\n const { publicDirs } = config;\n\n let robin:\n | null\n | { props: RobinProps; childTokens: Token[]; componentName: string; type: \"base\" }\n | { type: \"dummy\" } = null;\n let codeQueue: { [lang: string]: { element: React.ReactNode; tabName: string } } = {};\n const insertedCodeKeys: string[] = [];\n const DocumentToken: React.FC<{ token: Token | Token[] }> = ({ token }) => {\n if (!token) return null;\n\n if (isNewCodeToken(token, codeQueue)) {\n const tabsData = codeQueue;\n codeQueue = {};\n const tabsKey = Object.keys(tabsData).sort().join(\"-\");\n const isInsertedKey = insertedCodeKeys.includes(tabsKey);\n if (!isInsertedKey) insertedCodeKeys.push(tabsKey);\n\n return (\n <>\n <Tabs type=\"code\" tabsData={tabsData} insertStyles={!isInsertedKey} blockKey={tabsKey} />\n <DocumentToken token={token} />\n </>\n );\n }\n\n if (robin) {\n if (!Array.isArray(token) && token.type === \"html\" && token.raw.trim() === \"<!---/robin-->\") {\n if (robin.type === \"dummy\") {\n robin = null;\n return null;\n }\n\n const { componentName, childTokens, props } = robin;\n const RobinComponent = components![componentName];\n robin = null;\n return (\n <RobinComponent {...props}>\n <DocumentToken token={childTokens} />\n </RobinComponent>\n );\n } else {\n if (robin.type === \"dummy\") return null;\n\n if (Array.isArray(token)) {\n robin.childTokens.push(...token);\n } else {\n robin.childTokens.push(token);\n }\n return null;\n }\n }\n\n if (Array.isArray(token)) {\n return token.map((t, index) => <DocumentToken token={t} key={(t as Tokens.Text).raw + index} />);\n }\n\n switch (token.type) {\n case \"heading\":\n const Component = `h${token.depth}` as \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n const predefinedData = headings.find((heading) => heading.token === token);\n if (predefinedData?.id) {\n return (\n <AnchorHeading component={Component} id={predefinedData.id}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </AnchorHeading>\n );\n } else {\n return (\n <Heading component={Component} id={token.depth === 1 ? \"main-content\" : undefined}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </Heading>\n );\n }\n case \"table\":\n return (\n <Block>\n <Table>\n <Thead>\n <Tr>\n {token.header.map((t: Tokens.Text, index: number) => (\n <Th key={t.text + index}>\n {t.tokens ? <DocumentToken token={t.tokens} /> : t.text}\n </Th>\n ))}\n </Tr>\n </Thead>\n <Tbody>\n {token.rows.map((row: Tokens.Text[], rowIndex: number) => (\n <Tr key={rowIndex}>\n {row.map((elem, elemIndex) => (\n <Td key={elem.text + elemIndex}>\n {elem.tokens ? <DocumentToken token={elem.tokens} /> : elem.text}\n </Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </Table>\n </Block>\n );\n case \"link\":\n const { href, external } = formatLinkHref(token.href, pathname, pages);\n\n return (\n <NavContentLink href={href} external={external}>\n {token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}\n </NavContentLink>\n );\n case \"space\":\n return null;\n case \"hr\":\n return <Hr />;\n case \"image\":\n return (\n <Img\n src={token.href}\n publicDirs={publicDirs}\n provider={targetProvider}\n uri={uri}\n alt={token.title || \"\"}\n />\n );\n case \"paragraph\":\n if (subtree) return token.tokens ? <DocumentToken token={token.tokens} /> : token.raw;\n if (\n token.tokens?.some((t) => t.type === \"html\") &&\n token.tokens?.every((t) => t.type === \"html\" || t.type === \"text\" || t.raw === \"\\n\")\n ) {\n return <DocumentToken token={{ ...token, type: \"html\" }} />;\n }\n\n return <Paragraph>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Paragraph>;\n case \"strong\":\n return <Strong>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Strong>;\n case \"del\":\n return <Del>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Del>;\n case \"em\":\n return <Em>{token.tokens ? <DocumentToken token={token.tokens} /> : token.raw}</Em>;\n case \"blockquote\":\n const { token: blockquoteToken, type } = parseBlockqoute(token);\n\n return (\n <Blockquote type={type}>\n {blockquoteToken.tokens ? (\n <DocumentToken token={blockquoteToken.tokens} />\n ) : (\n blockquoteToken.raw\n )}\n </Blockquote>\n );\n case \"codespan\":\n const inlineCode = token.raw.replace(/^`|`$/g, \"\");\n const hightlightMatch = inlineCode.match(/(.+){:([a-zA-Z]+)}$/);\n if (hightlightMatch) {\n const [, raw, lang] = hightlightMatch;\n return <CodeBlock code={raw} lang={lang as BundledLanguage} inline />;\n }\n\n return <CodeSpan code={inlineCode} />;\n case \"code\":\n const { lang, configuration } = parseCodeLang(token.lang);\n if (configuration.switcher && lang) {\n const tabKey = typeof configuration.tab === \"string\" ? formatId(configuration.tab) : lang;\n codeQueue[tabKey] = {\n tabName: (configuration.tab || lang).toString(),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n element: <CodeSection lang={lang as any} code={token.text} {...configuration} />,\n };\n\n if (typeof configuration.clone === \"string\") {\n const copies = configuration.clone.split(\",\");\n\n copies.forEach((copy) => {\n const [copyLang, copyTab, copyFileName] = copy.split(\"|\");\n const copyTabKey = typeof copyTab === \"string\" ? formatId(copyTab) : copyLang;\n\n codeQueue[copyTabKey] = {\n tabName: (copyTab || copyLang).toString(),\n element: (\n <CodeSection\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n lang={copyLang as any}\n code={token.text}\n {...configuration}\n filename={copyFileName || (configuration.filename as string)}\n />\n ),\n };\n });\n }\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <CodeSection lang={lang as any} code={token.text} {...configuration} />;\n case \"escape\":\n return token.text;\n case \"list\":\n const isTaskList = token.items.every((i: Tokens.ListItem) => i.task);\n if (isTaskList) {\n const ListComponent = token.ordered ? TaskOrderedList : TaskUnorderedList;\n return (\n <ListComponent start={token.start}>\n {token.items.map((elem: Tokens.ListItem, index: number) => {\n const childTokens =\n elem.tokens?.length === 1 && elem.tokens[0].type === \"paragraph\"\n ? elem.tokens[0].tokens\n : elem.tokens;\n\n return (\n <TaskListItem key={elem.raw + index} defaultChecked={elem.checked}>\n {childTokens ? <DocumentToken token={childTokens} /> : elem.raw}\n </TaskListItem>\n );\n })}\n </ListComponent>\n );\n }\n\n const ListComponent = token.ordered ? OrderedList : UnorderedList;\n return (\n <ListComponent start={token.start}>\n {token.items.map((elem: Tokens.ListItem, index: number) => {\n const childTokens =\n elem.tokens?.length === 1 && elem.tokens[0].type === \"paragraph\"\n ? elem.tokens[0].tokens\n : elem.tokens;\n return (\n <ListItem key={elem.raw + index}>\n {childTokens ? <DocumentToken token={childTokens} /> : elem.raw}\n </ListItem>\n );\n })}\n </ListComponent>\n );\n case \"html\":\n const text = token.raw.trim();\n\n if (text.startsWith(\"<!---robin\") && text.endsWith(\"-->\")) {\n const selfClosed = text.endsWith(\"/-->\");\n const componentName = text.match(/<!---robin ([\\w]+)/)?.[1];\n\n if (!componentName) {\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n\n if (!validateComponentName(componentName)) {\n console.warn(\n `\"${componentName}\" is using incorrect casing. Use PascalCase for Robin components`,\n );\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n\n if (!components || !(componentName in components)) {\n console.warn(`Unknown component: \"${componentName}\"`);\n if (!selfClosed) robin = { type: \"dummy\" };\n return null;\n }\n const propRows = text.split(/\\r?\\n/).slice(1, -1);\n const props = propRows.reduce<{ [key: string]: string | true }>((acc, cur) => {\n const [_match, key, value] = cur.match(/^([\\w]+)(?:=\"(.+)\")?$/) || [];\n\n if (!_match) {\n console.warn(`Invalid component attribute: \"${cur}\"`);\n return acc;\n }\n\n acc[key] = value ?? true;\n return acc;\n }, {});\n\n if (selfClosed) {\n const Component = components[componentName as keyof typeof components];\n return <Component {...props} />;\n }\n\n robin = { props, componentName, childTokens: [], type: \"base\" };\n return null;\n }\n\n return (\n <DocumentJSX\n raw={token.raw}\n components={components}\n config={config}\n targetProvider={targetProvider}\n pathname={pathname}\n uri={uri}\n pages={pages}\n />\n );\n case \"text\":\n if (\"tokens\" in token) {\n return <DocumentToken token={token.tokens || []} />;\n }\n return token.raw;\n case \"def\":\n return null;\n default:\n if (!token.type && \"raw\" in token) return token.raw;\n\n console.warn(`Unknown token ${token.type}`, token);\n return null;\n }\n };\n\n tokens.push({ type: \"text\", raw: \"\" });\n return <DocumentToken token={tokens} />;\n};\n"],"names":["DocumentJSX","raw","components","baseProps","parseOptions","replace","domNode","Text","data","headings","tokens","parseMarkdown","React","Document","subtree","name","href","external","formatLinkHref","attribs","pathname","pages","createElement","NavContentLink","attributesToProps","domToReact","children","validateComponentName","console","warn","props","Component","htmlparser2","lowerCaseTags","lowerCaseAttributeNames","parse","uri","targetProvider","config","publicDirs","robin","codeQueue","insertedCodeKeys","DocumentToken","token","isNewCodeToken","tabsData","tabsKey","Object","keys","sort","join","isInsertedKey","includes","push","Fragment","Tabs","type","insertStyles","blockKey","Array","isArray","trim","childTokens","componentName","RobinComponent","map","t","index","key","depth","predefinedData","find","heading","id","AnchorHeading","component","Heading","undefined","Block","Table","Thead","Tr","header","Th","text","Tbody","rows","row","rowIndex","elem","elemIndex","Td","Hr","Img","src","provider","alt","title","some","every","Paragraph","Strong","Del","Em","blockquoteToken","parseBlockqoute","Blockquote","inlineCode","hightlightMatch","match","lang","CodeBlock","code","inline","CodeSpan","configuration","parseCodeLang","switcher","tabKey","tab","formatId","tabName","toString","element","CodeSection","clone","split","forEach","copy","copyLang","copyTab","copyFileName","copyTabKey","filename","items","i","task","ListComponent","ordered","TaskOrderedList","TaskUnorderedList","start","length","TaskListItem","defaultChecked","checked","OrderedList","UnorderedList","ListItem","startsWith","endsWith","selfClosed","slice","reduce","acc","cur","_match","value"],"mappings":"gxDA0CO,MAAMA,EAA0C,EAAGC,MAAKC,gBAAeC,MAC1E,MAAMC,EAAuC,CACzC,OAAAC,CAAQC,GACJ,GAAIA,aAAmBC,GAAQD,EAAQE,KAAM,CACzC,MAAMC,SAAEA,EAAQC,OAAEA,GAAWC,EAAcL,EAAQE,MAEnD,OAAOI,gBAACC,EAAQ,CAACJ,SAAUA,EAAUC,OAAQA,EAAQR,WAAYA,EAAYY,SAAO,KAAKX,GAC7F,CAEA,KAAM,SAAUG,GAAU,OAAOM,iCAEjC,GAAqB,MAAjBN,EAAQS,MAAgB,YAAaT,EAAS,CAC9C,MAAMU,KAAEA,EAAIC,SAAEA,GAAaC,EAAeZ,EAAQa,QAAQH,KAAMb,EAAUiB,SAAUjB,EAAUkB,OAC9F,OACIT,EAAAU,cAACC,EAAc,IAAKC,EAAkBlB,EAAQa,SAAUH,KAAMA,EAAMC,SAAUA,GACzEQ,EAAWnB,EAAQoB,SAAuBtB,GAGvD,CAEA,IAAKuB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ACrC,QAKnB,OADAlC,EAAO4C,KAAK,CAAEG,KAAM,OAAQxD,IAAK,KAC1BW,gBAAC+B,EAAa,CAACC,MAAOlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/article/index.tsx"],"sourcesContent":["import \"./article.scss\";\nimport React from \"react\";\n\nimport { type Components } from \"@src/core/types/content\";\nimport { type BaseProvider } from \"@src/core/providers/base\";\nimport { loadContent } from \"@src/core/utils/load-content\";\nimport { ContentsProvider } from \"@src/components/contexts/contents/provider\";\nimport { Contents, type ContentsProps } from \"@src/components/blocks/contents\";\nimport { Breadcrumbs, type BreadcrumbsProps } from \"@src/components/blocks/breadcrumbs\";\nimport { Pagination, type PaginationProps } from \"@src/components/blocks/pagination\";\nimport { parseMarkdown } from \"./utils\";\nimport { Document } from \"./document\";\nimport { LastModified } from \"@src/components/blocks/last-modified\";\n\nexport type ContentProps = {\n title: string;\n components?: Components;\n config?: {\n publicDirs?: string[];\n };\n provider?: BaseProvider;\n pathname: string;\n pages?: { clientPath: string; origPath: string }[];\n translations?: {\n /** Last modified on */\n lastModifiedOn?: string;\n };\n} & ({ content: string; uri?: undefined } | { uri: string; content?: undefined });\n\nexport type ArticleProps = Partial<PaginationProps> &\n Partial<BreadcrumbsProps> &\n Omit<ContentsProps, \"headings\"> &\n ContentProps;\n\nexport const Article: React.FC<ArticleProps> = async ({\n components,\n content,\n uri,\n config = {},\n provider,\n hideContents,\n editUri: editUriProp,\n pathname,\n title,\n breadcrumbs,\n prev,\n next,\n pages = [],\n translations,\n}) => {\n const {\n lastModifiedOn = \"Last modified on\",\n editOnService,\n onThisPage,\n next: nextTranslation,\n previous,\n } = translations || {};\n const { data, provider: targetProvider } =\n content || !uri ? { data: content, provider: null } : await loadContent(uri, provider);\n\n if (!data) {\n throw new Error(\"Robindoc: Please provide content or valid uri\");\n }\n\n const { headings, tokens } = parseMarkdown(data);\n const editUri = uri && targetProvider && (await targetProvider.getEditUri(uri));\n const lastModified = uri && targetProvider && (await targetProvider.getLastModifiedDate(uri));\n\n return (\n <ContentsProvider>\n {breadcrumbs && breadcrumbs.length > 0 && <Breadcrumbs breadcrumbs={breadcrumbs} title={title} />}\n <Contents\n editUri={editUriProp === null ? null : editUriProp || editUri}\n hideContents={hideContents}\n headings={headings}\n translations={{ editOnService, onThisPage }}\n />\n <div className=\"r-article\">\n <Document\n headings={headings}\n tokens={tokens}\n pages={pages}\n components={components}\n config={config}\n targetProvider={targetProvider}\n pathname={pathname}\n uri={uri}\n />\n {lastModified && <LastModified date={lastModified}>{lastModifiedOn}</LastModified>}\n </div>\n {(prev || next) && (\n <Pagination prev={prev} next={next} translations={{ next: nextTranslation, previous }} />\n )}\n </ContentsProvider>\n );\n};\n"],"names":["Article","async","components","content","uri","config","provider","hideContents","editUri","editUriProp","pathname","title","breadcrumbs","prev","next","pages","translations","lastModifiedOn","editOnService","onThisPage","nextTranslation","previous","data","targetProvider","loadContent","Error","headings","tokens","parseMarkdown","getEditUri","lastModified","getLastModifiedDate","React","ContentsProvider","length","createElement","Breadcrumbs","Contents","className","Document","LastModified","date","Pagination"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/article/index.tsx"],"sourcesContent":["import \"./article.scss\";\nimport React from \"react\";\n\nimport { type Components } from \"@src/core/types/content\";\nimport { type BaseProvider } from \"@src/core/providers/base\";\nimport { loadContent } from \"@src/core/utils/load-content\";\nimport { ContentsProvider } from \"@src/components/contexts/contents/provider\";\nimport { Contents, type ContentsProps } from \"@src/components/blocks/contents\";\nimport { Breadcrumbs, type BreadcrumbsProps } from \"@src/components/blocks/breadcrumbs\";\nimport { Pagination, type PaginationProps } from \"@src/components/blocks/pagination\";\nimport { parseMarkdown } from \"./utils\";\nimport { Document } from \"./document\";\nimport { LastModified } from \"@src/components/blocks/last-modified\";\n\nexport type ContentProps = {\n title: string;\n components?: Components;\n config?: {\n publicDirs?: string[];\n };\n provider?: BaseProvider;\n pathname: string;\n pages?: { clientPath: string; origPath: string }[];\n translations?: {\n /** Last modified on */\n lastModifiedOn?: string;\n };\n} & ({ content: string; uri?: undefined } | { uri: string; content?: undefined });\n\nexport type ArticleProps = Partial<PaginationProps> &\n Partial<BreadcrumbsProps> &\n Omit<ContentsProps, \"headings\"> &\n ContentProps;\n\nexport const Article: React.FC<ArticleProps> = async ({\n components,\n content,\n uri,\n config = {},\n provider,\n hideContents,\n editUri: editUriProp,\n pathname,\n title,\n breadcrumbs,\n prev,\n next,\n pages = [],\n translations,\n}) => {\n const {\n lastModifiedOn = \"Last modified on\",\n editOnService,\n onThisPage,\n next: nextTranslation,\n previous,\n } = translations || {};\n const { data, provider: targetProvider } =\n content || !uri ? { data: content, provider: null } : await loadContent(uri, provider);\n\n if (!data) {\n throw new Error(\"Robindoc: Please provide content or valid uri\");\n }\n\n const { headings, tokens } = parseMarkdown(data);\n const editUri = uri && targetProvider && (await targetProvider.getEditUri(uri));\n const lastModified = uri && targetProvider && (await targetProvider.getLastModifiedDate(uri));\n\n return (\n <ContentsProvider>\n {breadcrumbs && breadcrumbs.length > 0 && <Breadcrumbs breadcrumbs={breadcrumbs} title={title} />}\n <Contents\n editUri={editUriProp === null ? null : editUriProp || editUri}\n hideContents={hideContents}\n headings={headings}\n translations={{ editOnService, onThisPage }}\n />\n <div className=\"r-article\">\n <Document\n headings={headings}\n tokens={tokens}\n pages={pages}\n components={components}\n config={config}\n targetProvider={targetProvider}\n pathname={pathname}\n uri={uri}\n />\n {lastModified && <LastModified date={lastModified}>{lastModifiedOn}</LastModified>}\n </div>\n {(prev || next) && (\n <Pagination prev={prev} next={next} translations={{ next: nextTranslation, previous }} />\n )}\n </ContentsProvider>\n );\n};\n"],"names":["Article","async","components","content","uri","config","provider","hideContents","editUri","editUriProp","pathname","title","breadcrumbs","prev","next","pages","translations","lastModifiedOn","editOnService","onThisPage","nextTranslation","previous","data","targetProvider","loadContent","Error","headings","tokens","parseMarkdown","getEditUri","lastModified","getLastModifiedDate","React","ContentsProvider","length","createElement","Breadcrumbs","Contents","className","Document","LastModified","date","Pagination"],"mappings":"6eAkCO,MAAMA,EAAkCC,OAC3CC,aACAC,UACAC,MACAC,SAAS,CAAA,EACTC,WACAC,eACAC,QAASC,EACTC,WACAC,QACAC,cACAC,OACAC,OACAC,QAAQ,GACRC,mBAEA,MAAMC,eACFA,EAAiB,mBAAkBC,cACnCA,EAAaC,WACbA,EACAL,KAAMM,EAAeC,SACrBA,GACAL,GAAgB,CAAA,GACdM,KAAEA,EAAMhB,SAAUiB,GACpBpB,IAAYC,EAAM,CAAEkB,KAAMnB,EAASG,SAAU,YAAekB,EAAYpB,EAAKE,GAEjF,IAAKgB,EACD,MAAM,IAAIG,MAAM,iDAGpB,MAAMC,SAAEA,EAAQC,OAAEA,GAAWC,EAAcN,GACrCd,EAAUJ,GAAOmB,SAAyBA,EAAeM,WAAWzB,GACpE0B,EAAe1B,GAAOmB,SAAyBA,EAAeQ,oBAAoB3B,GAExF,OACI4B,gBAACC,EAAgB,KACZrB,GAAeA,EAAYsB,OAAS,GAAKF,EAAAG,cAACC,EAAW,CAACxB,YAAaA,EAAaD,MAAOA,IACxFqB,EAAAG,cAACE,EAAQ,CACL7B,QAAyB,OAAhBC,EAAuB,KAAOA,GAAeD,EACtDD,aAAcA,EACdmB,SAAUA,EACVV,aAAc,CAAEE,gBAAeC,gBAEnCa,EAAAG,cAAA,MAAA,CAAKG,UAAU,aACXN,EAAAG,cAACI,EAAQ,CACLb,SAAUA,EACVC,OAAQA,EACRZ,MAAOA,EACPb,WAAYA,EACZG,OAAQA,EACRkB,eAAgBA,EAChBb,SAAUA,EACVN,IAAKA,IAER0B,GAAgBE,EAAAG,cAACK,EAAY,CAACC,KAAMX,GAAeb,KAEtDJ,GAAQC,IACNkB,EAAAG,cAACO,EAAU,CAAC7B,KAAMA,EAAMC,KAAMA,EAAME,aAAc,CAAEF,KAAMM,EAAiBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/elements/article/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGxD,OAAO,EAAE,KAAK,cAAc,EAAE,4BAAsC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/elements/article/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGxD,OAAO,EAAE,KAAK,cAAc,EAAE,4BAAsC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM;;;CAmB5C,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,YAEjD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM;;;;;CAmBxC,CAAC;AAEF,eAAO,MAAM,cAAc,GACvB,OAAO,KAAK,GAAG,KAAK,EAAE,EACtB,WAAW;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,YAa/E,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE,QAAQ,SAAS;;;CAiB/E,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO;;;;;;;;;;;UAoBjC,cAAc;;;;CAKrD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"github-slugger";import e from"gray-matter";import{lexer as r}from"marked";import{join as n,dirname as o}from"path";import{parseTokenText as s}from"../../../core/utils/content-tools.js";const i=n=>{const{content:o}=e(n),i=r(o.trim()),a=new t,c=i.reduce((
|
|
1
|
+
import t from"github-slugger";import e from"gray-matter";import{lexer as r}from"marked";import{join as n,dirname as o}from"path";import{parseTokenText as s}from"../../../core/utils/content-tools.js";const i=n=>{const{content:o}=e(n),i=r(o.trim()),a=new t,c=i.reduce((t,e)=>{if("heading"===e.type&&(2===e.depth||3===e.depth)){const r=s(e);t.push({title:r,id:a.slug(r),token:e,nested:3===e.depth})}return t},[]);return{tokens:i,headings:c}},a=t=>t.toLowerCase().replace(/\W/g,"_").replace(/_+/g,"_"),c=t=>/^[A-Z][a-zA-Z0-9]+$/.test(t),g=t=>{let e={},r=t;const n=t.match(/[a-z]+=("[^"]+"|'[^']+'|[^ ]+)|[a-z]+/g);if(Array.isArray(n)){const[t,...o]=n;r=t,e=o.reduce((t,e)=>{const[r,...n]=e.split("=");return t[r]=!n||(0===n.length||n.join("=").replace(/(^["']|['"]$)/g,"")),t},{})}return{lang:r,configuration:e}},l=(t,e)=>{if(Array.isArray(t)||!Object.keys(e).length)return!1;if("code"===t.type){const{lang:r,configuration:n}=g(t.lang);if(e["string"==typeof n.tab?a(n.tab):r]||!n.switcher)return!0}return"space"!==t.type&&"code"!==t.type},p=(t,e,r)=>{let s=t;const i=/^(https?:\/\/|\/)/.test(t);if(r&&!i){const i=r.find(t=>t.clientPath===e);if(i){const e=n(o(i.origPath),t).replace(/\\/g,"/"),a=r.find(t=>t.origPath===e);a&&(s=a?.clientPath)}}return{href:s,external:i}},u=t=>{const e=t.raw.match(/^> \[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\n/);if(e){const[r,n]=e,o={...t,raw:t.raw.substring(r.length)};if(o.tokens){const t={...o.tokens[0]};if(t.raw=t.raw.substring(n.length+4),t.text=t.text.substring(n.length+4),t.tokens[0]){const e={...t.tokens[0]};e.raw=e.raw.substring(n.length+4),e.text=e.text.substring(n.length+4),t.tokens[0]=e}o.tokens[0]=t}return{token:o,type:n.toLowerCase()}}return{token:t,type:null}};export{a as formatId,p as formatLinkHref,l as isNewCodeToken,u as parseBlockqoute,g as parseCodeLang,i as parseMarkdown,c as validateComponentName};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/components/elements/article/utils.ts"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nimport matter from \"gray-matter\";\nimport { lexer, type Tokens, type Token } from \"marked\";\nimport { dirname, join } from \"path\";\n\nimport { type BlockquoteType } from \"@src/components/ui/blockquote\";\nimport { parseTokenText } from \"@src/core/utils/content-tools\";\n\nimport { type PagesType } from \"./types\";\n\nexport type AnchorData = {\n title: string;\n id: string;\n nested: boolean;\n token: Token;\n};\n\nexport const parseMarkdown = (content: string) => {\n const { content: matterContent } = matter(content);\n const tokens = lexer(matterContent.trim());\n\n const slugger = new GithubSlugger();\n const headings = tokens.reduce<AnchorData[]>((acc, token) => {\n if (token.type === \"heading\" && (token.depth === 2 || token.depth === 3)) {\n const title = parseTokenText(token);\n acc.push({\n title,\n id: slugger.slug(title),\n token,\n nested: token.depth === 3,\n });\n }\n return acc;\n }, []);\n\n return { tokens, headings };\n};\n\nexport const formatId = (raw: string) => {\n return raw.toLowerCase().replace(/\\W/g, \"_\").replace(/_+/g, \"_\");\n};\n\nexport const validateComponentName = (name: string) => {\n return /^[A-Z][a-zA-Z0-9]+$/.test(name);\n};\n\nexport const parseCodeLang = (raw: string) => {\n let configuration: { [key: string]: string | boolean } = {};\n let lang: string = raw;\n\n const match = raw.match(/[a-z]+=(\"[^\"]+\"|'[^']+'|[^ ]+)|[a-z]+/g);\n if (Array.isArray(match)) {\n const [language, ...modifiers] = match as string[];\n lang = language;\n configuration = modifiers.reduce<{ [key: string]: string | boolean }>((acc, cur) => {\n const [key, ...value] = cur.split(\"=\");\n if (value) {\n acc[key] = value.length === 0 ? true : value.join(\"=\").replace(/(^[\"']|['\"]$)/g, \"\");\n } else {\n acc[key] = true;\n }\n return acc;\n }, {});\n }\n return { lang, configuration };\n};\n\nexport const isNewCodeToken = (\n token: Token | Token[],\n codeQueue: { [lang: string]: { element: React.ReactNode; tabName: string } },\n) => {\n if (Array.isArray(token) || !Object.keys(codeQueue).length) return false;\n\n if (token.type === \"code\") {\n const { lang, configuration } = parseCodeLang(token.lang);\n const tabKey = typeof configuration.tab === \"string\" ? formatId(configuration.tab) : lang;\n if (codeQueue[tabKey] || !configuration.switcher) return true;\n }\n\n if (token.type !== \"space\" && token.type !== \"code\") return true;\n\n return false;\n};\n\nexport const formatLinkHref = (href: string, pathname: string, pages?: PagesType) => {\n let finalHref: string = href;\n const external = /^(https?:\\/\\/|\\/)/.test(href);\n\n if (pages && !external) {\n const currentPageData = pages.find((item) => item.clientPath === pathname);\n\n if (currentPageData) {\n const linkOrigPath = join(dirname(currentPageData.origPath), href).replace(/\\\\/g, \"/\");\n const linkData = pages.find((item) => item.origPath === linkOrigPath);\n\n if (linkData) {\n finalHref = linkData?.clientPath;\n }\n }\n }\n return { href: finalHref, external };\n};\n\nexport const parseBlockqoute = (token: Tokens.Blockquote | Tokens.Generic) => {\n const typeMatch = token.raw.match(/^> \\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\n/);\n if (typeMatch) {\n const [raw, type] = typeMatch;\n const newToken = { ...token, raw: token.raw.substring(raw.length) };\n if (newToken.tokens) {\n const firstToken = { ...newToken.tokens[0] } as Tokens.Paragraph;\n firstToken.raw = firstToken.raw.substring(type.length + 4);\n firstToken.text = firstToken.text.substring(type.length + 4);\n if (firstToken.tokens[0]) {\n const firstSubtoken = { ...firstToken.tokens[0] } as Tokens.Paragraph;\n firstSubtoken.raw = firstSubtoken.raw.substring(type.length + 4);\n firstSubtoken.text = firstSubtoken.text.substring(type.length + 4);\n firstToken.tokens[0] = firstSubtoken;\n }\n newToken.tokens[0] = firstToken;\n }\n\n return {\n token: newToken,\n type: type.toLowerCase() as BlockquoteType,\n };\n }\n\n return { token, type: null };\n};\n"],"names":["parseMarkdown","content","matterContent","matter","tokens","lexer","trim","slugger","GithubSlugger","headings","reduce","acc","token","type","depth","title","parseTokenText","push","id","slug","nested","formatId","raw","toLowerCase","replace","validateComponentName","name","test","parseCodeLang","configuration","lang","match","Array","isArray","language","modifiers","cur","key","value","split","length","join","isNewCodeToken","codeQueue","Object","keys","tab","switcher","formatLinkHref","href","pathname","pages","finalHref","external","currentPageData","find","item","clientPath","linkOrigPath","dirname","origPath","linkData","parseBlockqoute","typeMatch","newToken","substring","firstToken","text","firstSubtoken"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/elements/article/utils.ts"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nimport matter from \"gray-matter\";\nimport { lexer, type Tokens, type Token } from \"marked\";\nimport { dirname, join } from \"path\";\n\nimport { type BlockquoteType } from \"@src/components/ui/blockquote\";\nimport { parseTokenText } from \"@src/core/utils/content-tools\";\n\nimport { type PagesType } from \"./types\";\n\nexport type AnchorData = {\n title: string;\n id: string;\n nested: boolean;\n token: Token;\n};\n\nexport const parseMarkdown = (content: string) => {\n const { content: matterContent } = matter(content);\n const tokens = lexer(matterContent.trim());\n\n const slugger = new GithubSlugger();\n const headings = tokens.reduce<AnchorData[]>((acc, token) => {\n if (token.type === \"heading\" && (token.depth === 2 || token.depth === 3)) {\n const title = parseTokenText(token);\n acc.push({\n title,\n id: slugger.slug(title),\n token,\n nested: token.depth === 3,\n });\n }\n return acc;\n }, []);\n\n return { tokens, headings };\n};\n\nexport const formatId = (raw: string) => {\n return raw.toLowerCase().replace(/\\W/g, \"_\").replace(/_+/g, \"_\");\n};\n\nexport const validateComponentName = (name: string) => {\n return /^[A-Z][a-zA-Z0-9]+$/.test(name);\n};\n\nexport const parseCodeLang = (raw: string) => {\n let configuration: { [key: string]: string | boolean } = {};\n let lang: string = raw;\n\n const match = raw.match(/[a-z]+=(\"[^\"]+\"|'[^']+'|[^ ]+)|[a-z]+/g);\n if (Array.isArray(match)) {\n const [language, ...modifiers] = match as string[];\n lang = language;\n configuration = modifiers.reduce<{ [key: string]: string | boolean }>((acc, cur) => {\n const [key, ...value] = cur.split(\"=\");\n if (value) {\n acc[key] = value.length === 0 ? true : value.join(\"=\").replace(/(^[\"']|['\"]$)/g, \"\");\n } else {\n acc[key] = true;\n }\n return acc;\n }, {});\n }\n return { lang, configuration };\n};\n\nexport const isNewCodeToken = (\n token: Token | Token[],\n codeQueue: { [lang: string]: { element: React.ReactNode; tabName: string } },\n) => {\n if (Array.isArray(token) || !Object.keys(codeQueue).length) return false;\n\n if (token.type === \"code\") {\n const { lang, configuration } = parseCodeLang(token.lang);\n const tabKey = typeof configuration.tab === \"string\" ? formatId(configuration.tab) : lang;\n if (codeQueue[tabKey] || !configuration.switcher) return true;\n }\n\n if (token.type !== \"space\" && token.type !== \"code\") return true;\n\n return false;\n};\n\nexport const formatLinkHref = (href: string, pathname: string, pages?: PagesType) => {\n let finalHref: string = href;\n const external = /^(https?:\\/\\/|\\/)/.test(href);\n\n if (pages && !external) {\n const currentPageData = pages.find((item) => item.clientPath === pathname);\n\n if (currentPageData) {\n const linkOrigPath = join(dirname(currentPageData.origPath), href).replace(/\\\\/g, \"/\");\n const linkData = pages.find((item) => item.origPath === linkOrigPath);\n\n if (linkData) {\n finalHref = linkData?.clientPath;\n }\n }\n }\n return { href: finalHref, external };\n};\n\nexport const parseBlockqoute = (token: Tokens.Blockquote | Tokens.Generic) => {\n const typeMatch = token.raw.match(/^> \\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\n/);\n if (typeMatch) {\n const [raw, type] = typeMatch;\n const newToken = { ...token, raw: token.raw.substring(raw.length) };\n if (newToken.tokens) {\n const firstToken = { ...newToken.tokens[0] } as Tokens.Paragraph;\n firstToken.raw = firstToken.raw.substring(type.length + 4);\n firstToken.text = firstToken.text.substring(type.length + 4);\n if (firstToken.tokens[0]) {\n const firstSubtoken = { ...firstToken.tokens[0] } as Tokens.Paragraph;\n firstSubtoken.raw = firstSubtoken.raw.substring(type.length + 4);\n firstSubtoken.text = firstSubtoken.text.substring(type.length + 4);\n firstToken.tokens[0] = firstSubtoken;\n }\n newToken.tokens[0] = firstToken;\n }\n\n return {\n token: newToken,\n type: type.toLowerCase() as BlockquoteType,\n };\n }\n\n return { token, type: null };\n};\n"],"names":["parseMarkdown","content","matterContent","matter","tokens","lexer","trim","slugger","GithubSlugger","headings","reduce","acc","token","type","depth","title","parseTokenText","push","id","slug","nested","formatId","raw","toLowerCase","replace","validateComponentName","name","test","parseCodeLang","configuration","lang","match","Array","isArray","language","modifiers","cur","key","value","split","length","join","isNewCodeToken","codeQueue","Object","keys","tab","switcher","formatLinkHref","href","pathname","pages","finalHref","external","currentPageData","find","item","clientPath","linkOrigPath","dirname","origPath","linkData","parseBlockqoute","typeMatch","newToken","substring","firstToken","text","firstSubtoken"],"mappings":"uMAiBO,MAAMA,EAAiBC,IAC1B,MAAQA,QAASC,GAAkBC,EAAOF,GACpCG,EAASC,EAAMH,EAAcI,QAE7BC,EAAU,IAAIC,EACdC,EAAWL,EAAOM,OAAqB,CAACC,EAAKC,KAC/C,GAAmB,YAAfA,EAAMC,OAAuC,IAAhBD,EAAME,OAA+B,IAAhBF,EAAME,OAAc,CACtE,MAAMC,EAAQC,EAAeJ,GAC7BD,EAAIM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B,EAAQL,EAAgBM,UAAWX,GAAMzB,QAAQ,MAAO,KAC5EqC,EAAWV,EAAMI,KAAMC,GAASA,EAAKI,WAAaF,GAEpDG,IACAT,EAAYS,GAAUJ,WAE9B,CACJ,CACA,MAAO,CAAER,KAAMG,EAAWC,aAGjBS,EAAmBlD,IAC5B,MAAMmD,EAAYnD,EAAMU,IAAIS,MAAM,kDAClC,GAAIgC,EAAW,CACX,MAAOzC,EAAKT,GAAQkD,EACdC,EAAW,IAAKpD,EAAOU,IAAKV,EAAMU,IAAI2C,UAAU3C,EAAIkB,SAC1D,GAAIwB,EAAS5D,OAAQ,CACjB,MAAM8D,EAAa,IAAKF,EAAS5D,OAAO,IAGxC,GAFA8D,EAAW5C,IAAM4C,EAAW5C,IAAI2C,UAAUpD,EAAK2B,OAAS,GACxD0B,EAAWC,KAAOD,EAAWC,KAAKF,UAAUpD,EAAK2B,OAAS,GACtD0B,EAAW9D,OAAO,GAAI,CACtB,MAAMgE,EAAgB,IAAKF,EAAW9D,OAAO,IAC7CgE,EAAc9C,IAAM8C,EAAc9C,IAAI2C,UAAUpD,EAAK2B,OAAS,GAC9D4B,EAAcD,KAAOC,EAAcD,KAAKF,UAAUpD,EAAK2B,OAAS,GAChE0B,EAAW9D,OAAO,GAAKgE,CAC3B,CACAJ,EAAS5D,OAAO,GAAK8D,CACzB,CAEA,MAAO,CACHtD,MAAOoD,EACPnD,KAAMA,EAAKU,cAEnB,CAEA,MAAO,CAAEX,QAAOC,KAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/footer/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { ThemeSwitcher } from \"@src/components/blocks/theme-switcher\";\nimport { Container } from \"@src/components/ui/container\";\n\nimport \"./footer.scss\";\n\nexport type FooterProps = {\n copyright: string;\n hidePoweredBy?: boolean;\n};\n\nexport const Footer: React.FC<FooterProps> = ({ copyright, hidePoweredBy }) => (\n <footer className=\"r-footer\">\n <Container>\n <div className=\"r-footer-row\">\n <div className=\"r-copyright\">{copyright}</div>\n <ThemeSwitcher />\n </div>\n {!hidePoweredBy && (\n <div className=\"r-footer-row r-footer-additional\">\n <div className=\"r-powered\">\n Powered by{\" \"}\n <a\n href=\"https://robindoc.com\"\n className=\"r-powered-link\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n ROBINDOC\n </a>\n </div>\n </div>\n )}\n </Container>\n </footer>\n);\n"],"names":["Footer","copyright","hidePoweredBy","React","createElement","className","Container","ThemeSwitcher","href","target","rel"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/footer/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { ThemeSwitcher } from \"@src/components/blocks/theme-switcher\";\nimport { Container } from \"@src/components/ui/container\";\n\nimport \"./footer.scss\";\n\nexport type FooterProps = {\n copyright: string;\n hidePoweredBy?: boolean;\n};\n\nexport const Footer: React.FC<FooterProps> = ({ copyright, hidePoweredBy }) => (\n <footer className=\"r-footer\">\n <Container>\n <div className=\"r-footer-row\">\n <div className=\"r-copyright\">{copyright}</div>\n <ThemeSwitcher />\n </div>\n {!hidePoweredBy && (\n <div className=\"r-footer-row r-footer-additional\">\n <div className=\"r-powered\">\n Powered by{\" \"}\n <a\n href=\"https://robindoc.com\"\n className=\"r-powered-link\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n ROBINDOC\n </a>\n </div>\n </div>\n )}\n </Container>\n </footer>\n);\n"],"names":["Footer","copyright","hidePoweredBy","React","createElement","className","Container","ThemeSwitcher","href","target","rel"],"mappings":"kJAYO,MAAMA,EAAgC,EAAGC,YAAWC,mBACvDC,EAAAC,cAAA,SAAA,CAAQC,UAAU,YACdF,EAAAC,cAACE,EAAS,KACNH,EAAAC,cAAA,MAAA,CAAKC,UAAU,gBACXF,EAAAC,cAAA,MAAA,CAAKC,UAAU,eAAeJ,GAC9BE,EAAAC,cAACG,UAEHL,GACEC,EAAAC,cAAA,MAAA,CAAKC,UAAU,oCACXF,EAAAC,cAAA,MAAA,CAAKC,UAAU,0BACA,IACXF,EAAAC,cAAA,IAAA,CACII,KAAK,uBACLH,UAAU,iBACVI,OAAO,SACPC,IAAI,uBAAqB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"react";import{HeaderMenu as t}from"../../blocks/header-menu/index.js";import{Search as r}from"../../blocks/search/index.js";import{SectionDropdown as a}from"../../blocks/section-dropdown/index.js";import{HeaderSocial as l}from"../../blocks/header-social/index.js";import{Container as s}from"../../ui/container/index.js";import{NavLink as i}from"../../blocks/nav-link/index.js";const n=({logo:n,versions:o,locales:m,links:c=[],git:d,searcher:k,translations:h})=>{const{menu:f,...y}=h||{},p=o?.list.find(
|
|
1
|
+
import e from"react";import{HeaderMenu as t}from"../../blocks/header-menu/index.js";import{Search as r}from"../../blocks/search/index.js";import{SectionDropdown as a}from"../../blocks/section-dropdown/index.js";import{HeaderSocial as l}from"../../blocks/header-social/index.js";import{Container as s}from"../../ui/container/index.js";import{NavLink as i}from"../../blocks/nav-link/index.js";const n=({logo:n,versions:o,locales:m,links:c=[],git:d,searcher:k,translations:h})=>{const{menu:f,...y}=h||{},p=o?.list.find(e=>e.key===o.target),E=p&&p.key!==o?.default?`/${p.key}`:"",u=m?.list.find(e=>e.key===m.target),g=u&&u.key!==m?.default?`/${u.key}`:"";return e.createElement("header",{className:"r-header"},e.createElement(s,{className:"r-header-body"},e.createElement("div",null,e.createElement(i,{href:"/",className:"r-header-logo"},n)),e.createElement(t,{translations:{menu:f}},e.createElement("nav",{className:"r-header-nav"},c.map(t=>e.createElement(i,{href:t.href,className:"r-header-link",targetClassName:"_target",key:t.title},t.title))),e.createElement("div",{className:"r-header-actions"},e.createElement("div",{className:"r-header-sections"},o&&p&&e.createElement(a,{defaultOption:p.key,options:o.list.map(e=>({href:e.href||`${g}${e.key===o.default?"":`/${e.key}`}/`,key:e.key,title:e.title,shortTitle:e.shortTitle}))}),m&&u&&e.createElement(a,{defaultOption:u.key,options:m.list.map(e=>({href:e.href||`${e.key===m.default?"":`/${e.key}`}${E}/`,key:e.key,title:e.title,shortTitle:e.shortTitle}))})),k&&e.createElement(r,{searcher:k,translations:y}))),d&&e.createElement(l,{git:d})))};export{n as Header};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/header/index.tsx"],"sourcesContent":["import \"./header.scss\";\nimport React from \"react\";\nimport { HeaderMenu, type HeaderMenuProps } from \"@src/components/blocks/header-menu\";\nimport { Search, type SearchProps } from \"@src/components/blocks/search\";\nimport { SectionDropdown } from \"@src/components/blocks/section-dropdown\";\nimport { HeaderSocial } from \"@src/components/blocks/header-social\";\nimport { Container } from \"@src/components/ui/container\";\nimport { NavLink } from \"@src/components/blocks/nav-link\";\n\ntype SectionOption = {\n key: string;\n href?: string;\n title: string;\n shortTitle?: string;\n};\n\ntype SectionType = {\n default?: string;\n target: string;\n list: SectionOption[];\n};\n\nexport type HeaderProps = {\n logo: React.ReactElement;\n links?: {\n title: string;\n href: string;\n }[];\n git?: string | { uri: string; logo: React.ElementType };\n versions?: SectionType;\n locales?: SectionType;\n} & HeaderMenuProps &\n SearchProps;\n\nexport const Header: React.FC<HeaderProps> = ({ logo, versions, locales, links = [], git, searcher, translations }) => {\n const { menu, ...searchTranslations } = translations || {};\n const targetVersion = versions?.list.find((version) => version.key === versions.target);\n const versionPrefix = !targetVersion || targetVersion.key === versions?.default ? \"\" : `/${targetVersion.key}`;\n const targetLocale = locales?.list.find((locale) => locale.key === locales.target);\n const localePrefix = !targetLocale || targetLocale.key === locales?.default ? \"\" : `/${targetLocale.key}`;\n\n return (\n <header className=\"r-header\">\n <Container className=\"r-header-body\">\n <div>\n <NavLink href=\"/\" className=\"r-header-logo\">\n {logo}\n </NavLink>\n </div>\n <HeaderMenu translations={{ menu }}>\n <nav className=\"r-header-nav\">\n {links.map((link) => (\n <NavLink\n href={link.href}\n className=\"r-header-link\"\n targetClassName=\"_target\"\n key={link.title}\n >\n {link.title}\n </NavLink>\n ))}\n </nav>\n <div className=\"r-header-actions\">\n <div className=\"r-header-sections\">\n {versions && targetVersion && (\n <SectionDropdown\n defaultOption={targetVersion.key}\n options={versions.list.map((version) => ({\n href:\n version.href ||\n `${localePrefix}${version.key === versions.default ? \"\" : `/${version.key}`}/`,\n key: version.key,\n title: version.title,\n shortTitle: version.shortTitle,\n }))}\n />\n )}\n {locales && targetLocale && (\n <SectionDropdown\n defaultOption={targetLocale.key}\n options={locales.list.map((locale) => ({\n href:\n locale.href ||\n `${locale.key === locales.default ? \"\" : `/${locale.key}`}${versionPrefix}/`,\n key: locale.key,\n title: locale.title,\n shortTitle: locale.shortTitle,\n }))}\n />\n )}\n </div>\n {searcher && <Search searcher={searcher} translations={searchTranslations} />}\n </div>\n </HeaderMenu>\n {git && <HeaderSocial git={git} />}\n </Container>\n </header>\n );\n};\n"],"names":["Header","logo","versions","locales","links","git","searcher","translations","menu","searchTranslations","targetVersion","list","find","version","key","target","versionPrefix","default","targetLocale","locale","localePrefix","React","createElement","className","Container","NavLink","href","HeaderMenu","map","link","targetClassName","title","SectionDropdown","defaultOption","options","shortTitle","Search","HeaderSocial"],"mappings":"6YAkCaA,EAAgC,EAAGC,OAAMC,WAAUC,UAASC,QAAQ,GAAIC,MAAKC,WAAUC,mBAChG,MAAMC,KAAEA,KAASC,GAAuBF,GAAgB,CAAA,EAClDG,EAAgBR,GAAUS,KAAKC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/header/index.tsx"],"sourcesContent":["import \"./header.scss\";\nimport React from \"react\";\nimport { HeaderMenu, type HeaderMenuProps } from \"@src/components/blocks/header-menu\";\nimport { Search, type SearchProps } from \"@src/components/blocks/search\";\nimport { SectionDropdown } from \"@src/components/blocks/section-dropdown\";\nimport { HeaderSocial } from \"@src/components/blocks/header-social\";\nimport { Container } from \"@src/components/ui/container\";\nimport { NavLink } from \"@src/components/blocks/nav-link\";\n\ntype SectionOption = {\n key: string;\n href?: string;\n title: string;\n shortTitle?: string;\n};\n\ntype SectionType = {\n default?: string;\n target: string;\n list: SectionOption[];\n};\n\nexport type HeaderProps = {\n logo: React.ReactElement;\n links?: {\n title: string;\n href: string;\n }[];\n git?: string | { uri: string; logo: React.ElementType };\n versions?: SectionType;\n locales?: SectionType;\n} & HeaderMenuProps &\n SearchProps;\n\nexport const Header: React.FC<HeaderProps> = ({ logo, versions, locales, links = [], git, searcher, translations }) => {\n const { menu, ...searchTranslations } = translations || {};\n const targetVersion = versions?.list.find((version) => version.key === versions.target);\n const versionPrefix = !targetVersion || targetVersion.key === versions?.default ? \"\" : `/${targetVersion.key}`;\n const targetLocale = locales?.list.find((locale) => locale.key === locales.target);\n const localePrefix = !targetLocale || targetLocale.key === locales?.default ? \"\" : `/${targetLocale.key}`;\n\n return (\n <header className=\"r-header\">\n <Container className=\"r-header-body\">\n <div>\n <NavLink href=\"/\" className=\"r-header-logo\">\n {logo}\n </NavLink>\n </div>\n <HeaderMenu translations={{ menu }}>\n <nav className=\"r-header-nav\">\n {links.map((link) => (\n <NavLink\n href={link.href}\n className=\"r-header-link\"\n targetClassName=\"_target\"\n key={link.title}\n >\n {link.title}\n </NavLink>\n ))}\n </nav>\n <div className=\"r-header-actions\">\n <div className=\"r-header-sections\">\n {versions && targetVersion && (\n <SectionDropdown\n defaultOption={targetVersion.key}\n options={versions.list.map((version) => ({\n href:\n version.href ||\n `${localePrefix}${version.key === versions.default ? \"\" : `/${version.key}`}/`,\n key: version.key,\n title: version.title,\n shortTitle: version.shortTitle,\n }))}\n />\n )}\n {locales && targetLocale && (\n <SectionDropdown\n defaultOption={targetLocale.key}\n options={locales.list.map((locale) => ({\n href:\n locale.href ||\n `${locale.key === locales.default ? \"\" : `/${locale.key}`}${versionPrefix}/`,\n key: locale.key,\n title: locale.title,\n shortTitle: locale.shortTitle,\n }))}\n />\n )}\n </div>\n {searcher && <Search searcher={searcher} translations={searchTranslations} />}\n </div>\n </HeaderMenu>\n {git && <HeaderSocial git={git} />}\n </Container>\n </header>\n );\n};\n"],"names":["Header","logo","versions","locales","links","git","searcher","translations","menu","searchTranslations","targetVersion","list","find","version","key","target","versionPrefix","default","targetLocale","locale","localePrefix","React","createElement","className","Container","NavLink","href","HeaderMenu","map","link","targetClassName","title","SectionDropdown","defaultOption","options","shortTitle","Search","HeaderSocial"],"mappings":"6YAkCaA,EAAgC,EAAGC,OAAMC,WAAUC,UAASC,QAAQ,GAAIC,MAAKC,WAAUC,mBAChG,MAAMC,KAAEA,KAASC,GAAuBF,GAAgB,CAAA,EAClDG,EAAgBR,GAAUS,KAAKC,KAAMC,GAAYA,EAAQC,MAAQZ,EAASa,QAC1EC,EAAiBN,GAAiBA,EAAcI,MAAQZ,GAAUe,QAAe,IAAIP,EAAcI,MAAvB,GAC5EI,EAAef,GAASQ,KAAKC,KAAMO,GAAWA,EAAOL,MAAQX,EAAQY,QACrEK,EAAgBF,GAAgBA,EAAaJ,MAAQX,GAASc,QAAe,IAAIC,EAAaJ,MAAtB,GAE9E,OACIO,EAAAC,cAAA,SAAA,CAAQC,UAAU,YACdF,EAAAC,cAACE,EAAS,CAACD,UAAU,iBACjBF,EAAAC,cAAA,MAAA,KACID,EAAAC,cAACG,EAAO,CAACC,KAAK,IAAIH,UAAU,iBACvBtB,IAGToB,EAAAC,cAACK,EAAU,CAACpB,aAAc,CAAEC,SACxBa,EAAAC,cAAA,MAAA,CAAKC,UAAU,gBACVnB,EAAMwB,IAAKC,GACRR,EAAAC,cAACG,EAAO,CACJC,KAAMG,EAAKH,KACXH,UAAU,gBACVO,gBAAgB,UAChBhB,IAAKe,EAAKE,OAETF,EAAKE,SAIlBV,EAAAC,cAAA,MAAA,CAAKC,UAAU,oBACXF,EAAAC,cAAA,MAAA,CAAKC,UAAU,qBACVrB,GAAYQ,GACTW,EAAAC,cAACU,EAAe,CACZC,cAAevB,EAAcI,IAC7BoB,QAAShC,EAASS,KAAKiB,IAAKf,IAAO,CAC/Ba,KACIb,EAAQa,MACR,GAAGN,IAAeP,EAAQC,MAAQZ,EAASe,QAAU,GAAK,IAAIJ,EAAQC,SAC1EA,IAAKD,EAAQC,IACbiB,MAAOlB,EAAQkB,MACfI,WAAYtB,EAAQsB,gBAI/BhC,GAAWe,GACRG,EAAAC,cAACU,EAAe,CACZC,cAAef,EAAaJ,IAC5BoB,QAAS/B,EAAQQ,KAAKiB,IAAKT,IAAM,CAC7BO,KACIP,EAAOO,MACP,GAAGP,EAAOL,MAAQX,EAAQc,QAAU,GAAK,IAAIE,EAAOL,QAAQE,KAChEF,IAAKK,EAAOL,IACZiB,MAAOZ,EAAOY,MACdI,WAAYhB,EAAOgB,iBAKlC7B,GAAYe,EAAAC,cAACc,EAAM,CAAC9B,SAAUA,EAAUC,aAAcE,MAG9DJ,GAAOgB,EAAAC,cAACe,EAAY,CAAChC,IAAKA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/keylink-to-content/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { Keylink } from \"@src/components/ui/keylink\";\n\nimport \"./keylink-to-content.scss\";\n\nexport type KeylinkToContentProps = {\n translations?: {\n /** Skip to main content */\n skipToMainContent?: string;\n };\n};\n\nexport const KeylinkToContent: React.FC<KeylinkToContentProps> = ({ translations }) => {\n const { skipToMainContent = \"Skip to main content\" } = translations || {};\n\n return (\n <Keylink className=\"keylink-to-content\" toId=\"main-content\">\n {skipToMainContent}\n </Keylink>\n );\n};\n"],"names":["KeylinkToContent","translations","skipToMainContent","React","createElement","Keylink","className","toId"],"mappings":"+EAaaA,EAAoD,EAAGC,mBAChE,MAAMC,kBAAEA,EAAoB,wBAA2BD,GAAgB,CAAA,EAEvE,OACIE,EAAAC,cAACC,EAAO,CAACC,UAAU,qBAAqBC,KAAK,gBACxCL
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/keylink-to-content/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { Keylink } from \"@src/components/ui/keylink\";\n\nimport \"./keylink-to-content.scss\";\n\nexport type KeylinkToContentProps = {\n translations?: {\n /** Skip to main content */\n skipToMainContent?: string;\n };\n};\n\nexport const KeylinkToContent: React.FC<KeylinkToContentProps> = ({ translations }) => {\n const { skipToMainContent = \"Skip to main content\" } = translations || {};\n\n return (\n <Keylink className=\"keylink-to-content\" toId=\"main-content\">\n {skipToMainContent}\n </Keylink>\n );\n};\n"],"names":["KeylinkToContent","translations","skipToMainContent","React","createElement","Keylink","className","toId"],"mappings":"+EAaaA,EAAoD,EAAGC,mBAChE,MAAMC,kBAAEA,EAAoB,wBAA2BD,GAAgB,CAAA,EAEvE,OACIE,EAAAC,cAACC,EAAO,CAACC,UAAU,qBAAqBC,KAAK,gBACxCL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/keylink-to-navigation/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { Keylink } from \"@src/components/ui/keylink\";\n\nimport \"./keylink-to-navigation.scss\";\n\nexport type KeylinkToNavigationProps = {\n translations?: {\n /** Return to navigation */\n returnToNavigation?: string;\n };\n};\n\nexport const KeylinkToNavigation: React.FC<KeylinkToNavigationProps> = ({ translations }) => {\n const { returnToNavigation = \"Return to navigation\" } = translations || {};\n\n return (\n <Keylink className=\"keylink-to-navigation\" toId=\"navigation\">\n {returnToNavigation}\n </Keylink>\n );\n};\n"],"names":["KeylinkToNavigation","translations","returnToNavigation","React","createElement","Keylink","className","toId"],"mappings":"+EAaaA,EAA0D,EAAGC,mBACtE,MAAMC,mBAAEA,EAAqB,wBAA2BD,GAAgB,CAAA,EAExE,OACIE,EAAAC,cAACC,EAAO,CAACC,UAAU,wBAAwBC,KAAK,cAC3CL
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/keylink-to-navigation/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { Keylink } from \"@src/components/ui/keylink\";\n\nimport \"./keylink-to-navigation.scss\";\n\nexport type KeylinkToNavigationProps = {\n translations?: {\n /** Return to navigation */\n returnToNavigation?: string;\n };\n};\n\nexport const KeylinkToNavigation: React.FC<KeylinkToNavigationProps> = ({ translations }) => {\n const { returnToNavigation = \"Return to navigation\" } = translations || {};\n\n return (\n <Keylink className=\"keylink-to-navigation\" toId=\"navigation\">\n {returnToNavigation}\n </Keylink>\n );\n};\n"],"names":["KeylinkToNavigation","translations","returnToNavigation","React","createElement","Keylink","className","toId"],"mappings":"+EAaaA,EAA0D,EAAGC,mBACtE,MAAMC,mBAAEA,EAAqB,wBAA2BD,GAAgB,CAAA,EAExE,OACIE,EAAAC,cAACC,EAAO,CAACC,UAAU,wBAAwBC,KAAK,cAC3CL"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type Theme } from "../../../core/types/theme";
|
|
3
|
+
import "./robin-provider.scss";
|
|
3
4
|
interface RobinProviderProps {
|
|
4
5
|
theme?: Theme;
|
|
6
|
+
component?: React.ElementType;
|
|
5
7
|
}
|
|
6
8
|
export declare const RobinProvider: React.FC<React.PropsWithChildren<RobinProviderProps>>;
|
|
7
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/elements/robin-provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,KAAK,EAAE,kCAA8B;AAMnD,UAAU,kBAAkB;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/elements/robin-provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,KAAK,EAAE,kCAA8B;AAMnD,OAAO,uBAAuB,CAAC;AAE/B,UAAU,kBAAkB;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;CACjC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAW/E,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"react";import{NavigateProvider as t}from"../../contexts/navigate/provider.js";import{ThemeStyles as r}from"../../blocks/theme-styles/index.js";import{ThemeDetector as
|
|
1
|
+
import e from"react";import{NavigateProvider as t}from"../../contexts/navigate/provider.js";import{ThemeStyles as r}from"../../blocks/theme-styles/index.js";import{ThemeDetector as o}from"../../blocks/theme-detector/index.js";import{NoJs as m}from"../../blocks/no-js/index.js";const n=({children:n,theme:l,component:s="div"})=>e.createElement(s,{suppressHydrationWarning:!0,className:"r-root"},l&&e.createElement(r,{theme:l}),e.createElement(o,null),e.createElement(t,null,n),e.createElement(m,null));export{n as RobinProvider};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/robin-provider/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { type Theme } from \"@src/core/types/theme\";\nimport { NavigateProvider } from \"@src/components/contexts/navigate/provider\";\nimport { ThemeStyles } from \"@src/components/blocks/theme-styles\";\nimport { ThemeDetector } from \"@src/components/blocks/theme-detector\";\nimport { NoJs } from \"@src/components/blocks/no-js\";\n\ninterface RobinProviderProps {\n theme?: Theme;\n}\n\nexport const RobinProvider: React.FC<React.PropsWithChildren<RobinProviderProps>> = ({
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/robin-provider/index.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { type Theme } from \"@src/core/types/theme\";\nimport { NavigateProvider } from \"@src/components/contexts/navigate/provider\";\nimport { ThemeStyles } from \"@src/components/blocks/theme-styles\";\nimport { ThemeDetector } from \"@src/components/blocks/theme-detector\";\nimport { NoJs } from \"@src/components/blocks/no-js\";\n\nimport \"./robin-provider.scss\";\n\ninterface RobinProviderProps {\n theme?: Theme;\n component?: React.ElementType;\n}\n\nexport const RobinProvider: React.FC<React.PropsWithChildren<RobinProviderProps>> = ({\n children,\n theme,\n component: Component = \"div\",\n}) => (\n <Component suppressHydrationWarning className=\"r-root\">\n {theme && <ThemeStyles theme={theme} />}\n <ThemeDetector />\n <NavigateProvider>{children}</NavigateProvider>\n <NoJs />\n </Component>\n);\n"],"names":["RobinProvider","children","theme","component","Component","React","createElement","suppressHydrationWarning","className","ThemeStyles","ThemeDetector","NavigateProvider","NoJs"],"mappings":"qRAeO,MAAMA,EAAuE,EAChFC,WACAC,QACAC,UAAWC,EAAY,SAEvBC,EAAAC,cAACF,EAAS,CAACG,0BAAwB,EAACC,UAAU,UACzCN,GAASG,EAAAC,cAACG,GAAYP,MAAOA,IAC9BG,EAAAC,cAACI,EAAa,MACdL,EAAAC,cAACK,EAAgB,KAAEV,GACnBI,EAAAC,cAACM,EAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"react";import t from"clsx";import{SidebarMenu as r}from"./sidebar-menu/index.js";import{SidebarDrop as a}from"./sidebar-drop/index.js";import{SidebarLink as l}from"./sidebar-link/index.js";import{isActiveItem as s,collectItems as i}from"./tools.js";const n=({branch:r,depth:m,translations:p})=>{const{expandTitle:d="Expand {title}"}=p||{};return"separator"===r.type?e.createElement("li",{className:"r-sidebar-li _separator"}):e.createElement("li",{className:t("r-sidebar-li","heading"===r.type&&"r-sidebar-heading",r.items&&r.items.length>0&&"_droppable")},s(r)?e.createElement(l,{branch:r}):e.createElement("p",{className:t("r-sidebar-p","heading"===r.type&&"r-sidebar-heading")},r.title),r.items&&r.items.length>0&&e.createElement(a,{childHrefs:i(r),defaultOpen:!1,id:r.href+r.title,label:d.replace("{title}",r.title)},r.items.map((
|
|
1
|
+
import e from"react";import t from"clsx";import{SidebarMenu as r}from"./sidebar-menu/index.js";import{SidebarDrop as a}from"./sidebar-drop/index.js";import{SidebarLink as l}from"./sidebar-link/index.js";import{isActiveItem as s,collectItems as i}from"./tools.js";const n=({branch:r,depth:m,translations:p})=>{const{expandTitle:d="Expand {title}"}=p||{};return"separator"===r.type?e.createElement("li",{className:"r-sidebar-li _separator"}):e.createElement("li",{className:t("r-sidebar-li","heading"===r.type&&"r-sidebar-heading",r.items&&r.items.length>0&&"_droppable")},s(r)?e.createElement(l,{branch:r}):e.createElement("p",{className:t("r-sidebar-p","heading"===r.type&&"r-sidebar-heading")},r.title),r.items&&r.items.length>0&&e.createElement(a,{childHrefs:i(r),defaultOpen:!1,id:r.href+r.title,label:d.replace("{title}",r.title)},r.items.map((t,r)=>e.createElement(n,{branch:t,key:"separator"===t.type?`sep${r}`:t.href+t.title,depth:m>=4?4:m+1,translations:p}))))},m=({tree:t,translations:a})=>t?.length?e.createElement(e.Fragment,null,e.createElement("div",{className:"r-sidebar-top-mock"}),e.createElement(r,null,e.createElement("ul",{className:"r-sidebar-list"},t.map((t,r)=>e.createElement(n,{branch:t,key:"separator"===t.type?`sep${r}`:t.href+t.title,depth:0,translations:a}))))):e.createElement("div",{className:"r-sidebar"});export{m as Sidebar};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/sidebar/index.tsx"],"sourcesContent":["import React from \"react\";\nimport clsx from \"clsx\";\n\nimport { type TreeItem } from \"./types\";\nimport { SidebarMenu } from \"./sidebar-menu\";\nimport { SidebarDrop } from \"./sidebar-drop\";\nimport { SidebarLink } from \"./sidebar-link\";\nimport { collectItems, isActiveItem } from \"./tools\";\n\nimport \"./sidebar.scss\";\n\ntype LinkBranchProps = {\n branch: TreeItem;\n depth: number;\n translations?: {\n /** Expand {title} */\n expandTitle?: string;\n };\n};\n\nconst LinkBranch: React.FC<LinkBranchProps> = ({ branch, depth, translations }) => {\n const { expandTitle = \"Expand {title}\" } = translations || {};\n\n if (branch.type === \"separator\") {\n return <li className=\"r-sidebar-li _separator\" />;\n }\n\n return (\n <li\n className={clsx(\n \"r-sidebar-li\",\n branch.type === \"heading\" && \"r-sidebar-heading\",\n branch.items && branch.items.length > 0 && \"_droppable\",\n )}\n >\n {isActiveItem(branch) ? (\n <SidebarLink branch={branch} />\n ) : (\n <p className={clsx(\"r-sidebar-p\", branch.type === \"heading\" && \"r-sidebar-heading\")}>{branch.title}</p>\n )}\n {branch.items && branch.items.length > 0 && (\n <SidebarDrop\n childHrefs={collectItems(branch)}\n defaultOpen={false}\n id={branch.href + branch.title}\n label={expandTitle.replace(\"{title}\", branch.title)}\n >\n {branch.items.map((item, index) => (\n <LinkBranch\n branch={item}\n key={item.type === \"separator\" ? `sep${index}` : item.href + item.title}\n depth={depth >= 4 ? 4 : depth + 1}\n translations={translations}\n />\n ))}\n </SidebarDrop>\n )}\n </li>\n );\n};\n\nexport type SidebarProps = {\n tree?: TreeItem[] | null;\n translations?: LinkBranchProps[\"translations\"];\n};\n\nexport const Sidebar: React.FC<SidebarProps> = ({ tree, translations }) => {\n if (!tree?.length) return <div className=\"r-sidebar\" />;\n\n return (\n <>\n <div className=\"r-sidebar-top-mock\" />\n <SidebarMenu>\n <ul className=\"r-sidebar-list\">\n {tree.map((item, index) => (\n <LinkBranch\n branch={item}\n key={item.type === \"separator\" ? `sep${index}` : item.href + item.title}\n depth={0}\n translations={translations}\n />\n ))}\n </ul>\n </SidebarMenu>\n </>\n );\n};\n"],"names":["LinkBranch","branch","depth","translations","expandTitle","type","React","createElement","className","clsx","items","length","isActiveItem","SidebarLink","title","SidebarDrop","childHrefs","collectItems","defaultOpen","id","href","label","replace","map","item","index","key","Sidebar","tree","Fragment","SidebarMenu"],"mappings":"uQAoBA,MAAMA,EAAwC,EAAGC,SAAQC,QAAOC,mBAC5D,MAAMC,YAAEA,EAAc,kBAAqBD,GAAgB,CAAA,EAE3D,MAAoB,cAAhBF,EAAOI,KACAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/elements/sidebar/index.tsx"],"sourcesContent":["import React from \"react\";\nimport clsx from \"clsx\";\n\nimport { type TreeItem } from \"./types\";\nimport { SidebarMenu } from \"./sidebar-menu\";\nimport { SidebarDrop } from \"./sidebar-drop\";\nimport { SidebarLink } from \"./sidebar-link\";\nimport { collectItems, isActiveItem } from \"./tools\";\n\nimport \"./sidebar.scss\";\n\ntype LinkBranchProps = {\n branch: TreeItem;\n depth: number;\n translations?: {\n /** Expand {title} */\n expandTitle?: string;\n };\n};\n\nconst LinkBranch: React.FC<LinkBranchProps> = ({ branch, depth, translations }) => {\n const { expandTitle = \"Expand {title}\" } = translations || {};\n\n if (branch.type === \"separator\") {\n return <li className=\"r-sidebar-li _separator\" />;\n }\n\n return (\n <li\n className={clsx(\n \"r-sidebar-li\",\n branch.type === \"heading\" && \"r-sidebar-heading\",\n branch.items && branch.items.length > 0 && \"_droppable\",\n )}\n >\n {isActiveItem(branch) ? (\n <SidebarLink branch={branch} />\n ) : (\n <p className={clsx(\"r-sidebar-p\", branch.type === \"heading\" && \"r-sidebar-heading\")}>{branch.title}</p>\n )}\n {branch.items && branch.items.length > 0 && (\n <SidebarDrop\n childHrefs={collectItems(branch)}\n defaultOpen={false}\n id={branch.href + branch.title}\n label={expandTitle.replace(\"{title}\", branch.title)}\n >\n {branch.items.map((item, index) => (\n <LinkBranch\n branch={item}\n key={item.type === \"separator\" ? `sep${index}` : item.href + item.title}\n depth={depth >= 4 ? 4 : depth + 1}\n translations={translations}\n />\n ))}\n </SidebarDrop>\n )}\n </li>\n );\n};\n\nexport type SidebarProps = {\n tree?: TreeItem[] | null;\n translations?: LinkBranchProps[\"translations\"];\n};\n\nexport const Sidebar: React.FC<SidebarProps> = ({ tree, translations }) => {\n if (!tree?.length) return <div className=\"r-sidebar\" />;\n\n return (\n <>\n <div className=\"r-sidebar-top-mock\" />\n <SidebarMenu>\n <ul className=\"r-sidebar-list\">\n {tree.map((item, index) => (\n <LinkBranch\n branch={item}\n key={item.type === \"separator\" ? `sep${index}` : item.href + item.title}\n depth={0}\n translations={translations}\n />\n ))}\n </ul>\n </SidebarMenu>\n </>\n );\n};\n"],"names":["LinkBranch","branch","depth","translations","expandTitle","type","React","createElement","className","clsx","items","length","isActiveItem","SidebarLink","title","SidebarDrop","childHrefs","collectItems","defaultOpen","id","href","label","replace","map","item","index","key","Sidebar","tree","Fragment","SidebarMenu"],"mappings":"uQAoBA,MAAMA,EAAwC,EAAGC,SAAQC,QAAOC,mBAC5D,MAAMC,YAAEA,EAAc,kBAAqBD,GAAgB,CAAA,EAE3D,MAAoB,cAAhBF,EAAOI,KACAC,EAAAC,cAAA,KAAA,CAAIC,UAAU,4BAIrBF,EAAAC,cAAA,KAAA,CACIC,UAAWC,EACP,eACgB,YAAhBR,EAAOI,MAAsB,oBAC7BJ,EAAOS,OAAST,EAAOS,MAAMC,OAAS,GAAK,eAG9CC,EAAaX,GACVK,EAAAC,cAACM,EAAW,CAACZ,OAAQA,IAErBK,EAAAC,cAAA,IAAA,CAAGC,UAAWC,EAAK,cAA+B,YAAhBR,EAAOI,MAAsB,sBAAuBJ,EAAOa,OAEhGb,EAAOS,OAAST,EAAOS,MAAMC,OAAS,GACnCL,EAAAC,cAACQ,EAAW,CACRC,WAAYC,EAAahB,GACzBiB,aAAa,EACbC,GAAIlB,EAAOmB,KAAOnB,EAAOa,MACzBO,MAAOjB,EAAYkB,QAAQ,UAAWrB,EAAOa,QAE5Cb,EAAOS,MAAMa,IAAI,CAACC,EAAMC,IACrBnB,EAAAC,cAACP,EAAU,CACPC,OAAQuB,EACRE,IAAmB,cAAdF,EAAKnB,KAAuB,MAAMoB,IAAUD,EAAKJ,KAAOI,EAAKV,MAClEZ,MAAOA,GAAS,EAAI,EAAIA,EAAQ,EAChCC,aAAcA,QAc7BwB,EAAkC,EAAGC,OAAMzB,kBAC/CyB,GAAMjB,OAGPL,EAAAC,cAAAD,EAAAuB,SAAA,KACIvB,EAAAC,cAAA,MAAA,CAAKC,UAAU,uBACfF,EAAAC,cAACuB,EAAW,KACRxB,EAAAC,cAAA,KAAA,CAAIC,UAAU,kBACToB,EAAKL,IAAI,CAACC,EAAMC,IACbnB,EAAAC,cAACP,EAAU,CACPC,OAAQuB,EACRE,IAAmB,cAAdF,EAAKnB,KAAuB,MAAMoB,IAAUD,EAAKJ,KAAOI,EAAKV,MAClEZ,MAAO,EACPC,aAAcA,QAZZG,EAAAC,cAAA,MAAA,CAAKC,UAAU"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import e,{useState as r,useRef as t,useEffect as n}from"react";import{usePathname as o}from"next/navigation";const s=({childHrefs:s,label:a,children:i})=>{const l=o(),c=s.includes(l),[d,m]=r(c),u=t(null),p=t(null);return n((
|
|
2
|
+
import e,{useState as r,useRef as t,useEffect as n}from"react";import{usePathname as o}from"next/navigation";const s=({childHrefs:s,label:a,children:i})=>{const l=o(),c=s.includes(l),[d,m]=r(c),u=t(null),p=t(null);return n(()=>{c&&!d&&m(!0),c&&p.current&&!p.current?.open&&(p.current.open=!0)},[c]),n(()=>{p.current?.style.setProperty("--drop-height",u.current?.offsetHeight.toString()+"px")},[]),e.createElement("details",{className:"r-sidebar-drop",open:d,ref:p},e.createElement("summary",{className:"r-sidebar-drop-btn","aria-label":a},e.createElement("svg",{className:"r-sidebar-drop-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"m9 18 6-6-6-6"}))),e.createElement("ul",{className:"r-sidebar-list r-sidebar-sublist",ref:u},i))};export{s as SidebarDrop};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/elements/sidebar/sidebar-drop/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\n\nexport interface SidebarDropProps {\n childHrefs: string[];\n defaultOpen?: boolean;\n label: string;\n id: string;\n}\n\nexport const SidebarDrop: React.FC<React.PropsWithChildren<SidebarDropProps>> = ({ childHrefs, label, children }) => {\n const pathname = usePathname();\n const openedByDefault = childHrefs.includes(pathname);\n const [opened, setOpened] = useState(openedByDefault);\n const dropdownRef = useRef<HTMLUListElement>(null);\n const detailsRef = useRef<HTMLDetailsElement>(null);\n\n useEffect(() => {\n if (openedByDefault && !opened) setOpened(true);\n if (openedByDefault && detailsRef.current && !detailsRef.current?.open) detailsRef.current.open = true;\n }, [openedByDefault]);\n\n useEffect(() => {\n detailsRef.current?.style.setProperty(\"--drop-height\", dropdownRef.current?.offsetHeight.toString() + \"px\");\n }, []);\n\n return (\n <details className=\"r-sidebar-drop\" open={opened} ref={detailsRef}>\n <summary className=\"r-sidebar-drop-btn\" aria-label={label}>\n <svg\n className=\"r-sidebar-drop-icon\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </summary>\n <ul className=\"r-sidebar-list r-sidebar-sublist\" ref={dropdownRef}>\n {children}\n </ul>\n </details>\n );\n};\n"],"names":["SidebarDrop","childHrefs","label","children","pathname","usePathname","openedByDefault","includes","opened","setOpened","useState","dropdownRef","useRef","detailsRef","useEffect","current","open","style","setProperty","offsetHeight","toString","React","createElement","className","ref","width","height","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","d"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/elements/sidebar/sidebar-drop/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\n\nexport interface SidebarDropProps {\n childHrefs: string[];\n defaultOpen?: boolean;\n label: string;\n id: string;\n}\n\nexport const SidebarDrop: React.FC<React.PropsWithChildren<SidebarDropProps>> = ({ childHrefs, label, children }) => {\n const pathname = usePathname();\n const openedByDefault = childHrefs.includes(pathname);\n const [opened, setOpened] = useState(openedByDefault);\n const dropdownRef = useRef<HTMLUListElement>(null);\n const detailsRef = useRef<HTMLDetailsElement>(null);\n\n useEffect(() => {\n if (openedByDefault && !opened) setOpened(true);\n if (openedByDefault && detailsRef.current && !detailsRef.current?.open) detailsRef.current.open = true;\n }, [openedByDefault]);\n\n useEffect(() => {\n detailsRef.current?.style.setProperty(\"--drop-height\", dropdownRef.current?.offsetHeight.toString() + \"px\");\n }, []);\n\n return (\n <details className=\"r-sidebar-drop\" open={opened} ref={detailsRef}>\n <summary className=\"r-sidebar-drop-btn\" aria-label={label}>\n <svg\n className=\"r-sidebar-drop-icon\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </summary>\n <ul className=\"r-sidebar-list r-sidebar-sublist\" ref={dropdownRef}>\n {children}\n </ul>\n </details>\n );\n};\n"],"names":["SidebarDrop","childHrefs","label","children","pathname","usePathname","openedByDefault","includes","opened","setOpened","useState","dropdownRef","useRef","detailsRef","useEffect","current","open","style","setProperty","offsetHeight","toString","React","createElement","className","ref","width","height","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","d"],"mappings":";6GAYO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMA,CAAAA,CAAmE,CAAA,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAYC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAOC,CAAAA,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AA,CAAA,CAEfX,CAAAA,CAAAC,cAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMW,CAAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAGhBZ,CAAAA,CAAAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAIC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmCC,CAAAA,CAAAA,CAAAA,CAAKb,CAAAA,CAAAA,CACjDR,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/elements/sidebar/sidebar-link/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useRef } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport clsx from \"clsx\";\n\nimport { useReference } from \"@src/components/contexts/reference/use-reference\";\nimport { NavLink } from \"@src/components/blocks/nav-link\";\n\nimport { type TreeItem } from \"../types\";\nimport { checkIsTargetPathname, collectItems } from \"../tools\";\n\ntype SidebarLinkProps = {\n branch: Exclude<TreeItem, { type: \"separator\" }> & { href: string };\n};\n\nexport const SidebarLink: React.FC<SidebarLinkProps> = ({ branch }) => {\n const pathname = usePathname();\n const isActive = checkIsTargetPathname(branch.href, pathname);\n const isTarget = collectItems(branch).includes(pathname);\n const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n const sidebar = useReference();\n\n return (\n <NavLink\n href={branch.href}\n className={clsx(\"r-sidebar-link\", isActive && \"_active\", isTarget && \"_target\")}\n ref={(node) => {\n if (isTarget && sidebar && sidebar.scrollHeight > window.innerHeight - 60) {\n scrollTimeoutRef.current = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (node as any)?.parentElement?.scrollIntoViewIfNeeded?.();\n }\n }}\n >\n {branch.title}\n </NavLink>\n );\n};\n"],"names":["SidebarLink","branch","pathname","usePathname","isActive","checkIsTargetPathname","href","isTarget","collectItems","includes","scrollTimeoutRef","useRef","sidebar","useReference","React","createElement","NavLink","className","clsx","ref","node","scrollHeight","window","innerHeight","current","parentElement","scrollIntoViewIfNeeded","title"],"mappings":";wTAgBaA,CAA0C,CAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/elements/sidebar/sidebar-link/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useRef } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport clsx from \"clsx\";\n\nimport { useReference } from \"@src/components/contexts/reference/use-reference\";\nimport { NavLink } from \"@src/components/blocks/nav-link\";\n\nimport { type TreeItem } from \"../types\";\nimport { checkIsTargetPathname, collectItems } from \"../tools\";\n\ntype SidebarLinkProps = {\n branch: Exclude<TreeItem, { type: \"separator\" }> & { href: string };\n};\n\nexport const SidebarLink: React.FC<SidebarLinkProps> = ({ branch }) => {\n const pathname = usePathname();\n const isActive = checkIsTargetPathname(branch.href, pathname);\n const isTarget = collectItems(branch).includes(pathname);\n const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n const sidebar = useReference();\n\n return (\n <NavLink\n href={branch.href}\n className={clsx(\"r-sidebar-link\", isActive && \"_active\", isTarget && \"_target\")}\n ref={(node) => {\n if (isTarget && sidebar && sidebar.scrollHeight > window.innerHeight - 60) {\n scrollTimeoutRef.current = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (node as any)?.parentElement?.scrollIntoViewIfNeeded?.();\n }\n }}\n >\n {branch.title}\n </NavLink>\n );\n};\n"],"names":["SidebarLink","branch","pathname","usePathname","isActive","checkIsTargetPathname","href","isTarget","collectItems","includes","scrollTimeoutRef","useRef","sidebar","useReference","React","createElement","NavLink","className","clsx","ref","node","scrollHeight","window","innerHeight","current","parentElement","scrollIntoViewIfNeeded","title"],"mappings":";wTAgBaA,CAAAA,CAA0C,CAAA,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CACtD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMC,CAAAA,CAAWC,CAAAA,CAAAA,CAAAA,CACXC,CAAAA,CAAWC,EAAsBJ,CAAAA,CAAOK,CAAAA,CAAAA,CAAAA,CAAAA,CAAMJ,CAAAA,CAAAA,CAC9CK,CAAAA,CAAWC,CAAAA,CAAaP,CAAAA,CAAAA,CAAQQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAASP,CAAAA,CAAAA,CACzCQ,EAAmBC,CAAAA,CAA8B,CAAA,CAAA,CAAA,CAAA,CAAA,CACjDC,CAAAA,CAAUC,CAAAA,CAAAA,CAAAA,CAEhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACIC,CAAAA,CAAAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAACC,CAAAA,CAAO,CACJV,CAAAA,CAAAA,CAAAA,CAAAA,CAAML,CAAAA,CAAOK,CAAAA,CAAAA,CAAAA,CAAAA,CACbW,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWC,CAAAA,CAAK,CAAA,CAAA,CAAA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AO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACnD,YAAY,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL,CAAC,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/elements/sidebar/sidebar-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACnD,YAAY,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL,CAAC,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkElD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import e,{useState as
|
|
2
|
+
import e,{useState as r,useRef as t,useEffect as n}from"react";import{useNavigate as o}from"../../../contexts/navigate/use-navigate.js";import{ReferenceProvider as a}from"../../../contexts/reference/provider.js";const s=({children:s,translations:i})=>{const{menu:c="Menu"}=i||{},{addListener:l,removeListener:d}=o(),[m,u]=r(!1),b=t(null),p=()=>{const e=document.querySelector(".r-root");e?.classList.remove("body-mobile-lock"),u(!1),d("closeSidebarMenu")};return n(()=>()=>{p()},[]),e.createElement("div",{className:"r-sidebar"},e.createElement("input",{type:"checkbox",id:"sidebar-input",className:"r-sidebar-input",hidden:!0,onChange:()=>{m?p():(()=>{const e=document.querySelector(".r-root");e?.classList.add("body-mobile-lock"),u(!0),l("closeSidebarMenu",p)})()},checked:m}),e.createElement("label",{htmlFor:"sidebar-input",className:"r-sidebar-btn",role:"button",tabIndex:0},e.createElement("svg",{className:"r-sidebar-chevron",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"m9 18 6-6-6-6"})),e.createElement("span",null,c)),e.createElement("nav",{ref:b,className:"r-sidebar-nav",id:"navigation"},e.createElement(a,{reference:b},s)))};export{s as SidebarMenu};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|