@vectoriox/iox-ui 5.157.0 → 5.159.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/design-core/index.d.ts +18 -2
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +41 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +3292 -2477
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +5 -33
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +616 -414
- package/package.json +1 -1
- package/src/design-core/css-functions.ts +48 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/check-free.ts +31 -5
- package/src/generation-core/check-layout.ts +123 -14
- package/src/generation-core/compose-free.ts +205 -0
- package/src/generation-core/compose-layout.ts +3 -1
- package/src/generation-core/compose-site.ts +74 -9
- package/src/generation-core/free-fallback.ts +11 -3
- package/src/generation-core/free-slots.ts +125 -0
- package/src/generation-core/free-wire.ts +5 -0
- package/src/generation-core/layout-fingerprint.ts +28 -3
- package/src/generation-core/layout-language.ts +11 -2
- package/src/generation-core/layout-section-fallback.ts +38 -1
- package/src/generation-core/opening-edit.ts +2 -0
- package/src/generation-core/opening-mix.ts +39 -8
- package/src/generation-core/plan-wire.ts +5 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/site-plan.model.ts +12 -0
- package/src/generation-core/site-spec.generated.ts +58 -7
- package/src/generation-core/type-led.ts +31 -9
- package/src/generation-core/validate-site-plan.ts +124 -0
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The style controls that compose ONE multi-function CSS value (Effects ▸ Filter, Effects ▸ Backdrop): each control's
|
|
3
|
+
* trait, the CSS function it writes and its resting value — framework-free, so the main entry's style compiler
|
|
4
|
+
* (`composeVirtualTraits`) and generation-core's free stamp (`free-slots.ts`, which reads a model's whole `filter` into
|
|
5
|
+
* these controls) read ONE table. `decomposeCssFunctions` is the inverse: a whole value → the controls.
|
|
6
|
+
*/
|
|
7
|
+
export type CssFunctionControl = readonly [trait: string, fn: string, rest: string];
|
|
8
|
+
|
|
9
|
+
export const FILTER_FUNCTIONS: ReadonlyArray<CssFunctionControl> = [
|
|
10
|
+
['filterBlur', 'blur', '0px'],
|
|
11
|
+
['filterBrightness', 'brightness', '1'],
|
|
12
|
+
['filterContrast', 'contrast', '1'],
|
|
13
|
+
['filterGrayscale', 'grayscale', '0'],
|
|
14
|
+
['filterSaturate', 'saturate', '1'],
|
|
15
|
+
['filterHueRotate', 'hue-rotate', '0deg'],
|
|
16
|
+
['filterSepia', 'sepia', '0'],
|
|
17
|
+
['filterInvert', 'invert', '0'],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export const BACKDROP_FUNCTIONS: ReadonlyArray<CssFunctionControl> = [
|
|
21
|
+
['backdropBlur', 'blur', '0px'],
|
|
22
|
+
['backdropBrightness', 'brightness', '1'],
|
|
23
|
+
['backdropContrast', 'contrast', '1'],
|
|
24
|
+
['backdropSaturate', 'saturate', '1'],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
/** The functions whose argument is a length or an angle; the rest are 0–3 factors (`140%` reads as `1.4`). */
|
|
28
|
+
const VERBATIM: ReadonlyArray<string> = ['blur', 'hue-rotate'];
|
|
29
|
+
const ONE_FUNCTION = /^([a-z-]+)\(([^()]*)\)$/;
|
|
30
|
+
const asFactor = (arg: string): string => (arg.endsWith('%') ? String(Math.round(parseFloat(arg) * 100) / 10000) : arg);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A whole value (`blur(16px) saturate(1.4)`) → every control of the group (its resting value when absent). `none` /
|
|
34
|
+
* empty → all resting. A function the group has no control for, or a `var()`, → null: the caller keeps it whole rather
|
|
35
|
+
* than silently dropping part of the look.
|
|
36
|
+
*/
|
|
37
|
+
export function decomposeCssFunctions(controls: ReadonlyArray<CssFunctionControl>, value: string | null | undefined): Record<string, string> | null {
|
|
38
|
+
const out: Record<string, string> = Object.fromEntries(controls.map(([trait, , rest]) => [trait, rest]));
|
|
39
|
+
const text = (value ?? '').trim();
|
|
40
|
+
if (text === '' || text === 'none') return out;
|
|
41
|
+
for (const part of text.split(/\s+(?![^(]*\))/)) {
|
|
42
|
+
const m = ONE_FUNCTION.exec(part);
|
|
43
|
+
const control = m && controls.find(([, fn]) => fn === m[1]);
|
|
44
|
+
if (!m || !control || m[2].trim() === '' || m[2].includes('var(')) return null;
|
|
45
|
+
out[control[0]] = VERBATIM.includes(control[1]) ? m[2].trim() : asFactor(m[2].trim());
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { factIssues, PlanWordContext, WrittenText } from './plan-words';
|
|
9
9
|
import { PageSectionPlan } from './site-plan.model';
|
|
10
10
|
import { PathIssue } from './shape-check';
|
|
11
|
+
import { freeStyleWithoutSlot } from './free-slots';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* THE FREE PAGE'S JUDGE (award plan §11.4 gates 1 + 2, FS3): every reason a free page may not be stamped, path first,
|
|
@@ -80,7 +81,7 @@ const LARGE_STYLES: ReadonlyArray<string> = ['display', 'h1', 'h2'];
|
|
|
80
81
|
|
|
81
82
|
/** The style properties whose value is the LOOK's: a token of this type, or one of the listed plain words. */
|
|
82
83
|
export const FREE_TOKEN_PROPS: Readonly<Record<string, string>> = {
|
|
83
|
-
color: 'color', backgroundColor: 'color', borderColor: 'color',
|
|
84
|
+
color: 'color', backgroundColor: 'color', borderColor: 'color',
|
|
84
85
|
fontFamily: 'font', borderRadius: 'radius', boxShadow: 'shadow', transitionDuration: 'duration', transitionTimingFunction: 'easing',
|
|
85
86
|
};
|
|
86
87
|
const TOKEN_PLAIN: Readonly<Record<string, ReadonlyArray<string>>> = {
|
|
@@ -88,7 +89,9 @@ const TOKEN_PLAIN: Readonly<Record<string, ReadonlyArray<string>>> = {
|
|
|
88
89
|
};
|
|
89
90
|
/** A colour token may be either of these token types. */
|
|
90
91
|
const COLOUR_TYPES: ReadonlyArray<string> = ['color', 'paint'];
|
|
91
|
-
/** The free properties: geometry, arrangement, type scale and rhythm, clipping, blending
|
|
92
|
+
/** The free properties: geometry, arrangement, type scale and rhythm, clipping, blending — each one a builder control
|
|
93
|
+
* holds (`free-slots.ts` folds the start / end sides, the axes, `place*`, `flex` and `filter` into them; a node's TYPE may
|
|
94
|
+
* still lack one, which `freeSlotIssues` says). */
|
|
92
95
|
export const FREE_STYLE_PROPS: ReadonlyArray<string> = [
|
|
93
96
|
'display', 'position', 'top', 'bottom', 'insetInlineStart', 'insetInlineEnd', 'zIndex', 'order',
|
|
94
97
|
'width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'aspectRatio', 'overflow',
|
|
@@ -96,9 +99,9 @@ export const FREE_STYLE_PROPS: ReadonlyArray<string> = [
|
|
|
96
99
|
'padding', 'paddingTop', 'paddingBottom', 'paddingInlineStart', 'paddingInlineEnd', 'paddingInline', 'paddingBlock',
|
|
97
100
|
'gridTemplateColumns', 'gridTemplateRows', 'gridColumn', 'gridRow', 'gap', 'rowGap', 'columnGap',
|
|
98
101
|
'flexDirection', 'flexWrap', 'flex', 'alignItems', 'alignContent', 'justifyContent', 'alignSelf', 'justifySelf', 'placeItems', 'placeSelf',
|
|
99
|
-
'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textTransform', 'textAlign', 'fontStyle',
|
|
102
|
+
'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textTransform', 'textAlign', 'fontStyle',
|
|
100
103
|
'translateX', 'translateY', 'rotate', 'scaleX', 'scaleY', 'transformOrigin',
|
|
101
|
-
'clipPath', 'opacity', 'mixBlendMode', 'objectFit', '
|
|
104
|
+
'clipPath', 'opacity', 'mixBlendMode', 'objectFit', 'borderWidth', 'borderStyle', 'filter', 'backdropFilter',
|
|
102
105
|
];
|
|
103
106
|
/** A hover changes position, scale, turn, opacity or a colour token — never layout (Emil: transform / opacity only). */
|
|
104
107
|
export const FREE_HOVER_PROPS: ReadonlyArray<string> = ['translateX', 'translateY', 'scaleX', 'scaleY', 'rotate', 'opacity', 'color', 'backgroundColor', 'borderColor', 'boxShadow'];
|
|
@@ -164,6 +167,26 @@ export function freeStyleIssues(style: FreeStyle | undefined, path: string, ctx:
|
|
|
164
167
|
return out;
|
|
165
168
|
}
|
|
166
169
|
|
|
170
|
+
/**
|
|
171
|
+
* The style a node's TYPE has no builder control for (FS3 stamp, `free-slots.ts`): kept past the first save it could not
|
|
172
|
+
* be, so it is refused here, at the property the answer wrote — every layer, hover included.
|
|
173
|
+
*/
|
|
174
|
+
export function freeSlotIssues(node: FreeNode, path: string): FreeIssue[] {
|
|
175
|
+
if (!Object.values(FreeNodeType).includes(node?.type)) return [];
|
|
176
|
+
const layers: Array<[string, FreeStyle | undefined]> = [
|
|
177
|
+
['styleProps', node.styleProps], ...Object.entries(node.responsive ?? {}).map(([bp, s]) => [`responsive.${bp}`, s] as [string, FreeStyle]), ['hover', node.hover],
|
|
178
|
+
];
|
|
179
|
+
const out: FreeIssue[] = [];
|
|
180
|
+
for (const [layer, style] of layers) {
|
|
181
|
+
for (const [prop, control] of freeStyleWithoutSlot(node.type, style)) {
|
|
182
|
+
if (!FREE_TOKEN_PROPS[prop] && !FREE_STYLE_PROPS.includes(prop)) continue; // said once, by freeStyleIssues
|
|
183
|
+
const inside = node.type === FreeNodeType.Video || node.type === FreeNodeType.Image ? ' — put it on a Container around it' : '';
|
|
184
|
+
out.push({ code: FreeIssueCode.Style, path: `${path}.${layer}.${prop}`, message: `a ${node.type} has no ${control === prop ? `"${prop}"` : `"${control}" (what "${prop}" becomes)`}${inside}` });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
|
|
167
190
|
/** Every reason a free page may not be stamped (gate 1), contrast included (gate 2's tree half). */
|
|
168
191
|
export function checkFree(page: FreePage, ctx: FreeJudgeContext): FreeIssue[] {
|
|
169
192
|
return judgeFree(page, ctx, false);
|
|
@@ -197,7 +220,9 @@ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): F
|
|
|
197
220
|
const issues: FreeIssue[] = [];
|
|
198
221
|
const say = (code: FreeIssueCode, path: string, message: string) => issues.push({ code, path, message });
|
|
199
222
|
const sections = Array.isArray(page?.sections) ? page.sections : [];
|
|
200
|
-
|
|
223
|
+
// A section the fall back dropped still counts toward the minimum (iox-ui#134); the maximum is the page as it stands.
|
|
224
|
+
const counted = sections.length + Math.max(0, Number(page?.givenAway) || 0);
|
|
225
|
+
if (!signature && (counted < FREE_SECTIONS.min || sections.length > FREE_SECTIONS.max)) say(FreeIssueCode.Structure, 'sections', `a page is ${FREE_SECTIONS.min} to ${FREE_SECTIONS.max} sections (this one has ${sections.length})`);
|
|
201
226
|
const ready = (i: number) => !!sections[i]?.readyMade;
|
|
202
227
|
const walked = walkFree(sections).filter(w => !ready(w.section));
|
|
203
228
|
const ids = new Set(walkFree(sections).map(w => w.node.id));
|
|
@@ -246,6 +271,7 @@ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): F
|
|
|
246
271
|
}
|
|
247
272
|
for (const prop of Object.keys(node.hover ?? {})) if (!FREE_HOVER_PROPS.includes(prop)) say(FreeIssueCode.Style, `${path}.hover.${prop}`, `a hover changes position, scale, turn, opacity or a colour token only (${FREE_HOVER_PROPS.join(', ')}) — never layout`);
|
|
248
273
|
issues.push(...freeStyleIssues(Object.fromEntries(Object.entries(node.hover ?? {}).filter(([p]) => FREE_HOVER_PROPS.includes(p))), `${path}.hover`, ctx));
|
|
274
|
+
issues.push(...freeSlotIssues(node, path));
|
|
249
275
|
|
|
250
276
|
// the one move
|
|
251
277
|
if (node.move) {
|
|
@@ -2,9 +2,9 @@ import { columnWordOf, DesignChoices, designTokenRows, parseCssColour, presetCho
|
|
|
2
2
|
import { ParallaxDepth } from '@vectoriox/iox-ui/scene-core';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
LAYOUT_COLUMN_MENDED, LAYOUT_HIDDEN_OPACITY, LAYOUT_OPERATED, LAYOUT_TEXT_KINDS, LayoutBandMove, LayoutColour, LayoutDepth, LayoutDial, LayoutEnter, LayoutGalleryList, LayoutIssue, LayoutListShape, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutMend, LayoutMendKind,
|
|
5
|
+
LAYOUT_COLUMN_MENDED, LAYOUT_HIDDEN_OPACITY, LAYOUT_OPERATED, LAYOUT_TEXT_KINDS, LayoutBandMove, LayoutButtonVariant, LayoutColour, LayoutDepth, LayoutDial, LayoutEnter, LayoutGalleryList, LayoutIssue, LayoutListShape, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutMend, LayoutMendKind,
|
|
6
6
|
LayoutGivenAway, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListItem, LayoutListMix, LayoutListPhone, LayoutPage, LayoutPhotoSource,
|
|
7
|
-
LayoutRole, LayoutScrubRefusal, LayoutSection, LayoutSectionKind, LayoutSourceChoice, LayoutTrackProp, parseLayoutPhotoId,
|
|
7
|
+
LayoutRole, LayoutScrubRefusal, LayoutSection, LayoutSectionKind, LayoutSize, LayoutSourceChoice, LayoutTrackProp, parseLayoutPhotoId,
|
|
8
8
|
} from './layout-language';
|
|
9
9
|
import { layoutScrubTakes } from './text-scroll';
|
|
10
10
|
import { layoutColumnsOffered } from './layout-wire';
|
|
@@ -488,13 +488,16 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
488
488
|
else if (l.variant !== undefined && !inList(V.buttonVariants, l.variant)) add(LayoutIssueCode.Value, `${lp}.variant`, V.buttonVariants.join(' | '));
|
|
489
489
|
const text = String(l.text ?? (l.items ?? []).join(' '));
|
|
490
490
|
const maxChars = l.size ? L.maxChars[l.size] : undefined;
|
|
491
|
-
|
|
491
|
+
// iox-ui#131: a near miss — one size step down holds them — is the composer's to settle.
|
|
492
|
+
const smaller = placed ? sizeStepDown(l, s, i, judgeColumnPx, daring) : null;
|
|
493
|
+
const sizeMend = smaller ? { kind: LayoutMendKind.Size as const, layer: lp, size: smaller } : undefined;
|
|
494
|
+
if (maxChars !== undefined && text.length > maxChars) add(LayoutIssueCode.Reading, `${lp}.text`, `${text.length} characters is too long for size ${l.size} (≤ ${maxChars})`, sizeMend);
|
|
492
495
|
if ((l.size === 'm' || l.size === 's') && text.length > LIM.longTextChars && span(l.col) > LIM.longTextColumns) {
|
|
493
496
|
add(LayoutIssueCode.Reading, `${lp}.col`, `long text is never wider than ${LIM.longTextColumns} columns`);
|
|
494
497
|
}
|
|
495
498
|
if (placed && isText(l) && l.size && l.size !== 'screen' && text && !layoutTextFits(l, s, l.size, judgeColumnPx)) {
|
|
496
499
|
const lines = Math.floor(boxPx(l.col, l.row, s, judgeColumnPx).h / (L.sizePx[l.size] * LAYOUT_LINE_HEIGHT));
|
|
497
|
-
add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words
|
|
500
|
+
add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words`, sizeMend);
|
|
498
501
|
}
|
|
499
502
|
if (l.size === 'screen' || l.size === 'xxl') huge++;
|
|
500
503
|
if (l.size === 'screen') {
|
|
@@ -540,7 +543,8 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
540
543
|
add(LayoutIssueCode.Motion, `${lp}.enter`, 'decoration only fades ("fade" or "none")', { kind: LayoutMendKind.Fade, layer: lp });
|
|
541
544
|
}
|
|
542
545
|
if ((l.motion ?? []).some(m => m.prop !== LayoutTrackProp.Opacity)) add(LayoutIssueCode.Motion, `${lp}.motion`, 'decoration only fades — opacity tracks only');
|
|
543
|
-
|
|
546
|
+
// iox-ui#131: settled alone — a decoration sent back glides as the floor asks (the salon's and store's pages fell on it).
|
|
547
|
+
if (l.depth === 'front') add(LayoutIssueCode.Motion, `${lp}.depth`, 'decoration never runs ahead — back or mid', { kind: LayoutMendKind.Depth, layers: [lp] });
|
|
544
548
|
}
|
|
545
549
|
if (l.kind === LayoutLayerKind.Shape && !layoutShapeHasPurpose(s, j)) {
|
|
546
550
|
add(LayoutIssueCode.Look, lp, 'a shape that is there for nothing — not a rule (one row high), a band, a frame for a picture or a ground for words, and it does not move: an empty box on the page',
|
|
@@ -647,11 +651,15 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
647
651
|
if (preset === 'lead' && !ctx.takesLeads) add(LayoutIssueCode.Content, `${lp}.form.preset`, 'this business takes no leads — use contact or booking');
|
|
648
652
|
}
|
|
649
653
|
if (f?.channel?.href) add(LayoutIssueCode.Content, `${lp}.form.channel.href`, 'no link — the second channel is filled from the owner\'s facts');
|
|
650
|
-
if (span(l.col) < LIM.formColumns)
|
|
654
|
+
if (span(l.col) < LIM.formColumns) {
|
|
655
|
+
const col = formWidening(s, j, LIM.formColumns, lastCol);
|
|
656
|
+
add(LayoutIssueCode.Structure, `${lp}.col`, `a form needs at least ${LIM.formColumns} columns`, col ? { kind: LayoutMendKind.Widen, layer: lp, col } : undefined);
|
|
657
|
+
}
|
|
651
658
|
if (groundPhoto || layers.some(o => o !== l && isPictured(o) && overlaps(o, l))) add(LayoutIssueCode.Reading, lp, 'a form never sits on a photo');
|
|
652
659
|
}
|
|
653
660
|
if (l.kind === LayoutLayerKind.Button) {
|
|
654
|
-
|
|
661
|
+
// A secondary button wears the ink and a line, never the accent (iox-ui#131): it does not count.
|
|
662
|
+
if (l.variant !== LayoutButtonVariant.Secondary) accentUses++;
|
|
655
663
|
if (!l.to) add(LayoutIssueCode.Content, `${lp}.to`, 'a button leads somewhere: a section id or a page route');
|
|
656
664
|
else if (!ids.has(l.to) && !routes.includes(l.to)) {
|
|
657
665
|
add(LayoutIssueCode.Content, `${lp}.to`, `"${l.to}" is not a section id${routes.length ? ` or one of the routes ${routes.join(' | ')}` : ''}`);
|
|
@@ -792,9 +800,11 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
792
800
|
if (marquees > LIM.marquees) add(LayoutIssueCode.Structure, 'sections', `${marquees} marquees — at most ${LIM.marquees}`);
|
|
793
801
|
const minDepth = Math.max(0, (look && inList(LIM.calmLooks, look.id) ? LIM.depthLayersCalm : LIM.depthLayers) - carried.layered);
|
|
794
802
|
if (layered < minDepth) {
|
|
803
|
+
// iox-ui#131: the floor follows what the page can hold — every layer that may glide without its words meeting
|
|
804
|
+
// another's takes a depth; a page with none left to give is not refused for it (the salon's Home fell back whole on
|
|
805
|
+
// "4 layers glide — at least 6" with nothing more that could glide).
|
|
795
806
|
const glide = glideChoice(sections, minDepth - layered);
|
|
796
|
-
add(LayoutIssueCode.Motion, 'sections', `${layered} layers glide by depth or drift — at least ${minDepth}`,
|
|
797
|
-
glide.length === minDepth - layered ? { kind: LayoutMendKind.Depth, layers: glide } : undefined);
|
|
807
|
+
if (glide.length) add(LayoutIssueCode.Motion, 'sections', `${layered} layers glide by depth or drift — at least ${minDepth}`, { kind: LayoutMendKind.Depth, layers: glide });
|
|
798
808
|
}
|
|
799
809
|
if (daring) {
|
|
800
810
|
const d = LIM.daring;
|
|
@@ -813,8 +823,9 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
813
823
|
if (look) {
|
|
814
824
|
if (accentUses > look.accentMax) {
|
|
815
825
|
const bands = paint ? accentBandMoves(sections, ground => paint.colours[ground], (name, text) => colourHex(name, text)) : [];
|
|
826
|
+
const buttons = accentButtonSteps(sections);
|
|
816
827
|
add(LayoutIssueCode.Look, 'sections', `the accent is on ${accentUses} layers (a button counts, an accent ground twice) — the ${look.id} look allows ${look.accentMax}`,
|
|
817
|
-
{ kind: LayoutMendKind.Accent, over: accentUses - look.accentMax, ...(bands.length ? { bands } : {}) });
|
|
828
|
+
{ kind: LayoutMendKind.Accent, over: accentUses - look.accentMax, ...(bands.length ? { bands } : {}), ...(buttons.length ? { buttons } : {}) });
|
|
818
829
|
}
|
|
819
830
|
if (limits.hugeMax !== undefined && huge > limits.hugeMax) add(LayoutIssueCode.Look, 'sections', `${huge} xxl/screen layers — the ${look.id} look allows ${limits.hugeMax}`);
|
|
820
831
|
if (limits.centerMax !== undefined && textLayers && centered / textLayers > limits.centerMax) {
|
|
@@ -950,6 +961,52 @@ export function auditLayoutMotion(nodes: ReadonlyArray<SerializedNode>): LayoutI
|
|
|
950
961
|
return issues;
|
|
951
962
|
}
|
|
952
963
|
|
|
964
|
+
/** The sizes a near miss may step down from, and the step (iox-ui#131): one step, never below a heading's reading size. */
|
|
965
|
+
const SIZE_STEP_DOWN: Readonly<Partial<Record<`${LayoutSize}`, `${LayoutSize}`>>> = { [LayoutSize.Xxl]: LayoutSize.Xl, [LayoutSize.Xl]: LayoutSize.L, [LayoutSize.L]: LayoutSize.M };
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* iox-ui#131: the size one step down at which a text layer's words fit its box and the size still holds them — the near
|
|
969
|
+
* miss the composer settles. Never the opening's display (a daring page's one large thing — its own rule), never a word set
|
|
970
|
+
* to the screen. Null: the model's.
|
|
971
|
+
*/
|
|
972
|
+
function sizeStepDown(l: LayoutLayer, s: LayoutSection, si: number, columnPx: number, daring: boolean): `${LayoutSize}` | null {
|
|
973
|
+
if (!isText(l) || !l.size) return null;
|
|
974
|
+
const to = SIZE_STEP_DOWN[l.size as `${LayoutSize}`];
|
|
975
|
+
// A daring page's opening keeps its display (the daring rule asks one); any other opening's heading may step too.
|
|
976
|
+
if (!to || (daring && si === 0 && l.size === LayoutSize.Xxl) || l.kind === LayoutLayerKind.Word) return null;
|
|
977
|
+
const max = L.maxChars[to as keyof typeof L.maxChars];
|
|
978
|
+
if (max !== undefined && String(l.text ?? (l.items ?? []).join(" ")).length > max) return null;
|
|
979
|
+
return layoutTextFits(l, s, to, columnPx) ? to : null;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* iox-ui#131: the columns a form narrower than `need` takes by widening into empty cells of its own rows (toward the end,
|
|
984
|
+
* then the start; never over another layer, never past the grid). Null: no room — the model's.
|
|
985
|
+
*/
|
|
986
|
+
function formWidening(s: LayoutSection, li: number, need: number, lastCol: number): [number, number] | null {
|
|
987
|
+
const l = s.layers[li];
|
|
988
|
+
let [c0, c1] = l.col;
|
|
989
|
+
const free = (col: [number, number]) => s.layers.every((o, j) => j === li || !overlaps({ ...l, col }, o));
|
|
990
|
+
while (c1 - c0 < need && c1 + 1 <= lastCol && free([c0, c1 + 1])) c1++;
|
|
991
|
+
while (c1 - c0 < need && c0 - 1 >= 1 && free([c0 - 1, c1])) c0--;
|
|
992
|
+
return c1 - c0 >= need ? [c0, c1] : null;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* The primary buttons the accent mend may step to secondary (iox-ui#131), least important first: later sections first,
|
|
997
|
+
* never the main call to action (the first button that reaches the business — a form's section or a contact word — else
|
|
998
|
+
* the first button). A secondary one already paints no accent.
|
|
999
|
+
*/
|
|
1000
|
+
function accentButtonSteps(sections: ReadonlyArray<LayoutSection>): string[] {
|
|
1001
|
+
const buttons = sections.flatMap((s, si) => (s.layers ?? []).map((l, li) => ({ l, si, li })).filter(({ l }) => l.kind === LayoutLayerKind.Button));
|
|
1002
|
+
const formIds = new Set(sections.filter(s => s.layers?.some(l => l.kind === LayoutLayerKind.Form)).map(s => s.id));
|
|
1003
|
+
const main = buttons.find(({ l }) => formIds.has(String(l.to)) || CONTACT_WORDS.test(`${l.to ?? ''} ${l.text ?? ''}`)) ?? buttons[0];
|
|
1004
|
+
return buttons
|
|
1005
|
+
.filter(b => b !== main && b.l.variant !== LayoutButtonVariant.Secondary)
|
|
1006
|
+
.sort((a, b) => b.si - a.si || b.li - a.li)
|
|
1007
|
+
.map(({ si, li }) => `sections[${si}].layers[${li}]`);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
953
1010
|
/** Most important first: which layers take a depth when too few glide (iox-ui#63). */
|
|
954
1011
|
const GLIDE_ROLE_ORDER: ReadonlyArray<`${LayoutRole}` | undefined> = [LayoutRole.Lead, LayoutRole.Support, undefined, LayoutRole.Decoration];
|
|
955
1012
|
|
|
@@ -1139,11 +1196,30 @@ export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>)
|
|
|
1139
1196
|
const accented = (next.sections ?? []).flatMap((s, si) => (s.layers ?? []).map(l => ({ l, si })))
|
|
1140
1197
|
.filter(({ l }) => isText(l) && l.color === LayoutColour.Accent)
|
|
1141
1198
|
.sort((a, b) => MEND_ROLE_ORDER.indexOf(a.l.role) - MEND_ROLE_ORDER.indexOf(b.l.role) || b.si - a.si);
|
|
1142
|
-
// words first; a band (an accent ground counts twice) only for what the words cannot give back
|
|
1143
|
-
|
|
1144
|
-
|
|
1199
|
+
// words first; a band (an accent ground counts twice) only for what the words cannot give back; then a primary
|
|
1200
|
+
// button that is not the main call to action steps to secondary (iox-ui#131)
|
|
1201
|
+
const available = mend.bands?.length ?? 0;
|
|
1202
|
+
let bands = accented.length >= mend.over ? 0 : Math.ceil((mend.over - accented.length) / ACCENT_GROUND_USES);
|
|
1203
|
+
let steps: LayoutLayer[] = [];
|
|
1204
|
+
if (bands > available) {
|
|
1205
|
+
bands = available;
|
|
1206
|
+
const need = mend.over - accented.length - available * ACCENT_GROUND_USES;
|
|
1207
|
+
steps = (mend.buttons ?? []).map(layerAt).filter((b): b is LayoutLayer => !!b).slice(0, need);
|
|
1208
|
+
if (steps.length < need) continue;
|
|
1209
|
+
}
|
|
1145
1210
|
for (const band of (mend.bands ?? []).slice(0, bands)) next.sections[band.section].ground = band.ground;
|
|
1146
|
-
for (const { l } of accented.slice(0, Math.max(0, mend.over - bands * ACCENT_GROUND_USES))) delete l.color;
|
|
1211
|
+
for (const { l } of accented.slice(0, Math.max(0, mend.over - bands * ACCENT_GROUND_USES - steps.length))) delete l.color;
|
|
1212
|
+
for (const b of steps) b.variant = LayoutButtonVariant.Secondary;
|
|
1213
|
+
mended.push(issue);
|
|
1214
|
+
} else if (mend?.kind === LayoutMendKind.Size) {
|
|
1215
|
+
const layer = layerAt(mend.layer);
|
|
1216
|
+
if (!layer) continue;
|
|
1217
|
+
layer.size = mend.size;
|
|
1218
|
+
mended.push(issue);
|
|
1219
|
+
} else if (mend?.kind === LayoutMendKind.Widen) {
|
|
1220
|
+
const layer = layerAt(mend.layer);
|
|
1221
|
+
if (!layer) continue;
|
|
1222
|
+
layer.col = [...mend.col] as [number, number];
|
|
1147
1223
|
mended.push(issue);
|
|
1148
1224
|
} else if (mend?.kind === LayoutMendKind.Depth) {
|
|
1149
1225
|
const layers = mend.layers.map(layerAt);
|
|
@@ -1220,3 +1296,36 @@ export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>)
|
|
|
1220
1296
|
}
|
|
1221
1297
|
return { page: mended.length ? next : page, mended };
|
|
1222
1298
|
}
|
|
1299
|
+
|
|
1300
|
+
/** How many times the composer settles a page: a mend can make the next one possible (an accent band moved, then a
|
|
1301
|
+
* depth that no longer meets it), never more. */
|
|
1302
|
+
export const LAYOUT_SETTLE_PASSES = 3;
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* iox-ui#131: settle a page as far as the composer can — the mends of what the gate finds, then the gate again on the
|
|
1306
|
+
* mended page, until nothing more is settled (at most `LAYOUT_SETTLE_PASSES`). `issuesOf` is the whole gate the page is
|
|
1307
|
+
* judged by (static + sameness). What is left after it is the model's, or the section fallback's. Pure.
|
|
1308
|
+
*/
|
|
1309
|
+
export function settleLayoutPage(page: LayoutPage, issuesOf: (page: LayoutPage) => ReadonlyArray<LayoutIssue>): { page: LayoutPage; mended: LayoutIssue[] } {
|
|
1310
|
+
let current = page;
|
|
1311
|
+
const mended: LayoutIssue[] = [];
|
|
1312
|
+
for (let pass = 0; pass < LAYOUT_SETTLE_PASSES; pass++) {
|
|
1313
|
+
const settled = mendLayout(current, issuesOf(current));
|
|
1314
|
+
if (!settled.mended.length) break;
|
|
1315
|
+
current = settled.page;
|
|
1316
|
+
mended.push(...settled.mended);
|
|
1317
|
+
}
|
|
1318
|
+
return { page: current, mended };
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/** iox-ui#131: at most this many things left after the one repair is a near miss — asked once more, not given away. */
|
|
1322
|
+
export const LAYOUT_NEAR_MISS = 2;
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* iox-ui#131: a repaired page that came close — at most `LAYOUT_NEAR_MISS` things left, and fewer than the check found
|
|
1326
|
+
* before the repair (the model is converging, not wandering) — gets a second repair before its sections are given away.
|
|
1327
|
+
* Pure: the service and a replay ask the same question.
|
|
1328
|
+
*/
|
|
1329
|
+
export function layoutNearMiss(before: ReadonlyArray<LayoutIssue>, after: ReadonlyArray<LayoutIssue>): boolean {
|
|
1330
|
+
return after.length > 0 && after.length <= LAYOUT_NEAR_MISS && after.length < before.length;
|
|
1331
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { NO_ELEMENT_STYLE } from '@vectoriox/iox-ui/composite-core';
|
|
2
|
+
import { LinkType } from '@vectoriox/iox-ui/design-core';
|
|
3
|
+
import { VideoMode, VideoSource } from '@vectoriox/iox-ui/media-core';
|
|
4
|
+
|
|
5
|
+
import { composeListFrame, LayoutListBinding } from './compose-layout';
|
|
6
|
+
import { composePresetForm } from './compose-site';
|
|
7
|
+
import { freeStyleToSlots } from './free-slots';
|
|
8
|
+
import { FREE_BUILDER_TYPE, FreeLayer, FreeNode, FreeNodeType, FreePage, FreeStyle, FreeTrigger } from './free-wire';
|
|
9
|
+
import { LAYOUT_BEAT_DELAY, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING, LAYOUT_PACE, LAYOUT_RISE, LayoutEase, LayoutPace, LayoutRole, LayoutSite } from './layout-language';
|
|
10
|
+
import { listMixFromWords } from './layout-wire';
|
|
11
|
+
import { ComposeError, createSerializedNode, SerializedNode, setStyleProps } from './serialized-node';
|
|
12
|
+
import { stampSection } from './section-stamp';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* THE FREE STAMP (award-ingredients plan §11.4, FS3, R-H3): a free page — or one free signature section — that passed
|
|
16
|
+
* `checkFree` in, ordinary builder nodes out. Each free node is made by `createSerializedNode` (the builder's own
|
|
17
|
+
* creation: its type, its element style) and given the answer's look through the builder's CONTROLS (`free-slots.ts`),
|
|
18
|
+
* so the builder reloads the page and saves it unchanged and the engine renders it with nothing new to learn. A Slot is
|
|
19
|
+
* the product's recipe, never the model's nodes: a list through `composeListFrame` (the one list composer), a form
|
|
20
|
+
* through the forms-core preset (`composePresetForm`); a section the fall back gave the plan back is the plan's
|
|
21
|
+
* ready-made section, composed by the caller (`readyMade`). The header and the footer are the site's globals. Pure and
|
|
22
|
+
* deterministic; what the stamp cannot keep is a `ComposeError` (the judge refused it first).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const COMPOSED = { releaseLayoutDefaults: true } as const;
|
|
26
|
+
const SECTION_LINK = '#';
|
|
27
|
+
const ROUTE_MARK = '/';
|
|
28
|
+
const LIST_SLOT = 'list:';
|
|
29
|
+
const FORM_SLOT = 'form:';
|
|
30
|
+
/** A list slot's mix when the answer names no option: cards of the list's parts, in a grid. */
|
|
31
|
+
const LIST_SLOT_WORDS: ReadonlyArray<string> = ['item:card', 'arrange:grid'];
|
|
32
|
+
|
|
33
|
+
export interface ComposeFreeOptions {
|
|
34
|
+
/** The page key: every node's id is `<owner>-<the answer's id>`, unique on the site. */
|
|
35
|
+
owner: string;
|
|
36
|
+
/** The site's language: a right-to-left one puts the start side on the right. */
|
|
37
|
+
locale?: string;
|
|
38
|
+
rtl?: boolean;
|
|
39
|
+
/** The look's pace and easing (`layoutMotionOf`): how long an entrance takes. Default normal, ease-out. */
|
|
40
|
+
motion?: LayoutSite['motion'];
|
|
41
|
+
/** A material id as the address and the words of its picture (`ComposeContext.photoSrc` / `photoAlt`). */
|
|
42
|
+
photoSrc: (id: string) => string;
|
|
43
|
+
photoAlt: (id: string) => string;
|
|
44
|
+
/** How a list slot's items are read (`layoutListBinding`); null for an alias that is no list. */
|
|
45
|
+
listOf: (alias: string) => LayoutListBinding | null;
|
|
46
|
+
/** The plan's ready-made section at plan index `at`, composed under `id` (a section the fall back gave back). */
|
|
47
|
+
readyMade?: (at: number, id: string) => SerializedNode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface Ctx {
|
|
51
|
+
o: ComposeFreeOptions;
|
|
52
|
+
rtl: boolean;
|
|
53
|
+
pace: { lead: number; support: number; decoration: number; gap: number };
|
|
54
|
+
ease: string;
|
|
55
|
+
/** Every Button that goes to a section of this page, by the answer's id (resolved once every node is made). */
|
|
56
|
+
links: Array<{ node: SerializedNode; to: string }>;
|
|
57
|
+
ids: Set<string>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const idOf = (ctx: Ctx, id: string) => `${ctx.o.owner}-${id}`;
|
|
61
|
+
|
|
62
|
+
/** A free page's sections, one stamped root each (a ready-made place stamped with its pattern, the rest as model-laid). */
|
|
63
|
+
export function composeFreePage(page: FreePage, options: ComposeFreeOptions): SerializedNode[] {
|
|
64
|
+
const ctx = contextOf(options, page.sections);
|
|
65
|
+
const roots = page.sections.map(section => (section.readyMade ? readyMadeSection(section, ctx) : composeNode(section, ctx, 0)));
|
|
66
|
+
// The links are written once every node is made; the stamp's fingerprint is taken after them.
|
|
67
|
+
wireLinks(ctx);
|
|
68
|
+
return roots.map((root, i) => {
|
|
69
|
+
const pattern = page.sections[i].readyMade?.pattern;
|
|
70
|
+
return stampSection(root, pattern ? { pattern } : { layout: page.sections[i].id });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** ONE free signature section (FS-D19 Basic) as a section root under `id` — the page's other sections are the plan's. */
|
|
75
|
+
export function composeFreeSection(section: FreeNode, id: string, options: ComposeFreeOptions): SerializedNode {
|
|
76
|
+
if (section.type !== FreeNodeType.Section) throw new ComposeError(`${id}: a free section is a Section, not a ${section.type}`);
|
|
77
|
+
// Its nodes are named under the section's own id, so they never meet the ids of the patterns beside it.
|
|
78
|
+
const ctx = contextOf({ ...options, owner: id }, [section]);
|
|
79
|
+
const root = composeNode(section, ctx, 0);
|
|
80
|
+
root.id = id;
|
|
81
|
+
wireLinks(ctx, { [section.id]: id });
|
|
82
|
+
return stampSection(root, { layout: section.id });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function contextOf(options: ComposeFreeOptions, sections: ReadonlyArray<FreeNode>): Ctx {
|
|
86
|
+
const pace = LAYOUT_PACE[(options.motion?.pace ?? LayoutPace.Normal) as LayoutPace] ?? LAYOUT_PACE[LayoutPace.Normal];
|
|
87
|
+
const ids = new Set<string>();
|
|
88
|
+
const walk = (n: FreeNode) => { ids.add(n.id); (n.children ?? []).forEach(walk); };
|
|
89
|
+
sections.forEach(walk);
|
|
90
|
+
return {
|
|
91
|
+
o: options, rtl: !!options.rtl, pace, ids, links: [],
|
|
92
|
+
ease: LAYOUT_EASING[(options.motion?.ease ?? LayoutEase.Out) as LayoutEase] ?? LAYOUT_EASING[LayoutEase.Out],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function readyMadeSection(section: FreeNode, ctx: Ctx): SerializedNode {
|
|
97
|
+
if (!ctx.o.readyMade) throw new ComposeError(`${section.id}: a ready-made place, and no plan section to compose it from`);
|
|
98
|
+
return ctx.o.readyMade(section.readyMade!.at, idOf(ctx, section.id));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** One free node and its children, as the builder makes them. `beat` is its place among its moving siblings. */
|
|
102
|
+
function composeNode(n: FreeNode, ctx: Ctx, beat: number): SerializedNode {
|
|
103
|
+
const id = idOf(ctx, n.id);
|
|
104
|
+
const type = FREE_BUILDER_TYPE[n.type];
|
|
105
|
+
if (!type) throw new ComposeError(`${n.id}: "${n.type}" is not a free node type`);
|
|
106
|
+
const node = createSerializedNode(id, type, propsOf(n, ctx), n.elementStyle || NO_ELEMENT_STYLE, COMPOSED);
|
|
107
|
+
node.label = n.purpose ?? n.id;
|
|
108
|
+
if (n.type === FreeNodeType.Button) {
|
|
109
|
+
const label = createSerializedNode(`${id}-label`, 'Text', { content: n.text ?? '', tag: 'span' }, 'button-label', COMPOSED);
|
|
110
|
+
node.children = [label];
|
|
111
|
+
if (n.href?.startsWith(SECTION_LINK)) ctx.links.push({ node, to: n.href.slice(1) });
|
|
112
|
+
}
|
|
113
|
+
styleInto(node, n, ctx);
|
|
114
|
+
const move = moveOf(n, id, ctx, beat);
|
|
115
|
+
if (move) node.interactions = [...node.interactions, move];
|
|
116
|
+
if (n.type === FreeNodeType.Slot) node.children = [slotOf(n, id, ctx)];
|
|
117
|
+
else if (n.children?.length) {
|
|
118
|
+
let moving = 0;
|
|
119
|
+
node.children = [...(node.children ?? []), ...n.children.map(c => composeNode(c, ctx, c.move ? moving++ : 0))];
|
|
120
|
+
}
|
|
121
|
+
return node;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** What a node says and shows: its words, its level, its link, its picture. */
|
|
125
|
+
function propsOf(n: FreeNode, ctx: Ctx): Record<string, unknown> {
|
|
126
|
+
switch (n.type) {
|
|
127
|
+
case FreeNodeType.Heading: return { content: n.text ?? '', level: `h${n.level ?? 2}` };
|
|
128
|
+
case FreeNodeType.Text: return { content: n.text ?? '', tag: 'p' };
|
|
129
|
+
case FreeNodeType.Button:
|
|
130
|
+
return n.href?.startsWith(ROUTE_MARK) ? { tag: 'a', linkType: LinkType.Page, pageRoute: n.href } : { tag: 'button', type: 'button' };
|
|
131
|
+
case FreeNodeType.Image: return { src: ctx.o.photoSrc(n.src ?? ''), alt: ctx.o.photoAlt(n.src ?? '') };
|
|
132
|
+
case FreeNodeType.Video:
|
|
133
|
+
return { videoSource: VideoSource.File, src: ctx.o.photoSrc(n.src ?? ''), title: ctx.o.photoAlt(n.src ?? ''), mode: VideoMode.Inline };
|
|
134
|
+
default: return {};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The answer's style, every layer, through the builder's controls: base on the element style, each width on the one
|
|
139
|
+
* wider (tablet on the base, the phone on the tablet), the hover as the node's hover state. */
|
|
140
|
+
function styleInto(node: SerializedNode, n: FreeNode, ctx: Ctx): void {
|
|
141
|
+
const base = freeStyleToSlots(n.styleProps, { rtl: ctx.rtl, held: node.styleProps });
|
|
142
|
+
setStyleProps(node, base);
|
|
143
|
+
let held: Record<string, unknown> = { ...node.styleProps };
|
|
144
|
+
for (const layer of [FreeLayer.Tablet, FreeLayer.Phone]) {
|
|
145
|
+
const style = n.responsive?.[layer];
|
|
146
|
+
if (!style || !Object.keys(style).length) continue;
|
|
147
|
+
const values = freeStyleToSlots(style, { rtl: ctx.rtl, held });
|
|
148
|
+
assertLayer(node, values);
|
|
149
|
+
node.responsive = { ...(node.responsive ?? {}), [layer]: { styleProps: values } };
|
|
150
|
+
held = { ...held, ...values };
|
|
151
|
+
}
|
|
152
|
+
if (n.hover && Object.keys(n.hover).length) {
|
|
153
|
+
const values = freeStyleToSlots(n.hover as FreeStyle, { rtl: ctx.rtl, held: node.styleProps });
|
|
154
|
+
assertLayer(node, values);
|
|
155
|
+
node.stateStyles = { ...(node.stateStyles ?? {}), hover: { ...(node.stateStyles?.['hover'] ?? {}), ...values } };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A layer's controls must be the node's own, as the base's are (`setStyleProps`). */
|
|
160
|
+
function assertLayer(node: SerializedNode, values: Record<string, unknown>): void {
|
|
161
|
+
const probe = { ...node, styleProps: {} };
|
|
162
|
+
setStyleProps(probe, values);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The node's ONE move as the product's interaction: a time entrance (`viewportEnter`) or a depth played by the scroll. */
|
|
166
|
+
function moveOf(n: FreeNode, id: string, ctx: Ctx, beat: number): unknown | null {
|
|
167
|
+
const m = n.move;
|
|
168
|
+
if (!m) return null;
|
|
169
|
+
if (m.trigger === FreeTrigger.Scroll) {
|
|
170
|
+
return { id: `${id}-depth`, trigger: 'scrollProgress', range: 'cover', actions: [{ type: m.action, target: 'self', duration: 1000, delay: 0, easing: 'linear', params: { ...(m.params ?? {}), phone: LAYOUT_DEPTH_ON_PHONE } }] };
|
|
171
|
+
}
|
|
172
|
+
const lead = n.role === 'lead';
|
|
173
|
+
const params: Record<string, unknown> = { ...(m.params ?? {}) };
|
|
174
|
+
if (m.action === 'moveUp') params['distance'] = LAYOUT_RISE[lead ? LayoutRole.Lead : LayoutRole.Support];
|
|
175
|
+
const delay = Math.round(LAYOUT_BEAT_DELAY[Math.min(beat, LAYOUT_BEAT_DELAY.length - 1)] * ctx.pace.gap);
|
|
176
|
+
return {
|
|
177
|
+
id: `${id}-enter`, trigger: 'viewportEnter',
|
|
178
|
+
actions: [{ type: m.action, target: 'self', duration: lead ? ctx.pace.lead : ctx.pace.support, delay, easing: ctx.ease, once: true, ...(Object.keys(params).length ? { params } : {}) }],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The recipe a Slot places: the list composer's frame, or the preset form. */
|
|
183
|
+
function slotOf(n: FreeNode, id: string, ctx: Ctx): SerializedNode {
|
|
184
|
+
const slot = n.slot ?? '';
|
|
185
|
+
if (slot.startsWith(LIST_SLOT)) {
|
|
186
|
+
const alias = slot.slice(LIST_SLOT.length);
|
|
187
|
+
const list = ctx.o.listOf(alias);
|
|
188
|
+
if (!list) throw new ComposeError(`${n.id}: "${alias}" is no list of the plan`);
|
|
189
|
+
const asked = (n.opts ?? []).filter(Boolean);
|
|
190
|
+
const words = [...LIST_SLOT_WORDS.filter(w => !asked.some(a => a.split(':')[0] === w.split(':')[0])), ...asked];
|
|
191
|
+
const mix = listMixFromWords(words, Object.keys(list.roles))!;
|
|
192
|
+
return composeListFrame({ id: `${id}-list`, mix, source: alias, list, locale: ctx.o.locale, label: n.purpose ?? alias, path: n.id, ...(ctx.o.motion ? { motion: ctx.o.motion } : {}) }).frame;
|
|
193
|
+
}
|
|
194
|
+
if (slot.startsWith(FORM_SLOT)) return composePresetForm(`${id}-form`, slot.slice(FORM_SLOT.length), ctx.o.owner, ctx.o.locale);
|
|
195
|
+
throw new ComposeError(`${n.id}: "${slot}" is not a part a free page may place`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** A Button to a section of this page scrolls to it (the product's `scrollTo`: M8-G7, no shareable `#id`). */
|
|
199
|
+
function wireLinks(ctx: Ctx, renamed: Readonly<Record<string, string>> = {}): void {
|
|
200
|
+
for (const { node, to } of ctx.links) {
|
|
201
|
+
if (!ctx.ids.has(to)) throw new ComposeError(`${node.id}: goes to "#${to}", which this page does not have`);
|
|
202
|
+
const target = renamed[to] ?? idOf(ctx, to);
|
|
203
|
+
node.interactions = [...node.interactions, { id: `${node.id}-to`, trigger: 'click', actions: [{ type: 'scrollTo', target, duration: 0, delay: 0, easing: 'ease' }] }];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -1096,6 +1096,8 @@ export interface ListFrameInput {
|
|
|
1096
1096
|
/** vectoriox/iox-ui#122: the mix the frame on the page wears now (the panel's), so the composer can tell the owner's
|
|
1097
1097
|
* edits inside the card from its own drawing. Absent: read from the frame (`listMixOfFrame`). */
|
|
1098
1098
|
readonly was?: LayoutListMix | null;
|
|
1099
|
+
/** The id a NEW frame is made under (a free page's slot, FS3); default `list`. A recompose keeps `previous`'s. */
|
|
1100
|
+
readonly id?: string;
|
|
1099
1101
|
}
|
|
1100
1102
|
|
|
1101
1103
|
/** A recomposed list frame, and what the composer said while composing it (a word drawn as its stand-in…). */
|
|
@@ -1121,7 +1123,7 @@ const LIST_FRAME_PROPS: ReadonlyArray<string> = [LIST_MIX_PROP, 'colorScheme'];
|
|
|
1121
1123
|
* arrangement, role, room and classes. Pure.
|
|
1122
1124
|
*/
|
|
1123
1125
|
export function composeListFrame(input: ListFrameInput, previous?: SerializedNode | null): ListFrame {
|
|
1124
|
-
const composed = composeListOnly(input, previous?.id ?? 'list');
|
|
1126
|
+
const composed = composeListOnly(input, previous?.id ?? input.id ?? 'list');
|
|
1125
1127
|
if (!previous) return { frame: composed.frame, gaps: composed.gaps, edits: [] };
|
|
1126
1128
|
// What the composer draws for the mix the frame wears now: anything else on the page is the owner's (#122).
|
|
1127
1129
|
const was = input.was ?? listMixOfFrame(previous, input.list);
|