soma-kit 0.1.14 → 0.1.15

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 (287) hide show
  1. package/package.json +3 -3
  2. package/packs/finance/reconcile-desk/compile.ts +1 -1
  3. package/packs/finance/reconcile-desk/shell.ts +1 -1
  4. package/spec/generated/kit-app.schema.json +4 -2
  5. package/spec/generated/kit-page.schema.json +72 -2
  6. package/spec/kit-grammar.json +163 -57
  7. package/spec/kit-grammar.schema.json +0 -24
  8. package/src/app/app-config.ts +1 -1
  9. package/src/app/component-gate.ts +2 -2
  10. package/src/app/compose-apps.ts +5 -2
  11. package/src/app/define-kit-actions.ts +82 -10
  12. package/src/app/define-kit-app.ts +6 -5
  13. package/src/app/define-kit-view.ts +1 -1
  14. package/src/app/index.ts +7 -7
  15. package/src/app/kit-view-context.ts +11 -2
  16. package/src/app/theme-endpoint.ts +1 -1
  17. package/src/app/theme-runtime.ts +7 -2
  18. package/src/base/alert.ts +23 -20
  19. package/src/base/anchored-layer.ts +1 -1
  20. package/src/base/button.ts +30 -15
  21. package/src/base/cascader.ts +8 -4
  22. package/src/base/check-core.ts +9 -6
  23. package/src/base/color-picker.ts +10 -6
  24. package/src/base/command-palette.ts +10 -4
  25. package/src/base/context-menu.ts +5 -2
  26. package/src/base/date-range.ts +9 -6
  27. package/src/base/date.ts +10 -6
  28. package/src/base/delta.ts +4 -2
  29. package/src/base/divider.ts +15 -66
  30. package/src/base/fab.ts +11 -6
  31. package/src/base/gap-value.ts +1 -1
  32. package/src/base/hint-tips.ts +1 -1
  33. package/src/base/index.ts +15 -4
  34. package/src/base/inline-error.ts +84 -0
  35. package/src/base/input.ts +54 -18
  36. package/src/base/kbd.ts +4 -3
  37. package/src/base/link.ts +1 -1
  38. package/src/base/listbox-core.ts +70 -22
  39. package/src/base/mentions.ts +6 -3
  40. package/src/base/menu-button.ts +63 -27
  41. package/src/base/menu-core.ts +9 -2
  42. package/src/base/motion/hover-3d.ts +4 -1
  43. package/src/base/motion/hover-gallery.ts +4 -1
  44. package/src/base/otp.ts +7 -3
  45. package/src/base/overlay-runtime.ts +3 -2
  46. package/src/base/overlay-shell.ts +141 -0
  47. package/src/base/popover.ts +2 -2
  48. package/src/base/popup.ts +47 -41
  49. package/src/base/qty-stepper.ts +14 -9
  50. package/src/base/reason-tip.ts +2 -2
  51. package/src/{frames → base}/resize-handle.ts +1 -1
  52. package/src/base/segmented.ts +35 -36
  53. package/src/base/select.ts +1 -0
  54. package/src/base/shared.ts +43 -7
  55. package/src/base/status-tone.ts +1 -1
  56. package/src/base/tag-input.ts +13 -8
  57. package/src/base/tag.ts +53 -59
  58. package/src/base/text.ts +37 -13
  59. package/src/base/textarea.ts +1 -1
  60. package/src/base/time-picker.ts +9 -5
  61. package/src/base/tree-select.ts +12 -9
  62. package/src/base/upload.ts +21 -13
  63. package/src/biz/approval-desk/compile.ts +28 -1
  64. package/src/biz/approval-desk/shell.ts +2 -2
  65. package/src/biz/auth-panel/compile.ts +1 -1
  66. package/src/biz/auth-panel/shell.ts +2 -2
  67. package/src/biz/category-crud/compile.ts +17 -4
  68. package/src/biz/category-crud/shell.ts +7 -5
  69. package/src/biz/checkout-page/compile.ts +1 -1
  70. package/src/biz/checkout-page/shell.ts +7 -6
  71. package/src/biz/compose.ts +3 -3
  72. package/src/biz/define.ts +1 -1
  73. package/src/biz/import-wizard/compile.ts +1 -1
  74. package/src/biz/import-wizard/shell.ts +6 -4
  75. package/src/biz/index.ts +4 -3
  76. package/src/biz/landing-page/compile.ts +1 -1
  77. package/src/biz/landing-page/shell.ts +5 -4
  78. package/src/biz/link/shared.ts +8 -1
  79. package/src/biz/master-sub/compile.ts +162 -19
  80. package/src/biz/master-sub/detail-head.ts +7 -6
  81. package/src/biz/master-sub/index.ts +3 -3
  82. package/src/biz/master-sub/shell.ts +90 -53
  83. package/src/biz/multi-board/compile.ts +3 -3
  84. package/src/biz/multi-board/index.ts +24 -9
  85. package/src/biz/multi-board/prose-fold.ts +2 -2
  86. package/src/biz/multi-board/shell.ts +17 -13
  87. package/src/biz/names.ts +1 -0
  88. package/src/biz/notification-center/compile.ts +9 -2
  89. package/src/biz/notification-center/shell.ts +9 -2
  90. package/src/biz/page-templates/domain-templates.ts +6 -2
  91. package/src/biz/page-templates/result-page/compile.ts +1 -1
  92. package/src/biz/page-templates/result-page/shell.ts +4 -3
  93. package/src/biz/page-templates/shared.ts +1 -1
  94. package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
  95. package/src/biz/page-templates/sign-in-page/shell.ts +4 -4
  96. package/src/biz/record-detail/compile.ts +5 -2
  97. package/src/biz/record-detail/shell.ts +4 -4
  98. package/src/biz/settings-center/compile.ts +1 -1
  99. package/src/biz/settings-center/shell.ts +8 -5
  100. package/src/biz/shared/action-host.ts +12 -5
  101. package/src/biz/shared/compile-helpers.ts +4 -4
  102. package/src/biz/shared/coordinator.ts +104 -21
  103. package/src/biz/shared/overlay-compile.ts +48 -18
  104. package/src/biz/shared/overlay-shell.ts +63 -112
  105. package/src/biz/single-form/compile.ts +2 -2
  106. package/src/biz/single-form/shell.ts +8 -4
  107. package/src/biz/standard-crud/compile.ts +11 -4
  108. package/src/biz/standard-crud/shell.ts +26 -9
  109. package/src/biz/standard-crud/summary.ts +3 -1
  110. package/src/biz/step-form/compile.ts +1 -1
  111. package/src/biz/step-form/hub.ts +4 -0
  112. package/src/biz/step-form/shell.ts +6 -4
  113. package/src/biz/types.ts +11 -4
  114. package/src/cli/app-layer-check.ts +375 -0
  115. package/src/cli/kit-cli.ts +35 -8
  116. package/src/cli/kit-init.ts +149 -0
  117. package/src/compile/access-gate-attach.ts +1 -1
  118. package/src/compile/action-host-attach.ts +1 -1
  119. package/src/compile/compile-page.ts +29 -234
  120. package/src/compile/component-candidates.ts +2 -1
  121. package/src/compile/hints.ts +5 -58
  122. package/src/compile/index.ts +2 -2
  123. package/src/compile/layout-lint/index.ts +4 -1
  124. package/src/compile/layout-lint/rules-composition.ts +43 -13
  125. package/src/compile/page-composition.ts +33 -31
  126. package/src/compile/redirect.ts +1 -1
  127. package/src/compile/stages.ts +169 -0
  128. package/src/compile/styles.ts +70 -32
  129. package/src/compile/types.ts +2 -2
  130. package/src/data/amount-breakdown.ts +4 -2
  131. package/src/data/anchor-nav.ts +4 -1
  132. package/src/data/approval-flow.ts +9 -4
  133. package/src/data/assignment-picker.ts +28 -18
  134. package/src/data/async-result-panel.ts +6 -2
  135. package/src/data/breadcrumbs.ts +13 -9
  136. package/src/data/calendar.ts +4 -3
  137. package/src/data/carousel.ts +11 -5
  138. package/src/data/chart.ts +153 -23
  139. package/src/data/checklist.ts +5 -4
  140. package/src/data/code-view.ts +220 -26
  141. package/src/data/comment-thread.ts +7 -2
  142. package/src/data/confirm-dialog.ts +56 -13
  143. package/src/data/diff.ts +4 -1
  144. package/src/data/dock.ts +5 -1
  145. package/src/data/embed.ts +1 -1
  146. package/src/data/engine-ports.ts +126 -0
  147. package/src/data/field-mapper.ts +12 -6
  148. package/src/data/flow-editor.ts +105 -29
  149. package/src/data/footer.ts +6 -2
  150. package/src/data/gantt.ts +11 -8
  151. package/src/data/hero.ts +6 -2
  152. package/src/data/image-viewer.ts +7 -3
  153. package/src/data/index.ts +12 -5
  154. package/src/data/item-list.ts +6 -5
  155. package/src/data/json-view.ts +844 -0
  156. package/src/data/kanban.ts +11 -8
  157. package/src/data/markdown-view.ts +487 -0
  158. package/src/data/matrix.ts +23 -14
  159. package/src/data/media-grid.ts +5 -2
  160. package/src/data/mega-menu.ts +4 -3
  161. package/src/data/menu-dom.ts +9 -8
  162. package/src/data/menu.ts +15 -9
  163. package/src/data/mockup.ts +9 -5
  164. package/src/data/modal-dialog.ts +39 -88
  165. package/src/data/navbar.ts +11 -7
  166. package/src/data/notice-list.ts +1 -1
  167. package/src/data/notify-renderer.ts +21 -10
  168. package/src/data/object-form.ts +129 -48
  169. package/src/data/pager.ts +12 -8
  170. package/src/data/panel-head.ts +1 -1
  171. package/src/data/permission-matrix.ts +15 -8
  172. package/src/data/permission-tree.ts +24 -11
  173. package/src/data/pricing-table.ts +8 -3
  174. package/src/data/reaction-bar.ts +6 -3
  175. package/src/data/record-card.ts +13 -9
  176. package/src/data/record-picker.ts +8 -4
  177. package/src/data/redirect.ts +1 -1
  178. package/src/data/request-console.ts +20 -7
  179. package/src/data/resident.ts +0 -12
  180. package/src/data/result-panel.ts +2 -2
  181. package/src/data/rich-text.ts +58 -96
  182. package/src/data/row-editor.ts +10 -5
  183. package/src/data/rule-builder.ts +14 -8
  184. package/src/data/shape-util.ts +14 -3
  185. package/src/data/stat-group.ts +63 -22
  186. package/src/data/static-lazy.ts +3 -0
  187. package/src/data/static-registry.ts +8 -2
  188. package/src/data/steps.ts +6 -2
  189. package/src/data/survey.ts +9 -3
  190. package/src/data/system-switcher.ts +15 -6
  191. package/src/data/text-diff.ts +663 -0
  192. package/src/data/timeline.ts +1 -1
  193. package/src/data/tour-guide.ts +6 -3
  194. package/src/data/transfer.ts +19 -10
  195. package/src/data/tree-table.ts +77 -12
  196. package/src/data/tree.ts +5 -2
  197. package/src/data/virtual-rows.ts +17 -7
  198. package/src/data/wrap.ts +2 -2
  199. package/src/frames/index.ts +3 -2
  200. package/src/frames/inherited-shell.ts +178 -0
  201. package/src/frames/list-summary.ts +59 -36
  202. package/src/frames/page-bar.ts +4 -2
  203. package/src/frames/resident-components.ts +20 -0
  204. package/src/frames/shared.ts +18 -14
  205. package/src/frames/split-frame/shell.ts +17 -11
  206. package/src/frames/split-frame/wiring.ts +2 -2
  207. package/src/frames/tabs-frame/shell.ts +12 -6
  208. package/src/frames/types.ts +3 -2
  209. package/src/frames/workspace-frame/extras.ts +19 -5
  210. package/src/frames/workspace-frame/shell.ts +2 -1
  211. package/src/frames/workspace-frame/state.ts +8 -2
  212. package/src/frames/workspace-frame/view.ts +125 -76
  213. package/src/generated/kit-grammar-runtime.ts +61 -39
  214. package/src/i18n/kit-text.ts +114 -2
  215. package/src/i18n/resolve-text-refs.ts +1 -1
  216. package/src/object-renderer/action-group.ts +31 -1
  217. package/src/object-renderer/action-more.ts +28 -12
  218. package/src/object-renderer/arrange.ts +37 -7
  219. package/src/object-renderer/collection-parts.ts +38 -7
  220. package/src/object-renderer/collection-table.ts +68 -23
  221. package/src/object-renderer/collection.ts +63 -30
  222. package/src/object-renderer/compile-data.ts +1 -1
  223. package/src/object-renderer/defaults.ts +8 -0
  224. package/src/object-renderer/emit-events.ts +1 -1
  225. package/src/object-renderer/emit-object.ts +3 -0
  226. package/src/object-renderer/emit-static.ts +140 -37
  227. package/src/object-renderer/field-value.ts +12 -239
  228. package/src/object-renderer/filter-toolbar.ts +103 -0
  229. package/src/{compile → object-renderer}/fragment.ts +2 -2
  230. package/src/object-renderer/index.ts +1 -1
  231. package/src/object-renderer/layout-facts.ts +37 -5
  232. package/src/object-renderer/overlay-decide.ts +82 -0
  233. package/src/object-renderer/render-object.ts +1 -1
  234. package/src/object-renderer/table-actions.ts +70 -23
  235. package/src/object-renderer/table-tools.ts +12 -5
  236. package/src/object-renderer/types.ts +9 -15
  237. package/src/recipes/app-blocks.ts +66 -0
  238. package/src/recipes/code-view.ts +56 -0
  239. package/src/recipes/compact-group.ts +31 -0
  240. package/src/recipes/container.ts +25 -15
  241. package/src/recipes/control.ts +21 -3
  242. package/src/recipes/desc-list.ts +14 -0
  243. package/src/recipes/divider.ts +53 -0
  244. package/src/recipes/emphasis.ts +12 -8
  245. package/src/recipes/frame-bleed.ts +3 -3
  246. package/src/recipes/index.ts +11 -1
  247. package/src/recipes/inherited-shell.ts +37 -0
  248. package/src/recipes/json-view.ts +49 -0
  249. package/src/recipes/markdown.ts +86 -0
  250. package/src/recipes/overlay.ts +112 -26
  251. package/src/recipes/page-width.ts +20 -0
  252. package/src/recipes/placeholder.ts +1 -1
  253. package/src/recipes/stat-state.ts +1 -1
  254. package/src/recipes/state.ts +10 -8
  255. package/src/recipes/status.ts +13 -12
  256. package/src/recipes/strip.ts +72 -0
  257. package/src/recipes/surface.ts +10 -6
  258. package/src/recipes/table-gap.ts +1 -1
  259. package/src/recipes/table-native-edit.ts +4 -4
  260. package/src/recipes/table-row.ts +11 -8
  261. package/src/recipes/tabs.ts +108 -31
  262. package/src/recipes/text-diff.ts +90 -0
  263. package/src/recipes/title-row.ts +4 -2
  264. package/src/recipes/typography.ts +2 -2
  265. package/src/shared/diagnostics.ts +16 -0
  266. package/src/shared/envelope.ts +1 -1
  267. package/src/shared/field-value-format.ts +246 -0
  268. package/src/shared/focus-ring.ts +8 -0
  269. package/src/shared/hints.ts +56 -0
  270. package/src/{base → shared}/icons.ts +12 -0
  271. package/src/shared/kit-error.ts +1 -1
  272. package/src/{object-renderer → shared}/merge-class.ts +3 -2
  273. package/src/shared/path-guard.ts +1 -1
  274. package/src/shared/primitives-types.ts +8 -0
  275. package/src/shared/theme-runtime-shared.ts +19 -0
  276. package/src/theme/kit-theme-text.ts +1 -1
  277. package/src/theme/kit-theme.css +38 -14
  278. package/src/theme/kit-theme.tpl +38 -14
  279. package/src/theme/nine-dim-structure.ts +66 -41
  280. package/src/theme/surface-layers.ts +11 -3
  281. package/src/theme/theme-tokens.ts +5 -1
  282. package/src/app/envelope.ts +0 -1
  283. package/src/app/notify-renderer.ts +0 -1
  284. package/src/app/paged-list-adapter.ts +0 -1
  285. package/src/app/theme-runtime-shared.ts +0 -1
  286. package/src/compile/kit-error.ts +0 -1
  287. /package/src/{base → shared}/class-candidates.ts +0 -0
@@ -26,12 +26,15 @@ import type { SomaComponentDefinition } from 'soma-core';
26
26
  import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
27
27
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
28
28
  import { bool, createKitController, joinClass, num, str } from '../base/shared';
29
- import { kitIcon } from '../base/icons';
29
+ import { kitIcon } from '../shared/icons';
30
30
  import { markCheckBox } from '../base/check-core';
31
31
  import { kitText, type KitTextKey } from '../i18n/kit-text';
32
32
  import { kitControlRecipe, setKitFace } from '../recipes';
33
+ import { kitControlEdgeRecipe } from '../recipes/control';
34
+ import { kitDivideRecipe, kitDividerRecipe } from '../recipes/divider';
35
+ import { kitShellRecipe } from '../recipes/container';
33
36
  import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
34
- import { mergeClass } from '../object-renderer/merge-class';
37
+ import { mergeClass } from '../shared/merge-class';
35
38
  import {
36
39
  KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
37
40
  } from '../recipes/overlay';
@@ -44,34 +47,41 @@ import { kitTypographyRecipe } from '../recipes/typography';
44
47
 
45
48
  // ── 类串表:全部完整写死,不拼接片段 ──
46
49
 
47
- const ROOT_CLASS = `@container flex h-full flex-col gap-4 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
50
+ const ROOT_CLASS = `@container flex h-full flex-col gap-3 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
48
51
  const HELP_CLASS = 'text-sm text-fg-muted';
49
52
  const SUBJECT_CLASS = 'flex flex-wrap items-center gap-4';
50
53
  const SUBJECT_ITEM_CLASS = 'flex items-center gap-2';
51
54
  const CAPTION_CLASS = 'text-sm text-fg-muted';
52
55
  const STRONG_CLASS = 'text-sm font-semibold text-fg';
53
56
  const ALERT_CLASS = 'rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
54
- const GRID_CLASS = 'grid grid-cols-12 gap-4';
57
+ const GRID_CLASS = 'grid grid-cols-12 gap-3';
55
58
  const MAIN_FULL_CLASS = 'col-span-12';
56
- const MAIN_INNER_CLASS = 'flex flex-col gap-3';
57
- const SIDE_INNER_CLASS = 'flex flex-col gap-2';
59
+ // 间距只取 4 的倍数阶梯(尺寸规格 §1;接入核对 C2:10 / 6px 收回 8 / 12)
60
+ const MAIN_INNER_CLASS = 'flex flex-col gap-2';
61
+ const SIDE_TOP_LINE = kitDividerRecipe('top');
62
+ const ROWS_DIVIDE = kitDivideRecipe('y');
63
+ const BOX_EDGE = kitControlEdgeRecipe({ wrapper: true });
64
+ const SIDE_INNER_CLASS = `flex flex-col gap-2 ${SIDE_TOP_LINE} pt-3`;
58
65
  const HEAD_CLASS = 'flex items-center justify-between gap-3';
59
66
  const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
60
67
  const SUMMARY_CLASS = 'text-sm text-fg-muted';
61
68
  const CHANGES_CLASS = 'text-sm text-fg-muted';
62
69
  const TOOLS_CLASS = 'flex flex-wrap items-center gap-2';
63
- const SEARCH_CLASS = 'block h-9 min-w-40 flex-1 appearance-none autofill-clear rounded-md border border-border bg-surface px-3 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
64
- const TOOL_BTN_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'h-9');
65
- const LIST_CLASS = 'flex flex-col overflow-hidden rounded-md border border-border-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
66
- const GROUP_CLASS = 'flex flex-col';
67
- const GROUP_HEAD_CLASS = 'flex items-center justify-between gap-2 rounded-md bg-surface-sunken px-3 py-1.5 text-xs font-medium text-fg-muted';
70
+ // 搜索框 = 标准输入(控件配方,KT-B1 / §4 C6),工具钮与它同高(控件档)
71
+ const SEARCH_CLASS = mergeClass(kitControlRecipe(), 'min-w-40 flex-1');
72
+ const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
73
+ // 列表框外缘 = 壳配方(容器边,KT-B2);条目之间的线由父出(kitDivideRecipe,KT-B5);
74
+ // 分组:灰底组头与条目之间、组与组之间已有面差,不再画线(D-30)
75
+ const LIST_CLASS = mergeClass('flex max-h-36 flex-col overflow-y-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', `${kitShellRecipe({ tone: 'base', shadow: false })} ${kitDivideRecipe('y')}`);
76
+ const GROUP_CLASS = `flex flex-col border-b-0 ${ROWS_DIVIDE}`;
77
+ const GROUP_HEAD_CLASS = 'flex items-center justify-between gap-2 rounded-md bg-surface-sunken px-3 py-1.5 text-xs font-medium text-fg-muted border-b-0';
68
78
  const GROUP_BTN_CLASS = kitEmphasisButtonRecipe('button.quiet', { size: 'sm' });
69
- const ITEM_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-surface px-3 py-2 text-fg transition-colors last:border-b-0 state-layer';
70
- const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3 border-b border-border-divider bg-surface px-3 py-2 text-fg-subtle last:border-b-0';
71
- const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-success-soft px-3 py-2 text-success-on-soft transition-colors last:border-b-0';
72
- const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-danger-soft px-3 py-2 text-danger-on-soft transition-colors last:border-b-0';
79
+ const ITEM_CLASS = 'flex cursor-pointer items-center gap-3 bg-surface px-3 py-2 text-fg transition-colors state-layer';
80
+ const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3 bg-surface px-3 py-2 text-fg-subtle';
81
+ const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3 bg-success-soft px-3 py-2 text-success-on-soft transition-colors';
82
+ const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3 bg-danger-soft px-3 py-2 text-danger-on-soft transition-colors';
73
83
  const CURSOR_CLASS = 'ring-2 ring-inset ring-ring';
74
- const BOX_OFF_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-border bg-surface text-xs';
84
+ const BOX_OFF_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-md ${BOX_EDGE} bg-surface text-xs`;
75
85
  const BOX_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-fg';
76
86
  const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
77
87
  const LABEL_CLASS = 'truncate text-sm';
@@ -83,7 +93,7 @@ const CHIP_REMOVED_CLASS = 'bg-danger-soft text-danger-on-soft';
83
93
  const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
84
94
  const FIELD_LABEL_CLASS = 'flex items-center gap-1 text-sm text-fg';
85
95
  const STAR_CLASS = 'text-danger-on-soft';
86
- const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md border border-border bg-surface px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
96
+ const AREA_CLASS = mergeClass(kitControlRecipe({ multiline: true }), 'resize-none');
87
97
  const FIELD_ERROR_CLASS = 'text-xs text-danger-on-soft';
88
98
  // mt-auto:根随容器拉高时按钮区贴在面板底部,不悬在中间
89
99
  const FOOT_CLASS = 'mt-auto flex items-center justify-end gap-2 pt-1';
@@ -600,7 +610,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
600
610
  fieldLabel = mk('label', FIELD_LABEL_CLASS);
601
611
  area = mk('textarea', AREA_CLASS);
602
612
  setKitFace(area, 'field');
603
- area.rows = 4;
613
+ area.rows = 2;
604
614
  const areaId = `${uid}-reason`;
605
615
  area.id = areaId;
606
616
  fieldLabel.htmlFor = areaId;
@@ -23,6 +23,10 @@ import { watchKitOutcome, type KitOutcome } from './outcome-watch';
23
23
  import { KIT_MS_ASIDE_IDLE_ATTR, KIT_MS_ROOT_ATTR } from '../recipes/container';
24
24
  import { kitText } from '../i18n/kit-text';
25
25
  import { setKitFace } from '../recipes';
26
+ import { kitControlEdgeRecipe } from '../recipes/control';
27
+
28
+ /** 多行输入的边 = 控件轮廓出口(KT-B1 / §4 C6) */
29
+ const AREA_EDGE = kitControlEdgeRecipe();
26
30
  import { KIT_BUSY_PROP_DEFS, cancelKitAction, kitBusyOf } from '../base/action-busy';
27
31
  import {
28
32
  actionButton, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
@@ -35,7 +39,7 @@ const TITLE_CLASS = 'text-sm font-semibold text-fg';
35
39
  const SUBTITLE_CLASS = 'text-xs text-fg-subtle';
36
40
  const LABEL_WRAP = 'flex flex-col gap-1';
37
41
  const LABEL_CLASS = 'text-xs font-medium text-fg-muted';
38
- const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md border border-border bg-surface px-3 py-2 text-sm text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
42
+ const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md ' + AREA_EDGE + ' bg-surface px-3 py-2 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
39
43
  const BUTTONS_CLASS = 'flex flex-wrap items-center gap-2';
40
44
  const MESSAGE_CLASS = 'text-xs text-fg-subtle';
41
45
  const MESSAGE_FAILED = 'text-xs text-danger-on-soft';
@@ -198,7 +202,7 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
198
202
  },
199
203
  },
200
204
  services: ['data'],
201
- templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
205
+ templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
202
206
  controllerFactory: createKitController(() => ({
203
207
  busyAware: true,
204
208
  attach(root, api) {
@@ -11,16 +11,20 @@ import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
11
11
  import { createKitController, joinClass, num, str } from '../base/shared';
12
12
  import { safeHref } from '../base/link';
13
13
  import { kitText } from '../i18n/kit-text';
14
- import { kitIcon, kitIconHtml } from '../base/icons';
14
+ import { kitIcon, kitIconHtml } from '../shared/icons';
15
15
  import { classSet, FOCUS, h, isRec, recList, textOf, type Child, type Rec } from './menu-dom';
16
16
 
17
17
  const ROOT_CLASS = 'flex min-w-0 items-center text-sm text-fg-muted';
18
18
  const ROOT_SCROLL_CLASS = 'flex min-w-0 items-center overflow-x-auto text-sm text-fg-muted';
19
- const LIST_CLASS = 'flex min-w-0 flex-wrap items-center gap-1';
19
+ // 溢出策略 = 单行、不折行(面包屑在 40 高的条带里,折行会被条带裁掉上下,@320 外壳顶栏);放不下时上级先收缩成「…」、当前项保整(AR45):
20
+ // 上级项最窄收到一个省略号宽(min-w-5 + truncate,项本身不设 min-w-0,最小宽 = 分隔符 + 省略号),当前项不收缩(shrink-0,只在独占整行仍放不下时才省略)
21
+ const LIST_CLASS = 'flex min-w-0 flex-nowrap items-center gap-1';
20
22
  const LIST_SCROLL_CLASS = 'flex flex-nowrap items-center gap-1 whitespace-nowrap';
21
- const ITEM_CLASS = 'flex min-w-0 items-center gap-1';
23
+ const ITEM_CLASS = 'flex items-center gap-1';
24
+ const CURRENT_ITEM_CLASS = 'flex min-w-0 max-w-full shrink-0 items-center gap-1';
22
25
  // border-0 bg-transparent p-0:按钮型面包屑项没有 preflight 时带浏览器默认 6px 横向内边距,会让分隔符两侧间距不等、首项比当前项缩进多 6px
23
- const LINK_CLASS = `min-w-0 cursor-pointer truncate rounded-sm border-0 bg-transparent p-0 text-start text-fg-muted transition-colors hover:text-fg hover:underline ${FOCUS}`;
26
+ const LINK_CLASS = `min-w-5 cursor-pointer truncate rounded-sm border-0 bg-transparent px-0 py-1 -my-1 text-start text-fg-muted transition-colors hover:text-fg hover:underline ${FOCUS}`;
27
+ const ANCESTOR_TEXT_CLASS = 'min-w-5 truncate';
24
28
  const CURRENT_CLASS = 'min-w-0 truncate font-medium text-fg';
25
29
  const SEP_CLASS = 'shrink-0 text-fg-subtle';
26
30
  const ELLIPSIS_CLASS = `inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-sm px-1 text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ${FOCUS}`;
@@ -28,7 +32,7 @@ const ELLIPSIS_STATIC_CLASS = 'shrink-0 px-1 text-fg-muted';
28
32
 
29
33
  /** 本组件自带的全部类(供编译器并入候选类,页面框静态页头同用) */
30
34
  export const KIT_BREADCRUMBS_CLASS_CANDIDATES: readonly string[] = classSet(
31
- ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, LINK_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
35
+ ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, CURRENT_ITEM_CLASS, LINK_CLASS, ANCESTOR_TEXT_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
32
36
  );
33
37
 
34
38
  export const KIT_BREADCRUMBS_DEFAULT_MAX: number = KIT_STATIC_COMPONENT_LIMITS.navigation.breadcrumbs.defaultMaxItems;
@@ -92,11 +96,11 @@ export function breadcrumbsHtml(items: readonly { label: string; href?: string }
92
96
  return `<li class="${ITEM_CLASS}">${lead}<span title="${esc(title)}" class="${ELLIPSIS_STATIC_CLASS}">…</span></li>`;
93
97
  }
94
98
  const { crumb, current } = p;
95
- if (current) return `<li class="${ITEM_CLASS}">${lead}<span aria-current="page" class="${CURRENT_CLASS}">${esc(crumb.label)}</span></li>`;
99
+ if (current) return `<li class="${CURRENT_ITEM_CLASS}">${lead}<span aria-current="page" class="${CURRENT_CLASS}">${esc(crumb.label)}</span></li>`;
96
100
  const href = crumb.href !== '' ? safeHref(crumb.href) : '';
97
101
  const inner = href !== ''
98
102
  ? `<a href="${esc(href)}" class="${LINK_CLASS}">${esc(crumb.label)}</a>`
99
- : `<span class="min-w-0 truncate">${esc(crumb.label)}</span>`;
103
+ : `<span class="${ANCESTOR_TEXT_CLASS}">${esc(crumb.label)}</span>`;
100
104
  return `<li class="${ITEM_CLASS}">${lead}${inner}</li>`;
101
105
  });
102
106
  const id = opts.anchorId !== undefined ? ` data-soma-id="${esc(opts.anchorId)}"` : '';
@@ -126,7 +130,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
126
130
  root.setAttribute('aria-label', str(props.label, kitText('soma.kit.nav_breadcrumb', undefined, root)));
127
131
  const list = h('ol', scroll ? LIST_SCROLL_CLASS : LIST_CLASS);
128
132
  breadcrumbParts(crumbs, max, expanded).forEach((p, i) => {
129
- const li = h('li', ITEM_CLASS);
133
+ const li = h('li', p.kind !== 'ellipsis' && p.current ? CURRENT_ITEM_CLASS : ITEM_CLASS);
130
134
  if (i > 0) li.append(h('span', SEP_CLASS, { 'aria-hidden': 'true' }, str(props.marker) === 'chevron' ? kitIcon('chevron-right', 'xs', 'rtl:-scale-x-100') : sep));
131
135
  if (p.kind === 'ellipsis') {
132
136
  const title = p.hidden.map((c) => c.label).join(' / ');
@@ -142,7 +146,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
142
146
  const href = crumb.href !== '' ? safeHref(crumb.href) : '';
143
147
  if (isRec(crumb.raw) && crumb.raw.inert === true) {
144
148
  // inert:只是层级文字(如菜单分组名),不可点
145
- li.append(h('span', 'min-w-0 truncate', {}, ...text));
149
+ li.append(h('span', ANCESTOR_TEXT_CLASS, {}, ...text));
146
150
  } else {
147
151
  const el = href !== ''
148
152
  ? h('a', LINK_CLASS, { href }, ...text)
@@ -17,7 +17,8 @@ import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, type Month
17
17
  import { markKitEdge } from '../recipes/surface-edge';
18
18
  import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
19
19
  import { kitTypographyRecipe } from '../recipes/typography';
20
- import { mergeClass } from '../object-renderer/merge-class';
20
+ import { mergeClass } from '../shared/merge-class';
21
+ import { kitShellRecipe } from '../recipes/container';
21
22
  import {
22
23
  addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
23
24
  } from './d9-util';
@@ -32,7 +33,7 @@ const TITLE_CLASS = mergeClass('min-w-24', kitTypographyRecipe('sectionTitle'));
32
33
  const SPACER_CLASS = 'flex-1';
33
34
  const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
34
35
  const BTN_ON_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-primary bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
35
- const GRID_CLASS = 'flex flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface';
36
+ const GRID_CLASS = mergeClass('flex flex-col overflow-hidden', kitShellRecipe({ tone: 'base', shadow: false }));
36
37
  const ROW_CLASS = 'grid grid-cols-7 border-border-subtle';
37
38
  const ROW_BORDER = 'border-t';
38
39
  const HEADCELL_CLASS = 'px-2 py-1.5 text-center text-xs font-medium text-fg-muted';
@@ -121,7 +122,7 @@ export function createCalendar(): SomaComponentDefinition {
121
122
  },
122
123
  keyboard: { layout: 'grid', date_grid: true, wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
123
124
  },
124
- templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
125
+ templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
125
126
  controllerFactory: createKitController((api) => {
126
127
  const P = (): Record<string, unknown> => api.props();
127
128
  let root: HTMLElement | null = null;
@@ -15,9 +15,11 @@
15
15
  import type { SomaComponentDefinition } from 'soma-core';
16
16
  import { KIT_CAROUSEL_LIMITS, KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
17
17
  import { bool, createKitController, joinClass, str } from '../base/shared';
18
- import { kitIcon } from '../base/icons';
18
+ import { kitIcon } from '../shared/icons';
19
19
  import { kitText } from '../i18n/kit-text';
20
20
  import { setKitFace } from '../recipes';
21
+ import { kitButtonEdgeRecipe } from '../recipes/control';
22
+ import { kitShellRecipe } from '../recipes/container';
21
23
  import { kitKey } from '../i18n/kit-text';
22
24
  import { classTokens, emptyNode, mk, textOf, type Rec } from './shape-util';
23
25
  import { clampInt, keyOfRow, listOf, prefersReducedMotion, urlOf } from './display-util';
@@ -29,7 +31,11 @@ export const KIT_CAROUSEL_EDGES = ['top', 'bottom', 'start', 'end'] as const;
29
31
  export type KitCarouselEdge = (typeof KIT_CAROUSEL_EDGES)[number];
30
32
 
31
33
  const ROOT_CLASS = 'flex flex-col gap-3 text-fg';
32
- const VIEWPORT_CLASS = 'overflow-hidden rounded-lg border border-border-subtle bg-surface';
34
+ // 视窗 / 叠卡 = 壳配方(容器边,KT-B2);切换钮 = 带文字中性按钮描边(KT-B1)
35
+ const VIEWPORT_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
36
+ const NAV_EDGE = kitButtonEdgeRecipe();
37
+ const STACK_EDGE = kitShellRecipe({ tone: 'base' });
38
+ const VIEWPORT_CLASS = `overflow-hidden ${VIEWPORT_EDGE}`;
33
39
  const SLIDE_IMAGE_CLASS = 'flex flex-col';
34
40
  const IMG_CLASS = 'aspect-16/9 w-full object-cover';
35
41
  const CAPTION_CLASS = 'flex flex-col gap-1 px-4 py-3';
@@ -38,7 +44,7 @@ const TITLE_CLASS = 'text-lg font-semibold';
38
44
  const TEXT_CLASS = 'text-sm text-fg-muted';
39
45
  const CARD_TEXT_CLASS = 'text-sm';
40
46
  const BAR_CLASS = 'flex items-center justify-between gap-3';
41
- const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md border border-border bg-surface px-2 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
47
+ const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md ' + NAV_EDGE + ' bg-surface px-2 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
42
48
  // 圆点尺寸与间距取 design 真源 kit-limits#carousel(间距步数,乘 --spacing);排容器 hit-gap-N 写 gap 与 --kit-hit-gap,
43
49
  // 圆点用 hit-area-row(读 hitTarget;沿排热区 = min(命中边长, 中心距),相邻热区相接零重叠,垂直方向仍是完整命中边长),不手写外扩。
44
50
  const DOTS_CLASS = `flex flex-1 items-center justify-center hit-gap-${KIT_CAROUSEL_LIMITS.dotGapStep}`;
@@ -52,7 +58,7 @@ const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
52
58
  start: 'grid ps-6',
53
59
  end: 'grid pe-6',
54
60
  });
55
- const STACK_CARD_BASE = 'col-start-1 row-start-1 flex min-h-32 flex-col gap-2 rounded-lg border border-border-subtle bg-surface p-4 text-start shadow-md motion-safe:transition-transform';
61
+ const STACK_CARD_BASE = `col-start-1 row-start-1 flex min-h-32 flex-col gap-2 ${STACK_EDGE} p-4 text-start motion-safe:transition-transform`;
56
62
  const STACK_TOP = 'z-30 cursor-pointer hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
57
63
  /** 后面两张牌的位置:edge × 深度(1、2) */
58
64
  const STACK_BEHIND: Readonly<Record<KitCarouselEdge, readonly [string, string]>> = Object.freeze({
@@ -274,7 +280,7 @@ export function createCarousel(): SomaComponentDefinition {
274
280
  select: { payload: { index: { type: 'number' }, item: { type: 'object' } }, desc: 'slide 布局下点当前张的内容' },
275
281
  },
276
282
  },
277
- templateHtml: `<section data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
283
+ templateHtml: `<section data-kit-container="card" data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
278
284
  controllerFactory: createKitController(() => ({
279
285
  attach(root, api) {
280
286
  const s = stateOf(root);
package/src/data/chart.ts CHANGED
@@ -23,8 +23,9 @@ import {
23
23
  chartMarkDashPattern, defaultReadoutColumn, formatReadoutValue, parseChartMarks, parseReadout, resolveChartMarks, stepChartColumn,
24
24
  type ChartMark, type ChartMarkSpec, type ReadoutConfig, type ResolvedChartMark, type VizTone,
25
25
  } from 'soma-foundation/kit-viz';
26
- import { classCandidates } from '../base/class-candidates';
27
- import { mergeClass } from '../object-renderer/merge-class';
26
+ import { classCandidates } from '../shared/class-candidates';
27
+ import { mergeClass } from '../shared/merge-class';
28
+ import { kitShellRecipe } from '../recipes/container';
28
29
  import { kitFocusRingRecipe } from '../recipes/state';
29
30
  import { KIT_NOTICE_HEADLINE, KIT_STAT_VALUES_NUM, KIT_STAT_VALUES_ROW } from '../recipes/status';
30
31
  import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
@@ -87,7 +88,8 @@ const ROOT_CLASS = 'relative w-full';
87
88
  /** 图已就绪的根标记:引擎加载完并出过图后才有(截图 / 渲染测量据此判断,不靠固定等待) */
88
89
  export const KIT_CHART_READY_ATTR = 'data-kit-chart-ready';
89
90
  const STAGE_CLASS = 'h-72 w-full';
90
- const EMPTY_INNER_CLASS = 'flex h-72 w-full items-center justify-center rounded-md border border-border-subtle bg-surface-sunken text-sm text-fg-muted';
91
+ // 空态框 = 凹槽面的壳配方(容器边,KT-B2)
92
+ const EMPTY_INNER_CLASS = mergeClass('flex h-72 w-full items-center justify-center text-sm text-fg-muted', kitShellRecipe({ tone: 'sunken', shadow: false }));
91
93
 
92
94
  /**
93
95
  * 逐列读数区的类:排版与表面取 kit 配方(说明条标题 / StatGroup 多值行的字阶与等宽数字),不手写字阶;
@@ -105,7 +107,7 @@ const READOUT_BOTTOM_CLASS = 'mt-2';
105
107
  /** 本组件自带的全部类(供编译器并入候选类) */
106
108
  export const KIT_CHART_CLASS_CANDIDATES: readonly string[] = classCandidates(
107
109
  ['relative', 'absolute', 'inset-0', 'invisible', 'w-full', 'h-72', 'hidden', 'sr-only',
108
- 'flex', 'items-center', 'justify-center', 'rounded-md', 'border', 'border-border-subtle', 'bg-surface-sunken', 'text-sm', 'text-fg-muted'],
110
+ EMPTY_INNER_CLASS],
109
111
  KIT_STATE_PANEL_CLASS_CANDIDATES,
110
112
  READOUT_CLASS, READOUT_TITLE_CLASS, READOUT_ITEM_CLASS, READOUT_VALUE_CLASS, READOUT_NOTE_CLASS, ROOT_FOCUS_CLASS,
111
113
  READOUT_TOP_CLASS, READOUT_BOTTOM_CLASS,
@@ -168,9 +170,36 @@ export function engineSeriesOf(type: KitChartType): string {
168
170
  return type === 'area' ? 'line' : type === 'donut' ? 'pie' : type === 'combo' ? 'bar' : type;
169
171
  }
170
172
 
171
- /** 一张图要装的全部引擎系列类型(combo = bar + line) */
172
- export function engineSeriesListOf(type: KitChartType): string[] {
173
- return type === 'combo' ? ['bar', 'line'] : [engineSeriesOf(type)];
173
+ /** 一张图要装的全部引擎系列类型(combo = bar + line;bar 等直角图含 baseline / ideal / projection / line 系列时补齐 line) */
174
+ export function engineSeriesListOf(type: KitChartType, config?: Pick<KitChartConfig, 'roles' | 'line'>): string[] {
175
+ const out = type === 'combo' ? ['bar', 'line'] : [engineSeriesOf(type)];
176
+ const needsLine = (config?.line?.length ?? 0) > 0
177
+ || Object.values(config?.roles ?? {}).some((r) => r === 'ideal' || r === 'baseline' || r === 'projection');
178
+ if (needsLine && !out.includes('line')) out.push('line');
179
+ return out;
180
+ }
181
+
182
+ /** 扫描实际产出的 option.series,补齐全部引擎系列类型(防止 bar + baseline/line 等运行时报未导入系列) */
183
+ function renderedSeriesTypesOf(config: KitChartConfig, option: Record<string, unknown>): string[] {
184
+ const types = new Set(engineSeriesListOf(config.type, config));
185
+ if (Array.isArray(option.series)) {
186
+ for (const s of option.series) {
187
+ if (s !== null && typeof s === 'object' && typeof (s as { type?: unknown }).type === 'string') {
188
+ types.add((s as { type: string }).type);
189
+ }
190
+ }
191
+ }
192
+ return [...types];
193
+ }
194
+
195
+ /** 角色后缀去重:字段名已含同义角色词(如「预测」「理想」)时不拼成「预测(预测)」「理想(理想)」 */
196
+ function appendRoleSuffix(name: string, suffix: string): string {
197
+ if (suffix === '') return name;
198
+ const trimmed = name.trim();
199
+ if (trimmed === '') return name;
200
+ const core = suffix.replace(/^[\s((]+|[\s))]+$/g, '').trim().toLowerCase();
201
+ if (core !== '' && trimmed.toLowerCase().includes(core)) return name;
202
+ return `${name}${suffix}`;
174
203
  }
175
204
 
176
205
  /** 数据要求:除 x / y 外还必须给的字段,以及 y 最少几个字段(纯函数,chartConfigOf 用) */
@@ -459,29 +488,118 @@ export function buildChartOption(
459
488
  const style = MARK_SPEC.roles[role]!;
460
489
  return { color: toneColor(style.tone), dash: chartMarkDashPattern(style.dash), symbol: style.symbol };
461
490
  };
491
+ const hasY2 = config.type === 'combo' && (config.y2?.length ?? 0) > 0;
492
+ /** 估算参考线标签像素宽(中文约 12px、ASCII 约 7px),避免在无布局环境下被 SVG 右边界裁切 */
493
+ const estimateLabelPx = (text: string): number => {
494
+ let px = 0;
495
+ for (const ch of text) px += ch.charCodeAt(0) > 127 ? 12 : 7;
496
+ return px;
497
+ };
498
+ /** 估算参考线的数值坐标(用于判定右侧相邻标签是否过近并错开 y 偏移) */
499
+ const primaryValues = (): number[] => {
500
+ const firstY = config.y[0];
501
+ if (firstY === undefined) return [];
502
+ const k = src(firstY);
503
+ return rows.map((r) => num(r[k])).filter((v): v is number => v !== null);
504
+ };
505
+ const statValueOf = (stat: KitChartRefLine['stat'], vals: readonly number[]): number | null => {
506
+ if (vals.length === 0 || stat === undefined) return null;
507
+ if (stat === 'max') return Math.max(...vals);
508
+ if (stat === 'min') return Math.min(...vals);
509
+ if (stat === 'average') return vals.reduce((a, b) => a + b, 0) / vals.length;
510
+ const sorted = [...vals].sort((a, b) => a - b);
511
+ const mid = Math.floor(sorted.length / 2);
512
+ return sorted.length % 2 === 1 ? sorted[mid]! : (sorted[mid - 1]! + sorted[mid]!) / 2;
513
+ };
462
514
  /** 参考线与标记竖线 / 横线合并成引擎 markLine,只挂在第一条系列上(虚线 / 实线由角色定,不带 tooltip) */
463
515
  const markLineOf = (): Record<string, unknown> => {
464
516
  const refs = config.refLines ?? [];
465
517
  const lines = resolvedMarks.filter((m) => m.kind === 'line');
466
518
  if (refs.length === 0 && lines.length === 0) return {};
519
+ const vals = primaryValues();
520
+ const yLines: Array<{ key: string; yVal: number | null; label: string }> = [];
521
+ refs.forEach((r, idx) => {
522
+ if (r.label !== '') yLines.push({ key: `r:${idx}`, yVal: r.value !== undefined ? r.value : statValueOf(r.stat, vals), label: r.label });
523
+ });
524
+ lines.forEach((m, idx) => {
525
+ if (m.axis === 'y' && m.label !== '') yLines.push({ key: `m:${idx}`, yVal: typeof m.at === 'number' ? m.at : null, label: m.label });
526
+ });
527
+ const numericVals = [...vals, ...yLines.map((x) => x.yVal).filter((v): v is number => v !== null)];
528
+ // 直角坐标值轴默认含 0,估算可见纵轴跨度时把 0 纳入上下界,避免相邻参考线被误判为相距甚远
529
+ const ySpan = numericVals.length > 0 ? Math.max(0, ...numericVals) - Math.min(0, ...numericVals) : 0;
530
+ const closeGap = ySpan > 0 ? ySpan * 0.14 : 0;
531
+ const dyByKey = new Map<string, number>();
532
+ const posByKey = new Map<string, 'end' | 'insideEndTop' | 'insideEndBottom'>();
533
+ if (yLines.length > 0) {
534
+ const sorted = [...yLines].sort((a, b) => (b.yVal ?? 0) - (a.yVal ?? 0));
535
+ const clusters: Array<typeof sorted> = [];
536
+ for (const item of sorted) {
537
+ const lastCluster = clusters[clusters.length - 1];
538
+ const prev = lastCluster?.[lastCluster.length - 1];
539
+ const isClose = prev !== undefined && (
540
+ item.yVal === null || prev.yVal === null || Math.abs(prev.yVal - item.yVal) <= closeGap
541
+ );
542
+ if (lastCluster && isClose) lastCluster.push(item);
543
+ else clusters.push([item]);
544
+ }
545
+ for (const cluster of clusters) {
546
+ if (cluster.length === 1) {
547
+ posByKey.set(cluster[0]!.key, hasY2 ? 'insideEndTop' : 'end');
548
+ dyByKey.set(cluster[0]!.key, 0);
549
+ } else {
550
+ const mid = (cluster.length - 1) / 2;
551
+ cluster.forEach((item, i) => {
552
+ if (hasY2) {
553
+ posByKey.set(item.key, i <= mid ? 'insideEndTop' : 'insideEndBottom');
554
+ dyByKey.set(item.key, Math.round((i - mid) * 14));
555
+ } else {
556
+ posByKey.set(item.key, 'end');
557
+ dyByKey.set(item.key, Math.round((i - mid) * 16));
558
+ }
559
+ });
560
+ }
561
+ }
562
+ }
467
563
  return {
468
564
  markLine: {
469
565
  silent: true,
470
566
  symbol: 'none',
471
567
  data: [
472
- ...refs.map((r) => ({
473
- ...(r.value !== undefined ? { yAxis: r.value } : { type: r.stat }),
474
- name: r.label,
475
- lineStyle: { type: 'dashed', color: toneColor(r.tone) },
476
- label: { show: r.label !== '', formatter: r.label, color: toneColor(r.tone) },
477
- })),
478
- ...lines.map((m) => {
568
+ ...refs.map((r, idx) => {
569
+ const key = `r:${idx}`;
570
+ const dy = dyByKey.get(key) ?? 0;
571
+ const position = posByKey.get(key) ?? (hasY2 ? 'insideEndTop' : 'end');
572
+ return {
573
+ ...(r.value !== undefined ? { yAxis: r.value } : { type: r.stat }),
574
+ name: r.label,
575
+ lineStyle: { type: 'dashed', color: toneColor(r.tone) },
576
+ label: {
577
+ show: r.label !== '',
578
+ formatter: r.label,
579
+ color: toneColor(r.tone),
580
+ position,
581
+ ...(dy !== 0 ? { offset: [0, dy] } : {}),
582
+ },
583
+ };
584
+ }),
585
+ ...lines.map((m, idx) => {
479
586
  const s = roleOf(m.role);
587
+ const key = `m:${idx}`;
588
+ const isY = m.axis === 'y';
589
+ const dy = isY ? (dyByKey.get(key) ?? 0) : 0;
590
+ const position = isY ? (posByKey.get(key) ?? (hasY2 ? 'insideEndTop' : 'end')) : 'end';
480
591
  return {
481
592
  ...(m.axis === 'x' ? { xAxis: m.at } : { yAxis: m.at }),
482
593
  name: m.label,
483
594
  lineStyle: { type: s.dash === null ? 'solid' : [...s.dash], color: s.color, width: CHART_NUM.marks.lineWidth },
484
- label: { show: m.label !== '', formatter: m.label, color: s.color, position: 'end', rotate: 0 },
595
+ label: {
596
+ show: m.label !== '',
597
+ formatter: m.label,
598
+ color: s.color,
599
+ position,
600
+ rotate: 0,
601
+ ...(dy !== 0 ? { offset: [0, dy] } : {}),
602
+ },
485
603
  };
486
604
  }),
487
605
  ],
@@ -532,9 +650,18 @@ export function buildChartOption(
532
650
  },
533
651
  };
534
652
  };
535
- /** 直角坐标系的 grid:底部图例留 32,顶部图例把上沿让到 40 */
653
+ /** 直角坐标系的 grid:底部图例留 32,顶部图例把上沿让到 40;有右侧参考线外置标签时按标签宽留出右边距避免裁切 */
654
+ const rightMarkLabels = hasY2
655
+ ? []
656
+ : [
657
+ ...(config.refLines ?? []).map((r) => r.label).filter((s) => s !== ''),
658
+ ...resolvedMarks.filter((m) => m.kind === 'line' && m.axis === 'y' && m.label !== '').map((m) => m.label),
659
+ ];
660
+ const rightLabelPad = rightMarkLabels.length > 0
661
+ ? Math.min(136, Math.max(48, Math.max(...rightMarkLabels.map(estimateLabelPx)) + 20))
662
+ : 8;
536
663
  const gridFor = (multi: boolean): Record<string, unknown> => ({
537
- left: 8, right: 8, containLabel: true,
664
+ left: 8, right: rightLabelPad, containLabel: true,
538
665
  top: legendShown(multi) && config.legend === 'top' ? 40 : 24,
539
666
  bottom: legendShown(multi) && config.legend !== 'top' ? 32 : 8,
540
667
  });
@@ -729,7 +856,7 @@ export function buildChartOption(
729
856
  const plainYs = [...basicYs.filter((y) => toneOfRole(y) === null), ...basicYs.filter((y) => toneOfRole(y) !== null)];
730
857
  const idealYs = config.y.filter(isIdeal);
731
858
  const projectionYs = config.y.filter(isProjection);
732
- const projectionName = (y: string): string => `${y}${theme.projectionSuffix ?? ''}`;
859
+ const projectionName = (y: string): string => appendRoleSuffix(y, theme.projectionSuffix ?? '');
733
860
  /** 空值(null / undefined / 非数)保持 null:引擎据此断线留白,不补零不插值 */
734
861
  const cell = (r: Record<string, unknown>, key: string): number | null => num(r[key]);
735
862
  const idealSeries = idealYs.map((y) => {
@@ -885,12 +1012,14 @@ export function chartAltOf(
885
1012
  }
886
1013
  }
887
1014
  const withNotes = noteByRow.size > 0;
1015
+ const idealSuffix = kitText('soma.kit.chart_ideal', { name: '' }, at);
1016
+ const projSuffix = kitText('soma.kit.chart_projection', { name: '' }, at);
888
1017
  return {
889
1018
  label,
890
- // 理想线 / 预测线的表头标注;空值(null / 缺值)单元格为空串
1019
+ // 理想线 / 预测线的表头标注;空值(null / 缺值)单元格为空串(字段名已含角色词时不拼成「预测(预测)」)
891
1020
  columns: [
892
- ...fields.map((f) => (config.roles?.[f] === 'ideal' ? kitText('soma.kit.chart_ideal', { name: f }, at)
893
- : config.roles?.[f] === 'projection' ? kitText('soma.kit.chart_projection', { name: f }, at) : f)),
1021
+ ...fields.map((f) => (config.roles?.[f] === 'ideal' ? appendRoleSuffix(f, idealSuffix)
1022
+ : config.roles?.[f] === 'projection' ? appendRoleSuffix(f, projSuffix) : f)),
894
1023
  ...(withNotes ? [kitText('soma.kit.chart_marks_col', undefined, at)] : []),
895
1024
  ],
896
1025
  rows: shown.slice(0, cap).map((r, i) => [...fields.map((f) => cell(r[src(f)])), ...(withNotes ? [(noteByRow.get(i) ?? []).join('、')] : [])]),
@@ -1336,11 +1465,12 @@ export function createChart(): SomaComponentDefinition {
1336
1465
  drawn = { config, rows, theme, map: p.map, reduceMotion };
1337
1466
  syncInteractive(config, rows, str(p.aria_label) !== '' ? str(p.aria_label) : alt.label);
1338
1467
  const marked = chartMarkComponentsOf(config);
1468
+ const requiredSeries = renderedSeriesTypesOf(config, option);
1339
1469
  if (instance === null) {
1340
1470
  if (creating === null) {
1341
1471
  creating = (async () => {
1342
1472
  try {
1343
- await port.ensure(engineSeriesListOf(config.type), engineComponentsOf(config.type, marked.markLine, marked.extra));
1473
+ await port.ensure(requiredSeries, engineComponentsOf(config.type, marked.markLine, marked.extra));
1344
1474
  const locale = str(p.locale);
1345
1475
  const created = await port.create(stage!, { theme: { color: theme.palette }, ...(locale !== '' ? { locale } : {}) });
1346
1476
  if (!alive) { created.dispose(); return; }
@@ -1364,7 +1494,7 @@ export function createChart(): SomaComponentDefinition {
1364
1494
  }
1365
1495
  // 异步期间又有新一轮 paint 或已卸载:交给最新一轮
1366
1496
  if (!alive || mine !== seq || instance === null) return;
1367
- await port.ensure(engineSeriesListOf(config.type), engineComponentsOf(config.type, marked.markLine, marked.extra));
1497
+ await port.ensure(requiredSeries, engineComponentsOf(config.type, marked.markLine, marked.extra));
1368
1498
  if (!alive || mine !== seq) return;
1369
1499
  instance.setOption(option, 'replace');
1370
1500
  endEngineWait();
@@ -9,11 +9,12 @@
9
9
  import type { SomaComponentDefinition } from 'soma-core';
10
10
  import { bool, createKitController, joinClass, str } from '../base/shared';
11
11
  import { createCheck, markInput } from '../base/check-core';
12
- import { kitIcon } from '../base/icons';
13
- import { mergeClass } from '../object-renderer/merge-class';
12
+ import { kitIcon } from '../shared/icons';
13
+ import { mergeClass } from '../shared/merge-class';
14
14
  import { kitStateMarkRecipe } from '../recipes/state';
15
15
  import { kitText } from '../i18n/kit-text';
16
16
  import { markKitEdge } from '../recipes/surface-edge';
17
+ import { kitShellRecipe } from '../recipes/container';
17
18
  import { kitTypographyRecipe } from '../recipes/typography';
18
19
  import {
19
20
  actionButton, actionsOf, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, mkProgressBar, PROGRESS_BAR_CLASS_TOKENS, recOf, setProgressBar, rowsOf, shapeToneOf, textOf,
@@ -25,7 +26,7 @@ export const KIT_CHECKLIST_ITEM_DEFAULT_MAP = Object.freeze({ id: 'id', label: '
25
26
 
26
27
  export type KitCheckStatus = 'done' | 'blocked' | 'pending';
27
28
 
28
- const ROOT_CLASS = 'flex flex-col gap-3 rounded-lg border border-border-subtle bg-surface p-5 text-sm text-fg';
29
+ const ROOT_CLASS = mergeClass('flex flex-col gap-3 p-5 text-sm text-fg', kitShellRecipe({ tone: 'base', shadow: false }));
29
30
  const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
30
31
  const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
31
32
  const COUNT_CLASS = 'ms-auto text-xs text-fg-muted';
@@ -109,7 +110,7 @@ export function createChecklist(): SomaComponentDefinition {
109
110
  action: { payload: { key: { type: 'string' } }, desc: '点底部动作' },
110
111
  },
111
112
  },
112
- templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
113
+ templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
113
114
  controllerFactory: createKitController(() => ({
114
115
  attach(root, api) {
115
116
  const onChange = (event: Event): void => {