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.
- package/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +4 -2
- package/spec/generated/kit-page.schema.json +72 -2
- package/spec/kit-grammar.json +163 -57
- package/spec/kit-grammar.schema.json +0 -24
- package/src/app/app-config.ts +1 -1
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +7 -7
- package/src/app/kit-view-context.ts +11 -2
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +30 -15
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +1 -1
- package/src/base/hint-tips.ts +1 -1
- package/src/base/index.ts +15 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +63 -27
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +2 -2
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +35 -36
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +43 -7
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +53 -59
- package/src/base/text.ts +37 -13
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +21 -13
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +2 -2
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +2 -2
- package/src/biz/category-crud/compile.ts +17 -4
- package/src/biz/category-crud/shell.ts +7 -5
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +7 -6
- package/src/biz/compose.ts +3 -3
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +6 -4
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +5 -4
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +162 -19
- package/src/biz/master-sub/detail-head.ts +7 -6
- package/src/biz/master-sub/index.ts +3 -3
- package/src/biz/master-sub/shell.ts +90 -53
- package/src/biz/multi-board/compile.ts +3 -3
- package/src/biz/multi-board/index.ts +24 -9
- package/src/biz/multi-board/prose-fold.ts +2 -2
- package/src/biz/multi-board/shell.ts +17 -13
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +9 -2
- package/src/biz/page-templates/domain-templates.ts +6 -2
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +4 -4
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +4 -4
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +8 -5
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +4 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +48 -18
- package/src/biz/shared/overlay-shell.ts +63 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +8 -4
- package/src/biz/standard-crud/compile.ts +11 -4
- package/src/biz/standard-crud/shell.ts +26 -9
- package/src/biz/standard-crud/summary.ts +3 -1
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +6 -4
- package/src/biz/types.ts +11 -4
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +29 -234
- package/src/compile/component-candidates.ts +2 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +43 -13
- package/src/compile/page-composition.ts +33 -31
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +70 -32
- package/src/compile/types.ts +2 -2
- package/src/data/amount-breakdown.ts +4 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +9 -4
- package/src/data/assignment-picker.ts +28 -18
- package/src/data/async-result-panel.ts +6 -2
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +4 -3
- package/src/data/carousel.ts +11 -5
- package/src/data/chart.ts +153 -23
- package/src/data/checklist.ts +5 -4
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +7 -2
- package/src/data/confirm-dialog.ts +56 -13
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +12 -6
- package/src/data/flow-editor.ts +105 -29
- package/src/data/footer.ts +6 -2
- package/src/data/gantt.ts +11 -8
- package/src/data/hero.ts +6 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +12 -5
- package/src/data/item-list.ts +6 -5
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +11 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +23 -14
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +15 -9
- package/src/data/mockup.ts +9 -5
- package/src/data/modal-dialog.ts +39 -88
- package/src/data/navbar.ts +11 -7
- package/src/data/notice-list.ts +1 -1
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +129 -48
- package/src/data/pager.ts +12 -8
- package/src/data/panel-head.ts +1 -1
- package/src/data/permission-matrix.ts +15 -8
- package/src/data/permission-tree.ts +24 -11
- package/src/data/pricing-table.ts +8 -3
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +13 -9
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +0 -12
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +10 -5
- package/src/data/rule-builder.ts +14 -8
- package/src/data/shape-util.ts +14 -3
- package/src/data/stat-group.ts +63 -22
- package/src/data/static-lazy.ts +3 -0
- package/src/data/static-registry.ts +8 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +9 -3
- package/src/data/system-switcher.ts +15 -6
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +6 -3
- package/src/data/transfer.ts +19 -10
- package/src/data/tree-table.ts +77 -12
- package/src/data/tree.ts +5 -2
- package/src/data/virtual-rows.ts +17 -7
- package/src/data/wrap.ts +2 -2
- package/src/frames/index.ts +3 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +59 -36
- package/src/frames/page-bar.ts +4 -2
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +18 -14
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +12 -6
- package/src/frames/types.ts +3 -2
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +2 -1
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/view.ts +125 -76
- package/src/generated/kit-grammar-runtime.ts +61 -39
- package/src/i18n/kit-text.ts +114 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +31 -1
- package/src/object-renderer/action-more.ts +28 -12
- package/src/object-renderer/arrange.ts +37 -7
- package/src/object-renderer/collection-parts.ts +38 -7
- package/src/object-renderer/collection-table.ts +68 -23
- package/src/object-renderer/collection.ts +63 -30
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +8 -0
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +3 -0
- package/src/object-renderer/emit-static.ts +140 -37
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/layout-facts.ts +37 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/render-object.ts +1 -1
- package/src/object-renderer/table-actions.ts +70 -23
- package/src/object-renderer/table-tools.ts +12 -5
- package/src/object-renderer/types.ts +9 -15
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +25 -15
- package/src/recipes/control.ts +21 -3
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +12 -8
- package/src/recipes/frame-bleed.ts +3 -3
- package/src/recipes/index.ts +11 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +112 -26
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +1 -1
- package/src/recipes/stat-state.ts +1 -1
- package/src/recipes/state.ts +10 -8
- package/src/recipes/status.ts +13 -12
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +1 -1
- package/src/recipes/table-native-edit.ts +4 -4
- package/src/recipes/table-row.ts +11 -8
- package/src/recipes/tabs.ts +108 -31
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +4 -2
- package/src/recipes/typography.ts +2 -2
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -14
- package/src/theme/kit-theme.tpl +38 -14
- package/src/theme/nine-dim-structure.ts +66 -41
- package/src/theme/surface-layers.ts +11 -3
- package/src/theme/theme-tokens.ts +5 -1
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/base/shared.ts
CHANGED
|
@@ -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 '
|
|
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 '../
|
|
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
|
|
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
|
|
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 '
|
|
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
|
};
|
package/src/base/status-tone.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// 双编码:每个语气有图标(kit 图标名,SVG)+ 读屏文字,不靠颜色、不用符号字符。
|
|
4
4
|
|
|
5
5
|
import type { KitStatusTone } from '../recipes/status';
|
|
6
|
-
import type { KitIconName } from '
|
|
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
|
|
package/src/base/tag-input.ts
CHANGED
|
@@ -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 '
|
|
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:
|
|
29
|
-
md:
|
|
30
|
-
lg:
|
|
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:
|
|
34
|
-
md:
|
|
35
|
-
lg:
|
|
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
|
-
|
|
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 '
|
|
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
|
-
|
|
24
|
-
|
|
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
|
|
57
|
-
const DOT_ROOT: Record<KitSize, string> = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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-
|
|
65
|
-
lg: 'relative inline-flex h-
|
|
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-
|
|
85
|
-
md: 'inline-flex items-center gap-1
|
|
86
|
-
lg: 'inline-flex items-center gap-1
|
|
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: '
|
|
97
|
-
info: '
|
|
98
|
-
success: '
|
|
99
|
-
warning: '
|
|
100
|
-
danger: '
|
|
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:
|
|
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
|
-
//
|
|
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]
|
|
224
|
+
root.className = joinClass(`${DOT_ROOT[size]} ${unknownTone ? 'text-fg-muted' : DOT_TEXT[tone]}`, p.class);
|
|
231
225
|
return;
|
|
232
226
|
}
|
|
233
|
-
const 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 (
|
|
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 {
|
|
8
|
-
import { formatDateRangeValue, formatMoneyValue, formatPercentValue } from '../
|
|
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 时根元素变成一行:文字 + 复制钮(
|
|
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
|
|
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(
|
|
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: '
|
|
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.
|
|
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
|
-
//
|
|
189
|
-
|
|
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
|
};
|
package/src/base/textarea.ts
CHANGED
|
@@ -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 '../
|
|
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,
|
package/src/base/time-picker.ts
CHANGED
|
@@ -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 '
|
|
14
|
+
import { kitIcon } from '../shared/icons';
|
|
15
15
|
import { setKitFace } from '../recipes';
|
|
16
|
-
import {
|
|
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
|
|
33
|
-
md: 'flex h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-md
|
|
34
|
-
lg: 'flex h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-md
|
|
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';
|
package/src/base/tree-select.ts
CHANGED
|
@@ -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 '
|
|
14
|
+
import { kitIcon } from '../shared/icons';
|
|
15
15
|
import { setKitFace } from '../recipes';
|
|
16
|
-
import {
|
|
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:
|
|
35
|
-
md:
|
|
36
|
-
lg:
|
|
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
|
|
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(
|
|
45
|
-
const SEARCH_CLASS =
|
|
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';
|