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
@@ -16,14 +16,31 @@ import {
16
16
  isKitType,
17
17
  type KitFieldSetDefault,
18
18
  } from './defaults';
19
- import { adoptOf } from './adopt-gate';
20
19
  import { resultSlotOf } from './action-gate';
20
+ import {
21
+ KIT_PART_CARD,
22
+ KIT_PART_PANEL,
23
+ KIT_PART_SECTION,
24
+ KIT_PART_STAT_VALUE,
25
+ KIT_PART_TITLE_DIALOG,
26
+ KIT_PART_TITLE_PAGE,
27
+ KIT_PART_TITLE_SECTION,
28
+ KIT_PART_WELL,
29
+ kitTypographyRecipe,
30
+ KIT_VIEW_HIGHLIGHT_CLASS,
31
+ resolveContainerEmphasisClass,
32
+ resolveSurfaceRecipeClass,
33
+ } from './form-detail';
21
34
  import { checkDisplayProps } from './display-checks';
22
- import { checkFlowFields, checkViewFlowNodeOptions, checkViewRowColumns, collectFieldValues } from './field-value';
23
- import { fieldPolicyOf } from './field-policy';
24
- import { normalizeThen, predicateToCore } from './linkage';
35
+ import { bindFieldProps, checkNestedBindingValues, checkOnDraft, checkSubmitDisabled, classifyBindingValue, classifyEventBinding, collectFieldState, viewPathToCore } from './view-binding';
36
+ import { checkEnumOptionsAndEditCompatibility, checkFieldRules, checkFlowFields, checkViewFlowNodeOptions, checkViewRowColumns, collectFieldValues, fieldNamesOf } from './field-value';
37
+ import { validateRequestAction } from './request-actions';
38
+ import { hasBehaviorFrom, readStatePathsOf } from './crud-bridge';
39
+ import { KIT_ACTION_TONES } from './emit-events';
25
40
  import { checkClasses, mergeClass, splitClasses } from './merge-class';
41
+ import { KIT_FILTER_INLINE_CLASS } from './parts';
26
42
  import { slotModeOf } from './mode';
43
+ import { formNotifyProblem } from './form-notify';
27
44
  import type {
28
45
  KitArrangeInput,
29
46
  KitCell,
@@ -44,10 +61,79 @@ import type {
44
61
  KitViewSlot,
45
62
  } from './types';
46
63
 
64
+ const ENTITY_REF_RE = /^\$entity\.([A-Za-z_][A-Za-z0-9_]*)$/;
65
+ const DICT_REF_RE = /^\$dict\.([A-Za-z_][A-Za-z0-9_]*)$/;
66
+
67
+ function expandRawSchemaIfNeeded(rawSchema: unknown, ctx: KitRenderContext, diags: KitDiagnostic[]): Record<string, KitFieldSchema> {
68
+ if (typeof rawSchema === 'string') {
69
+ const m = ENTITY_REF_RE.exec(rawSchema.trim());
70
+ if (!m) {
71
+ diags.push({ code: 'KIT-OBJ-001', path: 'schema', message: `schema 字符串引用必须为 $entity.<实体名>(收到 "${rawSchema}")` });
72
+ return {};
73
+ }
74
+ const entityDef = ctx.entities?.[m[1]!];
75
+ if (!entityDef || typeof entityDef !== 'object') {
76
+ diags.push({ code: 'KIT-OBJ-001', path: 'schema', message: `对象引用了未声明的实体 ${rawSchema}` });
77
+ return {};
78
+ }
79
+ const out: Record<string, KitFieldSchema> = {};
80
+ for (const [k, v] of Object.entries(entityDef)) {
81
+ if (v && typeof v === 'object') out[k] = { ...(v as KitFieldSchema) };
82
+ }
83
+ return out;
84
+ }
85
+ if (rawSchema !== null && typeof rawSchema === 'object' && !Array.isArray(rawSchema) && '$ref' in (rawSchema as Record<string, unknown>)) {
86
+ const refObj = rawSchema as { $ref?: unknown; pick?: unknown; omit?: unknown; override?: unknown };
87
+ const refStr = typeof refObj.$ref === 'string' ? refObj.$ref.trim() : '';
88
+ const m = ENTITY_REF_RE.exec(refStr);
89
+ if (!m) {
90
+ diags.push({ code: 'KIT-OBJ-001', path: 'schema.$ref', message: `schema.$ref 必须为 $entity.<实体名>(收到 "${String(refObj.$ref)}")` });
91
+ return {};
92
+ }
93
+ const entityDef = ctx.entities?.[m[1]!];
94
+ if (!entityDef || typeof entityDef !== 'object') {
95
+ diags.push({ code: 'KIT-OBJ-001', path: 'schema.$ref', message: `对象引用了未声明的实体 ${refStr}` });
96
+ return {};
97
+ }
98
+ let names = Object.keys(entityDef);
99
+ if (Array.isArray(refObj.pick)) {
100
+ const picks = refObj.pick.filter((x): x is string => typeof x === 'string');
101
+ for (const p of picks) {
102
+ if (!(p in entityDef)) diags.push({ code: 'KIT-OBJ-001', path: 'schema.pick', message: `schema.pick 引用了实体 ${refStr} 中不存在的字段 ${p}` });
103
+ }
104
+ names = picks.filter((p) => p in entityDef);
105
+ }
106
+ if (Array.isArray(refObj.omit)) {
107
+ const omits = new Set(refObj.omit.filter((x): x is string => typeof x === 'string'));
108
+ names = names.filter((n) => !omits.has(n));
109
+ }
110
+ const out: Record<string, KitFieldSchema> = {};
111
+ for (const n of names) {
112
+ const base = entityDef[n];
113
+ if (base && typeof base === 'object') out[n] = { ...(base as KitFieldSchema) };
114
+ }
115
+ if (refObj.override && typeof refObj.override === 'object' && !Array.isArray(refObj.override)) {
116
+ for (const [fName, over] of Object.entries(refObj.override as Record<string, unknown>)) {
117
+ if (over && typeof over === 'object') {
118
+ out[fName] = { ...(out[fName] ?? (entityDef[fName] as KitFieldSchema) ?? ({} as KitFieldSchema)), ...(over as Partial<KitFieldSchema>) };
119
+ }
120
+ }
121
+ }
122
+ return out;
123
+ }
124
+ return (rawSchema ?? {}) as Record<string, KitFieldSchema>;
125
+ }
126
+
47
127
  function resolveSchema(obj: KitObject, ctx: KitRenderContext, diags: KitDiagnostic[]): KitSchema {
48
128
  const out: KitSchema = {};
49
- for (const [key, raw] of Object.entries(obj.schema)) {
50
- let field: KitFieldSchema = raw;
129
+ const rawObj = obj as unknown as Record<string, unknown>;
130
+ const hasWrite = (obj.behavior?.write !== undefined && obj.behavior.write !== null)
131
+ || (rawObj.write !== undefined && rawObj.write !== null);
132
+ const primaryKey = typeof obj.primaryKey === 'string' && obj.primaryKey.trim() !== '' ? obj.primaryKey.trim() : 'id';
133
+ const sourceSchema = expandRawSchemaIfNeeded(obj.schema, ctx, diags);
134
+
135
+ for (const [key, raw] of Object.entries(sourceSchema)) {
136
+ let field: KitFieldSchema = { ...raw };
51
137
  if (raw.ref) {
52
138
  const shared = ctx.sharedSchema?.[raw.ref];
53
139
  if (!shared) {
@@ -56,6 +142,53 @@ function resolveSchema(obj: KitObject, ctx: KitRenderContext, diags: KitDiagnost
56
142
  field = { ...shared, ...raw };
57
143
  }
58
144
  }
145
+ if (typeof (field.options as unknown) === 'string') {
146
+ const optStr = String(field.options).trim();
147
+ const dm = DICT_REF_RE.exec(optStr);
148
+ if (!dm) {
149
+ diags.push({ code: 'KIT-FORM-003', path: `schema.${key}.options`, message: `字段 ${key} 的 options 字符串引用必须为 $dict.<字典名>(收到 "${optStr}")` });
150
+ } else {
151
+ const dictItems = ctx.dicts?.[dm[1]!];
152
+ if (!Array.isArray(dictItems) || dictItems.length === 0) {
153
+ diags.push({ code: 'KIT-FORM-003', path: `schema.${key}.options`, message: `字段 ${key} 引用了未声明的字典 ${optStr}` });
154
+ } else {
155
+ field.options = dictItems.map((it) => ({ ...it })) as KitFieldSchema['options'];
156
+ }
157
+ }
158
+ }
159
+ const rawAccess = field.access ?? field.permission;
160
+ if (rawAccess !== undefined) {
161
+ if (rawAccess === 'read' || rawAccess === 'r') {
162
+ field.permission = 'r';
163
+ field.access = 'read';
164
+ } else if (rawAccess === 'write' || rawAccess === 'w') {
165
+ field.permission = 'w';
166
+ field.access = 'write';
167
+ } else if (rawAccess === 'create') {
168
+ field.permission = 'create';
169
+ field.access = 'create';
170
+ } else {
171
+ const attrKey = field.access !== undefined ? 'access' : 'permission';
172
+ diags.push({ code: 'KIT-OBJ-006', path: `schema.${key}.${attrKey}`, message: `字段 ${key} 的 ${attrKey} "${String(rawAccess)}" 不合法(允许:read / write / create)` });
173
+ field.permission = 'r';
174
+ field.access = 'read';
175
+ }
176
+ } else if (field.readonly === true) {
177
+ field.permission = 'r';
178
+ field.access = 'read';
179
+ } else if (hasWrite) {
180
+ const isPrimaryKey = field.key === true || key === primaryKey;
181
+ if (isPrimaryKey) {
182
+ field.permission = 'r';
183
+ field.access = 'read';
184
+ } else {
185
+ field.permission = 'w';
186
+ field.access = 'write';
187
+ }
188
+ } else {
189
+ field.permission = 'r';
190
+ field.access = 'read';
191
+ }
59
192
  if (!isKitType(field.type)) {
60
193
  diags.push({ code: 'KIT-TYPE-001', path: `schema.${key}.type`, message: `type ${String(field.type)} 未在 types 表登记` });
61
194
  }
@@ -89,7 +222,14 @@ function layoutCells(l: KitLayoutIR): KitCell[] {
89
222
 
90
223
  function layoutClasses(l: KitLayoutIR, out: string[]): void {
91
224
  switch (l.kind) {
92
- case 'grid': out.push(l.wrapClass, l.gridClass); break;
225
+ case 'grid':
226
+ out.push(l.wrapClass, l.gridClass);
227
+ // 筛选栏动作区并入字段栅格时才用到的类(emit-static 的 renderObjectForm 按 collapsible / overflow 决定用不用;候选类多收不碍事)
228
+ if (l.actionsClass !== undefined) out.push(l.actionsClass, KIT_FILTER_INLINE_CLASS.grid, KIT_FILTER_INLINE_CLASS.actionsExtra, KIT_FILTER_INLINE_CLASS.notice);
229
+ // 定宽流式版式(不折叠的筛选栏):根容器 / 字段宽度 / 动作区 / 提示条
230
+ if (l.filterFlow !== undefined) out.push(l.filterFlow.wrapClass, ...l.filterFlow.widthClasses, l.filterFlow.actionsClass, l.filterFlow.padClass, l.filterFlow.noticeClass, 'min-w-0');
231
+ if (l.filterPack !== undefined) out.push(l.filterPack.wrapClass, ...l.filterPack.cellClasses, l.filterPack.actionsClass, l.filterPack.padClass, l.filterPack.noticeClass, 'min-w-0');
232
+ break;
93
233
  case 'rows': out.push(l.wrapClass, l.rowClass); break;
94
234
  case 'flex': out.push(l.wrapClass); break;
95
235
  case 'groups':
@@ -99,9 +239,10 @@ function layoutClasses(l: KitLayoutIR, out: string[]): void {
99
239
  break;
100
240
  case 'table':
101
241
  out.push(l.wrapClass, l.innerClass, l.headClass, l.rowClass, l.selectClass, l.actionsClass, KIT_CLASS_DEFAULTS.tableActions, l.stripeClass);
242
+ // 普通表格斑马纹发射时改用 odd 键(行容器首子节点是 template),候选类要一并收
243
+ if (l.stripeClass !== '') out.push(KIT_CLASS_DEFAULTS.tableRowStripedAfterTemplate, KIT_CLASS_DEFAULTS.tableRowStripedExpandOuter, KIT_CLASS_DEFAULTS.tableRowStripedExpandInnerAfterTemplate);
102
244
  for (const h of l.head) out.push(h.class);
103
245
  // G2:表头里的选择 / 操作列类、合计行类(这些只经组件 props 下发,不在 HTML 里)
104
- for (const w of l.rowClassWhen ?? []) out.push(w.class);
105
246
  out.push(l.selectHeadClass ?? '', l.actionsHeadClass ?? '', l.summaryRowClass ?? '', ...(l.summaryCellClasses ?? []));
106
247
  if (l.expand !== null) layoutClasses(l.expand.layout, out);
107
248
  break;
@@ -123,8 +264,33 @@ const RESERVED_STATIC_PROPS: ReadonlySet<string> = new Set(['data', 'map', 'char
123
264
  const STATIC_PROP_KEY = /^[a-z][A-Za-z0-9_]*$/;
124
265
 
125
266
  /** view.props(配置类 prop 透传)与 view.value(值绑定路径)的校验;违规的键丢弃并记 KIT-STATIC-001 */
126
- function staticProps(form: KitViewForm, path: string, diags: KitDiagnostic[]): { props?: Record<string, unknown>; value?: string } {
127
- const out: { props?: Record<string, unknown>; value?: string } = {};
267
+ /** 实际值的类型名(诊断用):null / array 单列,其余取 typeof */
268
+ function literalTypeName(v: unknown): string {
269
+ if (v === null) return 'null';
270
+ if (Array.isArray(v)) return 'array';
271
+ return typeof v;
272
+ }
273
+
274
+ /**
275
+ * 字面量配置值是否符合契约 type:string / number / boolean / array / object / enum(只核是字符串,propTypes 不含枚举值);
276
+ * 未知类型 / 空串不核。null / undefined 视作「未填」不核。返回期望类型名,符合或不核返回 null。
277
+ */
278
+ function propTypeMismatch(type: string | undefined, v: unknown): string | null {
279
+ if (type === undefined || type === '' || v === null || v === undefined) return null;
280
+ switch (type) {
281
+ case 'string': case 'number': case 'boolean': return typeof v === type ? null : type;
282
+ case 'array': return Array.isArray(v) ? null : type;
283
+ case 'object': return typeof v === 'object' && !Array.isArray(v) ? null : type;
284
+ case 'enum': return typeof v === 'string' ? null : 'string';
285
+ default: return null;
286
+ }
287
+ }
288
+
289
+ function staticProps(
290
+ form: KitViewForm, path: string, diags: KitDiagnostic[], contractProps?: readonly string[], propTypes?: Readonly<Record<string, string>>,
291
+ ): { props?: Record<string, unknown>; value?: string; bound?: ReadonlySet<string> } {
292
+ const out: { props?: Record<string, unknown>; value?: string; bound?: ReadonlySet<string> } = {};
293
+ const bound = new Set<string>();
128
294
  if (form.props !== undefined) {
129
295
  if (form.props === null || typeof form.props !== 'object' || Array.isArray(form.props)) {
130
296
  diags.push({ code: 'KIT-STATIC-001', path: `${path}.props`, message: 'props 必须是对象' });
@@ -135,9 +301,38 @@ function staticProps(form: KitViewForm, path: string, diags: KitDiagnostic[]): {
135
301
  diags.push({ code: 'KIT-STATIC-001', path: `${path}.props.${k}`, message: `props 的键 ${k} 不合法或属保留键(data / map / chart / class / value 由编译器写)` });
136
302
  continue;
137
303
  }
304
+ // 闭集:组件契约登记了 props 时,键必须是契约里的 prop(已删除的写法 / 手误的键不静默透传给组件)
305
+ if (contractProps !== undefined && !contractProps.includes(k)) {
306
+ diags.push({ code: 'KIT-STATIC-001', path: `${path}.props.${k}`, message: `组件 ${form.staticComponent ?? ''} 没有 prop ${k}(契约 props:${contractProps.join(' / ')})` });
307
+ continue;
308
+ }
309
+ // 绑定(RV-1119):值写 view.<成员> 编成 core 页面变量路径(成员改了组件全量重画);row. 在静态视图里没有行;
310
+ // 原始运行期路径 / 取反 / 非纯路径记诊断。成员的存在与形状由 compile/view-check 对着登记表核(KIT-VIEW-003 / 011)
311
+ const binding = classifyBindingValue(v, `props 的 ${k}`);
312
+ if (binding.kind === 'invalid') {
313
+ diags.push({ code: binding.code, path: `${path}.props.${k}`, message: binding.message });
314
+ continue;
315
+ }
316
+ if (binding.kind === 'row') {
317
+ diags.push({ code: 'KIT-ROW-002', path: `${path}.props.${k}`, message: `静态视图 props 的 ${k} 不能绑 row.<字段>(没有行):row.<字段> 只用于列表视图的字段项 props;这里写 view.<成员>` });
318
+ continue;
319
+ }
320
+ if (binding.kind === 'view') {
321
+ kept[k] = viewPathToCore(binding.path);
322
+ bound.add(k);
323
+ continue;
324
+ }
325
+ checkNestedBindingValues(v, `${path}.props.${k}`, diags);
326
+ // 类型:契约给了 propTypes 才核(字面量配置值;绑定值的形状由 view-check 核,KIT-VIEW-011);类型不符的键丢弃,不把错类型透传给组件
327
+ const expected = propTypeMismatch(propTypes?.[k], v);
328
+ if (expected !== null) {
329
+ diags.push({ code: 'KIT-STATIC-001', path: `${path}.props.${k}`, message: `组件 ${form.staticComponent ?? ''} 的 prop ${k} 期望 ${expected},实际是 ${literalTypeName(v)}` });
330
+ continue;
331
+ }
138
332
  kept[k] = v;
139
333
  }
140
334
  if (Object.keys(kept).length > 0) out.props = kept;
335
+ if (bound.size > 0) out.bound = bound;
141
336
  }
142
337
  }
143
338
  if (form.value !== undefined) {
@@ -147,10 +342,8 @@ function staticProps(form: KitViewForm, path: string, diags: KitDiagnostic[]): {
147
342
  return out;
148
343
  }
149
344
 
150
- const VIEW_ON_THEN: ReadonlySet<string> = new Set(KIT_GRAMMAR.overlayEventRoles.actionForm.thenValues);
151
-
152
345
  /**
153
- * view.on(写死形状数据组件的事件接线)的形状与事件名校验:值是非空动作串,或 { action, then? };
346
+ * view.on(写死形状数据组件的事件接线)的形状与事件名校验:值是非空动作串,或 { action };
154
347
  * 事件名必须在组件契约 emits 里(契约没给 emits 时不核)。违规的项丢弃并记 KIT-STATIC-001;动作是否登记由 emitEvents 核。
155
348
  */
156
349
  function staticOn(
@@ -176,11 +369,20 @@ function staticOn(
176
369
  diags.push({ code: 'KIT-STATIC-001', path: at, message: 'on 的动作不能是空串' });
177
370
  continue;
178
371
  }
372
+ // view.<方法>:事件调展示对象方法(RV-1119);view. 开头却不是单段方法名记 KIT-VIEW-001。方法是否登记由 compile/view-check 核(KIT-VIEW-004)
373
+ const evt = classifyEventBinding(value, `on.${event}`);
374
+ if (evt.kind === 'invalid') {
375
+ diags.push({ code: 'KIT-VIEW-001', path: at, message: evt.message });
376
+ continue;
377
+ }
179
378
  } else if (value === null || typeof value !== 'object' || Array.isArray(value) || typeof value.action !== 'string' || value.action === '') {
180
- diags.push({ code: 'KIT-STATIC-001', path: at, message: 'on 的值必须是动作名字符串,或 { action, then? }' });
379
+ diags.push({ code: 'KIT-STATIC-001', path: at, message: 'on 的值必须是动作名字符串,或 { action }' });
380
+ continue;
381
+ } else if (value.action.startsWith('view.')) {
382
+ diags.push({ code: 'KIT-VIEW-001', path: `${at}.action`, message: `展示对象方法直接写成 on 的值(${event}: view.<方法>),不写进 { action } 对象形` });
181
383
  continue;
182
- } else if (value.then !== undefined && !VIEW_ON_THEN.has(value.then)) {
183
- diags.push({ code: 'KIT-STATIC-001', path: `${at}.then`, message: `then = "${String(value.then)}" 不在 ${[...VIEW_ON_THEN].join(' / ')} 内` });
384
+ } else if (Object.keys(value).some((k) => k !== 'action')) {
385
+ diags.push({ code: 'KIT-STATIC-001', path: at, message: 'on 的对象形态只许 action 键(动作之后的提示 / 重取 / 跳转写在具名动作或展示对象方法里)' });
184
386
  continue;
185
387
  }
186
388
  kept[event] = value;
@@ -206,9 +408,9 @@ const GROUPS_AS = KIT_GRAMMAR.formLinkage.groupsAs as { values: string[] };
206
408
 
207
409
  /**
208
410
  * 表单 / 筛选的布局与行为参数(M 波 G3 D6 / D7):只许写在对应槽位上,枚举 / 范围 / 布尔不对记 KIT-FORM-006 并忽略该键;
209
- * afterSave(form 写入成功后的后续链)写法不对记 KIT-FORM-002。返回 IR 形态(只含写了的键)。
411
+ * 返回 IR 形态(只含写了的键)。
210
412
  */
211
- function formOptsOf(slot: KitViewSlot, form: KitViewForm, path: string, diags: KitDiagnostic[], schema?: KitSchema): KitFormOpts {
413
+ function formOptsOf(slot: KitViewSlot, form: KitViewForm, path: string, diags: KitDiagnostic[]): KitFormOpts {
212
414
  const out: KitFormOpts = {};
213
415
  const raw = form as unknown as Record<string, unknown>;
214
416
  const bad = (key: string, message: string): void => { diags.push({ code: 'KIT-FORM-006', path: `${path}.${key}`, message }); };
@@ -239,60 +441,50 @@ function formOptsOf(slot: KitViewSlot, form: KitViewForm, path: string, diags: K
239
441
  }
240
442
  bool('inline', ['form']);
241
443
  const scroll = bool('scrollToError', ['form']);
242
- if (scroll === true) out.scrollToError = true;
243
- if (raw.afterSave !== undefined) {
244
- if (slot !== 'form') bad('afterSave', 'afterSave 只用于 form 视图');
245
- else {
246
- const then = normalizeThen(raw.afterSave, `${path}.afterSave`, diags);
247
- if (then !== null) out.afterSave = then;
248
- }
249
- }
250
- // 采纳建议:只许 form 视图
251
- if (raw.adopt !== undefined) {
252
- if (slot !== 'form') diags.push({ code: 'KIT-FORM-009', path: `${path}.adopt`, message: 'adopt 只用于 form 视图' });
253
- else {
254
- const adopt = adoptOf(raw.adopt, `${path}.adopt`, schema, diags);
255
- if (adopt !== null) out.adopt = adopt;
256
- }
257
- }
444
+ if (scroll !== undefined) out.scrollToError = scroll;
258
445
  // 底栏动作:只许 form 视图,动作 id 的字符串数组(是否存在 / 是否 request·download 在 emit 阶段核对)
259
446
  if (raw.footerActions !== undefined) {
260
447
  const list = raw.footerActions as unknown;
261
448
  if (slot !== 'form') diags.push({ code: 'KIT-FORM-009', path: `${path}.footerActions`, message: 'footerActions 只用于 form 视图' });
262
449
  else if (!Array.isArray(list) || list.length === 0 || list.some((x) => typeof x !== 'string' || x === '')) {
263
450
  diags.push({ code: 'KIT-FORM-009', path: `${path}.footerActions`, message: 'footerActions 必须是非空的动作 id 数组' });
264
- } else out.footerActions = [...new Set(list as string[])];
265
- }
266
- // 字段变化触发请求(H1e):只许 form 视图;键是可编辑字段,值是动作 id(是否 read 的 request 动作在 emit 阶段核对)
267
- if (raw.onChange !== undefined) {
268
- const map = raw.onChange as unknown;
269
- const at = `${path}.onChange`;
270
- if (slot !== 'form') diags.push({ code: 'KIT-ACT-008', path: at, message: 'onChange 只用于 form 视图' });
271
- else if (map === null || typeof map !== 'object' || Array.isArray(map) || Object.keys(map).length === 0) {
272
- diags.push({ code: 'KIT-ACT-008', path: at, message: 'onChange 必须是非空对象 { 字段名: request 动作 id }' });
273
- } else {
274
- const kept: Record<string, string> = {};
275
- for (const [field, aid] of Object.entries(map as Record<string, unknown>)) {
276
- const f = schema?.[field];
277
- if (typeof aid !== 'string' || aid === '') diags.push({ code: 'KIT-ACT-008', path: `${at}.${field}`, message: 'onChange 的值必须是 request 动作 id(字符串)' });
278
- else if (schema !== undefined && f === undefined) diags.push({ code: 'KIT-ACT-008', path: `${at}.${field}`, message: `onChange 的字段 ${field} 不在对象 schema 里` });
279
- else if (f !== undefined && (f.permission ?? 'r') === 'r') diags.push({ code: 'KIT-ACT-008', path: `${at}.${field}`, message: `onChange 的字段 ${field} 是只读字段(permission: r),用户改不了它,没有"变化"可触发` });
280
- else kept[field] = aid;
281
- }
282
- if (Object.keys(kept).length > 0) out.onChange = kept;
283
- }
451
+ } else if (new Set(list).size !== list.length) {
452
+ diags.push({ code: 'KIT-FORM-009', path: `${path}.footerActions`, message: 'footerActions 含重复的动作 id' });
453
+ } else out.footerActions = [...(list as string[])];
284
454
  }
285
455
  // 请求结果常驻槽(GA3):form 视图画在字段与按钮之间;其它视图在 renderSlot 里改写成 AsyncResultPanel
286
456
  if (raw.result !== undefined && slot === 'form') {
287
457
  const result = resultSlotOf(raw.result, `${path}.result`, diags);
288
458
  if (result !== null) out.result = result;
289
459
  }
290
- // filter:折叠与触发
460
+ // filter:折叠与触发(P2:筛选字段数量 > 4 且未显式设置 collapsible / defaultCollapsedCount 时,默认前 4 项常驻、第 5 项起自动折叠)
291
461
  if (slot === 'filter') {
292
- const collapsible = raw.collapsible === undefined ? undefined : typeof raw.collapsible === 'boolean' ? raw.collapsible : (bad('collapsible', 'collapsible 必须是布尔'), undefined);
462
+ const filterFieldCount = Array.isArray(form.fields)
463
+ ? form.fields.map(normalizeRef).filter((r) => r.divider === undefined).length
464
+ : 0;
465
+ let residentLimit = 4;
466
+ if (raw.defaultCollapsedCount !== undefined) {
467
+ if (typeof raw.defaultCollapsedCount !== 'number' || !Number.isInteger(raw.defaultCollapsedCount) || raw.defaultCollapsedCount < 1) {
468
+ bad('defaultCollapsedCount', 'defaultCollapsedCount 须是正整数');
469
+ } else {
470
+ residentLimit = raw.defaultCollapsedCount;
471
+ out.defaultCollapsedCount = residentLimit;
472
+ }
473
+ }
474
+ const autoCollapse = raw.collapsible === undefined && filterFieldCount > residentLimit;
475
+ const collapsible = raw.collapsible === undefined
476
+ ? (autoCollapse ? true : undefined)
477
+ : typeof raw.collapsible === 'boolean'
478
+ ? raw.collapsible
479
+ : (bad('collapsible', 'collapsible 必须是布尔'), undefined);
293
480
  if (collapsible === true) {
294
481
  out.collapsible = true;
295
- const rows = raw.collapsedRows ?? FILTER_OPTS.collapsedRowsDefault;
482
+ if (autoCollapse || filterFieldCount > residentLimit) {
483
+ out.filterOverflow = true;
484
+ out.defaultCollapsedCount ??= residentLimit;
485
+ }
486
+ const defaultRows = raw.defaultCollapsedCount !== undefined ? Math.max(1, Math.min(FILTER_OPTS.collapsedRowsMax, Math.ceil(residentLimit / 4))) : FILTER_OPTS.collapsedRowsDefault;
487
+ const rows = raw.collapsedRows ?? defaultRows;
296
488
  if (typeof rows !== 'number' || !Number.isInteger(rows) || rows < 1 || rows > FILTER_OPTS.collapsedRowsMax) {
297
489
  bad('collapsedRows', `collapsedRows 须是 1~${FILTER_OPTS.collapsedRowsMax} 的整数`);
298
490
  out.collapsedRows = FILTER_OPTS.collapsedRowsDefault;
@@ -306,6 +498,7 @@ function formOptsOf(slot: KitViewSlot, form: KitViewForm, path: string, diags: K
306
498
  }
307
499
  } else {
308
500
  onlyOn('collapsedRows', ['filter']);
501
+ onlyOn('defaultCollapsedCount', ['filter']);
309
502
  onlyOn('trigger', ['filter']);
310
503
  }
311
504
  // groupsAs
@@ -321,11 +514,78 @@ function formOptsOf(slot: KitViewSlot, form: KitViewForm, path: string, diags: K
321
514
  }
322
515
 
323
516
  /** list 槽上的 contextMenu 并入集合声明(集合自己写了就以集合为准);其它槽原样返回,由 renderSlot 报 KIT-MENU-001 */
324
- function withViewContextMenu(c: KitCollection, form: KitViewForm, slot: KitViewSlot): KitCollection {
325
- if (slot !== 'list' || form.contextMenu === undefined || (c as { contextMenu?: unknown }).contextMenu !== undefined) return c;
517
+ function withViewContextMenu(c: KitCollection, form: KitViewForm, slot: KitViewSlot, diags?: KitDiagnostic[]): KitCollection {
518
+ if (slot !== 'list' || form.contextMenu === undefined) return c;
519
+ if ((c as { contextMenu?: unknown }).contextMenu !== undefined) {
520
+ diags?.push({ code: 'KIT-MENU-001', path: 'view.list.contextMenu', message: 'view.list.contextMenu 与 view.list.collection.contextMenu 不能同时声明' });
521
+ return c;
522
+ }
326
523
  return { ...c, contextMenu: form.contextMenu } as KitCollection;
327
524
  }
328
525
 
526
+ function resolveSlotKnobs(
527
+ slot: KitViewSlot,
528
+ form: KitViewForm,
529
+ obj: KitObject,
530
+ path: string,
531
+ diags: KitDiagnostic[],
532
+ ): { emphasis?: 'primary' | 'normal' | 'subtle'; surface?: 'card' | 'flush' | 'plain'; highlight?: boolean; extraWrapClass: string } {
533
+ const viewRec = (obj.view ?? {}) as Record<string, unknown>;
534
+ const rawEmphasis = form.emphasis ?? (viewRec.emphasis as unknown) ?? obj.emphasis;
535
+ const rawSurface = form.surface ?? (viewRec.surface as unknown) ?? obj.surface;
536
+ const rawHighlight = form.highlight ?? (viewRec.highlight as unknown) ?? obj.highlight;
537
+
538
+ let emphasis: 'primary' | 'normal' | 'subtle' | undefined;
539
+ if (rawEmphasis !== undefined) {
540
+ if (rawEmphasis === 'primary' || rawEmphasis === 'normal' || rawEmphasis === 'subtle') {
541
+ emphasis = rawEmphasis;
542
+ } else {
543
+ diags.push({ code: 'KIT-OBJ-009', path: `${path}.emphasis`, message: `emphasis 只许 primary / normal / subtle,收到 "${String(rawEmphasis)}"` });
544
+ }
545
+ }
546
+
547
+ let surface: 'card' | 'flush' | 'plain' | undefined;
548
+ if (rawSurface !== undefined) {
549
+ if (rawSurface === 'card' || rawSurface === 'flush' || rawSurface === 'plain') {
550
+ surface = rawSurface;
551
+ } else {
552
+ diags.push({ code: 'KIT-OBJ-009', path: `${path}.surface`, message: `surface 只许 card / flush / plain,收到 "${String(rawSurface)}"` });
553
+ }
554
+ }
555
+
556
+ let highlight: boolean | undefined;
557
+ if (rawHighlight !== undefined) {
558
+ if (typeof rawHighlight === 'boolean') {
559
+ if (rawHighlight) highlight = true;
560
+ } else {
561
+ diags.push({ code: 'KIT-OBJ-009', path: `${path}.highlight`, message: 'highlight 必须是布尔值' });
562
+ }
563
+ }
564
+
565
+ const classes: string[] = [];
566
+ if (surface !== undefined) classes.push(resolveSurfaceRecipeClass(surface));
567
+ if (emphasis !== undefined) classes.push(resolveContainerEmphasisClass(emphasis));
568
+ if (highlight === true) {
569
+ classes.push(KIT_VIEW_HIGHLIGHT_CLASS);
570
+ }
571
+
572
+ return {
573
+ ...(emphasis !== undefined ? { emphasis } : {}),
574
+ ...(surface !== undefined ? { surface } : {}),
575
+ ...(highlight === true ? { highlight: true } : {}),
576
+ extraWrapClass: classes.filter(Boolean).join(' '),
577
+ };
578
+ }
579
+
580
+ function applyWrapKnobClass(layout: KitLayoutIR, extraWrapClass: string): void {
581
+ if (extraWrapClass === '') return;
582
+ if (layout.kind === 'static') {
583
+ layout.class = mergeClass(extraWrapClass, layout.class);
584
+ } else {
585
+ layout.wrapClass = mergeClass(layout.wrapClass, extraWrapClass);
586
+ }
587
+ }
588
+
329
589
  function renderSlot(
330
590
  slot: KitViewSlot,
331
591
  form: KitViewForm,
@@ -355,7 +615,8 @@ function renderSlot(
355
615
  }
356
616
  }
357
617
  const emptyEnv = summaryEmpty(slot, form, path, diags);
358
- const fopts = formOptsOf(slot, form, path, diags, schema);
618
+ const fopts = formOptsOf(slot, form, path, diags);
619
+ const slotKnobs = resolveSlotKnobs(slot, form, obj, path, diags);
359
620
  // inline: true 等价 arrange: inline;与别的 arrange 同写报错
360
621
  if (slot === 'form' && form.inline === true) {
361
622
  if (form.arrange !== undefined && form.arrange !== 'inline' && !(typeof form.arrange === 'object' && 'inline' in (form.arrange as object))) {
@@ -365,8 +626,6 @@ function renderSlot(
365
626
  }
366
627
  }
367
628
  const requiredMark = form.requiredMark === 'start' ? 'start' : 'end';
368
- // 字段策略表:form 视图的 policy 规整成 IR,经 env 交给每个字段格并入 showWhen / disabledWhen / requiredWhen
369
- const policy = form.policy === undefined ? null : fieldPolicyOf(form.policy, slot, schema, `${path}.policy`, diags);
370
629
 
371
630
  if (form.staticComponent) {
372
631
  const contract = ctx.staticComponents?.[form.staticComponent];
@@ -380,25 +639,41 @@ function renderSlot(
380
639
  });
381
640
  }
382
641
  diags.push(...checkClasses(form.class, `${path}.class`));
383
- const extraProps = staticProps(form, path, diags);
384
- checkDisplayProps(form, obj, path, diags);
642
+ const extraProps = staticProps(form, path, diags, contract?.props, contract?.propTypes);
643
+ // 绑定到展示对象成员的 prop 值不是字面量,不进字面量配置的展示校验
644
+ const boundKeys = extraProps.bound;
645
+ checkDisplayProps(boundKeys === undefined || form.props === undefined ? form : { ...form, props: Object.fromEntries(Object.entries(form.props).filter(([k]) => !boundKeys.has(k))) }, obj, path, diags);
385
646
  const on = staticOn(form, contract?.emits, path, diags);
386
647
  const dataSubmit = obj.behavior.write !== undefined
387
648
  && contract?.emits?.includes('submit') === true
388
649
  && contract?.props?.includes('object') === true;
389
650
  const hasScopeProp = contract?.props?.includes('scope') === true;
651
+ // 读状态属性:契约声明了 loading / error_text 且对象有数据来源才标记(契约只给属性名,类型由组件契约自身保证)
652
+ const hasSource = hasBehaviorFrom(obj.behavior);
653
+ const hasLoadingProp = hasSource && contract?.props?.includes('loading') === true;
654
+ const hasErrorTextProp = hasSource && contract?.props?.includes('error_text') === true;
655
+ // 无 error_text 的组件(如 ItemList)用 string 型 error 属性承接读失败:契约给了 propTypes 才按类型认(没给不绑)
656
+ const hasErrorProp = hasSource && !hasErrorTextProp && contract?.props?.includes('error') === true && contract?.propTypes?.error === 'string';
657
+ // 读失败自动重试:绑了读取错误、契约有 retry 事件与 retry_text 属性(RecordPicker 只有 error_text 与自带 search 重试,无 retry 事件,不受影响)
658
+ const autoRetry = (hasErrorTextProp || hasErrorProp)
659
+ && contract?.emits?.includes('retry') === true
660
+ && contract?.props?.includes('retry_text') === true;
390
661
  // 右键菜单:只有带行级动作的写死形状组件(ItemList / Tree / Kanban)接受;其它(Chart 等)报 KIT-MENU-001
391
662
  let ctxActions: ReturnType<typeof resolveContextMenuItems> = [];
392
663
  if (form.contextMenu !== undefined) {
393
664
  if (!KIT_CONTEXT_MENU.staticComponents.includes(form.staticComponent)) {
394
- diags.push({ code: 'KIT-MENU-001', path: `${path}.contextMenu`, message: `组件 ${form.staticComponent} 没有行级动作,不能写 contextMenu(只用于 ${KIT_CONTEXT_MENU.staticComponents.join(' / ')} 与 table / treeTable / cards / stack 集合),已忽略` });
665
+ diags.push({ code: 'KIT-MENU-001', path: `${path}.contextMenu`, message: `组件 ${form.staticComponent} 没有行级动作,不能写 contextMenu(只用于 ${KIT_CONTEXT_MENU.staticComponents.join(' / ')} 与 table / treeTable / cards / stack 集合)` });
395
666
  } else {
396
667
  ctxActions = resolveContextMenuItems(form.contextMenu, [], obj.behavior.actions ?? [], `${path}.contextMenu`, diags);
397
668
  }
398
669
  }
670
+ const staticBase = mergeClass(KIT_CLASS_DEFAULTS.staticRoot, slotKnobs.extraWrapClass);
399
671
  return {
400
672
  ...viewTexts(slot, form, path, diags),
401
673
  mode: 'show',
674
+ ...(slotKnobs.emphasis !== undefined ? { emphasis: slotKnobs.emphasis } : {}),
675
+ ...(slotKnobs.surface !== undefined ? { surface: slotKnobs.surface } : {}),
676
+ ...(slotKnobs.highlight === true ? { highlight: true } : {}),
402
677
  layout: {
403
678
  kind: 'static',
404
679
  component: form.staticComponent,
@@ -409,8 +684,12 @@ function renderSlot(
409
684
  ...(extraProps.value !== undefined ? { value: extraProps.value } : {}),
410
685
  ...(on !== undefined ? { on } : {}),
411
686
  ...(dataSubmit ? { dataSubmit: true, ...(hasScopeProp ? { hasScopeProp: true } : {}) } : {}),
687
+ ...(hasLoadingProp ? { hasLoadingProp: true } : {}),
688
+ ...(hasErrorTextProp ? { hasErrorTextProp: true } : {}),
689
+ ...(hasErrorProp ? { hasErrorProp: true } : {}),
690
+ ...(autoRetry ? { autoRetry: true } : {}),
412
691
  ...(ctxActions.length > 0 ? { contextMenu: ctxActions } : {}),
413
- class: mergeClass(KIT_CLASS_DEFAULTS.staticRoot, form.class, form.replaceClass),
692
+ class: mergeClass(staticBase, form.class, form.replaceClass),
414
693
  },
415
694
  };
416
695
  }
@@ -428,9 +707,9 @@ function renderSlot(
428
707
  path,
429
708
  slot,
430
709
  requiredMark,
431
- ...(policy !== null ? { policy } : {}),
432
710
  ...(ctx.locale !== undefined ? { locale: ctx.locale } : {}),
433
711
  ...(emptyEnv !== undefined ? { empty: emptyEnv } : {}),
712
+ staticPropKeys: (component: string) => ctx.staticComponents?.[component]?.props,
434
713
  actions: obj.behavior.actions ?? [],
435
714
  ...(ctx.expandHosts !== undefined ? { expandHosts: ctx.expandHosts } : {}),
436
715
  renderExpand: (viewName: string, at: string): KitExpandIR | null => {
@@ -471,19 +750,31 @@ function renderSlot(
471
750
  if (grouped !== null) {
472
751
  layout = grouped;
473
752
  } else if (form.collection) {
474
- layout = collection(withViewContextMenu(form.collection, form, slot), refs, form, env);
753
+ layout = collection(withViewContextMenu(form.collection, form, slot, diags), refs, form, env);
475
754
  } else if (form.arrange) {
476
755
  layout = arrange(form.arrange, refs, form, env);
477
756
  } else if (dflt.collection) {
478
- layout = collection(withViewContextMenu(dflt.collection, form, slot), refs, form, env);
757
+ layout = collection(withViewContextMenu(dflt.collection, form, slot, diags), refs, form, env);
479
758
  } else {
480
759
  layout = arrange(dflt.arrange!, refs, form, env);
481
760
  }
482
761
  // 没有行级动作的视图(summary / form / filter、排布而非集合的 list)写了 contextMenu:KIT-MENU-001
483
762
  if (form.contextMenu !== undefined && !(slot === 'list' && (layout.kind === 'table' || layout.kind === 'cards' || layout.kind === 'stack'))) {
484
- diags.push({ code: 'KIT-MENU-001', path: `${path}.contextMenu`, message: `${slot} 视图没有行级动作,不能写 contextMenu(只用于 table / treeTable / cards / stack 集合与 ItemList / Tree / Kanban),已忽略` });
763
+ diags.push({ code: 'KIT-MENU-001', path: `${path}.contextMenu`, message: `${slot} 视图没有行级动作,不能写 contextMenu(只用于 table / treeTable / cards / stack 集合与 ItemList / Tree / Kanban)` });
485
764
  }
486
765
 
766
+ applyWrapKnobClass(layout, slotKnobs.extraWrapClass);
767
+ // 字段项 props 绑展示对象 / 行字段(RV-1119):就地把格 props 里的 view.<成员> 换成 core 路径,row.<字段> 记进 cell.rowProps
768
+ bindFieldProps(slot, form, layoutCells(layout), path, diags, schema);
769
+ if (slot === 'filter' && fopts.filterOverflow === true) {
770
+ const limit = fopts.defaultCollapsedCount ?? 4;
771
+ let nonDividerIdx = 0;
772
+ for (const c of layoutCells(layout)) {
773
+ if (c.placeholder === true || c.divider === true || c.component === '') continue;
774
+ if (nonDividerIdx >= limit) c.overflow = true;
775
+ nonDividerIdx += 1;
776
+ }
777
+ }
487
778
  const modes = new Set(layoutCells(layout).filter((c) => !c.placeholder).map((c) => c.mode));
488
779
  const mode = modes.size === 0 ? (slot === 'filter' ? 'edit' : slotModeOf(slot, {}, ctx.formCtx)) : modes.size === 1 ? [...modes][0] : 'mixed';
489
780
  // view.loading: skeleton:只读的 summary / form 才有(可编辑 form 的初值来自协调组件,没有"数据未到"的瞬间)
@@ -493,11 +784,26 @@ function renderSlot(
493
784
  else skeleton = true;
494
785
  }
495
786
  const groupTabs = layout.kind === 'groups' && layout.tabs === true;
496
- const formOpts: KitFormOpts = { ...fopts, ...(groupTabs ? { groupTabs: true } : {}) };
787
+ // 展示对象的纯路径绑定:字段项 hidden / disabled / required、view.form.onDraft
788
+ const fieldState = collectFieldState(slot, form, path, diags, schema);
789
+ const onDraft = checkOnDraft(slot, form, path, diags);
790
+ const submitDisabled = checkSubmitDisabled(slot, form, path, diags);
791
+ const formOpts: KitFormOpts = {
792
+ ...fopts,
793
+ ...(groupTabs ? { groupTabs: true } : {}),
794
+ ...(Object.keys(fieldState).length > 0 ? { fieldState } : {}),
795
+ ...(onDraft !== undefined ? { onDraft } : {}),
796
+ ...(submitDisabled !== undefined ? { submitDisabled } : {}),
797
+ };
798
+ const hasFrom = slot !== 'filter' && hasBehaviorFrom(obj.behavior);
497
799
  return {
498
800
  layout, mode, ...(skeleton ? { skeleton } : {}), ...viewTexts(slot, form, path, diags),
801
+ ...(slotKnobs.emphasis !== undefined ? { emphasis: slotKnobs.emphasis } : {}),
802
+ ...(slotKnobs.surface !== undefined ? { surface: slotKnobs.surface } : {}),
803
+ ...(slotKnobs.highlight === true ? { highlight: true } : {}),
499
804
  ...(Object.keys(formOpts).length > 0 ? { formOpts } : {}),
500
- };
805
+ ...(hasFrom ? { readState: readStatePathsOf(ctx.object) } : {}),
806
+ } as KitViewIR;
501
807
  }
502
808
 
503
809
  /**
@@ -588,6 +894,7 @@ function groupsLayout(form: KitViewForm, env: KitCellEnv, fallbackArrange: KitAr
588
894
  refs.push({ ...item, name: `__divider_g${i}_${dividerSeq++}` });
589
895
  continue;
590
896
  }
897
+ if (slot === 'form' && env.schema[item.name]?.hidden === true) continue;
591
898
  if (seen.has(item.name)) {
592
899
  env.diagnostics.push({ code: 'KIT-OBJ-008', path: `${at}.fields`, message: `字段 ${item.name} 在多节里重复出现` });
593
900
  continue;
@@ -611,13 +918,28 @@ function groupsLayout(form: KitViewForm, env: KitCellEnv, fallbackArrange: KitAr
611
918
  else if (typeof g.divider === 'string') divider = g.divider;
612
919
  else if (g.divider !== false) env.diagnostics.push({ code: 'KIT-OBJ-008', path: `${at}.divider`, message: 'divider 必须是布尔或分隔线文字' });
613
920
  }
921
+ let grpEmphasis: 'primary' | 'normal' | 'subtle' | undefined;
922
+ if (g.emphasis !== undefined) {
923
+ if (g.emphasis === 'primary' || g.emphasis === 'normal' || g.emphasis === 'subtle') grpEmphasis = g.emphasis;
924
+ else env.diagnostics.push({ code: 'KIT-OBJ-008', path: `${at}.emphasis`, message: 'groups[i].emphasis 只许 primary / normal / subtle' });
925
+ }
926
+ let grpSurface: 'card' | 'flush' | 'plain' | undefined;
927
+ if (g.surface !== undefined) {
928
+ if (g.surface === 'card' || g.surface === 'flush' || g.surface === 'plain') grpSurface = g.surface;
929
+ else env.diagnostics.push({ code: 'KIT-OBJ-008', path: `${at}.surface`, message: 'groups[i].surface 只许 card / flush / plain' });
930
+ }
931
+ const grpLayout = arrange(form.arrange ?? fallbackArrange, refs, form, { ...env, path: at });
932
+ const grpExtra = [grpSurface ? resolveSurfaceRecipeClass(grpSurface) : '', grpEmphasis ? resolveContainerEmphasisClass(grpEmphasis) : ''].filter(Boolean).join(' ');
933
+ applyWrapKnobClass(grpLayout, grpExtra);
614
934
  out.push({
615
935
  title: g.title,
616
- layout: arrange(form.arrange ?? fallbackArrange, refs, form, { ...env, path: at }),
936
+ layout: grpLayout,
617
937
  id: `${objectName}__${slot}__g${i}`,
618
938
  collapsible,
619
939
  open,
620
940
  divider,
941
+ ...(grpEmphasis !== undefined ? { emphasis: grpEmphasis } : {}),
942
+ ...(grpSurface !== undefined ? { surface: grpSurface } : {}),
621
943
  });
622
944
  });
623
945
  if (out.length === 0) return null;
@@ -641,15 +963,34 @@ function groupsLayout(form: KitViewForm, env: KitCellEnv, fallbackArrange: KitAr
641
963
  function viewTexts(slot: KitViewSlot, form: KitViewForm, path: string, diags: KitDiagnostic[]): { title?: string; submitLabel?: string } {
642
964
  const out: { title?: string; submitLabel?: string } = {};
643
965
  if (form.title !== undefined) {
644
- if (typeof form.title === 'string') {
966
+ if (slot === 'filter') {
967
+ diags.push({ code: 'KIT-OBJ-007', path: `${path}.title`, message: 'filter 视图不支持 title' });
968
+ } else if (typeof form.title === 'string') {
645
969
  if (slot === 'list' || slot === 'summary') out.title = form.title;
646
970
  } else if (slot !== 'form') {
647
971
  diags.push({ code: 'KIT-OBJ-007', path: `${path}.title`, message: `${slot} 视图的 title 必须是字符串({ create, edit } 只用于 form)` });
972
+ } else if (form.title === null || typeof form.title !== 'object' || Array.isArray(form.title)) {
973
+ diags.push({ code: 'KIT-OBJ-007', path: `${path}.title`, message: 'form 视图的 title 必须是字符串或 { create?, edit? }' });
974
+ } else {
975
+ const tObj = form.title as Record<string, unknown>;
976
+ for (const [k, v] of Object.entries(tObj)) {
977
+ if (k !== 'create' && k !== 'edit') {
978
+ diags.push({ code: 'KIT-OBJ-007', path: `${path}.title.${k}`, message: `form.title 只许 create / edit,未知键 ${k}` });
979
+ } else if (v !== undefined && typeof v !== 'string') {
980
+ diags.push({ code: 'KIT-OBJ-007', path: `${path}.title.${k}`, message: `form.title.${k} 必须是字符串` });
981
+ }
982
+ }
648
983
  }
649
984
  }
650
985
  if (form.submitLabel !== undefined) {
651
986
  if (slot !== 'form') diags.push({ code: 'KIT-OBJ-007', path: `${path}.submitLabel`, message: 'submitLabel 只用于 form 视图' });
652
- else if (typeof form.submitLabel === 'string') out.submitLabel = form.submitLabel;
987
+ else if (typeof form.submitLabel !== 'string') diags.push({ code: 'KIT-OBJ-007', path: `${path}.submitLabel`, message: 'submitLabel 必须是字符串' });
988
+ else out.submitLabel = form.submitLabel;
989
+ }
990
+ // view.form.notify:保存成功提示的字面量文案(业务组件发 NOTIFY 管道时取用,见 form-notify.ts);这里只判写法
991
+ if (form.notify !== undefined) {
992
+ const problem = slot !== 'form' ? 'notify 只用于 form 视图' : formNotifyProblem(form.notify);
993
+ if (problem !== null) diags.push({ code: 'KIT-OBJ-007', path: `${path}.notify`, message: problem });
653
994
  }
654
995
  return out;
655
996
  }
@@ -658,18 +999,46 @@ export function renderObject(obj: KitObject, ctx: KitRenderContext): KitObjectIR
658
999
  const diags: KitDiagnostic[] = [];
659
1000
  const schema = resolveSchema(obj, ctx, diags);
660
1001
 
1002
+ for (const [name, field] of Object.entries(schema)) {
1003
+ checkFieldRules(name, field.rules, `schema.${name}.rules`, diags);
1004
+ }
1005
+ checkEnumOptionsAndEditCompatibility(schema as unknown as Record<string, unknown>, (obj.view ?? {}) as Record<string, unknown>, '', diags);
1006
+
1007
+ const rawBehavior = obj.behavior as unknown as Record<string, unknown>;
1008
+ if (rawBehavior.require_params !== undefined) {
1009
+ diags.push({ code: 'KIT-PAGE-001', path: 'behavior.require_params', message: '未知键 require_params(请改写为 behavior.requireParams)' });
1010
+ }
1011
+ if (rawBehavior.requireParams !== undefined) {
1012
+ if (!Array.isArray(rawBehavior.requireParams)) {
1013
+ diags.push({ code: 'KIT-FORM-004', path: 'behavior.requireParams', message: 'behavior.requireParams 必须是非空字符串数组' });
1014
+ } else {
1015
+ const knownParams = new Set<string>(Object.keys(obj.behavior.params ?? {}));
1016
+ for (const f of fieldNamesOf(obj.view?.filter?.fields)) knownParams.add(f);
1017
+ if (obj.view?.list !== undefined) {
1018
+ knownParams.add('page');
1019
+ knownParams.add('size');
1020
+ knownParams.add('sort');
1021
+ knownParams.add('order');
1022
+ }
1023
+ rawBehavior.requireParams.forEach((k, i) => {
1024
+ if (typeof k !== 'string' || k.trim() === '' || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {
1025
+ diags.push({ code: 'KIT-FORM-004', path: `behavior.requireParams[${i}]`, message: `behavior.requireParams[${i}] 必须是合法的参数名标识符` });
1026
+ } else if (!knownParams.has(k)) {
1027
+ diags.push({ code: 'KIT-FORM-004', path: `behavior.requireParams[${i}]`, message: `behavior.requireParams 的参数 "${k}" 不在该对象的请求参数(params / 筛选 / 分页 / 排序)中` });
1028
+ }
1029
+ });
1030
+ }
1031
+ }
1032
+
661
1033
  (obj.behavior.actions ?? []).forEach((a, i) => {
662
1034
  if (Array.isArray(a.permission)) {
663
1035
  diags.push({ code: 'KIT-OBJ-006', path: `behavior.actions[${i}].permission`, message: `动作 ${a.id} 的 permission 是数组,kit 层只允许一个权限码` });
664
1036
  }
665
- // 后续链 then 与行操作条件 when(M 波 G3 D1 / D2):写法在这里统一核;emitEvents 只管展开
666
- if (a.then !== undefined) normalizeThen(a.then, `behavior.actions[${i}].then`, diags);
667
- if (a.when !== undefined) {
668
- if (a.on !== 'row') {
669
- diags.push({ code: 'KIT-FORM-001', path: `behavior.actions[${i}].when`, message: `动作 ${a.id} 的 when 只用于 on: row 的行操作` });
670
- } else {
671
- predicateToCore(a.when, `behavior.actions[${i}].when`, new Set(Object.keys(schema)), diags);
672
- }
1037
+ if (a.tone !== undefined && (typeof a.tone !== 'string' || !KIT_ACTION_TONES.includes(a.tone))) {
1038
+ diags.push({ code: 'KIT-ACT-010', path: `behavior.actions[${i}].tone`, message: `动作 ${a.id} 的 tone "${String(a.tone)}" 不在闭集(允许:${KIT_ACTION_TONES.join(' / ')})` });
1039
+ }
1040
+ if (a.request !== undefined || a.download !== undefined) {
1041
+ validateRequestAction(a, `behavior.actions[${i}]`, diags);
673
1042
  }
674
1043
  });
675
1044
 
@@ -681,17 +1050,15 @@ export function renderObject(obj: KitObject, ctx: KitRenderContext): KitObjectIR
681
1050
 
682
1051
  const views: KitObjectIR['views'] = {};
683
1052
  const declared = obj.view ?? {};
684
- // GB2 / GB3 / GB6:字段 default / hidden / derive 的写法在这里统一核(每个对象一次)
1053
+ // GB2 / GB3:字段 default / hidden 的写法在这里统一核(每个对象一次)
685
1054
  const formDecl = declared.form;
686
1055
  const rawGroups: unknown[] = Array.isArray(formDecl?.groups) ? (formDecl?.groups as unknown[]) : [];
687
1056
  const groupFieldNames = rawGroups.flatMap((g) => (
688
- g !== null && typeof g === 'object' && Array.isArray((g as { fields?: unknown }).fields)
689
- ? ((g as { fields: unknown[] }).fields).flatMap((f) => (typeof f === 'string' ? [f] : []))
690
- : []));
1057
+ g !== null && typeof g === 'object' ? fieldNamesOf((g as { fields?: unknown }).fields) : []));
691
1058
  const fieldValue = collectFieldValues(schema, formDecl?.fields, groupFieldNames, diags);
692
1059
  checkFlowFields(schema, diags);
693
- checkViewRowColumns(declared as Record<string, unknown>, diags, schema);
694
- checkViewFlowNodeOptions(declared as Record<string, unknown>, schema, diags);
1060
+ checkViewRowColumns(declared as Record<string, unknown>, diags);
1061
+ checkViewFlowNodeOptions(declared as Record<string, unknown>, diags);
695
1062
  for (const key of Object.keys(declared)) {
696
1063
  if (!(KIT_VIEW_SLOTS as readonly string[]).includes(key)) {
697
1064
  diags.push({