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
@@ -16,14 +16,21 @@
16
16
 
17
17
  import type { SomaComponentDefinition } from 'soma-core';
18
18
  import { gridFillPlanOf, type SomaGridFillPlan } from 'soma-foundation/data/values';
19
- import { KIT_STAT_GRID } from 'soma-foundation/kit-limits';
19
+ import { KIT_DATA_LIMITS, KIT_LOOK_LIMITS, KIT_STAT_GRID } from 'soma-foundation/kit-limits';
20
20
  import { KIT_ARRANGE } from 'soma-foundation/arrange';
21
+ import { arrangeStatNotes } from 'soma-foundation/arrange/table';
21
22
  import { createKitController, formatValue, joinClass, kitSyncHeroSolo, num, str } from '../base/shared';
22
- import { kitIcon } from '../shared/icons';
23
+ import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
23
24
  import { trendTone } from '../base/trend-tone';
24
25
  import { TAG_CLASS } from '../base/tag';
25
26
  import { KIT_DELTA_TONE_CLASS } from '../base/delta';
26
27
  import { mergeClass } from '../shared/merge-class';
28
+ import {
29
+ KIT_ATTR_COLLAPSE, KIT_ATTR_GAP, KIT_ATTR_HIGHLIGHT, KIT_ATTR_STAT, KIT_ATTR_STAT_ACTION, KIT_ATTR_STAT_COMPARE, KIT_ATTR_STAT_FLAGS, KIT_ATTR_STAT_FOOT,
30
+ KIT_ATTR_STAT_ICON, KIT_ATTR_STAT_NOTE, KIT_ATTR_STAT_READ, KIT_ATTR_STAT_REASON, KIT_ATTR_STAT_RETRY, KIT_ATTR_STAT_SKELETON,
31
+ KIT_ATTR_STAT_STATE, KIT_ATTR_STAT_SUB, KIT_ATTR_STAT_UNIT, KIT_ATTR_STAT_VALUE, KIT_ATTR_STAT_VALUES, KIT_ATTR_STATE, KIT_ATTR_TIPS,
32
+ KIT_ATTR_TONE, KIT_ATTR_TREND, kitAttrSel,
33
+ } from '../shared/dom-attrs';
27
34
  import { KIT_DELTA_TEXT } from '../recipes/typography';
28
35
  import { gapMarkerNode } from '../base/gap-value';
29
36
  import { safeHref } from '../base/link';
@@ -33,11 +40,23 @@ import { kitText } from '../i18n/kit-text';
33
40
  import { KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES, paintKitStatePanel } from '../base/state-panel';
34
41
  import { KIT_TREND_LINE_CLASS_CANDIDATES, sparklineSvg, trendToneOf, trendValuesOf } from './trend-line';
35
42
  import { KIT_PART_ATTRIBUTE, KIT_PART_STAT_VALUE, kitFocusRingRecipe, kitTypographyRecipe } from '../recipes';
36
- import { KIT_RAIL_GRID_RECIPE_CLASS_CANDIDATES, kitRailGridRecipe, markKitRail } from '../recipes/rail-grid';
37
- import { KIT_SUMMARY_EMPTY_ATTR } from '../recipes/container';
43
+ import { KIT_RAIL_GRID_RECIPE_CLASS_CANDIDATES, KIT_RAIL_TILES, kitRailGridRecipe, markKitRail } from '../recipes/rail-grid';
44
+ import { KIT_SUMMARY_EMPTY_ATTR, kitShellRecipe } from '../recipes/container';
38
45
  import { markKitSlot, markKitSlotGrid, slotCountOf } from '../recipes/slot-align';
46
+ import { applyLook, lookOfItem, lookTone, type KitLookProp } from '../base/look';
47
+ import { KIT_LOOK_TONE_ATTR } from '../recipes/look';
48
+ import { kitFieldNameRecipe } from '../recipes/field-text';
49
+ import { KIT_COLOR_ROLE_CLASS_CANDIDATES, kitReadHostAutoSequence, kitResolveStatusOrCategoryTone, kitToneSoftBadgeClass } from '../recipes/color-role';
50
+ import { kitSelectedRecipe } from '../recipes/state';
51
+ import { kitWellRecipe } from '../recipes/surface';
52
+ import { KIT_SKELETON_BAR_LABEL } from '../recipes/placeholder';
53
+ import { KIT_PROGRESS_CLASS_CANDIDATES, kitMiniBarNode, type ProgressTone } from '../base/progress';
54
+ import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked, kitReadProps } from './kit-contract';
55
+ import { kitApplyLevelClass } from './level-class';
56
+ import { kitApplyCols, kitColsGrid, kitStripGridCols } from '../base/kit-contract';
57
+ import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
39
58
  import {
40
- KIT_STAT_GROUP_REASON_MIN, KIT_STAT_PLACEHOLDER, KIT_STAT_WARN_DOT_CLASS, KIT_STAT_RETRY_CLASS, KIT_STAT_STATE_CLASS_CANDIDATES, KIT_STAT_STATE_REASON,
59
+ KIT_STAT_GROUP_REASON_MIN, KIT_STAT_PLACEHOLDER, KIT_STAT_RETRY_CLASS, KIT_STAT_STATE_CLASS_CANDIDATES, KIT_STAT_STATE_REASON,
41
60
  kitStatGroupNoteClass, kitStatStateRowClass, statStateOf, type KitStatState,
42
61
  } from '../recipes/stat-state';
43
62
  import {
@@ -45,12 +64,19 @@ import {
45
64
  KIT_STAT_VALUES_NUM, KIT_STAT_VALUES_ROW,
46
65
  } from '../recipes/status';
47
66
 
48
- const WRAP_CLASS = '@container';
67
+ const WRAP_CLASS = '@container w-full min-w-0';
68
+ // 平级的小面(保留 prop tiles,看板编译照构成求解器的 fit = tiles 交入,§11.17 成套对齐):每个指标一张面(面配方 + 面内边距),不再是概况面里的子块;
69
+ // 一排铺满、等宽,格间距 = 面间距(导轨是 60 条细轨,不能用 column-gap:单元两侧各半个面间距的外边距、容器负外边距抵消)
70
+ const TILE_RAIL_CLASS = 'in-data-kit-board:-mx-2';
71
+ const TILE_CELL_CLASS = mergeClass('in-data-kit-board:mx-2 in-data-kit-board:my-0 p-card', kitShellRecipe());
49
72
  // 导轨拼合(recipes/rail-grid):块并进一个容器,块间只有 1px 通栏细线,块自己不描边不画卡片;
50
73
  // 容器的列间距 / 行间距 / 内边距 / 底色都由层内规则(真源 structure.railGrid)给,这里不写 gap-* / p-* / 边框类
51
74
  /** 导轨网格的轨数(排布引擎真源 kit-arrange.rail.tracks) */
52
75
  const KIT_RAIL_TRACKS: number = KIT_ARRANGE.rail.tracks;
53
- const GRID_CLASS = `${kitRailGridRecipe().container} grid-cols-${KIT_RAIL_TRACKS}`;
76
+ // 看板里(in-data-kit-board):导轨整条收进统一子块(in-data-kit-board:sub-block),消除单格 mx-1.5 在 layering:line 档把上下细线切碎成断续虚线的问题;
77
+ // 行距不在这里写(KT-P-compose C8):看板导轨的行距与槽间距抵消量由结构规则同取真源 slotAlign.rowGapUnits
78
+ const BOARD_RAIL_CLASS = 'in-data-kit-board:sub-block in-data-kit-board:gap-x-0 in-data-kit-board:border-0 in-data-kit-board:overflow-hidden';
79
+ const GRID_CLASS = `${kitRailGridRecipe().container} grid-cols-${KIT_RAIL_TRACKS} ${BOARD_RAIL_CLASS}`;
54
80
  /** 一个块可能的跨轨数:整行块(允许列数)与末行块(1..最大列数-1 项等分)的并集 */
55
81
  function railSpans(): number[] {
56
82
  const set = new Set<number>();
@@ -61,25 +87,59 @@ function railSpans(): number[] {
61
87
  }
62
88
  // 可点的统计块 = 导轨里的集合项:手形光标、悬停 / 按下走状态层(KT-K0-2,不用整体透明度当按下),焦点 = 集合项 2px 内收环(KT-K0-3 唯一出口)
63
89
  const BLOCK_FOCUS = kitFocusRingRecipe('item');
64
- const BLOCK_CLASS = `${kitRailGridRecipe().cell} appearance-none border-0 cursor-pointer transition-colors state-layer ${BLOCK_FOCUS}`;
65
- // 指标名:字阶角色 statLabel(KT-K-stat-5,标签在上、弱化墨,不手写类串)
66
- const LABEL_CLASS = kitTypographyRecipe('statLabel');
67
- /** 指标主数值样式:对齐规则卡 30px 大数字 + font-bold tabular-nums */
68
- export const STAT_VALUE_CLASS = kitTypographyRecipe('statValue');
90
+ // 看板里的指标格贴合统一子块导轨(mx-0 / my-0 抵消导轨负外边距,常态透出父导轨 sub-block 底色;高亮块保留 kitSelectedRecipe 选中底色)
91
+ const BOARD_BLOCK_BG_CLASS = 'in-data-kit-board:bg-transparent';
92
+ const BOARD_BLOCK_CLASS = 'in-data-kit-board:mx-0 in-data-kit-board:my-0 in-data-kit-board:p-inset-compact';
93
+ const BLOCK_CLASS = `${kitRailGridRecipe().cell} appearance-none border-0 cursor-pointer transition-colors state-layer ${BOARD_BLOCK_CLASS} ${BLOCK_FOCUS}`;
94
+ // 平级小面的格与导轨:不取子块类与去边类(面框由面配方画);导轨的格距换成面间距
95
+ const TILE_BLOCK_CLASS = `${kitRailGridRecipe().cell} appearance-none cursor-pointer text-start transition-colors state-layer ${TILE_CELL_CLASS} ${BLOCK_FOCUS}`;
96
+ const TILE_BOARD_RAIL_CLASS = `in-data-kit-board:gap-x-0 ${TILE_RAIL_CLASS} in-data-kit-board:border-0 in-data-kit-board:rounded-none in-data-kit-board:overflow-visible in-data-kit-board:shadow-none`;
97
+ const TILE_GRID_CLASS = `${kitRailGridRecipe().container} grid-cols-${KIT_RAIL_TRACKS} ${TILE_BOARD_RAIL_CLASS}`;
98
+ // 指标名是字段名:弱化墨、正文字号、500、无底,取字段名唯一出口(主题公式 F7;原字阶角色 statLabel 字重不对)
99
+ const LABEL_CLASS = kitFieldNameRecipe();
100
+ /** 指标主数值样式:对齐规则卡 30px 大数字 + font-title + tracking-tight tabular-nums */
101
+ export const STAT_VALUE_CLASS = mergeClass(kitTypographyRecipe('statValue'), 'tracking-tight tabular-nums');
69
102
  // 三槽(recipes/slot-align):标题 = 指标名,指标 = 数值 + 单位 + 迷你图 + 附加数值 + 标记,操作 = 变化率 / 对比期 / 提示;
70
103
  // 跨卡片的水平对齐由 subgrid 给,不支持 subgrid 时由层内规则退化为 flex 纵向 + 指标槽贴底
71
- const METRIC_SLOT_CLASS = 'flex min-w-0 flex-col gap-1';
104
+ const METRIC_SLOT_CLASS = 'flex min-w-0 flex-col gap-1.5';
72
105
  const VALUE_CLASS = STAT_VALUE_CLASS;
73
106
  /**
74
- * 项语气 -> 数值文字色(彩色文字只配 on-soft);info / neutral 不着色。
75
- * warning 不做大号文字色(R10 / 评审 §1.2「状态」:亮黄橙在白底压到 4.5:1 必然发褐):数字保持中性墨色,语义由指标名前的 6px 警告圆点 + 读屏文字承担。
107
+ * 项语气 -> 数值文字色(彩色文字只配 on-soft 文字级;DC2 一层缺省,2026-11-25 数据着色第二段):
108
+ * 声明了语气的项,值 > 0 时数值取该语气的文字级(warning 的文字级是解到对淡底 / 白 ≥ 4.5 的深琥珀,不再发褐,故与 danger 同样给数值上色,
109
+ * 删去原「指标名前 6px 警告圆点」——圆点与「状态 = 圆点 + 文字」同形,放在指标名前会被读成名的状态);值 = 0 时弱化墨(没有风险不该喊);neutral 不着色。
110
+ * 收紧(2026-11-25 第三段,CS21):只有「坏 / 需注意」(danger / warning)给数值上色;好(success)与信息(info)的数值保持墨色,
111
+ * 好坏由配套元素(迷你条)承担——一排指标里只有出问题的那几项跳出来,正常项不和它们抢注意。
76
112
  */
77
113
  const STAT_TONE_VALUE: Readonly<Partial<Record<string, string>>> = Object.freeze({
78
- danger: 'text-danger-on-soft', success: 'text-success-on-soft',
114
+ danger: 'text-danger-on-soft', warning: 'text-warning-on-soft',
79
115
  });
80
- const STAT_WARN_DOT_CLASS = KIT_STAT_WARN_DOT_CLASS;
116
+ /** 一组指标里数值语气的优先序(超出一个容器的色相预算时,排后的回到墨色):坏 > 注意 */
117
+ const STAT_TONE_PRIORITY: readonly string[] = ['danger', 'warning'];
118
+ /** 声明了语气、值为 0 的计数项:弱化墨 */
119
+ const STAT_ZERO_TONE = 'text-fg-muted';
120
+ /** 指标带可点详情(href / action)时名后的「›」提示(图标 xs,弱化墨,aria-hidden;名与图标同一行) */
121
+ const NAME_LINK_ROW_CLASS = 'inline-flex items-center gap-0.5';
122
+ const NAME_CHEVRON_CLASS = 'shrink-0 text-fg-subtle';
123
+ /** 指标名前可选图标位:圆底图标(未显式指定语气时按指标名与序号自动分配互不冲突的柔和分类色) */
124
+ const LABEL_ICON_CLASS = 'inline-flex items-center gap-2';
125
+ const ICON_BADGE_CLASS = 'flex size-6 shrink-0 items-center justify-center rounded-full text-xs';
126
+ const STAT_AUTO_TONE_CANDIDATES: readonly string[] = (
127
+ ['neutral', 'primary', 'info', 'success', 'warning', 'danger', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8'] as const
128
+ ).flatMap((t) => kitToneSoftBadgeClass(t).split(/\s+/)).filter((c) => c !== '');
129
+ /** 单卡加载骨架:标签 / 数值 / 变化量三条,与真实块同三槽(title / metric),块底同导轨块 */
130
+ const SKELETON_BLOCK_CLASS = `${kitRailGridRecipe().cell} ${BOARD_BLOCK_CLASS} ${BOARD_BLOCK_BG_CLASS}`;
131
+ const SKELETON_TILE_CLASS = `${kitRailGridRecipe().cell} ${TILE_CELL_CLASS}`;
132
+ // 单卡骨架的指标条:高 / 宽的步数读真源 kit-limits#dataLimits.statGroup,不在组件里写死
133
+ const SKELETON_VALUE_CLASS = mergeClass(mergeClass(`h-${KIT_DATA_LIMITS.statGroup.skeletonValueHeightStep} w-${KIT_DATA_LIMITS.statGroup.skeletonValueWidthStep} rounded-item`, kitWellRecipe()), 'motion-safe:animate-kit-pulse');
134
+ /** 迷你条(单位为 % 的比率,DC2):数值行之下的一行,宽与指标槽同 */
135
+ const MINI_BAR_UNIT = '%';
136
+ const isZeroNumber = (v: unknown): boolean => (typeof v === 'number' && v === 0) || (typeof v === 'string' && v.trim() !== '' && Number(v) === 0);
137
+ const numberOf = (v: unknown): number | null => {
138
+ const n = typeof v === 'number' ? v : typeof v === 'string' && v.trim() !== '' ? Number(v) : Number.NaN;
139
+ return Number.isFinite(n) ? n : null;
140
+ };
81
141
  // 数值行:数值 + 单位 + 变化率 / 对比期 / 提示同一条基线(没有副文本的块不为它留第三行,块高只由数值行决定)
82
- const VALUE_ROW_CLASS = 'flex flex-wrap items-baseline gap-x-1 gap-y-0.5';
142
+ const VALUE_ROW_CLASS = 'flex flex-wrap items-baseline gap-x-2 gap-y-1';
83
143
  // 单位 / 前后缀:字阶角色 statUnit(字号 = 数值字号 × 真源 statUnitRatio、下限字阶最小档,同一条基线;KT-K-stat-2)
84
144
  const UNIT_CLASS = kitTypographyRecipe('statUnit');
85
145
  // 缺失 / 出错项主位的「—」:弱化墨(不是一个值),数值字号不变以保住块高(KT-K-stat-3)
@@ -88,20 +148,25 @@ const VALUE_UNIT_CLASS = 'inline-flex items-baseline gap-x-1 whitespace-nowrap';
88
148
 
89
149
  /** 本组件自带的全部类(供编译器并入候选类) */
90
150
  export const KIT_STAT_GROUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
91
- '@container', 'grid', `grid-cols-${KIT_RAIL_TRACKS}`, 'min-w-0', 'appearance-none', 'border-0', 'bg-primary-soft',
92
- 'flex', 'flex-col', 'gap-1', 'text-start',
151
+ '@container', 'grid', `grid-cols-${KIT_RAIL_TRACKS}`, 'min-w-0', TILE_RAIL_CLASS, ...TILE_CELL_CLASS.split(' '), 'appearance-none', 'border-0', ...kitSelectedRecipe().split(' '),
152
+ 'flex', 'flex-col', 'gap-1', 'gap-1.5', 'text-start',
93
153
  // 指标名 / 单位字阶(statLabel / statUnit)、缺失占位弱化墨、趋势文字(涨跌字阶 + 语气色)与方向读屏文字
94
154
  ...LABEL_CLASS.split(' '), ...UNIT_CLASS.split(' '), PLACEHOLDER_TONE, ...KIT_DELTA_TEXT.sm.split(' '), ...Object.values(KIT_DELTA_TONE_CLASS), 'sr-only',
95
155
  'transition-colors', 'font-medium', 'font-normal', 'font-bold', 'tabular-nums',
96
- 'state-layer', 'cursor-pointer', ...BLOCK_FOCUS.split(' '),
156
+ 'state-layer', 'cursor-pointer', BOARD_BLOCK_BG_CLASS, ...BOARD_BLOCK_CLASS.split(' '), ...BOARD_RAIL_CLASS.split(' '), ...TILE_BOARD_RAIL_CLASS.split(' '), ...BLOCK_FOCUS.split(' '),
97
157
  ...KIT_RAIL_GRID_RECIPE_CLASS_CANDIDATES,
98
158
  'text-sm', 'text-fg-muted', 'text-2xl', 'text-stat-value', 'font-title', 'tracking-tight', 'font-semibold', 'text-fg',
99
- 'items-center', 'items-baseline', 'flex-wrap', 'rounded-md', 'px-1.5', 'py-0.5', 'text-xs', 'inline-flex',
159
+ 'items-center', 'items-baseline', 'flex-wrap', 'rounded-item', 'px-1.5', 'py-0.5', 'text-xs', 'inline-flex',
100
160
  // 数值行(VALUE_ROW_CLASS)与副文本(FOOT_CLASS)
101
- 'gap-x-1', 'gap-y-0.5', 'ms-1', 'whitespace-nowrap',
161
+ 'gap-x-1', 'gap-x-2', 'gap-y-0.5', 'gap-y-1', 'ms-1', 'whitespace-nowrap',
102
162
  ...Object.values(TAG_CLASS.sm).flatMap((s) => s.split(' ')),
103
- 'bg-success-soft', 'text-success-on-soft', 'text-warning-on-soft', 'bg-danger-soft', 'text-danger-on-soft', 'bg-surface-sunken', 'text-fg-subtle', 'gap-2', 'border-primary', 'bg-primary-soft',
104
- ...KIT_TREND_LINE_CLASS_CANDIDATES, 'h-8', 'w-full', ...STAT_WARN_DOT_CLASS.split(' '),
163
+ 'bg-success-soft', 'text-success-on-soft', 'text-warning-on-soft', 'bg-danger-soft', 'text-danger-on-soft', 'text-fg-subtle', 'gap-2', 'border-primary',
164
+ ...KIT_TREND_LINE_CLASS_CANDIDATES, 'h-8', 'w-full', 'fill-tone-mark',
165
+ // 数值语气(DC2)、0 值弱化、可点名后「›」、迷你条(与条形进度同一组类)
166
+ ...Object.values(STAT_TONE_VALUE).flatMap((s) => (s ?? '').split(' ')), STAT_ZERO_TONE, ...NAME_LINK_ROW_CLASS.split(' '), ...NAME_CHEVRON_CLASS.split(' '), ...KIT_PROGRESS_CLASS_CANDIDATES,
167
+ // 图标位与单卡骨架
168
+ ...LABEL_ICON_CLASS.split(' '), ...ICON_BADGE_CLASS.split(' '), ...STAT_AUTO_TONE_CANDIDATES, ...KIT_COLOR_ROLE_CLASS_CANDIDATES, ...SKELETON_BLOCK_CLASS.split(' '), ...SKELETON_TILE_CLASS.split(' '), ...SKELETON_VALUE_CLASS.split(' '),
169
+ ...KIT_SKELETON_BAR_LABEL.split(' '),
105
170
  // 整块读取失败面板(K6)
106
171
  ...KIT_STATE_PANEL_CLASS_CANDIDATES,
107
172
  // 项扩展(语气 / 多值 / 标记 / 缺口)自带的类:来自 recipes/status
@@ -110,10 +175,68 @@ export const KIT_STAT_GROUP_CLASS_CANDIDATES: readonly string[] = Object.freeze(
110
175
  ...KIT_STAT_STATE_CLASS_CANDIDATES,
111
176
  // 各档列数与末块拉伸的全部可能类(档名 x 允许列数取自真源,Tailwind 静态扫描不到运行期拼的类名,所以在此列全)
112
177
  // 导轨网格固定 tracks 轨;块按档跨 tracks / 列数(整行块)或 tracks / 末行项数(末行块)轨
113
- `col-span-${KIT_RAIL_TRACKS}`,
178
+ `col-span-${KIT_RAIL_TRACKS}`, `col-span-${KIT_RAIL_TRACKS / 2}`,
179
+ 'max-w-md', 'max-w-3xl', 'max-w-288',
114
180
  ...Object.keys(KIT_STAT_GRID.tierCols).flatMap((tier) => railSpans().map((s) => `@${tier}:col-span-${s}`)),
115
181
  ]);
116
182
 
183
+ /** 少项指标卡的导轨上限宽:确保 1/2/3 张卡在 1440/1920 宽屏下单卡均封顶 ≤ 448px(红线 ≤ 480px),不因 60 轨铺满而拉稀。 */
184
+ export function statGridMaxWidthClass(count: number, columns: number | null | undefined): string {
185
+ const hasExplicit = typeof columns === 'number' && Number.isFinite(columns) && columns > 0;
186
+ const eff = hasExplicit ? Math.min(count, Math.floor(columns)) : count;
187
+ if (count === 1) return 'max-w-md';
188
+ if (count === 2 && eff === 2) return 'max-w-3xl';
189
+ if (count === 3 && eff === 3) return 'max-w-288';
190
+ return '';
191
+ }
192
+
193
+ const STAT_PCT_KEY_RE = /(?:ratio|rate|percent)$/i;
194
+ const STAT_PCT_LABEL_RE = /[率比]$/;
195
+ const STAT_NO_GROUPING_KEY_RE = /(?:^|_)year$|年|(?:^|_)id$/i;
196
+
197
+ /** 指标数值格式化:补齐 bare currency/money、优雅百分比小数位,并在未声明 format 且无独立 unit 时对大额数值与比例字段自动做千分位与百分比格式化(纯文本与小整数兼容原样)。 */
198
+ export function formatStatValue(
199
+ value: unknown,
200
+ format: string,
201
+ locale: string,
202
+ meta?: { key?: string; label?: string; unit?: string },
203
+ ): string {
204
+ if (value === undefined || value === null || value === '') return '';
205
+ const fmt = format.trim();
206
+ const loc = locale || 'zh-CN';
207
+ if (fmt === 'currency' || fmt === 'money') {
208
+ return formatValue(value, 'currency:CNY', loc);
209
+ }
210
+ if (fmt === 'percent') {
211
+ const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
212
+ if (Number.isFinite(n)) {
213
+ try {
214
+ return new Intl.NumberFormat(loc, { style: 'percent', maximumFractionDigits: 1 }).format(n);
215
+ } catch {
216
+ return formatValue(value, fmt, loc);
217
+ }
218
+ }
219
+ return formatValue(value, fmt, loc);
220
+ }
221
+ if (fmt !== '') return formatValue(value, fmt, loc);
222
+ if (typeof value === 'number' && Number.isFinite(value)) {
223
+ const unit = meta?.unit ?? '';
224
+ const key = meta?.key ?? '';
225
+ const label = meta?.label ?? '';
226
+ if (unit === '' && Math.abs(value) > 0 && Math.abs(value) <= 1 && (STAT_PCT_KEY_RE.test(key) || STAT_PCT_LABEL_RE.test(label))) {
227
+ try {
228
+ return new Intl.NumberFormat(loc, { style: 'percent', maximumFractionDigits: 1 }).format(value);
229
+ } catch {
230
+ return String(value);
231
+ }
232
+ }
233
+ if (Math.abs(value) >= 1000 && !STAT_NO_GROUPING_KEY_RE.test(key)) {
234
+ return formatValue(value, 'number', loc);
235
+ }
236
+ }
237
+ return formatValue(value, '', loc);
238
+ }
239
+
117
240
  /**
118
241
  * 栅格计划 -> 类串:网格类按档升序只写列数变化处(窄屏基准 1 列);末块类只写拉伸标记变化处(拉伸 = 占满整行,退出 = 回到单列宽)。
119
242
  * 计划由 gridFillPlanOf 给出,这里只做格式化。
@@ -145,9 +268,64 @@ export function statGridClassesOf(plan: SomaGridFillPlan, count: number): { grid
145
268
  return { grid: GRID_CLASS, cell };
146
269
  }
147
270
 
148
- /** 一排统计块的类:columns 是作者显式写的列数(登记过的按登记,其余正整数是上限),各档列数由排布引擎按容器宽度档与项数求解;末行不满时各项等分末行。 */
271
+ /** 一排统计块的类:columns 是作者显式写的列数(登记过的按登记,其余正整数是上限),各档列数由排布引擎按容器宽度档与项数求解;末行不满时各项等分末行。少项(1/2/3 项)收束导轨最大宽度防宽屏单卡超过 480px。 */
149
272
  export function statGridClasses(count: number, columns: number | null | undefined): { grid: string; cell: (index: number) => string } {
150
- return statGridClassesOf(gridFillPlanOf(KIT_STAT_GRID, count, columns ?? undefined), count);
273
+ const res = statGridClassesOf(gridFillPlanOf(KIT_STAT_GRID, count, columns ?? undefined), count);
274
+ const maxW = statGridMaxWidthClass(count, columns);
275
+ if (maxW !== '') {
276
+ return { grid: `${res.grid} ${maxW}`, cell: res.cell };
277
+ }
278
+ return res;
279
+ }
280
+
281
+ /**
282
+ * 新模式(Kit 主题流水线)的列数:轨道串(kitColsTrack(n))写到窄容器退让容器上,栅格按取值表改写后的 --soma-vt-cols 排 n 轨、每块占 1 轨。
283
+ * n = 栅格计划最宽档的列数;只在那一档末行铺满(tail 为 0)时才能与旧版宽屏逐格等价——末行不满时旧版让末行各项等分整行,
284
+ * n 轨里写不出(还会露出导轨底色),这时返回 null,按旧版的跨轨类画。
285
+ */
286
+ export function statGridNextCols(count: number, columns?: number): number | null {
287
+ const plan = gridFillPlanOf(KIT_STAT_GRID, count, columns);
288
+ const tiers = Object.keys(KIT_STAT_GRID.tierCols);
289
+ const last = tiers[tiers.length - 1]!;
290
+ const n = plan.cols[last] ?? 1;
291
+ return (plan.tail[last] ?? 0) === 0 && n >= 1 ? n : null;
292
+ }
293
+
294
+ const STAT_SELF_COLLAPSE = new WeakSet<HTMLElement>();
295
+
296
+ /** 窄容器退让协调:复用外部 data-kit-collapse(尊重外部 none),无外部声明时在多列态(>=2 列)自落 to-single */
297
+ function syncStatGridCols(grid: HTMLElement, cols: number | null): boolean {
298
+ const validCols = cols !== null && cols >= 2 ? cols : null;
299
+ let externalCollapse: string | null = null;
300
+ for (let el: HTMLElement | null = grid; el !== null; el = el.parentElement) {
301
+ const val = el.getAttribute(KIT_ATTR_COLLAPSE);
302
+ if (val !== null && !(el === grid && STAT_SELF_COLLAPSE.has(grid))) {
303
+ externalCollapse = val;
304
+ break;
305
+ }
306
+ if (el.hasAttribute('data-soma-component')) break;
307
+ }
308
+ if (externalCollapse !== null) {
309
+ if (STAT_SELF_COLLAPSE.has(grid)) {
310
+ kitApplyCols(grid, null);
311
+ if (grid.getAttribute(KIT_ATTR_COLLAPSE) === 'to-single') grid.removeAttribute(KIT_ATTR_COLLAPSE);
312
+ STAT_SELF_COLLAPSE.delete(grid);
313
+ }
314
+ if (externalCollapse !== 'to-single') return kitApplyCols(grid, null);
315
+ return kitApplyCols(grid, validCols);
316
+ }
317
+ if (validCols !== null) {
318
+ if (grid.getAttribute(KIT_ATTR_COLLAPSE) !== 'to-single') grid.setAttribute(KIT_ATTR_COLLAPSE, 'to-single');
319
+ STAT_SELF_COLLAPSE.add(grid);
320
+ return kitApplyCols(grid, validCols);
321
+ }
322
+ if (STAT_SELF_COLLAPSE.has(grid)) {
323
+ const res = kitApplyCols(grid, null);
324
+ if (grid.getAttribute(KIT_ATTR_COLLAPSE) === 'to-single') grid.removeAttribute(KIT_ATTR_COLLAPSE);
325
+ STAT_SELF_COLLAPSE.delete(grid);
326
+ return res;
327
+ }
328
+ return kitApplyCols(grid, null);
151
329
  }
152
330
 
153
331
  export interface KitStatItem {
@@ -178,6 +356,8 @@ export interface KitStatItem {
178
356
  spark: string;
179
357
  /** 指标项主色高亮强调 */
180
358
  highlight?: boolean;
359
+ /** 可选图标位:kit 图标名(画装饰性 SVG)或 ≤2 字的短文字;空 = 无图标。圆底取分类色淡底(装饰,不表语义) */
360
+ icon: string;
181
361
  /** 项语气(neutral / info / success / warning / danger):只接数据给的词或字面量,组件不比较数值;非闭集 = 无语气 */
182
362
  tone: string;
183
363
  /** 语气取自数据里的键(给了就优先于 tone) */
@@ -223,8 +403,8 @@ function signedChange(change: number, text: string): string {
223
403
  if (/^[+\-−]/.test(text) || change === 0) return text;
224
404
  return `${change > 0 ? '+' : '−'}${text}`;
225
405
  }
226
- const FOOT_CLASS = 'ms-1 inline-flex flex-wrap items-baseline gap-2';
227
- const COMPARE_CLASS = 'text-xs text-fg-muted';
406
+ const FOOT_CLASS = 'inline-flex flex-wrap items-baseline gap-x-2 gap-y-0.5';
407
+ const COMPARE_CLASS = 'text-xs text-fg-subtle';
228
408
  const HINT_CLASS = 'text-xs text-fg-subtle';
229
409
 
230
410
  /** 环比徽标的语气:实现在基础层 base/trend-tone(KitDelta 共用),此处再导出保持旧引用不变 */
@@ -258,6 +438,7 @@ function itemOf(key: string, label: string, rec: Record<string, unknown>, inline
258
438
  hintKey: str(rec.hintKey),
259
439
  spark: str(rec.spark),
260
440
  ...(rec.highlight === true ? { highlight: true } : {}),
441
+ icon: str(rec.icon),
261
442
  tone: str(rec.tone),
262
443
  toneKey: str(rec.toneKey),
263
444
  href: str(rec.href),
@@ -396,16 +577,27 @@ function statReasonText(state: Exclude<KitStatState, 'ready'>, reason: string, a
396
577
  export function statStateRowNode(state: Exclude<KitStatState, 'ready'>, reason: string, at: Element | null): HTMLElement {
397
578
  const row = document.createElement('span');
398
579
  row.className = kitStatStateRowClass(state);
399
- row.setAttribute('data-kit-stat-state', state);
400
- row.setAttribute('data-kit-tips', '');
580
+ row.setAttribute(KIT_ATTR_STAT_STATE, state);
581
+ row.setAttribute(KIT_ATTR_TIPS, '');
401
582
  const text = document.createElement('span');
402
583
  text.className = KIT_STAT_STATE_REASON;
403
- text.setAttribute('data-kit-stat-reason', '');
584
+ text.setAttribute(KIT_ATTR_STAT_REASON, '');
404
585
  text.textContent = statReasonText(state, reason, at);
405
586
  row.append(text);
406
587
  return row;
407
588
  }
408
589
 
590
+ /**
591
+ * 契约 look 段(界面规则 KT-LK):选择器可寻址的条目节点与部件。条目 = props.items 的每一项(`item#<key>`);
592
+ * 部件 label = 标签(ink,只收语义色)、value = 数值(figure,收语义 + 分类色)。单位跟随数值、涨跌色由 upIs 定,不开放。
593
+ */
594
+ export const KIT_STAT_GROUP_LOOK = Object.freeze({
595
+ items: Object.freeze({ from: 'items', key: 'key' }),
596
+ parts: Object.freeze({ label: Object.freeze({ role: 'ink', in: 'item' }), value: Object.freeze({ role: 'figure', in: 'item' }), bar: Object.freeze({ role: 'fill', in: 'item' }) }),
597
+ });
598
+ /** 迷你条被界面规则着色时的填充类(载体色的图形级,与 recipes/look 的 fill 角色同一个令牌) */
599
+ const STAT_BAR_LOOK_FILL = 'fill-tone-mark';
600
+
409
601
  export function createStatGroup(): SomaComponentDefinition {
410
602
  return {
411
603
  contract: {
@@ -422,7 +614,10 @@ export function createStatGroup(): SomaComponentDefinition {
422
614
  // 重试文案写 retry_text,点重试抛 read_retry(展示对象的具名动作重取);数据为空时只画错误面板,已有数据时错误面板在块之上、块保留
423
615
  error_text: KIT_READ_STATE_PROP_DEFS.error_text,
424
616
  retry_text: KIT_READ_STATE_PROP_DEFS.retry_text,
617
+ loading: { type: 'boolean', default: false, desc: '加载中:每项画与真实块同三槽的骨架(标签 / 数值 / 变化量三条),根标 aria-busy;项的 icon 键(kit 图标名或 ≤2 字短文字)给出可选图标位' },
425
618
  class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
619
+ tiles: { type: 'boolean', default: false, desc: '平级的小面(保留 prop,页面不直接写):看板编译照页面构成求解器的结果交入——概况条里只有统计块且不带范围切换时为 true,每个指标画成一张面、一排铺满等宽' },
620
+ look: { type: 'object', default: {}, desc: '界面规则(look)编译出的部件外观表(保留 prop,页面不直接写):{ item: { <部件>: {…} }, items: { <项 key>: { <部件>: {…} } } };部件 label(ink)/ value(figure)' },
426
621
  },
427
622
  emits: {
428
623
  read_retry: { payload: {}, desc: '整块读取失败(error_text 非空)时点错误面板的重试钮;绑展示对象成员的统计组由页面把它接到重取动作' },
@@ -430,6 +625,7 @@ export function createStatGroup(): SomaComponentDefinition {
430
625
  action: { payload: { key: { type: 'string' }, action: { type: 'string' }, item: { type: 'object' } }, desc: '点带 action 的统计块(在 select 之后抛);action = 该项声明的事件名,item = { key, label, value }' },
431
626
  retry: { payload: { key: { type: 'string' }, retry: { type: 'string' }, item: { type: 'object' } }, desc: '点 error 态统计块的「重试」钮;retry = 该项声明的事件名;不触发 select / action' },
432
627
  },
628
+ look: KIT_STAT_GROUP_LOOK,
433
629
  },
434
630
  templateHtml: `<div data-soma-id="root" class="${WRAP_CLASS}"><div data-soma-id="grid" class="${GRID_CLASS}"></div></div>`,
435
631
  controllerFactory: createKitController((api) => {
@@ -448,22 +644,22 @@ export function createStatGroup(): SomaComponentDefinition {
448
644
  const onClick = (event: Event): void => {
449
645
  const target = event.target as HTMLElement | null;
450
646
  // 组级说明行的重试入口(在块外)
451
- const noteRetry = target?.closest<HTMLElement>('[data-kit-stat-note] [data-kit-stat-retry]') ?? null;
647
+ const noteRetry = target?.closest<HTMLElement>(`${kitAttrSel(KIT_ATTR_STAT_NOTE)} ${kitAttrSel(KIT_ATTR_STAT_RETRY)}`) ?? null;
452
648
  if (noteRetry !== null) {
453
- const nk = noteRetry.getAttribute('data-kit-stat-retry');
649
+ const nk = noteRetry.getAttribute(KIT_ATTR_STAT_RETRY);
454
650
  const ni = current.find((c) => c.key === nk);
455
651
  const nm = nk === null ? undefined : meta.get(nk);
456
652
  if (ni !== undefined && nm !== undefined && nm.retry !== '') api.emit('retry', { key: ni.key, retry: nm.retry, item: ni });
457
653
  return;
458
654
  }
459
- const hit = target?.closest<HTMLElement>('[data-kit-stat]');
655
+ const hit = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_STAT));
460
656
  if (!hit) return;
461
- const key = hit.getAttribute('data-kit-stat');
657
+ const key = hit.getAttribute(KIT_ATTR_STAT);
462
658
  const item = current.find((c) => c.key === key);
463
659
  if (!item) return;
464
660
  const m = meta.get(item.key);
465
661
  // 重试钮:只抛 retry,不触发整块的 select / action
466
- const retryEl = target?.closest<HTMLElement>('[data-kit-stat-retry]') ?? null;
662
+ const retryEl = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_STAT_RETRY)) ?? null;
467
663
  if (retryEl !== null && hit.contains(retryEl)) {
468
664
  event.stopPropagation();
469
665
  if (m !== undefined && m.retry !== '') api.emit('retry', { key: item.key, retry: m.retry, item });
@@ -492,43 +688,115 @@ export function createStatGroup(): SomaComponentDefinition {
492
688
  const flatMap = map;
493
689
  const locale = str(p.locale);
494
690
  root.className = joinClass(WRAP_CLASS, p.class);
691
+ // 页面线给的判定(新流水线才有):列数取 kit.columns,页面显式写的 columns 仍优先(作者意图压过缺省判定)
692
+ const kitProps = kitReadProps(p);
495
693
  // 整块读取失败(K6):错误面板画在块之前;数据为空时只留面板(块区收起),有数据时块保留
496
- root.querySelector('[data-kit-stat-read]')?.remove();
694
+ root.querySelector(kitAttrSel(KIT_ATTR_STAT_READ))?.remove();
497
695
  const readError = str(p.error_text);
498
696
  if (readError !== '') {
499
697
  const panel = document.createElement('div');
500
- panel.setAttribute('data-kit-stat-read', '');
698
+ panel.setAttribute(KIT_ATTR_STAT_READ, '');
501
699
  const retryLabel = str(p.retry_text);
502
700
  paintKitStatePanel(panel, 'error', {
503
701
  text: readError,
504
702
  ...(retryLabel !== '' ? { retry: (): void => { api.emit('read_retry', {}); }, retryLabel } : {}),
505
703
  });
506
704
  root.insertBefore(panel, grid);
507
- if (Object.keys(data).length === 0) { grid.className = 'hidden'; grid.textContent = ''; return; }
705
+ if (Object.keys(data).length === 0) {
706
+ syncStatGridCols(grid, null);
707
+ kitColsGrid(grid, false);
708
+ grid.className = 'hidden';
709
+ grid.textContent = '';
710
+ kitMarkDataFacts(root, { error: true });
711
+ return;
712
+ }
508
713
  }
509
714
  const items = statItemsOf(p.items, map, data, str(p.items_from));
510
715
  // 没有任何指标项(数据说「这一块不适用」,如旧口径报告无摘要统计):整块不渲染(根 hidden、无子节点),不留空卡片;同 NoticeList 的空约定
511
716
  // 概况条里的统计块没有指标可显示时自报(宿主带 data-kit-summary-empty):条内成员全空,整条概况条不渲染(结构 CSS)
512
- if (items.length === 0 && readError === '') { root.hidden = true; grid.className = 'hidden'; grid.textContent = ''; api.host.setAttribute(KIT_SUMMARY_EMPTY_ATTR, ''); kitSyncHeroSolo(api.host); return; }
717
+ // 数据状态自报(每次渲染都写,切回常态时去掉):出错 > 加载 > 空
718
+ kitMarkDataFacts(root, { error: readError !== '', loading: p.loading === true, empty: items.length === 0 });
719
+ if (items.length === 0 && readError === '') {
720
+ syncStatGridCols(grid, null);
721
+ kitColsGrid(grid, false);
722
+ root.hidden = true;
723
+ grid.className = 'hidden';
724
+ grid.textContent = '';
725
+ api.host.setAttribute(KIT_SUMMARY_EMPTY_ATTR, '');
726
+ kitSyncHeroSolo(api.host);
727
+ return;
728
+ }
513
729
  api.host.removeAttribute(KIT_SUMMARY_EMPTY_ATTR);
514
730
  kitSyncHeroSolo(api.host);
515
731
  root.hidden = false;
516
- const classes = statGridClasses(items.length, num(p.columns));
517
- grid.className = classes.grid;
732
+ // 页面显式写的 columns (>0) 优先;页面线在 capacity='unknown' 时可能给缺省 columns=1,多指标态下由真实项数与栅格计划推出桌面列数
733
+ const givenColumns = num(p.columns);
734
+ const explicitCols = givenColumns !== null && givenColumns > 0 ? givenColumns : undefined;
735
+ const layoutCols = kitProps.columns !== undefined && kitProps.columns > 1 ? kitProps.columns : undefined;
736
+ const resolvedCols = explicitCols ?? layoutCols;
737
+ const classes = statGridClasses(items.length, resolvedCols ?? givenColumns);
738
+ // 新模式多列(>=2 列且末行铺满)接线窄容器退让:无外部 data-kit-collapse 时在 grid 自身落 data-kit-collapse="to-single"
739
+ // (grid 位于 @container 根内),经 kitApplyCols + kitColsGrid 切入 --soma-vt-cols 变量列轨;旧版与末行不满保持原类
740
+ const nextCols = kitIsNextRuntime() ? statGridNextCols(items.length, resolvedCols) : null;
741
+ const varTracks = syncStatGridCols(grid, nextCols);
742
+ // 移动端(< @md)多指标(>=2 项且未显式锁单列)默认 2 列紧排(跨半轨 30),孤行末格由投影函数 gridFillPlanOf 判出跨满 60 防末行留空;单项或显式单列保持跨满 60
743
+ const mobileTwoCol = items.length >= 2 && resolvedCols !== 1;
744
+ const mobilePlan = mobileTwoCol ? gridFillPlanOf(KIT_STAT_GRID, items.length, 2) : null;
745
+ const mobileOrphanLast = mobilePlan !== null && Object.values(mobilePlan.tail).includes(1);
746
+ const baseSpanOf = (index: number): number => (mobileTwoCol && !(mobileOrphanLast && index === items.length - 1) ? KIT_RAIL_TRACKS / 2 : KIT_RAIL_TRACKS);
747
+ const spanClassOf = (index: number): string => (varTracks ? '' : `col-span-${baseSpanOf(index)} ${classes.cell(index)}`.trim());
748
+ const tileMaxW = statGridMaxWidthClass(items.length, resolvedCols ?? givenColumns);
749
+ const gridClass = p.tiles === true ? (tileMaxW !== '' ? `${TILE_GRID_CLASS} ${tileMaxW}` : TILE_GRID_CLASS) : classes.grid;
750
+ grid.className = varTracks ? kitStripGridCols(gridClass) : gridClass;
751
+ kitColsGrid(grid, varTracks);
518
752
  // 导轨拼合 + 三槽对齐(默认行为,不是页面语法):块并进一个带通栏细线的容器,标题 / 指标 / 操作三槽跨块水平对齐
519
- markKitRail(grid);
753
+ markKitRail(grid, p.tiles === true ? KIT_RAIL_TILES : '');
754
+ // 加载骨架:与真实块同导轨、同三槽(标题 / 指标 / 变化量),整组 aria-busy;就绪后重绘为真实块
755
+ if (p.loading === true) {
756
+ root.setAttribute('aria-busy', 'true');
757
+ markKitSlotGrid(grid, slotCountOf(false));
758
+ grid.textContent = '';
759
+ current = [];
760
+ meta = new Map();
761
+ for (const [index, item] of items.entries()) {
762
+ const sk = document.createElement('div');
763
+ sk.setAttribute(KIT_ATTR_STAT_SKELETON, item.key);
764
+ sk.setAttribute('aria-hidden', 'true');
765
+ const spanClass = spanClassOf(index);
766
+ sk.className = `${p.tiles === true ? SKELETON_TILE_CLASS : SKELETON_BLOCK_CLASS} ${spanClass}`.trimEnd();
767
+ const bar = (slot: 'title' | 'metric', cls: string): HTMLElement => {
768
+ const s = markKitSlot(document.createElement('span'), slot);
769
+ s.className = slot === 'metric' ? METRIC_SLOT_CLASS : 'flex';
770
+ const b = document.createElement('span');
771
+ b.className = cls;
772
+ s.appendChild(b);
773
+ return s;
774
+ };
775
+ const metric = bar('metric', SKELETON_VALUE_CLASS);
776
+ const change = document.createElement('span');
777
+ change.className = `${KIT_SKELETON_BAR_LABEL}`;
778
+ metric.appendChild(change);
779
+ sk.append(bar('title', KIT_SKELETON_BAR_LABEL), metric);
780
+ grid.appendChild(sk);
781
+ }
782
+ return;
783
+ }
784
+ root.removeAttribute('aria-busy');
520
785
  // 三态(由数据给):非 ready 的块没有可比的数值,不画环比 / 对比期;error 且给了 retry 时操作槽出重试钮
521
786
  const stateOfItem = (item: KitStatItem): KitStatState => {
522
787
  const scope = statScopeOf(item, map, data);
523
788
  return statStateOf(pickText(item.state, item.stateKey, scope.map, scope.data));
524
789
  };
525
790
  // 同组原因相同(达到 groupReasonMin)的非 ready 项:原因提到组级只写一次,各项只留「—」;error 组级带一个重试入口
526
- root.querySelectorAll('[data-kit-stat-note]').forEach((n) => n.remove());
791
+ root.querySelectorAll(kitAttrSel(KIT_ATTR_STAT_NOTE)).forEach((n) => n.remove());
527
792
  const hoistKey = (item: KitStatItem): string => {
528
793
  const st = stateOfItem(item);
529
794
  if (st === 'ready') return '';
530
795
  const sc = statScopeOf(item, flatMap, flatData);
531
- return `${st}\u0000${statReasonText(st, pickText(item.reason, item.reasonKey, sc.map, sc.data), rootEl)}`;
796
+ const given = pickText(item.reason, item.reasonKey, sc.map, sc.data);
797
+ // 缺失且没给原因的项不提组级说明(缺省的「暂无数据」不是内容,格里的短横已经说明,N20)
798
+ if (st === 'missing' && given.trim() === '') return '';
799
+ return `${st}\u0000${statReasonText(st, given, rootEl)}`;
532
800
  };
533
801
  const keyCount = new Map<string, number>();
534
802
  for (const item of items) {
@@ -537,12 +805,18 @@ export function createStatGroup(): SomaComponentDefinition {
537
805
  }
538
806
  const hoisted = new Set<string>([...keyCount].filter(([, n]) => n >= KIT_STAT_GROUP_REASON_MIN).map(([k]) => k));
539
807
  const isHoisted = (item: KitStatItem): boolean => hoisted.has(hoistKey(item));
540
- const foots = items.map((item) => {
808
+ // 每格都相同的副文不出(§11.17「只放内容」):判定在排布引擎 arrangeStatNotes(参数 kit-arrange#statNotes),这里只照结果不画
809
+ const rawHints = items.map((item) => {
810
+ const { map, data } = statScopeOf(item, flatMap, flatData);
811
+ return item.hintKey !== '' ? str(data[typeof map[item.hintKey] === 'string' && map[item.hintKey] !== '' ? String(map[item.hintKey]) : item.hintKey]) : item.hint;
812
+ });
813
+ const hintShown = arrangeStatNotes(rawHints).show;
814
+ const foots = items.map((item, itemIndex) => {
541
815
  const { map, data } = statScopeOf(item, flatMap, flatData);
542
816
  const itemState = stateOfItem(item);
543
817
  const changeBadge = itemState === 'ready' ? resolveChangeBadge(item, map, data, locale) : undefined;
544
818
  const compareText = itemState === 'ready' ? resolveMappedString(item.compare, item.compareKey, map, data) : '';
545
- const hintText = item.hintKey !== '' ? str(data[typeof map[item.hintKey] === 'string' && map[item.hintKey] !== '' ? String(map[item.hintKey]) : item.hintKey]) : item.hint;
819
+ const hintText = hintShown[itemIndex] === true ? rawHints[itemIndex]! : '';
546
820
  const retry = itemState === 'error' && item.retry !== '' && !isHoisted(item);
547
821
  return { changeBadge, compareText, hintText, retry, any: changeBadge !== undefined || compareText !== '' || hintText !== '' || retry };
548
822
  });
@@ -551,11 +825,24 @@ export function createStatGroup(): SomaComponentDefinition {
551
825
  grid.textContent = '';
552
826
  current = [];
553
827
  meta = new Map();
828
+ const valueOfItem = (item: KitStatItem): unknown => {
829
+ const { map, data } = statScopeOf(item, flatMap, flatData);
830
+ const source = typeof map[item.key] === 'string' && map[item.key] !== '' ? String(map[item.key]) : item.key;
831
+ return item.inline !== null ? item.inline.value : data[source];
832
+ };
833
+ // 数值语气的色相预算(一个容器至多 kit-limits#look.huesPerContainer 种):按 坏 > 注意 > 好 > 信息 取前几种,其余回墨
834
+ const wantTones = new Set<string>();
835
+ for (const item of items) {
836
+ const { map, data } = statScopeOf(item, flatMap, flatData);
837
+ const t = statusToneOrNull(pickText(item.tone, item.toneKey, map, data));
838
+ if (t !== null && STAT_TONE_VALUE[t] !== undefined && stateOfItem(item) === 'ready' && !isZeroNumber(valueOfItem(item))) wantTones.add(t);
839
+ }
840
+ const valueTones = new Set(STAT_TONE_PRIORITY.filter((t) => wantTones.has(t)).slice(0, KIT_LOOK_LIMITS.huesPerContainer));
841
+ const autoSeq = kitReadHostAutoSequence(rootEl);
554
842
  for (const [index, item] of items.entries()) {
555
843
  // 取数范围:自带数据的项取项本身,扁平项取全局 data + map(以下 map / data 在本项内指这个范围)
556
844
  const { map, data } = statScopeOf(item, flatMap, flatData);
557
- const source = typeof map[item.key] === 'string' && map[item.key] !== '' ? String(map[item.key]) : item.key;
558
- const value = item.inline !== null ? item.inline.value : data[source];
845
+ const value = valueOfItem(item);
559
846
  current.push({ key: item.key, label: item.label, value });
560
847
  const itemState = stateOfItem(item);
561
848
  const hasRetry = foots[index]!.retry;
@@ -569,46 +856,89 @@ export function createStatGroup(): SomaComponentDefinition {
569
856
  if (block instanceof HTMLButtonElement) block.type = 'button';
570
857
  else if (hasRetry) block.setAttribute('role', 'group');
571
858
  else block.setAttribute('href', hrefSafe);
572
- if (action !== '') block.setAttribute('data-kit-stat-action', action);
573
- if (itemState !== 'ready') block.setAttribute('data-kit-state', itemState);
859
+ if (action !== '') block.setAttribute(KIT_ATTR_STAT_ACTION, action);
860
+ if (itemState !== 'ready') block.setAttribute(KIT_ATTR_STATE, itemState);
574
861
  // 块在导轨里不描边、不画卡片(不标 card 部件,免得命中容器边界 / 阴影规则);高亮块只换底色
575
- const blockClass = item.highlight === true ? `${BLOCK_CLASS} bg-primary-soft` : BLOCK_CLASS;
576
- const spanClass = `col-span-${KIT_RAIL_TRACKS} ${classes.cell(index)}`.trim();
577
- block.className = `${blockClass} ${spanClass}`;
578
- block.setAttribute('data-kit-stat', item.key);
579
- if (item.highlight === true) block.setAttribute('data-kit-highlight', 'true');
862
+ const blockClass = item.highlight === true ? `${BLOCK_CLASS} ${kitSelectedRecipe()}` : `${BLOCK_CLASS} ${BOARD_BLOCK_BG_CLASS}`;
863
+ const spanClass = spanClassOf(index);
864
+ block.className = (p.tiles === true ? `${TILE_BLOCK_CLASS} ${spanClass}` : `${blockClass} ${spanClass}`).trimEnd();
865
+ block.setAttribute(KIT_ATTR_STAT, item.key);
866
+ // 指标组的每一格是一张对象面(业务功能描述 §8.2):取值表据它给面的取值,组件不判断要不要框
867
+ // 自报之后按实际角色剥掉取值表负责的类(旧版不动);高亮底色改由取值表的选中状态规则给(块下方自报 selected)
868
+ kitMarkLevel(block, 'face'); kitApplyLevelClass(block);
869
+ if (item.highlight === true) block.setAttribute(KIT_ATTR_HIGHLIGHT, 'true');
870
+ // 作筛选卡用:块是按钮且本组有高亮项时,每块带 aria-pressed(高亮 = true,其余 = false);链接 / 分组容器不是切换钮
871
+ if (block instanceof HTMLButtonElement && items.some((x) => x.highlight === true)) block.setAttribute('aria-pressed', item.highlight === true ? 'true' : 'false');
872
+ // 高亮块即当前选中的筛选卡:交互状态自报;aria-pressed 已在上一行按按钮语义写,这里不再写 aria-selected
873
+ if (item.highlight === true) kitMarkPicked(block, 'selected', true, null);
580
874
  const label = markKitSlot(document.createElement('span'), 'title');
581
875
  label.className = LABEL_CLASS;
582
876
  label.textContent = item.label;
877
+ kitMarkPart(label, 'field-name');
583
878
  // 项语气(数据给的词):指标名前加图标 + 读屏文字(双编码,不靠颜色);非闭集的词忽略
584
879
  const itemTone = statusToneOrNull(pickText(item.tone, item.toneKey, map, data));
585
880
  if (itemTone !== null) {
586
881
  // 语气不加图标(统计项标签前的图标有的有有的没有,是噪声):读屏文字 + 数值语义色(danger / warning / success)双编码
587
- block.setAttribute('data-kit-tone', itemTone);
882
+ block.setAttribute(KIT_ATTR_TONE, itemTone);
588
883
  const sr = document.createElement('span');
589
884
  sr.className = KIT_NOTICE_SR_ONLY;
590
885
  sr.textContent = kitText(KIT_STATUS_TONE_TEXT_KEY[itemTone], undefined, rootEl);
591
- if (itemTone === 'warning') {
592
- const dot = document.createElement('span');
593
- dot.className = STAT_WARN_DOT_CLASS;
594
- dot.setAttribute('aria-hidden', 'true');
595
- label.replaceChildren(sr, dot, document.createTextNode(item.label));
596
- } else label.replaceChildren(sr, document.createTextNode(item.label));
886
+ label.replaceChildren(sr, document.createTextNode(item.label));
887
+ }
888
+ // 带可点详情(链接 / 下钻动作):名后一个「›」,提示整块可点(CS19 ③ 隐性暗示,不靠文字说明)
889
+ if (hrefSafe !== '' || action !== '') {
890
+ label.className = mergeClass(LABEL_CLASS, NAME_LINK_ROW_CLASS);
891
+ label.appendChild(kitIcon('chevron-right', 'xs', NAME_CHEVRON_CLASS));
892
+ }
893
+ // 可选图标位:名前一枚圆底图标(kit 图标名 = 装饰性 SVG;≤2 字短文字 = 文字徽标);未显式指定 tone 时自动分配互不冲突的柔和分类色
894
+ if (item.icon !== '') {
895
+ const isName = (KIT_ICON_NAMES as readonly string[]).includes(item.icon);
896
+ if (isName || [...item.icon].length <= 2) {
897
+ const explicitTone = pickText(item.tone, item.toneKey, map, data).trim();
898
+ const badgeTone = kitResolveStatusOrCategoryTone(
899
+ item.label,
900
+ index,
901
+ {
902
+ ...(explicitTone !== '' ? { explicitTone } : {}),
903
+ ...(autoSeq !== undefined ? { autoSequence: autoSeq } : { host: rootEl }),
904
+ },
905
+ );
906
+ const badge = document.createElement('span');
907
+ badge.className = mergeClass(ICON_BADGE_CLASS, kitToneSoftBadgeClass(badgeTone));
908
+ badge.setAttribute('aria-hidden', 'true');
909
+ badge.setAttribute(KIT_ATTR_STAT_ICON, '');
910
+ kitMarkPart(badge, 'icon');
911
+ badge.setAttribute(KIT_LOOK_TONE_ATTR, badgeTone);
912
+ if (isName) badge.appendChild(kitIcon(item.icon as KitIconName, 'xs')); else badge.textContent = item.icon;
913
+ label.className = mergeClass(label.className, LABEL_ICON_CLASS);
914
+ label.prepend(badge);
915
+ }
597
916
  }
598
917
  const val = document.createElement('span');
599
- const toneText = itemTone !== null && itemState === 'ready' && STAT_TONE_VALUE[itemTone] !== undefined ? ` ${STAT_TONE_VALUE[itemTone]}` : '';
600
- val.className = `${VALUE_CLASS}${toneText}`;
601
- val.setAttribute('data-kit-stat-value', '');
918
+ // 语气字色替换数值配方里的墨色(同族合并,不并存:并存时 text-fg 按 CSS 顺序胜出,声明的语气不生效——W-0 缺陷);
919
+ // 值为 0 的计数项弱化墨;超出容器色相预算的语气回墨
920
+ const toneClass = itemTone === null || itemState !== 'ready' ? undefined
921
+ : isZeroNumber(value) ? STAT_ZERO_TONE
922
+ : valueTones.has(itemTone) ? STAT_TONE_VALUE[itemTone] : undefined;
923
+ val.className = toneClass === undefined ? VALUE_CLASS : mergeClass(VALUE_CLASS, toneClass);
924
+ // 界面规则(look):项的部件 label(ink)/ value(figure);item.<键> 绑定取本项数据(扁平写法取 data)。没写规则时什么都不改
925
+ const itemLook = lookOfItem(p.look as KitLookProp | undefined, item.key);
926
+ const lookCtx = { item: { ...data, ...(item as unknown as Record<string, unknown>) } };
927
+ if (itemState === 'ready') applyLook(val, itemLook, 'value', 'figure', lookCtx);
928
+ applyLook(label, itemLook, 'label', 'ink', lookCtx);
929
+ const toned = val.className;
930
+ val.setAttribute(KIT_ATTR_STAT_VALUE, '');
602
931
  val.setAttribute(KIT_PART_ATTRIBUTE, KIT_PART_STAT_VALUE);
603
- val.textContent = value === undefined || value === null || value === '' ? '' : formatValue(value, item.format, locale);
604
932
  // 缺口 / 未知(由数据给):state 明示 gap / unknown,或值缺失且给了原因(缺口);此时主数值位画标记,不画空白 / 0
605
933
  const stateRaw = pickText(item.state, item.stateKey, map, data);
606
934
  const reasonText = pickText(item.reason, item.reasonKey, map, data);
607
935
  const valueMissing = value === undefined || value === null || value === '';
608
936
  const gapKind = itemState !== 'ready' ? null : stateRaw === 'gap' || stateRaw === 'unknown' ? stateRaw : valueMissing && reasonText.trim() !== '' ? 'gap' : null;
937
+ const unitText = gapKind !== null || itemState !== 'ready' ? '' : resolveMappedString(item.unit, item.unitKey, map, data);
938
+ val.textContent = formatStatValue(value, item.format, locale, { key: item.key, label: item.label, unit: unitText });
609
939
  // 缺失 / 出错 / 就绪但无值(且不是缺口):主位写占位「—」,弱化墨 + 读屏「暂无数据」(KT-K-stat-3)
610
940
  const placeholder = itemState !== 'ready' || (valueMissing && gapKind === null);
611
- const valueClass = placeholder ? mergeClass(VALUE_CLASS, PLACEHOLDER_TONE) : `${VALUE_CLASS}${toneText}`;
941
+ const valueClass = placeholder ? mergeClass(VALUE_CLASS, PLACEHOLDER_TONE) : toned;
612
942
  if (placeholder) {
613
943
  val.className = valueClass;
614
944
  const mark = document.createElement('span');
@@ -621,17 +951,20 @@ export function createStatGroup(): SomaComponentDefinition {
621
951
  }
622
952
  if (gapKind !== null) {
623
953
  val.textContent = '';
624
- val.setAttribute('data-kit-gap', gapKind);
954
+ val.setAttribute(KIT_ATTR_GAP, gapKind);
625
955
  val.appendChild(gapMarkerNode(gapKind, reasonText, rootEl));
626
956
  }
627
957
  block.appendChild(label);
628
958
  const metric = markKitSlot(document.createElement('span'), 'metric');
629
959
  metric.className = METRIC_SLOT_CLASS;
960
+ // 指标值元素:数值节点自身已有存量部件 stat-value(主题结构钩子,保留),元素部件写在承载读数的指标槽上
961
+ kitMarkPart(metric, 'metric');
630
962
  block.appendChild(metric);
631
963
 
632
- const unitText = gapKind !== null || itemState !== 'ready' ? '' : resolveMappedString(item.unit, item.unitKey, map, data);
633
964
  // 三态原因行:状态圆点 + 原因文字;error 态指标位只有这一行(没有主数值),missing 态在占位「—」之下
634
- const stateRow = itemState === 'ready' || isHoisted(item) ? null : statStateRowNode(itemState, reasonText, rootEl);
965
+ // 缺失且数据没给原因:只留占位短横(读屏仍读「暂无数据」),不再多画一行缺省的「暂无数据」(非内容项 N20);给了原因 / 出错照旧出状态行
966
+ const bareMissing = itemState === 'missing' && reasonText.trim() === '';
967
+ const stateRow = itemState === 'ready' || bareMissing || isHoisted(item) ? null : statStateRowNode(itemState, reasonText, rootEl);
635
968
  // error 与 missing 一样主位只写「—」(上面 placeholder 已画),原因在其下(或提到组级)
636
969
  let valRow: HTMLElement | null = null;
637
970
  if (unitText !== '' || foots[index]!.any) {
@@ -645,7 +978,7 @@ export function createStatGroup(): SomaComponentDefinition {
645
978
  pair.className = VALUE_UNIT_CLASS;
646
979
  const unitEl = document.createElement('span');
647
980
  unitEl.className = UNIT_CLASS;
648
- unitEl.setAttribute('data-kit-stat-unit', '');
981
+ unitEl.setAttribute(KIT_ATTR_STAT_UNIT, '');
649
982
  unitEl.textContent = unitText;
650
983
  pair.append(val, unitEl);
651
984
  valRow.appendChild(pair);
@@ -656,7 +989,22 @@ export function createStatGroup(): SomaComponentDefinition {
656
989
  } else {
657
990
  metric.appendChild(val);
658
991
  }
659
- if (stateRow !== null) metric.appendChild(stateRow);
992
+ if (stateRow !== null) { kitMarkPart(stateRow, 'status'); metric.appendChild(stateRow); }
993
+
994
+ // 迷你条(DC2 一层缺省):单位为 % 的比率,数值下一根细条(自然上限 100);填充 = 判定为坏 / 需注意(warning / danger)时取判定色,其余(含好)主色——与数值同一条收紧规则
995
+ // 只画 0 < 值 ≤ 100 的占比(0 没有可画的量、空轨是噪声;负值与超过 100 的是偏差 / 增幅,不是「整体的一部分」)
996
+ const pct = itemState === 'ready' && gapKind === null && unitText.trim() === MINI_BAR_UNIT ? numberOf(value) : null;
997
+ if (pct !== null && pct > 0 && pct <= 100) {
998
+ const barTone: ProgressTone = itemTone === 'warning' || itemTone === 'danger' ? itemTone : 'primary';
999
+ const bar = kitMiniBarNode(document, pct, barTone);
1000
+ // 界面规则 item::bar { tone }(B2 接线):填充换成载体色(SVG 图形不经 className,单独落 fill 角色类)
1001
+ const lookBar = lookTone(itemLook, 'bar', lookCtx);
1002
+ if (lookBar !== undefined) {
1003
+ bar.setAttribute(KIT_LOOK_TONE_ATTR, lookBar);
1004
+ bar.lastElementChild?.setAttribute('class', STAT_BAR_LOOK_FILL);
1005
+ }
1006
+ metric.appendChild(bar);
1007
+ }
660
1008
 
661
1009
  if (itemState === 'ready' && item.spark !== '') {
662
1010
  const sparkSource = typeof map[item.spark] === 'string' && map[item.spark] !== '' ? String(map[item.spark]) : item.spark;
@@ -669,19 +1017,19 @@ export function createStatGroup(): SomaComponentDefinition {
669
1017
  if (itemState === 'ready' && item.values.length > 0) {
670
1018
  const row = document.createElement('span');
671
1019
  row.className = KIT_STAT_VALUES_ROW;
672
- row.setAttribute('data-kit-stat-values', '');
1020
+ row.setAttribute(KIT_ATTR_STAT_VALUES, '');
673
1021
  for (const sub of item.values) {
674
1022
  const subSource = typeof map[sub.key] === 'string' && map[sub.key] !== '' ? String(map[sub.key]) : sub.key;
675
1023
  const subValue = data[subSource];
676
1024
  const pair = document.createElement('span');
677
- pair.setAttribute('data-kit-stat-sub', sub.key);
1025
+ pair.setAttribute(KIT_ATTR_STAT_SUB, sub.key);
678
1026
  pair.appendChild(document.createTextNode(`${sub.label} `));
679
1027
  if (subValue === undefined || subValue === null || subValue === '') {
680
1028
  pair.appendChild(gapMarkerNode('gap', '', rootEl, 'sm'));
681
1029
  } else {
682
1030
  const numEl = document.createElement('span');
683
1031
  numEl.className = KIT_STAT_VALUES_NUM;
684
- const shown = formatValue(subValue, sub.format, locale);
1032
+ const shown = formatStatValue(subValue, sub.format, locale, { key: sub.key, label: sub.label, unit: sub.unit });
685
1033
  numEl.textContent = sub.unit === '' ? shown : `${shown} ${sub.unit}`;
686
1034
  pair.appendChild(numEl);
687
1035
  }
@@ -702,7 +1050,7 @@ export function createStatGroup(): SomaComponentDefinition {
702
1050
  if (flags.length > 0) {
703
1051
  const row = document.createElement('span');
704
1052
  row.className = KIT_STAT_FLAGS_ROW;
705
- row.setAttribute('data-kit-stat-flags', '');
1053
+ row.setAttribute(KIT_ATTR_STAT_FLAGS, '');
706
1054
  for (const f of flags) {
707
1055
  const chip = document.createElement('span');
708
1056
  chip.className = TAG_CLASS.sm[f.tone];
@@ -718,12 +1066,14 @@ export function createStatGroup(): SomaComponentDefinition {
718
1066
  if (foots[index]!.any) {
719
1067
  const foot = document.createElement('span');
720
1068
  foot.className = FOOT_CLASS;
721
- foot.setAttribute('data-kit-stat-foot', '');
1069
+ foot.setAttribute(KIT_ATTR_STAT_FOOT, '');
722
1070
  if (changeBadge !== undefined) {
723
1071
  const { change, text: changeText } = changeBadge;
724
1072
  const badge = document.createElement('span');
725
1073
  badge.className = TREND_UP_CLASS[trendTone(change, item.upIs)];
726
- badge.setAttribute('data-kit-trend', change > 0 ? 'up' : change < 0 ? 'down' : 'flat');
1074
+ badge.setAttribute(KIT_ATTR_TREND, change > 0 ? 'up' : change < 0 ? 'down' : 'flat');
1075
+ // 变化量是状态类元素(升 / 降 / 持平)
1076
+ kitMarkPart(badge, 'status');
727
1077
  badge.appendChild(kitIcon(change > 0 ? 'arrow-up' : change < 0 ? 'arrow-down' : 'minus', 'xs'));
728
1078
  badge.appendChild(document.createTextNode(signedChange(change, changeText)));
729
1079
  // 方向的读屏文字(箭头是 aria-hidden 的图形):与 KitDelta 同一词条
@@ -738,7 +1088,7 @@ export function createStatGroup(): SomaComponentDefinition {
738
1088
  if (compareText !== '') {
739
1089
  const cmp = document.createElement('span');
740
1090
  cmp.className = COMPARE_CLASS;
741
- cmp.setAttribute('data-kit-stat-compare', '');
1091
+ cmp.setAttribute(KIT_ATTR_STAT_COMPARE, '');
742
1092
  cmp.textContent = compareText;
743
1093
  foot.appendChild(cmp);
744
1094
  }
@@ -753,7 +1103,8 @@ export function createStatGroup(): SomaComponentDefinition {
753
1103
  const retryBtn = document.createElement('button');
754
1104
  retryBtn.type = 'button';
755
1105
  retryBtn.className = KIT_STAT_RETRY_CLASS;
756
- retryBtn.setAttribute('data-kit-stat-retry', item.key);
1106
+ retryBtn.setAttribute(KIT_ATTR_STAT_RETRY, item.key);
1107
+ kitMarkPart(retryBtn, 'action');
757
1108
  retryBtn.setAttribute('aria-label', kitText('soma.kit.retry_of', { label: item.label }, rootEl));
758
1109
  retryBtn.textContent = kitText('soma.kit.stat_retry', undefined, rootEl);
759
1110
  foot.appendChild(retryBtn);
@@ -775,9 +1126,9 @@ export function createStatGroup(): SomaComponentDefinition {
775
1126
  const state = k.slice(0, k.indexOf('\u0000')) as Exclude<KitStatState, 'ready'>;
776
1127
  const note = document.createElement('p');
777
1128
  note.className = `m-0 ${kitStatGroupNoteClass(state)}`;
778
- note.setAttribute('data-kit-stat-note', state);
1129
+ note.setAttribute(KIT_ATTR_STAT_NOTE, state);
779
1130
  const text = document.createElement('span');
780
- text.setAttribute('data-kit-stat-reason', '');
1131
+ text.setAttribute(KIT_ATTR_STAT_REASON, '');
781
1132
  text.textContent = k.slice(k.indexOf('\u0000') + 1);
782
1133
  note.appendChild(text);
783
1134
  const retryItem = state === 'error' ? members.find((it) => it.retry !== '') : undefined;
@@ -786,7 +1137,8 @@ export function createStatGroup(): SomaComponentDefinition {
786
1137
  const btn = document.createElement('button');
787
1138
  btn.type = 'button';
788
1139
  btn.className = KIT_STAT_RETRY_CLASS;
789
- btn.setAttribute('data-kit-stat-retry', retryItem.key);
1140
+ btn.setAttribute(KIT_ATTR_STAT_RETRY, retryItem.key);
1141
+ kitMarkPart(btn, 'action');
790
1142
  btn.textContent = kitText('soma.kit.stat_retry', undefined, rootEl);
791
1143
  note.appendChild(btn);
792
1144
  }