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
@@ -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))
@@ -3,6 +3,8 @@
3
3
  // 以及 slot 视图槽、容器 emphasis、highlight 高亮子配方函数,消除平行重复字面量。
4
4
 
5
5
  import { classCandidates } from '../base/class-candidates';
6
+ import { mergeClass } from '../object-renderer/merge-class';
7
+ import { kitSurfaceRecipe } from './surface';
6
8
 
7
9
  export const KIT_PART_CARD = 'card' as const;
8
10
  export const KIT_PART_PANEL = 'panel' as const;
@@ -29,7 +31,8 @@ export interface KitContainerRecipeOptions {
29
31
 
30
32
  const SURFACE_CLASS: Readonly<Record<KitContainerSurface, string>> = Object.freeze({
31
33
  // 标准卡片圆角(rounded-card),实底卡片高于画布
32
- card: 'flex flex-col rounded-card border border-border-subtle bg-surface text-fg shadow-sm',
34
+ // 面板级表面(圆角 / 容器边界 / 底色 / 高光边)取 recipes/surface.ts 的 panel 级;shadow-sm 是面板的常驻浅阴影(九维边界档改写),与高光边在 Tailwind 的 box-shadow 槽里叠加
35
+ card: mergeClass('flex flex-col text-fg shadow-sm', kitSurfaceRecipe('panel')),
33
36
  // flush 贴边面板:底部分隔线、无外圆角与外阴影
34
37
  flush: 'flex flex-col rounded-none border-b border-border-subtle bg-surface text-fg',
35
38
  // plain 纯结构区块容器:无背景与边框,遵循九维区块间距令牌(gap-section)
@@ -106,6 +109,45 @@ export function kitContainerEmphasisRecipe(emphasis: KitContainerEmphasis = 'nor
106
109
  }
107
110
  }
108
111
 
112
+ /**
113
+ * 「压平」标记属性:打在业务壳的卡片(分栏 / 区块)上,卡片里子对象自己输出的容器壳(section / role=region / 虚拟滚动外壳 / 树表)
114
+ * 不再画第二层容器(无边框、无阴影、透明底),避免卡中卡;规则在 theme/nine-dim-structure.ts(只认这个标记,不按主题维度分支)。
115
+ */
116
+ export const KIT_SHELL_FLAT_ATTR = 'data-kit-shell-flat' as const;
117
+ /** 直接拼进开标签的属性串(带前导空格) */
118
+ export const KIT_SHELL_FLAT_MARK = ` ${KIT_SHELL_FLAT_ATTR}="true"`;
119
+
120
+ /** 主从工作台根标记,及「辅助栏里的结果面板尚无结果」状态标记(打在根上,壳上的 `group-data-kit-aside-idle/ms:` 变体据此收起辅助栏、让中栏占满) */
121
+ export const KIT_MS_ROOT_ATTR = 'data-kit-ms-root' as const;
122
+ export const KIT_MS_ASIDE_IDLE_ATTR = 'data-kit-aside-idle' as const;
123
+
124
+ export type KitShellTone = 'raised' | 'base' | 'sunken';
125
+
126
+ export interface KitShellRecipeOptions {
127
+ /** 底色层:raised(默认,高于画布)/ base / sunken(凹槽) */
128
+ tone?: KitShellTone;
129
+ /** 常驻浅阴影(shadow-xs,由九维质感令牌改写);默认 true */
130
+ shadow?: boolean;
131
+ }
132
+
133
+ const SHELL_TONE_CLASS: Readonly<Record<KitShellTone, string>> = Object.freeze({
134
+ raised: 'bg-surface-raised',
135
+ base: 'bg-surface',
136
+ sunken: 'bg-surface-sunken',
137
+ });
138
+
139
+ /**
140
+ * 业务壳(biz/* 的分栏 / 卡片 / 区块)容器外观配方:圆角 + 容器边界色 + 底色层(+ 浅阴影),不含内边距与布局。
141
+ * 边界色用 border-border-container(= --soma-container-border-color,随九维「边界」维度求解:无边框档 transparent、其余档发丝边),
142
+ * 所以 div / button 型壳与 section / aside 型容器一样随边界维度变化,不再写死 border-border-strong 绕过边界维度。
143
+ * 壳里用 mergeClass(布局类, kitShellRecipe(...)) 组合,不手拼字符串。
144
+ */
145
+ export function kitShellRecipe(options: KitShellRecipeOptions = {}): string {
146
+ const tone = options.tone ?? 'raised';
147
+ const shadow = options.shadow ?? true;
148
+ return ['rounded-lg border border-border-container', SHELL_TONE_CLASS[tone] ?? SHELL_TONE_CLASS.raised, shadow ? 'shadow-xs' : ''].filter(Boolean).join(' ');
149
+ }
150
+
109
151
  /**
110
152
  * 视图/指标高亮 highlight 子配方函数:产出设计规范基准类串。
111
153
  */
@@ -157,6 +199,9 @@ function collectContainerRecipeCandidates(): string[] {
157
199
  for (const hk of ALL_HIGHLIGHT_KINDS) {
158
200
  classes.push(kitHighlightRecipe(hk));
159
201
  }
202
+ for (const tone of ['raised', 'base', 'sunken'] as const) {
203
+ classes.push(kitShellRecipe({ tone }), kitShellRecipe({ tone, shadow: false }));
204
+ }
160
205
  return classes;
161
206
  }
162
207
 
@@ -1,10 +1,20 @@
1
1
  // 控件配方(control.ts):覆盖单行输入、选择器触发器、多行文本(多行不进胶囊圆角)、按钮与徽标,
2
2
  // 统一高度(sm / md / lg)、内边距、边框与圆角,并提供 data-kit-part 常量标识。
3
3
 
4
+ import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
4
5
  import { classCandidates } from '../base/class-candidates';
5
6
  import type { KitSize } from '../base/shared';
6
7
  import { kitDisabledRecipe, kitFocusRingRecipe, kitInvalidRecipe } from './state';
7
8
 
9
+ /** 小号控件高度类(间距单位倍数,读 design 真源 kit-nine-dim.json#structure.smallControlHeightUnits:标准密度 6 × 4 = 24px,随密度同比走) */
10
+ const SMALL_CONTROL_H = `h-${KIT_NINE_DIM.structure.smallControlHeightUnits}`;
11
+
12
+ /**
13
+ * 按钮按下反馈:自定义工具类 press-feedback(kit-theme.tpl),按下时 transform 取 --soma-lift-press(design motion.json#lift.pressScale 0.985);
14
+ * 只在 prefers-reduced-motion: no-preference 下生效,减少动效下令牌同时被 design reducedMotion 归 none。
15
+ */
16
+ const PRESS_FEEDBACK = 'press-feedback';
17
+
8
18
  export const KIT_PART_CONTROL = 'control' as const;
9
19
  export const KIT_PART_BUTTON = 'button' as const;
10
20
  export const KIT_PART_TEXTAREA = 'textarea' as const;
@@ -36,14 +46,15 @@ export interface KitControlRecipeOptions {
36
46
  }
37
47
 
38
48
  const SINGLE_LINE_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string }>> = Object.freeze({
39
- sm: { h: 'h-8', px: 'px-2.5', text: 'text-sm' },
40
- md: { h: 'h-9', px: 'px-3', text: 'text-sm' },
49
+ // 控件高度档(默认主题):小号读真源 structure.smallControlHeightUnits(24)、标准 32 = h-8(间距单位 4 × 8,与 design 真源 density.controlUnits = 8 同值)
50
+ sm: { h: SMALL_CONTROL_H, px: 'px-2.5', text: 'text-sm' },
51
+ md: { h: 'h-8', px: 'px-3', text: 'text-sm' },
41
52
  lg: { h: 'h-10', px: 'px-4', text: 'text-base' },
42
53
  });
43
54
 
44
55
  const BUTTON_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string; gap: string }>> = Object.freeze({
45
- sm: { h: 'h-8', px: 'px-3', text: 'text-sm', gap: 'gap-1' },
46
- md: { h: 'h-9', px: 'px-4', text: 'text-sm', gap: 'gap-2' },
56
+ sm: { h: SMALL_CONTROL_H, px: 'px-3', text: 'text-sm', gap: 'gap-1' },
57
+ md: { h: 'h-8', px: 'px-4', text: 'text-sm', gap: 'gap-2' },
47
58
  lg: { h: 'h-10', px: 'px-5', text: 'text-base', gap: 'gap-2' },
48
59
  });
49
60
 
@@ -67,6 +78,18 @@ const BUTTON_VARIANTS: ReadonlySet<KitControlVariant> = new Set([
67
78
  'tonal',
68
79
  ]);
69
80
 
81
+ /**
82
+ * 带文字标签的中性按钮描边(border-button-edge = --soma-button-border-color)。
83
+ * 为什么不直接用 border-input:WCAG 1.4.11 要求的非文本对比度针对「识别控件所必需的边界」,带可见文字标签的按钮不靠描边识别,
84
+ * 所以无边框 / 色块边界档下它的描边可降为弱描边;输入框、选择框没有文字标签,描边是识别它的唯一视觉边界,不豁免(仍 border-input)。
85
+ * 令牌的逐档取值只在 soma-design 真源 kit-nine-dim.json#/dimensions/boundary/buttonBorder;这里只给类名。
86
+ * 手写的中性文字按钮(弹层取消钮、上传钮、菜单钮等)也用本配方,不再各写 border-border。
87
+ */
88
+ const BUTTON_EDGE_CLASS = 'border border-button-edge';
89
+ export function kitButtonEdgeRecipe(): string {
90
+ return BUTTON_EDGE_CLASS;
91
+ }
92
+
70
93
  /**
71
94
  * 控件尺寸子配方函数(返回单行控件尺寸类串:高度 h-*、横向内边距 px-*、字号 text-*)。
72
95
  * 供 input.ts 的 BOX_SIZE 等直接同源调用,严禁 .split / .find 回捞。
@@ -100,9 +123,9 @@ export function kitControlRecipe(options: KitControlRecipeOptions = {}): string
100
123
 
101
124
  if (variant === 'badge') {
102
125
  const parts = [
103
- 'inline-flex items-center justify-center rounded-md transition-colors',
126
+ 'inline-flex items-center justify-center rounded-full transition-colors',
104
127
  BADGE_SIZE_CLASS[size],
105
- 'border border-border-subtle bg-surface-sunken font-medium text-fg-muted',
128
+ 'bg-surface-sunken font-medium text-fg-muted',
106
129
  ];
107
130
  if (invalid) parts.push(kitInvalidRecipe(true));
108
131
  if (disabled) parts.push(kitDisabledRecipe('text'));
@@ -120,23 +143,28 @@ export function kitControlRecipe(options: KitControlRecipeOptions = {}): string
120
143
  let middle = '';
121
144
  switch (variant) {
122
145
  case 'primary':
123
- middle = `bg-primary ${sz.px} ${sz.text} font-medium text-primary-fg transition-colors enabled:hover:bg-primary-hover enabled:active:bg-primary-active`;
146
+ middle = `bg-primary ${sz.px} ${sz.text} font-medium text-primary-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-primary-hover enabled:active:bg-primary-active`;
124
147
  break;
125
148
  case 'neutral':
126
- middle = `border border-input bg-surface ${sz.px} ${sz.text} font-medium text-fg transition-colors enabled:hover:border-input-hover enabled:hover:bg-surface-sunken enabled:active:bg-border-subtle`;
149
+ // 带文字的中性按钮的描边走「按钮描边」令牌(--soma-button-border-color,随九维边界维度求解:无边框 / 色块档降为弱描边,其余档 = 控件描边);
150
+ // 输入框 / 选择框 / 多行文本仍走 border-input(≥ 3:1,不豁免)
151
+ middle = `${BUTTON_EDGE_CLASS} bg-surface ${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} state-layer enabled:hover:border-button-edge-hover`;
152
+ // 悬停 / 按下 = 白底上叠统一状态层(state-layer 工具类,8% / 12%,底色不换,三态各自可辨);文字对比由 G82 的状态层配对判;按下与悬停同时命中时描边已是悬停描边(控件描边)
127
153
  break;
128
154
  case 'danger':
129
- middle = `bg-danger ${sz.px} ${sz.text} font-medium text-danger-fg transition-colors enabled:hover:bg-danger-hover enabled:active:bg-danger-active`;
155
+ middle = `bg-danger ${sz.px} ${sz.text} font-medium text-danger-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-danger-hover enabled:active:bg-danger-active`;
130
156
  break;
131
157
  case 'ghost':
132
- middle = `${sz.px} ${sz.text} font-medium text-fg transition-colors enabled:hover:bg-fg/8 enabled:active:bg-fg/12`;
158
+ // 悬停 / 按下读统一状态层阶梯(真源 structure.stateLayer:墨色 4% / 8%),不再散写 bg-fg/8、/12
159
+ middle = `${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-hover enabled:active:bg-state-layer-press`;
133
160
  break;
134
161
  case 'tonal':
135
- middle = `bg-primary-soft ${sz.px} ${sz.text} font-medium text-primary-on-soft transition-colors enabled:hover:bg-primary-soft/70 enabled:active:bg-primary-soft/50`;
162
+ // 柔和底(primary-soft)上的悬停 / 按下:同一阶梯百分比叠主色(--soma-state-layer-tonal-*),不再用 /70 /50 透明度
163
+ middle = `bg-primary-soft ${sz.px} ${sz.text} font-medium text-primary-on-soft transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-tonal-hover enabled:active:bg-state-layer-tonal-press`;
136
164
  break;
137
165
  }
138
166
  return [
139
- `inline-flex ${sz.h} items-center justify-center ${sz.gap} rounded-md`,
167
+ `inline-flex ${sz.h} items-center justify-center ${sz.gap} whitespace-nowrap rounded-md`,
140
168
  middle,
141
169
  focusCls,
142
170
  disabledCls,
@@ -185,6 +213,24 @@ export function kitControlRecipe(options: KitControlRecipeOptions = {}): string
185
213
  ].filter(Boolean).join(' ');
186
214
  }
187
215
 
216
+ export type KitTextActionTone = 'primary' | 'neutral' | 'danger';
217
+
218
+ /**
219
+ * 行内操作的文字链接配方(表格 / 树表 / 虚拟表的操作列与「更多」触发器):
220
+ * 无底无描边,primary / neutral 同为主色文字(primary-on-soft 压表面,配对 primary-on-soft-surface),danger 为危险语义色文字(danger-on-soft-surface);
221
+ * 点击热区高度 h-8(不低于原按钮),-my-1.5 用负外边距把它在行里的占高收回到一行文字(表格行高因此固定一档,不被操作列撑高);焦点环与禁用态走状态配方。
222
+ */
223
+ export function kitTextActionRecipe(tone: KitTextActionTone = 'primary'): string {
224
+ const color = tone === 'danger' ? 'text-danger-on-soft' : 'text-primary-on-soft';
225
+ return [
226
+ // px-0:<button> 没有 preflight,浏览器默认左右内边距 6px 会让文字比表头「操作」缩进 6px,显式清零使首个操作与表头同一左缘
227
+ 'inline-flex h-8 -my-1.5 shrink-0 items-center gap-1 whitespace-nowrap rounded-md px-0 text-sm font-medium underline-offset-2 transition-colors hover:underline',
228
+ color,
229
+ kitFocusRingRecipe('button'),
230
+ kitDisabledRecipe('button'),
231
+ ].join(' ');
232
+ }
233
+
188
234
  const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
189
235
  'outline',
190
236
  'filled',
@@ -214,6 +260,18 @@ function collectControlRecipeCandidates(): string[] {
214
260
  return classes;
215
261
  }
216
262
 
263
+ /**
264
+ * 说明气泡触发钮(字段 help 的「i」小图标钮:列头 / 摘要标签旁;点读气泡走 kitTooltip,按需挂载,见 base/hint-tips.ts)。
265
+ * 小圆钮、弱化色、悬停转正文色;焦点环统一走 button 档。
266
+ */
267
+ const HELP_TRIGGER_CLASS = 'hit-area ms-1 inline-flex h-5 w-5 shrink-0 p-0 items-center justify-center rounded-full align-middle text-fg-subtle transition-colors hover:text-fg';
268
+ export function kitHelpTriggerRecipe(): string {
269
+ return `${HELP_TRIGGER_CLASS} ${kitFocusRingRecipe('button')}`;
270
+ }
271
+
217
272
  export const KIT_CONTROL_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
218
273
  collectControlRecipeCandidates(),
274
+ kitHelpTriggerRecipe(),
275
+ kitTextActionRecipe('primary'),
276
+ kitTextActionRecipe('danger'),
219
277
  );