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
@@ -18,14 +18,15 @@ import {
18
18
  KIT_POPUP_PLACE_CLASS_CANDIDATES, POPUP_TIP_BASE, POPUP_TIP_HIDDEN_CLASS, POPUP_TIP_PREF, POPUP_TIP_SHOWN_CLASS,
19
19
  popupTipClass, showPopupFitted,
20
20
  } from './popup';
21
- import { classCandidates } from './class-candidates';
21
+ import { classCandidates } from '../shared/class-candidates';
22
+ import type { KitSize } from '../shared/primitives-types';
22
23
  import { leaveAnchored, unmarkAnchored } from './anchored-layer';
23
24
  import type { KitLeaveHandle } from './overlay-runtime';
24
25
  import { withKitViewTransition } from './view-transition';
25
26
  import { kitBusyOf, onKitActionBusy } from './action-busy';
26
27
  import { deniedBy, registerLivePermissionGate } from './permission-gate';
27
28
  import { kitText } from '../i18n/kit-text';
28
- import { mergeClass } from '../object-renderer/merge-class';
29
+ import { mergeClass } from '../shared/merge-class';
29
30
  import {
30
31
  KIT_PART_ATTRIBUTE,
31
32
  KIT_PART_BADGE,
@@ -38,7 +39,7 @@ import {
38
39
 
39
40
  // ── 尺寸档 ────────────────────────────────────────────────────
40
41
 
41
- export type KitSize = 'sm' | 'md' | 'lg';
42
+ export type { KitSize };
42
43
  export const KIT_SIZES: readonly KitSize[] = ['sm', 'md', 'lg'];
43
44
 
44
45
  export function sizeOf(raw: unknown): KitSize {
@@ -113,6 +114,8 @@ export interface KitOption {
113
114
  icon?: string;
114
115
  /** Radio / Checkbox 读:纯图标选项的可访问名(缺省取 value) */
115
116
  aria_label?: string;
117
+ /** Radio segmented 读:选项尾部的计数(来自列表响应 facets;没给不显示) */
118
+ count?: number;
116
119
  }
117
120
 
118
121
  const warnedDuplicates = new Set<string>();
@@ -166,6 +169,7 @@ export function optionsOf(raw: unknown): KitOption[] {
166
169
  ...(tone ? { tone } : {}),
167
170
  ...(unknownTone ? { unknown: true } : {}),
168
171
  ...(rec.disabled === true ? { disabled: true } : {}),
172
+ ...(typeof rec.count === 'number' && Number.isInteger(rec.count) && rec.count >= 0 ? { count: rec.count } : {}),
169
173
  });
170
174
  }
171
175
  return out;
@@ -177,7 +181,7 @@ export function sameValue(a: unknown, b: unknown): boolean {
177
181
  }
178
182
 
179
183
  export function optionsKey(options: readonly KitOption[]): string {
180
- return JSON.stringify(options.map((o) => [String(o.value), o.label, o.disabled === true, o.icon ?? '', o.aria_label ?? '']));
184
+ return JSON.stringify(options.map((o) => [String(o.value), o.label, o.disabled === true, o.icon ?? '', o.aria_label ?? '', o.count ?? -1]));
181
185
  }
182
186
 
183
187
  export function toneOf(raw: unknown, fallback: KitTone): KitTone;
@@ -279,13 +283,42 @@ export function findRoot(host: HTMLElement): HTMLElement {
279
283
  }
280
284
 
281
285
  /**
282
- * 整块不渲染:收起组件根;根在没有标题的看板面板里(`data-kit-board-panel="bare"`)时,面板壳一并收起 / 恢复,不留空白圆角条。
286
+ * 整块不渲染:收起组件根;根在没有标题的看板面板里(`data-kit-board-panel="bare"`)时,面板壳在「面板里没有别的可见组件」时一并收起 / 恢复,不留空白圆角条。
287
+ * 面板里还有别的非空组件(如被并进同一面板的门控卡)时只收起自己的根,面板与其它组件不动。
283
288
  * 带标题的面板壳不动(标题行仍在,空态由组件自己画)。
284
289
  */
285
290
  export function kitCollapseBlock(root: HTMLElement, collapsed: boolean): void {
286
291
  root.hidden = collapsed;
287
292
  const panel = root.closest<HTMLElement>('[data-kit-board-panel="bare"]');
288
- if (panel !== null) panel.hidden = collapsed;
293
+ if (panel === null) return;
294
+ panel.hidden = collapsed && !panelHasOtherVisible(panel, root);
295
+ }
296
+
297
+ /**
298
+ * 概况条的统计一侧整体为空时给概况条标 `data-kit-hero-solo`(统计块与细线随之收起、结论占满整行,样式在多块看板壳的类串里);统计块自报空 / 非空后调用。
299
+ * 统计一侧 = 概况条里 `data-kit-hero-stats` 列内的全部组件宿主,全部带 data-kit-summary-empty 才算整体为空。
300
+ */
301
+ export function kitSyncHeroSolo(host: HTMLElement): void {
302
+ const hero = host.closest<HTMLElement>('[data-kit-slot="hero"]');
303
+ const col = hero?.querySelector<HTMLElement>('[data-kit-hero-stats]') ?? null;
304
+ if (hero === null || col === null) return;
305
+ const members = Array.from(col.querySelectorAll<HTMLElement>('[data-soma-component]'));
306
+ const empty = members.length > 0 && members.every((m) => m.hasAttribute('data-kit-summary-empty'));
307
+ if (empty) hero.setAttribute('data-kit-hero-solo', '');
308
+ else hero.removeAttribute('data-kit-hero-solo');
309
+ }
310
+
311
+ /** 面板里除 root 所在组件外,是否还有可见(根未收起)的组件宿主 */
312
+ function panelHasOtherVisible(panel: HTMLElement, root: HTMLElement): boolean {
313
+ for (const host of Array.from(panel.querySelectorAll<HTMLElement>('[data-soma-component]'))) {
314
+ if (host.contains(root) || root.contains(host)) continue;
315
+ const own = host.querySelector<HTMLElement>('[data-soma-scoped-id="root"]');
316
+ if (own === null && host.children.length === 0) continue;
317
+ let shown = own === null || !own.hidden;
318
+ for (let e: HTMLElement | null = host; shown && e !== null && e !== panel; e = e.parentElement) if (e.hidden) shown = false;
319
+ if (shown) return true;
320
+ }
321
+ return false;
289
322
  }
290
323
 
291
324
  export function setBoolAttr(el: Element, name: string, on: boolean): void {
@@ -923,7 +956,7 @@ export function wireKitTablist(root: HTMLElement, opts: KitTablistOptions = {}):
923
956
 
924
957
  // ── 类候选小工具(K9 / D1:补齐波基础组件共用)────────────────
925
958
 
926
- export { classCandidates } from './class-candidates';
959
+ export { classCandidates } from '../shared/class-candidates';
927
960
 
928
961
  // ── 通用 tooltip(按钮类基础组件的可选 prop)─────────────────
929
962
  // 提示气泡是目标元素内的一个 role=tooltip 子元素(绝对定位,目标补 `relative`):hover / focus 显示,Esc 与移开隐藏,
@@ -1002,6 +1035,9 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
1002
1035
  const s = stateOf(root);
1003
1036
  const show = (): void => {
1004
1037
  if (s.tip === null) return;
1038
+ // 禁用的按钮不挂提示气泡(knowledge/Kit主题规则与算法.md KT-K0-4 第 3 条,2026-11-25 裁决);为什么不可用由带原因的置灰(disabled_reason)另给
1039
+ const bound = s.bound;
1040
+ if (bound !== null && (bound.hasAttribute('disabled') || bound.getAttribute('aria-disabled') === 'true')) return;
1005
1041
  s.shown = true;
1006
1042
  paintTip(s);
1007
1043
  };
@@ -3,7 +3,7 @@
3
3
  // 双编码:每个语气有图标(kit 图标名,SVG)+ 读屏文字,不靠颜色、不用符号字符。
4
4
 
5
5
  import type { KitStatusTone } from '../recipes/status';
6
- import type { KitIconName } from './icons';
6
+ import type { KitIconName } from '../shared/icons';
7
7
 
8
8
  export const KIT_STATUS_TONES: readonly KitStatusTone[] = Object.freeze(['neutral', 'info', 'success', 'warning', 'danger']);
9
9
 
@@ -9,8 +9,9 @@
9
9
  import type { SomaComponentDefinition } from 'soma-core';
10
10
  import type { CollectionItem } from 'soma-core/keyboard';
11
11
  import { kitKey, kitText } from '../i18n/kit-text';
12
- import { kitIcon } from './icons';
12
+ import { kitIcon } from '../shared/icons';
13
13
  import { setKitFace } from '../recipes';
14
+ import { kitControlEdgeRecipe } from '../recipes/control';
14
15
  import {
15
16
  CLASS_PROP, FIELD_INVALID_CLASS, ID_PROPS, INVALID_PROPS, OPTIONS_PROP, SIZE_PROP,
16
17
  applyCommon, applyDisabled, bool, createKitController, joinClass, nextUid, num, optionsOf, sameValue, setAttr, setBoolAttr, sizeOf, str, withInvalid,
@@ -24,17 +25,21 @@ import {
24
25
 
25
26
  // ---- Tailwind 类常量与候选类清单 ----
26
27
 
28
+ // 外壳的边只取控件轮廓出口(KT-B1 / §4 C6)
29
+ const EDGE = kitControlEdgeRecipe({ wrapper: true });
30
+ const EDGE_STILL = kitControlEdgeRecipe({ wrapper: true, hover: false });
27
31
  const ROOT_CLASS: Record<KitSize, string> = {
28
- sm: 'relative flex min-h-6 w-full flex-wrap items-center gap-1 rounded-md border border-input bg-surface px-2 py-0.5 text-sm text-fg transition-colors hover:border-input-hover focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
29
- md: 'relative flex min-h-8 w-full flex-wrap items-center gap-1 rounded-md border border-input bg-surface px-2 py-0.5 text-sm text-fg transition-colors hover:border-input-hover focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
30
- lg: 'relative flex min-h-10 w-full flex-wrap items-center gap-2 rounded-md border border-input bg-surface px-3 py-1 text-base text-fg transition-colors hover:border-input-hover focus-within:border-primary focus-within:ring-2 focus-within:ring-ring',
32
+ sm: `relative flex min-h-6 w-full flex-wrap items-center gap-1 rounded-md ${EDGE} bg-surface px-2 py-0.5 text-sm text-fg transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
33
+ md: `relative flex min-h-8 w-full flex-wrap items-center gap-1 rounded-md ${EDGE} bg-surface px-2 py-0.5 text-sm text-fg transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
34
+ lg: `relative flex min-h-10 w-full flex-wrap items-center gap-2 rounded-md ${EDGE} bg-surface px-3 py-1 text-base text-fg transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring`,
31
35
  };
32
36
  const ROOT_DISABLED_CLASS: Record<KitSize, string> = {
33
- sm: 'relative flex min-h-6 w-full cursor-not-allowed flex-wrap items-center gap-1 rounded-md border border-input bg-surface-sunken px-2 py-0.5 text-sm text-fg-subtle opacity-60',
34
- md: 'relative flex min-h-8 w-full cursor-not-allowed flex-wrap items-center gap-1 rounded-md border border-input bg-surface-sunken px-2 py-0.5 text-sm text-fg-subtle opacity-60',
35
- lg: 'relative flex min-h-10 w-full cursor-not-allowed flex-wrap items-center gap-2 rounded-md border border-input bg-surface-sunken px-3 py-1 text-base text-fg-subtle opacity-60',
37
+ sm: `relative flex min-h-6 w-full cursor-not-allowed flex-wrap items-center gap-1 rounded-md ${EDGE_STILL} bg-surface-sunken px-2 py-0.5 text-sm text-fg-subtle opacity-60`,
38
+ md: `relative flex min-h-8 w-full cursor-not-allowed flex-wrap items-center gap-1 rounded-md ${EDGE_STILL} bg-surface-sunken px-2 py-0.5 text-sm text-fg-subtle opacity-60`,
39
+ lg: `relative flex min-h-10 w-full cursor-not-allowed flex-wrap items-center gap-2 rounded-md ${EDGE_STILL} bg-surface-sunken px-3 py-1 text-base text-fg-subtle opacity-60`,
36
40
  };
37
- const TOKEN_CLASS = 'inline-flex items-center gap-1 rounded-md border border-border-subtle bg-surface-sunken px-2 py-0 text-sm font-medium text-fg-muted';
41
+ // 标签芯片:浅底、无描边(控件里不套第二圈线,与多选框芯片同一形体)
42
+ const TOKEN_CLASS = 'inline-flex items-center gap-1 rounded-md bg-surface-sunken px-2 py-0 text-sm font-medium text-fg-muted';
38
43
  const REMOVE_CLASS = 'inline-flex min-h-5 min-w-5 cursor-pointer items-center justify-center rounded-md px-0.5 text-fg-subtle transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
39
44
  const INPUT_CLASS = 'min-w-24 flex-1 appearance-none autofill-clear bg-surface px-1 py-0 text-fg placeholder:text-fg-subtle focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-surface-sunken';
40
45
 
package/src/base/tag.ts CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  import type { SomaComponentDefinition } from 'soma-core';
5
5
  import { kitLocaleAt, kitText } from '../i18n/kit-text';
6
- import { KIT_ICON_NAMES, kitIcon, type KitIconName } from './icons';
6
+ import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
7
7
  import { setKitFace } from '../recipes';
8
8
  import {
9
9
  KIT_TAG_UNKNOWN_DOT, KIT_TAG_UNKNOWN_DOT_CORE, KIT_TAG_UNKNOWN_OUTLINE, KIT_TAG_UNKNOWN_SOFT, KIT_TAG_UNKNOWN_CLASS_CANDIDATES,
@@ -17,30 +17,22 @@ import {
17
17
  /** 空值占位(静默灰字,无底无边无内边距) */
18
18
  const EMPTY_PLACEHOLDER_CLASS = 'text-fg-subtle';
19
19
 
20
- // 档位 × 语气,每格一整串字面量
20
+ // 标签形体(knowledge/Kit主题规则与算法.md KT-K-tag-1;类型 / 分类 / 标识,不承载状态):浅底深字、无描边、小圆角(rounded-sm)、
21
+ // 高 20–24(text-xs 行高 + py-0.5)、字号 12、字重 400;只有一种尺寸(sm / md 只差左右内边距,lg 并入 md)。状态不用它(状态 = 圆点 + 文字,见 variant: dot)
22
+ const TAG_TONES: Record<KitTone, string> = {
23
+ neutral: 'bg-surface-sunken text-fg-muted',
24
+ info: 'bg-info-soft text-info-on-soft',
25
+ success: 'bg-success-soft text-success-on-soft',
26
+ warning: 'bg-warning-soft text-warning-on-soft',
27
+ danger: 'bg-danger-soft text-danger-on-soft',
28
+ };
29
+ const tagRow = (padX: string): Record<KitTone, string> => Object.fromEntries(
30
+ (Object.keys(TAG_TONES) as KitTone[]).map((t) => [t, `inline-flex items-center rounded-sm ${TAG_TONES[t]} ${padX} py-0.5 text-xs font-normal`]),
31
+ ) as Record<KitTone, string>;
21
32
  export const TAG_CLASS: Record<KitSize, Record<KitTone, string>> = {
22
- sm: {
23
- neutral: 'inline-flex items-center rounded-full bg-surface-sunken px-1.5 py-0.5 text-xs font-medium text-fg-muted',
24
- info: 'inline-flex items-center rounded-full bg-info-soft px-1.5 py-0.5 text-xs font-medium text-info-on-soft',
25
- success: 'inline-flex items-center rounded-full bg-success-soft px-1.5 py-0.5 text-xs font-medium text-success-on-soft',
26
- warning: 'inline-flex items-center rounded-full bg-warning-soft px-1.5 py-0.5 text-xs font-medium text-warning-on-soft',
27
- danger: 'inline-flex items-center rounded-full bg-danger-soft px-1.5 py-0.5 text-xs font-medium text-danger-on-soft',
28
- },
29
- // md 档:状态徽标(emphasis.status = pill)12 / 中等字重,与 sm 同字号、横向内边距大一档
30
- md: {
31
- neutral: 'inline-flex items-center rounded-full bg-surface-sunken px-2 py-0.5 text-xs font-medium text-fg-muted',
32
- info: 'inline-flex items-center rounded-full bg-info-soft px-2 py-0.5 text-xs font-medium text-info-on-soft',
33
- success: 'inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success-on-soft',
34
- warning: 'inline-flex items-center rounded-full bg-warning-soft px-2 py-0.5 text-xs font-medium text-warning-on-soft',
35
- danger: 'inline-flex items-center rounded-full bg-danger-soft px-2 py-0.5 text-xs font-medium text-danger-on-soft',
36
- },
37
- lg: {
38
- neutral: 'inline-flex items-center rounded-full bg-surface-sunken px-2.5 py-1 text-base font-medium text-fg-muted',
39
- info: 'inline-flex items-center rounded-full bg-info-soft px-2.5 py-1 text-base font-medium text-info-on-soft',
40
- success: 'inline-flex items-center rounded-full bg-success-soft px-2.5 py-1 text-base font-medium text-success-on-soft',
41
- warning: 'inline-flex items-center rounded-full bg-warning-soft px-2.5 py-1 text-base font-medium text-warning-on-soft',
42
- danger: 'inline-flex items-center rounded-full bg-danger-soft px-2.5 py-1 text-base font-medium text-danger-on-soft',
43
- },
33
+ sm: tagRow('px-1.5'),
34
+ md: tagRow('px-2'),
35
+ lg: tagRow('px-2'),
44
36
  };
45
37
 
46
38
  // 状态点:每个语气一整串字面量(实心语义色;neutral 用淡字色,闲置态不用 warning / danger 由调用方选 tone)
@@ -53,25 +45,34 @@ const DOT_CLASS: Record<KitTone, string> = {
53
45
  danger: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-danger',
54
46
  };
55
47
 
56
- // variant: dot(状态点 + 文字,无底色无边框);pulse 时点外扩一圈(motion-safe)
57
- const DOT_ROOT: Record<KitSize, string> = {
58
- sm: 'inline-flex items-center gap-1.5 text-xs text-fg',
59
- md: 'inline-flex items-center gap-2 text-sm text-fg',
60
- lg: 'inline-flex items-center gap-2 text-base text-fg',
48
+ // variant: dot = 状态形体:圆点 + 文字,没有容器;文字取语义色(on-soft 角色),常态(neutral)用中性灰;pulse 时点外扩一圈(motion-safe)
49
+ export const DOT_ROOT: Record<KitSize, string> = {
50
+ // 常规字重(风格档案 SPACE_MATERIAL:状态文字不加粗,圆点承担语义色的重量)
51
+ sm: 'inline-flex items-center gap-1.5 text-xs',
52
+ md: 'inline-flex items-center gap-1.5 text-sm',
53
+ lg: 'inline-flex items-center gap-2 text-base',
54
+ };
55
+ export const DOT_TEXT: Record<KitTone, string> = {
56
+ neutral: 'text-fg-muted',
57
+ info: 'text-info-on-soft',
58
+ success: 'text-success-on-soft',
59
+ warning: 'text-warning-on-soft',
60
+ danger: 'text-danger-on-soft',
61
61
  };
62
- const DOT_WRAP: Record<KitSize, string> = {
62
+ // 状态圆点只有一种尺寸 6px(KT-K-status-1:不随控件档变;表格 / 列表 / 卡片头同一个点)
63
+ export const DOT_WRAP: Record<KitSize, string> = {
63
64
  sm: 'relative inline-flex h-1.5 w-1.5 shrink-0',
64
- md: 'relative inline-flex h-2 w-2 shrink-0',
65
- lg: 'relative inline-flex h-2.5 w-2.5 shrink-0',
65
+ md: 'relative inline-flex h-1.5 w-1.5 shrink-0',
66
+ lg: 'relative inline-flex h-1.5 w-1.5 shrink-0',
66
67
  };
67
- const DOT_CORE: Record<KitTone, string> = {
68
+ export const DOT_CORE: Record<KitTone, string> = {
68
69
  neutral: 'relative inline-flex h-full w-full rounded-full bg-fg-subtle',
69
70
  info: 'relative inline-flex h-full w-full rounded-full bg-info',
70
71
  success: 'relative inline-flex h-full w-full rounded-full bg-success',
71
72
  warning: 'relative inline-flex h-full w-full rounded-full bg-warning',
72
73
  danger: 'relative inline-flex h-full w-full rounded-full bg-danger',
73
74
  };
74
- const DOT_RING: Record<KitTone, string> = {
75
+ export const DOT_RING: Record<KitTone, string> = {
75
76
  neutral: 'absolute inset-0 rounded-full bg-fg-subtle opacity-60 motion-safe:animate-kit-ping',
76
77
  info: 'absolute inset-0 rounded-full bg-info opacity-60 motion-safe:animate-kit-ping',
77
78
  success: 'absolute inset-0 rounded-full bg-success opacity-60 motion-safe:animate-kit-ping',
@@ -79,25 +80,20 @@ const DOT_RING: Record<KitTone, string> = {
79
80
  danger: 'absolute inset-0 rounded-full bg-danger opacity-60 motion-safe:animate-kit-ping',
80
81
  };
81
82
 
82
- // variant: outline / solid:尺寸壳与色彩分开给(互不含对方的属性,不会同类冲突)
83
+ // variant: outline / solid:尺寸壳与色彩分开给(互不含对方的属性,不会同类冲突)。
84
+ // 标签只有一种形体(KT-K-tag-1:小圆角、无描边;胶囊留给页头的对象总状态,状态与标签永不同形):outline 呈现同浅底(不再画描边),solid 是实心底,二者都是小圆角
83
85
  const SHAPE_CLASS: Record<KitSize, string> = {
84
- sm: 'inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs font-medium',
85
- md: 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-sm font-medium',
86
- lg: 'inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-base font-medium',
87
- };
88
- const OUTLINE_CLASS: Record<KitTone, string> = {
89
- neutral: 'border border-border bg-transparent text-fg-muted',
90
- info: 'border border-info-on-soft/40 bg-transparent text-info-on-soft',
91
- success: 'border border-success-on-soft/40 bg-transparent text-success-on-soft',
92
- warning: 'border border-warning-on-soft/40 bg-transparent text-warning-on-soft',
93
- danger: 'border border-danger-on-soft/40 bg-transparent text-danger-on-soft',
86
+ sm: 'inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-normal',
87
+ md: 'inline-flex items-center gap-1 rounded-sm px-2 py-0.5 text-xs font-normal',
88
+ lg: 'inline-flex items-center gap-1 rounded-sm px-2 py-0.5 text-xs font-normal',
94
89
  };
90
+ const OUTLINE_CLASS: Record<KitTone, string> = TAG_TONES;
95
91
  const SOLID_CLASS: Record<KitTone, string> = {
96
- neutral: 'border border-transparent bg-fg text-surface',
97
- info: 'border border-transparent bg-info text-info-fg',
98
- success: 'border border-transparent bg-success text-success-fg',
99
- warning: 'border border-transparent bg-warning text-warning-fg',
100
- danger: 'border border-transparent bg-danger text-danger-fg',
92
+ neutral: 'bg-fg text-surface',
93
+ info: 'bg-info text-info-fg',
94
+ success: 'bg-success text-success-fg',
95
+ warning: 'bg-warning text-warning-fg',
96
+ danger: 'bg-danger text-danger-fg',
101
97
  };
102
98
  // 可点击:整枚标签是一个按钮(内层 span),悬停淡出、焦点环
103
99
  const CLICK_CLASS = 'inline-flex cursor-pointer items-center gap-1.5 rounded-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
@@ -109,7 +105,7 @@ const SOFT_GAP_CLASS = 'gap-1.5';
109
105
  export const KIT_TAG_CLASS_CANDIDATES: readonly string[] = Object.freeze([
110
106
  ...new Set([
111
107
  ...Object.values(DOT_CLASS).join(' ').split(' '),
112
- ...[Object.values(DOT_ROOT), Object.values(DOT_WRAP), Object.values(DOT_CORE), Object.values(DOT_RING)].flat().join(' ').split(' '),
108
+ ...[Object.values(DOT_ROOT), Object.values(DOT_TEXT), Object.values(DOT_WRAP), Object.values(DOT_CORE), Object.values(DOT_RING)].flat().join(' ').split(' '),
113
109
  ...classCandidates(
114
110
  Object.values(SHAPE_CLASS), Object.values(OUTLINE_CLASS), Object.values(SOLID_CLASS), CLICK_CLASS, REMOVE_CLASS, ICON_CLASS, SOFT_GAP_CLASS, EMPTY_PLACEHOLDER_CLASS,
115
111
  KIT_BADGE_CLASS_CANDIDATES, KIT_TAG_UNKNOWN_CLASS_CANDIDATES,
@@ -157,7 +153,7 @@ export function createTag(): SomaComponentDefinition {
157
153
  click: { payload: { value: { type: 'string' } }, desc: 'clickable 时点击或 Enter / Space' },
158
154
  },
159
155
  },
160
- templateHtml: '<span data-soma-id="root" class="inline-flex items-center rounded-full bg-surface-sunken px-2 py-0.5 text-sm font-medium text-fg-muted"></span>',
156
+ templateHtml: `<span data-soma-id="root" class="${TAG_CLASS.md.neutral}"></span>`,
161
157
  controllerFactory: createKitController(() => withTooltip({
162
158
  attach(root, api) {
163
159
  const valueOf = (): unknown => api.props().value;
@@ -208,10 +204,8 @@ export function createTag(): SomaComponentDefinition {
208
204
  root.textContent = shown.text;
209
205
  return;
210
206
  }
211
- // 状态呈现全应用一种:`variant: dot` 带文字且不脉冲时就是状态徽标(浅底 + on-soft 字 + 圆点);
212
- // 只有脉冲(实时指示)或无文字的纯点才保留圆点形态
213
- const dotAsPill = p.variant === 'dot' && !bool(p.pulse) && text !== '';
214
- if (p.variant === 'dot' && !dotAsPill) {
207
+ // 状态呈现全应用一种:圆点 + 文字、没有容器(与按钮、标签三种形体一眼可分);文字取语义色,常态用中性灰
208
+ if (p.variant === 'dot') {
215
209
  const size = sizeOf(p.size);
216
210
  const wrap = document.createElement('span');
217
211
  wrap.setAttribute('aria-hidden', 'true');
@@ -227,10 +221,10 @@ export function createTag(): SomaComponentDefinition {
227
221
  root.appendChild(wrap);
228
222
  if (text !== '') root.appendChild(document.createTextNode(text));
229
223
  setKitFace(root, null);
230
- root.className = joinClass(DOT_ROOT[size], p.class);
224
+ root.className = joinClass(`${DOT_ROOT[size]} ${unknownTone ? 'text-fg-muted' : DOT_TEXT[tone]}`, p.class);
231
225
  return;
232
226
  }
233
- const variant = dotAsPill ? 'soft' : variantOf(p.variant);
227
+ const variant = variantOf(p.variant);
234
228
  const size = sizeOf(p.size);
235
229
  const clickable = bool(p.clickable);
236
230
  const removable = bool(p.removable);
@@ -245,7 +239,7 @@ export function createTag(): SomaComponentDefinition {
245
239
  body.setAttribute('data-kit-tag-click', '');
246
240
  root.appendChild(body);
247
241
  }
248
- if ((bool(p.dot) || dotAsPill) && variant !== 'solid') {
242
+ if (bool(p.dot) && variant !== 'solid') {
249
243
  const dot = document.createElement('span');
250
244
  dot.setAttribute('aria-hidden', 'true');
251
245
  dot.className = unknownTone ? KIT_TAG_UNKNOWN_DOT : DOT_CLASS[tone];
package/src/base/text.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  // (不带文本,避免凭据类文本再次上行);文字为空时不出钮。
5
5
 
6
6
  import type { SomaComponentDefinition } from 'soma-core';
7
- import { TAG_CLASS } from './tag';
8
- import { formatDateRangeValue, formatMoneyValue, formatPercentValue } from '../object-renderer/field-value';
7
+ import { DOT_CORE, DOT_ROOT, DOT_TEXT, DOT_WRAP } from './tag';
8
+ import { formatDateRangeValue, formatMoneyValue, formatPercentValue } from '../shared/field-value-format';
9
9
  import { kitLocaleAt, kitText } from '../i18n/kit-text';
10
10
  import { KIT_TIPS_SCOPE_ATTR } from './hint-tips';
11
11
  import {
@@ -24,6 +24,12 @@ const TEXT_CLASS: Record<KitSize, string> = {
24
24
  md: `${TEXT_SIZE_CLASS.md} text-fg`,
25
25
  lg: `${TEXT_SIZE_CLASS.lg} text-fg`,
26
26
  };
27
+ // 空值占位(「—」)弱化墨:看起来不像一个值(KT-K-desc-2 / KT-K-stat-3 同一占位)
28
+ const TEXT_EMPTY_CLASS: Record<KitSize, string> = {
29
+ sm: `${TEXT_SIZE_CLASS.sm} text-fg-subtle`,
30
+ md: `${TEXT_SIZE_CLASS.md} text-fg-subtle`,
31
+ lg: `${TEXT_SIZE_CLASS.lg} text-fg-subtle`,
32
+ };
27
33
  // 语气纯文字着色(tone_as: text):只换字色,无底无描边;neutral 用次要字色,其余取 -on-soft 配对字色
28
34
  export const TONE_AS_TEXT = 'text' as const;
29
35
  const TONE_TEXT_COLOR: Record<KitTone, string> = {
@@ -40,15 +46,16 @@ const TONE_TEXT_CLASS: Record<KitSize, Record<KitTone, string>> = {
40
46
  md: { neutral: toneTextClass('md', 'neutral'), info: toneTextClass('md', 'info'), success: toneTextClass('md', 'success'), warning: toneTextClass('md', 'warning'), danger: toneTextClass('md', 'danger') },
41
47
  lg: { neutral: toneTextClass('lg', 'neutral'), info: toneTextClass('lg', 'info'), success: toneTextClass('lg', 'success'), warning: toneTextClass('lg', 'warning'), danger: toneTextClass('lg', 'danger') },
42
48
  };
43
- // copyable 时根元素变成一行:文字 + 复制钮(whitespace-nowrap:值与复制钮是同一个不折行的行内组,宽松密度 / 窄格里也不会把钮挤到下一行)
49
+ // copyable 时根元素变成一行:文字 + 复制钮(max-w-full min-w-0 配合内层 truncate:长文本省略,复制按钮 shrink-0 永不被裁)
44
50
  const COPY_ROOT_CLASS: Record<KitSize, string> = {
45
- sm: 'inline-flex items-center gap-2 whitespace-nowrap text-sm text-fg',
46
- md: 'inline-flex items-center gap-2 whitespace-nowrap text-base text-fg',
47
- lg: 'inline-flex items-center gap-2 whitespace-nowrap text-lg text-fg',
51
+ sm: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-sm text-fg',
52
+ md: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-base text-fg',
53
+ lg: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-lg text-fg',
48
54
  };
49
- const COPY_BTN_CLASS = 'inline-flex shrink-0 cursor-pointer items-center rounded-sm px-1.5 py-0.5 text-xs font-medium text-primary-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
55
+ export const COPY_TEXT_CLASS = 'min-w-0 truncate';
56
+ export const COPY_BTN_CLASS = 'inline-flex shrink-0 cursor-pointer items-center rounded-sm px-1.5 py-0.5 text-xs font-medium text-primary-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
50
57
 
51
- export const KIT_TEXT_CLASS_CANDIDATES: readonly string[] = classCandidates(Object.values(COPY_ROOT_CLASS), COPY_BTN_CLASS, ...Object.values(TONE_TEXT_CLASS).flatMap((m) => Object.values(m)), ...Object.values(TAG_CLASS).flatMap((m) => Object.values(m)));
58
+ export const KIT_TEXT_CLASS_CANDIDATES: readonly string[] = classCandidates(Object.values(TEXT_EMPTY_CLASS), Object.values(COPY_ROOT_CLASS), COPY_TEXT_CLASS, COPY_BTN_CLASS, ...Object.values(TONE_TEXT_CLASS).flatMap((m) => Object.values(m)), ...[Object.values(DOT_ROOT), Object.values(DOT_TEXT), Object.values(DOT_WRAP), Object.values(DOT_CORE)].flat());
52
59
 
53
60
  const COPIED_MS = 1500;
54
61
 
@@ -114,7 +121,7 @@ export function createText(): SomaComponentDefinition {
114
121
  copyable: { type: 'boolean', default: false, desc: '文字后带「复制」钮,复制显示出来的文字' },
115
122
  copy_label: { type: 'string', default: '', desc: '复制钮文字;缺省取内置文案(按页面语言)' },
116
123
  copied_label: { type: 'string', default: '', desc: '复制成功后短暂显示的文字;缺省取内置文案(按页面语言)' },
117
- tone_as: { type: 'string', default: 'tag', desc: '选项带 tone 时的呈现:tag = 徽标(缺省)/ text = 纯文字着色(无底无描边)' },
124
+ tone_as: { type: 'string', default: 'dot', desc: '选项带 tone 时的呈现(值带语气 = 状态):dot = 6px 圆点 + 语义色文字(缺省,KT-K-status-1)/ text = 纯文字着色(无圆点);旧值 tag 按 dot 画(状态与标签永不同形)' },
118
125
  size: SIZE_PROP,
119
126
  class: CLASS_PROP,
120
127
  },
@@ -175,21 +182,38 @@ export function createText(): SomaComponentDefinition {
175
182
  else root.removeAttribute(KIT_TIPS_SCOPE_ATTR);
176
183
  if (bool(p.copyable) && !empty) {
177
184
  const s = stateOf(root);
185
+ root.textContent = '';
186
+ const valueEl = document.createElement('span');
187
+ valueEl.className = COPY_TEXT_CLASS;
188
+ valueEl.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
189
+ valueEl.textContent = text;
178
190
  const btn = document.createElement('button');
179
191
  btn.setAttribute('type', 'button');
180
192
  btn.setAttribute('data-kit-action', 'copy');
181
193
  btn.className = COPY_BTN_CLASS;
182
194
  btn.textContent = s.copied ? str(p.copied_label, kitText('soma.kit.copied', undefined, root)) : str(p.copy_label, kitText('soma.kit.copy', undefined, root));
183
- root.appendChild(btn);
195
+ root.append(valueEl, btn);
184
196
  root.className = joinClass(COPY_ROOT_CLASS[size], p.class);
185
197
  return;
186
198
  }
187
199
  if (!empty && !bool(p.copyable) && tone !== undefined) {
188
- // tone_as: text = 纯文字着色(text-<tone>-on-soft,无底无描边);缺省 tag = 徽标
189
- root.className = joinClass(str(p.tone_as) === TONE_AS_TEXT ? TONE_TEXT_CLASS[size][tone] : TAG_CLASS[size][tone], p.class);
200
+ // 值带语气 = 状态(knowledge/Kit主题规则与算法.md KT-K-status-1 / 3):缺省呈现为 6px 圆点 + 语义色文字、无底无框(与 Tag dot 同一组类);
201
+ // tone_as: text = 纯文字着色(无圆点)。旧值 tag(浅底徽标)已删:状态与标签永不同形,按圆点画
202
+ if (str(p.tone_as) === TONE_AS_TEXT) {
203
+ root.className = joinClass(TONE_TEXT_CLASS[size][tone], p.class);
204
+ return;
205
+ }
206
+ const dot = document.createElement('span');
207
+ dot.setAttribute('aria-hidden', 'true');
208
+ dot.className = DOT_WRAP[size];
209
+ const core = document.createElement('span');
210
+ core.className = DOT_CORE[tone];
211
+ dot.appendChild(core);
212
+ root.replaceChildren(dot, document.createTextNode(text));
213
+ root.className = joinClass(`${DOT_ROOT[size]} ${DOT_TEXT[tone]}`, p.class);
190
214
  return;
191
215
  }
192
- root.className = joinClass(TEXT_CLASS[size], p.class);
216
+ root.className = joinClass(empty && text !== '' ? TEXT_EMPTY_CLASS[size] : TEXT_CLASS[size], p.class);
193
217
  },
194
218
  })),
195
219
  };
@@ -4,7 +4,7 @@
4
4
  // 根元素(data-soma-id="root")始终是原生 textarea;计数在它外层 span 的第二个子元素里。
5
5
 
6
6
  import type { SomaComponentDefinition } from 'soma-core';
7
- import { mergeClass } from '../object-renderer/merge-class';
7
+ import { mergeClass } from '../shared/merge-class';
8
8
  import {
9
9
  CLASS_PROP, FIELD_INVALID_CLASS, FOCUS_RING, ID_PROPS, INVALID_PROPS, SIZE_PROP,
10
10
  applyCommon, applyDisabled, bool, classCandidates, createKitController, joinClass, num, setBoolAttr, sizeOf, str, withInvalid, type KitProps, type KitSize,
@@ -11,9 +11,13 @@
11
11
  import type { SomaComponentDefinition } from 'soma-core';
12
12
  import type { CollectionItem } from 'soma-core/keyboard';
13
13
  import { kitKey, kitText, type KitTextKey } from '../i18n/kit-text';
14
- import { kitIcon } from './icons';
14
+ import { kitIcon } from '../shared/icons';
15
15
  import { setKitFace } from '../recipes';
16
- import { mergeClass } from '../object-renderer/merge-class';
16
+ import { kitControlEdgeRecipe } from '../recipes/control';
17
+
18
+ // 触发框的边 = 控件轮廓出口(KT-B1 / §4 C6)
19
+ const CONTROL_EDGE = kitControlEdgeRecipe();
20
+ import { mergeClass } from '../shared/merge-class';
17
21
  import { kitSurfaceRecipe } from '../recipes/surface';
18
22
  import {
19
23
  CLASS_PROP, FIELD_INVALID_CLASS, ID_PROPS, INVALID_PROPS, SIZE_PROP,
@@ -29,9 +33,9 @@ import {
29
33
 
30
34
  const ROOT_CLASS = 'relative block w-full';
31
35
  const TRIGGER_CLASS: Record<KitSize, string> = {
32
- sm: 'flex h-6 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-2.5 text-sm text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
33
- md: 'flex h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-3 text-sm text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
34
- lg: 'flex h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-4 text-base text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
36
+ sm: 'flex h-6 w-full cursor-pointer items-center justify-between gap-2 rounded-md ' + CONTROL_EDGE + ' bg-surface px-2.5 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
37
+ md: 'flex h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-md ' + CONTROL_EDGE + ' bg-surface px-3 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
38
+ lg: 'flex h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-md ' + CONTROL_EDGE + ' bg-surface px-4 text-base text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
35
39
  };
36
40
  const PLACEHOLDER_CLASS = 'text-fg-subtle';
37
41
  const VALUE_CLASS = 'text-fg';
@@ -11,9 +11,10 @@
11
11
 
12
12
  import type { SomaComponentDefinition } from 'soma-core';
13
13
  import { kitText } from '../i18n/kit-text';
14
- import { kitIcon } from './icons';
14
+ import { kitIcon } from '../shared/icons';
15
15
  import { setKitFace } from '../recipes';
16
- import { mergeClass } from '../object-renderer/merge-class';
16
+ import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
17
+ import { mergeClass } from '../shared/merge-class';
17
18
  import { kitSurfaceRecipe } from '../recipes/surface';
18
19
  import type { CollectionItem } from 'soma-core/keyboard';
19
20
  import { createCheck, markInput } from './check-core';
@@ -23,26 +24,28 @@ import {
23
24
  type KitApi, type KitProps, type KitSize,
24
25
  } from './shared';
25
26
  import {
26
- EMPTY_ROW_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES,
27
+ EMPTY_ROW_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES, KIT_DROPDOWN_PANEL_MAX_CLASS,
27
28
  syncDropdown, releaseDropdown, cssEscape, createListNav, onOutsidePress, scrollIntoViewIfAny, type ListNav,
28
29
  } from './popup';
29
30
 
30
31
  // ---- Tailwind 类常量与候选类清单 ----
31
32
 
32
33
  const ROOT_CLASS = 'relative block w-full';
34
+ // 触发框 / 搜索框的边 = 控件轮廓出口(KT-B1 / §4 C6);已选芯片浅底无描边
35
+ const EDGE = kitControlEdgeRecipe();
33
36
  const TRIGGER_CLASS: Record<KitSize, string> = {
34
- sm: 'flex min-h-6 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-2.5 text-sm text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
35
- md: 'flex min-h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-3 text-sm text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
36
- lg: 'flex min-h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-surface px-4 text-base text-fg transition-colors enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
37
+ sm: `flex min-h-6 w-full cursor-pointer items-center justify-between gap-2 rounded-md ${EDGE} bg-surface px-2.5 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60`,
38
+ md: `flex min-h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-md ${EDGE} bg-surface px-3 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60`,
39
+ lg: `flex min-h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-md ${EDGE} bg-surface px-4 text-base text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60`,
37
40
  };
38
41
  const PLACEHOLDER_CLASS = 'truncate text-fg-subtle';
39
42
  const VALUE_CLASS = 'flex min-w-0 flex-1 flex-wrap items-center gap-1 text-start';
40
- const CHIP_CLASS = 'inline-flex items-center rounded-md border border-border-subtle bg-surface-sunken px-1.5 py-0.5 text-xs font-medium text-fg-muted';
43
+ const CHIP_CLASS = 'inline-flex items-center rounded-md bg-surface-sunken px-1.5 py-0.5 text-xs font-medium text-fg-muted';
41
44
  const CLEAR_CLASS = 'absolute end-8 top-0 flex h-full cursor-pointer items-center px-1 text-fg-subtle hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
42
45
  const HIDDEN_CLASS = 'hidden';
43
46
  const STATUS_CLASS = 'sr-only';
44
- const PANEL_BASE = mergeClass('absolute z-10 flex max-h-70 w-full flex-col gap-1 overflow-auto p-1', kitSurfaceRecipe('raised'));
45
- const SEARCH_CLASS = 'block h-8 w-full appearance-none autofill-clear rounded-md border border-input bg-surface px-2.5 text-sm text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring';
47
+ const PANEL_BASE = mergeClass(`absolute z-10 flex ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-full flex-col gap-1 overflow-auto p-1`, kitSurfaceRecipe('raised'));
48
+ const SEARCH_CLASS = kitControlRecipe();
46
49
  const TREE_CLASS = 'flex flex-col';
47
50
  const TOGGLE_CLASS = 'w-4 shrink-0 text-fg-subtle';
48
51
  const CHECK_CLASS = 'pointer-events-none';