@sentropic/design-system-svelte 0.35.1 → 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.
- package/LICENSE.THIRD-PARTY.md +74 -1
- package/dist/Calendar.svelte +28 -1
- package/dist/Calendar.svelte.d.ts +7 -0
- package/dist/Calendar.svelte.d.ts.map +1 -1
- package/dist/ContentSwitcher.svelte +6 -1
- package/dist/DiagramCard.svelte +282 -0
- package/dist/DiagramCard.svelte.d.ts +44 -0
- package/dist/DiagramCard.svelte.d.ts.map +1 -0
- package/dist/DiagramCardHeader.svelte +173 -0
- package/dist/DiagramCardHeader.svelte.d.ts +37 -0
- package/dist/DiagramCardHeader.svelte.d.ts.map +1 -0
- package/dist/DiagramZone.svelte +378 -0
- package/dist/DiagramZone.svelte.d.ts +45 -0
- package/dist/DiagramZone.svelte.d.ts.map +1 -0
- package/dist/DiagramZoneHeader.svelte +97 -0
- package/dist/DiagramZoneHeader.svelte.d.ts +40 -0
- package/dist/DiagramZoneHeader.svelte.d.ts.map +1 -0
- package/dist/MenuPopover.svelte +101 -12
- package/dist/MenuPopover.svelte.d.ts.map +1 -1
- package/dist/Pagination.svelte +5 -0
- package/dist/RadioGroup.svelte +4 -1
- package/dist/TimeRangePicker.svelte +19 -1
- package/dist/TimeRangePicker.svelte.d.ts.map +1 -1
- package/dist/diagram-icons/DiagramIcon.svelte +65 -0
- package/dist/diagram-icons/DiagramIcon.svelte.d.ts +11 -0
- package/dist/diagram-icons/DiagramIcon.svelte.d.ts.map +1 -0
- package/dist/diagram-icons/PROVENANCE.md +72 -0
- package/dist/diagram-icons/index.d.ts +6 -0
- package/dist/diagram-icons/index.d.ts.map +1 -0
- package/dist/diagram-icons/index.js +4 -0
- package/dist/diagram-icons/registry.d.ts +52 -0
- package/dist/diagram-icons/registry.d.ts.map +1 -0
- package/dist/diagram-icons/registry.js +79 -0
- package/dist/diagram-render/index.d.ts +17 -0
- package/dist/diagram-render/index.d.ts.map +1 -0
- package/dist/diagram-render/index.js +11 -0
- package/dist/diagram-render/renderCardSvg.d.ts +83 -0
- package/dist/diagram-render/renderCardSvg.d.ts.map +1 -0
- package/dist/diagram-render/renderCardSvg.js +149 -0
- package/dist/diagram-render/renderZoneSvg.d.ts +88 -0
- package/dist/diagram-render/renderZoneSvg.d.ts.map +1 -0
- package/dist/diagram-render/renderZoneSvg.js +184 -0
- package/dist/diagramCardModel.d.ts +582 -0
- package/dist/diagramCardModel.d.ts.map +1 -0
- package/dist/diagramCardModel.js +1133 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/presence-badge/LockPresenceBadge.svelte +490 -0
- package/dist/presence-badge/LockPresenceBadge.svelte.d.ts +18 -0
- package/dist/presence-badge/LockPresenceBadge.svelte.d.ts.map +1 -0
- package/dist/presence-badge/index.d.ts +6 -0
- package/dist/presence-badge/index.d.ts.map +1 -0
- package/dist/presence-badge/index.js +3 -0
- package/dist/rich-text-editor/ComposerEditor.svelte +485 -0
- package/dist/rich-text-editor/ComposerEditor.svelte.d.ts +16 -0
- package/dist/rich-text-editor/ComposerEditor.svelte.d.ts.map +1 -0
- package/dist/rich-text-editor/RichTextEditor.svelte +557 -0
- package/dist/rich-text-editor/RichTextEditor.svelte.d.ts +45 -0
- package/dist/rich-text-editor/RichTextEditor.svelte.d.ts.map +1 -0
- package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts +8 -0
- package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts.map +1 -0
- package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts +13 -0
- package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts.map +1 -0
- package/dist/rich-text-editor/index.d.ts +10 -0
- package/dist/rich-text-editor/index.d.ts.map +1 -0
- package/dist/rich-text-editor/index.js +4 -0
- package/dist/rich-text-editor/rich-text-editor.css +115 -0
- package/package.json +54 -7
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagramCard shared model — geometry, projection and line layout (DC-1).
|
|
3
|
+
*
|
|
4
|
+
* Pure TypeScript, zero imports: the Svelte `DiagramCard` (barrel graph)
|
|
5
|
+
* and the `diagram-render` pure renderer (subpath graph) both consume this
|
|
6
|
+
* module, so it must live outside both subpath directories and import
|
|
7
|
+
* nothing. Glyph path data arrives via props (resolved by the caller from
|
|
8
|
+
* the `diagram-icons` subpath); this module never resolves a glyph name.
|
|
9
|
+
*
|
|
10
|
+
* One geometry source (§5.6): every number below is frozen by
|
|
11
|
+
* spec/SPEC_EVOL_DS_DIAGRAM_CARDS.md §5.3/Appendix A and mirrors
|
|
12
|
+
* - the `diagramCard` component tokens (`packages/tokens/src/component.ts`),
|
|
13
|
+
* - `packages/diagram-canvas/src/layout/measure.ts`
|
|
14
|
+
* (`FIXED_CARD_WIDTH 460`, `FIXED_CARD_HEIGHT 200`,
|
|
15
|
+
* `TOGGLE_ALLOCATION 66`, `CONTENT_INSET 16`, `RULE_GAP 4`).
|
|
16
|
+
* The token↔constant agreement test asserts the sources agree.
|
|
17
|
+
*
|
|
18
|
+
* Line boxes use the kit's 1/64 px grid (`floor(size * 1.3 * 64) / 64`,
|
|
19
|
+
* cf. `frameHeaderContent`): with those boxes the frozen content sums
|
|
20
|
+
* exactly — footer text-box bottom at `198 − 9.25`, rule gaps 4/4 — instead
|
|
21
|
+
* of drifting by fractional pixels (DIF-04). Text baselines follow the
|
|
22
|
+
* kit's glyph bounds: a 24 px role sits 22 px above its baseline, the
|
|
23
|
+
* 22 px kicker and the 32 px title at their own size (cf. the frozen SVG:
|
|
24
|
+
* kicker baseline `headerY + 16 + 22`, title `+ 32`, subtitle `+ 22`).
|
|
25
|
+
*/
|
|
26
|
+
/** Frozen card geometry, in card pixels (spec §5.3, Appendix A). */
|
|
27
|
+
export const CARD_GEOMETRY = {
|
|
28
|
+
width: 460,
|
|
29
|
+
height: 200,
|
|
30
|
+
borderWidth: 2,
|
|
31
|
+
accentWidth: 8,
|
|
32
|
+
padding: 8,
|
|
33
|
+
/** Card left edge → header icon left edge (accent 8 + padding 8). */
|
|
34
|
+
headerInset: 16,
|
|
35
|
+
iconSize: 70,
|
|
36
|
+
iconTextGap: 6,
|
|
37
|
+
kicker: { size: 22, weight: 400, lineHeight: 1.3, letterSpacingEm: 0.04 },
|
|
38
|
+
title: { size: 32, weight: 700, lineHeight: 1.3 },
|
|
39
|
+
/** Header row → body block. */
|
|
40
|
+
gap: 6,
|
|
41
|
+
body: { size: 24, weight: 400, lineHeight: 1.3 },
|
|
42
|
+
/** Accent-bar left edge → first body glyph. */
|
|
43
|
+
bodyInsetFromBar: 14,
|
|
44
|
+
ruleHeight: 1,
|
|
45
|
+
ruleMargin: 4,
|
|
46
|
+
ruleInsetStart: 16,
|
|
47
|
+
ruleInsetEnd: 10,
|
|
48
|
+
footer: { size: 24, weight: 700, lineHeight: 1.3 },
|
|
49
|
+
/** Footer text-box bottom → inner edge of the bottom border. */
|
|
50
|
+
footerBottomInset: 9.25,
|
|
51
|
+
/**
|
|
52
|
+
* Title/kicker width reservation when the toggle slot is present
|
|
53
|
+
* (hrpn tints.css `header { padding-right: 66px }`: the 66 px the +/−
|
|
54
|
+
* control needs in the header's inline-end).
|
|
55
|
+
*/
|
|
56
|
+
toggleAllocation: 66,
|
|
57
|
+
/** The toggle slot box itself: the 32 px DS IconButton (sm) square. */
|
|
58
|
+
toggleBoxSize: 32,
|
|
59
|
+
/**
|
|
60
|
+
* Header text width of a folded card (toggle present, icon present):
|
|
61
|
+
* the owner-pinned 290 px — the hrpn folded-card title width
|
|
62
|
+
* (356 − 66 = 290). Plain cards keep `contentRight − headerTextX`
|
|
63
|
+
* (358 px with the icon).
|
|
64
|
+
*/
|
|
65
|
+
foldedHeaderTextWidth: 290,
|
|
66
|
+
/** Card allocations, frozen-box-derived (see module doc). */
|
|
67
|
+
allocatedLines: { kicker: 1, title: 2, body: 2, footer: 1 },
|
|
68
|
+
};
|
|
69
|
+
/** Line box height for a size at 1.3, on the 1/64 px grid. */
|
|
70
|
+
export function lineBoxHeight(size) {
|
|
71
|
+
return Math.floor(size * 1.3 * 64) / 64;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Alphabetic baseline inside a line box starting at `top`, per the kit's
|
|
75
|
+
* glyph bounds: 24 px roles (body/subtitle/footer) sit 22 px above the
|
|
76
|
+
* baseline; the 22 px kicker and the 32 px title at their own size.
|
|
77
|
+
*/
|
|
78
|
+
export function baselineOf(top, size) {
|
|
79
|
+
return top + (size === 24 ? 22 : size);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Shared `EntityPresentation` → props projection (§4.2), consumed by both
|
|
83
|
+
* renderers. A missing presentation entry (or a non-card form, or no title)
|
|
84
|
+
* resolves to `{ kind: "label" }`: the host renders a simple label node and
|
|
85
|
+
* no card (L-R12). The glyph name maps through the injected resolver, which
|
|
86
|
+
* the `diagram-render` subpath wires to the icon registry; a name with no
|
|
87
|
+
* record yields no glyph and the layout raises `card-icon-unknown`.
|
|
88
|
+
*/
|
|
89
|
+
export function projectCardProps(presentation, opts) {
|
|
90
|
+
if (presentation === undefined || presentation.form !== "card")
|
|
91
|
+
return { kind: "label" };
|
|
92
|
+
const title = presentation.text.title ?? "";
|
|
93
|
+
if (title === "")
|
|
94
|
+
return { kind: "label" };
|
|
95
|
+
const bodyLines = [];
|
|
96
|
+
if (presentation.text.body !== undefined && presentation.text.body !== "") {
|
|
97
|
+
bodyLines.push(presentation.text.body);
|
|
98
|
+
}
|
|
99
|
+
let detailCount = 0;
|
|
100
|
+
if (presentation.text.detail !== undefined && presentation.text.detail !== "") {
|
|
101
|
+
bodyLines.push(presentation.text.detail);
|
|
102
|
+
detailCount = 1;
|
|
103
|
+
}
|
|
104
|
+
const icon = presentation.icon;
|
|
105
|
+
return {
|
|
106
|
+
kind: "card",
|
|
107
|
+
props: {
|
|
108
|
+
entityId: opts.entityId,
|
|
109
|
+
...(presentation.text.kicker === undefined || presentation.text.kicker === ""
|
|
110
|
+
? {}
|
|
111
|
+
: { kicker: presentation.text.kicker }),
|
|
112
|
+
title,
|
|
113
|
+
body: bodyLines,
|
|
114
|
+
...(detailCount === 0 ? {} : { detailCount }),
|
|
115
|
+
...(presentation.text.footer === undefined || presentation.text.footer === ""
|
|
116
|
+
? {}
|
|
117
|
+
: { footer: presentation.text.footer }),
|
|
118
|
+
...(icon === undefined ? {} : { icon }),
|
|
119
|
+
...(icon === undefined || opts.resolveGlyph === undefined
|
|
120
|
+
? {}
|
|
121
|
+
: (() => {
|
|
122
|
+
const glyph = opts.resolveGlyph(icon);
|
|
123
|
+
return glyph === undefined ? {} : { iconGlyph: glyph };
|
|
124
|
+
})()),
|
|
125
|
+
...(presentation.categoryRef === undefined ? {} : { tone: presentation.categoryRef }),
|
|
126
|
+
...(presentation.proposed === undefined ? {} : { proposed: presentation.proposed }),
|
|
127
|
+
...(opts.toggle === undefined ? {} : { toggle: opts.toggle }),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Pinned per-character advances at 1 px (data, not code).
|
|
133
|
+
*
|
|
134
|
+
* Source: the pinned kit 'governance-font-metrics.js' (browser-measured
|
|
135
|
+
* Inter 400 advances for body/kicker, Dossier Inter 700 advances for
|
|
136
|
+
* title/footer — the same tables the reference layout wraps against).
|
|
137
|
+
* The DS default measurer consumes them so static strings wrap exactly
|
|
138
|
+
* where the reference wraps; production hosts inject their measured
|
|
139
|
+
* LineMeasurer (Inter-stack advances) instead. Measurer version:
|
|
140
|
+
* 'pinned-kit-1px'. Missing glyphs fall back to 0.7 em (the kit's
|
|
141
|
+
* unknown-glyph advance).
|
|
142
|
+
*/
|
|
143
|
+
const CARD_ADVANCES_TITLE = {
|
|
144
|
+
"0": 0.67,
|
|
145
|
+
"1": 0.43,
|
|
146
|
+
"2": 0.63,
|
|
147
|
+
"3": 0.65,
|
|
148
|
+
"4": 0.68,
|
|
149
|
+
"5": 0.62,
|
|
150
|
+
"6": 0.65,
|
|
151
|
+
"7": 0.58,
|
|
152
|
+
"8": 0.65,
|
|
153
|
+
"9": 0.65,
|
|
154
|
+
"\n": 0.24,
|
|
155
|
+
" ": 0.24,
|
|
156
|
+
"\"": 0.55,
|
|
157
|
+
"#": 0.65,
|
|
158
|
+
"%": 1.02,
|
|
159
|
+
"&": 0.67,
|
|
160
|
+
"'": 0.34,
|
|
161
|
+
"(": 0.38,
|
|
162
|
+
")": 0.38,
|
|
163
|
+
"*": 0.56,
|
|
164
|
+
"+": 0.68,
|
|
165
|
+
",": 0.33,
|
|
166
|
+
"-": 0.47,
|
|
167
|
+
".": 0.33,
|
|
168
|
+
"/": 0.39,
|
|
169
|
+
":": 0.33,
|
|
170
|
+
";": 0.34,
|
|
171
|
+
"<": 0.68,
|
|
172
|
+
"=": 0.68,
|
|
173
|
+
">": 0.68,
|
|
174
|
+
"@": 1.02,
|
|
175
|
+
"A": 0.75,
|
|
176
|
+
"B": 0.66,
|
|
177
|
+
"C": 0.74,
|
|
178
|
+
"D": 0.72,
|
|
179
|
+
"E": 0.61,
|
|
180
|
+
"F": 0.59,
|
|
181
|
+
"G": 0.75,
|
|
182
|
+
"H": 0.75,
|
|
183
|
+
"I": 0.28,
|
|
184
|
+
"J": 0.58,
|
|
185
|
+
"K": 0.72,
|
|
186
|
+
"L": 0.57,
|
|
187
|
+
"M": 0.93,
|
|
188
|
+
"N": 0.76,
|
|
189
|
+
"O": 0.77,
|
|
190
|
+
"P": 0.65,
|
|
191
|
+
"Q": 0.78,
|
|
192
|
+
"R": 0.66,
|
|
193
|
+
"S": 0.65,
|
|
194
|
+
"T": 0.67,
|
|
195
|
+
"U": 0.73,
|
|
196
|
+
"V": 0.75,
|
|
197
|
+
"W": 1.04,
|
|
198
|
+
"X": 0.74,
|
|
199
|
+
"Y": 0.73,
|
|
200
|
+
"Z": 0.66,
|
|
201
|
+
"[": 0.38,
|
|
202
|
+
"\\": 0.39,
|
|
203
|
+
"]": 0.38,
|
|
204
|
+
"_": 0.48,
|
|
205
|
+
"a": 0.58,
|
|
206
|
+
"b": 0.63,
|
|
207
|
+
"c": 0.59,
|
|
208
|
+
"d": 0.63,
|
|
209
|
+
"e": 0.6,
|
|
210
|
+
"f": 0.4,
|
|
211
|
+
"g": 0.63,
|
|
212
|
+
"h": 0.62,
|
|
213
|
+
"i": 0.27,
|
|
214
|
+
"j": 0.27,
|
|
215
|
+
"k": 0.58,
|
|
216
|
+
"l": 0.27,
|
|
217
|
+
"m": 0.91,
|
|
218
|
+
"n": 0.62,
|
|
219
|
+
"o": 0.61,
|
|
220
|
+
"p": 0.63,
|
|
221
|
+
"q": 0.63,
|
|
222
|
+
"r": 0.41,
|
|
223
|
+
"s": 0.56,
|
|
224
|
+
"t": 0.37,
|
|
225
|
+
"u": 0.62,
|
|
226
|
+
"v": 0.6,
|
|
227
|
+
"w": 0.85,
|
|
228
|
+
"x": 0.58,
|
|
229
|
+
"y": 0.6,
|
|
230
|
+
"z": 0.57,
|
|
231
|
+
"{": 0.47,
|
|
232
|
+
"}": 0.47,
|
|
233
|
+
"§": 0.57,
|
|
234
|
+
"«": 0.66,
|
|
235
|
+
"·": 0.33,
|
|
236
|
+
"»": 0.66,
|
|
237
|
+
"À": 0.75,
|
|
238
|
+
"Ç": 0.74,
|
|
239
|
+
"È": 0.61,
|
|
240
|
+
"É": 0.61,
|
|
241
|
+
"×": 0.68,
|
|
242
|
+
"à": 0.58,
|
|
243
|
+
"â": 0.58,
|
|
244
|
+
"ç": 0.59,
|
|
245
|
+
"è": 0.6,
|
|
246
|
+
"é": 0.6,
|
|
247
|
+
"ê": 0.6,
|
|
248
|
+
"î": 0.27,
|
|
249
|
+
"ô": 0.61,
|
|
250
|
+
"ù": 0.62,
|
|
251
|
+
"–": 0.5,
|
|
252
|
+
"’": 0.31,
|
|
253
|
+
"\u2026": 1,
|
|
254
|
+
"→": 1,
|
|
255
|
+
"↔": 1,
|
|
256
|
+
"≠": 0.83203,
|
|
257
|
+
"≥": 0.83203
|
|
258
|
+
};
|
|
259
|
+
const CARD_ADVANCES_BODY = {
|
|
260
|
+
"0": 0.59961,
|
|
261
|
+
"1": 0.59961,
|
|
262
|
+
"2": 0.59961,
|
|
263
|
+
"3": 0.59961,
|
|
264
|
+
"4": 0.59961,
|
|
265
|
+
"5": 0.59961,
|
|
266
|
+
"6": 0.59961,
|
|
267
|
+
"7": 0.59961,
|
|
268
|
+
"8": 0.59961,
|
|
269
|
+
"9": 0.59961,
|
|
270
|
+
"\n": 0.2998,
|
|
271
|
+
" ": 0.2998,
|
|
272
|
+
"\"": 0.45996,
|
|
273
|
+
"#": 0.59961,
|
|
274
|
+
"%": 0.69922,
|
|
275
|
+
"&": 0.67969,
|
|
276
|
+
"'": 0.2998,
|
|
277
|
+
"(": 0.2998,
|
|
278
|
+
")": 0.2998,
|
|
279
|
+
"*": 0.59961,
|
|
280
|
+
"+": 0.59961,
|
|
281
|
+
",": 0.2998,
|
|
282
|
+
"-": 0.2998,
|
|
283
|
+
".": 0.2998,
|
|
284
|
+
"/": 0.51953,
|
|
285
|
+
":": 0.2998,
|
|
286
|
+
";": 0.2998,
|
|
287
|
+
"<": 0.59961,
|
|
288
|
+
"=": 0.59961,
|
|
289
|
+
">": 0.59961,
|
|
290
|
+
"@": 0.7998,
|
|
291
|
+
"A": 0.55957,
|
|
292
|
+
"B": 0.61914,
|
|
293
|
+
"C": 0.61914,
|
|
294
|
+
"D": 0.65918,
|
|
295
|
+
"E": 0.55957,
|
|
296
|
+
"F": 0.47949,
|
|
297
|
+
"G": 0.65918,
|
|
298
|
+
"H": 0.65918,
|
|
299
|
+
"I": 0.25977,
|
|
300
|
+
"J": 0.39941,
|
|
301
|
+
"K": 0.61914,
|
|
302
|
+
"L": 0.5,
|
|
303
|
+
"M": 0.81934,
|
|
304
|
+
"N": 0.65918,
|
|
305
|
+
"O": 0.65918,
|
|
306
|
+
"P": 0.55957,
|
|
307
|
+
"Q": 0.65918,
|
|
308
|
+
"R": 0.61914,
|
|
309
|
+
"S": 0.61914,
|
|
310
|
+
"T": 0.5,
|
|
311
|
+
"U": 0.63965,
|
|
312
|
+
"V": 0.55957,
|
|
313
|
+
"W": 0.81934,
|
|
314
|
+
"X": 0.53906,
|
|
315
|
+
"Y": 0.55957,
|
|
316
|
+
"Z": 0.53906,
|
|
317
|
+
"[": 0.2998,
|
|
318
|
+
"\\": 0.51953,
|
|
319
|
+
"]": 0.2998,
|
|
320
|
+
"_": 0.5,
|
|
321
|
+
"a": 0.53906,
|
|
322
|
+
"b": 0.53906,
|
|
323
|
+
"c": 0.47949,
|
|
324
|
+
"d": 0.53906,
|
|
325
|
+
"e": 0.53906,
|
|
326
|
+
"f": 0.2998,
|
|
327
|
+
"g": 0.5,
|
|
328
|
+
"h": 0.53906,
|
|
329
|
+
"i": 0.23926,
|
|
330
|
+
"j": 0.21973,
|
|
331
|
+
"k": 0.5,
|
|
332
|
+
"l": 0.23926,
|
|
333
|
+
"m": 0.81934,
|
|
334
|
+
"n": 0.53906,
|
|
335
|
+
"o": 0.53906,
|
|
336
|
+
"p": 0.53906,
|
|
337
|
+
"q": 0.53906,
|
|
338
|
+
"r": 0.31934,
|
|
339
|
+
"s": 0.51953,
|
|
340
|
+
"t": 0.31934,
|
|
341
|
+
"u": 0.53906,
|
|
342
|
+
"v": 0.43945,
|
|
343
|
+
"w": 0.65918,
|
|
344
|
+
"x": 0.43945,
|
|
345
|
+
"y": 0.41992,
|
|
346
|
+
"z": 0.41992,
|
|
347
|
+
"{": 0.2998,
|
|
348
|
+
"}": 0.2998,
|
|
349
|
+
"§": 0.59961,
|
|
350
|
+
"«": 0.39941,
|
|
351
|
+
"·": 0.23926,
|
|
352
|
+
"»": 0.39941,
|
|
353
|
+
"À": 0.55957,
|
|
354
|
+
"Ç": 0.61914,
|
|
355
|
+
"È": 0.55957,
|
|
356
|
+
"É": 0.55957,
|
|
357
|
+
"×": 0.59961,
|
|
358
|
+
"à": 0.53906,
|
|
359
|
+
"â": 0.53906,
|
|
360
|
+
"ç": 0.47949,
|
|
361
|
+
"è": 0.53906,
|
|
362
|
+
"é": 0.53906,
|
|
363
|
+
"ê": 0.53906,
|
|
364
|
+
"î": 0.23926,
|
|
365
|
+
"ô": 0.53906,
|
|
366
|
+
"ù": 0.53906,
|
|
367
|
+
"–": 0.55566,
|
|
368
|
+
"’": 0.22168,
|
|
369
|
+
"\u2026": 1,
|
|
370
|
+
"→": 1,
|
|
371
|
+
"↔": 1,
|
|
372
|
+
"≠": 0.83203,
|
|
373
|
+
"≥": 0.83203
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* Deterministic greedy wrapper over the pinned per-character advances.
|
|
377
|
+
* Production hosts inject their measured ‘LineMeasurer’; tests and
|
|
378
|
+
* static strings use this. It mirrors the frozen reference measurer
|
|
379
|
+
* (`cardTextWidth`/`wrapText` of the pinned kit): every candidate line is
|
|
380
|
+
* measured as a whole — `sum(advance × size) + 2` px safety — with the
|
|
381
|
+
* unknown-glyph fallback at 0.7 em, and the kicker is uppercased and
|
|
382
|
+
* tracked at 0.04 em before lookup (the kicker renders uppercase with
|
|
383
|
+
* `letter-spacing: 0.04em`). Corpus fixtures wrap exactly where the
|
|
384
|
+
* reference wraps; overflow fixtures overflow under every metric.
|
|
385
|
+
*/
|
|
386
|
+
export function defaultCardMeasure(text, role, availableWidth) {
|
|
387
|
+
const size = role === "kicker"
|
|
388
|
+
? CARD_GEOMETRY.kicker.size
|
|
389
|
+
: role === "title"
|
|
390
|
+
? CARD_GEOMETRY.title.size
|
|
391
|
+
: role === "footer"
|
|
392
|
+
? CARD_GEOMETRY.footer.size
|
|
393
|
+
: CARD_GEOMETRY.body.size;
|
|
394
|
+
const table = role === "title" || role === "footer" ? CARD_ADVANCES_TITLE : CARD_ADVANCES_BODY;
|
|
395
|
+
const letterSpacing = role === "kicker" ? size * CARD_GEOMETRY.kicker.letterSpacingEm : 0;
|
|
396
|
+
const measureString = (value) => {
|
|
397
|
+
if (value.length === 0)
|
|
398
|
+
return 0;
|
|
399
|
+
const normalized = role === "kicker" ? value.toUpperCase() : value;
|
|
400
|
+
let sum = 0;
|
|
401
|
+
for (const char of normalized) {
|
|
402
|
+
sum += (table[char] ?? 0.7) * size + letterSpacing;
|
|
403
|
+
}
|
|
404
|
+
return sum + 2;
|
|
405
|
+
};
|
|
406
|
+
const lines = [];
|
|
407
|
+
let tooWide = false;
|
|
408
|
+
for (const word of String(text).split(/\s+/).filter(Boolean)) {
|
|
409
|
+
const candidate = lines.length === 0 ? word : `${lines[lines.length - 1]} ${word}`;
|
|
410
|
+
if (lines.length > 0 && measureString(candidate) <= availableWidth) {
|
|
411
|
+
lines[lines.length - 1] = candidate;
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
if (measureString(word) > availableWidth)
|
|
415
|
+
tooWide = true;
|
|
416
|
+
lines.push(word);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return { lines, tooWide, lineWidths: lines.map(measureString) };
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Bridge from the card measurer to the canvas `LineMeasurer` shape: a host
|
|
423
|
+
* pairing `diagram-canvas` with these renderers passes `cardLineMeasurer()`
|
|
424
|
+
* straight as the injected `LineMeasurer` — no adapter, no role cast.
|
|
425
|
+
* Every canvas role maps onto the card role with the same font size
|
|
426
|
+
* (subtitle, detail, legend-label and edge-label measure as body),
|
|
427
|
+
* `width` is the widest emitted line, `height` the line count at the
|
|
428
|
+
* role's line box, and `overflow` reports a too-wide line or a line-count
|
|
429
|
+
* overflow.
|
|
430
|
+
*/
|
|
431
|
+
export function cardLineMeasurer(measure = defaultCardMeasure) {
|
|
432
|
+
return (request) => {
|
|
433
|
+
const role = request.role === "kicker" || request.role === "title" || request.role === "footer"
|
|
434
|
+
? request.role
|
|
435
|
+
: "body";
|
|
436
|
+
const measured = measure(request.text, role, request.availableWidth, request.allocatedLines);
|
|
437
|
+
const size = role === "kicker"
|
|
438
|
+
? CARD_GEOMETRY.kicker.size
|
|
439
|
+
: role === "title"
|
|
440
|
+
? CARD_GEOMETRY.title.size
|
|
441
|
+
: CARD_GEOMETRY.body.size;
|
|
442
|
+
const widest = measured.lineWidths === undefined
|
|
443
|
+
? request.availableWidth
|
|
444
|
+
: Math.max(0, ...measured.lineWidths);
|
|
445
|
+
return {
|
|
446
|
+
lines: measured.lines,
|
|
447
|
+
width: widest,
|
|
448
|
+
height: measured.lines.length * lineBoxHeight(size),
|
|
449
|
+
overflow: measured.tooWide || measured.lines.length > request.allocatedLines,
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Overflow = refusal (owner criterion, DC-1 review): the first overflow
|
|
455
|
+
* diagnostic of a layout, or `undefined` when the content fits. Both
|
|
456
|
+
* renderers (pure SVG and Svelte) refuse on exactly this predicate, so the
|
|
457
|
+
* two contracts cannot diverge.
|
|
458
|
+
*/
|
|
459
|
+
export function firstOverflowDiagnostic(diagnostics) {
|
|
460
|
+
return diagnostics.find((diagnostic) => diagnostic.code === "card-overflow" || diagnostic.code === "zone-overflow");
|
|
461
|
+
}
|
|
462
|
+
export function headerSlotGeometry(opts) {
|
|
463
|
+
const g = CARD_GEOMETRY;
|
|
464
|
+
const kickerHeight = lineBoxHeight(g.kicker.size);
|
|
465
|
+
const titleHeight = lineBoxHeight(g.title.size);
|
|
466
|
+
const contentHeight = (opts.kickerLines > 0 ? kickerHeight : 0) + opts.titleLines * titleHeight;
|
|
467
|
+
const blockHeight = opts.hasIcon ? Math.max(g.iconSize, contentHeight) : contentHeight;
|
|
468
|
+
return {
|
|
469
|
+
kickerHeight,
|
|
470
|
+
titleHeight,
|
|
471
|
+
contentHeight,
|
|
472
|
+
blockHeight,
|
|
473
|
+
textTopOffset: (blockHeight - contentHeight) / 2,
|
|
474
|
+
iconTopOffset: opts.hasIcon ? (blockHeight - g.iconSize) / 2 : 0,
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Lay out one card: wrap every slot against its frozen allocation, position
|
|
479
|
+
* every line, pin the footer, emit diagnostics. Never truncates or clips
|
|
480
|
+
* (DC-D4): the layout always describes the complete content inside the
|
|
481
|
+
* fixed 460 × 200 box. Any overflow — a too-wide line, a line-count
|
|
482
|
+
* overflow, or a combined header+body height that does not fit the space
|
|
483
|
+
* above the pinned rule — raises `card-overflow` carrying the original slot
|
|
484
|
+
* text, and both renderers refuse on it (overflow = refusal, owner
|
|
485
|
+
* criterion): no normal card is emitted until the content fits. An icon
|
|
486
|
+
* name with no glyph data raises `card-icon-unknown` and the slot collapses.
|
|
487
|
+
*/
|
|
488
|
+
export function layoutCard(props, measure) {
|
|
489
|
+
const g = CARD_GEOMETRY;
|
|
490
|
+
const diagnostics = [];
|
|
491
|
+
const align = props.align ?? "left";
|
|
492
|
+
const bodyMode = props.bodyMode ?? "leaf";
|
|
493
|
+
const contentTop = g.borderWidth + g.padding;
|
|
494
|
+
const contentRight = g.width - g.borderWidth - g.padding;
|
|
495
|
+
// The icon slot collapses when the glyph is missing (DIF-14): the header
|
|
496
|
+
// text then starts at the content inset and no space is reserved.
|
|
497
|
+
const hasIcon = props.icon !== undefined && props.iconGlyph !== undefined;
|
|
498
|
+
const headerTextX = hasIcon ? g.headerInset + g.iconSize + g.iconTextGap : g.headerInset;
|
|
499
|
+
const toggle = props.toggle !== undefined;
|
|
500
|
+
// Toggle present: the header text keeps the owner-pinned folded width
|
|
501
|
+
// (290 px with the icon — the hrpn folded-card title width 356 − 66);
|
|
502
|
+
// the 66 px reservation covers the +/− control's inline-end room.
|
|
503
|
+
const headerTextWidth = toggle
|
|
504
|
+
? hasIcon
|
|
505
|
+
? g.foldedHeaderTextWidth
|
|
506
|
+
: contentRight - g.toggleAllocation - headerTextX
|
|
507
|
+
: contentRight - headerTextX;
|
|
508
|
+
const headerAnchor = align === "center" ? "middle" : "start";
|
|
509
|
+
const headerLineX = align === "center" ? headerTextX + headerTextWidth / 2 : headerTextX;
|
|
510
|
+
// Overflow diagnostic (Astra J4): a too-wide line reports horizontal dims
|
|
511
|
+
// (neededPx = widest measured line, allocatedPx = availableWidth, so
|
|
512
|
+
// neededPx > allocatedPx always); a line-count overflow reports line dims.
|
|
513
|
+
// `text` carries the original slot string: overflow is refused, never
|
|
514
|
+
// shortened, so the diagnostic preserves what the host must shorten.
|
|
515
|
+
const pushOverflow = (slot, measured, lineHeight, allocatedLines, availableWidth, text) => {
|
|
516
|
+
if (measured.tooWide) {
|
|
517
|
+
const widest = measured.lineWidths === undefined ? availableWidth + 1 : Math.max(0, ...measured.lineWidths);
|
|
518
|
+
diagnostics.push({
|
|
519
|
+
code: "card-overflow",
|
|
520
|
+
slot,
|
|
521
|
+
entityId: props.entityId,
|
|
522
|
+
neededPx: widest,
|
|
523
|
+
allocatedPx: availableWidth,
|
|
524
|
+
text,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
diagnostics.push({
|
|
529
|
+
code: "card-overflow",
|
|
530
|
+
slot,
|
|
531
|
+
entityId: props.entityId,
|
|
532
|
+
neededPx: measured.lines.length * lineHeight,
|
|
533
|
+
allocatedPx: allocatedLines * lineHeight,
|
|
534
|
+
text,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
if (props.icon !== undefined && props.iconGlyph === undefined) {
|
|
539
|
+
diagnostics.push({
|
|
540
|
+
code: "card-icon-unknown",
|
|
541
|
+
slot: "icon",
|
|
542
|
+
entityId: props.entityId,
|
|
543
|
+
neededPx: 1,
|
|
544
|
+
allocatedPx: 0,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
const kickerResult = props.kicker === undefined
|
|
548
|
+
? undefined
|
|
549
|
+
: measure(props.kicker, "kicker", headerTextWidth, g.allocatedLines.kicker);
|
|
550
|
+
const kickerTexts = kickerResult === undefined ? [] : [...kickerResult.lines];
|
|
551
|
+
const titleMeasured = measure(props.title, "title", headerTextWidth, g.allocatedLines.title);
|
|
552
|
+
const titleTexts = [...titleMeasured.lines];
|
|
553
|
+
// Optional slots (review pass 2, item 10): one shared derivation — the
|
|
554
|
+
// 70 px icon floor applies only when the icon is present, and the text
|
|
555
|
+
// band is centred in the block exactly like the Svelte header row.
|
|
556
|
+
// Pass 3: the kicker/title line heights and the icon offset come from the
|
|
557
|
+
// same derivation too — no header geometry is recomputed outside it.
|
|
558
|
+
const headerGeo = headerSlotGeometry({
|
|
559
|
+
hasIcon,
|
|
560
|
+
kickerLines: kickerTexts.length,
|
|
561
|
+
titleLines: titleTexts.length,
|
|
562
|
+
});
|
|
563
|
+
const kickerHeight = headerGeo.kickerHeight;
|
|
564
|
+
const titleHeight = headerGeo.titleHeight;
|
|
565
|
+
if (kickerResult !== undefined && (kickerTexts.length > g.allocatedLines.kicker || kickerResult.tooWide)) {
|
|
566
|
+
pushOverflow("kicker", kickerResult, kickerHeight, g.allocatedLines.kicker, headerTextWidth, props.kicker ?? "");
|
|
567
|
+
}
|
|
568
|
+
if (titleTexts.length > g.allocatedLines.title || titleMeasured.tooWide) {
|
|
569
|
+
pushOverflow("title", titleMeasured, titleHeight, g.allocatedLines.title, headerTextWidth, props.title);
|
|
570
|
+
}
|
|
571
|
+
const headerBlockHeight = headerGeo.blockHeight;
|
|
572
|
+
const textTop = contentTop + headerGeo.textTopOffset;
|
|
573
|
+
// Pass 3, item 11: the icon is centred in the header block exactly like
|
|
574
|
+
// the Svelte header row (align-items: center), so both renderers place it
|
|
575
|
+
// at contentTop + iconTopOffset.
|
|
576
|
+
const iconBox = hasIcon
|
|
577
|
+
? { x: g.headerInset, y: contentTop + headerGeo.iconTopOffset, size: g.iconSize }
|
|
578
|
+
: undefined;
|
|
579
|
+
const bodyHeight = lineBoxHeight(g.body.size);
|
|
580
|
+
const bodyY = contentTop + headerBlockHeight + g.gap;
|
|
581
|
+
// bodyInsetFromBar measures accent-bar edge → first glyph (14). The accent
|
|
582
|
+
// bar occupies the card's left edge, so the body x is the token value
|
|
583
|
+
// itself — 2 px left of the header icon edge (16). In `subtitle` body mode
|
|
584
|
+
// (collapsed zone, §6.2.1) the body is the centred subtitle: wrapped at the
|
|
585
|
+
// frozen 396 px measure (width − 2 × (collapsedInset + marginInline)).
|
|
586
|
+
const subtitleMode = bodyMode === "subtitle";
|
|
587
|
+
const subtitleMeasure = g.width - 2 * (ZONE_GEOMETRY.collapsedInset + ZONE_GEOMETRY.collapsedSubtitleMarginInline);
|
|
588
|
+
const bodyTextX = subtitleMode ? (g.width - subtitleMeasure) / 2 : g.bodyInsetFromBar;
|
|
589
|
+
const bodyWidth = subtitleMode ? subtitleMeasure : contentRight - bodyTextX;
|
|
590
|
+
const bodyAnchor = subtitleMode || align === "center" ? "middle" : "start";
|
|
591
|
+
const bodyLineX = bodyAnchor === "middle" ? bodyTextX + bodyWidth / 2 : bodyTextX;
|
|
592
|
+
const wrappedBody = [];
|
|
593
|
+
const bodyLineWidths = [];
|
|
594
|
+
let bodyTooWide = false;
|
|
595
|
+
for (const line of props.body) {
|
|
596
|
+
const measured = measure(line, "body", bodyWidth, g.allocatedLines.body);
|
|
597
|
+
wrappedBody.push(...measured.lines);
|
|
598
|
+
bodyLineWidths.push(...(measured.lineWidths ?? []));
|
|
599
|
+
bodyTooWide = bodyTooWide || measured.tooWide;
|
|
600
|
+
}
|
|
601
|
+
const bodySlot = subtitleMode ? "collapsed-subtitle" : "body";
|
|
602
|
+
const bodySourceText = props.body.join("\n");
|
|
603
|
+
let bodyOverflowPushed = false;
|
|
604
|
+
if (wrappedBody.length > g.allocatedLines.body || bodyTooWide) {
|
|
605
|
+
pushOverflow(bodySlot, { lines: wrappedBody, tooWide: bodyTooWide, lineWidths: bodyLineWidths }, bodyHeight, g.allocatedLines.body, bodyWidth, bodySourceText);
|
|
606
|
+
bodyOverflowPushed = true;
|
|
607
|
+
}
|
|
608
|
+
const footerHeight = lineBoxHeight(g.footer.size);
|
|
609
|
+
const footerBottom = g.height - g.borderWidth - g.footerBottomInset;
|
|
610
|
+
// Footer: wrapped as measured (never joined back), pinned bottom-up — the
|
|
611
|
+
// last line's box bottom sits at footerBottom; the rule stays ruleMargin
|
|
612
|
+
// above the footer block (§5.4). No footer: no rule (DH-04).
|
|
613
|
+
let footerLines = [];
|
|
614
|
+
let ruleY;
|
|
615
|
+
if (props.footer !== undefined) {
|
|
616
|
+
const footerWidth = subtitleMode ? contentRight - g.headerInset : bodyWidth;
|
|
617
|
+
const footerMeasured = measure(props.footer, "footer", footerWidth, g.allocatedLines.footer);
|
|
618
|
+
const footerTexts = [...footerMeasured.lines];
|
|
619
|
+
if (footerTexts.length > g.allocatedLines.footer || footerMeasured.tooWide) {
|
|
620
|
+
pushOverflow("footer", footerMeasured, footerHeight, g.allocatedLines.footer, footerWidth, props.footer ?? "");
|
|
621
|
+
}
|
|
622
|
+
const footerAnchor = align === "center" ? "middle" : "start";
|
|
623
|
+
const footerLineX = footerAnchor === "middle" ? g.headerInset + footerWidth / 2 : g.headerInset;
|
|
624
|
+
const footerBlockHeight = footerTexts.length * footerHeight;
|
|
625
|
+
footerLines = footerTexts.map((text, index) => ({
|
|
626
|
+
text,
|
|
627
|
+
x: footerLineX,
|
|
628
|
+
baseline: baselineOf(footerBottom - footerBlockHeight + index * footerHeight, g.footer.size),
|
|
629
|
+
size: g.footer.size,
|
|
630
|
+
weight: g.footer.weight,
|
|
631
|
+
secondary: false,
|
|
632
|
+
anchor: footerAnchor,
|
|
633
|
+
}));
|
|
634
|
+
ruleY = footerBottom - footerBlockHeight - g.ruleHeight - g.ruleMargin;
|
|
635
|
+
}
|
|
636
|
+
const bodyAreaBottom = ruleY === undefined ? g.height - g.borderWidth - g.padding : ruleY - g.ruleMargin;
|
|
637
|
+
// Vertical overflow (second review, blocking): the combined header + body
|
|
638
|
+
// height must fit the actual space above the pinned rule. The body starts
|
|
639
|
+
// at bodyY (derived from the header block), and the rule is pinned to the
|
|
640
|
+
// footer, so the body allocation is bodyAreaBottom − bodyY — a two-line
|
|
641
|
+
// title already leaves less than one body line above the rule, and the
|
|
642
|
+
// second body baseline would cross the footer baseline. Diagnosed here and
|
|
643
|
+
// refused by both renderers (overflow = refusal), never silently overlapped.
|
|
644
|
+
const bodyBlockHeight = wrappedBody.length * bodyHeight;
|
|
645
|
+
const bodyAreaHeight = bodyAreaBottom - bodyY;
|
|
646
|
+
if (!bodyOverflowPushed && wrappedBody.length > 0 && bodyBlockHeight > bodyAreaHeight) {
|
|
647
|
+
diagnostics.push({
|
|
648
|
+
code: "card-overflow",
|
|
649
|
+
slot: bodySlot,
|
|
650
|
+
entityId: props.entityId,
|
|
651
|
+
neededPx: bodyBlockHeight,
|
|
652
|
+
allocatedPx: bodyAreaHeight,
|
|
653
|
+
text: bodySourceText,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
// Subtitle mode centres the line block vertically inside the body area
|
|
657
|
+
// (§6.2.1); leaf lines stay top-aligned (§5.2).
|
|
658
|
+
const bodyBlockTop = subtitleMode
|
|
659
|
+
? bodyY + Math.max(0, (bodyAreaBottom - bodyY - wrappedBody.length * bodyHeight) / 2)
|
|
660
|
+
: bodyY;
|
|
661
|
+
const detailStart = wrappedBody.length - (props.detailCount ?? 0);
|
|
662
|
+
const body = wrappedBody.map((text, index) => ({
|
|
663
|
+
text,
|
|
664
|
+
x: bodyLineX,
|
|
665
|
+
baseline: baselineOf(bodyBlockTop + index * bodyHeight, g.body.size),
|
|
666
|
+
size: g.body.size,
|
|
667
|
+
weight: g.body.weight,
|
|
668
|
+
secondary: !subtitleMode && index >= detailStart && (props.detailCount ?? 0) > 0,
|
|
669
|
+
anchor: bodyAnchor,
|
|
670
|
+
}));
|
|
671
|
+
const bodyBottom = bodyY + wrappedBody.length * bodyHeight;
|
|
672
|
+
const kicker = kickerTexts.map((text, index) => ({
|
|
673
|
+
text,
|
|
674
|
+
x: headerLineX,
|
|
675
|
+
baseline: baselineOf(textTop + index * kickerHeight, g.kicker.size),
|
|
676
|
+
size: g.kicker.size,
|
|
677
|
+
weight: g.kicker.weight,
|
|
678
|
+
secondary: true,
|
|
679
|
+
anchor: headerAnchor,
|
|
680
|
+
}));
|
|
681
|
+
// Pass 3, item 10: title placement follows the MEASURED kicker-line
|
|
682
|
+
// presence — an empty or whitespace-only kicker measures zero lines and
|
|
683
|
+
// reserves no line, exactly like the shared header derivation above.
|
|
684
|
+
const titleTop = textTop + (kickerTexts.length > 0 ? kickerHeight : 0);
|
|
685
|
+
const title = titleTexts.map((text, index) => ({
|
|
686
|
+
text,
|
|
687
|
+
x: headerLineX,
|
|
688
|
+
baseline: baselineOf(titleTop + index * titleHeight, g.title.size),
|
|
689
|
+
size: g.title.size,
|
|
690
|
+
weight: g.title.weight,
|
|
691
|
+
secondary: false,
|
|
692
|
+
anchor: headerAnchor,
|
|
693
|
+
}));
|
|
694
|
+
// Toggle slot: top right of the content box with the card's own margins
|
|
695
|
+
// (hrpn folded-card placement, y = content top = 10 at the frozen values).
|
|
696
|
+
// The slot box is the 32 px IconButton; the 66 px text reservation is
|
|
697
|
+
// carried by headerTextWidth above.
|
|
698
|
+
const toggleBox = props.toggle === undefined
|
|
699
|
+
? undefined
|
|
700
|
+
: {
|
|
701
|
+
x: contentRight - g.toggleBoxSize,
|
|
702
|
+
y: contentTop,
|
|
703
|
+
size: g.toggleBoxSize,
|
|
704
|
+
};
|
|
705
|
+
return {
|
|
706
|
+
box: { width: g.width, height: g.height },
|
|
707
|
+
contentTop,
|
|
708
|
+
contentRight,
|
|
709
|
+
...(iconBox === undefined ? {} : { iconBox }),
|
|
710
|
+
headerTextX,
|
|
711
|
+
headerTextWidth,
|
|
712
|
+
kicker,
|
|
713
|
+
title,
|
|
714
|
+
headerBlockHeight,
|
|
715
|
+
bodyX: bodyTextX,
|
|
716
|
+
bodyWidth,
|
|
717
|
+
bodyArea: { top: bodyY, bottom: bodyAreaBottom },
|
|
718
|
+
body,
|
|
719
|
+
bodyBottom,
|
|
720
|
+
...(ruleY === undefined ? {} : { ruleY }),
|
|
721
|
+
ruleX1: g.ruleInsetStart,
|
|
722
|
+
ruleX2: g.width - g.ruleInsetEnd,
|
|
723
|
+
footerLines,
|
|
724
|
+
footerBottom,
|
|
725
|
+
...(toggleBox === undefined ? {} : { toggleBox }),
|
|
726
|
+
diagnostics,
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
/* ------------------------------------------------------------------ *
|
|
730
|
+
* DC-2 static half — the wrapping card `DiagramZone` (spec §6). *
|
|
731
|
+
* Same module, same rules: zero imports, one geometry source. *
|
|
732
|
+
* ------------------------------------------------------------------ */
|
|
733
|
+
/**
|
|
734
|
+
* Frozen zone geometry (spec §6.4). Mirrors the `diagramZone` component
|
|
735
|
+
* tokens (`packages/tokens/src/component.ts`) and the `diagram-canvas`
|
|
736
|
+
* `measure.ts` constants (`CONTENT_INSET 16`, `RULE_GAP 4`,
|
|
737
|
+
* `SUBTITLE_TO_RULE_GAP 4`, `RULE_TO_FIRST_CHILD_GAP 16`,
|
|
738
|
+
* `LAST_CHILD_TO_BOTTOM_GAP 16`, `TOGGLE_ALLOCATION 66`,
|
|
739
|
+
* `FIXED_CARD_WIDTH 460`, `FIXED_CARD_HEIGHT 200`); the token↔constant
|
|
740
|
+
* agreement test asserts the sources agree. Fields shared with the atomic
|
|
741
|
+
* card alias `CARD_GEOMETRY` directly — one geometry source (§5.6).
|
|
742
|
+
*/
|
|
743
|
+
export const ZONE_GEOMETRY = {
|
|
744
|
+
radius: 0,
|
|
745
|
+
borderWidth: 1.5,
|
|
746
|
+
// Shared with the atomic card by construction (one geometry source §5.6):
|
|
747
|
+
// every field below aliases CARD_GEOMETRY unless the zone frame differs.
|
|
748
|
+
headerInset: CARD_GEOMETRY.headerInset,
|
|
749
|
+
iconSize: CARD_GEOMETRY.iconSize,
|
|
750
|
+
iconTextGap: CARD_GEOMETRY.iconTextGap,
|
|
751
|
+
kicker: CARD_GEOMETRY.kicker,
|
|
752
|
+
title: CARD_GEOMETRY.title,
|
|
753
|
+
subtitle: CARD_GEOMETRY.body,
|
|
754
|
+
/** Rendered title → subtitle gap: alias of the card `gap` (§6.4). */
|
|
755
|
+
subtitleGap: CARD_GEOMETRY.gap,
|
|
756
|
+
headerRuleGap: 4,
|
|
757
|
+
contentInsetTop: 16,
|
|
758
|
+
contentInsetBottom: 16,
|
|
759
|
+
contentInsetInline: 16,
|
|
760
|
+
ruleHeight: CARD_GEOMETRY.ruleHeight,
|
|
761
|
+
ruleMargin: CARD_GEOMETRY.ruleMargin,
|
|
762
|
+
ruleInsetStart: CARD_GEOMETRY.ruleInsetStart,
|
|
763
|
+
ruleInsetEnd: CARD_GEOMETRY.ruleInsetEnd,
|
|
764
|
+
footer: CARD_GEOMETRY.footer,
|
|
765
|
+
footerBottomInset: CARD_GEOMETRY.footerBottomInset,
|
|
766
|
+
toggleAllocation: CARD_GEOMETRY.toggleAllocation,
|
|
767
|
+
toggleBoxSize: CARD_GEOMETRY.toggleBoxSize,
|
|
768
|
+
/**
|
|
769
|
+
* Expanded toggle top inset: the frozen SVG places every zone toggle at
|
|
770
|
+
* `y + 10` (flush under the frame's top edge), while the header band
|
|
771
|
+
* starts at `y + 16`.
|
|
772
|
+
*/
|
|
773
|
+
toggleTopInset: 10,
|
|
774
|
+
/**
|
|
775
|
+
* Expanded header text inset from the frame's left edge: the kit wraps
|
|
776
|
+
* kicker/title at `width − 178` (icon 16 + 70 + gap 6, toggle room, right
|
|
777
|
+
* inset) — 314 px at the PEOPLE width 492.
|
|
778
|
+
*/
|
|
779
|
+
headerTextInset: 178,
|
|
780
|
+
collapsedWidth: CARD_GEOMETRY.width,
|
|
781
|
+
collapsedHeight: CARD_GEOMETRY.height,
|
|
782
|
+
collapsedInset: 16,
|
|
783
|
+
collapsedSubtitleMarginInline: 16,
|
|
784
|
+
allocatedLines: { kicker: 1, title: 2, subtitle: 2, footer: 1 },
|
|
785
|
+
};
|
|
786
|
+
/** Centred collapsed-subtitle measure (§6.2.1): 460 − 2 × (16 + 16). */
|
|
787
|
+
export const COLLAPSED_SUBTITLE_MEASURE = ZONE_GEOMETRY.collapsedWidth -
|
|
788
|
+
2 * (ZONE_GEOMETRY.collapsedInset + ZONE_GEOMETRY.collapsedSubtitleMarginInline);
|
|
789
|
+
/**
|
|
790
|
+
* Collapsed-zone → atomic-card props mapping (§6.2 field table): the
|
|
791
|
+
* subtitle becomes the centred body (`bodyMode: "subtitle"`), the footer
|
|
792
|
+
* pins the rule, the toggle takes the top-right slot. Shared by
|
|
793
|
+
* `layoutZone` and both renderers so the collapsed zone is the card.
|
|
794
|
+
*/
|
|
795
|
+
export function zoneCollapsedCardProps(props) {
|
|
796
|
+
return {
|
|
797
|
+
entityId: props.entityId,
|
|
798
|
+
...(props.kicker === undefined ? {} : { kicker: props.kicker }),
|
|
799
|
+
title: props.title,
|
|
800
|
+
body: props.subtitle === undefined || props.subtitle === "" ? [] : [props.subtitle],
|
|
801
|
+
...(props.footer === undefined ? {} : { footer: props.footer }),
|
|
802
|
+
...(props.icon === undefined ? {} : { icon: props.icon }),
|
|
803
|
+
...(props.iconGlyph === undefined ? {} : { iconGlyph: props.iconGlyph }),
|
|
804
|
+
...(props.tone === undefined ? {} : { tone: props.tone }),
|
|
805
|
+
...(props.proposed === undefined ? {} : { proposed: props.proposed }),
|
|
806
|
+
...(props.toggleLabel === undefined
|
|
807
|
+
? {}
|
|
808
|
+
: { toggle: { collapsed: true, label: props.toggleLabel } }),
|
|
809
|
+
...(props.align === undefined ? {} : { align: props.align }),
|
|
810
|
+
bodyMode: "subtitle",
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Layout height of one child spec (review pass 3, item 9): a card child is
|
|
815
|
+
* the frozen 460 × 200; a zone child is laid out through `layoutZone` —
|
|
816
|
+
* recursively, so an auto-sized child contributes its own computed header +
|
|
817
|
+
* children + footer height, and an explicit or collapsed child its own box.
|
|
818
|
+
* A parent never assumes a 200 px child.
|
|
819
|
+
*/
|
|
820
|
+
function childLayoutHeight(child, measure) {
|
|
821
|
+
if (child.kind === "card")
|
|
822
|
+
return CARD_GEOMETRY.height;
|
|
823
|
+
if (child.zone === undefined)
|
|
824
|
+
return ZONE_GEOMETRY.collapsedHeight;
|
|
825
|
+
return layoutZone(child.zone, measure, child.children ?? []).box.height;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Lay out one zone. Collapsed, the zone IS the atomic card (§6.2): the
|
|
829
|
+
* subtitle wraps at the frozen 396 px measure and centres in the card body
|
|
830
|
+
* area (`bodyMode: "subtitle"`), the footer pins the rule, and the toggle
|
|
831
|
+
* takes the top-right slot. Expanded, the frame carries the shared header
|
|
832
|
+
* (icon 70 at the 16 px inset, text at x + 92), the subtitle under the
|
|
833
|
+
* icon from the left inset, the header rule 4 px under the subtitle (or
|
|
834
|
+
* the header block), and the content box 16 px under the rule.
|
|
835
|
+
*/
|
|
836
|
+
export function layoutZone(props, measure, children = []) {
|
|
837
|
+
const g = ZONE_GEOMETRY;
|
|
838
|
+
const x = props.x ?? 0;
|
|
839
|
+
const y = props.y ?? 0;
|
|
840
|
+
const diagnostics = [];
|
|
841
|
+
if (props.collapsed) {
|
|
842
|
+
const card = layoutCard(zoneCollapsedCardProps(props), measure);
|
|
843
|
+
for (const diagnostic of card.diagnostics) {
|
|
844
|
+
diagnostics.push({
|
|
845
|
+
code: diagnostic.code === "card-icon-unknown" ? "zone-icon-unknown" : "zone-overflow",
|
|
846
|
+
slot: diagnostic.slot,
|
|
847
|
+
entityId: diagnostic.entityId,
|
|
848
|
+
neededPx: diagnostic.neededPx,
|
|
849
|
+
allocatedPx: diagnostic.allocatedPx,
|
|
850
|
+
...(diagnostic.text === undefined ? {} : { text: diagnostic.text }),
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
box: { x, y, width: g.collapsedWidth, height: g.collapsedHeight },
|
|
855
|
+
collapsed: true,
|
|
856
|
+
card,
|
|
857
|
+
diagnostics,
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
// Expanded frame.
|
|
861
|
+
const width = props.width ?? g.collapsedWidth;
|
|
862
|
+
const contentRight = x + width - g.contentInsetInline;
|
|
863
|
+
const hasIcon = props.icon !== undefined && props.iconGlyph !== undefined;
|
|
864
|
+
const headerTextX = hasIcon ? x + g.headerInset + g.iconSize + g.iconTextGap : x + g.headerInset;
|
|
865
|
+
// Kit header rule: with the icon and the toggle room both present,
|
|
866
|
+
// kicker/title wrap at `width − 178` (314 px at the PEOPLE width 492).
|
|
867
|
+
// Without the icon the text starts at the 16 px inset; without the
|
|
868
|
+
// toggle there is no inline-end reservation — the 178 applies only when
|
|
869
|
+
// icon and toggle are both there.
|
|
870
|
+
const rightHeaderReserve = props.toggleLabel === undefined
|
|
871
|
+
? g.headerInset
|
|
872
|
+
: g.headerTextInset - (g.headerInset + g.iconSize + g.iconTextGap);
|
|
873
|
+
const headerTextWidth = Math.max(0, x + width - headerTextX - rightHeaderReserve);
|
|
874
|
+
const align = props.align ?? "left";
|
|
875
|
+
const headerAnchor = align === "center" ? "middle" : "start";
|
|
876
|
+
const headerLineX = align === "center" ? headerTextX + headerTextWidth / 2 : headerTextX;
|
|
877
|
+
// Overflow diagnostic (Astra J4): a too-wide line reports horizontal dims
|
|
878
|
+
// (neededPx = widest measured line > availableWidth = allocatedPx); a
|
|
879
|
+
// line-count overflow reports line dims.
|
|
880
|
+
const pushOverflow = (slot, measured, lineHeight, allocatedLines, availableWidth, text) => {
|
|
881
|
+
if (measured.tooWide) {
|
|
882
|
+
const widest = measured.lineWidths === undefined ? availableWidth + 1 : Math.max(0, ...measured.lineWidths);
|
|
883
|
+
diagnostics.push({
|
|
884
|
+
code: "zone-overflow",
|
|
885
|
+
slot,
|
|
886
|
+
entityId: props.entityId,
|
|
887
|
+
neededPx: widest,
|
|
888
|
+
allocatedPx: availableWidth,
|
|
889
|
+
text,
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
diagnostics.push({
|
|
894
|
+
code: "zone-overflow",
|
|
895
|
+
slot,
|
|
896
|
+
entityId: props.entityId,
|
|
897
|
+
neededPx: measured.lines.length * lineHeight,
|
|
898
|
+
allocatedPx: allocatedLines * lineHeight,
|
|
899
|
+
text,
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
if (props.icon !== undefined && props.iconGlyph === undefined) {
|
|
904
|
+
diagnostics.push({
|
|
905
|
+
code: "zone-icon-unknown",
|
|
906
|
+
slot: "icon",
|
|
907
|
+
entityId: props.entityId,
|
|
908
|
+
neededPx: 1,
|
|
909
|
+
allocatedPx: 0,
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
// The kit stacks the 24 px subtitle at the raw 24 × 1.3 = 31.2 (not the
|
|
913
|
+
// floored 1/64 grid) and ends its block 8 px under the last baseline.
|
|
914
|
+
const subtitleLineHeight = g.subtitle.size * g.subtitle.lineHeight;
|
|
915
|
+
const kickerResult = props.kicker === undefined
|
|
916
|
+
? undefined
|
|
917
|
+
: measure(props.kicker, "kicker", headerTextWidth, g.allocatedLines.kicker);
|
|
918
|
+
const kickerTexts = kickerResult === undefined ? [] : [...kickerResult.lines];
|
|
919
|
+
const titleMeasured = measure(props.title, "title", headerTextWidth, g.allocatedLines.title);
|
|
920
|
+
const titleTexts = [...titleMeasured.lines];
|
|
921
|
+
// Optional slots (review pass 2, item 10): the same shared derivation as
|
|
922
|
+
// the card — the 70 px icon floor applies only with the icon, and the
|
|
923
|
+
// text band is centred in the block exactly like the Svelte header row
|
|
924
|
+
// (align-items: center), so both renderers place it identically. Pass 3:
|
|
925
|
+
// the kicker/title line heights come from the same derivation too.
|
|
926
|
+
const headerGeo = headerSlotGeometry({
|
|
927
|
+
hasIcon,
|
|
928
|
+
kickerLines: kickerTexts.length,
|
|
929
|
+
titleLines: titleTexts.length,
|
|
930
|
+
});
|
|
931
|
+
const kickerHeight = headerGeo.kickerHeight;
|
|
932
|
+
const titleHeight = headerGeo.titleHeight;
|
|
933
|
+
if (kickerResult !== undefined && (kickerTexts.length > g.allocatedLines.kicker || kickerResult.tooWide)) {
|
|
934
|
+
pushOverflow("kicker", kickerResult, kickerHeight, g.allocatedLines.kicker, headerTextWidth, props.kicker ?? "");
|
|
935
|
+
}
|
|
936
|
+
if (titleTexts.length > g.allocatedLines.title || titleMeasured.tooWide) {
|
|
937
|
+
pushOverflow("title", titleMeasured, titleHeight, g.allocatedLines.title, headerTextWidth, props.title);
|
|
938
|
+
}
|
|
939
|
+
const headerBlockHeight = headerGeo.blockHeight;
|
|
940
|
+
const headerTop = y + g.headerInset;
|
|
941
|
+
const textTop = headerTop + headerGeo.textTopOffset;
|
|
942
|
+
const iconBox = hasIcon
|
|
943
|
+
? { x: x + g.headerInset, y: headerTop + headerGeo.iconTopOffset, size: g.iconSize }
|
|
944
|
+
: undefined;
|
|
945
|
+
const kicker = kickerTexts.map((text, index) => ({
|
|
946
|
+
text,
|
|
947
|
+
x: headerLineX,
|
|
948
|
+
baseline: baselineOf(textTop + index * kickerHeight, g.kicker.size),
|
|
949
|
+
size: g.kicker.size,
|
|
950
|
+
weight: g.kicker.weight,
|
|
951
|
+
secondary: true,
|
|
952
|
+
anchor: headerAnchor,
|
|
953
|
+
}));
|
|
954
|
+
// Pass 3, item 10: title placement follows the MEASURED kicker-line
|
|
955
|
+
// presence — an empty or whitespace-only kicker measures zero lines and
|
|
956
|
+
// reserves no line, exactly like the shared header derivation above.
|
|
957
|
+
const titleTop = textTop + (kickerTexts.length > 0 ? kickerHeight : 0);
|
|
958
|
+
const title = titleTexts.map((text, index) => ({
|
|
959
|
+
text,
|
|
960
|
+
x: headerLineX,
|
|
961
|
+
baseline: baselineOf(titleTop + index * titleHeight, g.title.size),
|
|
962
|
+
size: g.title.size,
|
|
963
|
+
weight: g.title.weight,
|
|
964
|
+
secondary: false,
|
|
965
|
+
anchor: headerAnchor,
|
|
966
|
+
}));
|
|
967
|
+
// Subtitle wraps under the icon from the left inset at x + 16 (§6.2).
|
|
968
|
+
// Kit rule: min(width, 460) − 26, i.e. the same 16/10 insets as the
|
|
969
|
+
// header rule inside a box capped at the atomic card width.
|
|
970
|
+
const subtitleX = x + g.headerInset;
|
|
971
|
+
const subtitleWidth = Math.min(width, g.collapsedWidth) - g.ruleInsetStart - g.ruleInsetEnd;
|
|
972
|
+
const subtitleAnchor = align === "center" ? "middle" : "start";
|
|
973
|
+
const subtitleLineX = align === "center" ? subtitleX + subtitleWidth / 2 : subtitleX;
|
|
974
|
+
const subtitleMeasured = props.subtitle === undefined || props.subtitle === ""
|
|
975
|
+
? { lines: [], tooWide: false }
|
|
976
|
+
: measure(props.subtitle, "body", subtitleWidth, g.allocatedLines.subtitle);
|
|
977
|
+
const subtitleTexts = [...subtitleMeasured.lines];
|
|
978
|
+
if (subtitleTexts.length > g.allocatedLines.subtitle || subtitleMeasured.tooWide) {
|
|
979
|
+
pushOverflow("subtitle", subtitleMeasured, subtitleLineHeight, g.allocatedLines.subtitle, subtitleWidth, props.subtitle ?? "");
|
|
980
|
+
}
|
|
981
|
+
const subtitleTop = headerTop + headerBlockHeight + g.subtitleGap;
|
|
982
|
+
const subtitle = subtitleTexts.map((text, index) => ({
|
|
983
|
+
text,
|
|
984
|
+
x: subtitleLineX,
|
|
985
|
+
baseline: baselineOf(subtitleTop + index * subtitleLineHeight, g.subtitle.size),
|
|
986
|
+
size: g.subtitle.size,
|
|
987
|
+
weight: g.subtitle.weight,
|
|
988
|
+
secondary: false,
|
|
989
|
+
anchor: subtitleAnchor,
|
|
990
|
+
}));
|
|
991
|
+
// Kit subtitle block bottom: 8 px descent under the last baseline.
|
|
992
|
+
const subtitleBottom = subtitleTexts.length === 0
|
|
993
|
+
? subtitleTop
|
|
994
|
+
: subtitleTop + (subtitleTexts.length - 1) * subtitleLineHeight + 22 + 8;
|
|
995
|
+
// Header rule 4 px under the subtitle last line, or under the header
|
|
996
|
+
// block when there is no subtitle (§6.2, §6.4 headerRuleGap).
|
|
997
|
+
const ruleY = subtitleTexts.length > 0
|
|
998
|
+
? subtitleBottom + g.headerRuleGap
|
|
999
|
+
: headerTop + headerBlockHeight + g.headerRuleGap;
|
|
1000
|
+
const contentTop = ruleY + g.contentInsetTop;
|
|
1001
|
+
// Footer, expanded state too (§6.1: folding never changes the footer):
|
|
1002
|
+
// wrapped as measured, pinned bottom-up at the frame bottom like the
|
|
1003
|
+
// card, with its own rule ruleMargin above the footer block. Measured
|
|
1004
|
+
// before the default height so an auto-sized frame reserves the footer.
|
|
1005
|
+
const footerHeight = lineBoxHeight(g.footer.size);
|
|
1006
|
+
const footerX = x + g.contentInsetInline;
|
|
1007
|
+
const footerWidth = x + width - g.contentInsetInline - footerX;
|
|
1008
|
+
const footerMeasured = props.footer === undefined ? undefined : measure(props.footer, "footer", footerWidth, g.allocatedLines.footer);
|
|
1009
|
+
const footerTexts = footerMeasured === undefined ? [] : [...footerMeasured.lines];
|
|
1010
|
+
if (footerMeasured !== undefined && (footerTexts.length > g.allocatedLines.footer || footerMeasured.tooWide)) {
|
|
1011
|
+
pushOverflow("footer", footerMeasured, footerHeight, g.allocatedLines.footer, footerWidth, props.footer ?? "");
|
|
1012
|
+
}
|
|
1013
|
+
const footerBlockHeight = footerTexts.length * footerHeight;
|
|
1014
|
+
// Frame height (review pass 2, item 9; pass 3, item 9): the supplied box,
|
|
1015
|
+
// or — when the host lets the zone size itself — the full vertical
|
|
1016
|
+
// requirement: header + rule (contentTop) or children, whichever is
|
|
1017
|
+
// lower, plus the bottom content inset and the footer reserve (footer
|
|
1018
|
+
// block + rule + both rule gaps + bottom inset). Children contribute
|
|
1019
|
+
// their own recursively computed layout height (never an assumed 200 px),
|
|
1020
|
+
// so a nested auto-sized child is fully inside the frame. The old
|
|
1021
|
+
// formula ignored the header, so a tall header silently overflowed an
|
|
1022
|
+
// auto-sized 200 px frame.
|
|
1023
|
+
const childrenBottom = children.reduce((bottom, child) => Math.max(bottom, child.y + childLayoutHeight(child, measure)), y);
|
|
1024
|
+
const footerReserve = footerTexts.length === 0
|
|
1025
|
+
? 0
|
|
1026
|
+
: footerBlockHeight + g.ruleHeight + 2 * g.ruleMargin + g.footerBottomInset;
|
|
1027
|
+
const requiredHeight = Math.max(childrenBottom, contentTop) + g.contentInsetBottom - y + footerReserve;
|
|
1028
|
+
const height = props.height ?? Math.max(g.collapsedHeight, requiredHeight);
|
|
1029
|
+
// An explicitly undersized frame is refused (overflow = refusal): the
|
|
1030
|
+
// header + content + footer requirement does not fit, diagnosed as a
|
|
1031
|
+
// zone-overflow on the frame slot, and both renderers refuse on it.
|
|
1032
|
+
if (props.height !== undefined && requiredHeight > props.height) {
|
|
1033
|
+
diagnostics.push({
|
|
1034
|
+
code: "zone-overflow",
|
|
1035
|
+
slot: "frame",
|
|
1036
|
+
entityId: props.entityId,
|
|
1037
|
+
neededPx: requiredHeight,
|
|
1038
|
+
allocatedPx: props.height,
|
|
1039
|
+
text: props.title,
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
// Toggle slot: the frozen SVG places every expanded-zone toggle at
|
|
1043
|
+
// y + 10 (the header band itself starts at y + 16).
|
|
1044
|
+
const toggleBox = props.toggleLabel === undefined
|
|
1045
|
+
? undefined
|
|
1046
|
+
: { x: contentRight - g.toggleBoxSize, y: y + g.toggleTopInset, size: g.toggleBoxSize };
|
|
1047
|
+
const footerBottom = y + height - g.borderWidth - g.footerBottomInset;
|
|
1048
|
+
let footer = [];
|
|
1049
|
+
let footerRuleY;
|
|
1050
|
+
if (footerMeasured !== undefined) {
|
|
1051
|
+
const footerAnchor = align === "center" ? "middle" : "start";
|
|
1052
|
+
const footerLineX = footerAnchor === "middle" ? footerX + footerWidth / 2 : footerX;
|
|
1053
|
+
footer = footerTexts.map((text, index) => ({
|
|
1054
|
+
text,
|
|
1055
|
+
x: footerLineX,
|
|
1056
|
+
baseline: baselineOf(footerBottom - footerBlockHeight + index * footerHeight, g.footer.size),
|
|
1057
|
+
size: g.footer.size,
|
|
1058
|
+
weight: g.footer.weight,
|
|
1059
|
+
secondary: false,
|
|
1060
|
+
anchor: footerAnchor,
|
|
1061
|
+
}));
|
|
1062
|
+
footerRuleY = footerBottom - footerBlockHeight - g.ruleHeight - g.ruleMargin;
|
|
1063
|
+
}
|
|
1064
|
+
return {
|
|
1065
|
+
box: { x, y, width, height },
|
|
1066
|
+
collapsed: false,
|
|
1067
|
+
header: {
|
|
1068
|
+
...(iconBox === undefined ? {} : { iconBox }),
|
|
1069
|
+
headerTextX,
|
|
1070
|
+
headerTextWidth,
|
|
1071
|
+
kicker,
|
|
1072
|
+
title,
|
|
1073
|
+
headerBlockHeight,
|
|
1074
|
+
subtitle,
|
|
1075
|
+
subtitleWidth,
|
|
1076
|
+
subtitleBottom,
|
|
1077
|
+
ruleY,
|
|
1078
|
+
contentTop,
|
|
1079
|
+
...(toggleBox === undefined ? {} : { toggleBox }),
|
|
1080
|
+
footer,
|
|
1081
|
+
...(footerRuleY === undefined ? {} : { footerRuleY }),
|
|
1082
|
+
footerBottom,
|
|
1083
|
+
},
|
|
1084
|
+
diagnostics,
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Shared `EntityPresentation` → zone props projection (§4.2/§6.1): container
|
|
1089
|
+
* and legend forms resolve to a zone; a missing entry or no title resolves
|
|
1090
|
+
* to `{ kind: "label" }` (L-R12).
|
|
1091
|
+
*/
|
|
1092
|
+
export function projectZoneProps(presentation, opts) {
|
|
1093
|
+
if (presentation === undefined ||
|
|
1094
|
+
(presentation.form !== "container" && presentation.form !== "legend")) {
|
|
1095
|
+
return { kind: "label" };
|
|
1096
|
+
}
|
|
1097
|
+
const title = presentation.text.title ?? "";
|
|
1098
|
+
if (title === "")
|
|
1099
|
+
return { kind: "label" };
|
|
1100
|
+
const icon = presentation.icon;
|
|
1101
|
+
return {
|
|
1102
|
+
kind: "zone",
|
|
1103
|
+
props: {
|
|
1104
|
+
entityId: opts.entityId,
|
|
1105
|
+
...(presentation.text.kicker === undefined || presentation.text.kicker === ""
|
|
1106
|
+
? {}
|
|
1107
|
+
: { kicker: presentation.text.kicker }),
|
|
1108
|
+
title,
|
|
1109
|
+
...(presentation.text.subtitle === undefined || presentation.text.subtitle === ""
|
|
1110
|
+
? {}
|
|
1111
|
+
: { subtitle: presentation.text.subtitle }),
|
|
1112
|
+
...(presentation.text.footer === undefined || presentation.text.footer === ""
|
|
1113
|
+
? {}
|
|
1114
|
+
: { footer: presentation.text.footer }),
|
|
1115
|
+
...(icon === undefined ? {} : { icon }),
|
|
1116
|
+
...(icon === undefined || opts.resolveGlyph === undefined
|
|
1117
|
+
? {}
|
|
1118
|
+
: (() => {
|
|
1119
|
+
const glyph = opts.resolveGlyph(icon);
|
|
1120
|
+
return glyph === undefined ? {} : { iconGlyph: glyph };
|
|
1121
|
+
})()),
|
|
1122
|
+
...(presentation.categoryRef === undefined ? {} : { tone: presentation.categoryRef }),
|
|
1123
|
+
...(presentation.proposed === undefined ? {} : { proposed: presentation.proposed }),
|
|
1124
|
+
collapsed: opts.collapsed,
|
|
1125
|
+
...(opts.toggleLabel === undefined ? {} : { toggleLabel: opts.toggleLabel }),
|
|
1126
|
+
...(opts.align === undefined ? {} : { align: opts.align }),
|
|
1127
|
+
...(opts.x === undefined ? {} : { x: opts.x }),
|
|
1128
|
+
...(opts.y === undefined ? {} : { y: opts.y }),
|
|
1129
|
+
...(opts.width === undefined ? {} : { width: opts.width }),
|
|
1130
|
+
...(opts.height === undefined ? {} : { height: opts.height }),
|
|
1131
|
+
},
|
|
1132
|
+
};
|
|
1133
|
+
}
|