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
@@ -11,6 +11,7 @@ import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
11
11
  import { createKitController, joinClass, num, str } from '../base/shared';
12
12
  import { classTokens, emptyNode, keyMap, mk, rowsOf, textOf } from './shape-util';
13
13
  import { rowKey, safeImgSrc } from './d9-util';
14
+ import { kitShellRecipe } from '../recipes/container';
14
15
  import { kitText } from '../i18n/kit-text';
15
16
  import { MEDIA_ASPECTS, MEDIA_COLUMNS, MEDIA_DEFAULT_COLUMNS, MEDIA_MAX, pickOf } from './d9-limits';
16
17
 
@@ -19,8 +20,10 @@ export const KIT_MEDIA_GRID_DEFAULT_MAP = Object.freeze({ id: 'id', src: 'src',
19
20
  const ROOT_CLASS = '@container text-sm text-fg';
20
21
  const CAPTION_CLASS = 'truncate px-1 text-xs text-fg-muted';
21
22
  const ITEM_CLASS = 'flex flex-col gap-1';
22
- const FRAME_CLASS = 'w-full overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken transition-colors hover:bg-surface focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
23
- const FRAME_STATIC = 'w-full overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken';
23
+ // 媒体格 = 凹槽面的壳配方(容器边,KT-B2)
24
+ const FRAME_EDGE = kitShellRecipe({ tone: 'sunken', shadow: false });
25
+ const FRAME_CLASS = 'w-full overflow-hidden ' + FRAME_EDGE + ' transition-colors hover:bg-surface focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
26
+ const FRAME_STATIC = `w-full overflow-hidden ${FRAME_EDGE}`;
24
27
  const COVER_CLASS = 'size-full object-cover';
25
28
  const FLOW_CLASS = 'block h-auto w-full';
26
29
  const COLUMN_CLASS = 'flex min-w-0 flex-1 flex-col gap-3';
@@ -8,12 +8,13 @@
8
8
 
9
9
  import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
10
10
  import { joinClass, str } from '../base/shared';
11
- import { kitIcon } from '../base/icons';
11
+ import { kitIcon } from '../shared/icons';
12
12
  import { kitKey, kitText } from '../i18n/kit-text';
13
13
  import { safeHref } from '../base/link';
14
14
  import { KIT_DROPDOWN_CLASS_CANDIDATES, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
15
15
  import { attrEsc } from './d9-util';
16
- import { mergeClass } from '../object-renderer/merge-class';
16
+ import { mergeClass } from '../shared/merge-class';
17
+ import { KIT_DIVIDER_FOOT_CLASS } from '../recipes/divider';
17
18
  import { kitSurfaceRecipe } from '../recipes/surface';
18
19
  import { classSet, FOCUS, h, isRec, onOutsidePointer, recList, textOf, type Rec } from './menu-dom';
19
20
 
@@ -38,7 +39,7 @@ const ITEM_HEAD_CLASS = 'flex items-center justify-between gap-2';
38
39
  const ITEM_LABEL_CLASS = 'min-w-0 truncate text-sm font-medium text-fg';
39
40
  const ITEM_DESC_CLASS = 'text-xs text-fg-muted';
40
41
  const BADGE_CLASS = 'shrink-0 rounded-full bg-primary-soft px-2 text-xs font-medium text-primary-on-soft';
41
- const FOOTER_CLASS = 'border-t border-border-subtle pt-3 text-xs text-fg-muted';
42
+ const FOOTER_CLASS = `${KIT_DIVIDER_FOOT_CLASS} pt-3 text-xs text-fg-muted`;
42
43
 
43
44
  /** 本组件自带的全部类(供编译器并入候选类) */
44
45
  export const KIT_MEGA_MENU_CLASS_CANDIDATES: readonly string[] = classSet(
@@ -2,14 +2,14 @@
2
2
  // 全部纯函数或无状态:建元素、类串拆候选、记录读取、下拉菜单(弹层 + 焦点进入 / 回焦 / Esc / 点外面关)。
3
3
 
4
4
  import { KIT_DROPDOWN_CLASS_CANDIDATES, dropdownOwnerOf, syncDropdown } from '../base/popup';
5
- import { mergeClass } from '../object-renderer/merge-class';
5
+ import { mergeClass } from '../shared/merge-class';
6
6
  import { kitSurfaceRecipe } from '../recipes/surface';
7
+ import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
7
8
 
8
- export type Child =Node | string | null | undefined | false;
9
+ import { FOCUS, FOCUS_INSET } from '../shared/focus-ring';
9
10
 
10
- export const FOCUS = 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
11
- /** 列表项 / 菜单项 / 导航钮的焦点环(R4):1px 内收,不增尺寸、不遮邻项 */
12
- export const FOCUS_INSET = 'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
11
+ export { FOCUS, FOCUS_INSET };
12
+ export type Child =Node | string | null | undefined | false;
13
13
 
14
14
  /** 建元素:h('div', 'class 串', { 属性 }, ...子节点);属性值 true = 空属性,false / undefined 不写;文本一律走文本节点 */
15
15
  export function h(tag: string, cls: string, attrs: Record<string, string | boolean | undefined> = {}, ...kids: Child[]): HTMLElement {
@@ -85,9 +85,10 @@ const DROP_BOX = `${DROP_BASE} end-0 top-full mt-1.5`;
85
85
  export function fitDropdownPanel(panel: HTMLElement): void {
86
86
  syncDropdown(panel, true, DROP_BASE, undefined, 'end');
87
87
  }
88
- const DROP_ITEM = `flex h-9 w-full cursor-pointer items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ${FOCUS_INSET}`;
89
- const DROP_ITEM_DISABLED = 'flex h-9 w-full cursor-not-allowed items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-fg-subtle opacity-60';
90
- const DROP_ITEM_DANGER = `flex h-9 w-full cursor-pointer items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-danger-on-soft transition-colors hover:bg-danger-soft ${FOCUS_INSET}`;
88
+ // 菜单项行高 = 条带阶梯的菜单项行高(strip.menuItemPx,与下拉选项同一行高,AR42)
89
+ const DROP_ITEM = `flex ${KIT_STRIP_MENU_ITEM_CLASS} w-full cursor-pointer items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ${FOCUS_INSET}`;
90
+ const DROP_ITEM_DISABLED = `flex ${KIT_STRIP_MENU_ITEM_CLASS} w-full cursor-not-allowed items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-fg-subtle opacity-60`;
91
+ const DROP_ITEM_DANGER = `flex ${KIT_STRIP_MENU_ITEM_CLASS} w-full cursor-pointer items-center whitespace-nowrap rounded-md px-3 text-start text-sm text-danger-on-soft transition-colors hover:bg-danger-soft ${FOCUS_INSET}`;
91
92
  const DROP_SEP = 'my-1 h-px w-full bg-border-subtle';
92
93
  const DROP_HEADER = 'px-3 pb-1 pt-2 text-xs font-semibold text-fg-subtle';
93
94
  export const DROPDOWN_CLASSES: readonly string[] = classSet(...KIT_DROPDOWN_CLASS_CANDIDATES, DROP_BASE, DROP_BOX, DROP_ITEM, DROP_ITEM_DISABLED, DROP_ITEM_DANGER, DROP_SEP, DROP_HEADER, 'relative');
package/src/data/menu.ts CHANGED
@@ -17,14 +17,18 @@ import { kitText } from '../i18n/kit-text';
17
17
  import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
18
18
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
19
19
  import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
20
+ import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
21
+ import { FOCUS_INSET } from '../shared/focus-ring';
20
22
  import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
21
23
  import { bool, createKitController, joinClass, str } from '../base/shared';
22
- import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../base/icons';
24
+ import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
23
25
  import { classSet, cssEscape, firstChar, h, isRec, textOf, type Rec } from './menu-dom';
24
26
  import { mountKitMegaMenu } from './mega-menu';
25
27
 
26
28
  // ───────── 样式常量:类串与 Tailwind 候选清单 ─────────
27
29
 
30
+ /** 菜单项行高 = 通用条带高度 sizeSpec.strip.menuItemPx(密度无关的 px 条带) */
31
+ const ROW_H = KIT_STRIP_MENU_ITEM_CLASS;
28
32
  const ROOT_CLASS = 'flex flex-col text-sm text-fg';
29
33
  const LIST_CLASS = 'flex flex-col gap-1';
30
34
  const LIST_RAIL_CLASS = 'flex flex-col items-center gap-1';
@@ -39,15 +43,17 @@ export function menuChildInsetUnits(parentHasIcon: boolean): number {
39
43
  }
40
44
  const PAD_TOP = `px-${MENU_INDENT.rowInsetUnits}`;
41
45
  const padChild = (parentHasIcon: boolean): string => `ps-${menuChildInsetUnits(parentHasIcon)} pe-${MENU_INDENT.rowInsetUnits}`;
42
- const ITEM_CLASS = 'flex flex-col gap-1 rounded-md focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
43
- const ITEM_RAIL_CLASS = 'flex w-full flex-col rounded-md focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
44
- const rowClass = (pad: string): string => `flex h-9 cursor-pointer items-center gap-2 rounded-md ${pad} text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
45
- const rowActiveClass = (pad: string): string => `flex h-9 cursor-pointer items-center gap-2 rounded-md bg-primary-soft ${pad} text-sm font-medium text-primary-on-soft`;
46
- const rowDisabledClass = (pad: string): string => `flex h-9 cursor-not-allowed items-center gap-2 rounded-md ${pad} text-sm text-fg-subtle opacity-60`;
46
+ // 侧栏项焦点 = 集合项焦点出口(KT-K0-3:2px 环内收,不被侧栏滚动区裁切)
47
+ const ITEM_CLASS = `flex flex-col gap-1 rounded-md ${FOCUS_INSET}`;
48
+ const ITEM_RAIL_CLASS = `flex w-full flex-col rounded-md ${FOCUS_INSET}`;
49
+ const rowClass = (pad: string): string => `flex ${ROW_H} cursor-pointer items-center gap-2 rounded-md ${pad} text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
50
+ // 选中项也有悬停 / 按下(同一档状态层,取 tonal 版:叠在主色浅底上),底色切换带过渡
51
+ const rowActiveClass = (pad: string): string => `flex ${ROW_H} cursor-pointer items-center gap-2 rounded-md bg-primary-soft ${pad} text-sm font-medium text-primary-on-soft transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`;
52
+ const rowDisabledClass = (pad: string): string => `flex ${ROW_H} cursor-not-allowed items-center gap-2 rounded-md ${pad} text-sm text-fg-disabled`;
47
53
  const PADS: readonly string[] = [PAD_TOP, padChild(true), padChild(false)];
48
- const ROW_RAIL_CLASS = 'flex h-9 w-full cursor-pointer items-center justify-center rounded-md text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg';
49
- const ROW_RAIL_ACTIVE_CLASS = 'flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary-soft text-sm font-medium text-primary-on-soft';
50
- const HEADING_CLASS = 'px-3 pb-1 pt-3 text-xs font-semibold text-fg-subtle';
54
+ const ROW_RAIL_CLASS = `flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-md text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
55
+ const ROW_RAIL_ACTIVE_CLASS = `flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-md bg-primary-soft text-sm font-medium text-primary-on-soft transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`;
56
+ const HEADING_CLASS = 'px-3 pb-1 pt-4 text-xs font-semibold text-fg-subtle';
51
57
  const ICON_CLASS = 'w-5 shrink-0 text-center';
52
58
  /** icon 写 kit 图标名时画 SVG:容器居中,不依赖字符基线 */
53
59
  const ICON_SVG_CLASS = 'flex w-5 shrink-0 items-center justify-center';
@@ -13,6 +13,8 @@ import { createKitController, joinClass, num, str } from '../base/shared';
13
13
  import { kitText } from '../i18n/kit-text';
14
14
  import { classTokens, emptyNode, mk, shapeToneOf, textOf, TONE_SOFT, type Rec, type ShapeTone } from './shape-util';
15
15
  import { singleOf, urlOf } from './display-util';
16
+ import { kitShellRecipe } from '../recipes/container';
17
+ import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
16
18
 
17
19
  export const KIT_MOCKUP_VARIANTS = ['browser', 'phone', 'window', 'code'] as const;
18
20
  export type KitMockupVariant = (typeof KIT_MOCKUP_VARIANTS)[number];
@@ -20,11 +22,13 @@ export type KitMockupVariant = (typeof KIT_MOCKUP_VARIANTS)[number];
20
22
  const KEYS = ['url', 'title', 'text', 'image', 'alt', 'lines'] as const;
21
23
 
22
24
  const ROOT_CLASS = 'm-0 text-fg';
23
- const BROWSER_CLASS = 'flex w-full flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken shadow-sm';
24
- const WINDOW_CLASS = 'flex w-full flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken shadow-sm';
25
- const PHONE_CLASS = 'mx-auto flex w-64 flex-col gap-2 rounded-xl border border-border-subtle bg-surface-sunken p-2 shadow-md ring-2 ring-border-subtle';
26
- const CODE_CLASS = 'flex w-full flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken shadow-sm';
27
- const BAR_CLASS = 'flex items-center gap-3 border-b border-border-subtle px-3 py-2';
25
+ // 示意框(浏览器 / 窗口 / 手机 / 代码)外缘 = 壳配方(容器边 + 容器阴影令牌,KT-B2);标题条只画朝内的一条分隔线(分隔线出口)
26
+ const FRAME = kitShellRecipe({ tone: 'sunken' });
27
+ const BROWSER_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
28
+ const WINDOW_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
29
+ const PHONE_CLASS = `mx-auto flex w-64 flex-col gap-2 ${FRAME} p-2 ring-2 ring-border-subtle`;
30
+ const CODE_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
31
+ const BAR_CLASS = `flex items-center gap-3 ${KIT_DIVIDER_HEAD_CLASS} px-3 py-2`;
28
32
  const DOTS_CLASS = 'flex items-center gap-1.5';
29
33
  const DOT_CLASS = 'size-2.5 rounded-full bg-border';
30
34
  const ADDRESS_CLASS = 'min-w-0 flex-1 truncate rounded-md bg-surface px-3 py-1 text-xs text-fg-muted';
@@ -16,41 +16,25 @@
16
16
  import { classTokens } from './shape-util';
17
17
  import { kitText } from '../i18n/kit-text';
18
18
  import { mountKitOverlay } from './overlay-portal';
19
- import { kitIcon } from '../base/icons';
20
19
  import { trapTab } from '../base/popup';
21
- import { mergeClass } from '../object-renderer/merge-class';
22
- import {
23
- KIT_DIALOG_SURFACE_CLASS, KIT_DRAWER_WIDTHS, KIT_OVERLAY_WIDTH_CLASS, kitDrawerContentRecipe, kitDrawerFocusRecipe, kitDrawerPanelClass, kitOverlayFooterRecipe, kitOverlayHeaderRecipe,
24
- type KitDrawerWidth,
25
- } from '../recipes/overlay';
26
- import { KIT_PART_ATTRIBUTE, KIT_PART_DIALOG, KIT_PART_DRAWER, KIT_PART_TITLE_DIALOG, kitTypographyRecipe } from '../recipes';
20
+ import { kitShellClasses, kitShellDom, type KitShellKind } from '../base/overlay-shell';
21
+ import { KIT_DRAWER_WIDTHS, kitDrawerFocusRecipe, type KitDialogTier, type KitDrawerWidth } from '../recipes/overlay';
27
22
  import { beginKitLeave, type KitLeaveHandle } from '../base/overlay-runtime';
28
23
  import { lockDocumentScroll } from 'soma-core/behavior';
29
24
  import type { OverlayMount } from 'soma-core/behavior';
30
25
 
31
- export type KitModalSize = 'sm' | 'md' | 'lg';
26
+ /** 命令式对话框宽度档:confirm 400(确认 / 提示)、sm 480、md 640、lg 800(与声明式表单窗口的三档同一组数,px 在 kit-limits#overlay) */
27
+ export type KitModalSize = 'confirm' | 'sm' | 'md' | 'lg';
32
28
  export type { KitDrawerWidth };
33
29
 
34
- const LAYER_CLASS = 'fixed inset-0 z-50 bg-scrim motion-safe:animate-kit-fade';
35
- const ROW_CLASS = 'flex h-full items-center justify-center p-4';
36
- const PANEL_BASE = `flex max-h-full w-full flex-col gap-4 ${KIT_DIALOG_SURFACE_CLASS} p-6 focus-visible:outline-none motion-safe:animate-kit-dialog-in`;
37
- // 宽度两档读 design 真源(kit-limits#overlay.dialogPx):sm = 480 默认档,md / lg = 720 长表单档(U1b)
38
- const PANEL_SIZE: Readonly<Record<KitModalSize, string>> = Object.freeze({ sm: KIT_OVERLAY_WIDTH_CLASS.dialog, md: KIT_OVERLAY_WIDTH_CLASS.dialogWide, lg: KIT_OVERLAY_WIDTH_CLASS.dialogWide });
39
- const HEAD_CLASS = 'flex shrink-0 items-center justify-between gap-3';
40
- const TITLE_CLASS = mergeClass(kitTypographyRecipe('dialogTitle'), 'm-0');
41
- const CLOSE_CLASS = 'inline-flex size-8 shrink-0 border-0 bg-transparent p-0 cursor-pointer items-center justify-center rounded-md 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';
42
- const BODY_CLASS = 'flex flex-1 min-h-0 flex-col gap-3 overflow-y-auto text-sm text-fg-muted';
43
- const FOOT_CLASS = 'flex shrink-0 flex-wrap items-center justify-end gap-3';
44
-
45
- // 抽屉:面板类串与页面 DSL 的抽屉外壳同一份(recipes/overlay.ts#kitDrawerPanelClass,宽度三档读 kit-limits#overlay.drawerPx);
46
- // 头 / 体 / 尾取浮层三段式子配方(头 shrink-0 + 下描边、体 flex-1 min-h-0 overflow-y-auto、尾 shrink-0 + 上描边)
47
- const DRAWER_ROW_CLASS = 'flex h-full justify-end';
48
- const DRAWER_FOCUS_CLASS = kitDrawerFocusRecipe();
49
- const DRAWER_BODY_CLASS = kitDrawerContentRecipe();
30
+ const MODAL_TIER: Readonly<Record<KitModalSize, KitDialogTier>> = Object.freeze({ confirm: 'confirm', sm: 'default', md: 'wide', lg: 'xwide' });
31
+ // 面板自己(tabindex -1)获得焦点时不画轮廓,焦点环只给内部可操作元素(对话框与抽屉同一条)
32
+ const PANEL_FOCUS_CLASS = kitDrawerFocusRecipe();
50
33
 
34
+ // 类串全部来自外壳的一份配方(base/overlay-shell):四档居中窗口 + 两档抽屉
51
35
  export const KIT_MODAL_CLASS_CANDIDATES: readonly string[] = classTokens(
52
- LAYER_CLASS, ROW_CLASS, PANEL_BASE, Object.values(PANEL_SIZE), HEAD_CLASS, TITLE_CLASS, CLOSE_CLASS, BODY_CLASS, FOOT_CLASS,
53
- DRAWER_ROW_CLASS, DRAWER_FOCUS_CLASS, KIT_DRAWER_WIDTHS.map((w) => kitDrawerPanelClass(w)), kitOverlayHeaderRecipe(), DRAWER_BODY_CLASS, kitOverlayFooterRecipe(),
36
+ ...(Object.values(MODAL_TIER).map((t) => Object.values(kitShellClasses({ kind: 'dialog', dialogTier: t, panelExtra: PANEL_FOCUS_CLASS })))),
37
+ ...KIT_DRAWER_WIDTHS.map((w) => Object.values(kitShellClasses({ kind: 'drawer', drawerWidth: w, panelExtra: PANEL_FOCUS_CLASS }))),
54
38
  );
55
39
 
56
40
  /** 命令式浮层(对话框 / 抽屉)共用的选项 */
@@ -70,6 +54,8 @@ export interface KitOverlayShellOptions {
70
54
  showClose?: boolean;
71
55
  /** 页脚槽,缺省 true;false 时不画页脚(footer 仍是一个脱离文档的空元素,写进去不显示)。抽屉的页脚在没有任何内容时不占位 */
72
56
  footer?: boolean;
57
+ /** 引导头(确认类窗口):语气图标块 + 标题一列、没有头部条与关闭钮;句柄的 lead 是标题所在的列(说明文字追加到这里) */
58
+ lead?: 'danger' | 'primary';
73
59
  }
74
60
 
75
61
  export interface KitModalOptions extends KitOverlayShellOptions {
@@ -91,6 +77,8 @@ export interface KitModalHandle {
91
77
  scrim: HTMLElement;
92
78
  body: HTMLElement;
93
79
  footer: HTMLElement;
80
+ /** 引导头的文字列(标题所在;没有引导头时是标题的父元素) */
81
+ lead: HTMLElement;
94
82
  open(): void;
95
83
  close(): void;
96
84
  isOpen(): boolean;
@@ -102,12 +90,6 @@ export interface KitModalHandle {
102
90
  /** 抽屉句柄与对话框句柄同形 */
103
91
  export type KitDrawerHandle = KitModalHandle;
104
92
 
105
- function el<K extends keyof HTMLElementTagNameMap>(doc: Document, tag: K, cls: string): HTMLElementTagNameMap[K] {
106
- const node = doc.createElement(tag);
107
- node.className = cls;
108
- return node;
109
- }
110
-
111
93
  /**
112
94
  * 命令式 Promise 对话框的卸载兜底:打开期间层锚点脱离文档(宿主区域被卸载)时调 onGone,调用方据此收口 Promise,await 不会永久挂起。
113
95
  * 返回停止监听的函数(收口时调用)。无 MutationObserver(SSR / 测试环境)时返回空操作。
@@ -119,50 +101,37 @@ export function watchKitModalDetached(layer: HTMLElement, doc: Document, onGone:
119
101
  return () => watch.disconnect();
120
102
  }
121
103
 
122
- /** 两种形态之间的差异:面板几何与分段类串(其余全部共用) */
104
+ /** 两种形态之间的差异只有哪一种窗口与档位(外壳结构、类串、标记全部在 base/overlay-shell,两种形态同一份) */
123
105
  interface ShellVariant {
124
- part: typeof KIT_PART_DIALOG | typeof KIT_PART_DRAWER;
125
- rowClass: string;
126
- panelClass: string;
127
- headClass: string;
128
- bodyClass: string;
129
- footClass: string;
130
- /** 页脚标记属性(测试与度量按它找页脚) */
131
- footAttr: 'data-kit-dialog-footer' | 'data-kit-overlay-footer';
106
+ kind: KitShellKind;
107
+ dialogTier?: KitDialogTier;
108
+ drawerWidth?: KitDrawerWidth;
132
109
  /** 页脚没有任何内容时不占位(抽屉的页脚带上描边与内边距,空着会留一条空栏) */
133
110
  hideEmptyFooter: boolean;
134
111
  }
135
112
 
136
113
  function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions, doc: Document): KitModalHandle {
137
- const panel = el(doc, 'div', variant.panelClass);
138
- panel.setAttribute('role', 'dialog');
139
- panel.setAttribute(KIT_PART_ATTRIBUTE, variant.part);
140
- panel.setAttribute('aria-modal', 'true');
141
- panel.setAttribute('aria-label', opts.title);
114
+ const shell = kitShellDom(doc, {
115
+ kind: variant.kind,
116
+ ...(variant.dialogTier !== undefined ? { dialogTier: variant.dialogTier } : {}),
117
+ ...(variant.drawerWidth !== undefined ? { drawerWidth: variant.drawerWidth } : {}),
118
+ panelExtra: PANEL_FOCUS_CLASS,
119
+ title: opts.title,
120
+ ariaLabel: opts.title,
121
+ close: opts.showClose === false ? null : { label: opts.closeLabel ?? kitText('soma.kit.close', undefined, opts.at) },
122
+ footerHtml: opts.footer === false ? null : '',
123
+ ...(opts.lead !== undefined ? { lead: opts.lead } : {}),
124
+ });
125
+ const { panel, title, body } = shell;
126
+ const closeBtn = shell.closeButton ?? doc.createElement('button');
127
+ // opts.footer === false:页脚仍是脱离文档的空元素,写进去不显示
128
+ const footer = shell.footer ?? doc.createElement('div');
142
129
  panel.tabIndex = -1;
143
- const title = el(doc, 'h2', TITLE_CLASS);
144
- title.setAttribute(KIT_PART_ATTRIBUTE, KIT_PART_TITLE_DIALOG);
145
- title.textContent = opts.title;
146
- const closeBtn = el(doc, 'button', CLOSE_CLASS);
147
- closeBtn.type = 'button';
148
- closeBtn.setAttribute('aria-label', opts.closeLabel ?? kitText('soma.kit.close', undefined, opts.at));
149
- closeBtn.appendChild(kitIcon('close', 'md'));
150
- const head = el(doc, 'div', variant.headClass);
151
- head.appendChild(title);
152
- if (opts.showClose !== false) head.appendChild(closeBtn);
153
- const body = el(doc, 'div', variant.bodyClass);
154
- const footer = el(doc, 'div', variant.footClass);
155
- footer.setAttribute(variant.footAttr, '');
156
- panel.append(head, body);
157
- if (opts.footer !== false) panel.appendChild(footer);
158
- const row = el(doc, 'div', variant.rowClass);
159
- row.appendChild(panel);
160
130
  // 真正的遮罩层 scrim 打开时经浮层挂载点端口挂到 body 下的专用根节点(不被祖先 transform 困住,Esc 由层栈裁决只关栈顶);
161
131
  // layer 只是留在调用方树里的锚点(空、恒 hidden 跟随开合):端口从它取主题作用域,它脱离文档后浮层自动卸载。
162
- const layer = el(doc, 'div', '');
163
- layer.removeAttribute('class');
132
+ const layer = doc.createElement('div');
164
133
  layer.hidden = true;
165
- const scrim = el(doc, 'div', LAYER_CLASS);
134
+ const scrim = shell.scrim;
166
135
  scrim.setAttribute('role', 'presentation');
167
136
  if (opts.at) {
168
137
  const lang = opts.at.closest('[lang]')?.getAttribute('lang');
@@ -170,7 +139,6 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
170
139
  if (lang) scrim.setAttribute('lang', lang);
171
140
  if (dir) scrim.setAttribute('dir', dir);
172
141
  }
173
- scrim.appendChild(row);
174
142
 
175
143
  let opened = false;
176
144
  let prev: Element | null = null;
@@ -207,7 +175,7 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
207
175
  // Esc 不在这里:mountKitOverlay 的 onEscape 走层栈
208
176
  const onKey = (e: KeyboardEvent): void => { trapTab(e, panel); };
209
177
  const onScrim = (e: MouseEvent): void => {
210
- if (opts.dismissOnScrim === true && (e.target === scrim || e.target === row)) opts.onClose();
178
+ if (opts.dismissOnScrim === true && e.target === scrim) opts.onClose();
211
179
  };
212
180
  const onCloseClick = (): void => opts.onClose();
213
181
  scrim.addEventListener('keydown', onKey);
@@ -216,6 +184,7 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
216
184
 
217
185
  return {
218
186
  layer, scrim, body, footer,
187
+ lead: title.parentElement ?? panel,
219
188
  open(): void {
220
189
  if (opened) return;
221
190
  opened = true;
@@ -275,16 +244,7 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
275
244
  }
276
245
 
277
246
  export function mountKitModal(opts: KitModalOptions, doc: Document = document): KitModalHandle {
278
- return mountOverlayShell({
279
- part: KIT_PART_DIALOG,
280
- rowClass: ROW_CLASS,
281
- panelClass: `${PANEL_BASE} ${PANEL_SIZE[opts.size ?? 'md']}`,
282
- headClass: HEAD_CLASS,
283
- bodyClass: BODY_CLASS,
284
- footClass: FOOT_CLASS,
285
- footAttr: 'data-kit-dialog-footer',
286
- hideEmptyFooter: false,
287
- }, opts, doc);
247
+ return mountOverlayShell({ kind: 'dialog', dialogTier: MODAL_TIER[opts.size ?? 'md'], hideEmptyFooter: false }, opts, doc);
288
248
  }
289
249
 
290
250
  /**
@@ -293,14 +253,5 @@ export function mountKitModal(opts: KitModalOptions, doc: Document = document):
293
253
  */
294
254
  export function mountKitDrawer(opts: KitDrawerOptions, doc: Document = document): KitDrawerHandle {
295
255
  const width: KitDrawerWidth = (KIT_DRAWER_WIDTHS as readonly string[]).includes(opts.width ?? 'default') ? (opts.width ?? 'default') : 'default';
296
- return mountOverlayShell({
297
- part: KIT_PART_DRAWER,
298
- rowClass: DRAWER_ROW_CLASS,
299
- panelClass: `${kitDrawerPanelClass(width)} ${DRAWER_FOCUS_CLASS}`,
300
- headClass: kitOverlayHeaderRecipe(),
301
- bodyClass: DRAWER_BODY_CLASS,
302
- footClass: kitOverlayFooterRecipe(),
303
- footAttr: 'data-kit-overlay-footer',
304
- hideEmptyFooter: true,
305
- }, opts, doc);
256
+ return mountOverlayShell({ kind: 'drawer', drawerWidth: width, hideEmptyFooter: true }, opts, doc);
306
257
  }
@@ -12,14 +12,16 @@
12
12
  // 点动作项抛 `action { item }`;下拉面板:↑↓ Home End 走项,Esc 关并回焦触发钮,点外面关。
13
13
 
14
14
  import type { SomaComponentDefinition } from 'soma-core';
15
+ import { KIT_STRIP_CRUMBS_CLASS, KIT_STRIP_NAVBAR_CLASS } from '../recipes/strip';
15
16
  import { kitText } from '../i18n/kit-text';
16
- import { kitIcon } from '../base/icons';
17
+ import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
17
18
  import { bool, createKitController, joinClass } from '../base/shared';
18
19
  import { safeHref } from '../base/link';
19
20
  import { attrEsc } from './d9-util';
20
21
  import { setKitFace } from '../recipes';
21
22
  import { kitTypographyRecipe } from '../recipes/typography';
22
- import { mergeClass } from '../object-renderer/merge-class';
23
+ import { mergeClass } from '../shared/merge-class';
24
+ import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
23
25
  import { activeWithDropdowns, queryWithDropdowns, releaseDropdownsIn } from '../base/popup';
24
26
  import {
25
27
  buildDropdownPanel, fitDropdownPanel, classSet, DROPDOWN_CLASSES, FOCUS, focusFirstItem, h, isRec, onOutsidePointer, recList, textOf,
@@ -27,9 +29,10 @@ import {
27
29
  } from './menu-dom';
28
30
 
29
31
  const ROOT_CONTAINER = '@container';
30
- const ROOT_BASE = 'flex w-full items-center gap-3 bg-surface px-4 text-fg';
31
- const SIZE_CLASS: Record<string, string> = { sm: 'min-h-12', md: 'min-h-14', lg: 'min-h-16' };
32
- const BORDER_CLASS = 'border-b border-border-subtle';
32
+ const ROOT_BASE = 'flex w-full items-center gap-3 bg-surface text-fg';
33
+ // xs = 外壳面包屑行:高 sizeSpec.strip.crumbsPx(密度无关 px 条带),左右边距 = 页面边距(与页签条、页面左缘同线)
34
+ const SIZE_CLASS: Record<string, string> = { xs: `${KIT_STRIP_CRUMBS_CLASS} px-6`, sm: `${KIT_STRIP_NAVBAR_CLASS.sm} px-4`, md: `${KIT_STRIP_NAVBAR_CLASS.md} px-4`, lg: `${KIT_STRIP_NAVBAR_CLASS.lg} px-4` };
35
+ const BORDER_CLASS = KIT_DIVIDER_HEAD_CLASS;
33
36
  const STICKY_CLASS = 'sticky top-0 z-20';
34
37
  const ELEVATED_CLASS = 'shadow-sm';
35
38
  const SLOT_START = 'flex min-w-0 items-center gap-2';
@@ -129,7 +132,8 @@ export function mountKitNavbar(root: HTMLElement, emit: KitNavbarEmit, options:
129
132
  const icon = textOf(item.icon);
130
133
  const badge = textOf(item.badge);
131
134
  const content: Array<Node | string | null> = [
132
- icon !== '' ? h('span', '', { 'aria-hidden': 'true' }, icon) : null,
135
+ // icon 写 kit 图标名画 SVG,其余按短字符原样画
136
+ icon !== '' ? h('span', (KIT_ICON_NAMES as readonly string[]).includes(icon) ? 'inline-flex' : '', { 'aria-hidden': 'true' }, (KIT_ICON_NAMES as readonly string[]).includes(icon) ? kitIcon(icon as KitIconName, 'md') : icon) : null,
133
137
  h('span', '', {}, label),
134
138
  badge !== '' ? h('span', BADGE_CLASS, {}, badge) : null,
135
139
  ];
@@ -275,7 +279,7 @@ export function createNavbar(): SomaComponentDefinition {
275
279
  sticky: { type: 'boolean', default: false, desc: '吸顶' },
276
280
  bordered: { type: 'boolean', default: true, desc: '底部分隔线' },
277
281
  elevated: { type: 'boolean', default: false, desc: '轻阴影' },
278
- size: { type: 'enum', values: ['sm', 'md', 'lg'], default: 'md', desc: '顶栏最小高度档' },
282
+ size: { type: 'enum', values: ['xs', 'sm', 'md', 'lg'], default: 'md', desc: '顶栏高度档(xs = 外壳面包屑行,定高条带;其余是最小高度)' },
279
283
  class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
280
284
  },
281
285
  emits: {
@@ -18,7 +18,7 @@
18
18
  import type { SomaComponentDefinition } from 'soma-core';
19
19
  import { KIT_NOTICE_FOLD as KIT_NOTICE_FOLD_LIMITS } from 'soma-foundation/kit-limits';
20
20
  import { kitText } from '../i18n/kit-text';
21
- import { KIT_ICON_CLASS_CANDIDATES, KIT_ICON_NAMES, kitIcon, type KitIconName } from '../base/icons';
21
+ import { KIT_ICON_CLASS_CANDIDATES, KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
22
22
  import { safeHref } from '../base/link';
23
23
  import { KIT_STATUS_TONE_ICON, KIT_STATUS_TONE_TEXT_KEY, statusToneOrNull } from '../base/status-tone';
24
24
  import {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import type { NotifyAction, NotifyEntry, NotifyRenderer } from 'soma-core';
7
7
  import { KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
8
- import { kitIcon, type KitIconName } from '../base/icons';
8
+ import { kitIcon, type KitIconName } from '../shared/icons';
9
9
  import { kitText } from '../i18n/kit-text';
10
10
  import { beginKitLeave } from '../base/overlay-runtime';
11
11
  import { askKitConfirm, KIT_CONFIRM_CLASS_CANDIDATES } from './confirm-dialog';
@@ -13,20 +13,31 @@ import { KIT_PROMPT_CLASS_CANDIDATES } from './prompt-dialog';
13
13
  import {
14
14
  KIT_PART_ATTRIBUTE,
15
15
  KIT_PART_TOAST,
16
+ KIT_TOAST_TOP_CLASS,
16
17
  kitOverlayRecipe,
17
18
  kitToastActionRecipe,
18
19
  kitToastCloseRecipe,
19
20
  kitToastTitleRecipe,
20
21
  } from '../recipes';
21
22
 
22
- // top-16:落在浮层页头(关闭钮所在行,约 56px)之下,toast 不盖对话框 / 抽屉右上角的关闭钮(U1d)
23
- const CONTAINER_CLASS = 'fixed top-16 end-4 z-50 flex flex-col gap-2';
24
- const ITEM_BASE = kitOverlayRecipe({ kind: 'toast', size: 'md', toned: true });
23
+ // 轻提示(knowledge/Kit主题规则与算法.md KT-K-feedback-2,§6.1 G-10):顶部居中(inset-x-0 + mx-auto + w-max,RTL 无关),
24
+ // 上偏移 = 页边距(KIT_TOAST_TOP_CLASS),单行高 = 页头标题行高:与页头标题行同一条带、落在左侧标题与右侧动作之间的留白里,
25
+ // 不压页头动作,也不压其下的筛选条(上一段上偏移 64px,正落在筛选条上)。居中且宽 ≤ toastPx,到不了抽屉 / 对话框右上角的关闭钮(U1d)。
26
+ // 外观 = 浮层面(白底、浮层阴影)+ 语义图标,正文正文墨;语气只由图标色承担
27
+ const CONTAINER_CLASS = `fixed inset-x-0 ${KIT_TOAST_TOP_CLASS} z-50 mx-auto flex w-max max-w-full flex-col items-center gap-2`;
28
+ const ITEM_BASE = kitOverlayRecipe({ kind: 'toast', size: 'md' });
25
29
  const LEVEL_CLASS: Readonly<Record<NotifyEntry['level'], string>> = {
26
- info: 'bg-info-soft text-info-on-soft',
27
- success: 'bg-success-soft text-success-on-soft',
28
- warning: 'bg-warning-soft text-warning-on-soft',
29
- error: 'bg-danger-soft text-danger-on-soft',
30
+ info: 'text-fg',
31
+ success: 'text-fg',
32
+ warning: 'text-fg',
33
+ error: 'text-fg',
34
+ };
35
+ /** 语义图标色(彩色只用 -on-soft,KT-C1):语气只由图标承担 */
36
+ const LEVEL_ICON_CLASS: Readonly<Record<NotifyEntry['level'], string>> = {
37
+ info: 'text-info-on-soft',
38
+ success: 'text-success-on-soft',
39
+ warning: 'text-warning-on-soft',
40
+ error: 'text-danger-on-soft',
30
41
  };
31
42
  const TITLE_CLASS = kitToastTitleRecipe();
32
43
  const ACTION_CLASS = kitToastActionRecipe();
@@ -49,7 +60,7 @@ const MIN_RESUME_BUFFER_MS = 1000;
49
60
  /** 通知用到的全部 Tailwind 类(供样式候选并入) */
50
61
  export const KIT_NOTIFY_CLASS_CANDIDATES: readonly string[] = [
51
62
  ...new Set(
52
- [CONTAINER_CLASS, ITEM_BASE, TITLE_CLASS, ACTION_CLASS, CLOSE_CLASS, BODY_CLASS, ICON_CLASS, COUNT_CLASS, ...Object.values(LEVEL_CLASS)].flatMap((s) => s.split(' ')).filter((c) => c !== ''),
63
+ [CONTAINER_CLASS, ITEM_BASE, TITLE_CLASS, ACTION_CLASS, CLOSE_CLASS, BODY_CLASS, ICON_CLASS, COUNT_CLASS, ...Object.values(LEVEL_CLASS), ...Object.values(LEVEL_ICON_CLASS)].flatMap((s) => s.split(' ')).filter((c) => c !== ''),
53
64
  ),
54
65
  // 确认 / 提示对话框(自绘,模态壳 + 按钮)的类并入:通知端口的 confirm / alert 每页都可能被调用
55
66
  ...KIT_CONFIRM_CLASS_CANDIDATES,
@@ -120,7 +131,7 @@ export function createKitNotifyRenderer(): NotifyRenderer {
120
131
  let count = 1;
121
132
  let countEl: HTMLElement | undefined;
122
133
  let restart: (() => void) | undefined;
123
- item.append(kitIcon(LEVEL_ICON[level] ?? 'info', 'md', ICON_CLASS), body);
134
+ item.append(kitIcon(LEVEL_ICON[level] ?? 'info', 'md', `${ICON_CLASS} ${LEVEL_ICON_CLASS[level] ?? LEVEL_ICON_CLASS.info}`), body);
124
135
 
125
136
  let timer: ReturnType<typeof setTimeout> | undefined;
126
137
  let dismissed = false;