payload-markdown 1.7.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -0
  2. package/dist/components/MarkdownRenderer/Component.client.js +9 -19
  3. package/dist/components/MarkdownRenderer/Component.client.js.map +1 -1
  4. package/dist/components/MarkdownRenderer/Component.js +55 -21
  5. package/dist/components/MarkdownRenderer/Component.js.map +1 -1
  6. package/dist/components/MarkdownRenderer/index.css +93 -42
  7. package/dist/components/MarkdownRenderer/index.scss +128 -57
  8. package/dist/core/codeToHtml.js +6 -0
  9. package/dist/core/codeToHtml.js.map +1 -1
  10. package/dist/core/plugins/directiveBadge.js +2 -0
  11. package/dist/core/plugins/directiveBadge.js.map +1 -1
  12. package/dist/core/plugins/directiveButton.js +4 -1
  13. package/dist/core/plugins/directiveButton.js.map +1 -1
  14. package/dist/core/plugins/rehypeContentLayout.d.ts +12 -0
  15. package/dist/core/plugins/rehypeContentLayout.js +64 -0
  16. package/dist/core/plugins/rehypeContentLayout.js.map +1 -0
  17. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +8 -0
  18. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -1
  19. package/dist/core/renderMarkdown.js +6 -3
  20. package/dist/core/renderMarkdown.js.map +1 -1
  21. package/dist/directives/definitions/callout.js +20 -11
  22. package/dist/directives/definitions/callout.js.map +1 -1
  23. package/dist/directives/definitions/card.d.ts +4 -2
  24. package/dist/directives/definitions/card.js +39 -11
  25. package/dist/directives/definitions/card.js.map +1 -1
  26. package/dist/directives/definitions/cards.js +10 -6
  27. package/dist/directives/definitions/cards.js.map +1 -1
  28. package/dist/directives/definitions/cell.js +4 -2
  29. package/dist/directives/definitions/cell.js.map +1 -1
  30. package/dist/directives/definitions/columns.js +2 -1
  31. package/dist/directives/definitions/columns.js.map +1 -1
  32. package/dist/directives/definitions/details.js +5 -3
  33. package/dist/directives/definitions/details.js.map +1 -1
  34. package/dist/directives/definitions/section.js +1 -1
  35. package/dist/directives/definitions/section.js.map +1 -1
  36. package/dist/directives/definitions/steps.js +34 -14
  37. package/dist/directives/definitions/steps.js.map +1 -1
  38. package/dist/directives/definitions/tab.js +2 -1
  39. package/dist/directives/definitions/tab.js.map +1 -1
  40. package/dist/directives/definitions/tabs.js +9 -6
  41. package/dist/directives/definitions/tabs.js.map +1 -1
  42. package/dist/directives/definitions/toc.js +2 -1
  43. package/dist/directives/definitions/toc.js.map +1 -1
  44. package/dist/directives/shields.js +16 -3
  45. package/dist/directives/shields.js.map +1 -1
  46. package/dist/directives/themes.js +13 -13
  47. package/dist/directives/themes.js.map +1 -1
  48. package/dist/exports/render.d.ts +2 -1
  49. package/dist/exports/render.js +1 -0
  50. package/dist/exports/render.js.map +1 -1
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/runtime/index.js +2 -0
  54. package/dist/runtime/index.js.map +1 -1
  55. package/dist/styles/directiveSurface.d.ts +39 -5
  56. package/dist/styles/directiveSurface.js +56 -13
  57. package/dist/styles/directiveSurface.js.map +1 -1
  58. package/dist/types/core.d.ts +13 -0
  59. package/dist/types/core.js.map +1 -1
  60. package/dist/version.d.ts +1 -1
  61. package/dist/version.js +1 -1
  62. package/dist/version.js.map +1 -1
  63. package/package.json +2 -1
  64. package/skills/payload-markdown/claude/skill.json +1 -1
  65. package/skills/payload-markdown/codex/skill.json +1 -1
@@ -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,uBAAuB,QAAQ,YAAW;AAEnD,OAAO,MAAMC,oBAAoB;IAAC;IAAK;IAAK;IAAK;IAAK;CAAO,CAAS;AACtE,OAAO,MAAMC,4BAA4B,IAAG;AAC5C,OAAO,MAAMC,oBAAoB;IAAC;IAAW;IAAQ;CAAQ,CAAS;AACtE,OAAO,MAAMC,2BAA2B,UAAS;AACjD,OAAO,MAAMC,4BAA4B,OAAM;AAK/C,MAAMC,wBAAyD;IAC7D,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACLC,MAAM;AACR;AAEA,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAYR,kBAAkBS,QAAQ,CAACD;AACjE;AAEA,SAASE,iBAAiBF,KAAc;IACtC,OAAO,OAAOA,UAAU,YAAYN,kBAAkBO,QAAQ,CAACD;AACjE;AAEA,SAASG,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAML,QAAQI,KAAKE,UAAU,EAAE,CAACD,KAAK;IAErC,OAAO,OAAOL,UAAU,YAAYA,MAAMO,IAAI,KAAKP,MAAMO,IAAI,KAAKC;AACpE;AAEA,SAASC,oBAAoBL,IAAwB,EAAEC,IAAY;IACjE,MAAMC,aAAaF,KAAKE,UAAU;IAI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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 { 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', '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 // 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 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,uBAAuB,QAAQ,YA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QACfrB,WAAW;QACXH,OAAO;IACT;IACAyB,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"}
@@ -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;AAE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,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,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,IAAIj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2
3
  import { resolveDirectiveTheme } from '../themes.js';
3
4
  const DEFAULT_DETAILS_TITLE = 'Details';
@@ -17,7 +18,7 @@ export const detailsDirective = {
17
18
  const theme = resolveDirectiveTheme('details', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
18
19
  const children = node.children;
19
20
  node.properties.dataTheme = theme.name;
20
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
21
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
21
22
  node.children = [
22
23
  {
23
24
  type: 'element',
@@ -29,7 +30,7 @@ export const detailsDirective = {
29
30
  ],
30
31
  properties: {
31
32
  className: [
32
- 'cursor-pointer text-sm font-semibold tracking-wide'
33
+ '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
34
  ]
34
35
  },
35
36
  tagName: 'summary'
@@ -39,7 +40,8 @@ export const detailsDirective = {
39
40
  children,
40
41
  properties: {
41
42
  className: [
42
- 'mt-3 space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'
43
+ 'mt-3',
44
+ DIRECTIVE_BODY_CLASS
43
45
  ],
44
46
  dataDirectiveBody: 'details'
45
47
  },
@@ -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;AAE9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ACpBgC,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 { 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 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 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","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,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,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;wBAAQpB;qBAAqB;oBACzC2B,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"}
@@ -7,7 +7,7 @@ export const sectionDirective = {
7
7
  applyHast (node, config, { mergeClassNames }) {
8
8
  const theme = resolveDirectiveTheme('section', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
9
9
  node.properties.dataTheme = theme.name;
10
- node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
10
+ node.properties.className = mergeClassNames('[&>:first-child]:mt-0 [&>:last-child]:mb-0', theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
11
11
  },
12
12
  editor: {
13
13
  detail: 'Layout directive',
@@ -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 { 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 '[&>: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 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,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;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,4 +1,4 @@
1
- import { DIRECTIVE_SURFACE_NESTED_CODE_CLASS } from '../../styles/directiveSurface.js';
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { resolveDirectiveTheme } from '../themes.js';
3
3
  import { CARD_BODY_CLASS_NAMES } from './card.js';
4
4
  const STEP_VARIANTS = [
@@ -43,6 +43,7 @@ function resolveCardStepNumbered(node) {
43
43
  if (typeof numbered !== 'string') return true;
44
44
  return numbered !== 'false';
45
45
  }
46
+ 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
47
  function isElement(node) {
47
48
  return node.type === 'element';
48
49
  }
@@ -56,11 +57,22 @@ function isStepHeading(node) {
56
57
  function makeStep(children, index) {
57
58
  return {
58
59
  type: 'element',
59
- children,
60
+ children: [
61
+ {
62
+ type: 'element',
63
+ children,
64
+ properties: {
65
+ className: [
66
+ DIRECTIVE_BODY_CLASS
67
+ ],
68
+ dataDirectiveBody: 'step'
69
+ },
70
+ tagName: 'div'
71
+ }
72
+ ],
60
73
  properties: {
61
74
  className: [
62
- 'relative pl-4 [&>:first-child]:mt-0 [&>:last-child]:mb-0',
63
- DIRECTIVE_SURFACE_NESTED_CODE_CLASS
75
+ 'relative'
64
76
  ],
65
77
  dataStep: String(index + 1)
66
78
  },
@@ -85,7 +97,7 @@ function makeCardStep(children, index, numbered, stepTheme) {
85
97
  ],
86
98
  properties: {
87
99
  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'
100
+ '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
101
  ],
90
102
  dataStepNumber: String(index + 1)
91
103
  },
@@ -99,9 +111,12 @@ function makeCardStep(children, index, numbered, stepTheme) {
99
111
  stepTheme.hookClassName,
100
112
  stepTheme.modifierClassName,
101
113
  stepTheme.classes,
114
+ 'h-full',
102
115
  CARD_BODY_CLASS_NAMES,
103
- DIRECTIVE_SURFACE_NESTED_CODE_CLASS
116
+ // The step title sits right under its number badge.
117
+ '[&>.pmd-step-number+*]:mt-0'
104
118
  ],
119
+ dataDirectiveBody: 'step',
105
120
  dataStepCard: '',
106
121
  dataTheme: stepTheme.name
107
122
  },
@@ -121,12 +136,13 @@ function groupStepChildren(children, columns, layout, numbered, variant, stepThe
121
136
  const groups = [];
122
137
  let current = [];
123
138
  const makeStepElement = variant === 'cards' ? (group, index)=>makeCardStep(group, index, numbered, stepTheme) : makeStep;
139
+ // Same container-width columns as `:::cards` (see cardGridColumnClasses).
124
140
  const gridColumnsClassNames = {
125
141
  '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))]'
142
+ '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',
143
+ '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',
144
+ '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',
145
+ auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]'
130
146
  };
131
147
  for (const child of children){
132
148
  if (isStepHeading(child) && current.length > 0) {
@@ -144,13 +160,17 @@ function groupStepChildren(children, columns, layout, numbered, variant, stepThe
144
160
  type: 'element',
145
161
  children: groups.map(makeStepElement),
146
162
  properties: {
163
+ // Step lists are structure, not prose lists: the `!` resets win over
164
+ // Typography's list styles and the renderer's list spacing.
147
165
  className: variant === 'cards' ? layout === 'grid' ? [
148
- 'm-0 grid list-none gap-4 p-0',
166
+ STEP_CARDS_LIST_CLASS_NAMES,
167
+ 'grid',
149
168
  gridColumnsClassNames[columns]
150
169
  ] : [
151
- 'm-0 flex list-none flex-col gap-4 p-0'
170
+ STEP_CARDS_LIST_CLASS_NAMES,
171
+ 'flex flex-col'
152
172
  ] : [
153
- 'm-0 list-decimal space-y-6 pl-6'
173
+ '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
174
  ]
155
175
  },
156
176
  tagName: 'ol'
@@ -175,7 +195,7 @@ export const stepsDirective = {
175
195
  const theme = resolveDirectiveTheme('steps', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
176
196
  const stepTheme = resolveDirectiveTheme('card', typeof node.properties.dataStepTheme === 'string' ? node.properties.dataStepTheme : undefined, config.themes);
177
197
  node.properties.dataTheme = theme.name;
178
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
198
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
179
199
  node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme);
180
200
  },
181
201
  attributeValues: {
@@ -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","validateAtt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F;IACA6D,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBpD,SAAS;IACTqD,iBAAiB;QACf5C,WAAW;QACX4B,OAAO;IACT;IACAiB,oBAAmB,EAAEjE,UAAU,EAAE;QAC/B,MAAMkE,WAAqB,EAAE;QAE7B,IAAI,OAAOlE,WAAWD,OAAO,KAAK,YAAY,CAACP,cAAcQ,WAAWD,OAAO,GAC7EmE,SAAS7B,IAAI,CACX,CAAC,2BAA2B,EAAErC,WAAWD,OAAO,CAAC,6BAA6B,CAAC;QAEnF,IAAI,OAAOC,WAAWE,MAAM,KAAK,YAAY,CAACP,iBAAiBK,WAAWE,MAAM,GAC9EgE,SAAS7B,IAAI,CAAC,CAAC,0BAA0B,EAAErC,WAAWE,MAAM,CAAC,2BAA2B,CAAC;QAC3F,IAAI,OAAOF,WAAWI,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 { 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', '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 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_BODY_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","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,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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,SAAS;IACTsD,iBAAiB;QACf5C,WAAW;QACX4B,OAAO;IACT;IACAiB,oBAAmB,EAAEnE,UAAU,EAAE;QAC/B,MAAMoE,WAAqB,EAAE;QAE7B,IAAI,OAAOpE,WAAWD,OAAO,KAAK,YAAY,CAACP,cAAcQ,WAAWD,OAAO,GAC7EqE,SAAS7B,IAAI,CACX,CAAC,2BAA2B,EAAEvC,WAAWD,OAAO,CAAC,6BAA6B,CAAC;QAEnF,IAAI,OAAOC,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,CA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IACN2B,mBAAmB;QAAC;QAAY;QAAS;QAAS;KAAQ;IAC1DC,WAAU7B,IAAI,EAAE8B,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQlC,sBACZ,OACA,OAAOE,KAAKiC,UAAU,CAACC,SAAS,KAAK,WAAWlC,KAAKiC,UAAU,CAACC,SAAS,GAAG7B,WAC5EyB,OAAOK,MAAM;QAGfnC,KAAKiC,UAAU,CAACC,SAAS,GAAGF,MAAM/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,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,OAAOW,mBAAmB,YAAYA,eAAeX,IAAI,IAAI,OAAOW,eAAeX,IAAI;IAE3F,OAAOC;AACT;AAEA,OAAO,SAASW,0BAA0Bb,UAAyB,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O,EACb,mBACA5C;IAEJ;IACA6C,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,4 +1,4 @@
1
- import { DIRECTIVE_SURFACE_DIVIDER_CLASS } from '../../styles/directiveSurface.js';
1
+ import { DIRECTIVE_BODY_CLASS, DIRECTIVE_SURFACE_DIVIDER_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { resolveDirectiveTheme } from '../themes.js';
3
3
  import { getTabLabel as getTabDirectiveLabel, getTabRawValue, getTabValue, resolveTabsDefault, slugTabValue, toTabSlug } from './tab.js';
4
4
  function isContainerDirective(node) {
@@ -53,7 +53,9 @@ function makeTabTrigger(tab, active) {
53
53
  const className = [
54
54
  'vl-md-tabs-trigger',
55
55
  active ? 'vl-md-tabs-trigger--active' : undefined,
56
- 'rounded-lg px-3 py-2 text-sm font-medium text-foreground/70 transition-colors hover:text-foreground aria-selected:bg-white/10 aria-selected:text-foreground'
56
+ // Inactive labels stay at 75% of the text colour: enough for AA contrast in
57
+ // both colour schemes while still reading as secondary.
58
+ 'rounded-lg px-3 py-2 text-sm font-medium text-current/75 transition-colors hover:bg-[color:color-mix(in_oklab,rgb(255_255_255/0.05)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.04))] hover:text-current aria-selected:bg-[color:color-mix(in_oklab,rgb(255_255_255/0.1)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.06))] aria-selected:text-current focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:color-mix(in_oklab,rgb(255_255_255/0.25)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent'
57
59
  ].filter((value)=>Boolean(value));
58
60
  return {
59
61
  type: 'element',
@@ -88,7 +90,8 @@ function makeTabPanel(tab, active, config, mergeClassNames, fallbackThemeName) {
88
90
  properties: {
89
91
  id: tab.panelId,
90
92
  ariaLabelledby: tab.triggerId,
91
- className: mergeClassNames('vl-md-tabs-panel', theme.hookClassName, theme.modifierClassName, theme.classes, '[&>:first-child]:mt-0 [&>:last-child]:mb-0'),
93
+ className: mergeClassNames('vl-md-tabs-panel', theme.hookClassName, theme.modifierClassName, theme.classes, DIRECTIVE_BODY_CLASS, // A panel holding only a code block shows just the code block.
94
+ 'has-[>pre:only-child]:border-0 has-[>pre:only-child]:bg-transparent has-[>pre:only-child]:p-0 has-[>pre:only-child]:shadow-none'),
92
95
  dataTabPanel: '',
93
96
  dataTabValue: tab.value,
94
97
  dataTheme: theme.name,
@@ -105,7 +108,7 @@ function makeTabList(tabs, activeValue) {
105
108
  children: tabs.map((tab)=>makeTabTrigger(tab, tab.value === activeValue)),
106
109
  properties: {
107
110
  className: [
108
- `vl-md-tabs-list flex flex-wrap gap-1 border-b ${DIRECTIVE_SURFACE_DIVIDER_CLASS} pb-2`
111
+ `not-prose vl-md-tabs-list flex flex-wrap gap-1 border-b ${DIRECTIVE_SURFACE_DIVIDER_CLASS} pb-2`
109
112
  ],
110
113
  dataTabsList: '',
111
114
  role: 'tablist'
@@ -143,7 +146,7 @@ export const tabsDirective = {
143
146
  const tabTheme = typeof node.properties.dataTabTheme === 'string' ? node.properties.dataTabTheme : undefined;
144
147
  node.properties.dataTheme = theme.name;
145
148
  node.properties.dataDefault = activeTab?.value;
146
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
149
+ node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
147
150
  if (!activeTab) {
148
151
  node.children = [
149
152
  {
@@ -156,7 +159,7 @@ export const tabsDirective = {
156
159
  ],
157
160
  properties: {
158
161
  className: [
159
- 'text-sm text-muted-foreground'
162
+ 'not-prose text-sm text-(--tw-prose-body)/80'
160
163
  ]
161
164
  },
162
165
  tagName: 'p'