soma-kit 0.1.11 → 0.1.13

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 (376) hide show
  1. package/README.md +106 -112
  2. package/bin/soma-kit.mjs +32 -2
  3. package/bin/soma.mjs +22 -0
  4. package/package.json +14 -7
  5. package/packs/finance/reconcile-board.ts +5 -2
  6. package/packs/finance/reconcile-desk/compile.ts +3 -2
  7. package/spec/generated/kit-app.schema.json +929 -37
  8. package/spec/generated/kit-page.schema.json +1684 -161
  9. package/spec/kit-grammar.json +1176 -584
  10. package/spec/kit-grammar.schema.json +1971 -393
  11. package/src/app/app-config.ts +449 -347
  12. package/src/app/component-gate.ts +283 -28
  13. package/src/app/compose-apps.ts +79 -8
  14. package/src/app/define-kit-actions.ts +245 -41
  15. package/src/app/define-kit-app.ts +176 -33
  16. package/src/app/define-kit-view.ts +104 -0
  17. package/src/app/dev-diagnostic.ts +5 -0
  18. package/src/app/envelope.ts +1 -161
  19. package/src/app/index.ts +29 -6
  20. package/src/app/kit-view-context.ts +439 -0
  21. package/src/app/notify-renderer.ts +1 -115
  22. package/src/app/paged-list-adapter.ts +1 -240
  23. package/src/app/render-ports.ts +18 -0
  24. package/src/app/server-pages.ts +11 -3
  25. package/src/app/server.ts +530 -103
  26. package/src/app/submit.types.ts +1 -1
  27. package/src/app/theme-endpoint.ts +63 -0
  28. package/src/app/theme-runtime-shared.ts +1 -0
  29. package/src/app/theme-runtime.ts +667 -0
  30. package/src/base/action-busy.ts +103 -6
  31. package/src/base/action-gate.ts +4 -255
  32. package/src/base/action-slots.ts +58 -0
  33. package/src/base/alert.ts +5 -3
  34. package/src/base/anchored-layer.ts +50 -0
  35. package/src/base/avatar.ts +2 -2
  36. package/src/base/button.ts +99 -37
  37. package/src/base/cascader.ts +11 -12
  38. package/src/base/check-core.ts +9 -1
  39. package/src/base/checkbox.ts +2 -1
  40. package/src/base/choice.ts +49 -28
  41. package/src/base/class-candidates.ts +17 -0
  42. package/src/base/color-picker.ts +16 -11
  43. package/src/base/combobox.ts +5 -3
  44. package/src/base/command-palette.ts +10 -6
  45. package/src/base/context-menu.ts +10 -7
  46. package/src/base/countdown.ts +1 -1
  47. package/src/base/date-range.ts +32 -18
  48. package/src/base/date.ts +135 -28
  49. package/src/base/delta.ts +72 -0
  50. package/src/base/divider.ts +2 -2
  51. package/src/base/end-edge.ts +49 -0
  52. package/src/base/fab.ts +12 -5
  53. package/src/base/gap-value.ts +148 -0
  54. package/src/base/hint-tips.ts +170 -0
  55. package/src/base/icons.ts +8 -0
  56. package/src/base/illustrations.ts +94 -0
  57. package/src/base/image.ts +1 -1
  58. package/src/base/index.ts +35 -11
  59. package/src/base/input.ts +42 -13
  60. package/src/base/kbd.ts +3 -1
  61. package/src/base/link.ts +4 -4
  62. package/src/base/listbox-core.ts +56 -35
  63. package/src/base/loading-gate.ts +186 -0
  64. package/src/base/mentions.ts +7 -6
  65. package/src/base/menu-button.ts +28 -12
  66. package/src/base/menu-core.ts +41 -8
  67. package/src/base/motion/aura.ts +2 -2
  68. package/src/base/motion/hover-3d.ts +3 -3
  69. package/src/base/motion/hover-gallery.ts +2 -2
  70. package/src/base/motion/marquee.ts +3 -3
  71. package/src/base/motion/text-rotate.ts +2 -2
  72. package/src/base/number.ts +93 -80
  73. package/src/base/otp.ts +9 -5
  74. package/src/base/overlay-runtime.ts +235 -0
  75. package/src/base/permission-gate.ts +6 -0
  76. package/src/base/popover.ts +48 -16
  77. package/src/base/popup.ts +143 -19
  78. package/src/base/portal-core.ts +4 -0
  79. package/src/base/price-text.ts +2 -2
  80. package/src/base/progress.ts +2 -2
  81. package/src/base/qr-code.ts +4 -4
  82. package/src/base/qty-stepper.ts +14 -8
  83. package/src/base/radio.ts +2 -1
  84. package/src/base/range.ts +21 -4
  85. package/src/base/rating.ts +12 -7
  86. package/src/base/reason-tip.ts +150 -0
  87. package/src/base/segmented.ts +27 -21
  88. package/src/base/select.ts +4 -3
  89. package/src/base/shared.ts +387 -49
  90. package/src/base/state-panel.ts +346 -0
  91. package/src/base/status-tone.ts +27 -0
  92. package/src/base/sticky-edge.ts +116 -0
  93. package/src/base/swap.ts +10 -7
  94. package/src/base/switch.ts +11 -6
  95. package/src/base/tag-input.ts +20 -16
  96. package/src/base/tag.ts +68 -34
  97. package/src/base/text.ts +80 -18
  98. package/src/base/textarea.ts +37 -11
  99. package/src/base/time-picker.ts +18 -13
  100. package/src/base/tree-select.ts +21 -12
  101. package/src/base/trend-tone.ts +9 -0
  102. package/src/base/upload.ts +48 -14
  103. package/src/base/view-transition.ts +77 -0
  104. package/src/base/virtual-list.ts +107 -1
  105. package/src/biz/approval-desk/compile.ts +23 -41
  106. package/src/biz/approval-desk/shell.ts +11 -8
  107. package/src/biz/auth-panel/compile.ts +37 -52
  108. package/src/biz/auth-panel/index.ts +1 -1
  109. package/src/biz/auth-panel/shell.ts +5 -4
  110. package/src/biz/category-crud/compile.ts +23 -37
  111. package/src/biz/category-crud/shell.ts +2 -1
  112. package/src/biz/checkout-page/compile.ts +22 -5
  113. package/src/biz/checkout-page/shell.ts +4 -3
  114. package/src/biz/compose.ts +13 -27
  115. package/src/biz/define.ts +5 -4
  116. package/src/biz/import-wizard/compile.ts +22 -26
  117. package/src/biz/import-wizard/hub.ts +126 -61
  118. package/src/biz/import-wizard/shell.ts +5 -4
  119. package/src/biz/index.ts +3 -3
  120. package/src/biz/landing-page/compile.ts +19 -3
  121. package/src/biz/link/hub.ts +69 -22
  122. package/src/biz/link/shared.ts +127 -119
  123. package/src/biz/master-sub/compile.ts +127 -48
  124. package/src/biz/master-sub/index.ts +5 -2
  125. package/src/biz/master-sub/shell.ts +95 -18
  126. package/src/biz/multi-board/compile.ts +38 -50
  127. package/src/biz/multi-board/index.ts +18 -1
  128. package/src/biz/multi-board/shell.ts +32 -20
  129. package/src/biz/notification-center/compile.ts +21 -33
  130. package/src/biz/notification-center/shell.ts +6 -4
  131. package/src/biz/page-templates/domain-templates.ts +80 -13
  132. package/src/biz/page-templates/result-page/compile.ts +11 -2
  133. package/src/biz/page-templates/result-page/shell.ts +2 -1
  134. package/src/biz/page-templates/shared.ts +34 -36
  135. package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
  136. package/src/biz/record-detail/compile.ts +48 -43
  137. package/src/biz/record-detail/index.ts +11 -1
  138. package/src/biz/record-detail/shell.ts +8 -6
  139. package/src/biz/settings-center/compile.ts +7 -5
  140. package/src/biz/settings-center/shell.ts +6 -4
  141. package/src/biz/shared/action-host.ts +97 -211
  142. package/src/biz/shared/compile-helpers.ts +98 -0
  143. package/src/biz/shared/coordinator.ts +472 -92
  144. package/src/biz/shared/index.ts +13 -2
  145. package/src/biz/shared/object-aliases.ts +154 -0
  146. package/src/biz/shared/overlay-compile.ts +239 -0
  147. package/src/biz/shared/overlay-shell.ts +209 -0
  148. package/src/biz/shared/pipes.ts +50 -31
  149. package/src/biz/shared/remove-wire.ts +14 -0
  150. package/src/biz/shared/runtime-hub.ts +226 -24
  151. package/src/biz/single-form/compile.ts +16 -37
  152. package/src/biz/single-form/shell.ts +4 -3
  153. package/src/biz/standard-crud/compile.ts +72 -255
  154. package/src/biz/standard-crud/shell.ts +21 -99
  155. package/src/biz/step-form/compile.ts +26 -97
  156. package/src/biz/step-form/hub.ts +34 -41
  157. package/src/biz/step-form/shell.ts +5 -5
  158. package/src/biz/types.ts +4 -3
  159. package/src/cli/core-imports.ts +54 -0
  160. package/src/cli/kit-cli.ts +254 -25
  161. package/src/cli/kit-init.ts +227 -0
  162. package/src/cli/layout-cli.ts +167 -0
  163. package/src/cli/migrate/index.ts +10 -0
  164. package/src/cli/migrate/migrate.ts +248 -0
  165. package/src/cli/migrate/text-utils.ts +306 -0
  166. package/src/cli/migrate/theme-map.ts +104 -0
  167. package/src/cli/migrate/ts-rules.ts +235 -0
  168. package/src/cli/migrate/types.ts +95 -0
  169. package/src/cli/migrate/view-skeleton.ts +159 -0
  170. package/src/cli/migrate/yaml-report.ts +376 -0
  171. package/src/cli/migrate/yaml-rules.ts +465 -0
  172. package/src/cli/service-endpoint-check.ts +425 -0
  173. package/src/cli/source-path-check.d.mts +17 -0
  174. package/src/cli/source-path-check.mjs +334 -0
  175. package/src/cli/view-writes.ts +761 -0
  176. package/src/compile/action-host-attach.ts +21 -29
  177. package/src/compile/closed-set.ts +570 -0
  178. package/src/compile/compile-page.ts +267 -76
  179. package/src/compile/component-candidates.ts +13 -2
  180. package/src/compile/hints.ts +30 -1
  181. package/src/compile/index.ts +1 -0
  182. package/src/compile/kit-error.ts +1 -0
  183. package/src/compile/layout-lint/engine.ts +82 -0
  184. package/src/compile/layout-lint/index.ts +55 -0
  185. package/src/compile/layout-lint/rules-composition.ts +218 -0
  186. package/src/compile/layout-lint/rules-form.ts +192 -0
  187. package/src/compile/layout-lint/rules-table.ts +194 -0
  188. package/src/compile/layout-lint/score.ts +52 -0
  189. package/src/compile/layout-lint/types.ts +51 -0
  190. package/src/compile/locate.ts +21 -1
  191. package/src/compile/parse.ts +370 -41
  192. package/src/compile/redirect.ts +6 -2
  193. package/src/compile/remove-guard.ts +10 -7
  194. package/src/compile/styles.ts +63 -2
  195. package/src/compile/types.ts +31 -3
  196. package/src/compile/view-check.ts +284 -0
  197. package/src/data/amount-breakdown.ts +8 -3
  198. package/src/data/anchor-nav.ts +2 -2
  199. package/src/data/approval-flow.ts +3 -3
  200. package/src/data/assignment-picker.ts +92 -55
  201. package/src/data/async-result-panel.ts +111 -9
  202. package/src/data/breadcrumbs.ts +5 -4
  203. package/src/data/calendar.ts +24 -27
  204. package/src/data/carousel.ts +13 -8
  205. package/src/data/chart.ts +183 -44
  206. package/src/data/checklist.ts +20 -7
  207. package/src/data/code-view.ts +12 -6
  208. package/src/data/comment-thread.ts +7 -4
  209. package/src/data/confirm-dialog.ts +81 -18
  210. package/src/data/context-menu.ts +29 -37
  211. package/src/data/d9-util.ts +2 -18
  212. package/src/data/diff.ts +4 -2
  213. package/src/data/dock.ts +3 -3
  214. package/src/data/embed.ts +233 -30
  215. package/src/data/field-mapper.ts +35 -30
  216. package/src/data/flow-editor-contract.ts +8 -1
  217. package/src/data/flow-editor.ts +113 -108
  218. package/src/data/flow-node-options.ts +120 -0
  219. package/src/data/flow-remote-options.ts +0 -103
  220. package/src/data/footer.ts +2 -2
  221. package/src/data/form-draft-registry.ts +2 -4
  222. package/src/data/gantt.ts +19 -19
  223. package/src/data/hero.ts +4 -3
  224. package/src/data/image-viewer.ts +27 -30
  225. package/src/data/index.ts +5 -2
  226. package/src/data/item-list.ts +48 -31
  227. package/src/data/kanban.ts +82 -52
  228. package/src/data/media-grid.ts +20 -20
  229. package/src/data/mega-menu.ts +6 -4
  230. package/src/data/menu-dom.ts +4 -2
  231. package/src/data/menu.ts +47 -15
  232. package/src/data/mockup.ts +10 -6
  233. package/src/data/modal-dialog.ts +49 -25
  234. package/src/data/navbar.ts +12 -7
  235. package/src/data/notice-list.ts +268 -0
  236. package/src/data/notify-renderer.ts +250 -0
  237. package/src/data/object-form.ts +1360 -666
  238. package/src/data/outcome-watch.ts +61 -2
  239. package/src/data/pager.ts +80 -34
  240. package/src/data/permission-matrix.ts +52 -31
  241. package/src/data/permission-tree.ts +71 -44
  242. package/src/data/pricing-table.ts +30 -14
  243. package/src/data/prompt-dialog.ts +124 -194
  244. package/src/data/reaction-bar.ts +83 -92
  245. package/src/data/read-rollback.ts +73 -0
  246. package/src/data/record-card.ts +26 -5
  247. package/src/data/record-picker.ts +104 -55
  248. package/src/data/redirect.ts +32 -32
  249. package/src/data/remote-options.ts +13 -6
  250. package/src/data/request-console.ts +5 -3
  251. package/src/data/resident.ts +2 -1
  252. package/src/data/result-panel.ts +8 -4
  253. package/src/data/rich-text.ts +61 -55
  254. package/src/data/row-editor.ts +362 -76
  255. package/src/data/rule-builder.ts +26 -20
  256. package/src/data/shape-util.ts +27 -9
  257. package/src/data/stat-group.ts +392 -109
  258. package/src/data/static-lazy.ts +1 -0
  259. package/src/data/static-registry.ts +24 -11
  260. package/src/data/steps.ts +10 -5
  261. package/src/data/survey.ts +27 -32
  262. package/src/data/system-switcher.ts +3 -3
  263. package/src/data/text-action-button.ts +17 -0
  264. package/src/data/timeline.ts +19 -8
  265. package/src/data/tour-guide.ts +23 -30
  266. package/src/data/transfer.ts +62 -38
  267. package/src/data/tree-table.ts +152 -78
  268. package/src/data/tree.ts +49 -36
  269. package/src/data/trend-line.ts +6 -24
  270. package/src/data/virtual-rows.ts +133 -82
  271. package/src/data/watermark.ts +2 -2
  272. package/src/data/wrap.ts +63 -38
  273. package/src/data/wrapped-candidates.ts +10 -0
  274. package/src/frames/blank-frame.ts +1 -0
  275. package/src/frames/index.ts +2 -2
  276. package/src/frames/page-bar.ts +26 -24
  277. package/src/frames/page-header.ts +14 -5
  278. package/src/frames/page-status.ts +9 -7
  279. package/src/frames/shared.ts +36 -25
  280. package/src/frames/single-frame.ts +1 -0
  281. package/src/frames/split-frame/shell.ts +6 -6
  282. package/src/frames/split-frame/wiring.ts +2 -2
  283. package/src/frames/tabs-frame/shell.ts +4 -14
  284. package/src/frames/tabs-frame/wiring.ts +5 -8
  285. package/src/frames/top-main-frame.ts +3 -2
  286. package/src/frames/types.ts +13 -2
  287. package/src/frames/workspace-frame/extras.ts +21 -5
  288. package/src/frames/workspace-frame/index.ts +1 -1
  289. package/src/frames/workspace-frame/shell.ts +3 -2
  290. package/src/frames/workspace-frame/state.ts +13 -6
  291. package/src/frames/workspace-frame/view.ts +250 -48
  292. package/src/generated/kit-grammar-runtime.ts +645 -397
  293. package/src/generated/page-origin.ts +0 -11
  294. package/src/i18n/kit-text.ts +84 -29
  295. package/src/i18n/resolve-text-refs.ts +22 -6
  296. package/src/index.ts +2 -1
  297. package/src/object-renderer/action-gate.ts +11 -147
  298. package/src/object-renderer/arrange.ts +112 -84
  299. package/src/object-renderer/collapse-wiring.ts +2 -2
  300. package/src/object-renderer/collection-expand.ts +2 -2
  301. package/src/object-renderer/collection-parts.ts +401 -104
  302. package/src/object-renderer/collection-table.ts +287 -45
  303. package/src/object-renderer/collection.ts +258 -104
  304. package/src/object-renderer/compile-data.ts +112 -102
  305. package/src/object-renderer/crud-bridge.ts +32 -0
  306. package/src/object-renderer/defaults.ts +38 -16
  307. package/src/object-renderer/display-checks.ts +4 -25
  308. package/src/object-renderer/emit-events.ts +224 -176
  309. package/src/object-renderer/emit-object.ts +15 -2
  310. package/src/object-renderer/emit-static.ts +533 -151
  311. package/src/object-renderer/field-value.ts +593 -396
  312. package/src/object-renderer/filter-reload.ts +70 -0
  313. package/src/object-renderer/form-detail.ts +111 -2
  314. package/src/object-renderer/form-notify.ts +45 -0
  315. package/src/object-renderer/index.ts +26 -0
  316. package/src/object-renderer/key-field.ts +12 -0
  317. package/src/object-renderer/layout-facts.ts +386 -0
  318. package/src/object-renderer/layout-plan.ts +132 -0
  319. package/src/object-renderer/layout-plan.types.ts +22 -0
  320. package/src/object-renderer/linkage.ts +7 -270
  321. package/src/object-renderer/merge-class.ts +18 -1
  322. package/src/object-renderer/parts.ts +252 -1
  323. package/src/object-renderer/path-pick.ts +27 -0
  324. package/src/object-renderer/render-object.ts +456 -89
  325. package/src/object-renderer/request-actions.ts +232 -249
  326. package/src/object-renderer/skeleton.ts +58 -19
  327. package/src/object-renderer/table-actions.ts +319 -111
  328. package/src/object-renderer/table-summary.ts +2 -2
  329. package/src/object-renderer/table-tools.ts +429 -94
  330. package/src/object-renderer/types.ts +204 -127
  331. package/src/object-renderer/view-binding.ts +393 -0
  332. package/src/page-target/ai-surface.ts +37 -0
  333. package/src/page-target/compile.ts +48 -8
  334. package/src/page-target/index.ts +8 -1
  335. package/src/page-target/intent-schema.ts +165 -28
  336. package/src/page-target/target.ts +262 -51
  337. package/src/page-target/writer-policy.ts +14 -3
  338. package/src/recipes/container.ts +210 -0
  339. package/src/recipes/control.ts +277 -0
  340. package/src/recipes/index.ts +312 -0
  341. package/src/recipes/nowrap.ts +16 -0
  342. package/src/recipes/overlay.ts +240 -0
  343. package/src/recipes/placeholder.ts +79 -0
  344. package/src/recipes/rail-grid.ts +45 -0
  345. package/src/recipes/slot-align.ts +56 -0
  346. package/src/recipes/state.ts +99 -0
  347. package/src/recipes/status.ts +139 -0
  348. package/src/recipes/surface.ts +40 -0
  349. package/src/recipes/table-row.ts +88 -0
  350. package/src/recipes/title-row.ts +37 -0
  351. package/src/recipes/typography.ts +99 -0
  352. package/src/shared/action-field-guard.ts +41 -0
  353. package/src/shared/confirm-decl.ts +118 -0
  354. package/src/shared/envelope.ts +207 -0
  355. package/src/shared/escape.ts +57 -0
  356. package/src/shared/kit-error.ts +21 -0
  357. package/src/shared/paged-list-adapter.ts +15 -0
  358. package/src/shared/path-guard.ts +127 -0
  359. package/src/shared/theme-runtime-shared.ts +180 -0
  360. package/src/shared/view-info.ts +10 -0
  361. package/src/theme/index.ts +13 -0
  362. package/src/theme/kit-theme-text.ts +1 -1
  363. package/src/theme/kit-theme.css +407 -10
  364. package/src/theme/kit-theme.tpl +407 -10
  365. package/src/theme/nine-dim-structure.ts +247 -0
  366. package/src/theme/surface-layers.ts +101 -0
  367. package/src/theme/theme-tokens.ts +130 -84
  368. package/src/theme/theme-types.ts +103 -0
  369. package/src/theme/typography.ts +17 -17
  370. package/src/biz/shared/step-values.ts +0 -25
  371. package/src/biz/step-form/steps-ref.ts +0 -112
  372. package/src/data/options-bus.ts +0 -24
  373. package/src/object-renderer/adopt-gate.ts +0 -333
  374. package/src/object-renderer/field-policy.ts +0 -89
  375. package/src/object-renderer/outcome-draft.ts +0 -61
  376. package/src/theme/nine-dim-palettes.ts +0 -1473
@@ -12,21 +12,35 @@ import type { SomaComponentDefinition } from 'soma-core';
12
12
  import { CLASS_PROP, createKitController, joinClass, str, type KitApi, type KitProps } from '../base/shared';
13
13
  import { permissionCheckerOf } from '../base/permission-gate';
14
14
  import { kitIcon } from '../base/icons';
15
- import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, setMarkLabel } from '../base/check-core';
15
+ import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, isMark, markInput, setMarkLabel } from '../base/check-core';
16
16
  import { wireMenu, type MenuClasses, type MenuHandle } from '../base/menu-core';
17
17
  import { KIT_POPUP_PLACE_CLASS_CANDIDATES, type PopPlace } from '../base/popup';
18
18
  import { KIT_MENU_BUTTON_CLASS_CANDIDATES, KIT_MENU_ITEM_CLASSES, KIT_MENU_PANEL } from '../base/menu-button';
19
19
  import { createPanelPortal, KIT_PANEL_PORTAL_CLASS_CANDIDATES } from '../data/overlay-portal';
20
- import { holds } from './linkage';
21
- import { evalActionGate, gateFrom, gateOutcomeNamesOf, gateOutcomeReader, gateRowKey, watchGateOutcomes, type KitActionGate } from '../base/action-gate';
22
- import type { SomaDataPort } from 'soma-core';
23
20
  import { expandKeyOf, moveExpandChild, returnExpandChild } from './collection-expand';
24
21
  import { kitText } from '../i18n/kit-text';
22
+ import { kitTextActionRecipe } from '../recipes';
23
+ import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
24
+ import { KIT_ITEM_TONE_CLASS, KIT_ROW_TONE_CLASS, disabledReasonOf, rowActionState, rowToneClass } from './view-binding';
25
+ import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
26
+ import { KIT_REASON_TIP_CLASS_CANDIDATES, releaseReasonTipsIn, syncReasonTip } from '../base/reason-tip';
27
+ import { kitDisabledRecipe } from '../recipes';
28
+ import { kitRowActionsNarrowCap, kitRowActionsNarrowTier } from 'soma-foundation/kit-layout';
29
+ import { watchEndEdge } from '../base/end-edge';
30
+
31
+ /** 行操作所在的表格容器(窄档判定用):普通表 / 虚拟表的外壳;不在表格里(cards / stack 条目等)= 无,按宽档 */
32
+ const TABLE_CONTAINER = '[data-kit-part="table"], [data-kit-vscroll]';
25
33
 
26
34
  // B8:行操作超过 maxInline 个(或动作写了 more: true)折叠进「更多」菜单(与 MenuButton 共用 menu-core 的菜单内核)
27
- const MORE_ROOT_CLASS = 'relative inline-block';
35
+ const MORE_ROOT_CLASS = 'relative inline-block shrink-0';
36
+ // 窄档折叠的容器查询档名读 design(type-presentation#/action/maxInline.narrowBelowTier),与表格窄栅格同一档;
37
+ // 次要行内操作窄档隐藏,宽档全部行内时「更多」触发器只在窄档显示(容器查询变体 `@max-<档>:`,本文件不写数字)
38
+ const NARROW_TIER = kitRowActionsNarrowTier();
39
+ const ROW_ACTION_SECONDARY_CLASS = `@max-${NARROW_TIER}:hidden`;
40
+ const MORE_ROOT_NARROW_ONLY_CLASS = `relative shrink-0 hidden @max-${NARROW_TIER}:inline-block`;
28
41
  // 外观只有一份:触发钮 / 面板 / 菜单项类全部取自 base/menu-button(KIT_MENU_PANEL、KIT_MENU_ITEM_CLASSES),这里不再手抄
29
- const MORE_TRIGGER_CLASS = KIT_MENU_PANEL.ghostTrigger();
42
+ // 「更多」触发器与行内操作同为文字链接形态(主色文字 + 下拉箭头)
43
+ const MORE_TRIGGER_CLASS = kitTextActionRecipe('primary');
30
44
  const MORE_PLACE: PopPlace = { side: 'bottom', align: 'end' };
31
45
  const MORE_MENU_SHOWN = KIT_MENU_PANEL.classFor(MORE_PLACE);
32
46
  export const MORE_MENU_CLASSES: MenuClasses = KIT_MENU_ITEM_CLASSES;
@@ -37,12 +51,25 @@ type ActionTone = 'primary' | 'neutral' | 'danger';
37
51
 
38
52
  // 每种语气一整串字面量,不拼接
39
53
  export const ACTION_BUTTON_CLASS: Record<ActionTone, string> = {
40
- primary: 'inline-flex h-8 items-center justify-center rounded-md bg-primary px-3 text-sm font-medium text-primary-fg hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
41
- neutral: 'inline-flex h-8 items-center justify-center rounded-md border border-border bg-surface px-3 text-sm font-medium text-fg hover:bg-surface-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
42
- danger: 'inline-flex h-8 items-center justify-center rounded-md bg-transparent px-3 text-sm font-medium text-danger-on-soft transition-colors hover:bg-danger-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
54
+ primary: 'inline-flex h-8 shrink-0 items-center justify-center whitespace-nowrap rounded-md bg-primary px-3 text-sm font-medium text-primary-fg hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
55
+ neutral: 'inline-flex h-8 shrink-0 items-center justify-center whitespace-nowrap rounded-md border border-button-edge bg-surface px-3 text-sm font-medium text-fg state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
56
+ danger: 'inline-flex h-8 shrink-0 items-center justify-center whitespace-nowrap rounded-md bg-transparent px-3 text-sm font-medium text-danger-on-soft transition-colors hover:bg-danger-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
57
+ };
58
+
59
+ /**
60
+ * 行内操作(表格 / 树表 / 虚拟表的操作列):文字链接形态(配方 kitTextActionRecipe)——primary / neutral 为主色文字,danger 为危险语义色文字,
61
+ * 无底无描边,点击热区仍是 h-8、行里占高收回到一行文字,悬停下划线,焦点环保留。2026-11-17 推翻「danger 与 neutral 同形的描边按钮」旧口径。
62
+ * 工具栏 / 批量条仍用 ACTION_BUTTON_CLASS。
63
+ */
64
+ export const ROW_ACTION_BUTTON_CLASS: Record<ActionTone, string> = {
65
+ primary: kitTextActionRecipe('primary'),
66
+ neutral: kitTextActionRecipe('neutral'),
67
+ danger: kitTextActionRecipe('danger'),
43
68
  };
44
69
 
45
- const ROOT_CLASS = 'flex flex-wrap items-center gap-2';
70
+ // 行操作根:链接不收缩、不折行(flex-nowrap + whitespace-nowrap,行高保持一行),项间距 16px(gap-x-4);放不下的由切分(splitRowActions)并入「更多」,不靠换行;
71
+ // 窄容器下超出窄档行内上限的动作标次要、由容器查询隐藏并在「更多」菜单打开时现算并入,操作列按内容定宽(见 collection 的窄栅格列轨)
72
+ const ROOT_CLASS = 'flex flex-nowrap items-center gap-x-4 whitespace-nowrap';
46
73
  /** 展开行开关按钮(文字钮,不带底色) */
47
74
  const EXPAND_BUTTON_CLASS = 'inline-flex items-center text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
48
75
  /** 整行点击不响应的行内交互元素(它们有自己的事件):按钮 / 链接 / 输入 / 菜单 / 勾选列 / 就地编辑格 */
@@ -51,6 +78,23 @@ const ROW_INTERACTIVE = 'button, a, input, select, textarea, label, [data-kit-ac
51
78
  const ROW_FOCUS_CLASS = 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset';
52
79
  /** 已加上焦点属性的行容器(卸载时还原) */
53
80
  const FOCUSABLE_ROWS = new WeakSet<HTMLElement>();
81
+ /** 还焦点:勾选标记(label)自身不可聚焦,落到里面的原生 input */
82
+ function focusControl(el: HTMLElement | null | undefined): void {
83
+ if (!el) return;
84
+ (isMark(el) ? (markInput(el) ?? el) : el).focus();
85
+ }
86
+ /** 元素身份编号(-1 = 无元素):重绘签名用它感知「组件被移入 / 移出某行或展开行」 */
87
+ const ELEMENT_IDS = new WeakMap<Element, number>();
88
+ let elementIdSeq = 0;
89
+ function elementId(el: Element | null): number {
90
+ if (el === null) return -1;
91
+ let id = ELEMENT_IDS.get(el);
92
+ if (id === undefined) {
93
+ id = ++elementIdSeq;
94
+ ELEMENT_IDS.set(el, id);
95
+ }
96
+ return id;
97
+ }
54
98
 
55
99
  type SelectMode = 'none' | 'single' | 'multi';
56
100
 
@@ -60,6 +104,24 @@ function rowKeyOf(row: unknown, keyField: string): string {
60
104
  return keyField !== '' && v !== undefined && v !== null ? String(v) : JSON.stringify(row);
61
105
  }
62
106
 
107
+ /** 行主键的字符串键:与协调组件删除目标的键同一规则(主键值是字符串 / 数字取它,否则整行 JSON) */
108
+ export function removeKeyOf(row: unknown, keyField: string): string {
109
+ const rec = row !== null && typeof row === 'object' ? (row as Record<string, unknown>) : {};
110
+ const v = keyField !== '' ? rec[keyField] : undefined;
111
+ return typeof v === 'string' || typeof v === 'number' ? String(v) : JSON.stringify(rec);
112
+ }
113
+
114
+ /** 行在途(内置删除与具名行动作共用)的忙闲通道名:作用域 + 对象名 + 行主键三段(同作用域下不同对象主键相同也不撞名;base/action-busy 以空白 / 逗号切名字,故各段做 URI 编码);协调组件(内置删除)与动作执行器(具名行动作,按载荷 kit_row_busy)登记,本组件读 */
115
+ export function rowBusyName(scope: string, object: string, key: string): string {
116
+ return `kit_row:${encodeURIComponent(scope)}:${encodeURIComponent(object)}:${encodeURIComponent(key)}`;
117
+ }
118
+
119
+ function removeBusyOf(p: Record<string, unknown>): boolean {
120
+ const scope = str(p.removeScope);
121
+ const object = str(p.removeObject);
122
+ return scope !== '' && object !== '' && isKitActionBusy(rowBusyName(scope, object, removeKeyOf(p.row, str(p.removeKeyField))));
123
+ }
124
+
63
125
  /** 供候选类汇总(candidates.ts)。 */
64
126
  export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
65
127
  ROOT_CLASS,
@@ -67,9 +129,13 @@ export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
67
129
  ROW_FOCUS_CLASS,
68
130
  EXPAND_BUTTON_CLASS,
69
131
  ...Object.values(ACTION_BUTTON_CLASS),
70
- MORE_ROOT_CLASS, MORE_TRIGGER_CLASS, MORE_MENU_SHOWN, 'hidden', ...Object.values(MORE_MENU_CLASSES), ...KIT_MENU_BUTTON_CLASS_CANDIDATES,
132
+ ...Object.values(ROW_ACTION_BUTTON_CLASS),
133
+ ...Object.values(KIT_ROW_TONE_CLASS),
134
+ ...Object.values(KIT_ITEM_TONE_CLASS),
135
+ MORE_ROOT_CLASS, MORE_ROOT_NARROW_ONLY_CLASS, ROW_ACTION_SECONDARY_CLASS, MORE_TRIGGER_CLASS, MORE_MENU_SHOWN, 'hidden', ...Object.values(MORE_MENU_CLASSES), ...KIT_MENU_BUTTON_CLASS_CANDIDATES,
71
136
  ...KIT_POPUP_PLACE_CLASS_CANDIDATES,
72
137
  ...KIT_PANEL_PORTAL_CLASS_CANDIDATES,
138
+ ...KIT_REASON_TIP_CLASS_CANDIDATES, kitDisabledRecipe('aria'),
73
139
  ].flatMap((s: string) => s.split(/\s+/).filter((c: string) => c !== ''));
74
140
 
75
141
  export interface KitTableActionItem {
@@ -79,14 +145,34 @@ export interface KitTableActionItem {
79
145
  builtin?: string;
80
146
  target?: string;
81
147
  permission?: string;
82
- /** 行条件(core 谓词形,字段是行字段);不成立时按钮不显示 */
83
- when?: Record<string, unknown>;
84
148
  /** 固定折叠进「更多」 */
85
149
  more?: boolean;
86
- /** 状态条件(GA2):hiddenWhen 成立不显示,disabledWhen 成立置灰且点不到;叶子是行字段或 outcome.<名>.… */
87
- gate?: KitActionGate;
88
- /** 行主键字段名(编译器附带):outcome 按行分槽时,条件默认读「本行主键值」那一份 */
89
- gateKey?: string;
150
+ /** 置灰原因的字面量文案(动作写了 disabled 时才有;行 / 展示对象给的原因在 actionState 叶子里,见 disabledReasonOf) */
151
+ disabledReason?: string;
152
+ }
153
+
154
+ /**
155
+ * 行内 / 「更多」切分(纯函数):shown = 已过权限与行级隐藏的动作(声明序)。
156
+ * - 宽档:非 more 动作前 maxInline 个行内(第一个 primary 恒在行内:超出时占掉最后一格),其余并入更多;more: true 的恒进更多(排在末尾)。
157
+ * - 窄档(容器低于 design 窄档线,行内上限取 design maxInline.narrow,且不超过 maxInline):最多保留 cap 个行内按钮,
158
+ * 首选 tone 为 primary 的动作,没有则取第一个非 more 动作;保留者仍按声明序,其余非 more 动作按声明序并入更多,more: true 的排在最后。
159
+ * 进更多的每一项,置灰与置灰原因仍由菜单项读 actionState / disabledReason(见 render 的 items),不在此丢失。
160
+ */
161
+ export function splitRowActions(
162
+ shown: readonly KitTableActionItem[], maxInline: number, narrow: boolean,
163
+ ): { inline: KitTableActionItem[]; folded: KitTableActionItem[] } {
164
+ const forced = shown.filter((i) => i.more === true);
165
+ const plain = shown.filter((i) => i.more !== true);
166
+ const cap = narrow ? Math.max(1, Math.min(maxInline, kitRowActionsNarrowCap())) : maxInline;
167
+ const keep = new Set<KitTableActionItem>();
168
+ // 任何宽度下第一个 primary 恒在行内(主要操作不被藏进菜单),再按声明序补满上限
169
+ const primary = plain.find((i) => i.tone === 'primary');
170
+ if (primary !== undefined && cap >= 1) keep.add(primary);
171
+ for (const item of plain) {
172
+ if (keep.size >= cap) break;
173
+ keep.add(item);
174
+ }
175
+ return { inline: plain.filter((i) => keep.has(i)), folded: [...plain.filter((i) => !keep.has(i)), ...forced] };
90
176
  }
91
177
 
92
178
  export function itemsOf(raw: unknown): KitTableActionItem[] {
@@ -105,18 +191,25 @@ export function itemsOf(raw: unknown): KitTableActionItem[] {
105
191
  ...(str(rec.builtin) !== '' ? { builtin: str(rec.builtin) } : {}),
106
192
  ...(str(rec.target) !== '' ? { target: str(rec.target) } : {}),
107
193
  ...(str(rec.permission) !== '' ? { permission: str(rec.permission) } : {}),
108
- ...(rec.when !== null && typeof rec.when === 'object' && !Array.isArray(rec.when) ? { when: rec.when as Record<string, unknown> } : {}),
109
194
  ...(rec.more === true ? { more: true } : {}),
110
- ...(gateFrom(rec) !== undefined ? { gate: gateFrom(rec)! } : {}),
111
- ...(str(rec.gateKey) !== '' ? { gateKey: str(rec.gateKey) } : {}),
195
+ ...(str(rec.disabledReason).trim() !== '' ? { disabledReason: str(rec.disabledReason).trim() } : {}),
112
196
  });
113
197
  }
114
198
  return out;
115
199
  }
116
200
 
117
- export function emitRowAction(api: { emit: (name: string, payload: unknown) => void; props: () => Record<string, unknown> }, item: KitTableActionItem): void {
118
- api.emit('row_action', {
201
+ /** 抛第 index 个行操作的槽位事件 row_action_<序号>(序号 = 动作在 actions 数组里的位置;页面事件给每个动作各绑一条管道) */
202
+ export function emitRowAction(api: { emit: (name: string, payload: unknown) => void; props: () => Record<string, unknown> }, item: KitTableActionItem, index: number): void {
203
+ const removeObject = str(api.props().removeObject);
204
+ const removeScope = str(api.props().removeScope);
205
+ emitActionSlot(api.emit, KIT_ACTION_SLOT_BASE.row, index, {
119
206
  kit_action: item.id,
207
+ // 行所属对象名:协调组件据此在多成员页面里确定删除的是哪个对象(kit_ 前缀,不与行字段撞名)
208
+ ...(removeObject !== '' ? { kit_object: removeObject } : {}),
209
+ // 本行的在途通道名:动作执行器在具名行动作执行期间原样登记,行组件读同名通道置灰本行
210
+ ...(removeScope !== '' && removeObject !== ''
211
+ ? { kit_row_busy: rowBusyName(removeScope, removeObject, removeKeyOf(api.props().row, str(api.props().removeKeyField))) }
212
+ : {}),
120
213
  id: item.id,
121
214
  name: item.name,
122
215
  builtin: item.builtin ?? '',
@@ -131,16 +224,21 @@ export function createKitTableActions(): SomaComponentDefinition {
131
224
  name: 'KitTableActions',
132
225
  layer: 'data',
133
226
  props: {
134
- actions: { type: 'array', default: [], desc: '行操作 [{ id, name, tone?, builtin?, target?, permission? }];permission 非空且无权限时不渲染该按钮' },
135
- maxInline: { type: 'number', default: DEFAULT_MAX_INLINE, desc: '行内最多直接显示的按钮数,超过的折叠进「更多」菜单;动作项 more: true 恒折叠;动作项 when(行条件)不成立时不显示' },
136
- rowClassWhen: { type: 'array', default: [], desc: '条件行类 [{ when(core 谓词,字段是行字段), class }]:行满足 when 时在所在行容器(data-kit-row)上加 class' },
227
+ actions: { type: 'array', default: [], desc: '行操作 [{ id, name, tone?, builtin?, target?, permission?, more?, disabledReason? }];permission 非空且无权限时不渲染该按钮;disabledReason 是置灰原因的字面量文案(动作置灰时才显示)' },
228
+ maxInline: { type: 'number', default: DEFAULT_MAX_INLINE, desc: '行内最多直接显示的按钮数,超过的折叠进「更多」菜单;动作项 more: true 恒折叠' },
229
+ actionState: { type: 'object', default: {}, desc: '行级动作状态 { 动作id: { hidden, disabled } }:叶子是行字段路径(业务对象逐行给出),core 逐行求值;hidden 为真该行不显示这个动作,disabled 为真置灰且点不到;叶子 disabledReason(可选)= 置灰原因文案(行字段 / 展示对象成员求值成字符串):置灰且非空时按钮保持可聚焦(只留 aria-disabled),原因经气泡与 aria-describedby 给出,「更多」菜单项带描述文字;字面量原因写在 actions 项的 disabledReason' },
230
+ rowTone: { type: 'string', default: '', desc: '行样式档位名(行字段取值,业务对象逐行给出):属于语法真源 viewObject.rowState.toneTiers 闭集时,给所在行容器(data-kit-row)加该档位的类串;不在闭集不加类(rowToneSet 为 item 时取 itemToneTiers)' },
231
+ rowToneSet: { type: 'string', default: 'row', desc: '行样式档位用哪张闭集表:row = toneTiers(表格行底色);item = itemToneTiers(cards / stack 条目自带底色与边框,只用描边 / 透明度);其它值按 row' },
137
232
  row: { type: 'object', default: {}, desc: '当前行数据,原样随 row_action 上抛' },
138
- pickOnRow: { type: 'boolean', default: false, desc: '开启后点击所在行(data-kit-row 容器)抛 row_action,builtin 为 select' },
233
+ pickOnRow: { type: 'boolean', default: false, desc: '开启后点击所在行(data-kit-row 容器)抛 row_pick,builtin 为 select' },
139
234
  selectMode: { type: 'string', default: 'none', desc: '勾选列模式 none / single / multi;非 none 时渲染选择框并抛 row_select' },
140
235
  selected: { type: 'array', default: [], desc: '已选行数组(协调组件 focus 切片 sel 的镜像);选择框的勾选态与所在行(data-kit-row)的 data-kit-selected 选中高亮由它推出' },
141
236
  keyField: { type: 'string', default: '', desc: '行主键字段名(比对已选行;空 = 按整行内容)' },
237
+ removeScope: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):协调组件的作用域 id;本行在途(经忙闲通道登记)时,本行全部操作置灰、容器挂 aria-busy;空 = 不读' },
238
+ removeObject: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):对象名,须与协调组件的主对象同名,空 = 不读' },
239
+ removeKeyField: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):行主键字段名(与协调组件登记忙态的键同一规则:显式主键 → id → 空串;独立于 keyField,不受选择 / 展开影响)' },
142
240
  expand: { type: 'boolean', default: false, desc: '展开行开关:渲染一个展开 / 收起按钮,开合所在行(data-kit-expand-row 容器)里的 data-kit-expand-body;开合状态留在本组件' },
143
- expandHost: { type: 'string', default: '', desc: '展开子表(Q 波 G5):非空 = list 形展开,值是页面级子对象名;开合不再留在本组件,点击抛 row_action(kit_action: expand)交协调组件写 expandId,本组件按 expandId 与 keyField 判断本行是否展开,并把子表承载壳挪进 / 挪出本行详情体' },
241
+ expandHost: { type: 'string', default: '', desc: '展开子表(Q 波 G5):非空 = list 形展开,值是页面级子对象名;开合不再留在本组件,点击抛 row_expand(kit_action: expand)交协调组件写 expandId,本组件按 expandId 与 keyField 判断本行是否展开,并把子表承载壳挪进 / 挪出本行详情体' },
144
242
  expandId: { type: 'string', default: '', desc: '当前展开行的主键(协调组件 focus 切片 expandId 的镜像,字符串;空 = 都没展开);只在 expandHost 非空时读' },
145
243
  expandLabel: { type: 'string', default: '', desc: '收起态按钮文案' },
146
244
  collapseLabel: { type: 'string', default: '', desc: '展开态按钮文案' },
@@ -156,45 +254,60 @@ export function createKitTableActions(): SomaComponentDefinition {
156
254
  },
157
255
  desc: '勾选列的选择框变化;选择态由协调组件持有',
158
256
  },
159
- row_action: {
160
- payload: {
161
- kit_action: { type: 'string', desc: '动作判别键(不与行字段撞名;core 会把行字段盖到载荷上,故 id 不可靠)' },
162
- id: { type: 'string', desc: '动作 id' },
163
- name: { type: 'string', desc: '动作显示名' },
164
- builtin: { type: 'string', desc: '内置动作名(第 3 层业务组件解释)' },
165
- target: { type: 'string', desc: '目标浮层(第 3 层业务组件解释)' },
166
- row: { type: 'object', desc: '当前行' },
167
- },
168
- desc: '点击某个行操作;载荷自带整行',
257
+ // 行操作:每个动作各抛各的槽位事件 row_action_<序号>,页面事件给每个动作各绑一条管道(不再共用一个事件按载荷分流)
258
+ ...actionSlotEmits(KIT_ACTION_SLOT_BASE.row, {
259
+ kit_action: { type: 'string', desc: '动作判别键(不与行字段撞名;core 会把行字段盖到载荷上,故 id 不可靠)' },
260
+ id: { type: 'string', desc: '动作 id' },
261
+ name: { type: 'string', desc: '动作显示名' },
262
+ builtin: { type: 'string', desc: '内置动作名(第 3 层业务组件解释)' },
263
+ target: { type: 'string', desc: '目标浮层(第 3 层业务组件解释)' },
264
+ kit_row_busy: { type: 'string', desc: '本行在途通道名(removeScope 与 removeObject 都非空时带;动作执行器在具名行动作执行期间登记)' },
265
+ row: { type: 'object', desc: '当前行' },
266
+ }, '点击某个行操作;载荷自带整行'),
267
+ row_pick: {
268
+ payload: { kit_action: { type: 'string', desc: '恒为 select' }, id: { type: 'string' }, builtin: { type: 'string' }, row: { type: 'object', desc: '当前行' } },
269
+ desc: '整行点击(pickOnRow);载荷自带整行',
270
+ },
271
+ row_expand: {
272
+ payload: { kit_action: { type: 'string', desc: '恒为 expand' }, id: { type: 'string' }, builtin: { type: 'string' }, row: { type: 'object', desc: '当前行' } },
273
+ desc: '展开子表(expandHost)的开合意图,交协调组件写 expandId',
169
274
  },
170
275
  },
171
276
  },
172
- services: ['permission', 'data'],
277
+ services: ['permission'],
173
278
  templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
174
- controllerFactory: (ctx) => {
175
- const check = permissionCheckerOf(ctx);
176
- let moreMenu: MenuHandle | null = null;
177
- // GA2:动作状态条件引用的 outcome 订阅(名单变了才重订;变化即重画本行)
178
- let offGate: (() => void) | null = null;
179
- let gateSig = '';
180
- const dataPort = (): SomaDataPort | undefined => {
181
- const d = (ctx.services as { data?: SomaDataPort } | undefined)?.data;
182
- return d !== undefined && d !== null && typeof d === 'object' ? d : undefined;
183
- };
184
- const rowOf = (raw: unknown): Record<string, unknown> => (raw !== null && typeof raw === 'object' ? raw as Record<string, unknown> : {});
185
- const gateStateOf = (item: KitTableActionItem, row: unknown): { disabled: boolean; hidden: boolean; reason?: string } =>
186
- evalActionGate(item.gate, rowOf(row), gateOutcomeReader(dataPort(), gateRowKey(item.gateKey, row)));
187
- const isGateDisabled = (item: KitTableActionItem, row: unknown): boolean => gateStateOf(item, row).disabled;
188
- return createKitController({
189
- attach(root, api) {
279
+ controllerFactory: createKitController((api) => {
280
+ const check = permissionCheckerOf(api as unknown as any);
281
+ let moreMenu: MenuHandle | null = null;
282
+ // 上次渲染依赖的 props 签名:props 没变就不重绘(保住焦点与已开的更多菜单)
283
+ let lastSig: string | null = null;
284
+ let lastRoot: HTMLElement | null = null;
285
+ // 最近一次渲染时本行是否处于删除在途(忙闲通道变化时据此判断要不要重绘)
286
+ let renderedBusy = false;
287
+ // 在途期间按钮被禁用会丢焦点:记下用户点的是哪个控件,落定恢复后还给它(仅当焦点已落到 body)
288
+ let lastActed: { attr: string; val: string } | null = null;
289
+ let wasBusy = false;
290
+ // 窄档折叠是纯样式(容器查询):行内次要操作带 `@max-<档>:hidden`,「更多」触发器常驻 DOM,窄档由 CSS 显示;
291
+ // 「更多」菜单的内容在打开时按「当前不可见的行内项」现算,没有重复 DOM、不观察宽度。
292
+ // 只有行操作在表格容器里才标次要操作(容器查询以表格自己的查询容器为准;cards / stack 条目里不折叠)。
293
+ // 首次绘制可能早于挂载(模板克隆出的行在取数后才挂进表壳):记下上次按「在不在表里」画的,挂载后不一致就补一次重绘(结构判断,不量宽度)
294
+ const inTableOf = (root: HTMLElement): boolean => root.closest(TABLE_CONTAINER) !== null;
295
+ let renderedInTable: boolean | null = null;
296
+ // 栅格表表壳(非虚拟表):标出右侧是否还有被遮住的内容,窄档贴右固定的操作格据此出分隔线与阴影;
297
+ // 挂载时行可能还没进表壳,在首次能找到表壳的那次绘制里再订阅
298
+ let offEdge: (() => void) | null = null;
299
+ return {
300
+ attach(root) {
301
+ queueMicrotask(() => { if (root.isConnected && renderedInTable !== null && inTableOf(root) !== renderedInTable) api.refresh(); });
190
302
  const onClick = (event: Event): void => {
191
303
  const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-act]');
192
304
  if (!hit || !root.contains(hit)) return;
193
305
  const id = hit.getAttribute('data-kit-act') ?? '';
194
306
  const item = itemsOf(api.props().actions).find((a) => a.id === id);
195
307
  if (!item) return;
196
- if (isGateDisabled(item, api.props().row)) return;
197
- emitRowAction(api, item);
308
+ if (rowActionState(api.props().actionState, item.id).disabled || removeBusyOf(api.props())) return;
309
+ lastActed = { attr: 'data-kit-act', val: id };
310
+ emitRowAction(api, item, itemsOf(api.props().actions).findIndex((a) => a.id === id));
198
311
  };
199
312
  root.addEventListener('click', onClick);
200
313
  // 展开行:开合状态存在本组件里;详情体由 emitStatic 标 data-kit-expand-body 并默认带 hidden
@@ -206,7 +319,7 @@ export function createKitTableActions(): SomaComponentDefinition {
206
319
  if (!hit || !root.contains(hit)) return;
207
320
  // list 形(展开子表):开合由协调组件的 expandId 决定,这里只抛意图;手风琴(换行即收旧行)也在那边
208
321
  if (str(api.props().expandHost) !== '') {
209
- api.emit('row_action', {
322
+ api.emit('row_expand', {
210
323
  kit_action: 'expand', id: 'expand', name: '', builtin: 'expand', target: '',
211
324
  row: api.props().row ?? {},
212
325
  });
@@ -223,6 +336,8 @@ export function createKitTableActions(): SomaComponentDefinition {
223
336
  if (mark.getAttribute('data-kit-sel') === null) return;
224
337
  const mode = str(api.props().selectMode, 'none');
225
338
  if (mode !== 'single' && mode !== 'multi') return;
339
+ // 本行删除在途:勾选标记已禁用(render 里 disabled),事件层再兜一道,不抛 row_select
340
+ if (removeBusyOf(api.props())) return;
226
341
  api.emit('row_select', {
227
342
  row: api.props().row ?? {},
228
343
  checked: next,
@@ -235,7 +350,9 @@ export function createKitTableActions(): SomaComponentDefinition {
235
350
  const rowEl = root.closest<HTMLElement>('[data-kit-row]');
236
351
  const pickOn = (): boolean => api.props().pickOnRow === true || api.props().pickOnRow === 'true';
237
352
  const emitSelect = (): void => {
238
- api.emit('row_action', {
353
+ // 本行删除在途:整行点击 / Enter 都不抛选行事件(行会随删除落定消失或恢复)
354
+ if (removeBusyOf(api.props())) return;
355
+ api.emit('row_pick', {
239
356
  kit_action: 'select',
240
357
  id: 'select',
241
358
  name: '',
@@ -261,7 +378,13 @@ export function createKitTableActions(): SomaComponentDefinition {
261
378
  };
262
379
  rowEl?.addEventListener('click', onRowClick);
263
380
  rowEl?.addEventListener('keydown', onRowKey);
381
+ const offRemoveBusy = onKitActionBusy(() => {
382
+ if (removeBusyOf(api.props()) !== renderedBusy) api.refresh();
383
+ });
264
384
  return () => {
385
+ offRemoveBusy();
386
+ offEdge?.();
387
+ offEdge = null;
265
388
  root.removeEventListener('click', onClick);
266
389
  root.removeEventListener('click', onExpand);
267
390
  // 展开子表:本行销毁时若承载壳还在本行详情体里,先挪回原位,免得子表随行一起被丢掉
@@ -280,33 +403,58 @@ export function createKitTableActions(): SomaComponentDefinition {
280
403
  }
281
404
  moreMenu?.destroy();
282
405
  moreMenu = null;
283
- offGate?.();
284
- offGate = null;
285
- gateSig = '';
406
+ releaseReasonTipsIn(root);
286
407
  };
287
408
  },
288
- // 具名函数表达式:状态条件订阅回调要按名重画本行,不借 this(this 的指向取决于调用方式)
289
- render: function renderActions(root: HTMLElement, p: KitProps, api: KitApi): void {
409
+ render(root: HTMLElement, p: KitProps, api: KitApi): void {
410
+ const busy = removeBusyOf(p);
411
+ renderedBusy = busy;
412
+ // 跳过判定的签名 = props(已选集合只并入「本行是否被选中」)+ 渲染另外读取的 DOM / 权限输入:
413
+ // 所在行元素身份、展开行容器身份与展开体显隐、每个动作的权限判定结果;任一变化即重绘
414
+ // 只依赖 props / 权限的部分:每次渲染只序列化一次;依赖 DOM 的部分在渲染后重算
415
+ const propsPart = ((): string | null => {
416
+ try {
417
+ const rest: Record<string, unknown> = { ...p };
418
+ delete rest.selected;
419
+ const keyF = str(p.keyField);
420
+ const selState = Array.isArray(p.selected) ? (p.selected.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0) : -1;
421
+ const perms = itemsOf(p.actions).map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? 1 : 0) : -1));
422
+ return JSON.stringify([rest, selState, perms]) + (busy ? '|busy' : '');
423
+ } catch {
424
+ return null; // 含环等不可序列化:不跳过
425
+ }
426
+ })();
427
+ const sigOf = (): string | null => {
428
+ if (propsPart === null) return null;
429
+ const expandRow = root.closest<HTMLElement>('[data-kit-expand-row]');
430
+ const expandBody = expandRow?.querySelector<HTMLElement>('[data-kit-expand-body]') ?? null;
431
+ return propsPart + JSON.stringify([elementId(root.closest('[data-kit-row]')), elementId(expandRow), expandBody === null ? -1 : expandBody.classList.contains('hidden') ? 0 : 1, inTableOf(root) ? 1 : 0]);
432
+ };
433
+ // 无 expandHost 的展开钮读的是 DOM 上详情体当前显隐(不在 props 里),不能凭签名跳过
434
+ const domDriven = (p.expand === true || p.expand === 'true') && str(p.expandHost) === '';
435
+ const sig = sigOf();
436
+ if (sig !== null && !domDriven && lastRoot === root && sig === lastSig && root.childNodes.length > 0) return;
437
+ // 渲染成功完成后才记录(渲染本身会改展开体显隐,所以签名按渲染后的状态重算);中途抛错见下方 catch:清空,下次不会被永久跳过
438
+ const commit = (): void => {
439
+ lastSig = sigOf();
440
+ lastRoot = root;
441
+ };
442
+ // 必须重绘:记下焦点所在的勾选框 / 动作钮,重绘后还给同值元素
443
+ const activeEl = root.ownerDocument.activeElement;
444
+ const focusedIn = activeEl && root.contains(activeEl) ? activeEl.closest<HTMLElement>('[data-kit-sel], [data-kit-act]') : null;
445
+ const focusKey = focusedIn
446
+ ? focusedIn.hasAttribute('data-kit-sel') ? { attr: 'data-kit-sel', val: focusedIn.getAttribute('data-kit-sel') ?? '' } : { attr: 'data-kit-act', val: focusedIn.getAttribute('data-kit-act') ?? '' }
447
+ : null;
448
+ try {
290
449
  moreMenu?.destroy();
291
450
  moreMenu = null;
451
+ // 旧按钮的原因气泡可能正挂在浮层根里:整片重画前先摘(锚点随旧树丢弃)
452
+ releaseReasonTipsIn(root);
292
453
  const items = itemsOf(p.actions);
293
- // GA2:条件引用的 outcome 变了才重订;订阅当下那次回调不重画(本次绘制已读最新值)
294
- const gateNames = [...new Set(items.flatMap((i) => gateOutcomeNamesOf(i.gate)))];
295
- const nextSig = gateNames.join('|');
296
- if (nextSig !== gateSig) {
297
- gateSig = nextSig;
298
- offGate?.();
299
- offGate = null;
300
- if (gateNames.length > 0) {
301
- let subscribing = true;
302
- offGate = watchGateOutcomes(dataPort(), gateNames, () => {
303
- if (!subscribing) renderActions(root, api.props(), api);
304
- });
305
- subscribing = false;
306
- }
307
- }
308
454
  root.className = joinClass(ROOT_CLASS, p.class);
309
455
  root.replaceChildren();
456
+ if (busy) root.setAttribute('aria-busy', 'true');
457
+ else root.removeAttribute('aria-busy');
310
458
  if (p.expand === true || p.expand === 'true') {
311
459
  const btn = root.ownerDocument.createElement('button');
312
460
  btn.setAttribute('type', 'button');
@@ -330,8 +478,17 @@ export function createKitTableActions(): SomaComponentDefinition {
330
478
  btn.className = EXPAND_BUTTON_CLASS;
331
479
  btn.textContent = btn.getAttribute('aria-expanded') === 'true' ? str(p.collapseLabel, kitText('soma.kit.collapse', undefined, root)) : str(p.expandLabel, kitText('soma.kit.expand_detail', undefined, root));
332
480
  root.appendChild(btn);
481
+ commit();
333
482
  return;
334
483
  }
484
+ // 行样式档位:先摘掉上次加的档位类,再按本行当前档位重加(类串来自语法真源闭集,已进候选类)
485
+ const toneRow = root.closest<HTMLElement>('[data-kit-row]');
486
+ if (toneRow) {
487
+ // 两张档位表(行底色 / 条目描边)的类串都摘,换档位集或换档位都不残留
488
+ for (const cls of [...Object.values(KIT_ROW_TONE_CLASS), ...Object.values(KIT_ITEM_TONE_CLASS)]) toneRow.classList.remove(...cls.split(/\s+/).filter((t) => t !== ''));
489
+ const toneCls = rowToneClass(p.rowTone, p.rowToneSet === 'item' ? 'item' : 'row');
490
+ if (toneCls !== '') toneRow.classList.add(...toneCls.split(/\s+/).filter((t) => t !== ''));
491
+ }
335
492
  // 整行可点(pickOnRow):行本身进 Tab 序并有焦点环,Enter 触发(键盘等价于点行)
336
493
  if (p.pickOnRow === true || p.pickOnRow === 'true') {
337
494
  const pickRow = root.closest<HTMLElement>('[data-kit-row]');
@@ -341,19 +498,6 @@ export function createKitTableActions(): SomaComponentDefinition {
341
498
  pickRow.classList.add(...ROW_FOCUS_CLASS.split(' '));
342
499
  }
343
500
  }
344
- // D9 条件行类:先摘掉上次加的,再按当前行重算(类串来自编译期,已进候选类)
345
- if (Array.isArray(p.rowClassWhen)) {
346
- const rowEl2 = root.closest<HTMLElement>('[data-kit-row]');
347
- const rowVals = (p.row !== null && typeof p.row === 'object' ? p.row : {}) as Record<string, unknown>;
348
- if (rowEl2) {
349
- for (const w of p.rowClassWhen as Array<{ when?: Record<string, unknown>; class?: string }>) {
350
- const toks = String(w.class ?? '').split(/\s+/).filter((t) => t !== '');
351
- if (toks.length === 0) continue;
352
- if (holds(w.when, rowVals)) rowEl2.classList.add(...toks);
353
- else rowEl2.classList.remove(...toks);
354
- }
355
- }
356
- }
357
501
  const mode = str(p.selectMode, 'none') as SelectMode;
358
502
  const keyField = str(p.keyField);
359
503
  const picked = Array.isArray(p.selected) && p.selected.some((r) => rowKeyOf(r, keyField) === rowKeyOf(p.row, keyField));
@@ -368,52 +512,89 @@ export function createKitTableActions(): SomaComponentDefinition {
368
512
  }
369
513
  }
370
514
  if (mode === 'single' || mode === 'multi') {
371
- const box = createCheck(root.ownerDocument, mode === 'single' ? 'radio' : 'checkbox', { checked: picked });
515
+ const box = createCheck(root.ownerDocument, mode === 'single' ? 'radio' : 'checkbox', { checked: picked, ...(busy ? { disabled: true } : {}) });
372
516
  box.setAttribute('data-kit-sel', '');
373
517
  // 可访问名带行主键,读屏用户能分清是哪一行;没有主键字段时退回通用文案
374
518
  const keyVal = keyField !== '' ? rowKeyOf(p.row, keyField) : '';
375
519
  setMarkLabel(box, keyVal !== '' ? kitText('soma.kit.select_row_of', { key: keyVal }, root) : kitText('soma.kit.select_this_row', undefined, root));
376
520
  root.appendChild(box);
377
521
  }
378
- const row = (p.row !== null && typeof p.row === 'object' ? p.row : {}) as Record<string, unknown>;
379
- // K1-2:无权限的动作不渲染(check 为 null = 未装配权限,保持渲染);行条件 when 不成立同样不显示
522
+ // K1-2:无权限的动作不渲染(check 为 null = 未装配权限,保持渲染)
380
523
  const shown = items.filter((item) =>
381
- !(item.permission !== undefined && check !== null && !check(item.permission)) && holds(item.when, row) && !gateStateOf(item, row).hidden);
524
+ !(item.permission !== undefined && check !== null && !check(item.permission)) && !rowActionState(p.actionState, item.id).hidden);
382
525
  const maxRaw = Number(p.maxInline);
383
526
  const maxInline = Number.isFinite(maxRaw) && maxRaw >= 1 ? Math.floor(maxRaw) : DEFAULT_MAX_INLINE;
384
- const forced = shown.filter((i) => i.more === true);
385
- const plain = shown.filter((i) => i.more !== true);
386
- const inline = plain.slice(0, maxInline);
387
- const folded = [...plain.slice(maxInline), ...forced];
527
+ if (offEdge === null) {
528
+ const wrap = root.closest<HTMLElement>('[data-kit-part="table"]');
529
+ if (wrap !== null) offEdge = watchEndEdge(wrap);
530
+ }
531
+ renderedInTable = inTableOf(root);
532
+ // 这次是在行还没进表壳时画的:下一帧对一次账,之后进了表壳就补一次重绘(重绘后两者一致,不会循环)
533
+ const paintedInTable = renderedInTable;
534
+ const recheck = (): void => {
535
+ if (root.isConnected && inTableOf(root) !== paintedInTable && renderedInTable === paintedInTable) api.refresh();
536
+ };
537
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(recheck); else queueMicrotask(recheck);
538
+ // 宽档切分:前 maxInline 个行内,其余并入「更多」。窄档保留者(primary 优先,上限取 design maxInline.narrow)取自宽档行内项,其余行内项标次要
539
+ const { inline, folded } = splitRowActions(shown, maxInline, false);
540
+ const narrowKeep = renderedInTable ? new Set(splitRowActions(inline, maxInline, true).inline) : new Set(inline);
541
+ const secondary = inline.filter((i) => !narrowKeep.has(i));
542
+ const secondaryButtons = new Map<string, HTMLButtonElement>();
388
543
  for (const item of inline) {
389
544
  const btn = root.ownerDocument.createElement('button');
390
545
  btn.setAttribute('type', 'button');
391
546
  btn.setAttribute('data-kit-act', item.id);
392
- btn.className = ACTION_BUTTON_CLASS[item.tone ?? 'neutral'];
547
+ btn.className = ROW_ACTION_BUTTON_CLASS[item.tone ?? 'neutral'];
548
+ if (!narrowKeep.has(item)) {
549
+ btn.setAttribute('data-kit-act-secondary', '');
550
+ btn.className = `${btn.className} ${ROW_ACTION_SECONDARY_CLASS}`;
551
+ secondaryButtons.set(item.id, btn);
552
+ }
553
+ // 文字链接形态:无面(不标 raised)
393
554
  btn.textContent = item.name;
394
- const gs = gateStateOf(item, row);
395
- if (gs.disabled) {
555
+ // 置灰原因(动作置灰且原因非空,本行没在删除在途):不用原生 disabled,只留 aria-disabled 保持可聚焦,原因经气泡 + aria-describedby 给出;点击由 onClick 的置灰判断拦下
556
+ const reason = busy ? '' : disabledReasonOf(p.actionState, item);
557
+ if (reason !== '') {
558
+ btn.setAttribute('aria-disabled', 'true');
559
+ btn.className = `${btn.className} ${kitDisabledRecipe('aria')}`;
560
+ } else if (busy || rowActionState(p.actionState, item.id).disabled) {
396
561
  btn.disabled = true;
397
562
  btn.setAttribute('aria-disabled', 'true');
398
- if (gs.reason !== undefined) btn.title = gs.reason;
399
563
  }
400
564
  root.appendChild(btn);
565
+ if (reason !== '') syncReasonTip(btn, reason);
401
566
  }
402
- if (folded.length > 0) {
567
+ if (folded.length > 0 || secondary.length > 0) {
403
568
  const doc = root.ownerDocument;
404
569
  const wrap = doc.createElement('div');
405
- wrap.className = MORE_ROOT_CLASS;
570
+ // 没有常驻折叠项(宽档全部行内)时触发器只在窄档出现;有常驻折叠项时恒显示
571
+ wrap.className = folded.length > 0 ? MORE_ROOT_CLASS : MORE_ROOT_NARROW_ONLY_CLASS;
572
+ wrap.setAttribute('data-kit-more-root', folded.length > 0 ? '' : 'narrow');
406
573
  const trigger = doc.createElement('button');
407
574
  trigger.setAttribute('type', 'button');
575
+ trigger.setAttribute('aria-haspopup', 'menu');
408
576
  trigger.setAttribute('aria-label', kitText('soma.kit.more_actions', undefined, root));
409
577
  trigger.className = MORE_TRIGGER_CLASS;
578
+ trigger.setAttribute('data-kit-more', '');
579
+ const win = doc.defaultView;
580
+ const menuEntries = (): KitTableActionItem[] => {
581
+ const hiddenSecondary = secondary.filter((i) => {
582
+ const btn = secondaryButtons.get(i.id);
583
+ return btn !== undefined && btn.isConnected && win !== null && win.getComputedStyle(btn).display === 'none';
584
+ });
585
+ return [...hiddenSecondary, ...folded.filter((i) => i.more !== true), ...folded.filter((i) => i.more === true)];
586
+ };
410
587
  trigger.textContent = kitText('soma.kit.more_menu', undefined, root);
411
588
  trigger.appendChild(kitIcon('chevron-down', 'sm'));
412
589
  const menu = doc.createElement('div');
413
590
  menu.className = 'hidden';
414
591
  wrap.append(trigger, menu);
415
592
  root.appendChild(wrap);
416
- moreMenu = wireMenu({
593
+ // 本行删除在途:「更多」触发钮置灰,菜单不接线(打不开)
594
+ if (busy) {
595
+ trigger.disabled = true;
596
+ trigger.setAttribute('aria-disabled', 'true');
597
+ } else moreMenu = wireMenu({
417
598
  scope: wrap,
418
599
  trigger,
419
600
  menu,
@@ -423,16 +604,43 @@ export function createKitTableActions(): SomaComponentDefinition {
423
604
  portal: createPanelPortal(trigger),
424
605
  fitted: () => ({ pref: MORE_PLACE, classFor: KIT_MENU_PANEL.classFor }),
425
606
  classes: MORE_MENU_CLASSES,
426
- items: () => folded.map((i) => ({ key: i.id, label: i.name, icon: '', disabled: gateStateOf(i, row).disabled, danger: i.tone === 'danger', divider: false })),
607
+ // 置灰项的原因作为该项的描述文字(可见的第二段文字 + aria-describedby),菜单项本身是 aria-disabled 的 div,读屏可取到
608
+ // 菜单内容在打开 / 取项时现算:常驻折叠项 + 当前被容器查询隐藏的次要行内项(display:none 即不可见),次序 = 隐藏的次要项(声明序)→ 常驻折叠的普通项 → more:true 项
609
+ items: () => menuEntries().map((i) => ({ key: i.id, label: i.name, icon: '', disabled: rowActionState(p.actionState, i.id).disabled, danger: i.tone === 'danger', divider: false, reason: disabledReasonOf(p.actionState, i) })),
427
610
  locked: () => false,
428
611
  onPick: (picked) => {
429
- const hit = folded.find((i) => i.id === picked.key);
430
- if (hit) emitRowAction(api, hit);
612
+ const hit = menuEntries().find((i) => i.id === picked.key);
613
+ if (hit) {
614
+ lastActed = { attr: 'data-kit-more', val: '' };
615
+ emitRowAction(api, hit, items.findIndex((a) => a.id === hit.id));
616
+ }
431
617
  },
432
618
  });
433
619
  }
620
+ commit();
621
+ } catch (error) {
622
+ lastSig = null;
623
+ lastRoot = null;
624
+ throw error;
625
+ } finally {
626
+ if (focusKey !== null) {
627
+ const again = Array.from(root.querySelectorAll<HTMLElement>(`[${focusKey.attr}]`)).find((e) => e.getAttribute(focusKey.attr) === focusKey.val);
628
+ focusControl(again);
629
+ }
630
+ // 删除在途 -> 落定:焦点若因按钮被禁用丢到了 body,还给用户刚才点的那个控件
631
+ if (busy) wasBusy = true;
632
+ else if (wasBusy) {
633
+ wasBusy = false;
634
+ const ae = root.ownerDocument.activeElement;
635
+ if (lastActed !== null && (!ae || ae === root.ownerDocument.body)) {
636
+ const back = Array.from(root.querySelectorAll<HTMLElement>(`[${lastActed.attr}]`)).find((e) => e.getAttribute(lastActed!.attr) === lastActed!.val);
637
+ focusControl(back);
638
+ }
639
+ lastActed = null;
640
+ }
641
+ }
434
642
  },
435
- })(ctx);
436
- },
643
+ };
644
+ }),
437
645
  };
438
646
  }