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
@@ -13,10 +13,11 @@ import type {
13
13
  } from 'soma-core';
14
14
  import { createKeyboardWiring } from 'soma-core/keyboard';
15
15
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
16
+ import { KIT_ICON_LIMITS, KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
16
17
  import { createFormatter, type SomaFormatter } from 'soma-foundation/values';
17
18
  import {
18
19
  KIT_POPUP_PLACE_CLASS_CANDIDATES, POPUP_TIP_BASE, POPUP_TIP_HIDDEN_CLASS, POPUP_TIP_PREF, POPUP_TIP_SHOWN_CLASS,
19
- popupTipClass, showPopupFitted,
20
+ onKitPanelMounted, popupTipClass, queryAllWithDropdowns, showPopupFitted,
20
21
  } from './popup';
21
22
  import { classCandidates } from '../shared/class-candidates';
22
23
  import type { KitSize } from '../shared/primitives-types';
@@ -26,7 +27,13 @@ import { withKitViewTransition } from './view-transition';
26
27
  import { kitBusyOf, onKitActionBusy } from './action-busy';
27
28
  import { deniedBy, registerLivePermissionGate } from './permission-gate';
28
29
  import { kitText } from '../i18n/kit-text';
30
+ import { kitOuterRoot, kitReportSelf, kitReportSelfTracked, type KitSelfReportAttrs } from './kit-contract';
31
+ import { kitFileSizeText } from '../shared/field-value-format';
29
32
  import { mergeClass } from '../shared/merge-class';
33
+ import {
34
+ KIT_ATTR_BADGE, KIT_ATTR_BOARD_PANEL, KIT_ATTR_HERO_SOLO, KIT_ATTR_HERO_STATS, KIT_ATTR_INVALID, KIT_ATTR_LAYER, KIT_ATTR_RKEY,
35
+ KIT_ATTR_SLOT, KIT_ATTR_SUMMARY_EMPTY, KIT_ATTR_TAB,
36
+ } from '../shared/dom-attrs';
30
37
  import {
31
38
  KIT_PART_ATTRIBUTE,
32
39
  KIT_PART_BADGE,
@@ -36,6 +43,7 @@ import {
36
43
  KIT_TYPOGRAPHY_RECIPE_MAP,
37
44
  type KitTypographyRecipeRole,
38
45
  } from '../recipes';
46
+ import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
39
47
 
40
48
  // ── 尺寸档 ────────────────────────────────────────────────────
41
49
 
@@ -55,10 +63,19 @@ export { KIT_TYPOGRAPHY_RECIPE_MAP };
55
63
 
56
64
  export const FOCUS_RING = kitFocusRingRecipe('control');
57
65
 
66
+ const FIELD_ARIA_INVALID = 'aria-invalid:border-danger';
67
+
58
68
  export const FIELD_CLASS: Record<KitSize, string> = {
59
- sm: mergeClass(kitControlRecipe({ size: 'sm', variant: 'outline' }), 'aria-invalid:border-danger'),
60
- md: mergeClass(kitControlRecipe({ size: 'md', variant: 'outline' }), 'aria-invalid:border-danger'),
61
- lg: mergeClass(kitControlRecipe({ size: 'lg', variant: 'outline' }), 'aria-invalid:border-danger'),
69
+ sm: mergeClass(kitControlRecipe({ size: 'sm', variant: 'outline' }), FIELD_ARIA_INVALID),
70
+ md: mergeClass(kitControlRecipe({ size: 'md', variant: 'outline' }), FIELD_ARIA_INVALID),
71
+ lg: mergeClass(kitControlRecipe({ size: 'lg', variant: 'outline' }), FIELD_ARIA_INVALID),
72
+ };
73
+
74
+ /** 触发器按钮用的字段外观(<button> 恒匹配 CSS :read-only 伪类,省略只读态井色背景防常态误染灰底) */
75
+ export const FIELD_TRIGGER_CLASS: Record<KitSize, string> = {
76
+ sm: mergeClass(kitControlRecipe({ size: 'sm', variant: 'outline', trigger: true }), FIELD_ARIA_INVALID),
77
+ md: mergeClass(kitControlRecipe({ size: 'md', variant: 'outline', trigger: true }), FIELD_ARIA_INVALID),
78
+ lg: mergeClass(kitControlRecipe({ size: 'lg', variant: 'outline', trigger: true }), FIELD_ARIA_INVALID),
62
79
  };
63
80
 
64
81
  export const FIELD_INVALID_CLASS = kitInvalidRecipe();
@@ -67,7 +84,15 @@ export function withInvalid(base: string, invalid: boolean): string {
67
84
  return invalid ? `${base} ${FIELD_INVALID_CLASS}` : base;
68
85
  }
69
86
 
70
- export const KIT_SPINNER_CLASS = 'inline-block h-4 w-4 motion-safe:animate-spin rounded-full border-2 border-border border-t-primary';
87
+ // 加载转圈三档(取值表 02 §7:Ant 14 / 20 / 32、TDesign 16 / 36 / 56 → 16 / 20 / 32):边长取间距阶(真源 kit-limits#icons.spinSteps,随 density),
88
+ // 环宽 2、轨与弧跟随宿主字色(border-current/30 border-t-current,解决实心彩色按钮上同色加载圈隐身);减弱动效静止
89
+ const spinClass = (step: number): string => `inline-block size-${step} motion-safe:animate-spin rounded-full border-2 border-current/30 border-t-current`;
90
+ export const KIT_SPIN_CLASS: Readonly<Record<KitSize, string>> = Object.freeze({
91
+ sm: spinClass(KIT_ICON_LIMITS.spinSteps.sm),
92
+ md: spinClass(KIT_ICON_LIMITS.spinSteps.md),
93
+ lg: spinClass(KIT_ICON_LIMITS.spinSteps.lg),
94
+ });
95
+ export const KIT_SPINNER_CLASS = KIT_SPIN_CLASS.sm;
71
96
 
72
97
  // ── props 读取 ────────────────────────────────────────────────
73
98
 
@@ -116,9 +141,16 @@ export interface KitOption {
116
141
  aria_label?: string;
117
142
  /** Radio segmented 读:选项尾部的计数(来自列表响应 facets;没给不显示) */
118
143
  count?: number;
144
+ /** 选项次要说明或分组(保留原始可选元数据供下游选择器读取) */
145
+ desc?: string;
146
+ description?: string;
147
+ group?: string;
119
148
  }
120
149
 
121
150
  const warnedDuplicates = new Set<string>();
151
+ const OPTIONS_CACHE = new WeakMap<readonly unknown[], readonly KitOption[]>();
152
+ const OPTIONS_MAP_CACHE = new WeakMap<readonly unknown[], ReadonlyMap<string, KitOption>>();
153
+ const EMPTY_OPTIONS_MAP: ReadonlyMap<string, KitOption> = new Map();
122
154
 
123
155
  /** 开发环境提示一次(生产构建 / 无 process 时静默) */
124
156
  function warnDuplicateOption(value: string): void {
@@ -131,9 +163,12 @@ function warnDuplicateOption(value: string): void {
131
163
  /**
132
164
  * 选项归一。value 按字符串比较(与 sameValue 同口径)去重:重复的第二项起直接丢弃,首项为准
133
165
  * (不做「标记禁用」:重复项留在列表里会让选中态同时命中多项、键盘游标也停在重复键上);开发环境 warn 一次。
166
+ * 数组引用经 WeakMap 缓存,避免重绘与过滤循环重复归一。
134
167
  */
135
168
  export function optionsOf(raw: unknown): KitOption[] {
136
169
  if (!Array.isArray(raw)) return [];
170
+ const cached = OPTIONS_CACHE.get(raw);
171
+ if (cached !== undefined) return cached as KitOption[];
137
172
  const out: KitOption[] = [];
138
173
  const seen = new Set<string>();
139
174
  const push = (opt: KitOption): void => {
@@ -170,11 +205,38 @@ export function optionsOf(raw: unknown): KitOption[] {
170
205
  ...(unknownTone ? { unknown: true } : {}),
171
206
  ...(rec.disabled === true ? { disabled: true } : {}),
172
207
  ...(typeof rec.count === 'number' && Number.isInteger(rec.count) && rec.count >= 0 ? { count: rec.count } : {}),
208
+ ...(typeof rec.desc === 'string' && rec.desc !== '' ? { desc: rec.desc } : {}),
209
+ ...(typeof rec.description === 'string' && rec.description !== '' ? { description: rec.description } : {}),
210
+ ...(typeof rec.group === 'string' && rec.group !== '' ? { group: rec.group } : {}),
173
211
  });
174
212
  }
213
+ OPTIONS_CACHE.set(raw, out);
214
+ OPTIONS_CACHE.set(out, out);
175
215
  return out;
176
216
  }
177
217
 
218
+ /** 选项按 String(value) -> KitOption 的 O(1) 查表映射(随数组引用 WeakMap 缓存) */
219
+ export function optionsMapOf(raw: unknown): ReadonlyMap<string, KitOption> {
220
+ if (!Array.isArray(raw)) return EMPTY_OPTIONS_MAP;
221
+ const cached = OPTIONS_MAP_CACHE.get(raw);
222
+ if (cached !== undefined) return cached;
223
+ const list = optionsOf(raw);
224
+ const cachedByList = OPTIONS_MAP_CACHE.get(list);
225
+ if (cachedByList !== undefined) {
226
+ OPTIONS_MAP_CACHE.set(raw, cachedByList);
227
+ return cachedByList;
228
+ }
229
+ const map = new Map<string, KitOption>();
230
+ for (const opt of list) {
231
+ if (opt.value === undefined || opt.value === null) continue;
232
+ const key = String(opt.value);
233
+ if (!map.has(key)) map.set(key, opt);
234
+ }
235
+ OPTIONS_MAP_CACHE.set(raw, map);
236
+ OPTIONS_MAP_CACHE.set(list, map);
237
+ return map;
238
+ }
239
+
178
240
  /** 值比较统一走字符串:`1` / `'1'` / `true` / `'true'` 各自互认,option.value 为数字时页面传字符串也命中 */
179
241
  export function sameValue(a: unknown, b: unknown): boolean {
180
242
  return String(a) === String(b);
@@ -195,13 +257,79 @@ export function toneOf(raw: unknown, fallback: KitTone | null): KitTone | null {
195
257
  // ── 显示文字(Text / Tag 共用)──────────────────────────────────
196
258
 
197
259
  const FALLBACK_LOCALE = 'zh-CN';
260
+ const FORMATTER_BY_LOCALE = new Map<string, SomaFormatter | null>();
261
+ const FORMAT_RUNNER_CACHE = new Map<string, (value: unknown, raw: string) => string>();
198
262
 
199
263
  function formatterOf(locale: string): SomaFormatter | null {
264
+ if (FORMATTER_BY_LOCALE.has(locale)) return FORMATTER_BY_LOCALE.get(locale) ?? null;
265
+ let fmt: SomaFormatter | null = null;
200
266
  try {
201
- return createFormatter({ locale, fallbackLocale: FALLBACK_LOCALE, placeholder: '', now: () => Date.now() });
267
+ fmt = createFormatter({ locale, fallbackLocale: FALLBACK_LOCALE, placeholder: '', now: () => Date.now() });
202
268
  } catch {
203
- return null;
269
+ fmt = null;
270
+ }
271
+ FORMATTER_BY_LOCALE.set(locale, fmt);
272
+ return fmt;
273
+ }
274
+
275
+ function formatRunnerOf(locale: string, format: string): (value: unknown, raw: string) => string {
276
+ const effectiveLocale = locale === '' ? FALLBACK_LOCALE : locale;
277
+ const cacheKey = `${effectiveLocale}\0${format}`;
278
+ const hit = FORMAT_RUNNER_CACHE.get(cacheKey);
279
+ if (hit !== undefined) return hit;
280
+ const fmt = formatterOf(effectiveLocale);
281
+ let runner: (value: unknown, raw: string) => string;
282
+ if (!fmt) {
283
+ runner = (_v, raw) => raw;
284
+ } else {
285
+ const [kind, arg] = format.split(':');
286
+ switch (kind) {
287
+ case 'number':
288
+ runner = (v, raw) => fmt.number(v) || raw;
289
+ break;
290
+ case 'percent':
291
+ runner = (v, raw) => fmt.percent(v) || raw;
292
+ break;
293
+ case 'currency':
294
+ runner = arg ? (v, raw) => fmt.currency(v, { currency: arg }) || raw : (_v, raw) => raw;
295
+ break;
296
+ case 'date':
297
+ runner = (v, raw) => fmt.date(v, { style: 'medium', time: 'none' }) || raw;
298
+ break;
299
+ case 'datetime':
300
+ runner = (v, raw) => fmt.date(v, { style: 'medium', time: 'short' }) || raw;
301
+ break;
302
+ case 'relative':
303
+ runner = (v, raw) => fmt.relative(v) || raw;
304
+ break;
305
+ case 'bytes':
306
+ runner = (v, raw) => {
307
+ const n = Number(v);
308
+ return Number.isFinite(n) ? kitFileSizeText(fmt.bytes(n)) : raw;
309
+ };
310
+ break;
311
+ case 'duration': {
312
+ const unit = arg === 'ms' || arg === 's' || arg === 'min' || arg === 'h' || arg === 'd' ? arg : 's';
313
+ runner = (v, raw) => {
314
+ const n = Number(v);
315
+ return Number.isFinite(n) ? fmt.duration(n, unit) : raw;
316
+ };
317
+ break;
318
+ }
319
+ default:
320
+ runner = (_v, raw) => raw;
321
+ break;
322
+ }
204
323
  }
324
+ const safeRunner = (v: unknown, raw: string): string => {
325
+ try {
326
+ return runner(v, raw);
327
+ } catch {
328
+ return raw;
329
+ }
330
+ };
331
+ FORMAT_RUNNER_CACHE.set(cacheKey, safeRunner);
332
+ return safeRunner;
205
333
  }
206
334
 
207
335
  /**
@@ -212,27 +340,7 @@ function formatterOf(locale: string): SomaFormatter | null {
212
340
  export function formatValue(value: unknown, format: string, locale: string): string {
213
341
  const raw = Array.isArray(value) ? value.map((v) => String(v)).join(', ') : String(value);
214
342
  if (format === '') return raw;
215
- const fmt = formatterOf(locale === '' ? FALLBACK_LOCALE : locale);
216
- if (!fmt) return raw;
217
- const [kind, arg] = format.split(':');
218
- try {
219
- switch (kind) {
220
- case 'number': return fmt.number(value) || raw;
221
- case 'percent': return fmt.percent(value) || raw;
222
- case 'currency': return arg ? fmt.currency(value, { currency: arg }) || raw : raw;
223
- case 'date': return fmt.date(value, { style: 'medium', time: 'none' }) || raw;
224
- case 'datetime': return fmt.date(value, { style: 'medium', time: 'short' }) || raw;
225
- case 'relative': return fmt.relative(value) || raw;
226
- case 'bytes': return Number.isFinite(Number(value)) ? fmt.bytes(Number(value)) : raw;
227
- case 'duration': {
228
- const unit = arg === 'ms' || arg === 's' || arg === 'min' || arg === 'h' || arg === 'd' ? arg : 's';
229
- return Number.isFinite(Number(value)) ? fmt.duration(Number(value), unit) : raw;
230
- }
231
- default: return raw;
232
- }
233
- } catch {
234
- return raw;
235
- }
343
+ return formatRunnerOf(locale, format)(value, raw);
236
344
  }
237
345
 
238
346
  export interface DisplayResult {
@@ -263,11 +371,15 @@ export function displayOf(
263
371
  return { text: placeholder, option: null };
264
372
  }
265
373
  if (options.length > 0) {
374
+ const map = optionsMapOf(options);
266
375
  if (Array.isArray(value)) {
267
- const labels = value.map((v) => options.find((o) => sameValue(o.value, v))?.label ?? String(v));
376
+ const labels = value.map((v) => {
377
+ const hit = (v !== undefined && v !== null ? map.get(String(v)) : undefined) ?? options.find((o) => sameValue(o.value, v));
378
+ return hit?.label ?? String(v);
379
+ });
268
380
  return { text: labels.join(', '), option: null };
269
381
  }
270
- const hit = options.find((o) => sameValue(o.value, value)) ?? null;
382
+ const hit = map.get(String(value)) ?? options.find((o) => sameValue(o.value, value)) ?? null;
271
383
  if (hit) return { text: hit.label, option: hit };
272
384
  }
273
385
  return { text: formatValue(value, format, locale), option: null };
@@ -289,7 +401,7 @@ export function findRoot(host: HTMLElement): HTMLElement {
289
401
  */
290
402
  export function kitCollapseBlock(root: HTMLElement, collapsed: boolean): void {
291
403
  root.hidden = collapsed;
292
- const panel = root.closest<HTMLElement>('[data-kit-board-panel="bare"]');
404
+ const panel = root.closest<HTMLElement>(`[${KIT_ATTR_BOARD_PANEL}="bare"]`);
293
405
  if (panel === null) return;
294
406
  panel.hidden = collapsed && !panelHasOtherVisible(panel, root);
295
407
  }
@@ -299,13 +411,13 @@ export function kitCollapseBlock(root: HTMLElement, collapsed: boolean): void {
299
411
  * 统计一侧 = 概况条里 `data-kit-hero-stats` 列内的全部组件宿主,全部带 data-kit-summary-empty 才算整体为空。
300
412
  */
301
413
  export function kitSyncHeroSolo(host: HTMLElement): void {
302
- const hero = host.closest<HTMLElement>('[data-kit-slot="hero"]');
303
- const col = hero?.querySelector<HTMLElement>('[data-kit-hero-stats]') ?? null;
414
+ const hero = host.closest<HTMLElement>(`[${KIT_ATTR_SLOT}="hero"]`);
415
+ const col = hero?.querySelector<HTMLElement>(`[${KIT_ATTR_HERO_STATS}]`) ?? null;
304
416
  if (hero === null || col === null) return;
305
417
  const members = Array.from(col.querySelectorAll<HTMLElement>('[data-soma-component]'));
306
- const empty = members.length > 0 && members.every((m) => m.hasAttribute('data-kit-summary-empty'));
307
- if (empty) hero.setAttribute('data-kit-hero-solo', '');
308
- else hero.removeAttribute('data-kit-hero-solo');
418
+ const empty = members.length > 0 && members.every((m) => m.hasAttribute(KIT_ATTR_SUMMARY_EMPTY));
419
+ if (empty) hero.setAttribute(KIT_ATTR_HERO_SOLO, '');
420
+ else hero.removeAttribute(KIT_ATTR_HERO_SOLO);
309
421
  }
310
422
 
311
423
  /** 面板里除 root 所在组件外,是否还有可见(根未收起)的组件宿主 */
@@ -331,6 +443,142 @@ export function setAttr(el: Element, name: string, value: string): void {
331
443
  else el.setAttribute(name, value);
332
444
  }
333
445
 
446
+ /** 同时写原生 hidden 与 Tailwind `hidden` 类,防止 `.flex` / `.grid` 覆盖 `[hidden]` */
447
+ export function toggleKitHidden(el: HTMLElement, hide: boolean): void {
448
+ el.hidden = hide;
449
+ el.classList.toggle('hidden', hide);
450
+ }
451
+
452
+ /** 重绘前后保持滚动容器位置(stickBottom 为真时贴底) */
453
+ export function preserveKitScroll<T>(
454
+ scroller: HTMLElement | null | undefined,
455
+ mutate: () => T,
456
+ opts?: { stickBottom?: boolean },
457
+ ): T {
458
+ const top = scroller ? scroller.scrollTop : 0;
459
+ const left = scroller ? scroller.scrollLeft : 0;
460
+ const out = mutate();
461
+ if (scroller) {
462
+ if (opts?.stickBottom) {
463
+ scroller.scrollTop = scroller.scrollHeight;
464
+ } else {
465
+ scroller.scrollTop = top;
466
+ scroller.scrollLeft = left;
467
+ }
468
+ }
469
+ return out;
470
+ }
471
+
472
+ /** 安全同步输入框文本:值同跳过、聚焦组词期保护 IME、聚焦更新后按末尾偏移还原光标 */
473
+ export function syncKitTextValue(
474
+ el: HTMLInputElement | HTMLTextAreaElement,
475
+ next: string,
476
+ composing = false,
477
+ ): void {
478
+ if (el.value === next) return;
479
+ const focused = el.ownerDocument.activeElement === el;
480
+ if (composing && focused) return;
481
+ if (!focused) {
482
+ el.value = next;
483
+ return;
484
+ }
485
+ const tail = el.value.length - (el.selectionEnd ?? el.value.length);
486
+ el.value = next;
487
+ try {
488
+ const pos = Math.max(0, next.length - tail);
489
+ el.setSelectionRange(pos, pos);
490
+ } catch {
491
+ // 不支持 setSelectionRange 的输入类型静默忽略
492
+ }
493
+ }
494
+
495
+ /**
496
+ * 基于专用属性 `data-kit-rkey` 原地调和子节点(避免与业务组件 `data-kit-key` 冲突):
497
+ * 同 rkey 节点不摘除重造(保住 `:focus` 与 CSS 过渡),仅摘除不在本轮列表的节点并按序对齐。
498
+ */
499
+ export function reconcileKeyedElements<T>(
500
+ container: HTMLElement,
501
+ items: readonly T[],
502
+ keyOf: (item: T, index: number) => string,
503
+ create: (item: T, index: number) => HTMLElement,
504
+ update: (el: HTMLElement, item: T, index: number) => void,
505
+ ): void {
506
+ const active = container.ownerDocument.activeElement;
507
+ const keepFocus = active !== null && active.nodeType === 1 && container.contains(active) ? (active as HTMLElement) : null;
508
+ const isTextControl = keepFocus !== null && (keepFocus.tagName === 'INPUT' || keepFocus.tagName === 'TEXTAREA');
509
+ let selStart: number | null = null;
510
+ let selEnd: number | null = null;
511
+ let selDir: 'forward' | 'backward' | 'none' | undefined;
512
+ if (isTextControl) {
513
+ try {
514
+ const ctrl = keepFocus as HTMLInputElement | HTMLTextAreaElement;
515
+ selStart = ctrl.selectionStart;
516
+ selEnd = ctrl.selectionEnd;
517
+ selDir = ctrl.selectionDirection ?? undefined;
518
+ } catch {
519
+ // 不支持选区读取的输入类型静默忽略
520
+ }
521
+ }
522
+
523
+ for (const node of Array.from(container.childNodes)) {
524
+ if (node.nodeType !== 1) node.remove();
525
+ }
526
+ const pool = new Map<string, HTMLElement>();
527
+ const orphans: Element[] = [];
528
+ for (const child of Array.from(container.children)) {
529
+ const k = child.getAttribute(KIT_ATTR_RKEY);
530
+ if (k !== null && !pool.has(k)) {
531
+ pool.set(k, child as HTMLElement);
532
+ } else {
533
+ orphans.push(child);
534
+ }
535
+ }
536
+ for (const orphan of orphans) orphan.remove();
537
+
538
+ const resolved: Array<{ el: HTMLElement; item: T; index: number; key: string }> = [];
539
+ for (let i = 0; i < items.length; i += 1) {
540
+ const item = items[i]!;
541
+ const key = keyOf(item, i);
542
+ let el = pool.get(key);
543
+ if (el !== undefined) {
544
+ pool.delete(key);
545
+ } else {
546
+ el = create(item, i);
547
+ el.setAttribute(KIT_ATTR_RKEY, key);
548
+ }
549
+ resolved.push({ el, item, index: i, key });
550
+ }
551
+
552
+ for (const stale of pool.values()) stale.remove();
553
+
554
+ for (let i = 0; i < resolved.length; i += 1) {
555
+ const { el, item, index, key } = resolved[i]!;
556
+ const ref = container.children[i] ?? null;
557
+ if (ref !== el) {
558
+ container.insertBefore(el, ref);
559
+ }
560
+ update(el, item, index);
561
+ if (el.getAttribute(KIT_ATTR_RKEY) !== key) {
562
+ el.setAttribute(KIT_ATTR_RKEY, key);
563
+ }
564
+ }
565
+
566
+ if (keepFocus !== null && keepFocus.isConnected && container.ownerDocument.activeElement !== keepFocus) {
567
+ keepFocus.focus({ preventScroll: true });
568
+ if (
569
+ isTextControl
570
+ && selStart !== null
571
+ && selEnd !== null
572
+ ) {
573
+ try {
574
+ (keepFocus as HTMLInputElement | HTMLTextAreaElement).setSelectionRange(selStart, selEnd, selDir);
575
+ } catch {
576
+ // 不支持 setSelectionRange 的输入类型静默忽略
577
+ }
578
+ }
579
+ }
580
+ }
581
+
334
582
  /** 上一次由 applyCommon 写进 aria-describedby 的 id 串(合并时只替换自己写的那部分,不抹掉控件自带的说明 id) */
335
583
  const APPLIED_DESCRIBEDBY = new WeakMap<Element, string[]>();
336
584
 
@@ -389,16 +637,16 @@ function applyAria(el: Element, p: KitProps): void {
389
637
  el.removeAttribute('aria-required');
390
638
  el.removeAttribute('aria-invalid');
391
639
  el.removeAttribute('aria-errormessage');
392
- setAttr(el, KIT_INVALID_MARK, bool(p.invalid) ? 'true' : '');
640
+ setAttr(el, KIT_ATTR_INVALID, bool(p.invalid) ? 'true' : '');
393
641
  } else {
394
642
  applyValidity(el, p);
395
- el.removeAttribute(KIT_INVALID_MARK);
643
+ el.removeAttribute(KIT_ATTR_INVALID);
396
644
  }
397
645
  mergeDescribedby(el, str(p.aria_describedby, str(p.describedby)));
398
646
  }
399
647
 
400
648
  /** group 根上的无效标记(ARIA 不允许 group 带 aria-invalid;表单据此找首个出错字段) */
401
- export const KIT_INVALID_MARK = 'data-kit-invalid';
649
+ export { KIT_ATTR_INVALID as KIT_INVALID_MARK } from '../shared/dom-attrs';
402
650
 
403
651
  /** 必填 / 无效 / 错误消息关联三个校验属性(只给支持它们的角色:原生输入、radiogroup、combobox、textbox 等) */
404
652
  function applyValidity(el: Element, p: KitProps): void {
@@ -471,6 +719,8 @@ export interface KitApi {
471
719
  emit(name: string, payload?: unknown): void;
472
720
  props(): KitProps;
473
721
  host: HTMLElement;
722
+ /** 实例 id(优先取 core 传入的 ctx.instanceId,回退宿主 data-soma-id) */
723
+ readonly instanceId?: string;
474
724
  /** 契约 `services` 白名单过滤后的运行时服务(虚拟滚动取 `engines.virtual`) */
475
725
  services?: Record<string, unknown>;
476
726
  /** 请求组件重绘(等价于触发新一轮全量 render) */
@@ -501,10 +751,11 @@ export interface KitView {
501
751
 
502
752
  export type KitViewSetup = (api: KitApi) => KitView;
503
753
 
504
- /** 包装异步引擎调用:若 await 返回时本轮 render 已过期或组件已卸载,自动丢弃旧结果(若刚创建出实例且已卸载则销毁) */
505
- function guardAsyncServices(
754
+ export const KIT_ASYNC_ABORTED = Symbol.for('soma.kit.asyncAborted');
755
+
756
+ /** 包装异步引擎调用:当 await 返回时组件已卸载(!isAlive())则自动销毁返回实例并抛出取消哨兵以释放调用栈 finally 锁(createKitController 外层统一兜底静默消化);同存活期内的渲染轮次交组件经 renderApi.isCurrent() 自判 */
757
+ export function guardAsyncServices(
506
758
  services: Record<string, unknown> | undefined,
507
- isCurrent: () => boolean,
508
759
  isAlive: () => boolean,
509
760
  ): Record<string, unknown> | undefined {
510
761
  if (!services || typeof services !== 'object') return services;
@@ -520,18 +771,23 @@ function guardAsyncServices(
520
771
  proxyPort[m] = (...args: unknown[]) => {
521
772
  const res = (fn as (...a: unknown[]) => unknown).apply(port, args);
522
773
  if (res && typeof (res as Promise<unknown>).then === 'function') {
523
- return (res as Promise<unknown>).then((val) => {
524
- if (!isAlive()) {
525
- if (val && typeof (val as { dispose?: () => void }).dispose === 'function') {
526
- (val as { dispose: () => void }).dispose();
774
+ return (res as Promise<unknown>).then(
775
+ (val) => {
776
+ if (!isAlive()) {
777
+ if (val && typeof (val as { dispose?: () => void }).dispose === 'function') {
778
+ (val as { dispose: () => void }).dispose();
779
+ }
780
+ throw KIT_ASYNC_ABORTED;
781
+ }
782
+ return val;
783
+ },
784
+ (err) => {
785
+ if (!isAlive()) {
786
+ throw KIT_ASYNC_ABORTED;
527
787
  }
528
- return new Promise<never>(() => {});
529
- }
530
- if (!isCurrent()) {
531
- return new Promise<never>(() => {});
532
- }
533
- return val;
534
- });
788
+ throw err;
789
+ },
790
+ );
535
791
  }
536
792
  return res;
537
793
  };
@@ -555,7 +811,110 @@ export function onKitControllerMount(hook: (host: HTMLElement) => void): void {
555
811
  * onMount 取根、挂事件并首绘,onPropsChange 全量重绘,onUnmount 统一执行清理函数。
556
812
  * 异步 render 由骨架统一处理后发先至(旧结果自动丢弃);handle 由骨架挂到 core 读取位置。
557
813
  */
558
- export function createKitController(setup: KitViewSetup | KitView): SomaComponentControllerFactory {
814
+ /**
815
+ * 骨架的组件契约选项(主题流水线):组件只声明自己知道的事实,骨架在挂载时统一写到模板最外层根上(不覆盖已有属性),
816
+ * 各组件不必在每个文件里重复「找外层根 + 自报」。可以是函数:按当轮入参决定(如 Card 有无标题都是对象面,但组件按用途有别)。
817
+ */
818
+ export interface KitControllerOptions {
819
+ /** 根节点自报(层级角色、元素部件、区域作用域);数据状态随数据变,组件在 render 里用 kitMarkDataState 写 */
820
+ readonly self?: KitSelfReportAttrs | ((p: KitProps) => KitSelfReportAttrs | undefined);
821
+ /**
822
+ * 模板内部节点的自报:[选择器(在组件宿主内取第一个匹配), 自报事实]。骨架每次绘制前写(经 kitReportSelf:按当前模式,旧版只写区域作用域;
823
+ * 已有的层级角色 / 元素部件不覆盖)。用它代替在静态模板串里拼 kitSelfAttrs——模板在组件创建时求值,那时的模式不可靠。
824
+ * 选择器按模板内的 data-soma-id 写时用 kitSid(id)(同时认核心改写后的 data-soma-scoped-id)。
825
+ */
826
+ readonly selfParts?: readonly KitSelfPart[];
827
+ }
828
+
829
+ /**
830
+ * 一条模板内部节点的自报:缺省取第一个匹配;第三项写 'all' 时写全部匹配(按行重复的 <template data-soma-role="item"> 里的节点用)。
831
+ * 匹配范围 = 组件宿主内(不进嵌套的别的组件宿主)+ 本组件挂到浮层端口里的面板(面板打开时不在宿主的后代中,见 popup.ts#queryAllWithDropdowns)。
832
+ */
833
+ export type KitSelfPart =
834
+ | readonly [selector: string, report: KitSelfReportAttrs]
835
+ | readonly [selector: string, report: KitSelfReportAttrs, match: 'all'];
836
+
837
+ /** 模板内节点的选择器:核心挂载后模板内的 data-soma-id 可能改写成 data-soma-scoped-id,两种都认 */
838
+ export function kitSid(id: string): string {
839
+ return `[data-soma-scoped-id="${id}"], [data-soma-id="${id}"]`;
840
+ }
841
+
842
+ /** 模板根(data-soma-id="root")下按子路径找的节点(没有 id 的模板节点用):path 如 'button > span' */
843
+ export function kitRootChild(path: string): string {
844
+ return `[data-soma-scoped-id="root"] > ${path}, [data-soma-id="root"] > ${path}`;
845
+ }
846
+
847
+ /** 节点属于宿主自己(不在宿主里嵌套的别的组件宿主里;插槽里收养的子组件可能有同名 id) */
848
+ function ownedBy(host: HTMLElement, el: Element): boolean {
849
+ const owner = el.parentElement?.closest('[data-soma-component]') ?? null;
850
+ return owner === null || owner === host || !host.contains(owner);
851
+ }
852
+
853
+ /** 宿主内(含本宿主挂到浮层端口里的面板)全部属于宿主自己的匹配节点,宿主内的在前 */
854
+ function ownNodes(host: HTMLElement, sel: string): Element[] {
855
+ const inHost = Array.from(host.querySelectorAll(sel)).filter((el) => ownedBy(host, el));
856
+ // 端口里的面板:锚点在本宿主内的面板整块算本宿主的(面板里嵌套的别的组件宿主照样排除)
857
+ const ported = queryAllWithDropdowns(host, sel).filter((el) => !host.contains(el) && (el.parentElement?.closest('[data-soma-component]') ?? null) === null);
858
+ return [...inHost, ...ported];
859
+ }
860
+
861
+ /** 宿主内第一个匹配、且不在嵌套的别的组件宿主里的节点(命中即止,宿主内找到就不再扫浮层端口,避免分配全量数组) */
862
+ function ownNode(host: HTMLElement, sel: string): Element | null {
863
+ const inHost = host.querySelectorAll(sel);
864
+ for (let i = 0; i < inHost.length; i += 1) {
865
+ const el = inHost[i]!;
866
+ if (ownedBy(host, el)) return el;
867
+ }
868
+ const ported = queryAllWithDropdowns(host, sel);
869
+ for (let i = 0; i < ported.length; i += 1) {
870
+ const el = ported[i]!;
871
+ if (!host.contains(el) && (el.parentElement?.closest('[data-soma-component]') ?? null) === null) return el;
872
+ }
873
+ return null;
874
+ }
875
+
876
+ /** 按 selfParts 写一遍模板内部节点的自报(经 kitReportSelf:按当前模式,旧版只写区域作用域) */
877
+ function writeSelfParts(host: HTMLElement, parts: readonly KitSelfPart[]): void {
878
+ // 旧版只写区域作用域:不带区域作用域的项在旧版下什么也不写,先判断模式,不为它们查询节点(每次绘制都会走到这里)
879
+ const next = kitIsNextRuntime();
880
+ for (const part of parts) {
881
+ const [sel, report] = part;
882
+ if (!next && report.scope === undefined) continue;
883
+ if (part[2] === 'all') for (const el of ownNodes(host, sel)) kitReportSelf(el, report);
884
+ else kitReportSelf(ownNode(host, sel), report);
885
+ }
886
+ }
887
+
888
+ /**
889
+ * 不经骨架的组件(或骨架之外的绘制时机,如核心按行重画之后)对全部匹配节点写自报:口径同 selfParts 的 'all'。
890
+ * 旧版只写区域作用域(kitReportSelf):旧版且 report 不带区域作用域时什么也不写,直接返回空、不查询节点。
891
+ * 返回本次写到的节点(调用方要对同一批节点再做别的事时复用,不必再查一遍)。
892
+ */
893
+ export function kitReportSelfAll(host: HTMLElement, selector: string, report: KitSelfReportAttrs): readonly Element[] {
894
+ if (report.scope === undefined && !kitIsNextRuntime()) return [];
895
+ const nodes = ownNodes(host, selector);
896
+ for (const el of nodes) kitReportSelf(el, report);
897
+ return nodes;
898
+ }
899
+
900
+ /**
901
+ * 面板挂到浮层端口时补写自报:首次绘制时面板可能还没建出或已不在宿主里,挂出那一刻按宿主登记的 selfParts 再写一遍。
902
+ * 登记在挂载时、撤销在卸载时(SELF_PART_WRITERS);从锚点往上逐个组件宿主找登记(嵌套组件各写各的)。
903
+ */
904
+ const SELF_PART_WRITERS = new WeakMap<HTMLElement, () => void>();
905
+ let panelHookOn = false;
906
+ /** 首次有组件登记时才接到 popup.ts 的挂出钩子(不在模块顶层调:避免与 popup.ts 的加载次序相依) */
907
+ function ensurePanelHook(): void {
908
+ if (panelHookOn) return;
909
+ panelHookOn = true;
910
+ onKitPanelMounted((anchor) => {
911
+ for (let h: HTMLElement | null = anchor.closest<HTMLElement>('[data-soma-component]'); h !== null; h = h.parentElement?.closest<HTMLElement>('[data-soma-component]') ?? null) {
912
+ SELF_PART_WRITERS.get(h)?.();
913
+ }
914
+ });
915
+ }
916
+
917
+ export function createKitController(setup: KitViewSetup | KitView, options: KitControllerOptions = {}): SomaComponentControllerFactory {
559
918
  const setupFn: KitViewSetup | null = typeof setup === 'function' ? setup : (setup && typeof setup === 'object' && typeof (setup as KitView).render === 'function' ? () => setup as KitView : null);
560
919
  if (!setupFn) {
561
920
  throw new Error('[soma-kit] createKitController 只接受 (api: KitApi) => KitView 构造函数');
@@ -567,6 +926,12 @@ export function createKitController(setup: KitViewSetup | KitView): SomaComponen
567
926
  let seq = 0;
568
927
  let view: KitView;
569
928
  const readProps = (): KitProps => (ctx.readProps ? ctx.readProps() : ctx.props);
929
+ const resolveInstanceId = (): string | undefined => {
930
+ const raw = (ctx as { instanceId?: unknown }).instanceId;
931
+ if (typeof raw === 'string' && raw !== '') return raw;
932
+ const attr = ctx.host?.getAttribute?.('data-soma-id');
933
+ return typeof attr === 'string' && attr !== '' ? attr : undefined;
934
+ };
570
935
  const applyPerm = (): void => {
571
936
  const p = readProps();
572
937
  if (p && 'permission' in p) {
@@ -583,11 +948,19 @@ export function createKitController(setup: KitViewSetup | KitView): SomaComponen
583
948
  emit: api.emit,
584
949
  props: readProps,
585
950
  host: ctx.host,
586
- services: guardAsyncServices(ctx.services, isCurrent, () => alive),
951
+ get instanceId(): string | undefined { return resolveInstanceId(); },
952
+ services: guardAsyncServices(ctx.services, () => alive),
587
953
  refresh: api.refresh,
588
954
  isCurrent,
589
955
  };
590
- const out = view.render(root, readProps(), renderApi);
956
+ const props = readProps();
957
+ // 旧版(legacy)直接跳过全部自报 DOM 查询与回调计算;新模式下根节点自报放在 render 之前:
958
+ // 组件 render 里改写根的 className 不影响属性;self 返回值变了就改写,变成 undefined 时对称清掉自报上一次写的值。
959
+ if (kitIsNextRuntime()) {
960
+ if (options.self !== undefined) kitReportSelfTracked(kitOuterRoot(ctx.host, root), typeof options.self === 'function' ? options.self(props) : options.self);
961
+ if (options.selfParts !== undefined) writeSelfParts(ctx.host, options.selfParts);
962
+ }
963
+ const out = view.render(root, props, renderApi);
591
964
  if (out && typeof (out as Promise<void>).then === 'function') {
592
965
  (out as Promise<void>).catch(() => {});
593
966
  }
@@ -597,6 +970,7 @@ export function createKitController(setup: KitViewSetup | KitView): SomaComponen
597
970
  emit: (name, payload) => ctx.emit(name, payload),
598
971
  props: readProps,
599
972
  host: ctx.host,
973
+ get instanceId(): string | undefined { return resolveInstanceId(); },
600
974
  services: ctx.services,
601
975
  refresh: () => {
602
976
  if (alive) {
@@ -618,26 +992,29 @@ export function createKitController(setup: KitViewSetup | KitView): SomaComponen
618
992
  alive = true;
619
993
  root = findRoot(ctx.host);
620
994
  for (const hook of MOUNT_HOOKS) hook(ctx.host);
995
+ const parts = options.selfParts;
996
+ if (parts !== undefined) { ensurePanelHook(); SELF_PART_WRITERS.set(ctx.host, () => { if (alive && kitIsNextRuntime()) writeSelfParts(ctx.host, parts); }); }
621
997
  offPerm = registerLivePermissionGate(applyPerm);
622
998
  cleanup = view.attach?.(root, api);
623
999
  paint();
624
1000
  if (view.busyAware === true) {
625
- lastBusy = kitBusyOf(api.props());
1001
+ lastBusy = kitBusyOf(api.props(), ctx.host);
626
1002
  offBusy = onKitActionBusy(() => {
627
- const now = kitBusyOf(api.props());
1003
+ const now = kitBusyOf(api.props(), ctx.host);
628
1004
  if (now === lastBusy) return;
629
1005
  lastBusy = now;
630
1006
  paint();
631
- });
1007
+ }, ctx.host);
632
1008
  }
633
1009
  },
634
1010
  onPropsChange(): void {
635
- if (view.busyAware === true) lastBusy = kitBusyOf(api.props());
1011
+ if (view.busyAware === true) lastBusy = kitBusyOf(api.props(), ctx.host);
636
1012
  paint();
637
1013
  },
638
1014
  onUnmount(): void {
639
1015
  alive = false;
640
1016
  seq += 1;
1017
+ SELF_PART_WRITERS.delete(ctx.host);
641
1018
  offPerm?.();
642
1019
  offPerm = null;
643
1020
  offBusy?.();
@@ -668,16 +1045,27 @@ export function createKitController(setup: KitViewSetup | KitView): SomaComponen
668
1045
  // 角标是目标元素内的一个绝对定位子元素(目标补 `relative`):计数(超过 badge_max 显示 `99+`,≤0 与空不显示)或小红点。
669
1046
  // 计数优先于小红点;文字走 textContent。Tag 已有 `dot`(文字前状态点),所以角标小红点统一叫 `badge_dot`。
670
1047
 
671
- export const BADGE_COUNT_CLASS = 'absolute -end-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-danger px-1 text-xs font-medium text-danger-fg ring-2 ring-surface';
672
- export const BADGE_DOT_CLASS = 'absolute -end-0.5 -top-0.5 h-2.5 w-2.5 rounded-full bg-danger ring-2 ring-surface';
1048
+ // 取值表 02 §2(Ant / Arco / TDesign):计数高 20 / 最小宽 20 / 横内边距 6 / 字 12 / 400 / 全圆;红点 6(size-status-dot,固定不随密度);与锚点间 2px 容器底色环
1049
+ export const BADGE_COUNT_CLASS = 'absolute -end-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-danger px-1.5 text-xs font-normal text-danger-fg ring-2 ring-surface-current';
1050
+ export const BADGE_DOT_CLASS = 'absolute -end-0.5 -top-0.5 size-status-dot rounded-full bg-danger ring-2 ring-surface-current';
673
1051
  const BADGE_ANCHOR_CLASS = 'relative';
674
1052
 
675
- export const KIT_BADGE_CLASS_CANDIDATES: readonly string[] = classCandidates(BADGE_COUNT_CLASS, BADGE_DOT_CLASS, BADGE_ANCHOR_CLASS);
1053
+ /**
1054
+ * 计数角标的语气:danger = 提醒(未读、待办,缺省);primary = 状态计数(如「筛选」入口上的已设条件数——不是告警,不用红)。
1055
+ * 实心底只配同色 -fg 字(色彩角色配对)。
1056
+ * 状态计数挂在图标钮上(窄窗格「筛选」入口,14px 图标在 32px 钮心):小一档(16)并整枚外移到钮的右上角外侧,
1057
+ * 不压图标——图标必须完整可见(主会话裁决 2026-11-24:20 的提醒角标压在图标右上角,图标几乎看不见)
1058
+ */
1059
+ const BADGE_COUNT_PRIMARY_CLASS = BADGE_COUNT_CLASS
1060
+ .replace('-end-1 -top-1', '-end-2 -top-2').replace('h-5 min-w-5', 'h-4 min-w-4')
1061
+ .replace('bg-danger', 'bg-primary').replace('text-danger-fg', 'text-primary-fg');
1062
+ export const KIT_BADGE_CLASS_CANDIDATES: readonly string[] = classCandidates(BADGE_COUNT_CLASS, BADGE_COUNT_PRIMARY_CLASS, BADGE_DOT_CLASS, BADGE_ANCHOR_CLASS, Object.values(KIT_SPIN_CLASS));
676
1063
 
677
1064
  export const BADGE_PROPS = {
678
1065
  badge: { type: 'string', default: '', desc: '右上角计数(超过 badge_max 显示 99+,0 / 空不显示;文字原样显示)' },
679
1066
  badge_max: { type: 'number', default: 99, desc: '计数封顶值,超过显示「N+」' },
680
1067
  badge_dot: { type: 'boolean', default: false, desc: '右上角小红点(badge 有值时以计数为准)' },
1068
+ badge_tone: { type: 'string', default: 'danger', desc: '计数角标语气 danger / primary:danger = 提醒(未读 / 待办,缺省);primary = 状态计数(如已设筛选条件数),不是告警;其它值按 danger' },
681
1069
  } as const;
682
1070
 
683
1071
  /** 角标文字:数字 ≤0 为空、超过 max 显示 `max+`,非数字原样 */
@@ -693,19 +1081,19 @@ export function paintBadge(host: HTMLElement, p: KitProps): boolean {
693
1081
  const maxRaw = num(p.badge_max);
694
1082
  const text = badgeText(p.badge, maxRaw !== null && maxRaw >= 1 ? Math.floor(maxRaw) : 99);
695
1083
  const dot = text === '' && bool(p.badge_dot);
696
- let el = Array.from(host.children).find((c) => c.hasAttribute('data-kit-badge')) as HTMLElement | undefined;
1084
+ let el = Array.from(host.children).find((c) => c.hasAttribute(KIT_ATTR_BADGE)) as HTMLElement | undefined;
697
1085
  if (text === '' && !dot) {
698
1086
  el?.remove();
699
1087
  return false;
700
1088
  }
701
1089
  if (!el) {
702
1090
  el = document.createElement('span');
703
- el.setAttribute('data-kit-badge', '');
1091
+ el.setAttribute(KIT_ATTR_BADGE, '');
704
1092
  el.setAttribute(KIT_PART_ATTRIBUTE, KIT_PART_BADGE);
705
1093
  host.appendChild(el);
706
1094
  }
707
1095
  if (text !== '') {
708
- el.className = BADGE_COUNT_CLASS;
1096
+ el.className = p.badge_tone === 'primary' ? BADGE_COUNT_PRIMARY_CLASS : BADGE_COUNT_CLASS;
709
1097
  el.textContent = text;
710
1098
  el.removeAttribute('role');
711
1099
  el.removeAttribute('aria-label');
@@ -807,7 +1195,7 @@ export interface KitTablistHandle {
807
1195
  export function wireKitTablist(root: HTMLElement, opts: KitTablistOptions = {}): KitTablistHandle {
808
1196
  const orientation = opts.orientation ?? 'horizontal';
809
1197
  const activation = opts.activation ?? 'auto';
810
- const tabsOf = opts.tabs ?? ((): HTMLElement[] => Array.from(root.querySelectorAll<HTMLElement>('[role="tab"], [data-kit-tab]')));
1198
+ const tabsOf = opts.tabs ?? ((): HTMLElement[] => Array.from(root.querySelectorAll<HTMLElement>(`[role="tab"], [${KIT_ATTR_TAB}]`)));
811
1199
  const idOf = opts.idOf ?? ((tab: HTMLElement): string => tab.dataset.key ?? tab.id);
812
1200
  const isDisabled = (tab: HTMLElement): boolean => tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true';
813
1201
 
@@ -930,11 +1318,11 @@ export function wireKitTablist(root: HTMLElement, opts: KitTablistOptions = {}):
930
1318
 
931
1319
  const onKeydown = (event: KeyboardEvent): void => {
932
1320
  const target = event.target as HTMLElement | null;
933
- if (!target || !target.closest('[role="tab"], [data-kit-tab]')) return;
1321
+ if (!target || !target.closest(`[role="tab"], [${KIT_ATTR_TAB}]`)) return;
934
1322
  if (wiring.onKeydown(event)) event.preventDefault();
935
1323
  };
936
1324
  const onClick = (event: Event): void => {
937
- const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>('[role="tab"], [data-kit-tab]');
1325
+ const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[role="tab"], [${KIT_ATTR_TAB}]`);
938
1326
  if (!tab || !root.contains(tab)) return;
939
1327
  select(idOf(tab));
940
1328
  };
@@ -996,6 +1384,12 @@ export function withTooltip(viewOrSetup: KitView | KitViewSetup, targetOf: (root
996
1384
  return setupFn;
997
1385
  }
998
1386
 
1387
+ /**
1388
+ * 提示气泡的出现时序(真源 motion#/timing/tooltip,经 kit-limits#overlay.tooltipOpenDelayMs / tooltipSkipDelayMs):
1389
+ * 指针首次悬停等 openDelay 才出现;任一气泡收起后 skipDelay 内移到相邻目标立即出现(全部气泡共用这一个时刻);键盘聚焦立即出现。
1390
+ */
1391
+ let kitTipLastHideAt = Number.NEGATIVE_INFINITY;
1392
+
999
1393
  function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLElement = (r) => r): KitView {
1000
1394
  // 视图对象在同一组件定义的所有实例间共享,逐实例状态按根元素存
1001
1395
  // bound / rebind:目标可随渲染变化(如 MenuButton split 时目标由箭头钮换成主钮),监听跟着目标走
@@ -1041,18 +1435,32 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
1041
1435
  s.shown = true;
1042
1436
  paintTip(s);
1043
1437
  };
1438
+ let pending: ReturnType<typeof setTimeout> | null = null;
1439
+ const cancelPending = (): void => {
1440
+ if (pending !== null) clearTimeout(pending);
1441
+ pending = null;
1442
+ };
1044
1443
  const hide = (): void => {
1444
+ cancelPending();
1045
1445
  if (!s.shown) return;
1046
1446
  s.shown = false;
1447
+ kitTipLastHideAt = Date.now();
1047
1448
  paintTip(s);
1048
1449
  };
1450
+ // 指针悬停:相邻免延迟窗口内立即出现,否则等 openDelay(键盘聚焦走 show,立即出现)
1451
+ const hover = (): void => {
1452
+ cancelPending();
1453
+ if (Date.now() - kitTipLastHideAt <= KIT_OVERLAY_LIMITS.tooltipSkipDelayMs) { show(); return; }
1454
+ pending = setTimeout(() => { pending = null; show(); }, KIT_OVERLAY_LIMITS.tooltipOpenDelayMs);
1455
+ };
1049
1456
  const onKey = (event: KeyboardEvent): void => {
1050
1457
  if (event.key === 'Escape') hide();
1051
1458
  };
1052
1459
  const unbind = (): void => {
1053
1460
  const t = s.bound;
1054
1461
  if (t === null) return;
1055
- t.removeEventListener('mouseenter', show);
1462
+ cancelPending();
1463
+ t.removeEventListener('mouseenter', hover);
1056
1464
  t.removeEventListener('mouseleave', hide);
1057
1465
  t.removeEventListener('focusin', show);
1058
1466
  t.removeEventListener('focusout', hide);
@@ -1063,7 +1471,7 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
1063
1471
  if (s.bound === t) return;
1064
1472
  if (s.bound !== null && s.tip !== null) removeIdToken(s.bound, 'aria-describedby', s.tip.id);
1065
1473
  unbind();
1066
- t.addEventListener('mouseenter', show);
1474
+ t.addEventListener('mouseenter', hover);
1067
1475
  t.addEventListener('mouseleave', hide);
1068
1476
  t.addEventListener('focusin', show);
1069
1477
  t.addEventListener('focusout', hide);
@@ -1103,6 +1511,7 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
1103
1511
  s.tip = document.createElement('span');
1104
1512
  s.tip.id = nextUid('kit-tip');
1105
1513
  s.tip.setAttribute('role', 'tooltip');
1514
+ s.tip.setAttribute(KIT_ATTR_LAYER, 'float');
1106
1515
  }
1107
1516
  s.tip.textContent = text;
1108
1517
  if (s.tip.parentNode !== target) target.appendChild(s.tip);
@@ -1119,5 +1528,7 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
1119
1528
  }
1120
1529
 
1121
1530
  export * from '../recipes';
1531
+ // 主题流水线组件契约通道(自报、读 kit 入参、可收纳、二次确认端口):基础组件统一从 shared 取
1532
+ export * from './kit-contract';
1122
1533
  export * from './loading-gate';
1123
1534
  export { withKitViewTransition, canKitViewTransition } from './view-transition';