payload-markdown 1.8.0 → 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.
- package/README.md +16 -0
- package/dist/agent/access.d.ts +1 -1
- package/dist/agent/access.js.map +1 -1
- package/dist/agent/guide.d.ts +3 -0
- package/dist/agent/guide.js +28 -2
- package/dist/agent/guide.js.map +1 -1
- package/dist/agent/palettes.d.ts +55 -0
- package/dist/agent/palettes.js +194 -0
- package/dist/agent/palettes.js.map +1 -0
- package/dist/agent/skill.d.ts +2 -2
- package/dist/agent/skill.js +2 -2
- package/dist/agent/skill.js.map +1 -1
- package/dist/agent/validate.d.ts +1 -1
- package/dist/agent/validate.js +3 -0
- package/dist/agent/validate.js.map +1 -1
- package/dist/appearance/PaletteRowLabel.client.d.ts +2 -0
- package/dist/appearance/PaletteRowLabel.client.js +70 -0
- package/dist/appearance/PaletteRowLabel.client.js.map +1 -0
- package/dist/appearance/config.d.ts +8 -0
- package/dist/appearance/config.js +172 -0
- package/dist/appearance/config.js.map +1 -0
- package/dist/appearance/options.d.ts +11 -0
- package/dist/appearance/options.js +15 -0
- package/dist/appearance/options.js.map +1 -0
- package/dist/appearance/runtime.d.ts +25 -0
- package/dist/appearance/runtime.js +126 -0
- package/dist/appearance/runtime.js.map +1 -0
- package/dist/components/MarkdownRenderer/Component.js +4 -0
- package/dist/components/MarkdownRenderer/Component.js.map +1 -1
- package/dist/core/plugins/rehypeResolveIcons.js +10 -1
- package/dist/core/plugins/rehypeResolveIcons.js.map +1 -1
- package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
- package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
- package/dist/core/plugins/remarkDirectiveLines.js +29 -18
- package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
- package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
- package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
- package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
- package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
- package/dist/core/plugins/remarkValidatePalettes.d.ts +9 -0
- package/dist/core/plugins/remarkValidatePalettes.js +51 -0
- package/dist/core/plugins/remarkValidatePalettes.js.map +1 -0
- package/dist/core/renderMarkdown.js +4 -221
- package/dist/core/renderMarkdown.js.map +1 -1
- package/dist/core/sanitizeSchema.d.ts +11 -0
- package/dist/core/sanitizeSchema.js +176 -0
- package/dist/core/sanitizeSchema.js.map +1 -0
- package/dist/directive-spec.json +60 -0
- package/dist/directives/definitions/badge.d.ts +5 -2
- package/dist/directives/definitions/badge.js +138 -10
- package/dist/directives/definitions/badge.js.map +1 -1
- package/dist/directives/definitions/badges.d.ts +1 -2
- package/dist/directives/definitions/badges.js +12 -3
- package/dist/directives/definitions/badges.js.map +1 -1
- package/dist/directives/definitions/button.d.ts +7 -3
- package/dist/directives/definitions/button.js +211 -14
- package/dist/directives/definitions/button.js.map +1 -1
- package/dist/directives/definitions/buttons.d.ts +1 -2
- package/dist/directives/definitions/buttons.js +12 -3
- package/dist/directives/definitions/buttons.js.map +1 -1
- package/dist/directives/definitions/callout.d.ts +1 -2
- package/dist/directives/definitions/callout.js +46 -5
- package/dist/directives/definitions/callout.js.map +1 -1
- package/dist/directives/definitions/card.d.ts +6 -4
- package/dist/directives/definitions/card.js +64 -11
- package/dist/directives/definitions/card.js.map +1 -1
- package/dist/directives/definitions/cards.d.ts +1 -2
- package/dist/directives/definitions/cards.js +49 -4
- package/dist/directives/definitions/cards.js.map +1 -1
- package/dist/directives/definitions/cell.d.ts +2 -2
- package/dist/directives/definitions/cell.js +9 -3
- package/dist/directives/definitions/cell.js.map +1 -1
- package/dist/directives/definitions/columns.d.ts +3 -4
- package/dist/directives/definitions/columns.js +17 -3
- package/dist/directives/definitions/columns.js.map +1 -1
- package/dist/directives/definitions/details.d.ts +1 -2
- package/dist/directives/definitions/details.js +28 -3
- package/dist/directives/definitions/details.js.map +1 -1
- package/dist/directives/definitions/section.d.ts +1 -2
- package/dist/directives/definitions/section.js +26 -3
- package/dist/directives/definitions/section.js.map +1 -1
- package/dist/directives/definitions/steps.d.ts +1 -2
- package/dist/directives/definitions/steps.js +26 -3
- package/dist/directives/definitions/steps.js.map +1 -1
- package/dist/directives/definitions/tab.d.ts +8 -2
- package/dist/directives/definitions/tab.js +45 -3
- package/dist/directives/definitions/tab.js.map +1 -1
- package/dist/directives/definitions/tabs.d.ts +1 -1
- package/dist/directives/definitions/tabs.js +44 -3
- package/dist/directives/definitions/tabs.js.map +1 -1
- package/dist/directives/definitions/toc.d.ts +1 -2
- package/dist/directives/definitions/toc.js +33 -5
- package/dist/directives/definitions/toc.js.map +1 -1
- package/dist/directives/diagnostics.d.ts +2 -10
- package/dist/directives/diagnostics.js +27 -141
- package/dist/directives/diagnostics.js.map +1 -1
- package/dist/directives/iconPlaceholder.d.ts +9 -3
- package/dist/directives/iconPlaceholder.js +8 -1
- package/dist/directives/iconPlaceholder.js.map +1 -1
- package/dist/directives/lint.d.ts +11 -0
- package/dist/directives/lint.js +33 -0
- package/dist/directives/lint.js.map +1 -0
- package/dist/directives/palette.d.ts +23 -0
- package/dist/directives/palette.js +40 -0
- package/dist/directives/palette.js.map +1 -0
- package/dist/directives/registry.d.ts +23 -5
- package/dist/directives/registry.js +52 -40
- package/dist/directives/registry.js.map +1 -1
- package/dist/directives/spec.d.ts +6 -2
- package/dist/directives/spec.js +29 -50
- package/dist/directives/spec.js.map +1 -1
- package/dist/directives/themeDiagnostics.d.ts +8 -0
- package/dist/directives/themeDiagnostics.js +21 -0
- package/dist/directives/themeDiagnostics.js.map +1 -0
- package/dist/directives/types.d.ts +157 -14
- package/dist/directives/types.js +6 -1
- package/dist/directives/types.js.map +1 -1
- package/dist/editor/directiveConfig.d.ts +15 -1
- package/dist/editor/directiveConfig.js +21 -1
- package/dist/editor/directiveConfig.js.map +1 -1
- package/dist/editor/directives/completions.d.ts +4 -2
- package/dist/editor/directives/completions.js +33 -7
- package/dist/editor/directives/completions.js.map +1 -1
- package/dist/editor/directives/diagnostics.d.ts +2 -2
- package/dist/editor/directives/diagnostics.js +10 -3
- package/dist/editor/directives/diagnostics.js.map +1 -1
- package/dist/editor/themes/payload.js +2 -1
- package/dist/editor/themes/payload.js.map +1 -1
- package/dist/exports/client.d.ts +4 -1
- package/dist/exports/client.js +5 -2
- package/dist/exports/client.js.map +1 -1
- package/dist/field/MarkdownField/Component.js +54 -3
- package/dist/field/MarkdownField/Component.js.map +1 -1
- package/dist/icons/entries.d.ts +22 -0
- package/dist/icons/entries.js +50 -0
- package/dist/icons/entries.js.map +1 -0
- package/dist/icons/resolve.d.ts +2 -1
- package/dist/icons/resolve.js +2 -2
- package/dist/icons/resolve.js.map +1 -1
- package/dist/icons/sanitizeSvg.d.ts +12 -2
- package/dist/icons/sanitizeSvg.js +104 -3
- package/dist/icons/sanitizeSvg.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +65 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/palettes/colors.d.ts +21 -0
- package/dist/palettes/colors.js +43 -0
- package/dist/palettes/colors.js.map +1 -0
- package/dist/palettes/contrast.d.ts +7 -0
- package/dist/palettes/contrast.js +63 -0
- package/dist/palettes/contrast.js.map +1 -0
- package/dist/palettes/defaults.d.ts +8 -0
- package/dist/palettes/defaults.js +275 -0
- package/dist/palettes/defaults.js.map +1 -0
- package/dist/palettes/diagnostics.d.ts +10 -0
- package/dist/palettes/diagnostics.js +38 -0
- package/dist/palettes/diagnostics.js.map +1 -0
- package/dist/palettes/index.d.ts +61 -0
- package/dist/palettes/index.js +246 -0
- package/dist/palettes/index.js.map +1 -0
- package/dist/render/renderMarkdown.d.ts +3 -1
- package/dist/render/renderMarkdown.js +9 -1
- package/dist/render/renderMarkdown.js.map +1 -1
- package/dist/runtime/index.d.ts +12 -1
- package/dist/runtime/index.js +21 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/types/core.d.ts +43 -0
- package/dist/types/core.js.map +1 -1
- package/dist/types.d.ts +46 -2
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/skills/payload-markdown/claude/SKILL.md +1 -0
- package/skills/payload-markdown/claude/reference/directive-spec.json +60 -0
- package/skills/payload-markdown/claude/reference/mcp-content-workflow.md +7 -0
- package/skills/payload-markdown/claude/reference/payload-markdown-directives.md +22 -2
- package/skills/payload-markdown/claude/skill.json +2 -2
- package/skills/payload-markdown/codex/SKILL.md +1 -0
- package/skills/payload-markdown/codex/reference/directive-spec.json +60 -0
- package/skills/payload-markdown/codex/reference/mcp-content-workflow.md +7 -0
- package/skills/payload-markdown/codex/reference/payload-markdown-directives.md +22 -2
- package/skills/payload-markdown/codex/skill.json +2 -2
- package/dist/core/plugins/directiveBadge.d.ts +0 -6
- package/dist/core/plugins/directiveBadge.js +0 -94
- package/dist/core/plugins/directiveBadge.js.map +0 -1
- package/dist/core/plugins/directiveButton.d.ts +0 -6
- package/dist/core/plugins/directiveButton.js +0 -115
- package/dist/core/plugins/directiveButton.js.map +0 -1
- package/dist/directives/buttonSyntax.d.ts +0 -7
- package/dist/directives/buttonSyntax.js +0 -6
- package/dist/directives/buttonSyntax.js.map +0 -1
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js';
|
|
2
|
+
import { normalizePayloadMarkdownIconRef } from '../../icons/refs.js';
|
|
3
|
+
import { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js';
|
|
1
4
|
import { getUnknownAttributeWarnings } from '../attributeDiagnostics.js';
|
|
2
|
-
import {
|
|
5
|
+
import { parseLeafDirectiveLine } from '../leafSyntax.js';
|
|
6
|
+
import { getIconLintDiagnostics, getPaletteLintDiagnostics } from '../lint.js';
|
|
7
|
+
import { applyDirectivePalette } from '../palette.js';
|
|
8
|
+
import { defineDirective } from '../types.js';
|
|
9
|
+
import { getSafeHref, getUnsafeHrefWarnings } from '../urls.js';
|
|
3
10
|
export const BUTTON_VARIANTS = [
|
|
4
11
|
'primary',
|
|
5
12
|
'secondary',
|
|
@@ -20,8 +27,10 @@ export const BUTTON_ALLOWED_ATTRIBUTES = [
|
|
|
20
27
|
'ariaLabel',
|
|
21
28
|
'href',
|
|
22
29
|
'icon',
|
|
30
|
+
'iconPalette',
|
|
23
31
|
'iconPosition',
|
|
24
32
|
'newTab',
|
|
33
|
+
'palette',
|
|
25
34
|
'size',
|
|
26
35
|
'variant'
|
|
27
36
|
];
|
|
@@ -37,15 +46,181 @@ export function isButtonSize(value) {
|
|
|
37
46
|
export function isButtonIconPosition(value) {
|
|
38
47
|
return typeof value === 'string' && BUTTON_ICON_POSITIONS.includes(value);
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
function validateButtonAttributes(attributes) {
|
|
50
|
+
const warnings = getUnknownAttributeWarnings('button', BUTTON_ALLOWED_ATTRIBUTES, attributes);
|
|
51
|
+
if (typeof attributes.variant === 'string' && !isButtonVariant(attributes.variant)) warnings.push(`Invalid button variant "${attributes.variant}". Falling back to "${DEFAULT_BUTTON_VARIANT}".`);
|
|
52
|
+
if (typeof attributes.size === 'string' && !isButtonSize(attributes.size)) warnings.push(`Invalid button size "${attributes.size}". Falling back to "${DEFAULT_BUTTON_SIZE}".`);
|
|
53
|
+
if (typeof attributes.iconPosition === 'string' && !isButtonIconPosition(attributes.iconPosition)) warnings.push(`Invalid button iconPosition "${attributes.iconPosition}". Falling back to "${DEFAULT_BUTTON_ICON_POSITION}".`);
|
|
54
|
+
if (typeof attributes.href !== 'string' || !attributes.href.trim()) warnings.push('Directive "button" requires an href attribute.');
|
|
55
|
+
else warnings.push(...getUnsafeHrefWarnings('button', attributes));
|
|
56
|
+
return warnings;
|
|
57
|
+
}
|
|
58
|
+
function getAttribute(attributes, name) {
|
|
59
|
+
const value = attributes[name];
|
|
60
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
61
|
+
}
|
|
62
|
+
function getBooleanAttribute(attributes, name) {
|
|
63
|
+
const value = attributes[name];
|
|
64
|
+
if (value === true) return true;
|
|
65
|
+
if (typeof value !== 'string') return false;
|
|
66
|
+
return value === 'true';
|
|
67
|
+
}
|
|
68
|
+
function makeIconPlaceholder(icon, iconPosition, palette) {
|
|
69
|
+
const normalized = normalizePayloadMarkdownIconRef(icon);
|
|
70
|
+
const iconKey = normalized.icon?.key ?? icon;
|
|
71
|
+
return {
|
|
72
|
+
type: 'element',
|
|
73
|
+
children: [],
|
|
74
|
+
properties: {
|
|
75
|
+
ariaHidden: 'true',
|
|
76
|
+
className: [
|
|
77
|
+
'pmd-button__icon',
|
|
78
|
+
`pmd-button__icon--${iconPosition}`
|
|
79
|
+
],
|
|
80
|
+
dataPmdIcon: iconKey,
|
|
81
|
+
...palette ? {
|
|
82
|
+
dataPmdIconPalette: palette
|
|
83
|
+
} : {},
|
|
84
|
+
dataPmdIconRef: icon,
|
|
85
|
+
focusable: 'false'
|
|
86
|
+
},
|
|
87
|
+
tagName: 'span'
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Builds the `::button` leaf (the renderer side of `leaf.build`). */ export function makeButtonDirective(line, file, config) {
|
|
91
|
+
const parsed = parseLeafDirectiveLine(line, 'button');
|
|
92
|
+
if (!parsed) return undefined;
|
|
93
|
+
const attributes = parsed.attributes;
|
|
94
|
+
const label = parsed.label.trim();
|
|
95
|
+
const href = getSafeHref(getAttribute(attributes, 'href'));
|
|
96
|
+
const variant = isButtonVariant(attributes.variant) ? attributes.variant : DEFAULT_BUTTON_VARIANT;
|
|
97
|
+
const size = isButtonSize(attributes.size) ? attributes.size : DEFAULT_BUTTON_SIZE;
|
|
98
|
+
const iconPosition = isButtonIconPosition(attributes.iconPosition) ? attributes.iconPosition : DEFAULT_BUTTON_ICON_POSITION;
|
|
99
|
+
// A button shows one icon; it may carry its own palette (`@pack/name palette=x`).
|
|
100
|
+
const iconEntries = parseIconEntries(getAttribute(attributes, 'icon'));
|
|
101
|
+
const [iconEntry] = iconEntries.entries;
|
|
102
|
+
const icon = iconEntry?.ref;
|
|
103
|
+
const palette = getAttribute(attributes, 'palette');
|
|
104
|
+
const iconPalette = iconEntry?.palette ?? getAttribute(attributes, 'iconPalette') ?? palette;
|
|
105
|
+
const ariaLabel = getAttribute(attributes, 'ariaLabel');
|
|
106
|
+
const newTab = getBooleanAttribute(attributes, 'newTab');
|
|
107
|
+
for (const warning of parsed.warnings)file.message(warning);
|
|
108
|
+
for (const warning of validateButtonAttributes(attributes))file.message(warning);
|
|
109
|
+
if (icon) {
|
|
110
|
+
const normalized = normalizePayloadMarkdownIconRef(icon);
|
|
111
|
+
if (normalized.warning) file.message(normalized.warning);
|
|
112
|
+
}
|
|
113
|
+
for (const warning of [
|
|
114
|
+
...iconEntries.warnings,
|
|
115
|
+
...getExtraIconWarnings('button', iconEntries.entries)
|
|
116
|
+
])file.message(warning);
|
|
117
|
+
for (const name of collectPaletteNames(BUTTON_ALLOWED_ATTRIBUTES, attributes)){
|
|
118
|
+
const warning = getUnknownPaletteWarning(name, 'button', config);
|
|
119
|
+
if (warning) file.message(warning);
|
|
120
|
+
}
|
|
121
|
+
if (!label && !ariaLabel) file.message('Icon-only button requires an ariaLabel attribute.');
|
|
122
|
+
const hChildren = [
|
|
123
|
+
...icon && iconPosition === 'left' ? [
|
|
124
|
+
makeIconPlaceholder(icon, iconPosition, iconPalette)
|
|
125
|
+
] : [],
|
|
126
|
+
...label ? [
|
|
127
|
+
{
|
|
128
|
+
type: 'text',
|
|
129
|
+
value: label
|
|
130
|
+
}
|
|
131
|
+
] : [],
|
|
132
|
+
...icon && iconPosition === 'right' ? [
|
|
133
|
+
makeIconPlaceholder(icon, iconPosition, iconPalette)
|
|
134
|
+
] : []
|
|
135
|
+
];
|
|
136
|
+
return {
|
|
137
|
+
name: 'button',
|
|
138
|
+
type: 'leafDirective',
|
|
139
|
+
attributes: Object.fromEntries(Object.entries(attributes).map(([key, value])=>[
|
|
140
|
+
key,
|
|
141
|
+
String(value)
|
|
142
|
+
])),
|
|
143
|
+
children: label ? [
|
|
144
|
+
{
|
|
145
|
+
type: 'text',
|
|
146
|
+
value: label
|
|
147
|
+
}
|
|
148
|
+
] : [],
|
|
149
|
+
data: {
|
|
150
|
+
hChildren,
|
|
151
|
+
hName: 'a',
|
|
152
|
+
hProperties: {
|
|
153
|
+
...ariaLabel ? {
|
|
154
|
+
ariaLabel
|
|
155
|
+
} : {},
|
|
156
|
+
className: [
|
|
157
|
+
'pmd-button',
|
|
158
|
+
`pmd-button--${variant}`,
|
|
159
|
+
`pmd-button--${size}`
|
|
160
|
+
],
|
|
161
|
+
dataButton: '',
|
|
162
|
+
dataDirective: 'button',
|
|
163
|
+
dataIconPalette: getAttribute(attributes, 'iconPalette'),
|
|
164
|
+
dataIconPosition: icon ? iconPosition : undefined,
|
|
165
|
+
dataPalette: palette,
|
|
166
|
+
dataSize: size,
|
|
167
|
+
dataVariant: variant,
|
|
168
|
+
href,
|
|
169
|
+
...newTab ? {
|
|
170
|
+
rel: 'noopener noreferrer',
|
|
171
|
+
target: '_blank'
|
|
172
|
+
} : {}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** Editor diagnostics for a `::button` line (the editor side of `leaf.lint`). */ function lintButtonLine(text, options) {
|
|
178
|
+
const parsed = parseLeafDirectiveLine(text, 'button');
|
|
179
|
+
if (!parsed) return [];
|
|
180
|
+
const diagnostics = [
|
|
181
|
+
...parsed.warnings,
|
|
182
|
+
...validateButtonAttributes(parsed.attributes)
|
|
183
|
+
];
|
|
184
|
+
const icon = parsed.attributes.icon;
|
|
185
|
+
const [iconEntry] = typeof icon === 'string' ? parseIconEntries(icon).entries : [];
|
|
186
|
+
if (iconEntry) {
|
|
187
|
+
const normalized = normalizePayloadMarkdownIconRef(iconEntry.ref);
|
|
188
|
+
if (normalized.warning) diagnostics.push(normalized.warning);
|
|
189
|
+
}
|
|
190
|
+
if (!parsed.label.trim() && typeof parsed.attributes.ariaLabel !== 'string') diagnostics.push('Icon-only button requires an ariaLabel attribute.');
|
|
191
|
+
return [
|
|
192
|
+
...diagnostics,
|
|
193
|
+
...getIconLintDiagnostics('button', icon, options),
|
|
194
|
+
...getPaletteLintDiagnostics('button', BUTTON_ALLOWED_ATTRIBUTES, parsed.attributes, options)
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
export const buttonDirective = defineDirective({
|
|
41
198
|
name: 'button',
|
|
42
199
|
allowedAttributes: BUTTON_ALLOWED_ATTRIBUTES,
|
|
43
|
-
applyHast (node,
|
|
200
|
+
applyHast (node, config, { mergeClassNames }) {
|
|
44
201
|
const variant = isButtonVariant(node.properties.dataVariant) ? node.properties.dataVariant : DEFAULT_BUTTON_VARIANT;
|
|
45
202
|
const size = isButtonSize(node.properties.dataSize) ? node.properties.dataSize : DEFAULT_BUTTON_SIZE;
|
|
203
|
+
// The sanitizer strips classes on links, so icon-only is read from the
|
|
204
|
+
// content: no label text, only the icon.
|
|
205
|
+
const iconOnly = node.children.length > 0 && node.children.every((child)=>child.type === 'element' || child.type === 'text' && !child.value.trim());
|
|
46
206
|
node.properties.dataVariant = variant;
|
|
47
207
|
node.properties.dataSize = size;
|
|
48
|
-
node.properties.className = mergeClassNames('pmd-button', `pmd-button--${variant}`, `pmd-button--${size}
|
|
208
|
+
node.properties.className = mergeClassNames('pmd-button', `pmd-button--${variant}`, `pmd-button--${size}`, iconOnly ? 'pmd-button--icon-only' : undefined);
|
|
209
|
+
applyDirectivePalette(node, config, 'button');
|
|
210
|
+
},
|
|
211
|
+
attributeTypes: {
|
|
212
|
+
href: {
|
|
213
|
+
type: 'url'
|
|
214
|
+
},
|
|
215
|
+
icon: {
|
|
216
|
+
type: 'icon'
|
|
217
|
+
},
|
|
218
|
+
iconPalette: {
|
|
219
|
+
type: 'palette'
|
|
220
|
+
},
|
|
221
|
+
palette: {
|
|
222
|
+
type: 'palette'
|
|
223
|
+
}
|
|
49
224
|
},
|
|
50
225
|
attributeValues: {
|
|
51
226
|
iconPosition: BUTTON_ICON_POSITIONS,
|
|
@@ -81,18 +256,40 @@ export const buttonDirective = {
|
|
|
81
256
|
]
|
|
82
257
|
},
|
|
83
258
|
kind: 'button',
|
|
259
|
+
leaf: {
|
|
260
|
+
build: (line, sink, config)=>makeButtonDirective(line, sink, config),
|
|
261
|
+
lint: (line, options)=>lintButtonLine(line, options),
|
|
262
|
+
// applyHast sets the variant classes and the palette on the link.
|
|
263
|
+
marker: true
|
|
264
|
+
},
|
|
84
265
|
public: true,
|
|
266
|
+
sanitize: {
|
|
267
|
+
a: [
|
|
268
|
+
'ariaLabel',
|
|
269
|
+
'className',
|
|
270
|
+
'dataButton',
|
|
271
|
+
'dataDirective',
|
|
272
|
+
'dataIconPalette',
|
|
273
|
+
'dataIconPosition',
|
|
274
|
+
'dataPalette',
|
|
275
|
+
'dataSize',
|
|
276
|
+
'dataVariant',
|
|
277
|
+
'href',
|
|
278
|
+
'rel',
|
|
279
|
+
'target'
|
|
280
|
+
],
|
|
281
|
+
// The icon placeholder (resolved after sanitizing by rehypeResolveIcons).
|
|
282
|
+
span: [
|
|
283
|
+
'className',
|
|
284
|
+
'dataPmdIcon',
|
|
285
|
+
'dataPmdIconPalette',
|
|
286
|
+
'dataPmdIconRef',
|
|
287
|
+
'focusable'
|
|
288
|
+
]
|
|
289
|
+
},
|
|
85
290
|
supportsAttributes: true,
|
|
86
291
|
tagName: 'a',
|
|
87
|
-
validateAttributes ({ attributes })
|
|
88
|
-
|
|
89
|
-
if (typeof attributes.variant === 'string' && !isButtonVariant(attributes.variant)) warnings.push(`Invalid button variant "${attributes.variant}". Falling back to "${DEFAULT_BUTTON_VARIANT}".`);
|
|
90
|
-
if (typeof attributes.size === 'string' && !isButtonSize(attributes.size)) warnings.push(`Invalid button size "${attributes.size}". Falling back to "${DEFAULT_BUTTON_SIZE}".`);
|
|
91
|
-
if (typeof attributes.iconPosition === 'string' && !isButtonIconPosition(attributes.iconPosition)) warnings.push(`Invalid button iconPosition "${attributes.iconPosition}". Falling back to "${DEFAULT_BUTTON_ICON_POSITION}".`);
|
|
92
|
-
if (typeof attributes.href !== 'string' || !attributes.href.trim()) warnings.push('Directive "button" requires an href attribute.');
|
|
93
|
-
else warnings.push(...getUnsafeHrefWarnings('button', attributes));
|
|
94
|
-
return warnings;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
292
|
+
validateAttributes: ({ attributes })=>validateButtonAttributes(attributes)
|
|
293
|
+
});
|
|
97
294
|
|
|
98
295
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/directives/definitions/button.ts"],"sourcesContent":["import type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { getUnknownAttributeWarnings } from '../attributeDiagnostics.js'\nimport { getUnsafeHrefWarnings } from '../urls.js'\n\nexport const BUTTON_VARIANTS = ['primary', 'secondary', 'outline', 'ghost', 'link'] as const\nexport const BUTTON_SIZES = ['sm', 'md', 'lg'] as const\nexport const BUTTON_ICON_POSITIONS = ['left', 'right'] as const\nexport const BUTTON_ALLOWED_ATTRIBUTES = [\n 'ariaLabel',\n 'href',\n 'icon',\n 'iconPosition',\n 'newTab',\n 'size',\n 'variant',\n] as const\n\nexport const DEFAULT_BUTTON_VARIANT = 'primary'\nexport const DEFAULT_BUTTON_SIZE = 'md'\nexport const DEFAULT_BUTTON_ICON_POSITION = 'left'\n\nexport type ButtonVariant = (typeof BUTTON_VARIANTS)[number]\nexport type ButtonSize = (typeof BUTTON_SIZES)[number]\nexport type ButtonIconPosition = (typeof BUTTON_ICON_POSITIONS)[number]\n\nexport function isButtonVariant(value: unknown): value is ButtonVariant {\n return typeof value === 'string' && BUTTON_VARIANTS.includes(value as ButtonVariant)\n}\n\nexport function isButtonSize(value: unknown): value is ButtonSize {\n return typeof value === 'string' && BUTTON_SIZES.includes(value as ButtonSize)\n}\n\nexport function isButtonIconPosition(value: unknown): value is ButtonIconPosition {\n return typeof value === 'string' && BUTTON_ICON_POSITIONS.includes(value as ButtonIconPosition)\n}\n\nexport const buttonDirective: LayoutDirectiveDefinition = {\n name: 'button',\n allowedAttributes: BUTTON_ALLOWED_ATTRIBUTES,\n applyHast(node, _config, { mergeClassNames }) {\n const variant = isButtonVariant(node.properties.dataVariant)\n ? node.properties.dataVariant\n : DEFAULT_BUTTON_VARIANT\n const size = isButtonSize(node.properties.dataSize) ? node.properties.dataSize : DEFAULT_BUTTON_SIZE\n\n node.properties.dataVariant = variant\n node.properties.dataSize = size\n node.properties.className = mergeClassNames(\n 'pmd-button',\n `pmd-button--${variant}`,\n `pmd-button--${size}`,\n )\n },\n attributeValues: {\n iconPosition: BUTTON_ICON_POSITIONS,\n newTab: ['true', 'false'],\n size: BUTTON_SIZES,\n variant: BUTTON_VARIANTS,\n },\n defaultAttributes: {\n iconPosition: DEFAULT_BUTTON_ICON_POSITION,\n newTab: 'false',\n size: DEFAULT_BUTTON_SIZE,\n variant: DEFAULT_BUTTON_VARIANT,\n },\n description: 'Link button with optional icon, variant, size, and new-tab behavior.',\n editor: {\n detail: 'Button leaf directive',\n label: '::button',\n snippet: '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n}\\n${}',\n snippets: [\n {\n detail: 'Button snippet variant; inserts canonical ::button',\n label: '::button_icon',\n snippet:\n '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n icon=\"${@fa-duotone/book-open}\"\\n}\\n${}',\n },\n {\n detail: 'Button snippet variant; inserts canonical ::button',\n label: '::button_full',\n snippet:\n '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n size=\"${md}\"\\n icon=\"${@fa-duotone/book-open}\"\\n iconPosition=\"${left}\"\\n newTab=${false}\\n ariaLabel=\"${}\"\\n}',\n },\n ],\n },\n kind: 'button',\n public: true,\n supportsAttributes: true,\n tagName: 'a',\n validateAttributes({ attributes }) {\n const warnings: string[] = getUnknownAttributeWarnings(\n 'button',\n BUTTON_ALLOWED_ATTRIBUTES,\n attributes,\n )\n\n if (typeof attributes.variant === 'string' && !isButtonVariant(attributes.variant))\n warnings.push(\n `Invalid button variant \"${attributes.variant}\". Falling back to \"${DEFAULT_BUTTON_VARIANT}\".`,\n )\n\n if (typeof attributes.size === 'string' && !isButtonSize(attributes.size))\n warnings.push(\n `Invalid button size \"${attributes.size}\". Falling back to \"${DEFAULT_BUTTON_SIZE}\".`,\n )\n\n if (\n typeof attributes.iconPosition === 'string' &&\n !isButtonIconPosition(attributes.iconPosition)\n )\n warnings.push(\n `Invalid button iconPosition \"${attributes.iconPosition}\". Falling back to \"${DEFAULT_BUTTON_ICON_POSITION}\".`,\n )\n\n if (typeof attributes.href !== 'string' || !attributes.href.trim())\n warnings.push('Directive \"button\" requires an href attribute.')\n else warnings.push(...getUnsafeHrefWarnings('button', attributes))\n\n return warnings\n },\n}\n"],"names":["getUnknownAttributeWarnings","getUnsafeHrefWarnings","BUTTON_VARIANTS","BUTTON_SIZES","BUTTON_ICON_POSITIONS","BUTTON_ALLOWED_ATTRIBUTES","DEFAULT_BUTTON_VARIANT","DEFAULT_BUTTON_SIZE","DEFAULT_BUTTON_ICON_POSITION","isButtonVariant","value","includes","isButtonSize","isButtonIconPosition","buttonDirective","name","allowedAttributes","applyHast","node","_config","mergeClassNames","variant","properties","dataVariant","size","dataSize","className","attributeValues","iconPosition","newTab","defaultAttributes","description","editor","detail","label","snippet","snippets","kind","public","supportsAttributes","tagName","validateAttributes","attributes","warnings","push","href","trim"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,6BAA4B;AACxE,SAASC,qBAAqB,QAAQ,aAAY;AAElD,OAAO,MAAMC,kBAAkB;IAAC;IAAW;IAAa;IAAW;IAAS;CAAO,CAAS;AAC5F,OAAO,MAAMC,eAAe;IAAC;IAAM;IAAM;CAAK,CA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AAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;QACTC,UAAU;YACR;gBACEH,QAAQ;gBACRC,OAAO;gBACPC,SACE;YACJ;YACA;gBACEF,QAAQ;gBACRC,OAAO;gBACPC,SACE;YACJ;SACD;IACH;IACAE,MAAM;IACNC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,oBAAmB,EAAEC,UAAU,EAAE;QAC/B,MAAMC,WAAqB3C,4BACzB,UACAK,2BACAqC;QAGF,IAAI,OAAOA,WAAWrB,OAAO,KAAK,YAAY,CAACZ,gBAAgBiC,WAAWrB,OAAO,GAC/EsB,SAASC,IAAI,CACX,CAAC,wBAAwB,EAAEF,WAAWrB,OAAO,CAAC,oBAAoB,EAAEf,uBAAuB,EAAE,CAAC;QAGlG,IAAI,OAAOoC,WAAWlB,IAAI,KAAK,YAAY,CAACZ,aAAa8B,WAAWlB,IAAI,GACtEmB,SAASC,IAAI,CACX,CAAC,qBAAqB,EAAEF,WAAWlB,IAAI,CAAC,oBAAoB,EAAEjB,oBAAoB,EAAE,CAAC;QAGzF,IACE,OAAOmC,WAAWd,YAAY,KAAK,YACnC,CAACf,qBAAqB6B,WAAWd,YAAY,GAE7Ce,SAASC,IAAI,CACX,CAAC,6BAA6B,EAAEF,WAAWd,YAAY,CAAC,oBAAoB,EAAEpB,6BAA6B,EAAE,CAAC;QAGlH,IAAI,OAAOkC,WAAWG,IAAI,KAAK,YAAY,CAACH,WAAWG,IAAI,CAACC,IAAI,IAC9DH,SAASC,IAAI,CAAC;aACXD,SAASC,IAAI,IAAI3C,sBAAsB,UAAUyC;QAEtD,OAAOC;IACT;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/button.ts"],"sourcesContent":["import type { LeafDirective } from 'mdast-util-directive'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\nimport type { DirectiveAttributes } from '../attributes.js'\nimport type { DirectiveMessageSink, LintMarkdownDirectivesOptions } from '../types.js'\n\nimport { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js'\nimport { normalizePayloadMarkdownIconRef } from '../../icons/refs.js'\nimport { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js'\nimport { getUnknownAttributeWarnings } from '../attributeDiagnostics.js'\nimport { parseLeafDirectiveLine } from '../leafSyntax.js'\nimport { getIconLintDiagnostics, getPaletteLintDiagnostics } from '../lint.js'\nimport { applyDirectivePalette } from '../palette.js'\nimport { defineDirective } from '../types.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\n\nexport const BUTTON_VARIANTS = ['primary', 'secondary', 'outline', 'ghost', 'link'] as const\nexport const BUTTON_SIZES = ['sm', 'md', 'lg'] as const\nexport const BUTTON_ICON_POSITIONS = ['left', 'right'] as const\nexport const BUTTON_ALLOWED_ATTRIBUTES = [\n 'ariaLabel',\n 'href',\n 'icon',\n 'iconPalette',\n 'iconPosition',\n 'newTab',\n 'palette',\n 'size',\n 'variant',\n] as const\n\nexport const DEFAULT_BUTTON_VARIANT = 'primary'\nexport const DEFAULT_BUTTON_SIZE = 'md'\nexport const DEFAULT_BUTTON_ICON_POSITION = 'left'\n\nexport type ButtonVariant = (typeof BUTTON_VARIANTS)[number]\nexport type ButtonSize = (typeof BUTTON_SIZES)[number]\nexport type ButtonIconPosition = (typeof BUTTON_ICON_POSITIONS)[number]\n\nexport function isButtonVariant(value: unknown): value is ButtonVariant {\n return typeof value === 'string' && BUTTON_VARIANTS.includes(value as ButtonVariant)\n}\n\nexport function isButtonSize(value: unknown): value is ButtonSize {\n return typeof value === 'string' && BUTTON_SIZES.includes(value as ButtonSize)\n}\n\nexport function isButtonIconPosition(value: unknown): value is ButtonIconPosition {\n return typeof value === 'string' && BUTTON_ICON_POSITIONS.includes(value as ButtonIconPosition)\n}\n\nfunction validateButtonAttributes(attributes: DirectiveAttributes): string[] {\n const warnings: string[] = getUnknownAttributeWarnings(\n 'button',\n BUTTON_ALLOWED_ATTRIBUTES,\n attributes,\n )\n\n if (typeof attributes.variant === 'string' && !isButtonVariant(attributes.variant))\n warnings.push(\n `Invalid button variant \"${attributes.variant}\". Falling back to \"${DEFAULT_BUTTON_VARIANT}\".`,\n )\n\n if (typeof attributes.size === 'string' && !isButtonSize(attributes.size))\n warnings.push(\n `Invalid button size \"${attributes.size}\". Falling back to \"${DEFAULT_BUTTON_SIZE}\".`,\n )\n\n if (\n typeof attributes.iconPosition === 'string' &&\n !isButtonIconPosition(attributes.iconPosition)\n )\n warnings.push(\n `Invalid button iconPosition \"${attributes.iconPosition}\". Falling back to \"${DEFAULT_BUTTON_ICON_POSITION}\".`,\n )\n\n if (typeof attributes.href !== 'string' || !attributes.href.trim())\n warnings.push('Directive \"button\" requires an href attribute.')\n else warnings.push(...getUnsafeHrefWarnings('button', attributes))\n\n return warnings\n}\n\nfunction getAttribute(attributes: Record<string, boolean | string>, name: string): string | undefined {\n const value = attributes[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(attributes: Record<string, boolean | string>, name: string): boolean {\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 makeIconPlaceholder(icon: string, iconPosition: 'left' | 'right', palette?: string) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n const iconKey = normalized.icon?.key ?? icon\n\n return {\n type: 'element' as const,\n children: [],\n properties: {\n ariaHidden: 'true',\n className: [\n 'pmd-button__icon',\n `pmd-button__icon--${iconPosition}`,\n ],\n dataPmdIcon: iconKey,\n ...(palette ? { dataPmdIconPalette: palette } : {}),\n dataPmdIconRef: icon,\n focusable: 'false',\n },\n tagName: 'span',\n }\n}\n\n/** Builds the `::button` leaf (the renderer side of `leaf.build`). */\nexport function makeButtonDirective(\n line: string,\n file: DirectiveMessageSink,\n config: MarkdownRenderConfig,\n): LeafDirective | undefined {\n const parsed = parseLeafDirectiveLine(line, 'button')\n if (!parsed) return undefined\n\n const attributes = parsed.attributes\n const label = parsed.label.trim()\n const href = getSafeHref(getAttribute(attributes, 'href'))\n const variant = isButtonVariant(attributes.variant) ? attributes.variant : DEFAULT_BUTTON_VARIANT\n const size = isButtonSize(attributes.size) ? attributes.size : DEFAULT_BUTTON_SIZE\n const iconPosition = isButtonIconPosition(attributes.iconPosition)\n ? attributes.iconPosition\n : DEFAULT_BUTTON_ICON_POSITION\n // A button shows one icon; it may carry its own palette (`@pack/name palette=x`).\n const iconEntries = parseIconEntries(getAttribute(attributes, 'icon'))\n const [iconEntry] = iconEntries.entries\n const icon = iconEntry?.ref\n const palette = getAttribute(attributes, 'palette')\n const iconPalette = iconEntry?.palette ?? getAttribute(attributes, 'iconPalette') ?? palette\n const ariaLabel = getAttribute(attributes, 'ariaLabel')\n const newTab = getBooleanAttribute(attributes, 'newTab')\n\n for (const warning of parsed.warnings) file.message(warning)\n for (const warning of validateButtonAttributes(attributes)) file.message(warning)\n\n if (icon) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n if (normalized.warning) file.message(normalized.warning)\n }\n\n for (const warning of [...iconEntries.warnings, ...getExtraIconWarnings('button', iconEntries.entries)])\n file.message(warning)\n\n for (const name of collectPaletteNames(BUTTON_ALLOWED_ATTRIBUTES, attributes)) {\n const warning = getUnknownPaletteWarning(name, 'button', config)\n if (warning) file.message(warning)\n }\n\n if (!label && !ariaLabel) file.message('Icon-only button requires an ariaLabel attribute.')\n\n const hChildren = [\n ...(icon && iconPosition === 'left' ? [makeIconPlaceholder(icon, iconPosition, iconPalette)] : []),\n ...(label\n ? [\n {\n type: 'text' as const,\n value: label,\n },\n ]\n : []),\n ...(icon && iconPosition === 'right' ? [makeIconPlaceholder(icon, iconPosition, iconPalette)] : []),\n ]\n\n return {\n name: 'button',\n type: 'leafDirective',\n attributes: Object.fromEntries(\n Object.entries(attributes).map(([key, value]) => [key, String(value)]),\n ),\n children: label ? [{ type: 'text', value: label }] : [],\n data: {\n hChildren,\n hName: 'a',\n hProperties: {\n ...(ariaLabel ? { ariaLabel } : {}),\n className: [\n 'pmd-button',\n `pmd-button--${variant}`,\n `pmd-button--${size}`,\n ],\n dataButton: '',\n dataDirective: 'button',\n dataIconPalette: getAttribute(attributes, 'iconPalette'),\n dataIconPosition: icon ? iconPosition : undefined,\n dataPalette: palette,\n dataSize: size,\n dataVariant: variant,\n href,\n ...(newTab\n ? {\n rel: 'noopener noreferrer',\n target: '_blank',\n }\n : {}),\n },\n },\n }\n}\n\n/** Editor diagnostics for a `::button` line (the editor side of `leaf.lint`). */\nfunction lintButtonLine(text: string, options: LintMarkdownDirectivesOptions): string[] {\n const parsed = parseLeafDirectiveLine(text, 'button')\n if (!parsed) return []\n\n const diagnostics = [...parsed.warnings, ...validateButtonAttributes(parsed.attributes)]\n const icon = parsed.attributes.icon\n const [iconEntry] = typeof icon === 'string' ? parseIconEntries(icon).entries : []\n\n if (iconEntry) {\n const normalized = normalizePayloadMarkdownIconRef(iconEntry.ref)\n if (normalized.warning) diagnostics.push(normalized.warning)\n }\n\n if (!parsed.label.trim() && typeof parsed.attributes.ariaLabel !== 'string')\n diagnostics.push('Icon-only button requires an ariaLabel attribute.')\n\n return [\n ...diagnostics,\n ...getIconLintDiagnostics('button', icon, options),\n ...getPaletteLintDiagnostics('button', BUTTON_ALLOWED_ATTRIBUTES, parsed.attributes, options),\n ]\n}\n\nexport const buttonDirective = defineDirective({\n name: 'button',\n allowedAttributes: BUTTON_ALLOWED_ATTRIBUTES,\n applyHast(node, config, { mergeClassNames }) {\n const variant = isButtonVariant(node.properties.dataVariant)\n ? node.properties.dataVariant\n : DEFAULT_BUTTON_VARIANT\n const size = isButtonSize(node.properties.dataSize) ? node.properties.dataSize : DEFAULT_BUTTON_SIZE\n // The sanitizer strips classes on links, so icon-only is read from the\n // content: no label text, only the icon.\n const iconOnly =\n node.children.length > 0 &&\n node.children.every((child) => child.type === 'element' || (child.type === 'text' && !child.value.trim()))\n\n node.properties.dataVariant = variant\n node.properties.dataSize = size\n node.properties.className = mergeClassNames(\n 'pmd-button',\n `pmd-button--${variant}`,\n `pmd-button--${size}`,\n iconOnly ? 'pmd-button--icon-only' : undefined,\n )\n applyDirectivePalette(node, config, 'button')\n },\n attributeTypes: {\n href: { type: 'url' },\n icon: { type: 'icon' },\n iconPalette: { type: 'palette' },\n palette: { type: 'palette' },\n },\n attributeValues: {\n iconPosition: BUTTON_ICON_POSITIONS,\n newTab: ['true', 'false'],\n size: BUTTON_SIZES,\n variant: BUTTON_VARIANTS,\n },\n defaultAttributes: {\n iconPosition: DEFAULT_BUTTON_ICON_POSITION,\n newTab: 'false',\n size: DEFAULT_BUTTON_SIZE,\n variant: DEFAULT_BUTTON_VARIANT,\n },\n description: 'Link button with optional icon, variant, size, and new-tab behavior.',\n editor: {\n detail: 'Button leaf directive',\n label: '::button',\n snippet: '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n}\\n${}',\n snippets: [\n {\n detail: 'Button snippet variant; inserts canonical ::button',\n label: '::button_icon',\n snippet:\n '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n icon=\"${@fa-duotone/book-open}\"\\n}\\n${}',\n },\n {\n detail: 'Button snippet variant; inserts canonical ::button',\n label: '::button_full',\n snippet:\n '::button[${Label}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n size=\"${md}\"\\n icon=\"${@fa-duotone/book-open}\"\\n iconPosition=\"${left}\"\\n newTab=${false}\\n ariaLabel=\"${}\"\\n}',\n },\n ],\n },\n kind: 'button',\n leaf: {\n build: (line, sink, config) => makeButtonDirective(line, sink, config),\n lint: (line, options) => lintButtonLine(line, options),\n // applyHast sets the variant classes and the palette on the link.\n marker: true,\n },\n public: true,\n sanitize: {\n a: [\n 'ariaLabel',\n 'className',\n 'dataButton',\n 'dataDirective',\n 'dataIconPalette',\n 'dataIconPosition',\n 'dataPalette',\n 'dataSize',\n 'dataVariant',\n 'href',\n 'rel',\n 'target',\n ],\n // The icon placeholder (resolved after sanitizing by rehypeResolveIcons).\n span: ['className', 'dataPmdIcon', 'dataPmdIconPalette', 'dataPmdIconRef', 'focusable'],\n },\n supportsAttributes: true,\n tagName: 'a',\n validateAttributes: ({ attributes }) => validateButtonAttributes(attributes),\n})\n"],"names":["getExtraIconWarnings","parseIconEntries","normalizePayloadMarkdownIconRef","collectPaletteNames","getUnknownPaletteWarning","getUnknownAttributeWarnings","parseLeafDirectiveLine","getIconLintDiagnostics","getPaletteLintDiagnostics","applyDirectivePalette","defineDirective","getSafeHref","getUnsafeHrefWarnings","BUTTON_VARIANTS","BUTTON_SIZES","BUTTON_ICON_POSITIONS","BUTTON_ALLOWED_ATTRIBUTES","DEFAULT_BUTTON_VARIANT","DEFAULT_BUTTON_SIZE","DEFAULT_BUTTON_ICON_POSITION","isButtonVariant","value","includes","isButtonSize","isButtonIconPosition","validateButtonAttributes","attributes","warnings","variant","push","size","iconPosition","href","trim","getAttribute","name","undefined","getBooleanAttribute","makeIconPlaceholder","icon","palette","normalized","iconKey","key","type","children","properties","ariaHidden","className","dataPmdIcon","dataPmdIconPalette","dataPmdIconRef","focusable","tagName","makeButtonDirective","line","file","config","parsed","label","iconEntries","iconEntry","entries","ref","iconPalette","ariaLabel","newTab","warning","message","hChildren","Object","fromEntries","map","String","data","hName","hProperties","dataButton","dataDirective","dataIconPalette","dataIconPosition","dataPalette","dataSize","dataVariant","rel","target","lintButtonLine","text","options","diagnostics","buttonDirective","allowedAttributes","applyHast","node","mergeClassNames","iconOnly","length","every","child","attributeTypes","attributeValues","defaultAttributes","description","editor","detail","snippet","snippets","kind","leaf","build","sink","lint","marker","public","sanitize","a","span","supportsAttributes","validateAttributes"],"mappings":"AAMA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,yBAAwB;AAC/E,SAASC,+BAA+B,QAAQ,sBAAqB;AACrE,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,gCAA+B;AAC7F,SAASC,2BAA2B,QAAQ,6BAA4B;AACxE,SAASC,sBAAsB,QAAQ,mBAAkB;AACzD,S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AEE,MAAM,EACrBiE,WAAW,0BAA0B3D;QAEvC3B,sBAAsBoF,MAAMpC,QAAQ;IACtC;IACA0C,gBAAgB;QACdnE,MAAM;YAAEY,MAAM;QAAM;QACpBL,MAAM;YAAEK,MAAM;QAAO;QACrBoB,aAAa;YAAEpB,MAAM;QAAU;QAC/BJ,SAAS;YAAEI,MAAM;QAAU;IAC7B;IACAwD,iBAAiB;QACfrE,cAAchB;QACdmD,QAAQ;YAAC;YAAQ;SAAQ;QACzBpC,MAAMhB;QACNc,SAASf;IACX;IACAwF,mBAAmB;QACjBtE,cAAcZ;QACd+C,QAAQ;QACRpC,MAAMZ;QACNU,SAASX;IACX;IACAqF,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACR7C,OAAO;QACP8C,SAAS;QACTC,UAAU;YACR;gBACEF,QAAQ;gBACR7C,OAAO;gBACP8C,SACE;YACJ;YACA;gBACED,QAAQ;gBACR7C,OAAO;gBACP8C,SACE;YACJ;SACD;IACH;IACAE,MAAM;IACNC,MAAM;QACJC,OAAO,CAACtD,MAAMuD,MAAMrD,SAAWH,oBAAoBC,MAAMuD,MAAMrD;QAC/DsD,MAAM,CAACxD,MAAMiC,UAAYF,eAAe/B,MAAMiC;QAC9C,kEAAkE;QAClEwB,QAAQ;IACV;IACAC,QAAQ;IACRC,UAAU;QACRC,GAAG;YACD;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACD,0EAA0E;QAC1EC,MAAM;YAAC;YAAa;YAAe;YAAsB;YAAkB;SAAY;IACzF;IACAC,oBAAoB;IACpBhE,SAAS;IACTiE,oBAAoB,CAAC,EAAE5F,UAAU,EAAE,GAAKD,yBAAyBC;AACnE,GAAE"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { LayoutDirectiveDefinition } from '../types.js';
|
|
2
1
|
export declare const BUTTONS_ALIGNS: readonly ["left", "center", "right"];
|
|
3
2
|
export declare const BUTTONS_STACKS: readonly ["mobile", "always", "never"];
|
|
4
3
|
export declare const BUTTONS_GAPS: readonly ["sm", "md", "lg"];
|
|
5
4
|
export declare const DEFAULT_BUTTONS_ALIGN = "left";
|
|
6
5
|
export declare const DEFAULT_BUTTONS_STACK = "mobile";
|
|
7
6
|
export declare const DEFAULT_BUTTONS_GAP = "md";
|
|
8
|
-
export declare const buttonsDirective: LayoutDirectiveDefinition
|
|
7
|
+
export declare const buttonsDirective: import("../types.js").LayoutDirectiveDefinition<"buttons", "buttons">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineDirective } from '../types.js';
|
|
1
2
|
export const BUTTONS_ALIGNS = [
|
|
2
3
|
'left',
|
|
3
4
|
'center',
|
|
@@ -25,7 +26,7 @@ function isButtonsStack(value) {
|
|
|
25
26
|
function isButtonsGap(value) {
|
|
26
27
|
return typeof value === 'string' && BUTTONS_GAPS.includes(value);
|
|
27
28
|
}
|
|
28
|
-
export const buttonsDirective = {
|
|
29
|
+
export const buttonsDirective = defineDirective({
|
|
29
30
|
name: 'buttons',
|
|
30
31
|
allowedAttributes: [
|
|
31
32
|
'align',
|
|
@@ -46,6 +47,7 @@ export const buttonsDirective = {
|
|
|
46
47
|
gap: BUTTONS_GAPS,
|
|
47
48
|
stack: BUTTONS_STACKS
|
|
48
49
|
},
|
|
50
|
+
container: {},
|
|
49
51
|
defaultAttributes: {
|
|
50
52
|
align: DEFAULT_BUTTONS_ALIGN,
|
|
51
53
|
gap: DEFAULT_BUTTONS_GAP,
|
|
@@ -66,8 +68,15 @@ export const buttonsDirective = {
|
|
|
66
68
|
};
|
|
67
69
|
},
|
|
68
70
|
kind: 'buttons',
|
|
69
|
-
openMarker: ':::buttons',
|
|
70
71
|
public: true,
|
|
72
|
+
sanitize: {
|
|
73
|
+
div: [
|
|
74
|
+
'dataAlign',
|
|
75
|
+
'dataDirective',
|
|
76
|
+
'dataGap',
|
|
77
|
+
'dataStack'
|
|
78
|
+
]
|
|
79
|
+
},
|
|
71
80
|
supportsAttributes: true,
|
|
72
81
|
tagName: 'div',
|
|
73
82
|
validateAttributes ({ attributes }) {
|
|
@@ -77,6 +86,6 @@ export const buttonsDirective = {
|
|
|
77
86
|
if (typeof attributes.gap === 'string' && !isButtonsGap(attributes.gap)) warnings.push(`Invalid buttons gap "${attributes.gap}". Falling back to "${DEFAULT_BUTTONS_GAP}".`);
|
|
78
87
|
return warnings;
|
|
79
88
|
}
|
|
80
|
-
};
|
|
89
|
+
});
|
|
81
90
|
|
|
82
91
|
//# sourceMappingURL=buttons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/directives/definitions/buttons.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/buttons.ts"],"sourcesContent":["import { defineDirective } from '../types.js'\n\nexport const BUTTONS_ALIGNS = ['left', 'center', 'right'] as const\nexport const BUTTONS_STACKS = ['mobile', 'always', 'never'] as const\nexport const BUTTONS_GAPS = ['sm', 'md', 'lg'] as const\n\nexport const DEFAULT_BUTTONS_ALIGN = 'left'\nexport const DEFAULT_BUTTONS_STACK = 'mobile'\nexport const DEFAULT_BUTTONS_GAP = 'md'\n\ntype ButtonsAlign = (typeof BUTTONS_ALIGNS)[number]\ntype ButtonsStack = (typeof BUTTONS_STACKS)[number]\ntype ButtonsGap = (typeof BUTTONS_GAPS)[number]\n\nfunction isButtonsAlign(value: unknown): value is ButtonsAlign {\n return typeof value === 'string' && BUTTONS_ALIGNS.includes(value as ButtonsAlign)\n}\n\nfunction isButtonsStack(value: unknown): value is ButtonsStack {\n return typeof value === 'string' && BUTTONS_STACKS.includes(value as ButtonsStack)\n}\n\nfunction isButtonsGap(value: unknown): value is ButtonsGap {\n return typeof value === 'string' && BUTTONS_GAPS.includes(value as ButtonsGap)\n}\n\nexport const buttonsDirective = defineDirective({\n name: 'buttons',\n allowedAttributes: ['align', 'gap', 'stack'],\n applyHast(node, _config, { mergeClassNames }) {\n const align =\n typeof node.properties.dataAlign === 'string' && isButtonsAlign(node.properties.dataAlign)\n ? node.properties.dataAlign\n : DEFAULT_BUTTONS_ALIGN\n const stack =\n typeof node.properties.dataStack === 'string' && isButtonsStack(node.properties.dataStack)\n ? node.properties.dataStack\n : DEFAULT_BUTTONS_STACK\n const gap =\n typeof node.properties.dataGap === 'string' && isButtonsGap(node.properties.dataGap)\n ? node.properties.dataGap\n : DEFAULT_BUTTONS_GAP\n\n node.properties.dataAlign = align\n node.properties.dataStack = stack\n node.properties.dataGap = gap\n node.properties.className = mergeClassNames(\n 'not-prose',\n 'pmd-buttons',\n `pmd-buttons--align-${align}`,\n `pmd-buttons--stack-${stack}`,\n `pmd-buttons--gap-${gap}`,\n )\n },\n attributeValues: {\n align: BUTTONS_ALIGNS,\n gap: BUTTONS_GAPS,\n stack: BUTTONS_STACKS,\n },\n container: {},\n defaultAttributes: {\n align: DEFAULT_BUTTONS_ALIGN,\n gap: DEFAULT_BUTTONS_GAP,\n stack: DEFAULT_BUTTONS_STACK,\n },\n description: 'Button group wrapper for one or more button directives.',\n editor: {\n detail: 'Button group directive',\n label: 'Buttons',\n snippet:\n ':::buttons{\\n align=\"${left}\"\\n stack=\"${mobile}\"\\n gap=\"${md}\"\\n}\\n::button[${Get started}]{\\n href=\"${/docs}\"\\n variant=\"${primary}\"\\n}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataAlign: typeof node.attributes?.align === 'string' ? node.attributes.align : DEFAULT_BUTTONS_ALIGN,\n dataDirective: 'buttons',\n dataGap: typeof node.attributes?.gap === 'string' ? node.attributes.gap : DEFAULT_BUTTONS_GAP,\n dataStack: typeof node.attributes?.stack === 'string' ? node.attributes.stack : DEFAULT_BUTTONS_STACK,\n }\n },\n kind: 'buttons',\n public: true,\n sanitize: {\n div: ['dataAlign', 'dataDirective', 'dataGap', 'dataStack'],\n },\n supportsAttributes: true,\n tagName: 'div',\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.align === 'string' && !isButtonsAlign(attributes.align))\n warnings.push(\n `Invalid buttons align \"${attributes.align}\". Falling back to \"${DEFAULT_BUTTONS_ALIGN}\".`,\n )\n\n if (typeof attributes.stack === 'string' && !isButtonsStack(attributes.stack))\n warnings.push(\n `Invalid buttons stack \"${attributes.stack}\". Falling back to \"${DEFAULT_BUTTONS_STACK}\".`,\n )\n\n if (typeof attributes.gap === 'string' && !isButtonsGap(attributes.gap))\n warnings.push(\n `Invalid buttons gap \"${attributes.gap}\". Falling back to \"${DEFAULT_BUTTONS_GAP}\".`,\n )\n\n return warnings\n },\n})\n"],"names":["defineDirective","BUTTONS_ALIGNS","BUTTONS_STACKS","BUTTONS_GAPS","DEFAULT_BUTTONS_ALIGN","DEFAULT_BUTTONS_STACK","DEFAULT_BUTTONS_GAP","isButtonsAlign","value","includes","isButtonsStack","isButtonsGap","buttonsDirective","name","allowedAttributes","applyHast","node","_config","mergeClassNames","align","properties","dataAlign","stack","dataStack","gap","dataGap","className","attributeValues","container","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","attributes","dataDirective","kind","public","sanitize","div","supportsAttributes","tagName","validateAttributes","warnings","push"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAa;AAE7C,OAAO,MAAMC,iBAAiB;IAAC;IAAQ;IAAU;CAAQ,CAAS;AAClE,OAAO,MAAMC,iBAAiB;IAAC;IAAU;IAAU;CAAQ,CAAS;AACpE,OAAO,MAAMC,eAAe;IAAC;IAAM;IAAM;CAAK,CAAS;AAEvD,OAAO,MAAMC,wBAAwB,OAAM;AAC3C,OAAO,MAAMC,wBAAwB,SAAQ;AAC7C,OAAO,MAAMC,sBAAsB,KAAI;AAMvC,SAASC,eAAeC,KAAc;IACpC,OAAO,OAAOA,UAAU,YAAYP,eAAeQ,QAAQ,CAACD;AAC9D;AAEA,SAASE,eAAeF,KAAc;IACpC,OAAO,OAAOA,UAAU,YAAYN,eAAeO,QAAQ,CAACD;AAC9D;AAEA,SAASG,aAAaH,KAAc;IAClC,OAAO,OAAOA,U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AAGf;YAChFiC,eAAe;YACfZ,SAAS,OAAOT,KAAKoB,UAAU,EAAEZ,QAAQ,WAAWR,KAAKoB,UAAU,CAACZ,GAAG,GAAGlB;YAC1EiB,WAAW,OAAOP,KAAKoB,UAAU,EAAEd,UAAU,WAAWN,KAAKoB,UAAU,CAACd,KAAK,GAAGjB;QAClF;IACF;IACAiC,MAAM;IACNC,QAAQ;IACRC,UAAU;QACRC,KAAK;YAAC;YAAa;YAAiB;YAAW;SAAY;IAC7D;IACAC,oBAAoB;IACpBC,SAAS;IACTC,oBAAmB,EAAER,UAAU,EAAE;QAC/B,MAAMS,WAAqB,EAAE;QAE7B,IAAI,OAAOT,WAAWjB,KAAK,KAAK,YAAY,CAACZ,eAAe6B,WAAWjB,KAAK,GAC1E0B,SAASC,IAAI,CACX,CAAC,uBAAuB,EAAEV,WAAWjB,KAAK,CAAC,oBAAoB,EAAEf,sBAAsB,EAAE,CAAC;QAG9F,IAAI,OAAOgC,WAAWd,KAAK,KAAK,YAAY,CAACZ,eAAe0B,WAAWd,KAAK,GAC1EuB,SAASC,IAAI,CACX,CAAC,uBAAuB,EAAEV,WAAWd,KAAK,CAAC,oBAAoB,EAAEjB,sBAAsB,EAAE,CAAC;QAG9F,IAAI,OAAO+B,WAAWZ,GAAG,KAAK,YAAY,CAACb,aAAayB,WAAWZ,GAAG,GACpEqB,SAASC,IAAI,CACX,CAAC,qBAAqB,EAAEV,WAAWZ,GAAG,CAAC,oBAAoB,EAAElB,oBAAoB,EAAE,CAAC;QAGxF,OAAOuC;IACT;AACF,GAAE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ContainerDirective } from 'mdast-util-directive';
|
|
2
|
-
import type { LayoutDirectiveDefinition } from '../types.js';
|
|
3
2
|
export declare const CALLOUT_VARIANTS: readonly ["note", "info", "tip", "warning", "danger", "success"];
|
|
4
3
|
export type CalloutVariant = (typeof CALLOUT_VARIANTS)[number];
|
|
5
4
|
export declare function resolveCalloutVariant(node: ContainerDirective): CalloutVariant;
|
|
6
|
-
export declare const calloutDirective: LayoutDirectiveDefinition
|
|
5
|
+
export declare const calloutDirective: import("../types.js").LayoutDirectiveDefinition<"callout", "callout">;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { parseIconEntries } from '../../icons/entries.js';
|
|
1
2
|
import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
|
|
2
3
|
import { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js';
|
|
3
4
|
import { getDirectiveLabelOrAttribute } from '../labels.js';
|
|
5
|
+
import { applyDirectivePalette, getPaletteRenderProperties, PALETTE_ATTRIBUTES, resolveIconPaletteName } from '../palette.js';
|
|
4
6
|
import { resolveDirectiveTheme } from '../themes.js';
|
|
7
|
+
import { defineDirective } from '../types.js';
|
|
5
8
|
export const CALLOUT_VARIANTS = [
|
|
6
9
|
'note',
|
|
7
10
|
'info',
|
|
@@ -32,10 +35,11 @@ export function resolveCalloutVariant(node) {
|
|
|
32
35
|
function getTitle(node) {
|
|
33
36
|
return getDirectiveLabelOrAttribute(node, 'title');
|
|
34
37
|
}
|
|
35
|
-
export const calloutDirective = {
|
|
38
|
+
export const calloutDirective = defineDirective({
|
|
36
39
|
name: 'callout',
|
|
37
40
|
allowedAttributes: [
|
|
38
41
|
'icon',
|
|
42
|
+
...PALETTE_ATTRIBUTES,
|
|
39
43
|
'theme',
|
|
40
44
|
'title',
|
|
41
45
|
'variant'
|
|
@@ -43,13 +47,16 @@ export const calloutDirective = {
|
|
|
43
47
|
applyHast (node, config, { mergeClassNames }) {
|
|
44
48
|
const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note';
|
|
45
49
|
const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined;
|
|
46
|
-
|
|
50
|
+
// A callout shows one icon; it may carry its own palette (`@pack/name palette=x`).
|
|
51
|
+
const [iconEntry] = parseIconEntries(typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined).entries;
|
|
52
|
+
const icon = iconEntry?.ref;
|
|
47
53
|
const theme = resolveDirectiveTheme('callout', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft', config.themes);
|
|
48
54
|
const children = node.children;
|
|
49
55
|
// An icon without a title sits beside the body instead of on its own row.
|
|
50
56
|
const iconBesideBody = Boolean(icon && !title);
|
|
51
57
|
node.properties.dataTheme = theme.name;
|
|
52
58
|
node.properties.className = mergeClassNames(iconBesideBody ? 'flex items-start gap-3' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes, calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note']);
|
|
59
|
+
applyDirectivePalette(node, config);
|
|
53
60
|
node.children = [
|
|
54
61
|
...title || icon ? [
|
|
55
62
|
{
|
|
@@ -59,7 +66,7 @@ export const calloutDirective = {
|
|
|
59
66
|
makeDirectiveIconPlaceholder(icon, [
|
|
60
67
|
'pmd-callout__icon inline-flex size-4 shrink-0 text-current',
|
|
61
68
|
iconBesideBody ? 'mt-1.5' : 'mt-0.5'
|
|
62
|
-
])
|
|
69
|
+
], resolveIconPaletteName(node, iconEntry))
|
|
63
70
|
] : [],
|
|
64
71
|
...title ? [
|
|
65
72
|
{
|
|
@@ -91,6 +98,24 @@ export const calloutDirective = {
|
|
|
91
98
|
}
|
|
92
99
|
];
|
|
93
100
|
},
|
|
101
|
+
attributeTypes: {
|
|
102
|
+
icon: {
|
|
103
|
+
type: 'icon'
|
|
104
|
+
},
|
|
105
|
+
iconPalette: {
|
|
106
|
+
type: 'palette'
|
|
107
|
+
},
|
|
108
|
+
palette: {
|
|
109
|
+
type: 'palette'
|
|
110
|
+
},
|
|
111
|
+
variant: {
|
|
112
|
+
type: 'enum',
|
|
113
|
+
values: CALLOUT_VARIANTS
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
container: {
|
|
117
|
+
labelAttribute: 'title'
|
|
118
|
+
},
|
|
94
119
|
defaultAttributes: {
|
|
95
120
|
variant: 'note'
|
|
96
121
|
},
|
|
@@ -104,24 +129,40 @@ export const calloutDirective = {
|
|
|
104
129
|
return {
|
|
105
130
|
dataDirective: 'callout',
|
|
106
131
|
dataIcon: typeof node.attributes?.icon === 'string' ? node.attributes.icon : undefined,
|
|
132
|
+
...getPaletteRenderProperties(node),
|
|
107
133
|
dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',
|
|
108
134
|
dataTitle: getTitle(node),
|
|
109
135
|
dataVariant: resolveCalloutVariant(node)
|
|
110
136
|
};
|
|
111
137
|
},
|
|
112
138
|
kind: 'callout',
|
|
113
|
-
openMarker: ':::callout',
|
|
114
139
|
public: true,
|
|
140
|
+
sanitize: {
|
|
141
|
+
div: [
|
|
142
|
+
'dataDirective',
|
|
143
|
+
'dataIcon',
|
|
144
|
+
'dataIconPalette',
|
|
145
|
+
'dataPalette',
|
|
146
|
+
'dataTheme',
|
|
147
|
+
'dataTitle',
|
|
148
|
+
'dataVariant'
|
|
149
|
+
]
|
|
150
|
+
},
|
|
115
151
|
supportsAttributes: true,
|
|
116
152
|
tagName: 'div',
|
|
117
153
|
themeAttributes: {
|
|
118
154
|
theme: 'callout'
|
|
119
155
|
},
|
|
156
|
+
// `theme` picks the surface and `variant` the colour; a variant name given
|
|
157
|
+
// as the theme is a common mix-up. It still falls back like any unknown theme.
|
|
158
|
+
unknownThemeHint (attribute, value) {
|
|
159
|
+
return attribute === 'theme' && isCalloutVariant(value) ? `"${value}" is a callout variant; use variant="${value}".` : undefined;
|
|
160
|
+
},
|
|
120
161
|
validateAttributes ({ attributes }) {
|
|
121
162
|
const warnings = [];
|
|
122
163
|
if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant)) warnings.push(`Unsupported callout variant "${attributes.variant}". Falling back to "note".`);
|
|
123
164
|
return warnings;
|
|
124
165
|
}
|
|
125
|
-
};
|
|
166
|
+
});
|
|
126
167
|
|
|
127
168
|
//# sourceMappingURL=callout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/directives/definitions/callout.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 { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CALLOUT_VARIANTS = [\n 'note',\n 'info',\n 'tip',\n 'warning',\n 'danger',\n 'success',\n] as const\n\nexport type CalloutVariant = (typeof CALLOUT_VARIANTS)[number]\n\n// The tint is a background-image so it layers over the theme's background\n// color instead of competing with it, and the ring composes with the theme's\n// shadow. Text, title and ring colours follow the colour scheme through\n// `--pmd-scheme-dark` (see styles/directiveSurface.ts).\nconst calloutVariantClasses: Record<CalloutVariant, string> = {\n danger:\n 'bg-linear-to-r from-red-500/10 to-red-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(248_113_113/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(220_38_38/0.2))] text-[color:color-mix(in_oklab,rgb(254_242_242)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_10_10))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_165_165)_calc(var(--pmd-scheme-dark,1)*100%),rgb(185_28_28))]',\n info:\n 'bg-linear-to-r from-sky-500/10 to-sky-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(56_189_248/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_132_199/0.2))] text-[color:color-mix(in_oklab,rgb(240_249_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(8_47_73))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(125_211_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(3_105_161))]',\n note:\n 'bg-linear-to-r from-slate-500/10 to-slate-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(148_163_184/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(100_116_139/0.2))] text-[color:color-mix(in_oklab,rgb(248_250_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(15_23_42))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(203_213_225)_calc(var(--pmd-scheme-dark,1)*100%),rgb(71_85_105))]',\n success:\n 'bg-linear-to-r from-emerald-500/10 to-emerald-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(52_211_153/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(5_150_105/0.2))] text-[color:color-mix(in_oklab,rgb(236_253_245)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_44_34))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(110_231_183)_calc(var(--pmd-scheme-dark,1)*100%),rgb(4_120_87))]',\n tip:\n 'bg-linear-to-r from-violet-500/10 to-violet-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(167_139_250/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(124_58_237/0.2))] text-[color:color-mix(in_oklab,rgb(245_243_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(46_16_101))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(196_181_253)_calc(var(--pmd-scheme-dark,1)*100%),rgb(109_40_217))]',\n warning:\n 'bg-linear-to-r from-amber-500/10 to-amber-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(251_191_36/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(217_119_6/0.2))] text-[color:color-mix(in_oklab,rgb(255_251_235)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_26_3))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_211_77)_calc(var(--pmd-scheme-dark,1)*100%),rgb(146_64_14))]',\n}\n\nfunction isCalloutVariant(value: unknown): value is CalloutVariant {\n return typeof value === 'string' && CALLOUT_VARIANTS.includes(value as CalloutVariant)\n}\n\nexport function resolveCalloutVariant(node: ContainerDirective): CalloutVariant {\n const variant = node.attributes?.variant\n\n return isCalloutVariant(variant) ? variant : 'note'\n}\n\nfunction getTitle(node: ContainerDirective): string | undefined {\n return getDirectiveLabelOrAttribute(node, 'title')\n}\n\nexport const calloutDirective: LayoutDirectiveDefinition = {\n name: 'callout',\n allowedAttributes: ['icon', 'theme', 'title', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note'\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined\n const theme = resolveDirectiveTheme(\n 'callout',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft',\n config.themes,\n )\n const children = node.children\n // An icon without a title sits beside the body instead of on its own row.\n const iconBesideBody = Boolean(icon && !title)\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n iconBesideBody ? 'flex items-start gap-3' : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note'],\n )\n\n node.children = [\n ...(title || icon\n ? [\n {\n type: 'element' as const,\n children: [\n ...(icon\n ? [\n makeDirectiveIconPlaceholder(icon, [\n 'pmd-callout__icon inline-flex size-4 shrink-0 text-current',\n iconBesideBody ? 'mt-1.5' : 'mt-0.5',\n ]),\n ]\n : []),\n ...(title ? [{ type: 'text' as const, value: title }] : []),\n ],\n properties: {\n className: [\n iconBesideBody\n ? 'not-prose flex shrink-0'\n : 'not-prose mb-2 flex items-start gap-2 text-sm font-semibold tracking-wide',\n ],\n dataDirectiveTitle: 'callout',\n },\n tagName: 'div',\n },\n ]\n : []),\n {\n type: 'element',\n children,\n properties: {\n className: [DIRECTIVE_BODY_CLASS, iconBesideBody ? 'min-w-0 flex-1' : ''].filter(Boolean),\n dataDirectiveBody: 'callout',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n variant: 'note',\n },\n description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',\n editor: {\n detail: 'Static directive',\n label: 'Callout',\n snippet: ':::callout[${Title}]{\\n variant=\"${note}\"\\n}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'callout',\n dataIcon: typeof node.attributes?.icon === 'string' ? node.attributes.icon : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',\n dataTitle: getTitle(node),\n dataVariant: resolveCalloutVariant(node),\n }\n },\n kind: 'callout',\n openMarker: ':::callout',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'callout',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant))\n warnings.push(\n `Unsupported callout variant \"${attributes.variant}\". Falling back to \"note\".`,\n )\n\n return warnings\n },\n}\n"],"names":["DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","resolveDirectiveTheme","CALLOUT_VARIANTS","calloutVariantClasses","danger","info","note","success","tip","warning","isCalloutVariant","value","includes","resolveCalloutVariant","node","variant","attributes","getTitle","calloutDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataVariant","title","dataTitle","undefined","icon","dataIcon","theme","dataTheme","themes","children","iconBesideBody","Boolean","className","hookClassName","modifierClassName","classes","type","dataDirectiveTitle","tagName","filter","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AA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AAK,YAAY,CAACL,iBAAiBM,WAAWD,OAAO,GAChF6C,SAASC,IAAI,CACX,CAAC,6BAA6B,EAAE7C,WAAWD,OAAO,CAAC,0BAA0B,CAAC;QAGlF,OAAO6C;IACT;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/callout.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport { 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 { defineDirective } from '../types.js'\n\nexport const CALLOUT_VARIANTS = [\n 'note',\n 'info',\n 'tip',\n 'warning',\n 'danger',\n 'success',\n] as const\n\nexport type CalloutVariant = (typeof CALLOUT_VARIANTS)[number]\n\n// The tint is a background-image so it layers over the theme's background\n// color instead of competing with it, and the ring composes with the theme's\n// shadow. Text, title and ring colours follow the colour scheme through\n// `--pmd-scheme-dark` (see styles/directiveSurface.ts).\nconst calloutVariantClasses: Record<CalloutVariant, string> = {\n danger:\n 'bg-linear-to-r from-red-500/10 to-red-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(248_113_113/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(220_38_38/0.2))] text-[color:color-mix(in_oklab,rgb(254_242_242)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_10_10))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_165_165)_calc(var(--pmd-scheme-dark,1)*100%),rgb(185_28_28))]',\n info:\n 'bg-linear-to-r from-sky-500/10 to-sky-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(56_189_248/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_132_199/0.2))] text-[color:color-mix(in_oklab,rgb(240_249_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(8_47_73))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(125_211_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(3_105_161))]',\n note:\n 'bg-linear-to-r from-slate-500/10 to-slate-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(148_163_184/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(100_116_139/0.2))] text-[color:color-mix(in_oklab,rgb(248_250_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(15_23_42))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(203_213_225)_calc(var(--pmd-scheme-dark,1)*100%),rgb(71_85_105))]',\n success:\n 'bg-linear-to-r from-emerald-500/10 to-emerald-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(52_211_153/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(5_150_105/0.2))] text-[color:color-mix(in_oklab,rgb(236_253_245)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_44_34))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(110_231_183)_calc(var(--pmd-scheme-dark,1)*100%),rgb(4_120_87))]',\n tip:\n 'bg-linear-to-r from-violet-500/10 to-violet-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(167_139_250/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(124_58_237/0.2))] text-[color:color-mix(in_oklab,rgb(245_243_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(46_16_101))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(196_181_253)_calc(var(--pmd-scheme-dark,1)*100%),rgb(109_40_217))]',\n warning:\n 'bg-linear-to-r from-amber-500/10 to-amber-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(251_191_36/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(217_119_6/0.2))] text-[color:color-mix(in_oklab,rgb(255_251_235)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_26_3))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_211_77)_calc(var(--pmd-scheme-dark,1)*100%),rgb(146_64_14))]',\n}\n\nfunction isCalloutVariant(value: unknown): value is CalloutVariant {\n return typeof value === 'string' && CALLOUT_VARIANTS.includes(value as CalloutVariant)\n}\n\nexport function resolveCalloutVariant(node: ContainerDirective): CalloutVariant {\n const variant = node.attributes?.variant\n\n return isCalloutVariant(variant) ? variant : 'note'\n}\n\nfunction getTitle(node: ContainerDirective): string | undefined {\n return getDirectiveLabelOrAttribute(node, 'title')\n}\n\nexport const calloutDirective = defineDirective({\n name: 'callout',\n allowedAttributes: ['icon', ...PALETTE_ATTRIBUTES, 'theme', 'title', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note'\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n // A callout shows one icon; it may carry its own palette (`@pack/name palette=x`).\n const [iconEntry] = parseIconEntries(\n typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined,\n ).entries\n const icon = iconEntry?.ref\n const theme = resolveDirectiveTheme(\n 'callout',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft',\n config.themes,\n )\n const children = node.children\n // An icon without a title sits beside the body instead of on its own row.\n const iconBesideBody = Boolean(icon && !title)\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n iconBesideBody ? 'flex items-start gap-3' : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note'],\n )\n\n applyDirectivePalette(node, config)\n\n node.children = [\n ...(title || icon\n ? [\n {\n type: 'element' as const,\n children: [\n ...(icon\n ? [\n makeDirectiveIconPlaceholder(\n icon,\n [\n 'pmd-callout__icon inline-flex size-4 shrink-0 text-current',\n iconBesideBody ? 'mt-1.5' : 'mt-0.5',\n ],\n resolveIconPaletteName(node, iconEntry),\n ),\n ]\n : []),\n ...(title ? [{ type: 'text' as const, value: title }] : []),\n ],\n properties: {\n className: [\n iconBesideBody\n ? 'not-prose flex shrink-0'\n : 'not-prose mb-2 flex items-start gap-2 text-sm font-semibold tracking-wide',\n ],\n dataDirectiveTitle: 'callout',\n },\n tagName: 'div',\n },\n ]\n : []),\n {\n type: 'element',\n children,\n properties: {\n className: [DIRECTIVE_BODY_CLASS, iconBesideBody ? 'min-w-0 flex-1' : ''].filter(Boolean),\n dataDirectiveBody: 'callout',\n },\n tagName: 'div',\n },\n ]\n },\n attributeTypes: {\n icon: { type: 'icon' },\n iconPalette: { type: 'palette' },\n palette: { type: 'palette' },\n variant: { type: 'enum', values: CALLOUT_VARIANTS },\n },\n container: {\n labelAttribute: 'title',\n },\n defaultAttributes: {\n variant: 'note',\n },\n description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',\n editor: {\n detail: 'Static directive',\n label: 'Callout',\n snippet: ':::callout[${Title}]{\\n variant=\"${note}\"\\n}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'callout',\n dataIcon: typeof node.attributes?.icon === 'string' ? node.attributes.icon : undefined,\n ...getPaletteRenderProperties(node),\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',\n dataTitle: getTitle(node),\n dataVariant: resolveCalloutVariant(node),\n }\n },\n kind: 'callout',\n public: true,\n sanitize: {\n div: ['dataDirective', 'dataIcon', 'dataIconPalette', 'dataPalette', 'dataTheme', 'dataTitle', 'dataVariant'],\n },\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'callout',\n },\n // `theme` picks the surface and `variant` the colour; a variant name given\n // as the theme is a common mix-up. It still falls back like any unknown theme.\n unknownThemeHint(attribute, value) {\n return attribute === 'theme' && isCalloutVariant(value)\n ? `\"${value}\" is a callout variant; use variant=\"${value}\".`\n : undefined\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant))\n warnings.push(\n `Unsupported callout variant \"${attributes.variant}\". Falling back to \"note\".`,\n )\n\n return warnings\n },\n})\n"],"names":["parseIconEntries","DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","applyDirectivePalette","getPaletteRenderProperties","PALETTE_ATTRIBUTES","resolveIconPaletteName","resolveDirectiveTheme","defineDirective","CALLOUT_VARIANTS","calloutVariantClasses","danger","info","note","success","tip","warning","isCalloutVariant","value","includes","resolveCalloutVariant","node","variant","attributes","getTitle","calloutDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataVariant","title","dataTitle","undefined","iconEntry","dataIcon","entries","icon","ref","theme","dataTheme","themes","children","iconBesideBody","Boolean","className","hookClassName","modifierClassName","classes","type","dataDirectiveTitle","tagName","filter","dataDirectiveBody","attributeTypes","iconPalette","palette","values","container","labelAttribute","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","public","sanitize","div","supportsAttributes","themeAttributes","unknownThemeHint","attribute","validateAttributes","warnings","push"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,yBAAwB;AACzD,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,eAAe,QAAQ,cAAa;AAE7C,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,wDAAwD;AACxD,MAAMC,wBAAwD;IAC5DC,QACE;IACFC,MACE;IACFC,MACE;IACFC,S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