payload-markdown 1.8.1 → 1.9.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 (94) hide show
  1. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  2. package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
  3. package/dist/core/plugins/remarkDirectiveLines.js +29 -18
  4. package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
  5. package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
  6. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  7. package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
  8. package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
  9. package/dist/core/renderMarkdown.js +2 -231
  10. package/dist/core/renderMarkdown.js.map +1 -1
  11. package/dist/core/sanitizeSchema.d.ts +11 -0
  12. package/dist/core/sanitizeSchema.js +176 -0
  13. package/dist/core/sanitizeSchema.js.map +1 -0
  14. package/dist/directives/definitions/badge.d.ts +5 -2
  15. package/dist/directives/definitions/badge.js +138 -10
  16. package/dist/directives/definitions/badge.js.map +1 -1
  17. package/dist/directives/definitions/badges.d.ts +1 -2
  18. package/dist/directives/definitions/badges.js +12 -3
  19. package/dist/directives/definitions/badges.js.map +1 -1
  20. package/dist/directives/definitions/button.d.ts +6 -2
  21. package/dist/directives/definitions/button.js +202 -12
  22. package/dist/directives/definitions/button.js.map +1 -1
  23. package/dist/directives/definitions/buttons.d.ts +1 -2
  24. package/dist/directives/definitions/buttons.js +12 -3
  25. package/dist/directives/definitions/buttons.js.map +1 -1
  26. package/dist/directives/definitions/callout.d.ts +1 -2
  27. package/dist/directives/definitions/callout.js +37 -3
  28. package/dist/directives/definitions/callout.js.map +1 -1
  29. package/dist/directives/definitions/card.d.ts +6 -2
  30. package/dist/directives/definitions/card.js +51 -3
  31. package/dist/directives/definitions/card.js.map +1 -1
  32. package/dist/directives/definitions/cards.d.ts +1 -2
  33. package/dist/directives/definitions/cards.js +40 -4
  34. package/dist/directives/definitions/cards.js.map +1 -1
  35. package/dist/directives/definitions/cell.d.ts +2 -2
  36. package/dist/directives/definitions/cell.js +9 -3
  37. package/dist/directives/definitions/cell.js.map +1 -1
  38. package/dist/directives/definitions/columns.d.ts +3 -4
  39. package/dist/directives/definitions/columns.js +17 -3
  40. package/dist/directives/definitions/columns.js.map +1 -1
  41. package/dist/directives/definitions/details.d.ts +1 -2
  42. package/dist/directives/definitions/details.js +24 -3
  43. package/dist/directives/definitions/details.js.map +1 -1
  44. package/dist/directives/definitions/section.d.ts +1 -2
  45. package/dist/directives/definitions/section.js +22 -3
  46. package/dist/directives/definitions/section.js.map +1 -1
  47. package/dist/directives/definitions/steps.d.ts +1 -2
  48. package/dist/directives/definitions/steps.js +22 -3
  49. package/dist/directives/definitions/steps.js.map +1 -1
  50. package/dist/directives/definitions/tab.d.ts +8 -2
  51. package/dist/directives/definitions/tab.js +45 -3
  52. package/dist/directives/definitions/tab.js.map +1 -1
  53. package/dist/directives/definitions/tabs.d.ts +1 -1
  54. package/dist/directives/definitions/tabs.js +40 -3
  55. package/dist/directives/definitions/tabs.js.map +1 -1
  56. package/dist/directives/definitions/toc.d.ts +1 -2
  57. package/dist/directives/definitions/toc.js +32 -4
  58. package/dist/directives/definitions/toc.js.map +1 -1
  59. package/dist/directives/diagnostics.d.ts +2 -15
  60. package/dist/directives/diagnostics.js +27 -157
  61. package/dist/directives/diagnostics.js.map +1 -1
  62. package/dist/directives/lint.d.ts +11 -0
  63. package/dist/directives/lint.js +33 -0
  64. package/dist/directives/lint.js.map +1 -0
  65. package/dist/directives/registry.d.ts +23 -5
  66. package/dist/directives/registry.js +52 -40
  67. package/dist/directives/registry.js.map +1 -1
  68. package/dist/directives/spec.js +25 -51
  69. package/dist/directives/spec.js.map +1 -1
  70. package/dist/directives/themeDiagnostics.d.ts +8 -0
  71. package/dist/directives/themeDiagnostics.js +21 -0
  72. package/dist/directives/themeDiagnostics.js.map +1 -0
  73. package/dist/directives/types.d.ts +157 -14
  74. package/dist/directives/types.js +6 -1
  75. package/dist/directives/types.js.map +1 -1
  76. package/dist/editor/directives/completions.js +11 -4
  77. package/dist/editor/directives/completions.js.map +1 -1
  78. package/dist/editor/themes/payload.js +2 -1
  79. package/dist/editor/themes/payload.js.map +1 -1
  80. package/dist/version.d.ts +1 -1
  81. package/dist/version.js +1 -1
  82. package/dist/version.js.map +1 -1
  83. package/package.json +1 -1
  84. package/skills/payload-markdown/claude/skill.json +1 -1
  85. package/skills/payload-markdown/codex/skill.json +1 -1
  86. package/dist/core/plugins/directiveBadge.d.ts +0 -6
  87. package/dist/core/plugins/directiveBadge.js +0 -94
  88. package/dist/core/plugins/directiveBadge.js.map +0 -1
  89. package/dist/core/plugins/directiveButton.d.ts +0 -6
  90. package/dist/core/plugins/directiveButton.js +0 -132
  91. package/dist/core/plugins/directiveButton.js.map +0 -1
  92. package/dist/directives/buttonSyntax.d.ts +0 -7
  93. package/dist/directives/buttonSyntax.js +0 -6
  94. package/dist/directives/buttonSyntax.js.map +0 -1
@@ -2,8 +2,10 @@ import { parseIconEntries } from '../../icons/entries.js';
2
2
  import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
3
3
  import { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js';
4
4
  import { getDirectiveLabelOrAttribute } from '../labels.js';
5
+ import { findNearestLintFrame } from '../lint.js';
5
6
  import { applyDirectivePalette, getPaletteRenderProperties, PALETTE_ATTRIBUTES, resolveIconPaletteName } from '../palette.js';
6
7
  import { resolveDirectiveTheme } from '../themes.js';
8
+ import { defineDirective } from '../types.js';
7
9
  import { getSafeHref, getUnsafeHrefWarnings } from '../urls.js';
8
10
  export const CARD_BODY_CLASS_NAMES = DIRECTIVE_BODY_CLASS;
9
11
  export const CARD_TITLE_CLASS_NAMES = 'not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)';
@@ -13,6 +15,11 @@ export const CARD_LINK_SCOPES = [
13
15
  'title'
14
16
  ];
15
17
  export const DEFAULT_CARD_LINK_SCOPE = 'full';
18
+ const CARD_LINK_OVERRIDE_ATTRIBUTES = [
19
+ 'href',
20
+ 'linkScope',
21
+ 'newTab'
22
+ ];
16
23
  export function isCardLinkScope(value) {
17
24
  return typeof value === 'string' && CARD_LINK_SCOPES.includes(value);
18
25
  }
@@ -136,7 +143,7 @@ function makeEyebrow(eyebrow) {
136
143
  tagName: 'p'
137
144
  };
138
145
  }
139
- export const cardDirective = {
146
+ export const cardDirective = defineDirective({
140
147
  name: 'card',
141
148
  allowedAttributes: [
142
149
  'eyebrow',
@@ -192,6 +199,20 @@ export const cardDirective = {
192
199
  }
193
200
  ];
194
201
  },
202
+ attributeTypes: {
203
+ href: {
204
+ type: 'url'
205
+ },
206
+ icon: {
207
+ type: 'icon'
208
+ },
209
+ iconPalette: {
210
+ type: 'palette'
211
+ },
212
+ palette: {
213
+ type: 'palette'
214
+ }
215
+ },
195
216
  attributeValues: {
196
217
  linkScope: CARD_LINK_SCOPES,
197
218
  newTab: [
@@ -199,6 +220,9 @@ export const cardDirective = {
199
220
  'false'
200
221
  ]
201
222
  },
223
+ container: {
224
+ labelAttribute: 'title'
225
+ },
202
226
  defaultAttributes: {
203
227
  linkScope: DEFAULT_CARD_LINK_SCOPE,
204
228
  newTab: 'false'
@@ -223,8 +247,32 @@ export const cardDirective = {
223
247
  };
224
248
  },
225
249
  kind: 'card',
226
- openMarker: ':::card',
250
+ lint: {
251
+ // Mirrors cards' validateMdast: a section-linked grid ignores card link overrides.
252
+ open ({ attributes, stack }) {
253
+ const cards = findNearestLintFrame(stack, 'cards')?.state;
254
+ const sectionLink = cards?.hasHref && (cards.linkScope === undefined || cards.linkScope === 'section');
255
+ const overrides = CARD_LINK_OVERRIDE_ATTRIBUTES.some((name)=>Object.prototype.hasOwnProperty.call(attributes, name));
256
+ return sectionLink && overrides ? [
257
+ 'Directive "cards" with linkScope="section" ignores child "card" link overrides.'
258
+ ] : [];
259
+ }
260
+ },
227
261
  public: true,
262
+ sanitize: {
263
+ article: [
264
+ 'dataDirective',
265
+ 'dataEyebrow',
266
+ 'dataHref',
267
+ 'dataIcon',
268
+ 'dataIconPalette',
269
+ 'dataLinkScope',
270
+ 'dataNewTab',
271
+ 'dataPalette',
272
+ 'dataTheme',
273
+ 'dataTitle'
274
+ ]
275
+ },
228
276
  supportsAttributes: true,
229
277
  tagName: 'article',
230
278
  themeAttributes: {
@@ -237,6 +285,6 @@ export const cardDirective = {
237
285
  if (typeof attributes.linkScope === 'string' && !isCardLinkScope(attributes.linkScope)) warnings.push(`Invalid card linkScope "${attributes.linkScope}". Falling back to "${DEFAULT_CARD_LINK_SCOPE}".`);
238
286
  return warnings;
239
287
  }
240
- };
288
+ });
241
289
 
242
290
  //# sourceMappingURL=card.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/card.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { type IconEntry, parseIconEntries } from '../../icons/entries.js'\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport {\n applyDirectivePalette,\n getPaletteRenderProperties,\n PALETTE_ATTRIBUTES,\n resolveIconPaletteName,\n} from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\n\nexport const CARD_BODY_CLASS_NAMES = DIRECTIVE_BODY_CLASS\nexport const CARD_TITLE_CLASS_NAMES =\n 'not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)'\nconst CARD_TITLE_LINK_CLASS_NAMES =\n 'rounded-sm transition-colors hover:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] focus-visible: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))]'\nexport const CARD_LINK_SCOPES = ['full', 'title'] as const\nexport const DEFAULT_CARD_LINK_SCOPE = 'full'\n\nexport type CardLinkScope = (typeof CARD_LINK_SCOPES)[number]\n\nexport function isCardLinkScope(value: unknown): value is CardLinkScope {\n return typeof value === 'string' && CARD_LINK_SCOPES.includes(value as CardLinkScope)\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 getLinkScope(node: ContainerDirective): CardLinkScope | undefined {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return undefined\n\n return isCardLinkScope(value) ? value : DEFAULT_CARD_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 makeTitle(title: string, href?: string, newTab = false): Element {\n const children: ElementContent[] = href\n ? [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: { ...getLinkProperties(href, newTab), className: [CARD_TITLE_LINK_CLASS_NAMES] },\n tagName: 'a',\n },\n ]\n : [{ type: 'text', value: title }]\n\n return {\n type: 'element',\n children,\n properties: {\n className: [CARD_TITLE_CLASS_NAMES],\n dataDirectiveTitle: 'card',\n },\n tagName: 'h3',\n }\n}\n\nfunction makeFullCardLink(href: string, title: string | undefined, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: title ? `Open ${title}` : 'Open card',\n className: [\n 'not-prose absolute inset-0 z-10 rounded-[inherit] 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: 'card',\n },\n tagName: 'a',\n }\n}\n\n/**\n * `icon` takes one icon or a comma-separated list; each entry may carry its\n * own palette (`@fa-brands/debian palette=debian`, see icons/entries.ts).\n */\nfunction makeIcons(card: Element, icons: IconEntry[], hasEyebrow: boolean): Element {\n return {\n type: 'element',\n children: icons.map((icon) =>\n makeDirectiveIconPlaceholder(\n icon.ref,\n ['pmd-card__icon inline-flex size-5 text-current'],\n resolveIconPaletteName(card, icon),\n ),\n ),\n properties: {\n className: [\n 'not-prose pmd-card__icons mb-3 flex flex-wrap items-center gap-2',\n // Clear of the eyebrow; its mb-2 collapses into this margin.\n ...(hasEyebrow ? ['mt-4'] : []),\n ],\n },\n tagName: 'div',\n }\n}\n\nfunction makeEyebrow(eyebrow: string): Element {\n return {\n type: 'element',\n children: [{ type: 'text', value: eyebrow }],\n properties: {\n // Muted relative to the body text rather than a fixed grey, so small\n // uppercase labels keep AA contrast on tinted or custom surfaces.\n className: ['not-prose mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-(--tw-prose-body)/80'],\n dataDirectiveEyebrow: 'card',\n },\n tagName: 'p',\n }\n}\n\nexport const cardDirective: LayoutDirectiveDefinition = {\n name: 'card',\n allowedAttributes: ['eyebrow', 'href', 'icon', 'linkScope', 'newTab', ...PALETTE_ATTRIBUTES, 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\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' && isCardLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARD_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const eyebrow =\n typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined\n const { entries: icons } = parseIconEntries(\n typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined,\n )\n const theme = resolveDirectiveTheme(\n 'card',\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 if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n node.properties.className = mergeClassNames(\n 'my-6',\n href && linkScope === 'full'\n ? 'relative cursor-pointer transition-colors hover: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))] [&>[data-directive-title]]:transition-colors hover:[&>[data-directive-title]]:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] [&_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 )\n applyDirectivePalette(node, config)\n\n node.children = [\n ...(href && linkScope === 'full' ? [makeFullCardLink(href, title, newTab)] : []),\n ...(eyebrow ? [makeEyebrow(eyebrow)] : []),\n ...(icons.length > 0 ? [makeIcons(node, icons, Boolean(eyebrow))] : []),\n ...(title ? [makeTitle(title, href && linkScope === 'title' ? href : undefined, newTab)] : []),\n {\n type: 'element',\n children,\n properties: {\n className: [CARD_BODY_CLASS_NAMES],\n dataDirectiveBody: 'card',\n },\n tagName: 'div',\n },\n ]\n },\n attributeValues: {\n linkScope: CARD_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n linkScope: DEFAULT_CARD_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Card content block with optional title, eyebrow, and card link.',\n editor: {\n detail: 'Layout directive',\n label: 'Card',\n snippet: ':::card[${Title}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'card',\n dataEyebrow: getAttribute(node, 'eyebrow'),\n dataHref: getSafeHref(getAttribute(node, 'href')),\n dataIcon: getAttribute(node, 'icon'),\n ...getPaletteRenderProperties(node),\n dataLinkScope: getLinkScope(node),\n dataNewTab: 'newTab' in (node.attributes ?? {})\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: getAttribute(node, 'theme'),\n dataTitle: getDirectiveLabelOrAttribute(node, 'title'),\n }\n },\n kind: 'card',\n openMarker: ':::card',\n public: true,\n supportsAttributes: true,\n tagName: 'article',\n themeAttributes: {\n theme: 'card',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('card', attributes)]\n\n if (typeof attributes.linkScope === 'string' && !isCardLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid card linkScope \"${attributes.linkScope}\". Falling back to \"${DEFAULT_CARD_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n}\n"],"names":["parseIconEntries","DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","applyDirectivePalette","getPaletteRenderProperties","PALETTE_ATTRIBUTES","resolveIconPaletteName","resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","CARD_BODY_CLASS_NAMES","CARD_TITLE_CLASS_NAMES","CARD_TITLE_LINK_CLASS_NAMES","CARD_LINK_SCOPES","DEFAULT_CARD_LINK_SCOPE","isCardLinkScope","value","includes","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","getLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeTitle","title","children","type","properties","className","tagName","dataDirectiveTitle","makeFullCardLink","ariaLabel","dataDirectiveLink","makeIcons","card","icons","hasEyebrow","map","icon","ref","makeEyebrow","eyebrow","dataDirectiveEyebrow","cardDirective","allowedAttributes","applyHast","config","mergeClassNames","dataTitle","dataHref","dataLinkScope","dataNewTab","dataEyebrow","entries","dataIcon","theme","dataTheme","themes","hookClassName","modifierClassName","classes","length","Boolean","dataDirectiveBody","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAKA,SAAyBA,gBAAgB,QAAQ,yBAAwB;AACzE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SACEC,qBAAqB,EACrBC,0BAA0B,EAC1BC,kBAAkB,EAClBC,sBAAsB,QACjB,gBAAe;AACtB,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAE/D,OAAO,MAAMC,wBAAwBV,qBAAoB;AACzD,OAAO,MAAMW,yBACX,iFAAgF;AAClF,MAAMC,8BACJ;AACF,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;CAAQ,CAAS;AAC1D,OAAO,MAAMC,0BAA0B,OAAM;AAI7C,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,OAAO,OAAOA,UAAU,YAAYH,iBAAiBI,QAAQ,CAACD;AAChE;AAEA,SAASE,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMJ,QAAQG,KAAKE,UAAU,EAAE,CAACD,KAAK;IAErC,OAAO,OAAOJ,UAAU,YAAYA,MAAMM,IAAI,KAAKN,MAAMM,IAAI,KAAKC;AACpE;AAEA,SAASC,oBAAoBL,IAAwB,EAAEC,IAAY;IACjE,MAAMC,aAAaF,KAAKE,UAAU;IAIlC,MAAML,QAAQK,YAAY,CAACD,KAAK;IAEhC,IAAIJ,UAAU,MAAM,OAAO;IAC3B,IAAI,OAAOA,UAAU,UAAU,OAAO;IAEtC,OAAOA,UAAU;AACnB;AAEA,SAASS,aAAaN,I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AAe;YACfpB,aAAa5C,aAAaC,MAAM;YAChCwC,UAAUnD,YAAYU,aAAaC,MAAM;YACzC6C,UAAU9C,aAAaC,MAAM;YAC7B,GAAGf,2BAA2Be,KAAK;YACnCyC,eAAenC,aAAaN;YAC5B0C,YAAY,YAAa1C,CAAAA,KAAKE,UAAU,IAAI,CAAC,CAAA,IACzCG,oBAAoBL,MAAM,YAAY,SAAS,UAC/CI;YACJ2C,WAAWhD,aAAaC,MAAM;YAC9BuC,WAAWxD,6BAA6BiB,MAAM;QAChD;IACF;IACAgE,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBhD,SAAS;IACTiD,iBAAiB;QACftB,OAAO;IACT;IACAuB,oBAAmB,EAAEnE,UAAU,EAAE;QAC/B,MAAMoE,WAAqB;eAAIhF,sBAAsB,QAAQY;SAAY;QAEzE,IAAI,OAAOA,WAAWK,SAAS,KAAK,YAAY,CAACX,gBAAgBM,WAAWK,SAAS,GACnF+D,SAASC,IAAI,CACX,CAAC,wBAAwB,EAAErE,WAAWK,SAAS,CAAC,oBAAoB,EAAEZ,wBAAwB,EAAE,CAAC;QAGrG,OAAO2E;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/card.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport { type IconEntry, parseIconEntries } from '../../icons/entries.js'\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { findNearestLintFrame } from '../lint.js'\nimport {\n applyDirectivePalette,\n getPaletteRenderProperties,\n PALETTE_ATTRIBUTES,\n resolveIconPaletteName,\n} from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\n\nexport const CARD_BODY_CLASS_NAMES = DIRECTIVE_BODY_CLASS\nexport const CARD_TITLE_CLASS_NAMES =\n 'not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)'\nconst CARD_TITLE_LINK_CLASS_NAMES =\n 'rounded-sm transition-colors hover:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] focus-visible: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))]'\nexport const CARD_LINK_SCOPES = ['full', 'title'] as const\nexport const DEFAULT_CARD_LINK_SCOPE = 'full'\n\nexport type CardLinkScope = (typeof CARD_LINK_SCOPES)[number]\n\n/** Editor-linter state of an open `cards` frame (set by the `cards` lint hook). */\nexport type CardsLintState = {\n hasHref: boolean\n linkScope?: string\n}\n\nconst CARD_LINK_OVERRIDE_ATTRIBUTES = ['href', 'linkScope', 'newTab'] as const\n\nexport function isCardLinkScope(value: unknown): value is CardLinkScope {\n return typeof value === 'string' && CARD_LINK_SCOPES.includes(value as CardLinkScope)\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 getLinkScope(node: ContainerDirective): CardLinkScope | undefined {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return undefined\n\n return isCardLinkScope(value) ? value : DEFAULT_CARD_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 makeTitle(title: string, href?: string, newTab = false): Element {\n const children: ElementContent[] = href\n ? [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: { ...getLinkProperties(href, newTab), className: [CARD_TITLE_LINK_CLASS_NAMES] },\n tagName: 'a',\n },\n ]\n : [{ type: 'text', value: title }]\n\n return {\n type: 'element',\n children,\n properties: {\n className: [CARD_TITLE_CLASS_NAMES],\n dataDirectiveTitle: 'card',\n },\n tagName: 'h3',\n }\n}\n\nfunction makeFullCardLink(href: string, title: string | undefined, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: title ? `Open ${title}` : 'Open card',\n className: [\n 'not-prose absolute inset-0 z-10 rounded-[inherit] 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: 'card',\n },\n tagName: 'a',\n }\n}\n\n/**\n * `icon` takes one icon or a comma-separated list; each entry may carry its\n * own palette (`@fa-brands/debian palette=debian`, see icons/entries.ts).\n */\nfunction makeIcons(card: Element, icons: IconEntry[], hasEyebrow: boolean): Element {\n return {\n type: 'element',\n children: icons.map((icon) =>\n makeDirectiveIconPlaceholder(\n icon.ref,\n ['pmd-card__icon inline-flex size-5 text-current'],\n resolveIconPaletteName(card, icon),\n ),\n ),\n properties: {\n className: [\n 'not-prose pmd-card__icons mb-3 flex flex-wrap items-center gap-2',\n // Clear of the eyebrow; its mb-2 collapses into this margin.\n ...(hasEyebrow ? ['mt-4'] : []),\n ],\n },\n tagName: 'div',\n }\n}\n\nfunction makeEyebrow(eyebrow: string): Element {\n return {\n type: 'element',\n children: [{ type: 'text', value: eyebrow }],\n properties: {\n // Muted relative to the body text rather than a fixed grey, so small\n // uppercase labels keep AA contrast on tinted or custom surfaces.\n className: ['not-prose mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-(--tw-prose-body)/80'],\n dataDirectiveEyebrow: 'card',\n },\n tagName: 'p',\n }\n}\n\nexport const cardDirective = defineDirective({\n name: 'card',\n allowedAttributes: ['eyebrow', 'href', 'icon', 'linkScope', 'newTab', ...PALETTE_ATTRIBUTES, 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\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' && isCardLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARD_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const eyebrow =\n typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined\n const { entries: icons } = parseIconEntries(\n typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined,\n )\n const theme = resolveDirectiveTheme(\n 'card',\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 if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n node.properties.className = mergeClassNames(\n 'my-6',\n href && linkScope === 'full'\n ? 'relative cursor-pointer transition-colors hover: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))] [&>[data-directive-title]]:transition-colors hover:[&>[data-directive-title]]:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] [&_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 )\n applyDirectivePalette(node, config)\n\n node.children = [\n ...(href && linkScope === 'full' ? [makeFullCardLink(href, title, newTab)] : []),\n ...(eyebrow ? [makeEyebrow(eyebrow)] : []),\n ...(icons.length > 0 ? [makeIcons(node, icons, Boolean(eyebrow))] : []),\n ...(title ? [makeTitle(title, href && linkScope === 'title' ? href : undefined, newTab)] : []),\n {\n type: 'element',\n children,\n properties: {\n className: [CARD_BODY_CLASS_NAMES],\n dataDirectiveBody: 'card',\n },\n tagName: 'div',\n },\n ]\n },\n attributeTypes: {\n href: { type: 'url' },\n icon: { type: 'icon' },\n iconPalette: { type: 'palette' },\n palette: { type: 'palette' },\n },\n attributeValues: {\n linkScope: CARD_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n container: {\n labelAttribute: 'title',\n },\n defaultAttributes: {\n linkScope: DEFAULT_CARD_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Card content block with optional title, eyebrow, and card link.',\n editor: {\n detail: 'Layout directive',\n label: 'Card',\n snippet: ':::card[${Title}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'card',\n dataEyebrow: getAttribute(node, 'eyebrow'),\n dataHref: getSafeHref(getAttribute(node, 'href')),\n dataIcon: getAttribute(node, 'icon'),\n ...getPaletteRenderProperties(node),\n dataLinkScope: getLinkScope(node),\n dataNewTab: 'newTab' in (node.attributes ?? {})\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: getAttribute(node, 'theme'),\n dataTitle: getDirectiveLabelOrAttribute(node, 'title'),\n }\n },\n kind: 'card',\n lint: {\n // Mirrors cards' validateMdast: a section-linked grid ignores card link overrides.\n open({ attributes, stack }) {\n const cards = findNearestLintFrame(stack, 'cards')?.state as CardsLintState | undefined\n const sectionLink = cards?.hasHref && (cards.linkScope === undefined || cards.linkScope === 'section')\n const overrides = CARD_LINK_OVERRIDE_ATTRIBUTES.some((name) =>\n Object.prototype.hasOwnProperty.call(attributes, name),\n )\n\n return sectionLink && overrides\n ? ['Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.']\n : []\n },\n },\n public: true,\n sanitize: {\n article: [\n 'dataDirective',\n 'dataEyebrow',\n 'dataHref',\n 'dataIcon',\n 'dataIconPalette',\n 'dataLinkScope',\n 'dataNewTab',\n 'dataPalette',\n 'dataTheme',\n 'dataTitle',\n ],\n },\n supportsAttributes: true,\n tagName: 'article',\n themeAttributes: {\n theme: 'card',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('card', attributes)]\n\n if (typeof attributes.linkScope === 'string' && !isCardLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid card linkScope \"${attributes.linkScope}\". Falling back to \"${DEFAULT_CARD_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n})\n"],"names":["parseIconEntries","DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","findNearestLintFrame","applyDirectivePalette","getPaletteRenderProperties","PALETTE_ATTRIBUTES","resolveIconPaletteName","resolveDirectiveTheme","defineDirective","getSafeHref","getUnsafeHrefWarnings","CARD_BODY_CLASS_NAMES","CARD_TITLE_CLASS_NAMES","CARD_TITLE_LINK_CLASS_NAMES","CARD_LINK_SCOPES","DEFAULT_CARD_LINK_SCOPE","CARD_LINK_OVERRIDE_ATTRIBUTES","isCardLinkScope","value","includes","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","getLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeTitle","title","children","type","properties","className","tagName","dataDirectiveTitle","makeFullCardLink","ariaLabel","dataDirectiveLink","makeIcons","card","icons","hasEyebrow","map","icon","ref","makeEyebrow","eyebrow","dataDirectiveEyebrow","cardDirective","allowedAttributes","applyHast","config","mergeClassNames","dataTitle","dataHref","dataLinkScope","dataNewTab","dataEyebrow","entries","dataIcon","theme","dataTheme","themes","hookClassName","modifierClassName","classes","length","Boolean","dataDirectiveBody","attributeTypes","iconPalette","palette","attributeValues","container","labelAttribute","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","lint","open","stack","cards","state","sectionLink","hasHref","overrides","some","Object","prototype","hasOwnProperty","call","public","sanitize","article","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAGA,SAAyBA,gBAAgB,QAAQ,yBAAwB;AACzE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,oBAAoB,QAAQ,aAAY;AACjD,SACEC,qBAAqB,EACrBC,0BAA0B,EAC1BC,kBAAkB,EAClBC,sBAAsB,QACjB,gBAAe;AACtB,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAE/D,OAAO,MAAMC,wBAAwBZ,qBAAoB;AACzD,OAAO,MAAMa,yBACX,iFAAgF;AAClF,MAAMC,8BACJ;AACF,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;CAAQ,CAAS;AAC1D,OAAO,MAAMC,0BAA0B,OAAM;AAU7C,MAAMC,gCAAgC;IAAC;IAAQ;IAAa;CAAS;AAErE,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,OAAO,OAAOA,UAAU,YAAYJ,iBAAiBK,QAAQ,CAACD;AAChE;AAEA,SAASE,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMJ,QAAQG,KAAKE,UAAU,EAAE,CAACD,KAAK;IAErC,OAAO,OAAOJ,UAAU,YAAYA,MAAMM,IAAI,KAAKN,MAAMM,IAAI,KAAKC;AACpE;AAEA,SAASC,oBAAoBL,IAAwB,EAAEC,IAAY;IACjE,MAAMC,aAAaF,KAAKE,UAAU;IAIlC,MAAML,QAAQK,YAAY,CAACD,KAAK;IAEhC,IAAIJ,UAAU,MAAM,OAAO;IAC3B,IAAI,OAAOA,UAAU,UAAU,OAAO;IAEtC,OAAOA,UAAU;AACnB;AAEA,SAASS,aAAaN,IAAwB;IAC5C,MAAMH,QAAQG,KAAK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AWK,SAAS,GACnFkF,SAASC,IAAI,CACX,CAAC,wBAAwB,EAAExF,WAAWK,SAAS,CAAC,oBAAoB,EAAEb,wBAAwB,EAAE,CAAC;QAGrG,OAAO+F;IACT;AACF,GAAE"}
@@ -1,5 +1,4 @@
1
1
  import type { ContainerDirective } from 'mdast-util-directive';
2
- import type { LayoutDirectiveDefinition } from '../types.js';
3
2
  export declare const CARD_GRID_COLUMNS: readonly ["1", "2", "3", "4", "auto"];
4
3
  export declare const DEFAULT_CARD_GRID_COLUMNS = "3";
5
4
  export declare const CARDS_LINK_SCOPES: readonly ["section", "card", "title"];
@@ -8,4 +7,4 @@ export declare const FALLBACK_CARDS_LINK_SCOPE = "card";
8
7
  export type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number];
9
8
  export type CardsLinkScope = (typeof CARDS_LINK_SCOPES)[number];
10
9
  export declare function resolveCardGridColumns(node: ContainerDirective): CardGridColumns;
11
- export declare const cardsDirective: LayoutDirectiveDefinition;
10
+ export declare const cardsDirective: import("../types.js").LayoutDirectiveDefinition<"cards", "cards">;
@@ -1,6 +1,7 @@
1
1
  import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
2
2
  import { resolveDirectiveTheme } from '../themes.js';
3
- import { getSafeHref, getUnsafeHrefWarnings } from '../urls.js';
3
+ import { defineDirective } from '../types.js';
4
+ import { getSafeHref, getUnsafeHrefWarnings, isSafeHref } from '../urls.js';
4
5
  import { DEFAULT_CARD_LINK_SCOPE } from './card.js';
5
6
  export const CARD_GRID_COLUMNS = [
6
7
  '1',
@@ -93,7 +94,7 @@ export function resolveCardGridColumns(node) {
93
94
  const columns = node.attributes?.columns;
94
95
  return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS;
95
96
  }
96
- export const cardsDirective = {
97
+ export const cardsDirective = defineDirective({
97
98
  name: 'cards',
98
99
  allowedAttributes: [
99
100
  'cardTheme',
@@ -146,6 +147,17 @@ export const cardsDirective = {
146
147
  ...node.children
147
148
  ];
148
149
  },
150
+ attributeTypes: {
151
+ href: {
152
+ type: 'url'
153
+ },
154
+ iconPalette: {
155
+ type: 'palette'
156
+ },
157
+ palette: {
158
+ type: 'palette'
159
+ }
160
+ },
149
161
  attributeValues: {
150
162
  columns: CARD_GRID_COLUMNS,
151
163
  linkScope: CARDS_LINK_SCOPES,
@@ -154,6 +166,7 @@ export const cardsDirective = {
154
166
  'false'
155
167
  ]
156
168
  },
169
+ container: {},
157
170
  defaultAttributes: {
158
171
  columns: DEFAULT_CARD_GRID_COLUMNS,
159
172
  linkScope: DEFAULT_CARDS_LINK_SCOPE,
@@ -179,8 +192,31 @@ export const cardsDirective = {
179
192
  };
180
193
  },
181
194
  kind: 'cards',
182
- openMarker: ':::cards',
195
+ lint: {
196
+ // Read by the lint hook of `card` (see CardsLintState).
197
+ open ({ attributes, frame }) {
198
+ const state = {
199
+ hasHref: typeof attributes.href === 'string' && isSafeHref(attributes.href.trim()),
200
+ linkScope: typeof attributes.linkScope === 'string' ? attributes.linkScope : undefined
201
+ };
202
+ frame.state = state;
203
+ return [];
204
+ }
205
+ },
183
206
  public: true,
207
+ sanitize: {
208
+ section: [
209
+ 'dataCardTheme',
210
+ 'dataColumns',
211
+ 'dataDirective',
212
+ 'dataHref',
213
+ 'dataIconPalette',
214
+ 'dataLinkScope',
215
+ 'dataNewTab',
216
+ 'dataPalette',
217
+ 'dataTheme'
218
+ ]
219
+ },
184
220
  supportsAttributes: true,
185
221
  tagName: 'section',
186
222
  themeAttributes: {
@@ -203,6 +239,6 @@ export const cardsDirective = {
203
239
  }
204
240
  return warnings;
205
241
  }
206
- };
242
+ });
207
243
 
208
244
  //# sourceMappingURL=cards.js.map
@@ -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 { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\nimport { DEFAULT_CARD_LINK_SCOPE } from './card.js'\n\nexport const CARD_GRID_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\nexport const DEFAULT_CARD_GRID_COLUMNS = '3'\nexport const CARDS_LINK_SCOPES = ['section', 'card', 'title'] as const\nexport const DEFAULT_CARDS_LINK_SCOPE = 'section'\nexport const FALLBACK_CARDS_LINK_SCOPE = 'card'\n\nexport type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number]\nexport type CardsLinkScope = (typeof CARDS_LINK_SCOPES)[number]\n\n// Columns collapse on the grid's own width (not the viewport): up to N\n// columns while each stays at least 14rem wide. The 2rem term covers the\n// widest theme gap, so a theme's gap never costs a column that would fit.\nconst cardGridColumnClasses: Record<CardGridColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',\n '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',\n '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',\n auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]',\n}\n\nfunction isCardGridColumns(value: unknown): value is CardGridColumns {\n return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value as CardGridColumns)\n}\n\nfunction isCardsLinkScope(value: unknown): value is CardsLinkScope {\n return typeof value === 'string' && CARDS_LINK_SCOPES.includes(value as CardsLinkScope)\n}\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(node: ContainerDirective, name: string): boolean {\n const attributes = node.attributes as\n | null\n | Record<string, boolean | null | string | undefined>\n | undefined\n const value = attributes?.[name]\n\n if (value === true) return true\n if (typeof value !== 'string') return false\n\n return value === 'true'\n}\n\nfunction hasAttribute(node: ContainerDirective, name: string): boolean {\n return Object.prototype.hasOwnProperty.call(node.attributes ?? {}, name)\n}\n\nfunction getCardsLinkScope(node: ContainerDirective): CardsLinkScope {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return DEFAULT_CARDS_LINK_SCOPE\n\n return isCardsLinkScope(value) ? value : FALLBACK_CARDS_LINK_SCOPE\n}\n\nfunction getLinkProperties(href: string, newTab: boolean): Element['properties'] {\n return {\n href,\n ...(newTab\n ? {\n rel: ['noopener', 'noreferrer'],\n target: '_blank',\n }\n : {}),\n }\n}\n\nfunction makeSectionLink(href: string, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: 'Open card section',\n className: [\n 'not-prose absolute -inset-2 z-10 rounded-3xl focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]',\n ],\n dataDirectiveLink: 'cards',\n },\n tagName: 'a',\n }\n}\n\nfunction hasCardLinkOverride(node: ContainerDirective): boolean {\n return ['href', 'linkScope', 'newTab'].some((name) => hasAttribute(node, name))\n}\n\nfunction isContainerDirective(node: unknown): node is ContainerDirective {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n (node as { type?: string }).type === 'containerDirective',\n )\n}\n\nexport function resolveCardGridColumns(node: ContainerDirective): CardGridColumns {\n const columns = node.attributes?.columns\n\n return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS\n}\n\nexport const cardsDirective: LayoutDirectiveDefinition = {\n name: 'cards',\n allowedAttributes: ['cardTheme', 'columns', 'href', 'iconPalette', 'linkScope', 'newTab', 'palette', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const columns =\n typeof node.properties.dataColumns === 'string'\n ? node.properties.dataColumns\n : DEFAULT_CARD_GRID_COLUMNS\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardsLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARDS_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const theme = resolveDirectiveTheme(\n 'cards',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cardTheme =\n typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined\n const childLinkScope = linkScope === 'title' ? 'title' : DEFAULT_CARD_LINK_SCOPE\n\n for (const child of node.children) {\n if (child.type !== 'element' || child.properties?.dataVlLayout !== 'card') continue\n\n if (typeof child.properties.dataTheme !== 'string' && cardTheme)\n child.properties.dataTheme = cardTheme\n\n // Cards without a palette of their own paint their icons with the\n // grid's iconPalette (or palette); the grid's surface tokens are inherited.\n const iconPaletteDefault = node.properties.dataIconPalette ?? node.properties.dataPalette\n if (\n typeof iconPaletteDefault === 'string' &&\n typeof child.properties.dataPalette !== 'string' &&\n typeof child.properties.dataIconPalette !== 'string'\n )\n child.properties.dataIconPalette = iconPaletteDefault\n\n if (href && linkScope === 'section') {\n delete child.properties.dataHref\n delete child.properties.dataLinkScope\n delete child.properties.dataNewTab\n continue\n }\n\n if (!href) continue\n\n if (typeof child.properties.dataHref !== 'string') child.properties.dataHref = href\n if (typeof child.properties.dataLinkScope !== 'string')\n child.properties.dataLinkScope = childLinkScope\n if (typeof child.properties.dataNewTab !== 'string')\n child.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n // Spacing lives in the theme; the base only sets what every grid needs.\n 'grid [&>article]:my-0',\n href && linkScope === 'section'\n ? 'relative cursor-pointer [&>article]:transition-colors hover:[&>article]:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20'\n : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS],\n )\n\n if (href && linkScope === 'section') node.children = [makeSectionLink(href, newTab), ...node.children]\n },\n attributeValues: {\n columns: CARD_GRID_COLUMNS,\n linkScope: CARDS_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n columns: DEFAULT_CARD_GRID_COLUMNS,\n linkScope: DEFAULT_CARDS_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Responsive card grid for docs and landing-page content.',\n editor: {\n detail: 'Layout directive',\n label: 'Cards',\n snippet:\n ':::cards{\\n columns=\"${3}\"\\n}\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n const href = getSafeHref(getAttribute(node, 'href'))\n\n return {\n ...getPaletteRenderProperties(node),\n dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,\n dataColumns: resolveCardGridColumns(node),\n dataDirective: 'cards',\n dataHref: href,\n dataLinkScope: href || hasAttribute(node, 'linkScope') ? getCardsLinkScope(node) : undefined,\n dataNewTab: href && hasAttribute(node, 'newTab')\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cards',\n openMarker: ':::cards',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n cardTheme: 'card',\n theme: 'cards',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('cards', attributes)]\n\n if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns))\n warnings.push(\n `Invalid cards columns \"${attributes.columns}\". Falling back to \"${DEFAULT_CARD_GRID_COLUMNS}\".`,\n )\n\n if (typeof attributes.linkScope === 'string' && !isCardsLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid cards linkScope \"${attributes.linkScope}\". Falling back to \"${FALLBACK_CARDS_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n validateMdast(node) {\n const warnings: string[] = []\n\n if (getSafeHref(getAttribute(node, 'href')) && getCardsLinkScope(node) === 'section') {\n const hasOverrides = node.children.some(\n (child) => isContainerDirective(child) && child.name === 'card' && hasCardLinkOverride(child),\n )\n\n if (hasOverrides)\n warnings.push(\n 'Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.',\n )\n }\n\n return warnings\n },\n}\n"],"names":["applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","DEFAULT_CARD_LINK_SCOPE","CARD_GRID_COLUMNS","DEFAULT_CARD_GRID_COLUMNS","CARDS_LINK_SCOPES","DEFAULT_CARDS_LINK_SCOPE","FALLBACK_CARDS_LINK_SCOPE","cardGridColumnClasses","auto","isCardGridColumns","value","includes","isCardsLinkScope","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","hasAttribute","Object","prototype","hasOwnProperty","call","getCardsLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeSectionLink","type","children","properties","ariaLabel","className","dataDirectiveLink","tagName","hasCardLinkOverride","some","isContainerDirective","Boolean","resolveCardGridColumns","columns","cardsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataColumns","dataHref","dataLinkScope","dataNewTab","theme","dataTheme","themes","cardTheme","dataCardTheme","childLinkScope","child","dataVlLayout","iconPaletteDefault","dataIconPalette","dataPalette","hookClassName","modifierClassName","classes","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push","validateMdast","hasOverrides"],"mappings":"AAKA,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAC/D,SAASC,uBAAuB,QAAQ,YAAW;AAEnD,OAAO,MAAMC,oBAAoB;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,uEAAuE;AACvE,yEAAyE;AACzE,0EAA0E;AAC1E,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;IAIlC,MAAMN,QAAQM,YAAY,CAACD,KAAK;IAEhC,IAAIL,UAAU,MAAM,OAAO;IAC3B,IAAI,OAAOA,UAAU,UAAU,OAAO;IAEtC,OAAOA,UAAU;AACnB;AAEA,SAASU,aAAaN,IAAwB,EAAEC,IAAY;IAC1D,OAAOM,OAAOC,S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,eAAezE,KAAKoB,QAAQ,CAACO,IAAI,CACrC,CAACoB,QAAUnB,qBAAqBmB,UAAUA,MAAM9C,IAAI,KAAK,UAAUyB,oBAAoBqB;YAGzF,IAAI0B,cACFH,SAASC,IAAI,CACX;QAEN;QAEA,OAAOD;IACT;AACF,EAAC"}
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 { CardsLintState } from './card.js'\n\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.js'\nimport { getSafeHref, getUnsafeHrefWarnings, isSafeHref } 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 = defineDirective({\n name: 'cards',\n allowedAttributes: ['cardTheme', 'columns', 'href', 'iconPalette', 'linkScope', 'newTab', 'palette', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const columns =\n typeof node.properties.dataColumns === 'string'\n ? node.properties.dataColumns\n : DEFAULT_CARD_GRID_COLUMNS\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardsLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARDS_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const theme = resolveDirectiveTheme(\n 'cards',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cardTheme =\n typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined\n const childLinkScope = linkScope === 'title' ? 'title' : DEFAULT_CARD_LINK_SCOPE\n\n for (const child of node.children) {\n if (child.type !== 'element' || child.properties?.dataVlLayout !== 'card') continue\n\n if (typeof child.properties.dataTheme !== 'string' && cardTheme)\n child.properties.dataTheme = cardTheme\n\n // Cards without a palette of their own paint their icons with the\n // grid's iconPalette (or palette); the grid's surface tokens are inherited.\n const iconPaletteDefault = node.properties.dataIconPalette ?? node.properties.dataPalette\n if (\n typeof iconPaletteDefault === 'string' &&\n typeof child.properties.dataPalette !== 'string' &&\n typeof child.properties.dataIconPalette !== 'string'\n )\n child.properties.dataIconPalette = iconPaletteDefault\n\n if (href && linkScope === 'section') {\n delete child.properties.dataHref\n delete child.properties.dataLinkScope\n delete child.properties.dataNewTab\n continue\n }\n\n if (!href) continue\n\n if (typeof child.properties.dataHref !== 'string') child.properties.dataHref = href\n if (typeof child.properties.dataLinkScope !== 'string')\n child.properties.dataLinkScope = childLinkScope\n if (typeof child.properties.dataNewTab !== 'string')\n child.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n // Spacing lives in the theme; the base only sets what every grid needs.\n 'grid [&>article]:my-0',\n href && linkScope === 'section'\n ? 'relative cursor-pointer [&>article]:transition-colors hover:[&>article]:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20'\n : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS],\n )\n\n if (href && linkScope === 'section') node.children = [makeSectionLink(href, newTab), ...node.children]\n },\n attributeTypes: {\n href: { type: 'url' },\n iconPalette: { type: 'palette' },\n palette: { type: 'palette' },\n },\n attributeValues: {\n columns: CARD_GRID_COLUMNS,\n linkScope: CARDS_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n container: {},\n defaultAttributes: {\n columns: DEFAULT_CARD_GRID_COLUMNS,\n linkScope: DEFAULT_CARDS_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Responsive card grid for docs and landing-page content.',\n editor: {\n detail: 'Layout directive',\n label: 'Cards',\n snippet:\n ':::cards{\\n columns=\"${3}\"\\n}\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::card[${Title}]\\n${Content}\\n:::\\n\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n const href = getSafeHref(getAttribute(node, 'href'))\n\n return {\n ...getPaletteRenderProperties(node),\n dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,\n dataColumns: resolveCardGridColumns(node),\n dataDirective: 'cards',\n dataHref: href,\n dataLinkScope: href || hasAttribute(node, 'linkScope') ? getCardsLinkScope(node) : undefined,\n dataNewTab: href && hasAttribute(node, 'newTab')\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cards',\n lint: {\n // Read by the lint hook of `card` (see CardsLintState).\n open({ attributes, frame }) {\n const state: CardsLintState = {\n hasHref: typeof attributes.href === 'string' && isSafeHref(attributes.href.trim()),\n linkScope: typeof attributes.linkScope === 'string' ? attributes.linkScope : undefined,\n }\n\n frame.state = state\n return []\n },\n },\n public: true,\n sanitize: {\n section: [\n 'dataCardTheme',\n 'dataColumns',\n 'dataDirective',\n 'dataHref',\n 'dataIconPalette',\n 'dataLinkScope',\n 'dataNewTab',\n 'dataPalette',\n 'dataTheme',\n ],\n },\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n cardTheme: 'card',\n theme: 'cards',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('cards', attributes)]\n\n if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns))\n warnings.push(\n `Invalid cards columns \"${attributes.columns}\". Falling back to \"${DEFAULT_CARD_GRID_COLUMNS}\".`,\n )\n\n if (typeof attributes.linkScope === 'string' && !isCardsLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid cards linkScope \"${attributes.linkScope}\". Falling back to \"${FALLBACK_CARDS_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n validateMdast(node) {\n const warnings: string[] = []\n\n if (getSafeHref(getAttribute(node, 'href')) && getCardsLinkScope(node) === 'section') {\n const hasOverrides = node.children.some(\n (child) => isContainerDirective(child) && child.name === 'card' && hasCardLinkOverride(child),\n )\n\n if (hasOverrides)\n warnings.push(\n 'Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.',\n )\n }\n\n return warnings\n },\n})\n"],"names":["applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","defineDirective","getSafeHref","getUnsafeHrefWarnings","isSafeHref","DEFAULT_CARD_LINK_SCOPE","CARD_GRID_COLUMNS","DEFAULT_CARD_GRID_COLUMNS","CARDS_LINK_SCOPES","DEFAULT_CARDS_LINK_SCOPE","FALLBACK_CARDS_LINK_SCOPE","cardGridColumnClasses","auto","isCardGridColumns","value","includes","isCardsLinkScope","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","hasAttribute","Object","prototype","hasOwnProperty","call","getCardsLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeSectionLink","type","children","properties","ariaLabel","className","dataDirectiveLink","tagName","hasCardLinkOverride","some","isContainerDirective","Boolean","resolveCardGridColumns","columns","cardsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataColumns","dataHref","dataLinkScope","dataNewTab","theme","dataTheme","themes","cardTheme","dataCardTheme","childLinkScope","child","dataVlLayout","iconPaletteDefault","dataIconPalette","dataPalette","hookClassName","modifierClassName","classes","attributeTypes","iconPalette","palette","attributeValues","container","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","lint","open","frame","state","hasHref","public","sanitize","section","supportsAttributes","themeAttributes","validateAttributes","warnings","push","validateMdast","hasOverrides"],"mappings":"AAKA,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,WAAW,EAAEC,qBAAqB,EAAEC,UAAU,QAAQ,aAAY;AAC3E,SAASC,uBAAuB,QAAQ,YAAW;AAEnD,OAAO,MAAMC,oBAAoB;IAAC;IAAK;IAAK;IAAK;IAAK;CAAO,CAAS;AACtE,OAAO,MAAMC,4BAA4B,IAAG;AAC5C,OAAO,MA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EpB,0BAA0B,EAAE,CAAC;QAGxG,OAAOwF;IACT;IACAE,eAAclF,IAAI;QAChB,MAAMgF,WAAqB,EAAE;QAE7B,IAAIhG,YAAYe,aAAaC,MAAM,YAAYW,kBAAkBX,UAAU,WAAW;YACpF,MAAMmF,eAAenF,KAAKoB,QAAQ,CAACO,IAAI,CACrC,CAACoB,QAAUnB,qBAAqBmB,UAAUA,MAAM9C,IAAI,KAAK,UAAUyB,oBAAoBqB;YAGzF,IAAIoC,cACFH,SAASC,IAAI,CACX;QAEN;QAEA,OAAOD;IACT;AACF,GAAE"}
@@ -1,4 +1,4 @@
1
1
  import type { ContainerDirective } from 'mdast-util-directive';
2
- import type { DirectiveChild, LayoutDirectiveDefinition } from '../types.js';
3
- export declare const cellDirective: LayoutDirectiveDefinition;
2
+ import type { DirectiveChild } from '../types.js';
3
+ export declare const cellDirective: import("../types.js").LayoutDirectiveDefinition<"cell", "cell">;
4
4
  export declare function makeCellDirective(children: DirectiveChild[]): ContainerDirective;
@@ -1,6 +1,7 @@
1
1
  import { setDirectiveRenderData } from '../renderData.js';
2
2
  import { resolveDirectiveTheme } from '../themes.js';
3
- export const cellDirective = {
3
+ import { defineDirective } from '../types.js';
4
+ export const cellDirective = defineDirective({
4
5
  name: 'cell',
5
6
  allowedAttributes: [
6
7
  'theme'
@@ -10,6 +11,7 @@ export const cellDirective = {
10
11
  node.properties.dataTheme = theme.name;
11
12
  node.properties.className = mergeClassNames('[&>:first-child]:mt-0 [&>:last-child]:mb-0', theme.hookClassName, theme.modifierClassName, theme.classes, config.columnClassName);
12
13
  },
14
+ container: {},
13
15
  editor: {
14
16
  detail: 'Layout directive',
15
17
  label: 'Layout cell',
@@ -23,14 +25,18 @@ export const cellDirective = {
23
25
  };
24
26
  },
25
27
  kind: 'cell',
26
- openMarker: ':::cell',
27
28
  public: true,
29
+ sanitize: {
30
+ div: [
31
+ 'dataTheme'
32
+ ]
33
+ },
28
34
  supportsAttributes: true,
29
35
  tagName: 'div',
30
36
  themeAttributes: {
31
37
  theme: 'cell'
32
38
  }
33
- };
39
+ });
34
40
  export function makeCellDirective(children) {
35
41
  const node = {
36
42
  name: '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 '[&>: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"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/cell.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { DirectiveChild } from '../types.js'\n\nimport { setDirectiveRenderData } from '../renderData.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.js'\n\nexport const cellDirective = defineDirective({\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 container: {},\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 public: true,\n sanitize: {\n div: ['dataTheme'],\n },\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","defineDirective","cellDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","columnClassName","container","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","public","sanitize","div","supportsAttributes","tagName","themeAttributes","makeCellDirective","children","type","data"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,mBAAkB;AACzD,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAE7C,OAAO,MAAMC,gBAAgBD,gBAAgB;IAC3CE,MAAM;IACNC,mBAAmB;QAAC;KAAQ;IAC5BC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQT,sBACZ,QACA,OAAOM,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,WAAW,CAAC;IACZC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBlB,IAAI;QAC3B,4EAA4E;QAC5E,6CAA6C;QAC7C,OAAO;YACLK,WAAW,OAAOL,KAAKmB,UAAU,EAAEhB,UAAU,WAAWH,KAAKmB,UAAU,CAAChB,KAAK,GAAGG;QAClF;IACF;IACAc,MAAM;IACNC,QAAQ;IACRC,UAAU;QACRC,KAAK;YAAC;SAAY;IACpB;IACAC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfvB,OAAO;IACT;AACF,GAAE;AAEF,OAAO,SAASwB,kBAAkBC,QAA0B;IAC1D,MAAM5B,OAA2B;QAC/BH,MAAM;QACNgC,MAAM;QACNV,YAAY,CAAC;QACbS;QACAE,MAAM,CAAC;IACT;IAEArC,uBAAuBO,MAAMJ;IAE7B,OAAOI;AACT"}
@@ -1,4 +1,3 @@
1
- import type { LayoutDirectiveDefinition } from '../types.js';
2
- export declare const twoColumnDirective: LayoutDirectiveDefinition;
3
- export declare const threeColumnDirective: LayoutDirectiveDefinition;
4
- export declare const columnDirectives: LayoutDirectiveDefinition[];
1
+ export declare const twoColumnDirective: import("../types.js").LayoutDirectiveDefinition<"2col", "grid">;
2
+ export declare const threeColumnDirective: import("../types.js").LayoutDirectiveDefinition<"3col", "grid">;
3
+ export declare const columnDirectives: readonly [import("../types.js").LayoutDirectiveDefinition<"2col", "grid">, import("../types.js").LayoutDirectiveDefinition<"3col", "grid">];
@@ -1,4 +1,5 @@
1
1
  import { resolveDirectiveTheme } from '../themes.js';
2
+ import { defineDirective } from '../types.js';
2
3
  import { makeCellDirective } from './cell.js';
3
4
  function isContainerDirective(node) {
4
5
  return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'containerDirective');
@@ -36,7 +37,7 @@ function groupGridChildren(children, cellHeadingDepth, context) {
36
37
  return grouped;
37
38
  }
38
39
  function createColumnDirective(name, columns) {
39
- return {
40
+ return defineDirective({
40
41
  name,
41
42
  allowedAttributes: [
42
43
  'cellTheme',
@@ -53,6 +54,13 @@ function createColumnDirective(name, columns) {
53
54
  const hasExplicitCells = node.children.some((child)=>child.type === 'element' && child.properties?.dataVlLayout === 'cell');
54
55
  if (!hasExplicitCells) node.children = groupChildrenIntoCells(node.children, config.columnClassName, resolvedCellTheme);
55
56
  },
57
+ container: {
58
+ closeLabel: 'endcol',
59
+ closeMarkers: [
60
+ ':::',
61
+ ':::endcol'
62
+ ]
63
+ },
56
64
  editor: {
57
65
  detail: 'Layout directive',
58
66
  label: `${columns}-column layout`,
@@ -66,8 +74,14 @@ function createColumnDirective(name, columns) {
66
74
  };
67
75
  },
68
76
  kind: 'grid',
69
- openMarker: `:::${name}`,
70
77
  public: true,
78
+ sanitize: {
79
+ div: [
80
+ 'dataCellTheme',
81
+ 'dataTheme',
82
+ 'dataVlCellHeadingDepth'
83
+ ]
84
+ },
71
85
  supportsAttributes: true,
72
86
  tagName: 'div',
73
87
  themeAttributes: {
@@ -78,7 +92,7 @@ function createColumnDirective(name, columns) {
78
92
  const cellHeadingDepth = resolveCellHeadingDepth(node);
79
93
  node.children = groupGridChildren(node.children, cellHeadingDepth, context);
80
94
  }
81
- };
95
+ });
82
96
  }
83
97
  export const twoColumnDirective = createColumnDirective('2col', 2);
84
98
  export const threeColumnDirective = createColumnDirective('3col', 3);
@@ -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 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,OAAw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C,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 { DirectiveChild, LayoutDirectiveTransformContext } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.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<const Name extends string>(name: Name, columns: 2 | 3) {\n return defineDirective({\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 container: {\n closeLabel: 'endcol',\n closeMarkers: [':::', ':::endcol'],\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 public: true,\n sanitize: {\n div: ['dataCellTheme', 'dataTheme', 'dataVlCellHeadingDepth'],\n },\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] as const\n"],"names":["resolveDirectiveTheme","defineDirective","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","container","closeLabel","closeMarkers","editor","detail","label","snippet","getMdastRenderProperties","attributes","dataVlCellHeadingDepth","kind","public","sanitize","div","supportsAttributes","tagName","themeAttributes","transformMdast","twoColumnDirective","threeColumnDirective","columnDirectives"],"mappings":"AAKA,SAASA,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,iBAAiB,QAAQ,YAAW;AAE7C,SAASC,qBAAqBC,IAAa;IACzC,OAAOC,QACLD,QACE,OAAOA,SAAS,YAChB,UAAUA,QACV,AAACA,KAA2BE,IAAI,KAAK;AAE3C;AAEA,SAASC,UAAUH,IAAoB;IACrC,OAAOA,KAAKE,IAAI,KAAK;AACvB;AAEA,SAASE,0BAA0BC,IAAY;IAC7C,OAAOA,SAAS,aAAaA,SAAS,UAAUA,SAAS,UAAUA,SAAS;AAC9E;AAEA,SAASC,2BACPN,IAAoB,EACpBO,OAAwC;IAExC,OACER,qBAAqBC,SACrBO,QAAQC,wBAAwB,CAACR,KAAKK,IAAI,KAC1CD,0BAA0BJ,KAAKK,IAAI;AAEvC;AAEA,SAASI,wBAAwBT,IAAwB;IACvD,OAAO,OAAOA,KAAKU,IAAI,EAAEC,uBAAuB,WAAWX,KAAKU,IAAI,CAACC,kBAAkB,GAAG;AAC5F;AAEA,SAASC,kBACPC,QAA0B,EAC1BC,gBAAwB,EACxBP,OAAwC;IAExC,MAAMQ,UAA4B,EAAE;IACpC,IAAIC,cAAgC,EAAE;IAEtC,MAAMC,YAAY;QAChB,IAAID,YAAYE,MAAM,KAAK,GAAG;QAC9BH,QAAQI,IAAI,CAACrB,kBAAkBkB;QAC/BA,cAAc,EAAE;IAClB;IAEA,KAAK,MAAMI,SAASP,SAAU;QAC5B,IAAIP,2BAA2Bc,OAAOb,UAAU;YAC9CU;YACAF,QAAQI,IAAI,CAACC;YACb;QACF;QAEA,IAAIjB,UAAUiB,UAAUA,MAAMC,KAAK,KAAKP,kBAAkBG;QAE1DD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ayoutDirectiveDefinition;
1
+ export declare const detailsDirective: import("../types.js").LayoutDirectiveDefinition<"details", "details">;