soma-kit 0.1.14 → 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 (505) 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/finance/reconcile-desk/compile.ts +1 -1
  5. package/packs/finance/reconcile-desk/shell.ts +1 -1
  6. package/packs/ops/error-budget-card.ts +3 -3
  7. package/packs/ops/release-readiness-card.ts +3 -3
  8. package/packs/security/control-evidence-card.ts +3 -3
  9. package/packs/security/finding-card.ts +3 -2
  10. package/packs/shared/card-util.ts +17 -0
  11. package/spec/generated/kit-app.schema.json +2148 -338
  12. package/spec/generated/kit-page.schema.json +1152 -87
  13. package/spec/kit-grammar.json +1084 -136
  14. package/spec/kit-grammar.schema.json +167 -26
  15. package/src/app/app-config.ts +220 -187
  16. package/src/app/component-gate.ts +2 -2
  17. package/src/app/compose-apps.ts +5 -2
  18. package/src/app/define-kit-actions.ts +200 -22
  19. package/src/app/define-kit-app.ts +54 -8
  20. package/src/app/define-kit-view.ts +1 -1
  21. package/src/app/index.ts +12 -7
  22. package/src/app/kit-view-context.ts +50 -3
  23. package/src/app/list-page-defaults.ts +14 -0
  24. package/src/app/server-pages.ts +239 -7
  25. package/src/app/server.ts +466 -25
  26. package/src/app/theme-endpoint.ts +68 -24
  27. package/src/app/theme-runtime.ts +421 -87
  28. package/src/app/theme-shards.ts +69 -0
  29. package/src/app/tier-compat.ts +107 -0
  30. package/src/base/action-busy.ts +215 -38
  31. package/src/base/affix.ts +137 -0
  32. package/src/base/alert.ts +107 -59
  33. package/src/base/anchored-layer.ts +8 -7
  34. package/src/base/avatar.ts +147 -61
  35. package/src/base/badge.ts +186 -0
  36. package/src/base/button-group.ts +227 -0
  37. package/src/base/button.ts +365 -53
  38. package/src/base/card.ts +233 -0
  39. package/src/base/cascader.ts +147 -32
  40. package/src/base/check-core.ts +196 -33
  41. package/src/base/checkbox.ts +67 -2
  42. package/src/base/choice.ts +132 -31
  43. package/src/base/collapse.ts +249 -0
  44. package/src/base/color-picker.ts +404 -28
  45. package/src/base/combobox.ts +6 -2
  46. package/src/base/command-palette.ts +155 -37
  47. package/src/base/context-menu.ts +26 -6
  48. package/src/base/countdown.ts +37 -15
  49. package/src/base/date-range.ts +115 -94
  50. package/src/base/date.ts +487 -76
  51. package/src/base/delta.ts +20 -11
  52. package/src/base/divider.ts +64 -97
  53. package/src/base/end-edge.ts +10 -4
  54. package/src/base/fab.ts +64 -23
  55. package/src/base/gap-value.ts +35 -16
  56. package/src/base/hint-tips.ts +100 -30
  57. package/src/base/identity-cells.ts +839 -0
  58. package/src/base/illustrations.ts +6 -4
  59. package/src/base/image.ts +40 -19
  60. package/src/base/index.ts +92 -24
  61. package/src/base/inline-error.ts +90 -0
  62. package/src/base/input.ts +174 -38
  63. package/src/base/kbd.ts +31 -17
  64. package/src/base/kit-contract.ts +400 -0
  65. package/src/base/link.ts +41 -20
  66. package/src/base/listbox-core.ts +324 -95
  67. package/src/base/loading-gate.ts +3 -0
  68. package/src/base/look.ts +197 -0
  69. package/src/base/mentions.ts +58 -22
  70. package/src/base/menu-button.ts +129 -42
  71. package/src/base/menu-core.ts +210 -26
  72. package/src/base/month-grid.ts +60 -3
  73. package/src/base/motion/aura.ts +52 -10
  74. package/src/base/motion/hover-3d.ts +10 -5
  75. package/src/base/motion/hover-gallery.ts +19 -12
  76. package/src/base/motion/limits.ts +10 -0
  77. package/src/base/motion/marquee.ts +18 -11
  78. package/src/base/motion/text-rotate.ts +34 -16
  79. package/src/base/notification.ts +292 -0
  80. package/src/base/number.ts +93 -12
  81. package/src/base/otp.ts +143 -27
  82. package/src/base/overlay-runtime.ts +32 -24
  83. package/src/base/overlay-shell.ts +186 -0
  84. package/src/base/period-picker.ts +868 -0
  85. package/src/base/popover.ts +625 -74
  86. package/src/base/popup.ts +219 -78
  87. package/src/base/portal-core.ts +99 -2
  88. package/src/base/price-text.ts +51 -17
  89. package/src/base/progress.ts +100 -18
  90. package/src/base/qr-code.ts +64 -17
  91. package/src/base/qty-stepper.ts +145 -21
  92. package/src/base/radio.ts +43 -2
  93. package/src/base/range.ts +194 -39
  94. package/src/base/rating.ts +117 -31
  95. package/src/base/reason-tip.ts +60 -18
  96. package/src/base/relation-cells.ts +541 -0
  97. package/src/{frames → base}/resize-handle.ts +6 -4
  98. package/src/base/row-fresh.ts +84 -0
  99. package/src/base/section-spy.ts +79 -0
  100. package/src/base/segmented.ts +99 -56
  101. package/src/base/select.ts +8 -2
  102. package/src/base/shared.ts +520 -73
  103. package/src/base/spinner.ts +107 -0
  104. package/src/base/state-panel.ts +77 -22
  105. package/src/base/status-tone.ts +1 -1
  106. package/src/base/sticky-edge.ts +96 -29
  107. package/src/base/swap.ts +39 -21
  108. package/src/base/switch.ts +158 -38
  109. package/src/base/tabs.ts +292 -0
  110. package/src/base/tag-input.ts +129 -55
  111. package/src/base/tag.ts +203 -91
  112. package/src/base/text.ts +491 -77
  113. package/src/base/textarea.ts +89 -40
  114. package/src/base/time-picker.ts +341 -57
  115. package/src/base/time-range.ts +846 -0
  116. package/src/base/tree-select.ts +346 -89
  117. package/src/base/upload.ts +612 -158
  118. package/src/base/view-transition.ts +7 -3
  119. package/src/base/virtual-list.ts +49 -14
  120. package/src/biz/approval-desk/compile.ts +98 -6
  121. package/src/biz/approval-desk/index.ts +2 -0
  122. package/src/biz/approval-desk/shell.ts +53 -13
  123. package/src/biz/auth-panel/compile.ts +14 -4
  124. package/src/biz/auth-panel/shell.ts +28 -8
  125. package/src/biz/category-crud/compile.ts +64 -13
  126. package/src/biz/category-crud/index.ts +2 -0
  127. package/src/biz/category-crud/shell.ts +30 -8
  128. package/src/biz/checkout-page/compile.ts +38 -4
  129. package/src/biz/checkout-page/index.ts +1 -0
  130. package/src/biz/checkout-page/shell.ts +28 -10
  131. package/src/biz/compose.ts +9 -4
  132. package/src/biz/data-components.ts +2 -0
  133. package/src/biz/define.ts +1 -1
  134. package/src/biz/import-wizard/compile.ts +5 -2
  135. package/src/biz/import-wizard/index.ts +1 -0
  136. package/src/biz/import-wizard/shell.ts +36 -20
  137. package/src/biz/index.ts +5 -4
  138. package/src/biz/landing-page/compile.ts +4 -3
  139. package/src/biz/landing-page/shell.ts +25 -5
  140. package/src/biz/layout-contracts.ts +918 -0
  141. package/src/biz/link/hub.ts +199 -8
  142. package/src/biz/link/shared.ts +62 -16
  143. package/src/biz/master-sub/compile.ts +318 -38
  144. package/src/biz/master-sub/detail-head.ts +145 -21
  145. package/src/biz/master-sub/index.ts +6 -3
  146. package/src/biz/master-sub/shell.ts +232 -66
  147. package/src/biz/multi-board/compile.ts +89 -38
  148. package/src/biz/multi-board/composition.ts +7 -20
  149. package/src/biz/multi-board/index.ts +25 -9
  150. package/src/biz/multi-board/prose-fold.ts +17 -13
  151. package/src/biz/multi-board/shell.ts +153 -38
  152. package/src/biz/names.ts +1 -0
  153. package/src/biz/notification-center/compile.ts +28 -7
  154. package/src/biz/notification-center/index.ts +2 -0
  155. package/src/biz/notification-center/shell.ts +51 -11
  156. package/src/biz/page-templates/domain-templates.ts +147 -20
  157. package/src/biz/page-templates/result-page/compile.ts +5 -2
  158. package/src/biz/page-templates/result-page/index.ts +1 -0
  159. package/src/biz/page-templates/result-page/shell.ts +20 -6
  160. package/src/biz/page-templates/shared.ts +1 -1
  161. package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
  162. package/src/biz/page-templates/sign-in-page/index.ts +1 -0
  163. package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
  164. package/src/biz/record-detail/compile.ts +43 -12
  165. package/src/biz/record-detail/index.ts +1 -0
  166. package/src/biz/record-detail/shell.ts +42 -11
  167. package/src/biz/settings-center/compile.ts +5 -2
  168. package/src/biz/settings-center/index.ts +1 -0
  169. package/src/biz/settings-center/shell.ts +33 -9
  170. package/src/biz/shared/action-host.ts +146 -48
  171. package/src/biz/shared/compile-helpers.ts +134 -32
  172. package/src/biz/shared/coordinator.ts +727 -163
  173. package/src/biz/shared/focus-return.ts +180 -0
  174. package/src/biz/shared/object-aliases.ts +7 -1
  175. package/src/biz/shared/overlay-compile.ts +102 -24
  176. package/src/biz/shared/overlay-shell.ts +97 -116
  177. package/src/biz/shared/page-form-actions.ts +151 -0
  178. package/src/biz/shared/page-form.ts +255 -0
  179. package/src/biz/shared/pipeline.ts +74 -0
  180. package/src/biz/shared/runtime-hub.ts +101 -8
  181. package/src/biz/shared/verbs.ts +129 -0
  182. package/src/biz/single-form/compile.ts +6 -4
  183. package/src/biz/single-form/index.ts +2 -0
  184. package/src/biz/single-form/shell.ts +22 -8
  185. package/src/biz/standard-crud/compile.ts +213 -38
  186. package/src/biz/standard-crud/index.ts +2 -1
  187. package/src/biz/standard-crud/shell.ts +90 -13
  188. package/src/biz/standard-crud/summary.ts +2 -35
  189. package/src/biz/step-form/compile.ts +13 -4
  190. package/src/biz/step-form/hub.ts +168 -49
  191. package/src/biz/step-form/index.ts +1 -0
  192. package/src/biz/step-form/shell.ts +35 -17
  193. package/src/biz/types.ts +49 -6
  194. package/src/cli/app-layer-check.ts +375 -0
  195. package/src/cli/kit-cli.ts +179 -33
  196. package/src/cli/kit-init.ts +152 -3
  197. package/src/cli/migrate/theme-map.ts +35 -28
  198. package/src/cli/migrate/ts-rules.ts +2 -2
  199. package/src/cli/migrate/types.ts +3 -3
  200. package/src/cli/migrate/yaml-rules.ts +11 -9
  201. package/src/cli/view-writes.ts +13 -0
  202. package/src/compile/access-gate-attach.ts +1 -1
  203. package/src/compile/action-host-attach.ts +1 -1
  204. package/src/compile/closed-set.ts +102 -6
  205. package/src/compile/compile-page.ts +461 -273
  206. package/src/compile/component-candidates.ts +58 -5
  207. package/src/compile/danger-tier.ts +65 -0
  208. package/src/compile/hints.ts +6 -59
  209. package/src/compile/index.ts +2 -2
  210. package/src/compile/info-structure.ts +155 -0
  211. package/src/compile/layout-lint/index.ts +4 -1
  212. package/src/compile/layout-lint/rules-composition.ts +44 -13
  213. package/src/compile/layout-lint/rules-table.ts +4 -19
  214. package/src/compile/look-page.ts +551 -0
  215. package/src/compile/look.ts +376 -0
  216. package/src/compile/page-composition.ts +405 -67
  217. package/src/compile/page-hierarchy.ts +131 -0
  218. package/src/compile/page-pipeline-look.ts +156 -0
  219. package/src/compile/page-pipeline.ts +200 -0
  220. package/src/compile/parse.ts +12 -11
  221. package/src/compile/redirect.ts +1 -1
  222. package/src/compile/relation-render.ts +120 -0
  223. package/src/compile/remove-guard.ts +115 -41
  224. package/src/compile/stages.ts +786 -0
  225. package/src/compile/styles.ts +286 -48
  226. package/src/compile/types.ts +63 -6
  227. package/src/compile/view-check.ts +190 -1
  228. package/src/data/access-gate.ts +17 -9
  229. package/src/data/amount-breakdown.ts +52 -23
  230. package/src/data/anchor-nav.ts +77 -16
  231. package/src/data/approval-flow.ts +217 -126
  232. package/src/data/assignment-picker.ts +182 -94
  233. package/src/data/async-result-panel.ts +114 -46
  234. package/src/data/audit-log.ts +461 -0
  235. package/src/data/breadcrumbs.ts +150 -24
  236. package/src/data/calendar.ts +436 -97
  237. package/src/data/card-grid.ts +319 -0
  238. package/src/data/carousel.ts +81 -41
  239. package/src/data/cell-value.ts +253 -0
  240. package/src/data/chart.ts +1053 -96
  241. package/src/data/checklist.ts +82 -38
  242. package/src/data/code-view.ts +296 -44
  243. package/src/data/comment-thread.ts +611 -86
  244. package/src/data/compare-view.ts +227 -0
  245. package/src/data/confirm-dialog.ts +250 -39
  246. package/src/data/context-menu.ts +95 -21
  247. package/src/data/d9-limits.ts +2 -0
  248. package/src/data/d9-util.ts +13 -5
  249. package/src/data/diff.ts +109 -49
  250. package/src/data/display-util.ts +9 -4
  251. package/src/data/dock.ts +38 -18
  252. package/src/data/embed.ts +143 -8
  253. package/src/data/engine-ports.ts +135 -0
  254. package/src/data/field-mapper.ts +116 -54
  255. package/src/data/file-list.ts +522 -0
  256. package/src/data/flow-editor.ts +695 -158
  257. package/src/data/flow-node-options.ts +24 -5
  258. package/src/data/flow-remote-options.ts +94 -19
  259. package/src/data/footer.ts +88 -26
  260. package/src/data/form-draft-registry.ts +183 -12
  261. package/src/data/gantt.ts +640 -117
  262. package/src/data/graph-view.ts +51 -0
  263. package/src/data/heat-calendar.ts +412 -0
  264. package/src/data/hero.ts +40 -13
  265. package/src/data/image-viewer.ts +265 -62
  266. package/src/data/index.ts +75 -6
  267. package/src/data/item-list.ts +219 -58
  268. package/src/data/json-view.ts +909 -0
  269. package/src/data/kanban.ts +346 -91
  270. package/src/data/kit-contract.ts +230 -0
  271. package/src/data/leaderboard.ts +343 -0
  272. package/src/data/level-class.ts +21 -0
  273. package/src/data/log-stream.ts +347 -0
  274. package/src/data/markdown-view.ts +597 -0
  275. package/src/data/matrix.ts +234 -120
  276. package/src/data/media-grid.ts +165 -38
  277. package/src/data/mega-menu.ts +43 -26
  278. package/src/data/menu-bar.ts +254 -0
  279. package/src/data/menu-dom.ts +55 -19
  280. package/src/data/menu.ts +138 -48
  281. package/src/data/mockup.ts +37 -25
  282. package/src/data/modal-dialog.ts +126 -98
  283. package/src/data/navbar.ts +152 -66
  284. package/src/data/notice-list.ts +101 -49
  285. package/src/data/notify-renderer.ts +80 -15
  286. package/src/data/object-form.ts +1504 -164
  287. package/src/data/org-chart.ts +544 -0
  288. package/src/data/outcome-watch.ts +90 -21
  289. package/src/data/pager.ts +129 -45
  290. package/src/data/panel-head.ts +238 -76
  291. package/src/data/permission-matrix.ts +379 -120
  292. package/src/data/permission-tree.ts +146 -78
  293. package/src/data/pricing-table.ts +112 -43
  294. package/src/data/prompt-dialog.ts +49 -21
  295. package/src/data/reaction-bar.ts +67 -32
  296. package/src/data/record-card.ts +245 -72
  297. package/src/data/record-picker.ts +61 -28
  298. package/src/data/redirect.ts +39 -15
  299. package/src/data/request-console.ts +141 -38
  300. package/src/data/resident.ts +11 -13
  301. package/src/data/result-panel.ts +65 -27
  302. package/src/data/rich-text.ts +260 -127
  303. package/src/data/row-confirm.ts +47 -0
  304. package/src/data/row-editor.ts +384 -105
  305. package/src/data/rule-builder.ts +136 -81
  306. package/src/data/schedule-grid.ts +238 -0
  307. package/src/data/segment-bar.ts +221 -0
  308. package/src/data/shape-util.ts +90 -36
  309. package/src/data/stage-flow.ts +244 -0
  310. package/src/data/staged-rows.ts +207 -24
  311. package/src/data/stat-group.ts +493 -100
  312. package/src/data/static-lazy.ts +21 -0
  313. package/src/data/static-registry.ts +46 -4
  314. package/src/data/status-strip.ts +171 -0
  315. package/src/data/steps.ts +69 -36
  316. package/src/data/summary-strip.ts +136 -0
  317. package/src/data/summary-util.ts +116 -0
  318. package/src/data/survey.ts +134 -47
  319. package/src/data/system-switcher.ts +53 -24
  320. package/src/data/target-progress.ts +208 -0
  321. package/src/data/text-action-button.ts +28 -7
  322. package/src/data/text-diff.ts +731 -0
  323. package/src/data/tile-grid.ts +343 -0
  324. package/src/data/timeline.ts +205 -36
  325. package/src/data/tour-guide.ts +113 -47
  326. package/src/data/transfer.ts +204 -47
  327. package/src/data/tree-table.ts +228 -81
  328. package/src/data/tree.ts +193 -69
  329. package/src/data/trend-line.ts +68 -12
  330. package/src/data/virtual-rows.ts +248 -98
  331. package/src/data/waterfall.ts +171 -0
  332. package/src/data/watermark.ts +35 -6
  333. package/src/data/wrap.ts +28 -6
  334. package/src/frames/blank-frame.ts +6 -4
  335. package/src/frames/index.ts +4 -4
  336. package/src/frames/inherited-shell.ts +219 -0
  337. package/src/frames/page-bar.ts +208 -28
  338. package/src/frames/page-status.ts +3 -2
  339. package/src/frames/resident-components.ts +18 -0
  340. package/src/frames/shared.ts +73 -26
  341. package/src/frames/single-frame.ts +20 -4
  342. package/src/frames/split-frame/shell.ts +27 -17
  343. package/src/frames/split-frame/wiring.ts +16 -12
  344. package/src/frames/tabs-frame/shell.ts +14 -7
  345. package/src/frames/tabs-frame/wiring.ts +2 -1
  346. package/src/frames/top-main-frame.ts +55 -3
  347. package/src/frames/types.ts +5 -2
  348. package/src/frames/workspace-frame/extras.ts +23 -7
  349. package/src/frames/workspace-frame/index.ts +1 -1
  350. package/src/frames/workspace-frame/pipeline-key.ts +6 -0
  351. package/src/frames/workspace-frame/shell.ts +24 -3
  352. package/src/frames/workspace-frame/state.ts +42 -8
  353. package/src/frames/workspace-frame/view.ts +773 -194
  354. package/src/generated/kit-grammar-runtime.ts +1061 -77
  355. package/src/generated/kit-page.ts +272 -0
  356. package/src/i18n/index.ts +2 -0
  357. package/src/i18n/kit-text.ts +210 -5
  358. package/src/i18n/resolve-text-refs.ts +1 -1
  359. package/src/object-renderer/action-group.ts +204 -22
  360. package/src/object-renderer/action-more.ts +66 -19
  361. package/src/object-renderer/arrange.ts +270 -28
  362. package/src/object-renderer/category-tone.ts +96 -0
  363. package/src/object-renderer/collapse-wiring.ts +19 -9
  364. package/src/object-renderer/collection-expand.ts +3 -3
  365. package/src/object-renderer/collection-parts.ts +459 -103
  366. package/src/object-renderer/collection-table.ts +406 -59
  367. package/src/object-renderer/collection.ts +333 -71
  368. package/src/object-renderer/compile-data.ts +13 -3
  369. package/src/object-renderer/defaults.ts +14 -5
  370. package/src/object-renderer/emit-events.ts +46 -20
  371. package/src/object-renderer/emit-object.ts +35 -6
  372. package/src/object-renderer/emit-static.ts +831 -153
  373. package/src/object-renderer/field-value.ts +12 -239
  374. package/src/object-renderer/filter-plan.ts +3 -3
  375. package/src/object-renderer/filter-toolbar.ts +190 -0
  376. package/src/object-renderer/form-detail.ts +87 -2
  377. package/src/{compile → object-renderer}/fragment.ts +2 -2
  378. package/src/object-renderer/index.ts +1 -1
  379. package/src/object-renderer/key-field.ts +21 -0
  380. package/src/object-renderer/layout-facts.ts +55 -7
  381. package/src/object-renderer/layout-plan.ts +6 -3
  382. package/src/object-renderer/overlay-decide.ts +124 -0
  383. package/src/object-renderer/pick-component.ts +8 -2
  384. package/src/object-renderer/pipeline-mode.ts +6 -0
  385. package/src/object-renderer/relation-field.ts +79 -0
  386. package/src/object-renderer/render-object.ts +72 -27
  387. package/src/object-renderer/request-actions.ts +119 -21
  388. package/src/object-renderer/table-actions.ts +479 -111
  389. package/src/object-renderer/table-gap.ts +2 -1
  390. package/src/object-renderer/table-reorder.ts +237 -0
  391. package/src/object-renderer/table-summary.ts +26 -12
  392. package/src/object-renderer/table-tools.ts +437 -130
  393. package/src/object-renderer/types.ts +100 -17
  394. package/src/object-renderer/value-present.ts +49 -0
  395. package/src/page-target/ai-surface.ts +15 -22
  396. package/src/page-target/compile.ts +5 -6
  397. package/src/page-target/drift.ts +0 -7
  398. package/src/page-target/intent-schema.ts +46 -43
  399. package/src/page-target/target.ts +4 -5
  400. package/src/page-target/writer-policy.ts +4 -5
  401. package/src/recipes/app-blocks.ts +66 -0
  402. package/src/recipes/chrome-surface.ts +20 -0
  403. package/src/recipes/code-view.ts +57 -0
  404. package/src/recipes/color-role.ts +442 -0
  405. package/src/recipes/compact-group.ts +32 -0
  406. package/src/recipes/composition-projector.ts +321 -0
  407. package/src/recipes/container.ts +93 -26
  408. package/src/recipes/control.ts +85 -8
  409. package/src/recipes/desc-list.ts +108 -0
  410. package/src/recipes/divider.ts +74 -0
  411. package/src/recipes/emphasis.ts +102 -13
  412. package/src/recipes/field-text.ts +72 -0
  413. package/src/recipes/form-section.ts +177 -0
  414. package/src/recipes/frame-bleed.ts +6 -5
  415. package/src/recipes/index.ts +39 -5
  416. package/src/recipes/inherited-shell.ts +43 -0
  417. package/src/recipes/json-view.ts +50 -0
  418. package/src/recipes/look.ts +56 -0
  419. package/src/recipes/mark.ts +138 -0
  420. package/src/recipes/markdown.ts +96 -0
  421. package/src/recipes/overlay.ts +151 -37
  422. package/src/recipes/page-width.ts +51 -0
  423. package/src/recipes/pipeline-runtime.ts +366 -0
  424. package/src/recipes/placeholder.ts +38 -20
  425. package/src/recipes/rail-grid.ts +6 -3
  426. package/src/recipes/self-owned.ts +59 -0
  427. package/src/recipes/slot-align.ts +5 -3
  428. package/src/recipes/stat-state.ts +6 -6
  429. package/src/recipes/state.ts +64 -11
  430. package/src/recipes/status.ts +21 -20
  431. package/src/recipes/strip.ts +114 -0
  432. package/src/recipes/surface-edge.ts +3 -1
  433. package/src/recipes/surface.ts +40 -7
  434. package/src/recipes/table-gap.ts +4 -3
  435. package/src/recipes/table-native-edit.ts +25 -12
  436. package/src/recipes/table-row.ts +56 -20
  437. package/src/recipes/tabs.ts +140 -31
  438. package/src/recipes/text-diff.ts +97 -0
  439. package/src/recipes/text-fit.ts +132 -0
  440. package/src/recipes/title-row.ts +72 -5
  441. package/src/recipes/typography.ts +2 -2
  442. package/src/shared/action-func.ts +106 -0
  443. package/src/shared/color-scheme.ts +127 -0
  444. package/src/shared/confirm-decl.ts +5 -2
  445. package/src/shared/danger-facts.ts +55 -0
  446. package/src/shared/diagnostics.ts +16 -0
  447. package/src/shared/dom-attrs-registry.ts +1009 -0
  448. package/src/shared/dom-attrs.ts +743 -0
  449. package/src/shared/envelope.ts +1 -1
  450. package/src/shared/field-kind.ts +49 -0
  451. package/src/shared/field-value-format.ts +292 -0
  452. package/src/shared/focus-ring.ts +8 -0
  453. package/src/shared/glyphs.ts +127 -0
  454. package/src/shared/hints.ts +56 -0
  455. package/src/{base → shared}/icons.ts +40 -1
  456. package/src/shared/identifier-field.ts +66 -0
  457. package/src/shared/kit-error.ts +1 -1
  458. package/src/shared/list-pager.ts +23 -0
  459. package/src/shared/list-title.ts +29 -0
  460. package/src/{object-renderer → shared}/merge-class.ts +3 -2
  461. package/src/shared/order-value.ts +15 -0
  462. package/src/shared/page-attrs-runtime.ts +327 -0
  463. package/src/shared/page-attrs.ts +262 -0
  464. package/src/shared/path-guard.ts +1 -1
  465. package/src/shared/pipeline-mode.ts +64 -0
  466. package/src/shared/primitives-types.ts +8 -0
  467. package/src/shared/row-key.ts +15 -0
  468. package/src/shared/theme-runtime-shared.ts +181 -21
  469. package/src/shared/theme-usage.ts +16 -0
  470. package/src/shared/value-table-contract.ts +68 -0
  471. package/src/spatial/action-func.ts +4 -0
  472. package/src/spatial/declared-actions.ts +116 -0
  473. package/src/spatial/emit.ts +660 -0
  474. package/src/spatial/expand.ts +1482 -0
  475. package/src/spatial/field-types.ts +48 -0
  476. package/src/spatial/index.ts +82 -0
  477. package/src/spatial/layout.ts +697 -0
  478. package/src/spatial/look-apply.ts +206 -0
  479. package/src/spatial/page-decl.ts +44 -0
  480. package/src/spatial/page-object.ts +349 -0
  481. package/src/spatial/recognize.ts +491 -0
  482. package/src/spatial/self-report.ts +571 -0
  483. package/src/spatial/shape.ts +205 -0
  484. package/src/spatial/spatial-map.ts +136 -0
  485. package/src/spatial/tone.ts +145 -0
  486. package/src/theme/index.ts +11 -2
  487. package/src/theme/kit-theme-text.ts +1 -1
  488. package/src/theme/kit-theme.css +563 -28
  489. package/src/theme/kit-theme.tpl +527 -28
  490. package/src/theme/look-carrier.ts +65 -0
  491. package/src/theme/nine-dim-structure.ts +538 -176
  492. package/src/theme/private-vars.ts +153 -0
  493. package/src/theme/surface-layers.ts +12 -3
  494. package/src/theme/theme-tokens.ts +1602 -90
  495. package/src/theme/theme-types.ts +38 -59
  496. package/src/theme/value-table.ts +2379 -0
  497. package/src/app/envelope.ts +0 -1
  498. package/src/app/notify-renderer.ts +0 -1
  499. package/src/app/paged-list-adapter.ts +0 -1
  500. package/src/app/theme-runtime-shared.ts +0 -1
  501. package/src/compile/kit-error.ts +0 -1
  502. package/src/frames/list-summary.ts +0 -100
  503. package/src/recipes/nowrap.ts +0 -16
  504. package/src/theme/block-theme.ts +0 -202
  505. /package/src/{base → shared}/class-candidates.ts +0 -0
@@ -8,17 +8,28 @@
8
8
 
9
9
  import type { SomaComponentDefinition } from 'soma-core';
10
10
  import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
11
+ import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
11
12
  import { kitText } from '../i18n/kit-text';
12
13
  import { createKitController, joinClass, num, str } from '../base/shared';
13
14
  import { classSet, FOCUS_INSET, h, recList, textOf, type Rec } from './menu-dom';
15
+ import { kitDividerRecipe } from '../recipes/divider';
16
+ import { kitGroupLabelRecipe } from '../recipes/field-text';
17
+ import { kitSelectedRecipe } from '../recipes/state';
18
+ import { mergeClass } from '../shared/merge-class';
19
+ import { kitMarkPart, kitMarkPicked } from './kit-contract';
20
+ import { KIT_ATTR_ANCHOR, KIT_ATTR_ANCHOR_LEVEL, kitAttrSel } from '../shared/dom-attrs';
14
21
 
15
22
  const ROOT_CLASS = 'flex flex-col gap-2 text-sm';
16
- const TITLE_CLASS = 'text-xs font-semibold text-fg-subtle';
17
- const LIST_CLASS = 'flex flex-col border-s border-border-subtle';
23
+ // 目录标题是分组眉题:取唯一出口(主题公式 F7:S(−1)、500、更弱的墨、无底)
24
+ const TITLE_CLASS = kitGroupLabelRecipe();
25
+ // 锚点列表的导轨线 = 分隔线出口(发丝宽、分隔灰);当前项竖条是强调指示(border-primary)
26
+ const RAIL_LINE = kitDividerRecipe('start');
27
+ const LIST_CLASS = `flex flex-col ${RAIL_LINE}`;
18
28
  const LINK_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-transparent py-1 ps-3 text-fg-muted transition-colors hover:text-fg ${FOCUS_INSET}`;
19
29
  const LINK_L2_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-transparent py-1 ps-6 text-fg-muted transition-colors hover:text-fg ${FOCUS_INSET}`;
20
- const LINK_ACTIVE_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-3 font-medium text-primary-on-soft ${FOCUS_INSET}`;
21
- const LINK_L2_ACTIVE_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-6 font-medium text-primary-on-soft ${FOCUS_INSET}`;
30
+ // 当前项 = 选中出口(kitSelectedRecipe:主色状态层 + 主色字)+ 起始侧强调竖条
31
+ const LINK_ACTIVE_CLASS = mergeClass(mergeClass('-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-3', kitSelectedRecipe()), FOCUS_INSET);
32
+ const LINK_L2_ACTIVE_CLASS = mergeClass(mergeClass('-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-6', kitSelectedRecipe()), FOCUS_INSET);
22
33
 
23
34
  /** 本组件自带的全部类(供编译器并入候选类) */
24
35
  export const KIT_ANCHOR_NAV_CLASS_CANDIDATES: readonly string[] = classSet(
@@ -90,12 +101,36 @@ export function createAnchorNav(): SomaComponentDefinition {
90
101
  let auto = '';
91
102
  let scroller: Element | Window | null = null;
92
103
  let frame = 0;
104
+ let lockedId = '';
105
+ let lockTimer: ReturnType<typeof setTimeout> | null = null;
106
+
107
+ const clearLock = (): void => {
108
+ lockedId = '';
109
+ if (lockTimer !== null) {
110
+ clearTimeout(lockTimer);
111
+ lockTimer = null;
112
+ }
113
+ };
93
114
 
94
115
  const offset = (): number => num(props.offset) ?? KIT_ANCHOR_DEFAULT_OFFSET;
95
116
  const forced = (): string => str(props.active);
96
117
  const current = (): string => (forced() !== '' ? forced() : auto);
97
118
  const targetEl = (a: KitAnchorItem): HTMLElement | null => doc.getElementById(a.target);
98
119
 
120
+ const syncActiveDom = (): void => {
121
+ const cur = current();
122
+ for (const link of Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ANCHOR)))) {
123
+ const id = link.getAttribute(KIT_ATTR_ANCHOR) ?? '';
124
+ const level = link.getAttribute(KIT_ATTR_ANCHOR_LEVEL) === '2' ? 2 : 1;
125
+ const on = id === cur;
126
+ link.className = level === 2 ? (on ? LINK_L2_ACTIVE_CLASS : LINK_L2_CLASS) : (on ? LINK_ACTIVE_CLASS : LINK_CLASS);
127
+ if (on) link.setAttribute('aria-current', 'location');
128
+ else link.removeAttribute('aria-current');
129
+ // 当前节自报「当前」(aria-current=location 已在上两行同步写,帮手不再碰无障碍属性)
130
+ kitMarkPicked(link, 'current', on, null);
131
+ }
132
+ };
133
+
99
134
  const resolveScroller = (): Element | Window | null => {
100
135
  const sel = str(props.scroll_container);
101
136
  if (sel !== '') return doc.querySelector(sel) ?? view;
@@ -115,7 +150,8 @@ export function createAnchorNav(): SomaComponentDefinition {
115
150
  return { top: 0, atBottom: se.scrollTop + se.clientHeight >= se.scrollHeight - 2 };
116
151
  };
117
152
 
118
- const recompute = (): void => {
153
+ const recompute = (fromUpdate = false): void => {
154
+ if (lockedId !== '' && !items.some((a) => a.id === lockedId)) clearLock();
119
155
  const { top, atBottom } = metrics();
120
156
  const tops = items.map((a) => {
121
157
  const t = targetEl(a);
@@ -123,7 +159,14 @@ export function createAnchorNav(): SomaComponentDefinition {
123
159
  });
124
160
  const at = pickActiveIndex(tops, offset(), atBottom);
125
161
  const next = at >= 0 ? items[at]!.id : '';
126
- if (next !== auto) { auto = next; paint(); }
162
+ if (lockedId !== '') {
163
+ if (next === lockedId) clearLock();
164
+ else return;
165
+ }
166
+ if (next !== auto) {
167
+ auto = next;
168
+ if (!fromUpdate) syncActiveDom();
169
+ }
127
170
  };
128
171
 
129
172
  const schedule = (): void => {
@@ -150,7 +193,7 @@ export function createAnchorNav(): SomaComponentDefinition {
150
193
  if (!resolvable()) return;
151
194
  stopWatch();
152
195
  bind();
153
- if (forced() === '') recompute();
196
+ if (forced() === '') recompute(true);
154
197
  paint();
155
198
  });
156
199
  watcher.observe(doc.body, { childList: true, subtree: true });
@@ -160,7 +203,7 @@ export function createAnchorNav(): SomaComponentDefinition {
160
203
  const scrollTo = (a: KitAnchorItem): void => {
161
204
  const t = targetEl(a);
162
205
  if (!t) return;
163
- const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
206
+ const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true;
164
207
  const behavior: ScrollBehavior = reduce ? 'auto' : 'smooth';
165
208
  if (scroller && scroller !== view) {
166
209
  const el = scroller as Element;
@@ -181,21 +224,38 @@ export function createAnchorNav(): SomaComponentDefinition {
181
224
  for (const a of items) {
182
225
  const on = a.id === cur;
183
226
  const cls = a.level === 2 ? (on ? LINK_L2_ACTIVE_CLASS : LINK_L2_CLASS) : (on ? LINK_ACTIVE_CLASS : LINK_CLASS);
184
- const link = h('a', cls, { href: `#${a.target}`, 'aria-current': on ? 'location' : undefined, 'data-kit-anchor': a.id }, a.label);
227
+ const link = h('a', cls, {
228
+ href: `#${a.target}`,
229
+ 'aria-current': on ? 'location' : undefined,
230
+ [KIT_ATTR_ANCHOR]: a.id,
231
+ [KIT_ATTR_ANCHOR_LEVEL]: String(a.level),
232
+ [KIT_TIPS_SCOPE_ATTR]: '',
233
+ }, a.label);
234
+ kitMarkPart(link, 'action');
235
+ kitMarkPicked(link, 'current', on, null);
185
236
  link.addEventListener('click', (e) => {
186
237
  e.preventDefault();
187
- scrollTo(a);
238
+ const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true;
239
+ clearLock();
188
240
  auto = a.id;
189
- paint();
241
+ if (!reduce && targetEl(a) !== null) {
242
+ lockedId = a.id;
243
+ lockTimer = setTimeout(() => { lockedId = ''; lockTimer = null; }, 600);
244
+ }
245
+ syncActiveDom();
246
+ scrollTo(a);
190
247
  api.emit('pick', { item: a.raw });
191
248
  });
192
249
  list.append(h('li', '', {}, link));
193
250
  }
194
- // 重画会换掉链接节点:键盘点链接 / 滚动高亮时焦点要还给同一项
195
- const focused = root.contains(doc.activeElement) ? (doc.activeElement as HTMLElement).getAttribute('data-kit-anchor') : null;
196
- root.replaceChildren(...(title !== '' ? [h('div', TITLE_CLASS, {}, title)] : []), list);
251
+ // 重画会换掉链接节点:键盘点链接 / 外部重绘时焦点要还给同一项
252
+ const focused = root.contains(doc.activeElement) ? (doc.activeElement as HTMLElement).getAttribute(KIT_ATTR_ANCHOR) : null;
253
+ const titleEl = title !== '' ? h('div', TITLE_CLASS, {}, title) : null;
254
+ // 目录标题是块标题
255
+ if (titleEl !== null) kitMarkPart(titleEl, 'block-title');
256
+ root.replaceChildren(...(titleEl !== null ? [titleEl] : []), list);
197
257
  if (focused !== null) {
198
- Array.from(root.querySelectorAll<HTMLElement>('[data-kit-anchor]')).find((el) => el.getAttribute('data-kit-anchor') === focused)?.focus({ preventScroll: true });
258
+ Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ANCHOR))).find((el) => el.getAttribute(KIT_ATTR_ANCHOR) === focused)?.focus({ preventScroll: true });
199
259
  }
200
260
  }
201
261
 
@@ -204,10 +264,11 @@ export function createAnchorNav(): SomaComponentDefinition {
204
264
  props = p;
205
265
  items = anchorItemsOf(p.data);
206
266
  bind();
207
- if (forced() === '') recompute();
267
+ if (forced() === '') recompute(true);
208
268
  paint();
209
269
  },
210
270
  destroy() {
271
+ clearLock();
211
272
  stopWatch();
212
273
  scroller?.removeEventListener('scroll', schedule);
213
274
  scroller = null;
@@ -8,23 +8,48 @@
8
8
  // 只展示并上抛意图,不做权限判断、接口调用或状态迁移:
9
9
  // action { key }、step_action { key, step }、step { id }(selectable 时点步骤名)。
10
10
 
11
+ import { kitApplyLevelClass } from './level-class';
11
12
  import type { SomaComponentDefinition } from 'soma-core';
13
+ import { KIT_FOCUS_RING } from '../recipes/state';
14
+ import {
15
+ KIT_COLOR_ROLE_CLASS_CANDIDATES,
16
+ kitResolveStatusOrCategoryTone,
17
+ kitToneSoftBadgeClass,
18
+ } from '../recipes/color-role';
12
19
  import { bool, createKitController, formatValue, joinClass, str } from '../base/shared';
13
- import { kitIcon, type KitIconName } from '../base/icons';
20
+ import { kitIcon, type KitIconName } from '../shared/icons';
14
21
  import { kitText, type KitTextKey } from '../i18n/kit-text';
15
22
  import { markKitEdge } from '../recipes/surface-edge';
23
+ import { kitShellRecipe } from '../recipes/container';
24
+ import { kitControlEdgeRecipe } from '../recipes/control';
25
+ import { kitDividerRecipe, kitThickDividerRecipe } from '../recipes/divider';
16
26
  import { kitTypographyRecipe } from '../recipes/typography';
27
+ import { mergeClass } from '../shared/merge-class';
28
+ import { KIT_AVATAR_CLASS_CANDIDATES, paintAvatar, ROOT_CLASS as AVATAR_ROOT_CLASS, specOf } from '../base/avatar';
29
+ import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
30
+ import { buildSkeleton, KIT_SKELETON_CLASS_CANDIDATES } from '../object-renderer/skeleton';
17
31
  import {
18
32
  actionButton, actionsOf, BADGE_BASE, classTokens, BUTTON_CLASS_TOKENS, emptyNode, keyMap, mk, recOf, rowsOf, textOf,
19
33
  TONE_DOT, TONE_SOFT, TONE_SOLID, type ShapeTone,
20
34
  } from './shape-util';
35
+ import { kitHasProps, kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
36
+ import {
37
+ KIT_ATTR_ACTION, KIT_ATTR_BLOCKED, KIT_ATTR_CONTAINER, KIT_ATTR_PERSON, KIT_ATTR_PICK, KIT_ATTR_REASON, KIT_ATTR_STATUS, KIT_ATTR_STEP,
38
+ kitAttrHtml, kitAttrSel,
39
+ } from '../shared/dom-attrs';
40
+
41
+ /** 状态徽标的元素部件自报(返回原节点,便于就地包在 appendChild 里) */
42
+ function markStatus(el: HTMLElement): HTMLElement {
43
+ kitMarkPart(el, 'status');
44
+ return el;
45
+ }
21
46
 
22
47
  export const KIT_APPROVAL_DEFAULT_MAP = Object.freeze({
23
48
  title: 'title', applicant: 'applicant', summary: 'summary', status: 'status', steps: 'steps', actions: 'actions',
24
49
  blocked_state: 'blocked_state', blocked_reason: 'blocked_reason',
25
50
  });
26
51
  export const KIT_APPROVAL_STEP_DEFAULT_MAP = Object.freeze({
27
- id: 'id', name: 'name', approver: 'approver', status: 'status', time: 'time', comment: 'comment', reason: 'reason', actions: 'actions',
52
+ id: 'id', name: 'name', approver: 'approver', avatar: 'avatar', approver_role: 'approver_role', status: 'status', time: 'time', comment: 'comment', reason: 'reason', actions: 'actions', overdue: 'overdue',
28
53
  });
29
54
 
30
55
  export type KitApprovalStatus = 'pending' | 'current' | 'approved' | 'rejected' | 'skipped' | 'blocked' | 'returned' | 'withdrawn';
@@ -57,34 +82,50 @@ const BLOCKED_TONE: Readonly<Record<string, ShapeTone>> = Object.freeze({
57
82
  /** 缺原因要显式说「未说明原因」的步骤状态;rejected 不在内(存量口径:只在给了原因时才显示) */
58
83
  const NEEDS_REASON: readonly KitApprovalStatus[] = Object.freeze(['blocked', 'returned', 'withdrawn']);
59
84
 
60
- const ROOT_CLASS = 'flex flex-col gap-4 rounded-lg border border-border-subtle bg-surface p-5 text-sm text-fg';
85
+ // 外缘 = 壳配方(容器边,KT-B2);待办节点圆点外圈 = 控件轮廓(KT-B1)
86
+ const ROOT_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
87
+ const DOT_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
88
+ const ROOT_CLASS = mergeClass(mergeClass('flex flex-col gap-4', ROOT_EDGE), mergeClass('p-5', kitTypographyRecipe('text')));
61
89
  const HEAD_CLASS = 'flex flex-col gap-1';
62
90
  const HEAD_ROW = 'flex flex-wrap items-center gap-2';
63
91
  const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
64
92
  const META_CLASS = 'text-fg-muted';
65
93
  const SUMMARY_CLASS = 'text-fg';
66
- const BANNER_BASE = 'flex flex-col gap-1 rounded-md px-3 py-2';
94
+ const BANNER_BASE = 'flex flex-col gap-1 rounded-item px-3 py-2';
67
95
  const BANNER_TITLE = 'font-medium';
68
96
  const LIST_CLASS = 'flex flex-col';
69
97
  const ITEM_CLASS = 'flex gap-3';
70
98
  const RAIL_CLASS = 'flex flex-col items-center gap-1';
71
99
  const DOT_CLASS = 'flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-semibold';
72
- const PENDING_DOT = 'border border-border bg-surface text-fg-subtle';
73
- const LINE_CLASS = 'min-h-4 w-0.5 flex-1 rounded-full bg-border-subtle';
74
- const BODY_CLASS = 'flex flex-1 flex-col gap-1 pb-4';
100
+ const PENDING_DOT = `${DOT_EDGE} bg-surface text-fg-subtle`;
101
+ const LINE_CLASS = mergeClass('min-h-4 flex-1', kitDividerRecipe('start'));
102
+ // 审批流 = Steps 型(竖向小号):Ant Steps style/index.ts:rail-size = lineWidth = 1、iconSizeSM = 24(size-6 节点);
103
+ // 项距 20 取 Ant Timeline(itemPaddingBottom = padding x 1.25)
104
+ const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1 pb-5';
75
105
  const NAME_ROW = 'flex flex-wrap items-center gap-x-2 gap-y-1';
76
106
  const NAME_CLASS = 'font-medium text-fg';
77
- const NAME_BUTTON = 'rounded-md font-medium text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
78
- const TIME_CLASS = 'text-xs text-fg-subtle';
79
- const COMMENT_CLASS = 'text-fg-muted';
80
- const REASON_BASE = 'rounded-md px-2 py-1 text-xs';
107
+ const NAME_BUTTON = 'rounded-item font-medium text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ' + KIT_FOCUS_RING.button;
108
+ const TIME_CLASS = kitTypographyRecipe('captionPlain');
109
+ // 超时:时间字转危险语气(卡:超时 = 时间字 danger +「已超时」)
110
+ const TIME_OVERDUE_CLASS = mergeClass(kitTypographyRecipe('menuGroup'), 'text-danger-on-soft');
111
+ // 人员单元(头像 + 姓名 + 角色):头像复用 base/avatar 支持真实图片 URL 与首字母回退,姓名取主文字、角色弱化
112
+ const PERSON_CLASS = 'inline-flex items-center gap-2';
113
+ const PERSON_AVATAR = AVATAR_ROOT_CLASS.sm;
114
+ const PERSON_NAME = 'text-fg';
115
+ const PERSON_ROLE = kitTypographyRecipe('captionPlain');
116
+ // 审批意见 = 引用块(左竖线 + 弱化字,卡:意见为引用块样式)
117
+ const COMMENT_CLASS = mergeClass(kitThickDividerRecipe('start'), 'ps-3 text-fg-muted');
118
+ // 当前节点 = 唯一带边的强调卡(内衬 p-3,外底距 mb-5 与其它步骤 pb-5 对齐,避免 py 覆盖 pb-5 致 0px 底距贴死)
119
+ const CURRENT_CARD = `mb-5 flex min-w-0 flex-1 flex-col gap-1 ${DOT_EDGE} rounded-item bg-surface p-3`;
120
+ const REASON_BASE = 'rounded-item px-2 py-1 text-xs';
81
121
  const STEP_ACTIONS = 'flex flex-wrap items-center gap-2';
82
122
  const FOOT_CLASS = 'flex flex-wrap items-center justify-end gap-2';
83
123
 
84
124
  export const KIT_APPROVAL_FLOW_CLASS_CANDIDATES: readonly string[] = classTokens(
85
125
  ROOT_CLASS, HEAD_CLASS, HEAD_ROW, TITLE_CLASS, META_CLASS, SUMMARY_CLASS, BANNER_BASE, BANNER_TITLE, LIST_CLASS, ITEM_CLASS, RAIL_CLASS,
86
126
  DOT_CLASS, PENDING_DOT, LINE_CLASS, BODY_CLASS, NAME_ROW, NAME_CLASS, NAME_BUTTON, TIME_CLASS, COMMENT_CLASS, REASON_BASE,
87
- STEP_ACTIONS, FOOT_CLASS, BADGE_BASE, BUTTON_CLASS_TOKENS, Object.values(TONE_SOFT), Object.values(TONE_SOLID), Object.values(TONE_DOT),
127
+ STEP_ACTIONS, FOOT_CLASS, TIME_OVERDUE_CLASS, PERSON_CLASS, PERSON_AVATAR, PERSON_NAME, PERSON_ROLE, CURRENT_CARD, KIT_AVATAR_CLASS_CANDIDATES, KIT_SKELETON_CLASS_CANDIDATES, BADGE_BASE, BUTTON_CLASS_TOKENS, Object.values(TONE_SOFT), Object.values(TONE_SOLID), Object.values(TONE_DOT),
128
+ KIT_COLOR_ROLE_CLASS_CANDIDATES,
88
129
  );
89
130
 
90
131
  export function approvalStatusOf(raw: unknown): KitApprovalStatus {
@@ -99,8 +140,13 @@ export interface KitApprovalStep {
99
140
  key: string;
100
141
  name: string;
101
142
  approver: string;
143
+ avatar: string;
144
+ /** 审批人角色(人员单元里姓名后的弱化小字) */
145
+ approverRole: string;
102
146
  status: KitApprovalStatus;
103
147
  time: string;
148
+ /** 超时(时间字转危险语气 + 「已超时」) */
149
+ overdue: boolean;
104
150
  comment: string;
105
151
  /** 要显示的原因行文字;空串 = 不显示 */
106
152
  reason: string;
@@ -118,6 +164,9 @@ export function approvalStepsOf(rawSteps: unknown, stepMapRaw: unknown, noReason
118
164
  key: raw[m.id] === undefined || raw[m.id] === null || raw[m.id] === '' ? `a${i}` : String(raw[m.id]),
119
165
  name: textOf(raw[m.name]),
120
166
  approver: textOf(raw[m.approver]),
167
+ avatar: textOf(raw[m.avatar] ?? raw.approver_avatar),
168
+ approverRole: textOf(raw[m.approver_role]),
169
+ overdue: raw[m.overdue] === true || raw[m.overdue] === 'true',
121
170
  status,
122
171
  time: time === undefined || time === null || time === '' ? '' : formatValue(time, timeFormat, locale),
123
172
  comment: textOf(raw[m.comment]),
@@ -135,7 +184,8 @@ export function createApprovalFlow(): SomaComponentDefinition {
135
184
  props: {
136
185
  data: { type: 'object', default: {}, desc: '审批单 { title, applicant, summary?, status?, steps[], actions?, blocked_state?, blocked_reason? }' },
137
186
  map: { type: 'object', default: {}, desc: '单据层键名对照:title / applicant / summary / status / steps / actions / blocked_state / blocked_reason' },
138
- step_map: { type: 'object', default: {}, desc: '步骤层键名对照:id / name / approver / status / time / comment / reason / actions' },
187
+ step_map: { type: 'object', default: {}, desc: '步骤层键名对照:id / name / approver / approver_role / status / time / comment / reason / actions / overdue;approver + approver_role 画成人员单元(头像 + 姓名 + 角色),overdue 为真时时间转危险语气并标「已超时」' },
188
+ ...KIT_READ_STATE_PROP_DEFS,
139
189
  selectable: { type: 'boolean', default: false, desc: '步骤名是按钮,点击抛 step' },
140
190
  labels: { type: 'object', default: {}, desc: '状态文案覆盖 { pending, current, approved, rejected, skipped, blocked, returned, withdrawn }' },
141
191
  applicant_label: { type: 'string', default: '', desc: '申请人前缀文案' },
@@ -149,124 +199,165 @@ export function createApprovalFlow(): SomaComponentDefinition {
149
199
  action: { payload: { key: { type: 'string' } }, desc: '点底部动作;只上抛意图,权限与接口由页面处理' },
150
200
  step_action: { payload: { key: { type: 'string' }, step: { type: 'string' } }, desc: '点步骤级动作;step 是所在步骤的 id' },
151
201
  step: { payload: { id: { type: 'string' } }, desc: '点步骤名(selectable 时),供页面打开详情' },
202
+ ...KIT_READ_STATE_EMIT_DEFS,
152
203
  },
153
204
  },
154
- templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
155
- controllerFactory: createKitController(() => ({
156
- attach(root, api) {
157
- const onClick = (event: Event): void => {
158
- const target = event.target as HTMLElement | null;
159
- const btn = target?.closest<HTMLButtonElement>('[data-kit-action]');
160
- if (btn && !btn.disabled) {
161
- const key = btn.getAttribute('data-kit-action') ?? '';
162
- const step = btn.closest<HTMLElement>('[data-kit-step]')?.getAttribute('data-kit-step');
163
- if (step !== undefined && step !== null) api.emit('step_action', { key, step });
164
- else api.emit('action', { key });
165
- return;
166
- }
167
- const pick = target?.closest<HTMLElement>('[data-kit-pick]');
168
- if (pick) api.emit('step', { id: pick.getAttribute('data-kit-pick') ?? '' });
169
- };
170
- root.addEventListener('click', onClick);
171
- return () => root.removeEventListener('click', onClick);
172
- },
173
- render(root, p) {
174
- root.className = joinClass(ROOT_CLASS, p.class);
175
- markKitEdge(root);
176
- root.textContent = '';
177
- const m = keyMap(KIT_APPROVAL_DEFAULT_MAP, p.map);
178
- const data = recOf(p.data);
179
- const labels = recOf(p.labels);
180
- const label = (s: KitApprovalStatus): string => (typeof labels[s] === 'string' && labels[s] !== '' ? String(labels[s]) : kitText(STATUS_TEXT[s], undefined, root));
181
- const noReason = str(p.no_reason_text, kitText('soma.kit.no_reason', undefined, root));
182
-
183
- // 抬头
184
- const head = mk('header', HEAD_CLASS);
185
- const row = mk('div', HEAD_ROW);
186
- row.appendChild(mk('h3', TITLE_CLASS, textOf(data[m.title])));
187
- if (data[m.status] !== undefined && data[m.status] !== null && data[m.status] !== '') {
188
- const st = approvalStatusOf(data[m.status]);
189
- row.appendChild(mk('span', `${BADGE_BASE} ${TONE_SOFT[STATUS_TONE[st]]}`, label(st)));
190
- }
191
- head.appendChild(row);
192
- const applicant = textOf(data[m.applicant]);
193
- if (applicant !== '') head.appendChild(mk('p', META_CLASS, `${str(p.applicant_label, kitText('soma.kit.af_applicant', undefined, root))}${kitText('soma.kit.colon', undefined, root)}${applicant}`));
194
- const summary = textOf(data[m.summary]);
195
- if (summary !== '') head.appendChild(mk('p', SUMMARY_CLASS, summary));
196
- root.appendChild(head);
197
-
198
- // 整单受阻横幅
199
- const blocked = blockedOf(data[m.blocked_state]);
200
- if (blocked !== 'none') {
201
- const banner = mk('div', `${BANNER_BASE} ${TONE_SOFT[BLOCKED_TONE[blocked] ?? 'warning']}`);
202
- banner.setAttribute('role', 'status');
203
- banner.setAttribute('data-kit-blocked', blocked);
204
- banner.appendChild(mk('span', BANNER_TITLE, BLOCKED_TEXT[blocked] ? kitText(BLOCKED_TEXT[blocked]!, undefined, root) : ''));
205
- const why = textOf(data[m.blocked_reason]);
206
- banner.appendChild(mk('span', '', why !== '' ? why : noReason));
207
- root.appendChild(banner);
208
- }
205
+ templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'card')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
206
+ controllerFactory: createKitController(() => {
207
+ const failedAvatars = new Set<string>();
208
+ return {
209
+ attach(root, api) {
210
+ const onClick = (event: Event): void => {
211
+ const target = event.target as HTMLElement | null;
212
+ const btn = target?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
213
+ if (btn && !btn.disabled) {
214
+ const key = btn.getAttribute(KIT_ATTR_ACTION) ?? '';
215
+ const step = btn.closest<HTMLElement>(kitAttrSel(KIT_ATTR_STEP))?.getAttribute(KIT_ATTR_STEP);
216
+ if (step !== undefined && step !== null) api.emit('step_action', { key, step });
217
+ else api.emit('action', { key });
218
+ return;
219
+ }
220
+ const pick = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PICK));
221
+ if (pick) api.emit('step', { id: pick.getAttribute(KIT_ATTR_PICK) ?? '' });
222
+ };
223
+ root.addEventListener('click', onClick);
224
+ return () => root.removeEventListener('click', onClick);
225
+ },
226
+ render(root, p, api) {
227
+ root.className = joinClass(ROOT_CLASS, p.class);
228
+ // C 项:新流水线下外框由取值表按邻接给,不再按祖先判断
229
+ if (!kitHasProps(p)) markKitEdge(root);
230
+ root.textContent = '';
231
+ const m = keyMap(KIT_APPROVAL_DEFAULT_MAP, p.map);
232
+ const data = recOf(p.data);
233
+ // 读状态(加载中 = 与节点同结构的骨架;读取失败 + 重试):同集合三态(base/state-panel.ts)
234
+ const hasSteps = rowsOf(data[m.steps]).length > 0;
235
+ // 数据状态自报(与读状态面板的 data-kit-state 并存):先按读状态写,步骤为空时下面再改写为空
236
+ kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true' });
237
+ if (applyKitReadState(root, p, {
238
+ hasContent: hasSteps, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh(),
239
+ skeleton: () => buildSkeleton(root.ownerDocument, { kind: 'stack' }),
240
+ })) return;
241
+ const labels = recOf(p.labels);
242
+ const label = (s: KitApprovalStatus): string => (typeof labels[s] === 'string' && labels[s] !== '' ? String(labels[s]) : kitText(STATUS_TEXT[s], undefined, root));
243
+ const noReason = str(p.no_reason_text, kitText('soma.kit.no_reason', undefined, root));
209
244
 
210
- // 步骤
211
- const steps = approvalStepsOf(data[m.steps], p.step_map, noReason, str(p.time_format), str(p.locale));
212
- if (steps.length === 0) {
213
- root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.af_empty', undefined, root))));
214
- } else {
215
- const ol = mk('ol', LIST_CLASS);
216
- ol.setAttribute('role', 'list');
217
- const selectable = bool(p.selectable);
218
- steps.forEach((s, index) => {
219
- const li = mk('li', ITEM_CLASS);
220
- li.setAttribute('data-kit-step', s.key);
221
- li.setAttribute('data-kit-status', s.status);
222
- if (s.status === 'current') li.setAttribute('aria-current', 'step');
223
- const rail = mk('div', RAIL_CLASS);
224
- const dot = mk('span', `${DOT_CLASS} ${s.status === 'pending' ? PENDING_DOT : TONE_SOLID[STATUS_TONE[s.status]]}`, STATUS_GLYPH[s.status]);
225
- const dotIcon = STATUS_ICON[s.status];
226
- if (dotIcon) dot.appendChild(kitIcon(dotIcon, 'xs'));
227
- dot.setAttribute('aria-hidden', 'true');
228
- rail.appendChild(dot);
229
- if (index < steps.length - 1) rail.appendChild(mk('span', LINE_CLASS));
230
- const body = mk('div', BODY_CLASS);
231
- const nameRow = mk('div', NAME_ROW);
232
- if (selectable) {
233
- const btn = mk('button', NAME_BUTTON, s.name);
234
- btn.type = 'button';
235
- btn.setAttribute('data-kit-pick', s.key);
236
- nameRow.appendChild(btn);
245
+ // 抬头
246
+ const head = mk('header', HEAD_CLASS);
247
+ // 抬头是这张单据面的标题行(面头),单据名是块标题
248
+ kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
249
+ const row = mk('div', HEAD_ROW);
250
+ const docTitle = mk('h3', TITLE_CLASS, textOf(data[m.title]));
251
+ kitMarkPart(docTitle, 'block-title');
252
+ row.appendChild(docTitle);
253
+ const rawDocStatus = textOf(data[m.status]).trim();
254
+ if (rawDocStatus !== '') {
255
+ if ((KIT_APPROVAL_STATUSES as readonly string[]).includes(rawDocStatus)) {
256
+ const st = rawDocStatus as KitApprovalStatus;
257
+ row.appendChild(markStatus(mk('span', `${BADGE_BASE} ${TONE_SOFT[STATUS_TONE[st]]}`, label(st))));
237
258
  } else {
238
- nameRow.appendChild(mk('span', NAME_CLASS, s.name));
259
+ const docTone = kitResolveStatusOrCategoryTone(rawDocStatus, undefined, { preferHash: true, host: root });
260
+ row.appendChild(markStatus(mk('span', `${BADGE_BASE} ${kitToneSoftBadgeClass(docTone)}`, rawDocStatus)));
239
261
  }
240
- nameRow.appendChild(mk('span', `${BADGE_BASE} ${TONE_SOFT[STATUS_TONE[s.status]]}`, label(s.status)));
241
- if (s.approver !== '') nameRow.appendChild(mk('span', META_CLASS, s.approver));
242
- if (s.time !== '') nameRow.appendChild(mk('span', TIME_CLASS, s.time));
243
- body.appendChild(nameRow);
244
- if (s.comment !== '') body.appendChild(mk('p', COMMENT_CLASS, s.comment));
245
- if (s.reason !== '') {
246
- const reason = mk('p', `${REASON_BASE} ${TONE_SOFT[STATUS_TONE[s.status]]}`, s.reason);
247
- reason.setAttribute('data-kit-reason', '');
248
- body.appendChild(reason);
249
- }
250
- if (s.actions.length > 0) {
251
- const acts = mk('div', STEP_ACTIONS);
252
- for (const a of s.actions) acts.appendChild(actionButton(a));
253
- body.appendChild(acts);
254
- }
255
- li.appendChild(rail);
256
- li.appendChild(body);
257
- ol.appendChild(li);
258
- });
259
- root.appendChild(ol);
260
- }
262
+ }
263
+ head.appendChild(row);
264
+ const applicant = textOf(data[m.applicant]);
265
+ if (applicant !== '') head.appendChild(mk('p', META_CLASS, `${str(p.applicant_label, kitText('soma.kit.af_applicant', undefined, root))}${kitText('soma.kit.colon', undefined, root)}${applicant}`));
266
+ const summary = textOf(data[m.summary]);
267
+ if (summary !== '') head.appendChild(mk('p', SUMMARY_CLASS, summary));
268
+ root.appendChild(head);
261
269
 
262
- // 底部动作
263
- const actions = actionsOf(data[m.actions]);
264
- if (actions.length > 0) {
265
- const foot = mk('div', FOOT_CLASS);
266
- for (const a of actions) foot.appendChild(actionButton(a));
267
- root.appendChild(foot);
268
- }
269
- },
270
- })),
270
+ // 整单受阻横幅
271
+ const blocked = blockedOf(data[m.blocked_state]);
272
+ if (blocked !== 'none') {
273
+ const banner = mk('div', `${BANNER_BASE} ${TONE_SOFT[BLOCKED_TONE[blocked] ?? 'warning']}`);
274
+ banner.setAttribute('role', 'status');
275
+ banner.setAttribute(KIT_ATTR_BLOCKED, blocked);
276
+ banner.appendChild(mk('span', BANNER_TITLE, BLOCKED_TEXT[blocked] ? kitText(BLOCKED_TEXT[blocked]!, undefined, root) : ''));
277
+ const why = textOf(data[m.blocked_reason]);
278
+ banner.appendChild(mk('span', '', why !== '' ? why : noReason));
279
+ root.appendChild(banner);
280
+ }
281
+
282
+ // 步骤
283
+ const steps = approvalStepsOf(data[m.steps], p.step_map, noReason, str(p.time_format), str(p.locale));
284
+ if (steps.length === 0) {
285
+ kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: true });
286
+ root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.af_empty', undefined, root))));
287
+ } else {
288
+ const ol = mk('ol', LIST_CLASS);
289
+ ol.setAttribute('role', 'list');
290
+ const selectable = bool(p.selectable);
291
+ steps.forEach((s, index) => {
292
+ const li = mk('li', ITEM_CLASS);
293
+ li.setAttribute(KIT_ATTR_STEP, s.key);
294
+ li.setAttribute(KIT_ATTR_STATUS, s.status);
295
+ if (s.status === 'current') li.setAttribute('aria-current', 'step');
296
+ // 每一步是集合的条目;当前步自报「当前」(aria-current 已在上一行写为 step,帮手不覆盖)
297
+ kitMarkLevel(li, 'item'); kitApplyLevelClass(li);
298
+ kitMarkPicked(li, 'current', s.status === 'current', 'current');
299
+ const rail = mk('div', RAIL_CLASS);
300
+ const dot = mk('span', `${DOT_CLASS} ${s.status === 'pending' ? PENDING_DOT : TONE_SOLID[STATUS_TONE[s.status]]}`, STATUS_GLYPH[s.status]);
301
+ const dotIcon = STATUS_ICON[s.status];
302
+ if (dotIcon) dot.appendChild(kitIcon(dotIcon, 'xs'));
303
+ dot.setAttribute('aria-hidden', 'true');
304
+ rail.appendChild(dot);
305
+ if (index < steps.length - 1) rail.appendChild(mk('span', LINE_CLASS));
306
+ const body = mk('div', s.status === 'current' ? CURRENT_CARD : BODY_CLASS);
307
+ const nameRow = mk('div', NAME_ROW);
308
+ if (selectable) {
309
+ const btn = mk('button', NAME_BUTTON, s.name);
310
+ btn.type = 'button';
311
+ btn.setAttribute(KIT_ATTR_PICK, s.key);
312
+ nameRow.appendChild(btn);
313
+ } else {
314
+ nameRow.appendChild(mk('span', NAME_CLASS, s.name));
315
+ }
316
+ nameRow.appendChild(markStatus(mk('span', `${BADGE_BASE} ${TONE_SOFT[STATUS_TONE[s.status]]}`, label(s.status))));
317
+ if (s.approver !== '' || s.avatar !== '') {
318
+ const person = mk('span', PERSON_CLASS);
319
+ person.setAttribute(KIT_ATTR_PERSON, '');
320
+ const avEl = mk('span', PERSON_AVATAR);
321
+ const avSpec = specOf({ src: s.avatar, name: s.approver, value: s.approver }, 'sm', 'circle');
322
+ paintAvatar(avEl, avSpec, failedAvatars, (failedSrc) => {
323
+ failedAvatars.add(failedSrc);
324
+ paintAvatar(avEl, avSpec, failedAvatars, () => {});
325
+ });
326
+ person.appendChild(avEl);
327
+ if (avSpec.name !== '') person.appendChild(mk('span', PERSON_NAME, avSpec.name));
328
+ if (s.approverRole !== '') person.appendChild(mk('span', PERSON_ROLE, s.approverRole));
329
+ nameRow.appendChild(person);
330
+ }
331
+ if (s.time !== '') nameRow.appendChild(mk('span', s.overdue ? TIME_OVERDUE_CLASS : TIME_CLASS, s.time));
332
+ if (s.overdue) nameRow.appendChild(mk('span', TIME_OVERDUE_CLASS, kitText('soma.kit.flowstat_expired', undefined, root)));
333
+ body.appendChild(nameRow);
334
+ if (s.comment !== '') body.appendChild(mk('p', COMMENT_CLASS, s.comment));
335
+ if (s.reason !== '') {
336
+ const reason = mk('p', `${REASON_BASE} ${TONE_SOFT[STATUS_TONE[s.status]]}`, s.reason);
337
+ reason.setAttribute(KIT_ATTR_REASON, '');
338
+ body.appendChild(reason);
339
+ }
340
+ if (s.actions.length > 0) {
341
+ const acts = mk('div', STEP_ACTIONS);
342
+ for (const a of s.actions) acts.appendChild(actionButton(a));
343
+ body.appendChild(acts);
344
+ }
345
+ li.appendChild(rail);
346
+ li.appendChild(body);
347
+ ol.appendChild(li);
348
+ });
349
+ root.appendChild(ol);
350
+ }
351
+
352
+ // 底部动作
353
+ const actions = actionsOf(data[m.actions]);
354
+ if (actions.length > 0) {
355
+ const foot = mk('div', FOOT_CLASS);
356
+ for (const a of actions) foot.appendChild(actionButton(a));
357
+ root.appendChild(foot);
358
+ }
359
+ },
360
+ };
361
+ }),
271
362
  };
272
363
  }