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,12 +2,13 @@ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { getDirectiveLabelOrAttribute } from '../labels.js';
3
3
  import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
4
4
  import { resolveDirectiveTheme } from '../themes.js';
5
+ import { defineDirective } from '../types.js';
5
6
  const DEFAULT_DETAILS_TITLE = 'Details';
6
7
  function getTitle(node) {
7
8
  const title = getDirectiveLabelOrAttribute(node, 'title');
8
9
  return title ?? DEFAULT_DETAILS_TITLE;
9
10
  }
10
- export const detailsDirective = {
11
+ export const detailsDirective = defineDirective({
11
12
  name: 'details',
12
13
  allowedAttributes: [
13
14
  'open',
@@ -52,6 +53,17 @@ export const detailsDirective = {
52
53
  }
53
54
  ];
54
55
  },
56
+ attributeTypes: {
57
+ open: {
58
+ type: 'boolean'
59
+ },
60
+ palette: {
61
+ type: 'palette'
62
+ }
63
+ },
64
+ container: {
65
+ labelAttribute: 'title'
66
+ },
55
67
  defaultAttributes: {
56
68
  title: DEFAULT_DETAILS_TITLE
57
69
  },
@@ -71,13 +83,22 @@ export const detailsDirective = {
71
83
  };
72
84
  },
73
85
  kind: 'details',
74
- openMarker: ':::details',
75
86
  public: true,
87
+ sanitize: {
88
+ details: [
89
+ 'dataDirective',
90
+ 'dataIconPalette',
91
+ 'dataPalette',
92
+ 'dataTheme',
93
+ 'dataTitle',
94
+ 'open'
95
+ ]
96
+ },
76
97
  supportsAttributes: true,
77
98
  tagName: 'details',
78
99
  themeAttributes: {
79
100
  theme: 'details'
80
101
  }
81
- };
102
+ });
82
103
 
83
104
  //# sourceMappingURL=details.js.map
@@ -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 { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nconst DEFAULT_DETAILS_TITLE = 'Details'\n\nfunction getTitle(node: ContainerDirective): string {\n const title = getDirectiveLabelOrAttribute(node, 'title')\n\n return title ?? DEFAULT_DETAILS_TITLE\n}\n\nexport const detailsDirective: LayoutDirectiveDefinition = {\n name: 'details',\n allowedAttributes: ['open', 'palette', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : DEFAULT_DETAILS_TITLE\n const theme = resolveDirectiveTheme(\n 'details',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n\n node.children = [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: {\n className: [\n 'not-prose ml-4 cursor-pointer list-outside text-sm font-semibold tracking-wide transition-colors hover:text-(--tw-prose-headings) marker:text-(--tw-prose-captions)',\n ],\n },\n tagName: 'summary',\n },\n {\n type: 'element',\n children,\n properties: {\n className: ['mt-3', DIRECTIVE_BODY_CLASS],\n dataDirectiveBody: 'details',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n title: DEFAULT_DETAILS_TITLE,\n },\n description: 'Native disclosure block for optional details.',\n editor: {\n detail: 'Static directive',\n label: 'Details',\n snippet: ':::details[${Details}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n ...getPaletteRenderProperties(node),\n dataDirective: 'details',\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataTitle: getTitle(node),\n open: node.attributes?.open === 'true',\n }\n },\n kind: 'details',\n openMarker: ':::details',\n public: true,\n supportsAttributes: true,\n tagName: 'details',\n themeAttributes: {\n theme: 'details',\n },\n}\n"],"names":["DIRECTIVE_BODY_CLASS","getDirectiveLabelOrAttribute","applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","DEFAULT_DETAILS_TITLE","getTitle","node","title","detailsDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataTitle","theme","dataTheme","undefined","themes","children","className","hookClassName","modifierClassName","classes","type","value","tagName","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","attributes","open","kind","openMarker","public","supportsAttributes","themeAttributes"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,MAAMC,wBAAwB;AAE9B,SAASC,SAASC,IAAwB;IACxC,MAAMC,QAAQP,6BAA6BM,MAA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AASC;YACpBgC,MAAMhC,KAAK+B,UAAU,EAAEC,SAAS;QAClC;IACF;IACAC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBf,SAAS;IACTgB,iBAAiB;QACf3B,OAAO;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/details.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.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 = defineDirective({\n name: 'details',\n allowedAttributes: ['open', 'palette', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : DEFAULT_DETAILS_TITLE\n const theme = resolveDirectiveTheme(\n 'details',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n\n node.children = [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: {\n className: [\n 'not-prose ml-4 cursor-pointer list-outside text-sm font-semibold tracking-wide transition-colors hover:text-(--tw-prose-headings) marker:text-(--tw-prose-captions)',\n ],\n },\n tagName: 'summary',\n },\n {\n type: 'element',\n children,\n properties: {\n className: ['mt-3', DIRECTIVE_BODY_CLASS],\n dataDirectiveBody: 'details',\n },\n tagName: 'div',\n },\n ]\n },\n attributeTypes: {\n open: { type: 'boolean' },\n palette: { type: 'palette' },\n },\n container: {\n labelAttribute: 'title',\n },\n defaultAttributes: {\n title: DEFAULT_DETAILS_TITLE,\n },\n description: 'Native disclosure block for optional details.',\n editor: {\n detail: 'Static directive',\n label: 'Details',\n snippet: ':::details[${Details}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n ...getPaletteRenderProperties(node),\n dataDirective: 'details',\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataTitle: getTitle(node),\n open: node.attributes?.open === 'true',\n }\n },\n kind: 'details',\n public: true,\n sanitize: {\n details: ['dataDirective', 'dataIconPalette', 'dataPalette', 'dataTheme', 'dataTitle', 'open'],\n },\n supportsAttributes: true,\n tagName: 'details',\n themeAttributes: {\n theme: 'details',\n },\n})\n"],"names":["DIRECTIVE_BODY_CLASS","getDirectiveLabelOrAttribute","applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","defineDirective","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","attributeTypes","open","palette","container","labelAttribute","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","attributes","kind","public","sanitize","details","supportsAttributes","themeAttributes"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAE7C,MAAMC,wBAAwB;AAE9B,SAASC,SAASC,IAAwB;IACxC,MAAMC,QAAQR,6BAA6BO,MAAM;IAEjD,OAAOC,SAASH;AAClB;AAEA,OAAO,MAAMI,mBAAmBL,gBAAgB;IAC9CM,MAAM;IACNC,mBAAmB;QAAC;QAAQ;Q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AAG;YAChFD,WAAWV,SAASC;YACpBwB,MAAMxB,KAAKoC,UAAU,EAAEZ,SAAS;QAClC;IACF;IACAa,MAAM;IACNC,QAAQ;IACRC,UAAU;QACRC,SAAS;YAAC;YAAiB;YAAmB;YAAe;YAAa;YAAa;SAAO;IAChG;IACAC,oBAAoB;IACpBpB,SAAS;IACTqB,iBAAiB;QACfhC,OAAO;IACT;AACF,GAAE"}
@@ -1,2 +1 @@
1
- import type { LayoutDirectiveDefinition } from '../types.js';
2
- export declare const sectionDirective: LayoutDirectiveDefinition;
1
+ export declare const sectionDirective: import("../types.js").LayoutDirectiveDefinition<"section", "section">;
@@ -1,6 +1,7 @@
1
1
  import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
2
2
  import { resolveDirectiveTheme } from '../themes.js';
3
- export const sectionDirective = {
3
+ import { defineDirective } from '../types.js';
4
+ export const sectionDirective = defineDirective({
4
5
  name: 'section',
5
6
  allowedAttributes: [
6
7
  'palette',
@@ -12,6 +13,18 @@ export const sectionDirective = {
12
13
  applyDirectivePalette(node, config);
13
14
  node.properties.className = mergeClassNames('[&>:first-child]:mt-0 [&>:last-child]:mb-0', theme.hookClassName, theme.modifierClassName, theme.classes, config.sectionClassName);
14
15
  },
16
+ attributeTypes: {
17
+ palette: {
18
+ type: 'palette'
19
+ }
20
+ },
21
+ container: {
22
+ closeMarkers: [
23
+ ':::',
24
+ ':::end',
25
+ ':::endsection'
26
+ ]
27
+ },
15
28
  editor: {
16
29
  detail: 'Layout directive',
17
30
  label: 'Layout section',
@@ -24,13 +37,19 @@ export const sectionDirective = {
24
37
  };
25
38
  },
26
39
  kind: 'section',
27
- openMarker: ':::section',
28
40
  public: true,
41
+ sanitize: {
42
+ section: [
43
+ 'dataIconPalette',
44
+ 'dataPalette',
45
+ 'dataTheme'
46
+ ]
47
+ },
29
48
  supportsAttributes: true,
30
49
  tagName: 'section',
31
50
  themeAttributes: {
32
51
  theme: 'section'
33
52
  }
34
- };
53
+ });
35
54
 
36
55
  //# sourceMappingURL=section.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/section.ts"],"sourcesContent":["import type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const sectionDirective: LayoutDirectiveDefinition = {\n name: 'section',\n allowedAttributes: ['palette', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'section',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n '[&>:first-child]:mt-0 [&>:last-child]:mb-0',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n config.sectionClassName,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout section',\n snippet: ':::section\\n${Content}\\n:::endsection\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n ...getPaletteRenderProperties(node),\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'section',\n openMarker: ':::section',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n theme: 'section',\n },\n}\n"],"names":["applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","sectionDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","sectionClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","openMarker","public","supportsAttributes","tagName","themeAttributes"],"mappings":"AAEA,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,mBAA8C;IACzDC,MAAM;IACNC,mBAAmB;QAAC;QAAW;KAAQ;IACvCC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQR,sBACZ,WACA,OAAOK,KAAKI,UAAU,CAACC,SAAS,KAAK,WAAWL,KAAKI,UAAU,CAACC,SAAS,GAAGC,WAC5EL,OAAOM,MAAM;QAGfP,KAAKI,UAAU,CAACC,SAAS,GAAGF,MAAMN,IAAI;QACtCJ,sBAAsBO,MAAMC;QAC5BD,KAAKI,UAAU,CAACI,SAAS,GAAGN,gBAC1B,8CACAC,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO,EACbV,OAAOW,gBAAgB;IAE3B;IACAC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBjB,IAAI;QAC3B,OAAO;YACL,GAAGN,2BAA2BM,KAAK;YACnCK,WAAW,OAAOL,KAAKkB,UAAU,EAAEf,UAAU,WAAWH,KAAKkB,UAAU,CAACf,KAAK,GAAG;QAClF;IACF;IACAgB,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfrB,OAAO;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/section.ts"],"sourcesContent":["import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.js'\n\nexport const sectionDirective = defineDirective({\n name: 'section',\n allowedAttributes: ['palette', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'section',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n '[&>:first-child]:mt-0 [&>:last-child]:mb-0',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n config.sectionClassName,\n )\n },\n attributeTypes: {\n palette: { type: 'palette' },\n },\n container: {\n closeMarkers: [':::', ':::end', ':::endsection'],\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout section',\n snippet: ':::section\\n${Content}\\n:::endsection\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n ...getPaletteRenderProperties(node),\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'section',\n public: true,\n sanitize: {\n section: ['dataIconPalette', 'dataPalette', 'dataTheme'],\n },\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n theme: 'section',\n },\n})\n"],"names":["applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","defineDirective","sectionDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","sectionClassName","attributeTypes","palette","type","container","closeMarkers","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","public","sanitize","section","supportsAttributes","tagName","themeAttributes"],"mappings":"AAAA,SAASA,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;AAE7C,OAAO,MAAMC,mBAAmBD,gBAAgB;IAC9CE,MAAM;IACNC,mBAAmB;QAAC;QAAW;KAAQ;IACvCC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQT,sBACZ,WACA,OAAOM,KAAKI,UAAU,CAACC,SAAS,KAAK,WAAWL,KAAKI,UAAU,CAACC,SAAS,GAAGC,WAC5EL,OAAOM,MAAM;QAGfP,KAAKI,UAAU,CAACC,SAAS,GAAGF,MAAMN,IAAI;QACtCL,sBAAsBQ,MAAMC;QAC5BD,KAAKI,UAAU,CAACI,SAAS,GAAGN,gBAC1B,8CACAC,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO,EACbV,OAAOW,gBAAgB;IAE3B;IACAC,gBAAgB;QACdC,SAAS;YAAEC,MAAM;QAAU;IAC7B;IACAC,WAAW;QACTC,cAAc;YAAC;YAAO;YAAU;SAAgB;IAClD;IACAC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBtB,IAAI;QAC3B,OAAO;YACL,GAAGP,2BAA2BO,KAAK;YACnCK,WAAW,OAAOL,KAAKuB,UAAU,EAAEpB,UAAU,WAAWH,KAAKuB,UAAU,CAACpB,KAAK,GAAG;QAClF;IACF;IACAqB,MAAM;IACNC,QAAQ;IACRC,UAAU;QACRC,SAAS;YAAC;YAAmB;YAAe;SAAY;IAC1D;IACAC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACf3B,OAAO;IACT;AACF,GAAE"}
@@ -1,2 +1 @@
1
- import type { LayoutDirectiveDefinition } from '../types.js';
2
- export declare const stepsDirective: LayoutDirectiveDefinition;
1
+ export declare const stepsDirective: import("../types.js").LayoutDirectiveDefinition<"steps", "steps">;
@@ -1,6 +1,7 @@
1
1
  import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
3
3
  import { resolveDirectiveTheme } from '../themes.js';
4
+ import { defineDirective } from '../types.js';
4
5
  import { CARD_BODY_CLASS_NAMES } from './card.js';
5
6
  const STEP_VARIANTS = [
6
7
  'default',
@@ -178,7 +179,7 @@ function groupStepChildren(children, columns, layout, numbered, variant, stepThe
178
179
  }
179
180
  ];
180
181
  }
181
- export const stepsDirective = {
182
+ export const stepsDirective = defineDirective({
182
183
  name: 'steps',
183
184
  allowedAttributes: [
184
185
  'columns',
@@ -201,6 +202,11 @@ export const stepsDirective = {
201
202
  node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes);
202
203
  node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme);
203
204
  },
205
+ attributeTypes: {
206
+ palette: {
207
+ type: 'palette'
208
+ }
209
+ },
204
210
  attributeValues: {
205
211
  columns: STEP_CARD_COLUMNS,
206
212
  layout: STEP_CARD_LAYOUTS,
@@ -210,6 +216,7 @@ export const stepsDirective = {
210
216
  ],
211
217
  variant: STEP_VARIANTS
212
218
  },
219
+ container: {},
213
220
  description: 'Structured ordered flow for tutorials and install steps.',
214
221
  editor: {
215
222
  detail: 'Docs directive',
@@ -245,8 +252,20 @@ export const stepsDirective = {
245
252
  };
246
253
  },
247
254
  kind: 'steps',
248
- openMarker: ':::steps',
249
255
  public: true,
256
+ sanitize: {
257
+ section: [
258
+ 'dataColumns',
259
+ 'dataDirective',
260
+ 'dataIconPalette',
261
+ 'dataLayout',
262
+ 'dataNumbered',
263
+ 'dataPalette',
264
+ 'dataStepTheme',
265
+ 'dataTheme',
266
+ 'dataVariant'
267
+ ]
268
+ },
250
269
  supportsAttributes: true,
251
270
  tagName: 'section',
252
271
  themeAttributes: {
@@ -261,6 +280,6 @@ export const stepsDirective = {
261
280
  if (typeof attributes.numbered === 'string' && attributes.numbered !== 'true' && attributes.numbered !== 'false') warnings.push(`Invalid steps numbered value "${attributes.numbered}". Falling back to "true".`);
262
281
  return warnings;
263
282
  }
264
- };
283
+ });
265
284
 
266
285
  //# sourceMappingURL=steps.js.map
@@ -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_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { CARD_BODY_CLASS_NAMES } from './card.js'\n\nconst STEP_VARIANTS = ['default', 'cards'] as const\nconst STEP_CARD_LAYOUTS = ['stack', 'grid'] as const\nconst STEP_CARD_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\n\ntype StepVariant = (typeof STEP_VARIANTS)[number]\ntype StepCardLayout = (typeof STEP_CARD_LAYOUTS)[number]\ntype StepCardColumns = (typeof STEP_CARD_COLUMNS)[number]\n\nfunction isStepVariant(value: unknown): value is StepVariant {\n return typeof value === 'string' && STEP_VARIANTS.includes(value as StepVariant)\n}\n\nfunction isStepCardLayout(value: unknown): value is StepCardLayout {\n return typeof value === 'string' && STEP_CARD_LAYOUTS.includes(value as StepCardLayout)\n}\n\nfunction isStepCardColumns(value: unknown): value is StepCardColumns {\n return typeof value === 'string' && STEP_CARD_COLUMNS.includes(value as StepCardColumns)\n}\n\nfunction resolveStepsVariant(node: ContainerDirective): StepVariant {\n const variant = node.attributes?.variant\n\n return isStepVariant(variant) ? variant : 'default'\n}\n\nfunction resolveCardStepLayout(node: ContainerDirective): StepCardLayout {\n const layout = node.attributes?.layout\n\n return isStepCardLayout(layout) ? layout : 'stack'\n}\n\nfunction resolveCardStepColumns(node: ContainerDirective): StepCardColumns {\n const columns = node.attributes?.columns\n\n return isStepCardColumns(columns) ? columns : '2'\n}\n\nfunction resolveCardStepNumbered(node: ContainerDirective): boolean {\n const numbered = node.attributes?.numbered\n\n if (numbered === undefined) return true\n if (typeof numbered !== 'string') return true\n\n return numbered !== 'false'\n}\n\nconst STEP_CARDS_LIST_CLASS_NAMES =\n 'm-0! list-none! gap-4 p-0! [&>li]:m-0! [&>li]:p-0! [&>li]:[font-size:inherit]'\n\nfunction isElement(node: ElementContent): node is Element {\n return node.type === 'element'\n}\n\nfunction isStepHeading(node: ElementContent): node is Element {\n return isElement(node) && ['h2', 'h3', 'h4'].includes(node.tagName)\n}\n\nfunction makeStep(children: ElementContent[], index: number): Element {\n return {\n type: 'element',\n children: [\n {\n type: 'element',\n children,\n properties: {\n className: [DIRECTIVE_BODY_CLASS],\n dataDirectiveBody: 'step',\n },\n tagName: 'div',\n },\n ],\n properties: {\n className: ['relative'],\n dataStep: String(index + 1),\n },\n tagName: 'li',\n }\n}\n\nfunction makeCardStep(\n children: ElementContent[],\n index: number,\n numbered: boolean,\n stepTheme: ReturnType<typeof resolveDirectiveTheme>,\n): Element {\n return {\n type: 'element',\n children: [\n {\n type: 'element',\n children: [\n ...(numbered\n ? [\n {\n type: 'element' as const,\n children: [{ type: 'text' as const, value: String(index + 1) }],\n properties: {\n className: [\n 'pmd-step-number not-prose mb-3 inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/25 bg-[color:color-mix(in_oklab,rgb(255_255_255/0.1)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.05))] text-sm font-semibold',\n ],\n dataStepNumber: String(index + 1),\n },\n tagName: 'span',\n },\n ]\n : []),\n ...children,\n ],\n properties: {\n className: [\n stepTheme.hookClassName,\n stepTheme.modifierClassName,\n stepTheme.classes,\n 'h-full',\n CARD_BODY_CLASS_NAMES,\n // The step title sits right under its number badge.\n '[&>.pmd-step-number+*]:mt-0',\n ],\n dataDirectiveBody: 'step',\n dataStepCard: '',\n dataTheme: stepTheme.name,\n },\n tagName: 'article',\n },\n ],\n properties: {\n className: ['list-none'],\n dataStep: String(index + 1),\n },\n tagName: 'li',\n }\n}\n\nfunction groupStepChildren(\n children: ElementContent[],\n columns: StepCardColumns,\n layout: StepCardLayout,\n numbered: boolean,\n variant: StepVariant,\n stepTheme: ReturnType<typeof resolveDirectiveTheme>,\n): ElementContent[] {\n const groups: ElementContent[][] = []\n let current: ElementContent[] = []\n const makeStepElement =\n variant === 'cards'\n ? (group: ElementContent[], index: number) => makeCardStep(group, index, numbered, stepTheme)\n : makeStep\n // Same container-width columns as `:::cards` (see cardGridColumnClasses).\n const gridColumnsClassNames: Record<StepCardColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',\n '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',\n '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',\n auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]',\n }\n\n for (const child of children) {\n if (isStepHeading(child) && current.length > 0) {\n groups.push(current)\n current = [child]\n continue\n }\n\n current.push(child)\n }\n\n if (current.length > 0) groups.push(current)\n\n return [\n {\n type: 'element',\n children: groups.map(makeStepElement),\n properties: {\n // Step lists are structure, not prose lists: the `!` resets win over\n // Typography's list styles and the renderer's list spacing.\n className:\n variant === 'cards'\n ? layout === 'grid'\n ? [STEP_CARDS_LIST_CLASS_NAMES, 'grid', gridColumnsClassNames[columns]]\n : [STEP_CARDS_LIST_CLASS_NAMES, 'flex flex-col']\n : [\n 'm-0! list-decimal pl-6! [&>li]:my-0! [&>li]:pl-4! [&>li+li]:mt-6! [&>li]:[font-size:inherit] [&>li]:marker:font-semibold',\n ],\n },\n tagName: 'ol',\n },\n ]\n}\n\nexport const stepsDirective: LayoutDirectiveDefinition = {\n name: 'steps',\n allowedAttributes: ['columns', 'layout', 'numbered', 'palette', 'stepTheme', 'theme', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant =\n typeof node.properties.dataVariant === 'string' && isStepVariant(node.properties.dataVariant)\n ? node.properties.dataVariant\n : 'default'\n const layout =\n typeof node.properties.dataLayout === 'string' && isStepCardLayout(node.properties.dataLayout)\n ? node.properties.dataLayout\n : 'stack'\n const columns =\n typeof node.properties.dataColumns === 'string' && isStepCardColumns(node.properties.dataColumns)\n ? node.properties.dataColumns\n : '2'\n const numbered = node.properties.dataNumbered !== 'false'\n const theme = resolveDirectiveTheme(\n 'steps',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const stepTheme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataStepTheme === 'string'\n ? node.properties.dataStepTheme\n : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme)\n },\n attributeValues: {\n columns: STEP_CARD_COLUMNS,\n layout: STEP_CARD_LAYOUTS,\n numbered: ['true', 'false'],\n variant: STEP_VARIANTS,\n },\n description: 'Structured ordered flow for tutorials and install steps.',\n editor: {\n detail: 'Docs directive',\n label: 'Steps',\n snippet: ':::steps\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n snippets: [\n {\n detail: 'Docs directive',\n label: 'Steps cards stack',\n snippet:\n ':::steps {variant=\"cards\" layout=\"stack\" numbered}\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n {\n detail: 'Docs directive',\n label: 'Steps cards grid',\n snippet:\n ':::steps {variant=\"cards\" layout=\"grid\" columns=\"${2}\" numbered}\\n\\n### ${First step}\\n\\n${Content}\\n\\n### ${Second step}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n ],\n },\n getMdastRenderProperties(node) {\n const variant = resolveStepsVariant(node)\n const layout = resolveCardStepLayout(node)\n const numbered = resolveCardStepNumbered(node)\n const columns = resolveCardStepColumns(node)\n\n return {\n ...getPaletteRenderProperties(node),\n dataColumns: variant === 'cards' && layout === 'grid' ? columns : undefined,\n dataDirective: 'steps',\n dataLayout: variant === 'cards' ? layout : undefined,\n dataNumbered: variant === 'cards' ? String(numbered) : undefined,\n dataStepTheme:\n typeof node.attributes?.stepTheme === 'string' ? node.attributes.stepTheme : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataVariant: variant === 'default' ? undefined : variant,\n }\n },\n kind: 'steps',\n openMarker: ':::steps',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n stepTheme: 'card',\n theme: 'steps',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isStepVariant(attributes.variant))\n warnings.push(\n `Unsupported steps variant \"${attributes.variant}\". Falling back to \"default\".`,\n )\n if (typeof attributes.layout === 'string' && !isStepCardLayout(attributes.layout))\n warnings.push(`Unsupported steps layout \"${attributes.layout}\". Falling back to \"stack\".`)\n if (typeof attributes.columns === 'string' && !isStepCardColumns(attributes.columns))\n warnings.push(`Invalid steps columns \"${attributes.columns}\". Falling back to \"2\".`)\n if (\n typeof attributes.numbered === 'string' &&\n attributes.numbered !== 'true' &&\n attributes.numbered !== 'false'\n )\n warnings.push(\n `Invalid steps numbered value \"${attributes.numbered}\". Falling back to \"true\".`,\n )\n\n return warnings\n },\n}\n"],"names":["DIRECTIVE_BODY_CLASS","applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","CARD_BODY_CLASS_NAMES","STEP_VARIANTS","STEP_CARD_LAYOUTS","STEP_CARD_COLUMNS","isStepVariant","value","includes","isStepCardLayout","isStepCardColumns","resolveStepsVariant","node","variant","attributes","resolveCardStepLayout","layout","resolveCardStepColumns","columns","resolveCardStepNumbered","numbered","undefined","STEP_CARDS_LIST_CLASS_NAMES","isElement","type","isStepHeading","tagName","makeStep","children","index","properties","className","dataDirectiveBody","dataStep","String","makeCardStep","stepTheme","dataStepNumber","hookClassName","modifierClassName","classes","dataStepCard","dataTheme","name","groupStepChildren","groups","current","makeStepElement","group","gridColumnsClassNames","auto","child","length","push","map","stepsDirective","allowedAttributes","applyHast","config","mergeClassNames","dataVariant","dataLayout","dataColumns","dataNumbered","theme","themes","dataStepTheme","attributeValues","description","editor","detail","label","snippet","snippets","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,gBAAe;AACjF,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,qBAAqB,QAAQ,YAAW;AAEjD,MAAMC,gBAAgB;IAAC;IAAW;CAAQ;AAC1C,MAAMC,oBAAoB;IAAC;IAAS;CAAO;AAC3C,MAAMC,oBAAoB;IAAC;IAAK;IAAK;IAAK;IAAK;CAAO;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,YAAYQ,YAAYR;QACnD;IACF;IACA+D,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBrD,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
+ {"version":3,"sources":["../../../src/directives/definitions/steps.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.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 = defineDirective({\n name: 'steps',\n allowedAttributes: ['columns', 'layout', 'numbered', 'palette', 'stepTheme', 'theme', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant =\n typeof node.properties.dataVariant === 'string' && isStepVariant(node.properties.dataVariant)\n ? node.properties.dataVariant\n : 'default'\n const layout =\n typeof node.properties.dataLayout === 'string' && isStepCardLayout(node.properties.dataLayout)\n ? node.properties.dataLayout\n : 'stack'\n const columns =\n typeof node.properties.dataColumns === 'string' && isStepCardColumns(node.properties.dataColumns)\n ? node.properties.dataColumns\n : '2'\n const numbered = node.properties.dataNumbered !== 'false'\n const theme = resolveDirectiveTheme(\n 'steps',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const stepTheme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataStepTheme === 'string'\n ? node.properties.dataStepTheme\n : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n applyDirectivePalette(node, config)\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = groupStepChildren(node.children, columns, layout, numbered, variant, stepTheme)\n },\n attributeTypes: {\n palette: { type: 'palette' },\n },\n attributeValues: {\n columns: STEP_CARD_COLUMNS,\n layout: STEP_CARD_LAYOUTS,\n numbered: ['true', 'false'],\n variant: STEP_VARIANTS,\n },\n container: {},\n description: 'Structured ordered flow for tutorials and install steps.',\n editor: {\n detail: 'Docs directive',\n label: 'Steps',\n snippet: ':::steps\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n snippets: [\n {\n detail: 'Docs directive',\n label: 'Steps cards stack',\n snippet:\n ':::steps {variant=\"cards\" layout=\"stack\" numbered}\\n\\n### ${Step title}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n {\n detail: 'Docs directive',\n label: 'Steps cards grid',\n snippet:\n ':::steps {variant=\"cards\" layout=\"grid\" columns=\"${2}\" numbered}\\n\\n### ${First step}\\n\\n${Content}\\n\\n### ${Second step}\\n\\n${Content}\\n\\n:::\\n${}',\n },\n ],\n },\n getMdastRenderProperties(node) {\n const variant = resolveStepsVariant(node)\n const layout = resolveCardStepLayout(node)\n const numbered = resolveCardStepNumbered(node)\n const columns = resolveCardStepColumns(node)\n\n return {\n ...getPaletteRenderProperties(node),\n dataColumns: variant === 'cards' && layout === 'grid' ? columns : undefined,\n dataDirective: 'steps',\n dataLayout: variant === 'cards' ? layout : undefined,\n dataNumbered: variant === 'cards' ? String(numbered) : undefined,\n dataStepTheme:\n typeof node.attributes?.stepTheme === 'string' ? node.attributes.stepTheme : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n dataVariant: variant === 'default' ? undefined : variant,\n }\n },\n kind: 'steps',\n public: true,\n sanitize: {\n section: [\n 'dataColumns',\n 'dataDirective',\n 'dataIconPalette',\n 'dataLayout',\n 'dataNumbered',\n 'dataPalette',\n 'dataStepTheme',\n 'dataTheme',\n 'dataVariant',\n ],\n },\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n stepTheme: 'card',\n theme: 'steps',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isStepVariant(attributes.variant))\n warnings.push(\n `Unsupported steps variant \"${attributes.variant}\". Falling back to \"default\".`,\n )\n if (typeof attributes.layout === 'string' && !isStepCardLayout(attributes.layout))\n warnings.push(`Unsupported steps layout \"${attributes.layout}\". Falling back to \"stack\".`)\n if (typeof attributes.columns === 'string' && !isStepCardColumns(attributes.columns))\n warnings.push(`Invalid steps columns \"${attributes.columns}\". Falling back to \"2\".`)\n if (\n typeof attributes.numbered === 'string' &&\n attributes.numbered !== 'true' &&\n attributes.numbered !== 'false'\n )\n warnings.push(\n `Invalid steps numbered value \"${attributes.numbered}\". Falling back to \"true\".`,\n )\n\n return warnings\n },\n})\n"],"names":["DIRECTIVE_BODY_CLASS","applyDirectivePalette","getPaletteRenderProperties","resolveDirectiveTheme","defineDirective","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","attributeTypes","palette","attributeValues","container","description","editor","detail","label","snippet","snippets","getMdastRenderProperties","dataDirective","kind","public","sanitize","section","support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,KAAK,YAC/BN,WAAWM,QAAQ,KAAK,UACxBN,WAAWM,QAAQ,KAAK,SAExBkE,SAASjC,IAAI,CACX,CAAC,8BAA8B,EAAEvC,WAAWM,QAAQ,CAAC,0BAA0B,CAAC;QAGpF,OAAOkE;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 function getTabLabel(node: ContainerDirective, index: number): string;
4
3
  type TabAttributes = null | Record<string, boolean | null | string | undefined> | undefined;
5
4
  /**
@@ -26,6 +25,13 @@ export type TabsDefaultCandidate = {
26
25
  * value/label text, so non-ASCII defaults such as `default="中文"` work.
27
26
  */
28
27
  export declare function resolveTabsDefault(requested: string | undefined, tabs: TabsDefaultCandidate[]): string | undefined;
28
+ /** Editor-linter state of an open `tabs` frame: set by the `tabs` lint hook, filled by `tab`'s. */
29
+ export type TabsLintState = {
30
+ defaultValue?: string;
31
+ tabCandidates?: TabsDefaultCandidate[];
32
+ tabCount?: number;
33
+ tabValues?: Map<string, number>;
34
+ };
29
35
  export declare function isTabDisabled(attributes: TabAttributes): boolean;
30
- export declare const tabDirective: LayoutDirectiveDefinition;
36
+ export declare const tabDirective: import("../types.js").LayoutDirectiveDefinition<"tab", "tab">;
31
37
  export {};
@@ -1,6 +1,8 @@
1
1
  import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { getDirectiveLabel, getDirectiveLabelOrAttribute } from '../labels.js';
3
+ import { findNearestLintFrame } from '../lint.js';
3
4
  import { resolveDirectiveTheme } from '../themes.js';
5
+ import { defineDirective } from '../types.js';
4
6
  function getAttribute(node, name) {
5
7
  const value = node.attributes?.[name];
6
8
  return typeof value === 'string' && value.trim() ? value.trim() : undefined;
@@ -49,7 +51,7 @@ export function isTabDisabled(attributes) {
49
51
  if (typeof disabled !== 'string') return false;
50
52
  return disabled !== 'false';
51
53
  }
52
- export const tabDirective = {
54
+ export const tabDirective = defineDirective({
53
55
  name: 'tab',
54
56
  allowedAttributes: [
55
57
  'disabled',
@@ -62,6 +64,14 @@ export const tabDirective = {
62
64
  node.properties.dataTheme = theme.name;
63
65
  node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, 'vl-md-tab-panel', DIRECTIVE_BODY_CLASS);
64
66
  },
67
+ attributeTypes: {
68
+ disabled: {
69
+ type: 'boolean'
70
+ }
71
+ },
72
+ container: {
73
+ labelAttribute: 'label'
74
+ },
65
75
  description: 'Single tab panel. Usually nested inside :::tabs.',
66
76
  editor: {
67
77
  detail: 'Tabs directive',
@@ -78,13 +88,45 @@ export const tabDirective = {
78
88
  };
79
89
  },
80
90
  kind: 'tab',
81
- openMarker: ':::tab',
91
+ lint: {
92
+ // Registers the tab with its tabs block, which reports duplicates and the default on close.
93
+ open ({ attributes, label, stack }) {
94
+ const tabsFrame = findNearestLintFrame(stack, 'tabs');
95
+ if (!tabsFrame) return [
96
+ 'Directive "tab" is usually intended inside "tabs".'
97
+ ];
98
+ const tabs = tabsFrame.state ??= {};
99
+ const nextIndex = tabs.tabCount ?? 0;
100
+ const value = slugTabValue(getTabRawValue(attributes, label) ?? `tab-${nextIndex + 1}`, nextIndex);
101
+ tabs.tabCandidates ??= [];
102
+ tabs.tabCandidates.push({
103
+ label: getTabRawValue({
104
+ label: attributes?.label ?? ''
105
+ }, label) ?? `Tab ${nextIndex + 1}`,
106
+ raw: getTabRawValue(attributes),
107
+ value
108
+ });
109
+ tabs.tabCount = nextIndex + 1;
110
+ tabs.tabValues ??= new Map();
111
+ tabs.tabValues.set(value, (tabs.tabValues.get(value) ?? 0) + 1);
112
+ return [];
113
+ }
114
+ },
82
115
  public: true,
116
+ sanitize: {
117
+ section: [
118
+ 'dataDirective',
119
+ 'dataDisabled',
120
+ 'dataLabel',
121
+ 'dataTheme',
122
+ 'dataValue'
123
+ ]
124
+ },
83
125
  supportsAttributes: true,
84
126
  tagName: 'section',
85
127
  themeAttributes: {
86
128
  theme: 'tab'
87
129
  }
88
- };
130
+ });
89
131
 
90
132
  //# sourceMappingURL=tab.js.map
@@ -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 { 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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AACtB;AAEA,OAAO,MAAMC,eAA0C;IACrD1B,MAAM;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,gBAC1BC,MAAMK,aAAa,EACnBL,MAAMM,iBAAiB,EACvBN,MAAMO,OAAO,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
+ {"version":3,"sources":["../../../src/directives/definitions/tab.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { getDirectiveLabel, getDirectiveLabelOrAttribute } from '../labels.js'\nimport { findNearestLintFrame } from '../lint.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { defineDirective } from '../types.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\n/** Editor-linter state of an open `tabs` frame: set by the `tabs` lint hook, filled by `tab`'s. */\nexport type TabsLintState = {\n defaultValue?: string\n tabCandidates?: TabsDefaultCandidate[]\n tabCount?: number\n tabValues?: Map<string, number>\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 = defineDirective({\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 attributeTypes: {\n disabled: { type: 'boolean' },\n },\n container: {\n labelAttribute: 'label',\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 lint: {\n // Registers the tab with its tabs block, which reports duplicates and the default on close.\n open({ attributes, label, stack }) {\n const tabsFrame = findNearestLintFrame(stack, 'tabs')\n if (!tabsFrame) return ['Directive \"tab\" is usually intended inside \"tabs\".']\n\n const tabs = (tabsFrame.state ??= {}) as TabsLintState\n const nextIndex = tabs.tabCount ?? 0\n const value = slugTabValue(getTabRawValue(attributes, label) ?? `tab-${nextIndex + 1}`, nextIndex)\n\n tabs.tabCandidates ??= []\n tabs.tabCandidates.push({\n label: getTabRawValue({ label: attributes?.label ?? '' }, label) ?? `Tab ${nextIndex + 1}`,\n raw: getTabRawValue(attributes),\n value,\n })\n tabs.tabCount = nextIndex + 1\n tabs.tabValues ??= new Map<string, number>()\n tabs.tabValues.set(value, (tabs.tabValues.get(value) ?? 0) + 1)\n\n return []\n },\n },\n public: true,\n sanitize: {\n section: ['dataDirective', 'dataDisabled', 'dataLabel', 'dataTheme', 'dataValue'],\n },\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n theme: 'tab',\n },\n})\n"],"names":["DIRECTIVE_BODY_CLASS","getDirectiveLabel","getDirectiveLabelOrAttribute","findNearestLintFrame","resolveDirectiveTheme","defineDirective","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","attributeTypes","type","container","labelAttribute","description","editor","detail","snippet","getMdastRenderProperties","dataDirective","dataDisabled","dataLabel","data","vlTabIndex","dataValue","kind","lint","open","stack","tabsFrame","state","nextIndex","tabCount","tabCandidates","push","tabValues","Map","set","get","public","sanitize","section","supportsAttributes","tagName","themeAttributes"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,EAAEC,4BAA4B,QAAQ,eAAc;AAC9E,SAASC,oBAAoB,QAAQ,aAAY;AACjD,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,cAAa;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: LayoutDirectiveDefinition;
2
+ export declare const tabsDirective: LayoutDirectiveDefinition<"tabs", "tabs">;
@@ -1,6 +1,7 @@
1
1
  import { DIRECTIVE_BODY_CLASS, DIRECTIVE_SURFACE_DIVIDER_CLASS } from '../../styles/directiveSurface.js';
2
2
  import { applyDirectivePalette, getPaletteRenderProperties } from '../palette.js';
3
3
  import { resolveDirectiveTheme } from '../themes.js';
4
+ import { defineDirective } from '../types.js';
4
5
  import { getTabLabel as getTabDirectiveLabel, getTabRawValue, getTabValue, resolveTabsDefault, slugTabValue, toTabSlug } from './tab.js';
5
6
  function isContainerDirective(node) {
6
7
  return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'containerDirective');
@@ -133,7 +134,7 @@ function getTabsDefaultCandidates(node) {
133
134
  function getDirectTabDirectives(node) {
134
135
  return node.children.filter((child)=>isContainerDirective(child) && child.name === 'tab');
135
136
  }
136
- export const tabsDirective = {
137
+ export const tabsDirective = defineDirective({
137
138
  name: 'tabs',
138
139
  allowedAttributes: [
139
140
  'default',
@@ -175,6 +176,12 @@ export const tabsDirective = {
175
176
  ...tabs.map((tab)=>makeTabPanel(tab, tab.value === activeTab.value, config, mergeClassNames, tabTheme))
176
177
  ];
177
178
  },
179
+ attributeTypes: {
180
+ palette: {
181
+ type: 'palette'
182
+ }
183
+ },
184
+ container: {},
178
185
  description: 'Accessible tabbed content block with server-rendered panels.',
179
186
  editor: {
180
187
  detail: 'Tabs directive',
@@ -192,8 +199,38 @@ export const tabsDirective = {
192
199
  };
193
200
  },
194
201
  kind: 'tabs',
195
- openMarker: ':::tabs',
202
+ lint: {
203
+ // Mirrors validateMdast below; the tab hooks fill the state.
204
+ close (frame) {
205
+ const tabs = frame.state ?? {};
206
+ const diagnostics = [];
207
+ const tabValues = tabs.tabValues ?? new Map();
208
+ if (!tabs.tabCount) diagnostics.push('Directive "tabs" has no child "tab" directives.');
209
+ for (const [value, count] of tabValues)if (count > 1) diagnostics.push(`Duplicate tab value "${value}" in "tabs".`);
210
+ if (tabs.defaultValue && !resolveTabsDefault(tabs.defaultValue, tabs.tabCandidates ?? [])) diagnostics.push(`Invalid tabs default "${tabs.defaultValue}". Falling back to the first tab.`);
211
+ return diagnostics;
212
+ },
213
+ open ({ attributes, frame }) {
214
+ const state = {
215
+ defaultValue: typeof attributes.default === 'string' ? attributes.default : undefined,
216
+ tabCount: 0,
217
+ tabValues: new Map()
218
+ };
219
+ frame.state = state;
220
+ return [];
221
+ }
222
+ },
196
223
  public: true,
224
+ sanitize: {
225
+ section: [
226
+ 'dataDefault',
227
+ 'dataDirective',
228
+ 'dataIconPalette',
229
+ 'dataPalette',
230
+ 'dataTabTheme',
231
+ 'dataTheme'
232
+ ]
233
+ },
197
234
  supportsAttributes: true,
198
235
  tagName: 'section',
199
236
  themeAttributes: {
@@ -219,6 +256,6 @@ export const tabsDirective = {
219
256
  if (typeof node.attributes?.default === 'string' && !resolveTabsDefault(node.attributes.default, getTabsDefaultCandidates(node))) warnings.push(`Invalid tabs default "${node.attributes.default}". Falling back to the first tab.`);
220
257
  return warnings;
221
258
  }
222
- };
259
+ });
223
260
 
224
261
  //# sourceMappingURL=tabs.js.map