soma-kit 0.1.12 → 0.1.14

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 (300) hide show
  1. package/README.md +5 -4
  2. package/bin/soma-kit.mjs +31 -1
  3. package/bin/soma.mjs +0 -0
  4. package/package.json +5 -4
  5. package/spec/generated/kit-app.schema.json +172 -4
  6. package/spec/generated/kit-page.schema.json +164 -5
  7. package/spec/kit-grammar.json +598 -96
  8. package/spec/kit-grammar.schema.json +12 -6
  9. package/src/app/app-config.ts +92 -8
  10. package/src/app/component-gate.ts +271 -13
  11. package/src/app/define-kit-app.ts +2 -2
  12. package/src/app/define-kit-view.ts +9 -5
  13. package/src/app/dev-diagnostic.ts +5 -0
  14. package/src/app/index.ts +29 -5
  15. package/src/app/kit-view-context.ts +181 -15
  16. package/src/app/render-ports.ts +18 -0
  17. package/src/app/server-pages.ts +8 -2
  18. package/src/app/server.ts +55 -8
  19. package/src/app/theme-runtime.ts +4 -0
  20. package/src/base/action-busy.ts +101 -4
  21. package/src/base/action-slots.ts +13 -2
  22. package/src/base/anchored-layer.ts +50 -0
  23. package/src/base/button.ts +62 -15
  24. package/src/base/check-core.ts +8 -0
  25. package/src/base/checkbox.ts +2 -1
  26. package/src/base/choice.ts +21 -2
  27. package/src/base/color-picker.ts +10 -5
  28. package/src/base/command-palette.ts +1 -1
  29. package/src/base/context-menu.ts +10 -7
  30. package/src/base/date-range.ts +7 -7
  31. package/src/base/date.ts +55 -16
  32. package/src/base/delta.ts +72 -0
  33. package/src/base/end-edge.ts +61 -0
  34. package/src/base/fab.ts +1 -1
  35. package/src/base/gap-value.ts +168 -0
  36. package/src/base/hint-tips.ts +170 -0
  37. package/src/base/icons.ts +8 -0
  38. package/src/base/illustrations.ts +95 -0
  39. package/src/base/index.ts +32 -9
  40. package/src/base/listbox-core.ts +6 -5
  41. package/src/base/loading-gate.ts +140 -87
  42. package/src/base/mentions.ts +2 -1
  43. package/src/base/menu-button.ts +16 -18
  44. package/src/base/menu-core.ts +37 -8
  45. package/src/base/motion/hover-3d.ts +1 -1
  46. package/src/base/motion/marquee.ts +1 -1
  47. package/src/base/otp.ts +5 -4
  48. package/src/base/overlay-runtime.ts +235 -0
  49. package/src/base/popover.ts +10 -9
  50. package/src/base/popup.ts +67 -8
  51. package/src/base/portal-core.ts +4 -0
  52. package/src/base/qty-stepper.ts +5 -5
  53. package/src/base/radio.ts +2 -1
  54. package/src/base/range.ts +19 -2
  55. package/src/base/rating.ts +11 -6
  56. package/src/base/reason-tip.ts +150 -0
  57. package/src/base/segmented.ts +36 -24
  58. package/src/base/shared.ts +180 -36
  59. package/src/base/state-panel.ts +367 -0
  60. package/src/base/status-tone.ts +27 -0
  61. package/src/base/sticky-edge.ts +116 -0
  62. package/src/base/swap.ts +6 -6
  63. package/src/base/switch.ts +10 -5
  64. package/src/base/tag-input.ts +6 -6
  65. package/src/base/tag.ts +76 -41
  66. package/src/base/text.ts +43 -14
  67. package/src/base/time-picker.ts +7 -5
  68. package/src/base/tree-select.ts +6 -4
  69. package/src/base/trend-tone.ts +9 -0
  70. package/src/base/upload.ts +15 -9
  71. package/src/base/view-transition.ts +77 -0
  72. package/src/biz/approval-desk/shell.ts +15 -11
  73. package/src/biz/auth-panel/shell.ts +9 -7
  74. package/src/biz/category-crud/compile.ts +5 -4
  75. package/src/biz/category-crud/shell.ts +5 -3
  76. package/src/biz/checkout-page/compile.ts +2 -1
  77. package/src/biz/checkout-page/shell.ts +10 -8
  78. package/src/biz/compose.ts +2 -2
  79. package/src/biz/data-components.ts +4 -0
  80. package/src/biz/import-wizard/shell.ts +13 -10
  81. package/src/biz/landing-page/shell.ts +2 -2
  82. package/src/biz/link/hub.ts +23 -5
  83. package/src/biz/link/shared.ts +23 -12
  84. package/src/biz/master-sub/compile.ts +207 -16
  85. package/src/biz/master-sub/detail-head.ts +61 -0
  86. package/src/biz/master-sub/index.ts +7 -3
  87. package/src/biz/master-sub/shell.ts +133 -24
  88. package/src/biz/multi-board/compile.ts +167 -9
  89. package/src/biz/multi-board/composition.ts +58 -0
  90. package/src/biz/multi-board/index.ts +1 -1
  91. package/src/biz/multi-board/prose-fold.ts +143 -0
  92. package/src/biz/multi-board/shell.ts +94 -23
  93. package/src/biz/notification-center/shell.ts +10 -7
  94. package/src/biz/page-templates/domain-templates.ts +2 -2
  95. package/src/biz/page-templates/result-page/shell.ts +4 -3
  96. package/src/biz/page-templates/sign-in-page/shell.ts +16 -16
  97. package/src/biz/record-detail/compile.ts +2 -2
  98. package/src/biz/record-detail/shell.ts +13 -10
  99. package/src/biz/settings-center/compile.ts +2 -1
  100. package/src/biz/settings-center/shell.ts +12 -9
  101. package/src/biz/shared/action-host.ts +6 -0
  102. package/src/biz/shared/compile-helpers.ts +97 -0
  103. package/src/biz/shared/coordinator.ts +7 -30
  104. package/src/biz/shared/index.ts +5 -0
  105. package/src/biz/shared/object-aliases.ts +154 -0
  106. package/src/biz/shared/overlay-compile.ts +281 -0
  107. package/src/biz/shared/overlay-shell.ts +142 -11
  108. package/src/biz/shared/pipes.ts +11 -5
  109. package/src/biz/shared/remove-wire.ts +4 -19
  110. package/src/biz/shared/runtime-hub.ts +10 -0
  111. package/src/biz/single-form/compile.ts +3 -2
  112. package/src/biz/single-form/shell.ts +9 -6
  113. package/src/biz/standard-crud/compile.ts +36 -161
  114. package/src/biz/standard-crud/shell.ts +23 -60
  115. package/src/biz/standard-crud/summary.ts +40 -0
  116. package/src/biz/step-form/shell.ts +15 -13
  117. package/src/biz/types.ts +6 -1
  118. package/src/cli/kit-cli.ts +138 -13
  119. package/src/cli/kit-init.ts +6 -1
  120. package/src/cli/layout-cli.ts +167 -0
  121. package/src/cli/migrate/index.ts +10 -0
  122. package/src/cli/migrate/migrate.ts +248 -0
  123. package/src/cli/migrate/text-utils.ts +306 -0
  124. package/src/cli/migrate/theme-map.ts +104 -0
  125. package/src/cli/migrate/ts-rules.ts +235 -0
  126. package/src/cli/migrate/types.ts +95 -0
  127. package/src/cli/migrate/view-skeleton.ts +159 -0
  128. package/src/cli/migrate/yaml-report.ts +376 -0
  129. package/src/cli/migrate/yaml-rules.ts +465 -0
  130. package/src/cli/view-writes.ts +69 -60
  131. package/src/compile/access-gate-attach.ts +27 -0
  132. package/src/compile/closed-set.ts +65 -4
  133. package/src/compile/compile-page.ts +66 -11
  134. package/src/compile/component-candidates.ts +14 -1
  135. package/src/compile/fragment.ts +11 -0
  136. package/src/compile/layout-lint/engine.ts +82 -0
  137. package/src/compile/layout-lint/index.ts +55 -0
  138. package/src/compile/layout-lint/rules-composition.ts +267 -0
  139. package/src/compile/layout-lint/rules-form.ts +191 -0
  140. package/src/compile/layout-lint/rules-table.ts +278 -0
  141. package/src/compile/layout-lint/score.ts +52 -0
  142. package/src/compile/layout-lint/types.ts +51 -0
  143. package/src/compile/page-composition.ts +189 -0
  144. package/src/compile/parse.ts +4 -0
  145. package/src/compile/producer-fingerprint.ts +56 -0
  146. package/src/compile/remove-guard.ts +10 -7
  147. package/src/compile/styles.ts +46 -8
  148. package/src/compile/types.ts +16 -2
  149. package/src/compile/view-check.ts +149 -16
  150. package/src/data/access-gate.ts +112 -0
  151. package/src/data/amount-breakdown.ts +9 -2
  152. package/src/data/approval-flow.ts +5 -2
  153. package/src/data/assignment-picker.ts +59 -28
  154. package/src/data/async-result-panel.ts +49 -3
  155. package/src/data/breadcrumbs.ts +3 -2
  156. package/src/data/calendar.ts +8 -3
  157. package/src/data/carousel.ts +10 -6
  158. package/src/data/chart.ts +744 -46
  159. package/src/data/checklist.ts +22 -6
  160. package/src/data/code-view.ts +8 -4
  161. package/src/data/comment-thread.ts +3 -2
  162. package/src/data/confirm-dialog.ts +72 -25
  163. package/src/data/context-menu.ts +3 -3
  164. package/src/data/dock.ts +1 -1
  165. package/src/data/embed.ts +231 -29
  166. package/src/data/field-mapper.ts +7 -4
  167. package/src/data/flow-editor-contract.ts +7 -0
  168. package/src/data/flow-editor.ts +26 -9
  169. package/src/data/flow-node-options.ts +33 -3
  170. package/src/data/footer.ts +2 -0
  171. package/src/data/gantt.ts +192 -27
  172. package/src/data/hero.ts +4 -1
  173. package/src/data/image-viewer.ts +7 -4
  174. package/src/data/index.ts +16 -4
  175. package/src/data/item-list.ts +27 -12
  176. package/src/data/kanban.ts +41 -10
  177. package/src/data/matrix.ts +391 -0
  178. package/src/data/media-grid.ts +6 -1
  179. package/src/data/mega-menu.ts +6 -4
  180. package/src/data/menu-dom.ts +4 -2
  181. package/src/data/menu.ts +60 -16
  182. package/src/data/mockup.ts +5 -1
  183. package/src/data/modal-dialog.ts +146 -26
  184. package/src/data/navbar.ts +8 -6
  185. package/src/data/notice-list.ts +301 -0
  186. package/src/data/notify-renderer.ts +21 -6
  187. package/src/data/object-form.ts +409 -87
  188. package/src/data/outcome-watch.ts +61 -2
  189. package/src/data/pager.ts +19 -8
  190. package/src/data/panel-head.ts +406 -0
  191. package/src/data/permission-matrix.ts +36 -11
  192. package/src/data/permission-tree.ts +52 -23
  193. package/src/data/pricing-table.ts +22 -11
  194. package/src/data/prompt-dialog.ts +165 -0
  195. package/src/data/reaction-bar.ts +6 -4
  196. package/src/data/record-card.ts +40 -7
  197. package/src/data/record-picker.ts +13 -7
  198. package/src/data/resident.ts +8 -0
  199. package/src/data/result-panel.ts +4 -2
  200. package/src/data/rich-text.ts +17 -1
  201. package/src/data/row-editor.ts +77 -24
  202. package/src/data/rule-builder.ts +14 -9
  203. package/src/data/shape-util.ts +27 -12
  204. package/src/data/stat-group.ts +459 -74
  205. package/src/data/static-lazy.ts +5 -0
  206. package/src/data/static-registry.ts +8 -0
  207. package/src/data/steps.ts +8 -3
  208. package/src/data/survey.ts +7 -4
  209. package/src/data/system-switcher.ts +3 -2
  210. package/src/data/text-action-button.ts +17 -0
  211. package/src/data/timeline.ts +17 -6
  212. package/src/data/tour-guide.ts +3 -2
  213. package/src/data/transfer.ts +40 -16
  214. package/src/data/tree-table.ts +65 -37
  215. package/src/data/tree.ts +22 -2
  216. package/src/data/virtual-rows.ts +21 -11
  217. package/src/data/wrapped-candidates.ts +32 -1
  218. package/src/frames/index.ts +1 -0
  219. package/src/frames/list-summary.ts +100 -0
  220. package/src/frames/page-bar.ts +7 -14
  221. package/src/frames/page-status.ts +7 -5
  222. package/src/frames/shared.ts +34 -13
  223. package/src/frames/split-frame/shell.ts +1 -1
  224. package/src/frames/tabs-frame/shell.ts +9 -6
  225. package/src/frames/tabs-frame/wiring.ts +1 -0
  226. package/src/frames/top-main-frame.ts +3 -3
  227. package/src/frames/types.ts +3 -1
  228. package/src/frames/workspace-frame/extras.ts +1 -1
  229. package/src/frames/workspace-frame/shell.ts +4 -4
  230. package/src/frames/workspace-frame/tab-scroll.ts +28 -0
  231. package/src/frames/workspace-frame/view.ts +168 -44
  232. package/src/generated/kit-grammar-runtime.ts +390 -59
  233. package/src/i18n/kit-text.ts +90 -4
  234. package/src/i18n/resolve-text-refs.ts +22 -6
  235. package/src/object-renderer/action-group.ts +139 -0
  236. package/src/object-renderer/action-more.ts +144 -0
  237. package/src/object-renderer/arrange.ts +71 -7
  238. package/src/object-renderer/candidates.ts +4 -0
  239. package/src/object-renderer/collection-parts.ts +264 -62
  240. package/src/object-renderer/collection-table.ts +177 -5
  241. package/src/object-renderer/collection.ts +188 -37
  242. package/src/object-renderer/compile-data.ts +28 -3
  243. package/src/object-renderer/defaults.ts +27 -2
  244. package/src/object-renderer/display-checks.ts +1 -1
  245. package/src/object-renderer/emit-events.ts +43 -9
  246. package/src/object-renderer/emit-object.ts +4 -0
  247. package/src/object-renderer/emit-static.ts +434 -41
  248. package/src/object-renderer/filter-plan.ts +84 -0
  249. package/src/object-renderer/form-detail.ts +1 -2
  250. package/src/object-renderer/form-notify.ts +45 -0
  251. package/src/object-renderer/index.ts +5 -0
  252. package/src/object-renderer/layout-facts.ts +394 -0
  253. package/src/object-renderer/layout-plan.ts +225 -0
  254. package/src/object-renderer/layout-plan.types.ts +59 -0
  255. package/src/object-renderer/parts.ts +6 -7
  256. package/src/object-renderer/render-object.ts +107 -46
  257. package/src/object-renderer/request-actions.ts +4 -2
  258. package/src/object-renderer/skeleton.ts +58 -19
  259. package/src/object-renderer/table-actions.ts +172 -32
  260. package/src/object-renderer/table-gap.ts +37 -0
  261. package/src/object-renderer/table-tools.ts +62 -30
  262. package/src/object-renderer/types.ts +84 -13
  263. package/src/object-renderer/view-binding.ts +205 -8
  264. package/src/page-target/intent-schema.ts +11 -0
  265. package/src/page-target/target.ts +5 -1
  266. package/src/recipes/container.ts +77 -1
  267. package/src/recipes/control.ts +76 -116
  268. package/src/recipes/emphasis.ts +56 -0
  269. package/src/recipes/frame-bleed.ts +33 -0
  270. package/src/recipes/index.ts +72 -0
  271. package/src/recipes/nowrap.ts +16 -0
  272. package/src/recipes/overlay.ts +120 -17
  273. package/src/recipes/placeholder.ts +95 -0
  274. package/src/recipes/rail-grid.ts +48 -0
  275. package/src/recipes/slot-align.ts +56 -0
  276. package/src/recipes/stat-state.ts +65 -0
  277. package/src/recipes/state.ts +40 -21
  278. package/src/recipes/status.ts +147 -0
  279. package/src/recipes/surface-edge.ts +16 -0
  280. package/src/recipes/surface.ts +40 -0
  281. package/src/recipes/table-gap.ts +80 -0
  282. package/src/recipes/table-native-edit.ts +242 -0
  283. package/src/recipes/table-row.ts +146 -3
  284. package/src/recipes/tabs.ts +49 -0
  285. package/src/recipes/title-row.ts +37 -0
  286. package/src/recipes/typography.ts +30 -37
  287. package/src/shared/confirm-decl.ts +118 -0
  288. package/src/shared/envelope.ts +2 -2
  289. package/src/shared/paged-list-adapter.ts +15 -240
  290. package/src/shared/theme-runtime-shared.ts +6 -1
  291. package/src/theme/index.ts +1 -0
  292. package/src/theme/kit-theme-text.ts +1 -1
  293. package/src/theme/kit-theme.css +384 -13
  294. package/src/theme/kit-theme.tpl +384 -13
  295. package/src/theme/nine-dim-structure.ts +244 -7
  296. package/src/theme/surface-layers.ts +10 -1
  297. package/src/theme/theme-tokens.ts +63 -16
  298. package/src/theme/theme-types.ts +32 -0
  299. package/src/theme/typography.ts +21 -17
  300. package/src/biz/shared/remove-key.ts +0 -6
@@ -1,3 +1,4 @@
1
+ import { kitRowActionsNarrowCap } from 'soma-foundation/kit-layout';
1
2
  import { esc } from '../shared/escape';
2
3
  import { getCompileEnvelope } from '../shared/envelope';
3
4
  // emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
@@ -13,15 +14,25 @@ import { getCompileEnvelope } from '../shared/envelope';
13
14
  // prop 值规则(core resolvePropValue):字符串首段是已注册变量才算绑定路径,否则是字面量;
14
15
  // `!path` 取反写法已删除,kit 绑定路径一律是纯路径(取反另给成员),以 `!` 开头的普通文案原样显示。
15
16
 
16
- import { checkRowPath, checkViewPath, isRowPath, isViewPath, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
17
+ import { checkRowPath, checkViewPath, classifyDisabledReason, isRowPath, isViewPath, KIT_ACTION_REASON_KEY, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
17
18
  import type {
18
19
  KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
19
20
  } from './types';
20
21
  import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
21
- import type { KitSkeletonConfig } from './skeleton';
22
+ import type { KitSkeletonCol, KitSkeletonConfig } from './skeleton';
23
+ import { isNumericColumnType } from './collection-table';
24
+ import { mergeClass } from './merge-class';
25
+ import { projectActionGroup, type KitActionImportance } from './action-group';
26
+ import { kitTabRecipe } from '../recipes/tabs';
27
+ import { KIT_TABLE_GAP_HEAD_ATTR, tableGapReasonField } from '../recipes/table-gap';
28
+ import { kitTextActionRecipe } from '../recipes/control';
29
+ import { kitStatusPillProps } from '../recipes/emphasis';
30
+ import { KIT_OVERLAY_FORM_HOST_CLASS } from '../recipes/overlay';
31
+ import { KIT_PANEL_TITLE_CLASS, kitPanelTitleHtml } from '../recipes/title-row';
22
32
  import { headAnchor } from './compile-data';
23
33
  import { KIT_STATE_DEFAULT_TEXT } from './collection';
24
34
  import { kitText } from '../i18n/kit-text';
35
+ import { KIT_TIPS_SCOPE_ATTR, kitHelpButtonHtml } from '../base/hint-tips';
25
36
  import { expandHostId } from './collection-expand';
26
37
  import { busyActionOf } from '../base/action-busy';
27
38
  import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
@@ -36,7 +47,14 @@ export function rowVarOf(object: string): string { return `kit_row_${object}`; }
36
47
  // ---------------------------------------------------------------- 锚点命名
37
48
 
38
49
  export function viewAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}`; }
39
- export function cellAnchor(object: string, slot: KitViewSlot, field: string): string { return `${object}__${slot}__${field}`; }
50
+ /**
51
+ * 同槽(`<对象>__list__`)里集合自己的实例后缀:字段名撞上它们会让页面锚点重复(CORE-ANCHOR-DUPLICATE,整页 500)。
52
+ * `state` / `title` / `meta` 都是常见的业务字段名,所以字段单元锚点遇到这些后缀时追加 `_cell`,字段名不受限。
53
+ */
54
+ export const KIT_RESERVED_LIST_ANCHORS: ReadonlySet<string> = new Set(['ctx', 'exp', 'head', 'meta', 'ops', 'rows', 'sel', 'state', 'sum', 'title', 'tools', 'tree', 'virtual']);
55
+ export function cellAnchor(object: string, slot: KitViewSlot, field: string): string {
56
+ return `${object}__${slot}__${slot === 'list' && KIT_RESERVED_LIST_ANCHORS.has(field) ? `${field}_cell` : field}`;
57
+ }
40
58
  export function rowsAnchor(object: string): string { return `${object}__list__rows`; }
41
59
  export function opsAnchor(object: string): string { return `${object}__list__ops`; }
42
60
  /** 右键菜单实例(Q 波 G6):行模板里每行一个,虚拟滚动表 / 树表是页面里一个 */
@@ -52,6 +70,11 @@ function rowToneProp(layout: { rowTone?: string }, ctx: Ctx): { rowTone?: string
52
70
  return layout.rowTone !== undefined ? { rowTone: `${ctx.rowVar}.${layout.rowTone}` } : {};
53
71
  }
54
72
 
73
+ /** 树表 / 虚拟滚动表自己画行(拿到整行对象):只传行字段名(不是 core 路径),组件按行取值映射档位类 */
74
+ function rowToneFieldProp(layout: { rowTone?: string }): { rowToneField?: string } {
75
+ return layout.rowTone !== undefined ? { rowToneField: layout.rowTone } : {};
76
+ }
77
+
55
78
  /** 展开行:开合按钮实例(每行一个 KitTableActions expand) */
56
79
  export function treeAnchor(object: string): string { return `${object}__list__tree`; }
57
80
  /** 虚拟滚动表体 KitVirtualRows 实例(N3) */
@@ -61,6 +84,8 @@ export function expandToggleAnchor(object: string): string { return `${object}__
61
84
  export function expandCellAnchor(object: string, field: string): string { return `${object}__list__x__${field}`; }
62
85
  /** 集合三态面板实例 */
63
86
  export function stateAnchor(object: string): string { return `${object}__list__state`; }
87
+ /** 标题旁的集合辅助文字(共 N 条 / 已筛选提示):KitCollectionState 的 meta 形态实例 */
88
+ export function metaAnchor(object: string): string { return `${object}__list__meta`; }
64
89
  export function toolbarAnchor(object: string, actionId: string): string { return `${object}__tb_${actionId}`; }
65
90
  /** 表格工具与接线件(工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐),紧挨在表格外壳之前 */
66
91
  export function toolsAnchor(object: string): string { return `${object}__list__tools`; }
@@ -83,12 +108,19 @@ export interface KitStaticOptions {
83
108
  schema?: KitSchema;
84
109
  /** 是否有列表视图(决定 from 是否带 into);缺省由 IR 判断 */
85
110
  wrapped?: boolean;
111
+ /**
112
+ * 没有列表视图(from 不带 into,数据对象存的是原样响应)时,`accept: list` 的写死形状件(Chart 等)的行数组在响应体里的相对路径
113
+ * (来自 behavior.list.rowsPath);缺省时行数组就是数据对象本身
114
+ */
115
+ staticRowsPath?: string;
86
116
  /** 摘要 / 只读 form / single 写死形状件读的“当前行”路径(如 `page.region_mirror.<scope>.focus_row`);缺省同 singlePath */
87
117
  summaryPath?: string;
88
118
  /** 可编辑 form 的 mode 绑定路径(镜像路径);给了就不写死 formMode 字面量 */
89
119
  formModePath?: string;
90
120
  /** 可编辑 form 的 initial 绑定路径(镜像路径);缺省 `{}` */
91
121
  formInitialPath?: string;
122
+ /** 分页条的附加类(业务壳给:列表页贴工作面底 sticky + 轴内边距) */
123
+ pagerClass?: string;
92
124
  /** 表格行可点选:行容器标 data-kit-row,KitTableActions 开 pickOnRow,行点击抛 row_action(builtin select) */
93
125
  pickOnRow?: boolean;
94
126
  /**
@@ -126,15 +158,41 @@ function attr(name: string, value: string): string {
126
158
  return value === '' ? '' : ` ${name}="${esc(value)}"`;
127
159
  }
128
160
 
161
+ const OVERLAY_FOOTER_HOSTS: ReadonlySet<string> = new Set(['KitObjectForm', 'Transfer', 'PermissionTree', 'AssignmentPicker']);
162
+ const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitTableGap', 'KitCollectionState', 'Pager']);
163
+
129
164
  function host(component: string, id: string): string {
130
- return `<div data-soma-component="${esc(component)}" data-soma-id="${esc(id)}"></div>`;
165
+ // 自带底栏的表单 / 穿梭框 / 授权树,其宿主在浮层滚动体里是体的 flex 子项并撑满体高(底栏才能落在浮层底部);变体只在 group-data-kit-overlay-scroll 祖先下生效
166
+ // 根常带 hidden 的辅助宿主(表格工具位 / 三态面板 / 分页器):宿主 display: contents,不占 flex 子项的位——
167
+ // 否则它们空着时(0 高)仍被卡片的 flex gap 各多量出 12px(表格面板顶部的「空工具栏行」、底部多出的空白)
168
+ const cls = OVERLAY_FOOTER_HOSTS.has(component) ? ` class="${KIT_OVERLAY_FORM_HOST_CLASS}"` : COLLAPSING_HOSTS.has(component) ? ' class="contents"' : '';
169
+ return `<div data-soma-component="${esc(component)}" data-soma-id="${esc(id)}"${cls}></div>`;
131
170
  }
132
171
 
133
172
  const opsHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_ops', undefined, ctx.options.locale ?? '');
134
173
  const selectHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_select', undefined, ctx.options.locale ?? '');
135
174
  const cellRoleAttr = (role: string): string => (role === '' ? '' : ` role="${role}"`);
136
175
  /** 视图标题行(K-4):语义色名 + utilityScales 里有的尺度 */
137
- const VIEW_TITLE_CLASS = 'text-base font-semibold text-fg';
176
+
177
+ /** 显式 `bordered: true`(完整网格线)的表格外壳标 data-kit-grid:主题结构 CSS 只对没有这个标记的表壳去掉容器卡片外观(圆角 / 边框 / 阴影 / 底色) */
178
+ function gridMark(layout: { bordered?: boolean }): string {
179
+ return layout.bordered === true ? ' data-kit-grid=""' : '';
180
+ }
181
+
182
+ /** 树表「全部展开 / 全部收起」:文字链接形态,放在表格工具位(与刷新同一行、标题行右侧);点击由 KitTreeTable 按 data-kit-tree-for 认领 */
183
+ function renderTreeControls(ctx: Ctx): string {
184
+ const locale = ctx.options.locale ?? '';
185
+ const cls = kitTextActionRecipe('primary');
186
+ const one = (act: 'expand' | 'collapse', key: 'soma.kit.expand_all' | 'soma.kit.collapse_all'): string =>
187
+ `<button type="button" data-kit-tree-ctl="${act}" data-kit-tree-for="${esc(ctx.object)}"${attr('class', cls)}>${esc(kitText(key, undefined, locale))}</button>`;
188
+ return `${one('expand', 'soma.kit.expand_all')}${one('collapse', 'soma.kit.collapse_all')}`;
189
+ }
190
+
191
+ /** 去掉栅格跨度类(`col-span-N` 与各容器档变体),换成流式版式的宽度类 */
192
+ function swapSpanForWidth(cellClass: string, widthClass: string): string {
193
+ const kept = cellClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?col-span-\d+$/.test(t));
194
+ return [...kept, widthClass, 'min-w-0'].filter((t) => t !== '').join(' ');
195
+ }
138
196
 
139
197
  function joinClasses(a: string, b: string): string {
140
198
  return [a, b].filter((s) => s !== '').join(' ');
@@ -166,6 +224,31 @@ interface Ctx {
166
224
  /** 列表对象整体路径(page.data.<对象>),三态面板据此判定 */
167
225
  basePath: string;
168
226
  scope(): string;
227
+ /** 筛选栏(非写死形状)的宿主锚点:集合的「清除筛选」优先点它的「重置」;本对象没有筛选栏为 undefined */
228
+ filterId?: string;
229
+ /** 表头筛选写进 view 切片的键(列表是带表头筛选的表格时非空) */
230
+ columnParams?: string[];
231
+ }
232
+
233
+ /**
234
+ * 集合标题旁的辅助文字(KitCollectionState meta 形态)计划:
235
+ * - count:有标题行的非分页集合(table / cards / stack,树表不算)自动显示「共 N 条」(分页集合由分页器显示总数,不重复);
236
+ * `collection.count: false` 关闭;
237
+ * - hint:本对象有筛选栏(非写死形状)或表头筛选时,被筛选状态下显示「已筛选 · N 项条件 清除」。
238
+ * 都不需要返回 null(不发射实例)。emitStatic 与 emitEvents 共用这一份判定,事件键与实例锚点才对得上。
239
+ */
240
+ export function collectionMetaOf(ir: KitObjectIR): { count: boolean; hint: boolean } | null {
241
+ const list = ir.views.list;
242
+ if (list === undefined) return null;
243
+ const l = list.layout;
244
+ if (l.kind !== 'table' && l.kind !== 'cards' && l.kind !== 'stack') return null;
245
+ if (l.kind === 'table' && l.tree !== null) return null;
246
+ const titled = typeof list.title === 'string' && list.title !== '';
247
+ const count = titled && l.pager === null && l.showCount !== false;
248
+ const hasFilterForm = ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static';
249
+ const hasColumnFilter = l.kind === 'table' && l.head.some((h) => h.filter !== undefined);
250
+ const hint = hasFilterForm || hasColumnFilter;
251
+ return count || hint ? { count, hint } : null;
169
252
  }
170
253
 
171
254
  /** 列表响应里错误文案的缺省路径(listShape.errorPath 可改) */
@@ -180,10 +263,20 @@ const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
180
263
  function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Record<string, unknown> {
181
264
  const props: Record<string, unknown> = { value: valuePath };
182
265
  for (const [k, v] of Object.entries(cell.props)) props[k] = v;
266
+ // 字段项 props 绑 row.<字段>(RV-1119):行模板里 core 逐行求值(行变量.<字段>),业务对象逐行给值,页面不算
267
+ for (const [k, field] of Object.entries(cell.rowProps ?? {})) props[k] = `${ctx.rowVar}.${field}`;
183
268
  if (LABELLED_CELL_CONTROLS.has(cell.component) && props.aria_label === undefined && Boolean(cell.label)) {
184
269
  props.aria_label = cell.label;
185
270
  }
186
271
  if (cell.valueClass !== '') props.class = cell.valueClass;
272
+ // 状态类字段(单选枚举且选项带 tone)默认呈现为状态徽标(emphasis.status = pill:浅色底 + on-soft 字 + 6px 圆点),全应用统一,与紧凑列表、表格一致;
273
+ // 圆点 + 文字(dot)形态只留给页面显式写的 variant: dot
274
+ // 集合里(表格 / 紧凑列表)作者写的 `variant: dot` 与不写等价——「全应用统一」是框架默认值的事,不逐页改应用页面;dot 形态留给集合之外的 Tag / StatusDot 用法
275
+ if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) {
276
+ const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
277
+ const opts = Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
278
+ if (field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>))) Object.assign(props, kitStatusPillProps());
279
+ }
187
280
  return props;
188
281
  }
189
282
 
@@ -191,6 +284,9 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Rec
191
284
 
192
285
  type IdOf = (field: string) => string;
193
286
 
287
+ /** 类串里有 truncate(含变体前缀与 `**:truncate` 这类后代选择写法):这类格的文字可能被截断 */
288
+ const TRUNCATING_CLASS_RE = /(?:^|\s)(?:[a-z0-9*@-]+:)*truncate(?=\s|$)/;
289
+
194
290
  function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string, at: string, showInto: Record<string, unknown>, idOf?: IdOf): string {
195
291
  if (cell.placeholder === true || cell.component === '') {
196
292
  return `<div${attr('class', cell.cellClass)}></div>`;
@@ -199,8 +295,12 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
199
295
  ctx.components.add(cell.component);
200
296
  showInto[id] = { props: cellProps(ctx, cell, valuePath, at) };
201
297
  const star = cell.required === undefined ? '' : `<span${attr('class', KIT_REQUIRED_STAR_CLASS[cell.required])} aria-hidden="true">*</span>`;
202
- const label = !cell.label ? '' : `<span${attr('class', cell.labelClass)}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}</span>`;
203
- 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"' : ''}`;
298
+ // 只读格的字段说明(J9):标签旁一个「i」图标钮(没有 help 的格不出节点);气泡由 base/hint-tips 的委托在悬停 / 聚焦时才建
299
+ const helpBtn = !cell.label ? '' : kitHelpButtonHtml(cell.helpTip ?? '', cell.label, ctx.options.locale ?? '');
300
+ const label = !cell.label ? '' : `<span${attr('class', cell.labelClass)}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}${helpBtn}</span>`;
301
+ // 值可能被截断(格 / 值类里带 truncate)的格标出提示作用范围,截断了才有全文提示(J10);不截断的格输出不变
302
+ const truncating = TRUNCATING_CLASS_RE.test(`${cell.cellClass} ${cell.valueClass}`);
303
+ 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}=""` : ''}`;
204
304
  // summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
205
305
  if (cell.hideEmpty === true) {
206
306
  const cellId = `${id}__cell`;
@@ -290,7 +390,8 @@ export function groupTabAnchor(object: string, slot: KitViewSlot, index: number
290
390
  export function groupPanelAnchor(object: string, slot: KitViewSlot, index: number | string): string { return `${object}__${slot}__gpanel__${index}`; }
291
391
  export function groupTabWireAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gwire`; }
292
392
 
293
- const GROUPS_AS = KIT_GRAMMAR.formLinkage.groupsAs as { barClass: string; tabClass: string };
393
+ // 分组页签的类:页签呈现唯一出口 recipes/tabs(与页内页签 / 外壳页签条同一套)
394
+ const GROUPS_AS = { barClass: `mb-4 ${kitTabRecipe().bar}`, tabClass: kitTabRecipe().tab };
294
395
 
295
396
  /**
296
397
  * groups 呈现为页签:tablist + 若干 tab 按钮 + 各组面板(首签显示,其余外层 hidden)。
@@ -334,7 +435,7 @@ export function groupTabsFrame(
334
435
  showInto: Record<string, unknown>,
335
436
  components: Set<string>,
336
437
  ): string {
337
- 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('');
438
+ 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('');
338
439
  const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}"${i === 0 ? '' : ' hidden'}>${inner}</div>`).join('');
339
440
  const wireId = groupTabWireAnchor(object, slot);
340
441
  components.add('KitTabsWiring');
@@ -363,9 +464,17 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
363
464
  // K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
364
465
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
365
466
  ...(a.more === true ? { more: true } : {}),
467
+ // 置灰原因的字面量文案(只有写了 disabled 的动作才有意义);row. / view. 路径形走 actionState 的叶子,不进这里
468
+ ...(a.disabled !== undefined ? literalReason(a) : {}),
366
469
  }));
367
470
  }
368
471
 
472
+ /** 动作的置灰原因:字面量文案(非空)原样带;路径形与非法值不带(路径进 actionState,非法值已在入口记诊断) */
473
+ function literalReason(a: KitAction): { disabledReason?: string } {
474
+ const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
475
+ return source.kind === 'literal' && source.text.trim() !== '' ? { disabledReason: source.text } : {};
476
+ }
477
+
369
478
  /**
370
479
  * 行动作的行级状态绑定:on: row 动作的 hidden / disabled(row.<字段>,业务对象逐行给出)编成
371
480
  * { 动作id: { hidden?, disabled? } },叶子是 core 行路径(行变量.<字段>),由 core 在行模板里逐行求值。
@@ -381,14 +490,29 @@ function actionStateProp(actions: readonly KitAction[], ctx: Ctx): { actionState
381
490
  // 行动作也可以绑展示对象成员(view.<成员>,编成页面变量 page.<成员>,行模板里 core 逐行求值同一个值),与 row.<字段> 二选一
382
491
  else if (isViewPath(raw)) (state[a.id] ??= {})[key] = viewPathToCore(raw);
383
492
  }
493
+ // 置灰原因:row.<字段> / view.<成员> 编成同一个叶子(core 逐行求值成文案);字面量走 actionItems 的 disabledReason
494
+ if (a.disabled !== undefined) {
495
+ const reason = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
496
+ if (reason.kind === 'row') (state[a.id] ??= {})[KIT_ACTION_REASON_KEY] = rowPathToCore(reason.path, ctx.rowVar);
497
+ else if (reason.kind === 'view') (state[a.id] ??= {})[KIT_ACTION_REASON_KEY] = viewPathToCore(reason.path);
498
+ }
384
499
  }
385
500
  return Object.keys(state).length > 0 ? { actionState: state } : {};
386
501
  }
387
502
 
503
+ /** treeTable / 虚拟滚动表的列单元由组件自己按行渲染,字段项 props 的 row.<字段> 没有行模板可绑:写了记 KIT-ROW-002(不静默失效) */
504
+ function rejectRowProps(cells: readonly KitCell[], ctx: Ctx, where: string): void {
505
+ for (const c of cells) {
506
+ for (const k of Object.keys(c.rowProps ?? {})) {
507
+ ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `views.list.${c.field}.props.${k}`, message: `${where}的列单元不支持字段项 props 绑 row.<字段>(字段 ${c.field} 的 props.${k});用普通表格 / cards / stack,或让接口逐行给成品字段后直接作为列` });
508
+ }
509
+ }
510
+ }
511
+
388
512
  /** treeTable / 虚拟滚动表的行操作与右键菜单不支持行级状态绑定:写了记 KIT-ROW-002(动作照常渲染,绑定被忽略) */
389
513
  function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string): void {
390
514
  for (const a of actions) {
391
- for (const key of KIT_ROW_ACTION_KEYS) {
515
+ for (const key of [...KIT_ROW_ACTION_KEYS, KIT_ACTION_REASON_KEY]) {
392
516
  if (a.on === 'row' && a[key] !== undefined) {
393
517
  ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `behavior.actions.${a.id}.${key}`, message: `${where}的行操作 / 右键菜单不支持行级状态绑定(动作 ${a.id} 的 ${key})` });
394
518
  }
@@ -396,14 +520,32 @@ function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string):
396
520
  }
397
521
  }
398
522
 
523
+ /**
524
+ * 表格的缺失值列:schema 里同时声明了 `<字段>` 与 `<字段>_reason`(缺失原因字段,后缀读真源)的只读文字类列,
525
+ * 单元格改用 GapValue 的 plain 形态(缺失 = 次级色短横 + 悬停原因;有值 = 与 Text 同一套格式化)。
526
+ * 带选项(徽标)的列不动。返回 字段名 -> 改写后的格。
527
+ */
528
+ function gapColumnsOf(ctx: Ctx, cells: readonly KitCell[]): Map<string, KitCell> {
529
+ const out = new Map<string, KitCell>();
530
+ const schema = ctx.options.schema;
531
+ for (const c of cells) {
532
+ if (c.component !== 'Text' || c.mode !== 'show' || c.placeholder === true || c.props.options !== undefined) continue;
533
+ const reasonField = tableGapReasonField(c.field);
534
+ if (schema === undefined || schema[reasonField] === undefined || c.rowProps?.reason !== undefined) continue;
535
+ out.set(c.field, { ...c, component: 'GapValue', props: { ...c.props, plain: true }, rowProps: { ...(c.rowProps ?? {}), reason: reasonField } });
536
+ }
537
+ return out;
538
+ }
539
+
399
540
  function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>): string {
400
541
  const object = ctx.object;
401
542
  const at = 'views.list.layout';
402
543
  const rowShow: Record<string, unknown> = {};
544
+ const gapCols = layout.tree === null && layout.virtual === undefined ? gapColumnsOf(ctx, layout.cells) : new Map<string, KitCell>();
403
545
 
404
546
  const tools = layout.tools === true && layout.tree === null;
405
547
  const selHead = layout.selectHeadClass ?? layout.selectClass;
406
- const actHead = layout.actionsHeadClass ?? layout.actionsClass;
548
+ const actHead = `${layout.actionsHeadClass ?? layout.actionsClass} text-end`;
407
549
  // 表格语义(W3C table 模式:table > row > columnheader / cell,aria-sort 在 columnheader 上):
408
550
  // 树表(外壳由 KitTreeTable 自带 treegrid,表头在它之外)与展开详情行(行下挂非 row 的开关与详情体)不满足 table 的结构要求,这两种不写表格角色
409
551
  const semTable = layout.tree === null && layout.expand === null;
@@ -422,6 +564,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
422
564
  ...(h.filter !== undefined ? { filter: h.filter } : {}),
423
565
  ...(h.group !== undefined ? { group: h.group } : {}),
424
566
  ...(tools && h.resizable === true ? { resizable: true } : {}),
567
+ ...(h.help !== undefined ? { help: h.help } : {}),
568
+ ...(h.col !== undefined && gapCols.has(h.col) ? { gapField: h.col } : {}),
425
569
  });
426
570
  }
427
571
  if (layout.rowActions.length > 0) cells.push({ label: opsHeadLabel(ctx), class: actHead });
@@ -429,6 +573,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
429
573
  ctx.show[headAnchor(object)] = {
430
574
  props: {
431
575
  cells, scope: ctx.scope(), class: layout.headClass, ...(semTable ? { semantics: 'table' } : {}),
576
+ ...(gapCols.size > 0 ? { rows: ctx.rowsPath } : {}),
432
577
  // 读状态:点表头排序后重取失败,表头据此把 sort / order / page 回滚到最近一次读成功的值
433
578
  readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
434
579
  ...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
@@ -453,7 +598,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
453
598
  };
454
599
  for (const h of layout.head) {
455
600
  if (h.group !== openGroup) flushGroup();
456
- 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>`;
601
+ const leaf = `<div${headRole}${tools && h.col !== undefined ? ` data-kit-col="${esc(h.col)}"` : ''}${h.col !== undefined && gapCols.has(h.col) ? ` ${KIT_TABLE_GAP_HEAD_ATTR}="${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>`;
457
602
  if (h.group === undefined) headParts.push(leaf);
458
603
  else {
459
604
  openGroup = h.group;
@@ -469,6 +614,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
469
614
  if (layout.tree !== null) {
470
615
  const id = treeAnchor(object);
471
616
  rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, 'treeTable');
617
+ rejectRowProps(layout.cells, ctx, 'treeTable');
472
618
  ctx.components.add('KitTreeTable');
473
619
  ctx.show[id] = {
474
620
  props: {
@@ -481,6 +627,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
481
627
  selectClass: layout.selectClass,
482
628
  actionsClass: layout.actionsClass,
483
629
  actions: actionItems(layout.rowActions, ctx),
630
+ ...rowToneFieldProp(layout),
484
631
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
485
632
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
486
633
  ...selectedProps(ctx),
@@ -496,8 +643,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
496
643
  }
497
644
  const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
498
645
  const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
499
- const treeBody = `<div${attr('class', layout.wrapClass)}${treeWrapA11y}${treeCtx !== '' ? ' data-kit-ctxhost=""' : ''}><div${attr('class', layout.innerClass)}>${head}${host('KitTreeTable', id)}${treeCtx}</div></div>`;
500
- return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
646
+ 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>`;
647
+ return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
501
648
  }
502
649
 
503
650
  // 虚拟滚动(N3):表头 / 三态 / 分页 / 工具与普通表格同一条路径,只有表体换成 KitVirtualRows(窗口内的行由组件画)
@@ -524,11 +671,11 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
524
671
  rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('Checkbox', selAnchor(object))}</div>`);
525
672
  }
526
673
  }
527
- layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
674
+ layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, gapCols.get(c.field) ?? c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
528
675
  if (layout.rowActions.length > 0) {
529
676
  ctx.components.add('KitTableActions');
530
677
  rowShow[opsAnchor(object)] = {
531
- 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) },
678
+ 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), ...(layout.tools === true && (layout.batch?.length ?? 0) > 0 && ctx.options.selectedPath !== undefined ? { bulkLock: true } : {}) },
532
679
  };
533
680
  rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.actionsClass)}>${host('KitTableActions', opsAnchor(object))}</div>`);
534
681
  }
@@ -549,9 +696,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
549
696
  // 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
550
697
  const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
551
698
  const rowMark = `${marked ? ' data-kit-row=""' : ''}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}`;
552
- const stripe = layout.stripeClass;
553
- const striped = stripe !== '';
554
- const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInner) : rowClass;
699
+ // 普通表格的行容器首子节点是 <template>,数据行从第 2 个子节点起:斑马纹用 odd 键(树表 / 虚拟表无 template,走 IR 里的 even 键)
700
+ const striped = layout.stripeClass !== '';
701
+ const stripe = striped ? KIT_CLASS_DEFAULTS.tableRowStripedAfterTemplate : '';
702
+ const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInnerAfterTemplate) : rowClass;
555
703
  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>`;
556
704
  let itemHtml = rowEl;
557
705
  if (layout.expand !== null) {
@@ -581,8 +729,16 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
581
729
  const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
582
730
  const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
583
731
  const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
584
- 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}"><div${tableA11y}${attr('class', layout.innerClass)}>${head}${rows}${summary}</div></div>`;
585
- return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
732
+ // 静态表头(不可排序)的整列缺失原因标注由 KitTableGap 接线件画;可排序表头由 KitTableHead 自己画(上面已给 rows)
733
+ let gapHost = '';
734
+ if (gapCols.size > 0 && !layout.sort) {
735
+ const gapId = `${object}__table_gap`;
736
+ ctx.components.add('KitTableGap');
737
+ ctx.show[gapId] = { props: { rows: ctx.rowsPath, fields: [...gapCols.keys()] } };
738
+ gapHost = host('KitTableGap', gapId);
739
+ }
740
+ 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)}>${gapHost}${head}${rows}${summary}</div></div>`;
741
+ return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
586
742
  }
587
743
 
588
744
  /**
@@ -595,6 +751,7 @@ function renderVirtualTable(
595
751
  const object = ctx.object;
596
752
  const id = virtualAnchor(object);
597
753
  rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, '虚拟滚动表');
754
+ rejectRowProps(layout.cells, ctx, '虚拟滚动表');
598
755
  ctx.components.add('KitVirtualRows');
599
756
  ctx.show[id] = {
600
757
  props: {
@@ -608,6 +765,7 @@ function renderVirtualTable(
608
765
  actionsClass: layout.actionsClass,
609
766
  actions: actionItems(layout.rowActions, ctx),
610
767
  label: object,
768
+ ...rowToneFieldProp(layout),
611
769
  colCount: layout.cells.length + (layout.select !== 'none' ? 1 : 0) + (layout.rowActions.length > 0 ? 1 : 0),
612
770
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
613
771
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
@@ -625,9 +783,9 @@ function renderVirtualTable(
625
783
  }
626
784
  const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
627
785
  const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
628
- const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''}>`
786
+ 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))}"` : ''}>`
629
787
  + `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
630
- return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
788
+ return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
631
789
  }
632
790
 
633
791
  /** 表格工具与接线件:工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐。放在表格外壳之前 */
@@ -703,11 +861,23 @@ function renderSummary(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>
703
861
  }
704
862
 
705
863
  /** 骨架屏的形态参数:表格按列的跨度类(含选择 / 操作列),cards / stack 沿用列表容器类 */
706
- function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>): KitSkeletonConfig {
864
+ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>, schema?: KitSchema): KitSkeletonConfig {
707
865
  if (layout.kind === 'table') {
708
- const cols = [
866
+ // 数据列形态:数值 -> number;枚举 / 布尔 / Tag 单元 -> tag;其余文本列里第一个 -> title,其它 -> text(text 仍输出字符串,保持旧形状)
867
+ let titleTaken = false;
868
+ const dataCols = layout.head.map((h, i): string | KitSkeletonCol => {
869
+ const field = layout.cells[i]?.field ?? h.col ?? '';
870
+ const type = schema?.[field]?.type;
871
+ let shape: KitSkeletonCol['shape'];
872
+ if (isNumericColumnType(type)) shape = 'number';
873
+ else if (type === 'enum' || type === 'enums' || type === 'bool' || layout.cells[i]?.component === 'Tag') shape = 'tag';
874
+ else if (!titleTaken) { shape = 'title'; titleTaken = true; }
875
+ else shape = 'text';
876
+ return shape === 'text' ? h.class : { cls: h.class, shape };
877
+ });
878
+ const cols: Array<string | KitSkeletonCol> = [
709
879
  ...(layout.select !== 'none' && layout.selectClass !== '' ? [layout.selectClass] : []),
710
- ...layout.head.map((h) => h.class),
880
+ ...dataCols,
711
881
  ...(layout.rowActions.length > 0 && layout.actionsClass !== '' ? [layout.actionsClass] : []),
712
882
  ];
713
883
  return { kind: 'table', cols };
@@ -719,6 +889,9 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
719
889
  const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
720
890
  const EXPAND_BODY_CLASS = 'border-b border-border-subtle bg-surface-sunken px-4 py-3';
721
891
 
892
+ /** 标题与它旁边的集合辅助文字(共 N 条 / 已筛选提示)同一组:基线对齐、窄时换行 */
893
+ const TITLE_GROUP_CLASS = 'flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1';
894
+
722
895
  /** 集合三态面板:列表之后、分页器之前 */
723
896
  function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
724
897
  if (state === null) return '';
@@ -739,12 +912,59 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
739
912
  error: state.error,
740
913
  ...(state.skeleton === true && shape !== undefined ? { skeleton: shape } : {}),
741
914
  ...(state.errorOnly === true ? { mode: 'errorOnly' } : {}),
915
+ // 筛选无结果 / 无数据的区分:本对象有筛选栏或表头筛选时,把作用域与清除入口交给三态面板(没有筛选的页面配置不变)
916
+ ...filteredConfig(ctx),
742
917
  },
743
918
  },
744
919
  };
745
920
  return host('KitCollectionState', id);
746
921
  }
747
922
 
923
+ /** 集合被筛选状态判断所需的配置:区域作用域、筛选栏宿主锚点(清除时优先点它的「重置」)、表头筛选键;对象没有任何筛选则为空 */
924
+ function filteredConfig(ctx: Ctx): Record<string, unknown> {
925
+ const columnParams = ctx.columnParams ?? [];
926
+ if (ctx.filterId === undefined && columnParams.length === 0) return {};
927
+ return {
928
+ scope: ctx.scope(),
929
+ ...(ctx.filterId !== undefined ? { filterId: ctx.filterId } : {}),
930
+ ...(columnParams.length > 0 ? { columnParams } : {}),
931
+ };
932
+ }
933
+
934
+ /** 标题旁的集合辅助文字实例(KitCollectionState 的 meta 形态):共 N 条 / 已筛选提示 */
935
+ function renderMeta(ctx: Ctx, plan: { count: boolean; hint: boolean }): string {
936
+ const id = metaAnchor(ctx.object);
937
+ ctx.components.add('KitCollectionState');
938
+ const paths = readStatePathsOf(ctx.object, ctx.basePath);
939
+ ctx.show[id] = {
940
+ props: {
941
+ data: ctx.basePath,
942
+ rows: ctx.rowsPath,
943
+ config: {
944
+ mode: 'meta',
945
+ object: ctx.object,
946
+ rowsPath: ctx.options.listShape.rows,
947
+ totalPath: ctx.options.listShape.total,
948
+ errorPath: typeof ctx.options.listShape.errorPath === 'string' ? ctx.options.listShape.errorPath : KIT_LIST_ERROR_PATH,
949
+ readStatePath: paths.readStatePath,
950
+ errorMessagePath: paths.errorMessagePath,
951
+ ...(plan.count ? { count: true } : {}),
952
+ ...(plan.hint ? { hint: true, ...filteredConfig(ctx) } : {}),
953
+ },
954
+ },
955
+ };
956
+ return host('KitCollectionState', id);
957
+ }
958
+
959
+ /** 面板标题绑展示对象只读成员(view.list.title: view.<成员>):h3 里放一个 Text 实例,值是 page.<成员>,成员变了标题被动刷新 */
960
+ function renderDynamicTitle(ctx: Ctx, slot: KitViewSlot, path: string): string {
961
+ const id = `${viewAnchor(ctx.object, slot)}__title`;
962
+ const textId = `${id}__text`;
963
+ ctx.components.add('Text');
964
+ ctx.show[textId] = { props: { value: viewPathToCore(path) } };
965
+ return `<h3 data-soma-id="${esc(id)}" data-kit-part="${KIT_PART_TITLE_SECTION}" class="${KIT_PANEL_TITLE_CLASS}">${host('Text', textId)}</h3>`;
966
+ }
967
+
748
968
  function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boolean; mode?: string; layout?: string; showTotal?: boolean } | null): string {
749
969
  if (pager === null) return '';
750
970
  const id = pagerAnchorOf(ctx.object);
@@ -754,6 +974,7 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
754
974
  scope: ctx.scope(), total: ctx.totalPath, size: pager.size, sizes: pager.sizes, jump: pager.jump,
755
975
  // 读状态:翻页后重取失败,分页器据此把页码 / 页长回滚到最近一次读成功的值
756
976
  readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
977
+ ...(ctx.options.pagerClass !== undefined ? { class: ctx.options.pagerClass } : {}),
757
978
  ...(pager.mode !== undefined ? { mode: pager.mode } : {}),
758
979
  ...(pager.layout !== undefined ? { layout: pager.layout } : {}),
759
980
  ...(pager.showTotal === false ? { show_total: false } : {}),
@@ -762,16 +983,66 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
762
983
  return host('Pager', id);
763
984
  }
764
985
 
986
+ /**
987
+ * 紧凑列表的条目正文:主标题一行 + 次要信息一行(其余字段以「·」分隔的辅助文字)。
988
+ * 枚举 / Tag 字段以状态圆点 + 文字呈现(Tag variant: dot);文本类次要字段为空时该项连同前导分隔符一起不显示(core 的 when 只判真值,数字 / 布尔 / 枚举不用它)。
989
+ */
990
+ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>['compact']>, rowShow: Record<string, unknown>): string {
991
+ const D = KIT_CLASS_DEFAULTS;
992
+ const at = 'views.list.layout.compact';
993
+ const sized = (cell: KitCell): Record<string, unknown> => {
994
+ const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at);
995
+ if (cell.component === 'Text' || cell.component === 'Tag') props.size ??= 'sm';
996
+ return props;
997
+ };
998
+ const titleId = cellAnchor(ctx.object, 'list', compact.title.field);
999
+ ctx.components.add(compact.title.component);
1000
+ rowShow[titleId] = { props: sized(compact.title) };
1001
+ const title = `<div${attr('class', D.compactTitle)} ${KIT_TIPS_SCOPE_ATTR}="">${host(compact.title.component, titleId)}</div>`;
1002
+ const items = compact.meta.map((cell, i) => {
1003
+ const id = cellAnchor(ctx.object, 'list', cell.field);
1004
+ ctx.components.add(cell.component);
1005
+ const props = sized(cell);
1006
+ // 状态字段:状态徽标(浅色底 + on-soft 字 + 圆点,emphasis.status);其余文本沿用组件默认外观
1007
+ if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
1008
+ // 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上)
1009
+ if (cell.component === 'Text') props.class = joinClasses(typeof props.class === 'string' ? props.class : '', 'text-fg-muted');
1010
+ rowShow[id] = { props };
1011
+ const type = ctx.options.schema?.[cell.field]?.type;
1012
+ const hideable = cell.component !== 'Tag' && !isNumericColumnType(type) && type !== 'enum' && type !== 'enums' && type !== 'bool';
1013
+ const sep = i > 0 ? `<span${attr('class', D.compactSep)} aria-hidden="true">·</span>` : '';
1014
+ if (!hideable) return `<span${attr('class', D.compactMetaItem)}>${sep}${host(cell.component, id)}</span>`;
1015
+ const wid = `${id}__item`;
1016
+ rowShow[wid] = { when: `${ctx.rowVar}.${cell.field}` };
1017
+ return `<span data-soma-id="${esc(wid)}"${attr('class', D.compactMetaItem)}>${sep}${host(cell.component, id)}</span>`;
1018
+ });
1019
+ const meta = items.length > 0 ? `<div${attr('class', D.compactMeta)}>${items.join('')}</div>` : '';
1020
+ return `<div${attr('class', D.compactBody)}>${title}${meta}</div>`;
1021
+ }
1022
+
765
1023
  function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>): string {
766
1024
  const object = ctx.object;
767
1025
  const rowShow: Record<string, unknown> = {};
768
1026
  const innerAt = 'views.list.layout.inner';
769
- const inner = renderArrangement(ctx, 'list', layout.inner, (f) => `${ctx.rowVar}.${f}`, innerAt, rowShow);
1027
+ const compact = layout.compact;
1028
+ const inner = compact !== undefined ? renderCompactBody(ctx, compact, rowShow) : renderArrangement(ctx, 'list', layout.inner, (f) => `${ctx.rowVar}.${f}`, innerAt, rowShow);
770
1029
  let actions = '';
1030
+ // 紧凑列表:行点选(pickOnRow)与选中行高亮(selectedPath)同表格行——同一个 KitTableActions 实例、同一条 row_action select 事件与区域切片
1031
+ const pickProps = compact !== undefined ? { ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...selectedProps(ctx) } : {};
1032
+ const pickOnly = compact !== undefined && ctx.options.pickOnRow === true;
1033
+ // 行样式档位:条目自带底色与边框,档位走 itemToneTiers(rowToneSet: item,描边 / 透明度);没有行操作时补一个 actions:[] 实例专管档位
1034
+ const toneProps = layout.rowTone !== undefined ? { ...rowToneProp(layout, ctx), rowToneSet: 'item' } : {};
771
1035
  if (layout.rowActions.length > 0) {
772
1036
  ctx.components.add('KitTableActions');
773
- rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...removeBusyProps(ctx) } };
1037
+ // 紧凑列表(主从的控件列)是窄栏:行内只留主动作(行内上限取窄档上限),其余进「更多」(危险动作在菜单末位,与前面分隔)——一行不堆四个文字动作
1038
+ const compactCap = compact !== undefined ? { maxInline: kitRowActionsNarrowCap() } : {};
1039
+ rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...compactCap, ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
774
1040
  actions = host('KitTableActions', opsAnchor(object));
1041
+ } else if (layout.rowTone !== undefined || pickOnly) {
1042
+ ctx.components.add('KitTableActions');
1043
+ rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
1044
+ // 无按钮的档位实例只管给条目加类,放 hidden 壳里不占版面(不在条目 flex / gap 里多出一格)
1045
+ actions = `<div class="hidden">${host('KitTableActions', opsAnchor(object))}</div>`;
775
1046
  }
776
1047
  // 右键菜单(Q 波 G6):块 / 卡外壳标 data-kit-ctx,内含一个 KitContextMenu 实例(hidden 壳,不占版面)
777
1048
  const ctxItems = layout.contextMenu ?? [];
@@ -782,10 +1053,14 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
782
1053
  ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
783
1054
  }
784
1055
  const itemPart = layout.kind === 'cards' ? ` data-kit-part="${KIT_PART_CARD}"` : '';
785
- const template = `<template data-soma-role="item"><div${attr('class', layout.itemClass)}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}${itemPart}>${inner}${actions}${ctxHost}</div></template>`;
1056
+ const itemClass = pickOnly ? joinClasses(layout.itemClass, 'cursor-pointer') : layout.itemClass;
1057
+ const rowMark = layout.rowTone !== undefined || pickOnly ? ' data-kit-row=""' : '';
1058
+ const actionsPart = compact !== undefined && actions !== '' ? `<div${attr('class', KIT_CLASS_DEFAULTS.compactActions)}>${actions}</div>` : actions;
1059
+ const compactMark = compact !== undefined ? ' data-kit-compact=""' : '';
1060
+ const template = `<template data-soma-role="item"><div${attr('class', itemClass)}${rowMark}${compactMark}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}${itemPart}>${inner}${actionsPart}${ctxHost}</div></template>`;
786
1061
  ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
787
1062
  const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
788
- return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
1063
+ return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
789
1064
  }
790
1065
 
791
1066
  // ---------------------------------------------------------------- static(写死形状数据组件)
@@ -905,6 +1180,8 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
905
1180
  }
906
1181
  const id = viewAnchor(ctx.object, slot);
907
1182
  ctx.components.add('KitObjectForm');
1183
+ // 底栏动作组的「更多」入口(可编辑表单;筛选表单没有)
1184
+ if (slot === 'form') ctx.components.add('KitActionMore');
908
1185
  for (const c of packed.fields) if (c.component !== '') ctx.components.add(c.component);
909
1186
  // 可编辑 form 的 mode / initial 可绑镜像路径(字符串路径由 core 解析成绑定);filter 恒为字面量
910
1187
  const bindMode = slot === 'form' ? ctx.options.formModePath : undefined;
@@ -925,11 +1202,26 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
925
1202
  if (envelope !== undefined) props.envelope = envelope;
926
1203
  // M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
927
1204
  const fo = ir.views[slot]?.formOpts;
1205
+ // 筛选栏(cols 排布):排布引擎的投影(filter-plan.ts)——根容器左起流式换行、字段按类型取 [最小, 理想, 最大] 定宽(不拉伸)、
1206
+ // 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段并对齐到控件那一行;档位(即时 / 提交 / 更多)与钉住个数作为 props,运行时不量宽
1207
+ const proj = slot === 'filter' && layout.kind === 'grid' ? layout.filterProjection : undefined;
1208
+ if (proj !== undefined && layout.kind === 'grid') {
1209
+ props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, proj.widthClasses[i] ?? '') }));
1210
+ const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
1211
+ props.classes = {
1212
+ wrap: joinClasses(joinClasses(layout.wrapClass, proj.wrapClass), keep.join(' ')),
1213
+ grid: 'contents',
1214
+ actions: proj.actionsClass,
1215
+ pad: proj.padClass,
1216
+ notice: proj.noticeClass,
1217
+ };
1218
+ }
928
1219
  if (fo?.labelPosition !== undefined) { props.labelPosition = fo.labelPosition; props.labelWidth = fo.labelWidth ?? 3; }
929
1220
  if (typeof fo?.scrollToError === 'boolean') props.scrollToError = fo.scrollToError;
930
1221
  if (fo?.requiredMark === 'start') props.requiredMark = 'start';
931
- if (fo?.collapsible === true) { props.collapsible = true; props.collapsedRows = fo.collapsedRows ?? 1; }
932
1222
  if (fo?.trigger === 'change') props.trigger = 'change';
1223
+ if (fo?.filterMode !== undefined) props.filterMode = fo.filterMode;
1224
+ if (fo?.pinned !== undefined) props.pinned = fo.pinned;
933
1225
  if (fo?.groupTabs === true) props.groupTabs = true;
934
1226
  if (slot === 'form') {
935
1227
  if (ctx.options.validateOn !== undefined) props.validateOn = ctx.options.validateOn;
@@ -941,6 +1233,16 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
941
1233
  return a === undefined ? [] : [{ id: aid, label: a.name }];
942
1234
  });
943
1235
  if (items.length > 0) props.footerActions = items;
1236
+ // 底栏动作的展示对象状态绑定:{ 动作id: { disabled?, hidden? } },叶子是 page.<成员>(core 求值);路径合法性已在 emitStatic 入口核过
1237
+ const footerState: Record<string, Record<string, string>> = {};
1238
+ for (const a of ctx.options.actions ?? []) {
1239
+ if (a.on !== undefined || !fo.footerActions.includes(a.id)) continue;
1240
+ for (const key of ['disabled', 'hidden'] as const) {
1241
+ const raw = a[key];
1242
+ if (raw !== undefined && isViewPath(raw)) (footerState[a.id] ??= {})[key] = viewPathToCore(raw);
1243
+ }
1244
+ }
1245
+ if (Object.keys(footerState).length > 0) props.footerState = footerState;
944
1246
  }
945
1247
  if (fo?.result !== undefined) props.result = fo.result;
946
1248
  // 展示对象的字段状态绑定:{ 字段: { hidden / disabled / required: page.<成员> } },叶子是路径,core 的 props 求值递归解析
@@ -953,12 +1255,16 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
953
1255
  if (ir.fieldValue.hidden.length > 0) props.hiddenFields = ir.fieldValue.hidden;
954
1256
  }
955
1257
  }
1258
+ // filter 视图的字段状态绑定只有 options({ 字段: { options: page.<成员> } };其余键编译期 collectFieldState 已拦)
1259
+ if (slot === 'filter' && fo?.fieldState !== undefined) props.fieldState = fo.fieldState;
956
1260
  ctx.show[id] = { props };
957
1261
  // 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
958
1262
  const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
959
- 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)));
960
1263
  let html = host('KitObjectForm', id);
961
- if (isOverflowFilter) html = html.replace('></div>', ' data-kit-filter-overflow="true"></div>');
1264
+ // 容器查询只对后代生效:表单根上的字段宽度 / 动作区变体类(@<档>:w-N)要查到宿主这一层,所以宿主做查询容器
1265
+ if (proj !== undefined) {
1266
+ html = html.includes(' class="') ? html.replace(' class="', ` class="${KIT_WIDTH.containerClass} `) : html.replace('></div>', ` class="${KIT_WIDTH.containerClass}"></div>`);
1267
+ }
962
1268
  return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
963
1269
  }
964
1270
 
@@ -979,9 +1285,31 @@ function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' | 'ghost' |
979
1285
  return 'primary';
980
1286
  }
981
1287
 
1288
+ /** 工具栏按钮的置灰原因 prop(Button 的 disabled_reason);没写 disabled 或来源是行路径 / 非法值时不带 */
1289
+ function toolbarReasonProp(a: KitAction): { disabled_reason?: string } {
1290
+ if (a.disabled === undefined) return {};
1291
+ const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
1292
+ if (source.kind === 'view') return { disabled_reason: viewPathToCore(source.path) };
1293
+ return source.kind === 'literal' && source.text.trim() !== '' ? { disabled_reason: source.text } : {};
1294
+ }
1295
+
1296
+ /** 动作在动作组里的重要度:primary 语气 = 主操作(恒在行尾、恒可见);danger 语气最后保留;其余为次要 */
1297
+ function toolbarImportance(a: KitAction): KitActionImportance {
1298
+ const t = actionTone(a);
1299
+ return t === 'primary' ? 'primary' : t === 'danger' ? 'danger' : 'secondary';
1300
+ }
1301
+
1302
+ /**
1303
+ * 工具栏(主操作与次级工具)一律不独占一整行:有列表标题时并入标题行右侧,没有标题时紧贴列表上方靠右。
1304
+ * 成组排布经排布引擎(action-group.ts):恒单行、文字不折行;空间不足时次要动作按优先级逐个收进「更多」(KitActionMore,菜单里危险项置末),
1305
+ * 主操作恒在行尾可见;视觉序取引擎 order(非主操作按声明序在前,主操作在行尾)。
1306
+ */
982
1307
  function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
983
- const list = actions.filter((a) => a.on === 'toolbar');
984
- if (list.length === 0) return '';
1308
+ const declared = actions.filter((a) => a.on === 'toolbar');
1309
+ if (declared.length === 0) return '';
1310
+ const projection = projectActionGroup(declared.map((a) => ({ id: a.id, label: a.name, importance: toolbarImportance(a) })));
1311
+ const byId = new Map(declared.map((a) => [a.id, a] as const));
1312
+ const list = projection.order.flatMap((id) => { const a = byId.get(id); return a === undefined ? [] : [a]; });
985
1313
  const parts = list.map((a) => {
986
1314
  const id = toolbarAnchor(ctx.object, a.id);
987
1315
  ctx.components.add('Button');
@@ -991,13 +1319,21 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
991
1319
  variant: actionTone(a),
992
1320
  // 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
993
1321
  ...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
1322
+ // 置灰原因(disabled 为真时 Button 才显示):字面量原样带,view.<成员> 编成页面变量路径;row. 路径在入口已报 KIT-VIEW-001
1323
+ ...toolbarReasonProp(a),
994
1324
  // K1-2:Button 读 permission 服务,无权不渲染
995
1325
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
996
1326
  },
997
1327
  };
998
- return host('Button', id);
1328
+ // 外壳承载「按档隐藏」类与「更多」菜单要读的标记(标签 / 语气);壳里是真按钮,菜单选中即对它 click() 回放
1329
+ return `<div${attr('class', projection.itemClass[a.id] ?? 'shrink-0')} data-kit-ag-item="${esc(a.id)}" data-kit-ag-label="${esc(a.name)}" data-kit-ag-tone="${esc(actionTone(a))}">${host('Button', id)}</div>`;
999
1330
  });
1000
- return `<div${attr('class', KIT_CLASS_DEFAULTS.tableActions)}>${parts.join('')}</div>`;
1331
+ let more = '';
1332
+ if (projection.plan.hasMore) {
1333
+ ctx.components.add('KitActionMore');
1334
+ more = `<div${attr('class', projection.moreClass)}>${host('KitActionMore', `${ctx.object}__tb_more`)}</div>`;
1335
+ }
1336
+ return `<div${attr('class', projection.hostClass)} data-kit-action-group="" data-kit-ag-flow="${esc(projection.flowHostClass)}"><div${attr('class', projection.rowClass)}>${parts.join('')}${more}</div></div>`;
1001
1337
  }
1002
1338
 
1003
1339
  // ---------------------------------------------------------------- 主函数
@@ -1010,6 +1346,9 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1010
1346
  const base = options.singlePath ?? `page.data.${object}`;
1011
1347
  // 摘要 / 只读 form / 写死形状(single)读 summaryPath(如焦点切片里的当前行);缺省同 base。行数组与总数仍按 base
1012
1348
  const summaryBase = options.summaryPath ?? base;
1349
+ // 表头筛选写进 view 切片的键(集合被筛选状态的判断用)
1350
+ const listLayout = ir.views.list?.layout;
1351
+ const columnParams = listLayout?.kind === 'table' ? listLayout.head.flatMap((h) => (h.filter !== undefined ? [h.filter.param] : [])) : [];
1013
1352
  const ctx: Ctx = {
1014
1353
  object,
1015
1354
  options,
@@ -1018,13 +1357,16 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1018
1357
  diagnostics: [],
1019
1358
  singlePath: summaryBase,
1020
1359
  rowVar: rowVarOf(object),
1021
- rowsPath: wrapped ? `${base}.${options.listShape.rows}` : base,
1360
+ rowsPath: wrapped ? `${base}.${options.listShape.rows}` : options.staticRowsPath !== undefined && options.staticRowsPath !== '' ? `${base}.${options.staticRowsPath}` : base,
1022
1361
  totalPath: `${base}.${options.listShape.total}`,
1023
1362
  basePath: base,
1024
1363
  scope: () => ir.scope,
1364
+ ...(ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static' ? { filterId: viewAnchor(object, 'filter') } : {}),
1365
+ ...(columnParams.length > 0 ? { columnParams } : {}),
1025
1366
  };
1026
1367
 
1027
1368
  // 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
1369
+ const footerIds = new Set(ir.views.form?.formOpts?.footerActions ?? []);
1028
1370
  (options.actions ?? []).forEach((a, i) => {
1029
1371
  for (const key of ['disabled', 'hidden'] as const) {
1030
1372
  if (a[key] === undefined) continue;
@@ -1034,13 +1376,29 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1034
1376
  if (!isViewPath(a[key])) checkRowPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics, options.schema);
1035
1377
  }
1036
1378
  else if (a.on === 'toolbar' && key === 'disabled') checkViewPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics);
1037
- else ctx.diagnostics.push({ code: 'KIT-VIEW-006', path: at, message: `动作 ${a.id} 的 ${key} 不支持 on: ${a.on}(toolbar 只支持 disabled,行级可用性写在 on: row 动作上)` });
1379
+ // 表单底栏动作(不写 on、被 view.form.footerActions 引用):disabled / hidden 都只许纯 view 路径,收集成表单的 footerState prop
1380
+ else if (a.on === undefined && footerIds.has(a.id)) checkViewPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics);
1381
+ 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 动作上)` });
1382
+ }
1383
+ // 置灰原因(形态与取值已在 closed-set 核过,这里核落点与路径):toolbar 只收字面量 / view.<成员>;row 动作收字面量 / view.<成员> / row.<字段>(字段须在 schema 里);
1384
+ // 表单底栏动作(由 object-form 渲染)与其它位置暂不支持,写了报 KIT-VIEW-006,不静默丢弃
1385
+ if (a.disabledReason !== undefined && a.disabled !== undefined) {
1386
+ const at = `behavior.actions[${i}].${KIT_ACTION_REASON_KEY}`;
1387
+ const source = classifyDisabledReason(a.disabledReason);
1388
+ if (a.on === 'row') {
1389
+ if (source.kind === 'row') checkRowPath(source.path, at, `动作 ${a.id} 的 ${KIT_ACTION_REASON_KEY}`, ctx.diagnostics, options.schema);
1390
+ } else if (a.on === 'toolbar') {
1391
+ 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}(工具栏没有「行」)` });
1392
+ } else {
1393
+ ctx.diagnostics.push({ code: 'KIT-VIEW-006', path: at, message: `动作 ${a.id} 的 ${KIT_ACTION_REASON_KEY} 不支持 on: ${String(a.on)}(支持 on: toolbar 与 on: row;表单底栏动作暂不支持)` });
1394
+ }
1038
1395
  }
1039
1396
  });
1040
1397
 
1041
1398
  const parts: KitStaticEmit['parts'] = {};
1042
1399
  const toolbar = renderToolbar(ctx, options.actions ?? []);
1043
1400
  if (toolbar !== '') parts.toolbar = toolbar;
1401
+ const secondaryToolbar = toolbar !== '';
1044
1402
 
1045
1403
  for (const slot of SLOT_ORDER) {
1046
1404
  const view = ir.views[slot];
@@ -1078,14 +1436,49 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1078
1436
  html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
1079
1437
  }
1080
1438
  }
1439
+ // 树表「全部展开 / 全部收起」:进表格工具位(与刷新同一行、标题行右侧),不再是表头下面那条灰条
1440
+ const treeCtl = slot === 'list' && html !== '' && layout.kind === 'table' && layout.tree !== null && layout.tree.expandAll ? renderTreeControls(ctx) : '';
1081
1441
  // K-4:list / summary 的标题位(视图内静态文案,h3)
1442
+ // 标题旁的集合辅助文字(共 N 条 / 已筛选提示):非分页集合有标题行时自动出,被筛选状态下出清除提示
1443
+ const metaPlan = slot === 'list' && html !== '' ? collectionMetaOf(ir) : null;
1444
+ const metaHtml = metaPlan !== null ? renderMeta(ctx, metaPlan) : '';
1082
1445
  if (html !== '' && view.title !== undefined && view.title !== '') {
1083
- html = `<h3 data-soma-id="${esc(viewAnchor(object, slot))}__title" data-kit-part="${KIT_PART_TITLE_SECTION}"${attr('class', VIEW_TITLE_CLASS)}>${esc(view.title)}</h3>${html}`;
1446
+ // 标题写成 view.<成员> 纯路径:被动绑定展示对象的只读成员(如选中项名称),不是字面量
1447
+ const dynamicTitle: boolean = isViewPath(view.title);
1448
+ const titleEl = dynamicTitle
1449
+ ? renderDynamicTitle(ctx, slot, view.title)
1450
+ : kitPanelTitleHtml({ title: view.title, id: `${viewAnchor(object, slot)}__title` });
1451
+ // 工具栏(含主操作,主操作在最右)与列表标题同一行靠右,不再独占一整行(评审 S5 / 第三轮);工具栏并入列表后不再单独出
1452
+ const mergeToolbar = slot === 'list' && secondaryToolbar && parts.toolbar !== undefined;
1453
+ if (slot === 'list' && (mergeToolbar || treeCtl !== '')) {
1454
+ const right = treeCtl !== ''
1455
+ ? `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${mergeToolbar ? parts.toolbar! : ''}</div>`
1456
+ : parts.toolbar!;
1457
+ // 集合辅助文字紧随标题作标题行的直接子项(宿主 display: contents,其根自带 me-auto 把工具区推到最右)
1458
+ html = `<div data-kit-title-row="" class="${KIT_CLASS_DEFAULTS.toolbarTitleRow}">${titleEl}${metaHtml}${right}</div>${html}`;
1459
+ if (mergeToolbar) delete parts.toolbar;
1460
+ } else {
1461
+ html = `${metaHtml === '' ? titleEl : `<div data-kit-title-row="" class="${TITLE_GROUP_CLASS}">${titleEl}${metaHtml}</div>`}${html}`;
1462
+ }
1463
+ } else {
1464
+ if (treeCtl !== '') {
1465
+ if (secondaryToolbar && parts.toolbar !== undefined) parts.toolbar = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${parts.toolbar}</div>`;
1466
+ else html = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}</div>${html}`;
1467
+ }
1468
+ // 没有标题行:只有「已筛选」提示(共 N 条需要标题行),放在列表上方;包一层标题行壳,与有标题时同走对齐轴的内缩规则(文字落在轴上)
1469
+ if (metaHtml !== '') html = `<div data-kit-title-row="" class="${TITLE_GROUP_CLASS}">${metaHtml}</div>${html}`;
1084
1470
  }
1085
1471
  parts[slot] = html;
1086
1472
  }
1087
1473
 
1088
- const ordered = [parts.toolbar, ...SLOT_ORDER.map((s) => parts[s])].filter((p): p is string => p !== undefined && p !== '');
1474
+ // 次要工具栏没并入标题行时,紧贴列表上方靠右(顺序:筛选 → 工具 → 列表),不压在筛选之前
1475
+ const slotParts = SLOT_ORDER.map((s) => parts[s]);
1476
+ let leading = parts.toolbar;
1477
+ if (secondaryToolbar && parts.toolbar !== undefined && parts.list !== undefined && parts.list !== '') {
1478
+ slotParts.splice(SLOT_ORDER.indexOf('list'), 0, parts.toolbar);
1479
+ leading = undefined;
1480
+ }
1481
+ const ordered = [leading, ...slotParts].filter((p): p is string => p !== undefined && p !== '');
1089
1482
  return {
1090
1483
  parts,
1091
1484
  html: ordered.join('\n'),