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
@@ -0,0 +1,141 @@
1
+ // 窗口外壳(居中窗口 / 抽屉)的唯一结构:遮罩行 > 面板 > 头(56)/ 正文(滚动,内边距 24)/ 底栏(56)。
2
+ // 声明式页面浮层(biz/shared/overlay-shell:`kind: dialog / drawer`、新增编辑弹窗)与命令式浮层(data/modal-dialog:确认 / 提示 / 选择器 / 抽屉)
3
+ // 都只是这里的调用方:调用方传「决定」(哪种窗口、哪一档宽度、标题与正文是什么),结构、类串、标记属性只在本文件与 recipes/overlay.ts 出口。
4
+ // 流水线位置:recipes(类串)-> 本文件(结构)-> data / biz(调用方)。本文件不认识页面、业务对象与具体窗口用途;颜色、阴影、圆角在 recipes 里按面阶取,这里不碰。
5
+ // 定位:居中窗口顶边固定(遮罩上沿下 topPx)、底部留白(bottomGapPx),高度随内容、最大高度占满其间,正文在窗口内滚动;抽屉贴 end 侧整高。
6
+
7
+ import { esc } from '../shared/escape';
8
+ import { kitIconHtml } from '../shared/icons';
9
+ import {
10
+ KIT_OVERLAY_CLOSE_CLASS, KIT_OVERLAY_HEAD_ACTIONS_CLASS, KIT_OVERLAY_SCRIM_CLASS, KIT_OVERLAY_SCROLL_ATTR, KIT_PART_DIALOG, KIT_PART_DRAWER,
11
+ kitDialogPanelClass, kitDrawerPanelClass, kitOverlayContentRecipe, kitOverlayFooterRecipe, kitOverlayHeaderRecipe, kitOverlayTitleRecipe,
12
+ KIT_OVERLAY_LEAD_ICON, KIT_OVERLAY_LEAD_TEXT_CLASS, kitOverlayLeadBodyRecipe, kitOverlayLeadHeaderRecipe,
13
+ type KitDialogTier, type KitDrawerWidth,
14
+ } from '../recipes/overlay';
15
+ import { KIT_FIXED_ATTRIBUTE, KIT_PART_ATTRIBUTE, KIT_PART_TITLE_DIALOG } from '../recipes';
16
+
17
+ export type KitShellKind = 'dialog' | 'drawer';
18
+
19
+ /** 外壳各段类串(一次取全:编译期候选类收集、测试都读这一份) */
20
+ export interface KitShellClasses {
21
+ scrim: string;
22
+ panel: string;
23
+ header: string;
24
+ title: string;
25
+ close: string;
26
+ headActions: string;
27
+ body: string;
28
+ footer: string;
29
+ }
30
+
31
+ /** 窗口的决定:哪种窗口 + 档位(居中窗口 confirm / default / wide / xwide;抽屉 default / wide);panelExtra 是调用方已合并好的附加类 */
32
+ export interface KitShellDecision {
33
+ kind: KitShellKind;
34
+ dialogTier?: KitDialogTier;
35
+ drawerWidth?: KitDrawerWidth;
36
+ panelExtra?: string;
37
+ }
38
+
39
+ export function kitShellClasses(d: KitShellDecision): KitShellClasses {
40
+ const panel = d.kind === 'drawer' ? kitDrawerPanelClass(d.drawerWidth ?? 'default') : kitDialogPanelClass(d.dialogTier ?? 'default');
41
+ return {
42
+ scrim: KIT_OVERLAY_SCRIM_CLASS[d.kind],
43
+ panel: d.panelExtra !== undefined && d.panelExtra !== '' ? `${panel} ${d.panelExtra}` : panel,
44
+ header: kitOverlayHeaderRecipe(),
45
+ title: kitOverlayTitleRecipe(),
46
+ close: KIT_OVERLAY_CLOSE_CLASS,
47
+ headActions: KIT_OVERLAY_HEAD_ACTIONS_CLASS,
48
+ body: kitOverlayContentRecipe(),
49
+ footer: kitOverlayFooterRecipe(),
50
+ };
51
+ }
52
+
53
+ /** 段标记属性(测试、协调组件与渲染度量按它找段):居中窗口 `data-kit-dialog-*`,抽屉 `data-kit-overlay-*` */
54
+ export function kitShellMarks(kind: KitShellKind): { header: string; body: string; footer: string } {
55
+ const family = kind === 'drawer' ? 'overlay' : 'dialog';
56
+ return { header: `data-kit-${family}-header`, body: `data-kit-${family}-body`, footer: `data-kit-${family}-footer` };
57
+ }
58
+
59
+ const classAttr = (v: string): string => (v === '' ? '' : ` class="${esc(v)}"`);
60
+
61
+ /** 关闭钮 HTML(someId 给声明式页面的事件绑定用;命令式没有) */
62
+ function closeHtml(label: string, c: KitShellClasses, somaId: string | undefined): string {
63
+ return `<button type="button"${somaId !== undefined ? ` data-soma-id="${esc(somaId)}"` : ''} aria-label="${esc(label)}"${classAttr(c.close)}>${kitIconHtml('close', 'md')}</button>`;
64
+ }
65
+
66
+ export interface KitShellHtmlSpec extends KitShellDecision {
67
+ /** 面板类串的最终值(调用方在 kitShellClasses 的基准上按同族规则合并了应用的附加类时传;缺省取基准) */
68
+ panelClass?: string;
69
+ /** 面板 aria-labelledby 指向的标题元素 id(声明式);命令式用 aria-label */
70
+ titleId?: string;
71
+ /** 标题元素的 data-soma-id(声明式页面事件 / 显隐绑定用) */
72
+ titleSomaId?: string;
73
+ /** 标题元素内部 HTML(调用方已转义;纯文本标题传 esc(title)) */
74
+ titleHtml: string;
75
+ /** 面板的 aria-label(没有 titleId 时) */
76
+ ariaLabel?: string;
77
+ /** 头右侧、关闭钮之前的操作区 HTML(如「编辑」钮宿主) */
78
+ headActionsHtml?: string;
79
+ /** 关闭钮;null = 不画(正文自带关闭钮的命令式浮层) */
80
+ close: { label: string; somaId?: string } | null;
81
+ bodyHtml: string;
82
+ /** 底栏内容:null = 不画底栏;'' = 画空底栏(命令式,内容随后填入) */
83
+ footerHtml: string | null;
84
+ /** 引导头(确认类窗口):语气图标块 + 标题一列,没有头部条与关闭钮;说明文字由调用方追加到标题之后(同一列) */
85
+ lead?: 'danger' | 'primary';
86
+ }
87
+
88
+ /** 窗口外壳 HTML(遮罩行为根)。声明式页面在外面再包一层显隐宿主;命令式经 kitShellDom 解析本串得到 DOM,两条路径同一结构。 */
89
+ export function kitShellHtml(s: KitShellHtmlSpec): string {
90
+ const c = kitShellClasses(s);
91
+ if (s.panelClass !== undefined) c.panel = s.panelClass;
92
+ const marks = kitShellMarks(s.kind);
93
+ const part = s.kind === 'drawer' ? KIT_PART_DRAWER : KIT_PART_DIALOG;
94
+ const label = s.titleId !== undefined ? ` aria-labelledby="${esc(s.titleId)}"` : s.ariaLabel !== undefined ? ` aria-label="${esc(s.ariaLabel)}"` : '';
95
+ const titleAttrs = `${s.titleId !== undefined ? ` id="${esc(s.titleId)}"` : ''}${s.titleSomaId !== undefined ? ` data-soma-id="${esc(s.titleSomaId)}"` : ''}`;
96
+ const headRight = s.close === null ? '' : closeHtml(s.close.label, c, s.close.somaId);
97
+ const actions = s.headActionsHtml !== undefined && s.headActionsHtml !== ''
98
+ ? `<div${classAttr(c.headActions)}>${s.headActionsHtml}${headRight}</div>`
99
+ : headRight;
100
+ const h2 = `<h2${titleAttrs}${classAttr(c.title)} ${KIT_PART_ATTRIBUTE}="${KIT_PART_TITLE_DIALOG}">${s.titleHtml}</h2>`;
101
+ const lead = s.lead === undefined ? null : KIT_OVERLAY_LEAD_ICON[s.lead];
102
+ const header = lead === null
103
+ ? `<div ${marks.header}=""${classAttr(c.header)}>${h2}${actions}</div>`
104
+ : `<div ${marks.header}="" data-kit-dialog-lead=""${classAttr(kitOverlayLeadHeaderRecipe())}>`
105
+ + `<span aria-hidden="true"${classAttr(lead.cls)}>${kitIconHtml(lead.icon, 'md')}</span>`
106
+ + `<div${classAttr(KIT_OVERLAY_LEAD_TEXT_CLASS)}>${h2}</div></div>`;
107
+ return `<div data-kit-scrim="" ${KIT_FIXED_ATTRIBUTE}=""${classAttr(c.scrim)}>`
108
+ + `<div role="dialog" aria-modal="true"${classAttr(c.panel)} ${KIT_PART_ATTRIBUTE}="${part}"${label}>`
109
+ + header
110
+ + `<div ${marks.body}="" ${KIT_OVERLAY_SCROLL_ATTR}=""${classAttr(lead === null ? c.body : kitOverlayLeadBodyRecipe())}>${s.bodyHtml}</div>`
111
+ + (s.footerHtml !== null ? `<div ${marks.footer}=""${classAttr(c.footer)}>${s.footerHtml}</div>` : '')
112
+ + '</div></div>';
113
+ }
114
+
115
+ /** 命令式外壳的各段元素 */
116
+ export interface KitShellDom {
117
+ scrim: HTMLElement;
118
+ panel: HTMLElement;
119
+ title: HTMLElement;
120
+ closeButton: HTMLButtonElement | null;
121
+ body: HTMLElement;
122
+ footer: HTMLElement | null;
123
+ }
124
+
125
+ /** 命令式窗口外壳:同一份 HTML 结构解析成 DOM(标题文本经 esc 转义后进入模板,调用方之后只往 body / footer 里放元素) */
126
+ export function kitShellDom(doc: Document, s: Omit<KitShellHtmlSpec, 'titleHtml' | 'bodyHtml'> & { title: string }): KitShellDom {
127
+ const marks = kitShellMarks(s.kind);
128
+ const tpl = doc.createElement('template');
129
+ tpl.innerHTML = kitShellHtml({ ...s, titleHtml: esc(s.title), bodyHtml: '' });
130
+ const root = tpl.content.firstElementChild as HTMLElement;
131
+ const must = <T extends Element>(sel: string): T => root.querySelector(sel) as T;
132
+ const closeButton = root.querySelector<HTMLButtonElement>(`[${marks.header}] button`);
133
+ return {
134
+ scrim: root,
135
+ panel: must<HTMLElement>('[role="dialog"]'),
136
+ title: must<HTMLElement>('h2'),
137
+ closeButton,
138
+ body: must<HTMLElement>(`[${marks.body}]`),
139
+ footer: root.querySelector<HTMLElement>(`[${marks.footer}]`),
140
+ };
141
+ }
@@ -1,4 +1,4 @@
1
- import { mergeClass } from '../object-renderer/merge-class';
1
+ import { mergeClass } from '../shared/merge-class';
2
2
  // Popover(通用气泡卡片)与 Popconfirm(气泡确认)。D8 组。
3
3
  //
4
4
  // 归类(2.1a 四问):触发钮 + 一小块浮出的文字 / 确认条,不带对象形状 -> 基础组件。
@@ -90,7 +90,7 @@ export function popPlaceOf(placement: PopPlacement): PopPlace {
90
90
  const [side, align] = placement.split('-') as ['top' | 'bottom', 'start' | 'end'];
91
91
  return { side, align };
92
92
  }
93
- const panelClass = (place: PopPlace): string => `${PANEL_BASE} ${popPlaceClass(place, 2)}`;
93
+ const panelClass = (place: PopPlace): string => `${PANEL_BASE} ${popPlaceClass(place)}`;
94
94
  const TITLE = 'text-sm font-semibold text-fg';
95
95
  const BODY = 'mt-2 text-sm text-fg-muted';
96
96
  const ACTIONS = mergeClass(kitPopoverActionsRecipe(), 'mt-2');
package/src/base/popup.ts CHANGED
@@ -9,6 +9,7 @@ import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
9
9
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
10
10
  import { kitDirAt } from '../i18n/kit-text';
11
11
  import { kitSurfaceRecipe } from '../recipes/surface';
12
+ import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
12
13
  import { leaveAnchored, markAnchored, unmarkAnchored } from './anchored-layer';
13
14
  import type { KitLeaveHandle } from './overlay-runtime';
14
15
  import {
@@ -16,18 +17,22 @@ import {
16
17
  type PanelPortal, type PointPanel, type PointPanelOptions, type PointXY,
17
18
  } from './portal-core';
18
19
 
19
- import { KIT_DROPDOWN_LIMITS } from 'soma-foundation/kit-limits';
20
+ import { KIT_DROPDOWN_LIMITS, KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
20
21
  import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
21
22
 
22
23
  type WiringOptions = Parameters<typeof createKeyboardWiring>[0];
23
24
 
24
- // 下拉面板高度与浮层阴影档的真源:类名读 spec/kit-grammar.json#dropdown,行高 / 内边距 / 各档像素读 design 的 kit-limits.json#dropdown
25
- // (最大高 = 整数行 + 半行;shadow-lg 浮层档;border-border-subtle);clamps 两处按下标一一对应(行数从大到小)
26
- type DropdownRules = {
27
- rowClass: string; panelMaxClass: string; panelShadowClass: string; panelBorderClass: string;
28
- clamps: readonly { cls: string }[];
29
- };
25
+ // 下拉面板高度与浮层阴影档的真源:阴影 / 描边类读 spec/kit-grammar.json#dropdown;行高 = 条带阶梯的菜单项行高 sizeSpec.strip.menuItemPx(AR42),
26
+ // 内边距与各档像素读 design 的 kit-limits.json#dropdown(最大高 = 内边距 + (整数行 + 半行) × 行高;行数从大到小);类按像素写成 max-h-[Npx](与行高同口径,密度无关)
27
+ type DropdownRules = { panelShadowClass: string; panelBorderClass: string };
30
28
  const DD = (grammarJson as unknown as { dropdown: DropdownRules }).dropdown;
29
+
30
+ /** 空间不足时面板内部滚动的 max-h 闭集档位,从大到小;每档都是「整数行 + 半行」(真源 dropdown.clamps),空间不够也不腰斩一行 */
31
+ export const DROPDOWN_CLAMPS: readonly { cls: string; px: number }[] = Object.freeze(
32
+ KIT_DROPDOWN_LIMITS.clamps.map((c) => ({ cls: `max-h-[${c.px}px]`, px: c.px })),
33
+ );
34
+ /** 下拉面板的默认最大高(最大一档:visibleRows 行 + 半行) */
35
+ export const KIT_DROPDOWN_PANEL_MAX_CLASS: string = DROPDOWN_CLAMPS[0]!.cls;
31
36
  /** 下拉 / 菜单面板的表面:浮起级(圆角 + 发丝描边 + 浮起底色 + 双层阴影 + 高光边,recipes/surface.ts 唯一拼装处) */
32
37
  const SURFACE_RAISED = kitSurfaceRecipe('raised');
33
38
 
@@ -136,19 +141,24 @@ export function focusCellQuiet(node: HTMLElement | null | undefined): void {
136
141
  node.focus({ preventScroll: true });
137
142
  }
138
143
 
144
+ /** 下拉 / 菜单面板宽度上限(kit-limits#overlay.menuMaxPx = 320,宽度模数阶梯):按最长项取宽到上限,更长的项在行内省略;下限是触发器宽(min-w-full) */
145
+ const MENU_MAX_WIDTH_CLASS = `max-w-[${KIT_OVERLAY_LIMITS.menuMaxPx}px]`;
146
+
139
147
  /** 默认的整串面板类:显隐只换整串,`hidden` 不与布局类并存 */
140
148
  export const PANEL_HIDDEN_CLASS = 'hidden';
141
149
  export const PANEL_SHOWN_CLASS =
142
- `absolute start-0 top-full z-10 mt-1 ${DD.panelMaxClass} w-max min-w-full max-w-screen overflow-auto ${SURFACE_RAISED} py-1`;
150
+ `absolute start-0 top-full z-10 mt-1 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} py-1`;
143
151
 
144
- // 选项行高固定(真源 dropdown.rowClass = h-9),面板最大高才能算成「整数行 + 半行」
145
- const ROW = DD.rowClass;
152
+ // 选项行高固定(条带阶梯的菜单项行高 strip.menuItemPx),面板最大高才能算成「整数行 + 半行」
153
+ const ROW = KIT_STRIP_MENU_ITEM_CLASS;
146
154
  export const OPTION_CLASS = {
147
155
  idle: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press`,
148
- active: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-surface-sunken px-3 text-sm text-fg transition-colors`,
149
- selected: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors`,
150
- selectedActive: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors`,
151
- disabled: `flex ${ROW} cursor-not-allowed items-center whitespace-nowrap gap-2 px-3 text-sm text-fg-subtle opacity-60`,
156
+ // 键盘当前项与鼠标悬停同一层;选中项 = 主色淡底,选中项上的悬停 / 当前 = tonal 层(第三级,KT-K0-2 / KT-K-select-3)
157
+ active: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-state-layer-hover px-3 text-sm text-fg transition-colors`,
158
+ selected: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
159
+ selectedActive: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-state-layer-tonal-hover px-3 text-sm font-medium text-primary-on-soft transition-colors`,
160
+ // 置灰项 = 禁用字色令牌(KT-K-select-5 / KT-K0-4),不降透明度
161
+ disabled: `flex ${ROW} cursor-not-allowed items-center whitespace-nowrap gap-2 px-3 text-sm text-fg-disabled`,
152
162
  } as const;
153
163
 
154
164
  export const EMPTY_ROW_CLASS = `flex ${ROW} items-center whitespace-nowrap px-3 text-sm text-fg-subtle`;
@@ -161,12 +171,12 @@ export function optionClass(selected: boolean, active: boolean, disabled: boolea
161
171
 
162
172
  /** 本文件自带的类(供各组件并入候选类清单) */
163
173
  export const KIT_POPUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
164
- 'hidden', 'absolute', 'start-0', 'top-full', 'z-10', 'mt-1', DD.panelMaxClass, DD.rowClass, 'w-full', 'w-max', 'min-w-full', 'max-w-screen', 'overflow-auto',
174
+ 'hidden', 'absolute', 'start-0', 'top-full', 'z-10', 'mt-1', KIT_DROPDOWN_PANEL_MAX_CLASS, KIT_STRIP_MENU_ITEM_CLASS, 'w-full', 'w-max', 'min-w-full', MENU_MAX_WIDTH_CLASS, 'overflow-auto',
165
175
  'rounded-md', 'rounded-lg', 'border', 'border-border', 'border-border-subtle', 'bg-surface-raised', 'py-1', DD.panelShadowClass, 'shadow-sm',
166
176
  ...SURFACE_RAISED.split(/\s+/),
167
177
  'flex', 'cursor-pointer', 'cursor-not-allowed', 'items-center', 'whitespace-nowrap', 'gap-2', 'px-3', 'py-2', 'text-sm',
168
178
  'text-fg', 'text-fg-subtle', 'bg-surface-sunken', 'font-medium', 'text-primary-on-soft',
169
- 'transition-colors', 'hover:bg-state-layer-hover', 'active:bg-state-layer-press', 'bg-primary-soft', 'text-primary-on-soft', 'opacity-60',
179
+ 'transition-colors', 'hover:bg-state-layer-hover', 'active:bg-state-layer-press', 'bg-primary-soft', 'text-primary-on-soft', 'text-fg-disabled',
170
180
  ]);
171
181
 
172
182
  /**
@@ -196,22 +206,25 @@ const POP_POS: Readonly<Record<PopSide, Readonly<Record<PopAlign, string>>>> = {
196
206
  start: { start: 'end-full top-0', end: 'bottom-0 end-full' },
197
207
  end: { start: 'start-full top-0', end: 'bottom-0 start-full' },
198
208
  };
199
- const POP_GAP: Readonly<Record<PopSide, Readonly<Record<1 | 2, string>>>> = {
200
- bottom: { 1: 'mt-1', 2: 'mt-2' },
201
- top: { 1: 'mb-1', 2: 'mb-2' },
202
- start: { 1: 'me-1', 2: 'me-2' },
203
- end: { 1: 'ms-1', 2: 'ms-2' },
209
+ /** 锚定层与触发器的间距:只此一个值(真源 dropdown.gapPx),所有锚定浮层(下拉 / 菜单 / 气泡 / 筛选面板)共用,构件不自带偏移 */
210
+ export const ANCHORED_GAP_PX: number = KIT_DROPDOWN_LIMITS.gapPx;
211
+ const GAP_UNIT = ANCHORED_GAP_PX / 4;
212
+ const POP_GAP: Readonly<Record<PopSide, string>> = {
213
+ bottom: `mt-${GAP_UNIT}`,
214
+ top: `mb-${GAP_UNIT}`,
215
+ start: `me-${GAP_UNIT}`,
216
+ end: `ms-${GAP_UNIT}`,
204
217
  };
205
218
 
206
- /** 位置类串(不含 absolute / z / 外观类,由组件自己拼) */
207
- export function popPlaceClass(place: PopPlace, gap: 1 | 2 = 1): string {
208
- return `${POP_POS[place.side][place.align]} ${POP_GAP[place.side][gap]}`;
219
+ /** 位置类串(不含 absolute / z / 外观类,由组件自己拼):左缘(start)或右缘(end)与触发器对齐 + 真源间距 */
220
+ export function popPlaceClass(place: PopPlace): string {
221
+ return `${POP_POS[place.side][place.align]} ${POP_GAP[place.side]}`;
209
222
  }
210
223
 
211
224
  /** 全部位置类(供类名候选清单) */
212
225
  export const KIT_POPUP_PLACE_CLASS_CANDIDATES: readonly string[] = Object.freeze(
213
226
  [...new Set((['top', 'bottom', 'start', 'end'] as const).flatMap((s) =>
214
- (['start', 'end'] as const).flatMap((a) => `${POP_POS[s][a]} ${POP_GAP[s][1]} ${POP_GAP[s][2]}`.split(' '))))],
227
+ (['start', 'end'] as const).flatMap((a) => `${POP_POS[s][a]} ${POP_GAP[s]}`.split(' '))))],
215
228
  );
216
229
 
217
230
  const FLIP_OPPOSITE: Readonly<Record<PopSide, PopSide>> = { top: 'bottom', bottom: 'top', start: 'end', end: 'start' };
@@ -222,7 +235,7 @@ export function resolvePopPlace(
222
235
  size: { width: number; height: number },
223
236
  viewport: { width: number; height: number },
224
237
  pref: PopPlace,
225
- gapPx = 8,
238
+ gapPx = ANCHORED_GAP_PX,
226
239
  rtl = false,
227
240
  ): PopPlace {
228
241
  const { width: w, height: h } = size;
@@ -268,7 +281,7 @@ export function showPopupFitted(
268
281
  anchor: HTMLElement,
269
282
  pref: PopPlace,
270
283
  classFor: (place: PopPlace) => string,
271
- gapPx = 8,
284
+ gapPx = ANCHORED_GAP_PX,
272
285
  ): PopPlace {
273
286
  const place = fitPopupPlace(panel, anchor, pref, classFor, gapPx);
274
287
  // 锚定浮层统一标记(anchored-layer.ts):落位后的实际方向,重定位 / 翻转时随之更新
@@ -297,7 +310,7 @@ function fitPopupPlace(
297
310
 
298
311
  /** 气泡的偏好位置:目标下方、左对齐;贴边时由 showPopupFitted 翻转 */
299
312
  export const POPUP_TIP_PREF: PopPlace = { side: 'bottom', align: 'start' };
300
- export const popupTipClass = (place: PopPlace): string => `${POPUP_TIP_BASE} ${popPlaceClass(place, 1)}`;
313
+ export const popupTipClass = (place: PopPlace): string => `${POPUP_TIP_BASE} ${popPlaceClass(place)}`;
301
314
  export const POPUP_TIP_SHOWN_CLASS = popupTipClass(POPUP_TIP_PREF);
302
315
 
303
316
  // ── 下拉面板的贴边翻转(Select / Combobox / Cascader / TreeSelect / TimePicker / ColorPicker / Mentions / TagInput / Navbar / Menu columns 共用)──
@@ -309,12 +322,7 @@ export const POPUP_TIP_SHOWN_CLASS = popupTipClass(POPUP_TIP_PREF);
309
322
 
310
323
  /** 下拉面板外观类(不含位置类):与 PANEL_SHOWN_CLASS 同一份外观 */
311
324
  export const PANEL_BASE_CLASS =
312
- `absolute z-10 ${DD.panelMaxClass} w-max min-w-full max-w-screen overflow-auto ${SURFACE_RAISED} py-1`;
313
-
314
- /** 空间不足时面板内部滚动的 max-h 闭集档位(px = 刻度 x 4),从大到小;每档都是「整数行 + 半行」(真源 dropdown.clamps),空间不够也不腰斩一行 */
315
- export const DROPDOWN_CLAMPS: readonly { cls: string; px: number }[] = Object.freeze(
316
- DD.clamps.map((c, i) => ({ cls: c.cls, px: KIT_DROPDOWN_LIMITS.clamps[i]!.px })),
317
- );
325
+ `absolute z-10 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} py-1`;
318
326
 
319
327
  /** 下拉翻转用到的全部类(位置类、间距类、max-h 档位、滚动) */
320
328
  export const KIT_DROPDOWN_CLASS_CANDIDATES: readonly string[] = Object.freeze([
@@ -334,7 +342,7 @@ export function resolveDropdown(
334
342
  size: { width: number; height: number },
335
343
  viewport: { width: number; height: number },
336
344
  prefAlign: PopAlign = 'start',
337
- gapPx = 8,
345
+ gapPx = ANCHORED_GAP_PX,
338
346
  rtl = false,
339
347
  ): { place: PopPlace; clampPx: number | null } {
340
348
  if (size.width === 0 && size.height === 0) return { place: { side: 'bottom', align: prefAlign }, clampPx: null };
@@ -374,9 +382,8 @@ export function showDropdownFitted(
374
382
  anchor: HTMLElement,
375
383
  base: string,
376
384
  prefAlign: PopAlign = 'start',
377
- gap: 1 | 2 = 1,
378
385
  ): PopPlace {
379
- const place = fitDropdownPlace(panel, anchor, base, prefAlign, gap);
386
+ const place = fitDropdownPlace(panel, anchor, base, prefAlign);
380
387
  markAnchored(panel, place);
381
388
  return place;
382
389
  }
@@ -386,9 +393,8 @@ function fitDropdownPlace(
386
393
  anchor: HTMLElement,
387
394
  base: string,
388
395
  prefAlign: PopAlign,
389
- gap: 1 | 2,
390
396
  ): PopPlace {
391
- const classFor = (place: PopPlace): string => `${base} ${popPlaceClass(place, gap)}`;
397
+ const classFor = (place: PopPlace): string => `${base} ${popPlaceClass(place)}`;
392
398
  const pref: PopPlace = { side: 'bottom', align: prefAlign };
393
399
  panel.className = classFor(pref);
394
400
  if (typeof panel.getBoundingClientRect !== 'function') return pref;
@@ -397,8 +403,8 @@ function fitDropdownPlace(
397
403
  if (vw === 0 || vh === 0) return pref;
398
404
  const a = anchor.getBoundingClientRect();
399
405
  const b = panel.getBoundingClientRect();
400
- const { place, clampPx } = resolveDropdown(a, { width: b.width, height: b.height }, { width: vw, height: vh }, prefAlign, 8, kitDirAt(anchor) === 'rtl');
401
- const next = clampPx === null ? classFor(place) : `${clampDropdownClass(base, clampPx)} ${popPlaceClass(place, gap)}`;
406
+ const { place, clampPx } = resolveDropdown(a, { width: b.width, height: b.height }, { width: vw, height: vh }, prefAlign, ANCHORED_GAP_PX, kitDirAt(anchor) === 'rtl');
407
+ const next = clampPx === null ? classFor(place) : `${clampDropdownClass(base, clampPx)} ${popPlaceClass(place)}`;
402
408
  if (panel.className !== next) panel.className = next;
403
409
  return place;
404
410
  }
@@ -12,24 +12,29 @@
12
12
  import { FIELD_INVALID_CLASS, classCandidates, bool, num, sizeOf, str, type KitProps, type KitSize } from './shared';
13
13
  import { kitText } from '../i18n/kit-text';
14
14
  import { setKitFace } from '../recipes';
15
+ import { kitControlEdgeRecipe } from '../recipes/control';
16
+ import { kitDividerRecipe } from '../recipes/divider';
15
17
 
18
+ // 步进器是一个控件(减 / 输入 / 加 同在一圈控件线里):外圈 = 控件轮廓(kitControlEdgeRecipe,KT-B1 / §4 C6),段间 = 分隔线出口(KT-B5)
19
+ const EDGE = kitControlEdgeRecipe({ wrapper: true });
20
+ const SEP = `${kitDividerRecipe('start')} ${kitDividerRecipe('end')}`;
16
21
  const GROUP: Record<KitSize, string> = {
17
- sm: 'inline-flex h-6 items-stretch overflow-hidden rounded-md border border-input bg-surface text-sm transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
18
- md: 'inline-flex h-8 items-stretch overflow-hidden rounded-md border border-input bg-surface text-sm transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
19
- lg: 'inline-flex h-10 items-stretch overflow-hidden rounded-md border border-input bg-surface text-base transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
22
+ sm: `inline-flex h-6 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface text-sm transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
23
+ md: `inline-flex h-8 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface text-sm transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
24
+ lg: `inline-flex h-10 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface text-base transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
20
25
  };
21
26
  const GROUP_OFF: Record<KitSize, string> = {
22
- sm: 'inline-flex h-6 items-stretch overflow-hidden rounded-md border border-input bg-surface-sunken text-sm opacity-60',
23
- md: 'inline-flex h-8 items-stretch overflow-hidden rounded-md border border-input bg-surface-sunken text-sm opacity-60',
24
- lg: 'inline-flex h-10 items-stretch overflow-hidden rounded-md border border-input bg-surface-sunken text-base opacity-60',
27
+ sm: `inline-flex h-6 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface-sunken text-sm opacity-60`,
28
+ md: `inline-flex h-8 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface-sunken text-sm opacity-60`,
29
+ lg: `inline-flex h-10 items-stretch overflow-hidden rounded-md ${EDGE} bg-surface-sunken text-base opacity-60`,
25
30
  };
26
31
  const BTN_ON = 'inline-flex w-8 shrink-0 cursor-pointer items-center justify-center text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
27
32
  const BTN_OFF = 'inline-flex w-8 shrink-0 cursor-not-allowed items-center justify-center text-fg-subtle opacity-60';
28
33
  // 无 preflight:input 不继承分组的字号(浏览器默认 13px),所以按档位自己写 text-sm / text-base
29
34
  export const STEPPER_INPUT: Record<KitSize, string> = {
30
- sm: 'w-14 min-w-0 appearance-none autofill-clear border-s border-e border-border-subtle bg-transparent px-1 text-center text-sm text-fg focus-visible:outline-none read-only:bg-surface-sunken',
31
- md: 'w-14 min-w-0 appearance-none autofill-clear border-s border-e border-border-subtle bg-transparent px-1 text-center text-sm text-fg focus-visible:outline-none read-only:bg-surface-sunken',
32
- lg: 'w-14 min-w-0 appearance-none autofill-clear border-s border-e border-border-subtle bg-transparent px-1 text-center text-base text-fg focus-visible:outline-none read-only:bg-surface-sunken',
35
+ sm: `w-14 min-w-0 appearance-none autofill-clear ${SEP} bg-transparent px-1 text-center text-sm text-fg focus-visible:outline-none read-only:bg-surface-sunken`,
36
+ md: `w-14 min-w-0 appearance-none autofill-clear ${SEP} bg-transparent px-1 text-center text-sm text-fg focus-visible:outline-none read-only:bg-surface-sunken`,
37
+ lg: `w-14 min-w-0 appearance-none autofill-clear ${SEP} bg-transparent px-1 text-center text-base text-fg focus-visible:outline-none read-only:bg-surface-sunken`,
33
38
  };
34
39
 
35
40
  export const KIT_QTY_STEPPER_CLASS_CANDIDATES: readonly string[] = classCandidates(
@@ -9,7 +9,7 @@
9
9
  // - 原因为空 / 动作未置灰:不建气泡、不改 aria-describedby,行为与没有该声明时完全相同。
10
10
  // 文字一律 textContent;气泡外观取 popup 底座的 tooltip 类(去掉 pointer-events-none,浮层根里需要 pointer-events-auto)。
11
11
 
12
- import { classCandidates } from './class-candidates';
12
+ import { classCandidates } from '../shared/class-candidates';
13
13
  import {
14
14
  KIT_POPUP_PLACE_CLASS_CANDIDATES, POPUP_TIP_BASE, POPUP_TIP_HIDDEN_CLASS, POPUP_TIP_PREF, popPlaceClass, releaseDropdown, syncAnchored,
15
15
  type PopPlace,
@@ -17,7 +17,7 @@ import {
17
17
  import { addIdToken, nextUid, removeIdToken } from './shared';
18
18
 
19
19
  const REASON_TIP_BASE = POPUP_TIP_BASE.split(/\s+/).filter((t) => t !== 'pointer-events-none').join(' ');
20
- const reasonTipClass = (place: PopPlace): string => `${REASON_TIP_BASE} ${popPlaceClass(place, 1)}`;
20
+ const reasonTipClass = (place: PopPlace): string => `${REASON_TIP_BASE} ${popPlaceClass(place)}`;
21
21
 
22
22
  export const KIT_REASON_TIP_CLASS_CANDIDATES: readonly string[] = classCandidates(
23
23
  POPUP_TIP_HIDDEN_CLASS, REASON_TIP_BASE, KIT_POPUP_PLACE_CLASS_CANDIDATES, 'pointer-events-auto',
@@ -1,4 +1,4 @@
1
- // resize-handle:可拖动分隔手柄的行为(role=separator),页面框内可复用的小模块。
1
+ // resize-handle:可拖动分隔手柄的行为(role=separator),基础层与页面框共用的小模块。
2
2
  //
3
3
  // 只管行为不管画面:给一个已有元素补 role=separator、tabindex、aria-orientation、aria-valuenow/min/max,
4
4
  // 指针拖动(pointer capture)、方向键按档位移动、Home / End 到边界、Enter 与双击复位。
@@ -13,6 +13,9 @@ import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
13
13
  import { textWidthEm } from 'soma-foundation/arrange';
14
14
  import { arrangeSegmented } from 'soma-foundation/arrange/table';
15
15
  import { setKitFace } from '../recipes';
16
+ import { kitButtonEdgeRecipe } from '../recipes/control';
17
+ import { kitCompactGroupRecipe, markKitCompactGroup } from '../recipes/compact-group';
18
+ import { kitTabRecipe } from '../recipes/tabs';
16
19
  import {
17
20
  applyCommon, bool, classCandidates, joinClass, num, optionsKey, optionsOf, sameValue, sizeOf,
18
21
  type KitOption, type KitProps, type KitSize, type KitView,
@@ -20,55 +23,42 @@ import {
20
23
 
21
24
  // ── 类串(整串字面量,不拼接)─────────────────────────────────
22
25
 
23
- // 2026-11-17(评审 K7):分段控件至多一层底色、无外描边——轨道无底无框,只有选中段是主色柔底(不再有「轨道底 + 白色滑块 + 阴影」的多层)
24
- // 横排各段紧邻无缝(无间距:未选中段无底色,选中段的柔底面自成一块);各段内边距同尺寸档一致
25
- const SEG_ROOT = 'inline-flex items-center';
26
- const SEG_ROOT_BLOCK = 'flex w-full items-center';
27
- const SEG_ROOT_EQUAL = 'inline-grid auto-cols-fr grid-flow-col items-center';
28
- const SEG_ITEM: Record<KitSize, { idle: string; on: string; off: string }> = {
29
- sm: {
30
- idle: 'inline-flex h-6 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md px-2.5 text-xs font-medium text-fg-muted transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
31
- on: 'inline-flex h-6 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md bg-primary-soft px-2.5 text-xs font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
32
- off: 'inline-flex h-6 min-w-0 flex-1 whitespace-nowrap cursor-not-allowed items-center justify-center rounded-md px-2.5 text-xs font-medium text-fg-subtle opacity-60',
33
- },
34
- md: {
35
- idle: 'inline-flex h-8 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md px-3 text-sm font-medium text-fg-muted transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
36
- on: 'inline-flex h-8 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md 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',
37
- off: 'inline-flex h-8 min-w-0 flex-1 whitespace-nowrap cursor-not-allowed items-center justify-center rounded-md px-3 text-sm font-medium text-fg-subtle opacity-60',
38
- },
39
- lg: {
40
- idle: 'inline-flex h-10 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md px-4 text-base font-medium text-fg-muted transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
41
- on: 'inline-flex h-10 min-w-0 flex-1 whitespace-nowrap cursor-pointer items-center justify-center rounded-md bg-primary-soft px-4 text-base font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
42
- off: 'inline-flex h-10 min-w-0 flex-1 whitespace-nowrap cursor-not-allowed items-center justify-center rounded-md px-4 text-base font-medium text-fg-subtle opacity-60',
43
- },
44
- };
45
-
46
- const SEG_ROOT_V = 'inline-flex flex-col items-stretch gap-0.5';
47
- const SEG_ROOT_BLOCK_V = 'flex w-full flex-col items-stretch gap-0.5';
48
- const TOG_ROOT = 'inline-flex flex-wrap items-center gap-2';
49
- const TOG_ROOT_V = 'inline-flex flex-col items-stretch gap-2';
26
+ // 分段切换的类串唯一出口 recipes/tabs(种类 segment):浅色底圆角槽 + 槽内浮起的亮面选中块;与工作页签 / 页内页签三种形体不同
27
+ const SEG = kitTabRecipe();
28
+ const SEG_ROOT = SEG.segRoot;
29
+ const SEG_ROOT_BLOCK = SEG.segRootBlock;
30
+ const SEG_ROOT_EQUAL = SEG.segRootEqual;
31
+ const SEG_ITEM: Record<KitSize, { idle: string; on: string; off: string }> = SEG.segItem;
32
+ const SEG_ROOT_V = SEG.segRootV;
33
+ const SEG_ROOT_BLOCK_V = SEG.segRootBlockV;
34
+ // 多选按钮组(Checkbox variant: buttons)= 紧凑组合(KT-B7):相邻钮共用一条边、首尾才有外侧圆角、悬停 / 聚焦者在上;
35
+ // 待命 / 禁用钮的边 = 带文字中性按钮描边(kitButtonEdgeRecipe,KT-B1),按下钮的边 = 强调指示(border-primary)
36
+ const TOG_ROOT = kitCompactGroupRecipe('x');
37
+ const TOG_ROOT_V = kitCompactGroupRecipe('y');
38
+ const TOG_EDGE = kitButtonEdgeRecipe();
50
39
  const OPT_ICON = 'shrink-0';
40
+ const OPT_COUNT = 'ms-1.5 text-xs tabular-nums text-fg-subtle';
51
41
  const OPT_GAP = 'gap-1.5';
52
42
  const TOG_ITEM: Record<KitSize, { idle: string; on: string; off: string }> = {
53
43
  sm: {
54
- idle: 'inline-flex h-6 cursor-pointer items-center justify-center rounded-md border border-border bg-surface px-2.5 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
44
+ idle: 'inline-flex h-6 cursor-pointer items-center justify-center rounded-md bg-surface px-2.5 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
55
45
  on: 'inline-flex h-6 cursor-pointer items-center justify-center rounded-md border border-primary bg-primary-soft px-2.5 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
56
- off: 'inline-flex h-6 cursor-not-allowed items-center justify-center rounded-md border border-border bg-surface-sunken px-2.5 text-sm text-fg-subtle opacity-60',
46
+ off: 'inline-flex h-6 cursor-not-allowed items-center justify-center rounded-md bg-control-disabled px-2.5 text-sm text-fg-disabled',
57
47
  },
58
48
  md: {
59
- idle: 'inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-border bg-surface px-3 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
49
+ idle: 'inline-flex h-8 cursor-pointer items-center justify-center rounded-md bg-surface px-3 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
60
50
  on: 'inline-flex h-8 cursor-pointer 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',
61
- off: 'inline-flex h-8 cursor-not-allowed items-center justify-center rounded-md border border-border bg-surface-sunken px-3 text-sm text-fg-subtle opacity-60',
51
+ off: 'inline-flex h-8 cursor-not-allowed items-center justify-center rounded-md bg-control-disabled px-3 text-sm text-fg-disabled',
62
52
  },
63
53
  lg: {
64
- idle: 'inline-flex h-10 cursor-pointer items-center justify-center rounded-md border border-border bg-surface px-4 text-base text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
54
+ idle: 'inline-flex h-10 cursor-pointer items-center justify-center rounded-md bg-surface px-4 text-base text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
65
55
  on: 'inline-flex h-10 cursor-pointer items-center justify-center rounded-md border border-primary bg-primary-soft px-4 text-base font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
66
- off: 'inline-flex h-10 cursor-not-allowed items-center justify-center rounded-md border border-border bg-surface-sunken px-4 text-base text-fg-subtle opacity-60',
56
+ off: 'inline-flex h-10 cursor-not-allowed items-center justify-center rounded-md bg-control-disabled px-4 text-base text-fg-disabled',
67
57
  },
68
58
  };
69
59
 
70
60
  export const KIT_SEGMENTED_CLASS_CANDIDATES: readonly string[] = classCandidates(
71
- SEG_ROOT, SEG_ROOT_BLOCK, SEG_ROOT_EQUAL, 'flex-none', SEG_ROOT_V, SEG_ROOT_BLOCK_V, TOG_ROOT, TOG_ROOT_V, OPT_ICON, OPT_GAP,
61
+ SEG_ROOT, SEG_ROOT_BLOCK, SEG_ROOT_EQUAL, 'flex-none', SEG_ROOT_V, SEG_ROOT_BLOCK_V, TOG_ROOT, TOG_ROOT_V, OPT_ICON, OPT_GAP, OPT_COUNT,
72
62
  Object.values(SEG_ITEM).flatMap((c) => [c.idle, c.on, c.off]),
73
63
  Object.values(TOG_ITEM).flatMap((c) => [c.idle, c.on, c.off]),
74
64
  );
@@ -101,6 +91,13 @@ export function fillOptionContent(host: HTMLElement, option: KitOption, named: H
101
91
  text.textContent = option.label;
102
92
  host.appendChild(text);
103
93
  }
94
+ // 计数(分段筛选):尾部一个小号弱色数字,等宽数字防跳动
95
+ if (option.count !== undefined) {
96
+ const count = document.createElement('span');
97
+ count.className = OPT_COUNT;
98
+ count.textContent = String(option.count);
99
+ host.appendChild(count);
100
+ }
104
101
  const name = iconOnlyName(option);
105
102
  if (name !== null) named.setAttribute('aria-label', name);
106
103
  else named.removeAttribute('aria-label');
@@ -287,7 +284,7 @@ export function createToggleView(): KitView {
287
284
  const o = options.find((x) => String(x.value) === b.dataset.key);
288
285
  const on = values.includes(b.dataset.key ?? '');
289
286
  const off = disabled || o?.disabled === true;
290
- b.className = joinClass(off ? TOG_ITEM[size].off : on ? TOG_ITEM[size].on : TOG_ITEM[size].idle, o?.icon !== undefined && o.label !== '' ? OPT_GAP : '');
287
+ b.className = joinClass(off ? `${TOG_ITEM[size].off} ${TOG_EDGE}` : on ? TOG_ITEM[size].on : `${TOG_ITEM[size].idle} ${TOG_EDGE}`, o?.icon !== undefined && o.label !== '' ? OPT_GAP : '');
291
288
  // 多选按钮组的每一枚在 idle / on / off 三态都带边框 + 底色(on 是 primary-soft 描边,off 是 surface-sunken),一律标 raised
292
289
  setKitFace(b, 'raised');
293
290
  b.setAttribute('aria-pressed', on ? 'true' : 'false');
@@ -296,7 +293,9 @@ export function createToggleView(): KitView {
296
293
  }
297
294
  root.setAttribute('role', 'group');
298
295
  applyCommon(root, p);
299
- root.className = joinClass(orientationOf(p.orientation) === 'vertical' ? TOG_ROOT_V : TOG_ROOT, p.class);
296
+ const vertical = orientationOf(p.orientation) === 'vertical';
297
+ root.className = joinClass(vertical ? TOG_ROOT_V : TOG_ROOT, p.class);
298
+ markKitCompactGroup(root, vertical ? 'y' : 'x');
300
299
  },
301
300
  };
302
301
  }
@@ -32,6 +32,7 @@ export function createSelect(): SomaComponentDefinition {
32
32
  value: { type: 'string', default: '', desc: '当前选中项的 value;multiple 时是 value 数组' },
33
33
  options: OPTIONS_PROP,
34
34
  placeholder: { type: 'string', default: '', desc: '无选中时字段里显示的提示文字' },
35
+ variant: { type: 'enum', values: ['outline', 'filled'], default: 'outline', desc: 'outline = 描边;filled = 浅底' },
35
36
  searchable: { type: 'boolean', default: false, desc: '可搜索:字段换成输入框,输入过滤选项,↑↓ 走项、Enter 确认、Escape 收起' },
36
37
  multiple: { type: 'boolean', default: false, desc: '多选:value 是数组,点选项切换选中、面板保持展开' },
37
38
  group: { type: 'string', default: '', desc: '选项里承载分组标题的字段名(如 region);同标题归一组,组标题粘顶' },