@vectoriox/iox-ui 5.140.0 → 5.142.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.
Files changed (45) hide show
  1. package/assist-core/index.d.ts +19 -2
  2. package/design-core/index.d.ts +171 -2
  3. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +29 -3
  4. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  5. package/fesm2022/vectoriox-iox-ui-design-core.mjs +358 -172
  6. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1671 -861
  8. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +49 -18
  10. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +32 -9
  12. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui.mjs +85 -4
  14. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  15. package/generation-core/index.d.ts +525 -144
  16. package/harness-core/index.d.ts +18 -18
  17. package/index.d.ts +92 -2
  18. package/package.json +1 -1
  19. package/scene-core/index.d.ts +17 -1
  20. package/src/assist-core/assist-turn.ts +34 -2
  21. package/src/design-core/flavor-spec.generated.ts +141 -0
  22. package/src/design-core/ink-on-ground.ts +36 -0
  23. package/src/design-core/list-classes.ts +37 -0
  24. package/src/design-core/node-classes.ts +3 -2
  25. package/src/design-core/public-api.ts +2 -0
  26. package/src/generation-core/check-layout.ts +23 -1
  27. package/src/generation-core/check-list.ts +144 -5
  28. package/src/generation-core/compose-layout.ts +188 -23
  29. package/src/generation-core/compose-site.ts +14 -2
  30. package/src/generation-core/header-edit.ts +15 -11
  31. package/src/generation-core/layout-fingerprint.ts +5 -1
  32. package/src/generation-core/layout-language.ts +10 -0
  33. package/src/generation-core/layout-wire.ts +64 -24
  34. package/src/generation-core/list-panel.ts +122 -0
  35. package/src/generation-core/list-space.ts +205 -0
  36. package/src/generation-core/list-table.ts +101 -0
  37. package/src/generation-core/node-baselines.generated.ts +3 -1
  38. package/src/generation-core/public-api.ts +2 -0
  39. package/src/generation-core/serialized-node.ts +2 -0
  40. package/src/generation-core/site-plan.model.ts +6 -0
  41. package/src/generation-core/site-spec.generated.ts +188 -70
  42. package/src/generation-core/validate-site-plan.ts +8 -4
  43. package/src/harness-core/harness-spec.generated.ts +49 -18
  44. package/src/scene-core/split-text.ts +31 -7
  45. package/styles/iox-design.css +438 -4
@@ -98,7 +98,8 @@ export const SPEC_SITE_PLAN_SHAPE = {
98
98
  "icon?": "string — a field: an icon name",
99
99
  "quote?": "string — a field: someone's words",
100
100
  "person?": "string — a field: who said or made it",
101
- "link?": "string — a field: where the item leads (a route or an address)"
101
+ "link?": "string — a field: where the item leads (a route or an address)",
102
+ "colour?": "string — a field: its own colour, a hex (a colour block's ground)"
102
103
  },
103
104
  "field": {
104
105
  "name": "string — unique in the type",
@@ -206,6 +207,7 @@ export const SPEC_SITE_ROLES = {
206
207
  "quote": "someone's words — a testimonial or a story's line, shown in quotation marks",
207
208
  "person": "who said or made it — a name (their role or place goes in meta)",
208
209
  "link": "where the item leads — its own page or an address; the card's arrow goes there",
210
+ "colour": "its own colour (a hex) — the ground of its block; the words on it are chosen to read",
209
211
  "price": "its price — the shop's own field, shown through the money pipe in the studio currency",
210
212
  "compareAt": "its earlier price, struck through beside the price (the shop's own field)"
211
213
  } as const;
@@ -7455,71 +7457,90 @@ export const SPEC_SITE_LAYOUT = {
7455
7457
  "hover.tilt": "the card's ground turns, its content settles smaller",
7456
7458
  "arrive.clip-up": "each card opens from its bottom edge, its content rising inside"
7457
7459
  },
7458
- "waits": {
7459
- "item.title-on-photo": {
7460
- "phase": "AW11",
7461
- "drawnAs": "photo"
7462
- },
7463
- "item.packshot": {
7464
- "phase": "AW11",
7465
- "drawnAs": "card"
7466
- },
7467
- "item.colour-block": {
7468
- "phase": "AW11",
7469
- "drawnAs": "card"
7470
- },
7471
- "item.numbered": {
7472
- "phase": "AW11",
7473
- "drawnAs": "card"
7474
- },
7475
- "arrange.hang": {
7476
- "phase": "AW11",
7477
- "drawnAs": "masonry"
7478
- },
7479
- "arrange.bento": {
7480
- "phase": "AW11",
7481
- "drawnAs": "grid"
7482
- },
7483
- "arrange.rows": {
7484
- "phase": "AW11",
7485
- "drawnAs": "grid"
7486
- },
7487
- "arrange.stage": {
7488
- "phase": "AW11",
7489
- "drawnAs": "grid"
7490
- },
7491
- "arrange.fan": {
7492
- "phase": "AW11",
7493
- "drawnAs": "row"
7494
- },
7495
- "arrange.tilted": {
7496
- "phase": "AW11",
7497
- "drawnAs": "grid"
7498
- },
7499
- "move.rows": {
7500
- "phase": "AW11",
7501
- "drawnAs": "auto"
7502
- },
7503
- "hover.swap": {
7504
- "phase": "AW11",
7505
- "drawnAs": "zoom"
7506
- },
7507
- "hover.unveil": {
7508
- "phase": "AW11",
7509
- "drawnAs": "zoom"
7510
- },
7511
- "hover.fill": {
7512
- "phase": "AW11",
7513
- "drawnAs": null
7514
- },
7515
- "hover.tilt": {
7516
- "phase": "AW11",
7517
- "drawnAs": "rise"
7518
- },
7519
- "arrive.clip-up": {
7520
- "phase": "AW11",
7521
- "drawnAs": "one-by-one"
7522
- }
7460
+ "waits": {},
7461
+ "belowPro": {
7462
+ "item.title-on-photo": "photo",
7463
+ "item.packshot": "card",
7464
+ "item.colour-block": "card",
7465
+ "item.numbered": "card",
7466
+ "arrange.hang": "masonry",
7467
+ "arrange.bento": "grid",
7468
+ "arrange.rows": "grid",
7469
+ "arrange.stage": "grid",
7470
+ "arrange.fan": "row",
7471
+ "arrange.tilted": "grid",
7472
+ "move.rows": "auto",
7473
+ "hover.swap": "zoom",
7474
+ "hover.unveil": "zoom",
7475
+ "hover.fill": null,
7476
+ "hover.tilt": "rise",
7477
+ "arrive.clip-up": "one-by-one"
7478
+ },
7479
+ "rhythms": {
7480
+ "hang": [
7481
+ {
7482
+ "span": 5,
7483
+ "drop": 0,
7484
+ "ratio": "4 / 5"
7485
+ },
7486
+ {
7487
+ "span": 4,
7488
+ "drop": 48,
7489
+ "ratio": "1 / 1"
7490
+ },
7491
+ {
7492
+ "span": 3,
7493
+ "drop": 16,
7494
+ "ratio": "3 / 4"
7495
+ },
7496
+ {
7497
+ "span": 3,
7498
+ "start": 2,
7499
+ "drop": 8,
7500
+ "ratio": "1 / 1"
7501
+ },
7502
+ {
7503
+ "span": 4,
7504
+ "drop": 0,
7505
+ "ratio": "3 / 4"
7506
+ },
7507
+ {
7508
+ "span": 4,
7509
+ "drop": 30,
7510
+ "ratio": "4 / 5"
7511
+ }
7512
+ ],
7513
+ "bento": [
7514
+ 3,
7515
+ 5,
7516
+ 7
7517
+ ],
7518
+ "tilt": [
7519
+ -1,
7520
+ 0.6,
7521
+ -0.4,
7522
+ 1
7523
+ ],
7524
+ "tiltMaxDeg": 4,
7525
+ "fanRadius": 1.7,
7526
+ "hoverTiltDeg": 2.5,
7527
+ "hoverSettle": 0.97,
7528
+ "clipUpRise": 22,
7529
+ "numberBehindInk": 0.1,
7530
+ "colourRamp": [
7531
+ {
7532
+ "ground": "accent",
7533
+ "ink": "accent-ink"
7534
+ },
7535
+ {
7536
+ "ground": "surface-2",
7537
+ "ink": "text"
7538
+ },
7539
+ {
7540
+ "ground": "inverse-bg",
7541
+ "ink": "inverse-text"
7542
+ }
7543
+ ]
7523
7544
  },
7524
7545
  "tiers": {
7525
7546
  "item.photo": "all",
@@ -7557,6 +7578,7 @@ export const SPEC_SITE_LAYOUT = {
7557
7578
  "rules.onlyRow": "all",
7558
7579
  "rules.moving": "all",
7559
7580
  "rules.neverSwipe": "all",
7581
+ "rules.alone": "all",
7560
7582
  "item.title-on-photo": "pro",
7561
7583
  "item.packshot": "pro",
7562
7584
  "item.colour-block": "pro",
@@ -7572,7 +7594,19 @@ export const SPEC_SITE_LAYOUT = {
7572
7594
  "hover.unveil": "pro",
7573
7595
  "hover.fill": "pro",
7574
7596
  "hover.tilt": "pro",
7575
- "arrive.clip-up": "pro"
7597
+ "arrive.clip-up": "pro",
7598
+ "rules.counts": "pro",
7599
+ "rules.bento": "pro",
7600
+ "rules.fanDragFrom": "pro",
7601
+ "rules.leaning": "pro",
7602
+ "rules.pictured": "pro",
7603
+ "rules.secondPicture": "pro",
7604
+ "rules.still": "pro",
7605
+ "rules.titleOnPhotoWords": "pro",
7606
+ "rules.rowsStandout": "pro",
7607
+ "rules.notFirstScreen": "pro",
7608
+ "rules.onlyPictures": "pro",
7609
+ "rules.middle": "pro"
7576
7610
  },
7577
7611
  "defaults": {
7578
7612
  "item": "card",
@@ -7771,7 +7805,8 @@ export const SPEC_SITE_LAYOUT = {
7771
7805
  "middle"
7772
7806
  ],
7773
7807
  "move": [
7774
- "page"
7808
+ "page",
7809
+ "rows"
7775
7810
  ]
7776
7811
  },
7777
7812
  "moving": [
@@ -7780,8 +7815,91 @@ export const SPEC_SITE_LAYOUT = {
7780
7815
  ],
7781
7816
  "neverSwipe": [
7782
7817
  "grid",
7783
- "masonry"
7784
- ]
7818
+ "masonry",
7819
+ "hang",
7820
+ "bento",
7821
+ "rows",
7822
+ "tilted"
7823
+ ],
7824
+ "alone": [
7825
+ "page",
7826
+ "rows"
7827
+ ],
7828
+ "counts": {
7829
+ "hang": [
7830
+ 5,
7831
+ 12
7832
+ ],
7833
+ "stage": [
7834
+ 3,
7835
+ 10
7836
+ ],
7837
+ "fan": [
7838
+ 3,
7839
+ 9
7840
+ ],
7841
+ "tilted": [
7842
+ 3,
7843
+ 9
7844
+ ],
7845
+ "rows": [
7846
+ 3,
7847
+ 12
7848
+ ]
7849
+ },
7850
+ "bento": [
7851
+ 3,
7852
+ 5,
7853
+ 7
7854
+ ],
7855
+ "fanDragFrom": 5,
7856
+ "leaning": [
7857
+ "fan",
7858
+ "tilted"
7859
+ ],
7860
+ "pictured": {
7861
+ "arrange": [
7862
+ "hang",
7863
+ "stage"
7864
+ ],
7865
+ "item": [
7866
+ "title-on-photo",
7867
+ "packshot"
7868
+ ],
7869
+ "hover": [
7870
+ "fill"
7871
+ ]
7872
+ },
7873
+ "secondPicture": {
7874
+ "hover": [
7875
+ "swap",
7876
+ "unveil"
7877
+ ]
7878
+ },
7879
+ "still": {
7880
+ "hover": [
7881
+ "tilt"
7882
+ ]
7883
+ },
7884
+ "titleOnPhotoWords": 6,
7885
+ "middle": [
7886
+ "row",
7887
+ "fan"
7888
+ ],
7889
+ "rowsStandout": {
7890
+ "who": "pointed",
7891
+ "how": "brighter"
7892
+ },
7893
+ "notFirstScreen": {
7894
+ "arrive": [
7895
+ "clip-up"
7896
+ ]
7897
+ },
7898
+ "onlyPictures": {
7899
+ "move": [
7900
+ "rows"
7901
+ ]
7902
+ }
7785
7903
  }
7786
7904
  },
7787
7905
  "header": {
@@ -6,7 +6,7 @@ import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX } from '@vectoriox/iox-ui/seo-core';
6
6
  import {
7
7
  BindScope, patternById, patternHasForm, patternLinkSlots, patternNeedsBinding, patternOptionalParts, patternRoleNeeds, patternTakesBinding, patternScopes,
8
8
  patternSlots, PatternGlobalPosition, slotBudget, SCENE_LEVEL, SCENE_OTHER_PAGES } from './patterns';
9
- import { ContentFieldControl, FIELD_TYPE_OF_CONTROL,
9
+ import { ContentFieldControl, ContentRole, FIELD_TYPE_OF_CONTROL,
10
10
  FACT_KEYS, GlobalSlot, PAGE_ARCHETYPES, SITE_NEED_IDS, PlanDataSourceMode, PlanDataSourceType, RelativeOp, REQUIRED_CONTENT_ROLES, ShopResource, SitePlan,
11
11
  SitePlanSourceKind, SITE_LOCALES, SITE_PLAN_VERSION, GenerationTier, STAMPED_PAGE_ARCHETYPES,
12
12
  } from './site-plan.model';
@@ -294,7 +294,8 @@ function validateContentTypes(c: Collector, list: unknown[]): Map<string, Conten
294
294
  c.unique(names, j => `${path}.fields[${j}].name`, 'field');
295
295
  const fieldSet = new Set(names.filter((n): n is string => !!n));
296
296
  const fieldTypes = new Map(fields.filter(isObject).map(f => [f['name'], f['type']]));
297
- const roles = validateRoles(c, raw['roles'], `${path}.roles`, name, fieldSet, fieldTypes);
297
+ const fieldControls = new Map(fields.filter(isObject).map(f => [f['name'], f['controller']]));
298
+ const roles = validateRoles(c, raw['roles'], `${path}.roles`, name, fieldSet, fieldTypes, fieldControls);
298
299
  const seed = raw['seed'];
299
300
  if (seed !== undefined) {
300
301
  if (!isObject(seed)) c.add(SitePlanIssueCode.Shape, `${path}.seed`, 'must be an object');
@@ -324,14 +325,17 @@ function validateContentTypes(c: Collector, list: unknown[]): Map<string, Conten
324
325
 
325
326
  const describeField = (f: Obj) => ({ name: String(f['name']), type: typeof f['type'] === 'string' ? f['type'] : undefined, controller: typeof f['controller'] === 'string' ? f['controller'] : undefined });
326
327
 
327
- /** A content type's roles (L0-3): known roles only, each played by a field of the type; `title` always; `gallery` a list. */
328
- function validateRoles(c: Collector, roles: unknown, path: string, typeName: string | null, fields: Set<string>, fieldTypes: Map<unknown, unknown>): Record<string, string> {
328
+ /** A content type's roles (L0-3): known roles only, each played by a field of the type; `title` always; `gallery` a list;
329
+ * `colour` (AW11-D10) a colour-picker field — any other field would paint a block from words. */
330
+ function validateRoles(c: Collector, roles: unknown, path: string, typeName: string | null, fields: Set<string>, fieldTypes: Map<unknown, unknown>,
331
+ fieldControls: Map<unknown, unknown>): Record<string, string> {
329
332
  if (!isObject(roles)) { c.add(SitePlanIssueCode.Shape, path, 'must be an object (which field plays each role)'); return {}; }
330
333
  const out: Record<string, string> = {};
331
334
  for (const [role, field] of Object.entries(roles)) {
332
335
  if (!ROLE_KEYS.includes(role)) { c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${role}" is not a role (${ROLE_KEYS.join(', ')})`); continue; }
333
336
  if (typeof field !== 'string' || !fields.has(field)) { c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${String(field)}" is not a field of ${typeName}`); continue; }
334
337
  if (role === 'gallery' && fieldTypes.get(field) !== ARRAY_TYPE) { c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${field}" is not a list field — a gallery is a list of pictures`); continue; }
338
+ if (role === ContentRole.Colour && fieldControls.get(field) !== ContentFieldControl.Colour) { c.add(SitePlanIssueCode.UnknownRole, `${path}.${role}`, `"${field}" is not a colour field — a colour block's ground is a picked colour`); continue; }
335
339
  out[role] = field;
336
340
  }
337
341
  for (const role of REQUIRED_CONTENT_ROLES) if (!out[role] && !has(roles, role)) c.add(SitePlanIssueCode.MissingRole, `${path}.${role}`, `every content type names its ${role} field`);
@@ -1162,9 +1162,14 @@ export const SPEC_BUSINESS_TYPES = [
1162
1162
  },
1163
1163
  "ceiling": "standard",
1164
1164
  "lists": {
1165
- "arranges": [],
1165
+ "arranges": [
1166
+ "fan",
1167
+ "tilted"
1168
+ ],
1166
1169
  "moves": [],
1167
- "say": []
1170
+ "say": [
1171
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
1172
+ ]
1168
1173
  },
1169
1174
  "art": {
1170
1175
  "preloader": [
@@ -1692,14 +1697,17 @@ export const SPEC_BUSINESS_TYPES = [
1692
1697
  "ceiling": "subtle",
1693
1698
  "lists": {
1694
1699
  "arranges": [
1695
- "deck"
1700
+ "deck",
1701
+ "fan",
1702
+ "tilted"
1696
1703
  ],
1697
1704
  "moves": [
1698
1705
  "auto",
1699
1706
  "page"
1700
1707
  ],
1701
1708
  "say": [
1702
- "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through."
1709
+ "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through.",
1710
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
1703
1711
  ]
1704
1712
  },
1705
1713
  "art": {
@@ -1850,14 +1858,17 @@ export const SPEC_BUSINESS_TYPES = [
1850
1858
  "ceiling": "subtle",
1851
1859
  "lists": {
1852
1860
  "arranges": [
1853
- "deck"
1861
+ "deck",
1862
+ "fan",
1863
+ "tilted"
1854
1864
  ],
1855
1865
  "moves": [
1856
1866
  "auto",
1857
1867
  "page"
1858
1868
  ],
1859
1869
  "say": [
1860
- "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through."
1870
+ "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through.",
1871
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
1861
1872
  ]
1862
1873
  },
1863
1874
  "art": {
@@ -2003,14 +2014,17 @@ export const SPEC_BUSINESS_TYPES = [
2003
2014
  "ceiling": "subtle",
2004
2015
  "lists": {
2005
2016
  "arranges": [
2006
- "deck"
2017
+ "deck",
2018
+ "fan",
2019
+ "tilted"
2007
2020
  ],
2008
2021
  "moves": [
2009
2022
  "auto",
2010
2023
  "page"
2011
2024
  ],
2012
2025
  "say": [
2013
- "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through."
2026
+ "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through.",
2027
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
2014
2028
  ]
2015
2029
  },
2016
2030
  "art": {
@@ -2156,9 +2170,14 @@ export const SPEC_BUSINESS_TYPES = [
2156
2170
  },
2157
2171
  "ceiling": "standard",
2158
2172
  "lists": {
2159
- "arranges": [],
2173
+ "arranges": [
2174
+ "fan",
2175
+ "tilted"
2176
+ ],
2160
2177
  "moves": [],
2161
- "say": []
2178
+ "say": [
2179
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
2180
+ ]
2162
2181
  },
2163
2182
  "art": {
2164
2183
  "preloader": [
@@ -2994,11 +3013,14 @@ export const SPEC_BUSINESS_TYPES = [
2994
3013
  "ceiling": "standard",
2995
3014
  "lists": {
2996
3015
  "arranges": [
2997
- "deck"
3016
+ "deck",
3017
+ "fan",
3018
+ "tilted"
2998
3019
  ],
2999
3020
  "moves": [],
3000
3021
  "say": [
3001
- "A deck reads as a game; advice and causes are read, not flicked."
3022
+ "A deck reads as a game; advice and causes are read, not flicked.",
3023
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
3002
3024
  ]
3003
3025
  },
3004
3026
  "art": {
@@ -3129,11 +3151,14 @@ export const SPEC_BUSINESS_TYPES = [
3129
3151
  "ceiling": "standard",
3130
3152
  "lists": {
3131
3153
  "arranges": [
3132
- "deck"
3154
+ "deck",
3155
+ "fan",
3156
+ "tilted"
3133
3157
  ],
3134
3158
  "moves": [],
3135
3159
  "say": [
3136
- "A deck reads as a game; advice and causes are read, not flicked."
3160
+ "A deck reads as a game; advice and causes are read, not flicked.",
3161
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
3137
3162
  ]
3138
3163
  },
3139
3164
  "art": {
@@ -3259,14 +3284,17 @@ export const SPEC_BUSINESS_TYPES = [
3259
3284
  "ceiling": "subtle",
3260
3285
  "lists": {
3261
3286
  "arranges": [
3262
- "deck"
3287
+ "deck",
3288
+ "fan",
3289
+ "tilted"
3263
3290
  ],
3264
3291
  "moves": [
3265
3292
  "auto",
3266
3293
  "page"
3267
3294
  ],
3268
3295
  "say": [
3269
- "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through."
3296
+ "People who come for care or advice read at their own pace: nothing turns by itself, nothing to flick through.",
3297
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
3270
3298
  ]
3271
3299
  },
3272
3300
  "art": {
@@ -3544,11 +3572,14 @@ export const SPEC_BUSINESS_TYPES = [
3544
3572
  "ceiling": "standard",
3545
3573
  "lists": {
3546
3574
  "arranges": [
3547
- "deck"
3575
+ "deck",
3576
+ "fan",
3577
+ "tilted"
3548
3578
  ],
3549
3579
  "moves": [],
3550
3580
  "say": [
3551
- "A deck reads as a game; advice and causes are read, not flicked."
3581
+ "A deck reads as a game; advice and causes are read, not flicked.",
3582
+ "Trust and care are shown straight: nothing leans, nothing is fanned like a hand of cards."
3552
3583
  ]
3553
3584
  },
3554
3585
  "art": {
@@ -51,6 +51,32 @@ export function lettersSplittable(text: string): boolean {
51
51
  return !JOINED_SCRIPTS.test(text);
52
52
  }
53
53
 
54
+ /** The pieces a letter split makes of `text`: the letters of its words (a letter with its points or a joined emoji is
55
+ * one). The spaces are no piece. */
56
+ export function letterCount(text: string): number {
57
+ const words: string[] = text.match(/\S+/g) ?? [];
58
+ return words.reduce((n, word) => n + graphemes(word).length, 0);
59
+ }
60
+
61
+ /** Why a reveal set to Letter by letter comes in by word for a text (AW10-D2). The values are the panel's words' keys. */
62
+ export enum LetterRefusal {
63
+ /** A script whose letters join (Arabic, Indic, Thai…): pulled apart, each would show its isolated form. */
64
+ Joined = 'letterJoined',
65
+ /** Longer than a display line: over `LETTER_PIECE_CAP` letters. */
66
+ Long = 'letterLong',
67
+ }
68
+
69
+ /**
70
+ * THE rule a letter split follows (AW10-D2): why `text` cannot come in letter by letter, or null when it can (an empty
71
+ * text refuses nothing — there is nothing to split). `splitForReveal` asks it before splitting, and the builder's panel
72
+ * asks it to SAY so before the text plays — one rule, so the two never disagree (vectoriox/iox-ui#107).
73
+ */
74
+ export function letterRefusalOf(text: string | null | undefined): LetterRefusal | null {
75
+ if (!text) return null;
76
+ if (!lettersSplittable(text)) return LetterRefusal.Joined;
77
+ return letterCount(text) > LETTER_PIECE_CAP ? LetterRefusal.Long : null;
78
+ }
79
+
54
80
  const SKIPPED_TAGS: ReadonlySet<string> = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'SELECT', 'OPTION']);
55
81
  const SHOW_TEXT = 4;
56
82
  /** Hebrew through Arabic Extended, and their presentation forms. */
@@ -152,7 +178,7 @@ export function splitText(root: HTMLElement, options: SplitTextOptions): SplitTe
152
178
  const planned = texts.map(original => ({
153
179
  original, parts: textPieces(original.nodeValue ?? '', keepRuns && !!options.rtl, keepRuns && !options.rtl),
154
180
  }));
155
- const pieceCount = (part: TextPiece): number => (!part.word ? 0 : letters ? graphemes(part.text.replace(/\s+/g, '')).length : 1);
181
+ const pieceCount = (part: TextPiece): number => (!part.word ? 0 : letters ? letterCount(part.text) : 1);
156
182
  const count = planned.reduce((sum, { parts }) => sum + parts.reduce((n, part) => n + pieceCount(part), 0), 0);
157
183
  if (!count || count > options.cap) return null;
158
184
 
@@ -263,12 +289,10 @@ export function splitForReveal(el: HTMLElement, by: TextRevealBy, look: TextReve
263
289
  if (el.isContentEditable) return null;
264
290
  const rtl = el.ownerDocument.defaultView?.getComputedStyle(el).direction === 'rtl';
265
291
  const mask = look === TextRevealLook.Rise;
266
- let used = by;
267
- let split = by === TextRevealBy.Letter ? splitText(el, { cap: LETTER_PIECE_CAP, mask, rtl, letters: true }) : null;
268
- if (!split) {
269
- if (used === TextRevealBy.Letter) used = TextRevealBy.Word;
270
- split = splitText(el, { cap: REVEAL_PIECE_CAP, mask, rtl });
271
- }
292
+ // The text a split reads: its text nodes, apart (a letter never joins across two of them).
293
+ const used = by === TextRevealBy.Letter && letterRefusalOf(textNodesOf(el).map(t => t.nodeValue ?? '').join(' ')) ? TextRevealBy.Word : by;
294
+ const letters = used === TextRevealBy.Letter;
295
+ const split = splitText(el, { cap: letters ? LETTER_PIECE_CAP : REVEAL_PIECE_CAP, mask, rtl, letters });
272
296
  if (!split) return null;
273
297
  const boxes = used === TextRevealBy.Line ? split.pieces.map(piece => ((mask ? piece.parentElement : piece) as HTMLElement).getBoundingClientRect()) : [];
274
298
  const order = used === TextRevealBy.Line ? lineIndexes(boxes.map(box => box.top), boxes.map(box => box.height)) : split.pieces.map((_, i) => i);