soma-kit 0.1.10 → 0.1.12
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/README.md +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1278
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// 控件配方(control.ts):覆盖单行输入、选择器触发器、多行文本(多行不进胶囊圆角)、按钮与徽标,
|
|
2
|
+
// 统一高度(sm / md / lg)、内边距、边框与圆角,并提供 data-kit-part 常量标识。
|
|
3
|
+
|
|
4
|
+
import { classCandidates } from '../base/class-candidates';
|
|
5
|
+
import type { KitSize } from '../base/shared';
|
|
6
|
+
import { kitDisabledRecipe, kitFocusRingRecipe, kitInvalidRecipe } from './state';
|
|
7
|
+
|
|
8
|
+
export const KIT_PART_CONTROL = 'control' as const;
|
|
9
|
+
export const KIT_PART_BUTTON = 'button' as const;
|
|
10
|
+
export const KIT_PART_TEXTAREA = 'textarea' as const;
|
|
11
|
+
export const KIT_PART_BADGE = 'badge' as const;
|
|
12
|
+
|
|
13
|
+
export type KitControlPart =
|
|
14
|
+
| typeof KIT_PART_CONTROL
|
|
15
|
+
| typeof KIT_PART_BUTTON
|
|
16
|
+
| typeof KIT_PART_TEXTAREA
|
|
17
|
+
| typeof KIT_PART_BADGE;
|
|
18
|
+
|
|
19
|
+
export type KitControlSize = KitSize;
|
|
20
|
+
export type KitControlVariant =
|
|
21
|
+
| 'outline'
|
|
22
|
+
| 'filled'
|
|
23
|
+
| 'primary'
|
|
24
|
+
| 'neutral'
|
|
25
|
+
| 'danger'
|
|
26
|
+
| 'ghost'
|
|
27
|
+
| 'tonal'
|
|
28
|
+
| 'badge';
|
|
29
|
+
|
|
30
|
+
export interface KitControlRecipeOptions {
|
|
31
|
+
size?: KitControlSize;
|
|
32
|
+
variant?: KitControlVariant;
|
|
33
|
+
invalid?: boolean;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
multiline?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const SINGLE_LINE_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string }>> = Object.freeze({
|
|
39
|
+
sm: { h: 'h-8', px: 'px-2.5', text: 'text-sm' },
|
|
40
|
+
md: { h: 'h-9', px: 'px-3', text: 'text-sm' },
|
|
41
|
+
lg: { h: 'h-10', px: 'px-4', text: 'text-base' },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const BUTTON_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string; gap: string }>> = Object.freeze({
|
|
45
|
+
sm: { h: 'h-8', px: 'px-3', text: 'text-sm', gap: 'gap-1' },
|
|
46
|
+
md: { h: 'h-9', px: 'px-4', text: 'text-sm', gap: 'gap-2' },
|
|
47
|
+
lg: { h: 'h-10', px: 'px-5', text: 'text-base', gap: 'gap-2' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const MULTILINE_SIZE_CLASS: Readonly<Record<KitControlSize, { minH: string; px: string; py: string; text: string }>> = Object.freeze({
|
|
51
|
+
sm: { minH: 'min-h-20', px: 'px-2.5', py: 'py-1.5', text: 'text-sm' },
|
|
52
|
+
md: { minH: 'min-h-24', px: 'px-3', py: 'py-2', text: 'text-sm' },
|
|
53
|
+
lg: { minH: 'min-h-28', px: 'px-4', py: 'py-2.5', text: 'text-base' },
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const BADGE_SIZE_CLASS: Readonly<Record<KitControlSize, string>> = Object.freeze({
|
|
57
|
+
sm: 'h-5 px-1.5 text-xs gap-1',
|
|
58
|
+
md: 'h-6 px-2 text-xs gap-1',
|
|
59
|
+
lg: 'h-7 px-2.5 text-sm gap-1.5',
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const BUTTON_VARIANTS: ReadonlySet<KitControlVariant> = new Set([
|
|
63
|
+
'primary',
|
|
64
|
+
'neutral',
|
|
65
|
+
'danger',
|
|
66
|
+
'ghost',
|
|
67
|
+
'tonal',
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 控件尺寸子配方函数(返回单行控件尺寸类串:高度 h-*、横向内边距 px-*、字号 text-*)。
|
|
72
|
+
* 供 input.ts 的 BOX_SIZE 等直接同源调用,严禁 .split / .find 回捞。
|
|
73
|
+
*/
|
|
74
|
+
export function kitControlSizeRecipe(size: KitControlSize = 'md'): string {
|
|
75
|
+
const normalized: KitControlSize = size === 'sm' || size === 'lg' ? size : 'md';
|
|
76
|
+
const sz = SINGLE_LINE_SIZE_CLASS[normalized];
|
|
77
|
+
return `${sz.h} ${sz.px} ${sz.text}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 根据控件选项推导对应的 data-kit-part 标识值。
|
|
82
|
+
*/
|
|
83
|
+
export function kitControlPartOf(options: KitControlRecipeOptions = {}): KitControlPart {
|
|
84
|
+
if (options.multiline) return KIT_PART_TEXTAREA;
|
|
85
|
+
if (options.variant === 'badge') return KIT_PART_BADGE;
|
|
86
|
+
if (options.variant !== undefined && BUTTON_VARIANTS.has(options.variant)) return KIT_PART_BUTTON;
|
|
87
|
+
return KIT_PART_CONTROL;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 控件配方纯函数:按「骨架 + 变体 + 档位(size / variant / invalid / disabled / multiline)」返回标准 Tailwind 类串。
|
|
92
|
+
* 多行文本(multiline: true)固定采用容器级圆角 rounded-md,不进入单行胶囊圆角(rounded-full)。
|
|
93
|
+
*/
|
|
94
|
+
export function kitControlRecipe(options: KitControlRecipeOptions = {}): string {
|
|
95
|
+
const size: KitControlSize = options.size === 'sm' || options.size === 'lg' ? options.size : 'md';
|
|
96
|
+
const variant: KitControlVariant = options.variant ?? 'outline';
|
|
97
|
+
const multiline = Boolean(options.multiline);
|
|
98
|
+
const invalid = Boolean(options.invalid);
|
|
99
|
+
const disabled = Boolean(options.disabled);
|
|
100
|
+
|
|
101
|
+
if (variant === 'badge') {
|
|
102
|
+
const parts = [
|
|
103
|
+
'inline-flex items-center justify-center rounded-md transition-colors',
|
|
104
|
+
BADGE_SIZE_CLASS[size],
|
|
105
|
+
'border border-border-subtle bg-surface-sunken font-medium text-fg-muted',
|
|
106
|
+
];
|
|
107
|
+
if (invalid) parts.push(kitInvalidRecipe(true));
|
|
108
|
+
if (disabled) parts.push(kitDisabledRecipe('text'));
|
|
109
|
+
return parts.filter(Boolean).join(' ');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const isButton = !multiline && BUTTON_VARIANTS.has(variant);
|
|
113
|
+
const focusCls = kitFocusRingRecipe(isButton ? 'button' : 'control');
|
|
114
|
+
const disabledCls = kitDisabledRecipe(isButton ? 'button' : 'control');
|
|
115
|
+
const activeDisabledCls = disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
116
|
+
const invalidCls = kitInvalidRecipe(invalid);
|
|
117
|
+
|
|
118
|
+
if (isButton) {
|
|
119
|
+
const sz = BUTTON_SIZE_CLASS[size];
|
|
120
|
+
let middle = '';
|
|
121
|
+
switch (variant) {
|
|
122
|
+
case 'primary':
|
|
123
|
+
middle = `bg-primary ${sz.px} ${sz.text} font-medium text-primary-fg transition-colors enabled:hover:bg-primary-hover enabled:active:bg-primary-active`;
|
|
124
|
+
break;
|
|
125
|
+
case 'neutral':
|
|
126
|
+
middle = `border border-input bg-surface ${sz.px} ${sz.text} font-medium text-fg transition-colors enabled:hover:border-input-hover enabled:hover:bg-surface-sunken enabled:active:bg-border-subtle`;
|
|
127
|
+
break;
|
|
128
|
+
case 'danger':
|
|
129
|
+
middle = `bg-danger ${sz.px} ${sz.text} font-medium text-danger-fg transition-colors enabled:hover:bg-danger-hover enabled:active:bg-danger-active`;
|
|
130
|
+
break;
|
|
131
|
+
case 'ghost':
|
|
132
|
+
middle = `${sz.px} ${sz.text} font-medium text-fg transition-colors enabled:hover:bg-fg/8 enabled:active:bg-fg/12`;
|
|
133
|
+
break;
|
|
134
|
+
case 'tonal':
|
|
135
|
+
middle = `bg-primary-soft ${sz.px} ${sz.text} font-medium text-primary-on-soft transition-colors enabled:hover:bg-primary-soft/70 enabled:active:bg-primary-soft/50`;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
return [
|
|
139
|
+
`inline-flex ${sz.h} items-center justify-center ${sz.gap} rounded-md`,
|
|
140
|
+
middle,
|
|
141
|
+
focusCls,
|
|
142
|
+
disabledCls,
|
|
143
|
+
activeDisabledCls,
|
|
144
|
+
invalidCls,
|
|
145
|
+
].filter(Boolean).join(' ');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (multiline) {
|
|
149
|
+
const sz = MULTILINE_SIZE_CLASS[size];
|
|
150
|
+
return [
|
|
151
|
+
'block w-full appearance-none autofill-clear resize-none rounded-md border border-input bg-surface',
|
|
152
|
+
sz.px,
|
|
153
|
+
sz.py,
|
|
154
|
+
sz.text,
|
|
155
|
+
'text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover',
|
|
156
|
+
focusCls,
|
|
157
|
+
disabledCls,
|
|
158
|
+
'read-only:bg-surface-sunken',
|
|
159
|
+
activeDisabledCls,
|
|
160
|
+
invalidCls,
|
|
161
|
+
].filter(Boolean).join(' ');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 单行控件(Input / Select / Date 等)
|
|
165
|
+
const sz = SINGLE_LINE_SIZE_CLASS[size];
|
|
166
|
+
|
|
167
|
+
if (variant === 'filled') {
|
|
168
|
+
return [
|
|
169
|
+
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-transparent bg-surface-sunken ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-border focus-visible:bg-surface`,
|
|
170
|
+
focusCls,
|
|
171
|
+
disabledCls,
|
|
172
|
+
'read-only:bg-surface-sunken',
|
|
173
|
+
activeDisabledCls,
|
|
174
|
+
invalidCls,
|
|
175
|
+
].filter(Boolean).join(' ');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return [
|
|
179
|
+
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-input bg-surface ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover`,
|
|
180
|
+
focusCls,
|
|
181
|
+
disabledCls,
|
|
182
|
+
'read-only:bg-surface-sunken',
|
|
183
|
+
activeDisabledCls,
|
|
184
|
+
invalidCls,
|
|
185
|
+
].filter(Boolean).join(' ');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
|
|
189
|
+
'outline',
|
|
190
|
+
'filled',
|
|
191
|
+
'primary',
|
|
192
|
+
'neutral',
|
|
193
|
+
'danger',
|
|
194
|
+
'ghost',
|
|
195
|
+
'tonal',
|
|
196
|
+
'badge',
|
|
197
|
+
]);
|
|
198
|
+
const ALL_SIZES: readonly KitControlSize[] = Object.freeze(['sm', 'md', 'lg']);
|
|
199
|
+
const BOOLEAN_FLAGS: readonly boolean[] = Object.freeze([false, true]);
|
|
200
|
+
|
|
201
|
+
function collectControlRecipeCandidates(): string[] {
|
|
202
|
+
const classes: string[] = [];
|
|
203
|
+
for (const variant of ALL_VARIANTS) {
|
|
204
|
+
for (const size of ALL_SIZES) {
|
|
205
|
+
for (const multiline of BOOLEAN_FLAGS) {
|
|
206
|
+
for (const disabled of BOOLEAN_FLAGS) {
|
|
207
|
+
for (const invalid of BOOLEAN_FLAGS) {
|
|
208
|
+
classes.push(kitControlRecipe({ variant, size, multiline, disabled, invalid }));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return classes;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const KIT_CONTROL_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
218
|
+
collectControlRecipeCandidates(),
|
|
219
|
+
);
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// soma-kit 六份配方层统一出口(control / container / typography / table-row / overlay / state)
|
|
2
|
+
// 与 data-kit-part 标准部件协议常量。
|
|
3
|
+
|
|
4
|
+
import { classCandidates } from '../base/class-candidates';
|
|
5
|
+
import {
|
|
6
|
+
KIT_STATE_RECIPE_CLASS_CANDIDATES,
|
|
7
|
+
kitDisabledRecipe,
|
|
8
|
+
kitFocusRingRecipe,
|
|
9
|
+
kitInvalidRecipe,
|
|
10
|
+
kitSelectedRecipe,
|
|
11
|
+
type KitDisabledKind,
|
|
12
|
+
type KitFocusRingKind,
|
|
13
|
+
type KitSelectedTone,
|
|
14
|
+
} from './state';
|
|
15
|
+
import {
|
|
16
|
+
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
17
|
+
KIT_PART_BADGE,
|
|
18
|
+
KIT_PART_BUTTON,
|
|
19
|
+
KIT_PART_CONTROL,
|
|
20
|
+
KIT_PART_TEXTAREA,
|
|
21
|
+
kitControlPartOf,
|
|
22
|
+
kitControlRecipe,
|
|
23
|
+
kitControlSizeRecipe,
|
|
24
|
+
type KitControlPart,
|
|
25
|
+
type KitControlRecipeOptions,
|
|
26
|
+
type KitControlSize,
|
|
27
|
+
type KitControlVariant,
|
|
28
|
+
} from './control';
|
|
29
|
+
import {
|
|
30
|
+
KIT_CONTAINER_EMPHASIS_CLASSES,
|
|
31
|
+
KIT_CONTAINER_RECIPE_CLASS_CANDIDATES,
|
|
32
|
+
KIT_METRIC_HIGHLIGHT_CLASS,
|
|
33
|
+
KIT_PART_CARD,
|
|
34
|
+
KIT_PART_PANEL,
|
|
35
|
+
KIT_PART_SECTION,
|
|
36
|
+
KIT_PART_WELL,
|
|
37
|
+
KIT_SURFACE_RECIPE_CLASSES,
|
|
38
|
+
KIT_VIEW_HIGHLIGHT_CLASS,
|
|
39
|
+
kitContainerEmphasisRecipe,
|
|
40
|
+
kitContainerPartOf,
|
|
41
|
+
kitContainerRecipe,
|
|
42
|
+
kitHighlightRecipe,
|
|
43
|
+
kitSlotSurfaceRecipe,
|
|
44
|
+
type KitContainerEmphasis,
|
|
45
|
+
type KitContainerPadding,
|
|
46
|
+
type KitContainerPart,
|
|
47
|
+
type KitContainerRecipeOptions,
|
|
48
|
+
type KitContainerSurface,
|
|
49
|
+
type KitHighlightKind,
|
|
50
|
+
type KitSlotSurface,
|
|
51
|
+
} from './container';
|
|
52
|
+
import {
|
|
53
|
+
KIT_FIELD_EMPHASIS_CLASSES,
|
|
54
|
+
KIT_PART_STAT_VALUE,
|
|
55
|
+
KIT_PART_TITLE_DIALOG,
|
|
56
|
+
KIT_PART_TITLE_PAGE,
|
|
57
|
+
KIT_PART_TITLE_SECTION,
|
|
58
|
+
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
59
|
+
KIT_TYPOGRAPHY_RECIPE_MAP,
|
|
60
|
+
kitFieldEmphasisRecipe,
|
|
61
|
+
kitTypographyPartOf,
|
|
62
|
+
kitTypographyRecipe,
|
|
63
|
+
type KitFieldEmphasis,
|
|
64
|
+
type KitTypographyPart,
|
|
65
|
+
type KitTypographyRecipeRole,
|
|
66
|
+
} from './typography';
|
|
67
|
+
import {
|
|
68
|
+
KIT_PART_TABLE,
|
|
69
|
+
KIT_PART_TABLE_CELL,
|
|
70
|
+
KIT_PART_TABLE_HEAD,
|
|
71
|
+
KIT_PART_TABLE_ROW,
|
|
72
|
+
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
73
|
+
kitTableCellRecipe,
|
|
74
|
+
type KitTableAlign,
|
|
75
|
+
type KitTableCellRecipeOptions,
|
|
76
|
+
type KitTablePart,
|
|
77
|
+
} from './table-row';
|
|
78
|
+
import {
|
|
79
|
+
KIT_OVERLAY_RECIPE_CLASS_CANDIDATES,
|
|
80
|
+
KIT_PART_DIALOG,
|
|
81
|
+
KIT_PART_DRAWER,
|
|
82
|
+
KIT_PART_POPOVER,
|
|
83
|
+
KIT_PART_TOAST,
|
|
84
|
+
kitOverlayBodyRecipe,
|
|
85
|
+
kitOverlayFooterRecipe,
|
|
86
|
+
kitOverlayHeaderRecipe,
|
|
87
|
+
kitOverlayPartOf,
|
|
88
|
+
kitOverlayRecipe,
|
|
89
|
+
kitPopoverActionsRecipe,
|
|
90
|
+
kitToastActionRecipe,
|
|
91
|
+
kitToastCloseRecipe,
|
|
92
|
+
kitToastTitleRecipe,
|
|
93
|
+
type KitOverlayKind,
|
|
94
|
+
type KitOverlayPart,
|
|
95
|
+
type KitOverlayRecipeOptions,
|
|
96
|
+
type KitOverlaySize,
|
|
97
|
+
} from './overlay';
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
// state
|
|
101
|
+
kitFocusRingRecipe,
|
|
102
|
+
kitDisabledRecipe,
|
|
103
|
+
kitSelectedRecipe,
|
|
104
|
+
kitInvalidRecipe,
|
|
105
|
+
KIT_STATE_RECIPE_CLASS_CANDIDATES,
|
|
106
|
+
// control
|
|
107
|
+
KIT_PART_CONTROL,
|
|
108
|
+
KIT_PART_BUTTON,
|
|
109
|
+
KIT_PART_TEXTAREA,
|
|
110
|
+
KIT_PART_BADGE,
|
|
111
|
+
kitControlRecipe,
|
|
112
|
+
kitControlSizeRecipe,
|
|
113
|
+
kitControlPartOf,
|
|
114
|
+
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
115
|
+
// container
|
|
116
|
+
KIT_PART_CARD,
|
|
117
|
+
KIT_PART_PANEL,
|
|
118
|
+
KIT_PART_SECTION,
|
|
119
|
+
KIT_PART_WELL,
|
|
120
|
+
kitContainerRecipe,
|
|
121
|
+
kitContainerPartOf,
|
|
122
|
+
kitSlotSurfaceRecipe,
|
|
123
|
+
kitContainerEmphasisRecipe,
|
|
124
|
+
kitHighlightRecipe,
|
|
125
|
+
KIT_SURFACE_RECIPE_CLASSES,
|
|
126
|
+
KIT_CONTAINER_EMPHASIS_CLASSES,
|
|
127
|
+
KIT_METRIC_HIGHLIGHT_CLASS,
|
|
128
|
+
KIT_VIEW_HIGHLIGHT_CLASS,
|
|
129
|
+
KIT_CONTAINER_RECIPE_CLASS_CANDIDATES,
|
|
130
|
+
// typography
|
|
131
|
+
KIT_PART_TITLE_PAGE,
|
|
132
|
+
KIT_PART_TITLE_SECTION,
|
|
133
|
+
KIT_PART_TITLE_DIALOG,
|
|
134
|
+
KIT_PART_STAT_VALUE,
|
|
135
|
+
KIT_TYPOGRAPHY_RECIPE_MAP,
|
|
136
|
+
kitTypographyRecipe,
|
|
137
|
+
kitTypographyPartOf,
|
|
138
|
+
kitFieldEmphasisRecipe,
|
|
139
|
+
KIT_FIELD_EMPHASIS_CLASSES,
|
|
140
|
+
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
141
|
+
// table-row
|
|
142
|
+
KIT_PART_TABLE,
|
|
143
|
+
KIT_PART_TABLE_ROW,
|
|
144
|
+
KIT_PART_TABLE_HEAD,
|
|
145
|
+
KIT_PART_TABLE_CELL,
|
|
146
|
+
kitTableCellRecipe,
|
|
147
|
+
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
148
|
+
// overlay
|
|
149
|
+
KIT_PART_DIALOG,
|
|
150
|
+
KIT_PART_DRAWER,
|
|
151
|
+
KIT_PART_POPOVER,
|
|
152
|
+
KIT_PART_TOAST,
|
|
153
|
+
kitOverlayRecipe,
|
|
154
|
+
kitToastActionRecipe,
|
|
155
|
+
kitToastCloseRecipe,
|
|
156
|
+
kitToastTitleRecipe,
|
|
157
|
+
kitOverlayHeaderRecipe,
|
|
158
|
+
kitOverlayBodyRecipe,
|
|
159
|
+
kitOverlayFooterRecipe,
|
|
160
|
+
kitPopoverActionsRecipe,
|
|
161
|
+
kitOverlayPartOf,
|
|
162
|
+
KIT_OVERLAY_RECIPE_CLASS_CANDIDATES,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type {
|
|
166
|
+
KitFocusRingKind,
|
|
167
|
+
KitDisabledKind,
|
|
168
|
+
KitSelectedTone,
|
|
169
|
+
KitControlPart,
|
|
170
|
+
KitControlSize,
|
|
171
|
+
KitControlVariant,
|
|
172
|
+
KitControlRecipeOptions,
|
|
173
|
+
KitContainerPart,
|
|
174
|
+
KitContainerSurface,
|
|
175
|
+
KitContainerEmphasis,
|
|
176
|
+
KitContainerPadding,
|
|
177
|
+
KitContainerRecipeOptions,
|
|
178
|
+
KitSlotSurface,
|
|
179
|
+
KitHighlightKind,
|
|
180
|
+
KitFieldEmphasis,
|
|
181
|
+
KitTypographyPart,
|
|
182
|
+
KitTypographyRecipeRole,
|
|
183
|
+
KitTablePart,
|
|
184
|
+
KitTableAlign,
|
|
185
|
+
KitTableCellRecipeOptions,
|
|
186
|
+
KitOverlayPart,
|
|
187
|
+
KitOverlayKind,
|
|
188
|
+
KitOverlaySize,
|
|
189
|
+
KitOverlayRecipeOptions,
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const KIT_PART_ATTRIBUTE = 'data-kit-part' as const;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 控件质感标记(质感维度的挂点):只标「有可见底色 / 边框」的控件,结构 CSS 的 `:where([data-kit-face=…])` 据此画浮雕线 / 内凹影。
|
|
196
|
+
* raised = 可浮起控件(实心 / 描边按钮、soft / solid 标签);field = 带边框的输入外壳(有装饰的输入把标记打在外壳上,不打在里面的无边 input)。
|
|
197
|
+
* 幽灵钮、仅描边标签、状态点没有「面」,不带标记。
|
|
198
|
+
* 注意:`data-kit-surface`(card / flush / plain)是容器表面,与本标记是两个属性,互不混用。
|
|
199
|
+
*/
|
|
200
|
+
export const KIT_FACE_ATTRIBUTE = 'data-kit-face' as const;
|
|
201
|
+
export const KIT_FACE_RAISED = 'raised' as const;
|
|
202
|
+
export const KIT_FACE_FIELD = 'field' as const;
|
|
203
|
+
/** tab = 选中态有底色 / 描边的页签(药丸 / 卡片 / 分段式):静态标记,结构 CSS 按 aria-selected="true" 才画浮雕线;仅下划线式页签不标 */
|
|
204
|
+
export const KIT_FACE_TAB = 'tab' as const;
|
|
205
|
+
export type KitFaceKind = typeof KIT_FACE_RAISED | typeof KIT_FACE_FIELD | typeof KIT_FACE_TAB;
|
|
206
|
+
|
|
207
|
+
/** 写 / 清控件质感标记(kind 为 null 即清除;幂等) */
|
|
208
|
+
export function setKitFace(el: Element, kind: KitFaceKind | null): void {
|
|
209
|
+
if (kind === null) {
|
|
210
|
+
if (el.hasAttribute(KIT_FACE_ATTRIBUTE)) el.removeAttribute(KIT_FACE_ATTRIBUTE);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (el.getAttribute(KIT_FACE_ATTRIBUTE) !== kind) el.setAttribute(KIT_FACE_ATTRIBUTE, kind);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 「在流内 position: fixed」标记:kit 自己渲染、没有经 mountKitOverlay / 浮层端口搬走的 fixed 元素(抽屉、弹层壳、浮动按钮)打此标记。
|
|
218
|
+
* 结构 CSS 的毛玻璃规则据此跳过「内含此类元素」的容器——backdrop-filter 会让容器成为 fixed 后代的包含块,fixed 元素会被困在容器里。
|
|
219
|
+
*/
|
|
220
|
+
export const KIT_FIXED_ATTRIBUTE = 'data-kit-fixed' as const;
|
|
221
|
+
|
|
222
|
+
/** 开 / 关在流内 fixed 标记(动态显隐的 fixed 元素只在真处于 fixed 时才打;幂等) */
|
|
223
|
+
export function setKitFixed(el: Element, on: boolean): void {
|
|
224
|
+
if (on) {
|
|
225
|
+
if (!el.hasAttribute(KIT_FIXED_ATTRIBUTE)) el.setAttribute(KIT_FIXED_ATTRIBUTE, '');
|
|
226
|
+
} else if (el.hasAttribute(KIT_FIXED_ATTRIBUTE)) {
|
|
227
|
+
el.removeAttribute(KIT_FIXED_ATTRIBUTE);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export const KIT_PARTS = Object.freeze({
|
|
232
|
+
control: KIT_PART_CONTROL,
|
|
233
|
+
button: KIT_PART_BUTTON,
|
|
234
|
+
textarea: KIT_PART_TEXTAREA,
|
|
235
|
+
badge: KIT_PART_BADGE,
|
|
236
|
+
card: KIT_PART_CARD,
|
|
237
|
+
panel: KIT_PART_PANEL,
|
|
238
|
+
section: KIT_PART_SECTION,
|
|
239
|
+
well: KIT_PART_WELL,
|
|
240
|
+
titlePage: KIT_PART_TITLE_PAGE,
|
|
241
|
+
titleSection: KIT_PART_TITLE_SECTION,
|
|
242
|
+
titleDialog: KIT_PART_TITLE_DIALOG,
|
|
243
|
+
statValue: KIT_PART_STAT_VALUE,
|
|
244
|
+
table: KIT_PART_TABLE,
|
|
245
|
+
tableRow: KIT_PART_TABLE_ROW,
|
|
246
|
+
tableHead: KIT_PART_TABLE_HEAD,
|
|
247
|
+
tableCell: KIT_PART_TABLE_CELL,
|
|
248
|
+
dialog: KIT_PART_DIALOG,
|
|
249
|
+
drawer: KIT_PART_DRAWER,
|
|
250
|
+
popover: KIT_PART_POPOVER,
|
|
251
|
+
toast: KIT_PART_TOAST,
|
|
252
|
+
} as const);
|
|
253
|
+
|
|
254
|
+
export type KitPartValue = (typeof KIT_PARTS)[keyof typeof KIT_PARTS];
|
|
255
|
+
|
|
256
|
+
export const KIT_RECIPES_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
257
|
+
KIT_STATE_RECIPE_CLASS_CANDIDATES,
|
|
258
|
+
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
259
|
+
KIT_CONTAINER_RECIPE_CLASS_CANDIDATES,
|
|
260
|
+
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
261
|
+
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
262
|
+
KIT_OVERLAY_RECIPE_CLASS_CANDIDATES,
|
|
263
|
+
);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// 浮层配方(overlay.ts):覆盖 dialog / drawer / popover / toast 四类浮层容器,
|
|
2
|
+
// 以及头(shrink-0)、体(flex-1 min-h-0 overflow-y-auto)、尾(shrink-0)三段式固定外壳子配方。
|
|
3
|
+
|
|
4
|
+
import { classCandidates } from '../base/class-candidates';
|
|
5
|
+
|
|
6
|
+
export const KIT_PART_DIALOG = 'dialog' as const;
|
|
7
|
+
export const KIT_PART_DRAWER = 'drawer' as const;
|
|
8
|
+
export const KIT_PART_POPOVER = 'popover' as const;
|
|
9
|
+
export const KIT_PART_TOAST = 'toast' as const;
|
|
10
|
+
|
|
11
|
+
export type KitOverlayPart =
|
|
12
|
+
| typeof KIT_PART_DIALOG
|
|
13
|
+
| typeof KIT_PART_DRAWER
|
|
14
|
+
| typeof KIT_PART_POPOVER
|
|
15
|
+
| typeof KIT_PART_TOAST;
|
|
16
|
+
|
|
17
|
+
export type KitOverlayKind = 'dialog' | 'drawer' | 'popover' | 'toast';
|
|
18
|
+
export type KitOverlaySize = 'sm' | 'md' | 'lg' | 'xl';
|
|
19
|
+
|
|
20
|
+
export interface KitOverlayRecipeOptions {
|
|
21
|
+
kind: KitOverlayKind;
|
|
22
|
+
size?: KitOverlaySize;
|
|
23
|
+
toned?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const DIALOG_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.freeze({
|
|
27
|
+
sm: 'max-w-sm',
|
|
28
|
+
md: 'max-w-lg',
|
|
29
|
+
lg: 'max-w-2xl',
|
|
30
|
+
xl: 'max-w-4xl',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const DRAWER_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.freeze({
|
|
34
|
+
sm: 'w-80 max-w-full',
|
|
35
|
+
md: 'w-96 max-w-full',
|
|
36
|
+
lg: 'w-[32rem] max-w-full',
|
|
37
|
+
xl: 'w-[42rem] max-w-full',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const POPOVER_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.freeze({
|
|
41
|
+
sm: 'w-48',
|
|
42
|
+
md: 'w-64',
|
|
43
|
+
lg: 'w-80',
|
|
44
|
+
xl: 'w-96',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const TOAST_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.freeze({
|
|
48
|
+
sm: 'w-72 max-w-full',
|
|
49
|
+
md: 'w-80 max-w-full',
|
|
50
|
+
lg: 'w-96 max-w-full',
|
|
51
|
+
xl: 'w-[28rem] max-w-full',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const TOAST_TONED_SKELETON_CLASS =
|
|
55
|
+
'flex items-start gap-3 rounded-lg border border-border-subtle px-4 py-3 text-sm shadow-lg';
|
|
56
|
+
|
|
57
|
+
const OVERLAY_SKELETON_CLASS: Readonly<Record<KitOverlayKind, string>> = Object.freeze({
|
|
58
|
+
dialog:
|
|
59
|
+
'flex flex-col max-h-[85vh] w-full overflow-hidden rounded-xl border border-border-strong bg-surface-raised text-fg shadow-xl',
|
|
60
|
+
drawer:
|
|
61
|
+
'flex flex-col h-full overflow-hidden border-s border-border-strong bg-surface-raised text-fg shadow-xl',
|
|
62
|
+
popover:
|
|
63
|
+
'rounded-lg border border-border-subtle bg-surface-raised text-fg shadow-lg',
|
|
64
|
+
toast:
|
|
65
|
+
'flex items-start gap-3 rounded-lg border border-border bg-surface-raised p-4 text-sm text-fg shadow-lg',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const OVERLAY_HEADER_CLASS =
|
|
69
|
+
'flex shrink-0 items-center justify-between gap-4 border-b border-border-subtle px-5 py-3';
|
|
70
|
+
const OVERLAY_BODY_CLASS =
|
|
71
|
+
'flex-1 min-h-0 overflow-y-auto p-5';
|
|
72
|
+
const OVERLAY_FOOTER_CLASS =
|
|
73
|
+
'flex shrink-0 items-center justify-end gap-2 border-t border-border-subtle px-5 py-3';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 根据浮层 kind 返回对应的 data-kit-part 标识值。
|
|
77
|
+
*/
|
|
78
|
+
export function kitOverlayPartOf(kind: KitOverlayKind = 'dialog'): KitOverlayPart {
|
|
79
|
+
if (kind === 'drawer') return KIT_PART_DRAWER;
|
|
80
|
+
if (kind === 'popover') return KIT_PART_POPOVER;
|
|
81
|
+
if (kind === 'toast') return KIT_PART_TOAST;
|
|
82
|
+
return KIT_PART_DIALOG;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 浮层主面板配方纯函数:按 kind(dialog / drawer / popover / toast)与 size(sm / md / lg / xl)返回标准类串。
|
|
87
|
+
* 下拉浮层(popover)与弹窗(dialog)固定采用容器圆角(rounded-lg / rounded-xl),绝不落入胶囊圆角(rounded-full)。
|
|
88
|
+
*/
|
|
89
|
+
export function kitOverlayRecipe(options: KitOverlayRecipeOptions = { kind: 'dialog' }): string {
|
|
90
|
+
const kind: KitOverlayKind = options.kind ?? 'dialog';
|
|
91
|
+
const size: KitOverlaySize = options.size ?? 'md';
|
|
92
|
+
|
|
93
|
+
const skeleton =
|
|
94
|
+
kind === 'toast' && options.toned === true
|
|
95
|
+
? TOAST_TONED_SKELETON_CLASS
|
|
96
|
+
: (OVERLAY_SKELETON_CLASS[kind] ?? OVERLAY_SKELETON_CLASS.dialog);
|
|
97
|
+
const sizeMap =
|
|
98
|
+
kind === 'drawer'
|
|
99
|
+
? DRAWER_SIZE_CLASS
|
|
100
|
+
: kind === 'popover'
|
|
101
|
+
? POPOVER_SIZE_CLASS
|
|
102
|
+
: kind === 'toast'
|
|
103
|
+
? TOAST_SIZE_CLASS
|
|
104
|
+
: DIALOG_SIZE_CLASS;
|
|
105
|
+
const sizeCls = sizeMap[size] ?? sizeMap.md;
|
|
106
|
+
|
|
107
|
+
return `${skeleton} ${sizeCls}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 浮层头部子配方(固定头部 shrink-0,不随主体滚动)。
|
|
112
|
+
*/
|
|
113
|
+
export function kitOverlayHeaderRecipe(): string {
|
|
114
|
+
return OVERLAY_HEADER_CLASS;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 浮层主体子配方(独立滚动区 flex-1 min-h-0 overflow-y-auto)。
|
|
119
|
+
*/
|
|
120
|
+
export function kitOverlayBodyRecipe(): string {
|
|
121
|
+
return OVERLAY_BODY_CLASS;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 浮层尾部子配方(固定底部操作栏 shrink-0,不随主体滚动)。
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
const POPOVER_ACTIONS_CLASS = 'flex items-center justify-end gap-2';
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 气泡确认操作条子配方(产出设计规范基准操作条流式布局类串,无顶部分割线与弹窗页脚内边距)。
|
|
132
|
+
*/
|
|
133
|
+
export function kitPopoverActionsRecipe(): string {
|
|
134
|
+
return POPOVER_ACTIONS_CLASS;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function kitOverlayFooterRecipe(): string {
|
|
138
|
+
return OVERLAY_FOOTER_CLASS;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const TOAST_ACTION_CLASS =
|
|
142
|
+
'ms-auto rounded-md px-1 font-medium underline transition-colors hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
143
|
+
const TOAST_CLOSE_CLASS =
|
|
144
|
+
'ms-auto inline-flex h-6 w-6 min-h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition-colors hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
145
|
+
const TOAST_TITLE_CLASS = 'font-semibold';
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 通知条内联动作子配方(按钮风格,文字下划线,右靠齐)。
|
|
149
|
+
*/
|
|
150
|
+
export function kitToastActionRecipe(): string {
|
|
151
|
+
return TOAST_ACTION_CLASS;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 通知条关闭按钮微控件子配方(热区保底 24px,右靠齐)。
|
|
156
|
+
*/
|
|
157
|
+
export function kitToastCloseRecipe(): string {
|
|
158
|
+
return TOAST_CLOSE_CLASS;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 通知条标题子配方(纯加粗,文字颜色自然继承容器语义前景色)。
|
|
163
|
+
*/
|
|
164
|
+
export function kitToastTitleRecipe(): string {
|
|
165
|
+
return TOAST_TITLE_CLASS;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const KIT_OVERLAY_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
169
|
+
Object.values(OVERLAY_SKELETON_CLASS),
|
|
170
|
+
TOAST_TONED_SKELETON_CLASS,
|
|
171
|
+
Object.values(DIALOG_SIZE_CLASS),
|
|
172
|
+
Object.values(DRAWER_SIZE_CLASS),
|
|
173
|
+
Object.values(POPOVER_SIZE_CLASS),
|
|
174
|
+
Object.values(TOAST_SIZE_CLASS),
|
|
175
|
+
OVERLAY_HEADER_CLASS,
|
|
176
|
+
OVERLAY_BODY_CLASS,
|
|
177
|
+
OVERLAY_FOOTER_CLASS,
|
|
178
|
+
POPOVER_ACTIONS_CLASS,
|
|
179
|
+
TOAST_ACTION_CLASS,
|
|
180
|
+
TOAST_CLOSE_CLASS,
|
|
181
|
+
TOAST_TITLE_CLASS,
|
|
182
|
+
);
|