@sentropic/design-system-svelte 0.36.0 → 0.37.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 (60) hide show
  1. package/LICENSE.THIRD-PARTY.md +74 -1
  2. package/dist/DiagramCard.svelte +282 -0
  3. package/dist/DiagramCard.svelte.d.ts +44 -0
  4. package/dist/DiagramCard.svelte.d.ts.map +1 -0
  5. package/dist/DiagramCardHeader.svelte +173 -0
  6. package/dist/DiagramCardHeader.svelte.d.ts +37 -0
  7. package/dist/DiagramCardHeader.svelte.d.ts.map +1 -0
  8. package/dist/DiagramZone.svelte +378 -0
  9. package/dist/DiagramZone.svelte.d.ts +45 -0
  10. package/dist/DiagramZone.svelte.d.ts.map +1 -0
  11. package/dist/DiagramZoneHeader.svelte +97 -0
  12. package/dist/DiagramZoneHeader.svelte.d.ts +40 -0
  13. package/dist/DiagramZoneHeader.svelte.d.ts.map +1 -0
  14. package/dist/Pagination.svelte +5 -0
  15. package/dist/diagram-icons/DiagramIcon.svelte +65 -0
  16. package/dist/diagram-icons/DiagramIcon.svelte.d.ts +11 -0
  17. package/dist/diagram-icons/DiagramIcon.svelte.d.ts.map +1 -0
  18. package/dist/diagram-icons/PROVENANCE.md +72 -0
  19. package/dist/diagram-icons/index.d.ts +6 -0
  20. package/dist/diagram-icons/index.d.ts.map +1 -0
  21. package/dist/diagram-icons/index.js +4 -0
  22. package/dist/diagram-icons/registry.d.ts +52 -0
  23. package/dist/diagram-icons/registry.d.ts.map +1 -0
  24. package/dist/diagram-icons/registry.js +79 -0
  25. package/dist/diagram-render/index.d.ts +17 -0
  26. package/dist/diagram-render/index.d.ts.map +1 -0
  27. package/dist/diagram-render/index.js +11 -0
  28. package/dist/diagram-render/renderCardSvg.d.ts +83 -0
  29. package/dist/diagram-render/renderCardSvg.d.ts.map +1 -0
  30. package/dist/diagram-render/renderCardSvg.js +149 -0
  31. package/dist/diagram-render/renderZoneSvg.d.ts +88 -0
  32. package/dist/diagram-render/renderZoneSvg.d.ts.map +1 -0
  33. package/dist/diagram-render/renderZoneSvg.js +184 -0
  34. package/dist/diagramCardModel.d.ts +582 -0
  35. package/dist/diagramCardModel.d.ts.map +1 -0
  36. package/dist/diagramCardModel.js +1133 -0
  37. package/dist/index.d.ts +5 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -0
  40. package/dist/presence-badge/LockPresenceBadge.svelte +490 -0
  41. package/dist/presence-badge/LockPresenceBadge.svelte.d.ts +18 -0
  42. package/dist/presence-badge/LockPresenceBadge.svelte.d.ts.map +1 -0
  43. package/dist/presence-badge/index.d.ts +6 -0
  44. package/dist/presence-badge/index.d.ts.map +1 -0
  45. package/dist/presence-badge/index.js +3 -0
  46. package/dist/rich-text-editor/ComposerEditor.svelte +485 -0
  47. package/dist/rich-text-editor/ComposerEditor.svelte.d.ts +16 -0
  48. package/dist/rich-text-editor/ComposerEditor.svelte.d.ts.map +1 -0
  49. package/dist/rich-text-editor/RichTextEditor.svelte +557 -0
  50. package/dist/rich-text-editor/RichTextEditor.svelte.d.ts +45 -0
  51. package/dist/rich-text-editor/RichTextEditor.svelte.d.ts.map +1 -0
  52. package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts +8 -0
  53. package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts.map +1 -0
  54. package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts +13 -0
  55. package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts.map +1 -0
  56. package/dist/rich-text-editor/index.d.ts +10 -0
  57. package/dist/rich-text-editor/index.d.ts.map +1 -0
  58. package/dist/rich-text-editor/index.js +4 -0
  59. package/dist/rich-text-editor/rich-text-editor.css +115 -0
  60. package/package.json +54 -7
@@ -0,0 +1,184 @@
1
+ /**
2
+ * `renderZoneSvg` — pure wrapping-card (zone) SVG renderer (DC-2 static
3
+ * half, spec §6).
4
+ *
5
+ * Plain TypeScript, no Svelte import. Ships on the
6
+ * `@sentropic/design-system-svelte/diagram-render` subpath next to
7
+ * `renderCardSvg`. Both renderers consume the same geometry source
8
+ * (`../diagramCardModel.js`): collapsed, the zone IS the atomic card
9
+ * (§6.2 — the card content is emitted inside a translated `<g>`); expanded,
10
+ * the frame carries the shared header, the header rule and the children.
11
+ *
12
+ * No hack from the hrpn FOLDED-CARD-HACKS list survives here: no
13
+ * `diagram-card-box` rect, no regex surgery on rendered output, no
14
+ * `foreignObject` toggle, no title pre-fitting (`FOLD_TITLE`), no
15
+ * function/detail re-roling (DH-08), no tint injection — the toggle is the
16
+ * same slot glyph as the card's and the subtitle is one body string.
17
+ */
18
+ import { CARD_GEOMETRY, ZONE_GEOMETRY, defaultCardMeasure, firstOverflowDiagnostic, layoutZone, projectZoneProps, zoneCollapsedCardProps, } from "../diagramCardModel.js";
19
+ import { getDiagramGlyph } from "../diagram-icons/registry.js";
20
+ import { iconGroupFor, renderCardContent, toggleGlyph } from "./renderCardSvg.js";
21
+ export { projectZoneProps };
22
+ function escapeXml(value) {
23
+ return String(value)
24
+ .replaceAll("&", "&amp;")
25
+ .replaceAll("<", "&lt;")
26
+ .replaceAll(">", "&gt;")
27
+ .replaceAll('"', "&quot;");
28
+ }
29
+ const FONT_STACK = "var(--st-font-sans, system-ui, sans-serif)";
30
+ function textLines(lines, className, fill, extra) {
31
+ return lines
32
+ .map((line) => `<text class="${className}" x="${line.x}" y="${line.baseline}" text-anchor="${line.anchor === "middle" ? "middle" : "start"}" font-size="${line.size}" font-weight="${line.weight}" fill="${fill}"${extra}>${escapeXml(line.text)}</text>`)
33
+ .join("");
34
+ }
35
+ function childContent(child, measure) {
36
+ if (child.kind === "card") {
37
+ if (child.card === undefined)
38
+ throw new Error("fixture-error: card child without card props");
39
+ // The child's own diagnostics are kept with the child's entity id (and
40
+ // its original slot text): an overflowing child is aggregated by the
41
+ // zone, not silently dropped.
42
+ const { content, layout } = renderCardContent(child.card, measure);
43
+ const diagnostics = layout.diagnostics.map((diagnostic) => ({
44
+ code: diagnostic.code,
45
+ slot: diagnostic.slot,
46
+ entityId: diagnostic.entityId,
47
+ neededPx: diagnostic.neededPx,
48
+ allocatedPx: diagnostic.allocatedPx,
49
+ ...(diagnostic.text === undefined ? {} : { text: diagnostic.text }),
50
+ }));
51
+ return { content, diagnostics };
52
+ }
53
+ if (child.zone === undefined)
54
+ throw new Error("fixture-error: zone child without zone props");
55
+ const rendered = zoneContent(child.zone, child.children ?? [], measure);
56
+ return { content: rendered.content, diagnostics: rendered.diagnostics };
57
+ }
58
+ /**
59
+ * Zone-local content (no outer `<svg>`): collapsed, the translated card
60
+ * content; expanded, frame + header + rule + children. Coordinates are
61
+ * zone-local (the caller wraps in `translate(x y)`). The returned
62
+ * `diagnostics` aggregate the zone's own diagnostics with every descendant
63
+ * card/zone diagnostic, each keeping its own `entityId` and original slot
64
+ * text — a nested overflow is never lost inside a zone.
65
+ */
66
+ export function zoneContent(props, children, measure) {
67
+ const g = ZONE_GEOMETRY;
68
+ const layout = layoutZone(props, measure, children);
69
+ const x = layout.box.x;
70
+ const y = layout.box.y;
71
+ const parts = [];
72
+ const descendantDiagnostics = [];
73
+ if (layout.collapsed) {
74
+ const cardProps = zoneCollapsedCardProps(props);
75
+ const { content } = renderCardContent(cardProps, measure);
76
+ parts.push(content);
77
+ return { content: parts.join(""), layout, diagnostics: layout.diagnostics };
78
+ }
79
+ const header = layout.header;
80
+ if (header === undefined)
81
+ throw new Error("fixture-error: expanded zone without header layout");
82
+ const width = layout.box.width;
83
+ const height = layout.box.height;
84
+ // Frame (expanded only; collapsed is the card border, §6.4).
85
+ // A proposed zone is always drawn dashed, independently of the tint
86
+ // (owner criterion 5); the dash pattern is the kit's `4 5`.
87
+ parts.push(`<rect class="st-diagramZone-frame" x="0" y="0" width="${width}" height="${height}" rx="${g.radius}" fill="var(--st-component-diagramZone-surface, var(--st-semantic-surface-raised))" stroke="var(--st-component-diagramZone-border, var(--st-semantic-border-strong))" stroke-width="${g.borderWidth}"${props.proposed === true ? ` stroke-dasharray="var(--st-component-diagramZone-proposedDashArray, 4 5)"` : ""}/>`);
88
+ if (header.iconBox !== undefined && props.icon !== undefined) {
89
+ parts.push(iconGroupFor(props.icon, props.iconGlyph, header.iconBox.x - x, header.iconBox.y - y, header.iconBox.size));
90
+ }
91
+ if (header.kicker.length > 0) {
92
+ parts.push(textLines(header.kicker.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-kicker", "var(--st-component-diagramZone-secondaryText, var(--st-semantic-text-secondary))", ` letter-spacing="0.04em" style="text-transform:uppercase"`));
93
+ }
94
+ if (header.title.length > 0) {
95
+ parts.push(textLines(header.title.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-title", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
96
+ }
97
+ if (header.subtitle.length > 0) {
98
+ parts.push(textLines(header.subtitle.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-subtitle", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
99
+ }
100
+ // Header rule: same rule as the card footer rule (1 px, border-subtle,
101
+ // same insets), 4 px under the subtitle or the header block (§6.2).
102
+ parts.push(`<line class="st-diagramZone-rule" x1="${g.ruleInsetStart}" x2="${width - g.ruleInsetEnd}" y1="${header.ruleY - y}" y2="${header.ruleY - y}" stroke="var(--st-component-diagramZone-rule, var(--st-semantic-border-subtle))" stroke-width="${g.ruleHeight}" vector-effect="non-scaling-stroke"/>`);
103
+ if (header.toggleBox !== undefined && props.toggleLabel !== undefined) {
104
+ parts.push(toggleGlyph({ collapsed: false, label: props.toggleLabel }, { x: header.toggleBox.x - x, y: header.toggleBox.y - y, size: header.toggleBox.size }));
105
+ }
106
+ // Expanded footer (§6.1: folding never changes the footer) — the same
107
+ // pinned block as the collapsed card, with its own rule above it.
108
+ if (header.footer.length > 0) {
109
+ if (header.footerRuleY !== undefined) {
110
+ parts.push(`<line class="st-diagramZone-footerRule" x1="${g.ruleInsetStart}" x2="${width - g.ruleInsetEnd}" y1="${header.footerRuleY - y}" y2="${header.footerRuleY - y}" stroke="var(--st-component-diagramZone-rule, var(--st-semantic-border-subtle))" stroke-width="${g.ruleHeight}" vector-effect="non-scaling-stroke"/>`);
111
+ }
112
+ parts.push(textLines(header.footer.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-footer", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
113
+ }
114
+ for (const child of children) {
115
+ const rendered = childContent(child, measure);
116
+ descendantDiagnostics.push(...rendered.diagnostics);
117
+ parts.push(`<g class="st-diagramZone-child" data-child-kind="${child.kind}" transform="translate(${child.x - x} ${child.y - y})">${rendered.content}</g>`);
118
+ }
119
+ return {
120
+ content: parts.join(""),
121
+ layout,
122
+ diagnostics: [...layout.diagnostics, ...descendantDiagnostics],
123
+ };
124
+ }
125
+ /**
126
+ * Render one zone as a standalone SVG string. Collapsed: the atomic card
127
+ * at the zone occurrence (460 × 200, plus the "+" toggle slot). Expanded:
128
+ * the frame with header, rule and children. `measure` defaults to the
129
+ * deterministic greedy wrapper. Returns a refused result (no `svg`) when
130
+ * the zone or any descendant overflows; descendant diagnostics are
131
+ * aggregated with their entity ids.
132
+ */
133
+ export function renderZoneSvg(props, opts = {}) {
134
+ const measure = opts.measure ?? defaultCardMeasure;
135
+ const children = opts.children ?? [];
136
+ const { content, layout, diagnostics } = zoneContent(props, children, measure);
137
+ if (firstOverflowDiagnostic(diagnostics) !== undefined) {
138
+ return { kind: "refused", diagnostics, layout };
139
+ }
140
+ const { x, y, width, height } = layout.box;
141
+ const overflowSlots = diagnostics
142
+ .filter((diagnostic) => diagnostic.code === "zone-overflow")
143
+ .map((diagnostic) => diagnostic.slot);
144
+ const unknownIcon = diagnostics.some((diagnostic) => diagnostic.code === "zone-icon-unknown");
145
+ const firstOverflow = overflowSlots.length === 0 ? undefined : overflowSlots[0];
146
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" class="st-diagramZoneSvg" width="${x + width}" height="${y + height}" viewBox="0 0 ${x + width} ${y + height}" role="img" aria-label="${escapeXml(props.title)}" style="font-family:${FONT_STACK}">` +
147
+ `<title>${escapeXml(props.title)}</title>` +
148
+ `<g class="st-diagramZone${layout.collapsed ? " st-diagramZone--collapsed" : " st-diagramZone--expanded"}" data-entity="${escapeXml(props.entityId)}" data-collapsed="${layout.collapsed ? "true" : "false"}"${props.tone === undefined ? "" : ` data-tone="${escapeXml(props.tone)}"`}${props.proposed === true ? ' data-proposed="true"' : ""}${firstOverflow === undefined ? "" : ` data-zone-overflow="${firstOverflow}"`}${unknownIcon ? ` data-zone-icon-unknown=""` : ""} transform="translate(${x} ${y})">` +
149
+ content +
150
+ `</g>` +
151
+ `</svg>`;
152
+ return { kind: "rendered", svg, diagnostics, layout };
153
+ }
154
+ /**
155
+ * Convenience: project an `EntityPresentation` then render the zone.
156
+ * Returns `{ kind: "label" }` when the view carries no zone presentation
157
+ * for the entity (L-R12), and `{ kind: "zone", result }` otherwise, where
158
+ * `result` is the refused or rendered `ZoneSvgResult`.
159
+ */
160
+ export function renderZoneSvgFromPresentation(presentation, opts) {
161
+ const resolved = projectZoneProps(presentation, {
162
+ entityId: opts.entityId,
163
+ collapsed: opts.collapsed,
164
+ ...(opts.toggleLabel === undefined ? {} : { toggleLabel: opts.toggleLabel }),
165
+ ...(opts.align === undefined ? {} : { align: opts.align }),
166
+ ...(opts.x === undefined ? {} : { x: opts.x }),
167
+ ...(opts.y === undefined ? {} : { y: opts.y }),
168
+ ...(opts.width === undefined ? {} : { width: opts.width }),
169
+ ...(opts.height === undefined ? {} : { height: opts.height }),
170
+ resolveGlyph: getDiagramGlyph,
171
+ });
172
+ if (resolved.kind !== "zone")
173
+ return { kind: "label" };
174
+ return {
175
+ kind: "zone",
176
+ result: renderZoneSvg(resolved.props, {
177
+ children: opts.children,
178
+ measure: opts.measure,
179
+ }),
180
+ };
181
+ }
182
+ // Re-exported for the zone parity corpus: the card geometry the collapsed
183
+ // zone reuses (DC-D13 — no second size).
184
+ export { CARD_GEOMETRY };