soma-kit 0.1.12 → 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 (261) 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 +158 -4
  6. package/spec/generated/kit-page.schema.json +139 -5
  7. package/spec/kit-grammar.json +438 -87
  8. package/spec/kit-grammar.schema.json +11 -3
  9. package/src/app/app-config.ts +83 -5
  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 +17 -5
  15. package/src/app/kit-view-context.ts +163 -14
  16. package/src/app/render-ports.ts +18 -0
  17. package/src/app/server-pages.ts +3 -1
  18. package/src/app/server.ts +40 -3
  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 +57 -12
  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 +49 -0
  34. package/src/base/fab.ts +1 -1
  35. package/src/base/gap-value.ts +148 -0
  36. package/src/base/hint-tips.ts +170 -0
  37. package/src/base/icons.ts +8 -0
  38. package/src/base/illustrations.ts +94 -0
  39. package/src/base/index.ts +27 -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 +23 -12
  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 +9 -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 +24 -22
  58. package/src/base/shared.ts +169 -23
  59. package/src/base/state-panel.ts +346 -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 +63 -33
  66. package/src/base/text.ts +42 -13
  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 -10
  71. package/src/base/view-transition.ts +77 -0
  72. package/src/biz/approval-desk/shell.ts +11 -8
  73. package/src/biz/auth-panel/shell.ts +5 -4
  74. package/src/biz/category-crud/compile.ts +2 -2
  75. package/src/biz/category-crud/shell.ts +2 -1
  76. package/src/biz/checkout-page/compile.ts +2 -1
  77. package/src/biz/checkout-page/shell.ts +4 -3
  78. package/src/biz/import-wizard/shell.ts +2 -1
  79. package/src/biz/link/hub.ts +23 -5
  80. package/src/biz/link/shared.ts +23 -12
  81. package/src/biz/master-sub/compile.ts +102 -10
  82. package/src/biz/master-sub/index.ts +5 -2
  83. package/src/biz/master-sub/shell.ts +95 -18
  84. package/src/biz/multi-board/compile.ts +4 -1
  85. package/src/biz/multi-board/shell.ts +8 -5
  86. package/src/biz/notification-center/shell.ts +6 -4
  87. package/src/biz/page-templates/result-page/shell.ts +2 -1
  88. package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
  89. package/src/biz/record-detail/compile.ts +2 -2
  90. package/src/biz/record-detail/shell.ts +8 -6
  91. package/src/biz/settings-center/compile.ts +2 -1
  92. package/src/biz/settings-center/shell.ts +6 -4
  93. package/src/biz/shared/action-host.ts +6 -0
  94. package/src/biz/shared/compile-helpers.ts +18 -0
  95. package/src/biz/shared/coordinator.ts +7 -30
  96. package/src/biz/shared/index.ts +5 -0
  97. package/src/biz/shared/object-aliases.ts +154 -0
  98. package/src/biz/shared/overlay-compile.ts +239 -0
  99. package/src/biz/shared/overlay-shell.ts +139 -10
  100. package/src/biz/shared/pipes.ts +11 -5
  101. package/src/biz/shared/remove-wire.ts +4 -19
  102. package/src/biz/shared/runtime-hub.ts +10 -0
  103. package/src/biz/single-form/compile.ts +3 -2
  104. package/src/biz/single-form/shell.ts +4 -3
  105. package/src/biz/standard-crud/compile.ts +22 -160
  106. package/src/biz/standard-crud/shell.ts +16 -44
  107. package/src/biz/step-form/shell.ts +5 -5
  108. package/src/cli/kit-cli.ts +138 -13
  109. package/src/cli/kit-init.ts +6 -1
  110. package/src/cli/layout-cli.ts +167 -0
  111. package/src/cli/migrate/index.ts +10 -0
  112. package/src/cli/migrate/migrate.ts +248 -0
  113. package/src/cli/migrate/text-utils.ts +306 -0
  114. package/src/cli/migrate/theme-map.ts +104 -0
  115. package/src/cli/migrate/ts-rules.ts +235 -0
  116. package/src/cli/migrate/types.ts +95 -0
  117. package/src/cli/migrate/view-skeleton.ts +159 -0
  118. package/src/cli/migrate/yaml-report.ts +376 -0
  119. package/src/cli/migrate/yaml-rules.ts +465 -0
  120. package/src/cli/view-writes.ts +69 -60
  121. package/src/compile/closed-set.ts +65 -4
  122. package/src/compile/compile-page.ts +51 -7
  123. package/src/compile/component-candidates.ts +12 -1
  124. package/src/compile/layout-lint/engine.ts +82 -0
  125. package/src/compile/layout-lint/index.ts +55 -0
  126. package/src/compile/layout-lint/rules-composition.ts +218 -0
  127. package/src/compile/layout-lint/rules-form.ts +192 -0
  128. package/src/compile/layout-lint/rules-table.ts +194 -0
  129. package/src/compile/layout-lint/score.ts +52 -0
  130. package/src/compile/layout-lint/types.ts +51 -0
  131. package/src/compile/remove-guard.ts +10 -7
  132. package/src/compile/styles.ts +36 -8
  133. package/src/compile/types.ts +13 -1
  134. package/src/compile/view-check.ts +149 -16
  135. package/src/data/amount-breakdown.ts +6 -1
  136. package/src/data/approval-flow.ts +1 -1
  137. package/src/data/assignment-picker.ts +53 -27
  138. package/src/data/async-result-panel.ts +49 -3
  139. package/src/data/breadcrumbs.ts +3 -2
  140. package/src/data/calendar.ts +2 -2
  141. package/src/data/carousel.ts +8 -6
  142. package/src/data/chart.ts +141 -10
  143. package/src/data/checklist.ts +18 -5
  144. package/src/data/code-view.ts +8 -4
  145. package/src/data/comment-thread.ts +2 -2
  146. package/src/data/confirm-dialog.ts +71 -18
  147. package/src/data/context-menu.ts +3 -3
  148. package/src/data/dock.ts +1 -1
  149. package/src/data/embed.ts +231 -29
  150. package/src/data/field-mapper.ts +4 -4
  151. package/src/data/flow-editor-contract.ts +7 -0
  152. package/src/data/flow-editor.ts +25 -9
  153. package/src/data/flow-node-options.ts +33 -3
  154. package/src/data/gantt.ts +5 -2
  155. package/src/data/hero.ts +2 -1
  156. package/src/data/image-viewer.ts +7 -4
  157. package/src/data/index.ts +6 -1
  158. package/src/data/item-list.ts +18 -10
  159. package/src/data/kanban.ts +39 -10
  160. package/src/data/media-grid.ts +6 -1
  161. package/src/data/mega-menu.ts +6 -4
  162. package/src/data/menu-dom.ts +4 -2
  163. package/src/data/menu.ts +45 -13
  164. package/src/data/mockup.ts +8 -4
  165. package/src/data/modal-dialog.ts +29 -9
  166. package/src/data/navbar.ts +5 -5
  167. package/src/data/notice-list.ts +268 -0
  168. package/src/data/notify-renderer.ts +21 -6
  169. package/src/data/object-form.ts +354 -48
  170. package/src/data/outcome-watch.ts +61 -2
  171. package/src/data/pager.ts +17 -7
  172. package/src/data/permission-matrix.ts +33 -11
  173. package/src/data/permission-tree.ts +47 -22
  174. package/src/data/pricing-table.ts +21 -11
  175. package/src/data/prompt-dialog.ts +165 -0
  176. package/src/data/reaction-bar.ts +6 -4
  177. package/src/data/record-card.ts +23 -2
  178. package/src/data/record-picker.ts +13 -7
  179. package/src/data/result-panel.ts +4 -2
  180. package/src/data/rich-text.ts +17 -1
  181. package/src/data/row-editor.ts +79 -26
  182. package/src/data/rule-builder.ts +8 -8
  183. package/src/data/shape-util.ts +23 -9
  184. package/src/data/stat-group.ts +170 -29
  185. package/src/data/static-lazy.ts +1 -0
  186. package/src/data/static-registry.ts +2 -0
  187. package/src/data/steps.ts +8 -3
  188. package/src/data/survey.ts +3 -3
  189. package/src/data/system-switcher.ts +1 -1
  190. package/src/data/text-action-button.ts +17 -0
  191. package/src/data/timeline.ts +17 -6
  192. package/src/data/tour-guide.ts +1 -1
  193. package/src/data/transfer.ts +36 -16
  194. package/src/data/tree-table.ts +62 -36
  195. package/src/data/tree.ts +22 -2
  196. package/src/data/virtual-rows.ts +19 -10
  197. package/src/data/wrapped-candidates.ts +10 -0
  198. package/src/frames/page-bar.ts +14 -13
  199. package/src/frames/page-status.ts +7 -5
  200. package/src/frames/shared.ts +15 -10
  201. package/src/frames/split-frame/shell.ts +1 -1
  202. package/src/frames/tabs-frame/shell.ts +2 -1
  203. package/src/frames/tabs-frame/wiring.ts +1 -0
  204. package/src/frames/top-main-frame.ts +2 -2
  205. package/src/frames/workspace-frame/extras.ts +1 -1
  206. package/src/frames/workspace-frame/shell.ts +2 -2
  207. package/src/frames/workspace-frame/view.ts +141 -33
  208. package/src/generated/kit-grammar-runtime.ts +239 -55
  209. package/src/i18n/kit-text.ts +63 -4
  210. package/src/i18n/resolve-text-refs.ts +22 -6
  211. package/src/object-renderer/arrange.ts +42 -8
  212. package/src/object-renderer/collection-parts.ts +241 -60
  213. package/src/object-renderer/collection-table.ts +109 -5
  214. package/src/object-renderer/collection.ts +174 -36
  215. package/src/object-renderer/compile-data.ts +28 -3
  216. package/src/object-renderer/defaults.ts +30 -2
  217. package/src/object-renderer/display-checks.ts +1 -1
  218. package/src/object-renderer/emit-events.ts +43 -9
  219. package/src/object-renderer/emit-static.ts +370 -30
  220. package/src/object-renderer/form-detail.ts +1 -2
  221. package/src/object-renderer/form-notify.ts +45 -0
  222. package/src/object-renderer/layout-facts.ts +386 -0
  223. package/src/object-renderer/layout-plan.ts +132 -0
  224. package/src/object-renderer/layout-plan.types.ts +22 -0
  225. package/src/object-renderer/parts.ts +252 -1
  226. package/src/object-renderer/render-object.ts +54 -6
  227. package/src/object-renderer/request-actions.ts +4 -2
  228. package/src/object-renderer/skeleton.ts +58 -19
  229. package/src/object-renderer/table-actions.ts +135 -27
  230. package/src/object-renderer/table-tools.ts +12 -11
  231. package/src/object-renderer/types.ts +78 -7
  232. package/src/object-renderer/view-binding.ts +205 -8
  233. package/src/page-target/intent-schema.ts +11 -0
  234. package/src/page-target/target.ts +5 -1
  235. package/src/recipes/container.ts +46 -1
  236. package/src/recipes/control.ts +70 -12
  237. package/src/recipes/index.ts +49 -0
  238. package/src/recipes/nowrap.ts +16 -0
  239. package/src/recipes/overlay.ts +75 -17
  240. package/src/recipes/placeholder.ts +79 -0
  241. package/src/recipes/rail-grid.ts +45 -0
  242. package/src/recipes/slot-align.ts +56 -0
  243. package/src/recipes/state.ts +34 -5
  244. package/src/recipes/status.ts +139 -0
  245. package/src/recipes/surface.ts +40 -0
  246. package/src/recipes/table-row.ts +40 -3
  247. package/src/recipes/title-row.ts +37 -0
  248. package/src/recipes/typography.ts +13 -1
  249. package/src/shared/confirm-decl.ts +118 -0
  250. package/src/shared/envelope.ts +2 -2
  251. package/src/shared/paged-list-adapter.ts +15 -240
  252. package/src/shared/theme-runtime-shared.ts +6 -1
  253. package/src/theme/index.ts +1 -0
  254. package/src/theme/kit-theme-text.ts +1 -1
  255. package/src/theme/kit-theme.css +372 -12
  256. package/src/theme/kit-theme.tpl +372 -12
  257. package/src/theme/nine-dim-structure.ts +177 -7
  258. package/src/theme/surface-layers.ts +4 -0
  259. package/src/theme/theme-tokens.ts +53 -13
  260. package/src/theme/theme-types.ts +32 -0
  261. package/src/biz/shared/remove-key.ts +0 -6
@@ -13,15 +13,22 @@ import { getCompileEnvelope } from '../shared/envelope';
13
13
  // prop 值规则(core resolvePropValue):字符串首段是已注册变量才算绑定路径,否则是字面量;
14
14
  // `!path` 取反写法已删除,kit 绑定路径一律是纯路径(取反另给成员),以 `!` 开头的普通文案原样显示。
15
15
 
16
- import { checkRowPath, checkViewPath, isRowPath, isViewPath, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
16
+ import { checkRowPath, checkViewPath, classifyDisabledReason, isRowPath, isViewPath, KIT_ACTION_REASON_KEY, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
17
17
  import type {
18
18
  KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
19
19
  } from './types';
20
20
  import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
21
- 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';
22
28
  import { headAnchor } from './compile-data';
23
29
  import { KIT_STATE_DEFAULT_TEXT } from './collection';
24
30
  import { kitText } from '../i18n/kit-text';
31
+ import { KIT_TIPS_SCOPE_ATTR, kitHelpButtonHtml } from '../base/hint-tips';
25
32
  import { expandHostId } from './collection-expand';
26
33
  import { busyActionOf } from '../base/action-busy';
27
34
  import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
@@ -52,6 +59,11 @@ function rowToneProp(layout: { rowTone?: string }, ctx: Ctx): { rowTone?: string
52
59
  return layout.rowTone !== undefined ? { rowTone: `${ctx.rowVar}.${layout.rowTone}` } : {};
53
60
  }
54
61
 
62
+ /** 树表 / 虚拟滚动表自己画行(拿到整行对象):只传行字段名(不是 core 路径),组件按行取值映射档位类 */
63
+ function rowToneFieldProp(layout: { rowTone?: string }): { rowToneField?: string } {
64
+ return layout.rowTone !== undefined ? { rowToneField: layout.rowTone } : {};
65
+ }
66
+
55
67
  /** 展开行:开合按钮实例(每行一个 KitTableActions expand) */
56
68
  export function treeAnchor(object: string): string { return `${object}__list__tree`; }
57
69
  /** 虚拟滚动表体 KitVirtualRows 实例(N3) */
@@ -61,6 +73,8 @@ export function expandToggleAnchor(object: string): string { return `${object}__
61
73
  export function expandCellAnchor(object: string, field: string): string { return `${object}__list__x__${field}`; }
62
74
  /** 集合三态面板实例 */
63
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`; }
64
78
  export function toolbarAnchor(object: string, actionId: string): string { return `${object}__tb_${actionId}`; }
65
79
  /** 表格工具与接线件(工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐),紧挨在表格外壳之前 */
66
80
  export function toolsAnchor(object: string): string { return `${object}__list__tools`; }
@@ -126,15 +140,41 @@ function attr(name: string, value: string): string {
126
140
  return value === '' ? '' : ` ${name}="${esc(value)}"`;
127
141
  }
128
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
+
129
146
  function host(component: string, id: string): string {
130
- 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>`;
131
152
  }
132
153
 
133
154
  const opsHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_ops', undefined, ctx.options.locale ?? '');
134
155
  const selectHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_select', undefined, ctx.options.locale ?? '');
135
156
  const cellRoleAttr = (role: string): string => (role === '' ? '' : ` role="${role}"`);
136
157
  /** 视图标题行(K-4):语义色名 + utilityScales 里有的尺度 */
137
- 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
+ }
138
178
 
139
179
  function joinClasses(a: string, b: string): string {
140
180
  return [a, b].filter((s) => s !== '').join(' ');
@@ -166,6 +206,31 @@ interface Ctx {
166
206
  /** 列表对象整体路径(page.data.<对象>),三态面板据此判定 */
167
207
  basePath: string;
168
208
  scope(): string;
209
+ /** 筛选栏(非写死形状)的宿主锚点:集合的「清除筛选」优先点它的「重置」;本对象没有筛选栏为 undefined */
210
+ filterId?: string;
211
+ /** 表头筛选写进 view 切片的键(列表是带表头筛选的表格时非空) */
212
+ columnParams?: string[];
213
+ }
214
+
215
+ /**
216
+ * 集合标题旁的辅助文字(KitCollectionState meta 形态)计划:
217
+ * - count:有标题行的非分页集合(table / cards / stack,树表不算)自动显示「共 N 条」(分页集合由分页器显示总数,不重复);
218
+ * `collection.count: false` 关闭;
219
+ * - hint:本对象有筛选栏(非写死形状)或表头筛选时,被筛选状态下显示「已筛选 · N 项条件 清除」。
220
+ * 都不需要返回 null(不发射实例)。emitStatic 与 emitEvents 共用这一份判定,事件键与实例锚点才对得上。
221
+ */
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;
169
234
  }
170
235
 
171
236
  /** 列表响应里错误文案的缺省路径(listShape.errorPath 可改) */
@@ -180,6 +245,8 @@ const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
180
245
  function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Record<string, unknown> {
181
246
  const props: Record<string, unknown> = { value: valuePath };
182
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}`;
183
250
  if (LABELLED_CELL_CONTROLS.has(cell.component) && props.aria_label === undefined && Boolean(cell.label)) {
184
251
  props.aria_label = cell.label;
185
252
  }
@@ -191,6 +258,9 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Rec
191
258
 
192
259
  type IdOf = (field: string) => string;
193
260
 
261
+ /** 类串里有 truncate(含变体前缀与 `**:truncate` 这类后代选择写法):这类格的文字可能被截断 */
262
+ const TRUNCATING_CLASS_RE = /(?:^|\s)(?:[a-z0-9*@-]+:)*truncate(?=\s|$)/;
263
+
194
264
  function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string, at: string, showInto: Record<string, unknown>, idOf?: IdOf): string {
195
265
  if (cell.placeholder === true || cell.component === '') {
196
266
  return `<div${attr('class', cell.cellClass)}></div>`;
@@ -199,8 +269,12 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
199
269
  ctx.components.add(cell.component);
200
270
  showInto[id] = { props: cellProps(ctx, cell, valuePath, at) };
201
271
  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"' : ''}`;
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}=""` : ''}`;
204
278
  // summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
205
279
  if (cell.hideEmpty === true) {
206
280
  const cellId = `${id}__cell`;
@@ -363,9 +437,17 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
363
437
  // K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
364
438
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
365
439
  ...(a.more === true ? { more: true } : {}),
440
+ // 置灰原因的字面量文案(只有写了 disabled 的动作才有意义);row. / view. 路径形走 actionState 的叶子,不进这里
441
+ ...(a.disabled !== undefined ? literalReason(a) : {}),
366
442
  }));
367
443
  }
368
444
 
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
+
369
451
  /**
370
452
  * 行动作的行级状态绑定:on: row 动作的 hidden / disabled(row.<字段>,业务对象逐行给出)编成
371
453
  * { 动作id: { hidden?, disabled? } },叶子是 core 行路径(行变量.<字段>),由 core 在行模板里逐行求值。
@@ -381,14 +463,29 @@ function actionStateProp(actions: readonly KitAction[], ctx: Ctx): { actionState
381
463
  // 行动作也可以绑展示对象成员(view.<成员>,编成页面变量 page.<成员>,行模板里 core 逐行求值同一个值),与 row.<字段> 二选一
382
464
  else if (isViewPath(raw)) (state[a.id] ??= {})[key] = viewPathToCore(raw);
383
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
+ }
384
472
  }
385
473
  return Object.keys(state).length > 0 ? { actionState: state } : {};
386
474
  }
387
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
+
388
485
  /** treeTable / 虚拟滚动表的行操作与右键菜单不支持行级状态绑定:写了记 KIT-ROW-002(动作照常渲染,绑定被忽略) */
389
486
  function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string): void {
390
487
  for (const a of actions) {
391
- for (const key of KIT_ROW_ACTION_KEYS) {
488
+ for (const key of [...KIT_ROW_ACTION_KEYS, KIT_ACTION_REASON_KEY]) {
392
489
  if (a.on === 'row' && a[key] !== undefined) {
393
490
  ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `behavior.actions.${a.id}.${key}`, message: `${where}的行操作 / 右键菜单不支持行级状态绑定(动作 ${a.id} 的 ${key})` });
394
491
  }
@@ -422,6 +519,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
422
519
  ...(h.filter !== undefined ? { filter: h.filter } : {}),
423
520
  ...(h.group !== undefined ? { group: h.group } : {}),
424
521
  ...(tools && h.resizable === true ? { resizable: true } : {}),
522
+ ...(h.help !== undefined ? { help: h.help } : {}),
425
523
  });
426
524
  }
427
525
  if (layout.rowActions.length > 0) cells.push({ label: opsHeadLabel(ctx), class: actHead });
@@ -453,7 +551,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
453
551
  };
454
552
  for (const h of layout.head) {
455
553
  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>`;
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>`;
457
555
  if (h.group === undefined) headParts.push(leaf);
458
556
  else {
459
557
  openGroup = h.group;
@@ -469,6 +567,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
469
567
  if (layout.tree !== null) {
470
568
  const id = treeAnchor(object);
471
569
  rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, 'treeTable');
570
+ rejectRowProps(layout.cells, ctx, 'treeTable');
472
571
  ctx.components.add('KitTreeTable');
473
572
  ctx.show[id] = {
474
573
  props: {
@@ -481,6 +580,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
481
580
  selectClass: layout.selectClass,
482
581
  actionsClass: layout.actionsClass,
483
582
  actions: actionItems(layout.rowActions, ctx),
583
+ ...rowToneFieldProp(layout),
484
584
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
485
585
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
486
586
  ...selectedProps(ctx),
@@ -496,8 +596,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
496
596
  }
497
597
  const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
498
598
  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)}`;
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)}`;
501
601
  }
502
602
 
503
603
  // 虚拟滚动(N3):表头 / 三态 / 分页 / 工具与普通表格同一条路径,只有表体换成 KitVirtualRows(窗口内的行由组件画)
@@ -549,9 +649,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
549
649
  // 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
550
650
  const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
551
651
  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;
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;
555
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>`;
556
657
  let itemHtml = rowEl;
557
658
  if (layout.expand !== null) {
@@ -581,8 +682,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
581
682
  const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
582
683
  const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
583
684
  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)}`;
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)}`;
586
687
  }
587
688
 
588
689
  /**
@@ -595,6 +696,7 @@ function renderVirtualTable(
595
696
  const object = ctx.object;
596
697
  const id = virtualAnchor(object);
597
698
  rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, '虚拟滚动表');
699
+ rejectRowProps(layout.cells, ctx, '虚拟滚动表');
598
700
  ctx.components.add('KitVirtualRows');
599
701
  ctx.show[id] = {
600
702
  props: {
@@ -608,6 +710,7 @@ function renderVirtualTable(
608
710
  actionsClass: layout.actionsClass,
609
711
  actions: actionItems(layout.rowActions, ctx),
610
712
  label: object,
713
+ ...rowToneFieldProp(layout),
611
714
  colCount: layout.cells.length + (layout.select !== 'none' ? 1 : 0) + (layout.rowActions.length > 0 ? 1 : 0),
612
715
  ...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
613
716
  ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
@@ -625,9 +728,9 @@ function renderVirtualTable(
625
728
  }
626
729
  const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
627
730
  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))}"` : ''}>`
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))}"` : ''}>`
629
732
  + `<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)}`;
733
+ return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
631
734
  }
632
735
 
633
736
  /** 表格工具与接线件:工具栏 / 批量条 / 就地编辑 / 滚动边缘 / 省略 title / 列显隐。放在表格外壳之前 */
@@ -703,11 +806,23 @@ function renderSummary(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>
703
806
  }
704
807
 
705
808
  /** 骨架屏的形态参数:表格按列的跨度类(含选择 / 操作列),cards / stack 沿用列表容器类 */
706
- function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>): KitSkeletonConfig {
809
+ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards' | 'stack' }>, schema?: KitSchema): KitSkeletonConfig {
707
810
  if (layout.kind === 'table') {
708
- 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> = [
709
824
  ...(layout.select !== 'none' && layout.selectClass !== '' ? [layout.selectClass] : []),
710
- ...layout.head.map((h) => h.class),
825
+ ...dataCols,
711
826
  ...(layout.rowActions.length > 0 && layout.actionsClass !== '' ? [layout.actionsClass] : []),
712
827
  ];
713
828
  return { kind: 'table', cols };
@@ -719,6 +834,9 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
719
834
  const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
720
835
  const EXPAND_BODY_CLASS = 'border-b border-border-subtle bg-surface-sunken px-4 py-3';
721
836
 
837
+ /** 标题与它旁边的集合辅助文字(共 N 条 / 已筛选提示)同一组:基线对齐、窄时换行 */
838
+ const TITLE_GROUP_CLASS = 'flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1';
839
+
722
840
  /** 集合三态面板:列表之后、分页器之前 */
723
841
  function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
724
842
  if (state === null) return '';
@@ -739,12 +857,59 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
739
857
  error: state.error,
740
858
  ...(state.skeleton === true && shape !== undefined ? { skeleton: shape } : {}),
741
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);
@@ -762,16 +927,64 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
762
927
  return host('Pager', id);
763
928
  }
764
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
+
765
967
  function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>): string {
766
968
  const object = ctx.object;
767
969
  const rowShow: Record<string, unknown> = {};
768
970
  const innerAt = 'views.list.layout.inner';
769
- 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);
770
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' } : {};
771
979
  if (layout.rowActions.length > 0) {
772
980
  ctx.components.add('KitTableActions');
773
- rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...removeBusyProps(ctx) } };
981
+ rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
774
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>`;
775
988
  }
776
989
  // 右键菜单(Q 波 G6):块 / 卡外壳标 data-kit-ctx,内含一个 KitContextMenu 实例(hidden 壳,不占版面)
777
990
  const ctxItems = layout.contextMenu ?? [];
@@ -782,10 +995,13 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
782
995
  ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
783
996
  }
784
997
  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>`;
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>`;
786
1002
  ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
787
1003
  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)}`;
1004
+ return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
789
1005
  }
790
1006
 
791
1007
  // ---------------------------------------------------------------- static(写死形状数据组件)
@@ -925,6 +1141,40 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
925
1141
  if (envelope !== undefined) props.envelope = envelope;
926
1142
  // M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
927
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
+ }
928
1178
  if (fo?.labelPosition !== undefined) { props.labelPosition = fo.labelPosition; props.labelWidth = fo.labelWidth ?? 3; }
929
1179
  if (typeof fo?.scrollToError === 'boolean') props.scrollToError = fo.scrollToError;
930
1180
  if (fo?.requiredMark === 'start') props.requiredMark = 'start';
@@ -941,6 +1191,16 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
941
1191
  return a === undefined ? [] : [{ id: aid, label: a.name }];
942
1192
  });
943
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;
944
1204
  }
945
1205
  if (fo?.result !== undefined) props.result = fo.result;
946
1206
  // 展示对象的字段状态绑定:{ 字段: { hidden / disabled / required: page.<成员> } },叶子是路径,core 的 props 求值递归解析
@@ -953,6 +1213,8 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
953
1213
  if (ir.fieldValue.hidden.length > 0) props.hiddenFields = ir.fieldValue.hidden;
954
1214
  }
955
1215
  }
1216
+ // filter 视图的字段状态绑定只有 options({ 字段: { options: page.<成员> } };其余键编译期 collectFieldState 已拦)
1217
+ if (slot === 'filter' && fo?.fieldState !== undefined) props.fieldState = fo.fieldState;
956
1218
  ctx.show[id] = { props };
957
1219
  // 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
958
1220
  const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
@@ -979,9 +1241,28 @@ function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' | 'ghost' |
979
1241
  return 'primary';
980
1242
  }
981
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
+ */
982
1262
  function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
983
- const list = actions.filter((a) => a.on === 'toolbar');
984
- 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)];
985
1266
  const parts = list.map((a) => {
986
1267
  const id = toolbarAnchor(ctx.object, a.id);
987
1268
  ctx.components.add('Button');
@@ -991,13 +1272,15 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
991
1272
  variant: actionTone(a),
992
1273
  // 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
993
1274
  ...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
1275
+ // 置灰原因(disabled 为真时 Button 才显示):字面量原样带,view.<成员> 编成页面变量路径;row. 路径在入口已报 KIT-VIEW-001
1276
+ ...toolbarReasonProp(a),
994
1277
  // K1-2:Button 读 permission 服务,无权不渲染
995
1278
  ...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
996
1279
  },
997
1280
  };
998
1281
  return host('Button', id);
999
1282
  });
1000
- return `<div${attr('class', KIT_CLASS_DEFAULTS.tableActions)}>${parts.join('')}</div>`;
1283
+ return `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${parts.join('')}</div>`;
1001
1284
  }
1002
1285
 
1003
1286
  // ---------------------------------------------------------------- 主函数
@@ -1010,6 +1293,9 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1010
1293
  const base = options.singlePath ?? `page.data.${object}`;
1011
1294
  // 摘要 / 只读 form / 写死形状(single)读 summaryPath(如焦点切片里的当前行);缺省同 base。行数组与总数仍按 base
1012
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] : [])) : [];
1013
1299
  const ctx: Ctx = {
1014
1300
  object,
1015
1301
  options,
@@ -1022,9 +1308,12 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1022
1308
  totalPath: `${base}.${options.listShape.total}`,
1023
1309
  basePath: base,
1024
1310
  scope: () => ir.scope,
1311
+ ...(ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static' ? { filterId: viewAnchor(object, 'filter') } : {}),
1312
+ ...(columnParams.length > 0 ? { columnParams } : {}),
1025
1313
  };
1026
1314
 
1027
1315
  // 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
1316
+ const footerIds = new Set(ir.views.form?.formOpts?.footerActions ?? []);
1028
1317
  (options.actions ?? []).forEach((a, i) => {
1029
1318
  for (const key of ['disabled', 'hidden'] as const) {
1030
1319
  if (a[key] === undefined) continue;
@@ -1034,13 +1323,29 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1034
1323
  if (!isViewPath(a[key])) checkRowPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics, options.schema);
1035
1324
  }
1036
1325
  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 动作上)` });
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
+ }
1038
1342
  }
1039
1343
  });
1040
1344
 
1041
1345
  const parts: KitStaticEmit['parts'] = {};
1042
1346
  const toolbar = renderToolbar(ctx, options.actions ?? []);
1043
1347
  if (toolbar !== '') parts.toolbar = toolbar;
1348
+ const secondaryToolbar = toolbar !== '';
1044
1349
 
1045
1350
  for (const slot of SLOT_ORDER) {
1046
1351
  const view = ir.views[slot];
@@ -1078,14 +1383,49 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
1078
1383
  html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
1079
1384
  }
1080
1385
  }
1386
+ // 树表「全部展开 / 全部收起」:进表格工具位(与刷新同一行、标题行右侧),不再是表头下面那条灰条
1387
+ const treeCtl = slot === 'list' && html !== '' && layout.kind === 'table' && layout.tree !== null && layout.tree.expandAll ? renderTreeControls(ctx) : '';
1081
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) : '';
1082
1392
  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}`;
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}`;
1084
1417
  }
1085
1418
  parts[slot] = html;
1086
1419
  }
1087
1420
 
1088
- 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 !== '');
1089
1429
  return {
1090
1430
  parts,
1091
1431
  html: ordered.join('\n'),