soma-kit 0.1.13 → 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 +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- 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 +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- 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 +34 -17
- 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/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -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 +73 -50
- 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 +7 -6
- 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 +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- 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 +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- 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 +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- 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 +16 -12
- package/src/biz/types.ts +15 -3
- 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/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -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 +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- 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 +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- 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 +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- 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 +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- 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 +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- 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 +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -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 +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- 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 +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- 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,
|
|
@@ -33,13 +34,12 @@ import {
|
|
|
33
34
|
kitFocusRingRecipe,
|
|
34
35
|
kitInvalidRecipe,
|
|
35
36
|
KIT_TYPOGRAPHY_RECIPE_MAP,
|
|
36
|
-
kitTypographyRecipe,
|
|
37
37
|
type KitTypographyRecipeRole,
|
|
38
38
|
} from '../recipes';
|
|
39
39
|
|
|
40
40
|
// ── 尺寸档 ────────────────────────────────────────────────────
|
|
41
41
|
|
|
42
|
-
export type KitSize
|
|
42
|
+
export type { KitSize };
|
|
43
43
|
export const KIT_SIZES: readonly KitSize[] = ['sm', 'md', 'lg'];
|
|
44
44
|
|
|
45
45
|
export function sizeOf(raw: unknown): KitSize {
|
|
@@ -49,18 +49,7 @@ export function sizeOf(raw: unknown): KitSize {
|
|
|
49
49
|
// ── 文本类控件的统一类串(Input / Textarea 的单行部分 / Number / Date / DateRange / Select)─────
|
|
50
50
|
// 直接由 kitControlRecipe 与 kitInvalidRecipe 生成,不再维护平行字面量或拆单 token。
|
|
51
51
|
|
|
52
|
-
export const KIT_TYPOGRAPHY: Readonly<Record<KitTypographyRecipeRole, string>> =
|
|
53
|
-
pageTitle: kitTypographyRecipe('pageTitle'),
|
|
54
|
-
dialogTitle: kitTypographyRecipe('dialogTitle'),
|
|
55
|
-
sectionTitle: kitTypographyRecipe('sectionTitle'),
|
|
56
|
-
statValue: kitTypographyRecipe('statValue'),
|
|
57
|
-
body: kitTypographyRecipe('body'),
|
|
58
|
-
bodyStrong: kitTypographyRecipe('bodyStrong'),
|
|
59
|
-
caption: kitTypographyRecipe('caption'),
|
|
60
|
-
muted: kitTypographyRecipe('muted'),
|
|
61
|
-
code: kitTypographyRecipe('code'),
|
|
62
|
-
label: kitTypographyRecipe('label'),
|
|
63
|
-
});
|
|
52
|
+
export const KIT_TYPOGRAPHY: Readonly<Record<KitTypographyRecipeRole, string>> = KIT_TYPOGRAPHY_RECIPE_MAP;
|
|
64
53
|
|
|
65
54
|
export { KIT_TYPOGRAPHY_RECIPE_MAP };
|
|
66
55
|
|
|
@@ -125,6 +114,8 @@ export interface KitOption {
|
|
|
125
114
|
icon?: string;
|
|
126
115
|
/** Radio / Checkbox 读:纯图标选项的可访问名(缺省取 value) */
|
|
127
116
|
aria_label?: string;
|
|
117
|
+
/** Radio segmented 读:选项尾部的计数(来自列表响应 facets;没给不显示) */
|
|
118
|
+
count?: number;
|
|
128
119
|
}
|
|
129
120
|
|
|
130
121
|
const warnedDuplicates = new Set<string>();
|
|
@@ -178,6 +169,7 @@ export function optionsOf(raw: unknown): KitOption[] {
|
|
|
178
169
|
...(tone ? { tone } : {}),
|
|
179
170
|
...(unknownTone ? { unknown: true } : {}),
|
|
180
171
|
...(rec.disabled === true ? { disabled: true } : {}),
|
|
172
|
+
...(typeof rec.count === 'number' && Number.isInteger(rec.count) && rec.count >= 0 ? { count: rec.count } : {}),
|
|
181
173
|
});
|
|
182
174
|
}
|
|
183
175
|
return out;
|
|
@@ -189,7 +181,7 @@ export function sameValue(a: unknown, b: unknown): boolean {
|
|
|
189
181
|
}
|
|
190
182
|
|
|
191
183
|
export function optionsKey(options: readonly KitOption[]): string {
|
|
192
|
-
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]));
|
|
193
185
|
}
|
|
194
186
|
|
|
195
187
|
export function toneOf(raw: unknown, fallback: KitTone): KitTone;
|
|
@@ -290,6 +282,45 @@ export function findRoot(host: HTMLElement): HTMLElement {
|
|
|
290
282
|
?? host;
|
|
291
283
|
}
|
|
292
284
|
|
|
285
|
+
/**
|
|
286
|
+
* 整块不渲染:收起组件根;根在没有标题的看板面板里(`data-kit-board-panel="bare"`)时,面板壳在「面板里没有别的可见组件」时一并收起 / 恢复,不留空白圆角条。
|
|
287
|
+
* 面板里还有别的非空组件(如被并进同一面板的门控卡)时只收起自己的根,面板与其它组件不动。
|
|
288
|
+
* 带标题的面板壳不动(标题行仍在,空态由组件自己画)。
|
|
289
|
+
*/
|
|
290
|
+
export function kitCollapseBlock(root: HTMLElement, collapsed: boolean): void {
|
|
291
|
+
root.hidden = collapsed;
|
|
292
|
+
const panel = root.closest<HTMLElement>('[data-kit-board-panel="bare"]');
|
|
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;
|
|
322
|
+
}
|
|
323
|
+
|
|
293
324
|
export function setBoolAttr(el: Element, name: string, on: boolean): void {
|
|
294
325
|
if (on) el.setAttribute(name, '');
|
|
295
326
|
else el.removeAttribute(name);
|
|
@@ -925,7 +956,7 @@ export function wireKitTablist(root: HTMLElement, opts: KitTablistOptions = {}):
|
|
|
925
956
|
|
|
926
957
|
// ── 类候选小工具(K9 / D1:补齐波基础组件共用)────────────────
|
|
927
958
|
|
|
928
|
-
export { classCandidates } from '
|
|
959
|
+
export { classCandidates } from '../shared/class-candidates';
|
|
929
960
|
|
|
930
961
|
// ── 通用 tooltip(按钮类基础组件的可选 prop)─────────────────
|
|
931
962
|
// 提示气泡是目标元素内的一个 role=tooltip 子元素(绝对定位,目标补 `relative`):hover / focus 显示,Esc 与移开隐藏,
|
|
@@ -1004,6 +1035,9 @@ function wrapTooltipView(view: KitView, targetOf: (root: HTMLElement) => HTMLEle
|
|
|
1004
1035
|
const s = stateOf(root);
|
|
1005
1036
|
const show = (): void => {
|
|
1006
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;
|
|
1007
1041
|
s.shown = true;
|
|
1008
1042
|
paintTip(s);
|
|
1009
1043
|
};
|
package/src/base/state-panel.ts
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
// 纯 DOM 小件,不碰数据:读状态怎么判由调用方给(集合用 collectionStatus,数据组件用 applyKitReadState / 契约 props)。
|
|
10
10
|
|
|
11
11
|
import { kitText } from '../i18n/kit-text';
|
|
12
|
+
import { KIT_ILLUSTRATION_CLASS_CANDIDATES, kitIllustration } from './illustrations';
|
|
12
13
|
import {
|
|
13
14
|
KIT_LOADING_GATE_DEFAULTS, LOADING_FEEDBACK_IDLE, stepLoadingFeedback,
|
|
14
15
|
type LoadingFeedbackConfig, type LoadingFeedbackState,
|
|
15
16
|
} from './loading-gate';
|
|
16
17
|
import {
|
|
17
|
-
KIT_STATE_DENIED_BOX, KIT_STATE_DESC_CLASS, KIT_STATE_EMPTY_BOX,
|
|
18
|
+
KIT_STATE_DENIED_BOX, KIT_STATE_DENIED_PAGE, KIT_STATE_DENIED_TITLE, KIT_STATE_DENIED_WRAP, KIT_STATE_DESC_CLASS, KIT_STATE_EMPTY_ACTION, KIT_STATE_EMPTY_BOX, KIT_STATE_EMPTY_PAGE, KIT_STATE_ERROR_BOX, KIT_STATE_LOADING_BOX, KIT_STATE_NOT_READY_BOX,
|
|
18
19
|
KIT_LOADING_HELD_ATTR, KIT_STATE_RETRY_CLASS_CANDIDATES, KIT_STATE_TITLE_CLASS, KIT_STATE_UPSTREAM_BOX, kitRetryRecipe,
|
|
19
20
|
} from '../recipes/placeholder';
|
|
20
21
|
|
|
@@ -87,8 +88,10 @@ const RETRY_CLASS = kitRetryRecipe('danger');
|
|
|
87
88
|
const RETRY_CLASS_WARNING = kitRetryRecipe('warning');
|
|
88
89
|
export const KIT_STATE_PANEL_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set(
|
|
89
90
|
[
|
|
90
|
-
KIT_STATE_EMPTY_BOX,
|
|
91
|
-
KIT_STATE_NOT_READY_BOX, KIT_STATE_UPSTREAM_BOX, KIT_STATE_DENIED_BOX, KIT_STATE_TITLE_CLASS, KIT_STATE_DESC_CLASS,
|
|
91
|
+
KIT_STATE_EMPTY_BOX, KIT_STATE_EMPTY_PAGE, KIT_STATE_EMPTY_ACTION, KIT_STATE_ERROR_BOX, KIT_STATE_LOADING_BOX, ...KIT_STATE_RETRY_CLASS_CANDIDATES,
|
|
92
|
+
KIT_STATE_NOT_READY_BOX, KIT_STATE_UPSTREAM_BOX, KIT_STATE_DENIED_BOX, KIT_STATE_DENIED_PAGE, KIT_STATE_DENIED_TITLE, KIT_STATE_DENIED_WRAP, KIT_STATE_TITLE_CLASS, KIT_STATE_DESC_CLASS,
|
|
93
|
+
// 空态面板自带小插画(中性色):它的类随面板一起并入页面候选
|
|
94
|
+
...KIT_ILLUSTRATION_CLASS_CANDIDATES,
|
|
92
95
|
]
|
|
93
96
|
.flatMap((s) => s.split(/\s+/).filter((c) => c !== '')),
|
|
94
97
|
)].sort());
|
|
@@ -109,8 +112,13 @@ export interface KitStatePanelOptions {
|
|
|
109
112
|
retry?: (() => unknown) | null;
|
|
110
113
|
/** 重试钮文字;缺省取内置「重试」(按页面语言) */
|
|
111
114
|
retryLabel?: string;
|
|
112
|
-
/**
|
|
113
|
-
|
|
115
|
+
/**
|
|
116
|
+
* empty:整页 / 首次使用空态(页面里没有任何内容的整块区域)——只有它带插画,标题 + 一行说明 + 至多一个操作;
|
|
117
|
+
* 缺省是集合内空态(表格、列表、主从右栏、面板内):一行标题 + 至多一个操作,无插画(总高 <= 真源 structure.emptyState.maxHeightPx)
|
|
118
|
+
*/
|
|
119
|
+
page?: boolean;
|
|
120
|
+
/** empty:至多一个操作(「尚无数据」给页面主操作的同名入口、「筛选无结果」给「清除筛选」);attr 是给委托点击处理用的标记属性 */
|
|
121
|
+
action?: { label: string; attr?: string; onClick?: () => void };
|
|
114
122
|
/** error:悬停提示文字(如被拆下来的状态码),写进 data-kit-tip;缺省不带 */
|
|
115
123
|
tip?: string;
|
|
116
124
|
/** 重试钮被键盘触发(click 的 detail 为 0)时回调:调用方据此在面板重绘后把焦点还给新钮 */
|
|
@@ -157,13 +165,26 @@ export function paintKitStatePanel(box: HTMLElement, kind: KitStateKind, o: KitS
|
|
|
157
165
|
}
|
|
158
166
|
if (kind === 'empty') {
|
|
159
167
|
box.setAttribute('role', 'status');
|
|
160
|
-
if (o.
|
|
161
|
-
box.className =
|
|
162
|
-
box.
|
|
168
|
+
if (o.page === true) {
|
|
169
|
+
box.className = KIT_STATE_EMPTY_PAGE;
|
|
170
|
+
box.replaceChildren(kitIllustration(doc, 'empty', 'md'));
|
|
171
|
+
appendStateText(box, doc, o.text, true, false);
|
|
163
172
|
} else {
|
|
173
|
+
// 集合内空态:一行标题(不拆说明、无插画);操作紧随其后同一行
|
|
164
174
|
box.className = KIT_STATE_EMPTY_BOX;
|
|
165
|
-
box.
|
|
166
|
-
|
|
175
|
+
box.textContent = '';
|
|
176
|
+
const title = doc.createElement('span');
|
|
177
|
+
title.textContent = o.text;
|
|
178
|
+
box.appendChild(title);
|
|
179
|
+
}
|
|
180
|
+
if (o.action !== undefined) {
|
|
181
|
+
const btn = doc.createElement('button');
|
|
182
|
+
btn.type = 'button';
|
|
183
|
+
btn.className = KIT_STATE_EMPTY_ACTION;
|
|
184
|
+
if (o.action.attr !== undefined) btn.setAttribute(o.action.attr, '');
|
|
185
|
+
btn.textContent = o.action.label;
|
|
186
|
+
if (o.action.onClick !== undefined) btn.addEventListener('click', o.action.onClick);
|
|
187
|
+
box.appendChild(btn);
|
|
167
188
|
}
|
|
168
189
|
return null;
|
|
169
190
|
}
|
|
@@ -338,9 +359,9 @@ export function applyKitReadState(root: HTMLElement, p: Record<string, unknown>,
|
|
|
338
359
|
return false;
|
|
339
360
|
}
|
|
340
361
|
|
|
341
|
-
/**
|
|
342
|
-
export function kitEmptyPanel(doc: Document, text: string
|
|
343
|
-
const box = kitStatePanel(doc, 'empty', { text
|
|
362
|
+
/** 空态面板(数据组件无内容时):与集合空态同一画法(一行标题,无插画) */
|
|
363
|
+
export function kitEmptyPanel(doc: Document, text: string): HTMLElement {
|
|
364
|
+
const box = kitStatePanel(doc, 'empty', { text });
|
|
344
365
|
box.setAttribute('data-kit-empty', '');
|
|
345
366
|
return box;
|
|
346
367
|
}
|
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,59 +17,62 @@ 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: {
|
|
30
|
-
neutral: 'inline-flex items-center rounded-full bg-surface-sunken px-2 py-0.5 text-sm font-medium text-fg-muted',
|
|
31
|
-
info: 'inline-flex items-center rounded-full bg-info-soft px-2 py-0.5 text-sm font-medium text-info-on-soft',
|
|
32
|
-
success: 'inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-sm font-medium text-success-on-soft',
|
|
33
|
-
warning: 'inline-flex items-center rounded-full bg-warning-soft px-2 py-0.5 text-sm font-medium text-warning-on-soft',
|
|
34
|
-
danger: 'inline-flex items-center rounded-full bg-danger-soft px-2 py-0.5 text-sm font-medium text-danger-on-soft',
|
|
35
|
-
},
|
|
36
|
-
lg: {
|
|
37
|
-
neutral: 'inline-flex items-center rounded-full bg-surface-sunken px-2.5 py-1 text-base font-medium text-fg-muted',
|
|
38
|
-
info: 'inline-flex items-center rounded-full bg-info-soft px-2.5 py-1 text-base font-medium text-info-on-soft',
|
|
39
|
-
success: 'inline-flex items-center rounded-full bg-success-soft px-2.5 py-1 text-base font-medium text-success-on-soft',
|
|
40
|
-
warning: 'inline-flex items-center rounded-full bg-warning-soft px-2.5 py-1 text-base font-medium text-warning-on-soft',
|
|
41
|
-
danger: 'inline-flex items-center rounded-full bg-danger-soft px-2.5 py-1 text-base font-medium text-danger-on-soft',
|
|
42
|
-
},
|
|
33
|
+
sm: tagRow('px-1.5'),
|
|
34
|
+
md: tagRow('px-2'),
|
|
35
|
+
lg: tagRow('px-2'),
|
|
43
36
|
};
|
|
44
37
|
|
|
45
38
|
// 状态点:每个语气一整串字面量(实心语义色;neutral 用淡字色,闲置态不用 warning / danger 由调用方选 tone)
|
|
39
|
+
// 徽标内的圆点 6px(h-1.5 w-1.5):与 12px 徽标字同一比例,不抢文字
|
|
46
40
|
const DOT_CLASS: Record<KitTone, string> = {
|
|
47
|
-
neutral: 'me-1.5 inline-block h-
|
|
48
|
-
info: 'me-1.5 inline-block h-
|
|
49
|
-
success: 'me-1.5 inline-block h-
|
|
50
|
-
warning: 'me-1.5 inline-block h-
|
|
51
|
-
danger: 'me-1.5 inline-block h-
|
|
41
|
+
neutral: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-fg-subtle',
|
|
42
|
+
info: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-info',
|
|
43
|
+
success: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success',
|
|
44
|
+
warning: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-warning',
|
|
45
|
+
danger: 'me-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-danger',
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
// variant: dot
|
|
55
|
-
const DOT_ROOT: Record<KitSize, string> = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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',
|
|
59
61
|
};
|
|
60
|
-
|
|
62
|
+
// 状态圆点只有一种尺寸 6px(KT-K-status-1:不随控件档变;表格 / 列表 / 卡片头同一个点)
|
|
63
|
+
export const DOT_WRAP: Record<KitSize, string> = {
|
|
61
64
|
sm: 'relative inline-flex h-1.5 w-1.5 shrink-0',
|
|
62
|
-
md: 'relative inline-flex h-
|
|
63
|
-
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',
|
|
64
67
|
};
|
|
65
|
-
const DOT_CORE: Record<KitTone, string> = {
|
|
68
|
+
export const DOT_CORE: Record<KitTone, string> = {
|
|
66
69
|
neutral: 'relative inline-flex h-full w-full rounded-full bg-fg-subtle',
|
|
67
70
|
info: 'relative inline-flex h-full w-full rounded-full bg-info',
|
|
68
71
|
success: 'relative inline-flex h-full w-full rounded-full bg-success',
|
|
69
72
|
warning: 'relative inline-flex h-full w-full rounded-full bg-warning',
|
|
70
73
|
danger: 'relative inline-flex h-full w-full rounded-full bg-danger',
|
|
71
74
|
};
|
|
72
|
-
const DOT_RING: Record<KitTone, string> = {
|
|
75
|
+
export const DOT_RING: Record<KitTone, string> = {
|
|
73
76
|
neutral: 'absolute inset-0 rounded-full bg-fg-subtle opacity-60 motion-safe:animate-kit-ping',
|
|
74
77
|
info: 'absolute inset-0 rounded-full bg-info opacity-60 motion-safe:animate-kit-ping',
|
|
75
78
|
success: 'absolute inset-0 rounded-full bg-success opacity-60 motion-safe:animate-kit-ping',
|
|
@@ -77,25 +80,20 @@ const DOT_RING: Record<KitTone, string> = {
|
|
|
77
80
|
danger: 'absolute inset-0 rounded-full bg-danger opacity-60 motion-safe:animate-kit-ping',
|
|
78
81
|
};
|
|
79
82
|
|
|
80
|
-
// variant: outline / solid
|
|
83
|
+
// variant: outline / solid:尺寸壳与色彩分开给(互不含对方的属性,不会同类冲突)。
|
|
84
|
+
// 标签只有一种形体(KT-K-tag-1:小圆角、无描边;胶囊留给页头的对象总状态,状态与标签永不同形):outline 呈现同浅底(不再画描边),solid 是实心底,二者都是小圆角
|
|
81
85
|
const SHAPE_CLASS: Record<KitSize, string> = {
|
|
82
|
-
sm: 'inline-flex items-center gap-1 rounded-
|
|
83
|
-
md: 'inline-flex items-center gap-1
|
|
84
|
-
lg: 'inline-flex items-center gap-1
|
|
85
|
-
};
|
|
86
|
-
const OUTLINE_CLASS: Record<KitTone, string> = {
|
|
87
|
-
neutral: 'border border-border bg-transparent text-fg-muted',
|
|
88
|
-
info: 'border border-info-on-soft/40 bg-transparent text-info-on-soft',
|
|
89
|
-
success: 'border border-success-on-soft/40 bg-transparent text-success-on-soft',
|
|
90
|
-
warning: 'border border-warning-on-soft/40 bg-transparent text-warning-on-soft',
|
|
91
|
-
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',
|
|
92
89
|
};
|
|
90
|
+
const OUTLINE_CLASS: Record<KitTone, string> = TAG_TONES;
|
|
93
91
|
const SOLID_CLASS: Record<KitTone, string> = {
|
|
94
|
-
neutral: '
|
|
95
|
-
info: '
|
|
96
|
-
success: '
|
|
97
|
-
warning: '
|
|
98
|
-
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',
|
|
99
97
|
};
|
|
100
98
|
// 可点击:整枚标签是一个按钮(内层 span),悬停淡出、焦点环
|
|
101
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';
|
|
@@ -107,7 +105,7 @@ const SOFT_GAP_CLASS = 'gap-1.5';
|
|
|
107
105
|
export const KIT_TAG_CLASS_CANDIDATES: readonly string[] = Object.freeze([
|
|
108
106
|
...new Set([
|
|
109
107
|
...Object.values(DOT_CLASS).join(' ').split(' '),
|
|
110
|
-
...[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(' '),
|
|
111
109
|
...classCandidates(
|
|
112
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,
|
|
113
111
|
KIT_BADGE_CLASS_CANDIDATES, KIT_TAG_UNKNOWN_CLASS_CANDIDATES,
|
|
@@ -155,7 +153,7 @@ export function createTag(): SomaComponentDefinition {
|
|
|
155
153
|
click: { payload: { value: { type: 'string' } }, desc: 'clickable 时点击或 Enter / Space' },
|
|
156
154
|
},
|
|
157
155
|
},
|
|
158
|
-
templateHtml:
|
|
156
|
+
templateHtml: `<span data-soma-id="root" class="${TAG_CLASS.md.neutral}"></span>`,
|
|
159
157
|
controllerFactory: createKitController(() => withTooltip({
|
|
160
158
|
attach(root, api) {
|
|
161
159
|
const valueOf = (): unknown => api.props().value;
|
|
@@ -206,6 +204,7 @@ export function createTag(): SomaComponentDefinition {
|
|
|
206
204
|
root.textContent = shown.text;
|
|
207
205
|
return;
|
|
208
206
|
}
|
|
207
|
+
// 状态呈现全应用一种:圆点 + 文字、没有容器(与按钮、标签三种形体一眼可分);文字取语义色,常态用中性灰
|
|
209
208
|
if (p.variant === 'dot') {
|
|
210
209
|
const size = sizeOf(p.size);
|
|
211
210
|
const wrap = document.createElement('span');
|
|
@@ -222,7 +221,7 @@ export function createTag(): SomaComponentDefinition {
|
|
|
222
221
|
root.appendChild(wrap);
|
|
223
222
|
if (text !== '') root.appendChild(document.createTextNode(text));
|
|
224
223
|
setKitFace(root, null);
|
|
225
|
-
root.className = joinClass(DOT_ROOT[size]
|
|
224
|
+
root.className = joinClass(`${DOT_ROOT[size]} ${unknownTone ? 'text-fg-muted' : DOT_TEXT[tone]}`, p.class);
|
|
226
225
|
return;
|
|
227
226
|
}
|
|
228
227
|
const variant = variantOf(p.variant);
|
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
|
|
|
@@ -66,7 +73,7 @@ function stateOf(root: HTMLElement): CopyState {
|
|
|
66
73
|
return s;
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
function resolveTextDisplay(p: Record<string, unknown>, root: HTMLElement): { text: string; option: ReturnType<typeof displayOf>['option'] } {
|
|
76
|
+
export function resolveTextDisplay(p: Record<string, unknown>, root: HTMLElement): { text: string; option: ReturnType<typeof displayOf>['option'] } {
|
|
70
77
|
const opts = optionsOf(p.options);
|
|
71
78
|
const raw = p.value;
|
|
72
79
|
const placeholder = str(p.placeholder);
|
|
@@ -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';
|