@vectoriox/iox-ui 5.135.0 → 5.137.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/composite-core/index.d.ts +15 -2
- package/design-core/index.d.ts +184 -9
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -36
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +28 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +296 -48
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1269 -154
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +7 -3
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +355 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +481 -89
- package/harness-core/index.d.ts +4 -2
- package/index.d.ts +105 -3
- package/package.json +1 -1
- package/src/assist-core/page-sections.ts +4 -31
- package/src/composite-core/slider.ts +35 -0
- package/src/design-core/design-settings.ts +16 -3
- package/src/design-core/design-token.model.ts +3 -0
- package/src/design-core/flavor-spec.generated.ts +98 -25
- package/src/design-core/motion-language.ts +12 -9
- package/src/design-core/preloader-of.ts +26 -0
- package/src/design-core/preloader.ts +174 -0
- package/src/design-core/public-api.ts +2 -0
- package/src/design-core/style-presets.ts +3 -1
- package/src/generation-core/carry.ts +37 -0
- package/src/generation-core/compose-site.ts +222 -9
- package/src/generation-core/node-baselines.generated.ts +2 -1
- package/src/generation-core/opening-edit.ts +240 -0
- package/src/generation-core/opening-mix.ts +639 -0
- package/src/generation-core/patterns.ts +3 -0
- package/src/generation-core/plan-wire.ts +26 -4
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/redesign-run.ts +42 -2
- package/src/generation-core/site-build-run.ts +27 -1
- package/src/generation-core/site-plan.model.ts +3 -1
- package/src/generation-core/site-spec.generated.ts +137 -84
- package/src/generation-core/validate-site-plan.ts +5 -3
- package/src/harness-core/starting-design.ts +8 -4
- package/styles/iox-design.css +32 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { carryButtonLink, carryInto } from './carry';
|
|
2
|
+
import { composeOpening, ComposedOpening, OpeningInput, openingContextOf } from './compose-site';
|
|
3
|
+
import { headerShape } from './header-edit';
|
|
4
|
+
import {
|
|
5
|
+
checkOpening, drawnOpeningMix, OpeningIngredient, openingGalleryIdOf, openingMix, OpeningMix, OpeningMedia, OpeningRepair, OpeningRole,
|
|
6
|
+
OPENING_MIX_PROP, storedOpeningMix,
|
|
7
|
+
} from './opening-mix';
|
|
8
|
+
import { SerializedNode, walkSerialized } from './serialized-node';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* EDITING AN OPENING IN THE BUILDER (AW8, board award-opening — OB-2, OB-4, OB-5, OB-6): what Bindings ▸ Opening and the
|
|
12
|
+
* Opening studio read off a page's opening, and what Apply writes. Pure, one recipe with the generator: every opening is
|
|
13
|
+
* `composeOpening(mix)`; the builder never builds one by hand.
|
|
14
|
+
*
|
|
15
|
+
* - `readOpening` — the mix the opening root stores (`openingMix`), and which rows the owner changed by hand (Custom).
|
|
16
|
+
* - `applyOpeningMix` — the opening for a new mix: the owner's words, pictures, film, button links, card, badge and form
|
|
17
|
+
* are carried into the parts the new mix has, and what found no place is said (OB-4) — never dropped silently.
|
|
18
|
+
* - `openingFromSection` — "Make this an opening" (OB-6): a hand-made first section becomes the default opening, carrying
|
|
19
|
+
* its words, its first picture and its first button by Ask's swap rule (generation-core `carryInto`).
|
|
20
|
+
* - `openingAdvice` — `checkOpening` as advice: what it would mend, never mended by itself (as `headerAdvice`).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** What an opening is composed from in the builder: the studio (its name, pages, language, look) — the mix aside. */
|
|
24
|
+
export type OpeningSite = Omit<OpeningInput, 'mix' | 'asAsked'>;
|
|
25
|
+
|
|
26
|
+
/** The page's opening: its first root section composed as one (role `opening`), else null. */
|
|
27
|
+
export function findOpening(layout: ReadonlyArray<SerializedNode>): SerializedNode | null {
|
|
28
|
+
const first = layout.find(n => !n.isGlobal);
|
|
29
|
+
return first?.role === OpeningRole.Root ? first : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The roles each Bindings row (and studio tab) reads: a row is Custom when one of its parts changed by hand. */
|
|
33
|
+
const ROW_ROLES: Readonly<Record<OpeningIngredient, ReadonlyArray<string>>> = {
|
|
34
|
+
[OpeningIngredient.Frame]: [OpeningRole.Frame, OpeningRole.FrameSettles],
|
|
35
|
+
[OpeningIngredient.Media]: [OpeningRole.Media, OpeningRole.MediaZooms, OpeningRole.Second, OpeningRole.Pair, OpeningRole.Film, OpeningRole.Slides, OpeningRole.Object, OpeningRole.Form],
|
|
36
|
+
[OpeningIngredient.Words]: [OpeningRole.Words, OpeningRole.Title, OpeningRole.Lead, OpeningRole.Action, OpeningRole.Apart, OpeningRole.ApartWord, OpeningRole.Aside, OpeningRole.Cutout, OpeningRole.Scrim],
|
|
37
|
+
[OpeningIngredient.Extras]: [OpeningRole.Card, OpeningRole.Badge, OpeningRole.Cue],
|
|
38
|
+
[OpeningIngredient.Motion]: [],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** The props that are the owner's CONTENT (words, pictures, a film, a form's identity) — never a sign of a hand edit. */
|
|
42
|
+
const CONTENT_PROPS: ReadonlyArray<string> = [OPENING_MIX_PROP, 'src', 'poster', 'frames', 'formId', 'name'];
|
|
43
|
+
|
|
44
|
+
/** A part's shape without its content: what it is made of and what it wears. */
|
|
45
|
+
function partShape(node: SerializedNode): string {
|
|
46
|
+
const strip = (n: SerializedNode): SerializedNode => ({
|
|
47
|
+
...n, props: Object.fromEntries(Object.entries(n.props ?? {}).filter(([k]) => !CONTENT_PROPS.includes(k))), children: (n.children ?? []).map(strip),
|
|
48
|
+
});
|
|
49
|
+
return headerShape(strip(node));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Every part with a role in `roles`, by role, in reading order (the frame is read as its own props, not its children). */
|
|
53
|
+
function partsOf(root: SerializedNode, roles: ReadonlyArray<string>): string {
|
|
54
|
+
const out: string[] = [];
|
|
55
|
+
walkSerialized([root], n => {
|
|
56
|
+
if (!n.role || !roles.includes(n.role)) return;
|
|
57
|
+
const own = n.role === OpeningRole.Frame || n.role === OpeningRole.FrameSettles ? { ...n, children: [] } : n;
|
|
58
|
+
out.push(`${n.role}:${partShape(own)}`);
|
|
59
|
+
});
|
|
60
|
+
return out.join('|');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface OpeningReading {
|
|
64
|
+
/** The mix the opening stores. */
|
|
65
|
+
mix: OpeningMix;
|
|
66
|
+
/** The rows the owner changed by hand (board 2: a drifted row reads Custom). */
|
|
67
|
+
custom: OpeningIngredient[];
|
|
68
|
+
/** The gallery mix it is, or null. */
|
|
69
|
+
galleryId: string | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The opening composed as `mix` for the studio, with the same id — what `readOpening` compares and Apply starts from. */
|
|
73
|
+
function compose(mix: OpeningMix, site: OpeningSite, id: string): ComposedOpening {
|
|
74
|
+
return composeOpening({ ...site, mix, asAsked: true }, { id });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What an opening is (OB-5): its stored mix, and which rows are no longer what that mix composes. Null: the section
|
|
78
|
+
* stores no mix (a hand-made section — OB-6's "Make this an opening", never an inferred mix). Pure. */
|
|
79
|
+
export function readOpening(root: SerializedNode, site: OpeningSite): OpeningReading | null {
|
|
80
|
+
const mix = storedOpeningMix(root);
|
|
81
|
+
if (!mix) return null;
|
|
82
|
+
const base = compose(mix, siteFor(site, root), root.id).section;
|
|
83
|
+
const custom = (Object.keys(ROW_ROLES) as OpeningIngredient[])
|
|
84
|
+
.filter(k => ROW_ROLES[k].length && partsOf(root, ROW_ROLES[k]) !== partsOf(base, ROW_ROLES[k]));
|
|
85
|
+
return { mix, custom, galleryId: openingGalleryIdOf(mix) };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ── The carry (OB-4) ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
const PICTURE_ROLES: ReadonlyArray<string> = [OpeningRole.Media, OpeningRole.MediaZooms, OpeningRole.Second, OpeningRole.Object, OpeningRole.Cutout];
|
|
91
|
+
|
|
92
|
+
/** The words a node shows (a button's are its label's). */
|
|
93
|
+
function wordsOf(n: SerializedNode | undefined): string {
|
|
94
|
+
if (!n) return '';
|
|
95
|
+
const own = n.props?.['content'] ?? n.props?.['label'];
|
|
96
|
+
if (typeof own === 'string' && own.trim()) return own.replace(/<[^>]+>/g, '').trim();
|
|
97
|
+
for (const c of n.children ?? []) { const w = wordsOf(c); if (w) return w; }
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const byRole = (root: SerializedNode, role: string): SerializedNode[] => {
|
|
102
|
+
const out: SerializedNode[] = [];
|
|
103
|
+
walkSerialized([root], n => { if (n.role === role) out.push(n); });
|
|
104
|
+
return out;
|
|
105
|
+
};
|
|
106
|
+
const firstRole = (root: SerializedNode, role: string): SerializedNode | undefined => byRole(root, role)[0];
|
|
107
|
+
|
|
108
|
+
/** The pictures of an opening, in order: the media, the second, the slideshow's, the object, the cut-out. */
|
|
109
|
+
function picturesOf(root: SerializedNode): SerializedNode[] {
|
|
110
|
+
const out: SerializedNode[] = [];
|
|
111
|
+
walkSerialized([root], (n, ancestors) => {
|
|
112
|
+
if (n.type !== 'Image') return;
|
|
113
|
+
if ((n.role && PICTURE_ROLES.includes(n.role)) || ancestors.some(a => a.role === OpeningRole.Slides)) out.push(n);
|
|
114
|
+
});
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The title's words as the owner wrote them: the heading, or the words placed apart read as one line. */
|
|
119
|
+
function titleWordsOf(root: SerializedNode): string {
|
|
120
|
+
const apart = firstRole(root, OpeningRole.Apart);
|
|
121
|
+
if (apart) return (apart.children ?? []).map(c => wordsOf(c)).filter(Boolean).join(' ');
|
|
122
|
+
return wordsOf(firstRole(root, OpeningRole.Title));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The site an opening is recomposed for: its display words are the owner's title (a re-mix never rewrites them). */
|
|
126
|
+
function siteFor(site: OpeningSite, current: SerializedNode): OpeningSite {
|
|
127
|
+
const title = titleWordsOf(current);
|
|
128
|
+
return title ? { ...site, business: { ...(site.business ?? { name: '' }), name: title } } : site;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Something of the owner's that the new mix has no place for — said before Apply. */
|
|
132
|
+
export interface OpeningNotPlaced {
|
|
133
|
+
role: string;
|
|
134
|
+
/** Its words, or empty (a picture). */
|
|
135
|
+
words: string;
|
|
136
|
+
nodeId: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface OpeningApplied {
|
|
140
|
+
/** The opening for the new mix — the same id, with the owner's content. */
|
|
141
|
+
section: SerializedNode;
|
|
142
|
+
mix: OpeningMix;
|
|
143
|
+
/** What found no place (empty: everything was carried). */
|
|
144
|
+
notPlaced: OpeningNotPlaced[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const setWords = (n: SerializedNode, words: string): void => {
|
|
148
|
+
if (n.type === 'ButtonBlock') {
|
|
149
|
+
const label = (n.children ?? []).find(c => c.type === 'Text');
|
|
150
|
+
if (label) label.props = { ...label.props, content: words };
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
n.props = { ...n.props, content: words };
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The owner's content carried from one opening into another, part for part (OB-4): the title, the line, the action (its
|
|
158
|
+
* words and where it leads), the cue's and the badge's words, the pictures in order, the film, the card's words and
|
|
159
|
+
* picture, the form (verbatim — its id, its fields). Returns what found no place.
|
|
160
|
+
*/
|
|
161
|
+
function carryOpening(from: SerializedNode, to: SerializedNode): OpeningNotPlaced[] {
|
|
162
|
+
const notPlaced: OpeningNotPlaced[] = [];
|
|
163
|
+
const miss = (n: SerializedNode, words = wordsOf(n)) => notPlaced.push({ role: n.role ?? n.type, words, nodeId: n.id });
|
|
164
|
+
for (const role of [OpeningRole.Lead, OpeningRole.Action, OpeningRole.Cue] as const) {
|
|
165
|
+
const src = firstRole(from, role);
|
|
166
|
+
if (!src) continue;
|
|
167
|
+
const dst = firstRole(to, role);
|
|
168
|
+
if (!dst) { if (role !== OpeningRole.Cue) miss(src); continue; }
|
|
169
|
+
setWords(dst, wordsOf(src));
|
|
170
|
+
if (role === OpeningRole.Action) carryButtonLink(src, dst);
|
|
171
|
+
}
|
|
172
|
+
const badge = firstRole(from, OpeningRole.Badge);
|
|
173
|
+
if (badge) {
|
|
174
|
+
const dst = firstRole(to, OpeningRole.Badge);
|
|
175
|
+
const words = wordsOf(badge);
|
|
176
|
+
if (dst) (dst.children ?? []).forEach(c => setWords(c, words));
|
|
177
|
+
else miss(badge, words);
|
|
178
|
+
}
|
|
179
|
+
const pictures = picturesOf(from).filter(p => typeof p.props?.['src'] === 'string' && p.props['src']);
|
|
180
|
+
const slots = picturesOf(to);
|
|
181
|
+
pictures.forEach((p, i) => {
|
|
182
|
+
const slot = slots[i];
|
|
183
|
+
if (!slot) { miss(p, ''); return; }
|
|
184
|
+
slot.props = { ...slot.props, src: p.props['src'], alt: p.props['alt'] ?? slot.props['alt'] ?? '' };
|
|
185
|
+
});
|
|
186
|
+
const film = firstRole(from, OpeningRole.Film);
|
|
187
|
+
if (film && film.props?.['src']) {
|
|
188
|
+
const dst = firstRole(to, OpeningRole.Film);
|
|
189
|
+
if (dst) dst.props = { ...dst.props, ...Object.fromEntries(['src', 'poster', 'frames'].filter(k => k in film.props).map(k => [k, film.props[k]])) };
|
|
190
|
+
else miss(film, '');
|
|
191
|
+
}
|
|
192
|
+
const card = firstRole(from, OpeningRole.Card);
|
|
193
|
+
if (card) {
|
|
194
|
+
const dst = firstRole(to, OpeningRole.Card);
|
|
195
|
+
if (!dst) miss(card);
|
|
196
|
+
else carryInto(card, dst);
|
|
197
|
+
}
|
|
198
|
+
const form = firstRole(from, OpeningRole.Form);
|
|
199
|
+
if (form) {
|
|
200
|
+
const dst = firstRole(to, OpeningRole.Form);
|
|
201
|
+
if (!dst) miss(form, wordsOf(form));
|
|
202
|
+
else dst.children = JSON.parse(JSON.stringify(form.children ?? []));
|
|
203
|
+
}
|
|
204
|
+
return notPlaced;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The opening for `next` (OB-4): the recipe's opening for the new mix, with the owner's content carried in, and what
|
|
208
|
+
* found no place said. The same id, still the page's first section. Pure. */
|
|
209
|
+
export function applyOpeningMix(current: SerializedNode, next: OpeningMix, site: OpeningSite): OpeningApplied {
|
|
210
|
+
const fresh = compose(next, siteFor(site, current), current.id);
|
|
211
|
+
const section = fresh.section;
|
|
212
|
+
const notPlaced = carryOpening(current, section);
|
|
213
|
+
return { section, mix: fresh.mix, notPlaced };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** "Make this an opening" (OB-6): a hand-made first section as the default opening — its words, first picture and first
|
|
217
|
+
* button carried by the swap rule; what found no place said. The same id. Pure. */
|
|
218
|
+
export function openingFromSection(section: SerializedNode, site: OpeningSite, mix: OpeningMix = openingMix()): OpeningApplied {
|
|
219
|
+
const headings: SerializedNode[] = [];
|
|
220
|
+
walkSerialized([section], n => { if (n.type === 'Heading') headings.push(n); });
|
|
221
|
+
const named = wordsOf(headings[0]);
|
|
222
|
+
const at: OpeningSite = named ? { ...site, business: { ...(site.business ?? { name: '' }), name: named } } : site;
|
|
223
|
+
const fresh = compose(mix, at, section.id);
|
|
224
|
+
const lost = carryInto(section, fresh.section);
|
|
225
|
+
return { section: fresh.section, mix: fresh.mix, notPlaced: lost.map(n => ({ role: n.role ?? n.type, words: n.type === 'Image' ? '' : wordsOf(n), nodeId: n.id })) };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** What `checkOpening` would mend in a mix on this site — said in the studio, never applied by itself. */
|
|
229
|
+
export function openingAdvice(mix: OpeningMix, site: OpeningSite): OpeningRepair[] {
|
|
230
|
+
return checkOpening(drawnOpeningMix(mix).drawn, openingContextOf(site)).repairs;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The mix the advice's one action applies (the check's own mend), or null. */
|
|
234
|
+
export function openingAdviceMix(mix: OpeningMix, site: OpeningSite): OpeningMix | null {
|
|
235
|
+
const checked = checkOpening(drawnOpeningMix(mix).drawn, openingContextOf(site));
|
|
236
|
+
return checked.repairs.length ? checked.mix : null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Media that move on their own — the slideshow's pause control is part of them (board 5). */
|
|
240
|
+
export const MOVING_OPENING_MEDIA: ReadonlySet<string> = new Set([OpeningMedia.Film, OpeningMedia.Slideshow]);
|