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
@@ -10,15 +10,63 @@
10
10
  // 组件不改数据:写入只抛事件;勾选只抛 select_change(载荷 rows 批量,协调组件维护已选)。
11
11
  // 记忆(列显隐、行高):localStorage,键含页面路径与对象名,读写全包 try/catch。
12
12
 
13
+ import { kitApplyLevelClass } from '../data/level-class';
13
14
  import { substituteConfirmText, type SomaComponentDefinition, type SomaDataPort, type SomaRegionPort } from 'soma-core';
14
15
  import { tableQuerySignature } from './collection-table';
15
16
  import { KIT_ROW_TONE_CLASS } from './view-binding';
16
- import { KIT_FACE_FIELD, KIT_FACE_RAISED, kitDisabledRecipe, kitSegmentRecipe, kitTextActionRecipe, setKitFace, type KitFaceKind } from '../recipes';
17
- import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
17
+ import { KIT_FACE_FIELD, KIT_FACE_RAISED, kitDisabledRecipe, kitFocusRingRecipe, kitSegmentRecipe, setKitFace, type KitFaceKind } from '../recipes';
18
+ import { kitActionRecipe, kitEmphasisButtonRecipe } from '../recipes/emphasis';
19
+ import { kitSurfaceRecipe } from '../recipes/surface';
20
+ import { kitTabRecipe } from '../recipes/tabs';
21
+ import { kitTypographyRecipe } from '../recipes/typography';
22
+ import { KIT_DIVIDER_FOOT_CLASS } from '../recipes/divider';
23
+ import { kitTableToolsRootClass } from '../recipes/self-owned';
24
+ import {
25
+ KIT_ATTR_BATCH,
26
+ KIT_ATTR_BATCH_NO,
27
+ KIT_ATTR_BATCH_YES,
28
+ KIT_ATTR_CLS,
29
+ KIT_ATTR_COL,
30
+ KIT_ATTR_COL_TOGGLE,
31
+ KIT_ATTR_COLS_PANEL,
32
+ KIT_ATTR_COLS_RESET,
33
+ KIT_ATTR_DENSE,
34
+ KIT_ATTR_EDGE_L,
35
+ KIT_ATTR_EDGE_R,
36
+ KIT_ATTR_EDIT_CONTROL,
37
+ KIT_ATTR_EDIT_READY,
38
+ KIT_ATTR_EDITABLE,
39
+ KIT_ATTR_GROUP_COLS,
40
+ KIT_ATTR_GROUP_COUNT,
41
+ KIT_ATTR_GROUP_HEAD,
42
+ KIT_ATTR_GROUP_TEXT,
43
+ KIT_ATTR_INDEX,
44
+ KIT_ATTR_LIVE,
45
+ KIT_ATTR_MERGE,
46
+ KIT_ATTR_MERGED,
47
+ KIT_ATTR_PAGE_ALL,
48
+ KIT_ATTR_PAGE_SELECT,
49
+ KIT_ATTR_RESIZABLE,
50
+ KIT_ATTR_RESIZE,
51
+ KIT_ATTR_ROOMY,
52
+ KIT_ATTR_ROWS,
53
+ KIT_ATTR_SEL_CLEAR,
54
+ KIT_ATTR_SELECT_ALL,
55
+ KIT_ATTR_SERIAL,
56
+ KIT_ATTR_SUMMARY,
57
+ KIT_ATTR_TABLE,
58
+ KIT_ATTR_TABLE_DENSITY,
59
+ KIT_ATTR_TABLE_OF,
60
+ KIT_ATTR_TOOL,
61
+ } from '../shared/dom-attrs';
62
+ import { mergeClass } from '../shared/merge-class';
63
+ import { kitSelectedRecipe } from '../recipes/state';
64
+ import { KIT_FIELD_TEXT_CLASS_CANDIDATES, kitFieldNameRecipe } from '../recipes/field-text';
65
+ import { REORDER_CLASS_CANDIDATES, bindRowReorder, reorderFromIntent, type ReorderDragPort } from './table-reorder';
18
66
  import { measureEdges } from '../base/end-edge';
19
67
  import { CLASS_PROP, createKitController, num, str } from '../base/shared';
20
68
  import { KIT_DROPDOWN_CLASS_CANDIDATES, onOutsidePress, overlayVerdict, releaseDropdownsIn, syncDropdown } from '../base/popup';
21
- import { permissionCheckerOf } from '../base/permission-gate';
69
+ import { permissionCheckerOf, registerLivePermissionGate } from '../base/permission-gate';
22
70
  import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, isMark, markInput, paintCheck } from '../base/check-core';
23
71
  import { attachSpin } from '../base/qty-stepper';
24
72
  import { KIT_DATE_CLASS_CANDIDATES, mountKitDateField } from '../base/date';
@@ -26,62 +74,95 @@ import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
26
74
  import { createKitEmbedBag, mountKitSelectField, type KitEmbedHandle } from '../data/embed';
27
75
  import { KIT_TABLE_ACTIONS_CLASS_CANDIDATES, ACTION_BUTTON_CLASS } from './table-actions';
28
76
  import { KIT_TABLE_DENSITIES, KIT_TABLE_DENSITY_DEFAULT, KIT_TABLE_EXT, type KitTableDensity } from './defaults';
29
- import { attachResizeHandle, type ResizeHandle } from '../frames/resize-handle';
77
+ import { attachResizeHandle, type ResizeHandle } from '../base/resize-handle';
30
78
  import { kitText, type KitTextKey } from '../i18n/kit-text';
31
79
  import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
32
- import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
80
+ import { isKitActionBusy, isKitObjectBusyChannel, onKitActionBusy } from '../base/action-busy';
33
81
  import { KIT_ACTION_MORE_CLASS_CANDIDATES, buildActionGroup, type DomActionEntry } from './action-more';
82
+ import { kitActionPropsOf, kitMarkLevel, kitMarkPart, kitMarkPicked } from '../data/kit-contract';
83
+ import { createKitRowConfirm } from '../data/row-confirm';
84
+ import { kitRowKey } from '../shared/row-key';
34
85
 
35
86
  /** 按语气取质感标记:primary 实心 / neutral 描边有面;danger 是透明底幽灵钮,无面不标 */
36
87
  const faceOfTone = (tone: 'primary' | 'danger' | 'neutral'): KitFaceKind | null => (tone === 'danger' ? null : KIT_FACE_RAISED);
37
88
 
38
89
  // ---------------------------------------------------------------- 类(整串字面量)
39
90
 
40
- // 工具条 / 批量条里的成组动作恒单行(action-group.ts:排布引擎投影):根与组都不换行,放不下的次要动作收进「更多」
41
- const ROOT_CLASS = 'flex flex-nowrap items-center justify-between gap-2 pb-2';
42
- const GROUP_CLASS = 'flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2';
91
+ // 工具条 / 批量条:常态单行贴右,触控档(touch-pill)或窄容器放不下密度分段槽与操作组时允许受控折行,杜绝左右横向冲出容器
92
+ const ROOT_CLASS = 'flex w-full max-w-full flex-wrap items-center justify-between gap-2 pb-2';
93
+ const GROUP_CLASS = 'flex min-w-0 max-w-full flex-1 flex-wrap items-center justify-end gap-2';
43
94
  // 工具条按钮 / 分段按钮 / 文字链接:控件引擎的配方(工具条宿主 tight),不再手写按钮类串
44
95
  const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar', { tight: true });
45
- const SEG_GROUP_CLASS = 'inline-flex items-center rounded-md border border-border-subtle bg-surface p-0.5';
96
+ // 分段组 = 分段控件的槽(与 SegmentedSwitch 同一个出口 kitTabRecipe().segRoot:凹槽面、无描边;一种呈现一个配方,不再自画一圈灰线)
97
+ const SEG_GROUP_CLASS = kitTabRecipe().segRoot;
46
98
  const SEG_BTN_CLASS = kitSegmentRecipe(false);
47
99
  const SEG_BTN_ON_CLASS = kitSegmentRecipe(true);
48
- const BATCH_BAR_CLASS = 'flex w-full flex-nowrap items-center gap-2 whitespace-nowrap rounded-lg bg-primary-soft px-3 py-1.5 text-sm text-primary-on-soft';
100
+ // 批量条 = 「已选中 N 行」的呈现:选中只走 kitSelectedRecipe()(KT-HB-F 第 2 条)
101
+ const BATCH_BAR_CLASS = mergeClass('flex w-full flex-nowrap items-center gap-2 whitespace-nowrap rounded-card px-3 py-1.5 text-sm', kitSelectedRecipe());
49
102
  const BATCH_TEXT_CLASS = 'shrink-0 font-medium';
50
- const LINK_BTN_CLASS = kitTextActionRecipe('primary');
103
+ const LINK_BTN_CLASS = kitActionRecipe('reset', { tight: true, size: 'sm' });
51
104
  const CHECK_TEXT_CLASS = 'text-sm text-fg';
52
105
  const PANEL_CHECK_CLASS = 'w-full px-2 py-1 text-sm text-fg hover:bg-state-layer-hover active:bg-state-layer-press';
53
106
  const PANEL_CHECK_LOCKED_CLASS = 'w-full px-2 py-1 text-sm';
54
107
  const ANCHOR_CLASS = 'relative inline-flex';
55
- const PANEL_BASE = 'absolute z-20 w-56 rounded-lg border border-border-subtle bg-surface-raised p-2 text-sm text-fg shadow-lg';
56
- const PANEL_ITEM_CLASS = 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-state-layer-hover active:bg-state-layer-press';
57
- const PANEL_ITEM_LOCKED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-md px-2 py-1 text-fg-subtle';
58
- const PANEL_FOOT_CLASS = 'mt-1 flex justify-end border-t border-border-subtle pt-1';
108
+ // 列设置弹层:浮起表面只取表面配方(KT-B4:双层阴影 + 发丝描边),不自写边框 / 阴影
109
+ const PANEL_BASE = mergeClass('absolute z-20 w-56 p-2 text-sm text-fg', kitSurfaceRecipe('raised'));
110
+ const PANEL_ITEM_CLASS = 'flex cursor-pointer items-center gap-2 rounded-item px-2 py-1 hover:bg-state-layer-hover active:bg-state-layer-press';
111
+ const PANEL_ITEM_LOCKED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-item px-2 py-1 text-fg-subtle';
112
+ const PANEL_FOOT_CLASS = mergeClass('mt-1 flex justify-end pt-1', KIT_DIVIDER_FOOT_CLASS);
59
113
  const NOTICE_CLASS = 'text-xs text-fg-muted';
60
114
  const NOTICE_ERR_CLASS = 'text-xs text-danger-on-soft';
61
- const EDIT_CELL_CLASS = 'cursor-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
62
- const EDIT_INPUT_CLASS = 'block h-8 w-full min-w-0 appearance-none autofill-clear rounded-md border border-primary bg-surface px-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
115
+ /** 同值合并的被并格:内容隐藏、占位不变(visibility,行线与列宽不动) */
116
+ export const MERGED_CLASS = 'invisible';
117
+ /** 行拖拽排序的实例计数(拖放 id 命名空间) */
118
+ let reorderCount = 0;
119
+ /** 分组组头行:满行、高 32(同 ItemList 组头 h-8)、凹槽底、12 / 500 弱文字(取值表 06「分组列表:组头 32」) */
120
+ // 分组行 = 节的淡底带(surface-band,KT-HB-F);组名走字段名出口(弱化墨 / 正文字号 / 500)
121
+ const GROUP_HEAD_REST = mergeClass('col-span-full w-full h-8 items-center gap-2 bg-surface-band px-4', kitFieldNameRecipe());
122
+ export const GROUP_HEAD_ROW_CLASS = `flex ${GROUP_HEAD_REST}`;
123
+ /** 组头不继承数据行的这些类:交互态、行高 / 内边距、列距 / 对齐 / 跨列、底色(由组头自己定) */
124
+ const ROW_CLASS_DROP = /^(?:hover:|even:|odd:|active:|focus|data-|cursor-|py-|px-|min-h-|h-|state-layer|group|bg-|gap-|items-|col-span-|w-)/;
125
+ /**
126
+ * 组头沿用数据行的容器结构(flex / grid / 子网格同一种)再叠满宽类:不再依赖 col-span-full 单独撑满(flex 行容器里它不生效)。
127
+ * 数据行是 grid 容器时组头也是 grid(子网格类随行),否则 flex。
128
+ */
129
+ export function groupHeadClassFor(rowClass: string): string {
130
+ const tokens = rowClass.split(/\s+/).filter((t) => t !== '');
131
+ const display = tokens.includes('grid') ? 'grid' : 'flex';
132
+ const kept = tokens.filter((t) => t !== 'flex' && t !== 'grid' && !ROW_CLASS_DROP.test(t));
133
+ return [...kept, display, ...GROUP_HEAD_REST.split(' ')].join(' ');
134
+ }
135
+ export const GROUP_HEAD_COUNT_CLASS = 'tabular-nums text-fg-subtle';
136
+ export const GROUP_HEAD_CELL_CLASS = 'col-span-full flex min-w-0 items-center gap-2';
137
+ const EDIT_CELL_CLASS ='cursor-text ' + kitFocusRingRecipe('item');
138
+ const EDIT_INPUT_CLASS = 'block h-8 w-full min-w-0 appearance-none autofill-clear rounded-control border border-primary bg-surface px-2 text-sm text-fg ' + kitFocusRingRecipe('control');
63
139
  const EDIT_SELECT_CLASS = 'min-w-0';
64
- const EDIT_DATE_CLASS ='block h-8 w-full min-w-0 rounded-md border border-primary bg-surface ps-2 pe-8 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
140
+ const EDIT_DATE_CLASS = mergeClass(
141
+ mergeClass('block h-control w-full min-w-0 rounded-control border border-primary bg-surface ps-2 pe-8', kitTypographyRecipe('text')),
142
+ kitFocusRingRecipe('control'),
143
+ );
65
144
  const EDIT_ERR_CLASS = 'block text-xs text-danger-on-soft';
66
145
  const HIDDEN_CLASS = 'hidden';
67
146
  /** 重新读取中(已有行):表格外壳降不透明度;刷新按钮置灰 */
68
147
  const BUSY_TABLE_CLASS = `${KIT_ROW_TONE_CLASS.muted} transition-opacity`;
69
148
  const BUSY_BTN_CLASS = kitDisabledRecipe('button');
70
149
  const SR_ONLY_CLASS = 'sr-only';
150
+ /** 底部粘性汇总行实底:替代半透明混色带,防止表格滚动时数字重叠穿底 */
151
+ export const SUMMARY_STICKY_BG_CLASS = 'bg-layer-sub';
71
152
  /** 工具栏 / 批量条 / 列面板里可交互元素的标识属性:整体重建后按「属性 + 值」把焦点还给同一个控件 */
72
153
  const FOCUS_ID_ATTRS: readonly string[] = [
73
- 'data-kit-tool', 'data-kit-table-density', 'data-kit-batch', 'data-kit-batch-yes', 'data-kit-batch-no',
74
- 'data-kit-cols-reset', 'data-kit-col-toggle', 'data-kit-sel-clear', 'data-kit-select-all',
75
- 'data-kit-page-select', 'data-kit-page-all',
154
+ KIT_ATTR_TOOL, KIT_ATTR_TABLE_DENSITY, KIT_ATTR_BATCH, KIT_ATTR_BATCH_YES, KIT_ATTR_BATCH_NO,
155
+ KIT_ATTR_COLS_RESET, KIT_ATTR_COL_TOGGLE, KIT_ATTR_SEL_CLEAR, KIT_ATTR_SELECT_ALL,
156
+ KIT_ATTR_PAGE_SELECT, KIT_ATTR_PAGE_ALL,
76
157
  ];
77
158
  /**
78
159
  * 同标识控件消失时的焦点接力(批量二次确认的进出):键为原控件标识属性,值为接力目标。
79
160
  * 进确认条:批量钮 -> 取消钮(最不具破坏性);确认 / 取消后:回到同 id 的批量钮。
80
161
  */
81
162
  const FOCUS_RELAY: Readonly<Record<string, { attr: string; sameValue: boolean }>> = {
82
- 'data-kit-batch': { attr: 'data-kit-batch-no', sameValue: false },
83
- 'data-kit-batch-yes': { attr: 'data-kit-batch', sameValue: true },
84
- 'data-kit-batch-no': { attr: 'data-kit-batch', sameValue: true },
163
+ [KIT_ATTR_BATCH]: { attr: KIT_ATTR_BATCH_NO, sameValue: false },
164
+ [KIT_ATTR_BATCH_YES]: { attr: KIT_ATTR_BATCH, sameValue: true },
165
+ [KIT_ATTR_BATCH_NO]: { attr: KIT_ATTR_BATCH, sameValue: true },
85
166
  };
86
167
 
87
168
  /** 列宽拖拽(Q 波 G4)运行期换上的类:10 档预置宽 `w-N`(N 取 scroll.minSteps)+ 叶子表头格 / 手柄类;拖到的档位类必须全在候选里,否则按页裁剪后缺类 */
@@ -92,10 +173,10 @@ export const KIT_TABLE_RESIZE_CLASS_CANDIDATES: readonly string[] = [
92
173
 
93
174
  export const KIT_TABLE_TOOLS_CLASS_CANDIDATES: readonly string[] = [
94
175
  ...KIT_TABLE_RESIZE_CLASS_CANDIDATES,
95
- SR_ONLY_CLASS,
176
+ SR_ONLY_CLASS, SUMMARY_STICKY_BG_CLASS,
96
177
  ROOT_CLASS, GROUP_CLASS, TOOL_BTN_CLASS, SEG_GROUP_CLASS, SEG_BTN_CLASS, SEG_BTN_ON_CLASS, BATCH_BAR_CLASS, BATCH_TEXT_CLASS, LINK_BTN_CLASS,
97
178
  CHECK_TEXT_CLASS, PANEL_CHECK_CLASS, PANEL_CHECK_LOCKED_CLASS, ...KIT_CHECK_CLASS_CANDIDATES, ANCHOR_CLASS, PANEL_BASE, PANEL_ITEM_CLASS, PANEL_ITEM_LOCKED_CLASS, PANEL_FOOT_CLASS, NOTICE_CLASS, NOTICE_ERR_CLASS,
98
- EDIT_CELL_CLASS, EDIT_INPUT_CLASS, EDIT_DATE_CLASS, EDIT_SELECT_CLASS, EDIT_ERR_CLASS, HIDDEN_CLASS, BUSY_TABLE_CLASS, BUSY_BTN_CLASS,
179
+ ...REORDER_CLASS_CANDIDATES, ...KIT_FIELD_TEXT_CLASS_CANDIDATES, MERGED_CLASS, GROUP_HEAD_ROW_CLASS, GROUP_HEAD_COUNT_CLASS, GROUP_HEAD_CELL_CLASS, EDIT_CELL_CLASS, EDIT_INPUT_CLASS, EDIT_DATE_CLASS, EDIT_SELECT_CLASS, EDIT_ERR_CLASS, HIDDEN_CLASS, BUSY_TABLE_CLASS, BUSY_BTN_CLASS,
99
180
  ...KIT_DATE_CLASS_CANDIDATES, ...KIT_LISTBOX_CLASS_CANDIDATES,
100
181
  ...Object.values(ACTION_BUTTON_CLASS), ...KIT_TABLE_ACTIONS_CLASS_CANDIDATES, ...KIT_DROPDOWN_CLASS_CANDIDATES, ...KIT_ACTION_MORE_CLASS_CANDIDATES,
101
182
  ].flatMap((s) => s.split(/\s+/).filter((c) => c !== ''));
@@ -165,11 +246,122 @@ export function columnsOf(raw: unknown): ToolsColumn[] {
165
246
  return out;
166
247
  }
167
248
 
168
- /** 行主键串(无主键字段时按整行内容) */
249
+ /** 序号列的页偏移:(page - 1) * size;两者任一缺失或非正整数时为 0 */
250
+ export function serialOffsetOf(view: unknown): number {
251
+ if (!isRec(view)) return 0;
252
+ const page = view.page;
253
+ const size = view.size;
254
+ if (typeof page !== 'number' || typeof size !== 'number' || !Number.isInteger(page) || !Number.isInteger(size) || page < 1 || size < 1) return 0;
255
+ return (page - 1) * size;
256
+ }
257
+
258
+ /**
259
+ * 序号列回填(纯 DOM,无状态):表体行容器 `[data-kit-rows]` 里优先读取行上的 `data-kit-index`(支持虚拟滚动真实行号),
260
+ * 缺省按 DOM 序给每行的 `[data-kit-serial]` 写 offset + 位置(1 起)。
261
+ * 跳过 <template> 与分组标题行;文字没变不写(避免触发 MutationObserver 自循环)。
262
+ */
263
+ export function fillSerial(table: ParentNode, offset: number): void {
264
+ const container = table.querySelector(`[${KIT_ATTR_ROWS}]`);
265
+ if (!container) return;
266
+ let n = offset;
267
+ for (const row of Array.from(container.children)) {
268
+ if (row.tagName === 'TEMPLATE' || row.hasAttribute(KIT_ATTR_GROUP_HEAD)) continue;
269
+ const el = row.querySelector(`[${KIT_ATTR_SERIAL}]`);
270
+ if (!el) continue;
271
+ n += 1;
272
+ const rawIdx = row.getAttribute(KIT_ATTR_INDEX);
273
+ const parsedIdx = rawIdx !== null && rawIdx.trim() !== '' ? Number(rawIdx) : Number.NaN;
274
+ const serial = Number.isInteger(parsedIdx) && parsedIdx >= 0 ? offset + parsedIdx + 1 : n;
275
+ const text = String(serial);
276
+ if (el.textContent !== text) el.textContent = text;
277
+ }
278
+ }
279
+
280
+ /**
281
+ * 同值合并(视觉版,抄 Ant Table 的 rowSpan 语义但不改行结构):对带 `data-kit-merge` 的列,纵向连续同值(trim 后文字相同且非空)
282
+ * 的后续格加 MERGED_CLASS 隐藏内容并标 `data-kit-merged`,首格照常显示。遇到分组标题行 `[data-kit-group-head]` 清空跨组记忆;
283
+ * 多列合并须前序合并列也同值才合并;排序 / 重取后随 DOM 顺序重算;幂等。
284
+ */
285
+ export function applyMergeSame(table: ParentNode): void {
286
+ const container = table.querySelector(`[${KIT_ATTR_ROWS}]`);
287
+ if (!container) return;
288
+ const prev = new Map<string, string>();
289
+ for (const row of Array.from(container.children)) {
290
+ if (row.tagName === 'TEMPLATE') continue;
291
+ if (row.hasAttribute(KIT_ATTR_GROUP_HEAD)) {
292
+ prev.clear();
293
+ continue;
294
+ }
295
+ let priorSame = true;
296
+ for (const cell of Array.from(row.querySelectorAll(`[${KIT_ATTR_MERGE}]`))) {
297
+ const col = cell.getAttribute(KIT_ATTR_COL) ?? '';
298
+ const text = (cell.textContent ?? '').trim();
299
+ const same = text !== '' && prev.get(col) === text;
300
+ const dup = priorSame && same;
301
+ if (!dup) priorSame = false;
302
+ cell.classList.toggle(MERGED_CLASS, dup);
303
+ if (dup) cell.setAttribute(KIT_ATTR_MERGED, '');
304
+ else cell.removeAttribute(KIT_ATTR_MERGED);
305
+ prev.set(col, text);
306
+ }
307
+ }
308
+ }
309
+
310
+ /**
311
+ * 按字段分组行:在表体行容器 `[data-kit-rows]` 里,每组首行前插一条组头行(`data-kit-group-head`)。
312
+ * 数据行与 rows 按 DOM 序一一对应(跳过 <template> 与组头自身);组值取 rows[i][field],显示文字优先取该行 `[data-kit-col=field]` 格的文字(枚举显示标签)。
313
+ * 组头已在正确位置(每个组头的下一个兄弟就是该组首行、数量一致)时不动 DOM(避免触发 MutationObserver 自循环)。
314
+ * 抄 TanStack Table `getGroupedRowModel` 的「连续同值成组」语义(不重排数据,数据需自行按该字段排好)。
315
+ */
316
+ export function applyGroupHeads(table: ParentNode, rows: readonly unknown[], field: string): void {
317
+ const container = table.querySelector(`[${KIT_ATTR_ROWS}]`);
318
+ if (!container) return;
319
+ const dataRows = Array.from(container.children).filter((c) => c.tagName !== 'TEMPLATE' && !c.hasAttribute(KIT_ATTR_GROUP_HEAD));
320
+ const groups: Array<{ first: Element; text: string; count: number }> = [];
321
+ let prevKey: string | null = null;
322
+ dataRows.forEach((row, i) => {
323
+ const rec = rows[i];
324
+ const raw = rec !== null && typeof rec === 'object' ? (rec as Rec)[field] : undefined;
325
+ const key = raw === undefined || raw === null ? '' : String(raw);
326
+ if (prevKey === null || key !== prevKey) {
327
+ const shown = (row.querySelector(`[${KIT_ATTR_COL}="${field}"]`)?.textContent ?? '').trim();
328
+ groups.push({ first: row, text: shown !== '' ? shown : key, count: 0 });
329
+ prevKey = key;
330
+ }
331
+ groups[groups.length - 1]!.count += 1;
332
+ });
333
+ const heads = Array.from(container.children).filter((c) => c.hasAttribute(KIT_ATTR_GROUP_HEAD));
334
+ const inPlace = heads.length === groups.length && heads.every((h, i) => h.nextElementSibling === groups[i]!.first
335
+ && h.getAttribute(KIT_ATTR_GROUP_TEXT) === groups[i]!.text && h.getAttribute(KIT_ATTR_GROUP_COUNT) === String(groups[i]!.count));
336
+ if (inPlace) return;
337
+ for (const h of heads) h.remove();
338
+ const doc = container.ownerDocument;
339
+ for (const g of groups) {
340
+ const head = doc.createElement('div');
341
+ head.className = groupHeadClassFor(g.first.className);
342
+ head.setAttribute('role', 'row');
343
+ head.setAttribute(KIT_ATTR_GROUP_HEAD, '');
344
+ // 分组行自报「淡底带」
345
+ kitMarkLevel(head, 'band'); kitApplyLevelClass(head);
346
+ head.setAttribute(KIT_ATTR_GROUP_TEXT, g.text);
347
+ head.setAttribute(KIT_ATTR_GROUP_COUNT, String(g.count));
348
+ // 单个满宽格(Ant 分组行 / Table.md:单个 th scope=rowgroup colSpan=全部列):组名 + 条数同在一格里
349
+ const label = doc.createElement('span');
350
+ label.className = GROUP_HEAD_CELL_CLASS;
351
+ label.setAttribute('role', 'cell');
352
+ label.appendChild(doc.createTextNode(g.text));
353
+ const count = doc.createElement('span');
354
+ count.className = GROUP_HEAD_COUNT_CLASS;
355
+ count.textContent = String(g.count);
356
+ label.appendChild(count);
357
+ head.appendChild(label);
358
+ container.insertBefore(head, g.first);
359
+ }
360
+ }
361
+
362
+ /** 行主键串(无主键字段时按整行内容):全仓口径在 shared/row-key.ts,这里保留导出名并委托 */
169
363
  export function rowKeyOf(row: unknown, keyField: string): string {
170
- if (!isRec(row)) return '';
171
- const v = keyField !== '' ? row[keyField] : undefined;
172
- return v !== undefined && v !== null ? String(v) : JSON.stringify(row);
364
+ return kitRowKey(row, keyField);
173
365
  }
174
366
 
175
367
  import { csvCell } from '../shared/escape';
@@ -231,12 +423,12 @@ export function parseHidden(raw: string | null, known: readonly string[]): Set<s
231
423
  }
232
424
  }
233
425
 
234
- // 行高三档就是九维 density 枚举(COMPACT_DENSE / STANDARD_BALANCED / SPACIOUS_AIRY),名字与真源同一份
426
+ // 行高三档就是主题 density 的单调阶梯(compact / standard / spacious),名字与真源同一份
235
427
  type Density = KitTableDensity;
236
428
  const DENSITY_LABEL: Readonly<Record<Density, KitTextKey>> = {
237
- COMPACT_DENSE: 'soma.kit.density_compact_dense',
238
- STANDARD_BALANCED: 'soma.kit.density_standard_balanced',
239
- SPACIOUS_AIRY: 'soma.kit.density_spacious_airy',
429
+ compact: 'soma.kit.density_compact_dense',
430
+ standard: 'soma.kit.density_standard_balanced',
431
+ spacious: 'soma.kit.density_spacious_airy',
240
432
  };
241
433
  const DENSITIES: ReadonlyArray<{ id: Density; label: KitTextKey }> = KIT_TABLE_DENSITIES.map((id) => ({ id, label: DENSITY_LABEL[id] }));
242
434
  const isDensity = (v: unknown): v is Density => typeof v === 'string' && (KIT_TABLE_DENSITIES as readonly string[]).includes(v);
@@ -254,7 +446,10 @@ function batchOf(raw: unknown): BatchItem[] {
254
446
  }
255
447
 
256
448
  function batchBusyNames(b: BatchItem): string {
257
- return b.busyAction !== '' ? `${b.id},${b.busyAction}` : b.id;
449
+ // 声明式 request 批量动作的 busyAction 是对象限定通道(kitObjectBusyChannel),仅订阅该对象通道不再拼裸 b.id,
450
+ // 避免批量 request.id 与同页具名动作或其它对象同名 request 串台;其余具名动作保持兼容,无 busyAction 时回退 b.id。
451
+ if (b.busyAction === '') return b.id;
452
+ return isKitObjectBusyChannel(b.busyAction) ? b.busyAction : `${b.id},${b.busyAction}`;
258
453
  }
259
454
 
260
455
  // ---------------------------------------------------------------- 组件
@@ -274,6 +469,8 @@ export function createKitTableTools(): SomaComponentDefinition {
274
469
  items: { type: 'array', default: [], desc: '工具栏项:reload / density / columns / export' },
275
470
  scroll: { type: 'boolean', default: false, desc: '表格处于滚动模式(影响滚动边缘标记)' },
276
471
  editMode: { type: 'string', default: '', desc: '就地编辑方式:cell / row;空 = 不编辑' },
472
+ reorder: { type: 'string', default: '', desc: '行拖拽排序的排序字段名;非空时每行前导槽出拖拽柄,落点经 order_move 抛纯顺序载荷' },
473
+ groupBy: { type: 'string', default: '', desc: '按字段分组行:字段名;每组首行前插入组头行(data-kit-group-head),空 = 不分组' },
277
474
  selectMode: { type: 'string', default: 'none', desc: '勾选列模式 none / single / multi' },
278
475
  selectScope: { type: 'string', default: 'all', desc: '勾选范围:all 跨页保留 / page 翻页丢弃不在本页的勾选' },
279
476
  selected: { type: 'array', default: [], desc: '已选行数组(协调组件 focus 切片 sel 的镜像);配 batch 才有' },
@@ -312,6 +509,20 @@ export function createKitTableTools(): SomaComponentDefinition {
312
509
  count: { type: 'number', desc: '作用的行数(all 时为总数)' },
313
510
  all: { type: 'boolean', desc: '用户选了「选择全部 N 项」:服务端按当前筛选条件处理' },
314
511
  }, '点批量动作(有 confirm 时已在批量条里确认过),序号 = 动作在 batch 数组里的位置'),
512
+ order_move: {
513
+ payload: {
514
+ id: { type: 'string', desc: '被移动行的主键' },
515
+ from: { type: 'number', desc: '原位置(0 起)' },
516
+ to: { type: 'number', desc: '目标位置(0 起,去掉自身后的序位)' },
517
+ index: { type: 'number', desc: '同 to' },
518
+ target: { type: 'string', desc: '被移动行的主键(data.orderMove 的目标)' },
519
+ orderField: { type: 'string', desc: '排序字段名' },
520
+ position: { type: 'number', desc: '序值:落点相邻两行序值的中点(首 -1 / 末 +1 / 无邻行 0)' },
521
+ set: { type: 'object', desc: '同时要改的字段(表格行拖拽恒为空)' },
522
+ object: { type: 'string', desc: '对象名' },
523
+ },
524
+ desc: '行拖拽排序落点(拖放或柄上 ↑ / ↓):页面接 ACTION | data.orderMove(纯顺序载荷)',
525
+ },
315
526
  cell_edit: {
316
527
  payload: {
317
528
  object: { type: 'string', desc: '对象名' },
@@ -326,10 +537,16 @@ export function createKitTableTools(): SomaComponentDefinition {
326
537
  },
327
538
  scope: { slices: ['filter', 'view'] },
328
539
  },
329
- services: ['data', 'permission', 'region'],
540
+ services: ['data', 'permission', 'region', 'engines'],
330
541
  templateHtml: `<div data-soma-id="root" class="${HIDDEN_CLASS}"></div>`,
331
542
  controllerFactory: createKitController((api) => {
332
- const check = permissionCheckerOf(api as unknown as any);
543
+ let renderedBatchPerm = '';
544
+ const batchPermStateOf = (): string => {
545
+ const batch = batchOf(api.props().batch);
546
+ if (!batch.some((b) => b.permission !== '')) return '';
547
+ const check = permissionCheckerOf(api as unknown as any);
548
+ return batch.map((b) => (b.permission !== '' && check !== null ? (check(b.permission) ? '1' : '0') : '-')).join('');
549
+ };
333
550
  const dataPort = (): SomaDataPort | undefined => {
334
551
  const port = (api.services as { data?: SomaDataPort } | undefined)?.data;
335
552
  return port && typeof port === 'object' ? port : undefined;
@@ -362,6 +579,8 @@ export function createKitTableTools(): SomaComponentDefinition {
362
579
  let panelBind: ((panel: HTMLElement) => void) | null = null;
363
580
  let confirming: string | null = null;
364
581
  let confirmingBatch = false;
582
+ // 页面线对没有声明确认文案的危险批量动作下发的二次确认(props.kit.actions[动作].confirm):经确认端口,没有判定时同步触发
583
+ const batchConfirm = createKitRowConfirm(() => api.isCurrent());
365
584
  let allMode = false;
366
585
  let lastQuerySig = '';
367
586
  let notice: { text: string; error: boolean } | null = null;
@@ -381,13 +600,13 @@ export function createKitTableTools(): SomaComponentDefinition {
381
600
  // 内置文案:按宿主所在页面语言取词(运行期读法)
382
601
  const T = (key: KitTextKey, params?: Record<string, string | number>): string => kitText(key, params, api.host);
383
602
  let selAnnounced = false;
384
- const announce =(text: string): void => {
603
+ const announce = (text: string): void => {
385
604
  if (!liveEl || text === liveLast) return;
386
605
  liveLast = text;
387
606
  liveEl.textContent = text;
388
607
  };
389
608
 
390
- const P =(): Rec => (apiRef?.props() ?? api.props()) as Rec;
609
+ const P = (): Rec => (apiRef?.props() ?? api.props()) as Rec;
391
610
  const cols = (): ToolsColumn[] => columnsOf(P().columns);
392
611
  const object = (): string => str(P().object);
393
612
  const rowsList = (): unknown[] => (Array.isArray(P().rows) ? (P().rows as unknown[]) : []);
@@ -397,6 +616,7 @@ export function createKitTableTools(): SomaComponentDefinition {
397
616
  const pathname = (): string => (typeof location === 'undefined' ? '' : location.pathname);
398
617
 
399
618
  const effectiveDensity = (): Density => {
619
+ // 用户没选过:取全局缺省(标准 = 主题档本身;列表页不再默认标紧凑,尺寸校准 S-2)
400
620
  return density ?? KIT_TABLE_DENSITY_DEFAULT;
401
621
  };
402
622
 
@@ -404,36 +624,36 @@ export function createKitTableTools(): SomaComponentDefinition {
404
624
  const applyDensity = (): void => {
405
625
  if (!table) return;
406
626
  const d = effectiveDensity();
407
- if (d === 'COMPACT_DENSE') table.setAttribute('data-kit-dense', '');
408
- else table.removeAttribute('data-kit-dense');
409
- if (d === 'SPACIOUS_AIRY') table.setAttribute('data-kit-roomy', '');
410
- else table.removeAttribute('data-kit-roomy');
627
+ if (d === 'compact') table.setAttribute(KIT_ATTR_DENSE, '');
628
+ else table.removeAttribute(KIT_ATTR_DENSE);
629
+ if (d === 'spacious') table.setAttribute(KIT_ATTR_ROOMY, '');
630
+ else table.removeAttribute(KIT_ATTR_ROOMY);
411
631
  };
412
632
 
413
633
  const applyHidden = (): void => {
414
634
  if (!table) return;
415
- table.querySelectorAll<HTMLElement>('[data-kit-col]').forEach((el) => {
416
- const hide = hidden.has(el.getAttribute('data-kit-col') ?? '');
417
- const stored = el.getAttribute('data-kit-cls');
635
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_COL}]`).forEach((el) => {
636
+ const hide = hidden.has(el.getAttribute(KIT_ATTR_COL) ?? '');
637
+ const stored = el.getAttribute(KIT_ATTR_CLS);
418
638
  if (hide && stored === null) {
419
- el.setAttribute('data-kit-cls', el.className);
639
+ el.setAttribute(KIT_ATTR_CLS, el.className);
420
640
  el.className = HIDDEN_CLASS;
421
641
  } else if (!hide && stored !== null) {
422
642
  el.className = stored;
423
- el.removeAttribute('data-kit-cls');
643
+ el.removeAttribute(KIT_ATTR_CLS);
424
644
  }
425
645
  });
426
646
  // 多级表头:组内列全隐则整个组块隐,部分隐则自然收窄(固定列不可隐,所以固定组不会被隐)
427
- table.querySelectorAll<HTMLElement>('[data-kit-group-cols]').forEach((el) => {
428
- const members = (el.getAttribute('data-kit-group-cols') ?? '').split(',').filter((f) => f !== '');
647
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_GROUP_COLS}]`).forEach((el) => {
648
+ const members = (el.getAttribute(KIT_ATTR_GROUP_COLS) ?? '').split(',').filter((f) => f !== '');
429
649
  const hide = members.length > 0 && members.every((f) => hidden.has(f));
430
- const stored = el.getAttribute('data-kit-cls');
650
+ const stored = el.getAttribute(KIT_ATTR_CLS);
431
651
  if (hide && stored === null) {
432
- el.setAttribute('data-kit-cls', el.className);
652
+ el.setAttribute(KIT_ATTR_CLS, el.className);
433
653
  el.className = HIDDEN_CLASS;
434
654
  } else if (!hide && stored !== null) {
435
655
  el.className = stored;
436
- el.removeAttribute('data-kit-cls');
656
+ el.removeAttribute(KIT_ATTR_CLS);
437
657
  }
438
658
  });
439
659
  };
@@ -446,14 +666,14 @@ export function createKitTableTools(): SomaComponentDefinition {
446
666
  const applyWidths = (): void => {
447
667
  if (!table || touched.size === 0) return;
448
668
  const byField = new Map(cols().map((c) => [c.field, c]));
449
- table.querySelectorAll<HTMLElement>('[data-kit-col]').forEach((el) => {
450
- const field = el.getAttribute('data-kit-col') ?? '';
669
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_COL}]`).forEach((el) => {
670
+ const field = el.getAttribute(KIT_ATTR_COL) ?? '';
451
671
  if (!touched.has(field)) return;
452
672
  const col = byField.get(field);
453
673
  if (!col) return;
454
674
  const step = stepList[currentIndex(col)]!;
455
- const stored = el.getAttribute('data-kit-cls');
456
- if (stored !== null) el.setAttribute('data-kit-cls', withWidthStep(stored, stepList, step));
675
+ const stored = el.getAttribute(KIT_ATTR_CLS);
676
+ if (stored !== null) el.setAttribute(KIT_ATTR_CLS, withWidthStep(stored, stepList, step));
457
677
  else {
458
678
  const next = withWidthStep(el.className, stepList, step);
459
679
  if (next !== el.className) el.className = next;
@@ -474,13 +694,13 @@ export function createKitTableTools(): SomaComponentDefinition {
474
694
  }
475
695
  const doc = table.ownerDocument;
476
696
  const list = cols();
477
- table.querySelectorAll<HTMLElement>('[data-kit-resizable]').forEach((cell) => {
478
- const field = cell.getAttribute('data-kit-col') ?? '';
697
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_RESIZABLE}]`).forEach((cell) => {
698
+ const field = cell.getAttribute(KIT_ATTR_COL) ?? '';
479
699
  const col = list.find((c) => c.field === field);
480
- if (!col || !col.resizable || cell.querySelector(':scope > [data-kit-resize]')) return;
700
+ if (!col || !col.resizable || cell.querySelector(`:scope > [${KIT_ATTR_RESIZE}]`)) return;
481
701
  const handleEl = doc.createElement('span');
482
702
  handleEl.className = KIT_TABLE_EXT.resize.handle;
483
- handleEl.setAttribute('data-kit-resize', field);
703
+ handleEl.setAttribute(KIT_ATTR_RESIZE, field);
484
704
  cell.appendChild(handleEl);
485
705
  let startX = 0;
486
706
  let startWidth = 0;
@@ -519,8 +739,8 @@ export function createKitTableTools(): SomaComponentDefinition {
519
739
  const applyEdges = (): void => {
520
740
  if (!table || P().scroll !== true) return;
521
741
  const { left, right } = measureEdges(table);
522
- if (left) table.setAttribute('data-kit-edge-l', ''); else table.removeAttribute('data-kit-edge-l');
523
- if (right) table.setAttribute('data-kit-edge-r', ''); else table.removeAttribute('data-kit-edge-r');
742
+ if (left) table.setAttribute(KIT_ATTR_EDGE_L, ''); else table.removeAttribute(KIT_ATTR_EDGE_L);
743
+ if (right) table.setAttribute(KIT_ATTR_EDGE_R, ''); else table.removeAttribute(KIT_ATTR_EDGE_R);
524
744
  };
525
745
 
526
746
  const applyCells = (): void => {
@@ -528,22 +748,68 @@ export function createKitTableTools(): SomaComponentDefinition {
528
748
  // 省略列的全文提示不在这里逐格写原生 title:改由 base/hint-tips.ts 的委托在悬停 / 聚焦到单元格时现量、真被截断才挂 kitTooltip
529
749
  //(表格外壳带 data-kit-tips 标出作用范围;大表 / 虚拟表不为每个单元格建任何东西)
530
750
  if (str(P().editMode) !== '') {
531
- table.querySelectorAll<HTMLElement>('[data-kit-editable]').forEach((el) => {
532
- if (el.hasAttribute('data-kit-edit-ready')) return;
533
- el.setAttribute('data-kit-edit-ready', '');
751
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_EDITABLE}]`).forEach((el) => {
752
+ if (el.hasAttribute(KIT_ATTR_EDIT_READY)) return;
753
+ el.setAttribute(KIT_ATTR_EDIT_READY, '');
534
754
  el.setAttribute('tabindex', '0');
535
755
  el.className = `${el.className} ${EDIT_CELL_CLASS}`;
536
756
  });
537
757
  }
538
758
  };
539
759
 
760
+ /** 序号列回填:页偏移取 view 切片的 page / size(累加翻页 more / infinite 页码恒 1,偏移 0),行位置取 DOM 序 */
761
+ const applySerial = (): void => {
762
+ if (!table) return;
763
+ fillSerial(table, serialOffsetOf(regionPort()?.slice('view')?.get()));
764
+ };
765
+ const reorderUid = `kit-reorder-${++reorderCount}`;
766
+ const reorderOffs: Array<() => void> = [];
767
+ const dndPortOf = (): ReorderDragPort | null => {
768
+ const engines = (api.services as { engines?: { dnd?: ReorderDragPort } } | undefined)?.engines;
769
+ return engines?.dnd ?? null;
770
+ };
771
+ /** 行拖拽排序:给每行前导槽补拖拽柄并登记拖放(重绑前先释放旧绑定防 DOM 变动叠加泄漏) */
772
+ const applyReorder = (): void => {
773
+ while (reorderOffs.length > 0) reorderOffs.pop()!();
774
+ const field = str(P().reorder);
775
+ if (!table || field === '') return;
776
+ reorderOffs.push(bindRowReorder({
777
+ table, port: dndPortOf(), uid: reorderUid, rows: rowsList, keyField: keyField(), orderField: field, object: object(),
778
+ handleLabel: (key) => T('soma.kit.reorder_handle_of', { name: key }),
779
+ onMove: (payload) => api.emit('order_move', payload),
780
+ }));
781
+ };
782
+ /** 底部粘性汇总行及汇总固定格:由透明混色带升级为实底 bg-layer-sub,防止滚动时数字穿透重叠 */
783
+ const applySummarySticky = (): void => {
784
+ if (!table) return;
785
+ const upgradeSolidBg = (el: HTMLElement): void => {
786
+ if (!el.classList.contains('sticky')) return;
787
+ for (const tok of Array.from(el.classList)) {
788
+ if (tok === 'bg-surface-band' || tok.startsWith('bg-surface/')) {
789
+ el.classList.remove(tok);
790
+ }
791
+ }
792
+ if (!el.classList.contains(SUMMARY_STICKY_BG_CLASS)) {
793
+ el.classList.add(SUMMARY_STICKY_BG_CLASS);
794
+ }
795
+ };
796
+ table.querySelectorAll<HTMLElement>(`[${KIT_ATTR_SUMMARY}]`).forEach((row) => {
797
+ upgradeSolidBg(row);
798
+ row.querySelectorAll<HTMLElement>('.sticky').forEach(upgradeSolidBg);
799
+ });
800
+ };
540
801
  const applyAll = (): void => {
802
+ if (table && str(P().groupBy) !== '') applyGroupHeads(table, rowsList(), str(P().groupBy));
803
+ applySerial();
804
+ applyReorder();
805
+ if (table) applyMergeSame(table);
541
806
  applyHidden();
542
807
  applyWidths();
543
808
  applyHandles();
544
809
  applyDensity();
545
810
  applyEdges();
546
811
  applyCells();
812
+ applySummarySticky();
547
813
  };
548
814
 
549
815
  const persistHidden = (): void => {
@@ -594,14 +860,14 @@ export function createKitTableTools(): SomaComponentDefinition {
594
860
  let editing: { rowIndex: number; row: Rec; cells: EditCell[]; focusCell: HTMLElement } | null = null;
595
861
 
596
862
  const rowOfCell = (cell: HTMLElement): { index: number; row: Rec } | null => {
597
- const container = table?.querySelector<HTMLElement>('[data-kit-rows]');
863
+ const container = table?.querySelector<HTMLElement>(`[${KIT_ATTR_ROWS}]`);
598
864
  if (!container) return null;
599
865
  let el: HTMLElement | null = cell;
600
866
  while (el && el.parentElement !== container) el = el.parentElement;
601
867
  if (!el) return null;
602
868
  // 虚拟滚动表体(KitVirtualRows)只画窗口内的行:行自带数据下标 data-kit-index,不能按 DOM 序号推
603
- const stamped = el.getAttribute('data-kit-index');
604
- const items = Array.from(container.children).filter((c) => c.tagName !== 'TEMPLATE');
869
+ const stamped = el.getAttribute(KIT_ATTR_INDEX);
870
+ const items = Array.from(container.children).filter((c) => c.tagName !== 'TEMPLATE' && !c.hasAttribute(KIT_ATTR_GROUP_HEAD));
605
871
  const index = stamped !== null && Number.isInteger(Number(stamped)) ? Number(stamped) : items.indexOf(el);
606
872
  const row = rowsList()[index];
607
873
  return index >= 0 && isRec(row) ? { index, row } : null;
@@ -653,7 +919,7 @@ export function createKitTableTools(): SomaComponentDefinition {
653
919
 
654
920
  const startEdit = (cell: HTMLElement): void => {
655
921
  const mode = str(P().editMode);
656
- if (mode === '' || cell.getAttribute('data-kit-editable') === null) return;
922
+ if (mode === '' || cell.getAttribute(KIT_ATTR_EDITABLE) === null) return;
657
923
  const hit = rowOfCell(cell);
658
924
  if (!hit) return;
659
925
  // 点到同表另一格:旧编辑与「点到别处」同一套(有改动提交、无改动取消);校验没过则留在旧编辑
@@ -661,17 +927,17 @@ export function createKitTableTools(): SomaComponentDefinition {
661
927
  if (editing) return;
662
928
  const doc = cell.ownerDocument;
663
929
  const targets = mode === 'row'
664
- ? Array.from(cell.parentElement?.querySelectorAll<HTMLElement>('[data-kit-editable]') ?? [cell])
930
+ ? Array.from(cell.parentElement?.querySelectorAll<HTMLElement>(`[${KIT_ATTR_EDITABLE}]`) ?? [cell])
665
931
  : [cell];
666
932
  const list: EditCell[] = [];
667
933
  for (const t of targets) {
668
- const col = cols().find((c) => c.field === t.getAttribute('data-kit-col'));
934
+ const col = cols().find((c) => c.field === t.getAttribute(KIT_ATTR_COL));
669
935
  if (!col || !col.editable || hit.index !== rowOfCell(t)?.index) continue;
670
936
  const host = t.firstElementChild instanceof HTMLElement ? t.firstElementChild : null;
671
937
  const made = controlFor(doc, col, hit.row[col.field]);
672
938
  const { control } = made;
673
939
  control.setAttribute('aria-label', col.label);
674
- control.setAttribute('data-kit-edit-control', col.field);
940
+ control.setAttribute(KIT_ATTR_EDIT_CONTROL, col.field);
675
941
  const err = doc.createElement('span');
676
942
  err.className = HIDDEN_CLASS;
677
943
  err.setAttribute('role', 'alert');
@@ -775,6 +1041,8 @@ export function createKitTableTools(): SomaComponentDefinition {
775
1041
  setKitFace(b, face);
776
1042
  b.textContent = text;
777
1043
  for (const [k, v] of Object.entries(attrs)) b.setAttribute(k, v);
1044
+ // 工具栏 / 批量条里的按钮都是动作(密度分段由调用处改报控件)
1045
+ kitMarkPart(b, 'action');
778
1046
  return b;
779
1047
  };
780
1048
 
@@ -799,7 +1067,7 @@ export function createKitTableTools(): SomaComponentDefinition {
799
1067
  id: 'reload', label: T('soma.kit.refresh'), importance: 'secondary',
800
1068
  button: btn(
801
1069
  doc, busy ? `${TOOL_BTN_CLASS} ${BUSY_BTN_CLASS}` : TOOL_BTN_CLASS, T('soma.kit.refresh'),
802
- busy ? { 'data-kit-tool': 'reload', disabled: '', 'aria-busy': 'true' } : { 'data-kit-tool': 'reload' },
1070
+ busy ? { [KIT_ATTR_TOOL]: 'reload', disabled: '', 'aria-busy': 'true' } : { [KIT_ATTR_TOOL]: 'reload' },
803
1071
  KIT_FACE_RAISED,
804
1072
  ),
805
1073
  });
@@ -810,19 +1078,22 @@ export function createKitTableTools(): SomaComponentDefinition {
810
1078
  seg.setAttribute('aria-label', T('soma.kit.row_height'));
811
1079
  for (const d of DENSITIES) {
812
1080
  const on = effectiveDensity() === d.id;
813
- const b = btn(doc, on ? SEG_BTN_ON_CLASS : SEG_BTN_CLASS, T(d.label), { 'data-kit-table-density': d.id, 'aria-pressed': on ? 'true' : 'false' }, on ? KIT_FACE_RAISED : null);
1081
+ const b = btn(doc, on ? SEG_BTN_ON_CLASS : SEG_BTN_CLASS, T(d.label), { [KIT_ATTR_TABLE_DENSITY]: d.id, 'aria-pressed': on ? 'true' : 'false' }, on ? KIT_FACE_RAISED : null);
1082
+ // 密度分段是视图模式开关:元素部件「控件」,当前档自报「选中」(aria-pressed 已写)
1083
+ kitMarkPart(b, 'control');
1084
+ kitMarkPicked(b, 'selected', on, null);
814
1085
  seg.appendChild(b);
815
1086
  }
816
- seg.classList.add('shrink-0');
1087
+ seg.classList.add('shrink-0', 'max-w-full');
817
1088
  group.appendChild(seg);
818
1089
  } else if (it === 'columns') {
819
1090
  const anchor = doc.createElement('div');
820
1091
  anchor.className = ANCHOR_CLASS;
821
- anchor.appendChild(btn(doc, TOOL_BTN_CLASS, T('soma.kit.columns'), { 'data-kit-tool': 'columns', 'aria-haspopup': 'dialog', 'aria-expanded': panelOpen ? 'true' : 'false' }, KIT_FACE_RAISED));
1092
+ anchor.appendChild(btn(doc, TOOL_BTN_CLASS, T('soma.kit.columns'), { [KIT_ATTR_TOOL]: 'columns', 'aria-haspopup': 'dialog', 'aria-expanded': panelOpen ? 'true' : 'false' }, KIT_FACE_RAISED));
822
1093
  if (panelOpen) anchor.appendChild(columnPanel(doc));
823
1094
  entries.push({ id: 'columns', label: T('soma.kit.columns'), importance: 'primary', button: anchor });
824
1095
  } else if (it === 'export') {
825
- entries.push({ id: 'export', label: T('soma.kit.export'), importance: 'secondary', button: btn(doc, TOOL_BTN_CLASS, T('soma.kit.export'), { 'data-kit-tool': 'export', title: T('soma.kit.export_page_hint') }, KIT_FACE_RAISED) });
1096
+ entries.push({ id: 'export', label: T('soma.kit.export'), importance: 'secondary', button: btn(doc, TOOL_BTN_CLASS, T('soma.kit.export'), { [KIT_ATTR_TOOL]: 'export', title: T('soma.kit.export_page_hint') }, KIT_FACE_RAISED) });
826
1097
  }
827
1098
  }
828
1099
  if (entries.length > 0) {
@@ -837,15 +1108,17 @@ export function createKitTableTools(): SomaComponentDefinition {
837
1108
  const panel = doc.createElement('div');
838
1109
  panel.setAttribute('role', 'dialog');
839
1110
  panel.setAttribute('aria-label', T('soma.kit.columns'));
840
- panel.setAttribute('data-kit-cols-panel', '');
1111
+ panel.setAttribute(KIT_ATTR_COLS_PANEL, '');
841
1112
  panel.className = PANEL_BASE;
1113
+ // 列设置面板是浮出的气泡:自报「浮起」
1114
+ kitMarkLevel(panel, 'float'); kitApplyLevelClass(panel);
842
1115
  colsPanelEl = panel;
843
1116
  for (const c of cols()) {
844
1117
  const locked = c.fixed !== '';
845
1118
  const box = createCheck(doc, 'checkbox', {
846
1119
  checked: locked || !hidden.has(c.field), disabled: locked, extra: locked ? PANEL_CHECK_LOCKED_CLASS : PANEL_CHECK_CLASS,
847
1120
  });
848
- box.setAttribute('data-kit-col-toggle', c.field);
1121
+ box.setAttribute(KIT_ATTR_COL_TOGGLE, c.field);
849
1122
  const text = doc.createElement('span');
850
1123
  text.textContent = locked ? T('soma.kit.col_fixed', { label: c.label }) : c.label;
851
1124
  box.appendChild(text);
@@ -853,7 +1126,7 @@ export function createKitTableTools(): SomaComponentDefinition {
853
1126
  }
854
1127
  const foot = doc.createElement('div');
855
1128
  foot.className = PANEL_FOOT_CLASS;
856
- foot.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.restore_default'), { 'data-kit-cols-reset': '' }));
1129
+ foot.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.restore_default'), { [KIT_ATTR_COLS_RESET]: '' }));
857
1130
  panel.appendChild(foot);
858
1131
  queueMicrotask(() => {
859
1132
  const anchor = panel.parentElement;
@@ -882,10 +1155,10 @@ export function createKitTableTools(): SomaComponentDefinition {
882
1155
  bar.appendChild(text);
883
1156
  // 本页都选了、总数更多:给「选择全部 N 项」(用户确认后批量动作按当前筛选处理)
884
1157
  if (str(P().selectScope, 'all') === 'all' && !allMode && pageSelected() && total > rows.length && total > picked.length) {
885
- bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.select_all_n', { n: total }), { 'data-kit-select-all': '' }));
1158
+ bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.select_all_n', { n: total }), { [KIT_ATTR_SELECT_ALL]: '' }));
886
1159
  }
887
- if (rows.length > 0 && !pageSelected()) bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.select_page'), { 'data-kit-page-select': '' }));
888
- bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.clear'), { 'data-kit-sel-clear': '' }));
1160
+ if (rows.length > 0 && !pageSelected()) bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.select_page'), { [KIT_ATTR_PAGE_SELECT]: '' }));
1161
+ bar.appendChild(btn(doc, LINK_BTN_CLASS, T('soma.kit.clear'), { [KIT_ATTR_SEL_CLEAR]: '' }));
889
1162
  if (confirming !== null) {
890
1163
  const item = batch.find((b) => b.id === confirming);
891
1164
  if (item) {
@@ -894,7 +1167,7 @@ export function createKitTableTools(): SomaComponentDefinition {
894
1167
  q.textContent = confirmText(item.confirm, count);
895
1168
  bar.appendChild(q);
896
1169
  const busy = isKitActionBusy(batchBusyNames(item));
897
- const yesAttrs: Record<string, string> = { 'data-kit-batch-yes': item.id };
1170
+ const yesAttrs: Record<string, string> = { [KIT_ATTR_BATCH_YES]: item.id };
898
1171
  if (busy) {
899
1172
  yesAttrs.disabled = '';
900
1173
  yesAttrs['aria-busy'] = 'true';
@@ -902,23 +1175,28 @@ export function createKitTableTools(): SomaComponentDefinition {
902
1175
  const yesButton = btn(doc, ACTION_BUTTON_CLASS[item.tone], T('soma.kit.confirm'), yesAttrs, faceOfTone(item.tone));
903
1176
  if (busy) yesButton.disabled = true;
904
1177
  bar.appendChild(yesButton);
905
- bar.appendChild(btn(doc, ACTION_BUTTON_CLASS.neutral, T('soma.kit.cancel'), { 'data-kit-batch-no': item.id }, KIT_FACE_RAISED));
1178
+ bar.appendChild(btn(doc, ACTION_BUTTON_CLASS.neutral, T('soma.kit.cancel'), { [KIT_ATTR_BATCH_NO]: item.id }, KIT_FACE_RAISED));
906
1179
  return bar;
907
1180
  }
908
1181
  }
909
1182
  // 批量动作成组经排布引擎:恒单行,放不下的次要动作收进「更多」(危险项置末加分隔线),主操作恒在行尾可见
1183
+ const check = permissionCheckerOf(api as unknown as any);
1184
+ renderedBatchPerm = batchPermStateOf();
910
1185
  const entries: DomActionEntry[] = [];
911
1186
  for (const b of batch) {
912
1187
  if (b.permission !== '' && check !== null && !check(b.permission)) continue;
913
1188
  const busy = isKitActionBusy(batchBusyNames(b));
914
- const attrs: Record<string, string> = { 'data-kit-batch': b.id };
1189
+ const attrs: Record<string, string> = { [KIT_ATTR_BATCH]: b.id };
915
1190
  if (busy) {
916
1191
  attrs.disabled = '';
917
1192
  attrs['aria-busy'] = 'true';
918
1193
  }
919
- const button = btn(doc, ACTION_BUTTON_CLASS[b.tone], b.name, attrs, faceOfTone(b.tone));
1194
+ // 动作级判定(props.kit.actions[动作id],emit 侧汇总后生效):危险语气按危险档画;不可收纳的永不收进「更多」。没有判定按原样
1195
+ const kit = kitActionPropsOf(P(), b.id);
1196
+ const tone = kit.tone === 'danger' ? 'danger' : b.tone;
1197
+ const button = btn(doc, ACTION_BUTTON_CLASS[tone], b.name, attrs, faceOfTone(tone));
920
1198
  if (busy) button.disabled = true;
921
- entries.push({ id: b.id, label: b.name, importance: b.tone === 'primary' ? 'primary' : b.tone === 'danger' ? 'danger' : 'secondary', tone: b.tone, button });
1199
+ entries.push({ id: b.id, label: b.name, importance: tone === 'primary' ? 'primary' : tone === 'danger' ? 'danger' : 'secondary', tone, button, ...(kit.stowable !== undefined ? { stowable: kit.stowable } : {}) });
922
1200
  }
923
1201
  if (entries.length > 0) {
924
1202
  const built = buildActionGroup(doc, entries);
@@ -947,7 +1225,7 @@ export function createKitTableTools(): SomaComponentDefinition {
947
1225
  const batching = batch.length > 0 && picked.length > 0;
948
1226
  const selectAll = batch.length > 0 && str(p.selectMode) === 'multi';
949
1227
  const activeBefore = doc.activeElement;
950
- const onReload = activeBefore instanceof HTMLElement && root.contains(activeBefore) && activeBefore.matches('[data-kit-tool="reload"]');
1228
+ const onReload = activeBefore instanceof HTMLElement && root.contains(activeBefore) && activeBefore.matches(`[${KIT_ATTR_TOOL}="reload"]`);
951
1229
  const idleBefore = activeBefore === null || activeBefore === doc.body;
952
1230
  // 归还标记由键盘触发的刷新点击置位(见 click 处理);焦点在别处时清掉
953
1231
  if (!onReload && !idleBefore) reloadHadFocus = false;
@@ -970,7 +1248,7 @@ export function createKitTableTools(): SomaComponentDefinition {
970
1248
  liveEl = doc.createElement('div');
971
1249
  liveEl.className = SR_ONLY_CLASS;
972
1250
  liveEl.setAttribute('role', 'status');
973
- liveEl.setAttribute('data-kit-live', '');
1251
+ liveEl.setAttribute(KIT_ATTR_LIVE, '');
974
1252
  root.insertAdjacentElement('afterend', liveEl);
975
1253
  }
976
1254
  const parts: HTMLElement[] = [];
@@ -980,7 +1258,7 @@ export function createKitTableTools(): SomaComponentDefinition {
980
1258
  } else {
981
1259
  if (selectAll) {
982
1260
  const box = createCheck(doc, 'checkbox', { checked: pageState() });
983
- box.setAttribute('data-kit-page-all', '');
1261
+ box.setAttribute(KIT_ATTR_PAGE_ALL, '');
984
1262
  const text = doc.createElement('span');
985
1263
  text.className = CHECK_TEXT_CLASS;
986
1264
  text.textContent = T('soma.kit.select_page');
@@ -998,7 +1276,8 @@ export function createKitTableTools(): SomaComponentDefinition {
998
1276
  }
999
1277
  // 批量条与全选在同一行:全选本页放在批量条之外时与工具栏分居两端
1000
1278
  for (const part of parts) root.appendChild(part);
1001
- root.className = parts.length === 0 ? `${HIDDEN_CLASS}` : `${ROOT_CLASS} ${typeof p.class === 'string' ? p.class : ''}`.trim();
1279
+ // 新模式:列表对齐轴里的轴内边距由本条自带 in-data-kit-axis: 变体类承担(主题不再按组件名写 KitTableTools>div,recipes/self-owned);旧版原样
1280
+ root.className = parts.length === 0 ? `${HIDDEN_CLASS}` : `${kitTableToolsRootClass(ROOT_CLASS)} ${typeof p.class === 'string' ? p.class : ''}`.trim();
1002
1281
  if (focusMark !== null) {
1003
1282
  const now = doc.activeElement;
1004
1283
  if (now === null || now === doc.body) {
@@ -1029,7 +1308,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1029
1308
  if (reloadHadFocus && !busyNow) {
1030
1309
  reloadHadFocus = false;
1031
1310
  const now = doc.activeElement;
1032
- const again = root.querySelector<HTMLElement>('[data-kit-tool="reload"]');
1311
+ const again = root.querySelector<HTMLElement>(`[${KIT_ATTR_TOOL}="reload"]`);
1033
1312
  if (again && (now === null || now === doc.body)) again.focus({ preventScroll: true });
1034
1313
  }
1035
1314
  };
@@ -1045,12 +1324,12 @@ export function createKitTableTools(): SomaComponentDefinition {
1045
1324
  table = (() => {
1046
1325
  const key = api.host.getAttribute('data-soma-id') ?? '';
1047
1326
  if (key !== '') {
1048
- const paired = Array.from(api.host.parentElement?.querySelectorAll<HTMLElement>('[data-kit-table-of]') ?? []).find((e) => e.getAttribute('data-kit-table-of') === key);
1327
+ const paired = Array.from(api.host.parentElement?.querySelectorAll<HTMLElement>(`[${KIT_ATTR_TABLE_OF}]`) ?? []).find((e) => e.getAttribute(KIT_ATTR_TABLE_OF) === key);
1049
1328
  if (paired) return paired;
1050
1329
  }
1051
1330
  const next = api.host.nextElementSibling;
1052
- if (next instanceof HTMLElement && next.hasAttribute('data-kit-table') && !next.hasAttribute('data-kit-table-of')) return next;
1053
- const free = Array.from(api.host.parentElement?.querySelectorAll<HTMLElement>('[data-kit-table]:not([data-kit-table-of])') ?? []);
1331
+ if (next instanceof HTMLElement && next.hasAttribute(KIT_ATTR_TABLE) && !next.hasAttribute(KIT_ATTR_TABLE_OF)) return next;
1332
+ const free = Array.from(api.host.parentElement?.querySelectorAll<HTMLElement>(`[${KIT_ATTR_TABLE}]:not([${KIT_ATTR_TABLE_OF}])`) ?? []);
1054
1333
  return free.length === 1 ? free[0]! : null;
1055
1334
  })();
1056
1335
  hidden = parseHidden(readStore(rememberKey(pathname(), object(), 'cols')), names());
@@ -1144,7 +1423,22 @@ export function createKitTableTools(): SomaComponentDefinition {
1144
1423
  cancelHeldRebuild = () => { rebuildHeld = false; renderHeld = false; pressing = false; disarmHeld(); };
1145
1424
  offs.push(() => cancelHeldRebuild());
1146
1425
  offs.push(() => releaseGroups());
1426
+ // 行拖拽排序:端口的落点意图 -> order_move 纯顺序载荷(页面接 ACTION | data.orderMove)
1427
+ const dnd = dndPortOf();
1428
+ if (dnd) {
1429
+ offs.push(dnd.onMove((intent) => {
1430
+ const field = str(P().reorder);
1431
+ if (field === '') return;
1432
+ const payload = reorderFromIntent(intent, reorderUid, rowsList(), keyField(), field, object());
1433
+ if (payload) api.emit('order_move', payload);
1434
+ }));
1435
+ }
1436
+ offs.push(() => { for (const fn of reorderOffs.splice(0)) fn(); });
1147
1437
  offs.push(onKitActionBusy(() => rebuild()));
1438
+ offs.push(registerLivePermissionGate(() => {
1439
+ if (batchPermStateOf() !== renderedBatchPerm) rebuild();
1440
+ }));
1441
+ offs.push(() => { renderedBatchPerm = ''; });
1148
1442
  for (const sliceName of ['filter', 'view'] as const) {
1149
1443
  const slice = regionPort()?.slice(sliceName);
1150
1444
  if (slice?.subscribe) {
@@ -1163,7 +1457,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1163
1457
  const button = (event as { button?: unknown }).button;
1164
1458
  if (typeof button === 'number' && button !== 0) return;
1165
1459
  const t = event.target;
1166
- if (!(t instanceof Element) || !root.contains(t) || t.closest('button, [role="button"], [data-kit-tool]') === null) return;
1460
+ if (!(t instanceof Element) || !root.contains(t) || t.closest(`button, [role="button"], [${KIT_ATTR_TOOL}]`) === null) return;
1167
1461
  pressing = true;
1168
1462
  armHeldRebuild();
1169
1463
  });
@@ -1178,7 +1472,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1178
1472
  settleEdit();
1179
1473
  if (stillEditing()) return;
1180
1474
  }
1181
- const tool = t.closest<HTMLElement>('[data-kit-tool]')?.getAttribute('data-kit-tool');
1475
+ const tool = t.closest<HTMLElement>(`[${KIT_ATTR_TOOL}]`)?.getAttribute(KIT_ATTR_TOOL);
1182
1476
  if (tool === 'reload') {
1183
1477
  // 焦点归还只给键盘用户:键盘触发的 click 其 detail 为 0,鼠标 ≥ 1
1184
1478
  if ((event as MouseEvent).detail === 0) reloadHadFocus = true;
@@ -1187,15 +1481,21 @@ export function createKitTableTools(): SomaComponentDefinition {
1187
1481
  }
1188
1482
  if (tool === 'export') { exportCsv(); return; }
1189
1483
  if (tool === 'columns') { panelOpen = !panelOpen; rebuild(); return; }
1190
- const dens = t.closest<HTMLElement>('[data-kit-table-density]')?.getAttribute('data-kit-table-density');
1484
+ const dens = t.closest<HTMLElement>(`[${KIT_ATTR_TABLE_DENSITY}]`)?.getAttribute(KIT_ATTR_TABLE_DENSITY);
1191
1485
  if (isDensity(dens)) {
1192
1486
  density = dens;
1193
1487
  writeStore(rememberKey(pathname(), object(), 'density'), dens);
1194
1488
  applyDensity();
1195
- rebuild();
1489
+ const curDens = effectiveDensity();
1490
+ for (const b of Array.from(root.querySelectorAll<HTMLButtonElement>(`[${KIT_ATTR_TABLE_DENSITY}]`))) {
1491
+ const on = b.getAttribute(KIT_ATTR_TABLE_DENSITY) === curDens;
1492
+ b.className = on ? SEG_BTN_ON_CLASS : SEG_BTN_CLASS;
1493
+ b.setAttribute('aria-pressed', on ? 'true' : 'false');
1494
+ setKitFace(b, on ? KIT_FACE_RAISED : null);
1495
+ }
1196
1496
  return;
1197
1497
  }
1198
- if (t.closest('[data-kit-cols-reset]')) {
1498
+ if (t.closest(`[${KIT_ATTR_COLS_RESET}]`)) {
1199
1499
  hidden = new Set();
1200
1500
  persistHidden();
1201
1501
  applyHidden();
@@ -1203,39 +1503,44 @@ export function createKitTableTools(): SomaComponentDefinition {
1203
1503
  rebuild();
1204
1504
  return;
1205
1505
  }
1206
- if (t.closest('[data-kit-sel-clear]')) {
1506
+ if (t.closest(`[${KIT_ATTR_SEL_CLEAR}]`)) {
1207
1507
  allMode = false;
1208
1508
  confirming = null;
1209
1509
  selectRows(selectedList(), false);
1210
1510
  return;
1211
1511
  }
1212
- if (t.closest('[data-kit-select-all]')) { allMode = true; rebuild(); return; }
1213
- if (t.closest('[data-kit-page-select]')) { selectRows(rowsList(), true); return; }
1214
- const batchId = t.closest<HTMLElement>('[data-kit-batch]')?.getAttribute('data-kit-batch');
1512
+ if (t.closest(`[${KIT_ATTR_SELECT_ALL}]`)) { allMode = true; rebuild(); return; }
1513
+ if (t.closest(`[${KIT_ATTR_PAGE_SELECT}]`)) { selectRows(rowsList(), true); return; }
1514
+ const batchId = t.closest<HTMLElement>(`[${KIT_ATTR_BATCH}]`)?.getAttribute(KIT_ATTR_BATCH);
1215
1515
  if (batchId) {
1216
1516
  const item = batchOf(api.props().batch).find((b) => b.id === batchId);
1217
1517
  if (!item) return;
1218
1518
  if (item.confirm !== '') { confirming = item.id; rebuild(); return; }
1219
1519
  if (confirmingBatch || isKitActionBusy(batchBusyNames(item))) return;
1220
- const batchBtn = t.closest<HTMLButtonElement>('[data-kit-batch]');
1221
- if (batchBtn) batchBtn.disabled = true;
1222
- confirmingBatch = true;
1223
- try {
1224
- fireBatch(item);
1225
- } finally {
1226
- queueMicrotask(() => {
1227
- confirmingBatch = false;
1228
- if (batchBtn && !isKitActionBusy(batchBusyNames(item))) batchBtn.disabled = false;
1229
- });
1230
- }
1520
+ const batchBtn = t.closest<HTMLButtonElement>(`[${KIT_ATTR_BATCH}]`);
1521
+ const run = (): void => {
1522
+ // 等待确认期间状态可能变了(在途 / 已在触发):再核一次,同步路径下这两条与上面刚核过的一致
1523
+ if (confirmingBatch || isKitActionBusy(batchBusyNames(item))) return;
1524
+ if (batchBtn) batchBtn.disabled = true;
1525
+ confirmingBatch = true;
1526
+ try {
1527
+ fireBatch(item);
1528
+ } finally {
1529
+ queueMicrotask(() => {
1530
+ confirmingBatch = false;
1531
+ if (batchBtn && !isKitActionBusy(batchBusyNames(item))) batchBtn.disabled = false;
1532
+ });
1533
+ }
1534
+ };
1535
+ batchConfirm.guard(api.props(), item.id, batchBtn ?? t, item.name, run);
1231
1536
  return;
1232
1537
  }
1233
- const yes = t.closest<HTMLElement>('[data-kit-batch-yes]')?.getAttribute('data-kit-batch-yes');
1538
+ const yes = t.closest<HTMLElement>(`[${KIT_ATTR_BATCH_YES}]`)?.getAttribute(KIT_ATTR_BATCH_YES);
1234
1539
  if (yes) {
1235
1540
  const item = batchOf(api.props().batch).find((b) => b.id === yes);
1236
1541
  if (!item) return;
1237
1542
  if (confirmingBatch || isKitActionBusy(batchBusyNames(item))) return;
1238
- const yesBtn = t.closest<HTMLButtonElement>('[data-kit-batch-yes]');
1543
+ const yesBtn = t.closest<HTMLButtonElement>(`[${KIT_ATTR_BATCH_YES}]`);
1239
1544
  if (yesBtn) yesBtn.disabled = true;
1240
1545
  confirmingBatch = true;
1241
1546
  try {
@@ -1249,7 +1554,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1249
1554
  }
1250
1555
  return;
1251
1556
  }
1252
- if (t.closest('[data-kit-batch-no]')) { confirming = null; rebuild(); }
1557
+ if (t.closest(`[${KIT_ATTR_BATCH_NO}]`)) { confirming = null; rebuild(); }
1253
1558
  });
1254
1559
  const fireBatch = (item: BatchItem): void => {
1255
1560
  const curProps = api.props();
@@ -1264,12 +1569,12 @@ export function createKitTableTools(): SomaComponentDefinition {
1264
1569
  };
1265
1570
  // 勾选标记(check-core):全选本页 / 列显隐;乐观着色后再动数据
1266
1571
  const onMark = (mark: HTMLElement, next: boolean): void => {
1267
- paintCheck(mark, { checked: next, extra: mark.hasAttribute('data-kit-col-toggle') ? PANEL_CHECK_CLASS : undefined });
1268
- if (mark.hasAttribute('data-kit-page-all')) {
1572
+ paintCheck(mark, { checked: next, extra: mark.hasAttribute(KIT_ATTR_COL_TOGGLE) ? PANEL_CHECK_CLASS : undefined });
1573
+ if (mark.hasAttribute(KIT_ATTR_PAGE_ALL)) {
1269
1574
  selectRows(rowsList(), next);
1270
1575
  return;
1271
1576
  }
1272
- const f = mark.getAttribute('data-kit-col-toggle');
1577
+ const f = mark.getAttribute(KIT_ATTR_COL_TOGGLE);
1273
1578
  if (f !== null) {
1274
1579
  if (next) hidden.delete(f);
1275
1580
  else hidden.add(f);
@@ -1283,7 +1588,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1283
1588
  event.preventDefault();
1284
1589
  panelOpen = false;
1285
1590
  rebuild();
1286
- root.querySelector<HTMLElement>('[data-kit-tool="columns"]')?.focus();
1591
+ root.querySelector<HTMLElement>(`[${KIT_ATTR_TOOL}="columns"]`)?.focus();
1287
1592
  } else if (event.key === 'Escape' && confirming !== null) {
1288
1593
  confirming = null;
1289
1594
  rebuild();
@@ -1294,7 +1599,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1294
1599
  // 面板在浮层里:勾选 / 恢复默认 / Esc 直接听在面板上(与 root 上的委托同一套处理)
1295
1600
  attachMarkEvents(panel, onMark);
1296
1601
  panel.addEventListener('click', (event: Event) => {
1297
- if (!(event.target as HTMLElement | null)?.closest('[data-kit-cols-reset]')) return;
1602
+ if (!(event.target as HTMLElement | null)?.closest(`[${KIT_ATTR_COLS_RESET}]`)) return;
1298
1603
  hidden = new Set();
1299
1604
  persistHidden();
1300
1605
  applyHidden();
@@ -1307,7 +1612,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1307
1612
  event.stopPropagation();
1308
1613
  panelOpen = false;
1309
1614
  rebuild();
1310
- root.querySelector<HTMLElement>('[data-kit-tool="columns"]')?.focus();
1615
+ root.querySelector<HTMLElement>(`[${KIT_ATTR_TOOL}="columns"]`)?.focus();
1311
1616
  });
1312
1617
  };
1313
1618
 
@@ -1316,13 +1621,13 @@ export function createKitTableTools(): SomaComponentDefinition {
1316
1621
  const tb = table;
1317
1622
  on(tb, 'scroll', () => applyEdges());
1318
1623
  on(tb, 'dblclick', (event: Event) => {
1319
- const cell = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-editable]');
1320
- if (cell && !(event.target as HTMLElement).closest('[data-kit-edit-control]')) startEdit(cell);
1624
+ const cell = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_EDITABLE}]`);
1625
+ if (cell && !(event.target as HTMLElement).closest(`[${KIT_ATTR_EDIT_CONTROL}]`)) startEdit(cell);
1321
1626
  });
1322
1627
  on(tb, 'keydown', (event: KeyboardEvent) => {
1323
1628
  const t = event.target as HTMLElement | null;
1324
1629
  if (!t) return;
1325
- const control = t.closest('[data-kit-edit-control]');
1630
+ const control = t.closest(`[${KIT_ATTR_EDIT_CONTROL}]`);
1326
1631
  if (control && editing) {
1327
1632
  // 自绘下拉自己处理 Enter(开面板 / 选中,已 preventDefault),不当作整行提交
1328
1633
  const onSelect = editing.cells.some((c) => c.col.kind === 'select' && c.control === control);
@@ -1330,7 +1635,7 @@ export function createKitTableTools(): SomaComponentDefinition {
1330
1635
  else if (event.key === 'Escape') { event.preventDefault(); cancelEdit(true); }
1331
1636
  return;
1332
1637
  }
1333
- if ((event.key === 'Enter' || event.key === 'F2') && t.hasAttribute('data-kit-editable')) {
1638
+ if ((event.key === 'Enter' || event.key === 'F2') && t.hasAttribute(KIT_ATTR_EDITABLE)) {
1334
1639
  event.preventDefault();
1335
1640
  startEdit(t);
1336
1641
  }
@@ -1395,6 +1700,8 @@ export function createKitTableTools(): SomaComponentDefinition {
1395
1700
  }
1396
1701
  applyAll();
1397
1702
  return () => {
1703
+ batchConfirm.dispose();
1704
+ while (reorderOffs.length > 0) reorderOffs.pop()!();
1398
1705
  for (const off of offs) off();
1399
1706
  if (rootEl) releaseDropdownsIn(rootEl);
1400
1707
  panelBind = null;