@valkyrianlabs/payload-markdown 1.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.
Files changed (204) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +222 -0
  3. package/dist/blocks/MarkdownBlock/Component.d.ts +2 -0
  4. package/dist/blocks/MarkdownBlock/Component.js +13 -0
  5. package/dist/blocks/MarkdownBlock/Component.js.map +1 -0
  6. package/dist/blocks/MarkdownBlock/config.d.ts +2 -0
  7. package/dist/blocks/MarkdownBlock/config.js +20 -0
  8. package/dist/blocks/MarkdownBlock/config.js.map +1 -0
  9. package/dist/blocks/MarkdownBlock/types.d.js +3 -0
  10. package/dist/blocks/MarkdownBlock/types.d.js.map +1 -0
  11. package/dist/components/MarkdownRenderer/Component.client.d.ts +5 -0
  12. package/dist/components/MarkdownRenderer/Component.client.js +163 -0
  13. package/dist/components/MarkdownRenderer/Component.client.js.map +1 -0
  14. package/dist/components/MarkdownRenderer/Component.d.ts +3 -0
  15. package/dist/components/MarkdownRenderer/Component.js +87 -0
  16. package/dist/components/MarkdownRenderer/Component.js.map +1 -0
  17. package/dist/components/MarkdownRenderer/index.css +69 -0
  18. package/dist/components/MarkdownRenderer/index.module.css +45 -0
  19. package/dist/components/MarkdownRenderer/index.module.scss +43 -0
  20. package/dist/components/MarkdownRenderer/index.scss +83 -0
  21. package/dist/components/MarkdownRenderer/types.d.js +5 -0
  22. package/dist/components/MarkdownRenderer/types.d.js.map +1 -0
  23. package/dist/core/codeConfig.d.ts +6 -0
  24. package/dist/core/codeConfig.js +45 -0
  25. package/dist/core/codeConfig.js.map +1 -0
  26. package/dist/core/codeToHtml.d.ts +5 -0
  27. package/dist/core/codeToHtml.js +180 -0
  28. package/dist/core/codeToHtml.js.map +1 -0
  29. package/dist/core/plugins/rehypeApplyLayoutClasses.d.ts +4 -0
  30. package/dist/core/plugins/rehypeApplyLayoutClasses.js +72 -0
  31. package/dist/core/plugins/rehypeApplyLayoutClasses.js.map +1 -0
  32. package/dist/core/plugins/rehypeStripAuthoredInlineStyles.d.ts +3 -0
  33. package/dist/core/plugins/rehypeStripAuthoredInlineStyles.js +17 -0
  34. package/dist/core/plugins/rehypeStripAuthoredInlineStyles.js.map +1 -0
  35. package/dist/core/plugins/remarkCompileLayouts.d.ts +3 -0
  36. package/dist/core/plugins/remarkCompileLayouts.js +169 -0
  37. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -0
  38. package/dist/core/plugins/remarkHeadingAnchorsAndToc.d.ts +3 -0
  39. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +68 -0
  40. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -0
  41. package/dist/core/plugins/remarkLayoutDirectives.d.ts +3 -0
  42. package/dist/core/plugins/remarkLayoutDirectives.js +26 -0
  43. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -0
  44. package/dist/core/plugins/remarkLayoutSentinels.d.ts +3 -0
  45. package/dist/core/plugins/remarkLayoutSentinels.js +184 -0
  46. package/dist/core/plugins/remarkLayoutSentinels.js.map +1 -0
  47. package/dist/core/plugins/remarkLiftLayoutDirectives.d.ts +3 -0
  48. package/dist/core/plugins/remarkLiftLayoutDirectives.js +93 -0
  49. package/dist/core/plugins/remarkLiftLayoutDirectives.js.map +1 -0
  50. package/dist/core/plugins/remarkNormalizeLayoutSyntax.d.ts +3 -0
  51. package/dist/core/plugins/remarkValidateDirectiveThemes.d.ts +4 -0
  52. package/dist/core/plugins/remarkValidateDirectiveThemes.js +28 -0
  53. package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -0
  54. package/dist/core/renderMarkdown.d.ts +2 -0
  55. package/dist/core/renderMarkdown.js +270 -0
  56. package/dist/core/renderMarkdown.js.map +1 -0
  57. package/dist/core/types.d.js +7 -0
  58. package/dist/core/types.d.js.map +1 -0
  59. package/dist/core/types.d.ts +238 -0
  60. package/dist/core/types.js +5 -0
  61. package/dist/core/types.js.map +1 -0
  62. package/dist/directives/attributes.d.ts +14 -0
  63. package/dist/directives/attributes.js +121 -0
  64. package/dist/directives/attributes.js.map +1 -0
  65. package/dist/directives/definitions/callout.d.ts +6 -0
  66. package/dist/directives/definitions/callout.js +107 -0
  67. package/dist/directives/definitions/callout.js.map +1 -0
  68. package/dist/directives/definitions/card.d.ts +4 -0
  69. package/dist/directives/definitions/card.js +120 -0
  70. package/dist/directives/definitions/card.js.map +1 -0
  71. package/dist/directives/definitions/cards.d.ts +7 -0
  72. package/dist/directives/definitions/cards.js +72 -0
  73. package/dist/directives/definitions/cards.js.map +1 -0
  74. package/dist/directives/definitions/cell.d.ts +4 -0
  75. package/dist/directives/definitions/cell.js +44 -0
  76. package/dist/directives/definitions/cell.js.map +1 -0
  77. package/dist/directives/definitions/columns.d.ts +4 -0
  78. package/dist/directives/definitions/columns.js +89 -0
  79. package/dist/directives/definitions/columns.js.map +1 -0
  80. package/dist/directives/definitions/details.d.ts +2 -0
  81. package/dist/directives/definitions/details.js +76 -0
  82. package/dist/directives/definitions/details.js.map +1 -0
  83. package/dist/directives/definitions/section.d.ts +2 -0
  84. package/dist/directives/definitions/section.js +32 -0
  85. package/dist/directives/definitions/section.js.map +1 -0
  86. package/dist/directives/definitions/steps.d.ts +2 -0
  87. package/dist/directives/definitions/steps.js +242 -0
  88. package/dist/directives/definitions/steps.js.map +1 -0
  89. package/dist/directives/definitions/tab.d.ts +8 -0
  90. package/dist/directives/definitions/tab.js +59 -0
  91. package/dist/directives/definitions/tab.js.map +1 -0
  92. package/dist/directives/definitions/tabs.d.ts +2 -0
  93. package/dist/directives/definitions/tabs.js +197 -0
  94. package/dist/directives/definitions/tabs.js.map +1 -0
  95. package/dist/directives/definitions/toc.d.ts +7 -0
  96. package/dist/directives/definitions/toc.js +59 -0
  97. package/dist/directives/definitions/toc.js.map +1 -0
  98. package/dist/directives/diagnostics.d.ts +8 -0
  99. package/dist/directives/diagnostics.js +167 -0
  100. package/dist/directives/diagnostics.js.map +1 -0
  101. package/dist/directives/headingAnchors.d.ts +9 -0
  102. package/dist/directives/headingAnchors.js +54 -0
  103. package/dist/directives/headingAnchors.js.map +1 -0
  104. package/dist/directives/index.d.ts +5 -0
  105. package/dist/directives/index.js +6 -0
  106. package/dist/directives/index.js.map +1 -0
  107. package/dist/directives/registry.d.ts +20 -0
  108. package/dist/directives/registry.js +152 -0
  109. package/dist/directives/registry.js.map +1 -0
  110. package/dist/directives/renderData.d.ts +3 -0
  111. package/dist/directives/renderData.js +11 -0
  112. package/dist/directives/renderData.js.map +1 -0
  113. package/dist/directives/themes.d.ts +25 -0
  114. package/dist/directives/themes.js +274 -0
  115. package/dist/directives/themes.js.map +1 -0
  116. package/dist/directives/types.d.ts +72 -0
  117. package/dist/directives/types.js +3 -0
  118. package/dist/directives/types.js.map +1 -0
  119. package/dist/editor/MarkdownCodeMirror/Component.client.d.ts +8 -0
  120. package/dist/editor/MarkdownCodeMirror/Component.client.js +78 -0
  121. package/dist/editor/MarkdownCodeMirror/Component.client.js.map +1 -0
  122. package/dist/editor/MarkdownCodeMirror/Component.d.ts +9 -0
  123. package/dist/editor/MarkdownCodeMirror/Component.js +10 -0
  124. package/dist/editor/MarkdownCodeMirror/Component.js.map +1 -0
  125. package/dist/editor/MarkdownCodeMirror.d.ts +8 -0
  126. package/dist/editor/MarkdownCodeMirror.js +74 -0
  127. package/dist/editor/MarkdownCodeMirror.js.map +1 -0
  128. package/dist/editor/MarkdownEditor.d.ts +10 -0
  129. package/dist/editor/MarkdownEditor.js +22 -0
  130. package/dist/editor/MarkdownEditor.js.map +1 -0
  131. package/dist/editor/directives/completions.d.ts +5 -0
  132. package/dist/editor/directives/completions.js +93 -0
  133. package/dist/editor/directives/completions.js.map +1 -0
  134. package/dist/editor/directives/diagnostics.d.ts +1 -0
  135. package/dist/editor/directives/diagnostics.js +12 -0
  136. package/dist/editor/directives/diagnostics.js.map +1 -0
  137. package/dist/editor/themes/payload.d.ts +27 -0
  138. package/dist/editor/themes/payload.js +269 -0
  139. package/dist/editor/themes/payload.js.map +1 -0
  140. package/dist/editor/themes/support/highlighters.d.ts +20 -0
  141. package/dist/editor/themes/support/highlighters.js +1141 -0
  142. package/dist/editor/themes/support/highlighters.js.map +1 -0
  143. package/dist/editor/themes/support/lang.d.ts +40 -0
  144. package/dist/editor/themes/support/lang.js +201 -0
  145. package/dist/editor/themes/support/lang.js.map +1 -0
  146. package/dist/exports/advanced.d.ts +3 -0
  147. package/dist/exports/advanced.js +5 -0
  148. package/dist/exports/advanced.js.map +1 -0
  149. package/dist/exports/client.d.ts +1 -0
  150. package/dist/exports/client.js +2 -0
  151. package/dist/exports/client.js.map +1 -0
  152. package/dist/exports/server.d.ts +3 -0
  153. package/dist/exports/server.js +5 -0
  154. package/dist/exports/server.js.map +1 -0
  155. package/dist/field/BlocksParams/config.d.ts +7 -0
  156. package/dist/field/BlocksParams/config.js +149 -0
  157. package/dist/field/BlocksParams/config.js.map +1 -0
  158. package/dist/field/CodeBlock/config.d.ts +7 -0
  159. package/dist/field/CodeBlock/config.js +321 -0
  160. package/dist/field/CodeBlock/config.js.map +1 -0
  161. package/dist/field/CodeBlockConfig/config.d.ts +7 -0
  162. package/dist/field/CodeBlockConfig/config.js +306 -0
  163. package/dist/field/CodeBlockConfig/config.js.map +1 -0
  164. package/dist/field/CodeBlockParams/config.d.ts +7 -0
  165. package/dist/field/CodeBlockParams/config.js +321 -0
  166. package/dist/field/CodeBlockParams/config.js.map +1 -0
  167. package/dist/field/Config/config.d.ts +7 -0
  168. package/dist/field/Config/config.js +149 -0
  169. package/dist/field/Config/config.js.map +1 -0
  170. package/dist/field/MarkdownField/Component.d.ts +2 -0
  171. package/dist/field/MarkdownField/Component.js +42 -0
  172. package/dist/field/MarkdownField/Component.js.map +1 -0
  173. package/dist/field/MarkdownField/config.d.ts +3 -0
  174. package/dist/field/MarkdownField/config.js +20 -0
  175. package/dist/field/MarkdownField/config.js.map +1 -0
  176. package/dist/field/Tailwind/config.d.ts +9 -0
  177. package/dist/field/Tailwind/config.js +13 -0
  178. package/dist/field/Tailwind/config.js.map +1 -0
  179. package/dist/field/TailwindField/config.d.ts +9 -0
  180. package/dist/field/TailwindField/config.js +13 -0
  181. package/dist/field/TailwindField/config.js.map +1 -0
  182. package/dist/index.d.ts +10 -0
  183. package/dist/index.js +91 -0
  184. package/dist/index.js.map +1 -0
  185. package/dist/runtime/index.d.ts +36 -0
  186. package/dist/runtime/index.js +124 -0
  187. package/dist/runtime/index.js.map +1 -0
  188. package/dist/styles/directiveSurface.d.ts +11 -0
  189. package/dist/styles/directiveSurface.js +38 -0
  190. package/dist/styles/directiveSurface.js.map +1 -0
  191. package/dist/types/core.d.ts +285 -0
  192. package/dist/types/core.js +5 -0
  193. package/dist/types/core.js.map +1 -0
  194. package/dist/types/layoutToken.d.ts +1 -0
  195. package/dist/types/layoutToken.js +3 -0
  196. package/dist/types/layoutToken.js.map +1 -0
  197. package/dist/types/mdast.d.js +5 -0
  198. package/dist/types/mdast.d.js.map +1 -0
  199. package/dist/types.d.js +3 -0
  200. package/dist/types.d.js.map +1 -0
  201. package/dist/types.d.ts +80 -0
  202. package/dist/types.js +3 -0
  203. package/dist/types.js.map +1 -0
  204. package/package.json +181 -0
@@ -0,0 +1,89 @@
1
+ import { resolveDirectiveTheme } from '../themes.js';
2
+ import { makeCellDirective } from './cell.js';
3
+ function isContainerDirective(node) {
4
+ return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'containerDirective');
5
+ }
6
+ function isHeading(node) {
7
+ return node.type === 'heading';
8
+ }
9
+ function isLayoutBoundaryDirective(name) {
10
+ return name === 'section' || name === '2col' || name === '3col' || name === 'cell';
11
+ }
12
+ function isStructuralDirectiveChild(node, context) {
13
+ return isContainerDirective(node) && context.isSupportedDirectiveName(node.name) && isLayoutBoundaryDirective(node.name);
14
+ }
15
+ function resolveCellHeadingDepth(node) {
16
+ return typeof node.data?.vlCellHeadingDepth === 'number' ? node.data.vlCellHeadingDepth : 3;
17
+ }
18
+ function groupGridChildren(children, cellHeadingDepth, context) {
19
+ const grouped = [];
20
+ let currentCell = [];
21
+ const flushCell = ()=>{
22
+ if (currentCell.length === 0) return;
23
+ grouped.push(makeCellDirective(currentCell));
24
+ currentCell = [];
25
+ };
26
+ for (const child of children){
27
+ if (isStructuralDirectiveChild(child, context)) {
28
+ flushCell();
29
+ grouped.push(child);
30
+ continue;
31
+ }
32
+ if (isHeading(child) && child.depth === cellHeadingDepth) flushCell();
33
+ currentCell.push(child);
34
+ }
35
+ flushCell();
36
+ return grouped;
37
+ }
38
+ function createColumnDirective(name, columns) {
39
+ return {
40
+ name,
41
+ allowedAttributes: [
42
+ 'cellTheme',
43
+ 'theme'
44
+ ],
45
+ applyHast (node, config, { groupChildrenIntoCells, mergeClassNames }) {
46
+ const theme = resolveDirectiveTheme('columns', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
47
+ const cellTheme = typeof node.properties.dataCellTheme === 'string' ? node.properties.dataCellTheme : undefined;
48
+ const resolvedCellTheme = cellTheme ? resolveDirectiveTheme('cell', cellTheme, config.themes) : undefined;
49
+ for (const child of node.children)if (child.type === 'element' && child.properties?.dataVlLayout === 'cell' && typeof child.properties.dataTheme !== 'string' && cellTheme) child.properties.dataTheme = cellTheme;
50
+ node.properties.dataTheme = theme.name;
51
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, columns === 2 ? 'md:grid-cols-2' : 'md:grid-cols-3');
52
+ const hasExplicitCells = node.children.some((child)=>child.type === 'element' && child.properties?.dataVlLayout === 'cell');
53
+ if (!hasExplicitCells) node.children = groupChildrenIntoCells(node.children, config.columnClassName, resolvedCellTheme);
54
+ },
55
+ editor: {
56
+ detail: 'Layout directive',
57
+ label: `${columns}-column layout`,
58
+ snippet: columns === 2 ? `:::${name}\n\n### ${'${First column}'}\n\n${'${Content}'}\n\n### ${'${Second column}'}\n\n${'${Content}'}\n:::endcol\n${'${}'}` : `:::${name}\n\n### ${'${First column}'}\n\n${'${Content}'}\n\n### ${'${Second column}'}\n\n${'${Content}'}\n\n### ${'${Third column}'}\n\n${'${Content}'}\n:::endcol\n${'${}'}`
59
+ },
60
+ getMdastRenderProperties (node) {
61
+ return {
62
+ dataCellTheme: typeof node.attributes?.cellTheme === 'string' ? node.attributes.cellTheme : undefined,
63
+ dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',
64
+ dataVlCellHeadingDepth: resolveCellHeadingDepth(node)
65
+ };
66
+ },
67
+ kind: 'grid',
68
+ openMarker: `:::${name}`,
69
+ public: true,
70
+ supportsAttributes: true,
71
+ tagName: 'div',
72
+ themeAttributes: {
73
+ cellTheme: 'cell',
74
+ theme: 'columns'
75
+ },
76
+ transformMdast (node, context) {
77
+ const cellHeadingDepth = resolveCellHeadingDepth(node);
78
+ node.children = groupGridChildren(node.children, cellHeadingDepth, context);
79
+ }
80
+ };
81
+ }
82
+ export const twoColumnDirective = createColumnDirective('2col', 2);
83
+ export const threeColumnDirective = createColumnDirective('3col', 3);
84
+ export const columnDirectives = [
85
+ twoColumnDirective,
86
+ threeColumnDirective
87
+ ];
88
+
89
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/directives/definitions/columns.ts"],"sourcesContent":["import type { Heading } from 'mdast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type {\n DirectiveChild,\n GridDirectiveName,\n LayoutDirectiveDefinition,\n LayoutDirectiveTransformContext,\n} from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { makeCellDirective } from './cell.js'\n\nfunction isContainerDirective(node: unknown): node is ContainerDirective {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n (node as { type?: string }).type === 'containerDirective',\n )\n}\n\nfunction isHeading(node: DirectiveChild): node is Heading {\n return node.type === 'heading'\n}\n\nfunction isLayoutBoundaryDirective(name: string): boolean {\n return name === 'section' || name === '2col' || name === '3col' || name === 'cell'\n}\n\nfunction isStructuralDirectiveChild(\n node: DirectiveChild,\n context: LayoutDirectiveTransformContext,\n): node is ContainerDirective {\n return (\n isContainerDirective(node) &&\n context.isSupportedDirectiveName(node.name) &&\n isLayoutBoundaryDirective(node.name)\n )\n}\n\nfunction resolveCellHeadingDepth(node: ContainerDirective): number {\n return typeof node.data?.vlCellHeadingDepth === 'number' ? node.data.vlCellHeadingDepth : 3\n}\n\nfunction groupGridChildren(\n children: DirectiveChild[],\n cellHeadingDepth: number,\n context: LayoutDirectiveTransformContext,\n): DirectiveChild[] {\n const grouped: DirectiveChild[] = []\n let currentCell: DirectiveChild[] = []\n\n const flushCell = () => {\n if (currentCell.length === 0) return\n grouped.push(makeCellDirective(currentCell))\n currentCell = []\n }\n\n for (const child of children) {\n if (isStructuralDirectiveChild(child, context)) {\n flushCell()\n grouped.push(child)\n continue\n }\n\n if (isHeading(child) && child.depth === cellHeadingDepth) flushCell()\n\n currentCell.push(child)\n }\n\n flushCell()\n\n return grouped\n}\n\nfunction createColumnDirective(name: GridDirectiveName, columns: 2 | 3): LayoutDirectiveDefinition {\n return {\n name,\n allowedAttributes: ['cellTheme', 'theme'],\n applyHast(node, config, { groupChildrenIntoCells, mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'columns',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cellTheme =\n typeof node.properties.dataCellTheme === 'string' ? node.properties.dataCellTheme : undefined\n const resolvedCellTheme = cellTheme\n ? resolveDirectiveTheme('cell', cellTheme, config.themes)\n : undefined\n\n for (const child of node.children)\n if (\n child.type === 'element' &&\n child.properties?.dataVlLayout === 'cell' &&\n typeof child.properties.dataTheme !== 'string' &&\n cellTheme\n )\n child.properties.dataTheme = cellTheme\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n columns === 2 ? 'md:grid-cols-2' : 'md:grid-cols-3',\n )\n\n const hasExplicitCells = node.children.some(\n (child) =>\n child.type === 'element' && child.properties?.dataVlLayout === 'cell',\n )\n\n if (!hasExplicitCells)\n node.children = groupChildrenIntoCells(\n node.children,\n config.columnClassName,\n resolvedCellTheme,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: `${columns}-column layout`,\n snippet:\n columns === 2\n ? `:::${name}\\n\\n### ${'${First column}'}\\n\\n${'${Content}'}\\n\\n### ${'${Second column}'}\\n\\n${'${Content}'}\\n:::endcol\\n${'${}'}`\n : `:::${name}\\n\\n### ${'${First column}'}\\n\\n${'${Content}'}\\n\\n### ${'${Second column}'}\\n\\n${'${Content}'}\\n\\n### ${'${Third column}'}\\n\\n${'${Content}'}\\n:::endcol\\n${'${}'}`,\n },\n getMdastRenderProperties(node) {\n return {\n dataCellTheme:\n typeof node.attributes?.cellTheme === 'string' ? node.attributes.cellTheme : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataVlCellHeadingDepth: resolveCellHeadingDepth(node),\n }\n },\n kind: 'grid',\n openMarker: `:::${name}`,\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n cellTheme: 'cell',\n theme: 'columns',\n },\n transformMdast(node, context) {\n const cellHeadingDepth = resolveCellHeadingDepth(node)\n node.children = groupGridChildren(node.children, cellHeadingDepth, context)\n },\n }\n}\n\nexport const twoColumnDirective = createColumnDirective('2col', 2)\nexport const threeColumnDirective = createColumnDirective('3col', 3)\nexport const columnDirectives = [twoColumnDirective, threeColumnDirective]\n"],"names":["resolveDirectiveTheme","makeCellDirective","isContainerDirective","node","Boolean","type","isHeading","isLayoutBoundaryDirective","name","isStructuralDirectiveChild","context","isSupportedDirectiveName","resolveCellHeadingDepth","data","vlCellHeadingDepth","groupGridChildren","children","cellHeadingDepth","grouped","currentCell","flushCell","length","push","child","depth","createColumnDirective","columns","allowedAttributes","applyHast","config","groupChildrenIntoCells","mergeClassNames","theme","properties","dataTheme","undefined","themes","cellTheme","dataCellTheme","resolvedCellTheme","dataVlLayout","className","hookClassName","modifierClassName","classes","hasExplicitCells","some","columnClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","dataVlCellHeadingDepth","kind","openMarker","public","supportsAttributes","tagName","themeAttributes","transformMdast","twoColumnDirective","threeColumnDirective","columnDirectives"],"mappings":"AAUA,SAASA,qBAAqB,QAAQ,eAAc;AACpD,SAASC,iBAAiB,QAAQ,YAAW;AAE7C,SAASC,qBAAqBC,IAAa;IACzC,OAAOC,QACLD,QACE,OAAOA,SAAS,YAChB,UAAUA,QACV,AAACA,KAA2BE,IAAI,KAAK;AAE3C;AAEA,SAASC,UAAUH,IAAoB;IACrC,OAAOA,KAAKE,IAAI,KAAK;AACvB;AAEA,SAASE,0BAA0BC,IAAY;IAC7C,OAAOA,SAAS,aAAaA,SAAS,UAAUA,SAAS,UAAUA,SAAS;AAC9E;AAEA,SAASC,2BACPN,IAAoB,EACpBO,OAAwC;IAExC,OACER,qBAAqBC,SACrBO,QAAQC,wBAAwB,CAACR,KAAKK,IAAI,KAC1CD,0BAA0BJ,KAAKK,IAAI;AAEvC;AAEA,SAASI,wBAAwBT,IAAwB;IACvD,OAAO,OAAOA,KAAKU,IAAI,EAAEC,uBAAuB,WAAWX,KAAKU,IAAI,CAACC,kBAAkB,GAAG;AAC5F;AAEA,SAASC,kBACPC,QAA0B,EAC1BC,gBAAwB,EACxBP,OAAwC;IAExC,MAAMQ,UAA4B,EAAE;IACpC,IAAIC,cAAgC,EAAE;IAEtC,MAAMC,YAAY;QAChB,IAAID,YAAYE,MAAM,KAAK,GAAG;QAC9BH,QAAQI,IAAI,CAACrB,kBAAkBkB;QAC/BA,cAAc,EAAE;IAClB;IAEA,KAAK,MAAMI,SAASP,SAAU;QAC5B,IAAIP,2BAA2Bc,OAAOb,UAAU;YAC9CU;YACAF,QAAQI,IAAI,CAACC;YACb;QACF;QAEA,IAAIjB,UAAUiB,UAAUA,MAAMC,KAAK,KAAKP,kBAAkBG;QAE1DD,YAAYG,IAAI,CAACC;IACnB;IAEAH;I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,CAAC,GAAG,EAAElB,KAAK,QAAQ,EAAE,kBAAkB,IAAI,EAAE,aAAa,QAAQ,EAAE,mBAAmB,IAAI,EAAE,aAAa,aAAa,EAAE,OAAO,GAChI,CAAC,GAAG,EAAEA,KAAK,QAAQ,EAAE,kBAAkB,IAAI,EAAE,aAAa,QAAQ,EAAE,mBAAmB,IAAI,EAAE,aAAa,QAAQ,EAAE,kBAAkB,IAAI,EAAE,aAAa,aAAa,EAAE,OAAO;QACvL;QACA4C,0BAAyBjD,IAAI;YAC3B,OAAO;gBACLmC,eACE,OAAOnC,KAAKkD,UAAU,EAAEhB,cAAc,WAAWlC,KAAKkD,UAAU,CAAChB,SAAS,GAAGF;gBAC/ED,WAAW,OAAO/B,KAAKkD,UAAU,EAAErB,UAAU,WAAW7B,KAAKkD,UAAU,CAACrB,KAAK,GAAG;gBAChFsB,wBAAwB1C,wBAAwBT;YAClD;QACF;QACAoD,MAAM;QACNC,YAAY,CAAC,GAAG,EAAEhD,MAAM;QACxBiD,QAAQ;QACRC,oBAAoB;QACpBC,SAAS;QACTC,iBAAiB;YACfvB,WAAW;YACXL,OAAO;QACT;QACA6B,gBAAe1D,IAAI,EAAEO,OAAO;YAC1B,MAAMO,mBAAmBL,wBAAwBT;YACjDA,KAAKa,QAAQ,GAAGD,kBAAkBZ,KAAKa,QAAQ,EAAEC,kBAAkBP;QACrE;IACF;AACF;AAEA,OAAO,MAAMoD,qBAAqBrC,sBAAsB,QAAQ,GAAE;AAClE,OAAO,MAAMsC,uBAAuBtC,sBAAsB,QAAQ,GAAE;AACpE,OAAO,MAAMuC,mBAAmB;IAACF;IAAoBC;CAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutDirectiveDefinition } from '../types.js';
2
+ export declare const detailsDirective: LayoutDirectiveDefinition;
@@ -0,0 +1,76 @@
1
+ import { resolveDirectiveTheme } from '../themes.js';
2
+ const DEFAULT_DETAILS_TITLE = 'Details';
3
+ function getTitle(node) {
4
+ const title = node.attributes?.title;
5
+ return typeof title === 'string' && title.trim() ? title.trim() : DEFAULT_DETAILS_TITLE;
6
+ }
7
+ export const detailsDirective = {
8
+ name: 'details',
9
+ allowedAttributes: [
10
+ 'open',
11
+ 'theme',
12
+ 'title'
13
+ ],
14
+ applyHast (node, config, { mergeClassNames }) {
15
+ const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : DEFAULT_DETAILS_TITLE;
16
+ const theme = resolveDirectiveTheme('details', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
17
+ const children = node.children;
18
+ node.properties.dataTheme = theme.name;
19
+ node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
20
+ node.children = [
21
+ {
22
+ type: 'element',
23
+ children: [
24
+ {
25
+ type: 'text',
26
+ value: title
27
+ }
28
+ ],
29
+ properties: {
30
+ className: [
31
+ 'cursor-pointer text-sm font-semibold tracking-wide'
32
+ ]
33
+ },
34
+ tagName: 'summary'
35
+ },
36
+ {
37
+ type: 'element',
38
+ children,
39
+ properties: {
40
+ className: [
41
+ 'mt-3 space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'
42
+ ],
43
+ dataDirectiveBody: 'details'
44
+ },
45
+ tagName: 'div'
46
+ }
47
+ ];
48
+ },
49
+ defaultAttributes: {
50
+ title: DEFAULT_DETAILS_TITLE
51
+ },
52
+ description: 'Native disclosure block for optional details.',
53
+ editor: {
54
+ detail: 'Static directive',
55
+ label: 'Details',
56
+ snippet: ':::details {title="${Details}"}\n${Content}\n:::\n${}'
57
+ },
58
+ getMdastRenderProperties (node) {
59
+ return {
60
+ dataDirective: 'details',
61
+ dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',
62
+ dataTitle: getTitle(node),
63
+ open: node.attributes?.open === 'true'
64
+ };
65
+ },
66
+ kind: 'details',
67
+ openMarker: ':::details',
68
+ public: true,
69
+ supportsAttributes: true,
70
+ tagName: 'details',
71
+ themeAttributes: {
72
+ theme: 'details'
73
+ }
74
+ };
75
+
76
+ //# sourceMappingURL=details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/directives/definitions/details.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\n\nconst DEFAULT_DETAILS_TITLE = 'Details'\n\nfunction getTitle(node: ContainerDirective): string {\n const title = node.attributes?.title\n\n return typeof title === 'string' && title.trim() ? title.trim() : DEFAULT_DETAILS_TITLE\n}\n\nexport const detailsDirective: LayoutDirectiveDefinition = {\n name: 'details',\n allowedAttributes: ['open', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : DEFAULT_DETAILS_TITLE\n const theme = resolveDirectiveTheme(\n 'details',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n\n node.children = [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: {\n className: ['cursor-pointer text-sm font-semibold tracking-wide'],\n },\n tagName: 'summary',\n },\n {\n type: 'element',\n children,\n properties: {\n className: ['mt-3 space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'],\n dataDirectiveBody: 'details',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n title: DEFAULT_DETAILS_TITLE,\n },\n description: 'Native disclosure block for optional details.',\n editor: {\n detail: 'Static directive',\n label: 'Details',\n snippet: ':::details {title=\"${Details}\"}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'details',\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataTitle: getTitle(node),\n open: node.attributes?.open === 'true',\n }\n },\n kind: 'details',\n openMarker: ':::details',\n public: true,\n supportsAttributes: true,\n tagName: 'details',\n themeAttributes: {\n theme: 'details',\n },\n}\n"],"names":["resolveDirectiveTheme","DEFAULT_DETAILS_TITLE","getTitle","node","title","attributes","trim","detailsDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataTitle","theme","dataTheme","undefined","themes","children","className","hookClassName","modifierClassName","classes","type","value","tagName","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","open","kind","openMarker","public","supportsAttributes","themeAttributes"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD,MAAMC,wBAAwB;AAE9B,SAASC,SAASC,IAAwB;IACxC,MAAMC,QAAQD,KAAKE,UAAU,EAAED;IAE/B,OAAO,OAAOA,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKL;AACpE;AAEA,OAAO,MAAMM,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;QAAQ;QAAS;KAAQ;IAC7CC,WAAUP,IAAI,EAAEQ,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMR,QAAQ,OAAOD,KAAKU,UAAU,CAACC,SAAS,KAAK,WAAWX,KAAKU,UAAU,CAACC,SAAS,GAAGb;QAC1F,MAAMc,QAAQf,sBACZ,WACA,OAAOG,KAAKU,UAAU,CAACG,SAAS,KAAK,WAAWb,KAAKU,UAAU,CAACG,SAAS,GAAGC,WAC5EN,OAAOO,MAAM;QAEf,MAAMC,WAAWhB,KAAKgB,QAAQ;QAE9BhB,KAAKU,UAAU,CAACG,SAAS,GAAGD,MAAMP,IAAI;QACtCL,KAAKU,UAAU,CAACO,SAAS,GAAGR,gBAC1B,aACAG,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO;QAGfpB,KAAKgB,QAAQ,GAAG;YACd;gBACEK,MAAM;gBACNL,UAAU;oBAAC;wBAAEK,MAAM;wBAAQC,OAAOrB;oBAAM;iBAAE;gBAC1CS,YAAY;oBACVO,WAAW;wBAAC;qBAAqD;gBACnE;gBACAM,SAAS;YACX;YACA;gBACEF,MAAM;gBACNL;gBACAN,YAAY;oBACVO,WAAW;wBAAC;qBAA4D;oBACxEO,mBAAmB;gBACrB;gBACAD,SAAS;YACX;SACD;IACH;IACAE,mBAAmB;QACjBxB,OAAOH;IACT;IACA4B,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyB/B,IAAI;QAC3B,OAAO;YACLgC,eAAe;YACfnB,WAAW,OAAOb,KAAKE,UAAU,EAAEU,UAAU,WAAWZ,KAAKE,UAAU,CAACU,KAAK,GAAG;YAChFD,WAAWZ,SAASC;YACpBiC,MAAMjC,KAAKE,UAAU,EAAE+B,SAAS;QAClC;IACF;IACAC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBd,SAAS;IACTe,iBAAiB;QACf1B,OAAO;IACT;AACF,EAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutDirectiveDefinition } from '../types.js';
2
+ export declare const sectionDirective: LayoutDirectiveDefinition;
@@ -0,0 +1,32 @@
1
+ import { resolveDirectiveTheme } from '../themes.js';
2
+ export const sectionDirective = {
3
+ name: 'section',
4
+ allowedAttributes: [
5
+ 'theme'
6
+ ],
7
+ applyHast (node, config, { mergeClassNames }) {
8
+ const theme = resolveDirectiveTheme('section', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
9
+ node.properties.dataTheme = theme.name;
10
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
11
+ },
12
+ editor: {
13
+ detail: 'Layout directive',
14
+ label: 'Layout section',
15
+ snippet: ':::section\n${Content}\n:::endsection\n${}'
16
+ },
17
+ getMdastRenderProperties (node) {
18
+ return {
19
+ dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default'
20
+ };
21
+ },
22
+ kind: 'section',
23
+ openMarker: ':::section',
24
+ public: true,
25
+ supportsAttributes: true,
26
+ tagName: 'section',
27
+ themeAttributes: {
28
+ theme: 'section'
29
+ }
30
+ };
31
+
32
+ //# sourceMappingURL=section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/directives/definitions/section.ts"],"sourcesContent":["import type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const sectionDirective: LayoutDirectiveDefinition = {\n name: 'section',\n allowedAttributes: ['theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'section',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n config.sectionClassName,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout section',\n snippet: ':::section\\n${Content}\\n:::endsection\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'section',\n openMarker: ':::section',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n theme: 'section',\n },\n}\n"],"names":["resolveDirectiveTheme","sectionDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","sectionClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","openMarker","public","supportsAttributes","tagName","themeAttributes"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;KAAQ;IAC5BC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQR,sBACZ,WACA,OAAOK,KAAKI,UAAU,CAACC,SAAS,KAAK,WAAWL,KAAKI,UAAU,CAACC,SAAS,GAAGC,WAC5EL,OAAOM,MAAM;QAGfP,KAAKI,UAAU,CAACC,SAAS,GAAGF,MAAMN,IAAI;QACtCG,KAAKI,UAAU,CAACI,SAAS,GAAGN,gBAC1BC,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO,EACbV,OAAOW,gBAAgB;IAE3B;IACAC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBjB,IAAI;QAC3B,OAAO;YACLK,WAAW,OAAOL,KAAKkB,UAAU,EAAEf,UAAU,WAAWH,KAAKkB,UAAU,CAACf,KAAK,GAAG;QAClF;IACF;IACAgB,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfrB,OAAO;IACT;AACF,EAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutDirectiveDefinition } from '../types.js';
2
+ export declare const stepsDirective: LayoutDirectiveDefinition;
@@ -0,0 +1,242 @@
1
+ import { DIRECTIVE_SURFACE_NESTED_CODE_CLASS } from '../../styles/directiveSurface.js';
2
+ import { resolveDirectiveTheme } from '../themes.js';
3
+ import { CARD_BODY_CLASS_NAMES } from './card.js';
4
+ const STEP_VARIANTS = [
5
+ 'default',
6
+ 'cards'
7
+ ];
8
+ const STEP_CARD_LAYOUTS = [
9
+ 'stack',
10
+ 'grid'
11
+ ];
12
+ const STEP_CARD_COLUMNS = [
13
+ '1',
14
+ '2',
15
+ '3',
16
+ '4',
17
+ 'auto'
18
+ ];
19
+ function isStepVariant(value) {
20
+ return typeof value === 'string' && STEP_VARIANTS.includes(value);
21
+ }
22
+ function isStepCardLayout(value) {
23
+ return typeof value === 'string' && STEP_CARD_LAYOUTS.includes(value);
24
+ }
25
+ function isStepCardColumns(value) {
26
+ return typeof value === 'string' && STEP_CARD_COLUMNS.includes(value);
27
+ }
28
+ function resolveStepsVariant(node) {
29
+ const variant = node.attributes?.variant;
30
+ return isStepVariant(variant) ? variant : 'default';
31
+ }
32
+ function resolveCardStepLayout(node) {
33
+ const layout = node.attributes?.layout;
34
+ return isStepCardLayout(layout) ? layout : 'stack';
35
+ }
36
+ function resolveCardStepColumns(node) {
37
+ const columns = node.attributes?.columns;
38
+ return isStepCardColumns(columns) ? columns : '2';
39
+ }
40
+ function resolveCardStepNumbered(node) {
41
+ const numbered = node.attributes?.numbered;
42
+ if (numbered === undefined) return true;
43
+ if (typeof numbered !== 'string') return true;
44
+ return numbered !== 'false';
45
+ }
46
+ function isElement(node) {
47
+ return node.type === 'element';
48
+ }
49
+ function isStepHeading(node) {
50
+ return isElement(node) && [
51
+ 'h2',
52
+ 'h3',
53
+ 'h4'
54
+ ].includes(node.tagName);
55
+ }
56
+ function makeStep(children, index) {
57
+ return {
58
+ type: 'element',
59
+ children,
60
+ properties: {
61
+ className: [
62
+ 'relative pl-4 [&>:first-child]:mt-0 [&>:last-child]:mb-0',
63
+ DIRECTIVE_SURFACE_NESTED_CODE_CLASS
64
+ ],
65
+ dataStep: String(index + 1)
66
+ },
67
+ tagName: 'li'
68
+ };
69
+ }
70
+ function makeCardStep(children, index, numbered, stepTheme) {
71
+ return {
72
+ type: 'element',
73
+ children: [
74
+ {
75
+ type: 'element',
76
+ children: [
77
+ ...numbered ? [
78
+ {
79
+ type: 'element',
80
+ children: [
81
+ {
82
+ type: 'text',
83
+ value: String(index + 1)
84
+ }
85
+ ],
86
+ properties: {
87
+ className: [
88
+ 'mb-3 inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/25 bg-black/10 text-sm font-semibold dark:bg-white/10'
89
+ ],
90
+ dataStepNumber: String(index + 1)
91
+ },
92
+ tagName: 'span'
93
+ }
94
+ ] : [],
95
+ ...children
96
+ ],
97
+ properties: {
98
+ className: [
99
+ stepTheme.hookClassName,
100
+ stepTheme.modifierClassName,
101
+ stepTheme.classes,
102
+ CARD_BODY_CLASS_NAMES,
103
+ DIRECTIVE_SURFACE_NESTED_CODE_CLASS
104
+ ],
105
+ dataStepCard: '',
106
+ dataTheme: stepTheme.name
107
+ },
108
+ tagName: 'article'
109
+ }
110
+ ],
111
+ properties: {
112
+ className: [
113
+ 'list-none'
114
+ ],
115
+ dataStep: String(index + 1)
116
+ },
117
+ tagName: 'li'
118
+ };
119
+ }
120
+ function groupStepChildren(children, columns, layout, numbered, variant, stepTheme) {
121
+ const groups = [];
122
+ let current = [];
123
+ const makeStepElement = variant === 'cards' ? (group, index)=>makeCardStep(group, index, numbered, stepTheme) : makeStep;
124
+ const gridColumnsClassNames = {
125
+ '1': 'grid-cols-1',
126
+ '2': 'grid-cols-1 md:grid-cols-2',
127
+ '3': 'grid-cols-1 md:grid-cols-3',
128
+ '4': 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4',
129
+ auto: 'grid-cols-1 md:grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]'
130
+ };
131
+ for (const child of children){
132
+ if (isStepHeading(child) && current.length > 0) {
133
+ groups.push(current);
134
+ current = [
135
+ child
136
+ ];
137
+ continue;
138
+ }
139
+ current.push(child);
140
+ }
141
+ if (current.length > 0) groups.push(current);
142
+ return [
143
+ {
144
+ type: 'element',
145
+ children: groups.map(makeStepElement),
146
+ properties: {
147
+ className: variant === 'cards' ? layout === 'grid' ? [
148
+ 'm-0 grid list-none gap-4 p-0',
149
+ gridColumnsClassNames[columns]
150
+ ] : [
151
+ 'm-0 flex list-none flex-col gap-4 p-0'
152
+ ] : [
153
+ 'm-0 list-decimal space-y-6 pl-6'
154
+ ]
155
+ },
156
+ tagName: 'ol'
157
+ }
158
+ ];
159
+ }
160
+ export const stepsDirective = {
161
+ name: 'steps',
162
+ allowedAttributes: [
163
+ 'columns',
164
+ 'layout',
165
+ 'numbered',
166
+ 'stepTheme',
167
+ 'theme',
168
+ 'variant'
169
+ ],
170
+ applyHast (node, config, { mergeClassNames }) {
171
+ const variant = typeof node.properties.dataVariant === 'string' && isStepVariant(node.properties.dataVariant) ? node.properties.dataVariant : 'default';
172
+ const layout = typeof node.properties.dataLayout === 'string' && isStepCardLayout(node.properties.dataLayout) ? node.properties.dataLayout : 'stack';
173
+ const columns = typeof node.properties.dataColumns === 'string' && isStepCardColumns(node.properties.dataColumns) ? node.properties.dataColumns : '2';
174
+ const numbered = node.properties.dataNumbered !== 'false';
175
+ const theme = resolveDirectiveTheme('steps', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
176
+ const stepTheme = resolveDirectiveTheme('card', typeof node.properties.dataStepTheme === 'string' ? node.properties.dataStepTheme : undefined, config.themes);
177
+ node.properties.dataTheme = theme.name;
178
+ node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
179
+ node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme);
180
+ },
181
+ attributeValues: {
182
+ columns: STEP_CARD_COLUMNS,
183
+ layout: STEP_CARD_LAYOUTS,
184
+ numbered: [
185
+ 'true',
186
+ 'false'
187
+ ],
188
+ variant: STEP_VARIANTS
189
+ },
190
+ description: 'Structured ordered flow for tutorials and install steps.',
191
+ editor: {
192
+ detail: 'Docs directive',
193
+ label: 'Steps',
194
+ snippet: ':::steps\n\n### ${Step title}\n\n${Content}\n\n:::\n${}',
195
+ snippets: [
196
+ {
197
+ detail: 'Docs directive',
198
+ label: 'Steps cards stack',
199
+ snippet: ':::steps {variant="cards" layout="stack" numbered}\n\n### ${Step title}\n\n${Content}\n\n:::\n${}'
200
+ },
201
+ {
202
+ detail: 'Docs directive',
203
+ label: 'Steps cards grid',
204
+ snippet: ':::steps {variant="cards" layout="grid" columns="${2}" numbered}\n\n### ${First step}\n\n${Content}\n\n### ${Second step}\n\n${Content}\n\n:::\n${}'
205
+ }
206
+ ]
207
+ },
208
+ getMdastRenderProperties (node) {
209
+ const variant = resolveStepsVariant(node);
210
+ const layout = resolveCardStepLayout(node);
211
+ const numbered = resolveCardStepNumbered(node);
212
+ const columns = resolveCardStepColumns(node);
213
+ return {
214
+ dataColumns: variant === 'cards' && layout === 'grid' ? columns : undefined,
215
+ dataDirective: 'steps',
216
+ dataLayout: variant === 'cards' ? layout : undefined,
217
+ dataNumbered: variant === 'cards' ? String(numbered) : undefined,
218
+ dataStepTheme: typeof node.attributes?.stepTheme === 'string' ? node.attributes.stepTheme : undefined,
219
+ dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',
220
+ dataVariant: variant === 'default' ? undefined : variant
221
+ };
222
+ },
223
+ kind: 'steps',
224
+ openMarker: ':::steps',
225
+ public: true,
226
+ supportsAttributes: true,
227
+ tagName: 'section',
228
+ themeAttributes: {
229
+ stepTheme: 'card',
230
+ theme: 'steps'
231
+ },
232
+ validateAttributes ({ attributes }) {
233
+ const warnings = [];
234
+ if (typeof attributes.variant === 'string' && !isStepVariant(attributes.variant)) warnings.push(`Unsupported steps variant "${attributes.variant}". Falling back to "default".`);
235
+ if (typeof attributes.layout === 'string' && !isStepCardLayout(attributes.layout)) warnings.push(`Unsupported steps layout "${attributes.layout}". Falling back to "stack".`);
236
+ if (typeof attributes.columns === 'string' && !isStepCardColumns(attributes.columns)) warnings.push(`Invalid steps columns "${attributes.columns}". Falling back to "2".`);
237
+ if (typeof attributes.numbered === 'string' && attributes.numbered !== 'true' && attributes.numbered !== 'false') warnings.push(`Invalid steps numbered value "${attributes.numbered}". Falling back to "true".`);
238
+ return warnings;
239
+ }
240
+ };
241
+
242
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/directives/definitions/steps.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { DIRECTIVE_SURFACE_NESTED_CODE_CLASS } from '../../styles/directiveSurface.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { CARD_BODY_CLASS_NAMES } from './card.js'\n\nconst STEP_VARIANTS = ['default', 'cards'] as const\nconst STEP_CARD_LAYOUTS = ['stack', 'grid'] as const\nconst STEP_CARD_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\n\ntype StepVariant = (typeof STEP_VARIANTS)[number]\ntype StepCardLayout = (typeof STEP_CARD_LAYOUTS)[number]\ntype StepCardColumns = (typeof STEP_CARD_COLUMNS)[number]\n\nfunction isStepVariant(value: unknown): value is StepVariant {\n return typeof value === 'string' && STEP_VARIANTS.includes(value as StepVariant)\n}\n\nfunction isStepCardLayout(value: unknown): value is StepCardLayout {\n return typeof value === 'string' && STEP_CARD_LAYOUTS.includes(value as StepCardLayout)\n}\n\nfunction isStepCardColumns(value: unknown): value is StepCardColumns {\n return typeof value === 'string' && STEP_CARD_COLUMNS.includes(value as StepCardColumns)\n}\n\nfunction resolveStepsVariant(node: ContainerDirective): StepVariant {\n const variant = node.attributes?.variant\n\n return isStepVariant(variant) ? variant : 'default'\n}\n\nfunction resolveCardStepLayout(node: ContainerDirective): StepCardLayout {\n const layout = node.attributes?.layout\n\n return isStepCardLayout(layout) ? layout : 'stack'\n}\n\nfunction resolveCardStepColumns(node: ContainerDirective): StepCardColumns {\n const columns = node.attributes?.columns\n\n return isStepCardColumns(columns) ? columns : '2'\n}\n\nfunction resolveCardStepNumbered(node: ContainerDirective): boolean {\n const numbered = node.attributes?.numbered\n\n if (numbered === undefined) return true\n if (typeof numbered !== 'string') return true\n\n return numbered !== 'false'\n}\n\nfunction isElement(node: ElementContent): node is Element {\n return node.type === 'element'\n}\n\nfunction isStepHeading(node: ElementContent): node is Element {\n return isElement(node) && ['h2', 'h3', 'h4'].includes(node.tagName)\n}\n\nfunction makeStep(children: ElementContent[], index: number): Element {\n return {\n type: 'element',\n children,\n properties: {\n className: [\n 'relative pl-4 [&>:first-child]:mt-0 [&>:last-child]:mb-0',\n DIRECTIVE_SURFACE_NESTED_CODE_CLASS,\n ],\n dataStep: String(index + 1),\n },\n tagName: 'li',\n }\n}\n\nfunction makeCardStep(\n children: ElementContent[],\n index: number,\n numbered: boolean,\n stepTheme: ReturnType<typeof resolveDirectiveTheme>,\n): Element {\n return {\n type: 'element',\n children: [\n {\n type: 'element',\n children: [\n ...(numbered\n ? [\n {\n type: 'element' as const,\n children: [{ type: 'text' as const, value: String(index + 1) }],\n properties: {\n className: [\n 'mb-3 inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/25 bg-black/10 text-sm font-semibold dark:bg-white/10',\n ],\n dataStepNumber: String(index + 1),\n },\n tagName: 'span',\n },\n ]\n : []),\n ...children,\n ],\n properties: {\n className: [\n stepTheme.hookClassName,\n stepTheme.modifierClassName,\n stepTheme.classes,\n CARD_BODY_CLASS_NAMES,\n DIRECTIVE_SURFACE_NESTED_CODE_CLASS,\n ],\n dataStepCard: '',\n dataTheme: stepTheme.name,\n },\n tagName: 'article',\n },\n ],\n properties: {\n className: ['list-none'],\n dataStep: String(index + 1),\n },\n tagName: 'li',\n }\n}\n\nfunction groupStepChildren(\n children: ElementContent[],\n columns: StepCardColumns,\n layout: StepCardLayout,\n numbered: boolean,\n variant: StepVariant,\n stepTheme: ReturnType<typeof resolveDirectiveTheme>,\n): ElementContent[] {\n const groups: ElementContent[][] = []\n let current: ElementContent[] = []\n const makeStepElement =\n variant === 'cards'\n ? (group: ElementContent[], index: number) => makeCardStep(group, index, numbered, stepTheme)\n : makeStep\n const gridColumnsClassNames: Record<StepCardColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-1 md:grid-cols-2',\n '3': 'grid-cols-1 md:grid-cols-3',\n '4': 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4',\n auto: 'grid-cols-1 md:grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]',\n }\n\n for (const child of children) {\n if (isStepHeading(child) && current.length > 0) {\n groups.push(current)\n current = [child]\n continue\n }\n\n current.push(child)\n }\n\n if (current.length > 0) groups.push(current)\n\n return [\n {\n type: 'element',\n children: groups.map(makeStepElement),\n properties: {\n className:\n variant === 'cards'\n ? layout === 'grid'\n ? ['m-0 grid list-none gap-4 p-0', gridColumnsClassNames[columns]]\n : ['m-0 flex list-none flex-col gap-4 p-0']\n : ['m-0 list-decimal space-y-6 pl-6'],\n },\n tagName: 'ol',\n },\n ]\n}\n\nexport const stepsDirective: LayoutDirectiveDefinition = {\n name: 'steps',\n allowedAttributes: ['columns', 'layout', 'numbered', 'stepTheme', 'theme', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant =\n typeof node.properties.dataVariant === 'string' && isStepVariant(node.properties.dataVariant)\n ? node.properties.dataVariant\n : 'default'\n const layout =\n typeof node.properties.dataLayout === 'string' && isStepCardLayout(node.properties.dataLayout)\n ? node.properties.dataLayout\n : 'stack'\n const columns =\n typeof node.properties.dataColumns === 'string' && isStepCardColumns(node.properties.dataColumns)\n ? node.properties.dataColumns\n : '2'\n const numbered = node.properties.dataNumbered !== 'false'\n const theme = resolveDirectiveTheme(\n 'steps',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const stepTheme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataStepTheme === 'string'\n ? node.properties.dataStepTheme\n : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme)\n },\n attributeValues: {\n columns: STEP_CARD_COLUMNS,\n layout: STEP_CARD_LAYOUTS,\n numbered: ['true', 'false'],\n variant: STEP_VARIANTS,\n },\n description: 'Structured ordered flow for tutorials and install steps.',\n editor: {\n detail: 'Docs directive',\n label: 'Steps',\n snippet: ':::steps\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n snippets: [\n {\n detail: 'Docs directive',\n label: 'Steps cards stack',\n snippet:\n ':::steps {variant=\"cards\" layout=\"stack\" numbered}\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n {\n detail: 'Docs directive',\n label: 'Steps cards grid',\n snippet:\n ':::steps {variant=\"cards\" layout=\"grid\" columns=\"${2}\" numbered}\\n\\n### ${First step}\\n\\n${Content}\\n\\n### ${Second step}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n ],\n },\n getMdastRenderProperties(node) {\n const variant = resolveStepsVariant(node)\n const layout = resolveCardStepLayout(node)\n const numbered = resolveCardStepNumbered(node)\n const columns = resolveCardStepColumns(node)\n\n return {\n dataColumns: variant === 'cards' && layout === 'grid' ? columns : undefined,\n dataDirective: 'steps',\n dataLayout: variant === 'cards' ? layout : undefined,\n dataNumbered: variant === 'cards' ? String(numbered) : undefined,\n dataStepTheme:\n typeof node.attributes?.stepTheme === 'string' ? node.attributes.stepTheme : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataVariant: variant === 'default' ? undefined : variant,\n }\n },\n kind: 'steps',\n openMarker: ':::steps',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n stepTheme: 'card',\n theme: 'steps',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isStepVariant(attributes.variant))\n warnings.push(\n `Unsupported steps variant \"${attributes.variant}\". Falling back to \"default\".`,\n )\n if (typeof attributes.layout === 'string' && !isStepCardLayout(attributes.layout))\n warnings.push(`Unsupported steps layout \"${attributes.layout}\". Falling back to \"stack\".`)\n if (typeof attributes.columns === 'string' && !isStepCardColumns(attributes.columns))\n warnings.push(`Invalid steps columns \"${attributes.columns}\". Falling back to \"2\".`)\n if (\n typeof attributes.numbered === 'string' &&\n attributes.numbered !== 'true' &&\n attributes.numbered !== 'false'\n )\n warnings.push(\n `Invalid steps numbered value \"${attributes.numbered}\". Falling back to \"true\".`,\n )\n\n return warnings\n },\n}\n"],"names":["DIRECTIVE_SURFACE_NESTED_CODE_CLASS","resolveDirectiveTheme","CARD_BODY_CLASS_NAMES","STEP_VARIANTS","STEP_CARD_LAYOUTS","STEP_CARD_COLUMNS","isStepVariant","value","includes","isStepCardLayout","isStepCardColumns","resolveStepsVariant","node","variant","attributes","resolveCardStepLayout","layout","resolveCardStepColumns","columns","resolveCardStepNumbered","numbered","undefined","isElement","type","isStepHeading","tagName","makeStep","children","index","properties","className","dataStep","String","makeCardStep","stepTheme","dataStepNumber","hookClassName","modifierClassName","classes","dataStepCard","dataTheme","name","groupStepChildren","groups","current","makeStepElement","group","gridColumnsClassNames","auto","child","length","push","map","stepsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataVariant","dataLayout","dataColumns","dataNumbered","theme","themes","dataStepTheme","attributeValues","description","editor","detail","label","snippet","snippets","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings"],"mappings":"AAKA,SAASA,mCAAmC,QAAQ,mCAAkC;AACtF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,qBAAqB,QAAQ,YAAW;AAEjD,MAAMC,gBAAgB;IAAC;IAAW;CAAQ;AAC1C,MAAMC,oBAAoB;IAAC;IAAS;CAAO;AAC3C,MAAMC,oBAAoB;IAAC;IAAK;IAAK;IAAK;IAAK;CAAO;AAMtD,SAASC,cAAcC,KAAc;IACnC,OAAO,OAAOA,UAAU,YAAYJ,cAAcK,QAAQ,CAACD;AAC7D;AAEA,SAASE,iBAAiBF,KAAc;IACtC,OAAO,OAAOA,UAAU,YAAYH,kBAAkBI,QAAQ,CAACD;AACjE;AAEA,SAASG,kBAAkBH,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAYF,kBAAkBG,QAAQ,CAACD;AACjE;AAEA,SAASI,oBAAoBC,IAAwB;IACnD,MAAMC,UAAUD,KAAKE,UAAU,EAAED;IAEjC,OAAOP,cAAcO,WAAWA,UAAU;AAC5C;AAEA,SAASE,sBAAsBH,IAAwB;IACrD,MAAMI,SAASJ,KAAKE,UAAU,EAAEE;IAEhC,OAAOP,iBAAiBO,UAAUA,SAAS;AAC7C;AAEA,SAASC,uBAAuB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IAAI,CACX,CAAC,8BAA8B,EAAErC,WAAWM,QAAQ,CAAC,0BAA0B,CAAC;QAGpF,OAAO4D;IACT;AACF,EAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ContainerDirective } from 'mdast-util-directive';
2
+ import type { LayoutDirectiveDefinition } from '../types.js';
3
+ export declare function getTabLabel(node: ContainerDirective, index: number): string;
4
+ type TabAttributes = null | Record<string, boolean | null | string | undefined> | undefined;
5
+ export declare function getTabValueFromAttributes(attributes: TabAttributes, index: number): string;
6
+ export declare function isTabDisabled(attributes: TabAttributes): boolean;
7
+ export declare const tabDirective: LayoutDirectiveDefinition;
8
+ export {};
@@ -0,0 +1,59 @@
1
+ import { resolveDirectiveTheme, slugThemeName } from '../themes.js';
2
+ function getAttribute(node, name) {
3
+ const value = node.attributes?.[name];
4
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
5
+ }
6
+ export function getTabLabel(node, index) {
7
+ return getAttribute(node, 'label') ?? getAttribute(node, 'value') ?? `Tab ${index + 1}`;
8
+ }
9
+ export function getTabValueFromAttributes(attributes, index) {
10
+ const value = attributes?.value;
11
+ const label = attributes?.label;
12
+ const raw = typeof value === 'string' && value.trim() ? value.trim() : typeof label === 'string' && label.trim() ? label.trim() : `tab-${index + 1}`;
13
+ return slugThemeName(raw);
14
+ }
15
+ export function isTabDisabled(attributes) {
16
+ const disabled = attributes?.disabled;
17
+ if (disabled === true) return true;
18
+ if (typeof disabled !== 'string') return false;
19
+ return disabled !== 'false';
20
+ }
21
+ export const tabDirective = {
22
+ name: 'tab',
23
+ allowedAttributes: [
24
+ 'disabled',
25
+ 'label',
26
+ 'theme',
27
+ 'value'
28
+ ],
29
+ applyHast (node, config, { mergeClassNames }) {
30
+ const theme = resolveDirectiveTheme('tab', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
31
+ node.properties.dataTheme = theme.name;
32
+ node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes, 'vl-md-tab-panel');
33
+ },
34
+ description: 'Single tab panel. Usually nested inside :::tabs.',
35
+ editor: {
36
+ detail: 'Tabs directive',
37
+ label: 'Tab',
38
+ snippet: ':::tab {label="${Label}"}\n${Content}\n:::\n${}'
39
+ },
40
+ getMdastRenderProperties (node) {
41
+ return {
42
+ dataDirective: 'tab',
43
+ dataDisabled: isTabDisabled(node.attributes) ? 'true' : undefined,
44
+ dataLabel: getTabLabel(node, 0),
45
+ dataTheme: getAttribute(node, 'theme'),
46
+ dataValue: getTabValueFromAttributes(node.attributes, 0)
47
+ };
48
+ },
49
+ kind: 'tab',
50
+ openMarker: ':::tab',
51
+ public: true,
52
+ supportsAttributes: true,
53
+ tagName: 'section',
54
+ themeAttributes: {
55
+ theme: 'tab'
56
+ }
57
+ };
58
+
59
+ //# sourceMappingURL=tab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/directives/definitions/tab.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme, slugThemeName } from '../themes.js'\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nexport function getTabLabel(node: ContainerDirective, index: number): string {\n return getAttribute(node, 'label') ?? getAttribute(node, 'value') ?? `Tab ${index + 1}`\n}\n\ntype TabAttributes = null | Record<string, boolean | null | string | undefined> | undefined\n\nexport function getTabValueFromAttributes(attributes: TabAttributes, index: number): string {\n const value = attributes?.value\n const label = attributes?.label\n const raw =\n typeof value === 'string' && value.trim()\n ? value.trim()\n : typeof label === 'string' && label.trim()\n ? label.trim()\n : `tab-${index + 1}`\n\n return slugThemeName(raw)\n}\n\nexport function isTabDisabled(attributes: TabAttributes): boolean {\n const disabled = attributes?.disabled\n\n if (disabled === true) return true\n if (typeof disabled !== 'string') return false\n\n return disabled !== 'false'\n}\n\nexport const tabDirective: LayoutDirectiveDefinition = {\n name: 'tab',\n allowedAttributes: ['disabled', 'label', 'theme', 'value'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'tab',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n 'vl-md-tab-panel',\n )\n },\n description: 'Single tab panel. Usually nested inside :::tabs.',\n editor: {\n detail: 'Tabs directive',\n label: 'Tab',\n snippet: ':::tab {label=\"${Label}\"}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'tab',\n dataDisabled: isTabDisabled(node.attributes) ? 'true' : undefined,\n dataLabel: getTabLabel(node, 0),\n dataTheme: getAttribute(node, 'theme'),\n dataValue: getTabValueFromAttributes(node.attributes, 0),\n }\n },\n kind: 'tab',\n openMarker: ':::tab',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n theme: 'tab',\n },\n}\n"],"names":["resolveDirectiveTheme","slugThemeName","getAttribute","node","name","value","attributes","trim","undefined","getTabLabel","index","getTabValueFromAttributes","label","raw","isTabDisabled","disabled","tabDirective","allowedAttributes","applyHast","config","mergeClassNames","theme","properties","dataTheme","themes","className","hookClassName","modifierClassName","classes","description","editor","detail","snippet","getMdastRenderProperties","dataDirective","dataDisabled","dataLabel","dataValue","kind","openMarker","public","supportsAttributes","tagName","themeAttributes"],"mappings":"AAIA,SAASA,qBAAqB,EAAEC,aAAa,QAAQ,eAAc;AAEnE,SAASC,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMC,QAAQF,KAAKG,UAAU,EAAE,CAACF,KAAK;IAErC,OAAO,OAAOC,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKC;AACpE;AAEA,OAAO,SAASC,YAAYN,IAAwB,EAAEO,KAAa;IACjE,OA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AC9BkC,WAAW1B,0BAA0BR,KAAKG,UAAU,EAAE;QACxD;IACF;IACAgC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACftB,OAAO;IACT;AACF,EAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutDirectiveDefinition } from '../types.js';
2
+ export declare const tabsDirective: LayoutDirectiveDefinition;