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
@@ -0,0 +1,84 @@
1
+ // 筛选区的排布投影:引擎(soma-foundation/arrange#arrangeFilter → 参考实现 solveFilterBar)给出档位与字段 [最小, 理想, 最大] 宽,这里只把 plan 翻成类串与标记。
2
+ // · 档位三选一(字段数 → 即时 / 提交 / 更多),页面可显式指定(filter.mode / filter.pinned,见 render-object);
3
+ // · 字段按类型取理想宽、靠左流式排布(`w-full @<档>:w-<理想>`,最大宽封顶,不拉伸);分隔线占满一行;
4
+ // · 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段:容器达到「最后字段 + 动作区」所需宽的档起同行,更窄时整行靠左;
5
+ // · 动作区顶部的标签行占位与字段格同结构,把按钮对齐到控件那一行。
6
+ // 运行时不再代算:不量宽、不读容器宽,只切换这里写出的变体类。旧的 12 份制装行(filterPackOf)与折叠搜索区的量宽折行已删除。
7
+
8
+ import { arrangeFilter, arrangeTierAtLeastRem, arrangeTiers, type ArrangeFilterPlan } from 'soma-foundation/arrange';
9
+ import { KIT_CLASS_DEFAULTS } from './defaults';
10
+
11
+ /** 筛选栏里整行分隔线占位的字段类型名(分隔线不计入可筛选字段数,宽度恒占满一行) */
12
+ export const KIT_FILTER_DIVIDER = 'divider';
13
+
14
+ /** 筛选栏投影:根容器 / 各格宽度 / 动作区 / 标签行占位 / 提示条的类 */
15
+ export interface KitFilterProjection {
16
+ readonly plan: ArrangeFilterPlan;
17
+ /** 根容器:左起、可换行、控件顶对齐(间距走 classDefaults.gridGap) */
18
+ readonly wrapClass: string;
19
+ /** 各格宽度类(与传入的 fieldTypes 一一对应;分隔线 `w-full`) */
20
+ readonly widthClasses: string[];
21
+ /** 动作区类:紧跟最后一个字段,同行起点档取 plan.tailTier */
22
+ readonly actionsClass: string;
23
+ /** 动作区顶部标签行占位类:与动作区同行的档起显示并占满一行,把按钮挤到控件那一行 */
24
+ readonly padClass: string;
25
+ readonly noticeClass: string;
26
+ }
27
+
28
+ /** rem → 间距刻度步数(4 步 = 1rem,与 `w-60` = 15rem 同口径) */
29
+ const stepOf = (rem: number): number => Math.round(rem * 4);
30
+
31
+ /** 最大宽类:恰有同 rem 的容器档时取具名档(`max-w-xs`),否则取间距刻度 */
32
+ function maxWidthClass(rem: number): string {
33
+ const tier = arrangeTiers().find((t) => t.rem === rem);
34
+ return tier === undefined ? `max-w-${stepOf(rem)}` : `max-w-${tier.name}`;
35
+ }
36
+
37
+ export interface KitFilterOverride {
38
+ /** 页面显式指定的档位(instant / submit / more);非法值由 render-object 先报诊断,不会走到这里 */
39
+ readonly mode?: string;
40
+ /** 更多档钉住的字段数 */
41
+ readonly pinned?: number;
42
+ /** 页面写了 trigger: submit(显式不要即时生效):自动选到即时档时改取提交档 */
43
+ readonly noInstant?: boolean;
44
+ /** 页面写了 trigger: change(字段一变即生效):与档位无关——更多档同样按它生效,只是不再把档位钉成即时档 */
45
+ readonly liveTrigger?: boolean;
46
+ }
47
+
48
+ /** 取筛选区 plan:fieldTypes 是全部字段的类型(分隔线传 KIT_FILTER_DIVIDER,不计数)。 */
49
+ export function filterPlanOf(fieldTypes: ReadonlyArray<string | undefined>, override: KitFilterOverride = {}): ArrangeFilterPlan {
50
+ const fields = fieldTypes.filter((t) => t !== KIT_FILTER_DIVIDER).map((t) => ({ type: t ?? 'text' }));
51
+ const solve = (mode: string | undefined): ArrangeFilterPlan => arrangeFilter({ fields, ...(mode !== undefined ? { mode } : {}), ...(override.pinned !== undefined ? { pinned: override.pinned } : {}) });
52
+ const plan = solve(override.mode);
53
+ return override.noInstant === true && plan.mode === 'instant' ? solve('submit') : plan;
54
+ }
55
+
56
+ /** plan → 类串(见文件头)。 */
57
+ export function projectFilter(fieldTypes: ReadonlyArray<string | undefined>, override: KitFilterOverride = {}): KitFilterProjection {
58
+ const plan = filterPlanOf(fieldTypes, override);
59
+ let k = 0;
60
+ const widthClasses = fieldTypes.map((t) => {
61
+ if (t === KIT_FILTER_DIVIDER) return 'w-full';
62
+ const w = plan.widths[k++]!;
63
+ const tier = arrangeTierAtLeastRem(w.ideal);
64
+ const fixed = tier === null ? '' : ` @${tier}:w-${stepOf(w.ideal)}`;
65
+ return `w-full${fixed} ${maxWidthClass(w.max)}`;
66
+ });
67
+ // 标签行与控件行的间距取字段格同一个值(classDefaults.cell 的 gap-*):动作区的占位行才与输入框对齐
68
+ const cellGap = /(?:^|\s)gap-([\d.]+)(?=\s|$)/.exec(KIT_CLASS_DEFAULTS.cell)?.[1] ?? '1.5';
69
+ const tail = plan.tailTier;
70
+ const sameRow = tail === null ? '' : ` @${tail}:w-auto @${tail}:justify-start`;
71
+ return {
72
+ plan,
73
+ wrapClass: `flex flex-wrap items-start ${KIT_CLASS_DEFAULTS.gridGap}`,
74
+ widthClasses,
75
+ actionsClass: `mt-0 gap-y-${cellGap} items-center w-full justify-start${sameRow}`,
76
+ padClass: tail === null ? 'hidden' : `hidden w-full invisible @${tail}:block`,
77
+ noticeClass: 'w-full',
78
+ };
79
+ }
80
+
81
+ /** 投影里会用到的全部类(候选类:类串安全,一并交样式引擎) */
82
+ export function filterProjectionClasses(p: KitFilterProjection): string[] {
83
+ return [p.wrapClass, ...p.widthClasses, p.actionsClass, p.padClass, p.noticeClass].flatMap((s) => s.split(/\s+/)).filter((c) => c !== '');
84
+ }
@@ -5,8 +5,7 @@
5
5
  // · unwrap:详情在响应里的点路径;缺省按应用声明的信封约定(kit.app.yaml#envelope:failWhen 判失败、dataPath 拆数据)。
6
6
  // 取数成功用「行 + 详情(详情盖行)」作表单初值;取数中只显示处理中状态;失败照实报错并给重试,不渲染表单。
7
7
 
8
- import { isBizFailure, unwrapBizEnvelope } from '../shared/paged-list-adapter';
9
- import { envelopeMessage, getCompileEnvelope, type KitEnvelope } from '../shared/envelope';
8
+ import { envelopeMessage, getCompileEnvelope, isEnvelopeFailure as isBizFailure, unwrapEnvelope as unwrapBizEnvelope, type KitEnvelope } from '../shared/envelope';
10
9
  import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
11
10
  import { KIT_GRAMMAR } from './defaults';
12
11
  import type { KitDiagnostic } from './types';
@@ -0,0 +1,45 @@
1
+ // 表单保存成功提示(view.form.notify):页面只写一段字面量文案,替换默认「已保存」类提示。
2
+ //
3
+ // 唯一实现:业务组件(SingleObjectForm / CheckoutPage / SettingsCenter)发 `<表单>.saved` 事件管道 `NOTIFY | success | <文案>` 时都经 `savedNoticePipe` 取文案;
4
+ // 对象渲染(render-object 的视图文本校验)经 `formNotifyProblem` 判写法。含义与请求动作 `request.notify` 相同(成功提示的文案),
5
+ // 但这里只许字面量:不是 view. / row. 路径、不是 {…} 占位、不含管道符,也不与 core 事件管道的可选段前缀撞车。
6
+ // 空串 / 空白 / 未写 = 没写:默认文案与输出与没有该键时逐字节相同。
7
+
8
+ /** core 事件管道的可选段(出现在第三段之外的位置会被当成选项吞掉,文案不能与它们相撞) */
9
+ const RESERVED_SEGMENT = /^(force$|confirm:|permission:|roles:)/;
10
+
11
+ /** 文案写法有问题时返回原因;写法合法(含空串 / 未写)返回 null */
12
+ export function formNotifyProblem(raw: unknown): string | null {
13
+ if (raw === undefined) return null;
14
+ if (typeof raw !== 'string') return 'notify 必须是字符串字面量(保存成功的提示文案)';
15
+ const text = raw.trim();
16
+ if (text === '') return null;
17
+ if (text.includes('|')) return 'notify 不许含管道符 |';
18
+ if (text.includes('{') || text.includes('}')) return 'notify 只许字面量,不许 {…} 占位(要拼值请由接口 / 展示对象给成品文案)';
19
+ if (/^(view|row|page)\./.test(text) || text.startsWith('$')) return 'notify 只许字面量,不许 view. / row. / page. / $ 路径';
20
+ if (RESERVED_SEGMENT.test(text)) return 'notify 不能以 force / confirm: / permission: / roles: 开头(与事件管道的可选段冲突)';
21
+ return null;
22
+ }
23
+
24
+ /**
25
+ * 展示对象 `ctx.notify` 的成品文案(运行期值,不是页面字面量):去首尾空白,剔除管道符 |(与上面 `notify` 不许含 | 同一条规则,
26
+ * 避免文案被事件管道切段);不是字符串或处理后为空返回 null(调用方当「没有可提示的」处理)。
27
+ */
28
+ export function runtimeNoticeText(raw: unknown): string | null {
29
+ if (typeof raw !== 'string') return null;
30
+ const text = raw.replace(/\|/g, '').trim();
31
+ return text === '' ? null : text;
32
+ }
33
+
34
+ /** 取这个表单的保存成功文案:写了合法字面量用它(去首尾空白),否则用默认文案 */
35
+ export function savedNoticeText(formView: unknown, fallback: string): string {
36
+ const raw = typeof formView === 'object' && formView !== null ? (formView as { notify?: unknown }).notify : undefined;
37
+ if (typeof raw !== 'string' || formNotifyProblem(raw) !== null) return fallback;
38
+ const text = raw.trim();
39
+ return text === '' ? fallback : text;
40
+ }
41
+
42
+ /** 表单 `saved` 事件的管道:`NOTIFY | success | <文案>`(业务组件发射保存成功提示的唯一出口) */
43
+ export function savedNoticePipe(formView: unknown, fallback: string): string {
44
+ return `NOTIFY | success | ${savedNoticeText(formView, fallback)}`;
45
+ }
@@ -10,6 +10,11 @@ export { rowVarOf, emitStatic } from './emit-static';
10
10
  export type { KitStaticOptions, KitStaticEmit } from './emit-static';
11
11
  export { collectCandidates, classesInHtml } from './candidates';
12
12
  export { createKitTableActions, KIT_TABLE_ACTIONS_CLASS_CANDIDATES } from './table-actions';
13
+ // 动作组(排布引擎投影)出口:应用组件自己成组的动作用同一套恒单行 / 「更多」规则
14
+ export { projectActionGroup, projectionClasses as actionGroupClasses, planActionGroup, menuOrderDangerLast, KIT_ACTION_GROUP_CLASS_CANDIDATES } from './action-group';
15
+ export type { KitActionEntry, KitActionImportance, KitActionGroupOptions, KitActionGroupProjection } from './action-group';
16
+ export { createKitActionMore, buildActionGroup, mountActionMore, KIT_ACTION_MORE_CLASS_CANDIDATES } from './action-more';
17
+ export type { DomActionEntry } from './action-more';
13
18
  export type * from './types';
14
19
  export {
15
20
  CURRENCY_SYMBOLS,
@@ -0,0 +1,394 @@
1
+ // 布局事实适配(RV-1117 T04):kit 页面声明(解析后的 KitPageDecl)→ 与方言无关的「内容事实」(类型、标签、选项、max_len、角色、显式覆写)。
2
+ // 纯函数、只读:不改声明、不产类名、不碰发射。下游:layout-plan.ts(求解)与 compile/layout-lint(体检)。
3
+ // 角色推断读 foundation 生成的 field-roles 真源(SOMA_PIPELINE_FIELD_ROLES.inference:键名别名 × 类型),不另写一份表。
4
+
5
+ import { SOMA_PIPELINE_FIELD_ROLES } from 'soma-foundation/data/generated';
6
+ import type { KitPanelKind } from 'soma-foundation/kit-layout';
7
+ import type { KitPageDecl, KitProductDecl, KitTabDecl } from '../compile/types';
8
+ import { normalizeRef } from './arrange';
9
+ import type { KitFieldRef, KitType, KitViewSlot } from './types';
10
+
11
+ type Rec = Record<string, unknown>;
12
+ const isRec = (v: unknown): v is Rec => v !== null && typeof v === 'object' && !Array.isArray(v);
13
+ const str = (v: unknown): string | undefined => (typeof v === 'string' ? v : undefined);
14
+ const num = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
15
+
16
+ const KIT_TYPE_NAMES: readonly string[] = ['text', 'longtext', 'int', 'decimal', 'money', 'percent', 'bool', 'enum', 'enums', 'date', 'datetime', 'daterange'];
17
+
18
+ // ─── 事实类型 ───
19
+
20
+ export interface KitFactField {
21
+ readonly name: string;
22
+ readonly label: string;
23
+ readonly type: KitType;
24
+ readonly maxLen: number | null;
25
+ /** 静态枚举候选的文案;远程候选 / 无候选为 undefined */
26
+ readonly options?: readonly string[];
27
+ /** 静态候选里是否有任何一项带 tone */
28
+ readonly optionTones: boolean;
29
+ /** 候选文案是否以符号开头(038) */
30
+ readonly optionLabelsWithSymbol: readonly string[];
31
+ /** 作者写的组件名(component,或 schema 的 show / edit) */
32
+ readonly component?: string;
33
+ readonly sortable: boolean;
34
+ readonly columnFilter: boolean;
35
+ readonly width: number | null;
36
+ readonly align: 'start' | 'center' | 'end' | null;
37
+ readonly fixed: boolean;
38
+ readonly span: number | null;
39
+ readonly emphasis: 'strong' | 'muted' | null;
40
+ readonly highlight: boolean;
41
+ readonly roles: readonly string[];
42
+ readonly path: string;
43
+ /** 作者在该字段项上写的类(class / labelClass / valueClass) */
44
+ readonly classes: ReadonlyArray<{ readonly key: string; readonly value: string; readonly path: string }>;
45
+ readonly isDivider: boolean;
46
+ }
47
+
48
+ export interface KitFactAction {
49
+ readonly id: string;
50
+ readonly name: string;
51
+ readonly on: 'row' | 'toolbar' | 'field' | string;
52
+ readonly tone: string | null;
53
+ readonly more: boolean;
54
+ readonly danger: boolean;
55
+ readonly primary: boolean;
56
+ readonly path: string;
57
+ }
58
+
59
+ export interface KitFactGroup {
60
+ readonly title: string;
61
+ readonly fields: readonly KitFactField[];
62
+ readonly surface: string | null;
63
+ }
64
+
65
+ export interface KitFactView {
66
+ readonly slot: KitViewSlot;
67
+ readonly path: string;
68
+ readonly fields: readonly KitFactField[];
69
+ readonly groups: readonly KitFactGroup[];
70
+ readonly explicitCols: number | null;
71
+ readonly collapsible: boolean | null;
72
+ readonly collapsedRows: number | null;
73
+ readonly defaultCollapsedCount: number | null;
74
+ readonly labelPosition: string | null;
75
+ readonly labelWidth: number | null;
76
+ /** list 槽:集合形态;其余槽为 null */
77
+ readonly collection: 'table' | 'treeTable' | 'cards' | 'stack' | 'compact-list' | null;
78
+ readonly rowActionIds: readonly string[];
79
+ readonly select: boolean;
80
+ readonly hasFixedColumn: boolean;
81
+ readonly hasColumnsTool: boolean;
82
+ readonly hasExpand: boolean;
83
+ readonly staticComponent: string | null;
84
+ readonly staticItems: ReadonlyArray<{ readonly hasTrend: boolean }> | null;
85
+ readonly emphasis: string | null;
86
+ readonly surface: string | null;
87
+ readonly classes: ReadonlyArray<{ readonly key: string; readonly value: string; readonly path: string }>;
88
+ readonly hasOn: boolean;
89
+ }
90
+
91
+ export interface KitFactObject {
92
+ /** 例 `main.entity` / `main.panels.stat` */
93
+ readonly path: string;
94
+ readonly role: string;
95
+ readonly name: string | null;
96
+ readonly isPanel: boolean;
97
+ readonly title: string | null;
98
+ readonly panelSpan: number | null;
99
+ /** 面板组名(MultiObjectBoard 的 panels.*.group);null = 首屏常显区 */
100
+ readonly panelGroup?: string | null;
101
+ /** 面板头槽位的宿主面板名(panels.*.head);null = 独立面板 */
102
+ readonly panelHead?: string | null;
103
+ readonly panelKind: KitPanelKind;
104
+ readonly views: readonly KitFactView[];
105
+ readonly actions: readonly KitFactAction[];
106
+ readonly schemaFieldNames: readonly string[];
107
+ readonly emphasis: string | null;
108
+ readonly surface: string | null;
109
+ readonly classes: ReadonlyArray<{ readonly key: string; readonly value: string; readonly path: string }>;
110
+ }
111
+
112
+ export interface KitFactProduct {
113
+ readonly path: string;
114
+ readonly slot: string;
115
+ readonly kind: string;
116
+ readonly objects: readonly KitFactObject[];
117
+ readonly surface: string | null;
118
+ readonly classes: ReadonlyArray<{ readonly key: string; readonly value: string; readonly path: string }>;
119
+ }
120
+
121
+ export interface KitPageFacts {
122
+ readonly title: string;
123
+ readonly subtitle: string | null;
124
+ readonly url: string;
125
+ readonly frameKind: string;
126
+ readonly maxWidth: string | null;
127
+ readonly products: readonly KitFactProduct[];
128
+ readonly tabsDepth: number;
129
+ readonly frameClasses: ReadonlyArray<{ readonly key: string; readonly value: string; readonly path: string }>;
130
+ }
131
+
132
+ // ─── 抽取 ───
133
+
134
+ const SYMBOL_START = /^[\s]*[■-➿⭐⭕]/u;
135
+
136
+ /** 字段角色推断(field-roles#inference):键名(小写、去下划线连字符)命中别名且类型在允许集里。 */
137
+ export function inferFieldRoles(key: string, type: string): string[] {
138
+ const normalized = key.toLowerCase().replace(/[_-]/g, '');
139
+ const out: string[] = [];
140
+ const inference = SOMA_PIPELINE_FIELD_ROLES.inference as unknown as Record<string, { aliases: readonly string[]; types: readonly string[] }>;
141
+ const typeKey = type === 'decimal' ? 'float' : type;
142
+ for (const [role, rule] of Object.entries(inference)) {
143
+ if (rule.aliases.includes(normalized) && (rule.types.includes(typeKey) || rule.types.includes(type))) out.push(role);
144
+ }
145
+ return out;
146
+ }
147
+
148
+ function classSites(raw: Rec | undefined, at: string, keys: readonly string[]): Array<{ key: string; value: string; path: string }> {
149
+ const out: Array<{ key: string; value: string; path: string }> = [];
150
+ if (raw === undefined) return out;
151
+ for (const key of keys) {
152
+ const value = str(raw[key]);
153
+ if (value !== undefined && value.trim() !== '') out.push({ key, value, path: `${at}.${key}` });
154
+ }
155
+ return out;
156
+ }
157
+
158
+ function fieldFact(ref: KitFieldRef, schema: Rec, at: string): KitFactField {
159
+ const raw = ref as unknown as Rec;
160
+ if (raw.divider !== undefined) {
161
+ return { name: '', label: '', type: 'text', maxLen: null, optionTones: false, optionLabelsWithSymbol: [], sortable: false, columnFilter: false, width: null, align: null, fixed: false, span: null, emphasis: null, highlight: false, roles: [], path: at, classes: [], isDivider: true };
162
+ }
163
+ const def = isRec(schema[ref.name]) ? (schema[ref.name] as Rec) : {};
164
+ const typeRaw = str(def.type) ?? 'text';
165
+ const type = (KIT_TYPE_NAMES.includes(typeRaw) ? typeRaw : 'text') as KitType;
166
+ let maxLen: number | null = null;
167
+ if (Array.isArray(def.rules)) {
168
+ for (const r of def.rules) {
169
+ if (!isRec(r)) continue;
170
+ const v = num(r.max_len) ?? num(r.maxLength);
171
+ if (v !== undefined) maxLen = maxLen === null ? v : Math.min(maxLen, v);
172
+ }
173
+ }
174
+ let options: string[] | undefined;
175
+ let optionTones = false;
176
+ const optionLabelsWithSymbol: string[] = [];
177
+ if (Array.isArray(def.options)) {
178
+ options = [];
179
+ for (const o of def.options) {
180
+ if (!isRec(o)) continue;
181
+ const label = str(o.label) ?? String(o.value ?? '');
182
+ options.push(label);
183
+ if (o.tone !== undefined) optionTones = true;
184
+ if (SYMBOL_START.test(label)) optionLabelsWithSymbol.push(label);
185
+ }
186
+ }
187
+ const component = str(raw.component) ?? str(def.show) ?? str(def.edit);
188
+ const align = raw.align === 'start' || raw.align === 'center' || raw.align === 'end' ? raw.align : null;
189
+ const emphasis = raw.emphasis === 'strong' || raw.emphasis === 'muted' ? raw.emphasis : def.emphasis === 'strong' || def.emphasis === 'muted' ? (def.emphasis as 'strong' | 'muted') : null;
190
+ return {
191
+ name: ref.name,
192
+ label: str(raw.label) ?? str(def.name) ?? ref.name,
193
+ type,
194
+ maxLen,
195
+ ...(options !== undefined ? { options } : {}),
196
+ optionTones,
197
+ optionLabelsWithSymbol,
198
+ ...(component !== undefined ? { component } : {}),
199
+ sortable: raw.sortable === true,
200
+ columnFilter: raw.columnFilter === true || raw.columnFilter === 'enum' || raw.columnFilter === 'text',
201
+ width: num(raw.width) ?? null,
202
+ align,
203
+ fixed: raw.fixed === 'left' || raw.fixed === 'right',
204
+ span: num(raw.span) ?? null,
205
+ emphasis,
206
+ highlight: raw.highlight === true || def.highlight === true,
207
+ roles: inferFieldRoles(ref.name, type),
208
+ path: at,
209
+ classes: classSites(raw, at, ['class', 'labelClass', 'valueClass']),
210
+ isDivider: false,
211
+ };
212
+ }
213
+ function fieldsOf(items: unknown, schema: Rec, at: string): KitFactField[] {
214
+ if (!Array.isArray(items)) return [];
215
+ const out: KitFactField[] = [];
216
+ items.forEach((item, i) => {
217
+ if (item === null || (typeof item !== 'string' && typeof item !== 'object')) return;
218
+ const f = fieldFact(normalizeRef(item as never), schema, `${at}[${i}]`);
219
+ if (!f.isDivider) out.push(f);
220
+ });
221
+ return out;
222
+ }
223
+
224
+ /** 缺省字段集合(视图没写 fields 时,按 kit 缺省:list = 非主键、summary = 全部、form = 可写)。 */
225
+ function defaultFieldNames(slot: KitViewSlot, schema: Rec): string[] {
226
+ const entries = Object.entries(schema).filter(([, d]) => isRec(d));
227
+ if (slot === 'list') return entries.filter(([, d]) => (d as Rec).key !== true).map(([k]) => k);
228
+ if (slot === 'summary') return entries.map(([k]) => k);
229
+ if (slot === 'form') return entries.filter(([, d]) => { const p = (d as Rec).permission ?? (d as Rec).access; return p === 'w' || p === 'write' || p === 'create'; }).map(([k]) => k);
230
+ return [];
231
+ }
232
+
233
+ function viewFact(slot: KitViewSlot, raw: Rec, schema: Rec, at: string): KitFactView {
234
+ const groups: KitFactGroup[] = [];
235
+ if (Array.isArray(raw.groups)) {
236
+ raw.groups.forEach((g, gi) => {
237
+ if (!isRec(g)) return;
238
+ groups.push({ title: str(g.title) ?? '', fields: fieldsOf(g.fields, schema, `${at}.groups[${gi}].fields`), surface: str(g.surface) ?? null });
239
+ });
240
+ }
241
+ let fields = fieldsOf(raw.fields, schema, `${at}.fields`);
242
+ if (raw.fields === undefined && groups.length === 0 && raw.staticComponent === undefined) {
243
+ fields = fieldsOf(defaultFieldNames(slot, schema), schema, `${at}.fields`);
244
+ }
245
+ const collection = isRec(raw.collection) ? raw.collection : undefined;
246
+ const collectionType = slot === 'list' && raw.staticComponent === undefined ? (str(collection?.type) as KitFactView['collection'] | undefined) ?? 'table' : null;
247
+ const arrange = isRec(raw.arrange) ? raw.arrange : undefined;
248
+ const rowActionsRaw = Array.isArray(raw.rowActions) ? raw.rowActions : Array.isArray(collection?.rowActions) ? (collection?.rowActions as unknown[]) : [];
249
+ const toolbar = Array.isArray(collection?.toolbar) ? (collection?.toolbar as unknown[]) : [];
250
+ const select = collection?.select;
251
+ const items = isRec(raw.props) && Array.isArray(raw.props.items) ? raw.props.items : undefined;
252
+ const allFields = [...fields, ...groups.flatMap((g) => g.fields)];
253
+ return {
254
+ slot,
255
+ path: at,
256
+ fields,
257
+ groups,
258
+ explicitCols: num(arrange?.cols) ?? null,
259
+ collapsible: typeof raw.collapsible === 'boolean' ? raw.collapsible : null,
260
+ collapsedRows: num(raw.collapsedRows) ?? null,
261
+ defaultCollapsedCount: num(raw.defaultCollapsedCount) ?? null,
262
+ labelPosition: str(raw.labelPosition) ?? null,
263
+ labelWidth: num(raw.labelWidth) ?? null,
264
+ collection: collectionType === undefined ? null : collectionType,
265
+ rowActionIds: rowActionsRaw.filter((x): x is string => typeof x === 'string').map((x) => (x.startsWith('@') ? x.slice(1) : x)),
266
+ select: select === 'single' || select === 'multi' || (isRec(select) && (select.mode === 'single' || select.mode === 'multi')),
267
+ hasFixedColumn: allFields.some((f) => f.fixed),
268
+ hasColumnsTool: toolbar.includes('columns'),
269
+ hasExpand: collection?.expand !== undefined,
270
+ staticComponent: str(raw.staticComponent) ?? null,
271
+ staticItems: items === undefined ? null : items.map((it) => ({ hasTrend: isRec(it) && it.trend !== undefined })),
272
+ emphasis: str(raw.emphasis) ?? null,
273
+ surface: str(raw.surface) ?? null,
274
+ classes: classSites(raw, at, ['class', 'cellClass', 'rowClass', 'replaceClass']),
275
+ hasOn: isRec(raw.on) && Object.keys(raw.on).length > 0,
276
+ };
277
+ }
278
+
279
+ function actionFacts(behavior: unknown, at: string): KitFactAction[] {
280
+ if (!isRec(behavior) || !Array.isArray(behavior.actions)) return [];
281
+ const out: KitFactAction[] = [];
282
+ behavior.actions.forEach((a, i) => {
283
+ if (!isRec(a) || typeof a.id !== 'string') return;
284
+ const tone = str(a.tone) ?? null;
285
+ out.push({
286
+ id: a.id,
287
+ name: str(a.name) ?? a.id,
288
+ on: str(a.on) ?? '',
289
+ tone,
290
+ more: a.more === true,
291
+ danger: tone === 'danger' || a.builtin === 'remove',
292
+ primary: tone === 'primary',
293
+ path: `${at}.behavior.actions[${i}]`,
294
+ });
295
+ });
296
+ return out;
297
+ }
298
+
299
+ const PANEL_KIND_BY_STATIC: Readonly<Record<string, KitPanelKind>> = { StatGroup: 'metric', Chart: 'chart' };
300
+
301
+ function panelKindOf(views: readonly KitFactView[]): KitPanelKind {
302
+ const first = views[0];
303
+ if (first === undefined) return 'unknown';
304
+ if (first.staticComponent !== null) {
305
+ const direct = PANEL_KIND_BY_STATIC[first.staticComponent];
306
+ if (direct !== undefined) return direct;
307
+ return /^App(Stat|Metric)/.test(first.staticComponent) ? 'metric' : 'unknown';
308
+ }
309
+ if (first.slot === 'list') return first.collection === 'table' || first.collection === 'treeTable' ? 'table' : 'unknown';
310
+ if (first.slot === 'summary') return 'summary';
311
+ if (first.slot === 'form') return 'form';
312
+ return 'unknown';
313
+ }
314
+
315
+ function objectFact(raw: Rec, role: string, name: string | null, isPanel: boolean, at: string): KitFactObject {
316
+ const schema = isRec(raw.schema) ? raw.schema : {};
317
+ const views: KitFactView[] = [];
318
+ if (isRec(raw.view)) {
319
+ for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
320
+ const v = raw.view[slot];
321
+ if (isRec(v)) views.push(viewFact(slot, v, schema, `${at}.view.${slot}`));
322
+ }
323
+ // 视图级散键写成 staticComponent / props / on:并入一个合成的 list 槽事实(写死形状数据组件没有槽)
324
+ if (raw.view.staticComponent !== undefined) views.push(viewFact('list', raw.view, schema, `${at}.view`));
325
+ }
326
+ return {
327
+ path: at,
328
+ role,
329
+ name,
330
+ isPanel,
331
+ title: str(raw.title) ?? null,
332
+ panelSpan: num(raw.span) ?? null,
333
+ panelGroup: isPanel ? (str(raw.group)?.trim() || null) : null,
334
+ panelHead: isPanel ? (str(raw.head)?.trim() || null) : null,
335
+ panelKind: panelKindOf(views),
336
+ views,
337
+ actions: actionFacts(raw.behavior, at),
338
+ schemaFieldNames: Object.keys(schema),
339
+ emphasis: str(raw.emphasis) ?? null,
340
+ surface: str(raw.surface) ?? null,
341
+ classes: classSites(raw, at, ['class']),
342
+ };
343
+ }
344
+
345
+ function productFact(product: KitProductDecl, at: string, slot: string): KitFactProduct {
346
+ const objects: KitFactObject[] = [];
347
+ for (const [role, value] of Object.entries(product.objects ?? {})) {
348
+ if (!isRec(value)) continue;
349
+ if (value.schema !== undefined || value.behavior !== undefined || value.view !== undefined) {
350
+ objects.push(objectFact(value, role, null, false, `${at}.objects.${role}`));
351
+ } else {
352
+ // 对象表(many 角色:panels / subs / steps …):名字 → 对象;MultiObjectBoard 的 panels 是面板
353
+ for (const [name, sub] of Object.entries(value)) {
354
+ // 面板头控件(panels.<控件>.head: <宿主>)不是面板:画在宿主标题行里,不占栅格、不单独成卡(不进面板计数 / 栅格求解 / 表面层数)
355
+ const isHeadControl = role === 'panels' && isRec(sub) && typeof sub.head === 'string' && sub.head.trim() !== '';
356
+ if (isRec(sub)) objects.push(objectFact(sub, role, name, role === 'panels' && !isHeadControl, `${at}.objects.${role}.${name}`));
357
+ }
358
+ }
359
+ }
360
+ const classes = [...classSites(product as unknown as Rec, at, ['class'])];
361
+ if (isRec(product.areaClass)) {
362
+ for (const [area, value] of Object.entries(product.areaClass)) if (typeof value === 'string' && value.trim() !== '') classes.push({ key: `areaClass.${area}`, value, path: `${at}.areaClass.${area}` });
363
+ }
364
+ return { path: at, slot, kind: product.kind, objects, surface: product.surface ?? null, classes };
365
+ }
366
+
367
+ /** 页面声明 → 布局事实。声明形状不对的部分跳过,不抛。 */
368
+ export function extractKitPageFacts(decl: KitPageDecl): KitPageFacts {
369
+ const products: KitFactProduct[] = [];
370
+ let tabsDepth = 0;
371
+ for (const [slot, val] of Object.entries(decl.frame.slots)) {
372
+ if (Array.isArray(val)) {
373
+ tabsDepth = Math.max(tabsDepth, 1);
374
+ (val as KitTabDecl[]).forEach((tab, i) => products.push(productFact(tab.product, `frame.slots.${slot}[${i}].product`, slot)));
375
+ } else {
376
+ // 路径与 view-check 的 viewUsageOf 同口径(main 槽的产品在 YAML 里是顶层 product:),compile/locate 才定位得到行列
377
+ products.push(productFact(val as KitProductDecl, slot === 'main' ? 'product' : `frame.slots.${slot}`, slot));
378
+ }
379
+ }
380
+ const frameClasses: Array<{ key: string; value: string; path: string }> = classSites(decl.frame as unknown as Rec, 'frame', ['class']);
381
+ if (isRec(decl.frame.slotClass)) {
382
+ for (const [slot, value] of Object.entries(decl.frame.slotClass)) if (typeof value === 'string' && value.trim() !== '') frameClasses.push({ key: `slotClass.${slot}`, value, path: `frame.slotClass.${slot}` });
383
+ }
384
+ return {
385
+ title: decl.page.title,
386
+ subtitle: decl.page.subtitle ?? null,
387
+ url: decl.page.url,
388
+ frameKind: decl.frame.kind,
389
+ maxWidth: decl.page.maxWidth ?? null,
390
+ products,
391
+ tabsDepth,
392
+ frameClasses,
393
+ };
394
+ }