payload-markdown 1.7.2 → 1.8.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 (169) hide show
  1. package/README.md +17 -0
  2. package/dist/agent/access.d.ts +1 -1
  3. package/dist/agent/access.js.map +1 -1
  4. package/dist/agent/guide.d.ts +3 -0
  5. package/dist/agent/guide.js +28 -2
  6. package/dist/agent/guide.js.map +1 -1
  7. package/dist/agent/palettes.d.ts +55 -0
  8. package/dist/agent/palettes.js +194 -0
  9. package/dist/agent/palettes.js.map +1 -0
  10. package/dist/agent/skill.d.ts +2 -2
  11. package/dist/agent/skill.js +2 -2
  12. package/dist/agent/skill.js.map +1 -1
  13. package/dist/agent/validate.d.ts +1 -1
  14. package/dist/agent/validate.js +3 -0
  15. package/dist/agent/validate.js.map +1 -1
  16. package/dist/appearance/PaletteRowLabel.client.d.ts +2 -0
  17. package/dist/appearance/PaletteRowLabel.client.js +70 -0
  18. package/dist/appearance/PaletteRowLabel.client.js.map +1 -0
  19. package/dist/appearance/config.d.ts +8 -0
  20. package/dist/appearance/config.js +172 -0
  21. package/dist/appearance/config.js.map +1 -0
  22. package/dist/appearance/options.d.ts +11 -0
  23. package/dist/appearance/options.js +15 -0
  24. package/dist/appearance/options.js.map +1 -0
  25. package/dist/appearance/runtime.d.ts +25 -0
  26. package/dist/appearance/runtime.js +126 -0
  27. package/dist/appearance/runtime.js.map +1 -0
  28. package/dist/components/MarkdownRenderer/Component.client.js +9 -19
  29. package/dist/components/MarkdownRenderer/Component.client.js.map +1 -1
  30. package/dist/components/MarkdownRenderer/Component.js +59 -21
  31. package/dist/components/MarkdownRenderer/Component.js.map +1 -1
  32. package/dist/components/MarkdownRenderer/index.css +93 -42
  33. package/dist/components/MarkdownRenderer/index.scss +128 -57
  34. package/dist/core/codeToHtml.js +6 -0
  35. package/dist/core/codeToHtml.js.map +1 -1
  36. package/dist/core/plugins/directiveBadge.js +2 -0
  37. package/dist/core/plugins/directiveBadge.js.map +1 -1
  38. package/dist/core/plugins/directiveButton.d.ts +1 -1
  39. package/dist/core/plugins/directiveButton.js +26 -6
  40. package/dist/core/plugins/directiveButton.js.map +1 -1
  41. package/dist/core/plugins/rehypeContentLayout.d.ts +12 -0
  42. package/dist/core/plugins/rehypeContentLayout.js +64 -0
  43. package/dist/core/plugins/rehypeContentLayout.js.map +1 -0
  44. package/dist/core/plugins/rehypeResolveIcons.js +10 -1
  45. package/dist/core/plugins/rehypeResolveIcons.js.map +1 -1
  46. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +8 -0
  47. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -1
  48. package/dist/core/plugins/remarkValidatePalettes.d.ts +9 -0
  49. package/dist/core/plugins/remarkValidatePalettes.js +51 -0
  50. package/dist/core/plugins/remarkValidatePalettes.js.map +1 -0
  51. package/dist/core/renderMarkdown.js +19 -4
  52. package/dist/core/renderMarkdown.js.map +1 -1
  53. package/dist/directive-spec.json +60 -0
  54. package/dist/directives/definitions/button.d.ts +1 -1
  55. package/dist/directives/definitions/button.js +9 -2
  56. package/dist/directives/definitions/button.js.map +1 -1
  57. package/dist/directives/definitions/callout.js +29 -13
  58. package/dist/directives/definitions/callout.js.map +1 -1
  59. package/dist/directives/definitions/card.d.ts +2 -2
  60. package/dist/directives/definitions/card.js +44 -11
  61. package/dist/directives/definitions/card.js.map +1 -1
  62. package/dist/directives/definitions/cards.js +19 -6
  63. package/dist/directives/definitions/cards.js.map +1 -1
  64. package/dist/directives/definitions/cell.js +4 -2
  65. package/dist/directives/definitions/cell.js.map +1 -1
  66. package/dist/directives/definitions/columns.js +2 -1
  67. package/dist/directives/definitions/columns.js.map +1 -1
  68. package/dist/directives/definitions/details.js +9 -3
  69. package/dist/directives/definitions/details.js.map +1 -1
  70. package/dist/directives/definitions/section.js +5 -1
  71. package/dist/directives/definitions/section.js.map +1 -1
  72. package/dist/directives/definitions/steps.js +38 -14
  73. package/dist/directives/definitions/steps.js.map +1 -1
  74. package/dist/directives/definitions/tab.js +2 -1
  75. package/dist/directives/definitions/tab.js.map +1 -1
  76. package/dist/directives/definitions/tabs.js +13 -6
  77. package/dist/directives/definitions/tabs.js.map +1 -1
  78. package/dist/directives/definitions/toc.js +2 -1
  79. package/dist/directives/definitions/toc.js.map +1 -1
  80. package/dist/directives/diagnostics.d.ts +5 -0
  81. package/dist/directives/diagnostics.js +26 -10
  82. package/dist/directives/diagnostics.js.map +1 -1
  83. package/dist/directives/iconPlaceholder.d.ts +9 -3
  84. package/dist/directives/iconPlaceholder.js +8 -1
  85. package/dist/directives/iconPlaceholder.js.map +1 -1
  86. package/dist/directives/palette.d.ts +23 -0
  87. package/dist/directives/palette.js +40 -0
  88. package/dist/directives/palette.js.map +1 -0
  89. package/dist/directives/shields.js +16 -3
  90. package/dist/directives/shields.js.map +1 -1
  91. package/dist/directives/spec.d.ts +6 -2
  92. package/dist/directives/spec.js +5 -0
  93. package/dist/directives/spec.js.map +1 -1
  94. package/dist/directives/themes.js +13 -13
  95. package/dist/directives/themes.js.map +1 -1
  96. package/dist/editor/directiveConfig.d.ts +15 -1
  97. package/dist/editor/directiveConfig.js +21 -1
  98. package/dist/editor/directiveConfig.js.map +1 -1
  99. package/dist/editor/directives/completions.d.ts +4 -2
  100. package/dist/editor/directives/completions.js +22 -3
  101. package/dist/editor/directives/completions.js.map +1 -1
  102. package/dist/editor/directives/diagnostics.d.ts +2 -2
  103. package/dist/editor/directives/diagnostics.js +10 -3
  104. package/dist/editor/directives/diagnostics.js.map +1 -1
  105. package/dist/exports/client.d.ts +4 -1
  106. package/dist/exports/client.js +5 -2
  107. package/dist/exports/client.js.map +1 -1
  108. package/dist/exports/render.d.ts +2 -1
  109. package/dist/exports/render.js +1 -0
  110. package/dist/exports/render.js.map +1 -1
  111. package/dist/field/MarkdownField/Component.js +54 -3
  112. package/dist/field/MarkdownField/Component.js.map +1 -1
  113. package/dist/icons/entries.d.ts +22 -0
  114. package/dist/icons/entries.js +50 -0
  115. package/dist/icons/entries.js.map +1 -0
  116. package/dist/icons/resolve.d.ts +2 -1
  117. package/dist/icons/resolve.js +2 -2
  118. package/dist/icons/resolve.js.map +1 -1
  119. package/dist/icons/sanitizeSvg.d.ts +12 -2
  120. package/dist/icons/sanitizeSvg.js +104 -3
  121. package/dist/icons/sanitizeSvg.js.map +1 -1
  122. package/dist/index.d.ts +11 -4
  123. package/dist/index.js +34 -3
  124. package/dist/index.js.map +1 -1
  125. package/dist/mcp/index.d.ts +2 -2
  126. package/dist/mcp/index.js +65 -4
  127. package/dist/mcp/index.js.map +1 -1
  128. package/dist/palettes/colors.d.ts +21 -0
  129. package/dist/palettes/colors.js +43 -0
  130. package/dist/palettes/colors.js.map +1 -0
  131. package/dist/palettes/contrast.d.ts +7 -0
  132. package/dist/palettes/contrast.js +63 -0
  133. package/dist/palettes/contrast.js.map +1 -0
  134. package/dist/palettes/defaults.d.ts +8 -0
  135. package/dist/palettes/defaults.js +275 -0
  136. package/dist/palettes/defaults.js.map +1 -0
  137. package/dist/palettes/diagnostics.d.ts +10 -0
  138. package/dist/palettes/diagnostics.js +38 -0
  139. package/dist/palettes/diagnostics.js.map +1 -0
  140. package/dist/palettes/index.d.ts +61 -0
  141. package/dist/palettes/index.js +246 -0
  142. package/dist/palettes/index.js.map +1 -0
  143. package/dist/render/renderMarkdown.d.ts +3 -1
  144. package/dist/render/renderMarkdown.js +9 -1
  145. package/dist/render/renderMarkdown.js.map +1 -1
  146. package/dist/runtime/index.d.ts +12 -1
  147. package/dist/runtime/index.js +23 -2
  148. package/dist/runtime/index.js.map +1 -1
  149. package/dist/styles/directiveSurface.d.ts +39 -5
  150. package/dist/styles/directiveSurface.js +56 -13
  151. package/dist/styles/directiveSurface.js.map +1 -1
  152. package/dist/types/core.d.ts +56 -0
  153. package/dist/types/core.js.map +1 -1
  154. package/dist/types.d.ts +46 -2
  155. package/dist/types.js.map +1 -1
  156. package/dist/version.d.ts +1 -1
  157. package/dist/version.js +1 -1
  158. package/dist/version.js.map +1 -1
  159. package/package.json +2 -1
  160. package/skills/payload-markdown/claude/SKILL.md +1 -0
  161. package/skills/payload-markdown/claude/reference/directive-spec.json +60 -0
  162. package/skills/payload-markdown/claude/reference/mcp-content-workflow.md +7 -0
  163. package/skills/payload-markdown/claude/reference/payload-markdown-directives.md +22 -2
  164. package/skills/payload-markdown/claude/skill.json +2 -2
  165. package/skills/payload-markdown/codex/SKILL.md +1 -0
  166. package/skills/payload-markdown/codex/reference/directive-spec.json +60 -0
  167. package/skills/payload-markdown/codex/reference/mcp-content-workflow.md +7 -0
  168. package/skills/payload-markdown/codex/reference/payload-markdown-directives.md +22 -2
  169. package/skills/payload-markdown/codex/skill.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/cards.ts"],"sourcesContent":["import type { Element } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\nimport { DEFAULT_CARD_LINK_SCOPE } from './card.js'\n\nexport const CARD_GRID_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\nexport const DEFAULT_CARD_GRID_COLUMNS = '3'\nexport const CARDS_LINK_SCOPES = ['section', 'card', 'title'] as const\nexport const DEFAULT_CARDS_LINK_SCOPE = 'section'\nexport const FALLBACK_CARDS_LINK_SCOPE = 'card'\n\nexport type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number]\nexport type CardsLinkScope = (typeof CARDS_LINK_SCOPES)[number]\n\nconst cardGridColumnClasses: Record<CardGridColumns, 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\nfunction isCardGridColumns(value: unknown): value is CardGridColumns {\n return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value as CardGridColumns)\n}\n\nfunction isCardsLinkScope(value: unknown): value is CardsLinkScope {\n return typeof value === 'string' && CARDS_LINK_SCOPES.includes(value as CardsLinkScope)\n}\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\nfunction getBooleanAttribute(node: ContainerDirective, name: string): boolean {\n const attributes = node.attributes as\n | null\n | Record<string, boolean | null | string | undefined>\n | undefined\n const value = attributes?.[name]\n\n if (value === true) return true\n if (typeof value !== 'string') return false\n\n return value === 'true'\n}\n\nfunction hasAttribute(node: ContainerDirective, name: string): boolean {\n return Object.prototype.hasOwnProperty.call(node.attributes ?? {}, name)\n}\n\nfunction getCardsLinkScope(node: ContainerDirective): CardsLinkScope {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return DEFAULT_CARDS_LINK_SCOPE\n\n return isCardsLinkScope(value) ? value : FALLBACK_CARDS_LINK_SCOPE\n}\n\nfunction getLinkProperties(href: string, newTab: boolean): Element['properties'] {\n return {\n href,\n ...(newTab\n ? {\n rel: ['noopener', 'noreferrer'],\n target: '_blank',\n }\n : {}),\n }\n}\n\nfunction makeSectionLink(href: string, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: 'Open card section',\n className: [\n 'absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300',\n ],\n dataDirectiveLink: 'cards',\n },\n tagName: 'a',\n }\n}\n\nfunction hasCardLinkOverride(node: ContainerDirective): boolean {\n return ['href', 'linkScope', 'newTab'].some((name) => hasAttribute(node, name))\n}\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\nexport function resolveCardGridColumns(node: ContainerDirective): CardGridColumns {\n const columns = node.attributes?.columns\n\n return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS\n}\n\nexport const cardsDirective: LayoutDirectiveDefinition = {\n name: 'cards',\n allowedAttributes: ['cardTheme', 'columns', 'href', 'linkScope', 'newTab', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const columns =\n typeof node.properties.dataColumns === 'string'\n ? node.properties.dataColumns\n : DEFAULT_CARD_GRID_COLUMNS\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardsLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARDS_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const theme = resolveDirectiveTheme(\n 'cards',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cardTheme =\n typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined\n const childLinkScope = linkScope === 'title' ? 'title' : DEFAULT_CARD_LINK_SCOPE\n\n for (const child of node.children) {\n if (child.type !== 'element' || child.properties?.dataVlLayout !== 'card') continue\n\n if (typeof child.properties.dataTheme !== 'string' && cardTheme)\n child.properties.dataTheme = cardTheme\n\n if (href && linkScope === 'section') {\n delete child.properties.dataHref\n delete child.properties.dataLinkScope\n delete child.properties.dataNewTab\n continue\n }\n\n if (!href) continue\n\n if (typeof child.properties.dataHref !== 'string') child.properties.dataHref = href\n if (typeof child.properties.dataLinkScope !== 'string')\n child.properties.dataLinkScope = childLinkScope\n if (typeof child.properties.dataNewTab !== 'string')\n child.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n node.properties.className = mergeClassNames(\n 'not-prose my-8 grid gap-4',\n href && linkScope === 'section' ? 'relative cursor-pointer [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS],\n )\n\n if (href && linkScope === 'section') node.children = [makeSectionLink(href, newTab), ...node.children]\n },\n attributeValues: {\n columns: CARD_GRID_COLUMNS,\n linkScope: CARDS_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n columns: DEFAULT_CARD_GRID_COLUMNS,\n linkScope: DEFAULT_CARDS_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Responsive card grid for docs and landing-page content.',\n editor: {\n detail: 'Layout directive',\n label: 'Cards',\n snippet:\n ':::cards{\\n columns=\"${3}\"\\n}\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n const href = getSafeHref(getAttribute(node, 'href'))\n\n return {\n dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,\n dataColumns: resolveCardGridColumns(node),\n dataDirective: 'cards',\n dataHref: href,\n dataLinkScope: href || hasAttribute(node, 'linkScope') ? getCardsLinkScope(node) : undefined,\n dataNewTab: href && hasAttribute(node, 'newTab')\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cards',\n openMarker: ':::cards',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n cardTheme: 'card',\n theme: 'cards',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('cards', attributes)]\n\n if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns))\n warnings.push(\n `Invalid cards columns \"${attributes.columns}\". Falling back to \"${DEFAULT_CARD_GRID_COLUMNS}\".`,\n )\n\n if (typeof attributes.linkScope === 'string' && !isCardsLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid cards linkScope \"${attributes.linkScope}\". Falling back to \"${FALLBACK_CARDS_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n validateMdast(node) {\n const warnings: string[] = []\n\n if (getSafeHref(getAttribute(node, 'href')) && getCardsLinkScope(node) === 'section') {\n const hasOverrides = node.children.some(\n (child) => isContainerDirective(child) && child.name === 'card' && hasCardLinkOverride(child),\n )\n\n if (hasOverrides)\n warnings.push(\n 'Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.',\n )\n }\n\n return warnings\n },\n}\n"],"names":["resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","DEFAULT_CARD_LINK_SCOPE","CARD_GRID_COLUMNS","DEFAULT_CARD_GRID_COLUMNS","CARDS_LINK_SCOPES","DEFAULT_CARDS_LINK_SCOPE","FALLBACK_CARDS_LINK_SCOPE","cardGridColumnClasses","auto","isCardGridColumns","value","includes","isCardsLinkScope","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","hasAttribute","Object","prototype","hasOwnProperty","call","getCardsLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeSectionLink","type","children","properties","ariaLabel","className","dataDirectiveLink","tagName","hasCardLinkOverride","some","isContainerDirective","Boolean","resolveCardGridColumns","columns","cardsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataColumns","dataHref","dataLinkScope","dataNewTab","theme","dataTheme","themes","cardTheme","dataCardTheme","childLinkScope","child","dataVlLayout","hookClassName","modifierClassName","classes","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push","validateMdast","hasOverrides"],"mappings":"AAKA,SAASA,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAC/D,SAASC,u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oBAAmB,EAAEhE,UAAU,EAAE;QAC/B,MAAMiE,WAAqB;eAAIjF,sBAAsB,SAASgB;SAAY;QAE1E,IAAI,OAAOA,WAAW6B,OAAO,KAAK,YAAY,CAACpC,kBAAkBO,WAAW6B,OAAO,GACjFoC,SAASC,IAAI,CACX,CAAC,uBAAuB,EAAElE,WAAW6B,OAAO,CAAC,oBAAoB,EAAE1C,0BAA0B,EAAE,CAAC;QAGpG,IAAI,OAAOa,WAAWU,SAAS,KAAK,YAAY,CAACd,iBAAiBI,WAAWU,SAAS,GACpFuD,SAASC,IAAI,CACX,CAAC,yBAAyB,EAAElE,WAAWU,SAAS,CAAC,oBAAoB,EAAEpB,0BAA0B,EAAE,CAAC;QAGxG,OAAO2E;IACT;IACAE,eAAcrE,IAAI;QAChB,MAAMmE,WAAqB,EAAE;QAE7B,IAAIlF,YAAYc,aAAaC,MAAM,YAAYW,kBAAkBX,UAAU,WAAW;YACpF,MAAMsE,eAAetE,KAAKoB,QAAQ,CAACO,IAAI,CACrC,CAACoB,QAAUnB,qBAAqBmB,UAAUA,MAAM9C,IAAI,KAAK,UAAUyB,oBAAoBqB;YAGzF,IAAIuB,cACFH,SAASC,IAAI,CACX;QAEN;QAEA,OAAOD;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/cards.ts"],"sourcesContent":["import type { Element } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\nimport { DEFAULT_CARD_LINK_SCOPE } from './card.js'\n\nexport const CARD_GRID_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\nexport const DEFAULT_CARD_GRID_COLUMNS = '3'\nexport const CARDS_LINK_SCOPES = ['section', 'card', 'title'] as const\nexport const DEFAULT_CARDS_LINK_SCOPE = 'section'\nexport const FALLBACK_CARDS_LINK_SCOPE = 'card'\n\nexport type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number]\nexport type CardsLinkScope = (typeof CARDS_LINK_SCOPES)[number]\n\n// Columns collapse on the grid's own width (not the viewport): up to N\n// columns while each stays at least 14rem wide. The 2rem term covers the\n// widest theme gap, so a theme's gap never costs a column that would fit.\nconst cardGridColumnClasses: Record<CardGridColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',\n '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',\n '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',\n auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]',\n}\n\nfunction isCardGridColumns(value: unknown): value is CardGridColumns {\n return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value as CardGridColumns)\n}\n\nfunction isCardsLinkScope(value: unknown): value is CardsLinkScope {\n return typeof value === 'string' && CARDS_LINK_SCOPES.includes(value as CardsLinkScope)\n}\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\nfunction getBooleanAttribute(node: ContainerDirective, name: string): boolean {\n const attributes = node.attributes as\n | null\n | Record<string, boolean | null | string | undefined>\n | undefined\n const value = attributes?.[name]\n\n if (value === true) return true\n if (typeof value !== 'string') return false\n\n return value === 'true'\n}\n\nfunction hasAttribute(node: ContainerDirective, name: string): boolean {\n return Object.prototype.hasOwnProperty.call(node.attributes ?? {}, name)\n}\n\nfunction getCardsLinkScope(node: ContainerDirective): CardsLinkScope {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return DEFAULT_CARDS_LINK_SCOPE\n\n return isCardsLinkScope(value) ? value : FALLBACK_CARDS_LINK_SCOPE\n}\n\nfunction getLinkProperties(href: string, newTab: boolean): Element['properties'] {\n return {\n href,\n ...(newTab\n ? {\n rel: ['noopener', 'noreferrer'],\n target: '_blank',\n }\n : {}),\n }\n}\n\nfunction makeSectionLink(href: string, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: 'Open card section',\n className: [\n 'not-prose absolute -inset-2 z-10 rounded-3xl focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]',\n ],\n dataDirectiveLink: 'cards',\n },\n tagName: 'a',\n }\n}\n\nfunction hasCardLinkOverride(node: ContainerDirective): boolean {\n return ['href', 'linkScope', 'newTab'].some((name) => hasAttribute(node, name))\n}\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\nexport function resolveCardGridColumns(node: ContainerDirective): CardGridColumns {\n const columns = node.attributes?.columns\n\n return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS\n}\n\nexport const cardsDirective: LayoutDirectiveDefinition = {\n name: 'cards',\n allowedAttributes: ['cardTheme', 'columns', 'href', 'iconPalette', 'linkScope', 'newTab', 'palette', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const columns =\n typeof node.properties.dataColumns === 'string'\n ? node.properties.dataColumns\n : DEFAULT_CARD_GRID_COLUMNS\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardsLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARDS_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const theme = resolveDirectiveTheme(\n 'cards',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cardTheme =\n typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined\n const childLinkScope = linkScope === 'title' ? 'title' : DEFAULT_CARD_LINK_SCOPE\n\n for (const child of node.children) {\n if (child.type !== 'element' || child.properties?.dataVlLayout !== 'card') continue\n\n if (typeof child.properties.dataTheme !== 'string' && cardTheme)\n child.properties.dataTheme = cardTheme\n\n // Cards without a palette of their own paint their icons with the\n // grid's iconPalette (or palette); the grid's surface tokens are inherited.\n const iconPaletteDefault = node.properties.dataIconPalette ?? node.properties.dataPalette\n if (\n typeof iconPaletteDefault === 'string' &&\n typeof child.properties.dataPalette !== 'string' &&\n typeof child.properties.dataIconPalette !== 'string'\n )\n child.properties.dataIconPalette = iconPaletteDefault\n\n if (href && linkScope === 'section') {\n delete child.properties.dataHref\n delete child.properties.dataLinkScope\n delete child.properties.dataNewTab\n continue\n }\n\n if (!href) continue\n\n if (typeof child.properties.dataHref !== 'string') child.properties.dataHref = href\n if (typeof child.properties.dataLinkScope !== 'string')\n child.properties.dataLinkScope = childLinkScope\n if (typeof child.properties.dataNewTab !== 'string')\n child.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n // Spacing lives in the theme; the base only sets what every grid needs.\n 'grid [&>article]:my-0',\n href && linkScope === 'section'\n ? 'relative cursor-pointer [&>article]:transition-colors hover:[&>article]:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20'\n : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS],\n )\n\n if (href && linkScope === 'section') node.children = [makeSectionLink(href, newTab), ...node.children]\n },\n attributeValues: {\n columns: CARD_GRID_COLUMNS,\n linkScope: CARDS_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n columns: DEFAULT_CARD_GRID_COLUMNS,\n linkScope: DEFAULT_CARDS_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Responsive card grid for docs and landing-page content.',\n editor: {\n detail: 'Layout directive',\n label: 'Cards',\n snippet:\n ':::cards{\\n columns=\"${3}\"\\n}\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n const href = getSafeHref(getAttribute(node, 'href'))\n\n return {\n ...getPaletteRenderProperties(node),\n dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,\n dataColumns: resolveCardGridColumns(node),\n dataDirective: 'cards',\n dataHref: href,\n dataLinkScope: href || hasAttribute(node, 'linkScope') ? getCardsLinkScope(node) : undefined,\n dataNewTab: href && hasAttribute(node, 'newTab')\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cards',\n openMarker: ':::cards',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n cardTheme: 'card',\n theme: 'cards',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('cards', attributes)]\n\n if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns))\n warnings.push(\n `Invalid cards columns \"${attributes.columns}\". Falling back to \"${DEFAULT_CARD_GRID_COLUMNS}\".`,\n )\n\n if (typeof attributes.linkScope === 'string' && !isCardsLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid cards linkScope \"${attributes.linkScope}\". Falling back to \"${FALLBACK_CARDS_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n validateMdast(node) {\n const warnings: string[] = []\n\n if (getSafeHref(getAttribute(node, 'href')) && getCardsLinkScope(node) === 'section') {\n const hasOverrides = node.children.some(\n (child) => isContainerDirective(child) && child.name === 'card' && hasCardLinkOverride(child),\n )\n\n if (hasOverrides)\n warnings.push(\n 'Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.',\n )\n }\n\n return warnings\n },\n}\n"],"names":["applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","DEFAULT_CARD_LINK_SCOPE","CARD_GRID_COLUMNS","DEFAULT_CARD_GRID_COLUMNS","CARDS_LINK_SCOPES","DEFAULT_CARDS_LINK_SCOPE","FALLBACK_CARDS_LINK_SCOPE","cardGridColumnClasses","auto","isCardGridColumns","value","includes","isCardsLinkScope","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","hasAttribute","Object","prototype","hasOwnProperty","call","getCardsLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeSectionLink","type","children","properties","ariaLabel","className","dataDirectiveLink","tagName","hasCardLinkOverride","some","isContainerDirective","Boolean","resolveCardGridColumns","columns","cardsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataColumns","dataHref","dataLinkScope","dataNewTab","theme","dataTheme","themes","cardTheme","dataCardTheme","childLinkScope","child","dataVlLayout","iconPaletteDefault","dataIconPalette","dataPalette","hookClassName","modifierClassName","classes","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push","validateMdast","hasOverrides"],"mappings":"AAKA,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAC/D,SAASC,uBAAuB,QAAQ,YAAW;AAEnD,OAAO,MAAMC,oBAAoB;I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AAUxB;YACVyB,eAAezB,QAAQR,aAAaN,MAAM,eAAeW,kBAAkBX,QAAQI;YACnFoC,YAAY1B,QAAQR,aAAaN,MAAM,YACnCK,oBAAoBL,MAAM,YAAY,SAAS,UAC/CI;YACJsC,WAAW,OAAO1C,KAAKE,UAAU,EAAEuC,UAAU,WAAWzC,KAAKE,UAAU,CAACuC,KAAK,GAAG;QAClF;IACF;IACAuB,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpB1C,SAAS;IACT2C,iBAAiB;QACfxB,WAAW;QACXH,OAAO;IACT;IACA4B,oBAAmB,EAAEnE,UAAU,EAAE;QAC/B,MAAMoE,WAAqB;eAAIpF,sBAAsB,SAASgB;SAAY;QAE1E,IAAI,OAAOA,WAAW6B,OAAO,KAAK,YAAY,CAACpC,kBAAkBO,WAAW6B,OAAO,GACjFuC,SAASC,IAAI,CACX,CAAC,uBAAuB,EAAErE,WAAW6B,OAAO,CAAC,oBAAoB,EAAE1C,0BAA0B,EAAE,CAAC;QAGpG,IAAI,OAAOa,WAAWU,SAAS,KAAK,YAAY,CAACd,iBAAiBI,WAAWU,SAAS,GACpF0D,SAASC,IAAI,CACX,CAAC,yBAAyB,EAAErE,WAAWU,SAAS,CAAC,oBAAoB,EAAEpB,0BAA0B,EAAE,CAAC;QAGxG,OAAO8E;IACT;IACAE,eAAcxE,IAAI;QAChB,MAAMsE,WAAqB,EAAE;QAE7B,IAAIrF,YAAYc,aAAaC,MAAM,YAAYW,kBAAkBX,UAAU,WAAW;YACpF,MAAMyE,eAAezE,KAAKoB,QAAQ,CAACO,IAAI,CACrC,CAACoB,QAAUnB,qBAAqBmB,UAAUA,MAAM9C,IAAI,KAAK,UAAUyB,oBAAoBqB;YAGzF,IAAI0B,cACFH,SAASC,IAAI,CACX;QAEN;QAEA,OAAOD;IACT;AACF,EAAC"}
@@ -8,7 +8,7 @@ export const cellDirective = {
8
8
  applyHast (node, config, { mergeClassNames }) {
9
9
  const theme = resolveDirectiveTheme('cell', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
10
10
  node.properties.dataTheme = theme.name;
11
- node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, config.columnClassName);
11
+ node.properties.className = mergeClassNames('[&>:first-child]:mt-0 [&>:last-child]:mb-0', theme.hookClassName, theme.modifierClassName, theme.classes, config.columnClassName);
12
12
  },
13
13
  editor: {
14
14
  detail: 'Layout directive',
@@ -16,8 +16,10 @@ export const cellDirective = {
16
16
  snippet: ':::cell\n${Content}\n:::\n${}'
17
17
  },
18
18
  getMdastRenderProperties (node) {
19
+ // Leave an unthemed cell unset so its 2col/3col parent can apply cellTheme;
20
+ // applyHast falls back to the default theme.
19
21
  return {
20
- dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default'
22
+ dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : undefined
21
23
  };
22
24
  },
23
25
  kind: 'cell',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/cell.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { DirectiveChild, LayoutDirectiveDefinition } from '../types.js'\n\nimport { setDirectiveRenderData } from '../renderData.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const cellDirective: LayoutDirectiveDefinition = {\n name: 'cell',\n allowedAttributes: ['theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'cell',\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.columnClassName,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout cell',\n snippet: ':::cell\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cell',\n openMarker: ':::cell',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'cell',\n },\n}\n\nexport function makeCellDirective(children: DirectiveChild[]): ContainerDirective {\n const node: ContainerDirective = {\n name: 'cell',\n type: 'containerDirective',\n attributes: {},\n children,\n data: {},\n }\n\n setDirectiveRenderData(node, cellDirective)\n\n return node\n}\n"],"names":["setDirectiveRenderData","resolveDirectiveTheme","cellDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","columnClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","openMarker","public","supportsAttributes","tagName","themeAttributes","makeCellDirective","children","type","data"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,mBAAkB;AACzD,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,gBAA2C;IACtDC,MAAM;IACNC,mBAAmB;QAAC;KAAQ;IAC5BC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQR,sBACZ,QACA,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,eAAe;IAE1B;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;AAED,OAAO,SAASsB,kBAAkBC,QAA0B;IAC1D,MAAM1B,OAA2B;QAC/BH,MAAM;QACN8B,MAAM;QACNT,YAAY,CAAC;QACbQ;QACAE,MAAM,CAAC;IACT;IAEAlC,uBAAuBM,MAAMJ;IAE7B,OAAOI;AACT"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/cell.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { DirectiveChild, LayoutDirectiveDefinition } from '../types.js'\n\nimport { setDirectiveRenderData } from '../renderData.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const cellDirective: LayoutDirectiveDefinition = {\n name: 'cell',\n allowedAttributes: ['theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'cell',\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 '[&>:first-child]:mt-0 [&>:last-child]:mb-0',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n config.columnClassName,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout cell',\n snippet: ':::cell\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n // Leave an unthemed cell unset so its 2col/3col parent can apply cellTheme;\n // applyHast falls back to the default theme.\n return {\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : undefined,\n }\n },\n kind: 'cell',\n openMarker: ':::cell',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'cell',\n },\n}\n\nexport function makeCellDirective(children: DirectiveChild[]): ContainerDirective {\n const node: ContainerDirective = {\n name: 'cell',\n type: 'containerDirective',\n attributes: {},\n children,\n data: {},\n }\n\n setDirectiveRenderData(node, cellDirective)\n\n return node\n}\n"],"names":["setDirectiveRenderData","resolveDirectiveTheme","cellDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","columnClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","openMarker","public","supportsAttributes","tagName","themeAttributes","makeCellDirective","children","type","data"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,mBAAkB;AACzD,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,gBAA2C;IACtDC,MAAM;IACNC,mBAAmB;QAAC;KAAQ;IAC5BC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQR,sBACZ,QACA,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,gBAC1B,8CACAC,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO,EACbV,OAAOW,eAAe;IAE1B;IACAC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBjB,IAAI;QAC3B,4EAA4E;QAC5E,6CAA6C;QAC7C,OAAO;YACLK,WAAW,OAAOL,KAAKkB,UAAU,EAAEf,UAAU,WAAWH,KAAKkB,UAAU,CAACf,KAAK,GAAGG;QAClF;IACF;IACAa,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfrB,OAAO;IACT;AACF,EAAC;AAED,OAAO,SAASsB,kBAAkBC,QAA0B;IAC1D,MAAM1B,OAA2B;QAC/BH,MAAM;QACN8B,MAAM;QACNT,YAAY,CAAC;QACbQ;QACAE,MAAM,CAAC;IACT;IAEAlC,uBAAuBM,MAAMJ;IAE7B,OAAOI;AACT"}
@@ -48,7 +48,8 @@ function createColumnDirective(name, columns) {
48
48
  const resolvedCellTheme = cellTheme ? resolveDirectiveTheme('cell', cellTheme, config.themes) : undefined;
49
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
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');
51
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, // Columns collapse on the grid's own width, keeping each at least 12rem.
52
+ columns === 2 ? 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(12rem,calc((100%_-_2rem)/2))),1fr))]' : 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(12rem,calc((100%_-_2*2rem)/3))),1fr))]');
52
53
  const hasExplicitCells = node.children.some((child)=>child.type === 'element' && child.properties?.dataVlLayout === 'cell');
53
54
  if (!hasExplicitCells) node.children = groupChildrenIntoCells(node.children, config.columnClassName, resolvedCellTheme);
54
55
  },
@@ -1 +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;IAEA,OAAOF;AACT;AAEA,SA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,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"}
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 collapse on the grid's own width, keeping each at least 12rem.\n columns === 2\n ? 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(12rem,calc((100%_-_2rem)/2))),1fr))]'\n : 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(12rem,calc((100%_-_2*2rem)/3))),1fr))]',\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,EAC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,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"}
@@ -1,4 +1,6 @@
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
1
2
  import { getDirectiveLabelOrAttribute } from '../labels.js';
3
+ import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
2
4
  import { resolveDirectiveTheme } from '../themes.js';
3
5
  const DEFAULT_DETAILS_TITLE = 'Details';
4
6
  function getTitle(node) {
@@ -9,6 +11,7 @@ export const detailsDirective = {
9
11
  name: 'details',
10
12
  allowedAttributes: [
11
13
  'open',
14
+ 'palette',
12
15
  'theme',
13
16
  'title'
14
17
  ],
@@ -17,7 +20,8 @@ export const detailsDirective = {
17
20
  const theme = resolveDirectiveTheme('details', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
18
21
  const children = node.children;
19
22
  node.properties.dataTheme = theme.name;
20
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
23
+ applyDirectivePalette(node, config);
24
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
21
25
  node.children = [
22
26
  {
23
27
  type: 'element',
@@ -29,7 +33,7 @@ export const detailsDirective = {
29
33
  ],
30
34
  properties: {
31
35
  className: [
32
- 'cursor-pointer text-sm font-semibold tracking-wide'
36
+ 'not-prose ml-4 cursor-pointer list-outside text-sm font-semibold tracking-wide transition-colors hover:text-(--tw-prose-headings) marker:text-(--tw-prose-captions)'
33
37
  ]
34
38
  },
35
39
  tagName: 'summary'
@@ -39,7 +43,8 @@ export const detailsDirective = {
39
43
  children,
40
44
  properties: {
41
45
  className: [
42
- 'mt-3 space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'
46
+ 'mt-3',
47
+ DIRECTIVE_BODY_CLASS
43
48
  ],
44
49
  dataDirectiveBody: 'details'
45
50
  },
@@ -58,6 +63,7 @@ export const detailsDirective = {
58
63
  },
59
64
  getMdastRenderProperties (node) {
60
65
  return {
66
+ ...getPaletteRenderProperties(node),
61
67
  dataDirective: 'details',
62
68
  dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',
63
69
  dataTitle: getTitle(node),
@@ -1 +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 { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nconst DEFAULT_DETAILS_TITLE = 'Details'\n\nfunction getTitle(node: ContainerDirective): string {\n const title = getDirectiveLabelOrAttribute(node, 'title')\n\n return title ?? 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[${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":["getDirectiveLabelOrAttribute","resolveDirectiveTheme","DEFAULT_DETAILS_TITLE","getTitle","node","title","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","attributes","open","kind","openMarker","public","supportsAttributes","themeAttributes"],"mappings":"AAIA,SAASA,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,MAAMC,wBAAwB;AAE9B,SAASC,SAASC,IAAwB;IACxC,MAAMC,QAAQL,6BAA6BI,MAAM;IAEjD,OAAOC,SAASH;AAClB;AAEA,OAAO,MAAMI,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;QAAQ;QAAS;KAAQ;IAC7CC,WAAUL,IAAI,EAAEM,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMN,QAAQ,OAAOD,KAAKQ,UAAU,CAACC,SAAS,KAAK,WAAWT,KAAKQ,UAAU,CAACC,SAAS,GAAGX;QAC1F,MAAMY,QAAQb,sBACZ,WACA,OAAOG,KAAKQ,UAAU,CAACG,SAAS,KAAK,WAAWX,KAAKQ,UAAU,CAACG,SAAS,GAAGC,WAC5EN,OAAOO,MAAM;QAEf,MAAMC,WAAWd,KAAKc,QAAQ;QAE9Bd,KAAKQ,UAAU,CAACG,SAAS,GAAGD,MAAMP,IAAI;QACtCH,KAAKQ,UAAU,CAACO,SAAS,GAAGR,gBAC1B,aACAG,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO;QAGflB,KAAKc,QAAQ,GAAG;YACd;gBACEK,MAAM;gBACNL,UAAU;oBAAC;wBAAEK,MAAM;wBAAQC,OAAOnB;oBAAM;iBAAE;gBAC1CO,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;QACjBtB,OAAOH;IACT;IACA0B,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyB7B,IAAI;QAC3B,OAAO;YACL8B,eAAe;YACfnB,WAAW,OAAOX,KAAK+B,UAAU,EAAErB,UAAU,WAAWV,KAAK+B,UAAU,CAACrB,KAAK,GAAG;YAChFD,WAAWV,SAASC;YACpBgC,MAAMhC,KAAK+B,UAAU,EAAEC,SAAS;QAClC;IACF;IACAC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBf,SAAS;IACTgB,iBAAiB;QACf3B,OAAO;IACT;AACF,EAAC"}
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 { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nconst DEFAULT_DETAILS_TITLE = 'Details'\n\nfunction getTitle(node: ContainerDirective): string {\n const title = getDirectiveLabelOrAttribute(node, 'title')\n\n return title ?? DEFAULT_DETAILS_TITLE\n}\n\nexport const detailsDirective: LayoutDirectiveDefinition = {\n name: 'details',\n allowedAttributes: ['open', 'palette', '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 applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\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: [\n 'not-prose ml-4 cursor-pointer list-outside text-sm font-semibold tracking-wide transition-colors hover:text-(--tw-prose-headings) marker:text-(--tw-prose-captions)',\n ],\n },\n tagName: 'summary',\n },\n {\n type: 'element',\n children,\n properties: {\n className: ['mt-3', DIRECTIVE_BODY_CLASS],\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[${Details}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n ...getPaletteRenderProperties(node),\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":["DIRECTIVE_BODY_CLASS","getDirectiveLabelOrAttribute","applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","DEFAULT_DETAILS_TITLE","getTitle","node","title","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","attributes","open","kind","openMarker","public","supportsAttributes","themeAttributes"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,MAAMC,wBAAwB;AAE9B,SAASC,SAASC,IAAwB;IACxC,MAAMC,QAAQP,6BAA6BM,MAAM;IAEjD,OAAOC,SAASH;AAClB;AAEA,OAAO,MAAMI,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;QAAQ;QAAW;QAAS;KAAQ;IACxDC,WAAUL,IAAI,EAAEM,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMN,QAAQ,OAAOD,KAAKQ,UAAU,CAACC,SAAS,KAAK,WAAWT,KAAKQ,UAAU,CAACC,SAAS,GAAGX;QAC1F,MAAMY,QAAQb,sBACZ,WACA,OAAOG,KAAKQ,UAAU,CAACG,SAAS,KAAK,WAAWX,KAAKQ,UAAU,CAACG,SAAS,GAAGC,WAC5EN,OAAOO,MAAM;QAEf,MAAMC,WAAWd,KAAKc,QAAQ;QAE9Bd,KAAKQ,UAAU,CAACG,SAAS,GAAGD,MAAMP,IAAI;QACtCR,sBAAsBK,MAAMM;QAC5BN,KAAKQ,UAAU,CAACO,SAAS,GAAGR,gBAC1BG,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO;QAGflB,KAAKc,QAAQ,GAAG;YACd;gBACEK,MAAM;gBACNL,UAAU;oBAAC;wBAAEK,MAAM;wBAAQC,OAAOnB;oBAAM;iBAAE;gBAC1CO,YAAY;oBACVO,WAAW;wBACT;qBACD;gBACH;gBACAM,SAAS;YACX;YACA;gBACEF,MAAM;gBACNL;gBACAN,YAAY;oBACVO,WAAW;wBAAC;wBAAQtB;qBAAqB;oBACzC6B,mBAAmB;gBACrB;gBACAD,SAAS;YACX;SACD;IACH;IACAE,mBAAmB;QACjBtB,OAAOH;IACT;IACA0B,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyB7B,IAAI;QAC3B,OAAO;YACL,GAAGJ,2BAA2BI,KAAK;YACnC8B,eAAe;YACfnB,WAAW,OAAOX,KAAK+B,UAAU,EAAErB,UAAU,WAAWV,KAAK+B,UAAU,CAACrB,KAAK,GAAG;YAChFD,WAAWV,SAASC;YACpBgC,MAAMhC,KAAK+B,UAAU,EAAEC,SAAS;QAClC;IACF;IACAC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBf,SAAS;IACTgB,iBAAiB;QACf3B,OAAO;IACT;AACF,EAAC"}
@@ -1,13 +1,16 @@
1
+ import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
1
2
  import { resolveDirectiveTheme } from '../themes.js';
2
3
  export const sectionDirective = {
3
4
  name: 'section',
4
5
  allowedAttributes: [
6
+ 'palette',
5
7
  'theme'
6
8
  ],
7
9
  applyHast (node, config, { mergeClassNames }) {
8
10
  const theme = resolveDirectiveTheme('section', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
9
11
  node.properties.dataTheme = theme.name;
10
- node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
12
+ applyDirectivePalette(node, config);
13
+ node.properties.className = mergeClassNames('[&>:first-child]:mt-0 [&>:last-child]:mb-0', theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
11
14
  },
12
15
  editor: {
13
16
  detail: 'Layout directive',
@@ -16,6 +19,7 @@ export const sectionDirective = {
16
19
  },
17
20
  getMdastRenderProperties (node) {
18
21
  return {
22
+ ...getPaletteRenderProperties(node),
19
23
  dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default'
20
24
  };
21
25
  },
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/section.ts"],"sourcesContent":["import type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const sectionDirective: LayoutDirectiveDefinition = {\n name: 'section',\n allowedAttributes: ['palette', '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 applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n '[&>:first-child]:mt-0 [&>:last-child]:mb-0',\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 ...getPaletteRenderProperties(node),\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":["applyDirectivePalette","getPaletteRenderProperties","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,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;QAAW;KAAQ;IACvCC,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;QACtCJ,sBAAsBO,MAAMC;QAC5BD,KAAKI,UAAU,CAACI,SAAS,GAAGN,gBAC1B,8CACAC,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;YACL,GAAGN,2BAA2BM,KAAK;YACnCK,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"}
@@ -1,4 +1,5 @@
1
- import { DIRECTIVE_SURFACE_NESTED_CODE_CLASS } from '../../styles/directiveSurface.js';
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
2
+ import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
2
3
  import { resolveDirectiveTheme } from '../themes.js';
3
4
  import { CARD_BODY_CLASS_NAMES } from './card.js';
4
5
  const STEP_VARIANTS = [
@@ -43,6 +44,7 @@ function resolveCardStepNumbered(node) {
43
44
  if (typeof numbered !== 'string') return true;
44
45
  return numbered !== 'false';
45
46
  }
47
+ const STEP_CARDS_LIST_CLASS_NAMES = 'm-0! list-none! gap-4 p-0! [&>li]:m-0! [&>li]:p-0! [&>li]:[font-size:inherit]';
46
48
  function isElement(node) {
47
49
  return node.type === 'element';
48
50
  }
@@ -56,11 +58,22 @@ function isStepHeading(node) {
56
58
  function makeStep(children, index) {
57
59
  return {
58
60
  type: 'element',
59
- children,
61
+ children: [
62
+ {
63
+ type: 'element',
64
+ children,
65
+ properties: {
66
+ className: [
67
+ DIRECTIVE_BODY_CLASS
68
+ ],
69
+ dataDirectiveBody: 'step'
70
+ },
71
+ tagName: 'div'
72
+ }
73
+ ],
60
74
  properties: {
61
75
  className: [
62
- 'relative pl-4 [&>:first-child]:mt-0 [&>:last-child]:mb-0',
63
- DIRECTIVE_SURFACE_NESTED_CODE_CLASS
76
+ 'relative'
64
77
  ],
65
78
  dataStep: String(index + 1)
66
79
  },
@@ -85,7 +98,7 @@ function makeCardStep(children, index, numbered, stepTheme) {
85
98
  ],
86
99
  properties: {
87
100
  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'
101
+ 'pmd-step-number not-prose mb-3 inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/25 bg-[color:color-mix(in_oklab,rgb(255_255_255/0.1)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.05))] text-sm font-semibold'
89
102
  ],
90
103
  dataStepNumber: String(index + 1)
91
104
  },
@@ -99,9 +112,12 @@ function makeCardStep(children, index, numbered, stepTheme) {
99
112
  stepTheme.hookClassName,
100
113
  stepTheme.modifierClassName,
101
114
  stepTheme.classes,
115
+ 'h-full',
102
116
  CARD_BODY_CLASS_NAMES,
103
- DIRECTIVE_SURFACE_NESTED_CODE_CLASS
117
+ // The step title sits right under its number badge.
118
+ '[&>.pmd-step-number+*]:mt-0'
104
119
  ],
120
+ dataDirectiveBody: 'step',
105
121
  dataStepCard: '',
106
122
  dataTheme: stepTheme.name
107
123
  },
@@ -121,12 +137,13 @@ function groupStepChildren(children, columns, layout, numbered, variant, stepThe
121
137
  const groups = [];
122
138
  let current = [];
123
139
  const makeStepElement = variant === 'cards' ? (group, index)=>makeCardStep(group, index, numbered, stepTheme) : makeStep;
140
+ // Same container-width columns as `:::cards` (see cardGridColumnClasses).
124
141
  const gridColumnsClassNames = {
125
142
  '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))]'
143
+ '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',
144
+ '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',
145
+ '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',
146
+ auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]'
130
147
  };
131
148
  for (const child of children){
132
149
  if (isStepHeading(child) && current.length > 0) {
@@ -144,13 +161,17 @@ function groupStepChildren(children, columns, layout, numbered, variant, stepThe
144
161
  type: 'element',
145
162
  children: groups.map(makeStepElement),
146
163
  properties: {
164
+ // Step lists are structure, not prose lists: the `!` resets win over
165
+ // Typography's list styles and the renderer's list spacing.
147
166
  className: variant === 'cards' ? layout === 'grid' ? [
148
- 'm-0 grid list-none gap-4 p-0',
167
+ STEP_CARDS_LIST_CLASS_NAMES,
168
+ 'grid',
149
169
  gridColumnsClassNames[columns]
150
170
  ] : [
151
- 'm-0 flex list-none flex-col gap-4 p-0'
171
+ STEP_CARDS_LIST_CLASS_NAMES,
172
+ 'flex flex-col'
152
173
  ] : [
153
- 'm-0 list-decimal space-y-6 pl-6'
174
+ 'm-0! list-decimal pl-6! [&>li]:my-0! [&>li]:pl-4! [&>li+li]:mt-6! [&>li]:[font-size:inherit] [&>li]:marker:font-semibold'
154
175
  ]
155
176
  },
156
177
  tagName: 'ol'
@@ -163,6 +184,7 @@ export const stepsDirective = {
163
184
  'columns',
164
185
  'layout',
165
186
  'numbered',
187
+ 'palette',
166
188
  'stepTheme',
167
189
  'theme',
168
190
  'variant'
@@ -175,7 +197,8 @@ export const stepsDirective = {
175
197
  const theme = resolveDirectiveTheme('steps', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
176
198
  const stepTheme = resolveDirectiveTheme('card', typeof node.properties.dataStepTheme === 'string' ? node.properties.dataStepTheme : undefined, config.themes);
177
199
  node.properties.dataTheme = theme.name;
178
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
200
+ applyDirectivePalette(node, config);
201
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
179
202
  node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme);
180
203
  },
181
204
  attributeValues: {
@@ -211,6 +234,7 @@ export const stepsDirective = {
211
234
  const numbered = resolveCardStepNumbered(node);
212
235
  const columns = resolveCardStepColumns(node);
213
236
  return {
237
+ ...getPaletteRenderProperties(node),
214
238
  dataColumns: variant === 'cards' && layout === 'grid' ? columns : undefined,
215
239
  dataDirective: 'steps',
216
240
  dataLayout: variant === 'cards' ? layout : undefined,
@@ -1 +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;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AAWI,OAAO,KAAK,YAAY,CAACR,kBAAkBI,WAAWI,OAAO,GACjF8D,SAAS7B,IAAI,CAAC,CAAC,uBAAuB,EAAErC,WAAWI,OAAO,CAAC,uBAAuB,CAAC;QACrF,IACE,OAAOJ,WAAWM,QAAQ,KAAK,YAC/BN,WAAWM,QAAQ,KAAK,UACxBN,WAAWM,QAAQ,KAAK,SAExB4D,SAAS7B,IAAI,CACX,CAAC,8BAA8B,EAAErC,WAAWM,QAAQ,CAAC,0BAA0B,CAAC;QAGpF,OAAO4D;IACT;AACF,EAAC"}
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_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.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\nconst STEP_CARDS_LIST_CLASS_NAMES =\n 'm-0! list-none! gap-4 p-0! [&>li]:m-0! [&>li]:p-0! [&>li]:[font-size:inherit]'\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 {\n type: 'element',\n children,\n properties: {\n className: [DIRECTIVE_BODY_CLASS],\n dataDirectiveBody: 'step',\n },\n tagName: 'div',\n },\n ],\n properties: {\n className: ['relative'],\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 'pmd-step-number not-prose mb-3 inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/25 bg-[color:color-mix(in_oklab,rgb(255_255_255/0.1)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.05))] text-sm font-semibold',\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 'h-full',\n CARD_BODY_CLASS_NAMES,\n // The step title sits right under its number badge.\n '[&>.pmd-step-number+*]:mt-0',\n ],\n dataDirectiveBody: 'step',\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 // Same container-width columns as `:::cards` (see cardGridColumnClasses).\n const gridColumnsClassNames: Record<StepCardColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',\n '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',\n '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',\n auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,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 // Step lists are structure, not prose lists: the `!` resets win over\n // Typography's list styles and the renderer's list spacing.\n className:\n variant === 'cards'\n ? layout === 'grid'\n ? [STEP_CARDS_LIST_CLASS_NAMES, 'grid', gridColumnsClassNames[columns]]\n : [STEP_CARDS_LIST_CLASS_NAMES, 'flex flex-col']\n : [\n 'm-0! list-decimal pl-6! [&>li]:my-0! [&>li]:pl-4! [&>li+li]:mt-6! [&>li]:[font-size:inherit] [&>li]:marker:font-semibold',\n ],\n },\n tagName: 'ol',\n },\n ]\n}\n\nexport const stepsDirective: LayoutDirectiveDefinition = {\n name: 'steps',\n allowedAttributes: ['columns', 'layout', 'numbered', 'palette', '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 applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\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 ...getPaletteRenderProperties(node),\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_BODY_CLASS","applyDirectivePalette","getPaletteRenderProperties","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","STEP_CARDS_LIST_CLASS_NAMES","isElement","type","isStepHeading","tagName","makeStep","children","index","properties","className","dataDirectiveBody","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,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,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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AAOC,WAAWE,MAAM,KAAK,YAAY,CAACP,iBAAiBK,WAAWE,MAAM,GAC9EkE,SAAS7B,IAAI,CAAC,CAAC,0BAA0B,EAAEvC,WAAWE,MAAM,CAAC,2BAA2B,CAAC;QAC3F,IAAI,OAAOF,WAAWI,OAAO,KAAK,YAAY,CAACR,kBAAkBI,WAAWI,OAAO,GACjFgE,SAAS7B,IAAI,CAAC,CAAC,uBAAuB,EAAEvC,WAAWI,OAAO,CAAC,uBAAuB,CAAC;QACrF,IACE,OAAOJ,WAAWM,QAAQ,KAAK,YAC/BN,WAAWM,QAAQ,KAAK,UACxBN,WAAWM,QAAQ,KAAK,SAExB8D,SAAS7B,IAAI,CACX,CAAC,8BAA8B,EAAEvC,WAAWM,QAAQ,CAAC,0BAA0B,CAAC;QAGpF,OAAO8D;IACT;AACF,EAAC"}
@@ -1,3 +1,4 @@
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
1
2
  import { getDirectiveLabel, getDirectiveLabelOrAttribute } from '../labels.js';
2
3
  import { resolveDirectiveTheme } from '../themes.js';
3
4
  function getAttribute(node, name) {
@@ -59,7 +60,7 @@ export const tabDirective = {
59
60
  applyHast (node, config, { mergeClassNames }) {
60
61
  const theme = resolveDirectiveTheme('tab', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
61
62
  node.properties.dataTheme = theme.name;
62
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes, 'vl-md-tab-panel');
63
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, 'vl-md-tab-panel', DIRECTIVE_BODY_CLASS);
63
64
  },
64
65
  description: 'Single tab panel. Usually nested inside :::tabs.',
65
66
  editor: {
@@ -1 +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 { getDirectiveLabel, getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } 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 getDirectiveLabelOrAttribute(node, 'label') ?? getAttribute(node, 'value') ?? `Tab ${index + 1}`\n}\n\ntype TabAttributes = null | Record<string, boolean | null | string | undefined> | undefined\n\n/**\n * Slug used for tab values. ASCII labels slug exactly as before; labels with\n * no ASCII letters or digits (for example `日本`) fall back to the tab's\n * position (`tab-2`) instead of all colliding on `default`. The editor linter\n * uses the same function.\n */\nexport function slugTabValue(raw: string, index: number): string {\n return toTabSlug(raw) || `tab-${index + 1}`\n}\n\n/** ASCII slug of a tab value, or an empty string when nothing remains. */\nexport function toTabSlug(raw: string): string {\n return raw\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n/** Authored text a tab value is derived from: `value`, then the label. */\nexport function getTabRawValue(\n attributes: TabAttributes,\n label?: string,\n): string | undefined {\n const value = attributes?.value\n const attributeLabel = attributes?.label\n\n if (typeof value === 'string' && value.trim()) return value.trim()\n if (typeof label === 'string' && label.trim()) return label.trim()\n if (typeof attributeLabel === 'string' && attributeLabel.trim()) return attributeLabel.trim()\n\n return undefined\n}\n\nexport function getTabValueFromAttributes(attributes: TabAttributes, index: number): string {\n return slugTabValue(getTabRawValue(attributes) ?? `tab-${index + 1}`, index)\n}\n\nexport function getTabValue(node: ContainerDirective, index: number): string {\n return slugTabValue(\n getTabRawValue(node.attributes, getDirectiveLabel(node)) ?? `tab-${index + 1}`,\n index,\n )\n}\n\nexport type TabsDefaultCandidate = {\n label?: string\n raw?: string\n value: string\n}\n\n/**\n * Resolves a `:::tabs{default=\"…\"}` request to a tab value. Matches the\n * slugged value first (the historical behaviour) and then the authored\n * value/label text, so non-ASCII defaults such as `default=\"中文\"` work.\n */\nexport function resolveTabsDefault(\n requested: string | undefined,\n tabs: TabsDefaultCandidate[],\n): string | undefined {\n const trimmed = requested?.trim()\n if (!trimmed) return undefined\n\n const slug = toTabSlug(trimmed)\n\n return (\n (slug ? tabs.find((tab) => tab.value === slug)?.value : undefined) ??\n tabs.find((tab) => tab.raw === trimmed || tab.label === trimmed)?.value\n )\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}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'tab',\n dataDisabled: isTabDisabled(node.attributes) ? 'true' : undefined,\n dataLabel: getTabLabel(node, node.data?.vlTabIndex ?? 0),\n dataTheme: getAttribute(node, 'theme'),\n dataValue: getTabValue(node, node.data?.vlTabIndex ?? 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":["getDirectiveLabel","getDirectiveLabelOrAttribute","resolveDirectiveTheme","getAttribute","node","name","value","attributes","trim","undefined","getTabLabel","index","slugTabValue","raw","toTabSlug","replace","toLowerCase","getTabRawValue","label","attributeLabel","getTabValueFromAttributes","getTabValue","resolveTabsDefault","requested","tabs","trimmed","slug","find","tab","isTabDisabled","disabled","tabDirective","allowedAttributes","applyHast","config","mergeClassNames","theme","properties","dataTheme","themes","className","hookClassName","modifierClassName","classes","description","editor","detail","snippet","getMdastRenderProperties","dataDirective","dataDisabled","dataLabel","data","vlTabIndex","dataValue","kind","openMarker","public","supportsAttributes","tagName","themeAttributes"],"mappings":"AAIA,SAASA,iBAAiB,EAAEC,4BAA4B,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,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,OAAOV,6BAA6BG,MAAM,YAAYD,aAAaC,MAAM,YAAY,CAAC,IAAI,EAAEO,QAAQ,GAAG;AACzG;AAIA;;;;;CAKC,GACD,OAAO,SAASC,aAAaC,GAAW,EAAEF,KAAa;IACrD,OAAOG,UAAUD,QAAQ,CAAC,IAAI,EAAEF,QAAQ,GAAG;AAC7C;AAEA,wEAAwE,GACxE,OAAO,SAASG,UAAUD,GAAW;IACnC,OAAOA,IACJE,OAAO,CAAC,sBAAsB,SAC9BC,WAAW,GACXD,OAAO,CAAC,eAAe,KACvBA,OAAO,CAAC,YAAY;AACzB;AAEA,wEAAwE,GACxE,OAAO,SAASE,eACdV,UAAyB,EACzBW,KAAc;IAEd,MAAMZ,QAAQC,YAAYD;IAC1B,MAAMa,iBAAiBZ,YAAYW;IAEnC,IAAI,OAAOZ,UAAU,YAAYA,MAAME,IAAI,IAAI,OAAOF,MAAME,IAAI;IAChE,IAAI,OAAOU,UAAU,YAAYA,MAAMV,IAAI,IAAI,OAAOU,MAAMV,IAAI;IAChE,IAAI,O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AM/B,IAAI;QACtCD,KAAKiC,UAAU,CAACG,SAAS,GAAGL,gBAC1B,aACAC,MAAMK,aAAa,EACnBL,MAAMM,iBAAiB,EACvBN,MAAMO,OAAO,EACb;IAEJ;IACAC,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACR5B,OAAO;QACP6B,SAAS;IACX;IACAC,0BAAyB5C,IAAI;QAC3B,OAAO;YACL6C,eAAe;YACfC,cAAcrB,cAAczB,KAAKG,UAAU,IAAI,SAASE;YACxD0C,WAAWzC,YAAYN,MAAMA,KAAKgD,IAAI,EAAEC,cAAc;YACtDf,WAAWnC,aAAaC,MAAM;YAC9BkD,WAAWjC,YAAYjB,MAAMA,KAAKgD,IAAI,EAAEC,cAAc;QACxD;IACF;IACAE,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfxB,OAAO;IACT;AACF,EAAC"}
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 { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { getDirectiveLabel, getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } 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 getDirectiveLabelOrAttribute(node, 'label') ?? getAttribute(node, 'value') ?? `Tab ${index + 1}`\n}\n\ntype TabAttributes = null | Record<string, boolean | null | string | undefined> | undefined\n\n/**\n * Slug used for tab values. ASCII labels slug exactly as before; labels with\n * no ASCII letters or digits (for example `日本`) fall back to the tab's\n * position (`tab-2`) instead of all colliding on `default`. The editor linter\n * uses the same function.\n */\nexport function slugTabValue(raw: string, index: number): string {\n return toTabSlug(raw) || `tab-${index + 1}`\n}\n\n/** ASCII slug of a tab value, or an empty string when nothing remains. */\nexport function toTabSlug(raw: string): string {\n return raw\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n/** Authored text a tab value is derived from: `value`, then the label. */\nexport function getTabRawValue(\n attributes: TabAttributes,\n label?: string,\n): string | undefined {\n const value = attributes?.value\n const attributeLabel = attributes?.label\n\n if (typeof value === 'string' && value.trim()) return value.trim()\n if (typeof label === 'string' && label.trim()) return label.trim()\n if (typeof attributeLabel === 'string' && attributeLabel.trim()) return attributeLabel.trim()\n\n return undefined\n}\n\nexport function getTabValueFromAttributes(attributes: TabAttributes, index: number): string {\n return slugTabValue(getTabRawValue(attributes) ?? `tab-${index + 1}`, index)\n}\n\nexport function getTabValue(node: ContainerDirective, index: number): string {\n return slugTabValue(\n getTabRawValue(node.attributes, getDirectiveLabel(node)) ?? `tab-${index + 1}`,\n index,\n )\n}\n\nexport type TabsDefaultCandidate = {\n label?: string\n raw?: string\n value: string\n}\n\n/**\n * Resolves a `:::tabs{default=\"…\"}` request to a tab value. Matches the\n * slugged value first (the historical behaviour) and then the authored\n * value/label text, so non-ASCII defaults such as `default=\"中文\"` work.\n */\nexport function resolveTabsDefault(\n requested: string | undefined,\n tabs: TabsDefaultCandidate[],\n): string | undefined {\n const trimmed = requested?.trim()\n if (!trimmed) return undefined\n\n const slug = toTabSlug(trimmed)\n\n return (\n (slug ? tabs.find((tab) => tab.value === slug)?.value : undefined) ??\n tabs.find((tab) => tab.raw === trimmed || tab.label === trimmed)?.value\n )\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 theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n 'vl-md-tab-panel',\n DIRECTIVE_BODY_CLASS,\n )\n },\n description: 'Single tab panel. Usually nested inside :::tabs.',\n editor: {\n detail: 'Tabs directive',\n label: 'Tab',\n snippet: ':::tab[${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, node.data?.vlTabIndex ?? 0),\n dataTheme: getAttribute(node, 'theme'),\n dataValue: getTabValue(node, node.data?.vlTabIndex ?? 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":["DIRECTIVE_BODY_CLASS","getDirectiveLabel","getDirectiveLabelOrAttribute","resolveDirectiveTheme","getAttribute","node","name","value","attributes","trim","undefined","getTabLabel","index","slugTabValue","raw","toTabSlug","replace","toLowerCase","getTabRawValue","label","attributeLabel","getTabValueFromAttributes","getTabValue","resolveTabsDefault","requested","tabs","trimmed","slug","find","tab","isTabDisabled","disabled","tabDirective","allowedAttributes","applyHast","config","mergeClassNames","theme","properties","dataTheme","themes","className","hookClassName","modifierClassName","classes","description","editor","detail","snippet","getMdastRenderProperties","dataDirective","dataDisabled","dataLabel","data","vlTabIndex","dataValue","kind","openMarker","public","supportsAttributes","tagName","themeAttributes"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,EAAEC,4BAA4B,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,SAASC,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,M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