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
@@ -1,3 +1,5 @@
1
+ import { esc } from '../shared/escape';
2
+ import { getCompileEnvelope } from '../shared/envelope';
1
3
  // emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
2
4
  //
3
5
  // 两种发射:
@@ -8,24 +10,32 @@
8
10
  //
9
11
  // 绑定约定:行变量按对象取 `kit_row_<对象>`;单对象路径默认 `page.data.<对象>`;列表对象带 `into: result`,
10
12
  // 行数组在 `page.data.<对象>.<listShape.rows>`、总数在 `...<listShape.total>`(compile-data 保证)。
11
- // prop 值规则(core resolvePropValue):字符串首段是已注册变量才算绑定路径,否则是字面量;以 `!` 开头的字符串会被当取反,
12
- // 所以字面量文案不得以 `!` 开头(emitStatic 对这类值报 KIT-STYLE-001 之外的预警诊断,不改值)。
13
+ // prop 值规则(core resolvePropValue):字符串首段是已注册变量才算绑定路径,否则是字面量;
14
+ // `!path` 取反写法已删除,kit 绑定路径一律是纯路径(取反另给成员),以 `!` 开头的普通文案原样显示。
13
15
 
16
+ import { checkRowPath, checkViewPath, classifyDisabledReason, isRowPath, isViewPath, KIT_ACTION_REASON_KEY, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
14
17
  import type {
15
- KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitPollDecl, KitSchema, KitViewSlot,
18
+ KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
16
19
  } from './types';
17
20
  import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
18
- import type { KitSkeletonConfig } from './skeleton';
21
+ import type { KitSkeletonCol, KitSkeletonConfig } from './skeleton';
22
+ import { isNumericColumnType } from './collection-table';
23
+ import { mergeClass } from './merge-class';
24
+ import { KIT_FILTER_INLINE_CLASS } from './parts';
25
+ import { kitTextActionRecipe } from '../recipes/control';
26
+ import { KIT_OVERLAY_FORM_HOST_CLASS } from '../recipes/overlay';
27
+ import { KIT_PANEL_TITLE_CLASS, kitPanelTitleHtml } from '../recipes/title-row';
19
28
  import { headAnchor } from './compile-data';
20
29
  import { KIT_STATE_DEFAULT_TEXT } from './collection';
21
30
  import { kitText } from '../i18n/kit-text';
22
- import { predicateToCore } from './linkage';
23
- import { actionGateOf } from './action-gate';
31
+ import { KIT_TIPS_SCOPE_ATTR, kitHelpButtonHtml } from '../base/hint-tips';
24
32
  import { expandHostId } from './collection-expand';
25
33
  import { busyActionOf } from '../base/action-busy';
26
- import { gateLeafFields } from '../base/action-gate';
27
34
  import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
28
- import type { KitFormDetail } from './form-detail';
35
+ import { KIT_PART_CARD, KIT_PART_SECTION, KIT_PART_TITLE_SECTION, kitContainerPartOf, type KitFormDetail } from './form-detail';
36
+ import { KIT_PART_TABLE, KIT_PART_TABLE_CELL, KIT_PART_TABLE_HEAD, KIT_PART_TABLE_ROW } from './collection-table';
37
+ import { readStatePathsOf } from './crud-bridge';
38
+ import { primaryKeyFieldOf } from './key-field';
29
39
 
30
40
  /** 行变量按对象取(`kit_row_<对象>`):core 的 varMap 按变量名建,同页两个列表共用一个名字会撞 */
31
41
  export function rowVarOf(object: string): string { return `kit_row_${object}`; }
@@ -44,6 +54,16 @@ export function selAnchor(object: string): string { return `${object}__list__sel
44
54
  export function pagerAnchorOf(object: string): string { return `${object}__pager`; }
45
55
  /** 可排序表头实例(view 切片 sort / order 的写者) */
46
56
  export function headAnchorOf(object: string): string { return headAnchor(object); }
57
+ /** 行样式档位:rowTone 的行字段编成 core 行路径(KitTableActions 读到档位名后给所在行容器加闭集类串) */
58
+ function rowToneProp(layout: { rowTone?: string }, ctx: Ctx): { rowTone?: string } {
59
+ return layout.rowTone !== undefined ? { rowTone: `${ctx.rowVar}.${layout.rowTone}` } : {};
60
+ }
61
+
62
+ /** 树表 / 虚拟滚动表自己画行(拿到整行对象):只传行字段名(不是 core 路径),组件按行取值映射档位类 */
63
+ function rowToneFieldProp(layout: { rowTone?: string }): { rowToneField?: string } {
64
+ return layout.rowTone !== undefined ? { rowToneField: layout.rowTone } : {};
65
+ }
66
+
47
67
  /** 展开行:开合按钮实例(每行一个 KitTableActions expand) */
48
68
  export function treeAnchor(object: string): string { return `${object}__list__tree`; }
49
69
  /** 虚拟滚动表体 KitVirtualRows 实例(N3) */
@@ -53,6 +73,8 @@ export function expandToggleAnchor(object: string): string { return `${object}__
53
73
  export function expandCellAnchor(object: string, field: string): string { return `${object}__list__x__${field}`; }
54
74
  /** 集合三态面板实例 */
55
75
  export function stateAnchor(object: string): string { return `${object}__list__state`; }
76
+ /** 标题旁的集合辅助文字(共 N 条 / 已筛选提示):KitCollectionState 的 meta 形态实例 */
77
+ export function metaAnchor(object: string): string { return `${object}__list__meta`; }
56
78
  export function toolbarAnchor(object: string, actionId: string): string { return `${object}__tb_${actionId}`; }
57
79
  /** 表格工具与接线件(工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐),紧挨在表格外壳之前 */
58
80
  export function toolsAnchor(object: string): string { return `${object}__list__tools`; }
@@ -88,6 +110,8 @@ export interface KitStaticOptions {
88
110
  * KitTableActions(选择态存在协调组件的 focus 切片里);不给保持存量的惰性 Checkbox
89
111
  */
90
112
  selectedPath?: string;
113
+ /** 行删除在途置灰读的协调组件作用域;忙闲通道名 = 作用域 + 行主键,必须与 KitCrudBridge 的 scope 一致;缺省用本对象作用域(standard-crud 两者相同) */
114
+ removeScope?: string;
91
115
  /** 展开子表(Q 波 G5):协调组件 focus 切片 expandId 镜像的路径;给了,list 形展开的开关才读它判断本行是否展开 */
92
116
  expandPath?: string;
93
117
  /** behavior.validateOn(已校验):KitObjectForm 在 change / blur 时即时校验 */
@@ -112,23 +136,45 @@ export interface KitStaticEmit {
112
136
 
113
137
  // ---------------------------------------------------------------- 小工具
114
138
 
115
- function esc(text: string): string {
116
- return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
117
- }
118
-
119
139
  function attr(name: string, value: string): string {
120
140
  return value === '' ? '' : ` ${name}="${esc(value)}"`;
121
141
  }
122
142
 
143
+ const OVERLAY_FOOTER_HOSTS: ReadonlySet<string> = new Set(['KitObjectForm', 'Transfer', 'PermissionTree', 'AssignmentPicker']);
144
+ const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitCollectionState', 'Pager']);
145
+
123
146
  function host(component: string, id: string): string {
124
- return `<div data-soma-component="${esc(component)}" data-soma-id="${esc(id)}"></div>`;
147
+ // 自带底栏的表单 / 穿梭框 / 授权树,其宿主在浮层滚动体里是体的 flex 子项并撑满体高(底栏才能落在浮层底部);变体只在 group-data-kit-overlay-scroll 祖先下生效
148
+ // 根常带 hidden 的辅助宿主(表格工具位 / 三态面板 / 分页器):宿主 display: contents,不占 flex 子项的位——
149
+ // 否则它们空着时(0 高)仍被卡片的 flex gap 各多量出 12px(表格面板顶部的「空工具栏行」、底部多出的空白)
150
+ const cls = OVERLAY_FOOTER_HOSTS.has(component) ? ` class="${KIT_OVERLAY_FORM_HOST_CLASS}"` : COLLAPSING_HOSTS.has(component) ? ' class="contents"' : '';
151
+ return `<div data-soma-component="${esc(component)}" data-soma-id="${esc(id)}"${cls}></div>`;
125
152
  }
126
153
 
127
154
  const opsHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_ops', undefined, ctx.options.locale ?? '');
128
155
  const selectHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_select', undefined, ctx.options.locale ?? '');
129
156
  const cellRoleAttr = (role: string): string => (role === '' ? '' : ` role="${role}"`);
130
157
  /** 视图标题行(K-4):语义色名 + utilityScales 里有的尺度 */
131
- const VIEW_TITLE_CLASS = 'text-base font-semibold text-fg';
158
+
159
+ /** 显式 `bordered: true`(完整网格线)的表格外壳标 data-kit-grid:主题结构 CSS 只对没有这个标记的表壳去掉容器卡片外观(圆角 / 边框 / 阴影 / 底色) */
160
+ function gridMark(layout: { bordered?: boolean }): string {
161
+ return layout.bordered === true ? ' data-kit-grid=""' : '';
162
+ }
163
+
164
+ /** 树表「全部展开 / 全部收起」:文字链接形态,放在表格工具位(与刷新同一行、标题行右侧);点击由 KitTreeTable 按 data-kit-tree-for 认领 */
165
+ function renderTreeControls(ctx: Ctx): string {
166
+ const locale = ctx.options.locale ?? '';
167
+ const cls = kitTextActionRecipe('primary');
168
+ const one = (act: 'expand' | 'collapse', key: 'soma.kit.expand_all' | 'soma.kit.collapse_all'): string =>
169
+ `<button type="button" data-kit-tree-ctl="${act}" data-kit-tree-for="${esc(ctx.object)}"${attr('class', cls)}>${esc(kitText(key, undefined, locale))}</button>`;
170
+ return `${one('expand', 'soma.kit.expand_all')}${one('collapse', 'soma.kit.collapse_all')}`;
171
+ }
172
+
173
+ /** 去掉栅格跨度类(`col-span-N` 与各容器档变体),换成流式版式的宽度类 */
174
+ function swapSpanForWidth(cellClass: string, widthClass: string): string {
175
+ const kept = cellClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?col-span-\d+$/.test(t));
176
+ return [...kept, widthClass, 'min-w-0'].filter((t) => t !== '').join(' ');
177
+ }
132
178
 
133
179
  function joinClasses(a: string, b: string): string {
134
180
  return [a, b].filter((s) => s !== '').join(' ');
@@ -140,6 +186,13 @@ function selectedProps(ctx: Ctx): Record<string, unknown> {
140
186
  return { selected: ctx.options.selectedPath, keyField: keysOf(ctx.options.schema)[0] ?? '' };
141
187
  }
142
188
 
189
+ /** 行操作组件读「本行删除在途」:协调组件按作用域 + 行主键经忙闲通道登记,这里只给出作用域与主键字段名(作用域空则不绑) */
190
+ function removeBusyProps(ctx: Ctx): Record<string, unknown> {
191
+ // 作用域取 options.removeScope(业务组件成员传协调组件的 link 作用域),缺省本对象作用域;主键规则与协调组件同一份实现
192
+ const scope = ctx.options.removeScope ?? ctx.scope();
193
+ return scope === '' ? {} : { removeScope: scope, removeObject: ctx.object, removeKeyField: primaryKeyFieldOf(ctx.options.schema) ?? '' };
194
+ }
195
+
143
196
  interface Ctx {
144
197
  object: string;
145
198
  options: KitStaticOptions;
@@ -153,40 +206,35 @@ interface Ctx {
153
206
  /** 列表对象整体路径(page.data.<对象>),三态面板据此判定 */
154
207
  basePath: string;
155
208
  scope(): string;
209
+ /** 筛选栏(非写死形状)的宿主锚点:集合的「清除筛选」优先点它的「重置」;本对象没有筛选栏为 undefined */
210
+ filterId?: string;
211
+ /** 表头筛选写进 view 切片的键(列表是带表头筛选的表格时非空) */
212
+ columnParams?: string[];
156
213
  }
157
214
 
158
- /** 列表响应里错误文案的缺省路径(listShape.errorPath 可改) */
159
- export const KIT_LIST_ERROR_PATH = 'result.error';
160
-
161
215
  /**
162
- * core 的 prop 求值没有字面量转义:字符串以 `!` 开头一律当取反绑定,文案会静默错显。
163
- * 排查口径统一在 emitStatic 收尾:扫描整张 show 里所有 props(含嵌套对象 / 数组),任何以 `!` 开头的字符串报诊断,提示改写。
216
+ * 集合标题旁的辅助文字(KitCollectionState meta 形态)计划:
217
+ * - count:有标题行的非分页集合(table / cards / stack,树表不算)自动显示「共 N 条」(分页集合由分页器显示总数,不重复);
218
+ * `collection.count: false` 关闭;
219
+ * - hint:本对象有筛选栏(非写死形状)或表头筛选时,被筛选状态下显示「已筛选 · N 项条件 清除」。
220
+ * 都不需要返回 null(不发射实例)。emitStatic 与 emitEvents 共用这一份判定,事件键与实例锚点才对得上。
164
221
  */
165
- function warnBang(diagnostics: KitDiagnostic[], value: unknown, at: string): void {
166
- if (typeof value === 'string') {
167
- if (value.startsWith('!')) {
168
- diagnostics.push({
169
- code: 'KIT-STYLE-001',
170
- message: `文案 ${JSON.stringify(value)} 以 ! 开头,core 会把它当成取反绑定而不是字面量;请改写(如去掉开头的 ! 或前置一个字符)`,
171
- path: at,
172
- });
173
- }
174
- } else if (Array.isArray(value)) {
175
- value.forEach((v, i) => warnBang(diagnostics, v, `${at}[${i}]`));
176
- } else if (value !== null && typeof value === 'object') {
177
- for (const [k, v] of Object.entries(value)) warnBang(diagnostics, v, `${at}.${k}`);
178
- }
222
+ export function collectionMetaOf(ir: KitObjectIR): { count: boolean; hint: boolean } | null {
223
+ const list = ir.views.list;
224
+ if (list === undefined) return null;
225
+ const l = list.layout;
226
+ if (l.kind !== 'table' && l.kind !== 'cards' && l.kind !== 'stack') return null;
227
+ if (l.kind === 'table' && l.tree !== null) return null;
228
+ const titled = typeof list.title === 'string' && list.title !== '';
229
+ const count = titled && l.pager === null && l.showCount !== false;
230
+ const hasFilterForm = ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static';
231
+ const hasColumnFilter = l.kind === 'table' && l.head.some((h) => h.filter !== undefined);
232
+ const hint = hasFilterForm || hasColumnFilter;
233
+ return count || hint ? { count, hint } : null;
179
234
  }
180
235
 
181
- /** 遍历 show 树:每个锚点的 props 全量查 `!` 开头字面量;嵌套的行级 show 递归 */
182
- export function scanShowForBang(diagnostics: KitDiagnostic[], show: Record<string, unknown>, at: string): void {
183
- for (const [anchor, node] of Object.entries(show)) {
184
- if (node === null || typeof node !== 'object') continue;
185
- const n = node as { props?: unknown; show?: unknown };
186
- if (n.props !== undefined) warnBang(diagnostics, n.props, `${at}.${anchor}.props`);
187
- if (n.show !== null && typeof n.show === 'object') scanShowForBang(diagnostics, n.show as Record<string, unknown>, `${at}.${anchor}.show`);
188
- }
189
- }
236
+ /** 列表响应里错误文案的缺省路径(listShape.errorPath 可改) */
237
+ export const KIT_LIST_ERROR_PATH = 'result.error';
190
238
 
191
239
  /** 只读单元内无自身文本标签的交互控件:未显式传 aria_label 时补字段名 */
192
240
  const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
@@ -194,10 +242,11 @@ const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
194
242
  ]);
195
243
 
196
244
  /** 单元的 props:字段值绑定 + IR 里的 props + 值类 */
197
- function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, at: string): Record<string, unknown> {
245
+ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Record<string, unknown> {
198
246
  const props: Record<string, unknown> = { value: valuePath };
199
- void at;
200
247
  for (const [k, v] of Object.entries(cell.props)) props[k] = v;
248
+ // 字段项 props 绑 row.<字段>(RV-1119):行模板里 core 逐行求值(行变量.<字段>),业务对象逐行给值,页面不算
249
+ for (const [k, field] of Object.entries(cell.rowProps ?? {})) props[k] = `${ctx.rowVar}.${field}`;
201
250
  if (LABELLED_CELL_CONTROLS.has(cell.component) && props.aria_label === undefined && Boolean(cell.label)) {
202
251
  props.aria_label = cell.label;
203
252
  }
@@ -209,6 +258,9 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, at: string): Reco
209
258
 
210
259
  type IdOf = (field: string) => string;
211
260
 
261
+ /** 类串里有 truncate(含变体前缀与 `**:truncate` 这类后代选择写法):这类格的文字可能被截断 */
262
+ const TRUNCATING_CLASS_RE = /(?:^|\s)(?:[a-z0-9*@-]+:)*truncate(?=\s|$)/;
263
+
212
264
  function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string, at: string, showInto: Record<string, unknown>, idOf?: IdOf): string {
213
265
  if (cell.placeholder === true || cell.component === '') {
214
266
  return `<div${attr('class', cell.cellClass)}></div>`;
@@ -217,23 +269,20 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
217
269
  ctx.components.add(cell.component);
218
270
  showInto[id] = { props: cellProps(ctx, cell, valuePath, at) };
219
271
  const star = cell.required === undefined ? '' : `<span${attr('class', KIT_REQUIRED_STAR_CLASS[cell.required])} aria-hidden="true">*</span>`;
220
- const label = !cell.label ? '' : `<span${attr('class', cell.labelClass)}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}</span>`;
272
+ // 只读格的字段说明(J9):标签旁一个「i」图标钮(没有 help 的格不出节点);气泡由 base/hint-tips 的委托在悬停 / 聚焦时才建
273
+ const helpBtn = !cell.label ? '' : kitHelpButtonHtml(cell.helpTip ?? '', cell.label, ctx.options.locale ?? '');
274
+ const label = !cell.label ? '' : `<span${attr('class', cell.labelClass)}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}${helpBtn}</span>`;
275
+ // 值可能被截断(格 / 值类里带 truncate)的格标出提示作用范围,截断了才有全文提示(J10);不截断的格输出不变
276
+ const truncating = TRUNCATING_CLASS_RE.test(`${cell.cellClass} ${cell.valueClass}`);
277
+ const cellExtraAttrs = `${cell.emphasis !== undefined ? ` data-kit-emphasis="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ' data-kit-highlight="true"' : ''}${cell.overflow === true ? ' data-kit-filter-overflow="true"' : ''}${truncating ? ` ${KIT_TIPS_SCOPE_ATTR}=""` : ''}`;
221
278
  // summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
222
- // 只读视图 showWhen:Show 对象谓词 when,条件字段取同一对象的路径前缀
223
- if (cell.showWhen !== undefined && cell.hideEmpty !== true) {
224
- const cellId = `${id}__cell`;
225
- const prefix = valuePath.endsWith(`.${cell.field}`) ? valuePath.slice(0, -cell.field.length) : '';
226
- const w = cell.showWhen as { field: string };
227
- showInto[cellId] = { when: { ...cell.showWhen, field: `${prefix}${w.field}` } };
228
- return `<div data-soma-id="${esc(cellId)}"${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
229
- }
230
279
  if (cell.hideEmpty === true) {
231
280
  const cellId = `${id}__cell`;
232
- // present:0 / false 算有值,所以数字 / 布尔字段也能 hideEmpty
233
- showInto[cellId] = { when: { field: valuePath, op: 'present' } };
234
- return `<div data-soma-id="${esc(cellId)}"${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
281
+ // 纯路径绑定(不发射对象形 when);数字 / 布尔字段由 buildCell 拒收
282
+ showInto[cellId] = { when: valuePath };
283
+ return `<div data-soma-id="${esc(cellId)}"${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
235
284
  }
236
- return `<div${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
285
+ return `<div${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
237
286
  }
238
287
 
239
288
  /** 表格行里的列单元:无 label,只有值组件 */
@@ -242,10 +291,11 @@ function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string
242
291
  ctx.components.add(cell.component);
243
292
  showInto[id] = { props: cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at) };
244
293
  // KitTableTools 按这些标记接管:列显隐(data-kit-col)、省略 title、就地编辑
294
+ const cellKnobAttrs = `${cell.emphasis !== undefined ? ` data-kit-emphasis="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ' data-kit-highlight="true"' : ''}`;
245
295
  const marks = marked
246
296
  ? ` data-kit-col="${esc(cell.field)}"${cell.ellipsis === true ? ' data-kit-ellipsis=""' : ''}${cell.editable === true ? ' data-kit-editable=""' : ''}`
247
297
  : '';
248
- return `<div${marks}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)}>${host(cell.component, id)}</div>`;
298
+ return `<div${marks}${cellKnobAttrs}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)} data-kit-part="${KIT_PART_TABLE_CELL}">${host(cell.component, id)}</div>`;
249
299
  }
250
300
 
251
301
  // ---------------------------------------------------------------- 排布
@@ -280,8 +330,10 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
280
330
  showInto[did] = { props: g.divider === '' ? {} : { label: g.divider } };
281
331
  divider = host('KitDivider', did);
282
332
  }
333
+ const grpPart = g.surface !== undefined ? kitContainerPartOf(g.surface) : KIT_PART_SECTION;
334
+ const grpAttrs = `${g.surface !== undefined ? ` data-kit-surface="${esc(g.surface)}"` : ''}${g.emphasis !== undefined ? ` data-kit-emphasis="${esc(g.emphasis)}"` : ''} data-kit-part="${esc(grpPart)}"`;
283
335
  if (!g.collapsible) {
284
- return `${divider}<section${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)}>${esc(g.title)}</h4>${inner}</section>`;
336
+ return `${divider}<section${grpAttrs}${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)} data-kit-part="${KIT_PART_TITLE_SECTION}">${esc(g.title)}</h4>${inner}</section>`;
285
337
  }
286
338
  // 可折叠:标题是 h4 里的 button(aria-expanded + aria-controls),折叠体是块级 div(hidden 不和 flex / grid 同元素),初态按 open 写好
287
339
  const btn = `<button type="button" id="${esc(g.id)}__btn"${attr('class', KIT_CLASS_DEFAULTS.groupToggle)} data-kit-collapse-toggle="" aria-expanded="${g.open ? 'true' : 'false'}" aria-controls="${esc(g.id)}">`
@@ -289,7 +341,7 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
289
341
  + `<span${attr('class', KIT_CLASS_DEFAULTS.groupMark)} aria-hidden="true" data-kit-collapse-mark="" data-kit-mark-open="${markers[1]}" data-kit-mark-closed="${markers[0]}">${g.open ? markers[1] : markers[0]}</span>`
290
342
  + '</button>';
291
343
  const body = `<div id="${esc(g.id)}" role="region" aria-labelledby="${esc(g.id)}__btn"${attr('class', g.open ? '' : 'hidden')}>${inner}</div>`;
292
- return `${divider}<section${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)}>${btn}</h4>${body}</section>`;
344
+ return `${divider}<section${grpAttrs}${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)} data-kit-part="${KIT_PART_TITLE_SECTION}">${btn}</h4>${body}</section>`;
293
345
  }).join('');
294
346
  const wrap = `<div${attr('class', layout.wrapClass)}${layout.collapsible ? ' data-kit-collapse-root=""' : ''}>${sections}</div>`;
295
347
  if (!layout.collapsible) return wrap;
@@ -316,7 +368,7 @@ const GROUPS_AS = KIT_GRAMMAR.formLinkage.groupsAs as { barClass: string; tabCla
316
368
 
317
369
  /**
318
370
  * groups 呈现为页签:tablist + 若干 tab 按钮 + 各组面板(首签显示,其余外层 hidden)。
319
- * 显隐走 core 原生 UI_INTERACT(事件在 emitEvents),ARIA 与 ←/→/Home/End 由 KitTabsWiring(同 tabs-frame)补;
371
+ * 没有事件声明:面板显隐、ARIA 与 ←/→/Home/End 都由 KitTabsWiring(同 tabs-frame)在组件内完成;
320
372
  * 外层 data-kit-tabs-frame 让接线件只在本块内查锚点。hidden 只放在面板外层,不和 flex / grid 同元素。
321
373
  */
322
374
  function renderGroupTabs(
@@ -356,7 +408,7 @@ export function groupTabsFrame(
356
408
  showInto: Record<string, unknown>,
357
409
  components: Set<string>,
358
410
  ): string {
359
- const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}"${attr('class', GROUPS_AS.tabClass)}>${esc(title)}</button>`).join('');
411
+ const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" data-kit-face="tab" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}"${attr('class', GROUPS_AS.tabClass)}>${esc(title)}</button>`).join('');
360
412
  const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}"${i === 0 ? '' : ' hidden'}>${inner}</div>`).join('');
361
413
  const wireId = groupTabWireAnchor(object, slot);
362
414
  components.add('KitTabsWiring');
@@ -373,22 +425,9 @@ export function groupTabsFrame(
373
425
  return `<div data-kit-tabs-frame=""${attr('class', wrapClass)}>${bar}${wiring}${panelEls}</div>`;
374
426
  }
375
427
 
376
- /** 页签点击事件(点页签 = 关别的面板、开本面板);与 groupsAs 共用,emit-events 与 RecordDetail 都用它 */
377
- export function groupTabEvents(object: string, slot: KitViewSlot, n: number): Record<string, unknown> {
378
- const events: Record<string, unknown> = {};
379
- for (let i = 0; i < n; i += 1) {
380
- events[`${groupTabAnchor(object, slot, i)}.click`] = {
381
- steps: Array.from({ length: n }, (_x, j) => ({ do: `UI_INTERACT | ${groupPanelAnchor(object, slot, j)} | | ${j === i ? 'open' : 'close'}` })),
382
- };
383
- }
384
- return events;
385
- }
386
-
387
428
  // ---------------------------------------------------------------- list
388
429
 
389
430
  function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<string, unknown>> {
390
- // 按行分槽的 outcome 条件按主键读本行那一份:带状态条件的动作项附上主键字段名(gateKey)
391
- const gateKey = keysOf(ctx.options.schema)[0] ?? '';
392
431
  return actions.map((a) => ({
393
432
  id: a.id,
394
433
  name: a.name,
@@ -397,18 +436,61 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
397
436
  ...(a.targetOverlay !== undefined ? { target: a.targetOverlay } : {}),
398
437
  // K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
399
438
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
400
- // 行操作条件(core 谓词形,字段是行字段):按钮组件可据此隐藏;执行前置已编进 steps,点不到也不会执行
401
- ...(a.when !== undefined ? whenItem(a) : {}),
402
439
  ...(a.more === true ? { more: true } : {}),
403
- // GA2:状态条件(core 谓词;叶子是行字段或 outcome.<名>.…,运行期由 KitTableActions / 右键菜单求值)
404
- ...actionGateOf(a),
405
- ...(gateKey !== '' && Object.keys(actionGateOf(a)).length > 0 ? { gateKey } : {}),
440
+ // 置灰原因的字面量文案(只有写了 disabled 的动作才有意义);row. / view. 路径形走 actionState 的叶子,不进这里
441
+ ...(a.disabled !== undefined ? literalReason(a) : {}),
406
442
  }));
407
443
  }
408
444
 
409
- function whenItem(a: KitAction): { when?: Record<string, unknown> } {
410
- const core = predicateToCore(a.when, 'when', null, []);
411
- return core === null ? {} : { when: core };
445
+ /** 动作的置灰原因:字面量文案(非空)原样带;路径形与非法值不带(路径进 actionState,非法值已在入口记诊断) */
446
+ function literalReason(a: KitAction): { disabledReason?: string } {
447
+ const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
448
+ return source.kind === 'literal' && source.text.trim() !== '' ? { disabledReason: source.text } : {};
449
+ }
450
+
451
+ /**
452
+ * 行动作的行级状态绑定:on: row 动作的 hidden / disabled(row.<字段>,业务对象逐行给出)编成
453
+ * { 动作id: { hidden?, disabled? } },叶子是 core 行路径(行变量.<字段>),由 core 在行模板里逐行求值。
454
+ * 返回要并进 prop 的 { actionState };没有绑定返回空对象。非法写法已在 emitStatic 入口记过诊断,这里只收合法的。
455
+ */
456
+ function actionStateProp(actions: readonly KitAction[], ctx: Ctx): { actionState?: Record<string, Record<string, string>> } {
457
+ const state: Record<string, Record<string, string>> = {};
458
+ for (const a of actions) {
459
+ if (a.on !== 'row') continue;
460
+ for (const key of KIT_ROW_ACTION_KEYS) {
461
+ const raw = a[key];
462
+ if (isRowPath(raw)) (state[a.id] ??= {})[key] = rowPathToCore(raw, ctx.rowVar);
463
+ // 行动作也可以绑展示对象成员(view.<成员>,编成页面变量 page.<成员>,行模板里 core 逐行求值同一个值),与 row.<字段> 二选一
464
+ else if (isViewPath(raw)) (state[a.id] ??= {})[key] = viewPathToCore(raw);
465
+ }
466
+ // 置灰原因:row.<字段> / view.<成员> 编成同一个叶子(core 逐行求值成文案);字面量走 actionItems 的 disabledReason
467
+ if (a.disabled !== undefined) {
468
+ const reason = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
469
+ if (reason.kind === 'row') (state[a.id] ??= {})[KIT_ACTION_REASON_KEY] = rowPathToCore(reason.path, ctx.rowVar);
470
+ else if (reason.kind === 'view') (state[a.id] ??= {})[KIT_ACTION_REASON_KEY] = viewPathToCore(reason.path);
471
+ }
472
+ }
473
+ return Object.keys(state).length > 0 ? { actionState: state } : {};
474
+ }
475
+
476
+ /** treeTable / 虚拟滚动表的列单元由组件自己按行渲染,字段项 props 的 row.<字段> 没有行模板可绑:写了记 KIT-ROW-002(不静默失效) */
477
+ function rejectRowProps(cells: readonly KitCell[], ctx: Ctx, where: string): void {
478
+ for (const c of cells) {
479
+ for (const k of Object.keys(c.rowProps ?? {})) {
480
+ ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `views.list.${c.field}.props.${k}`, message: `${where}的列单元不支持字段项 props 绑 row.<字段>(字段 ${c.field} 的 props.${k});用普通表格 / cards / stack,或让接口逐行给成品字段后直接作为列` });
481
+ }
482
+ }
483
+ }
484
+
485
+ /** treeTable / 虚拟滚动表的行操作与右键菜单不支持行级状态绑定:写了记 KIT-ROW-002(动作照常渲染,绑定被忽略) */
486
+ function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string): void {
487
+ for (const a of actions) {
488
+ for (const key of [...KIT_ROW_ACTION_KEYS, KIT_ACTION_REASON_KEY]) {
489
+ if (a.on === 'row' && a[key] !== undefined) {
490
+ ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `behavior.actions.${a.id}.${key}`, message: `${where}的行操作 / 右键菜单不支持行级状态绑定(动作 ${a.id} 的 ${key})` });
491
+ }
492
+ }
493
+ }
412
494
  }
413
495
 
414
496
  function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>): string {
@@ -437,6 +519,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
437
519
  ...(h.filter !== undefined ? { filter: h.filter } : {}),
438
520
  ...(h.group !== undefined ? { group: h.group } : {}),
439
521
  ...(tools && h.resizable === true ? { resizable: true } : {}),
522
+ ...(h.help !== undefined ? { help: h.help } : {}),
440
523
  });
441
524
  }
442
525
  if (layout.rowActions.length > 0) cells.push({ label: opsHeadLabel(ctx), class: actHead });
@@ -444,6 +527,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
444
527
  ctx.show[headAnchor(object)] = {
445
528
  props: {
446
529
  cells, scope: ctx.scope(), class: layout.headClass, ...(semTable ? { semantics: 'table' } : {}),
530
+ // 读状态:点表头排序后重取失败,表头据此把 sort / order / page 回滚到最近一次读成功的值
531
+ readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
447
532
  ...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
448
533
  },
449
534
  };
@@ -466,7 +551,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
466
551
  };
467
552
  for (const h of layout.head) {
468
553
  if (h.group !== openGroup) flushGroup();
469
- const leaf = `<div${headRole}${tools && h.col !== undefined ? ` data-kit-col="${esc(h.col)}"` : ''}${tools && h.resizable === true ? ' data-kit-resizable=""' : ''}${attr('class', h.class)}>${esc(h.label)}</div>`;
554
+ const leaf = `<div${headRole}${tools && h.col !== undefined ? ` data-kit-col="${esc(h.col)}"` : ''}${tools && h.resizable === true ? ' data-kit-resizable=""' : ''}${attr('class', h.class)}>${esc(h.label)}${kitHelpButtonHtml(h.help ?? '', h.label, ctx.options.locale ?? '')}</div>`;
470
555
  if (h.group === undefined) headParts.push(leaf);
471
556
  else {
472
557
  openGroup = h.group;
@@ -475,12 +560,14 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
475
560
  }
476
561
  flushGroup();
477
562
  if (layout.rowActions.length > 0) headParts.push(`<div${headRole}${attr('class', actHead)}>${esc(opsHeadLabel(ctx))}</div>`);
478
- head = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.headClass)}>${headParts.join('')}</div>`;
563
+ head = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.headClass)} data-kit-part="${KIT_PART_TABLE_HEAD}">${headParts.join('')}</div>`;
479
564
  }
480
565
 
481
566
  // 树表:列 / 表头 / 三态 / 分页与普通表格同一条路径,只有表体换成 KitTreeTable(层级 + 展开状态在组件里)
482
567
  if (layout.tree !== null) {
483
568
  const id = treeAnchor(object);
569
+ rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, 'treeTable');
570
+ rejectRowProps(layout.cells, ctx, 'treeTable');
484
571
  ctx.components.add('KitTreeTable');
485
572
  ctx.show[id] = {
486
573
  props: {
@@ -493,9 +580,11 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
493
580
  selectClass: layout.selectClass,
494
581
  actionsClass: layout.actionsClass,
495
582
  actions: actionItems(layout.rowActions, ctx),
583
+ ...rowToneFieldProp(layout),
496
584
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
497
585
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
498
586
  ...selectedProps(ctx),
587
+ ...removeBusyProps(ctx),
499
588
  },
500
589
  };
501
590
  // 右键菜单:页面里一个实例,宿主壳(data-kit-ctxhost)里的 KitTreeTable 按行主键登记取行函数(provideCtxRows)
@@ -507,8 +596,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
507
596
  }
508
597
  const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
509
598
  const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
510
- const treeBody = `<div${attr('class', layout.wrapClass)}${treeWrapA11y}${treeCtx !== '' ? ' data-kit-ctxhost=""' : ''}><div${attr('class', layout.innerClass)}>${head}${host('KitTreeTable', id)}${treeCtx}</div></div>`;
511
- return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
599
+ const treeBody = `<div${attr('class', layout.wrapClass)}${treeWrapA11y}${treeCtx !== '' ? ' data-kit-ctxhost=""' : ''}${gridMark(layout)} data-kit-tree-of="${esc(object)}" ${KIT_TIPS_SCOPE_ATTR}=""><div${attr('class', layout.innerClass)}>${head}${host('KitTreeTable', id)}${treeCtx}</div></div>`;
600
+ return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
512
601
  }
513
602
 
514
603
  // 虚拟滚动(N3):表头 / 三态 / 分页 / 工具与普通表格同一条路径,只有表体换成 KitVirtualRows(窗口内的行由组件画)
@@ -525,6 +614,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
525
614
  selectMode: layout.select,
526
615
  selected: ctx.options.selectedPath,
527
616
  keyField: keysOf(ctx.options.schema)[0] ?? '',
617
+ ...removeBusyProps(ctx),
528
618
  },
529
619
  };
530
620
  rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('KitTableActions', selAnchor(object))}</div>`);
@@ -535,37 +625,35 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
535
625
  }
536
626
  }
537
627
  layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
538
- // D9 rowClassWhen:条件行类由 KitTableActions 在行容器(data-kit-row)上切换
539
- const hasRowWhen = (layout.rowClassWhen ?? []).length > 0;
540
- const rowWhenProps = hasRowWhen ? { rowClassWhen: layout.rowClassWhen } : {};
541
628
  if (layout.rowActions.length > 0) {
542
629
  ctx.components.add('KitTableActions');
543
630
  rowShow[opsAnchor(object)] = {
544
- props: { actions: actionItems(layout.rowActions, ctx), row: ctx.rowVar, ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...rowWhenProps, ...selectedProps(ctx) },
631
+ props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) },
545
632
  };
546
633
  rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.actionsClass)}>${host('KitTableActions', opsAnchor(object))}</div>`);
547
634
  }
548
- // pickOnRow / rowClassWhen 且没有行操作列:补一个无按钮的 KitTableActions 实例,专管行点击与条件行类
549
- if ((ctx.options.pickOnRow === true || hasRowWhen) && layout.rowActions.length === 0) {
635
+ // pickOnRow 或行样式档位(rowTone)且没有行操作列:补一个无按钮的 KitTableActions 实例,专管行点击 / 行样式
636
+ if ((ctx.options.pickOnRow === true || layout.rowTone !== undefined) && layout.rowActions.length === 0) {
550
637
  ctx.components.add('KitTableActions');
551
- rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...rowWhenProps, ...selectedProps(ctx) } };
638
+ rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) } };
552
639
  rowParts.push(host('KitTableActions', opsAnchor(object)));
553
640
  }
554
641
  // 右键菜单(Q 波 G6):行内一个 KitContextMenu 实例(包在 hidden 壳里,不占栅格列),行容器标 data-kit-ctx 供它监听
555
642
  const ctxItems = layout.contextMenu ?? [];
556
643
  if (ctxItems.length > 0) {
557
644
  ctx.components.add('KitContextMenu');
558
- rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), row: ctx.rowVar } };
645
+ rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
559
646
  rowParts.push(`<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`);
560
647
  }
561
648
  const rowClass = ctx.options.pickOnRow === true ? joinClasses(layout.rowClass, 'cursor-pointer') : layout.rowClass;
562
649
  // 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
563
- const marked = ctx.options.pickOnRow === true || hasRowWhen || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
650
+ const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
564
651
  const rowMark = `${marked ? ' data-kit-row=""' : ''}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}`;
565
- const stripe = layout.stripeClass;
566
- const striped = stripe !== '';
567
- const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInner) : rowClass;
568
- const rowEl = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.expand === null ? joinClasses(rowClass, stripe) : expandRowClass)}${rowMark}>${rowParts.join('')}</div>`;
652
+ // 普通表格的行容器首子节点是 <template>,数据行从第 2 个子节点起:斑马纹用 odd 键(树表 / 虚拟表无 template,走 IR 里的 even 键)
653
+ const striped = layout.stripeClass !== '';
654
+ const stripe = striped ? KIT_CLASS_DEFAULTS.tableRowStripedAfterTemplate : '';
655
+ const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInnerAfterTemplate) : rowClass;
656
+ const rowEl = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.expand === null ? joinClasses(rowClass, stripe) : expandRowClass)}${rowMark} data-kit-part="${KIT_PART_TABLE_ROW}">${rowParts.join('')}</div>`;
569
657
  let itemHtml = rowEl;
570
658
  if (layout.expand !== null) {
571
659
  // 展开行:行下一条“展开详情”开关(KitTableActions expand)+ 默认 hidden 的详情体;开合状态在开关组件里
@@ -594,8 +682,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
594
682
  const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
595
683
  const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
596
684
  const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
597
- const body = `<div${attr('class', layout.wrapClass)}${wrapA11y}${tools ? ' data-kit-table=""' : ''}><div${tableA11y}${attr('class', layout.innerClass)}>${head}${rows}${summary}</div></div>`;
598
- return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
685
+ const body = `<div${attr('class', layout.wrapClass)}${wrapA11y}${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''} data-kit-part="${KIT_PART_TABLE}"${gridMark(layout)} ${KIT_TIPS_SCOPE_ATTR}=""><div${tableA11y}${attr('class', layout.innerClass)}>${head}${rows}${summary}</div></div>`;
686
+ return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
599
687
  }
600
688
 
601
689
  /**
@@ -607,26 +695,27 @@ function renderVirtualTable(
607
695
  ): string {
608
696
  const object = ctx.object;
609
697
  const id = virtualAnchor(object);
698
+ rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, '虚拟滚动表');
699
+ rejectRowProps(layout.cells, ctx, '虚拟滚动表');
610
700
  ctx.components.add('KitVirtualRows');
611
- const hasRowWhen = (layout.rowClassWhen ?? []).length > 0;
612
701
  ctx.show[id] = {
613
702
  props: {
614
703
  rows: ctx.rowsPath,
615
704
  cells: layout.cells,
616
705
  rowHeight: layout.virtual!.rowHeight,
617
- density: layout.density,
618
706
  rowClass: layout.rowClass,
619
- ...(hasRowWhen ? { rowClassWhen: layout.rowClassWhen } : {}),
620
707
  stripeClass: layout.stripeClass,
621
708
  select: layout.select,
622
709
  selectClass: layout.selectClass,
623
710
  actionsClass: layout.actionsClass,
624
711
  actions: actionItems(layout.rowActions, ctx),
625
712
  label: object,
713
+ ...rowToneFieldProp(layout),
626
714
  colCount: layout.cells.length + (layout.select !== 'none' ? 1 : 0) + (layout.rowActions.length > 0 ? 1 : 0),
627
715
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
628
716
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
629
717
  ...selectedProps(ctx),
718
+ ...removeBusyProps(ctx),
630
719
  },
631
720
  };
632
721
  const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
@@ -639,9 +728,9 @@ function renderVirtualTable(
639
728
  }
640
729
  const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
641
730
  const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
642
- const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${tools ? ' data-kit-table=""' : ''}>`
731
+ const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${gridMark(layout)} ${KIT_TIPS_SCOPE_ATTR}=""${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''}>`
643
732
  + `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
644
- return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
733
+ return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
645
734
  }
646
735
 
647
736
  /** 表格工具与接线件:工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐。放在表格外壳之前 */
@@ -651,7 +740,7 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
651
740
  const keyField = keysOf(ctx.options.schema)[0] ?? '';
652
741
  let batchOn = batch.length > 0;
653
742
  if (batchOn && ctx.options.selectedPath === undefined) {
654
- ctx.diagnostics.push({ code: 'KIT-OBJ-009', path: 'views.list.layout', message: 'batchActions 需要勾选态来源(StandardCrud 等带协调组件的业务组件),当前对象没有,批量条已忽略' });
743
+ ctx.diagnostics.push({ code: 'KIT-OBJ-009', path: 'views.list.layout', message: 'batchActions 需要勾选态来源(StandardCrud 等带协调组件的业务组件),当前对象没有' });
655
744
  batchOn = false;
656
745
  }
657
746
  const id = toolsAnchor(ctx.object);
@@ -663,9 +752,9 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
663
752
  rows: ctx.rowsPath,
664
753
  total: ctx.totalPath,
665
754
  keyField,
755
+ readState: readStatePathsOf(ctx.object, ctx.basePath).readStatePath,
666
756
  columns: layout.columns ?? [],
667
757
  items: layout.toolbar ?? [],
668
- density: layout.density,
669
758
  scroll: layout.scroll === true,
670
759
  editMode: layout.editMode ?? '',
671
760
  selectMode: layout.select,
@@ -673,7 +762,17 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
673
762
  ...(batchOn
674
763
  ? {
675
764
  selected: ctx.options.selectedPath,
676
- batch: batch.map((b) => ({ id: b.id, name: b.name, tone: b.tone, confirm: b.confirm, ...(b.permission !== undefined ? { permission: b.permission } : {}) })),
765
+ batch: batch.map((b) => {
766
+ const busyAction = (b as { on?: string }).on ?? b.action?.on;
767
+ return {
768
+ id: b.id,
769
+ name: b.name,
770
+ tone: b.tone,
771
+ confirm: b.confirm,
772
+ ...(b.permission !== undefined ? { permission: b.permission } : {}),
773
+ ...(busyAction !== undefined && busyAction !== '' ? { busyAction } : {}),
774
+ };
775
+ }),
677
776
  }
678
777
  : {}),
679
778
  },
@@ -707,11 +806,23 @@ function renderSummary(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>
707
806
  }
708
807
 
709
808
  /** 骨架屏的形态参数:表格按列的跨度类(含选择 / 操作列),cards / stack 沿用列表容器类 */
710
- function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>): KitSkeletonConfig {
809
+ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>, schema?: KitSchema): KitSkeletonConfig {
711
810
  if (layout.kind === 'table') {
712
- const cols = [
811
+ // 数据列形态:数值 -> number;枚举 / 布尔 / Tag 单元 -> tag;其余文本列里第一个 -> title,其它 -> text(text 仍输出字符串,保持旧形状)
812
+ let titleTaken = false;
813
+ const dataCols = layout.head.map((h, i): string | KitSkeletonCol => {
814
+ const field = layout.cells[i]?.field ?? h.col ?? '';
815
+ const type = schema?.[field]?.type;
816
+ let shape: KitSkeletonCol['shape'];
817
+ if (isNumericColumnType(type)) shape = 'number';
818
+ else if (type === 'enum' || type === 'enums' || type === 'bool' || layout.cells[i]?.component === 'Tag') shape = 'tag';
819
+ else if (!titleTaken) { shape = 'title'; titleTaken = true; }
820
+ else shape = 'text';
821
+ return shape === 'text' ? h.class : { cls: h.class, shape };
822
+ });
823
+ const cols: Array<string | KitSkeletonCol> = [
713
824
  ...(layout.select !== 'none' && layout.selectClass !== '' ? [layout.selectClass] : []),
714
- ...layout.head.map((h) => h.class),
825
+ ...dataCols,
715
826
  ...(layout.rowActions.length > 0 && layout.actionsClass !== '' ? [layout.actionsClass] : []),
716
827
  ];
717
828
  return { kind: 'table', cols };
@@ -723,8 +834,11 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
723
834
  const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
724
835
  const EXPAND_BODY_CLASS = 'border-b border-border-subtle bg-surface-sunken px-4 py-3';
725
836
 
837
+ /** 标题与它旁边的集合辅助文字(共 N 条 / 已筛选提示)同一组:基线对齐、窄时换行 */
838
+ const TITLE_GROUP_CLASS = 'flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1';
839
+
726
840
  /** 集合三态面板:列表之后、分页器之前 */
727
- function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean } | null, shape?: KitSkeletonConfig): string {
841
+ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
728
842
  if (state === null) return '';
729
843
  const id = stateAnchor(ctx.object);
730
844
  ctx.components.add('KitCollectionState');
@@ -733,18 +847,69 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
733
847
  data: ctx.basePath,
734
848
  rows: ctx.rowsPath,
735
849
  config: {
850
+ object: ctx.object,
736
851
  rowsPath: ctx.options.listShape.rows,
737
852
  errorPath: typeof ctx.options.listShape.errorPath === 'string' ? ctx.options.listShape.errorPath : KIT_LIST_ERROR_PATH,
853
+ readStatePath: readStatePathsOf(ctx.object, ctx.basePath).readStatePath,
854
+ errorMessagePath: readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath,
738
855
  loading: state.loading === KIT_STATE_DEFAULT_TEXT.loading ? kitText('soma.kit.loading', undefined, ctx.options.locale ?? '') : state.loading,
739
856
  empty: state.empty === KIT_STATE_DEFAULT_TEXT.empty ? kitText('soma.kit.empty', undefined, ctx.options.locale ?? '') : state.empty,
740
857
  error: state.error,
741
858
  ...(state.skeleton === true && shape !== undefined ? { skeleton: shape } : {}),
859
+ ...(state.errorOnly === true ? { mode: 'errorOnly' } : {}),
860
+ // 筛选无结果 / 无数据的区分:本对象有筛选栏或表头筛选时,把作用域与清除入口交给三态面板(没有筛选的页面配置不变)
861
+ ...filteredConfig(ctx),
742
862
  },
743
863
  },
744
864
  };
745
865
  return host('KitCollectionState', id);
746
866
  }
747
867
 
868
+ /** 集合被筛选状态判断所需的配置:区域作用域、筛选栏宿主锚点(清除时优先点它的「重置」)、表头筛选键;对象没有任何筛选则为空 */
869
+ function filteredConfig(ctx: Ctx): Record<string, unknown> {
870
+ const columnParams = ctx.columnParams ?? [];
871
+ if (ctx.filterId === undefined && columnParams.length === 0) return {};
872
+ return {
873
+ scope: ctx.scope(),
874
+ ...(ctx.filterId !== undefined ? { filterId: ctx.filterId } : {}),
875
+ ...(columnParams.length > 0 ? { columnParams } : {}),
876
+ };
877
+ }
878
+
879
+ /** 标题旁的集合辅助文字实例(KitCollectionState 的 meta 形态):共 N 条 / 已筛选提示 */
880
+ function renderMeta(ctx: Ctx, plan: { count: boolean; hint: boolean }): string {
881
+ const id = metaAnchor(ctx.object);
882
+ ctx.components.add('KitCollectionState');
883
+ const paths = readStatePathsOf(ctx.object, ctx.basePath);
884
+ ctx.show[id] = {
885
+ props: {
886
+ data: ctx.basePath,
887
+ rows: ctx.rowsPath,
888
+ config: {
889
+ mode: 'meta',
890
+ object: ctx.object,
891
+ rowsPath: ctx.options.listShape.rows,
892
+ totalPath: ctx.options.listShape.total,
893
+ errorPath: typeof ctx.options.listShape.errorPath === 'string' ? ctx.options.listShape.errorPath : KIT_LIST_ERROR_PATH,
894
+ readStatePath: paths.readStatePath,
895
+ errorMessagePath: paths.errorMessagePath,
896
+ ...(plan.count ? { count: true } : {}),
897
+ ...(plan.hint ? { hint: true, ...filteredConfig(ctx) } : {}),
898
+ },
899
+ },
900
+ };
901
+ return host('KitCollectionState', id);
902
+ }
903
+
904
+ /** 面板标题绑展示对象只读成员(view.list.title: view.<成员>):h3 里放一个 Text 实例,值是 page.<成员>,成员变了标题被动刷新 */
905
+ function renderDynamicTitle(ctx: Ctx, slot: KitViewSlot, path: string): string {
906
+ const id = `${viewAnchor(ctx.object, slot)}__title`;
907
+ const textId = `${id}__text`;
908
+ ctx.components.add('Text');
909
+ ctx.show[textId] = { props: { value: viewPathToCore(path) } };
910
+ return `<h3 data-soma-id="${esc(id)}" data-kit-part="${KIT_PART_TITLE_SECTION}" class="${KIT_PANEL_TITLE_CLASS}">${host('Text', textId)}</h3>`;
911
+ }
912
+
748
913
  function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boolean; mode?: string; layout?: string; showTotal?: boolean } | null): string {
749
914
  if (pager === null) return '';
750
915
  const id = pagerAnchorOf(ctx.object);
@@ -752,6 +917,8 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
752
917
  ctx.show[id] = {
753
918
  props: {
754
919
  scope: ctx.scope(), total: ctx.totalPath, size: pager.size, sizes: pager.sizes, jump: pager.jump,
920
+ // 读状态:翻页后重取失败,分页器据此把页码 / 页长回滚到最近一次读成功的值
921
+ readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
755
922
  ...(pager.mode !== undefined ? { mode: pager.mode } : {}),
756
923
  ...(pager.layout !== undefined ? { layout: pager.layout } : {}),
757
924
  ...(pager.showTotal === false ? { show_total: false } : {}),
@@ -760,29 +927,81 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
760
927
  return host('Pager', id);
761
928
  }
762
929
 
930
+ /**
931
+ * 紧凑列表的条目正文:主标题一行 + 次要信息一行(其余字段以「·」分隔的辅助文字)。
932
+ * 枚举 / Tag 字段以状态圆点 + 文字呈现(Tag variant: dot);文本类次要字段为空时该项连同前导分隔符一起不显示(core 的 when 只判真值,数字 / 布尔 / 枚举不用它)。
933
+ */
934
+ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>['compact']>, rowShow: Record<string, unknown>): string {
935
+ const D = KIT_CLASS_DEFAULTS;
936
+ const at = 'views.list.layout.compact';
937
+ const sized = (cell: KitCell): Record<string, unknown> => {
938
+ const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at);
939
+ if (cell.component === 'Text' || cell.component === 'Tag') props.size ??= 'sm';
940
+ return props;
941
+ };
942
+ const titleId = cellAnchor(ctx.object, 'list', compact.title.field);
943
+ ctx.components.add(compact.title.component);
944
+ rowShow[titleId] = { props: sized(compact.title) };
945
+ const title = `<div${attr('class', D.compactTitle)} ${KIT_TIPS_SCOPE_ATTR}="">${host(compact.title.component, titleId)}</div>`;
946
+ const items = compact.meta.map((cell, i) => {
947
+ const id = cellAnchor(ctx.object, 'list', cell.field);
948
+ ctx.components.add(cell.component);
949
+ const props = sized(cell);
950
+ // 状态字段:圆点 + 文字(无底无描边);其余文本沿用组件默认外观
951
+ if (cell.component === 'Tag') props.variant ??= 'dot';
952
+ // 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上)
953
+ if (cell.component === 'Text') props.class = joinClasses(typeof props.class === 'string' ? props.class : '', 'text-fg-muted');
954
+ rowShow[id] = { props };
955
+ const type = ctx.options.schema?.[cell.field]?.type;
956
+ const hideable = cell.component !== 'Tag' && !isNumericColumnType(type) && type !== 'enum' && type !== 'enums' && type !== 'bool';
957
+ const sep = i > 0 ? `<span${attr('class', D.compactSep)} aria-hidden="true">·</span>` : '';
958
+ if (!hideable) return `<span${attr('class', D.compactMetaItem)}>${sep}${host(cell.component, id)}</span>`;
959
+ const wid = `${id}__item`;
960
+ rowShow[wid] = { when: `${ctx.rowVar}.${cell.field}` };
961
+ return `<span data-soma-id="${esc(wid)}"${attr('class', D.compactMetaItem)}>${sep}${host(cell.component, id)}</span>`;
962
+ });
963
+ const meta = items.length > 0 ? `<div${attr('class', D.compactMeta)}>${items.join('')}</div>` : '';
964
+ return `<div${attr('class', D.compactBody)}>${title}${meta}</div>`;
965
+ }
966
+
763
967
  function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>): string {
764
968
  const object = ctx.object;
765
969
  const rowShow: Record<string, unknown> = {};
766
970
  const innerAt = 'views.list.layout.inner';
767
- const inner = renderArrangement(ctx, 'list', layout.inner, (f) => `${ctx.rowVar}.${f}`, innerAt, rowShow);
971
+ const compact = layout.compact;
972
+ const inner = compact !== undefined ? renderCompactBody(ctx, compact, rowShow) : renderArrangement(ctx, 'list', layout.inner, (f) => `${ctx.rowVar}.${f}`, innerAt, rowShow);
768
973
  let actions = '';
974
+ // 紧凑列表:行点选(pickOnRow)与选中行高亮(selectedPath)同表格行——同一个 KitTableActions 实例、同一条 row_action select 事件与区域切片
975
+ const pickProps = compact !== undefined ? { ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...selectedProps(ctx) } : {};
976
+ const pickOnly = compact !== undefined && ctx.options.pickOnRow === true;
977
+ // 行样式档位:条目自带底色与边框,档位走 itemToneTiers(rowToneSet: item,描边 / 透明度);没有行操作时补一个 actions:[] 实例专管档位
978
+ const toneProps = layout.rowTone !== undefined ? { ...rowToneProp(layout, ctx), rowToneSet: 'item' } : {};
769
979
  if (layout.rowActions.length > 0) {
770
980
  ctx.components.add('KitTableActions');
771
- rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), row: ctx.rowVar } };
981
+ rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
772
982
  actions = host('KitTableActions', opsAnchor(object));
983
+ } else if (layout.rowTone !== undefined || pickOnly) {
984
+ ctx.components.add('KitTableActions');
985
+ rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
986
+ // 无按钮的档位实例只管给条目加类,放 hidden 壳里不占版面(不在条目 flex / gap 里多出一格)
987
+ actions = `<div class="hidden">${host('KitTableActions', opsAnchor(object))}</div>`;
773
988
  }
774
989
  // 右键菜单(Q 波 G6):块 / 卡外壳标 data-kit-ctx,内含一个 KitContextMenu 实例(hidden 壳,不占版面)
775
990
  const ctxItems = layout.contextMenu ?? [];
776
991
  let ctxHost = '';
777
992
  if (ctxItems.length > 0) {
778
993
  ctx.components.add('KitContextMenu');
779
- rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), row: ctx.rowVar } };
994
+ rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
780
995
  ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
781
996
  }
782
- const template = `<template data-soma-role="item"><div${attr('class', layout.itemClass)}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}>${inner}${actions}${ctxHost}</div></template>`;
997
+ const itemPart = layout.kind === 'cards' ? ` data-kit-part="${KIT_PART_CARD}"` : '';
998
+ const itemClass = pickOnly ? joinClasses(layout.itemClass, 'cursor-pointer') : layout.itemClass;
999
+ const rowMark = layout.rowTone !== undefined || pickOnly ? ' data-kit-row=""' : '';
1000
+ const actionsPart = compact !== undefined && actions !== '' ? `<div${attr('class', KIT_CLASS_DEFAULTS.compactActions)}>${actions}</div>` : actions;
1001
+ const template = `<template data-soma-role="item"><div${attr('class', itemClass)}${rowMark}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}${itemPart}>${inner}${actionsPart}${ctxHost}</div></template>`;
783
1002
  ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
784
1003
  const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
785
- return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
1004
+ return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
786
1005
  }
787
1006
 
788
1007
  // ---------------------------------------------------------------- static(写死形状数据组件)
@@ -810,6 +1029,20 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
810
1029
  if (layout.dataSubmit === true && layout.hasScopeProp === true && props.scope === undefined) {
811
1030
  props.scope = ctx.scope();
812
1031
  }
1032
+ // 读状态:契约声明了 loading / error_text(或无 error_text 时 string 型 error)的组件,页面没显式给时绑到数据对象的读状态(loading / errorMessage)
1033
+ if (layout.hasLoadingProp === true && props.loading === undefined) {
1034
+ props.loading = `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.loading`;
1035
+ }
1036
+ if (layout.hasErrorTextProp === true && props.error_text === undefined) {
1037
+ props.error_text = readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath;
1038
+ }
1039
+ if (layout.hasErrorProp === true && props.error === undefined) {
1040
+ props.error = readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath;
1041
+ }
1042
+ // 读失败自动重试:页面没给 retry_text 时补缺省文案(接线在 emitEvents:页面没接 retry 时接重取管道)
1043
+ if (layout.autoRetry === true && props.retry_text === undefined) {
1044
+ props.retry_text = kitText('soma.kit.ct_retry', undefined, ctx.options.locale ?? '');
1045
+ }
813
1046
  if (layout.class !== '') props.class = layout.class;
814
1047
  ctx.show[id] = { props };
815
1048
  // 右键菜单:宿主壳(display: contents,不影响版面)里放组件与一个 KitContextMenu(hidden 壳);组件按行主键登记取行函数
@@ -819,7 +1052,11 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
819
1052
  ctx.show[menuId] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
820
1053
  return `<div class="contents" data-kit-ctxhost="">${host(layout.component, id)}<div class="hidden">${host('KitContextMenu', menuId)}</div></div>`;
821
1054
  }
822
- return host(layout.component, id);
1055
+ const hasStatHighlight = layout.component === 'StatGroup'
1056
+ && Array.isArray(props.items)
1057
+ && props.items.some((it) => it !== null && typeof it === 'object' && (it as { highlight?: unknown }).highlight === true);
1058
+ const rawHost = host(layout.component, id);
1059
+ return hasStatHighlight ? rawHost.replace('></div>', ' data-kit-highlight="true"></div>') : rawHost;
823
1060
  }
824
1061
 
825
1062
  // ---------------------------------------------------------------- KitObjectForm(filter / 可编辑 form)
@@ -870,7 +1107,7 @@ export function formFieldsAndClasses(layout: KitLayoutIR): { fields: KitCell[];
870
1107
  }
871
1108
 
872
1109
  function createOnlyOf(schema: KitSchema | undefined): string[] {
873
- return Object.entries(schema ?? {}).filter(([, f]) => f.permission === 'create').map(([k]) => k);
1110
+ return Object.entries(schema ?? {}).filter(([, f]) => f.permission === 'create' || f.access === 'create').map(([k]) => k);
874
1111
  }
875
1112
  export function keysOf(schema: KitSchema | undefined): string[] {
876
1113
  return Object.entries(schema ?? {}).filter(([, f]) => f.key === true).map(([k]) => k);
@@ -899,10 +1136,47 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
899
1136
  keys: keysOf(ctx.options.schema),
900
1137
  ...(slot === 'form' && ir.views.form?.submitLabel !== undefined ? { submitLabel: ir.views.form.submitLabel } : {}),
901
1138
  };
1139
+ // 本页有效信封(与 detail.envelope 同一来源:编译期页面 > 应用);筛选与可编辑表单的远程选项、句柄 envelope() 据此解包。未声明不写这个 prop
1140
+ const envelope = getCompileEnvelope();
1141
+ if (envelope !== undefined) props.envelope = envelope;
902
1142
  // M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
903
1143
  const fo = ir.views[slot]?.formOpts;
1144
+ // 筛选栏动作区并入字段栅格(字段占满一行才另起一行,否则与字段同行靠右):根即栅格、字段容器 display: contents、动作区带跨度类;
1145
+ // 折叠搜索区(collapsible / filterOverflow)同走流式版式:折起的行数由表单按宿主宽度现算,「查询 / 重置 / 展开」紧跟最后一个可见字段
1146
+ if (slot === 'filter' && layout.kind === 'grid' && layout.actionsClass !== undefined) {
1147
+ props.classes = { wrap: mergeClass(layout.wrapClass, layout.gridClass), grid: KIT_FILTER_INLINE_CLASS.grid, actions: mergeClass(layout.actionsClass, KIT_FILTER_INLINE_CLASS.actionsExtra), notice: KIT_FILTER_INLINE_CLASS.notice };
1148
+ // 不折叠的筛选栏默认走定宽流式版式:字段按类型定宽(文本 / 日期 240、下拉按 design 阶梯)、「查询 / 重置」紧跟最后一个字段并对齐到控件那一行,
1149
+ // 容器放不下一个字段 + 动作区时字段占满一行、动作区另起一行靠右;折叠搜索区(上面的条件不成立)仍按 12 份栅格折行
1150
+ const flow = layout.filterFlow;
1151
+ const pack = layout.filterPack;
1152
+ // 不折叠的筛选栏:按字段数装行(列等分行宽、动作区当一格参与装行,放不进首行时与末行字段同排靠右,绝不孤行靠左);
1153
+ // 折叠搜索区的折起行数由表单按宿主宽度现算(依赖定宽类 @档:w-N),仍走上面的流式版式
1154
+ if (pack !== undefined && fo?.collapsible !== true && fo?.filterOverflow !== true) {
1155
+ props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, pack.cellClasses[i] ?? '') }));
1156
+ const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
1157
+ props.classes = {
1158
+ wrap: joinClasses(joinClasses(layout.wrapClass, pack.wrapClass), keep.join(' ')),
1159
+ grid: KIT_FILTER_INLINE_CLASS.grid,
1160
+ actions: mergeClass('', pack.actionsClass),
1161
+ pad: pack.padClass,
1162
+ notice: pack.noticeClass,
1163
+ };
1164
+ } else if (flow !== undefined) {
1165
+ props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, flow.widthClasses[i] ?? '') }));
1166
+ const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
1167
+ props.classes = {
1168
+ wrap: joinClasses(joinClasses(layout.wrapClass, flow.wrapClass), keep.join(' ')),
1169
+ grid: KIT_FILTER_INLINE_CLASS.grid,
1170
+ actions: mergeClass('', flow.actionsClass),
1171
+ pad: flow.padClass,
1172
+ notice: flow.noticeClass,
1173
+ };
1174
+ // 折叠搜索区也走流式版式:折起哪些字段要按容器宽度现算(定宽字段每行放几个),由表单量宿主宽度判,不再按 12 份栅格的份数折行
1175
+ props.flow = true;
1176
+ }
1177
+ }
904
1178
  if (fo?.labelPosition !== undefined) { props.labelPosition = fo.labelPosition; props.labelWidth = fo.labelWidth ?? 3; }
905
- if (fo?.scrollToError === true) props.scrollToError = true;
1179
+ if (typeof fo?.scrollToError === 'boolean') props.scrollToError = fo.scrollToError;
906
1180
  if (fo?.requiredMark === 'start') props.requiredMark = 'start';
907
1181
  if (fo?.collapsible === true) { props.collapsible = true; props.collapsedRows = fo.collapsedRows ?? 1; }
908
1182
  if (fo?.trigger === 'change') props.trigger = 'change';
@@ -914,54 +1188,81 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
914
1188
  if (fo?.footerActions !== undefined) {
915
1189
  const items = fo.footerActions.flatMap((aid) => {
916
1190
  const a = ctx.options.actions?.find((x) => x.id === aid);
917
- return a === undefined ? [] : [{ id: aid, label: a.name, ...actionGateOf(a) }];
1191
+ return a === undefined ? [] : [{ id: aid, label: a.name }];
918
1192
  });
919
1193
  if (items.length > 0) props.footerActions = items;
1194
+ // 底栏动作的展示对象状态绑定:{ 动作id: { disabled?, hidden? } },叶子是 page.<成员>(core 求值);路径合法性已在 emitStatic 入口核过
1195
+ const footerState: Record<string, Record<string, string>> = {};
1196
+ for (const a of ctx.options.actions ?? []) {
1197
+ if (a.on !== undefined || !fo.footerActions.includes(a.id)) continue;
1198
+ for (const key of ['disabled', 'hidden'] as const) {
1199
+ const raw = a[key];
1200
+ if (raw !== undefined && isViewPath(raw)) (footerState[a.id] ??= {})[key] = viewPathToCore(raw);
1201
+ }
1202
+ }
1203
+ if (Object.keys(footerState).length > 0) props.footerState = footerState;
920
1204
  }
921
- if (fo?.onChange !== undefined) props.changeFields = Object.keys(fo.onChange);
922
1205
  if (fo?.result !== undefined) props.result = fo.result;
923
- if (fo?.adopt !== undefined) props.adopt = fo.adopt;
1206
+ // 展示对象的字段状态绑定:{ 字段: { hidden / disabled / required: page.<成员> } },叶子是路径,core 的 props 求值递归解析
1207
+ if (fo?.fieldState !== undefined) props.fieldState = fo.fieldState;
1208
+ if (fo?.submitDisabled !== undefined) props.submitDisabled = fo.submitDisabled;
1209
+ if (fo?.onDraft !== undefined) props.draftNotify = true;
924
1210
  // GB2 / GB3:字段初值(新建时填空字段)与隐藏草稿字段(随草稿提交、不画)
925
1211
  if (ir.fieldValue !== undefined) {
926
1212
  if (Object.keys(ir.fieldValue.defaults).length > 0) props.defaults = ir.fieldValue.defaults;
927
1213
  if (ir.fieldValue.hidden.length > 0) props.hiddenFields = ir.fieldValue.hidden;
928
1214
  }
929
1215
  }
1216
+ // filter 视图的字段状态绑定只有 options({ 字段: { options: page.<成员> } };其余键编译期 collectFieldState 已拦)
1217
+ if (slot === 'filter' && fo?.fieldState !== undefined) props.fieldState = fo.fieldState;
930
1218
  ctx.show[id] = { props };
931
1219
  // 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
932
1220
  const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
933
- const html = host('KitObjectForm', id);
1221
+ const isOverflowFilter = slot === 'filter' && (fo?.filterOverflow === true || (fo?.collapsible === true && packed.fields.filter((c) => c.placeholder !== true && c.divider !== true && c.component !== '').length > (fo?.defaultCollapsedCount ?? 4)));
1222
+ let html = host('KitObjectForm', id);
1223
+ if (isOverflowFilter) html = html.replace('></div>', ' data-kit-filter-overflow="true"></div>');
934
1224
  return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
935
1225
  }
936
1226
 
937
1227
  // ---------------------------------------------------------------- 工具栏
938
1228
 
939
- /** 工具栏动作条件用到的页面读态绑定:total -> 列表总条数路径,selectedCount / selected.x -> 勾选态来源路径(没有勾选来源时不绑,selectedCount 恒 0) */
940
- function toolbarGateBindings(ctx: Ctx, a: KitAction): Record<string, string> {
941
- const g = actionGateOf(a);
942
- const leaves = [...new Set([...gateLeafFields(g.disabledWhen), ...gateLeafFields(g.hiddenWhen)])];
943
- const out: Record<string, string> = {};
944
- if (leaves.includes('total')) out.gateTotal = ctx.totalPath;
945
- if (ctx.options.selectedPath !== undefined && leaves.some((f) => f === 'selectedCount' || f.startsWith('selected.'))) out.gateSelected = ctx.options.selectedPath;
946
- return out;
947
- }
948
-
949
1229
  const AUXILIARY_BUILTINS = new Set(['reload', 'reset', 'export', 'back']);
950
1230
  const AUXILIARY_IDS = new Set(['reload', 'refresh', 'reset', 'export', 'back']);
951
1231
 
952
- function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' {
953
- if (a.tone === 'danger') return 'danger';
954
- if (a.tone === 'neutral') return 'neutral';
955
- if (a.tone === 'primary') return 'primary';
1232
+ function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' | 'ghost' | 'tonal' {
1233
+ if (a.tone === 'danger' || a.tone === 'neutral' || a.tone === 'primary' || a.tone === 'ghost' || a.tone === 'tonal') {
1234
+ return a.tone;
1235
+ }
1236
+ if (a.tone === 'info' || a.tone === 'success') return 'primary';
1237
+ if (a.tone === 'warning') return 'tonal';
956
1238
  if ((a.builtin !== undefined && AUXILIARY_BUILTINS.has(a.builtin)) || AUXILIARY_IDS.has(a.id)) {
957
1239
  return 'neutral';
958
1240
  }
959
1241
  return 'primary';
960
1242
  }
961
1243
 
1244
+ /** 工具栏按钮的置灰原因 prop(Button 的 disabled_reason);没写 disabled 或来源是行路径 / 非法值时不带 */
1245
+ function toolbarReasonProp(a: KitAction): { disabled_reason?: string } {
1246
+ if (a.disabled === undefined) return {};
1247
+ const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
1248
+ if (source.kind === 'view') return { disabled_reason: viewPathToCore(source.path) };
1249
+ return source.kind === 'literal' && source.text.trim() !== '' ? { disabled_reason: source.text } : {};
1250
+ }
1251
+
1252
+ /** 主操作语气(新增 / 危险):工具栏里排在最右,次级工具(刷新 / 导出 / 重置等中性或幽灵语气)在其左 */
1253
+ function isPrimaryToolbarAction(a: KitAction): boolean {
1254
+ const t = actionTone(a);
1255
+ return t !== 'neutral' && t !== 'ghost';
1256
+ }
1257
+
1258
+ /**
1259
+ * 工具栏(主操作与次级工具)一律不独占一整行:有列表标题时并入标题行右侧,没有标题时紧贴列表上方靠右;
1260
+ * 次级工具在左、主操作在最右(同档保持声明顺序)。
1261
+ */
962
1262
  function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
963
- const list = actions.filter((a) => a.on === 'toolbar');
964
- if (list.length === 0) return '';
1263
+ const declared = actions.filter((a) => a.on === 'toolbar');
1264
+ if (declared.length === 0) return '';
1265
+ const list = [...declared.filter((a) => !isPrimaryToolbarAction(a)), ...declared.filter(isPrimaryToolbarAction)];
965
1266
  const parts = list.map((a) => {
966
1267
  const id = toolbarAnchor(ctx.object, a.id);
967
1268
  ctx.components.add('Button');
@@ -969,16 +1270,17 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
969
1270
  props: {
970
1271
  label: a.name,
971
1272
  variant: actionTone(a),
1273
+ // 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
1274
+ ...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
1275
+ // 置灰原因(disabled 为真时 Button 才显示):字面量原样带,view.<成员> 编成页面变量路径;row. 路径在入口已报 KIT-VIEW-001
1276
+ ...toolbarReasonProp(a),
972
1277
  // K1-2:Button 读 permission 服务,无权不渲染
973
1278
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
974
- // GA2:状态条件(叶子 outcome.* 与页面读态 total / selectedCount / selected.<字段>),Button 订阅写入结果自行重判;
975
- // 页面读态只在条件真用到时才绑(总条数 / 勾选态来源),免得无关按钮随数据白白重判
976
- ...(Object.keys(actionGateOf(a)).length > 0 ? { gate: actionGateOf(a), ...toolbarGateBindings(ctx, a) } : {}),
977
1279
  },
978
1280
  };
979
1281
  return host('Button', id);
980
1282
  });
981
- return `<div${attr('class', KIT_CLASS_DEFAULTS.tableActions)}>${parts.join('')}</div>`;
1283
+ return `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${parts.join('')}</div>`;
982
1284
  }
983
1285
 
984
1286
  // ---------------------------------------------------------------- 主函数
@@ -991,6 +1293,9 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
991
1293
  const base = options.singlePath ?? `page.data.${object}`;
992
1294
  // 摘要 / 只读 form / 写死形状(single)读 summaryPath(如焦点切片里的当前行);缺省同 base。行数组与总数仍按 base
993
1295
  const summaryBase = options.summaryPath ?? base;
1296
+ // 表头筛选写进 view 切片的键(集合被筛选状态的判断用)
1297
+ const listLayout = ir.views.list?.layout;
1298
+ const columnParams = listLayout?.kind === 'table' ? listLayout.head.flatMap((h) => (h.filter !== undefined ? [h.filter.param] : [])) : [];
994
1299
  const ctx: Ctx = {
995
1300
  object,
996
1301
  options,
@@ -1003,11 +1308,44 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1003
1308
  totalPath: `${base}.${options.listShape.total}`,
1004
1309
  basePath: base,
1005
1310
  scope: () => ir.scope,
1311
+ ...(ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static' ? { filterId: viewAnchor(object, 'filter') } : {}),
1312
+ ...(columnParams.length > 0 ? { columnParams } : {}),
1006
1313
  };
1007
1314
 
1315
+ // 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
1316
+ const footerIds = new Set(ir.views.form?.formOpts?.footerActions ?? []);
1317
+ (options.actions ?? []).forEach((a, i) => {
1318
+ for (const key of ['disabled', 'hidden'] as const) {
1319
+ if (a[key] === undefined) continue;
1320
+ const at = `behavior.actions[${i}].${key}`;
1321
+ if (a.on === 'row') {
1322
+ // 行动作:row.<字段>(业务对象逐行给出)或 view.<成员>(展示对象给出,整页同值),二选一
1323
+ if (!isViewPath(a[key])) checkRowPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics, options.schema);
1324
+ }
1325
+ else if (a.on === 'toolbar' && key === 'disabled') checkViewPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics);
1326
+ // 表单底栏动作(不写 on、被 view.form.footerActions 引用):disabled / hidden 都只许纯 view 路径,收集成表单的 footerState prop
1327
+ else if (a.on === undefined && footerIds.has(a.id)) checkViewPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics);
1328
+ else ctx.diagnostics.push({ code: 'KIT-VIEW-006', path: at, message: `动作 ${a.id} 的 ${key} 不支持 on: ${String(a.on)}(toolbar 只支持 disabled,底栏动作(被 footerActions 引用)支持 disabled / hidden,行级可用性写在 on: row 动作上)` });
1329
+ }
1330
+ // 置灰原因(形态与取值已在 closed-set 核过,这里核落点与路径):toolbar 只收字面量 / view.<成员>;row 动作收字面量 / view.<成员> / row.<字段>(字段须在 schema 里);
1331
+ // 表单底栏动作(由 object-form 渲染)与其它位置暂不支持,写了报 KIT-VIEW-006,不静默丢弃
1332
+ if (a.disabledReason !== undefined && a.disabled !== undefined) {
1333
+ const at = `behavior.actions[${i}].${KIT_ACTION_REASON_KEY}`;
1334
+ const source = classifyDisabledReason(a.disabledReason);
1335
+ if (a.on === 'row') {
1336
+ if (source.kind === 'row') checkRowPath(source.path, at, `动作 ${a.id} 的 ${KIT_ACTION_REASON_KEY}`, ctx.diagnostics, options.schema);
1337
+ } else if (a.on === 'toolbar') {
1338
+ if (source.kind === 'row') ctx.diagnostics.push({ code: 'KIT-VIEW-001', path: at, message: `动作 ${a.id} 的 ${KIT_ACTION_REASON_KEY} 在 on: toolbar 上只许写字面量文案或展示对象成员路径 view.<成员>,不许写行路径 ${a.disabledReason}(工具栏没有「行」)` });
1339
+ } else {
1340
+ ctx.diagnostics.push({ code: 'KIT-VIEW-006', path: at, message: `动作 ${a.id} 的 ${KIT_ACTION_REASON_KEY} 不支持 on: ${String(a.on)}(支持 on: toolbar 与 on: row;表单底栏动作暂不支持)` });
1341
+ }
1342
+ }
1343
+ });
1344
+
1008
1345
  const parts: KitStaticEmit['parts'] = {};
1009
1346
  const toolbar = renderToolbar(ctx, options.actions ?? []);
1010
1347
  if (toolbar !== '') parts.toolbar = toolbar;
1348
+ const secondaryToolbar = toolbar !== '';
1011
1349
 
1012
1350
  for (const slot of SLOT_ORDER) {
1013
1351
  const view = ir.views[slot];
@@ -1031,19 +1369,63 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1031
1369
  if (html !== '' && view.skeleton === true) {
1032
1370
  const sid = `${viewAnchor(object, slot)}__skel`;
1033
1371
  ctx.components.add('KitCollectionState');
1034
- ctx.show[sid] = { props: { data: summaryBase, config: { mode: 'single', loading: kitText('soma.kit.loading', undefined, ctx.options.locale ?? ''), skeleton: { kind: 'single' } } } };
1372
+ const rsPaths = readStatePathsOf(object, summaryBase);
1373
+ ctx.show[sid] = { props: { data: summaryBase, config: { object, mode: 'single', readStatePath: rsPaths.readStatePath, errorMessagePath: rsPaths.errorMessagePath, loading: kitText('soma.kit.loading', undefined, ctx.options.locale ?? ''), skeleton: { kind: 'single' } } } };
1035
1374
  html = `${host('KitCollectionState', sid)}<div data-kit-skeleton-body="">${html}</div>`;
1036
1375
  }
1376
+ if (html !== '' && (view.surface !== undefined || view.emphasis !== undefined || view.highlight === true)) {
1377
+ const slotAttrs = [
1378
+ view.surface !== undefined ? `data-kit-part="${esc(kitContainerPartOf(view.surface))}" data-kit-surface="${esc(view.surface)}"` : '',
1379
+ view.emphasis !== undefined ? `data-kit-emphasis="${esc(view.emphasis)}"` : '',
1380
+ view.highlight === true ? 'data-kit-highlight="true"' : '',
1381
+ ].filter(Boolean).join(' ');
1382
+ if (slotAttrs !== '') {
1383
+ html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
1384
+ }
1385
+ }
1386
+ // 树表「全部展开 / 全部收起」:进表格工具位(与刷新同一行、标题行右侧),不再是表头下面那条灰条
1387
+ const treeCtl = slot === 'list' && html !== '' && layout.kind === 'table' && layout.tree !== null && layout.tree.expandAll ? renderTreeControls(ctx) : '';
1037
1388
  // K-4:list / summary 的标题位(视图内静态文案,h3)
1389
+ // 标题旁的集合辅助文字(共 N 条 / 已筛选提示):非分页集合有标题行时自动出,被筛选状态下出清除提示
1390
+ const metaPlan = slot === 'list' && html !== '' ? collectionMetaOf(ir) : null;
1391
+ const metaHtml = metaPlan !== null ? renderMeta(ctx, metaPlan) : '';
1038
1392
  if (html !== '' && view.title !== undefined && view.title !== '') {
1039
- html = `<h3 data-soma-id="${esc(viewAnchor(object, slot))}__title"${attr('class', VIEW_TITLE_CLASS)}>${esc(view.title)}</h3>${html}`;
1393
+ // 标题写成 view.<成员> 纯路径:被动绑定展示对象的只读成员(如选中项名称),不是字面量
1394
+ const dynamicTitle: boolean = isViewPath(view.title);
1395
+ const titleEl = dynamicTitle
1396
+ ? renderDynamicTitle(ctx, slot, view.title)
1397
+ : kitPanelTitleHtml({ title: view.title, id: `${viewAnchor(object, slot)}__title` });
1398
+ // 工具栏(含主操作,主操作在最右)与列表标题同一行靠右,不再独占一整行(评审 S5 / 第三轮);工具栏并入列表后不再单独出
1399
+ const mergeToolbar = slot === 'list' && secondaryToolbar && parts.toolbar !== undefined;
1400
+ if (slot === 'list' && (mergeToolbar || treeCtl !== '')) {
1401
+ const right = treeCtl !== ''
1402
+ ? `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${mergeToolbar ? parts.toolbar! : ''}</div>`
1403
+ : parts.toolbar!;
1404
+ // 集合辅助文字紧随标题作标题行的直接子项(宿主 display: contents,其根自带 me-auto 把工具区推到最右)
1405
+ html = `<div class="${KIT_CLASS_DEFAULTS.toolbarTitleRow}">${titleEl}${metaHtml}${right}</div>${html}`;
1406
+ if (mergeToolbar) delete parts.toolbar;
1407
+ } else {
1408
+ html = `${metaHtml === '' ? titleEl : `<div class="${TITLE_GROUP_CLASS}">${titleEl}${metaHtml}</div>`}${html}`;
1409
+ }
1410
+ } else {
1411
+ if (treeCtl !== '') {
1412
+ if (secondaryToolbar && parts.toolbar !== undefined) parts.toolbar = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${parts.toolbar}</div>`;
1413
+ else html = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}</div>${html}`;
1414
+ }
1415
+ // 没有标题行:只有「已筛选」提示(共 N 条需要标题行),放在列表上方
1416
+ if (metaHtml !== '') html = `${metaHtml}${html}`;
1040
1417
  }
1041
1418
  parts[slot] = html;
1042
1419
  }
1043
1420
 
1044
- scanShowForBang(ctx.diagnostics, ctx.show, 'show');
1045
-
1046
- const ordered = [parts.toolbar, ...SLOT_ORDER.map((s) => parts[s])].filter((p): p is string => p !== undefined && p !== '');
1421
+ // 次要工具栏没并入标题行时,紧贴列表上方靠右(顺序:筛选 → 工具 → 列表),不压在筛选之前
1422
+ const slotParts = SLOT_ORDER.map((s) => parts[s]);
1423
+ let leading = parts.toolbar;
1424
+ if (secondaryToolbar && parts.toolbar !== undefined && parts.list !== undefined && parts.list !== '') {
1425
+ slotParts.splice(SLOT_ORDER.indexOf('list'), 0, parts.toolbar);
1426
+ leading = undefined;
1427
+ }
1428
+ const ordered = [leading, ...slotParts].filter((p): p is string => p !== undefined && p !== '');
1047
1429
  return {
1048
1430
  parts,
1049
1431
  html: ordered.join('\n'),