@kerfjs/ui 5.0.0-beta.125 → 5.0.0-beta.126

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 (287) hide show
  1. package/README.md +5 -0
  2. package/ai/application-ui-diagnostic-ids-v1.json +1 -0
  3. package/ai/component-catalog.json +77 -6
  4. package/ai/component-catalog.schema.json +14 -1
  5. package/ai/component-composition.json +27 -6
  6. package/ai/component-props.json +245 -40
  7. package/ai/components/combobox.md +1 -1
  8. package/ai/components/surface-scaffold.md +19 -5
  9. package/ai/components/tab-bar.md +2 -0
  10. package/ai/components/toolbar.md +1 -0
  11. package/ai/public-api-signatures-v1.md +246 -295
  12. package/ai/skill.md +10 -4
  13. package/ai/view-document.schema.json +55 -2
  14. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  15. package/analyzer/cli.mjs +60 -24
  16. package/analyzer/index.mjs +331 -58
  17. package/catalog-projection-cli.mjs +86 -50
  18. package/dist/anchored-surface.js +2 -1
  19. package/dist/browser/editor.js +11 -8
  20. package/dist/catalog-resources.d.ts +1 -1
  21. package/dist/catalog.d.ts +1 -1
  22. package/dist/catalog.js +6 -6
  23. package/dist/{chunk-VX3YF2UD.js → chunk-3K5V3ZSD.js} +3 -3
  24. package/dist/{chunk-VX3YF2UD.js.map → chunk-3K5V3ZSD.js.map} +1 -1
  25. package/dist/chunk-3SCGTP5O.js +682 -0
  26. package/dist/chunk-3SCGTP5O.js.map +1 -0
  27. package/dist/{chunk-NHQOX7T4.js → chunk-3ZKUXWAV.js} +4 -4
  28. package/dist/chunk-3ZKUXWAV.js.map +1 -0
  29. package/dist/{chunk-ADMWT7FX.js → chunk-3ZWYGGEC.js} +136 -8
  30. package/dist/chunk-3ZWYGGEC.js.map +1 -0
  31. package/dist/{chunk-KLR3DCHH.js → chunk-4L5ZIKDZ.js} +1 -1
  32. package/dist/chunk-4L5ZIKDZ.js.map +1 -0
  33. package/dist/{chunk-2E7S5C4D.js → chunk-4UWLHKNU.js} +5 -5
  34. package/dist/chunk-4UWLHKNU.js.map +1 -0
  35. package/dist/{chunk-EXGDKG7B.js → chunk-5A2DN3LR.js} +5 -5
  36. package/dist/chunk-5A2DN3LR.js.map +1 -0
  37. package/dist/{chunk-DJ65XFVN.js → chunk-63TJH2RF.js} +4 -4
  38. package/dist/chunk-63TJH2RF.js.map +1 -0
  39. package/dist/{chunk-Q2CLQ3IJ.js → chunk-6PHG2DMG.js} +1 -1
  40. package/dist/chunk-6PHG2DMG.js.map +1 -0
  41. package/dist/{chunk-SPI6VMIY.js → chunk-6T7AX365.js} +4 -4
  42. package/dist/chunk-6T7AX365.js.map +1 -0
  43. package/dist/{chunk-GVII4JSD.js → chunk-6V6UHPJD.js} +4 -4
  44. package/dist/chunk-6V6UHPJD.js.map +1 -0
  45. package/dist/{chunk-2LM3PYHA.js → chunk-C2TY5DJC.js} +11 -8
  46. package/dist/chunk-C2TY5DJC.js.map +1 -0
  47. package/dist/{chunk-3WYREXW4.js → chunk-COMEWURO.js} +8 -6
  48. package/dist/chunk-COMEWURO.js.map +1 -0
  49. package/dist/{chunk-VPDSPD76.js → chunk-DB64I3DB.js} +4 -3
  50. package/dist/chunk-DB64I3DB.js.map +1 -0
  51. package/dist/{chunk-SBCXWGNP.js → chunk-DBCDYBZP.js} +2 -2
  52. package/dist/{chunk-SBCXWGNP.js.map → chunk-DBCDYBZP.js.map} +1 -1
  53. package/dist/{chunk-CNM6ZWP2.js → chunk-DJWBXEF4.js} +4 -2
  54. package/dist/chunk-DJWBXEF4.js.map +1 -0
  55. package/dist/{chunk-SVUJIVMR.js → chunk-E2MTHHLS.js} +3 -3
  56. package/dist/{chunk-SVUJIVMR.js.map → chunk-E2MTHHLS.js.map} +1 -1
  57. package/dist/{chunk-JG4ONAOI.js → chunk-EI55KWHP.js} +2 -2
  58. package/dist/chunk-EI55KWHP.js.map +1 -0
  59. package/dist/{chunk-MVKHSAKE.js → chunk-GE2BQXB3.js} +41 -4
  60. package/dist/chunk-GE2BQXB3.js.map +1 -0
  61. package/dist/{chunk-KELWWCMX.js → chunk-I2K4OQKB.js} +4 -4
  62. package/dist/chunk-I2K4OQKB.js.map +1 -0
  63. package/dist/chunk-IFDTSVE6.js +9 -0
  64. package/dist/chunk-IFDTSVE6.js.map +1 -0
  65. package/dist/{chunk-TPLVC5BE.js → chunk-IR32NI2O.js} +336 -247
  66. package/dist/chunk-IR32NI2O.js.map +1 -0
  67. package/dist/{chunk-ZKKO4MHC.js → chunk-JYKP7TBZ.js} +4 -2
  68. package/dist/chunk-JYKP7TBZ.js.map +1 -0
  69. package/dist/{chunk-6OT7FOSA.js → chunk-K3C35KGR.js} +4 -4
  70. package/dist/chunk-K3C35KGR.js.map +1 -0
  71. package/dist/{chunk-4RECPEHI.js → chunk-KBS3GP6S.js} +4 -3
  72. package/dist/chunk-KBS3GP6S.js.map +1 -0
  73. package/dist/{chunk-YHRJNKD5.js → chunk-KS7EXW4P.js} +6 -4
  74. package/dist/chunk-KS7EXW4P.js.map +1 -0
  75. package/dist/{chunk-V6N3YLTM.js → chunk-LTOTL5AS.js} +3 -3
  76. package/dist/chunk-LTOTL5AS.js.map +1 -0
  77. package/dist/chunk-M64TAGZY.js +590 -0
  78. package/dist/chunk-M64TAGZY.js.map +1 -0
  79. package/dist/{chunk-JZZVWTUB.js → chunk-MMOQR426.js} +2 -2
  80. package/dist/chunk-MMOQR426.js.map +1 -0
  81. package/dist/{chunk-SJBMKA4X.js → chunk-OHT2AXER.js} +11 -10
  82. package/dist/chunk-OHT2AXER.js.map +1 -0
  83. package/dist/{chunk-TTFW6E6C.js → chunk-OZKBIPXU.js} +2 -2
  84. package/dist/chunk-OZKBIPXU.js.map +1 -0
  85. package/dist/{chunk-Q2SLOMN6.js → chunk-RHMY45DK.js} +4 -4
  86. package/dist/chunk-RHMY45DK.js.map +1 -0
  87. package/dist/{chunk-BZXA5SSA.js → chunk-S7QB5KMM.js} +2 -2
  88. package/dist/{chunk-BZXA5SSA.js.map → chunk-S7QB5KMM.js.map} +1 -1
  89. package/dist/{chunk-HDXUHLTQ.js → chunk-SHECA2N4.js} +8 -2
  90. package/dist/chunk-SHECA2N4.js.map +1 -0
  91. package/dist/{chunk-R6FIXYAE.js → chunk-SJEPM5ZU.js} +2 -2
  92. package/dist/{chunk-R6FIXYAE.js.map → chunk-SJEPM5ZU.js.map} +1 -1
  93. package/dist/{chunk-FJMABKKV.js → chunk-UQ4FRQ6M.js} +35 -17
  94. package/dist/chunk-UQ4FRQ6M.js.map +1 -0
  95. package/dist/{chunk-S4ZGTDSG.js → chunk-UU37OR3D.js} +2 -2
  96. package/dist/chunk-UU37OR3D.js.map +1 -0
  97. package/dist/{chunk-SWXWLSUD.js → chunk-WEQNPYVA.js} +1 -1
  98. package/dist/{chunk-SWXWLSUD.js.map → chunk-WEQNPYVA.js.map} +1 -1
  99. package/dist/{chunk-5SFHBYEY.js → chunk-WUVHP3UC.js} +97 -24
  100. package/dist/chunk-WUVHP3UC.js.map +1 -0
  101. package/dist/{chunk-3S3WXAZ5.js → chunk-X43QQWVC.js} +3 -2
  102. package/dist/chunk-X43QQWVC.js.map +1 -0
  103. package/dist/{chunk-Z3T24FX3.js → chunk-YE6KCAIN.js} +3 -2
  104. package/dist/chunk-YE6KCAIN.js.map +1 -0
  105. package/dist/{chunk-BCO673YW.js → chunk-Z3BT2SZE.js} +3 -3
  106. package/dist/chunk-Z3BT2SZE.js.map +1 -0
  107. package/dist/{chunk-KQZIC5CA.js → chunk-ZC4KSRAF.js} +7 -7
  108. package/dist/chunk-ZC4KSRAF.js.map +1 -0
  109. package/dist/collapsible-panel.d.ts +2 -2
  110. package/dist/collapsible-panel.js +2 -2
  111. package/dist/collapsible-panel.js.map +1 -1
  112. package/dist/column-explorer.d.ts +2 -2
  113. package/dist/column-explorer.js +2 -2
  114. package/dist/column-explorer.js.map +1 -1
  115. package/dist/dialog-surface-controller-BeKZ3e8Z.d.ts +251 -0
  116. package/dist/editor-frame.d.ts +1 -1
  117. package/dist/editor-frame.js +1 -1
  118. package/dist/editor.d.ts +38 -20
  119. package/dist/editor.js +10855 -6979
  120. package/dist/editor.js.map +1 -1
  121. package/dist/file-picker.js +1 -1
  122. package/dist/help-tags-register.js +2 -1
  123. package/dist/help-tags-register.js.map +1 -1
  124. package/dist/index.d.ts +2 -1
  125. package/dist/index.js +24 -23
  126. package/dist/list-action-row.d.ts +1 -1
  127. package/dist/list-action-row.js +1 -1
  128. package/dist/list-detail-dialog.d.ts +7 -7
  129. package/dist/list-detail-dialog.js +6 -5
  130. package/dist/list-detail-dialog.js.map +1 -1
  131. package/dist/list-header.d.ts +1 -1
  132. package/dist/list-header.js +1 -1
  133. package/dist/list-item.d.ts +1 -1
  134. package/dist/list-item.js +1 -1
  135. package/dist/message-composer.js +1 -1
  136. package/dist/nav-stack.d.ts +6 -6
  137. package/dist/nav-stack.js +1 -1
  138. package/dist/popup-menu-register.js +1 -7
  139. package/dist/popup-menu-register.js.map +1 -1
  140. package/dist/popup-menu.d.ts +2 -2
  141. package/dist/popup-menu.js +1 -1
  142. package/dist/resizable-region.js +1 -1
  143. package/dist/segmented-control.d.ts +1 -1
  144. package/dist/segmented-control.js +1 -1
  145. package/dist/select-register.js +17 -23
  146. package/dist/select-register.js.map +1 -1
  147. package/dist/split-view.d.ts +6 -6
  148. package/dist/split-view.js +1 -1
  149. package/dist/styles/collapsible-panel.css +34 -25
  150. package/dist/styles/components/actions/popup-menu/popup-menu.css +4 -4
  151. package/dist/styles/components/actions/toolbar/toolbar.css +34 -1
  152. package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +1 -1
  153. package/dist/styles/components/forms/segmented-control/segmented-control.css +1 -1
  154. package/dist/styles/components/layout/collapsible-panel/collapsible-panel.css +34 -25
  155. package/dist/styles/components/layout/split-view/split-view.css +19 -33
  156. package/dist/styles/components/navigation/nav-stack/nav-stack.css +15 -19
  157. package/dist/styles/components/navigation/tab-navigator/tab-navigator.css +30 -29
  158. package/dist/styles/components/surfaces/editor-frame/editor-frame.css +2 -2
  159. package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +259 -4
  160. package/dist/styles/editor/editor.css +55 -0
  161. package/dist/styles/editor-frame.css +2 -2
  162. package/dist/styles/nav-stack.css +15 -19
  163. package/dist/styles/popup-menu.css +4 -4
  164. package/dist/styles/segmented-control.css +1 -1
  165. package/dist/styles/split-view.css +19 -33
  166. package/dist/styles/surface-scaffold.css +259 -4
  167. package/dist/styles/tab-navigator.css +30 -29
  168. package/dist/styles/toolbar-control-group.css +1 -1
  169. package/dist/styles/toolbar.css +34 -1
  170. package/dist/styles/webawesome.css +4 -5
  171. package/dist/surface-scaffold-register.js +2 -1
  172. package/dist/surface-scaffold-register.js.map +1 -1
  173. package/dist/surface-scaffold.d.ts +153 -246
  174. package/dist/surface-scaffold.js +3 -2
  175. package/dist/toolbar-control-group.d.ts +2 -2
  176. package/dist/toolbar-control-group.js +1 -1
  177. package/dist/toolbar.d.ts +6 -1
  178. package/dist/toolbar.js +1 -1
  179. package/dist/tree-list.d.ts +2 -2
  180. package/dist/tree-list.js +1 -1
  181. package/dist/wire-catalog.d.ts +1 -1
  182. package/dist/wire-catalog.js +3 -2
  183. package/dist/wire-catalog.js.map +1 -1
  184. package/dist/wire-checkboxes.js +2 -1
  185. package/dist/wire-choice-chips.js +2 -1
  186. package/dist/wire-color-fields.js +2 -1
  187. package/dist/wire-color-pickers.js +2 -1
  188. package/dist/wire-comboboxes.d.ts +2 -0
  189. package/dist/wire-comboboxes.js +2 -1
  190. package/dist/wire-content-items.js +2 -1
  191. package/dist/wire-corner-status.js +2 -1
  192. package/dist/wire-nav-stack.js +2 -1
  193. package/dist/wire-overlay-sheets.js +2 -1
  194. package/dist/wire-paged-views.js +2 -2
  195. package/dist/wire-paged-views.js.map +1 -1
  196. package/dist/wire-resizable-regions.js +2 -1
  197. package/dist/wire-scroll-dividers.js +1 -1
  198. package/dist/wire-search-fields.js +2 -1
  199. package/dist/wire-sidebar.js +2 -1
  200. package/dist/wire-tab-bars.d.ts +41 -2
  201. package/dist/wire-tab-bars.js +1 -1
  202. package/dist/wire-tab-navigator.js +2 -1
  203. package/dist/wire-tag-fields.js +2 -1
  204. package/dist/wire-workbench.js +2 -1
  205. package/dist/workbench-dialog.d.ts +7 -7
  206. package/dist/workbench-dialog.js +5 -4
  207. package/dist/workbench-dialog.js.map +1 -1
  208. package/dist/workbench.d.ts +1 -1
  209. package/dist/workbench.js +1 -1
  210. package/docs/accessibility.md +3 -6
  211. package/docs/component-contract.md +47 -7
  212. package/docs/component-selection.md +90 -80
  213. package/docs/design/templates.md +5 -4
  214. package/docs/editor-frame.md +1 -1
  215. package/docs/editor-host.md +15 -2
  216. package/docs/overlay-tooltip.md +1 -1
  217. package/docs/recipes.md +1 -1
  218. package/docs/surface-scaffold.md +63 -2
  219. package/docs/ui-analyzer.md +42 -0
  220. package/docs/ui-doctor.md +45 -1
  221. package/docs/ui-evaluator.md +35 -0
  222. package/docs/ux-demo.md +1 -1
  223. package/docs/view.md +295 -0
  224. package/docs/webawesome-theme.md +16 -0
  225. package/doctor/cli.mjs +36 -31
  226. package/doctor/index.mjs +349 -162
  227. package/evaluator/cli.mjs +36 -30
  228. package/llms.txt +17 -4
  229. package/package.json +3 -1
  230. package/props/cli.mjs +47 -21
  231. package/scripts/lib/cli-args.mjs +98 -0
  232. package/ux-demo/recipes/compact-toolbar.tsx +1 -1
  233. package/ux-demo/recipes/loading-inspector.tsx +1 -1
  234. package/view/catalog.mjs +229 -0
  235. package/view/child-kind.mjs +22 -0
  236. package/view/cli.mjs +142 -119
  237. package/view/contract.mjs +84 -11
  238. package/view/css-grammar.mjs +93 -0
  239. package/view/generate.d.mts +16 -0
  240. package/view/generate.mjs +122 -43
  241. package/view/index.d.mts +80 -14
  242. package/view/index.mjs +5 -9
  243. package/view/interpret.mjs +104 -36
  244. package/view/types.mjs +161 -0
  245. package/view/validate-move.mjs +66 -30
  246. package/view/validate.mjs +420 -654
  247. package/vite-editor.d.mts +16 -1
  248. package/vite-editor.mjs +74 -4
  249. package/dist/chunk-2E7S5C4D.js.map +0 -1
  250. package/dist/chunk-2LM3PYHA.js.map +0 -1
  251. package/dist/chunk-3S3WXAZ5.js.map +0 -1
  252. package/dist/chunk-3WYREXW4.js.map +0 -1
  253. package/dist/chunk-4RECPEHI.js.map +0 -1
  254. package/dist/chunk-5SFHBYEY.js.map +0 -1
  255. package/dist/chunk-6OT7FOSA.js.map +0 -1
  256. package/dist/chunk-ADMWT7FX.js.map +0 -1
  257. package/dist/chunk-BCO673YW.js.map +0 -1
  258. package/dist/chunk-CNM6ZWP2.js.map +0 -1
  259. package/dist/chunk-DJ65XFVN.js.map +0 -1
  260. package/dist/chunk-EXGDKG7B.js.map +0 -1
  261. package/dist/chunk-FJMABKKV.js.map +0 -1
  262. package/dist/chunk-GVII4JSD.js.map +0 -1
  263. package/dist/chunk-HDXUHLTQ.js.map +0 -1
  264. package/dist/chunk-JG4ONAOI.js.map +0 -1
  265. package/dist/chunk-JZZVWTUB.js.map +0 -1
  266. package/dist/chunk-KELWWCMX.js.map +0 -1
  267. package/dist/chunk-KLR3DCHH.js.map +0 -1
  268. package/dist/chunk-KQZIC5CA.js.map +0 -1
  269. package/dist/chunk-LD6A6PYB.js +0 -268
  270. package/dist/chunk-LD6A6PYB.js.map +0 -1
  271. package/dist/chunk-MVKHSAKE.js.map +0 -1
  272. package/dist/chunk-NHQOX7T4.js.map +0 -1
  273. package/dist/chunk-Q2CLQ3IJ.js.map +0 -1
  274. package/dist/chunk-Q2SLOMN6.js.map +0 -1
  275. package/dist/chunk-S4ZGTDSG.js.map +0 -1
  276. package/dist/chunk-SJBMKA4X.js.map +0 -1
  277. package/dist/chunk-SPI6VMIY.js.map +0 -1
  278. package/dist/chunk-TPLVC5BE.js.map +0 -1
  279. package/dist/chunk-TTFW6E6C.js.map +0 -1
  280. package/dist/chunk-V6N3YLTM.js.map +0 -1
  281. package/dist/chunk-VNT4MXR5.js +0 -548
  282. package/dist/chunk-VNT4MXR5.js.map +0 -1
  283. package/dist/chunk-VPDSPD76.js.map +0 -1
  284. package/dist/chunk-YHRJNKD5.js.map +0 -1
  285. package/dist/chunk-Z3T24FX3.js.map +0 -1
  286. package/dist/chunk-ZKKO4MHC.js.map +0 -1
  287. package/dist/{nav-stack-DwxpXxqJ.d.ts → nav-stack-vQ3ieerq.d.ts} +3 -3
package/view/types.mjs ADDED
@@ -0,0 +1,161 @@
1
+ // The structural type system of @kerfjs/ui/view: whether a param or binding
2
+ // type fits a prop type (isAssignable) and whether a JSON literal is a value
3
+ // of a type (isLiteralOf), over the catalogs' type descriptors.
4
+
5
+ import { isObject, resolveType, ZoneFill } from './catalog.mjs';
6
+ import { parseCssCall } from './css-grammar.mjs';
7
+
8
+ export const ICON_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+
10
+ /** Whether a value of type `from` (a param or binding) fits type `to`. */
11
+ export function isAssignable(from, to, definitions = {}) {
12
+ // A component prop's type fits only that same component prop.
13
+ if (from?.kind === 'prop' || to?.kind === 'prop')
14
+ return (
15
+ from?.kind === to?.kind &&
16
+ from.component === to.component &&
17
+ from.prop === to.prop
18
+ );
19
+ const target = resolveType(to, definitions);
20
+ const source = resolveType(from, definitions);
21
+ if (target.kind === 'unknown' || source.kind === 'unknown') return true;
22
+ if (target.kind === 'union') {
23
+ return target.members.some((member) =>
24
+ isAssignable(source, member, definitions),
25
+ );
26
+ }
27
+ const values =
28
+ source.kind === 'enum'
29
+ ? source.values
30
+ : source.kind === 'literal'
31
+ ? [source.value]
32
+ : undefined;
33
+ if (values) {
34
+ if (target.kind === 'enum') {
35
+ return values.every((value) => target.values.includes(value));
36
+ }
37
+ if (target.kind === 'literal') {
38
+ return values.length === 1 && values[0] === target.value;
39
+ }
40
+ return values.every((value) => isLiteralOf(value, target, definitions));
41
+ }
42
+ switch (source.kind) {
43
+ case 'string':
44
+ case 'number':
45
+ return (
46
+ target.kind === source.kind ||
47
+ (target.kind === 'content' && target.acceptsText === true)
48
+ );
49
+ case 'boolean':
50
+ case 'content':
51
+ return target.kind === source.kind;
52
+ case 'array':
53
+ return (
54
+ target.kind === 'array' &&
55
+ isAssignable(source.items, target.items, definitions)
56
+ );
57
+ case 'object': {
58
+ if (target.kind === 'record') return true;
59
+ if (target.kind !== 'object') return false;
60
+ const given = new Map(
61
+ (source.props ?? []).map((prop) => [prop.name, prop]),
62
+ );
63
+ return (target.props ?? []).every((prop) => {
64
+ const match = given.get(prop.name);
65
+ if (!match) return !prop.required;
66
+ return (
67
+ (match.required || !prop.required) &&
68
+ isAssignable(match.type, prop.type, definitions)
69
+ );
70
+ });
71
+ }
72
+ default:
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /** Whether a JSON literal is a valid value of a type descriptor. */
78
+ export function isLiteralOf(value, type, definitions = {}) {
79
+ return literalOf(value, type, definitions);
80
+ }
81
+
82
+ /**
83
+ * `isLiteralOf`, with `hooks` for the forms a prop value may nest:
84
+ * `hooks.slot` decides a `{ $slot }` at a content-typed position (KF-SXDM56:
85
+ * item slots), and `hooks.dynamic` a `{ $param }` / `{ $bind }` at any typed
86
+ * position against that position's type (KF-3QEZFB: nested params). Without
87
+ * them, neither is a literal.
88
+ */
89
+ export function literalOf(value, type, definitions, hooks) {
90
+ if (
91
+ hooks?.dynamic &&
92
+ isObject(value) &&
93
+ ('$param' in value || '$bind' in value)
94
+ )
95
+ return hooks.dynamic(value, type);
96
+ const target = resolveType(type, definitions);
97
+ if (value === null) return target.nullable === true;
98
+ switch (target.kind) {
99
+ case 'unknown':
100
+ return true;
101
+ case 'union':
102
+ return target.members.some((member) =>
103
+ literalOf(value, member, definitions, hooks),
104
+ );
105
+ case 'string':
106
+ return typeof value === 'string';
107
+ case 'number':
108
+ return typeof value === 'number' && Number.isFinite(value);
109
+ case 'boolean':
110
+ return typeof value === 'boolean';
111
+ case 'enum':
112
+ return target.values.includes(value);
113
+ case 'literal':
114
+ return value === target.value;
115
+ // A builder call inside a list or object value (KF-3J9GJV).
116
+ case 'css-value':
117
+ return isObject(value) && parseCssCall(value.$css) !== undefined;
118
+ case 'content':
119
+ if (value instanceof ZoneFill) return true;
120
+ if (hooks?.slot && isObject(value) && '$slot' in value)
121
+ return hooks.slot(value);
122
+ return (
123
+ target.acceptsText === true &&
124
+ (typeof value === 'string' || typeof value === 'number')
125
+ );
126
+ case 'array':
127
+ return (
128
+ Array.isArray(value) &&
129
+ value.every((item) => literalOf(item, target.items, definitions, hooks))
130
+ );
131
+ case 'record':
132
+ return (
133
+ isObject(value) &&
134
+ Object.values(value).every((item) => typeof item === 'string')
135
+ );
136
+ case 'object': {
137
+ if (!isObject(value)) return false;
138
+ const known = new Map(
139
+ (target.props ?? []).map((prop) => [prop.name, prop]),
140
+ );
141
+ const { index } = target;
142
+ return (
143
+ Object.entries(value).every(([name, item]) =>
144
+ known.has(name)
145
+ ? // An icon-data field names its icon (KF-3J9GJV).
146
+ (known.get(name).iconSource &&
147
+ ICON_NAME.test(item?.$icon ?? '')) ||
148
+ literalOf(item, known.get(name).type, definitions, hooks)
149
+ : index !== undefined &&
150
+ name.startsWith(index.keyPrefix) &&
151
+ literalOf(item, index.value, definitions, hooks),
152
+ ) &&
153
+ [...known.values()].every(
154
+ (prop) => !prop.required || prop.name in value,
155
+ )
156
+ );
157
+ }
158
+ default:
159
+ return false;
160
+ }
161
+ }
@@ -7,9 +7,11 @@
7
7
  // adjusted. Where a check depends on more than those places (the order of
8
8
  // action uses, duplicate ids; docs/26-ui-editor.md §8.1), the check answers `undefined`
9
9
  // and the caller validates in full, so an answer is never a guess.
10
+ import { childKind } from './child-kind.mjs';
10
11
  import {
11
12
  childFacts,
12
13
  createScopedCheck,
14
+ eachTemplates,
13
15
  runView,
14
16
  validateView,
15
17
  } from './validate.mjs';
@@ -45,11 +47,16 @@ function sharedSlot(root) {
45
47
  };
46
48
  const child = (item) => {
47
49
  if (!isObject(item)) return false;
48
- if ('$each' in item) return node(item.template);
49
- if ('$if' in item)
50
- return value(item.$if) || child(item.then) || child(item.else);
51
- if ('$slot' in item) return value(item.input);
52
- return node(item);
50
+ switch (childKind(item)) {
51
+ case 'each':
52
+ return value(item.kind) || eachTemplates(item).some(child);
53
+ case 'if':
54
+ return value(item.$if) || child(item.then) || child(item.else);
55
+ case 'slot':
56
+ return value(item.input);
57
+ default:
58
+ return node(item);
59
+ }
53
60
  };
54
61
  const node = (item) =>
55
62
  isObject(item) &&
@@ -88,14 +95,21 @@ function indexDocument(document) {
88
95
  }
89
96
  };
90
97
  const child = (item, parent, zone, index, direct) => {
91
- if (!isObject(item)) ok = false;
92
- else if ('$each' in item) node(item.template);
93
- else if ('$if' in item) {
94
- child(item.then, parent, zone, index, false);
95
- if ('else' in item) child(item.else, parent, zone, index, false);
96
- } else if (!('$slot' in item)) {
97
- if (direct) placements.set(item.id, { parent, zone, index });
98
- node(item);
98
+ if (!isObject(item)) return void (ok = false);
99
+ switch (childKind(item)) {
100
+ case 'each':
101
+ for (const template of eachTemplates(item))
102
+ child(template, parent, zone, index, false);
103
+ break;
104
+ case 'if':
105
+ child(item.then, parent, zone, index, false);
106
+ if ('else' in item) child(item.else, parent, zone, index, false);
107
+ break;
108
+ case 'slot':
109
+ break;
110
+ default:
111
+ if (direct) placements.set(item.id, { parent, zone, index });
112
+ node(item);
99
113
  }
100
114
  };
101
115
  if (ok) node(document.root);
@@ -104,12 +118,16 @@ function indexDocument(document) {
104
118
 
105
119
  /** The ids of every node a zone child holds, itself included. */
106
120
  function heldIds(item, ids = new Set()) {
107
- if ('$slot' in item) return ids;
108
- if ('$each' in item) return heldIds(item.template, ids);
109
- if ('$if' in item) {
110
- heldIds(item.then, ids);
111
- if (item.else) heldIds(item.else, ids);
112
- return ids;
121
+ switch (childKind(item)) {
122
+ case 'slot':
123
+ return ids;
124
+ case 'each':
125
+ for (const template of eachTemplates(item)) heldIds(template, ids);
126
+ return ids;
127
+ case 'if':
128
+ heldIds(item.then, ids);
129
+ if (item.else) heldIds(item.else, ids);
130
+ return ids;
113
131
  }
114
132
  ids.add(item.id);
115
133
  for (const list of Object.values(item.zones ?? {}))
@@ -138,20 +156,38 @@ function prepareTree(node, prepare, map) {
138
156
  }
139
157
 
140
158
  function prepareChild(item, prepare, map) {
141
- if ('$each' in item) {
142
- const template = prepareTree(item.template, prepare, map);
143
- return template === item.template ? item : { ...item, template };
159
+ switch (childKind(item)) {
160
+ case 'each':
161
+ return prepareEach(item, prepare, map);
162
+ case 'if': {
163
+ const then = prepareChild(item.then, prepare, map);
164
+ const otherwise =
165
+ 'else' in item ? prepareChild(item.else, prepare, map) : undefined;
166
+ return then === item.then && otherwise === item.else
167
+ ? item
168
+ : { ...item, then, ...('else' in item ? { else: otherwise } : {}) };
169
+ }
170
+ case 'slot':
171
+ return item;
172
+ default:
173
+ return prepareTree(item, prepare, map);
144
174
  }
145
- if ('$if' in item) {
146
- const then = prepareChild(item.then, prepare, map);
147
- const otherwise =
148
- 'else' in item ? prepareChild(item.else, prepare, map) : undefined;
149
- return then === item.then && otherwise === item.else
175
+ }
176
+
177
+ function prepareEach(item, prepare, map) {
178
+ if ('templates' in item) {
179
+ // KF-YX6HMT: one prepared node per kind, sharing an unchanged map.
180
+ const entries = Object.entries(item.templates);
181
+ const prepared = entries.map(([kind, node]) => [
182
+ kind,
183
+ prepareChild(node, prepare, map),
184
+ ]);
185
+ return prepared.every(([, node], index) => node === entries[index][1])
150
186
  ? item
151
- : { ...item, then, ...('else' in item ? { else: otherwise } : {}) };
187
+ : { ...item, templates: Object.fromEntries(prepared) };
152
188
  }
153
- if ('$slot' in item) return item;
154
- return prepareTree(item, prepare, map);
189
+ const template = prepareChild(item.template, prepare, map);
190
+ return template === item.template ? item : { ...item, template };
155
191
  }
156
192
 
157
193
  /**