soma-kit 0.1.11 → 0.1.12

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 (302) hide show
  1. package/README.md +103 -110
  2. package/bin/soma-kit.mjs +1 -1
  3. package/bin/soma.mjs +22 -0
  4. package/package.json +13 -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 +776 -38
  8. package/spec/generated/kit-page.schema.json +1613 -224
  9. package/spec/kit-grammar.json +770 -529
  10. package/spec/kit-grammar.schema.json +1962 -392
  11. package/src/app/app-config.ts +371 -347
  12. package/src/app/component-gate.ts +12 -15
  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 +174 -31
  16. package/src/app/define-kit-view.ts +100 -0
  17. package/src/app/envelope.ts +1 -161
  18. package/src/app/index.ts +13 -2
  19. package/src/app/kit-view-context.ts +290 -0
  20. package/src/app/notify-renderer.ts +1 -115
  21. package/src/app/paged-list-adapter.ts +1 -240
  22. package/src/app/server-pages.ts +8 -2
  23. package/src/app/server.ts +491 -101
  24. package/src/app/submit.types.ts +1 -1
  25. package/src/app/theme-endpoint.ts +63 -0
  26. package/src/app/theme-runtime-shared.ts +1 -0
  27. package/src/app/theme-runtime.ts +663 -0
  28. package/src/base/action-busy.ts +2 -2
  29. package/src/base/action-gate.ts +4 -255
  30. package/src/base/action-slots.ts +47 -0
  31. package/src/base/alert.ts +5 -3
  32. package/src/base/avatar.ts +2 -2
  33. package/src/base/button.ts +46 -29
  34. package/src/base/cascader.ts +11 -12
  35. package/src/base/check-core.ts +1 -1
  36. package/src/base/choice.ts +28 -26
  37. package/src/base/class-candidates.ts +17 -0
  38. package/src/base/color-picker.ts +6 -6
  39. package/src/base/combobox.ts +5 -3
  40. package/src/base/command-palette.ts +9 -5
  41. package/src/base/countdown.ts +1 -1
  42. package/src/base/date-range.ts +25 -11
  43. package/src/base/date.ts +85 -17
  44. package/src/base/divider.ts +2 -2
  45. package/src/base/fab.ts +11 -4
  46. package/src/base/image.ts +1 -1
  47. package/src/base/index.ts +9 -3
  48. package/src/base/input.ts +42 -13
  49. package/src/base/kbd.ts +3 -1
  50. package/src/base/link.ts +4 -4
  51. package/src/base/listbox-core.ts +50 -30
  52. package/src/base/loading-gate.ts +133 -0
  53. package/src/base/mentions.ts +5 -5
  54. package/src/base/menu-button.ts +6 -1
  55. package/src/base/menu-core.ts +4 -0
  56. package/src/base/motion/aura.ts +2 -2
  57. package/src/base/motion/hover-3d.ts +2 -2
  58. package/src/base/motion/hover-gallery.ts +2 -2
  59. package/src/base/motion/marquee.ts +2 -2
  60. package/src/base/motion/text-rotate.ts +2 -2
  61. package/src/base/number.ts +93 -80
  62. package/src/base/otp.ts +4 -1
  63. package/src/base/permission-gate.ts +6 -0
  64. package/src/base/popover.ts +40 -8
  65. package/src/base/popup.ts +79 -14
  66. package/src/base/price-text.ts +2 -2
  67. package/src/base/progress.ts +2 -2
  68. package/src/base/qr-code.ts +4 -4
  69. package/src/base/qty-stepper.ts +9 -3
  70. package/src/base/range.ts +2 -2
  71. package/src/base/rating.ts +1 -1
  72. package/src/base/segmented.ts +4 -0
  73. package/src/base/select.ts +4 -3
  74. package/src/base/shared.ts +221 -29
  75. package/src/base/swap.ts +4 -1
  76. package/src/base/switch.ts +1 -1
  77. package/src/base/tag-input.ts +14 -10
  78. package/src/base/tag.ts +5 -1
  79. package/src/base/text.ts +39 -6
  80. package/src/base/textarea.ts +37 -11
  81. package/src/base/time-picker.ts +12 -9
  82. package/src/base/tree-select.ts +15 -8
  83. package/src/base/upload.ts +34 -5
  84. package/src/base/virtual-list.ts +107 -1
  85. package/src/biz/approval-desk/compile.ts +23 -41
  86. package/src/biz/auth-panel/compile.ts +37 -52
  87. package/src/biz/auth-panel/index.ts +1 -1
  88. package/src/biz/category-crud/compile.ts +22 -36
  89. package/src/biz/checkout-page/compile.ts +21 -5
  90. package/src/biz/compose.ts +13 -27
  91. package/src/biz/define.ts +5 -4
  92. package/src/biz/import-wizard/compile.ts +22 -26
  93. package/src/biz/import-wizard/hub.ts +126 -61
  94. package/src/biz/import-wizard/shell.ts +3 -3
  95. package/src/biz/index.ts +3 -3
  96. package/src/biz/landing-page/compile.ts +19 -3
  97. package/src/biz/link/hub.ts +49 -20
  98. package/src/biz/link/shared.ts +115 -118
  99. package/src/biz/master-sub/compile.ts +31 -44
  100. package/src/biz/multi-board/compile.ts +34 -49
  101. package/src/biz/multi-board/index.ts +18 -1
  102. package/src/biz/multi-board/shell.ts +24 -15
  103. package/src/biz/notification-center/compile.ts +21 -33
  104. package/src/biz/page-templates/domain-templates.ts +80 -13
  105. package/src/biz/page-templates/result-page/compile.ts +11 -2
  106. package/src/biz/page-templates/shared.ts +34 -36
  107. package/src/biz/record-detail/compile.ts +47 -42
  108. package/src/biz/record-detail/index.ts +11 -1
  109. package/src/biz/settings-center/compile.ts +6 -5
  110. package/src/biz/shared/action-host.ts +91 -211
  111. package/src/biz/shared/compile-helpers.ts +80 -0
  112. package/src/biz/shared/coordinator.ts +486 -83
  113. package/src/biz/shared/index.ts +8 -2
  114. package/src/biz/shared/overlay-shell.ts +80 -0
  115. package/src/biz/shared/pipes.ts +43 -30
  116. package/src/biz/shared/remove-key.ts +6 -0
  117. package/src/biz/shared/remove-wire.ts +29 -0
  118. package/src/biz/shared/runtime-hub.ts +216 -24
  119. package/src/biz/single-form/compile.ts +15 -37
  120. package/src/biz/standard-crud/compile.ts +62 -107
  121. package/src/biz/standard-crud/shell.ts +16 -66
  122. package/src/biz/step-form/compile.ts +26 -97
  123. package/src/biz/step-form/hub.ts +34 -41
  124. package/src/biz/types.ts +4 -3
  125. package/src/cli/core-imports.ts +54 -0
  126. package/src/cli/kit-cli.ts +130 -26
  127. package/src/cli/kit-init.ts +222 -0
  128. package/src/cli/service-endpoint-check.ts +425 -0
  129. package/src/cli/source-path-check.d.mts +17 -0
  130. package/src/cli/source-path-check.mjs +334 -0
  131. package/src/cli/view-writes.ts +752 -0
  132. package/src/compile/action-host-attach.ts +21 -29
  133. package/src/compile/closed-set.ts +509 -0
  134. package/src/compile/compile-page.ts +219 -72
  135. package/src/compile/component-candidates.ts +1 -1
  136. package/src/compile/hints.ts +30 -1
  137. package/src/compile/index.ts +1 -0
  138. package/src/compile/kit-error.ts +1 -0
  139. package/src/compile/locate.ts +21 -1
  140. package/src/compile/parse.ts +370 -41
  141. package/src/compile/redirect.ts +6 -2
  142. package/src/compile/styles.ts +35 -2
  143. package/src/compile/types.ts +18 -2
  144. package/src/compile/view-check.ts +151 -0
  145. package/src/data/amount-breakdown.ts +2 -2
  146. package/src/data/anchor-nav.ts +2 -2
  147. package/src/data/approval-flow.ts +2 -2
  148. package/src/data/assignment-picker.ts +40 -29
  149. package/src/data/async-result-panel.ts +62 -6
  150. package/src/data/breadcrumbs.ts +2 -2
  151. package/src/data/calendar.ts +22 -25
  152. package/src/data/carousel.ts +5 -2
  153. package/src/data/chart.ts +42 -34
  154. package/src/data/checklist.ts +2 -2
  155. package/src/data/code-view.ts +4 -2
  156. package/src/data/comment-thread.ts +5 -2
  157. package/src/data/confirm-dialog.ts +10 -0
  158. package/src/data/context-menu.ts +29 -37
  159. package/src/data/d9-util.ts +2 -18
  160. package/src/data/diff.ts +4 -2
  161. package/src/data/dock.ts +2 -2
  162. package/src/data/embed.ts +2 -1
  163. package/src/data/field-mapper.ts +31 -26
  164. package/src/data/flow-editor-contract.ts +1 -1
  165. package/src/data/flow-editor.ts +89 -100
  166. package/src/data/flow-node-options.ts +90 -0
  167. package/src/data/flow-remote-options.ts +0 -103
  168. package/src/data/footer.ts +2 -2
  169. package/src/data/form-draft-registry.ts +2 -4
  170. package/src/data/gantt.ts +14 -17
  171. package/src/data/hero.ts +2 -2
  172. package/src/data/image-viewer.ts +20 -26
  173. package/src/data/index.ts +0 -2
  174. package/src/data/item-list.ts +31 -22
  175. package/src/data/kanban.ts +43 -42
  176. package/src/data/media-grid.ts +14 -19
  177. package/src/data/menu.ts +2 -2
  178. package/src/data/mockup.ts +2 -2
  179. package/src/data/modal-dialog.ts +22 -18
  180. package/src/data/navbar.ts +7 -2
  181. package/src/data/notify-renderer.ts +235 -0
  182. package/src/data/object-form.ts +1036 -648
  183. package/src/data/pager.ts +65 -29
  184. package/src/data/permission-matrix.ts +20 -21
  185. package/src/data/permission-tree.ts +28 -26
  186. package/src/data/pricing-table.ts +9 -3
  187. package/src/data/reaction-bar.ts +77 -88
  188. package/src/data/read-rollback.ts +73 -0
  189. package/src/data/record-card.ts +3 -3
  190. package/src/data/record-picker.ts +93 -50
  191. package/src/data/redirect.ts +32 -32
  192. package/src/data/remote-options.ts +13 -6
  193. package/src/data/request-console.ts +5 -3
  194. package/src/data/resident.ts +2 -1
  195. package/src/data/result-panel.ts +4 -2
  196. package/src/data/rich-text.ts +45 -55
  197. package/src/data/row-editor.ts +285 -52
  198. package/src/data/rule-builder.ts +18 -12
  199. package/src/data/shape-util.ts +4 -0
  200. package/src/data/stat-group.ts +243 -101
  201. package/src/data/static-registry.ts +22 -11
  202. package/src/data/steps.ts +2 -2
  203. package/src/data/survey.ts +24 -29
  204. package/src/data/system-switcher.ts +2 -2
  205. package/src/data/timeline.ts +2 -2
  206. package/src/data/tour-guide.ts +22 -29
  207. package/src/data/transfer.ts +27 -23
  208. package/src/data/tree-table.ts +96 -48
  209. package/src/data/tree.ts +27 -34
  210. package/src/data/trend-line.ts +6 -24
  211. package/src/data/virtual-rows.ts +118 -76
  212. package/src/data/watermark.ts +2 -2
  213. package/src/data/wrap.ts +63 -38
  214. package/src/frames/blank-frame.ts +1 -0
  215. package/src/frames/index.ts +2 -2
  216. package/src/frames/page-bar.ts +12 -11
  217. package/src/frames/page-header.ts +14 -5
  218. package/src/frames/page-status.ts +2 -2
  219. package/src/frames/shared.ts +23 -17
  220. package/src/frames/single-frame.ts +1 -0
  221. package/src/frames/split-frame/shell.ts +5 -5
  222. package/src/frames/split-frame/wiring.ts +2 -2
  223. package/src/frames/tabs-frame/shell.ts +2 -13
  224. package/src/frames/tabs-frame/wiring.ts +4 -8
  225. package/src/frames/top-main-frame.ts +1 -0
  226. package/src/frames/types.ts +13 -2
  227. package/src/frames/workspace-frame/extras.ts +20 -4
  228. package/src/frames/workspace-frame/index.ts +1 -1
  229. package/src/frames/workspace-frame/shell.ts +1 -0
  230. package/src/frames/workspace-frame/state.ts +13 -6
  231. package/src/frames/workspace-frame/view.ts +119 -25
  232. package/src/generated/kit-grammar-runtime.ts +430 -366
  233. package/src/generated/page-origin.ts +0 -11
  234. package/src/i18n/kit-text.ts +23 -27
  235. package/src/index.ts +2 -1
  236. package/src/object-renderer/action-gate.ts +11 -147
  237. package/src/object-renderer/arrange.ts +71 -77
  238. package/src/object-renderer/collapse-wiring.ts +2 -2
  239. package/src/object-renderer/collection-expand.ts +2 -2
  240. package/src/object-renderer/collection-parts.ts +216 -100
  241. package/src/object-renderer/collection-table.ts +180 -42
  242. package/src/object-renderer/collection.ts +95 -79
  243. package/src/object-renderer/compile-data.ts +85 -100
  244. package/src/object-renderer/crud-bridge.ts +32 -0
  245. package/src/object-renderer/defaults.ts +8 -14
  246. package/src/object-renderer/display-checks.ts +3 -24
  247. package/src/object-renderer/emit-events.ts +186 -172
  248. package/src/object-renderer/emit-object.ts +15 -2
  249. package/src/object-renderer/emit-static.ts +174 -132
  250. package/src/object-renderer/field-value.ts +593 -396
  251. package/src/object-renderer/filter-reload.ts +70 -0
  252. package/src/object-renderer/form-detail.ts +112 -2
  253. package/src/object-renderer/index.ts +26 -0
  254. package/src/object-renderer/key-field.ts +12 -0
  255. package/src/object-renderer/linkage.ts +7 -270
  256. package/src/object-renderer/merge-class.ts +18 -1
  257. package/src/object-renderer/path-pick.ts +27 -0
  258. package/src/object-renderer/render-object.ts +405 -86
  259. package/src/object-renderer/request-actions.ts +230 -249
  260. package/src/object-renderer/table-actions.ts +195 -95
  261. package/src/object-renderer/table-summary.ts +2 -2
  262. package/src/object-renderer/table-tools.ts +418 -84
  263. package/src/object-renderer/types.ts +128 -122
  264. package/src/object-renderer/view-binding.ts +196 -0
  265. package/src/page-target/ai-surface.ts +37 -0
  266. package/src/page-target/compile.ts +48 -8
  267. package/src/page-target/index.ts +8 -1
  268. package/src/page-target/intent-schema.ts +154 -28
  269. package/src/page-target/target.ts +257 -50
  270. package/src/page-target/writer-policy.ts +14 -3
  271. package/src/recipes/container.ts +165 -0
  272. package/src/recipes/control.ts +219 -0
  273. package/src/recipes/index.ts +263 -0
  274. package/src/recipes/overlay.ts +182 -0
  275. package/src/recipes/state.ts +70 -0
  276. package/src/recipes/table-row.ts +51 -0
  277. package/src/recipes/typography.ts +87 -0
  278. package/src/shared/action-field-guard.ts +41 -0
  279. package/src/shared/envelope.ts +207 -0
  280. package/src/shared/escape.ts +57 -0
  281. package/src/shared/kit-error.ts +21 -0
  282. package/src/shared/paged-list-adapter.ts +240 -0
  283. package/src/shared/path-guard.ts +127 -0
  284. package/src/shared/theme-runtime-shared.ts +175 -0
  285. package/src/shared/view-info.ts +10 -0
  286. package/src/theme/index.ts +12 -0
  287. package/src/theme/kit-theme-text.ts +1 -1
  288. package/src/theme/kit-theme.css +38 -1
  289. package/src/theme/kit-theme.tpl +38 -1
  290. package/src/theme/nine-dim-structure.ts +77 -0
  291. package/src/theme/surface-layers.ts +97 -0
  292. package/src/theme/theme-tokens.ts +85 -79
  293. package/src/theme/theme-types.ts +71 -0
  294. package/src/theme/typography.ts +17 -17
  295. package/src/biz/shared/step-values.ts +0 -25
  296. package/src/biz/step-form/steps-ref.ts +0 -112
  297. package/src/data/options-bus.ts +0 -24
  298. package/src/data/prompt-dialog.ts +0 -235
  299. package/src/object-renderer/adopt-gate.ts +0 -333
  300. package/src/object-renderer/field-policy.ts +0 -89
  301. package/src/object-renderer/outcome-draft.ts +0 -61
  302. package/src/theme/nine-dim-palettes.ts +0 -1473
@@ -1,5 +1,8 @@
1
- // emitEvents:IR + 动作表 -> `_event.yaml` 片段(设计稿 §4.4)。输出是对象树,键 = selector,值 = 管道串或 `{ steps }`;
1
+ // emitEvents:IR + 动作表 -> `_event.yaml` 片段(设计稿 §4.4)。输出是对象树,键 = selector,值 = 单条管道串(core 只认这一种叶子);
2
2
  // 行模板内的事件嵌套在行数组锚点之下(与 `_ui.yaml` 的 bind 层级一一对应,手册 1.4)。
3
+ // 页面不留编排:一个事件键只绑一条管道,没有 steps、没有按载荷分流、没有「动作之后再做 X」。多动作组件(行操作、批量条、
4
+ // 表单底栏、右键菜单)每个动作各抛各的槽位事件 `<事件名>_<序号>`(见 base/action-slots.ts),这里给每个槽位各绑自己的管道。
5
+ // 需要顺序的事(请求 → 提示 → 重取)写成展示对象方法(async/await + ctx)或具名动作处理函数。
3
6
  //
4
7
  // ── G15 静态核实结论(裁决 Q2,D 组必报):走「KitTableActions」退路,不走「行内按钮 + SCOPE set focus from:row」──
5
8
  // 读 core 源码得到两条硬阻塞:
@@ -12,14 +15,16 @@
12
15
  // 行内路由用 `ACTION | 名字`(emit 载荷原样透传含 `row`,event-engine.ts:529-538)。「把行写进区域切片」交给
13
16
  // 具名动作 / 第 3 层业务组件去做(它们在页面级拿得到 `services.region`),D 组不发射行内 SCOPE set。
14
17
  //
15
- // 多个行操作共用一个 `row_action` 事件,按载荷里的 `id` 用 `steps[].when` 分流(手册 1.4.5)。
18
+ // 多个行操作各抛各的槽位事件 `row_action_<序号>`(序号 = 动作在组件 actions 数组里的位置),每个动作各绑一条管道。
16
19
 
17
20
  import type { KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitObjectIR, KitViewOnValue } from './types';
21
+ import { hintOf, nameSuggestion } from '../compile/hints';
18
22
  import { filterAnchor, headAnchor, pagerAnchor } from './compile-data';
19
- import { normalizeThen, predicateToCore, rowPredicate, thenPipes } from './linkage';
20
- import { checkAutoTriggerable, isRequestLikeAction, registerRequestAction } from './request-actions';
21
- import { checkActionGates, type KitGateSurface } from './action-gate';
22
- import { groupTabEvents } from './emit-static';
23
+ import { registerSliceReload } from './filter-reload';
24
+ import { KIT_ACTION_SLOT_BASE, actionSlotEvent, actionSlotOverflow } from '../base/action-slots';
25
+ import { checkRequestFieldMapping, isRequestLikeAction, registerRequestAction } from './request-actions';
26
+ import { isValidBuiltinName, isValidPermissionCode, formatBuiltinInvalidMessage, formatPermissionInvalidMessage } from '../shared/action-field-guard';
27
+ export { checkRequestFieldMapping };
23
28
  import { cellAnchor, ctxMenuAnchor, expandCellAnchor, expandToggleAnchor, opsAnchor, rowsAnchor, selAnchor, staticCtxAnchor, toolbarAnchor, toolsAnchor, treeAnchor, viewAnchor, virtualAnchor } from './emit-static';
24
29
 
25
30
  export interface KitEventOptions {
@@ -27,6 +32,8 @@ export interface KitEventOptions {
27
32
  actions?: readonly KitAction[];
28
33
  /** 对象是否声明了 write(可编辑 form 才发 `data.submit`) */
29
34
  hasWrite: boolean;
35
+ /** 对象有读来源 behavior.from:独立(非弹窗)表单冲突后的「刷新」据此接作用域重取 */
36
+ hasFrom?: boolean;
30
37
  /** 当前对象名:request / download 动作按「对象 + 动作 id」命名自己的语义事件与合成写对象 */
31
38
  object?: string;
32
39
  /** 对象的主键字段名(空串 = 没有 key: true 字段);request.into 按行分槽时核对 key 必须是它 */
@@ -56,15 +63,31 @@ export interface KitEventEmit {
56
63
  }
57
64
 
58
65
  const BUILTIN_PREFIX = 'kit.';
66
+ export const KIT_ACTION_TONES: readonly string[] = ['primary', 'neutral', 'danger', 'ghost', 'tonal', 'info', 'success', 'warning'];
59
67
 
60
68
  function permissionOf(action: KitAction, at: string, diagnostics: KitDiagnostic[]): string | null {
61
- const p = action.permission;
69
+ const p = action.permission as unknown;
62
70
  if (p === undefined) return null;
63
- if (Array.isArray(p)) {
64
- diagnostics.push({ code: 'KIT-OBJ-006', message: `动作 ${action.id} 的 permission 写成数组:kit 层每个动作只允许一个权限码`, path: `${at}.permission` });
71
+ if (typeof p !== 'string') {
72
+ diagnostics.push({
73
+ code: Array.isArray(p) ? 'KIT-OBJ-006' : 'KIT-ACT-010',
74
+ message: Array.isArray(p)
75
+ ? `动作 ${action.id ?? ''} 的 permission 写成数组:kit 层每个动作只允许一个权限码`
76
+ : `动作 ${action.id ?? ''} 的 permission 必须是字符串(收到 ${typeof p})`,
77
+ path: `${at}.permission`,
78
+ });
65
79
  return null;
66
80
  }
67
- return p === '' ? null : p;
81
+ if (p === '') return null;
82
+ if (!isValidPermissionCode(p)) {
83
+ diagnostics.push({
84
+ code: 'KIT-ACT-010',
85
+ message: formatPermissionInvalidMessage(p, `动作 ${action.id ?? ''} 的 permission`),
86
+ path: `${at}.permission`,
87
+ });
88
+ return null;
89
+ }
90
+ return p;
68
91
  }
69
92
 
70
93
  /** 一个动作 -> 管道串;失败返回 null 并记诊断 */
@@ -74,6 +97,61 @@ export function actionPipeline(
74
97
  options: KitEventOptions,
75
98
  diagnostics: KitDiagnostic[],
76
99
  ): string | null {
100
+ if (action === null || typeof action !== 'object') {
101
+ diagnostics.push({ code: 'KIT-ACT-010', path: at, message: '动作必须是对象' });
102
+ return null;
103
+ }
104
+ if (action.id !== undefined && typeof action.id !== 'string') {
105
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.id`, message: `动作 id 必须是字符串(收到 ${typeof action.id})` });
106
+ return null;
107
+ }
108
+ if (action.name !== undefined && typeof action.name !== 'string') {
109
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.name`, message: `动作 name 必须是字符串(收到 ${typeof action.name})` });
110
+ return null;
111
+ }
112
+ if (action.on !== undefined && typeof action.on !== 'string') {
113
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.on`, message: `动作 on 必须是字符串(收到 ${typeof action.on})` });
114
+ return null;
115
+ }
116
+ if (action.tone !== undefined) {
117
+ if (typeof action.tone !== 'string' || !KIT_ACTION_TONES.includes(action.tone)) {
118
+ diagnostics.push({
119
+ code: 'KIT-ACT-010',
120
+ path: `${at}.tone`,
121
+ message: `动作 ${action.id ?? ''} 的 tone "${String(action.tone)}" 不在闭集(允许:${KIT_ACTION_TONES.join(' / ')})`,
122
+ });
123
+ return null;
124
+ }
125
+ }
126
+ if (action.submit !== undefined && typeof action.submit !== 'string') {
127
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.submit`, message: `动作 ${action.id ?? ''} 的 submit 必须是字符串(收到 ${typeof action.submit})` });
128
+ return null;
129
+ }
130
+ if (action.builtin !== undefined) {
131
+ if (typeof action.builtin !== 'string') {
132
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.builtin`, message: `动作 ${action.id ?? ''} 的 builtin 必须是字符串(收到 ${typeof action.builtin})` });
133
+ return null;
134
+ }
135
+ if (action.builtin !== '' && !isValidBuiltinName(action.builtin)) {
136
+ diagnostics.push({
137
+ code: 'KIT-ACT-010',
138
+ path: `${at}.builtin`,
139
+ message: formatBuiltinInvalidMessage(action.builtin, `动作 ${action.id ?? ''} 的 builtin`),
140
+ });
141
+ return null;
142
+ }
143
+ }
144
+ if (action.confirm !== undefined) {
145
+ if (typeof action.confirm !== 'string') {
146
+ diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.confirm`, message: `动作 ${action.id ?? ''} 的 confirm 必须是字符串(收到 ${typeof action.confirm})` });
147
+ return null;
148
+ }
149
+ if (action.confirm.includes('|')) {
150
+ diagnostics.push({ code: 'KIT-ACT-010', message: `动作 ${action.id} 的 confirm 文案含 "|",管道尾段不支持转义`, path: `${at}.confirm` });
151
+ return null;
152
+ }
153
+ }
154
+
77
155
  let name: string;
78
156
  let segments: string[] = [];
79
157
  if (isRequestLikeAction(action)) {
@@ -85,7 +163,7 @@ export function actionPipeline(
85
163
  } else if (action.submit !== undefined && action.submit !== '') {
86
164
  name = action.submit;
87
165
  if (options.registeredActions !== undefined && !options.registeredActions.has(name)) {
88
- diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 的 submit "${name}" 未在应用的具名动作中登记`, path: `${at}.submit` });
166
+ diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 的 submit "${name}" 未在应用的具名动作中登记`, path: `${at}.submit`, ...hintOf(nameSuggestion(name, options.registeredActions)) });
89
167
  return null;
90
168
  }
91
169
  } else if (action.builtin !== undefined && action.builtin !== '') {
@@ -96,17 +174,12 @@ export function actionPipeline(
96
174
  }
97
175
  if (!isRequestLikeAction(action)) segments = ['ACTION', name];
98
176
  if (action.confirm !== undefined && action.confirm !== '') {
99
- if (action.confirm.includes('|')) {
100
- diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 的 confirm 文案含 "|",管道尾段不支持转义`, path: `${at}.confirm` });
101
- return null;
102
- }
103
177
  segments.push(`confirm:${action.confirm}`);
104
178
  }
105
179
  const permission = permissionOf(action, at, diagnostics);
106
180
  if (permission !== null) segments.push(`permission:${permission}`);
107
181
  return segments.join(' | ');
108
182
  }
109
-
110
183
  /** view.on 内置角色 -> 协调组件语义事件(与 overlayEventRoles.conventional 同口径;cancel 等同 close) */
111
184
  const VIEW_ON_ROLE_SEMANTIC: Readonly<Record<string, string>> = {
112
185
  saved: KIT_SAVED_SEMANTIC,
@@ -117,7 +190,7 @@ const VIEW_ON_ROLE_SEMANTIC: Readonly<Record<string, string>> = {
117
190
  /** 纯顺序载荷的 core 内置动作(Kanban 的 move 原样透传) */
118
191
  const VIEW_ON_ORDER_MOVE = 'data.orderMove';
119
192
 
120
- /** view.on 一项 -> 事件值(管道串或 steps);动作未登记返回 null 并记 KIT-EVT-001 */
193
+ /** view.on 一项 -> 事件值(单条管道串);动作未登记返回 null 并记 KIT-EVT-001 */
121
194
  function viewOnEvent(
122
195
  value: KitViewOnValue,
123
196
  scope: string,
@@ -128,13 +201,13 @@ function viewOnEvent(
128
201
  const actionPipe = (name: string, path: string): string | null => {
129
202
  if (name === VIEW_ON_ORDER_MOVE) return `ACTION | ${VIEW_ON_ORDER_MOVE}`;
130
203
  if (options.registeredActions !== undefined && !options.registeredActions.has(name)) {
131
- diagnostics.push({ code: 'KIT-EVT-001', message: `view.on 的动作 "${name}" 未在应用的具名动作中登记(也不是 data.orderMove / reload / saved / cancel)`, path });
204
+ diagnostics.push({ code: 'KIT-EVT-001', message: `view.on 的动作 "${name}" 未在应用的具名动作中登记(也不是 data.orderMove / reload / saved / cancel)`, path, ...hintOf(nameSuggestion(name, options.registeredActions)) });
132
205
  return null;
133
206
  }
134
207
  return `ACTION | ${name}`;
135
208
  };
136
- // GA1:值写 behavior.actions 里 request / download 动作的 id,组件事件的载荷作 $event 取值根;
137
- // 页面级宿主执行(请求结束自己刷新),所以这里不接 then
209
+ // GA1:值写 behavior.actions 里 request / download 动作的 id;
210
+ // 页面级宿主执行(写操作请求成功后宿主固定重取)
138
211
  const requestLike = (name: string): KitAction | undefined => {
139
212
  if (!Object.prototype.hasOwnProperty.call(VIEW_ON_ROLE_SEMANTIC, name)) return options.actions?.find((a) => a.id === name && isRequestLikeAction(a));
140
213
  return undefined;
@@ -148,58 +221,29 @@ function viewOnEvent(
148
221
  return actionPipe(value, at);
149
222
  }
150
223
  const hitObj = requestLike(value.action);
151
- if (hitObj !== undefined) {
152
- if (value.then !== undefined) {
153
- diagnostics.push({ code: 'KIT-ACT-003', path: `${at}.then`, message: `view.on 接的 ${hitObj.id} 是 request / download 动作,由页面级宿主异步执行,不能再写 then(刷新写 request.then)` });
154
- return null;
155
- }
156
- return actionPipeline(hitObj, `behavior.actions.${hitObj.id}`, options, diagnostics);
157
- }
158
- const first = actionPipe(value.action, `${at}.action`);
159
- if (first === null) return null;
160
- const steps: Array<{ do: string }> = [{ do: first }];
161
- if (value.then !== undefined) steps.push({ do: `SCOPE | semantic | ${scope} | ${VIEW_ON_ROLE_SEMANTIC[value.then]!}` });
162
- return { steps };
224
+ if (hitObj !== undefined) return actionPipeline(hitObj, `behavior.actions.${hitObj.id}`, options, diagnostics);
225
+ return actionPipe(value.action, `${at}.action`);
163
226
  }
164
227
 
165
228
  /**
166
- * 动作的后续链(then:link / toast / reload)展开成管道串;写法不对返回空(诊断已在 renderObject 报过)。
167
- * 业务组件(standard-crud 等自己拼 steps 的)也用它拿到同一份展开。
229
+ * 一组多按钮动作 -> 槽位事件绑定:第 i 个动作的管道绑在 `<key(槽位基名)>_<i>` 上(序号 = 动作在组件 actions 数组里的位置)。
230
+ * 动作写不对(诊断已记)的槽位留空;动作数超过槽位上限报 KIT-EVT-001。返回是否绑了至少一个。
231
+ * 业务组件(standard-crud 等)整段改写行操作时也用它。
168
232
  */
169
- export function actionThenPipes(action: KitAction, scope: string): string[] {
170
- if (action.then === undefined) return [];
171
- const items = normalizeThen(action.then, 'then', []);
172
- return items === null ? [] : thenPipes(items, scope);
173
- }
174
-
175
- /** 动作管道 + 后续链:没有 then 就是管道串本身;有 then 是 { steps }(动作抛错 / 返回 false 时后续不执行) */
176
- export function actionEvent(pipe: string, action: KitAction, scope: string): string | { steps: Array<{ do: string }> } {
177
- const after = actionThenPipes(action, scope);
178
- return after.length === 0 ? pipe : { steps: [{ do: pipe }, ...after.map((p) => ({ do: p }))] };
179
- }
180
-
181
- /** 行操作 steps 的前置条件:动作判别 + 可选的行条件 when(业务组件自己拼 steps 时也用它) */
182
- export function rowActionGate(a: KitAction): Record<string, unknown> {
183
- const base = { field: 'kit_action', op: 'eq', value: a.id };
184
- const cond = a.when === undefined ? null : predicateToCore(a.when, 'when', null, []);
185
- return cond === null ? base : { all_of: [base, rowPredicate(cond)] };
186
- }
187
-
188
- function rowActionEvent(actions: readonly KitAction[], at: string, options: KitEventOptions, diagnostics: KitDiagnostic[], scope: string): unknown | null {
189
- const steps: Array<Record<string, unknown>> = [];
233
+ export function bindActionSlots(
234
+ target: Record<string, unknown>, key: (event: string) => string, base: string,
235
+ actions: readonly KitAction[], at: string, options: KitEventOptions, diagnostics: KitDiagnostic[],
236
+ ): boolean {
237
+ const overflow = actionSlotOverflow(actions.length, at);
238
+ if (overflow !== null) diagnostics.push({ code: 'KIT-EVT-001', message: overflow, path: at });
239
+ let bound = false;
190
240
  actions.forEach((a, i) => {
191
241
  const pipe = actionPipeline(a, `${at}[${i}]`, options, diagnostics);
192
242
  if (pipe === null) return;
193
- const base = { field: 'kit_action', op: 'eq', value: a.id };
194
- // 行操作条件:与动作判别同一个 when(载荷里行在 row 下,叶子字段改写成 { field: row, path: 字段 })
195
- const cond = a.when === undefined ? null : predicateToCore(a.when, `${at}[${i}].when`, null, []);
196
- const when = cond === null ? base : { all_of: [base, rowPredicate(cond)] };
197
- steps.push({ when, do: pipe });
198
- for (const p of actionThenPipes(a, scope)) steps.push({ when, do: p });
243
+ target[key(actionSlotEvent(base, i))] = pipe;
244
+ bound = true;
199
245
  });
200
- if (steps.length === 0) return null;
201
- // 只有一个动作时也保留 when:载荷 id 不匹配就什么都不做,行为与多动作一致
202
- return { steps };
246
+ return bound;
203
247
  }
204
248
 
205
249
  function collectCells(layout: KitLayoutIR): KitCell[] {
@@ -230,6 +274,30 @@ function rowActionsOf(layout: KitLayoutIR): readonly KitAction[] {
230
274
  return layout.kind === 'table' || layout.kind === 'cards' || layout.kind === 'stack' ? layout.rowActions : [];
231
275
  }
232
276
 
277
+ /** 一个对象渲染出的各处行动作组件里,动作 id 的排列(= 组件 actions / menu prop 的顺序,槽位序号取它的位置);业务组件改写行动作事件时按它取槽位 */
278
+ export interface KitRowActionSlots {
279
+ /** 行操作列 / 虚拟滚动表 / 树表的行操作 */
280
+ rows: string[];
281
+ /** 表格 / 卡片 / 堆叠集合的右键菜单 */
282
+ menu: string[];
283
+ /** 写死形状行视图(ItemList / Tree / Kanban)各槽位的右键菜单 */
284
+ staticMenus: Partial<Record<'list' | 'summary' | 'filter' | 'form', string[]>>;
285
+ }
286
+
287
+ export function rowActionSlotsOf(ir: KitObjectIR): KitRowActionSlots {
288
+ const out: KitRowActionSlots = { rows: [], menu: [], staticMenus: {} };
289
+ const list = ir.views.list?.layout;
290
+ if (list !== undefined) {
291
+ out.rows = rowActionsOf(list).map((a) => a.id);
292
+ if (list.kind === 'table' || list.kind === 'cards' || list.kind === 'stack') out.menu = (list.contextMenu ?? []).map((a) => a.id);
293
+ }
294
+ for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
295
+ const layout = ir.views[slot]?.layout;
296
+ if (layout !== undefined && layout.kind === 'static' && (layout.contextMenu ?? []).length > 0) out.staticMenus[slot] = layout.contextMenu!.map((a) => a.id);
297
+ }
298
+ return out;
299
+ }
300
+
233
301
  export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEventEmit {
234
302
  const object = ir.object;
235
303
  const options: KitEventOptions = rawOptions.object === undefined ? { ...rawOptions, object } : rawOptions;
@@ -238,105 +306,54 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
238
306
  const events: Record<string, unknown> = {};
239
307
  const all = options.actions ?? [];
240
308
 
241
- // GA2:动作的 disabledWhen / hiddenWhen 校验(落点:行操作 / 右键菜单 / 工具栏 / 表单底栏)
242
- if (all.some((a) => a.disabledWhen !== undefined || a.hiddenWhen !== undefined)) {
243
- const surfaces = new Map<string, KitGateSurface>();
244
- for (const a of all) {
245
- if (a.on === 'row') surfaces.set(a.id, 'row');
246
- else if (a.on === 'toolbar') surfaces.set(a.id, 'toolbar');
247
- }
248
- for (const id of ir.views.form?.formOpts?.footerActions ?? []) if (!surfaces.has(id)) surfaces.set(id, 'footer');
249
- checkActionGates(all, surfaces, null, diagnostics);
250
- }
251
-
252
- // 筛选:提交与重置都是「写 filter 切片 + 重取」;重置时组件抛空 values
309
+ // 筛选:提交与重置都只写 filter 切片(单管道;重置时组件抛空 values);
310
+ // 「切片一变就重取」登记给页面级宿主(它订阅 filter 切片,等一拍让分页器回第 1 页后再重取),不再靠第二步 window-reload
253
311
  if (ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static') {
254
312
  const id = filterAnchor(object);
255
- const apply = {
256
- steps: [
257
- { do: `SCOPE | set | ${scope} | filter | from:values` },
258
- { do: `SCOPE | window-reload | ${scope}` },
259
- ],
260
- };
313
+ const apply = `SCOPE | set | ${scope} | filter | from:values`;
261
314
  events[`${id}.submit`] = apply;
262
315
  events[`${id}.reset`] = apply;
316
+ registerSliceReload({ scope, slice: 'filter', reload: [{ scope }] });
263
317
  }
264
318
 
265
319
  // 可编辑表单:提交走内置 data.submit,载荷由 KitObjectForm 自己组装 { object, model, mode, scope }
266
320
  const form = ir.views.form;
267
321
  if (form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show' && options.hasWrite) {
268
322
  events[`${viewAnchor(object, 'form')}.submit`] = 'ACTION | data.submit';
269
- // view.form.afterSave:写入成功(表单抛 saved)后的有序后续链;业务组件接 saved 的话会覆盖它
270
- const after = form.formOpts?.afterSave;
271
- if (after !== undefined && after.length > 0) {
272
- events[`${viewAnchor(object, 'form')}.saved`] = { steps: thenPipes(after, scope).map((p) => ({ do: p })) };
273
- }
323
+ // 冲突后的「刷新」:表单的 initial 绑对象值时由宿主重取该作用域的对象(弹窗表单由 wireDialogForm 在其后改写为协调组件语义管道)
324
+ if (options.hasFrom === true) events[`${viewAnchor(object, 'form')}.reload`] = `SCOPE | window-reload | ${scope}`;
274
325
  }
275
326
 
276
- // 编辑表单底栏动作(view.form.footerActions):表单抛 footer_action { id },按 id 分流到 request / download 动作
277
- // (编成交页面级宿主的语义事件;$draft 在宿主执行那一刻取表单草稿)
278
- const footerIds = ir.views.form?.formOpts?.footerActions ?? [];
279
- if (footerIds.length > 0) {
280
- const steps: Array<{ when: Record<string, unknown>; do: string }> = [];
281
- for (const aid of footerIds) {
282
- const a = all.find((x) => x.id === aid);
283
- if (a === undefined || !isRequestLikeAction(a)) {
284
- diagnostics.push({ code: 'KIT-EVT-001', message: `footerActions 的 "${aid}" 不是本对象 behavior.actions 里的 request / download 动作`, path: 'views.form.footerActions' });
285
- continue;
286
- }
287
- const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
288
- if (pipe !== null) steps.push({ when: { field: 'id', op: 'eq', value: aid }, do: pipe });
289
- }
290
- if (steps.length > 0) events[`${viewAnchor(object, 'form')}.footer_action`] = { steps };
327
+ // 展示对象方法:表单草稿变化(draft_change,载荷 { values, dirty })-> UI_REFRESH | page.<方法>;方法改写展示对象成员,页面经路径绑定被动刷新
328
+ if (form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show' && form.formOpts?.onDraft !== undefined) {
329
+ events[`${viewAnchor(object, 'form')}.draft_change`] = `UI_REFRESH | page.${form.formOpts.onDraft}`;
291
330
  }
292
-
293
- // 采纳条上的「获取建议」钮:form 抛 adopt_ask,接到 adopt.ask 指向的 request 动作(页面级请求宿主发,body 可取 $draft.*)
294
- const askId = form?.formOpts?.adopt?.ask;
295
- if (askId !== undefined && form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show') {
296
- const hit = all.find((a) => a.id === askId);
297
- if (hit === undefined || !isRequestLikeAction(hit) || hit.request === undefined) {
298
- diagnostics.push({ code: 'KIT-FORM-009', message: `adopt.ask "${askId}" 不是本对象 behavior.actions 里的 request 动作`, path: 'view.form.adopt.ask' });
299
- } else if (hit.on !== undefined) {
300
- diagnostics.push({ code: 'KIT-FORM-009', message: `adopt.ask 指向的动作 ${askId} 不能写 on(它只由采纳条上的钮触发,不渲染成别处的按钮)`, path: `behavior.actions.${askId}.on` });
301
- } else if (hit.request.into !== form.formOpts?.adopt?.from) {
302
- diagnostics.push({ code: 'KIT-FORM-009', message: `adopt.ask 的动作 ${askId} 的 request.into 必须是字符串且等于 adopt.from("${form.formOpts?.adopt?.from}"),否则采纳条收不到它的结果(采纳条没有「当前行」,不能引用按行分槽的 into)`, path: `behavior.actions.${askId}.request.into` });
303
- } else {
304
- const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
305
- if (pipe !== null) events[`${viewAnchor(object, 'form')}.adopt_ask`] = actionEvent(pipe, hit, scope);
331
+ // 编辑表单底栏动作(view.form.footerActions):每个动作各抛 footer_action_<序号>(序号 = 它在表单 footerActions prop 里的位置,
332
+ // 即 footerActions 里存在于 behavior.actions 的那些),各绑一条 request / download 管道(交页面级宿主的语义事件)
333
+ const footerIds = (ir.views.form?.formOpts?.footerActions ?? []).filter((aid) => all.some((x) => x.id === aid));
334
+ for (const aid of ir.views.form?.formOpts?.footerActions ?? []) {
335
+ const a = all.find((x) => x.id === aid);
336
+ if (a === undefined || !isRequestLikeAction(a)) {
337
+ diagnostics.push({ code: 'KIT-EVT-001', message: `footerActions 的 "${aid}" 不是本对象 behavior.actions 里的 request / download 动作`, path: 'views.form.footerActions' });
306
338
  }
307
339
  }
340
+ const footerOverflow = actionSlotOverflow(footerIds.length, 'views.form.footerActions');
341
+ if (footerOverflow !== null) diagnostics.push({ code: 'KIT-EVT-001', message: footerOverflow, path: 'views.form.footerActions' });
342
+ footerIds.forEach((aid, i) => {
343
+ const a = all.find((x) => x.id === aid)!;
344
+ if (!isRequestLikeAction(a)) return;
345
+ const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
346
+ if (pipe !== null) events[`${viewAnchor(object, 'form')}.${actionSlotEvent(KIT_ACTION_SLOT_BASE.footer, i)}`] = pipe;
347
+ });
308
348
 
309
- // H1d:request.on: mount 的动作登记进页面级请求宿主(不渲染成按钮;宿主挂载时自己发一次)
349
+ // H1d / 展示对象 ctx.request:不挂在按钮上的 request 动作(request.on: mount,或无 on 供展示对象触发)登记进页面级请求宿主
310
350
  for (const a of all) {
311
- if (a.request?.on === undefined) continue;
351
+ if (a.request === undefined) continue;
352
+ if (a.request.on === undefined && (a.on !== undefined || footerIds.includes(a.id))) continue;
312
353
  actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
313
354
  }
314
355
 
315
- // H1e:view.form.onChange(字段值变化触发 request 动作):表单抛 field_change { field, value, kit_auto },按字段分流到 request 动作
316
- const changeMap = ir.views.form?.formOpts?.onChange;
317
- if (changeMap !== undefined && form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show') {
318
- const steps: Array<{ when: Record<string, unknown>; do: string }> = [];
319
- for (const [field, aid] of Object.entries(changeMap)) {
320
- const a = all.find((x) => x.id === aid);
321
- const at = `view.form.onChange.${field}`;
322
- if (a === undefined || a.request === undefined) {
323
- diagnostics.push({ code: 'KIT-ACT-008', path: at, message: `onChange 的 "${aid}" 不是本对象 behavior.actions 里的 request 动作` });
324
- continue;
325
- }
326
- if (!checkAutoTriggerable(a, `behavior.actions.${a.id}`, diagnostics)) continue;
327
- const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
328
- if (pipe !== null) steps.push({ when: { field: 'field', op: 'eq', value: field }, do: pipe });
329
- }
330
- if (steps.length > 0) events[`${viewAnchor(object, 'form')}.field_change`] = { steps };
331
- }
332
-
333
- // groups 页签(groupsAs: tabs,只读视图):点页签 = 关别的面板、开本面板(同 tabs-frame 的 UI_INTERACT)
334
- for (const slot of ['summary', 'form'] as const) {
335
- const v = ir.views[slot];
336
- if (v === undefined || (slot === 'form' && v.mode !== 'show')) continue;
337
- if (v.layout.kind !== 'groups' || v.layout.tabs !== true) continue;
338
- Object.assign(events, groupTabEvents(object, slot, v.layout.groups.length));
339
- }
356
+ // groups 页签(groupsAs: tabs,只读视图):面板显隐由 KitTabsWiring 在组件内自己切(点页签 / 键盘),不走事件声明
340
357
 
341
358
  // 列表:分页 + 行操作 + 列内字段动作
342
359
  const list = ir.views.list;
@@ -357,16 +374,9 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
357
374
  if (layout.toolbar?.includes('reload') === true) events[`${tid}.reload`] = `SCOPE | window-reload | ${scope}`;
358
375
  if (options.selectable === true && layout.select === 'multi') events[`${tid}.select_change`] = `SCOPE | semantic | ${scope} | ${KIT_SELECT_SEMANTIC}`;
359
376
  if (options.selectable === true && (layout.batch?.length ?? 0) > 0) {
360
- const after = `SCOPE | semantic | ${scope} | ${KIT_RELOAD_SEMANTIC}`;
361
- const steps: Array<Record<string, unknown>> = [];
362
- layout.batch!.forEach((b, i) => {
363
- const pipe = actionPipeline(b.action, `views.list.batchActions[${i}]`, options, diagnostics);
364
- if (pipe === null) return;
365
- const when = { field: 'kit_action', op: 'eq', value: b.id };
366
- steps.push({ when, do: pipe });
367
- steps.push({ when, do: after });
368
- });
369
- if (steps.length > 0) events[`${tid}.batch_action`] = { steps };
377
+ // 批量动作:每个按钮各抛 batch_action_<序号>,各绑自己的管道(具名动作做完在有协调组件的页面里由 defineKitActions 固定重取)
378
+ const batchActs = layout.batch!.map((b) => b.action);
379
+ bindActionSlots(events, (n) => `${tid}.${n}`, KIT_ACTION_SLOT_BASE.batch, batchActs, 'views.list.batchActions', options, diagnostics);
370
380
  }
371
381
  if (layout.editMode !== undefined && layout.editMode !== null) {
372
382
  if (options.hasWrite) events[`${tid}.cell_edit`] = 'ACTION | data.submit';
@@ -376,7 +386,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
376
386
  const nested: Record<string, unknown> = {};
377
387
  // 展开子表(Q 波 G5):行里的展开开关(KitTableActions)把"展开哪一行"交协调组件写 focus.expandId
378
388
  if (layout.kind === 'table' && layout.expand?.list !== undefined && options.expandable === true) {
379
- nested[`${expandToggleAnchor(object)}.row_action`] = `SCOPE | semantic | ${scope} | ${KIT_EXPAND_SEMANTIC}`;
389
+ nested[`${expandToggleAnchor(object)}.row_expand`] = `SCOPE | semantic | ${scope} | ${KIT_EXPAND_SEMANTIC}`;
380
390
  }
381
391
  if (layout.kind === 'table' && layout.expand !== null && layout.expand.list === undefined) {
382
392
  for (const cell of collectCells(layout.expand.layout)) {
@@ -387,7 +397,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
387
397
  continue;
388
398
  }
389
399
  const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
390
- if (pipe !== null) nested[`${expandCellAnchor(object, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = actionEvent(pipe, hit, scope);
400
+ if (pipe !== null) nested[`${expandCellAnchor(object, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
391
401
  }
392
402
  }
393
403
  // 树表:表体 KitTreeTable 是页面直接实例(不在行模板里),row_select / row_action 挂在它自己的锚点上,不嵌套在 rowsAnchor 下
@@ -398,27 +408,24 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
398
408
  target[key('row_select')] = `SCOPE | semantic | ${scope} | ${KIT_SELECT_SEMANTIC}`;
399
409
  }
400
410
  const rowActions = rowActionsOf(layout);
401
- if (rowActions.length > 0) {
402
- const ev = rowActionEvent(rowActions, 'views.list.rowActions', options, diagnostics, scope);
403
- if (ev !== null) target[key('row_action')] = ev;
404
- }
411
+ if (rowActions.length > 0) bindActionSlots(target, key, KIT_ACTION_SLOT_BASE.row, rowActions, 'views.list.rowActions', options, diagnostics);
405
412
  };
406
413
  // 虚拟滚动表体 KitVirtualRows 同树表:页面直接实例,事件挂在它自己的锚点上
407
414
  const isVirtual = layout.kind === 'table' && layout.virtual !== undefined && layout.tree === null;
408
415
  if (isTree) bodyEvents(events, (n) => `${treeAnchor(object)}.${n}`);
409
416
  else if (isVirtual) bodyEvents(events, (n) => `${virtualAnchor(object)}.${n}`);
410
- else bodyEvents(nested, (n) => (n === 'row_select' ? `${selAnchor(object)}.row_select` : `${opsAnchor(object)}.row_action`));
411
- // 右键菜单(Q 波 G6):KitContextMenu 的 row_action 与行操作同形(kit_action 分流 + 条件 + 尾段)。
417
+ else bodyEvents(nested, (n) => (n === 'row_select' ? `${selAnchor(object)}.row_select` : `${opsAnchor(object)}.${n}`));
418
+ // 右键菜单(Q 波 G6):KitContextMenu 每个菜单项各抛 row_action_<序号>(序号 = 它在 menu 数组里的位置),与行操作同形、各绑一条管道。
412
419
  // 行实例在行模板里(嵌套在 rowsAnchor 下),虚拟滚动表的实例是页面直接实例。已在 rowActions 里报过的动作诊断不重复报
413
420
  if ((layout.kind === 'table' || layout.kind === 'cards' || layout.kind === 'stack') && (layout.contextMenu ?? []).length > 0) {
414
421
  const ctxActions = layout.contextMenu!;
415
422
  const known = new Set(rowActionsOf(layout).map((a) => a.id));
416
- rowActionEvent(ctxActions.filter((a) => !known.has(a.id)), 'views.list.contextMenu', options, diagnostics, scope);
417
- const ctxEv = rowActionEvent(ctxActions, 'views.list.contextMenu', options, [], scope);
418
- if (ctxEv !== null) {
419
- if (isVirtual || isTree) events[`${ctxMenuAnchor(object)}.row_action`] = ctxEv;
420
- else nested[`${ctxMenuAnchor(object)}.row_action`] = ctxEv;
421
- }
423
+ const ctxAt = 'views.list.contextMenu';
424
+ const tmp: KitDiagnostic[] = [];
425
+ bindActionSlots(isVirtual || isTree ? events : nested, (n) => `${ctxMenuAnchor(object)}.${n}`, KIT_ACTION_SLOT_BASE.row, ctxActions, ctxAt, options, tmp);
426
+ ctxActions.forEach((a, i) => {
427
+ if (!known.has(a.id)) diagnostics.push(...tmp.filter((d) => d.path.startsWith(`${ctxAt}[${i}]`)));
428
+ });
422
429
  }
423
430
  for (const cell of collectCells(layout)) {
424
431
  if (cell.action === undefined || cell.component === '') continue;
@@ -428,7 +435,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
428
435
  continue;
429
436
  }
430
437
  const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
431
- if (pipe !== null) nested[`${cellAnchor(object, 'list', cell.field)}.${fieldEventName(cell.component, cell.event)}`] = actionEvent(pipe, hit, scope);
438
+ if (pipe !== null) nested[`${cellAnchor(object, 'list', cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
432
439
  }
433
440
  if (Object.keys(nested).length > 0) events[rowsAnchor(object)] = nested;
434
441
  }
@@ -445,7 +452,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
445
452
  continue;
446
453
  }
447
454
  const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
448
- if (pipe !== null) events[`${cellAnchor(object, slot, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = actionEvent(pipe, hit, scope);
455
+ if (pipe !== null) events[`${cellAnchor(object, slot, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
449
456
  }
450
457
  }
451
458
 
@@ -479,19 +486,26 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
479
486
  }
480
487
  }
481
488
 
489
+ // 读失败自动重试:静态视图的错误框带重试钮(emit-static 补文案),页面没接 retry 时接重取本对象的管道
490
+ for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
491
+ const layout = ir.views[slot]?.layout;
492
+ if (layout === undefined || layout.kind !== 'static' || layout.autoRetry !== true) continue;
493
+ const key = `${viewAnchor(object, slot)}.retry`;
494
+ if (events[key] === undefined) events[key] = `SCOPE | window-reload | ${scope}`;
495
+ }
496
+
482
497
  // 写死形状行视图(ItemList / Tree / Kanban)的右键菜单:页面里一个 KitContextMenu,row_action 与行操作同形
483
498
  for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
484
499
  const layout = ir.views[slot]?.layout;
485
500
  if (layout === undefined || layout.kind !== 'static' || (layout.contextMenu ?? []).length === 0) continue;
486
- const ctxEv = rowActionEvent(layout.contextMenu!, `views.${slot}.contextMenu`, options, diagnostics, scope);
487
- if (ctxEv !== null) events[`${staticCtxAnchor(object, slot)}.row_action`] = ctxEv;
501
+ bindActionSlots(events, (n) => `${staticCtxAnchor(object, slot)}.${n}`, KIT_ACTION_SLOT_BASE.row, layout.contextMenu!, `views.${slot}.contextMenu`, options, diagnostics);
488
502
  }
489
503
 
490
504
  // 工具栏动作:不在行里,载荷无 row
491
505
  all.forEach((a, i) => {
492
506
  if (a.on !== 'toolbar') return;
493
507
  const pipe = actionPipeline(a, `behavior.actions[${i}]`, options, diagnostics);
494
- if (pipe !== null) events[`${toolbarAnchor(object, a.id)}.click`] = actionEvent(pipe, a, scope);
508
+ if (pipe !== null) events[`${toolbarAnchor(object, a.id)}.click`] = pipe;
495
509
  });
496
510
 
497
511
  return { events, diagnostics };
@@ -3,9 +3,10 @@
3
3
 
4
4
  import { collectCandidates } from './candidates';
5
5
  import { compileData, listShapeOf, type KitCompiledData } from './compile-data';
6
+ import { hasBehaviorFrom } from './crud-bridge';
6
7
  import { emitEvents } from './emit-events';
7
8
  import { checkFormDetail } from './form-detail';
8
- import { emitStatic, keysOf, type KitStaticEmit } from './emit-static';
9
+ import { emitStatic, keysOf, viewAnchor, type KitStaticEmit } from './emit-static';
9
10
  import { renderObject } from './render-object';
10
11
  import type { KitDiagnostic, KitObject, KitObjectIR, KitRenderContext } from './types';
11
12
 
@@ -25,6 +26,8 @@ export interface KitEmitInput {
25
26
  pickOnRow?: boolean;
26
27
  /** 勾选列接 selection:协调组件 focus 切片 sel 镜像的路径;给了才发射可勾选的勾选列与 row_select 事件 */
27
28
  selectedPath?: string;
29
+ /** 行删除在途置灰读的协调组件作用域(忙闲通道名 = 作用域 + 行主键,须与 KitCrudBridge 的 scope 一致);缺省用本对象作用域 */
30
+ removeScope?: string;
28
31
  /** 展开子表(Q 波 G5):协调组件 focus 切片 expandId 镜像的路径;给了才把 list 形展开的开关接到 crud_expand 语义事件 */
29
32
  expandPath?: string;
30
33
  }
@@ -62,6 +65,7 @@ export function emitObject(obj: KitObject, ctx: KitRenderContext, input: KitEmit
62
65
  ...(input.formInitialPath !== undefined ? { formInitialPath: input.formInitialPath } : {}),
63
66
  ...(input.pickOnRow === true ? { pickOnRow: true } : {}),
64
67
  ...(input.selectedPath !== undefined ? { selectedPath: input.selectedPath } : {}),
68
+ ...(input.removeScope !== undefined ? { removeScope: input.removeScope } : {}),
65
69
  ...(input.expandPath !== undefined ? { expandPath: input.expandPath } : {}),
66
70
  ...(compiled.data[ctx.object]?.write?.validate_on !== undefined ? { validateOn: compiled.data[ctx.object]!.write!.validate_on! } : {}),
67
71
  ...(obj.behavior.leaveGuard === true || obj.behavior.leaveGuard === 'confirm' ? { leaveGuard: true } : {}),
@@ -71,6 +75,7 @@ export function emitObject(obj: KitObject, ctx: KitRenderContext, input: KitEmit
71
75
  keyField: keysOf(obj.schema)[0] ?? '',
72
76
  // 以编出的 write 为准:全字段只读时 compileWrite 不生成 write,此时不能再把表单提交接到 data.submit
73
77
  hasWrite: obj.behavior.write !== undefined && compiled.data[ctx.object]?.write !== undefined,
78
+ hasFrom: hasBehaviorFrom(obj.behavior),
74
79
  ...(input.selectedPath !== undefined ? { selectable: true } : {}),
75
80
  ...(input.expandPath !== undefined ? { expandable: true } : {}),
76
81
  ...(input.registeredActions !== undefined ? { registeredActions: input.registeredActions } : {}),
@@ -83,11 +88,19 @@ export function emitObject(obj: KitObject, ctx: KitRenderContext, input: KitEmit
83
88
  withBase: false,
84
89
  ...(input.extraCandidates !== undefined ? { extra: input.extraCandidates } : {}),
85
90
  });
91
+ // 带 from 的可编辑表单会发 `<对象>__form.reload -> SCOPE | window-reload | <作用域>`,window-reload 按作用域声明取对象名;
92
+ // 没有筛选 / 分页 / 排序时 compileData 不产出作用域声明,这里按需补一份最小声明(已有声明——如带 slices 的列表作用域——不重复补)
93
+ const reloadKey = `${viewAnchor(ctx.object, 'form')}.reload`;
94
+ const needsReloadScope = ev.events[reloadKey] === `SCOPE | window-reload | ${ctx.scope}`
95
+ && !compiled.scopes.some((s) => s.id === ctx.scope);
96
+ const scopes: KitCompiledData['scopes'] = needsReloadScope
97
+ ? [...compiled.scopes, { id: ctx.scope, object: ctx.object, slices: [] }]
98
+ : compiled.scopes;
86
99
  const filled: KitObjectIR = { ...ir, data: compiled.data as unknown as Record<string, unknown>, candidates };
87
100
  return {
88
101
  ir: filled,
89
102
  compiled,
90
- ui: { data: compiled.data, scopes: compiled.scopes, show: stat.show },
103
+ ui: { data: compiled.data, scopes, show: stat.show },
91
104
  html: stat.html,
92
105
  parts: stat.parts,
93
106
  events: ev.events,