@vectoriox/iox-ui 5.150.0 → 5.151.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/fesm2022/vectoriox-iox-ui-generation-core.mjs +622 -63
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +76 -21
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +293 -4
- package/harness-core/index.d.ts +32 -0
- package/package.json +1 -1
- package/src/generation-core/audit-words.ts +2 -1
- package/src/generation-core/check-list.ts +62 -49
- package/src/generation-core/compose-layout.ts +42 -4
- package/src/generation-core/layout-language.ts +17 -0
- package/src/generation-core/list-keep.ts +179 -0
- package/src/generation-core/list-panel.ts +15 -4
- package/src/generation-core/list-table.ts +9 -3
- package/src/generation-core/list-words.ts +340 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/site-spec.generated.ts +47 -0
- package/src/harness-core/business-types.ts +2 -0
- package/src/harness-core/harness-spec.generated.ts +76 -21
- package/styles/iox-design.css +26 -6
|
@@ -11,7 +11,8 @@ import { composeNavHeader, composePresetForm } from './compose-site';
|
|
|
11
11
|
import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
|
|
12
12
|
import { LIST_RULES, LIST_RHYTHMS, listWait } from './list-table';
|
|
13
13
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
14
|
-
import { listMixWords } from './layout-wire';
|
|
14
|
+
import { listMixFromWords, listMixWords } from './layout-wire';
|
|
15
|
+
import { keepListParts, ListPartEdit } from './list-keep';
|
|
15
16
|
import {
|
|
16
17
|
LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHOTO_ASPECT, LAYOUT_TOOLTIP_TRAIT,
|
|
17
18
|
LAYOUT_PHONE_PADDING, LAYOUT_RISE, LAYOUT_TEXT_KINDS, LayoutBleed, LayoutColour, LayoutEase, LayoutEnter, LayoutForm, LayoutGallery, LayoutLayer,
|
|
@@ -138,6 +139,9 @@ export enum LayoutListRole {
|
|
|
138
139
|
Dim = 'list.dim',
|
|
139
140
|
Masonry = 'list.masonry',
|
|
140
141
|
MasonryTwo = 'list.masonry-two',
|
|
142
|
+
/** CW2: a grid that keeps two across on a phone (its columns are the node's own) — named so the shared CSS can hold a
|
|
143
|
+
* half-width tile's title at the lead size. */
|
|
144
|
+
GridTwo = 'list.grid-two',
|
|
141
145
|
/** LI3: strips (the Repeater) — stacked on a phone, two across, or a row to swipe; each row a strip item. */
|
|
142
146
|
Strips = 'list.strips',
|
|
143
147
|
StripsTwo = 'list.strips-two',
|
|
@@ -1053,6 +1057,7 @@ function composeList(id: string, l: LayoutLayer, mix: LayoutListMix, source: str
|
|
|
1053
1057
|
} else {
|
|
1054
1058
|
setStyleProps(items, { display: 'grid', gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gap: LIST_GAP, alignItems: 'stretch', width: FULL });
|
|
1055
1059
|
phone(items, { gridTemplateColumns: mix.phone === LayoutListPhone.TwoUp ? 'repeat(2, minmax(0, 1fr))' : 'minmax(0, 1fr)' });
|
|
1060
|
+
if (mix.phone === LayoutListPhone.TwoUp) items.role = LayoutListRole.GridTwo;
|
|
1056
1061
|
if (mix.phone === LayoutListPhone.Swipe) gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.phone`, 'a grid stacks on a phone; only a row swipes');
|
|
1057
1062
|
}
|
|
1058
1063
|
items.children = [shown];
|
|
@@ -1088,12 +1093,18 @@ export interface ListFrameInput {
|
|
|
1088
1093
|
* (`listColumns`). Absent: wide, as before. */
|
|
1089
1094
|
readonly column?: string;
|
|
1090
1095
|
readonly density?: string;
|
|
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
|
+
* edits inside the card from its own drawing. Absent: read from the frame (`listMixOfFrame`). */
|
|
1098
|
+
readonly was?: LayoutListMix | null;
|
|
1091
1099
|
}
|
|
1092
1100
|
|
|
1093
1101
|
/** A recomposed list frame, and what the composer said while composing it (a word drawn as its stand-in…). */
|
|
1094
1102
|
export interface ListFrame {
|
|
1095
1103
|
readonly frame: SerializedNode;
|
|
1096
1104
|
readonly gaps: ReadonlyArray<LayoutGap>;
|
|
1105
|
+
/** vectoriox/iox-ui#122 (BL-D8): every part of the card the owner changed — kept on the new card, or redrawn (said
|
|
1106
|
+
* before Apply). Empty with no frame on the page. */
|
|
1107
|
+
readonly edits: ReadonlyArray<ListPartEdit>;
|
|
1097
1108
|
}
|
|
1098
1109
|
|
|
1099
1110
|
/** The frame styles the list composer owns (laptop and phone) beyond a new Container's own: a recompose replaces them
|
|
@@ -1110,7 +1121,17 @@ const LIST_FRAME_PROPS: ReadonlyArray<string> = [LIST_MIX_PROP, 'colorScheme'];
|
|
|
1110
1121
|
* arrangement, role, room and classes. Pure.
|
|
1111
1122
|
*/
|
|
1112
1123
|
export function composeListFrame(input: ListFrameInput, previous?: SerializedNode | null): ListFrame {
|
|
1113
|
-
const
|
|
1124
|
+
const composed = composeListOnly(input, previous?.id ?? 'list');
|
|
1125
|
+
if (!previous) return { frame: composed.frame, gaps: composed.gaps, edits: [] };
|
|
1126
|
+
// What the composer draws for the mix the frame wears now: anything else on the page is the owner's (#122).
|
|
1127
|
+
const was = input.was ?? listMixOfFrame(previous, input.list);
|
|
1128
|
+
const baseline = was ? composeListOnly({ ...input, mix: was }, previous.id).frame : null;
|
|
1129
|
+
const kept = keepListParts(previous, baseline, composed.frame);
|
|
1130
|
+
return { frame: keepPlace(previous, { ...composed.frame, children: kept.children }), gaps: composed.gaps, edits: kept.edits };
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/** `composeList` for one frame under an id. */
|
|
1134
|
+
function composeListOnly(input: ListFrameInput, id: string): { frame: SerializedNode; gaps: ReadonlyArray<LayoutGap> } {
|
|
1114
1135
|
const pace = LAYOUT_PACE[(input.motion?.pace ?? LayoutPace.Normal) as LayoutPace] ?? LAYOUT_PACE[LayoutPace.Normal];
|
|
1115
1136
|
const site = { locale: input.locale, sections: [], motion: input.motion } as unknown as LayoutSite;
|
|
1116
1137
|
const ctx = {
|
|
@@ -1124,8 +1145,25 @@ export function composeListFrame(input: ListFrameInput, previous?: SerializedNod
|
|
|
1124
1145
|
const layer = { kind: LayoutLayerKind.Gallery, col: [col[0], col[1]], row: [1, 2], text: input.label, gallery: { slides: [], source: input.source, list: input.mix } } as unknown as LayoutLayer;
|
|
1125
1146
|
const path = input.path ?? 'list';
|
|
1126
1147
|
const lc = { section: { ground: input.ground } as LayoutSection, si: 0, li: 0, path, held: !!input.held, track: 1, order: 0, phoneGap: 0, phoneAlign: 'start' } as LayerCtx;
|
|
1127
|
-
|
|
1128
|
-
|
|
1148
|
+
return { frame: composeList(id, layer, input.mix, input.source, input.list, lc, ctx), gaps: ctx.gaps };
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** The props a part's field is bound to when the card SHOWS it (an image's alt and an item's page link only follow). */
|
|
1152
|
+
const LIST_PART_PROPS: ReadonlySet<string> = new Set(['content', 'src']);
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* The mix a composed list frame wears: its words (`LIST_MIX_PROP`) and the parts its card shows — the list's roles whose
|
|
1156
|
+
* field a part of the card is bound to. Null when the frame carries no mix (not a composed list).
|
|
1157
|
+
*/
|
|
1158
|
+
export function listMixOfFrame(frame: SerializedNode, list: LayoutListBinding): LayoutListMix | null {
|
|
1159
|
+
const words = String(frame.props?.[LIST_MIX_PROP] ?? '').split(' ').filter(Boolean);
|
|
1160
|
+
if (!words.length) return null;
|
|
1161
|
+
const fields = new Set<string>();
|
|
1162
|
+
walkSerialized(frame.children ?? [], node => {
|
|
1163
|
+
for (const b of node.bindings ?? []) if (LIST_PART_PROPS.has(b.prop) && typeof b.path === 'string') fields.add(b.path);
|
|
1164
|
+
});
|
|
1165
|
+
const parts = Object.entries(list.roles).filter(([, field]) => typeof field === 'string' && fields.has(field)).map(([role]) => role);
|
|
1166
|
+
return listMixFromWords(words, parts);
|
|
1129
1167
|
}
|
|
1130
1168
|
|
|
1131
1169
|
/** The recomposed frame on the previous one's place: what the composer owns is the new composition's (a key it no longer
|
|
@@ -556,6 +556,21 @@ export type LayoutMend =
|
|
|
556
556
|
| { kind: LayoutMendKind.ShowList; layer: string; source: string; mix: LayoutListMix }
|
|
557
557
|
| { kind: LayoutMendKind.Column; column: string | null };
|
|
558
558
|
|
|
559
|
+
/** A word of a mix table named by a sentence (`{ k: 'arrange', w: 'strips' }`) — said as the word in English, as its
|
|
560
|
+
* meaning in the owner's language. */
|
|
561
|
+
export interface LayoutWordRef {
|
|
562
|
+
k: string;
|
|
563
|
+
w: string;
|
|
564
|
+
}
|
|
565
|
+
export type LayoutWordsValue = string | number | LayoutWordRef | ReadonlyArray<string | number> | ReadonlyArray<LayoutWordRef>;
|
|
566
|
+
|
|
567
|
+
/** vectoriox/iox-ui#123: what an issue says, as a code and the values it names — a screen says it in the admin's language
|
|
568
|
+
* (the list judge's: `listSentence`, list-words.ts); `message` stays the English the model and the log read. */
|
|
569
|
+
export interface LayoutIssueWords {
|
|
570
|
+
code: string;
|
|
571
|
+
params: Readonly<Record<string, LayoutWordsValue>>;
|
|
572
|
+
}
|
|
573
|
+
|
|
559
574
|
export interface LayoutIssue {
|
|
560
575
|
code: `${LayoutIssueCode}`;
|
|
561
576
|
/** `sections[2].layers[1].box`, or `sections` for the page. */
|
|
@@ -563,6 +578,8 @@ export interface LayoutIssue {
|
|
|
563
578
|
message: string;
|
|
564
579
|
/** Set when the composer can settle it alone (`mendLayout`); the model is asked only for what is left. */
|
|
565
580
|
mend?: LayoutMend;
|
|
581
|
+
/** The issue's code and values, when the judge that raised it words them (the list judge, #123). */
|
|
582
|
+
words?: LayoutIssueWords;
|
|
566
583
|
}
|
|
567
584
|
|
|
568
585
|
export interface LayoutSite {
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { SerializedNode } from './serialized-node';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE OWNER'S EDITS INSIDE A LIST CARD (vectoriox/iox-ui#122, board bindings-list BL-D8). Recomposing a list (Bindings ▸
|
|
5
|
+
* List, Ask) draws its card again from the new mix; before #122 the card template was replaced and whatever the owner had
|
|
6
|
+
* changed inside it was lost silently. `keepListParts` keeps it, part by part — the carry's rule (site-redesign RD1:
|
|
7
|
+
* the owner's is placed, never retyped, and what finds no place is SAID, never dropped silently):
|
|
8
|
+
*
|
|
9
|
+
* - What is the owner's is told by the composer itself: the frame as the composer would draw it with the mix it wears
|
|
10
|
+
* now (`baseline`) against the frame on the page (`previous`). A value that differs is the owner's; one that does not
|
|
11
|
+
* is the composer's and follows the new mix.
|
|
12
|
+
* - A part is found by its ROLE (`card.title`, `card.eyebrow`…), else by its place in the frame (the composer's ids are
|
|
13
|
+
* the frame id + a fixed suffix: `-item-image`). An edited part whose role survives in the new card takes the edits
|
|
14
|
+
* there (kept); one whose role is gone is redrawn — and listed.
|
|
15
|
+
* - A node the owner added goes into the same parent part in the new card (at the same place among its children);
|
|
16
|
+
* a part the owner deleted stays deleted. Either is listed as redrawn when its parent part is gone.
|
|
17
|
+
*
|
|
18
|
+
* Pure: `composed` is not changed; the result's `children` are the new card with the owner's edits.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** What became of one part the owner changed. */
|
|
22
|
+
export enum ListPartOutcome {
|
|
23
|
+
/** The part's role is in the new card: the owner's edits are on it there. */
|
|
24
|
+
Kept = 'kept',
|
|
25
|
+
/** The new card has no such part: the edits are lost — said before Apply (the kept notice, BL-D8). */
|
|
26
|
+
Redrawn = 'redrawn',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** How the owner changed a part. */
|
|
30
|
+
export enum ListPartChange {
|
|
31
|
+
/** Values on a composed part (a style, its words, an element style, a binding…). */
|
|
32
|
+
Edited = 'edited',
|
|
33
|
+
/** A node the owner put in the card. */
|
|
34
|
+
Added = 'added',
|
|
35
|
+
/** A composed part the owner deleted. */
|
|
36
|
+
Removed = 'removed',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** One part the owner changed, and what became of it. */
|
|
40
|
+
export interface ListPartEdit {
|
|
41
|
+
/** The part's key: its role, else its place in the frame (`item-image`), else `node:<id>` for one the owner added. */
|
|
42
|
+
readonly part: string;
|
|
43
|
+
/** Its composite role, when it has one (what a screen names: "the card's year"). */
|
|
44
|
+
readonly role?: string;
|
|
45
|
+
/** The node's type (Heading, Image…). */
|
|
46
|
+
readonly type: string;
|
|
47
|
+
readonly change: `${ListPartChange}`;
|
|
48
|
+
/** How many values the owner changed on it (an Edited part); 1 for an added or removed one. */
|
|
49
|
+
readonly edits: number;
|
|
50
|
+
readonly outcome: `${ListPartOutcome}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ListPartsKept {
|
|
54
|
+
/** The new card, with the owner's edits. */
|
|
55
|
+
readonly children: SerializedNode[];
|
|
56
|
+
/** Every part the owner changed, kept or redrawn. */
|
|
57
|
+
readonly edits: ReadonlyArray<ListPartEdit>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Node fields whose values are maps — compared and carried value by value (`styleProps.color`, `props.content`…). */
|
|
61
|
+
const MAP_FIELDS: ReadonlyArray<string> = ['props', 'styleProps', 'stateStyles', 'responsive', 'stateTriggers'];
|
|
62
|
+
/** Fields that are the node's identity or its subtree, never an edit. */
|
|
63
|
+
const SKIP_FIELDS: ReadonlySet<string> = new Set(['id', 'children']);
|
|
64
|
+
const same = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);
|
|
65
|
+
|
|
66
|
+
interface Placed {
|
|
67
|
+
node: SerializedNode;
|
|
68
|
+
parent: string | null;
|
|
69
|
+
index: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Every node under the frame by its part key (the first of a key wins; a repeat is keyed by its place). */
|
|
73
|
+
function partsOf(frame: SerializedNode): Map<string, Placed> {
|
|
74
|
+
const out = new Map<string, Placed>();
|
|
75
|
+
const prefix = `${frame.id}-`;
|
|
76
|
+
const keyOf = (n: SerializedNode): string => n.role ?? (n.id.startsWith(prefix) ? n.id.slice(prefix.length) : `node:${n.id}`);
|
|
77
|
+
const visit = (n: SerializedNode, parent: string | null, index: number) => {
|
|
78
|
+
let key = keyOf(n);
|
|
79
|
+
if (out.has(key)) key = n.id.startsWith(prefix) ? n.id.slice(prefix.length) : `node:${n.id}`;
|
|
80
|
+
if (!out.has(key)) out.set(key, { node: n, parent, index });
|
|
81
|
+
(n.children ?? []).forEach((c, i) => visit(c, key, i));
|
|
82
|
+
};
|
|
83
|
+
(frame.children ?? []).forEach((c, i) => visit(c, null, i));
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** One value the owner changed: a field, or one key of a map field (`value` undefined: the owner removed it). */
|
|
88
|
+
interface Edit {
|
|
89
|
+
field: string;
|
|
90
|
+
key?: string;
|
|
91
|
+
value: unknown;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** What differs on a part between the composer's drawing and the page. */
|
|
95
|
+
function editsOn(baseline: SerializedNode, page: SerializedNode): Edit[] {
|
|
96
|
+
const edits: Edit[] = [];
|
|
97
|
+
const fields = new Set([...Object.keys(baseline), ...Object.keys(page)].filter(f => !SKIP_FIELDS.has(f)));
|
|
98
|
+
for (const field of fields) {
|
|
99
|
+
const was = (baseline as unknown as Record<string, unknown>)[field];
|
|
100
|
+
const now = (page as unknown as Record<string, unknown>)[field];
|
|
101
|
+
if (same(was, now)) continue;
|
|
102
|
+
if (MAP_FIELDS.includes(field) && (was === undefined || isMap(was)) && (now === undefined || isMap(now))) {
|
|
103
|
+
const a = (was ?? {}) as Record<string, unknown>;
|
|
104
|
+
const b = (now ?? {}) as Record<string, unknown>;
|
|
105
|
+
for (const key of new Set([...Object.keys(a), ...Object.keys(b)])) if (!same(a[key], b[key])) edits.push({ field, key, value: b[key] });
|
|
106
|
+
} else {
|
|
107
|
+
edits.push({ field, value: now });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return edits;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const isMap = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
114
|
+
|
|
115
|
+
function applyEdits(node: SerializedNode, edits: ReadonlyArray<Edit>): void {
|
|
116
|
+
const target = node as unknown as Record<string, unknown>;
|
|
117
|
+
for (const e of edits) {
|
|
118
|
+
if (e.key === undefined) {
|
|
119
|
+
if (e.value === undefined) delete target[e.field];
|
|
120
|
+
else target[e.field] = structuredClone(e.value);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const map = { ...((target[e.field] as Record<string, unknown> | undefined) ?? {}) };
|
|
124
|
+
if (e.value === undefined) delete map[e.key];
|
|
125
|
+
else map[e.key] = structuredClone(e.value);
|
|
126
|
+
target[e.field] = map;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The new card (`composed`'s children) with the owner's edits from the frame on the page (`previous`), told from what the
|
|
132
|
+
* composer would draw for the mix the frame wears now (`baseline`). With no baseline nothing is known to be the owner's:
|
|
133
|
+
* the new card as composed, nothing listed.
|
|
134
|
+
*/
|
|
135
|
+
export function keepListParts(previous: SerializedNode, baseline: SerializedNode | null, composed: SerializedNode): ListPartsKept {
|
|
136
|
+
const out = structuredClone(composed);
|
|
137
|
+
out.id = previous.id;
|
|
138
|
+
if (!baseline) return { children: out.children ?? [], edits: [] };
|
|
139
|
+
// The composer draws every frame from its id: a baseline drawn under another id is read under the page's.
|
|
140
|
+
const was = partsOf({ ...baseline, id: previous.id });
|
|
141
|
+
const page = partsOf(previous);
|
|
142
|
+
const now = partsOf(out);
|
|
143
|
+
const edits: ListPartEdit[] = [];
|
|
144
|
+
const say = (part: string, n: SerializedNode, change: ListPartChange, count: number, kept: boolean) =>
|
|
145
|
+
edits.push({ part, ...(n.role ? { role: n.role } : {}), type: n.type, change, edits: count, outcome: kept ? ListPartOutcome.Kept : ListPartOutcome.Redrawn });
|
|
146
|
+
|
|
147
|
+
for (const [key, placed] of page) {
|
|
148
|
+
const drawn = was.get(key);
|
|
149
|
+
if (!drawn) {
|
|
150
|
+
// The owner added it — unless its parent is itself the owner's (it travels inside it).
|
|
151
|
+
if (placed.parent !== null && !was.has(placed.parent)) continue;
|
|
152
|
+
const into = placed.parent === null ? out : now.get(placed.parent)?.node;
|
|
153
|
+
if (into) {
|
|
154
|
+
const children = [...(into.children ?? [])];
|
|
155
|
+
children.splice(Math.min(placed.index, children.length), 0, structuredClone(placed.node));
|
|
156
|
+
into.children = children;
|
|
157
|
+
}
|
|
158
|
+
say(key, placed.node, ListPartChange.Added, 1, !!into);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const changes = editsOn(drawn.node, placed.node);
|
|
162
|
+
if (!changes.length) continue;
|
|
163
|
+
const target = now.get(key)?.node;
|
|
164
|
+
if (target) applyEdits(target, changes);
|
|
165
|
+
say(key, placed.node, ListPartChange.Edited, changes.length, !!target);
|
|
166
|
+
}
|
|
167
|
+
for (const [key, drawn] of was) {
|
|
168
|
+
if (page.has(key)) continue;
|
|
169
|
+
// The owner deleted it — once, at the topmost part deleted (its own parts went with it).
|
|
170
|
+
if (drawn.parent !== null && !page.has(drawn.parent)) continue;
|
|
171
|
+
const gone = now.get(key);
|
|
172
|
+
if (gone) {
|
|
173
|
+
const parent = gone.parent === null ? out : now.get(gone.parent)?.node;
|
|
174
|
+
if (parent) parent.children = (parent.children ?? []).filter(c => c !== gone.node);
|
|
175
|
+
}
|
|
176
|
+
say(key, drawn.node, ListPartChange.Removed, 1, !!gone);
|
|
177
|
+
}
|
|
178
|
+
return { children: out.children ?? [], edits };
|
|
179
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
LIST_INGREDIENTS, LIST_TABLE, ListIngredient, ListWordRefusal, listBuiltWords, listMeaning, listWordRefusal, listWordTier,
|
|
7
7
|
} from './list-table';
|
|
8
|
+
import { ListSaid } from './list-words';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Bindings ▸ List (AW11-D18, board award-lists "Where an owner sets it"): the rows of the ONE list group, framework-free so
|
|
@@ -46,6 +47,8 @@ export interface ListPanelContext {
|
|
|
46
47
|
readonly tier?: string | null;
|
|
47
48
|
/** The business type's never rule (`LIST_NEVER`). */
|
|
48
49
|
readonly never?: LayoutListNever | null;
|
|
50
|
+
/** The admin's language — each word's hint is its meaning in it (`he`: the contract's `LIST.meaningsHe`, #123). */
|
|
51
|
+
readonly locale?: string | null;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
const MANY: ReadonlySet<string> = new Set(LIST_TABLE.many as ReadonlyArray<string>);
|
|
@@ -70,7 +73,7 @@ export function listPanelRows(mix: LayoutListMix, ctx: ListPanelContext): ListPa
|
|
|
70
73
|
value: listMixValue(mix, k),
|
|
71
74
|
words: listBuiltWords(k).map(word => ({
|
|
72
75
|
word,
|
|
73
|
-
meaning: listMeaning(k, word),
|
|
76
|
+
meaning: listMeaning(k, word, ctx.locale),
|
|
74
77
|
pro: listWordTier(k, word) === 'pro',
|
|
75
78
|
mouse: k === HOVER,
|
|
76
79
|
refusal: listWordRefusal(k, word, ctx.shape, ctx.tier, ctx.never),
|
|
@@ -82,7 +85,10 @@ export function listPanelRows(mix: LayoutListMix, ctx: ListPanelContext): ListPa
|
|
|
82
85
|
* refused (the pick is not applied). */
|
|
83
86
|
export interface ListPick {
|
|
84
87
|
readonly mix: LayoutListMix;
|
|
88
|
+
/** The mends in English — the words the model and the log read. */
|
|
85
89
|
readonly said: ReadonlyArray<string>;
|
|
90
|
+
/** The same mends as codes and values: a screen says each with `listSaidSentence(w, lang)` (#123, BL-D6). */
|
|
91
|
+
readonly words: ReadonlyArray<ListSaid>;
|
|
86
92
|
readonly refused: ReadonlyArray<LayoutIssue>;
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -111,12 +117,17 @@ export function pickListWord(mix: LayoutListMix, k: ListIngredient, word: string
|
|
|
111
117
|
const refusal = listWordRefusal(k, word, ctx.shape, ctx.tier, ctx.never);
|
|
112
118
|
const adding = !(k === 'move' || k === 'hover') || !(mix[k] as string[]).includes(word);
|
|
113
119
|
if (refusal && adding) {
|
|
114
|
-
return { mix, said: [], refused: [{ code: LayoutIssueCode.Value, path: `list.${k}`, message: `${k} "${word}": ${refusal}` }] };
|
|
120
|
+
return { mix, said: [], words: [], refused: [{ code: LayoutIssueCode.Value, path: `list.${k}`, message: `${k} "${word}": ${refusal}` }] };
|
|
115
121
|
}
|
|
116
122
|
const next = withListWord(mix, k, word);
|
|
117
123
|
const issues = checkList(next, ctx.shape, 'list', ctx.never, { tier: ctx.tier });
|
|
118
124
|
const refused = issues.filter(i => !i.mend);
|
|
119
|
-
if (refused.length) return { mix, said: [], refused };
|
|
125
|
+
if (refused.length) return { mix, said: [], words: [], refused };
|
|
120
126
|
const mend = issues.map(i => i.mend).find(m => m?.kind === LayoutMendKind.List);
|
|
121
|
-
return {
|
|
127
|
+
return {
|
|
128
|
+
mix: mend?.kind === LayoutMendKind.List ? mend.mix : next,
|
|
129
|
+
said: issues.map(i => i.message),
|
|
130
|
+
words: issues.flatMap(i => (i.words ? [i.words as ListSaid] : [])),
|
|
131
|
+
refused: [],
|
|
132
|
+
};
|
|
122
133
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CommerceLanguage, commerceLanguage } from '@vectoriox/iox-ui/commerce-core';
|
|
2
|
+
|
|
1
3
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -17,6 +19,8 @@ export interface ListWait { phase: string; drawnAs: string | null }
|
|
|
17
19
|
|
|
18
20
|
const WAITS = LIST_TABLE.waits as Readonly<Record<string, ListWait>>;
|
|
19
21
|
const MEANINGS = LIST_TABLE.meanings as Readonly<Record<string, string>>;
|
|
22
|
+
/** vectoriox/iox-ui#123 (BL-D7): the meanings in Hebrew, key for key (the contract's build fails on a missing one). */
|
|
23
|
+
const MEANINGS_HE = ((LIST_TABLE as { meaningsHe?: unknown }).meaningsHe ?? {}) as Readonly<Record<string, string>>;
|
|
20
24
|
|
|
21
25
|
/** Every word of an ingredient. */
|
|
22
26
|
export function listIngredientWords(k: ListIngredient): ReadonlyArray<string> {
|
|
@@ -33,9 +37,11 @@ export function listBuiltWords(k: ListIngredient): string[] {
|
|
|
33
37
|
return listIngredientWords(k).filter(w => !listWait(k, w));
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
/** What a word means, in the words the model and the owner read (the word itself when the table has none).
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
/** What a word means, in the words the model and the owner read (the word itself when the table has none). The model
|
|
41
|
+
* reads English; an owner reads it in the admin's language (`he`, `he-IL`, `iw` — commerce-core's ONE language rule). */
|
|
42
|
+
export function listMeaning(k: ListIngredient, word: string, locale?: string | null): string {
|
|
43
|
+
const key = `${k}.${word}`;
|
|
44
|
+
return (commerceLanguage(locale) === CommerceLanguage.He ? MEANINGS_HE[key] : undefined) ?? MEANINGS[key] ?? word;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
// ── AW11 (award-ingredients-plan.md §7.1f, board award-lists): the award tier, the rhythms, what each word needs ─────
|