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
@@ -6,13 +6,13 @@
6
6
  // 纯函数,不碰 DOM;成员 / 方法是否在展示对象上声明过,由 compile/view-check.ts 对着登记表核(这里不认登记表)。
7
7
 
8
8
  import { KIT_GRAMMAR } from './defaults';
9
- import type { KitDiagnostic, KitFieldRef, KitSchema, KitViewForm, KitViewSlot } from './types';
9
+ import type { KitCell, KitDiagnostic, KitFieldRef, KitSchema, KitViewForm, KitViewSlot } from './types';
10
10
  import { normalizeRef } from './arrange';
11
11
 
12
12
  type Json = Record<string, any>;
13
13
  const VO = (KIT_GRAMMAR as Json).viewObject as {
14
14
  pathPattern: string; pathRoot: string; pathCoreVar: string; namePattern: string;
15
- rowState: { pathPattern: string; pathRoot: string; actionKeys: string[]; toneTiers: Record<string, string> };
15
+ rowState: { pathPattern: string; pathRoot: string; actionKeys: string[]; toneTiers: Record<string, string>; itemToneTiers: Record<string, string> };
16
16
  };
17
17
  const RS = VO.rowState;
18
18
  const ROW_RE = new RegExp(RS.pathPattern);
@@ -22,7 +22,7 @@ const NAME_RE = new RegExp(VO.namePattern);
22
22
  const METHOD_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
23
23
 
24
24
  /** 字段项上的状态键(hidden / disabled / required 要标量,options 要数组成员,nodeOptions 要对象成员,只用于画布字段) */
25
- export const KIT_FIELD_STATE_KEYS = ['hidden', 'disabled', 'required', 'options', 'nodeOptions'] as const;
25
+ export const KIT_FIELD_STATE_KEYS = ['hidden', 'disabled', 'required', 'options', 'nodeOptions', 'columnOptions', 'suggestions'] as const;
26
26
  export type KitFieldStateKey = (typeof KIT_FIELD_STATE_KEYS)[number];
27
27
 
28
28
  /** 页面上写的 view 路径(view.<成员>[.<子成员>])? */
@@ -68,6 +68,9 @@ export const KIT_ROW_ACTION_KEYS = RS.actionKeys as readonly ('hidden' | 'disabl
68
68
  /** 行样式档位 -> 类串(闭集,真源 viewObject.rowState.toneTiers) */
69
69
  export const KIT_ROW_TONE_CLASS: Readonly<Record<string, string>> = RS.toneTiers;
70
70
  export const KIT_ROW_TONE_TIERS: readonly string[] = Object.keys(RS.toneTiers);
71
+ /** 卡 / 块条目的档位 -> 类串(闭集,真源 viewObject.rowState.itemToneTiers):条目自带底色与边框,档位只用描边 / 透明度,不改底色 */
72
+ export const KIT_ITEM_TONE_CLASS: Readonly<Record<string, string>> = RS.itemToneTiers;
73
+ export type KitRowToneSet = 'row' | 'item';
71
74
 
72
75
  /** 页面上写的行路径(row.<字段>,单段字段名)? */
73
76
  export function isRowPath(value: unknown): value is string {
@@ -118,13 +121,197 @@ export function rowActionState(all: unknown, id: string): { hidden: boolean; dis
118
121
  return { hidden: on(rec.hidden), disabled: on(rec.disabled) };
119
122
  }
120
123
 
124
+ // ---------------------------------------------------------------- 置灰原因(动作 disabledReason)
125
+
126
+ /** 动作上的置灰原因键(键名登记在语法真源顶层 actionKeys;必须与 disabled 同写,置灰才显示) */
127
+ export const KIT_ACTION_REASON_KEY = 'disabledReason' as const;
128
+
129
+ /** disabledReason 取值的来源:字面量文案 | 行字段路径 | 展示对象成员路径 | 非法 */
130
+ export type KitReasonSource =
131
+ | { kind: 'literal'; text: string }
132
+ | { kind: 'row'; path: string }
133
+ | { kind: 'view'; path: string }
134
+ | { kind: 'invalid'; code: 'KIT-ACT-010' | 'KIT-ROW-001' | 'KIT-VIEW-001'; message: string };
135
+
136
+ /**
137
+ * 判一个 disabledReason 值的来源(唯一实现):
138
+ * 以 row. 开头必须是纯 row.<字段>、以 view. 开头必须是纯 view.<成员>,别的(含空串)一律是字面量文案;
139
+ * 对象 / 数字 / 含 {…} 占位(拼值)一律拒绝——原因文案由接口逐行给成品,或由展示对象给成品成员。
140
+ */
141
+ export function classifyDisabledReason(raw: unknown): KitReasonSource {
142
+ if (typeof raw !== 'string') {
143
+ return { kind: 'invalid', code: 'KIT-ACT-010', message: `disabledReason 必须是字符串(字面量文案 | view.<成员> | row.<字段>),收到 ${JSON.stringify(raw)}` };
144
+ }
145
+ if (/[{}]/.test(raw)) {
146
+ return { kind: 'invalid', code: 'KIT-ACT-010', message: `disabledReason 不支持 {…} 占位或拼值(${JSON.stringify(raw)}):原因文案由接口逐行给成品字段(row.<字段>),或由展示对象给成品成员(view.<成员>)` };
147
+ }
148
+ if (raw.startsWith(`${RS.pathRoot}.`)) {
149
+ return isRowPath(raw)
150
+ ? { kind: 'row', path: raw }
151
+ : { kind: 'invalid', code: 'KIT-ROW-001', message: `disabledReason 的行路径只许写 ${RS.pathRoot}.<字段>(单段字段名),收到 ${JSON.stringify(raw)}` };
152
+ }
153
+ if (raw.startsWith(`${VO.pathRoot}.`)) {
154
+ return isViewPath(raw)
155
+ ? { kind: 'view', path: raw }
156
+ : { kind: 'invalid', code: 'KIT-VIEW-001', message: `disabledReason 的展示对象路径只许写 ${VO.pathRoot}.<成员>,收到 ${JSON.stringify(raw)}` };
157
+ }
158
+ return { kind: 'literal', text: raw };
159
+ }
160
+
161
+ /** 运行期:从 actionState prop 取一个动作此刻的置灰原因文案(叶子 disabledReason 已被 core 逐行求成值);只认非空字符串,其余 ''(与没写时一致) */
162
+ export function rowActionReason(all: unknown, id: string): string {
163
+ const one = all !== null && typeof all === 'object' ? (all as Record<string, unknown>)[id] : undefined;
164
+ const v = one !== null && typeof one === 'object' ? (one as Record<string, unknown>)[KIT_ACTION_REASON_KEY] : undefined;
165
+ return typeof v === 'string' ? v.trim() : '';
166
+ }
167
+
168
+ /** 运行期:行动作 / 菜单项此刻的置灰原因:只在动作置灰时有效;行 / 展示对象给的值优先,其次是 actions 项里的字面量 */
169
+ export function disabledReasonOf(all: unknown, item: { id: string; disabledReason?: string }): string {
170
+ if (!rowActionState(all, item.id).disabled) return '';
171
+ const bound = rowActionReason(all, item.id);
172
+ return bound !== '' ? bound : (item.disabledReason ?? '').trim();
173
+ }
174
+
175
+ // ---------------------------------------------------------------- 组件 props / 请求 params / 组件事件 绑展示对象(RV-1119)
176
+ // 页面只写纯路径:props / params 的值写 view.<成员>[.<子成员>](字段项 props 在列表里另许 row.<字段>)或字面量;
177
+ // 事件的值写 view.<方法>(组件抛出的事件调展示对象方法,载荷 = 组件 emit 的载荷)。本节是这条规则的唯一实现,
178
+ // 渲染层(render-object / arrange / compile-data)与编译期核对(compile/view-check)共用,不各写一份。
179
+
180
+ /** 页面里写的原始运行期路径(page.* / kit_row_* / $page.* / $row.*):props 里会被 core 静默当路径绑定,params 里会绕过展示对象,一律拒绝 */
181
+ const RUNTIME_PATH_RE = /^(\$?page\.|\$?kit_row_[A-Za-z0-9_]+\.|\$row\.)/;
182
+ /** 取反写法(!view.x / !row.x / !page.x):页面不写取反,相反的值由展示对象另给成员 */
183
+ const NEGATED_PATH_RE = /^!\s*(view|row|page)\./;
184
+
185
+ export type KitBindingSource =
186
+ | { kind: 'literal' }
187
+ | { kind: 'view'; path: string }
188
+ | { kind: 'row'; path: string }
189
+ | { kind: 'invalid'; code: 'KIT-VIEW-001' | 'KIT-ROW-001' | 'KIT-VIEW-010'; message: string };
190
+
191
+ /**
192
+ * 判一个 props / params 取值的来源(唯一实现):
193
+ * 以 view. 开头必须是纯 view.<成员>[.<子成员>]、以 row. 开头必须是纯 row.<字段>,否则 invalid;
194
+ * 原始运行期路径(page. / kit_row_ / $page. / $row.)与取反写法 invalid;别的字符串与非字符串一律是字面量。
195
+ */
196
+ export function classifyBindingValue(raw: unknown, what: string): KitBindingSource {
197
+ if (typeof raw !== 'string') return { kind: 'literal' };
198
+ if (NEGATED_PATH_RE.test(raw)) {
199
+ return { kind: 'invalid', code: 'KIT-VIEW-001', message: `${what} 不许取反(${JSON.stringify(raw)}):页面只写纯路径,相反的值由展示对象另给一个成员` };
200
+ }
201
+ if (raw.startsWith(`${VO.pathRoot}.`)) {
202
+ return isViewPath(raw)
203
+ ? { kind: 'view', path: raw }
204
+ : { kind: 'invalid', code: 'KIT-VIEW-001', message: `${what} 只许写展示对象成员路径 ${VO.pathRoot}.<成员>[.<子成员>],收到 ${JSON.stringify(raw)}(不许表达式、比较、下标、插值)` };
205
+ }
206
+ if (raw.startsWith(`${RS.pathRoot}.`)) {
207
+ return isRowPath(raw)
208
+ ? { kind: 'row', path: raw }
209
+ : { kind: 'invalid', code: 'KIT-ROW-001', message: `${what} 的行路径只许写 ${RS.pathRoot}.<字段>(单段字段名),收到 ${JSON.stringify(raw)}` };
210
+ }
211
+ if (RUNTIME_PATH_RE.test(raw)) {
212
+ return { kind: 'invalid', code: 'KIT-VIEW-010', message: `${what} 不许写原始运行期路径 ${JSON.stringify(raw)}(page.* / kit_row_* / $page.* 等):值由展示对象成员(view.<成员>)或行字段(row.<字段>,仅列表字段项)给出` };
213
+ }
214
+ return { kind: 'literal' };
215
+ }
216
+
217
+ /** 页面声明的请求参数里不许出现的跨对象 / 行运行期路径(params 合法的 $page.query.* / $page.params.* 不在其中) */
218
+ const FORBIDDEN_PARAM_PATH_RE = /^\$?(page\.(data|region_mirror)\.|kit_row_[A-Za-z0-9_]+\.)|^\$row\./;
219
+
220
+ /**
221
+ * 判一个 behavior.params 取值的来源:同 classifyBindingValue,但 params 里合法的 $page.query.* / $page.params.* 等 $ 路径是字面量(原样透传给 core);
222
+ * rejectRuntime 为真(核页面声明)时,跨对象运行期路径($page.data.* / $page.region_mirror.* / $kit_row_* / $row.*)记 KIT-VIEW-010;
223
+ * 编译产物里 biz 层会合法注入镜像路径,所以发射阶段不开 rejectRuntime。
224
+ */
225
+ export function classifyParamBinding(raw: unknown, what: string, rejectRuntime: boolean): KitBindingSource {
226
+ if (typeof raw === 'string' && FORBIDDEN_PARAM_PATH_RE.test(raw)) {
227
+ return rejectRuntime
228
+ ? { kind: 'invalid', code: 'KIT-VIEW-010', message: `${what} 不许写跨对象 / 行的运行期路径 ${JSON.stringify(raw)}:另一个对象的数据由展示对象转存成成员后写 view.<成员>(ctx.data(对象).onChange)` }
229
+ : { kind: 'literal' };
230
+ }
231
+ const b = classifyBindingValue(raw, what);
232
+ return b.kind === 'invalid' && b.code === 'KIT-VIEW-010' ? { kind: 'literal' } : b;
233
+ }
234
+
235
+ /**
236
+ * 嵌套在对象 / 数组里的字符串:绑定只认整个值,嵌套处写了原始运行期路径记 KIT-VIEW-010(core 会静默绑定它),
237
+ * 写了 view. / row. 纯路径或取反记 KIT-VIEW-001(嵌套处不会被绑定,不许静默当字面量)。
238
+ */
239
+ export function checkNestedBindingValues(value: unknown, at: string, diags: KitDiagnostic[]): void {
240
+ if (value === null || typeof value !== 'object') return;
241
+ const entries: Array<[string, unknown]> = Array.isArray(value) ? value.map((v, i): [string, unknown] => [`[${i}]`, v]) : Object.entries(value).map(([k, v]): [string, unknown] => [`.${k}`, v]);
242
+ for (const [sub, v] of entries) {
243
+ const here = `${at}${sub}`;
244
+ if (typeof v === 'string') {
245
+ const b = classifyBindingValue(v, `${here}`);
246
+ if (b.kind === 'invalid') diags.push({ code: b.code, path: here, message: b.message });
247
+ else if (b.kind === 'view' || b.kind === 'row') {
248
+ diags.push({ code: 'KIT-VIEW-001', path: here, message: `${here} 是嵌套在对象 / 数组里的绑定路径 ${JSON.stringify(v)}:绑定只认整个 prop 值,请把整个 prop 写成 ${VO.pathRoot}.<成员>(展示对象整体替换引用)` });
249
+ }
250
+ } else checkNestedBindingValues(v, here, diags);
251
+ }
252
+ }
253
+
254
+ /** 事件值的来源:展示对象方法(view.<方法>)| 不是 view. 写法(按动作名处理)| 非法(view. 开头却不是单段方法名) */
255
+ export type KitEventBinding =
256
+ | { kind: 'method'; name: string }
257
+ | { kind: 'other' }
258
+ | { kind: 'invalid'; message: string };
259
+
260
+ const VIEW_METHOD_REF_RE = /^view\.[A-Za-z][A-Za-z0-9_]*$/;
261
+
262
+ /** 判一个事件值是不是 view.<方法>(组件事件 / 浮层事件 / 动作 submit 共用);唯一实现 */
263
+ export function classifyEventBinding(raw: unknown, what: string): KitEventBinding {
264
+ if (typeof raw !== 'string' || !raw.startsWith(`${VO.pathRoot}.`)) return { kind: 'other' };
265
+ if (VIEW_METHOD_REF_RE.test(raw)) return { kind: 'method', name: raw.slice(VO.pathRoot.length + 1) };
266
+ return { kind: 'invalid', message: `${what} 只许写展示对象方法 ${VO.pathRoot}.<方法>(单段方法名),收到 ${JSON.stringify(raw)}` };
267
+ }
268
+
269
+ /**
270
+ * 字段项 props 的绑定(只读单元:list / summary / 只读 form 的字段):值写 view.<成员> 编成 core 页面变量路径;
271
+ * 列表字段项另许 row.<字段>(业务对象逐行给的字段,字段须在 schema 里声明,KIT-ROW-003),记进 cell.rowProps 由发射层按行变量换成 core 行路径。
272
+ * 可编辑单元(edit 态 form / filter)不支持(表单草稿与重画互相打架):写了记 KIT-VIEW-006;row. 写在 list 以外记 KIT-ROW-002。
273
+ * cells 是该视图排布出的全部格(按字段名对应字段项);调用前格的 props 里仍是页面原值,这里就地改写。
274
+ */
275
+ export function bindFieldProps(slot: KitViewSlot, form: KitViewForm, cells: readonly KitCell[], path: string, diags: KitDiagnostic[], schema?: KitSchema): void {
276
+ const byField = new Map<string, KitCell>();
277
+ for (const c of cells) if (c.placeholder !== true && c.divider !== true && !byField.has(c.field)) byField.set(c.field, c);
278
+ for (const { ref, at } of refsOf(form, path)) {
279
+ const raw = ref.props;
280
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) continue;
281
+ const cell = byField.get(ref.name);
282
+ for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {
283
+ const where = `${at}.props.${k}`;
284
+ const what = `字段 ${ref.name} 的 props.${k}`;
285
+ const b = classifyBindingValue(v, what);
286
+ if (b.kind === 'literal') { checkNestedBindingValues(v, where, diags); continue; }
287
+ if (cell !== undefined) delete cell.props[k];
288
+ if (b.kind === 'invalid') { diags.push({ code: b.code, path: where, message: b.message }); continue; }
289
+ if (cell === undefined) continue;
290
+ if (cell.mode !== 'show') {
291
+ diags.push({ code: 'KIT-VIEW-006', path: where, message: `${what} 绑定到展示对象只对只读单元生效(list / summary / 只读 form);${slot} 视图的可编辑字段不支持` });
292
+ continue;
293
+ }
294
+ if (b.kind === 'view') { cell.props[k] = viewPathToCore(b.path); continue; }
295
+ if (slot !== 'list') {
296
+ diags.push({ code: 'KIT-ROW-002', path: where, message: `${what} 不能绑 row.<字段>:row.<字段> 只用于列表视图的字段项;${slot} 视图没有行,写 view.<成员>` });
297
+ continue;
298
+ }
299
+ const field = checkRowPath(b.path, where, what, diags, schema);
300
+ if (field !== undefined) (cell.rowProps ??= {})[k] = field;
301
+ }
302
+ }
303
+ }
304
+
121
305
  /** 运行期:行样式档位名 -> 类串;不在闭集(含空、未知)返回 ''(不加任何类) */
122
- export function rowToneClass(tier: unknown): string {
123
- return typeof tier === 'string' && Object.prototype.hasOwnProperty.call(KIT_ROW_TONE_CLASS, tier) ? KIT_ROW_TONE_CLASS[tier]! : '';
306
+ export function rowToneClass(tier: unknown, set: KitRowToneSet = 'row'): string {
307
+ const map = set === 'item' ? KIT_ITEM_TONE_CLASS : KIT_ROW_TONE_CLASS;
308
+ return typeof tier === 'string' && Object.prototype.hasOwnProperty.call(map, tier) ? map[tier]! : '';
124
309
  }
125
310
 
126
311
  /** nodeOptions 的宿主:只有这个编辑组件的字段项可写 nodeOptions */
127
312
  const NODE_OPTIONS_EDITOR = 'FlowEditor';
313
+ /** columnOptions 的宿主:只有这个编辑组件(子表)的字段项可写 columnOptions */
314
+ const COLUMN_OPTIONS_EDITOR = 'RowEditor';
128
315
 
129
316
  export type KitFieldStateIR = Record<string, Partial<Record<KitFieldStateKey, string>>>;
130
317
 
@@ -144,7 +331,7 @@ function refsOf(form: KitViewForm, path: string): Array<{ ref: KitFieldRef; at:
144
331
  }
145
332
 
146
333
  /**
147
- * 收集一个视图字段项上的状态绑定。只有可编辑 form 视图的字段项有意义,其它视图写了记 KIT-VIEW-006;
334
+ * 收集一个视图字段项上的状态绑定。可编辑 form 视图全部键有意义;filter 视图只认 options;其它写法 / 视图记 KIT-VIEW-006;
148
335
  * 值不是纯 view 路径记 KIT-VIEW-001。返回 { 字段: { hidden?, disabled?, required? } }(路径已换成 core 的 page.<成员>)。
149
336
  */
150
337
  export function collectFieldState(slot: KitViewSlot, form: KitViewForm, path: string, diags: KitDiagnostic[], schema?: KitSchema): KitFieldStateIR {
@@ -154,14 +341,24 @@ export function collectFieldState(slot: KitViewSlot, form: KitViewForm, path: st
154
341
  const raw = (ref as unknown as Record<string, unknown>)[key];
155
342
  if (raw === undefined) continue;
156
343
  const where = `${at}.${key}`;
157
- if (slot !== 'form') {
158
- diags.push({ code: 'KIT-VIEW-006', path: where, message: `字段项的 ${key} 只对可编辑 form 视图生效,${slot} 视图不能写` });
344
+ // filter 视图只放行 options(候选随另一个筛选字段变化);hidden / disabled / required 在筛选栏没有对应语义(筛选字段恒可选填),其余键是画布 / 子表专用
345
+ if (slot !== 'form' && !(slot === 'filter' && key === 'options')) {
346
+ diags.push({ code: 'KIT-VIEW-006', path: where, message: slot === 'filter'
347
+ ? `字段项的 ${key} 在 filter 视图里不能写(筛选视图的字段项只支持 options: view.<成员>;${key} 只对可编辑 form 视图生效)`
348
+ : `字段项的 ${key} 只对可编辑 form 视图生效${key === 'options' ? '(options 另可写在 filter 视图)' : ''},${slot} 视图不能写` });
159
349
  continue;
160
350
  }
161
351
  // nodeOptions 是画布字段(编辑组件 FlowEditor)的节点候选项,写在别的字段上没有落点
162
352
  if (key === 'nodeOptions' && (ref.component ?? schema?.[ref.name]?.edit) !== NODE_OPTIONS_EDITOR) {
163
353
  diags.push({ code: 'KIT-VIEW-006', path: where, message: `字段 ${ref.name} 的 nodeOptions 只对编辑组件是 ${NODE_OPTIONS_EDITOR} 的字段生效(schema 里 edit: ${NODE_OPTIONS_EDITOR},或字段项 component: ${NODE_OPTIONS_EDITOR})` });
164
354
  }
355
+ if (key === 'columnOptions' && (ref.component ?? schema?.[ref.name]?.edit) !== COLUMN_OPTIONS_EDITOR) {
356
+ diags.push({ code: 'KIT-VIEW-006', path: where, message: `字段 ${ref.name} 的 columnOptions 只对编辑组件是 ${COLUMN_OPTIONS_EDITOR} 的字段生效(schema 里 edit: ${COLUMN_OPTIONS_EDITOR},或字段项 component: ${COLUMN_OPTIONS_EDITOR})` });
357
+ }
358
+ // suggestions 是画布字段(FlowEditor)的 AI 建议,只在画布上有落点
359
+ if (key === 'suggestions' && (ref.component ?? schema?.[ref.name]?.edit) !== NODE_OPTIONS_EDITOR) {
360
+ diags.push({ code: 'KIT-VIEW-006', path: where, message: `字段 ${ref.name} 的 suggestions 只对编辑组件是 ${NODE_OPTIONS_EDITOR} 的字段生效(schema 里 edit: ${NODE_OPTIONS_EDITOR},或字段项 component: ${NODE_OPTIONS_EDITOR})` });
361
+ }
165
362
  const core = checkViewPath(raw, where, `字段 ${ref.name} 的 ${key}`, diags);
166
363
  if (core !== undefined) (out[ref.name] ??= {})[key] = core;
167
364
  }
@@ -419,6 +419,17 @@ function checkField(f: unknown, at: string, out: PageDiagnostic[]): void {
419
419
  out.push(issue(CODE_UNKNOWN, `${at}.display`, `展示词 ${String(f.display)} 不在闭集`, `改用 ${words.join(' / ')}`));
420
420
  } else if (typeof f.type === 'string' && !word.types.includes('*') && !word.types.includes(f.type)) {
421
421
  out.push(issue(CODE_INSUFFICIENT, `${at}.display`, `展示词 ${String(f.display)} 不适用于 ${f.type} 类型的字段(可用类型:${word.types.join(' / ')})`, `改用适合 ${f.type} 的展示词,或删去 display`));
422
+ } else if (word.requiresOptionTone === true) {
423
+ const opts = Array.isArray(f.options) ? f.options : [];
424
+ if (opts.length === 0) {
425
+ out.push(issue(CODE_INSUFFICIENT, `${at}.options`, `展示词 ${String(f.display)} 要求每个选项声明语气(tone),但字段没有选项`, `给字段写 options,并给每个选项补 tone(${aiTones().join(' / ')};没有明确好坏写 neutral)`));
426
+ } else {
427
+ opts.forEach((o, i) => {
428
+ if (isRecord(o) && o.tone === undefined) {
429
+ out.push(issue(CODE_INSUFFICIENT, `${at}.options[${i}].tone`, `展示词 ${String(f.display)} 要求每个选项声明语气(tone),选项 ${String(o.value)} 没写`, `给每个选项补 tone(${aiTones().join(' / ')};没有明确好坏写 neutral)`));
430
+ }
431
+ });
432
+ }
422
433
  }
423
434
  }
424
435
  for (const k of fieldHintKeys()) {
@@ -46,6 +46,7 @@ import type { KitApp } from '../app/define-kit-app';
46
46
  import { KitSubmitError } from '../app/submit.types';
47
47
  import { compileKitPage } from '../compile/compile-page';
48
48
  import { createYamlLocator } from '../compile/locate';
49
+ import { KIT_LAYOUT_LATEST_PIN } from '../object-renderer/layout-plan';
49
50
  import { isRecord, parsePageDecl } from '../compile/parse';
50
51
  import type { KitDiagnostic } from '../object-renderer/types';
51
52
  import { KIT_CORE_MAPPING } from '../object-renderer/defaults';
@@ -129,6 +130,8 @@ const DISPLAY_SUMMARY: Readonly<Record<string, string>> = Object.freeze({
129
130
  text: '纯文本(默认)',
130
131
  tag: '标签',
131
132
  progress: '进度条',
133
+ delta: '涨跌标(箭头 + 变化率,数值是比率,如 0.12 = 12%)',
134
+ status: '状态点 + 文字',
132
135
  switch: '只读开关',
133
136
  rating: '只读星级',
134
137
  avatar: '头像',
@@ -547,7 +550,8 @@ export async function createKitPageTarget(app: KitPageTargetApp, targetOptions:
547
550
  const surface = checkKitWriterSurface(parsed.value);
548
551
  if (surface.length > 0) return { ok: false, issues: surface };
549
552
  const locate = createYamlLocator(text);
550
- const compiled = await compileKitPage(text, appContext);
553
+ // AI 目标恒钉最新布局规则版本(RV-1117 T09);规则版本 0 / 1 的发射目前相同(求解生效属第二期),所以产物不变,只影响旁路的布局报告
554
+ const compiled = await compileKitPage(text, { ...appContext, layoutRules: KIT_LAYOUT_LATEST_PIN });
551
555
  if (compiled.artifact === undefined || compiled.diagnostics.length > 0) {
552
556
  const shown = compiled.diagnostics.length > 0
553
557
  ? compiled.diagnostics.map((d) => issueOfKit(d, locate))
@@ -2,7 +2,19 @@
2
2
  // 提供 card / panel / section / well 四类 data-kit-part 常量与纯函数配方,
3
3
  // 以及 slot 视图槽、容器 emphasis、highlight 高亮子配方函数,消除平行重复字面量。
4
4
 
5
+ import { arrangePairBalance } from 'soma-foundation/arrange';
5
6
  import { classCandidates } from '../base/class-candidates';
7
+ import { mergeClass } from '../object-renderer/merge-class';
8
+ import { kitSurfaceRecipe } from './surface';
9
+
10
+ /**
11
+ * 筛选带(R04 / 视觉语言第 1 期):列表面板顶部的下沉带(--soma-surface-band,通栏、顶部圆角随面板),取代原先的通栏 hairline;
12
+ * 负外边距抵消面板内边距 p-card,内容位置不变。容器内的段与段用色带与间距分,不用线(线只留给重复项之间:表格行)。
13
+ */
14
+ export const KIT_LIST_BAR_CLASS = '-mx-card -mt-card rounded-t-lg bg-surface-band p-card';
15
+
16
+ /** 无容器列表(唯一主体 = 页面本身,container: plain)的筛选带:自己带圆角的下沉带,不再抵消面板内边距(没有面板)。 */
17
+ export const KIT_LIST_BAR_FLAT_CLASS = 'rounded-lg bg-surface-band p-card';
6
18
 
7
19
  export const KIT_PART_CARD = 'card' as const;
8
20
  export const KIT_PART_PANEL = 'panel' as const;
@@ -29,7 +41,8 @@ export interface KitContainerRecipeOptions {
29
41
 
30
42
  const SURFACE_CLASS: Readonly<Record<KitContainerSurface, string>> = Object.freeze({
31
43
  // 标准卡片圆角(rounded-card),实底卡片高于画布
32
- card: 'flex flex-col rounded-card border border-border-subtle bg-surface text-fg shadow-sm',
44
+ // 面板级表面(圆角 / 容器边界 / 底色 / 高光边)取 recipes/surface.ts 的 panel 级;shadow-sm 是面板的常驻浅阴影(九维边界档改写),与高光边在 Tailwind 的 box-shadow 槽里叠加
45
+ card: mergeClass('flex flex-col text-fg shadow-sm', kitSurfaceRecipe('panel')),
33
46
  // flush 贴边面板:底部分隔线、无外圆角与外阴影
34
47
  flush: 'flex flex-col rounded-none border-b border-border-subtle bg-surface text-fg',
35
48
  // plain 纯结构区块容器:无背景与边框,遵循九维区块间距令牌(gap-section)
@@ -106,6 +119,49 @@ export function kitContainerEmphasisRecipe(emphasis: KitContainerEmphasis = 'nor
106
119
  }
107
120
  }
108
121
 
122
+ /**
123
+ * 「压平」标记属性:打在业务壳的卡片(分栏 / 区块)上,卡片里子对象自己输出的容器壳(section / role=region / 虚拟滚动外壳 / 树表)
124
+ * 不再画第二层容器(无边框、无阴影、透明底),避免卡中卡;规则在 theme/nine-dim-structure.ts(只认这个标记,不按主题维度分支)。
125
+ */
126
+ export const KIT_SHELL_FLAT_ATTR = 'data-kit-shell-flat' as const;
127
+ /** 直接拼进开标签的属性串(带前导空格) */
128
+ export const KIT_SHELL_FLAT_MARK = ` ${KIT_SHELL_FLAT_ATTR}="true"`;
129
+
130
+ /** 主从工作台根标记,及「辅助栏里的结果面板尚无结果」状态标记(打在根上,壳上的 `group-data-kit-aside-idle/ms:` 变体据此收起辅助栏、让中栏占满) */
131
+ export const KIT_MS_ROOT_ATTR = 'data-kit-ms-root' as const;
132
+ export const KIT_MS_ASIDE_IDLE_ATTR = 'data-kit-aside-idle' as const;
133
+ /** 概况条成员(应用组件)没有可显示的概况(缺失 / 门禁未过)时,在自己的宿主上打这个属性;条内成员全部带它时整条概况条不渲染(结构 CSS),由下方的卡自己说明 */
134
+ export const KIT_SUMMARY_EMPTY_ATTR = 'data-kit-summary-empty' as const;
135
+ /** 面板主体(应用组件)整个就是一行空态时,在自己的宿主上打这个属性;面板里的组件宿主全部带它时面板不画卡(无边框 / 底色 / 阴影 / 内边距),只留标题与一行空态(与列表页空态同版式) */
136
+ export const KIT_HOST_EMPTY_ATTR = 'data-kit-host-empty' as const;
137
+
138
+ export type KitShellTone = 'raised' | 'base' | 'sunken';
139
+
140
+ export interface KitShellRecipeOptions {
141
+ /** 底色层:raised(默认,高于画布)/ base / sunken(凹槽) */
142
+ tone?: KitShellTone;
143
+ /** 常驻浅阴影(shadow-xs,由九维质感令牌改写);默认 true */
144
+ shadow?: boolean;
145
+ }
146
+
147
+ const SHELL_TONE_CLASS: Readonly<Record<KitShellTone, string>> = Object.freeze({
148
+ raised: 'bg-surface-raised',
149
+ base: 'bg-surface',
150
+ sunken: 'bg-surface-sunken',
151
+ });
152
+
153
+ /**
154
+ * 业务壳(biz/* 的分栏 / 卡片 / 区块)容器外观配方:圆角 + 容器边界色 + 底色层(+ 浅阴影),不含内边距与布局。
155
+ * 边界色用 border-border-container(= --soma-container-border-color,随九维「边界」维度求解:无边框档 transparent、其余档发丝边),
156
+ * 所以 div / button 型壳与 section / aside 型容器一样随边界维度变化,不再写死 border-border-strong 绕过边界维度。
157
+ * 壳里用 mergeClass(布局类, kitShellRecipe(...)) 组合,不手拼字符串。
158
+ */
159
+ export function kitShellRecipe(options: KitShellRecipeOptions = {}): string {
160
+ const tone = options.tone ?? 'raised';
161
+ const shadow = options.shadow ?? true;
162
+ return ['rounded-lg border border-border-container', SHELL_TONE_CLASS[tone] ?? SHELL_TONE_CLASS.raised, shadow ? 'shadow-xs' : ''].filter(Boolean).join(' ');
163
+ }
164
+
109
165
  /**
110
166
  * 视图/指标高亮 highlight 子配方函数:产出设计规范基准类串。
111
167
  */
@@ -157,9 +213,29 @@ function collectContainerRecipeCandidates(): string[] {
157
213
  for (const hk of ALL_HIGHLIGHT_KINDS) {
158
214
  classes.push(kitHighlightRecipe(hk));
159
215
  }
216
+ for (const tone of ['raised', 'base', 'sunken'] as const) {
217
+ classes.push(kitShellRecipe({ tone }), kitShellRecipe({ tone, shadow: false }));
218
+ }
160
219
  return classes;
161
220
  }
162
221
 
222
+ /**
223
+ * 并排块配比的类串(真源 kit-arrange#pairBalance,判定在 foundation 的 arrangePairBalance):两个并排块(概况 / 汇总类,如「谁没交」|「谁有风险」)
224
+ * 内容单位数(行 / 条,空态算 1)悬殊时,少的一侧收窄到内容宽、多的一侧吃余量;否则等宽并排。窄于 @3xl 一律上下堆叠。
225
+ * 调用方把 root / a / b 写到容器与两个块上;a、b 是块的位置(第一块 / 第二块)。
226
+ */
227
+ export interface KitPairBalanceClasses { readonly mode: 'equal' | 'fit-a' | 'fit-b'; readonly root: string; readonly a: string; readonly b: string }
228
+ const PAIR_EQUAL = 'grid grid-cols-1 gap-x-section gap-y-region @3xl:grid-cols-2';
229
+ const PAIR_FIT = 'flex flex-col gap-x-section gap-y-region @3xl:flex-row';
230
+ const PAIR_LIGHT = 'min-w-0 @3xl:w-fit @3xl:max-w-xs @3xl:shrink-0';
231
+ const PAIR_HEAVY = 'min-w-0 @3xl:flex-1 @3xl:max-w-2xl';
232
+ export function kitPairBalanceRecipe(unitsA: number, unitsB: number): KitPairBalanceClasses {
233
+ const { mode } = arrangePairBalance(unitsA, unitsB);
234
+ if (mode === 'equal') return { mode, root: PAIR_EQUAL, a: 'min-w-0', b: 'min-w-0' };
235
+ return { mode, root: PAIR_FIT, a: mode === 'fit-a' ? PAIR_LIGHT : PAIR_HEAVY, b: mode === 'fit-b' ? PAIR_LIGHT : PAIR_HEAVY };
236
+ }
237
+ export const KIT_PAIR_BALANCE_CLASS_CANDIDATES: readonly string[] = classCandidates(PAIR_EQUAL, PAIR_FIT, PAIR_LIGHT, PAIR_HEAVY, 'min-w-0');
238
+
163
239
  export const KIT_CONTAINER_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
164
240
  collectContainerRecipeCandidates(),
165
241
  );