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
@@ -8,9 +8,11 @@
8
8
  import type { SomaComponentDefinition } from 'soma-core';
9
9
  import { kitLocaleAt } from '../i18n/kit-text';
10
10
  import { createFormatter } from 'soma-foundation/values';
11
+ import { KIT_ATTR_ORIGINAL } from '../shared/dom-attrs';
11
12
  import {
12
13
  CLASS_PROP, ID_PROPS,
13
14
  applyCommon, classCandidates, createKitController, joinClass, num, str,
15
+ kitInlineRootAlign, kitMarkDataState, kitOuterRoot, kitReadProps,
14
16
  type KitSize,
15
17
  } from './shared';
16
18
 
@@ -18,21 +20,24 @@ const CURRENCY_CODE = /^[A-Za-z]{3}$/;
18
20
  const LOCALE_FALLBACK = 'zh-CN';
19
21
 
20
22
  const ROOT: Record<KitSize, string> = {
21
- sm: 'inline-flex items-baseline gap-1.5 text-sm',
22
- md: 'inline-flex items-baseline gap-2 text-base',
23
- lg: 'inline-flex items-baseline gap-2 text-xl',
23
+ sm: 'inline-flex items-baseline gap-1.5 text-sm tabular-nums',
24
+ md: 'inline-flex items-baseline gap-2 text-base tabular-nums',
25
+ lg: 'inline-flex items-baseline gap-2 text-xl tabular-nums',
24
26
  };
25
- const NOW: Record<'normal' | 'negative' | 'muted', string> = {
27
+ const NOW: Record<'normal' | 'negative' | 'muted' | 'empty', string> = {
26
28
  normal: 'font-semibold text-fg',
27
29
  negative: 'font-semibold text-danger-on-soft',
28
30
  muted: 'font-semibold text-fg-muted',
31
+ empty: 'font-normal text-fg-subtle',
29
32
  };
30
33
  const ORIGINAL = 'text-xs text-fg-subtle line-through';
31
34
  const HIDDEN = 'hidden';
35
+ const DEFAULT_PLACEHOLDER = '—';
32
36
 
33
37
  export const KIT_PRICE_TEXT_CLASS_CANDIDATES: readonly string[] = classCandidates(
34
38
  Object.values(ROOT), Object.values(NOW), ORIGINAL, HIDDEN,
35
39
  );
40
+ // 页面线对齐换上的块级根与自动外边距(kitInlineRootAlign)只在新模式下用到,由 data/kit-contract.ts#KIT_CONTRACT_CLASS_CANDIDATES 统一并入,不进本组件候选
36
41
 
37
42
  export interface PriceSpec {
38
43
  currency: string;
@@ -42,6 +47,27 @@ export interface PriceSpec {
42
47
  locale: string;
43
48
  }
44
49
 
50
+ type PriceFormatter = ReturnType<typeof createFormatter>;
51
+ const FORMATTER_CACHE = new Map<string, PriceFormatter>();
52
+ const FORMATTER_CACHE_MAX = 64;
53
+
54
+ function cachedPriceFormatter(spec: PriceSpec): PriceFormatter {
55
+ const digitsKey = spec.minFraction !== undefined || spec.maxFraction !== undefined
56
+ ? `${spec.minFraction ?? ''}:${spec.maxFraction ?? ''}`
57
+ : '';
58
+ const key = `${spec.locale}|${spec.currency}|${digitsKey}`;
59
+ let fmt = FORMATTER_CACHE.get(key);
60
+ if (!fmt) {
61
+ if (FORMATTER_CACHE.size >= FORMATTER_CACHE_MAX) {
62
+ const oldest = FORMATTER_CACHE.keys().next().value;
63
+ if (oldest !== undefined) FORMATTER_CACHE.delete(oldest);
64
+ }
65
+ fmt = createFormatter({ locale: spec.locale, fallbackLocale: LOCALE_FALLBACK, placeholder: DEFAULT_PLACEHOLDER, now: () => Date.now() });
66
+ FORMATTER_CACHE.set(key, fmt);
67
+ }
68
+ return fmt;
69
+ }
70
+
45
71
  function digitsOf(raw: unknown): number | undefined {
46
72
  const n = num(raw);
47
73
  return n !== null && n >= 0 && n <= 6 ? Math.floor(n) : undefined;
@@ -57,13 +83,14 @@ export function priceSpecOf(p: Record<string, unknown>): PriceSpec {
57
83
  };
58
84
  }
59
85
 
60
- /** 金额文字;值不是有限数字 -> placeholder(缺省 '-') */
61
- export function formatPrice(value: unknown, spec: PriceSpec, placeholder = '-'): string {
62
- if (value === null || value === undefined || value === '') return placeholder;
86
+ /** 金额文字;值不是有限数字 -> placeholder(缺省 '—') */
87
+ export function formatPrice(value: unknown, spec: PriceSpec, placeholder = DEFAULT_PLACEHOLDER): string {
88
+ if (value === null || value === undefined) return placeholder;
89
+ if (typeof value === 'string' && value.trim() === '') return placeholder;
63
90
  const n = typeof value === 'number' ? value : Number(value);
64
91
  if (!Number.isFinite(n)) return placeholder;
65
92
  try {
66
- const fmt = createFormatter({ locale: spec.locale, fallbackLocale: LOCALE_FALLBACK, placeholder, now: () => Date.now() });
93
+ const fmt = cachedPriceFormatter(spec);
67
94
  return fmt.currency(typeof value === 'string' ? value : n, {
68
95
  currency: spec.currency,
69
96
  ...(spec.minFraction !== undefined ? { minFraction: spec.minFraction } : {}),
@@ -86,7 +113,7 @@ export function createPriceText(): SomaComponentDefinition {
86
113
  digits: { type: 'string', default: '', desc: '固定小数位数 0..6;空为按币种默认' },
87
114
  locale: { type: 'string', default: '', desc: '格式化语言环境;缺省取页面语言(page.locale),都没声明为 zh-CN' },
88
115
  negative: { type: 'enum', values: ['danger', 'plain'], default: 'danger', desc: '负数:danger 着色 / plain 不着色' },
89
- placeholder: { type: 'string', default: '-', desc: '金额不可用时的占位' },
116
+ placeholder: { type: 'string', default: DEFAULT_PLACEHOLDER, desc: '金额不可用时的占位' },
90
117
  muted: { type: 'boolean', default: false, desc: '次要色(如已失效的价格)' },
91
118
  ...ID_PROPS,
92
119
  size: { type: 'enum', values: ['sm', 'md', 'lg'], default: 'md', desc: '字号档' },
@@ -97,30 +124,37 @@ export function createPriceText(): SomaComponentDefinition {
97
124
  templateHtml:
98
125
  `<span data-soma-id="root" class="${ROOT.md}">` +
99
126
  `<span data-soma-id="now" class="${NOW.normal}"></span><del data-soma-id="was" class="${HIDDEN}"></del></span>`,
127
+ // 金额是值:根只报元素部件,不报层级角色
100
128
  controllerFactory: createKitController(() => ({
101
- render(root, p) {
129
+ render(root, p, api) {
102
130
  const spec = priceSpecOf({ ...p, locale: str(p.locale, kitLocaleAt(root)) });
103
- const placeholder = str(p.placeholder, '-');
131
+ const placeholder = str(p.placeholder, DEFAULT_PLACEHOLDER);
104
132
  const now = root.querySelector<HTMLElement>('[data-soma-id="now"], [data-soma-scoped-id="now"]');
105
133
  const was = root.querySelector<HTMLElement>('[data-soma-id="was"], [data-soma-scoped-id="was"]');
106
134
  const n = num(p.value);
107
135
  if (now) {
108
136
  now.textContent = formatPrice(p.value, spec, placeholder);
109
- now.className = n !== null && n < 0 && str(p.negative, 'danger') !== 'plain'
110
- ? NOW.negative
111
- : p.muted === true || p.muted === 'true' ? NOW.muted : NOW.normal;
137
+ now.className = n === null
138
+ ? NOW.empty
139
+ : n < 0 && str(p.negative, 'danger') !== 'plain'
140
+ ? NOW.negative
141
+ : p.muted === true || p.muted === 'true' ? NOW.muted : NOW.normal;
112
142
  }
113
143
  if (was) {
114
144
  const hasOriginal = num(p.original) !== null;
115
145
  was.textContent = hasOriginal ? formatPrice(p.original, spec, placeholder) : '';
116
146
  was.className = hasOriginal ? ORIGINAL : HIDDEN;
117
147
  // 划线靠 <del> 语义之外的类实现;文字本身保持金额,读屏按顺序读出现价、原价
118
- was.setAttribute('data-kit-original', hasOriginal ? 'true' : 'false');
148
+ was.setAttribute(KIT_ATTR_ORIGINAL, hasOriginal ? 'true' : 'false');
119
149
  }
120
150
  applyCommon(root, { id: p.id, aria_label: p.aria_label });
121
151
  const sz = p.size === 'sm' || p.size === 'lg' ? p.size : 'md';
122
- root.className = joinClass(ROOT[sz], p.class);
152
+ // 逻辑对齐(页面线判定,如表格金额列靠止端):根是 inline-flex,文本对齐类对它自身无效,所以换成块级根 + 自动外边距真正移动位置
153
+ // (kitInlineRootAlign);p.class 已有对齐类时以自有类为准;没有判定时类串与原来一致
154
+ const align = kitReadProps(p).align;
155
+ root.className = joinClass(kitInlineRootAlign(ROOT[sz], align, p.class), p.class);
156
+ kitMarkDataState(kitOuterRoot(api.host, root), n === null ? 'empty' : 'normal');
123
157
  },
124
- })),
158
+ }), { self: { part: 'value' } }),
125
159
  };
126
160
  }
@@ -5,39 +5,56 @@
5
5
 
6
6
  import type { SomaComponentDefinition } from 'soma-core';
7
7
  import { kitText } from '../i18n/kit-text';
8
+ import { kitIcon } from '../shared/icons';
9
+ import { mergeClass } from '../shared/merge-class';
10
+ import { KIT_ATTR_MINI_BAR } from '../shared/dom-attrs';
11
+ import { KIT_CONTROL_TRACK_CLASS, kitToneFillClass, type KitSemanticOrCategoryTone } from '../recipes/color-role';
8
12
  import {
9
13
  CLASS_PROP, ID_PROPS, SIZE_PROP,
10
14
  classCandidates, createKitController, joinClass, num, setAttr, sizeOf, str,
15
+ kitReadProps, kitToneOfPipeline,
11
16
  type KitSize,
12
17
  } from './shared';
13
18
 
14
19
  export type ProgressShape = 'ring' | 'bar' | 'dots';
15
20
  export type ProgressTone = 'primary' | 'info' | 'success' | 'warning' | 'danger';
21
+ export type ProgressStatus = '' | 'complete' | 'exception';
16
22
 
17
23
  const RING_ROOT: Record<KitSize, string> = {
18
24
  sm: 'relative inline-flex h-10 w-10 shrink-0 items-center justify-center',
19
- md: 'relative inline-flex h-14 w-14 shrink-0 items-center justify-center',
20
- lg: 'relative inline-flex h-20 w-20 shrink-0 items-center justify-center',
25
+ // 取值表 02 §6(Ant progress/utils):环直径 小 60 / 大 120(随 density 比例);环内文字 20 / 500
26
+ md: 'relative inline-flex h-15 w-15 shrink-0 items-center justify-center',
27
+ lg: 'relative inline-flex h-30 w-30 shrink-0 items-center justify-center',
21
28
  };
22
29
  const RING_TEXT: Record<KitSize, string> = {
23
- sm: 'absolute text-xs font-medium text-fg',
24
- md: 'absolute text-sm font-medium text-fg',
25
- lg: 'absolute text-lg font-medium text-fg',
30
+ sm: 'absolute text-xs font-medium tabular-nums text-fg',
31
+ md: 'absolute text-sm font-medium tabular-nums text-fg',
32
+ lg: 'absolute text-xl font-medium tabular-nums text-fg',
26
33
  };
27
34
  const BAR_ROOT = 'flex w-full items-center gap-2';
35
+ // 条文字 12 / 次要色(取值表 02 §6:Arco 12 / Ant 14);条高 小 4 / 缺省 6 / 大 8(Ant 8 / TDesign 6)
28
36
  const BAR_TEXT: Record<KitSize, string> = {
29
- sm: 'shrink-0 text-xs font-medium text-fg-muted',
30
- md: 'shrink-0 text-sm font-medium text-fg-muted',
31
- lg: 'shrink-0 text-base font-medium text-fg-muted',
37
+ // 等宽数字 + 最小宽 + 右对齐:百分比跳动时条不抖(组件卡 Progress §6)
38
+ sm: 'min-w-10 shrink-0 text-end text-xs font-medium tabular-nums text-fg-muted',
39
+ md: 'min-w-10 shrink-0 text-end text-xs font-medium tabular-nums text-fg-muted',
40
+ lg: 'min-w-12 shrink-0 text-end text-sm font-medium tabular-nums text-fg-muted',
32
41
  };
42
+ // 末端状态图标(成功 / 异常):条文字位换成语气色图标,环中心文字位换成图标;与文字同占一格
43
+ const STATUS_ICON: Record<'success' | 'danger', string> = {
44
+ success: 'shrink-0 text-success',
45
+ danger: 'shrink-0 text-danger',
46
+ };
47
+ const BAR_STATUS_ICON_WRAP = 'inline-flex min-w-10 shrink-0 items-center justify-end';
48
+ const RING_STATUS_ICON_WRAP = 'absolute inline-flex items-center justify-center';
33
49
  const RING_SVG = 'h-full w-full';
34
50
  const BAR_SVG: Record<KitSize, string> = {
35
51
  sm: 'block h-1 w-full overflow-hidden rounded-full',
36
52
  md: 'block h-1.5 w-full overflow-hidden rounded-full',
37
- lg: 'block h-2.5 w-full overflow-hidden rounded-full',
53
+ lg: 'block h-2 w-full overflow-hidden rounded-full',
38
54
  };
39
- const TRACK_RING = 'fill-none stroke-border-subtle';
40
- const TRACK_BAR = 'fill-border-subtle';
55
+ // 轨 = 宿主自适应控件滑轨色(放在凹槽井或子块内仍具清晰层次),不用边线令牌
56
+ const TRACK_RING = 'fill-none stroke-control-track';
57
+ const TRACK_BAR = mergeClass('fill-control-track', KIT_CONTROL_TRACK_CLASS);
41
58
  const ARC: Record<ProgressTone, string> = {
42
59
  primary: 'fill-none stroke-primary',
43
60
  info: 'fill-none stroke-info',
@@ -86,12 +103,37 @@ const DOT_GAP: Record<KitSize, number> = { sm: 12, md: 16, lg: 20 };
86
103
  const DOT_RADIUS: Record<KitSize, number> = { sm: 3, md: 4, lg: 5 };
87
104
  const SVG_NS = 'http://www.w3.org/2000/svg';
88
105
 
106
+ const MINI_BAR_TONES: readonly KitSemanticOrCategoryTone[] = Object.freeze([
107
+ 'primary', 'info', 'success', 'warning', 'danger', 'neutral', 'tertiary', 'second',
108
+ 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8',
109
+ ]);
110
+
89
111
  export const KIT_PROGRESS_CLASS_CANDIDATES: readonly string[] = classCandidates(
90
112
  Object.values(RING_ROOT), Object.values(RING_TEXT), BAR_ROOT, Object.values(BAR_TEXT), RING_SVG,
91
- Object.values(BAR_SVG), TRACK_RING, TRACK_BAR, Object.values(ARC), Object.values(FILL), HIDDEN,
113
+ Object.values(BAR_SVG), TRACK_RING, TRACK_BAR, Object.values(ARC), Object.values(FILL),
114
+ MINI_BAR_TONES.map((t) => kitToneFillClass(t)), HIDDEN,
92
115
  Object.values(BUFFER), Object.values(FILL_INDET), Object.values(ARC_INDET), DOTS_SVG, DOTS_SVG_INDET,
116
+ Object.values(STATUS_ICON), BAR_STATUS_ICON_WRAP, RING_STATUS_ICON_WRAP,
93
117
  );
94
118
 
119
+ /**
120
+ * 迷你条(指标配套元素,DC2 一层缺省:单位为 % 的比率在数值下出一根细条,自然上限 100):与条形进度同一组形体类(sm 轨道 + 填充),
121
+ * 只画图形、不带文字与 role(数值已在旁边读出,条是 aria-hidden 的冗余编码)。tone 支持语义色与分类色 c1..c8,缺省主色。
122
+ */
123
+ export function kitMiniBarNode(doc: Document, percent: number, tone: ProgressTone | KitSemanticOrCategoryTone = 'primary'): SVGSVGElement {
124
+ const svg = doc.createElementNS(SVG_NS, 'svg');
125
+ svg.setAttribute('aria-hidden', 'true');
126
+ svg.setAttribute('class', BAR_SVG.sm);
127
+ svg.setAttribute(KIT_ATTR_MINI_BAR, '');
128
+ const rect = (width: string, cls: string): SVGRectElement => {
129
+ const r = doc.createElementNS(SVG_NS, 'rect');
130
+ for (const [k, v] of [['x', '0'], ['y', '0'], ['width', width], ['height', '100%'], ['ry', '50%'], ['class', cls]] as const) r.setAttribute(k, v);
131
+ return r;
132
+ };
133
+ svg.append(rect('100%', TRACK_BAR), rect(`${clampPercent(percent)}%`, kitToneFillClass(tone)));
134
+ return svg;
135
+ }
136
+
95
137
  export function clampPercent(raw: unknown): number {
96
138
  const n = num(raw);
97
139
  if (n === null) return 0;
@@ -115,6 +157,10 @@ function indeterminateOf(raw: unknown): boolean {
115
157
  return raw === true || raw === 'true';
116
158
  }
117
159
 
160
+ function statusOf(raw: unknown): ProgressStatus {
161
+ return raw === 'complete' || raw === 'exception' ? raw : '';
162
+ }
163
+
118
164
  export function createKitProgress(): SomaComponentDefinition {
119
165
  return {
120
166
  contract: {
@@ -126,7 +172,8 @@ export function createKitProgress(): SomaComponentDefinition {
126
172
  indeterminate: { type: 'boolean', default: false, desc: '不确定态(不知道进度多少):条形一段色块来回扫、环形一段弧呼吸、点阵整体呼吸;减少动效下静止;不带 aria-valuenow,文字只显示 label' },
127
173
  buffer: { type: 'string', default: '', desc: '缓冲进度 0~100(条形:画在进度段之下的淡色段,如视频已缓冲);空 = 不画' },
128
174
  tone: { type: 'enum', values: ['primary', 'info', 'success', 'warning', 'danger'], default: 'primary', desc: '进度色' },
129
- show_text: { type: 'boolean', default: true, desc: '显示百分比文字' },
175
+ status: { type: 'enum', values: ['', 'complete', 'exception'], default: '', desc: '末端状态:显式指定 complete / exception(或满 100 且 tone=success)时将右侧百分比换成完成/异常图标' },
176
+ show_text: { type: 'boolean', default: true, desc: '显示百分比文字或末端状态图标' },
130
177
  label: { type: 'string', default: '', desc: '自定义文字,非空时替代百分比' },
131
178
  id: ID_PROPS.id,
132
179
  aria_label: ID_PROPS.aria_label,
@@ -141,7 +188,9 @@ export function createKitProgress(): SomaComponentDefinition {
141
188
  const value = clampPercent(p.value);
142
189
  const shape = shapeOf(p.shape);
143
190
  const size = sizeOf(p.size);
144
- const tone = toneOf(p.tone);
191
+ // 进度色:组件自己写了非缺省(primary 是契约缺省)的 tone 优先,否则取页面线的语义色调(中性 / 无不改色)
192
+ const kitTone = kitToneOfPipeline(kitReadProps(p).tone);
193
+ const tone = toneOf(p.tone !== 'primary' && str(p.tone) !== '' ? p.tone : kitTone ?? p.tone);
145
194
  const [ring, bar, dots, text] = Array.from(root.children) as [SVGElement, SVGElement, SVGElement, HTMLElement];
146
195
  const isRing = shape === 'ring';
147
196
  const isBar = shape === 'bar';
@@ -196,9 +245,41 @@ export function createKitProgress(): SomaComponentDefinition {
196
245
  dots.textContent = '';
197
246
  }
198
247
  const custom = str(p.label);
199
- const showText = custom !== '' || (!indeterminate && p.show_text !== false && p.show_text !== 'false');
200
- text.textContent = custom !== '' ? custom : `${Math.round(value)}%`;
201
- text.className = !showText ? HIDDEN : isRing ? RING_TEXT[size] : BAR_TEXT[size];
248
+ const allowRightSlot = p.show_text !== false && p.show_text !== 'false';
249
+ const explicitStatus = statusOf(p.status);
250
+ const statusIconTone: 'success' | 'danger' | null = !indeterminate && shape !== 'dots' && custom === ''
251
+ ? (explicitStatus === 'complete'
252
+ ? 'success'
253
+ : explicitStatus === 'exception'
254
+ ? 'danger'
255
+ : value >= 100 && tone === 'success'
256
+ ? 'success'
257
+ : null)
258
+ : null;
259
+ const dataState = !indeterminate
260
+ ? (explicitStatus === 'exception' || tone === 'danger'
261
+ ? 'exception'
262
+ : explicitStatus === 'complete' || value >= 100
263
+ ? 'complete'
264
+ : null)
265
+ : null;
266
+ if (!allowRightSlot) {
267
+ text.replaceChildren();
268
+ text.className = HIDDEN;
269
+ root.removeAttribute('aria-valuetext');
270
+ } else if (statusIconTone !== null) {
271
+ text.replaceChildren(kitIcon(statusIconTone === 'success' ? 'check' : 'close', isRing ? (size === 'sm' ? 'sm' : 'lg') : 'sm', STATUS_ICON[statusIconTone]));
272
+ text.className = isRing ? RING_STATUS_ICON_WRAP : BAR_STATUS_ICON_WRAP;
273
+ // 图标不进读屏文字,状态由 aria-valuetext 给
274
+ root.setAttribute('aria-valuetext', `${Math.round(value)}%`);
275
+ } else {
276
+ const showText = custom !== '' || !indeterminate;
277
+ text.textContent = custom !== '' ? custom : `${Math.round(value)}%`;
278
+ text.className = !showText ? HIDDEN : isRing ? RING_TEXT[size] : BAR_TEXT[size];
279
+ root.removeAttribute('aria-valuetext');
280
+ }
281
+ if (dataState !== null) root.setAttribute('data-state', dataState);
282
+ else root.removeAttribute('data-state');
202
283
  root.setAttribute('role', 'progressbar');
203
284
  root.setAttribute('aria-valuemin', '0');
204
285
  root.setAttribute('aria-valuemax', '100');
@@ -211,6 +292,7 @@ export function createKitProgress(): SomaComponentDefinition {
211
292
  if (indeterminate) root.setAttribute('aria-busy', 'true'); else root.removeAttribute('aria-busy');
212
293
  root.className = joinClass(isRing ? RING_ROOT[size] : BAR_ROOT, p.class);
213
294
  },
214
- })),
295
+ // 进度是指标:根只报元素部件
296
+ }), { self: { part: 'metric' } }),
215
297
  };
216
298
  }
@@ -3,32 +3,53 @@
3
3
  // 归类(2.1a 四问):单值展示(文本 -> 图形),没有对象形状 -> 基础组件。不引入第三方库:最小的 QR Code Model 2 编码器在本文件
4
4
  // (字节模式、UTF-8、版本 1–10、纠错 L / M / Q / H、8 种掩码按罚分自动择优),做法与公开的 QR 规范(ISO/IEC 18004)一致;
5
5
  // 不支持数字 / 字母数字 / 汉字模式与版本 11 以上(容量:纠错 M 约 213 字节,L 约 271 字节),超出时不画并抛 `error { reason: 'too-long' }`。
6
- // 输出是 SVG:背景一个 rect,暗模块按行合并成横向长条 rect,颜色走 `fill-fg` / `fill-surface` 类(跟随主题;深色主题下是浅码深底,
7
- // 个别老扫码器不认反色,要打印请用浅色主题)。四周静区 `quiet` 默认 4 个模块(规范值)。读屏读 `label`(缺省「二维码」),不朗读矩阵。
6
+ // 输出是 SVG:背景一个 rect,暗模块按行合并成横向长条 rect,颜色走 `fill-static-black` / `fill-static-white` 物理恒量类(暗色模式下绝不翻转,
7
+ // 保障光学扫码器在亮/暗任意宿主下 100% 可靠识别)。四周静区 `quiet` 默认 4 个模块(规范值)。读屏读 `label`(缺省「二维码」),不朗读矩阵。
8
8
  // 值是纯字符串,不进样式;组件不联网、不做 URL 校验。
9
9
 
10
10
  import type { SomaComponentDefinition } from 'soma-core';
11
- import { kitText } from '../i18n/kit-text';
11
+ import { kitLocaleAt, kitText, kitTextLocaleOf } from '../i18n/kit-text';
12
+ import { KIT_STATIC_QR_INK_CLASS, KIT_STATIC_QR_SURFACE_CLASS } from '../recipes/color-role';
13
+ import { kitWellRecipe } from '../recipes/surface';
14
+ import { kitTypographyRecipe, KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES } from '../recipes/typography';
15
+ import { KIT_ICON_CLASS_CANDIDATES, kitIcon } from '../shared/icons';
16
+ import { mergeClass } from '../shared/merge-class';
17
+ import { KIT_ATTR_STATE } from '../shared/dom-attrs';
12
18
  import {
13
19
  CLASS_PROP, ID_PROPS, classCandidates,
14
20
  createKitController, joinClass, num, setAttr, str,
21
+ kitMarkDataState, kitOuterRoot,
15
22
  } from './shared';
16
23
 
17
24
  // ---- Tailwind 类常量与候选类清单 ----
18
25
 
26
+ const SIZE_BOX = {
27
+ sm: 'h-28 w-28 shrink-0',
28
+ md: 'h-40 w-40 shrink-0',
29
+ lg: 'h-56 w-56 shrink-0',
30
+ } as const;
31
+ // 高对比静态白底静区:暗色主题下二维码外缘与静区恒保持白底黑码,防止反色或贴暗边扫不出
19
32
  const SIZE_CLASS = {
20
- sm: 'block h-28 w-28 shrink-0',
21
- md: 'block h-40 w-40 shrink-0',
22
- lg: 'block h-56 w-56 shrink-0',
33
+ sm: `block ${SIZE_BOX.sm} rounded-item bg-static-white p-1`,
34
+ md: `block ${SIZE_BOX.md} rounded-item bg-static-white p-1.5`,
35
+ lg: `block ${SIZE_BOX.lg} rounded-item bg-static-white p-2`,
36
+ } as const;
37
+ const TOO_LONG_BASE = mergeClass(mergeClass('inline-flex flex-col items-center justify-center gap-1 overflow-hidden rounded-control p-2 text-center', kitWellRecipe()), kitTypographyRecipe('caption'));
38
+ const TOO_LONG_ICON_CLASS = 'shrink-0 text-warning-on-soft';
39
+ const TOO_LONG_TEXT_CLASS = 'max-w-full break-words';
40
+ const QR_TOO_LONG_TEXT = {
41
+ 'zh-CN': '内容超出二维码容量上限',
42
+ en: 'Content exceeds QR capacity',
23
43
  } as const;
24
- const BG_CLASS = 'fill-surface';
25
- const DARK_CLASS = 'fill-fg';
44
+ const BG_CLASS = KIT_STATIC_QR_SURFACE_CLASS;
45
+ const DARK_CLASS = KIT_STATIC_QR_INK_CLASS;
26
46
  const SVG_CLASS = 'block h-full w-full';
27
47
  const HIDDEN = 'hidden';
28
48
  const SVG_NS = 'http://www.w3.org/2000/svg';
29
49
 
30
50
  export const KIT_QR_CODE_CLASS_CANDIDATES: readonly string[] = classCandidates(
31
- Object.values(SIZE_CLASS), BG_CLASS, DARK_CLASS, SVG_CLASS, HIDDEN,
51
+ Object.values(SIZE_BOX), Object.values(SIZE_CLASS), TOO_LONG_BASE, TOO_LONG_ICON_CLASS, TOO_LONG_TEXT_CLASS,
52
+ BG_CLASS, DARK_CLASS, SVG_CLASS, HIDDEN, KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES, KIT_ICON_CLASS_CANDIDATES,
32
53
  );
33
54
 
34
55
  // ---- 纯 TS 编码器(QR Code Model 2,字节模式、UTF-8、版本 1–10、纠错 L / M / Q / H、8 种掩码按罚分择优)与矩阵合并 ----
@@ -395,24 +416,49 @@ export function createQrCode(): SomaComponentDefinition {
395
416
  const quiet = rawQuiet !== null && rawQuiet >= 0 && rawQuiet <= 8 ? Math.floor(rawQuiet) : 4;
396
417
  const size = p.size === 'sm' || p.size === 'lg' ? p.size : 'md';
397
418
  const matrix = qrMatrix(text, ecc);
419
+ const ariaLabel = str(p.aria_label) !== ''
420
+ ? str(p.aria_label)
421
+ : str(p.label) !== ''
422
+ ? str(p.label)
423
+ : kitText('soma.kit.qr_label', undefined, root);
398
424
  const key = `${text}\u0000${ecc}\u0000${quiet}`;
399
425
  setAttr(root, 'id', str(p.id));
400
426
  if (matrix === null) {
401
- root.textContent = '';
402
427
  lastKey = '';
403
- root.className = HIDDEN;
404
- root.setAttribute('data-kit-state', text === '' ? 'empty' : 'too-long');
405
- if (text !== '' && lastError !== text) {
428
+ if (text === '') {
429
+ root.textContent = '';
430
+ root.removeAttribute('role');
431
+ root.removeAttribute('aria-label');
432
+ root.className = HIDDEN;
433
+ root.setAttribute(KIT_ATTR_STATE, 'empty');
434
+ kitMarkDataState(kitOuterRoot(api.host, root), 'empty');
435
+ return;
436
+ }
437
+ root.setAttribute(KIT_ATTR_STATE, 'too-long');
438
+ // 文本装不下 = 生成失败:组件根报「加载出错」(data-kit-state 是本组件原有的细分标记,保留)
439
+ kitMarkDataState(kitOuterRoot(api.host, root), 'error');
440
+ root.setAttribute('role', 'status');
441
+ root.className = joinClass(mergeClass(TOO_LONG_BASE, SIZE_BOX[size]), p.class);
442
+ const declared = kitLocaleAt(root);
443
+ const col = kitTextLocaleOf(declared) ?? (declared.trim() === '' ? 'zh-CN' : 'en');
444
+ const notice = document.createElement('span');
445
+ notice.className = TOO_LONG_TEXT_CLASS;
446
+ notice.textContent = QR_TOO_LONG_TEXT[col];
447
+ root.replaceChildren(kitIcon('warning', 'sm', TOO_LONG_ICON_CLASS), notice);
448
+ if (lastError !== text) {
406
449
  lastError = text;
407
450
  api.emit('error', { reason: 'too-long' });
408
451
  }
409
452
  return;
410
453
  }
411
454
  lastError = '';
412
- root.removeAttribute('data-kit-state');
455
+ root.removeAttribute(KIT_ATTR_STATE);
456
+ kitMarkDataState(kitOuterRoot(api.host, root), 'normal');
457
+ root.removeAttribute('role');
458
+ root.removeAttribute('aria-label');
413
459
  root.className = joinClass(SIZE_CLASS[size], p.class);
414
460
  if (key === lastKey && root.firstElementChild) {
415
- root.firstElementChild.setAttribute('aria-label', str(p.label, kitText('soma.kit.qr_label', undefined, root)));
461
+ root.firstElementChild.setAttribute('aria-label', ariaLabel);
416
462
  return;
417
463
  }
418
464
  lastKey = key;
@@ -421,7 +467,7 @@ export function createQrCode(): SomaComponentDefinition {
421
467
  svg.setAttribute('viewBox', `0 0 ${n} ${n}`);
422
468
  svg.setAttribute('class', SVG_CLASS);
423
469
  svg.setAttribute('role', 'img');
424
- svg.setAttribute('aria-label', str(p.label, kitText('soma.kit.qr_label', undefined, root)));
470
+ svg.setAttribute('aria-label', ariaLabel);
425
471
  svg.setAttribute('shape-rendering', 'crispEdges');
426
472
  const bg = document.createElementNS(SVG_NS, 'rect');
427
473
  bg.setAttribute('width', String(n));
@@ -441,6 +487,7 @@ export function createQrCode(): SomaComponentDefinition {
441
487
  root.appendChild(svg);
442
488
  },
443
489
  };
444
- }),
490
+ // 二维码是值(链接 / 编码的图形呈现):根只报元素部件
491
+ }, { self: { part: 'value' } }),
445
492
  };
446
493
  }