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
package/src/data/tree.ts CHANGED
@@ -13,11 +13,18 @@
13
13
  // 页面重取数据把 children 补进该节点后自动结束加载态;已有的勾选会顺着级联落到新子项上。
14
14
  // - `filter`:关键字(页面绑一个输入框的值),只留命中项 + 祖先 + 命中项的后代,祖先自动展开,命中文字高亮;无命中显示 filter_empty_text。
15
15
 
16
+ import { kitApplyLevelClass } from './level-class';
17
+ import { kitLevelClassFor } from '../recipes/pipeline-runtime';
16
18
  import type { SomaComponentDefinition } from 'soma-core';
19
+ import { KIT_FOCUS_RING, kitSelectedRecipe } from '../recipes/state';
20
+ import { mergeClass } from '../shared/merge-class';
21
+ import {
22
+ KIT_ATTR_CHECK, KIT_ATTR_ICON_CACHE, KIT_ATTR_KEY, KIT_ATTR_LSIG, KIT_ATTR_NODE_ICON, KIT_ATTR_TOGGLE, KIT_ATTR_TREE_LABEL, KIT_ATTR_TREE_ROW, kitAttrSel,
23
+ } from '../shared/dom-attrs';
17
24
  import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
18
25
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
19
- import { bool, createKitController, joinClass, str } from '../base/shared';
20
- import { kitIcon } from '../shared/icons';
26
+ import { bool, createKitController, joinClass, reconcileKeyedElements, str } from '../base/shared';
27
+ import { KIT_ICON_NAMES, kitIcon, setKitIconCached, type KitIconName } from '../shared/icons';
21
28
  import { markCheckBox } from '../base/check-core';
22
29
  import { kitText } from '../i18n/kit-text';
23
30
  import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES, kitEmptyPanel } from '../base/state-panel';
@@ -28,6 +35,7 @@ import {
28
35
  import { classTokens } from './shape-util';
29
36
  import { provideCtxRows } from './context-menu';
30
37
  import { aggregateCheck, nextCheckTarget } from './tree-check';
38
+ import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
31
39
  import { kitControlEdgeRecipe } from '../recipes/control';
32
40
 
33
41
  export interface KitTreeMap {
@@ -44,23 +52,29 @@ export const KIT_TREE_DEFAULT_MAP: Readonly<KitTreeMap> = Object.freeze({
44
52
  });
45
53
 
46
54
  const ROOT_CLASS = 'flex flex-col gap-0.5 text-sm text-fg';
47
- const GROUP_CLASS = 'ms-4 flex flex-col gap-0.5';
48
- const ITEM_CLASS = 'flex flex-col gap-0.5 rounded-md focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
49
- const ROW_CLASS = 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
50
- const ROW_SELECTED_CLASS = 'flex cursor-pointer items-center gap-2 rounded-md bg-primary-soft px-2 py-1.5 text-primary-on-soft';
51
- const ROW_DISABLED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-md px-2 py-1.5 text-fg-subtle opacity-60';
55
+ // 每级缩进 24(6 个间距单位;Ant indentSize 24 / TDesign 24 / Arco 约 22,取 24,2026-11-26 裁决)
56
+ const GROUP_CLASS = 'ms-6 flex flex-col gap-0.5';
57
+ const ITEM_CLASS = 'flex flex-col gap-0.5 rounded-item ' + KIT_FOCUS_RING.item;
58
+ const ROW_CLASS = 'flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5 text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
59
+ // 选中只走 kitSelectedRecipe(KT-HB-F);选中项也有悬停 / 按下:叠第三级 tonal 状态层(卡 Tree:选中 + 悬停走 tonal,不被一级悬停层盖住)
60
+ // 选中不改字重(VA3-R1:避免选中时字宽跳动):选中配方自带 font-medium,这里同族覆写回常态字重
61
+ const ROW_SELECTED_CLASS = mergeClass(mergeClass(mergeClass('flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5', kitSelectedRecipe()), 'transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press'), 'font-normal');
62
+ // 节点图标位(node.icon 写 kit 图标名)与标题:标题单行省略(flex-1 min-w-0 truncate),图标不收缩
63
+ const NODE_ICON_CLASS = 'inline-flex shrink-0 text-fg-muted';
64
+ const NODE_TEXT_CLASS = 'min-w-0 flex-1 truncate';
65
+ const ROW_DISABLED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-item px-2 py-1.5 text-fg-disabled **:text-fg-disabled'; // KT-K0-4
52
66
  const TOGGLE_CLASS = 'w-4 shrink-0 text-fg-subtle';
53
- // 勾选框外圈 = 控件轮廓出口(KT-B1)
67
+ // 勾选框外圈 = 控件轮廓出口(KT-B1);尺寸走 KT-D5 固定几何(不随密度漂移)
54
68
  const CHECK_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
55
- const CHECK_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-sm ${CHECK_EDGE} bg-surface`;
56
- const CHECK_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-sm border border-primary bg-primary text-primary-fg';
57
- const HIT_CLASS = 'rounded-sm bg-warning-soft px-0.5 text-warning-on-soft';
69
+ const CHECK_CLASS = `inline-flex h-check-md w-check-md shrink-0 items-center justify-center rounded-item ${CHECK_EDGE} bg-surface`;
70
+ const CHECK_ON_CLASS = 'inline-flex h-check-md w-check-md shrink-0 items-center justify-center rounded-item border border-primary bg-primary text-primary-fg';
71
+ const HIT_CLASS = 'rounded-item bg-warning-soft px-0.5 text-warning-on-soft';
58
72
  const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
59
73
 
60
74
  /** 本组件自带的全部类(供编译器并入候选类) */
61
- /** virtual 下的扁平缩进(每层 4 个间距单位,最多 11 层,更深的层保持同一缩进):整串字面量,不拼接 */
75
+ /** virtual 下的扁平缩进(每层 6 个间距单位 = 24,最多 11 层,更深的层保持同一缩进):整串字面量,不拼接 */
62
76
  const FLAT_INDENT: readonly string[] = [
63
- 'ms-0', 'ms-4', 'ms-8', 'ms-12', 'ms-16', 'ms-20', 'ms-24', 'ms-28', 'ms-32', 'ms-36', 'ms-40', 'ms-44',
77
+ 'ms-0', 'ms-6', 'ms-12', 'ms-18', 'ms-24', 'ms-30', 'ms-36', 'ms-42', 'ms-48', 'ms-54', 'ms-60', 'ms-66',
64
78
  ];
65
79
  const FLAT_ROW_FILL = 'h-full';
66
80
  /** virtual 的根:列与列之间不留 gap(行距算进固定行高,估算才准) */
@@ -68,7 +82,7 @@ const VIRTUAL_ROOT_CLASS = 'flex flex-col text-sm text-fg';
68
82
 
69
83
  export const KIT_TREE_CLASS_CANDIDATES: readonly string[] = classTokens(
70
84
  ...FLAT_INDENT, FLAT_ROW_FILL, VIRTUAL_ROOT_CLASS, KIT_VIRTUAL_VIEWPORT_BASE, ...Object.values(KIT_VIRTUAL_VIEWPORT_CLASS), ...KIT_VIRTUAL_CLASS_CANDIDATES,
71
- ROOT_CLASS, GROUP_CLASS, ITEM_CLASS, ROW_CLASS, ROW_SELECTED_CLASS, ROW_DISABLED_CLASS, TOGGLE_CLASS, CHECK_CLASS, CHECK_ON_CLASS, HIT_CLASS, EMPTY_CLASS,
85
+ ROOT_CLASS, GROUP_CLASS, ITEM_CLASS, ROW_CLASS, ROW_SELECTED_CLASS, ROW_DISABLED_CLASS, NODE_ICON_CLASS, NODE_TEXT_CLASS, TOGGLE_CLASS, CHECK_CLASS, CHECK_ON_CLASS, HIT_CLASS, EMPTY_CLASS,
72
86
  'py-1', KIT_STATE_PANEL_CLASS_CANDIDATES,
73
87
  );
74
88
 
@@ -95,6 +109,8 @@ interface FlatNode {
95
109
  /** 待加载(lazy 下才有意义):标了 has_children 而没有子项 */
96
110
  pending: boolean;
97
111
  disabled: boolean;
112
+ /** 节点图标(kit 图标名,数据里的 icon 键;不是图标名则不画) */
113
+ icon: string;
98
114
  /** 先序下标(勾选状态数组的下标) */
99
115
  index: number;
100
116
  }
@@ -139,6 +155,7 @@ export function buildTreeNodes(data: unknown, mapIn: Pick<KitTreeMap, 'id' | 'la
139
155
  children: [],
140
156
  pending: false,
141
157
  disabled: rec[map.disabled] === true || rec[map.disabled] === 'true',
158
+ icon: typeof rec.icon === 'string' && (KIT_ICON_NAMES as readonly string[]).includes(rec.icon) ? rec.icon : '',
142
159
  index: counter,
143
160
  };
144
161
  counter += 1;
@@ -202,7 +219,7 @@ export function createTree(): SomaComponentDefinition {
202
219
  name: 'Tree',
203
220
  layer: 'data',
204
221
  props: {
205
- data: { type: 'array', default: [], desc: '树数据 [{ id, label, children?, has_children?, disabled? }]' },
222
+ data: { type: 'array', default: [], desc: '树数据 [{ id, label, icon?, children?, has_children?, disabled? }];icon 写 kit 图标名,画在标题前;标题单行省略' },
206
223
  map: { type: 'object', default: {}, desc: '键名对照 { id, label, children, has_children, disabled }:组件期望的键 -> 数据里的键' },
207
224
  selected: { type: 'string', default: '', desc: '当前选中项的 id' },
208
225
  expand_all: { type: 'boolean', default: false, desc: '初始全部展开' },
@@ -298,7 +315,7 @@ export function createTree(): SomaComponentDefinition {
298
315
 
299
316
  const focusCursor = (): void => {
300
317
  if (!root || cursor === null) return;
301
- const el = root.querySelector<HTMLElement>(`[data-kit-key="${cssEscape(cursor)}"]`);
318
+ const el = root.querySelector<HTMLElement>(`[${KIT_ATTR_KEY}="${cssEscape(cursor)}"]`);
302
319
  el?.focus();
303
320
  };
304
321
 
@@ -437,24 +454,35 @@ export function createTree(): SomaComponentDefinition {
437
454
  };
438
455
 
439
456
  const labelNodes = (text: string, hit: boolean, keyword: string): Array<Node> => {
440
- if (!hit) return [document.createTextNode(text)];
441
- const at = text.toLowerCase().indexOf(keyword);
442
- if (at < 0) return [document.createTextNode(text)];
443
- const mark = document.createElement('span');
444
- mark.className = HIT_CLASS;
445
- mark.textContent = text.slice(at, at + keyword.length);
446
- return [document.createTextNode(text.slice(0, at)), mark, document.createTextNode(text.slice(at + keyword.length))];
457
+ if (!hit || keyword === '') return [document.createTextNode(text)];
458
+ const lower = text.toLowerCase();
459
+ const out: Node[] = [];
460
+ let pos = 0;
461
+ for (;;) {
462
+ const at = lower.indexOf(keyword, pos);
463
+ if (at < 0) break;
464
+ if (at > pos) out.push(document.createTextNode(text.slice(pos, at)));
465
+ const mark = document.createElement('span');
466
+ mark.className = HIT_CLASS;
467
+ mark.textContent = text.slice(at, at + keyword.length);
468
+ out.push(mark);
469
+ pos = at + keyword.length;
470
+ }
471
+ if (out.length === 0) return [document.createTextNode(text)];
472
+ if (pos < text.length) out.push(document.createTextNode(text.slice(pos)));
473
+ return out;
447
474
  };
448
475
 
449
- const buildNode = (
476
+ const updateNodeDom = (
477
+ li: HTMLElement,
450
478
  n: FlatNode,
451
479
  tabbable: string | null,
452
480
  flt: ReturnType<typeof filterTreeNodes>,
453
481
  keyword: string,
454
482
  box: boolean,
483
+ showToggleSlot: boolean,
455
484
  flat?: { indent: string; liClass: string; total: number; pos: number },
456
- ): HTMLElement => {
457
- const li = document.createElement('li');
485
+ ): void => {
458
486
  const branch = n.children.length > 0;
459
487
  const lazyNode = bool(P().lazy) && n.pending;
460
488
  const isOpen = (branch || lazyNode) && (open.has(n.key) || (branch && flt?.forced.has(n.key) === true));
@@ -462,64 +490,142 @@ export function createTree(): SomaComponentDefinition {
462
490
  li.setAttribute('aria-level', String(n.level));
463
491
  li.setAttribute('aria-selected', n.key === selected ? 'true' : 'false');
464
492
  if (branch || lazyNode) li.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
493
+ else li.removeAttribute('aria-expanded');
465
494
  if (loading.has(n.key)) li.setAttribute('aria-busy', 'true');
495
+ else li.removeAttribute('aria-busy');
466
496
  if (n.disabled) li.setAttribute('aria-disabled', 'true');
497
+ else li.removeAttribute('aria-disabled');
467
498
  if (box) {
468
499
  const s = st[n.index] ?? 0;
469
500
  li.setAttribute('aria-checked', s === 1 ? 'true' : s === 2 ? 'mixed' : 'false');
501
+ } else {
502
+ li.removeAttribute('aria-checked');
470
503
  }
471
- li.setAttribute('data-kit-key', n.key);
504
+ li.setAttribute(KIT_ATTR_KEY, n.key);
505
+ // 树节点 = 集合的条目;选中节点自报交互状态(aria-selected 上面已按 treeitem 写好,这里不重复)
506
+ kitMarkLevel(li, 'item');
507
+ kitMarkPicked(li, 'selected', n.key === selected, null);
472
508
  li.tabIndex = n.key === tabbable ? 0 : -1;
473
509
  const rowCls = n.disabled ? ROW_DISABLED_CLASS : n.key === selected ? ROW_SELECTED_CLASS : ROW_CLASS;
474
- const row = document.createElement('div');
510
+ let row = li.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TREE_ROW)}`);
511
+ if (!row) {
512
+ row = document.createElement('div');
513
+ row.setAttribute(KIT_ATTR_TREE_ROW, '');
514
+ // 节点的可见行:元素部件「行」
515
+ kitMarkPart(row, 'line');
516
+ li.prepend(row);
517
+ }
475
518
  if (flat) {
476
- // 虚拟滚动:节点拍平成一列,固定行高由 li 定,行铺满并按层级缩进(aria-level / setsize / posinset 补全层级与位置)
477
- li.className = `${ITEM_CLASS} ${flat.liClass}`;
519
+ li.className = kitLevelClassFor(li, `${ITEM_CLASS} ${flat.liClass}`);
478
520
  li.setAttribute('aria-setsize', String(flat.total));
479
521
  li.setAttribute('aria-posinset', String(flat.pos));
480
522
  row.className = `${withoutPy(rowCls)} ${FLAT_ROW_FILL} ${flat.indent}`;
481
523
  } else {
482
- li.className = ITEM_CLASS;
524
+ li.className = kitLevelClassFor(li, ITEM_CLASS);
525
+ li.removeAttribute('aria-setsize');
526
+ li.removeAttribute('aria-posinset');
483
527
  row.className = rowCls;
484
528
  }
485
- const toggle = document.createElement('span');
486
- toggle.className = TOGGLE_CLASS;
487
- toggle.setAttribute('aria-hidden', 'true');
488
- toggle.setAttribute('data-kit-toggle', '');
489
- if (loading.has(n.key)) toggle.appendChild(kitIcon('loading', 'sm'));
490
- else if (branch || lazyNode) toggle.appendChild(kitIcon(isOpen ? 'chevron-down' : 'chevron-right', 'sm', 'rtl:-scale-x-100'));
491
- row.appendChild(toggle);
529
+ let toggle = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TOGGLE)}`);
530
+ if (showToggleSlot) {
531
+ if (!toggle) {
532
+ toggle = document.createElement('span');
533
+ toggle.className = TOGGLE_CLASS;
534
+ toggle.setAttribute('aria-hidden', 'true');
535
+ toggle.setAttribute(KIT_ATTR_TOGGLE, '');
536
+ row.prepend(toggle);
537
+ }
538
+ if (loading.has(n.key)) setKitIconCached(toggle, 'loading', 'sm');
539
+ else if (branch || lazyNode) setKitIconCached(toggle, isOpen ? 'chevron-down' : 'chevron-right', 'sm', 'rtl:-scale-x-100');
540
+ else { toggle.removeAttribute(KIT_ATTR_ICON_CACHE); toggle.textContent = ''; }
541
+ } else if (toggle) {
542
+ toggle.remove();
543
+ }
544
+ let cb = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_CHECK)}`);
492
545
  if (box) {
493
546
  const s = st[n.index] ?? 0;
494
- const cb = document.createElement('span');
547
+ if (!cb) {
548
+ cb = document.createElement('span');
549
+ cb.setAttribute('aria-hidden', 'true');
550
+ markCheckBox(cb);
551
+ cb.setAttribute(KIT_ATTR_CHECK, '');
552
+ const afterToggle = row.querySelector(`:scope > ${kitAttrSel(KIT_ATTR_TOGGLE)}`);
553
+ if (afterToggle) afterToggle.after(cb);
554
+ else row.prepend(cb);
555
+ }
495
556
  cb.className = s === 0 ? CHECK_CLASS : CHECK_ON_CLASS;
496
- cb.setAttribute('aria-hidden', 'true');
497
- markCheckBox(cb);
498
- cb.setAttribute('data-kit-check', '');
499
- if (s !== 0) cb.appendChild(kitIcon(s === 1 ? 'check' : 'minus', 'xs'));
500
- row.appendChild(cb);
557
+ if (s !== 0) setKitIconCached(cb, s === 1 ? 'check' : 'minus', 'xs');
558
+ else { cb.removeAttribute(KIT_ATTR_ICON_CACHE); cb.textContent = ''; }
559
+ } else if (cb) {
560
+ cb.remove();
561
+ }
562
+ let ico = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_NODE_ICON)}`);
563
+ if (n.icon !== '') {
564
+ if (!ico) {
565
+ ico = document.createElement('span');
566
+ ico.className = NODE_ICON_CLASS;
567
+ ico.setAttribute('aria-hidden', 'true');
568
+ ico.setAttribute(KIT_ATTR_NODE_ICON, '');
569
+ const labelRef = row.querySelector(`:scope > ${kitAttrSel(KIT_ATTR_TREE_LABEL)}`);
570
+ if (labelRef) row.insertBefore(ico, labelRef);
571
+ else row.appendChild(ico);
572
+ }
573
+ setKitIconCached(ico, n.icon as KitIconName, 'md');
574
+ } else if (ico) {
575
+ ico.remove();
576
+ }
577
+ let label = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TREE_LABEL)}`);
578
+ if (!label) {
579
+ label = document.createElement('span');
580
+ label.className = NODE_TEXT_CLASS;
581
+ label.setAttribute(KIT_ATTR_TREE_LABEL, '');
582
+ row.appendChild(label);
501
583
  }
502
- const label = document.createElement('span');
503
- for (const part of labelNodes(n.label, flt?.hits.has(n.key) === true, keyword)) label.appendChild(part);
504
- row.appendChild(label);
505
- li.appendChild(row);
584
+ const hit = flt?.hits.has(n.key) === true;
585
+ const labelSig = `${n.label}\0${hit ? keyword : ''}`;
586
+ if (label.getAttribute(KIT_ATTR_LSIG) !== labelSig) {
587
+ label.setAttribute(KIT_ATTR_LSIG, labelSig);
588
+ label.replaceChildren(...labelNodes(n.label, hit, keyword));
589
+ }
590
+ let group = li.querySelector<HTMLElement>(':scope > ul[role="group"]');
506
591
  if (isOpen && branch && !flat) {
507
- const group = document.createElement('ul');
508
- group.setAttribute('role', 'group');
509
- group.className = GROUP_CLASS;
510
- for (const child of n.children) {
511
- if (flt !== null && !flt.visible.has(child.key)) continue;
512
- group.appendChild(buildNode(child, tabbable, flt, keyword, box));
592
+ if (!group) {
593
+ group = document.createElement('ul');
594
+ group.setAttribute('role', 'group');
595
+ group.className = GROUP_CLASS;
596
+ li.appendChild(group);
513
597
  }
514
- li.appendChild(group);
598
+ const visibleChildren = flt === null ? n.children : n.children.filter((c) => flt.visible.has(c.key));
599
+ reconcileKeyedElements(
600
+ group,
601
+ visibleChildren,
602
+ (c) => c.key,
603
+ () => document.createElement('li'),
604
+ (childLi, c) => updateNodeDom(childLi, c, tabbable, flt, keyword, box, showToggleSlot),
605
+ );
606
+ } else if (group) {
607
+ group.remove();
515
608
  }
609
+ };
610
+
611
+ const buildNode = (
612
+ n: FlatNode,
613
+ tabbable: string | null,
614
+ flt: ReturnType<typeof filterTreeNodes>,
615
+ keyword: string,
616
+ box: boolean,
617
+ showToggleSlot: boolean,
618
+ flat?: { indent: string; liClass: string; total: number; pos: number },
619
+ ): HTMLElement => {
620
+ const li = document.createElement('li');
621
+ updateNodeDom(li, n, tabbable, flt, keyword, box, showToggleSlot, flat);
516
622
  return li;
517
623
  };
518
624
 
519
625
  /** 虚拟滚动画法:可见节点拍平成一列,只画窗口内的行;游标变了才滚到游标行,游标行不在窗口时焦点退到根 */
520
626
  const paintVirtual = (
521
627
  p: Record<string, unknown>, flt: ReturnType<typeof filterTreeNodes>, keyword: string, visible: readonly FlatNode[],
522
- tabbable: string | null, box: boolean, hadFocus: boolean,
628
+ tabbable: string | null, box: boolean, showToggleSlot: boolean, hadFocus: boolean,
523
629
  ): void => {
524
630
  const r = root;
525
631
  if (!r) return;
@@ -546,13 +652,13 @@ export function createTree(): SomaComponentDefinition {
546
652
  const liClass = KIT_VIRTUAL_OPTION_ROW_CLASS[tier];
547
653
  const painted = paintVirtualRows(r, virt, visible.length, (i) => {
548
654
  const n = visible[i]!;
549
- return buildNode(n, tabbable, flt, keyword, box, {
655
+ return buildNode(n, tabbable, flt, keyword, box, showToggleSlot, {
550
656
  indent: FLAT_INDENT[Math.min(n.level - 1, FLAT_INDENT.length - 1)]!, liClass, total: visible.length, pos: i + 1,
551
657
  });
552
658
  }, 'li');
553
659
  const keyEl = (key: string | null): HTMLElement | null => {
554
660
  if (key === null) return null;
555
- for (const el of painted.rows.values()) if (el.getAttribute('data-kit-key') === key) return el;
661
+ for (const el of painted.rows.values()) if (el.getAttribute(KIT_ATTR_KEY) === key) return el;
556
662
  return null;
557
663
  };
558
664
  r.tabIndex = keyEl(tabbable) === null ? 0 : -1;
@@ -569,6 +675,12 @@ export function createTree(): SomaComponentDefinition {
569
675
  function paint(): void {
570
676
  if (!root) return;
571
677
  const p = P();
678
+ // 数据状态自报:与 applyKitReadState 读同两个入参(loading / error_text),外加有没有节点;每次重画都写,回常态即移除
679
+ kitMarkDataFacts(root, {
680
+ loading: p.loading === true || p.loading === 'true',
681
+ error: str(p.error_text) !== '',
682
+ empty: nodes.length === 0,
683
+ });
572
684
  // 没有节点:读取中 / 读取失败 + 重试 / 空态,与集合三态同一画法(base/state-panel.ts;有读接口时编译器自动绑 loading / error_text)
573
685
  if (nodes.length === 0) {
574
686
  if (virt !== null) root.tabIndex = -1;
@@ -577,38 +689,47 @@ export function createTree(): SomaComponentDefinition {
577
689
  root.removeAttribute('aria-multiselectable');
578
690
  root.className = joinClass(ROOT_CLASS, p.class);
579
691
  if (!applyKitReadState(root, p, { hasContent: false, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) {
580
- root.appendChild(kitEmptyPanel(document, str(p.empty_text, kitText('soma.kit.empty', undefined, api.host))));
692
+ const emptyPanel = kitEmptyPanel(document, str(p.empty_text, kitText('soma.kit.empty', undefined, api.host)));
693
+ // 空状态块 = 子块(不经 shape-util.emptyNode,在此单独自报)
694
+ kitMarkLevel(emptyPanel, 'sub'); kitApplyLevelClass(emptyPanel);
695
+ root.appendChild(emptyPanel);
581
696
  }
582
697
  return;
583
698
  }
584
699
  const flt = filterOf();
585
700
  const keyword = str(p.filter).trim().toLowerCase();
586
701
  const visible = visibleOf(nodes, open, flt);
702
+ // 纯平级无任何带子节点(或待懒加载)的叶子列表,省去左侧 24px 空白展开槽
703
+ const showToggleSlot = order.some((n) => expandable(n));
587
704
  // 漫游 tabindex:游标项,没有游标时落首个可见项
588
705
  const tabbable = cursor !== null && visible.some((n) => n.key === cursor) ? cursor : (visible[0]?.key ?? null);
589
706
  const hadFocus = root.contains(document.activeElement);
590
707
  const box = checkable();
591
708
  if (bool(p.virtual) && !(flt !== null && visible.length === 0)) {
592
- paintVirtual(p, flt, keyword, visible, tabbable, box, hadFocus);
709
+ paintVirtual(p, flt, keyword, visible, tabbable, box, showToggleSlot, hadFocus);
593
710
  return;
594
711
  }
595
712
  if (virt !== null) root.tabIndex = -1;
596
713
  disposeVirt();
597
- root.textContent = '';
598
714
  if (box) root.setAttribute('aria-multiselectable', 'true'); else root.removeAttribute('aria-multiselectable');
599
715
  // 已有内容时的读状态:重取中根 aria-busy(内容保留);读取失败不往 role=tree 里塞面板(树结构不被破坏)
600
716
  if (p.loading === true || p.loading === 'true') root.setAttribute('aria-busy', 'true'); else root.removeAttribute('aria-busy');
601
717
  if (flt !== null && visible.length === 0) {
718
+ root.textContent = '';
602
719
  const empty = document.createElement('li');
603
720
  empty.setAttribute('role', 'none');
604
721
  empty.className = EMPTY_CLASS;
605
722
  empty.textContent = str(p.filter_empty_text, kitText('soma.kit.empty_node', undefined, api.host));
606
723
  root.appendChild(empty);
607
724
  } else {
608
- for (const n of nodes) {
609
- if (flt !== null && !flt.visible.has(n.key)) continue;
610
- root.appendChild(buildNode(n, tabbable, flt, keyword, box));
611
- }
725
+ const topVisible = flt === null ? nodes : nodes.filter((n) => flt.visible.has(n.key));
726
+ reconcileKeyedElements(
727
+ root,
728
+ topVisible,
729
+ (n) => n.key,
730
+ () => document.createElement('li'),
731
+ (li, n) => updateNodeDom(li, n, tabbable, flt, keyword, box, showToggleSlot),
732
+ );
612
733
  }
613
734
  root.className = joinClass(ROOT_CLASS, p.class);
614
735
  if (hadFocus) focusCursor();
@@ -619,14 +740,14 @@ export function createTree(): SomaComponentDefinition {
619
740
  root = rootEl;
620
741
  const onClick = (event: Event): void => {
621
742
  const target = event.target as HTMLElement | null;
622
- const li = target?.closest<HTMLElement>('[data-kit-key]');
623
- const key = li?.getAttribute('data-kit-key');
743
+ const li = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
744
+ const key = li?.getAttribute(KIT_ATTR_KEY);
624
745
  if (!li || !key) return;
625
- if (target?.closest('[data-kit-toggle]')) {
746
+ if (target?.closest(kitAttrSel(KIT_ATTR_TOGGLE))) {
626
747
  setOpen(key, !open.has(key));
627
748
  return;
628
749
  }
629
- if (target?.closest('[data-kit-check]')) {
750
+ if (target?.closest(kitAttrSel(KIT_ATTR_CHECK))) {
630
751
  cursor = key;
631
752
  toggleCheck(key);
632
753
  return;
@@ -637,7 +758,7 @@ export function createTree(): SomaComponentDefinition {
637
758
  };
638
759
  const onKeydown = (event: KeyboardEvent): void => {
639
760
  if (cursor === null) {
640
- const first = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-key]')?.getAttribute('data-kit-key');
761
+ const first = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
641
762
  if (first) cursor = first;
642
763
  }
643
764
  if (wiring.onKeydown(event)) event.preventDefault();
@@ -7,25 +7,40 @@
7
7
  // 同一份折线也被 StatGroup 的 `spark` 项复用(`sparklineSvg`)。
8
8
 
9
9
  import type { SomaComponentDefinition } from 'soma-core';
10
- import { bool, createKitController, joinClass, type KitProps, num, str } from '../base/shared';
10
+ import { kitMarkDataFacts } from './kit-contract';
11
+ import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
12
+ import { bool, createKitController, formatValue, joinClass, type KitProps, nextUid, num, str } from '../base/shared';
13
+ import { KIT_TIP_ATTR } from '../base/hint-tips';
14
+ import { releaseReasonTipsIn } from '../base/reason-tip';
15
+ import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
16
+ import { kitWellRecipe } from '../recipes/surface';
17
+ import { mergeClass } from '../shared/merge-class';
18
+ import { KIT_ATTR_SKELETON } from '../shared/dom-attrs';
11
19
  import { classTokens, mk, rowsOf, textOf } from './shape-util';
12
20
  import { SPARKLINE_MAX_POINTS } from './d9-limits';
21
+ import { plainNumber } from './summary-util';
13
22
 
14
23
  const SVG_NS = 'http://www.w3.org/2000/svg';
15
24
  const ROOT_CLASS = 'block h-8 w-full';
16
25
  const EMPTY_CLASS = 'text-xs text-fg-subtle';
26
+ const SKELETON_CLASS = mergeClass(mergeClass('block h-full w-full rounded-item', kitWellRecipe()), 'motion-safe:animate-kit-pulse');
27
+ const AREA_TOP_OPACITY = KIT_DATA_LIMITS.chart.style.areaTopOpacity;
28
+ const AREA_BOTTOM_OPACITY = KIT_DATA_LIMITS.chart.style.areaBottomOpacity;
17
29
 
18
30
  export type KitTrendTone = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
19
31
  const STROKE: Readonly<Record<KitTrendTone, string>> = Object.freeze({
20
32
  primary: 'stroke-primary', success: 'stroke-success', warning: 'stroke-warning', danger: 'stroke-danger', info: 'stroke-info', neutral: 'stroke-fg-muted',
21
33
  });
22
34
  const FILL: Readonly<Record<KitTrendTone, string>> = Object.freeze({
23
- primary: 'fill-primary-soft', success: 'fill-success-soft', warning: 'fill-warning-soft', danger: 'fill-danger-soft', info: 'fill-info-soft', neutral: 'fill-surface-sunken',
35
+ primary: 'fill-primary-soft', success: 'fill-success-soft', warning: 'fill-warning-soft', danger: 'fill-danger-soft', info: 'fill-info-soft', neutral: kitWellRecipe({ paint: 'fill' }),
36
+ });
37
+ const TEXT_TONE: Readonly<Record<KitTrendTone, string>> = Object.freeze({
38
+ primary: 'text-primary', success: 'text-success', warning: 'text-warning', danger: 'text-danger', info: 'text-info', neutral: 'text-fg-muted',
24
39
  });
25
40
  const LINE_CLASS = 'fill-none stroke-2';
26
41
 
27
42
  export const KIT_TREND_LINE_CLASS_CANDIDATES: readonly string[] = classTokens(
28
- ROOT_CLASS, EMPTY_CLASS, Object.values(STROKE), Object.values(FILL), LINE_CLASS, 'size-full',
43
+ ROOT_CLASS, EMPTY_CLASS, SKELETON_CLASS, Object.values(STROKE), Object.values(FILL), Object.values(TEXT_TONE), LINE_CLASS, 'size-full',
29
44
  );
30
45
 
31
46
  const TONES = Object.keys(STROKE) as KitTrendTone[];
@@ -64,7 +79,10 @@ export function trendPoints(values: readonly number[]): Array<[number, number]>
64
79
  }
65
80
 
66
81
  /** 画一条迷你折线的 SVG 节点(TrendLine 与 StatGroup 共用);点数不足 2 返回 null */
67
- export function sparklineSvg(values: readonly number[], opts: { tone?: KitTrendTone; area?: boolean; label?: string; className?: string } = {}): SVGSVGElement | null {
82
+ export function sparklineSvg(
83
+ values: readonly number[],
84
+ opts: { tone?: KitTrendTone; area?: boolean; label?: string; className?: string; format?: string; locale?: string } = {},
85
+ ): SVGSVGElement | null {
68
86
  if (values.length < 2) return null;
69
87
  const tone = opts.tone ?? 'primary';
70
88
  const pts = trendPoints(values);
@@ -72,15 +90,39 @@ export function sparklineSvg(values: readonly number[], opts: { tone?: KitTrendT
72
90
  svg.setAttribute('viewBox', '0 0 100 32');
73
91
  svg.setAttribute('preserveAspectRatio', 'none');
74
92
  svg.setAttribute('role', 'img');
75
- svg.setAttribute('class', opts.className ?? ROOT_CLASS);
93
+ svg.setAttribute('class', `${opts.className ?? ROOT_CLASS} ${TEXT_TONE[tone]}`);
76
94
  const min = Math.min(...values);
77
95
  const max = Math.max(...values);
78
- svg.setAttribute('aria-label', `${opts.label ?? ''} ${values[values.length - 1]} (${min} - ${max})`.trim());
96
+ const fmt = opts.format ?? '';
97
+ const loc = opts.locale ?? '';
98
+ const show = (n: number): string => (fmt !== '' ? formatValue(n, fmt, loc) : formatValue(n, 'number', loc) || plainNumber(n));
99
+ const summary = `${opts.label ?? ''} ${show(values[values.length - 1]!)} (${show(min)} - ${show(max)})`.trim();
100
+ svg.setAttribute('aria-label', summary);
101
+ svg.setAttribute(KIT_TIP_ATTR, summary);
79
102
  const d = pts.map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x} ${y}`).join(' ');
80
103
  if (opts.area === true) {
104
+ const gradId = nextUid('kit-trend-grad');
105
+ const defs = document.createElementNS(SVG_NS, 'defs');
106
+ const grad = document.createElementNS(SVG_NS, 'linearGradient');
107
+ grad.setAttribute('id', gradId);
108
+ grad.setAttribute('x1', '0');
109
+ grad.setAttribute('y1', '0');
110
+ grad.setAttribute('x2', '0');
111
+ grad.setAttribute('y2', '1');
112
+ const stopTop = document.createElementNS(SVG_NS, 'stop');
113
+ stopTop.setAttribute('offset', '0%');
114
+ stopTop.setAttribute('stop-color', 'currentColor');
115
+ stopTop.setAttribute('stop-opacity', String(AREA_TOP_OPACITY));
116
+ const stopBottom = document.createElementNS(SVG_NS, 'stop');
117
+ stopBottom.setAttribute('offset', '100%');
118
+ stopBottom.setAttribute('stop-color', 'currentColor');
119
+ stopBottom.setAttribute('stop-opacity', String(AREA_BOTTOM_OPACITY));
120
+ grad.append(stopTop, stopBottom);
121
+ defs.appendChild(grad);
122
+ svg.appendChild(defs);
81
123
  const area = document.createElementNS(SVG_NS, 'path');
82
124
  area.setAttribute('d', `${d} L100 32 L0 32 Z`);
83
- area.setAttribute('class', FILL[tone]);
125
+ area.setAttribute('fill', `url(#${gradId})`);
84
126
  svg.appendChild(area);
85
127
  }
86
128
  const line = document.createElementNS(SVG_NS, 'path');
@@ -103,26 +145,40 @@ export function createTrendLine(): SomaComponentDefinition {
103
145
  y: { type: 'string', default: 'value', desc: '行数组的取值键' },
104
146
  tone: { type: 'string', default: 'primary', desc: '线色:primary | success | warning | danger | info | neutral | auto(按首末涨跌)' },
105
147
  up_is: { type: 'string', default: 'good', desc: 'auto 时上涨是好事(good)还是坏事(bad)' },
106
- area: { type: 'boolean', default: false, desc: '折线下填浅色面' },
148
+ area: { type: 'boolean', default: false, desc: '折线下填浅色面(顶→底柔和透明度渐变)' },
149
+ format: { type: 'string', default: '', desc: '数值格式(soma-foundation/values 写法)' },
150
+ locale: { type: 'string', default: '', desc: '格式化语言' },
107
151
  label: { type: 'string', default: '', desc: '无障碍名称前缀(如「近 7 日订单」)' },
108
- empty_text: { type: 'string', default: '–', desc: '点数不足时的占位文案' },
152
+ empty_text: { type: 'string', default: '—', desc: '点数不足时的占位文案' },
153
+ ...KIT_READ_STATE_PROP_DEFS,
109
154
  class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾(宽度 / 高度类在这里给)' },
110
155
  },
111
- emits: {},
156
+ emits: { ...KIT_READ_STATE_EMIT_DEFS },
112
157
  },
113
158
  templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
114
- controllerFactory: createKitController((_api) => ({
159
+ controllerFactory: createKitController((api) => ({
115
160
  render(root: HTMLElement, p: KitProps): void {
116
161
  root.className = joinClass(ROOT_CLASS, p.class);
162
+ releaseReasonTipsIn(root);
117
163
  root.textContent = '';
118
164
  const values = trendValuesOf(p.data, str(p.y, 'value'));
165
+ const skeleton = (): HTMLElement => {
166
+ const sk = mk('span', SKELETON_CLASS);
167
+ sk.setAttribute(KIT_ATTR_SKELETON, '');
168
+ return sk;
169
+ };
170
+ // 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
171
+ kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(values.length >= 2) });
172
+ if (applyKitReadState(root, p, { hasContent: values.length >= 2, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh(), skeleton })) return;
119
173
  const svg = sparklineSvg(values, {
120
174
  tone: trendToneOf(textOf(p.tone), values, p.up_is === 'bad' ? 'bad' : 'good'),
121
175
  area: bool(p.area),
122
176
  label: str(p.label),
177
+ format: str(p.format),
178
+ locale: str(p.locale),
123
179
  className: 'size-full',
124
180
  });
125
- if (svg) root.appendChild(svg); else root.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, '–')));
181
+ if (svg) root.appendChild(svg); else root.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, '—')));
126
182
  },
127
183
  })),
128
184
  };