soma-kit 0.1.15 → 0.1.16

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 (470) hide show
  1. package/README.md +1 -1
  2. package/package.json +8 -5
  3. package/packs/ai/model-card.ts +3 -3
  4. package/packs/ops/error-budget-card.ts +3 -3
  5. package/packs/ops/release-readiness-card.ts +3 -3
  6. package/packs/security/control-evidence-card.ts +3 -3
  7. package/packs/security/finding-card.ts +3 -2
  8. package/packs/shared/card-util.ts +17 -0
  9. package/spec/generated/kit-app.schema.json +2148 -340
  10. package/spec/generated/kit-page.schema.json +1134 -139
  11. package/spec/kit-grammar.json +934 -92
  12. package/spec/kit-grammar.schema.json +167 -2
  13. package/src/app/app-config.ts +219 -186
  14. package/src/app/define-kit-actions.ts +126 -20
  15. package/src/app/define-kit-app.ts +49 -4
  16. package/src/app/index.ts +5 -0
  17. package/src/app/kit-view-context.ts +39 -1
  18. package/src/app/list-page-defaults.ts +14 -0
  19. package/src/app/server-pages.ts +239 -7
  20. package/src/app/server.ts +466 -25
  21. package/src/app/theme-endpoint.ts +67 -23
  22. package/src/app/theme-runtime.ts +414 -85
  23. package/src/app/theme-shards.ts +69 -0
  24. package/src/app/tier-compat.ts +107 -0
  25. package/src/base/action-busy.ts +215 -38
  26. package/src/base/affix.ts +137 -0
  27. package/src/base/alert.ts +104 -59
  28. package/src/base/anchored-layer.ts +7 -6
  29. package/src/base/avatar.ts +147 -61
  30. package/src/base/badge.ts +186 -0
  31. package/src/base/button-group.ts +227 -0
  32. package/src/base/button.ts +347 -50
  33. package/src/base/card.ts +233 -0
  34. package/src/base/cascader.ts +143 -32
  35. package/src/base/check-core.ts +193 -33
  36. package/src/base/checkbox.ts +67 -2
  37. package/src/base/choice.ts +132 -31
  38. package/src/base/collapse.ts +249 -0
  39. package/src/base/color-picker.ts +399 -27
  40. package/src/base/combobox.ts +6 -2
  41. package/src/base/command-palette.ts +148 -36
  42. package/src/base/context-menu.ts +23 -6
  43. package/src/base/countdown.ts +37 -15
  44. package/src/base/date-range.ts +114 -96
  45. package/src/base/date.ts +481 -74
  46. package/src/base/delta.ts +16 -9
  47. package/src/base/divider.ts +51 -33
  48. package/src/base/end-edge.ts +10 -4
  49. package/src/base/fab.ts +57 -21
  50. package/src/base/gap-value.ts +34 -15
  51. package/src/base/hint-tips.ts +99 -29
  52. package/src/base/identity-cells.ts +839 -0
  53. package/src/base/illustrations.ts +6 -4
  54. package/src/base/image.ts +40 -19
  55. package/src/base/index.ts +79 -22
  56. package/src/base/inline-error.ts +13 -7
  57. package/src/base/input.ts +135 -35
  58. package/src/base/kbd.ts +30 -17
  59. package/src/base/kit-contract.ts +400 -0
  60. package/src/base/link.ts +41 -20
  61. package/src/base/listbox-core.ts +282 -101
  62. package/src/base/loading-gate.ts +3 -0
  63. package/src/base/look.ts +197 -0
  64. package/src/base/mentions.ts +55 -22
  65. package/src/base/menu-button.ts +73 -22
  66. package/src/base/menu-core.ts +201 -24
  67. package/src/base/month-grid.ts +60 -3
  68. package/src/base/motion/aura.ts +52 -10
  69. package/src/base/motion/hover-3d.ts +7 -5
  70. package/src/base/motion/hover-gallery.ts +16 -12
  71. package/src/base/motion/limits.ts +10 -0
  72. package/src/base/motion/marquee.ts +18 -11
  73. package/src/base/motion/text-rotate.ts +34 -16
  74. package/src/base/notification.ts +292 -0
  75. package/src/base/number.ts +93 -12
  76. package/src/base/otp.ts +139 -27
  77. package/src/base/overlay-runtime.ts +30 -23
  78. package/src/base/overlay-shell.ts +59 -14
  79. package/src/base/period-picker.ts +868 -0
  80. package/src/base/popover.ts +624 -73
  81. package/src/base/popup.ts +187 -52
  82. package/src/base/portal-core.ts +99 -2
  83. package/src/base/price-text.ts +51 -17
  84. package/src/base/progress.ts +100 -18
  85. package/src/base/qr-code.ts +64 -17
  86. package/src/base/qty-stepper.ts +141 -22
  87. package/src/base/radio.ts +43 -2
  88. package/src/base/range.ts +194 -39
  89. package/src/base/rating.ts +117 -31
  90. package/src/base/reason-tip.ts +58 -16
  91. package/src/base/relation-cells.ts +541 -0
  92. package/src/base/resize-handle.ts +5 -3
  93. package/src/base/row-fresh.ts +84 -0
  94. package/src/base/section-spy.ts +79 -0
  95. package/src/base/segmented.ts +70 -26
  96. package/src/base/select.ts +8 -3
  97. package/src/base/shared.ts +482 -71
  98. package/src/base/spinner.ts +107 -0
  99. package/src/base/state-panel.ts +77 -22
  100. package/src/base/sticky-edge.ts +96 -29
  101. package/src/base/swap.ts +39 -21
  102. package/src/base/switch.ts +158 -38
  103. package/src/base/tabs.ts +292 -0
  104. package/src/base/tag-input.ts +123 -54
  105. package/src/base/tag.ts +184 -66
  106. package/src/base/text.ts +461 -71
  107. package/src/base/textarea.ts +88 -39
  108. package/src/base/time-picker.ts +335 -55
  109. package/src/base/time-range.ts +846 -0
  110. package/src/base/tree-select.ts +342 -88
  111. package/src/base/upload.ts +604 -158
  112. package/src/base/view-transition.ts +7 -3
  113. package/src/base/virtual-list.ts +49 -14
  114. package/src/biz/approval-desk/compile.ts +70 -5
  115. package/src/biz/approval-desk/index.ts +2 -0
  116. package/src/biz/approval-desk/shell.ts +52 -12
  117. package/src/biz/auth-panel/compile.ts +13 -3
  118. package/src/biz/auth-panel/shell.ts +27 -7
  119. package/src/biz/category-crud/compile.ts +51 -13
  120. package/src/biz/category-crud/index.ts +2 -0
  121. package/src/biz/category-crud/shell.ts +29 -9
  122. package/src/biz/checkout-page/compile.ts +37 -3
  123. package/src/biz/checkout-page/index.ts +1 -0
  124. package/src/biz/checkout-page/shell.ts +26 -9
  125. package/src/biz/compose.ts +6 -1
  126. package/src/biz/data-components.ts +2 -0
  127. package/src/biz/import-wizard/compile.ts +4 -1
  128. package/src/biz/import-wizard/index.ts +1 -0
  129. package/src/biz/import-wizard/shell.ts +32 -18
  130. package/src/biz/index.ts +1 -1
  131. package/src/biz/landing-page/compile.ts +3 -2
  132. package/src/biz/landing-page/shell.ts +22 -3
  133. package/src/biz/layout-contracts.ts +918 -0
  134. package/src/biz/link/hub.ts +199 -8
  135. package/src/biz/link/shared.ts +54 -15
  136. package/src/biz/master-sub/compile.ts +194 -57
  137. package/src/biz/master-sub/detail-head.ts +141 -18
  138. package/src/biz/master-sub/index.ts +3 -0
  139. package/src/biz/master-sub/shell.ts +186 -57
  140. package/src/biz/multi-board/compile.ts +87 -36
  141. package/src/biz/multi-board/composition.ts +7 -20
  142. package/src/biz/multi-board/index.ts +3 -2
  143. package/src/biz/multi-board/prose-fold.ts +15 -11
  144. package/src/biz/multi-board/shell.ts +148 -37
  145. package/src/biz/notification-center/compile.ts +20 -6
  146. package/src/biz/notification-center/index.ts +2 -0
  147. package/src/biz/notification-center/shell.ts +43 -10
  148. package/src/biz/page-templates/domain-templates.ts +145 -22
  149. package/src/biz/page-templates/result-page/compile.ts +4 -1
  150. package/src/biz/page-templates/result-page/index.ts +1 -0
  151. package/src/biz/page-templates/result-page/shell.ts +17 -4
  152. package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
  153. package/src/biz/page-templates/sign-in-page/index.ts +1 -0
  154. package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
  155. package/src/biz/record-detail/compile.ts +39 -11
  156. package/src/biz/record-detail/index.ts +1 -0
  157. package/src/biz/record-detail/shell.ts +41 -10
  158. package/src/biz/settings-center/compile.ts +4 -1
  159. package/src/biz/settings-center/index.ts +1 -0
  160. package/src/biz/settings-center/shell.ts +30 -9
  161. package/src/biz/shared/action-host.ts +137 -46
  162. package/src/biz/shared/compile-helpers.ts +130 -28
  163. package/src/biz/shared/coordinator.ts +628 -147
  164. package/src/biz/shared/focus-return.ts +180 -0
  165. package/src/biz/shared/object-aliases.ts +7 -1
  166. package/src/biz/shared/overlay-compile.ts +58 -10
  167. package/src/biz/shared/overlay-shell.ts +40 -10
  168. package/src/biz/shared/page-form-actions.ts +151 -0
  169. package/src/biz/shared/page-form.ts +255 -0
  170. package/src/biz/shared/pipeline.ts +74 -0
  171. package/src/biz/shared/runtime-hub.ts +101 -8
  172. package/src/biz/shared/verbs.ts +129 -0
  173. package/src/biz/single-form/compile.ts +4 -2
  174. package/src/biz/single-form/index.ts +2 -0
  175. package/src/biz/single-form/shell.ts +21 -11
  176. package/src/biz/standard-crud/compile.ts +206 -38
  177. package/src/biz/standard-crud/index.ts +2 -1
  178. package/src/biz/standard-crud/shell.ts +82 -22
  179. package/src/biz/standard-crud/summary.ts +2 -37
  180. package/src/biz/step-form/compile.ts +12 -3
  181. package/src/biz/step-form/hub.ts +165 -50
  182. package/src/biz/step-form/index.ts +1 -0
  183. package/src/biz/step-form/shell.ts +31 -15
  184. package/src/biz/types.ts +40 -4
  185. package/src/cli/kit-cli.ts +145 -26
  186. package/src/cli/kit-init.ts +3 -3
  187. package/src/cli/migrate/theme-map.ts +35 -28
  188. package/src/cli/migrate/ts-rules.ts +2 -2
  189. package/src/cli/migrate/types.ts +3 -3
  190. package/src/cli/migrate/yaml-rules.ts +11 -9
  191. package/src/cli/view-writes.ts +13 -0
  192. package/src/compile/closed-set.ts +102 -6
  193. package/src/compile/compile-page.ts +446 -53
  194. package/src/compile/component-candidates.ts +56 -4
  195. package/src/compile/danger-tier.ts +65 -0
  196. package/src/compile/hints.ts +1 -1
  197. package/src/compile/info-structure.ts +155 -0
  198. package/src/compile/layout-lint/rules-composition.ts +2 -1
  199. package/src/compile/layout-lint/rules-table.ts +4 -19
  200. package/src/compile/look-page.ts +551 -0
  201. package/src/compile/look.ts +376 -0
  202. package/src/compile/page-composition.ts +382 -46
  203. package/src/compile/page-hierarchy.ts +131 -0
  204. package/src/compile/page-pipeline-look.ts +156 -0
  205. package/src/compile/page-pipeline.ts +200 -0
  206. package/src/compile/parse.ts +12 -11
  207. package/src/compile/relation-render.ts +120 -0
  208. package/src/compile/remove-guard.ts +115 -41
  209. package/src/compile/stages.ts +645 -28
  210. package/src/compile/styles.ts +226 -26
  211. package/src/compile/types.ts +62 -5
  212. package/src/compile/view-check.ts +190 -1
  213. package/src/data/access-gate.ts +17 -9
  214. package/src/data/amount-breakdown.ts +49 -22
  215. package/src/data/anchor-nav.ts +73 -15
  216. package/src/data/approval-flow.ts +210 -124
  217. package/src/data/assignment-picker.ts +163 -85
  218. package/src/data/async-result-panel.ts +110 -46
  219. package/src/data/audit-log.ts +461 -0
  220. package/src/data/breadcrumbs.ts +141 -19
  221. package/src/data/calendar.ts +434 -96
  222. package/src/data/card-grid.ts +319 -0
  223. package/src/data/carousel.ts +72 -38
  224. package/src/data/cell-value.ts +253 -0
  225. package/src/data/chart.ts +904 -77
  226. package/src/data/checklist.ts +78 -35
  227. package/src/data/code-view.ts +106 -48
  228. package/src/data/comment-thread.ts +607 -87
  229. package/src/data/compare-view.ts +227 -0
  230. package/src/data/confirm-dialog.ts +198 -30
  231. package/src/data/context-menu.ts +95 -21
  232. package/src/data/d9-limits.ts +2 -0
  233. package/src/data/d9-util.ts +13 -5
  234. package/src/data/diff.ts +107 -50
  235. package/src/data/display-util.ts +9 -4
  236. package/src/data/dock.ts +33 -17
  237. package/src/data/embed.ts +142 -7
  238. package/src/data/engine-ports.ts +13 -4
  239. package/src/data/field-mapper.ts +104 -48
  240. package/src/data/file-list.ts +522 -0
  241. package/src/data/flow-editor.ts +603 -142
  242. package/src/data/flow-node-options.ts +24 -5
  243. package/src/data/flow-remote-options.ts +94 -19
  244. package/src/data/footer.ts +85 -27
  245. package/src/data/form-draft-registry.ts +183 -12
  246. package/src/data/gantt.ts +637 -117
  247. package/src/data/graph-view.ts +51 -0
  248. package/src/data/heat-calendar.ts +412 -0
  249. package/src/data/hero.ts +38 -15
  250. package/src/data/image-viewer.ts +261 -62
  251. package/src/data/index.ts +63 -1
  252. package/src/data/item-list.ts +217 -57
  253. package/src/data/json-view.ts +165 -100
  254. package/src/data/kanban.ts +339 -87
  255. package/src/data/kit-contract.ts +230 -0
  256. package/src/data/leaderboard.ts +343 -0
  257. package/src/data/level-class.ts +21 -0
  258. package/src/data/log-stream.ts +347 -0
  259. package/src/data/markdown-view.ts +155 -45
  260. package/src/data/matrix.ts +217 -112
  261. package/src/data/media-grid.ts +162 -38
  262. package/src/data/mega-menu.ts +39 -23
  263. package/src/data/menu-bar.ts +254 -0
  264. package/src/data/menu-dom.ts +50 -15
  265. package/src/data/menu.ts +131 -47
  266. package/src/data/mockup.ts +30 -22
  267. package/src/data/modal-dialog.ts +90 -13
  268. package/src/data/navbar.ts +143 -61
  269. package/src/data/notice-list.ts +100 -48
  270. package/src/data/notify-renderer.ts +61 -7
  271. package/src/data/object-form.ts +1389 -130
  272. package/src/data/org-chart.ts +544 -0
  273. package/src/data/outcome-watch.ts +90 -21
  274. package/src/data/pager.ts +122 -42
  275. package/src/data/panel-head.ts +237 -75
  276. package/src/data/permission-matrix.ts +371 -119
  277. package/src/data/permission-tree.ts +135 -80
  278. package/src/data/pricing-table.ts +106 -42
  279. package/src/data/prompt-dialog.ts +49 -21
  280. package/src/data/reaction-bar.ts +63 -31
  281. package/src/data/record-card.ts +239 -70
  282. package/src/data/record-picker.ts +56 -27
  283. package/src/data/redirect.ts +39 -15
  284. package/src/data/request-console.ts +131 -41
  285. package/src/data/resident.ts +11 -1
  286. package/src/data/result-panel.ts +65 -27
  287. package/src/data/rich-text.ts +206 -35
  288. package/src/data/row-confirm.ts +47 -0
  289. package/src/data/row-editor.ts +376 -102
  290. package/src/data/rule-builder.ts +129 -80
  291. package/src/data/schedule-grid.ts +238 -0
  292. package/src/data/segment-bar.ts +221 -0
  293. package/src/data/shape-util.ts +86 -43
  294. package/src/data/stage-flow.ts +244 -0
  295. package/src/data/staged-rows.ts +207 -24
  296. package/src/data/stat-group.ts +438 -86
  297. package/src/data/static-lazy.ts +18 -0
  298. package/src/data/static-registry.ts +38 -2
  299. package/src/data/status-strip.ts +171 -0
  300. package/src/data/steps.ts +63 -34
  301. package/src/data/summary-strip.ts +136 -0
  302. package/src/data/summary-util.ts +116 -0
  303. package/src/data/survey.ts +128 -47
  304. package/src/data/system-switcher.ts +40 -20
  305. package/src/data/target-progress.ts +208 -0
  306. package/src/data/text-action-button.ts +28 -7
  307. package/src/data/text-diff.ts +99 -31
  308. package/src/data/tile-grid.ts +343 -0
  309. package/src/data/timeline.ts +205 -36
  310. package/src/data/tour-guide.ts +110 -47
  311. package/src/data/transfer.ts +195 -47
  312. package/src/data/tree-table.ts +194 -112
  313. package/src/data/tree.ts +191 -70
  314. package/src/data/trend-line.ts +68 -12
  315. package/src/data/virtual-rows.ts +242 -102
  316. package/src/data/waterfall.ts +171 -0
  317. package/src/data/watermark.ts +35 -6
  318. package/src/data/wrap.ts +26 -4
  319. package/src/frames/blank-frame.ts +6 -4
  320. package/src/frames/index.ts +1 -2
  321. package/src/frames/inherited-shell.ts +54 -13
  322. package/src/frames/page-bar.ts +205 -27
  323. package/src/frames/page-status.ts +3 -2
  324. package/src/frames/resident-components.ts +0 -2
  325. package/src/frames/shared.ts +64 -21
  326. package/src/frames/single-frame.ts +20 -4
  327. package/src/frames/split-frame/shell.ts +11 -7
  328. package/src/frames/split-frame/wiring.ts +14 -10
  329. package/src/frames/tabs-frame/shell.ts +3 -2
  330. package/src/frames/tabs-frame/wiring.ts +2 -1
  331. package/src/frames/top-main-frame.ts +55 -3
  332. package/src/frames/types.ts +2 -0
  333. package/src/frames/workspace-frame/extras.ts +5 -3
  334. package/src/frames/workspace-frame/index.ts +1 -1
  335. package/src/frames/workspace-frame/pipeline-key.ts +6 -0
  336. package/src/frames/workspace-frame/shell.ts +22 -2
  337. package/src/frames/workspace-frame/state.ts +42 -14
  338. package/src/frames/workspace-frame/view.ts +697 -167
  339. package/src/generated/kit-grammar-runtime.ts +1015 -53
  340. package/src/generated/kit-page.ts +272 -0
  341. package/src/i18n/index.ts +2 -0
  342. package/src/i18n/kit-text.ts +96 -3
  343. package/src/object-renderer/action-group.ts +175 -23
  344. package/src/object-renderer/action-more.ts +48 -17
  345. package/src/object-renderer/arrange.ts +241 -29
  346. package/src/object-renderer/category-tone.ts +96 -0
  347. package/src/object-renderer/collapse-wiring.ts +19 -9
  348. package/src/object-renderer/collection-expand.ts +3 -3
  349. package/src/object-renderer/collection-parts.ts +432 -107
  350. package/src/object-renderer/collection-table.ts +347 -45
  351. package/src/object-renderer/collection.ts +291 -62
  352. package/src/object-renderer/compile-data.ts +12 -2
  353. package/src/object-renderer/defaults.ts +6 -5
  354. package/src/object-renderer/emit-events.ts +45 -19
  355. package/src/object-renderer/emit-object.ts +35 -9
  356. package/src/object-renderer/emit-static.ts +734 -159
  357. package/src/object-renderer/filter-plan.ts +3 -3
  358. package/src/object-renderer/filter-toolbar.ts +105 -18
  359. package/src/object-renderer/form-detail.ts +87 -2
  360. package/src/object-renderer/key-field.ts +21 -0
  361. package/src/object-renderer/layout-facts.ts +18 -2
  362. package/src/object-renderer/layout-plan.ts +6 -3
  363. package/src/object-renderer/overlay-decide.ts +44 -2
  364. package/src/object-renderer/pick-component.ts +8 -2
  365. package/src/object-renderer/pipeline-mode.ts +6 -0
  366. package/src/object-renderer/relation-field.ts +79 -0
  367. package/src/object-renderer/render-object.ts +71 -26
  368. package/src/object-renderer/request-actions.ts +119 -21
  369. package/src/object-renderer/table-actions.ts +424 -103
  370. package/src/object-renderer/table-gap.ts +2 -1
  371. package/src/object-renderer/table-reorder.ts +237 -0
  372. package/src/object-renderer/table-summary.ts +26 -12
  373. package/src/object-renderer/table-tools.ts +428 -128
  374. package/src/object-renderer/types.ts +91 -2
  375. package/src/object-renderer/value-present.ts +49 -0
  376. package/src/page-target/ai-surface.ts +15 -22
  377. package/src/page-target/compile.ts +5 -6
  378. package/src/page-target/drift.ts +0 -7
  379. package/src/page-target/intent-schema.ts +46 -43
  380. package/src/page-target/target.ts +4 -5
  381. package/src/page-target/writer-policy.ts +4 -5
  382. package/src/recipes/chrome-surface.ts +20 -0
  383. package/src/recipes/code-view.ts +15 -14
  384. package/src/recipes/color-role.ts +442 -0
  385. package/src/recipes/compact-group.ts +3 -2
  386. package/src/recipes/composition-projector.ts +321 -0
  387. package/src/recipes/container.ts +76 -19
  388. package/src/recipes/control.ts +64 -5
  389. package/src/recipes/desc-list.ts +101 -7
  390. package/src/recipes/divider.ts +30 -9
  391. package/src/recipes/emphasis.ts +90 -5
  392. package/src/recipes/field-text.ts +72 -0
  393. package/src/recipes/form-section.ts +177 -0
  394. package/src/recipes/frame-bleed.ts +3 -2
  395. package/src/recipes/index.ts +28 -4
  396. package/src/recipes/inherited-shell.ts +21 -15
  397. package/src/recipes/json-view.ts +6 -5
  398. package/src/recipes/look.ts +56 -0
  399. package/src/recipes/mark.ts +138 -0
  400. package/src/recipes/markdown.ts +16 -6
  401. package/src/recipes/overlay.ts +47 -19
  402. package/src/recipes/page-width.ts +31 -0
  403. package/src/recipes/pipeline-runtime.ts +366 -0
  404. package/src/recipes/placeholder.ts +37 -19
  405. package/src/recipes/rail-grid.ts +6 -3
  406. package/src/recipes/self-owned.ts +59 -0
  407. package/src/recipes/slot-align.ts +5 -3
  408. package/src/recipes/stat-state.ts +5 -5
  409. package/src/recipes/state.ts +54 -3
  410. package/src/recipes/status.ts +14 -14
  411. package/src/recipes/strip.ts +47 -5
  412. package/src/recipes/surface-edge.ts +3 -1
  413. package/src/recipes/surface.ts +33 -4
  414. package/src/recipes/table-gap.ts +3 -2
  415. package/src/recipes/table-native-edit.ts +22 -9
  416. package/src/recipes/table-row.ts +45 -12
  417. package/src/recipes/tabs.ts +54 -22
  418. package/src/recipes/text-diff.ts +15 -8
  419. package/src/recipes/text-fit.ts +132 -0
  420. package/src/recipes/title-row.ts +68 -3
  421. package/src/shared/action-func.ts +106 -0
  422. package/src/shared/color-scheme.ts +127 -0
  423. package/src/shared/confirm-decl.ts +5 -2
  424. package/src/shared/danger-facts.ts +55 -0
  425. package/src/shared/dom-attrs-registry.ts +1009 -0
  426. package/src/shared/dom-attrs.ts +743 -0
  427. package/src/shared/field-kind.ts +49 -0
  428. package/src/shared/field-value-format.ts +58 -12
  429. package/src/shared/glyphs.ts +127 -0
  430. package/src/shared/icons.ts +28 -1
  431. package/src/shared/identifier-field.ts +66 -0
  432. package/src/shared/list-pager.ts +23 -0
  433. package/src/shared/list-title.ts +29 -0
  434. package/src/shared/order-value.ts +15 -0
  435. package/src/shared/page-attrs-runtime.ts +327 -0
  436. package/src/shared/page-attrs.ts +262 -0
  437. package/src/shared/pipeline-mode.ts +64 -0
  438. package/src/shared/row-key.ts +15 -0
  439. package/src/shared/theme-runtime-shared.ts +165 -24
  440. package/src/shared/theme-usage.ts +16 -0
  441. package/src/shared/value-table-contract.ts +68 -0
  442. package/src/spatial/action-func.ts +4 -0
  443. package/src/spatial/declared-actions.ts +116 -0
  444. package/src/spatial/emit.ts +660 -0
  445. package/src/spatial/expand.ts +1482 -0
  446. package/src/spatial/field-types.ts +48 -0
  447. package/src/spatial/index.ts +82 -0
  448. package/src/spatial/layout.ts +697 -0
  449. package/src/spatial/look-apply.ts +206 -0
  450. package/src/spatial/page-decl.ts +44 -0
  451. package/src/spatial/page-object.ts +349 -0
  452. package/src/spatial/recognize.ts +491 -0
  453. package/src/spatial/self-report.ts +571 -0
  454. package/src/spatial/shape.ts +205 -0
  455. package/src/spatial/spatial-map.ts +136 -0
  456. package/src/spatial/tone.ts +145 -0
  457. package/src/theme/index.ts +11 -2
  458. package/src/theme/kit-theme-text.ts +1 -1
  459. package/src/theme/kit-theme.css +527 -16
  460. package/src/theme/kit-theme.tpl +491 -16
  461. package/src/theme/look-carrier.ts +65 -0
  462. package/src/theme/nine-dim-structure.ts +522 -185
  463. package/src/theme/private-vars.ts +153 -0
  464. package/src/theme/surface-layers.ts +3 -2
  465. package/src/theme/theme-tokens.ts +1601 -93
  466. package/src/theme/theme-types.ts +38 -59
  467. package/src/theme/value-table.ts +2379 -0
  468. package/src/frames/list-summary.ts +0 -123
  469. package/src/recipes/nowrap.ts +0 -16
  470. package/src/theme/block-theme.ts +0 -202
@@ -0,0 +1,327 @@
1
+ // 组件侧的属性读写帮手(Kit 主题流水线):组件只做两件事——读自己的入参里由页面线写好的判定(props.kit),
2
+ // 以及自报自己知道的事实(层级角色、元素部件、区域作用域、数据状态、交互状态)。组件不判断主次、不判断该不该画框。
3
+ // 这里只有纯函数与对单个元素的属性读写,不依赖任何组件模块,供 base / data / object-renderer / biz / frames 共用。
4
+ // 属性名一律经 kitStructureAttr 生成,与属性总账(shared/page-attrs.ts)同源。
5
+
6
+ import {
7
+ KIT_ALIGNS, KIT_CONFIRMS, KIT_CONTROL_SIZES, KIT_DATA_STATES, KIT_ELEMENT_PARTS, KIT_INTERACT_STATES, KIT_KEEPS, KIT_LEVELS,
8
+ KIT_OVERFLOWS, KIT_SCOPES, KIT_TONES, KIT_VALUE_FORMS, KIT_VARIANTS, kitStructureAttr,
9
+ type KitAlign, type KitConfirm, type KitControlSize, type KitDataState, type KitElementPart, type KitInteractState, type KitKeep,
10
+ type KitLevel, type KitOverflow, type KitScope, type KitTone, type KitValueForm, type KitVariant,
11
+ } from './page-attrs';
12
+ import { KIT_ARRANGE } from 'soma-foundation/arrange';
13
+
14
+ /** 运行期自报用到的属性名(与总账的键一一对应,不在别处再拼一遍) */
15
+ export const KIT_SELF_ATTR = Object.freeze({
16
+ level: kitStructureAttr('level'),
17
+ part: kitStructureAttr('part'),
18
+ scope: kitStructureAttr('scope'),
19
+ dataState: kitStructureAttr('dataState'),
20
+ interact: kitStructureAttr('interact'),
21
+ /** 条带的流向与窄容器退让:只有运行期自画条带(表单底栏)经 kitWriteSelfKey 写,页面线锚点上的编译期值照旧不动 */
22
+ flow: kitStructureAttr('flow'),
23
+ collapse: kitStructureAttr('collapse'),
24
+ });
25
+
26
+ /** 组件自报的事实:都是组件自己就知道的,不含任何页面级判定 */
27
+ export interface KitSelfReportAttrs {
28
+ readonly level?: KitLevel;
29
+ readonly part?: KitElementPart;
30
+ /** 'none' 不写属性 */
31
+ readonly scope?: KitScope;
32
+ /** 'normal' 不写属性 */
33
+ readonly dataState?: KitDataState;
34
+ }
35
+
36
+ const esc = (v: string): string => v.replace(/&/g, '&').replace(/"/g, '"');
37
+
38
+ /**
39
+ * 模板字符串里用:返回带前导空格的属性串(没有可写的返回空串)。
40
+ * 例:`<div${kitSelfAttrs({ level: 'face' })} class="…">`
41
+ */
42
+ export function kitSelfAttrs(report: KitSelfReportAttrs): string {
43
+ let out = '';
44
+ if (report.level !== undefined) out += ` ${KIT_SELF_ATTR.level}="${esc(report.level)}"`;
45
+ if (report.part !== undefined) out += ` ${KIT_SELF_ATTR.part}="${esc(report.part)}"`;
46
+ if (report.scope !== undefined && report.scope !== 'none') out += ` ${KIT_SELF_ATTR.scope}="${esc(report.scope)}"`;
47
+ if (report.dataState !== undefined && report.dataState !== 'normal') out += ` ${KIT_SELF_ATTR.dataState}="${esc(report.dataState)}"`;
48
+ return out;
49
+ }
50
+
51
+ /** 自报记账支持的属性键(层级角色、元素部件、区域作用域、数据状态,以及运行期条带的流向、窄容器退让) */
52
+ export type KitSelfTrackedKey = 'level' | 'part' | 'scope' | 'dataState' | 'flow' | 'collapse';
53
+
54
+ /**
55
+ * 自报记账(唯一一份):按元素、按键记下「自报上一次写到这个节点上的值」。
56
+ * 只记自报经 kitWriteSelfKey 写的;模板、配方、页面线编译期写的值不在账上。WeakMap:节点被丢弃时记录随之回收。
57
+ */
58
+ const SELF_WRITTEN = new WeakMap<Element, Partial<Record<KitSelfTrackedKey, string>>>();
59
+
60
+ /**
61
+ * 层级角色 / 元素部件 / 区域作用域 / 数据状态的自报口径(唯一规则:本函数之外,kitMarkSelf、kitMarkScope、kitMarkDataState、
62
+ * base/kit-contract#kitReportSelf · kitReportSelfTracked、base/shared#kitReportSelfAll、data/kit-contract#kitMarkPart · kitMarkLevel 都经这里写):
63
+ * · 节点上没有值(或为空串)→ 写入并记账;
64
+ * · 节点上已有值、且正是自报上一次写的(账上的值)→ 按本次的值改写(值未变则跳过 DOM 写入);
65
+ * · 节点上已有值、但不是自报写的(模板、配方的私有钩子如 Input 的 control、rule-builder 的 value、title-row 的 icon,
66
+ * 页面线编译期写在锚点上的层级角色或区域作用域)→ 不动——不论那个值在不在闭集内;
67
+ * · value 为 undefined:节点上仍是自报上一次写的值 → 去掉;别人写的不动。
68
+ * 账上的值与节点当前值不一致(自报写过之后被别处改写)时,这条记录作废:之后视同别人写的。
69
+ * 返回本次由自报落在节点上的值(没写、被挡住或去掉时为 undefined)。
70
+ */
71
+ export function kitWriteSelfKey(el: Element, key: KitSelfTrackedKey, value: string | undefined): string | undefined {
72
+ const name = KIT_SELF_ATTR[key];
73
+ const now = el.getAttribute(name);
74
+ const book = SELF_WRITTEN.get(el);
75
+ const mine = book?.[key];
76
+ const ours = mine !== undefined && now === mine;
77
+ if (book !== undefined && mine !== undefined && !ours) delete book[key];
78
+ if (value === undefined) {
79
+ if (ours && book !== undefined) {
80
+ if (el.hasAttribute(name)) el.removeAttribute(name);
81
+ delete book[key];
82
+ }
83
+ return undefined;
84
+ }
85
+ if (now !== null && now !== '' && !ours) return undefined;
86
+ if (now !== value) el.setAttribute(name, value);
87
+ const entry = book ?? {};
88
+ entry[key] = value;
89
+ if (book === undefined) SELF_WRITTEN.set(el, entry);
90
+ return value;
91
+ }
92
+
93
+ /** 运行期给已存在的元素自报(控制器里新建节点、或数据到达后改写时用);传 undefined 的键不动;四键均按 kitWriteSelfKey 的口径写(已有值不是自报写的不覆盖) */
94
+ export function kitMarkSelf(el: Element, report: KitSelfReportAttrs): void {
95
+ if (report.level !== undefined) kitWriteSelfKey(el, 'level', report.level);
96
+ if (report.part !== undefined) kitWriteSelfKey(el, 'part', report.part);
97
+ if (report.scope !== undefined) kitMarkScope(el, report.scope);
98
+ if (report.dataState !== undefined) kitMarkDataState(el, report.dataState);
99
+ }
100
+
101
+ /** 区域作用域:'none' 时仅撤回本通道自报写入的属性(不误删宿主 / 编译期显式写入的 data-kit-scope);带脏检查 */
102
+ export function kitMarkScope(el: Element, scope: KitScope): void {
103
+ kitWriteSelfKey(el, 'scope', scope === 'none' ? undefined : scope);
104
+ }
105
+
106
+ /** 数据状态:'normal' 时仅撤回本通道自报写入的属性,其余写上(加载中、内容全空、加载出错、只读);带脏检查 */
107
+ export function kitMarkDataState(el: Element, state: KitDataState): void {
108
+ kitWriteSelfKey(el, 'dataState', state === 'normal' ? undefined : state);
109
+ }
110
+
111
+ /** 无分配检查空格分隔词表 raw 中是否已包含完整词 token(用于 kitMarkInteract 脏检查早退) */
112
+ function hasSpaceToken(raw: string, token: string): boolean {
113
+ const len = token.length;
114
+ let pos = raw.indexOf(token);
115
+ while (pos !== -1) {
116
+ const beforeOk = pos === 0 || /\s/.test(raw.charAt(pos - 1));
117
+ const afterPos = pos + len;
118
+ const afterOk = afterPos === raw.length || /\s/.test(raw.charAt(afterPos));
119
+ if (beforeOk && afterOk) return true;
120
+ pos = raw.indexOf(token, pos + 1);
121
+ }
122
+ return false;
123
+ }
124
+
125
+ /**
126
+ * 交互状态:悬停、按下、聚焦、禁用、校验失败优先走原生伪类与无障碍属性,组件只对选中、激活、拖拽中自报。
127
+ * 同一元素可同时有多个状态,写成空格分隔的词表;带脏检查,状态未变时不分配集合也不写 DOM。
128
+ */
129
+ export function kitMarkInteract(el: Element, state: KitInteractState, on: boolean): void {
130
+ const attr = KIT_SELF_ATTR.interact;
131
+ const raw = el.getAttribute(attr);
132
+ if (raw === null || raw === '') {
133
+ if (on) el.setAttribute(attr, state);
134
+ else if (raw !== null) el.removeAttribute(attr);
135
+ return;
136
+ }
137
+ if (raw === state) {
138
+ if (!on) el.removeAttribute(attr);
139
+ return;
140
+ }
141
+ const had = hasSpaceToken(raw, state);
142
+ if (on === had) return;
143
+ const now = new Set(raw.split(/\s+/).filter((s) => s !== ''));
144
+ if (on) now.add(state);
145
+ else now.delete(state);
146
+ if (now.size === 0) {
147
+ if (el.hasAttribute(attr)) el.removeAttribute(attr);
148
+ } else {
149
+ const next = [...now].join(' ');
150
+ if (raw !== next) el.setAttribute(attr, next);
151
+ }
152
+ }
153
+
154
+ /** 页面线写进组件入参 kit 对象里的判定(全部可选:legacy 下没有这个对象,组件按自己原来的缺省画) */
155
+ export interface KitRuntimeProps {
156
+ readonly controlSize?: KitControlSize;
157
+ readonly columns?: number;
158
+ readonly overflow?: KitOverflow;
159
+ readonly align?: KitAlign;
160
+ readonly width?: string;
161
+ readonly keep?: KitKeep;
162
+ readonly valueForm?: KitValueForm;
163
+ readonly tone?: KitTone;
164
+ /** 0 = 不启用分类色;大于 0 = 启用,逐项序号由组件按选项声明顺序取 */
165
+ readonly categoryIndex?: number;
166
+ readonly variant?: KitVariant;
167
+ readonly confirm?: KitConfirm;
168
+ readonly solid?: boolean;
169
+ readonly stowable?: boolean;
170
+ readonly titleHidden?: boolean;
171
+ /** 界面规则里跟数据走的条件规则,原样带到运行期由组件求值 */
172
+ readonly look?: readonly unknown[];
173
+ }
174
+
175
+ /**
176
+ * 列数上限:页面线布局写列数时的校验(spatial/layout.ts 的 columns 校验器)与运行期读列数同界,两处都取这一个常量。
177
+ * 真源(kit-arrange / kit-page.json)没有列数上限的字段,这是现有常量(原在 spatial/layout.ts#MAX_COLUMNS)下沉到这里,值不变。
178
+ */
179
+ export const KIT_COLUMNS_MAX = 99;
180
+ /** 字段宽度档的闭集:页面线布局写的 width 取自语法真源的列宽档名(KIT_ARRANGE.columns.widthRem 的键,spatial/layout.ts#widthClassOf),不是 CSS 长度 */
181
+ const WIDTH_TIERS: ReadonlySet<string> = new Set(Object.keys(KIT_ARRANGE.columns.widthRem as Readonly<Record<string, unknown>>));
182
+
183
+ /** 闭集查找表(模块加载时预建 Set,热路径 O(1) 判定,避免 Array.includes 线性扫描) */
184
+ const CONTROL_SIZE_SET: ReadonlySet<string> = new Set(KIT_CONTROL_SIZES);
185
+ const OVERFLOW_SET: ReadonlySet<string> = new Set(KIT_OVERFLOWS);
186
+ const ALIGN_SET: ReadonlySet<string> = new Set(KIT_ALIGNS);
187
+ const KEEP_SET: ReadonlySet<string> = new Set(KIT_KEEPS);
188
+ const VALUE_FORM_SET: ReadonlySet<string> = new Set(KIT_VALUE_FORMS);
189
+ const TONE_SET: ReadonlySet<string> = new Set(KIT_TONES);
190
+ const VARIANT_SET: ReadonlySet<string> = new Set(KIT_VARIANTS);
191
+ const CONFIRM_SET: ReadonlySet<string> = new Set(KIT_CONFIRMS);
192
+ const LEVEL_SET: ReadonlySet<string> = new Set(KIT_LEVELS);
193
+ const ELEMENT_PART_SET: ReadonlySet<string> = new Set(KIT_ELEMENT_PARTS);
194
+ const SCOPE_SET: ReadonlySet<string> = new Set(KIT_SCOPES);
195
+ const DATA_STATE_SET: ReadonlySet<string> = new Set(KIT_DATA_STATES);
196
+
197
+ const isRec = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
198
+ const oneOf = <T extends string>(set: ReadonlySet<string>, v: unknown): T | undefined => (typeof v === 'string' && set.has(v) ? (v as T) : undefined);
199
+ const bool = (v: unknown): boolean | undefined => (typeof v === 'boolean' ? v : undefined);
200
+
201
+ const EMPTY_KIT_PROPS: KitRuntimeProps = Object.freeze({});
202
+
203
+ interface KitPropsCacheEntry {
204
+ readonly parsed: KitRuntimeProps;
205
+ readonly frozen: boolean;
206
+ readonly controlSize: unknown;
207
+ readonly columns: unknown;
208
+ readonly overflow: unknown;
209
+ readonly align: unknown;
210
+ readonly width: unknown;
211
+ readonly keep: unknown;
212
+ readonly valueForm: unknown;
213
+ readonly tone: unknown;
214
+ readonly categoryIndex: unknown;
215
+ readonly variant: unknown;
216
+ readonly confirm: unknown;
217
+ readonly solid: unknown;
218
+ readonly stowable: unknown;
219
+ readonly titleHidden: unknown;
220
+ readonly look: unknown;
221
+ }
222
+
223
+ /**
224
+ * kit 对象解析缓存:键为 props.kit 本身(既服务 kitReadProps(props),也服务 kitFieldPropsOf / kitActionPropsOf 构造的 { kit: fields[f] });
225
+ * 冻结对象 O(1) 命中;可变对象按 15 个受控键做浅快照核验(遇到原地改写立即失效重算);含非空动态 look 数组的可变对象跳过缓存防止嵌套篡改失真。
226
+ */
227
+ const KIT_PROPS_CACHE = new WeakMap<Record<string, unknown>, KitPropsCacheEntry>();
228
+
229
+ function cacheMatches(entry: KitPropsCacheEntry, kit: Record<string, unknown>): boolean {
230
+ if (entry.frozen) return true;
231
+ return entry.controlSize === kit.controlSize
232
+ && entry.columns === kit.columns
233
+ && entry.overflow === kit.overflow
234
+ && entry.align === kit.align
235
+ && entry.width === kit.width
236
+ && entry.keep === kit.keep
237
+ && entry.valueForm === kit.valueForm
238
+ && entry.tone === kit.tone
239
+ && entry.categoryIndex === kit.categoryIndex
240
+ && entry.variant === kit.variant
241
+ && entry.confirm === kit.confirm
242
+ && entry.solid === kit.solid
243
+ && entry.stowable === kit.stowable
244
+ && entry.titleHidden === kit.titleHidden
245
+ && entry.look === kit.look;
246
+ }
247
+
248
+ /**
249
+ * 读组件入参里的 kit 对象。入参不可信(可能来自旧产物或手写页面):每个键都按闭集校验,不合法的当作没有。
250
+ * 没有 kit 对象时返回共享冻结空对象单例——调用方据此走自己原来的缺省,不需要另外判断新旧模式,也避免每次渲染分配空对象。
251
+ */
252
+ export function kitReadProps(props: unknown): KitRuntimeProps {
253
+ const kit = isRec(props) ? props.kit : undefined;
254
+ if (!isRec(kit)) return EMPTY_KIT_PROPS;
255
+ const cached = KIT_PROPS_CACHE.get(kit);
256
+ if (cached !== undefined && cacheMatches(cached, kit)) return cached.parsed;
257
+ const columns = typeof kit.columns === 'number' && Number.isInteger(kit.columns) && kit.columns > 0 && kit.columns <= KIT_COLUMNS_MAX ? kit.columns : undefined;
258
+ const categoryIndex = typeof kit.categoryIndex === 'number' && Number.isInteger(kit.categoryIndex) && kit.categoryIndex >= 0 ? kit.categoryIndex : undefined;
259
+ const out: { -readonly [K in keyof KitRuntimeProps]: KitRuntimeProps[K] } = {};
260
+ let hasAny = false;
261
+ const put = <K extends keyof KitRuntimeProps>(key: K, value: KitRuntimeProps[K] | undefined): void => {
262
+ if (value !== undefined) { out[key] = value; hasAny = true; }
263
+ };
264
+ put('controlSize', oneOf<KitControlSize>(CONTROL_SIZE_SET, kit.controlSize));
265
+ put('columns', columns);
266
+ put('overflow', oneOf<KitOverflow>(OVERFLOW_SET, kit.overflow));
267
+ put('align', oneOf<KitAlign>(ALIGN_SET, kit.align));
268
+ // 宽度只认列宽档名(闭集),任意字符串不当作宽度
269
+ put('width', typeof kit.width === 'string' && WIDTH_TIERS.has(kit.width) ? kit.width : undefined);
270
+ put('keep', oneOf<KitKeep>(KEEP_SET, kit.keep));
271
+ put('valueForm', oneOf<KitValueForm>(VALUE_FORM_SET, kit.valueForm));
272
+ put('tone', oneOf<KitTone>(TONE_SET, kit.tone));
273
+ put('categoryIndex', categoryIndex);
274
+ put('variant', oneOf<KitVariant>(VARIANT_SET, kit.variant));
275
+ put('confirm', oneOf<KitConfirm>(CONFIRM_SET, kit.confirm));
276
+ put('solid', bool(kit.solid));
277
+ put('stowable', bool(kit.stowable));
278
+ put('titleHidden', bool(kit.titleHidden));
279
+ // 条件规则逐条须是对象(形状 { key, value },见 spatial/emit.ts 的 dynamic 写入);不是对象的条目丢掉
280
+ const lookArr = Array.isArray(kit.look) ? kit.look.filter(isRec) : undefined;
281
+ put('look', lookArr !== undefined ? Object.freeze(lookArr) : undefined);
282
+ const parsed: KitRuntimeProps = hasAny ? Object.freeze(out) : EMPTY_KIT_PROPS;
283
+ const frozen = Object.isFrozen(kit);
284
+ // 非冻结且含数组 look 时不缓存(防止外部原地 push/改元素命中陈旧结果);其余一律缓存
285
+ if (frozen || !Array.isArray(kit.look)) {
286
+ KIT_PROPS_CACHE.set(kit, {
287
+ parsed,
288
+ frozen,
289
+ controlSize: kit.controlSize,
290
+ columns: kit.columns,
291
+ overflow: kit.overflow,
292
+ align: kit.align,
293
+ width: kit.width,
294
+ keep: kit.keep,
295
+ valueForm: kit.valueForm,
296
+ tone: kit.tone,
297
+ categoryIndex: kit.categoryIndex,
298
+ variant: kit.variant,
299
+ confirm: kit.confirm,
300
+ solid: kit.solid,
301
+ stowable: kit.stowable,
302
+ titleHidden: kit.titleHidden,
303
+ look: kit.look,
304
+ });
305
+ } else {
306
+ KIT_PROPS_CACHE.delete(kit);
307
+ }
308
+ return parsed;
309
+ }
310
+
311
+ /** 入参里有没有页面线写的判定:组件用它区分「按新流水线画」还是「按原来的缺省画」 */
312
+ export function kitHasProps(props: unknown): boolean {
313
+ return isRec(props) && isRec(props.kit);
314
+ }
315
+
316
+ /** 自报值的校验(给登记、测试用):不在闭集内返回 false */
317
+ export function kitIsSelfReportValid(report: KitSelfReportAttrs): boolean {
318
+ return (report.level === undefined || LEVEL_SET.has(report.level))
319
+ && (report.part === undefined || ELEMENT_PART_SET.has(report.part))
320
+ && (report.scope === undefined || SCOPE_SET.has(report.scope))
321
+ && (report.dataState === undefined || DATA_STATE_SET.has(report.dataState));
322
+ }
323
+
324
+ /** 交互状态里由组件自报的那三个;其余走原生伪类与无障碍属性,不该出现在 data-kit-interact 里 */
325
+ export const KIT_SELF_INTERACT_STATES: readonly KitInteractState[] = Object.freeze(
326
+ KIT_INTERACT_STATES.filter((s) => s === 'selected' || s === 'current' || s === 'dragging'),
327
+ );
@@ -0,0 +1,262 @@
1
+ // 主题流水线页面线的属性词登记处:闭集、合法父子层级角色对、属性总账的类型化出口。
2
+ // 真源是 soma-design/spec/pipeline/kit-page.json;数据常量由 soma-design/src/gen-kit-page.mjs 生成进 ../generated/kit-page.ts,
3
+ // 本文件只再导出那些常量,并保留由它们派生的类型别名、查询函数与说明——这里不再写任何闭集成员、父子对或总账行的字面值。
4
+ // 改词表请改真源并执行 `npm run generate -w soma-design`(或 `npm run regen -w soma-kit`);生成物新鲜度由两包的 verify:fresh 判定。
5
+ // 业务含义以 docs/01-业务功能/Kit主题业务功能描述.md 为准:取值只用英文短词,中文名只留在真源 label 里,代码里不出现第二份。
6
+ // 本文件是基础支撑层的叶子:只 import 同层的生成物,不 import 任何 kit 模块,任何层都可以依赖它。
7
+
8
+ import {
9
+ KIT_ALIGNS,
10
+ KIT_ARRANGES,
11
+ KIT_CLOSED_SETS,
12
+ KIT_COLLAPSES,
13
+ KIT_COMPONENT_PARTS,
14
+ KIT_CONFIRMS,
15
+ KIT_CONTROL_SIZES,
16
+ KIT_DANGERS,
17
+ KIT_DATA_STATES,
18
+ KIT_EDIT_CONTAINERS,
19
+ KIT_ELEMENT_PARTS,
20
+ KIT_EMPHASES,
21
+ KIT_ENVELOPES,
22
+ KIT_EXCLUSIVES,
23
+ KIT_FIELD_ROLES,
24
+ KIT_FIELD_TYPES,
25
+ KIT_FLOWS,
26
+ KIT_FUNCS,
27
+ KIT_HOSTS,
28
+ KIT_IDENTITIES,
29
+ KIT_INTERACT_STATES,
30
+ KIT_KEEPS,
31
+ KIT_LEDGER_ACTORS,
32
+ KIT_LEDGER_CARRIERS,
33
+ KIT_LEDGER_EVENTS,
34
+ KIT_LEDGER_NODE_KINDS,
35
+ KIT_LEDGER_OFF_PAGE_CARRIERS,
36
+ KIT_LEDGER_OFF_PAGE_KINDS,
37
+ KIT_LEVELS,
38
+ KIT_OVERFLOWS,
39
+ KIT_OWNERS,
40
+ KIT_PAGE_LEGAL_PAIRS,
41
+ KIT_PAGE_OFF_NODE_ATTRS,
42
+ KIT_PAGE_ON_NODE_ATTRS,
43
+ KIT_PAGE_RUNTIME_ATTRS,
44
+ KIT_PAGE_VALUE_TABLE_ATTRS,
45
+ KIT_PAIR_VERDICTS,
46
+ KIT_PLACES,
47
+ KIT_PRESENT_UNSET,
48
+ KIT_PRESENTS,
49
+ KIT_REGION_KINDS,
50
+ KIT_ROLES,
51
+ KIT_SCOPES,
52
+ KIT_SLOTS,
53
+ KIT_STRIP_KINDS,
54
+ KIT_TONES,
55
+ KIT_TREE_SHAPES,
56
+ KIT_VALUE_FORMS,
57
+ KIT_VARIANTS,
58
+ } from '../generated/kit-page';
59
+
60
+ // ── 闭集(业务功能描述 §8.1 的 28 个 + 第 2、3 节另用到的 7 个)────────────────────────
61
+ // 说明随真源走,这里只记几条读代码时要知道的:
62
+ // · 呈现(KIT_PRESENTS)九种实际形态;契约没写时展开写过渡值 KIT_PRESENT_UNSET,由识别补成九种之一(过渡值不是闭集成员,只是两阶段写入的判据);
63
+ // · 动作位置(KIT_PLACES)里的「筛选区」与工具条分开,因为控件区域的按钮恒不取实心(design-rules IA25);
64
+ // · 归属(KIT_OWNERS)是分组与条带的归属:页面框、业务组件、对象(业务功能描述 §3.4);
65
+ // · 页面框区域的种类(KIT_REGION_KINDS)取值与层级角色里的四个页面框角色同词,单列成闭集是因为它是展开写的事实,
66
+ // 层级角色是布局按它推出的结论,两者分属不同事件(同词由生成器核对)。
67
+
68
+ export {
69
+ KIT_ALIGNS,
70
+ KIT_ARRANGES,
71
+ KIT_CLOSED_SETS,
72
+ KIT_COLLAPSES,
73
+ KIT_COMPONENT_PARTS,
74
+ KIT_CONFIRMS,
75
+ KIT_CONTROL_SIZES,
76
+ KIT_DANGERS,
77
+ KIT_DATA_STATES,
78
+ KIT_EDIT_CONTAINERS,
79
+ KIT_ELEMENT_PARTS,
80
+ KIT_EMPHASES,
81
+ KIT_ENVELOPES,
82
+ KIT_EXCLUSIVES,
83
+ KIT_FIELD_ROLES,
84
+ KIT_FIELD_TYPES,
85
+ KIT_FLOWS,
86
+ KIT_FUNCS,
87
+ KIT_HOSTS,
88
+ KIT_IDENTITIES,
89
+ KIT_INTERACT_STATES,
90
+ KIT_KEEPS,
91
+ KIT_LEVELS,
92
+ KIT_OVERFLOWS,
93
+ KIT_OWNERS,
94
+ KIT_PLACES,
95
+ KIT_PRESENT_UNSET,
96
+ KIT_PRESENTS,
97
+ KIT_REGION_KINDS,
98
+ KIT_ROLES,
99
+ KIT_SCOPES,
100
+ KIT_SLOTS,
101
+ KIT_STRIP_KINDS,
102
+ KIT_TONES,
103
+ KIT_TREE_SHAPES,
104
+ KIT_VALUE_FORMS,
105
+ KIT_VARIANTS,
106
+ };
107
+
108
+ export type KitLevel = (typeof KIT_LEVELS)[number];
109
+ export type KitComponentPart = (typeof KIT_COMPONENT_PARTS)[number];
110
+ export type KitElementPart = (typeof KIT_ELEMENT_PARTS)[number];
111
+ export type KitPresent = (typeof KIT_PRESENTS)[number];
112
+ export type KitArrange = (typeof KIT_ARRANGES)[number];
113
+ export type KitExclusive = (typeof KIT_EXCLUSIVES)[number];
114
+ export type KitIdentity = (typeof KIT_IDENTITIES)[number];
115
+ export type KitEditContainer = (typeof KIT_EDIT_CONTAINERS)[number];
116
+ export type KitRole = (typeof KIT_ROLES)[number];
117
+ export type KitSlot = (typeof KIT_SLOTS)[number];
118
+ export type KitEmphasis = (typeof KIT_EMPHASES)[number];
119
+ export type KitEnvelope = (typeof KIT_ENVELOPES)[number];
120
+ export type KitHost = (typeof KIT_HOSTS)[number];
121
+ export type KitFlow = (typeof KIT_FLOWS)[number];
122
+ export type KitAlign = (typeof KIT_ALIGNS)[number];
123
+ export type KitOverflow = (typeof KIT_OVERFLOWS)[number];
124
+ export type KitControlSize = (typeof KIT_CONTROL_SIZES)[number];
125
+ export type KitValueForm = (typeof KIT_VALUE_FORMS)[number];
126
+ export type KitTone = (typeof KIT_TONES)[number];
127
+ export type KitDanger = (typeof KIT_DANGERS)[number];
128
+ export type KitConfirm = (typeof KIT_CONFIRMS)[number];
129
+ export type KitVariant = (typeof KIT_VARIANTS)[number];
130
+ export type KitPlace = (typeof KIT_PLACES)[number];
131
+ export type KitScope = (typeof KIT_SCOPES)[number];
132
+ export type KitDataState = (typeof KIT_DATA_STATES)[number];
133
+ export type KitInteractState = (typeof KIT_INTERACT_STATES)[number];
134
+ export type KitStripKind = (typeof KIT_STRIP_KINDS)[number];
135
+ export type KitOwner = (typeof KIT_OWNERS)[number];
136
+ export type KitRegionKind = (typeof KIT_REGION_KINDS)[number];
137
+ export type KitTreeShape = (typeof KIT_TREE_SHAPES)[number];
138
+ export type KitFieldType = (typeof KIT_FIELD_TYPES)[number];
139
+ export type KitFieldRole = (typeof KIT_FIELD_ROLES)[number];
140
+ export type KitFunc = (typeof KIT_FUNCS)[number];
141
+ export type KitKeep = (typeof KIT_KEEPS)[number];
142
+ export type KitCollapse = (typeof KIT_COLLAPSES)[number];
143
+
144
+ /** 闭集名(与真源 closedSets 的键一一对应);测试与门禁按 KIT_CLOSED_SETS 这一张表对账,不必再逐个常量列名单 */
145
+ export type KitClosedSetName = keyof typeof KIT_CLOSED_SETS;
146
+
147
+ // ── 合法父子层级角色对(业务功能描述 §8.3)──────────────────────────────────────────
148
+
149
+ /** pass = 直接放行;except = 需要邻接例外取值;origin = 子是新的起点(不继承父的取值) */
150
+ export type KitPairVerdict = (typeof KIT_PAIR_VERDICTS)[number];
151
+
152
+ /** 父:层级角色,或「页面框最外层」(真源 legalPairs 的 root 行;生成器保证每个层级角色都有一行) */
153
+ type KitPairParent = keyof typeof KIT_PAGE_LEGAL_PAIRS;
154
+
155
+ /**
156
+ * 生成事件的硬规则与主题求解的邻接取值共用的唯一一张表;父为 root 表示页面框最外层(外壳、顶栏、外壳内容面板与画布在产物里并列于此,见 spatial/expand.ts#frameRegions)。
157
+ * 表外的组合一律非法:真源不写「非法」项,缺席即非法,免得两处判据不一致。
158
+ */
159
+ export const KIT_LEGAL_PAIRS: Readonly<Record<KitPairParent, Readonly<Partial<Record<KitLevel, KitPairVerdict>>>>> = KIT_PAGE_LEGAL_PAIRS;
160
+
161
+ export function kitPairVerdict(parent: KitPairParent, child: KitLevel): KitPairVerdict | 'illegal' {
162
+ return KIT_LEGAL_PAIRS[parent]?.[child] ?? 'illegal';
163
+ }
164
+
165
+ // ── 属性总账(业务功能描述附录)────────────────────────────────────────────────────
166
+
167
+ /** 页面线组件树上的节点种类:页面本身 + 业务功能描述第 3 节的七种组件 */
168
+ export type KitNodeKind = (typeof KIT_LEDGER_NODE_KINDS)[number];
169
+ /** 页面线的六个事件:只有它们能经写入入口改组件树上的属性 */
170
+ export type KitEvent = (typeof KIT_LEDGER_EVENTS)[number];
171
+ /** 到达浏览器的途径:structure = 页面结构上的 data-kit-<键名>;prop = 组件入参;none = 只在编译期 */
172
+ export type KitCarrier = (typeof KIT_LEDGER_CARRIERS)[number];
173
+ /** 途径是否含结构下发(structure 与 structure-prop 都算):按闭集成员的组成词判,闭集增减途径不必改这里 */
174
+ export const kitCarriesStructure = (carrier: string): boolean => carrier.split('-').includes('structure');
175
+ /** 途径闭集里含结构下发的那几种(页面线结构属性 = 总账里途径落在这里的键,属性名 = kitStructureAttr(键名)) */
176
+ export const KIT_STRUCTURE_CARRIERS: readonly KitCarrier[] = Object.freeze(KIT_LEDGER_CARRIERS.filter((c) => kitCarriesStructure(c)));
177
+ /**
178
+ * 总账里读写一栏能出现的角色(与真源 ledgerActors 同词):页面线六个事件 + 主题线四个事件(主题求解、组合核对、换肤、运行期提交)+
179
+ * 组件运行期 + 编译期(业务模板 template、页面编排层 orchestrator)+ 产物之外的读者(浏览器、浏览器缓存、运行时、开发者)。
180
+ * 读者栏要能写「浏览器」,所以不能只用 KitEvent。
181
+ */
182
+ export type KitLedgerActor = (typeof KIT_LEDGER_ACTORS)[number];
183
+
184
+ export interface KitAttrSpec {
185
+ readonly kind: KitNodeKind;
186
+ readonly key: string;
187
+ readonly label: string;
188
+ readonly writers: readonly KitEvent[];
189
+ /** 谁读它:源码门禁按这一栏核对各事件实际读到的键(tests/spatial/pipeline-chain.test.ts) */
190
+ readonly readers: readonly KitLedgerActor[];
191
+ readonly carrier: KitCarrier;
192
+ /**
193
+ * 只对途径含 structure 的布尔属性登记:缺省值为真、为真时不写结构属性,为假时写成这个值(留边:不留边写 data-kit-inset="none")。
194
+ * 不登记即通用的布尔下发:为真写空属性、为假不写(spatial/emit.ts#structureValue)
195
+ */
196
+ readonly structureFalse?: string;
197
+ }
198
+
199
+ /**
200
+ * 页面线之外的两类属性(取值表、运行期自报):写入方不是页面线事件,也不进组件树,
201
+ * 只登记出来供门禁与对账读,写入入口不认它们——这正是「页面线不碰取值表与运行期」的执行点。
202
+ * 写入方取自这两张表实际登记的写入方(主题求解、组合核对、组件运行期)。
203
+ */
204
+ export type KitOffPageWriter = (typeof KIT_PAGE_VALUE_TABLE_ATTRS | typeof KIT_PAGE_RUNTIME_ATTRS)[number]['writers'][number];
205
+ export interface KitOffPageAttrSpec {
206
+ readonly kind: (typeof KIT_LEDGER_OFF_PAGE_KINDS)[number];
207
+ readonly key: string;
208
+ readonly label: string;
209
+ readonly writers: readonly KitOffPageWriter[];
210
+ readonly readers: readonly KitLedgerActor[];
211
+ /** head = 应用文档头(取值表的下发途径) */
212
+ readonly carrier: (typeof KIT_LEDGER_OFF_PAGE_CARRIERS)[number];
213
+ }
214
+
215
+ /**
216
+ * 页面线 8 种节点上的属性(落在节点上的那些);写入入口只认这张表。
217
+ * 几条读代码时要知道的取舍(详见真源与业务功能描述附录):默认选中单列,只对选中互斥有意义;排法为分窗格的业务组件自己就是那张面,
218
+ * 由布局写对象面;页头去重的标题显隐、条带显隐由识别写(不改呈现);动作的位置只有识别读,识别据它写有效位置,之后的事件都读有效位置。
219
+ */
220
+ export const KIT_ATTR_LEDGER: readonly KitAttrSpec[] = KIT_PAGE_ON_NODE_ATTRS;
221
+
222
+ /**
223
+ * 不落节点的页面线属性的写入方:取自这张生成表实际登记的写入方——页面线事件(空间地图由识别返回),
224
+ * 外加页面编排层 orchestrator(页面产物、版本号由页面编译写完产物后算出,主题用到情况由流水线编排入口按报告汇总)。
225
+ * 这几行不经写入入口(kitAttrSpec 查不到),放宽写入方不影响 writeAttr 的写入权核对;生成器只许 onNode 为 false 的行登记编排层
226
+ */
227
+ export type KitOffNodeWriter = (typeof KIT_PAGE_OFF_NODE_ATTRS)[number]['writers'][number];
228
+ /** 不落节点的页面线属性:与 KitAttrSpec 同形,只有写入方另取 KitOffNodeWriter */
229
+ export interface KitOffNodeAttrSpec extends Omit<KitAttrSpec, 'writers'> {
230
+ readonly writers: readonly KitOffNodeWriter[];
231
+ }
232
+
233
+ /**
234
+ * 登记在总账里、但不落在节点上的属性。空间地图是识别事件的返回值,由调用方持有、生成后丢弃:
235
+ * 它是函数集合,写进节点会让报告与产物里混进不可序列化的值,也会让「值在组件上、不在地图里」的分工变模糊。
236
+ * 页面产物、版本号、主题用到情况由页面编排层在交付后产出,同样不进组件树。
237
+ * 不在 KIT_ATTR_LEDGER 里,所以 writeAttr 拒绝写它们。
238
+ */
239
+ export const KIT_OFF_NODE_ATTRS: readonly KitOffNodeAttrSpec[] = KIT_PAGE_OFF_NODE_ATTRS;
240
+
241
+ /** 取值表的属性:由主题线写,页面线不读(业务功能描述 §5) */
242
+ export const KIT_VALUE_TABLE_ATTRS: readonly KitOffPageAttrSpec[] = KIT_PAGE_VALUE_TABLE_ATTRS;
243
+
244
+ /**
245
+ * 运行期由组件代码自报的属性:编译期的组件树上没有这些节点(业务功能描述 §6.2)。
246
+ * 键名避开现有组件已占用的 row / face / action / state / view(data-kit-state 已承载空、错、加载面板状态);
247
+ * 悬停、按下、聚焦、禁用、校验失败优先走原生伪类与无障碍属性,组件只对选中、激活、拖拽中自报。
248
+ */
249
+ export const KIT_RUNTIME_ATTRS: readonly KitOffPageAttrSpec[] = KIT_PAGE_RUNTIME_ATTRS;
250
+
251
+ // 写入入口每次写都要查,建一次索引;键用「种类 + 键名」,同名键在不同种类下是不同的属性(如 level、tone)
252
+ const LEDGER_INDEX: ReadonlyMap<string, KitAttrSpec> = new Map(KIT_ATTR_LEDGER.map((s) => [`${s.kind}\u0000${s.key}`, s]));
253
+
254
+ /** 只查落在节点上的属性:不落节点的(空间地图)查不到,写入入口因此拒绝它 */
255
+ export function kitAttrSpec(kind: KitNodeKind, key: string): KitAttrSpec | undefined {
256
+ return LEDGER_INDEX.get(`${kind}\u0000${key}`);
257
+ }
258
+
259
+ /** 结构途径的属性名:data-kit-<键名>,键名驼峰转短横线 */
260
+ export function kitStructureAttr(key: string): string {
261
+ return `data-kit-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
262
+ }
@@ -0,0 +1,64 @@
1
+ // 主题流水线「新旧模式」的唯一状态处(基础支撑层的叶子:只 import 同为叶子的属性登记处 shared/dom-attrs.ts,任何层都可以依赖它)。
2
+ //
3
+ // 为什么在 shared/:编译期模式原先放在 object-renderer/pipeline-mode.ts,但配方层(recipes/)在 object-renderer 之下,
4
+ // 配方的「单一值输出」分支也要在编译期问「当前是不是新模式」——不能反向 import,所以把设置 / 读取下沉到这里,
5
+ // object-renderer/pipeline-mode.ts 改为原名 re-export(导出名不变,compile-page、biz、emit-object 照旧引它)。
6
+ //
7
+ // 编译期的模式来源是应用上下文(KitAppContext.pipeline,kit.app.yaml 的 layout.pipeline):compile-page 在同步编译段开始时设置、
8
+ // 结束与异常清理时复位;环境对象上显式给的 pipeline 以显式为准(单测、直接调用 renderObject / emitObject 时用)。
9
+ // 浏览器里的模式由运行期启动处(app/theme-runtime.ts)写在文档根上(KIT_PIPELINE_ROOT_ATTR="next"),读法在 recipes/pipeline-runtime.ts;
10
+ // 属性名与取值只在这里定义,写的一侧(app/)与读的一侧(recipes/)都从这里取。
11
+
12
+ // dom-attrs.ts 没有任何 import(不反向依赖本文件),这里引它不成环
13
+ import { KIT_ATTR_PIPELINE } from './dom-attrs';
14
+
15
+ /** 与 compile/page-pipeline 的 KitPipelineMode 同值;这里不反向依赖 compile 层 */
16
+ export type KitRenderPipeline = 'legacy' | 'next';
17
+
18
+ /** 文档根上的新模式专用标记:运行期启动处只在新模式下写,取值恒为 KIT_PIPELINE_ROOT_NEXT(属性名取登记处 shared/dom-attrs.ts#KIT_ATTR_PIPELINE) */
19
+ export const KIT_PIPELINE_ROOT_ATTR: typeof KIT_ATTR_PIPELINE = KIT_ATTR_PIPELINE;
20
+ export const KIT_PIPELINE_ROOT_NEXT: KitRenderPipeline = 'next';
21
+
22
+ let compilePipeline: KitRenderPipeline = 'legacy';
23
+ /** 是否处在编译段内(compile-page 设置了模式、尚未复位):编译段内只认编译模式,不读文档根(recipes/pipeline-runtime.ts#kitIsNextRuntime) */
24
+ let compileActive = false;
25
+
26
+ /** 页面编译期间的流水线模式(compile-page 设置;传 undefined 复位为 legacy 并结束编译段) */
27
+ export function setKitCompilePipeline(mode: KitRenderPipeline | undefined): void {
28
+ compilePipeline = mode ?? 'legacy';
29
+ compileActive = mode !== undefined;
30
+ }
31
+
32
+ /** 当前是否在编译段内(设置过编译模式、尚未复位);运行期恒为 false */
33
+ export function kitCompileActive(): boolean {
34
+ return compileActive;
35
+ }
36
+
37
+ /**
38
+ * 在给定模式的编译段里执行 run(对象渲染的显式 pipeline 入口用:renderObject / emitObject / emitStatic)。
39
+ * 为什么:这些入口按显式模式输出属性,同一份输出里的配方与帮手(如 base/hint-tips#kitHelpButtonHtml、动作配方)按 kitIsNextRuntime 判断;
40
+ * 在编译段外直接调用并显式给模式时,两种判断会分叉。进入编译段后两者一致。
41
+ * mode 为 undefined:不动现状,直接执行。已处在同模式的编译段内:不重复设置、也不在结束时复位(外层编译段照常由设置方复位)。
42
+ * 其余情况:设置后执行,结束(含异常)时还原为进入前的状态——进入前不在编译段内则复位结束编译段,在另一模式的编译段内则还原那个模式(嵌套安全)。
43
+ */
44
+ export function kitWithCompilePipeline<T>(mode: KitRenderPipeline | undefined, run: () => T): T {
45
+ if (mode === undefined || (compileActive && compilePipeline === mode)) return run();
46
+ const prevActive = compileActive;
47
+ const prevMode = compilePipeline;
48
+ setKitCompilePipeline(mode);
49
+ try {
50
+ return run();
51
+ } finally {
52
+ setKitCompilePipeline(prevActive ? prevMode : undefined);
53
+ }
54
+ }
55
+
56
+ /** 当前模式:显式给的优先,其次是编译期设置的,缺省 legacy */
57
+ export function kitRenderPipeline(explicit?: KitRenderPipeline): KitRenderPipeline {
58
+ return explicit ?? compilePipeline;
59
+ }
60
+
61
+ /** 是否新流水线:编译期输出新增属性前统一问这一处 */
62
+ export function kitIsNextPipeline(explicit?: KitRenderPipeline): boolean {
63
+ return kitRenderPipeline(explicit) === 'next';
64
+ }