@vectoriox/iox-ui 5.194.0 → 5.195.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/actions-core/index.d.ts +1 -0
- package/commerce-core/index.d.ts +0 -1
- package/composite-core/index.d.ts +28 -11
- package/design-core/index.d.ts +44 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +1 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +0 -2
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +65 -34
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +142 -60
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +244 -16
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +15 -16
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +141 -4
- package/index.d.ts +8 -7
- package/package.json +1 -1
- package/src/actions-core/public-api.ts +3 -0
- package/src/commerce-core/shop-display.ts +0 -2
- package/src/composite-core/lightbox.ts +27 -8
- package/src/composite-core/shop.ts +45 -28
- package/src/design-core/close-word.ts +18 -0
- package/src/design-core/contrast-audit.ts +24 -14
- package/src/design-core/locale-direction.ts +17 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/design-core/token-css.ts +62 -3
- package/src/generation-core/audit-site.ts +26 -5
- package/src/generation-core/audit-words.ts +8 -0
- package/src/generation-core/compose-site.ts +3 -2
- package/src/generation-core/import-plan.ts +41 -0
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/stock-photos.ts +23 -4
- package/src/generation-core/stock-search.ts +235 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ShopWord, shopWord } from '@vectoriox/iox-ui/commerce-core';
|
|
2
2
|
import type { ProductOption } from '@vectoriox/iox-ui/commerce-core';
|
|
3
|
-
import { roleClass } from '@vectoriox/iox-ui/design-core';
|
|
3
|
+
import { closeWord, roleClass } from '@vectoriox/iox-ui/design-core';
|
|
4
4
|
|
|
5
5
|
import { CompositeNode, CompositeNodeFactory, findByRole, writeProp } from './composite-node';
|
|
6
|
-
import { bindSlot, COLUMN, onClick, recipeButton, recipeIcon, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
|
|
6
|
+
import { bindSlot, COLUMN, onClick, recipeButton, recipeIcon, recipeLang, RecipeLang, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* THE SHOP PARTS (commerce E1c, C-D16 — commerce board 10). Not components: recipes of ordinary builder nodes, each part
|
|
@@ -206,26 +206,39 @@ enum Style {
|
|
|
206
206
|
Title = 'h3',
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/** The sample product a fresh recipe shows (board 10's vase) — the runtime replaces it with the page's product and the
|
|
210
|
+
* bag's lines, but the canvas and a page's first paint show it, so it is in the site's language too (vectoriox/iox-ui#100). */
|
|
211
|
+
const SHOP_SAMPLES: Readonly<Record<RecipeLang, { option: string; value: string; swatch: string; soldOut: string; lineTitle: string }>> = Object.freeze({
|
|
212
|
+
en: { option: 'Glaze — Sand', value: '32 cm', swatch: 'Sand', soldOut: 'Charcoal', lineTitle: 'Tall speckled vase' },
|
|
213
|
+
he: { option: 'זיגוג — חול', value: '32 ס״מ', swatch: 'חול', soldOut: 'פחם', lineTitle: 'אגרטל גבוה מנומר' },
|
|
214
|
+
});
|
|
215
|
+
|
|
209
216
|
/** The words a fresh recipe shows, in the site's language (vectoriox/iox-ui#100 — a Hebrew store's bag, buttons and drawer
|
|
210
|
-
* speak Hebrew, as its header does
|
|
217
|
+
* speak Hebrew, as its header does; so do the sample product's words and the names a screen reader hears). */
|
|
211
218
|
export function shopRecipeWords(lang: string | null | undefined = 'en') {
|
|
212
219
|
const w = (word: ShopWord, fill: Readonly<Record<string, string | number>> = {}) => shopWord(word, lang, fill);
|
|
220
|
+
const sample = SHOP_SAMPLES[recipeLang(lang)];
|
|
213
221
|
return Object.freeze({
|
|
214
222
|
price: '₪240.00',
|
|
215
223
|
compareAt: '₪280.00',
|
|
216
|
-
option:
|
|
217
|
-
value:
|
|
218
|
-
|
|
224
|
+
option: sample.option,
|
|
225
|
+
value: sample.value,
|
|
226
|
+
swatch: sample.swatch,
|
|
227
|
+
note: w(ShopWord.ValueSoldOut, { name: sample.soldOut }),
|
|
219
228
|
quantity: '1',
|
|
229
|
+
quantityLabel: w(ShopWord.Quantity),
|
|
230
|
+
decrease: w(ShopWord.Decrease),
|
|
231
|
+
increase: w(ShopWord.Increase),
|
|
220
232
|
add: w(ShopWord.AddToCart),
|
|
221
233
|
added: w(ShopWord.Added),
|
|
222
234
|
buyNow: w(ShopWord.BuyNow),
|
|
223
235
|
cart: w(ShopWord.Cart),
|
|
224
236
|
count: '2',
|
|
225
237
|
drawer: w(ShopWord.YourBag),
|
|
226
|
-
close
|
|
227
|
-
|
|
228
|
-
|
|
238
|
+
// The drawer's × is named by the ONE close word (design-core `closeWord`, iox-ui#170) — never a shop word of its own.
|
|
239
|
+
close: closeWord(lang),
|
|
240
|
+
lineTitle: sample.lineTitle,
|
|
241
|
+
lineVariant: `${sample.swatch} · ${sample.value}`,
|
|
229
242
|
lineTotal: '₪240.00',
|
|
230
243
|
remove: w(ShopWord.RemoveLine),
|
|
231
244
|
empty: w(ShopWord.EmptyBag),
|
|
@@ -270,45 +283,49 @@ function button(create: CompositeNodeFactory, key: string, role: ShopRole, style
|
|
|
270
283
|
}
|
|
271
284
|
|
|
272
285
|
/** Price: the variant's price and, when it is higher, its earlier price struck through (board 10). */
|
|
273
|
-
export function buildPriceRecipe(create: CompositeNodeFactory): CompositeNode {
|
|
286
|
+
export function buildPriceRecipe(create: CompositeNodeFactory, lang: string | null = 'en'): CompositeNode {
|
|
287
|
+
const t = shopRecipeWords(lang);
|
|
274
288
|
const root = part(create, 'price', Type.Container, ShopRole.Price, null, {}, SHOP_LABELS.price,
|
|
275
289
|
{ ...ROW, alignItems: 'baseline', flexWrap: 'wrap', gap: '8px' });
|
|
276
|
-
const amount = text(create, 'price-amount', ShopRole.PriceAmount, Style.Price,
|
|
290
|
+
const amount = text(create, 'price-amount', ShopRole.PriceAmount, Style.Price, t.price, 'Price');
|
|
277
291
|
bindSlot(amount, 'content', '$variant', 'price', true);
|
|
278
|
-
const compare = text(create, 'price-compare', ShopRole.PriceCompare, Style.PriceCompare,
|
|
292
|
+
const compare = text(create, 'price-compare', ShopRole.PriceCompare, Style.PriceCompare, t.compareAt, 'Price before');
|
|
279
293
|
bindSlot(compare, 'content', '$variant', 'compareAt', true);
|
|
280
294
|
root.children = [amount, compare];
|
|
281
295
|
return root;
|
|
282
296
|
}
|
|
283
297
|
|
|
284
298
|
/** Options: one group per option, each a radio group of chips, swatches or a select (T26). */
|
|
285
|
-
export function buildVariantPickerRecipe(create: CompositeNodeFactory): CompositeNode {
|
|
299
|
+
export function buildVariantPickerRecipe(create: CompositeNodeFactory, lang: string | null = 'en'): CompositeNode {
|
|
300
|
+
const t = shopRecipeWords(lang);
|
|
286
301
|
const root = part(create, 'variants', Type.Container, ShopRole.Variants, null, {}, SHOP_LABELS.variants, { ...COLUMN, gap: '16px' });
|
|
287
302
|
const group = part(create, 'variant-group', Type.Container, ShopRole.VariantGroup, null, {}, 'Option', { ...COLUMN, gap: '6px' });
|
|
288
|
-
const label = text(create, 'variant-label', ShopRole.VariantLabel, Style.Small,
|
|
303
|
+
const label = text(create, 'variant-label', ShopRole.VariantLabel, Style.Small, t.option, 'Option name');
|
|
289
304
|
const values = part(create, 'variant-values', Type.Container, ShopRole.VariantValues, null, {}, 'Values',
|
|
290
305
|
{ ...ROW, flexWrap: 'wrap', gap: '8px' });
|
|
291
306
|
const chip = button(create, 'variant-value', ShopRole.VariantValue, Style.Chip, 'Value', '', { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 'auto', height: 'auto' });
|
|
292
|
-
chip.children = [text(create, 'variant-value-text', null, Style.Label,
|
|
293
|
-
const swatch = button(create, 'variant-swatch', ShopRole.VariantSwatch, Style.Swatch, 'Swatch',
|
|
307
|
+
chip.children = [text(create, 'variant-value-text', null, Style.Label, t.value, 'Text', WORDS, 'span')];
|
|
308
|
+
const swatch = button(create, 'variant-swatch', ShopRole.VariantSwatch, Style.Swatch, 'Swatch', t.swatch, {}); // the swatch style owns its size and padding (iox-cms-client#89)
|
|
294
309
|
values.children = [chip, swatch];
|
|
295
|
-
const note = text(create, 'variant-note', ShopRole.VariantNote, Style.Small,
|
|
310
|
+
const note = text(create, 'variant-note', ShopRole.VariantNote, Style.Small, t.note, 'Sold-out note');
|
|
296
311
|
group.children = [label, values, note];
|
|
297
312
|
root.children = [group];
|
|
298
313
|
return root;
|
|
299
314
|
}
|
|
300
315
|
|
|
301
|
-
/** Quantity: − · the count · + (min 1, max from the variant's stock). `compact` = a cart line's.
|
|
302
|
-
|
|
316
|
+
/** Quantity: − · the count · + (min 1, max from the variant's stock). `compact` = a cart line's. The − and + are named in
|
|
317
|
+
* the site's language (the runtime names them again once it fills them; a page's first paint already speaks it). */
|
|
318
|
+
export function buildQuantityRecipe(create: CompositeNodeFactory, compact = false, key = 'quantity', lang: string | null = 'en'): CompositeNode {
|
|
319
|
+
const t = shopRecipeWords(lang);
|
|
303
320
|
const size = compact ? '30px' : 'var(--iox-stepper-size)';
|
|
304
321
|
const root = part(create, key, Type.Container, ShopRole.Quantity, Style.Quantity, {}, SHOP_LABELS.quantity,
|
|
305
322
|
{ ...ROW, alignItems: 'stretch', gap: '0px', minHeight: size });
|
|
306
|
-
const down = button(create, `${key}-down`, ShopRole.QuantityDown, Style.QuantityButton, 'Decrease',
|
|
323
|
+
const down = button(create, `${key}-down`, ShopRole.QuantityDown, Style.QuantityButton, 'Decrease', t.decrease,
|
|
307
324
|
{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', minWidth: size, padding: ZERO });
|
|
308
325
|
down.children = [icon(create, `${key}-down-icon`, 'ph ph-minus', compact ? '14px' : '16px')];
|
|
309
|
-
const value = text(create, `${key}-value`, ShopRole.QuantityValue, Style.Body,
|
|
326
|
+
const value = text(create, `${key}-value`, ShopRole.QuantityValue, Style.Body, t.quantity, 'Count',
|
|
310
327
|
{ ...WORDS, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', minWidth: compact ? '32px' : '40px', fontVariantNumeric: 'tabular-nums' }, 'span');
|
|
311
|
-
const up = button(create, `${key}-up`, ShopRole.QuantityUp, Style.QuantityButton, 'Increase',
|
|
328
|
+
const up = button(create, `${key}-up`, ShopRole.QuantityUp, Style.QuantityButton, 'Increase', t.increase,
|
|
312
329
|
{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', minWidth: size, padding: ZERO });
|
|
313
330
|
up.children = [icon(create, `${key}-up-icon`, 'ph ph-plus', compact ? '14px' : '16px')];
|
|
314
331
|
root.children = [down, value, up];
|
|
@@ -353,7 +370,7 @@ export function buildCartButtonRecipe(create: CompositeNodeFactory, lang: string
|
|
|
353
370
|
}
|
|
354
371
|
|
|
355
372
|
/** One cart line: thumbnail · title, variant, quantity and Remove · line total (board 10). */
|
|
356
|
-
function buildCartLine(create: CompositeNodeFactory, t: ShopRecipeWords): CompositeNode {
|
|
373
|
+
function buildCartLine(create: CompositeNodeFactory, t: ShopRecipeWords, lang: string | null): CompositeNode {
|
|
357
374
|
const line = part(create, 'cart-line', Type.Container, ShopRole.CartLine, Style.CartLine, {}, 'Line',
|
|
358
375
|
{ display: 'grid', gridTemplateColumns: 'var(--iox-cart-thumb-size) minmax(0, 1fr) auto', alignItems: 'start', gap: '12px', width: '100%', height: 'auto', minHeight: 'auto', padding: ZERO });
|
|
359
376
|
const image = part(create, 'cart-line-image', Type.Image, ShopRole.CartLineImage, Style.Media, { src: '', alt: '' }, 'Image',
|
|
@@ -364,7 +381,7 @@ function buildCartLine(create: CompositeNodeFactory, t: ShopRecipeWords): Compos
|
|
|
364
381
|
const actions = part(create, 'cart-line-actions', Type.Container, null, null, {}, 'Actions', { ...ROW, gap: '12px' });
|
|
365
382
|
const remove = button(create, 'cart-line-remove', ShopRole.CartLineRemove, Style.Ghost, 'Remove', '', { padding: '4px 4px 4px 4px', width: 'auto', height: 'auto', minHeight: 'auto' });
|
|
366
383
|
remove.children = [text(create, 'cart-line-remove-text', null, Style.Small, t.remove, 'Text', WORDS, 'span')];
|
|
367
|
-
actions.children = [buildQuantityRecipe(create, true, 'cart-line-quantity'), remove];
|
|
384
|
+
actions.children = [buildQuantityRecipe(create, true, 'cart-line-quantity', lang), remove];
|
|
368
385
|
info.children = [title, variant, actions];
|
|
369
386
|
const total = text(create, 'cart-line-total', ShopRole.CartLineTotal, Style.Price, t.lineTotal, 'Line total',
|
|
370
387
|
{ ...WORDS, fontSize: 'var(--iox-size-body)', textAlign: 'end' });
|
|
@@ -390,7 +407,7 @@ export function buildCartDrawerRecipe(create: CompositeNodeFactory, lang: string
|
|
|
390
407
|
head.children = [title, close];
|
|
391
408
|
|
|
392
409
|
const lines = part(create, 'cart-lines', Type.Container, ShopRole.CartLines, null, {}, 'Lines', { ...COLUMN, gap: '16px' });
|
|
393
|
-
lines.children = [buildCartLine(create, t)];
|
|
410
|
+
lines.children = [buildCartLine(create, t, lang)];
|
|
394
411
|
const issues = text(create, 'cart-issues', ShopRole.CartIssues, Style.Small, '', 'Issues', { ...WORDS, color: 'var(--iox-danger)' });
|
|
395
412
|
const empty = text(create, 'cart-empty', ShopRole.CartEmpty, Style.Body, t.empty, 'Empty');
|
|
396
413
|
const note = text(create, 'cart-shipping-note', ShopRole.CartShippingNote, Style.CartNote, t.shippingNote, 'Free delivery note',
|
|
@@ -422,9 +439,9 @@ export enum ShopRecipe {
|
|
|
422
439
|
|
|
423
440
|
/** Each recipe in the site's language (`lang` — vectoriox/iox-ui#100; English when the host has none). */
|
|
424
441
|
export const SHOP_RECIPES: Readonly<Record<ShopRecipe, (create: CompositeNodeFactory, lang?: string | null) => CompositeNode>> = Object.freeze({
|
|
425
|
-
[ShopRecipe.Price]: buildPriceRecipe,
|
|
426
|
-
[ShopRecipe.Variants]: buildVariantPickerRecipe,
|
|
427
|
-
[ShopRecipe.Quantity]: (create: CompositeNodeFactory) => buildQuantityRecipe(create),
|
|
442
|
+
[ShopRecipe.Price]: (create: CompositeNodeFactory, lang?: string | null) => buildPriceRecipe(create, lang ?? 'en'),
|
|
443
|
+
[ShopRecipe.Variants]: (create: CompositeNodeFactory, lang?: string | null) => buildVariantPickerRecipe(create, lang ?? 'en'),
|
|
444
|
+
[ShopRecipe.Quantity]: (create: CompositeNodeFactory, lang?: string | null) => buildQuantityRecipe(create, false, 'quantity', lang ?? 'en'),
|
|
428
445
|
[ShopRecipe.Add]: (create: CompositeNodeFactory, lang?: string | null) => buildAddToCartRecipe(create, lang ?? 'en'),
|
|
429
446
|
[ShopRecipe.BuyNow]: (create: CompositeNodeFactory, lang?: string | null) => buildBuyNowRecipe(create, lang ?? 'en'),
|
|
430
447
|
[ShopRecipe.CartButton]: (create: CompositeNodeFactory, lang?: string | null) => buildCartButtonRecipe(create, lang ?? 'en'),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { languageOf } from './locale-direction';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* "Close" in the page's language — the accessible name of every × the platform names: the Dialog's close button (the
|
|
5
|
+
* iox-ui component path AND the engine's string path, vectoriox/iox-ui#167), the toast's close control (premium M5) and
|
|
6
|
+
* the Lightbox recipe's stamped Close part (composite-core, vectoriox/iox-ui#170). ONE table, so no overlay on a Hebrew
|
|
7
|
+
* site is ever named "Close". It lives in design-core — the entry every other one may import (composite-core cannot
|
|
8
|
+
* import actions-core, which imports it); actions-core re-exports it. Framework-free (the engine's string renderer and
|
|
9
|
+
* iox-cms read it); a locale is read by its language subtag (`he-IL` → `he`).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The close word by language subtag. English is the fallback for every language the table lacks. */
|
|
13
|
+
export const CLOSE_WORDS: Readonly<Record<string, string>> = Object.freeze({ en: 'Close', he: 'סגירה' });
|
|
14
|
+
|
|
15
|
+
/** "Close" in `lang` (its base language), else English. */
|
|
16
|
+
export function closeWord(lang: string | null | undefined): string {
|
|
17
|
+
return CLOSE_WORDS[languageOf(lang)] ?? CLOSE_WORDS['en'];
|
|
18
|
+
}
|
|
@@ -4,7 +4,7 @@ import { compositeOver, paintColours, parseCssColour, quantizeRgb, Rgba, ringCol
|
|
|
4
4
|
import { ElementStyle, ELEMENT_STYLES } from './element-styles';
|
|
5
5
|
import { SPEC_CONTRAST_AUDIT, SPEC_INK_SCOPES, SPEC_SCHEMES } from './flavor-spec.generated';
|
|
6
6
|
import { SCHEME_INK } from './node-classes';
|
|
7
|
-
import { DesignTokenLike, ResolvedMode,
|
|
7
|
+
import { DesignTokenLike, ResolvedMode, schemeTokenResolver } from './token-css';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The contrast AUDIT (design-system DS9). The contract's token pairs were all AA and Doron still found a
|
|
@@ -12,7 +12,7 @@ import { DesignTokenLike, ResolvedMode, resolveSchemeTokenValues } from './token
|
|
|
12
12
|
* Icon dropped into a Primary button painted `icon-color` (accent-text) on the accent fill, 1:1 in a Brand
|
|
13
13
|
* section. So this resolves what each element style actually paints, the way CSS resolves it:
|
|
14
14
|
*
|
|
15
|
-
* - in every section scheme (`resolveSchemeTokenValues`), directly on the section and inside every
|
|
15
|
+
* - in every section scheme (`resolveSchemeTokenValues`, one `schemeTokenResolver` per look), directly on the section and inside every
|
|
16
16
|
* container style (Card, Panel, Navigation bar, Dialog);
|
|
17
17
|
* - `inherit` → the container's ink, a transparent fill → what is under it, translucent fills composited,
|
|
18
18
|
* a gradient ground (Glass's mesh, Midnight's glow) checked at its worst stop;
|
|
@@ -90,6 +90,8 @@ const TOKEN_REF = /var\(\s*--iox-([\w-]+)\s*(?:,([^()]*))?\)/g;
|
|
|
90
90
|
|
|
91
91
|
type Values = Readonly<Record<string, string>>;
|
|
92
92
|
type StyleMap = Readonly<Record<string, string>>;
|
|
93
|
+
/** One look's token values in a scheme (or a chain), in the audited mode. */
|
|
94
|
+
type SchemeValues = ReturnType<typeof schemeTokenResolver>;
|
|
93
95
|
|
|
94
96
|
/** A style value with its var() references resolved against `values` (already-resolved tokens). */
|
|
95
97
|
function resolveIn(values: Values, v: string | undefined): string {
|
|
@@ -163,9 +165,10 @@ function sweepDesignContrast(rows: ReadonlyArray<DesignTokenLike>, mode: Resolve
|
|
|
163
165
|
const section = ownStyle(byId.get(SECTION_STYLE) as ElementStyle);
|
|
164
166
|
const iconColour = ownStyle(byId.get(ICON_STYLE) as ElementStyle)['color'];
|
|
165
167
|
const bodyWeight = ownStyle(byId.get(BODY_STYLE) as ElementStyle)['fontWeight'];
|
|
168
|
+
const valuesIn = schemeTokenResolver(rows, mode);
|
|
166
169
|
|
|
167
170
|
for (const schemeId of SCHEME_IDS) {
|
|
168
|
-
const values =
|
|
171
|
+
const values = valuesIn(schemeId);
|
|
169
172
|
const pageInk = parseCssColour(values['text']);
|
|
170
173
|
const page = paintColours(values['page-bg'], pageInk);
|
|
171
174
|
const sectionPaint = paintColours(values['section-bg'], pageInk);
|
|
@@ -173,15 +176,23 @@ function sweepDesignContrast(rows: ReadonlyArray<DesignTokenLike>, mode: Resolve
|
|
|
173
176
|
? sectionPaint.map(c => (c.a < 1 ? compositeOver(c, page[0] ?? WHITE) : c))
|
|
174
177
|
: page;
|
|
175
178
|
const sectionInk = parseCssColour(resolveIn(values, section['color']), pageInk);
|
|
179
|
+
// What an ink-scoped element's Icon paints depends on the scheme alone, never the box: resolved once per scheme.
|
|
180
|
+
const scopedIcon = new Map<string, string>();
|
|
181
|
+
const iconIn = (styleId: string) => {
|
|
182
|
+
let v = scopedIcon.get(styleId);
|
|
183
|
+
if (v === undefined) scopedIcon.set(styleId, v = resolveIn(inkScoped(values, styleId), iconColour));
|
|
184
|
+
return v;
|
|
185
|
+
};
|
|
176
186
|
|
|
177
187
|
for (const box of containers) {
|
|
178
188
|
const boxStyle = box ? ownStyle(box) : null;
|
|
179
189
|
const bgs = boxStyle ? overAll(paintColours(resolveIn(values, boxStyle['backgroundColor']), sectionInk), ground) : ground;
|
|
180
190
|
const boxInk = boxStyle?.['color'] && boxStyle['color'] !== 'inherit'
|
|
181
191
|
? parseCssColour(resolveIn(values, boxStyle['color']), sectionInk) : sectionInk;
|
|
182
|
-
const
|
|
192
|
+
const container = box?.id ?? SECTION;
|
|
193
|
+
// A plain literal, one shape for every finding (a `{ ...where }` spread here was a fifth of the sweep's time).
|
|
183
194
|
const record = (element: string, part: string, fg: string, bg: string, ratio: number, min: number) =>
|
|
184
|
-
findings.push({
|
|
195
|
+
findings.push({ scheme: schemeId, container, element, part, fg, bg, ratio: Math.round(ratio * 100) / 100, min, pass: ratio >= min - 1e-9 });
|
|
185
196
|
const check = (element: string, part: string, fg: Rgba | null, under: Rgba[], min: number) => {
|
|
186
197
|
if (!fg) return;
|
|
187
198
|
for (const g of under) {
|
|
@@ -223,7 +234,7 @@ function sweepDesignContrast(rows: ReadonlyArray<DesignTokenLike>, mode: Resolve
|
|
|
223
234
|
if (state === 'selected' && (e.selected as StyleMap | undefined)?.['backgroundColor']) for (const f of fill) check(e.id, 'selected mark', f, bgs, WCAG_AA_UI);
|
|
224
235
|
// What a filled element HOLDS (inkScopes): a button's or a badge's icon reads its ink.
|
|
225
236
|
if (state === 'base' && INK_SCOPES.some(sc => sc.styles.includes(e.id))) {
|
|
226
|
-
check(e.id, 'icon', parseCssColour(
|
|
237
|
+
check(e.id, 'icon', parseCssColour(iconIn(e.id), ink), under, WCAG_AA_UI);
|
|
227
238
|
}
|
|
228
239
|
// Every focus ring an element style draws, on every ground the element sits on (CC4b: a Segmented
|
|
229
240
|
// option on its track — not only the buttons).
|
|
@@ -260,8 +271,8 @@ function sweepDesignContrast(rows: ReadonlyArray<DesignTokenLike>, mode: Resolve
|
|
|
260
271
|
}
|
|
261
272
|
}
|
|
262
273
|
}
|
|
263
|
-
findings.push(...schemedContainerFindings(
|
|
264
|
-
for (const scrim of SCRIMS) findings.push(...scrimFindings(
|
|
274
|
+
findings.push(...schemedContainerFindings(valuesIn, section, containers.filter((c): c is ElementStyle => !!c)));
|
|
275
|
+
for (const scrim of SCRIMS) findings.push(...scrimFindings(valuesIn, scrim, byId.get(scrim.style)));
|
|
265
276
|
return findings;
|
|
266
277
|
}
|
|
267
278
|
|
|
@@ -279,13 +290,12 @@ function sectionGround(values: Values): Rgba[] {
|
|
|
279
290
|
* section's (what it does not set, it inherits); a translucent fill composites over the OUTER section; the running text it holds (`body`, `lead`, a label: `color: inherit`)
|
|
280
291
|
* reads the scheme's ink, which is what the scheme-ink rule and `withSchemeInk` make CSS compute.
|
|
281
292
|
*/
|
|
282
|
-
function schemedContainerFindings(
|
|
283
|
-
containers: ReadonlyArray<ElementStyle>): ContrastFinding[] {
|
|
293
|
+
function schemedContainerFindings(valuesIn: SchemeValues, section: StyleMap, containers: ReadonlyArray<ElementStyle>): ContrastFinding[] {
|
|
284
294
|
const out: ContrastFinding[] = [];
|
|
285
295
|
for (const outer of SCHEME_IDS) {
|
|
286
|
-
const ground = sectionGround(
|
|
296
|
+
const ground = sectionGround(valuesIn(outer));
|
|
287
297
|
for (const inner of SCHEME_IDS.filter(id => id !== DEFAULT_SCHEME)) {
|
|
288
|
-
const values =
|
|
298
|
+
const values = valuesIn([outer, inner]);
|
|
289
299
|
const schemeInk = parseCssColour(resolveIn(values, SCHEME_INK), parseCssColour(resolveIn(values, section['color'])));
|
|
290
300
|
for (const box of containers) {
|
|
291
301
|
const style = ownStyle(box);
|
|
@@ -310,8 +320,8 @@ function schemedContainerFindings(rows: ReadonlyArray<DesignTokenLike>, mode: Re
|
|
|
310
320
|
/** Text over an image: the block's ink — and every token its ink scope pins to it — over the scrim
|
|
311
321
|
* composited on the WORST-CASE image, in the scheme the block wears. Never over the section: the image
|
|
312
322
|
* covers it. */
|
|
313
|
-
function scrimFindings(
|
|
314
|
-
const values =
|
|
323
|
+
function scrimFindings(valuesIn: SchemeValues, scrim: Scrim, style: ElementStyle | undefined): ContrastFinding[] {
|
|
324
|
+
const values = valuesIn(scrim.scheme);
|
|
315
325
|
const layer = parseCssColour(values[scrim.token]);
|
|
316
326
|
const image = parseCssColour(scrim.image);
|
|
317
327
|
if (!style || !layer || !image) return [];
|
|
@@ -13,6 +13,23 @@ export enum LocaleDirection {
|
|
|
13
13
|
/** The languages written right to left (their BCP 47 language subtags). */
|
|
14
14
|
export const RTL_LANGUAGES: ReadonlySet<string> = new Set(['ar', 'ckb', 'dv', 'fa', 'he', 'iw', 'ps', 'sd', 'ug', 'ur', 'yi']);
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The languages whose script has NO letter case (their BCP 47 language subtags): every right-to-left language (Hebrew,
|
|
18
|
+
* Arabic and the Arabic-script languages, Thaana) plus the common caseless scripts of Asia and Ethiopia. In them
|
|
19
|
+
* `text-transform: uppercase` touches only the Latin words a label borrows ("המשך עם GOOGLE", vectoriox/iox-ui#124) and
|
|
20
|
+
* letter-spacing opens up letters their typography never spaces — so the look's case and tracking tokens stand down
|
|
21
|
+
* (design-core `CASELESS_SCRIPT_OVERRIDES`, emitted by `compileTokenCss`).
|
|
22
|
+
*/
|
|
23
|
+
export const CASELESS_LANGUAGES: ReadonlySet<string> = new Set([
|
|
24
|
+
...RTL_LANGUAGES,
|
|
25
|
+
'am', 'bn', 'gu', 'hi', 'ja', 'km', 'kn', 'ko', 'lo', 'ml', 'mr', 'my', 'ne', 'pa', 'si', 'ta', 'te', 'th', 'zh',
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
/** True when `locale`'s language is written in a script without letter case (`he-IL`, `ar`, `ja`…). */
|
|
29
|
+
export function isCaselessLocale(locale: string | null | undefined): boolean {
|
|
30
|
+
return CASELESS_LANGUAGES.has(languageOf(locale));
|
|
31
|
+
}
|
|
32
|
+
|
|
16
33
|
/** The language subtag of a locale (`he-IL` → `he`, `pt_BR` → `pt`), lower-cased; '' when there is none. */
|
|
17
34
|
export function languageOf(locale: string | null | undefined): string {
|
|
18
35
|
return String(locale ?? '').trim().split(/[-_]/)[0].toLowerCase();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DesignMode } from './design-token.model';
|
|
2
|
+
import { CASELESS_LANGUAGES } from './locale-direction';
|
|
2
3
|
import { SPEC_A11Y, SPEC_AXES, SPEC_SCHEMES } from './flavor-spec.generated';
|
|
3
4
|
import { columnSelector, CONTENT_CAP_TOKEN, CONTENT_WIDTH_TOKEN, contentCapOf, contentWidthOf, openingFollowerSelector, SCHEME_INK } from './node-classes';
|
|
4
5
|
import { specTokenNames } from './token-names';
|
|
@@ -14,6 +15,7 @@ import { specTokenNames } from './token-names';
|
|
|
14
15
|
* 2. schemes `.iox-scheme-<id> { overrides; every var()-referencing token re-declared }`, then the
|
|
15
16
|
* ONE scheme-ink rule `.iox-scheme-subtle, … { color: var(--iox-text) }` (iox-ui#15)
|
|
16
17
|
* columns `[data-iox-column="<word>"] { --iox-content-width: <literal>; --iox-content-cap: <length>; every token reading it }` (award §0c)
|
|
18
|
+
* caseless script `<root>:is([lang|="he" i], …), <root> :is(…) { case + tracking tokens stand down }` (iox-ui#124)
|
|
17
19
|
* 3. reduced motion `@media (prefers-reduced-motion: reduce)`
|
|
18
20
|
* 4. reduced transparency `@media (prefers-reduced-transparency: reduce)`
|
|
19
21
|
* 5. dark — LAST `@media (prefers-color-scheme: dark)`
|
|
@@ -66,6 +68,30 @@ export const REDUCED_MOTION_OVERRIDES: Readonly<Record<string, string>> = SPEC_A
|
|
|
66
68
|
/** What `prefers-reduced-transparency: reduce` makes solid — the contract's `a11y.reducedTransparency`. */
|
|
67
69
|
export const REDUCED_TRANSPARENCY_OVERRIDES: Readonly<Record<string, string>> = SPEC_A11Y.reducedTransparency;
|
|
68
70
|
|
|
71
|
+
/**
|
|
72
|
+
* What a page in a CASELESS script (Hebrew, Arabic, Japanese… — locale-direction `CASELESS_LANGUAGES`) does with the
|
|
73
|
+
* look's case and tracking tokens (vectoriox/iox-ui#124): a pairing that sets buttons and labels `uppercase` with
|
|
74
|
+
* 0.04–0.12em tracking shouted only the Latin word inside a Hebrew label ("המשך עם GOOGLE") and opened up the Hebrew
|
|
75
|
+
* letters, which Hebrew typography never does. So under a caseless `lang` the case tokens compile to `none` and the
|
|
76
|
+
* tracking to `0em` (the contract's own `button-tracking` default). A CSS rule, not a compile option: the language is
|
|
77
|
+
* read where it is written — the engine's `<html lang>`, the canvas's token scope `lang` (the SITE's, never the
|
|
78
|
+
* admin's), a `lang` island inside a page — so ONE stylesheet serves a site whose pages differ in language.
|
|
79
|
+
* An author's own `text-transform` on a node (styleProps) is untouched: only the look's tokens stand down.
|
|
80
|
+
*/
|
|
81
|
+
export const CASELESS_SCRIPT_OVERRIDES: Readonly<Record<string, string>> = Object.freeze({
|
|
82
|
+
'button-case': 'none',
|
|
83
|
+
'case-label': 'none',
|
|
84
|
+
'button-tracking': '0em',
|
|
85
|
+
'tracking-label': '0em',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** `:is([lang|="he" i], …)` — an element whose own `lang` names a caseless language (any region: `he`, `he-IL`). */
|
|
89
|
+
const CASELESS_LANG_SELECTOR = `:is(${[...CASELESS_LANGUAGES].map(l => `[lang|="${l}" i]`).join(', ')})`;
|
|
90
|
+
|
|
91
|
+
/** The scope itself carrying a caseless `lang`, and any element inside it that does. Specificity (0,2,0) on `:root`, so
|
|
92
|
+
* it outranks the base `:root` block and the dark block's `:root` (0,1,0) wherever either is emitted. */
|
|
93
|
+
const caselessSelector = (root: string): string => `${root}${CASELESS_LANG_SELECTOR}, ${root} ${CASELESS_LANG_SELECTOR}`;
|
|
94
|
+
|
|
69
95
|
const ROOT = ':root';
|
|
70
96
|
const DEFAULT_SCHEME = 'default';
|
|
71
97
|
const REFERENCE = 'var(';
|
|
@@ -179,12 +205,44 @@ export function resolveSchemeTokenValues(
|
|
|
179
205
|
mode: ResolvedMode,
|
|
180
206
|
schemeId: string | ReadonlyArray<string>,
|
|
181
207
|
): Record<string, string> {
|
|
208
|
+
return schemeValuesOf(usableTokens(tokens), mode, schemeId, {});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* `resolveSchemeTokenValues` for MANY schemes (and chains) of ONE look in one mode: the look's root and
|
|
213
|
+
* other-mode values are resolved once, and each scheme or chain once. The contrast audit asks ~90 of them per
|
|
214
|
+
* look and the sweep thousands of looks (iox-ui#166). The answers are shared between calls: read them, never
|
|
215
|
+
* write to them.
|
|
216
|
+
*/
|
|
217
|
+
export function schemeTokenResolver(
|
|
218
|
+
tokens: ReadonlyArray<DesignTokenLike> | null | undefined,
|
|
219
|
+
mode: ResolvedMode,
|
|
220
|
+
): (schemeId: string | ReadonlyArray<string>) => Readonly<Record<string, string>> {
|
|
182
221
|
const rows = usableTokens(tokens);
|
|
222
|
+
const ground: SchemeGround = {};
|
|
223
|
+
const known = new Map<string, Record<string, string>>();
|
|
224
|
+
return schemeId => {
|
|
225
|
+
const key = typeof schemeId === 'string' ? schemeId : schemeId.join('\u0001');
|
|
226
|
+
let values = known.get(key);
|
|
227
|
+
if (!values) known.set(key, values = schemeValuesOf(rows, mode, schemeId, ground));
|
|
228
|
+
return values;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The look's root and other-mode values, resolved on first need and kept for the next scheme. */
|
|
233
|
+
interface SchemeGround { root?: Record<string, string>; other?: Record<string, string>; }
|
|
234
|
+
|
|
235
|
+
function schemeValuesOf(
|
|
236
|
+
rows: ReadonlyArray<DesignTokenLike>,
|
|
237
|
+
mode: ResolvedMode,
|
|
238
|
+
schemeId: string | ReadonlyArray<string>,
|
|
239
|
+
ground: SchemeGround,
|
|
240
|
+
): Record<string, string> {
|
|
183
241
|
const sets = (typeof schemeId === 'string' ? [schemeId] : schemeId)
|
|
184
242
|
.map(id => (id === DEFAULT_SCHEME ? undefined : (SPEC_SCHEMES as Readonly<Record<string, { set: Readonly<Record<string, string>> }>>)[id]?.set));
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const other = resolveTokenValues(rows, mode === DARK ? LIGHT : DARK);
|
|
243
|
+
const root = (ground.root ??= resolveTokenValues(rows, mode));
|
|
244
|
+
if (!sets.some(Boolean)) return root;
|
|
245
|
+
const other = (ground.other ??= resolveTokenValues(rows, mode === DARK ? LIGHT : DARK));
|
|
188
246
|
// Nested (`[outer, inner]` — a Featured card in an Inverse section): each scheme block re-declares the
|
|
189
247
|
// rows that reference a token, so at every level those are restored before the block's own set.
|
|
190
248
|
const overrides = new Map<string, string>();
|
|
@@ -382,6 +440,7 @@ export function compileTokenCssBlocks(
|
|
|
382
440
|
rule(root, [...unset, ...rows.map((t): [string, string] => [t.name, t.value])]),
|
|
383
441
|
compileSchemeCss(rows, opts.scope, opposite),
|
|
384
442
|
columns.base,
|
|
443
|
+
rule(caselessSelector(root), presentOverrides(rows, CASELESS_SCRIPT_OVERRIDES, false)),
|
|
385
444
|
...ACCESSIBILITY_MEDIA.map(({ query, overrides }) =>
|
|
386
445
|
media(query, [rule(root, presentOverrides(rows, overrides, false), ' ')])),
|
|
387
446
|
].filter(Boolean).join('\n');
|
|
@@ -102,6 +102,10 @@ export enum SiteFindingCode {
|
|
|
102
102
|
DeadLink = 'dead-link',
|
|
103
103
|
DeadDialogTarget = 'dead-dialog-target',
|
|
104
104
|
ActionNeedsConnector = 'action-needs-connector',
|
|
105
|
+
/** Actions plan R-H5 (K4): a shop or account action (`addToCart`, `startCheckout`, `signIn`, `signOut` — the catalog's
|
|
106
|
+
* `entitlement`) on a studio whose plan lacks that feature (`features.shop`): the checkout and the sign-in refuse it
|
|
107
|
+
* live, so the button would do nothing for every buyer. */
|
|
108
|
+
ActionNeedsEntitlement = 'action-needs-entitlement',
|
|
105
109
|
/** Popups PU3 (§11): a popup's title or its action's words are empty — never invented for it. `variant` title | action. */
|
|
106
110
|
PopupEmpty = 'popup-empty',
|
|
107
111
|
/** Popups PU3 (§11): a centred popup arrives by time sooner than the minimum seconds — an interstitial over the landing view. */
|
|
@@ -146,6 +150,7 @@ export const FINDING_SEVERITY: Readonly<Record<SiteFindingCode, CheckSeverity>>
|
|
|
146
150
|
[SiteFindingCode.DeadLink]: CheckSeverity.Block,
|
|
147
151
|
[SiteFindingCode.DeadDialogTarget]: CheckSeverity.Block,
|
|
148
152
|
[SiteFindingCode.ActionNeedsConnector]: CheckSeverity.Block,
|
|
153
|
+
[SiteFindingCode.ActionNeedsEntitlement]: CheckSeverity.Block,
|
|
149
154
|
[SiteFindingCode.PopupEmpty]: CheckSeverity.Block,
|
|
150
155
|
[SiteFindingCode.PopupCentredEarly]: CheckSeverity.Block,
|
|
151
156
|
[SiteFindingCode.PopupEnded]: CheckSeverity.Warn,
|
|
@@ -185,6 +190,7 @@ const CHECK_OF: Readonly<Record<SiteFindingCode, SiteCheckId>> = {
|
|
|
185
190
|
[SiteFindingCode.DeadLink]: SiteCheckId.Actions,
|
|
186
191
|
[SiteFindingCode.DeadDialogTarget]: SiteCheckId.Actions,
|
|
187
192
|
[SiteFindingCode.ActionNeedsConnector]: SiteCheckId.Actions,
|
|
193
|
+
[SiteFindingCode.ActionNeedsEntitlement]: SiteCheckId.Actions,
|
|
188
194
|
[SiteFindingCode.PopupEmpty]: SiteCheckId.Facts,
|
|
189
195
|
[SiteFindingCode.PopupCentredEarly]: SiteCheckId.Accessibility,
|
|
190
196
|
[SiteFindingCode.PopupEnded]: SiteCheckId.Facts,
|
|
@@ -248,6 +254,12 @@ export interface SiteAuditSnapshot {
|
|
|
248
254
|
connectors: Readonly<Record<string, boolean>>;
|
|
249
255
|
/** Connector types that set a tracker (a consent category) and are configured. */
|
|
250
256
|
trackers?: ReadonlyArray<string>;
|
|
257
|
+
/**
|
|
258
|
+
* Actions plan R-H5: the studio's plan features by the catalog's `entitlement` key (the control plane's
|
|
259
|
+
* `features.<key>`, e.g. `shop`) → in the plan. Absent = the caller does not know the plan, so nothing is judged by it
|
|
260
|
+
* (K4's v1 default); given, a key that is not `true` is not in the plan — unknown is never "included", as a connector.
|
|
261
|
+
*/
|
|
262
|
+
entitlements?: Readonly<Record<string, boolean>> | null;
|
|
251
263
|
/** The look's token rows and the mode(s) the site wears. */
|
|
252
264
|
design?: { rows: ReadonlyArray<DesignTokenLike>; modes: ReadonlyArray<'light' | 'dark'> } | null;
|
|
253
265
|
placeholders?: ReadonlyArray<AuditPlaceholder>;
|
|
@@ -610,11 +622,14 @@ function checkTokens(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray
|
|
|
610
622
|
});
|
|
611
623
|
}
|
|
612
624
|
|
|
625
|
+
/** What the owner sees a node as: its own words (a button's label, a heading's text), else its layer name, else its type. */
|
|
626
|
+
const shownAs = (n: SerializedNode): string => String(n.props['label'] ?? n.props['content'] ?? n.label ?? n.type);
|
|
627
|
+
|
|
613
628
|
function checkActions(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<AuditPage>): void {
|
|
614
629
|
const routeExists = (route: unknown) => typeof route === 'string' && ctx.routes.some(r => routeMatches(r, route));
|
|
615
630
|
eachNode(snapshot, pages, (n, where) => {
|
|
616
631
|
if (LINKING_TYPES.has(n.type) && n.props['linkType'] === PAGE_LINK && !routeExists(n.props['pageRoute'])) {
|
|
617
|
-
add(ctx, SiteFindingCode.DeadLink, deadLinkParams(
|
|
632
|
+
add(ctx, SiteFindingCode.DeadLink, deadLinkParams(shownAs(n), String(n.props['pageRoute'] ?? '')), { ...where, nodeId: n.id });
|
|
618
633
|
}
|
|
619
634
|
for (const ix of (n.interactions ?? []) as Array<{ actions?: Array<{ type?: string; target?: string; params?: Record<string, unknown>; disabled?: boolean }> }>) {
|
|
620
635
|
for (const action of ix?.actions ?? []) {
|
|
@@ -625,17 +640,23 @@ function checkActions(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArra
|
|
|
625
640
|
if (descriptor.target?.required && action.target !== SELF) {
|
|
626
641
|
const targetType = action.target ? ctx.nodeIds.get(action.target) : undefined;
|
|
627
642
|
if (!targetType || (types && !types.includes(targetType))) {
|
|
628
|
-
add(ctx, SiteFindingCode.DeadDialogTarget, { label:
|
|
643
|
+
add(ctx, SiteFindingCode.DeadDialogTarget, { label: shownAs(n) }, { ...where, nodeId: n.id });
|
|
629
644
|
}
|
|
630
645
|
}
|
|
631
646
|
if (action.type === 'navigate' && action.params?.['navigateTo'] === PAGE_LINK && !routeExists(action.params?.['page'])) {
|
|
632
|
-
add(ctx, SiteFindingCode.DeadLink, { variant: 'action', label:
|
|
647
|
+
add(ctx, SiteFindingCode.DeadLink, { variant: 'action', label: shownAs(n) }, { ...where, nodeId: n.id });
|
|
633
648
|
}
|
|
634
649
|
// A connector the snapshot does not say is usable is not: unknown is never "fine".
|
|
635
650
|
const connectors = descriptor.connector ? { [descriptor.connector]: snapshot.connectors[descriptor.connector] === true } : {};
|
|
636
|
-
|
|
651
|
+
// R-H5: the same for the plan — judged only when the caller knows it (`entitlements` given).
|
|
652
|
+
const entitlements = descriptor.entitlement && snapshot.entitlements
|
|
653
|
+
? { [descriptor.entitlement]: snapshot.entitlements[descriptor.entitlement] === true } : undefined;
|
|
654
|
+
const availability = resolveActionAvailability(descriptor, { connectors, ...(entitlements ? { entitlements } : {}) });
|
|
637
655
|
if (availability.state === 'connector-missing') {
|
|
638
|
-
add(ctx, SiteFindingCode.ActionNeedsConnector, { label:
|
|
656
|
+
add(ctx, SiteFindingCode.ActionNeedsConnector, { label: shownAs(n), connector: String(availability.connector) }, { ...where, nodeId: n.id });
|
|
657
|
+
}
|
|
658
|
+
if (availability.state === 'entitlement-missing') {
|
|
659
|
+
add(ctx, SiteFindingCode.ActionNeedsEntitlement, { label: shownAs(n), entitlement: String(availability.entitlement) }, { ...where, nodeId: n.id });
|
|
639
660
|
}
|
|
640
661
|
}
|
|
641
662
|
}
|
|
@@ -209,6 +209,14 @@ export const SITE_FINDING_WORDS: Readonly<Record<`${SiteFindingCode}`, FindingWo
|
|
|
209
209
|
one: S('"{label}" needs {connector} connected.', '"{label}" צריך ש-{connector} יהיה מחובר.'),
|
|
210
210
|
group: FindingGrouping.Never,
|
|
211
211
|
},
|
|
212
|
+
// R-H5: one feature today (`shop`), so the sentence names it; a second gated feature gets variants.
|
|
213
|
+
'action-needs-entitlement': {
|
|
214
|
+
one: S('"{label}" sells or signs buyers in, and your plan does not include Shop and customer sign-in — upgrade the plan, or take it off the site.',
|
|
215
|
+
'"{label}" מוכר או מחבר קונים, והתוכנית שלך לא כוללת חנות והתחברות לקוחות — שדרגו את התוכנית, או הסירו אותו מהאתר.'),
|
|
216
|
+
many: S('{n} buttons sell or sign buyers in, and your plan does not include Shop and customer sign-in — upgrade the plan, or take them off the site.',
|
|
217
|
+
'{n} כפתורים מוכרים או מחברים קונים, והתוכנית שלך לא כוללת חנות והתחברות לקוחות — שדרגו את התוכנית, או הסירו אותם מהאתר.'),
|
|
218
|
+
group: FindingGrouping.Site,
|
|
219
|
+
},
|
|
212
220
|
'popup-empty': {
|
|
213
221
|
one: {
|
|
214
222
|
title: S('A popup has no title — write what it tells your visitors.', 'לחלון קופץ אין כותרת — כתבו מה הוא מספר למבקרים.'),
|
|
@@ -1538,13 +1538,14 @@ function composeSlideshow(pn: PatternNode, id: string, ctx: Ctx): SerializedNode
|
|
|
1538
1538
|
|
|
1539
1539
|
/**
|
|
1540
1540
|
* CC3: the Lightbox — a Dialog holding a Slider bound to the node's `src` (the gallery's own source): one template
|
|
1541
|
-
* slide whose image reads the row (a bare URL row: decorative alt), its arrows hidden on a phone.
|
|
1541
|
+
* slide whose image reads the row (a bare URL row: decorative alt), its arrows hidden on a phone. Its stored names
|
|
1542
|
+
* (Close, the arrows, the gallery) in the plan's language (iox-ui#170).
|
|
1542
1543
|
*/
|
|
1543
1544
|
function composeLightbox(pn: PatternNode, id: string, repeater: RepeaterScope | null, ctx: Ctx): SerializedNode {
|
|
1544
1545
|
if (!pn.src) throw new ComposeError(`${id}: a lightbox needs the gallery's source (src)`);
|
|
1545
1546
|
const scoped = resolveScoped(pn.src, repeater, ctx, id);
|
|
1546
1547
|
const sourcePath = scoped.path === ITEM_VALUE_PATH ? '' : scoped.path;
|
|
1547
|
-
return buildLightboxRecipe(recipeFactory(id, 'lightbox'), { source: scoped.source, sourcePath, imageField: 'item' }) as SerializedNode;
|
|
1548
|
+
return buildLightboxRecipe(recipeFactory(id, 'lightbox'), { source: scoped.source, sourcePath, imageField: 'item', lang: ctx.plan.locale }) as SerializedNode;
|
|
1548
1549
|
}
|
|
1549
1550
|
|
|
1550
1551
|
/** CC3: every `opens: lightbox` node of a stamped pattern opens the pattern's lightbox at its own row. */
|
|
@@ -88,11 +88,26 @@ export interface ImportReading {
|
|
|
88
88
|
readonly home?: ImportedHome;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* X9-D23 (What we found's ticks): what the owner leaves on the old site. Pages, their search words and their old addresses
|
|
93
|
+
* always move — an old address with no page has nowhere to go — so only these can stay behind:
|
|
94
|
+
*/
|
|
95
|
+
export interface ImportLeave {
|
|
96
|
+
/** The keys of the lists (the scan's content types, `ImportedList.key`) that stay: no type, no pages, no redirects. */
|
|
97
|
+
readonly lists?: ReadonlyArray<string>;
|
|
98
|
+
/** The pictures stay: every picture box is kept but left empty, so nothing is copied (`importedPicturesOf` is empty). */
|
|
99
|
+
readonly pictures?: boolean;
|
|
100
|
+
/** The details from the old site (its email, phone, address and hours) stay: the business carries none of them. */
|
|
101
|
+
readonly details?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
export interface ImportPlanInput {
|
|
92
105
|
/** The owner's pick (the Design step). */
|
|
93
106
|
readonly design: DesignChoices;
|
|
94
107
|
/** The structure the home page, the contact page and the globals come from; absent = the Studio. */
|
|
95
108
|
readonly template?: SiteTemplate;
|
|
109
|
+
/** What stays on the old site (X9-D23); absent = everything moves. */
|
|
110
|
+
readonly leave?: ImportLeave;
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
/** A Site Plan read from the owner's own site. */
|
|
@@ -385,6 +400,32 @@ const pageHeader = (title: string, lead?: string): PageSectionPlan => lead
|
|
|
385
400
|
* page, the contact page).
|
|
386
401
|
*/
|
|
387
402
|
export function planImport(reading: ImportReading, input: ImportPlanInput): ImportPlan {
|
|
403
|
+
const plan = planAll(readingKept(reading, input.leave), input);
|
|
404
|
+
return input.leave?.pictures ? withoutPictures(plan) : plan;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** X9-D23: the reading without the lists that stay, and without the old site's details when they stay. */
|
|
408
|
+
function readingKept(reading: ImportReading, leave: ImportLeave | undefined): ImportReading {
|
|
409
|
+
if (!leave) return reading;
|
|
410
|
+
const staying = new Set(leave.lists ?? []);
|
|
411
|
+
const lists = staying.size ? reading.lists.filter(l => !staying.has(l.key)) : reading.lists;
|
|
412
|
+
const { facts: _facts, ...business } = reading.business;
|
|
413
|
+
return { ...reading, lists, business: leave.details ? business : reading.business };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** X9-D23: the pictures stay — every picture and gallery field of a real item kept, its value empty (a box to fill). */
|
|
417
|
+
function withoutPictures(plan: ImportPlan): ImportPlan {
|
|
418
|
+
const contentTypes = plan.contentTypes.map(type => {
|
|
419
|
+
const perItem = type.seed?.importedFrom?.length ? type.seed.perItem : undefined;
|
|
420
|
+
if (!perItem) return type;
|
|
421
|
+
const emptied = Object.fromEntries(type.fields.filter(f => PICTURE_CONTROLS.includes(f.controller) && f.name in perItem)
|
|
422
|
+
.map(f => [f.name, perItem[f.name].map(() => f.controller === ContentFieldControl.Gallery ? [] : '')]));
|
|
423
|
+
return { ...type, seed: { ...type.seed!, perItem: { ...perItem, ...emptied } } };
|
|
424
|
+
});
|
|
425
|
+
return { ...plan, contentTypes };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function planAll(reading: ImportReading, input: ImportPlanInput): ImportPlan {
|
|
388
429
|
const template = input.template ?? STUDIO_TEMPLATE;
|
|
389
430
|
const lists = reading.lists.filter(l => l.items.length > 0);
|
|
390
431
|
const matched = templateListOf(template, lists);
|