soma-kit 0.1.12 → 0.1.13
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 +5 -4
- package/bin/soma-kit.mjs +31 -1
- package/bin/soma.mjs +0 -0
- package/package.json +5 -4
- package/spec/generated/kit-app.schema.json +158 -4
- package/spec/generated/kit-page.schema.json +139 -5
- package/spec/kit-grammar.json +438 -87
- package/spec/kit-grammar.schema.json +11 -3
- package/src/app/app-config.ts +83 -5
- package/src/app/component-gate.ts +271 -13
- package/src/app/define-kit-app.ts +2 -2
- package/src/app/define-kit-view.ts +9 -5
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/index.ts +17 -5
- package/src/app/kit-view-context.ts +163 -14
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +3 -1
- package/src/app/server.ts +40 -3
- package/src/app/theme-runtime.ts +4 -0
- package/src/base/action-busy.ts +101 -4
- package/src/base/action-slots.ts +13 -2
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/button.ts +57 -12
- package/src/base/check-core.ts +8 -0
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +21 -2
- package/src/base/color-picker.ts +10 -5
- package/src/base/command-palette.ts +1 -1
- package/src/base/context-menu.ts +10 -7
- package/src/base/date-range.ts +7 -7
- package/src/base/date.ts +55 -16
- package/src/base/delta.ts +72 -0
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +1 -1
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/index.ts +27 -9
- package/src/base/listbox-core.ts +6 -5
- package/src/base/loading-gate.ts +140 -87
- package/src/base/mentions.ts +2 -1
- package/src/base/menu-button.ts +23 -12
- package/src/base/menu-core.ts +37 -8
- package/src/base/motion/hover-3d.ts +1 -1
- package/src/base/motion/marquee.ts +1 -1
- package/src/base/otp.ts +5 -4
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/popover.ts +9 -9
- package/src/base/popup.ts +67 -8
- package/src/base/portal-core.ts +4 -0
- package/src/base/qty-stepper.ts +5 -5
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +19 -2
- package/src/base/rating.ts +11 -6
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +24 -22
- package/src/base/shared.ts +169 -23
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +6 -6
- package/src/base/switch.ts +10 -5
- package/src/base/tag-input.ts +6 -6
- package/src/base/tag.ts +63 -33
- package/src/base/text.ts +42 -13
- package/src/base/time-picker.ts +7 -5
- package/src/base/tree-select.ts +6 -4
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +15 -10
- package/src/base/view-transition.ts +77 -0
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +2 -2
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +2 -1
- package/src/biz/checkout-page/shell.ts +4 -3
- package/src/biz/import-wizard/shell.ts +2 -1
- package/src/biz/link/hub.ts +23 -5
- package/src/biz/link/shared.ts +23 -12
- package/src/biz/master-sub/compile.ts +102 -10
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +4 -1
- package/src/biz/multi-board/shell.ts +8 -5
- package/src/biz/notification-center/shell.ts +6 -4
- package/src/biz/page-templates/result-page/shell.ts +2 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +2 -2
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +2 -1
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +6 -0
- package/src/biz/shared/compile-helpers.ts +18 -0
- package/src/biz/shared/coordinator.ts +7 -30
- package/src/biz/shared/index.ts +5 -0
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +139 -10
- package/src/biz/shared/pipes.ts +11 -5
- package/src/biz/shared/remove-wire.ts +4 -19
- package/src/biz/shared/runtime-hub.ts +10 -0
- package/src/biz/single-form/compile.ts +3 -2
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +22 -160
- package/src/biz/standard-crud/shell.ts +16 -44
- package/src/biz/step-form/shell.ts +5 -5
- package/src/cli/kit-cli.ts +138 -13
- package/src/cli/kit-init.ts +6 -1
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -0
- package/src/cli/view-writes.ts +69 -60
- package/src/compile/closed-set.ts +65 -4
- package/src/compile/compile-page.ts +51 -7
- package/src/compile/component-candidates.ts +12 -1
- package/src/compile/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -0
- package/src/compile/remove-guard.ts +10 -7
- package/src/compile/styles.ts +36 -8
- package/src/compile/types.ts +13 -1
- package/src/compile/view-check.ts +149 -16
- package/src/data/amount-breakdown.ts +6 -1
- package/src/data/approval-flow.ts +1 -1
- package/src/data/assignment-picker.ts +53 -27
- package/src/data/async-result-panel.ts +49 -3
- package/src/data/breadcrumbs.ts +3 -2
- package/src/data/calendar.ts +2 -2
- package/src/data/carousel.ts +8 -6
- package/src/data/chart.ts +141 -10
- package/src/data/checklist.ts +18 -5
- package/src/data/code-view.ts +8 -4
- package/src/data/comment-thread.ts +2 -2
- package/src/data/confirm-dialog.ts +71 -18
- package/src/data/context-menu.ts +3 -3
- package/src/data/dock.ts +1 -1
- package/src/data/embed.ts +231 -29
- package/src/data/field-mapper.ts +4 -4
- package/src/data/flow-editor-contract.ts +7 -0
- package/src/data/flow-editor.ts +25 -9
- package/src/data/flow-node-options.ts +33 -3
- package/src/data/gantt.ts +5 -2
- package/src/data/hero.ts +2 -1
- package/src/data/image-viewer.ts +7 -4
- package/src/data/index.ts +6 -1
- package/src/data/item-list.ts +18 -10
- package/src/data/kanban.ts +39 -10
- package/src/data/media-grid.ts +6 -1
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +45 -13
- package/src/data/mockup.ts +8 -4
- package/src/data/modal-dialog.ts +29 -9
- package/src/data/navbar.ts +5 -5
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +21 -6
- package/src/data/object-form.ts +354 -48
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +17 -7
- package/src/data/permission-matrix.ts +33 -11
- package/src/data/permission-tree.ts +47 -22
- package/src/data/pricing-table.ts +21 -11
- package/src/data/prompt-dialog.ts +165 -0
- package/src/data/reaction-bar.ts +6 -4
- package/src/data/record-card.ts +23 -2
- package/src/data/record-picker.ts +13 -7
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +17 -1
- package/src/data/row-editor.ts +79 -26
- package/src/data/rule-builder.ts +8 -8
- package/src/data/shape-util.ts +23 -9
- package/src/data/stat-group.ts +170 -29
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +2 -0
- package/src/data/steps.ts +8 -3
- package/src/data/survey.ts +3 -3
- package/src/data/system-switcher.ts +1 -1
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +17 -6
- package/src/data/tour-guide.ts +1 -1
- package/src/data/transfer.ts +36 -16
- package/src/data/tree-table.ts +62 -36
- package/src/data/tree.ts +22 -2
- package/src/data/virtual-rows.ts +19 -10
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/page-bar.ts +14 -13
- package/src/frames/page-status.ts +7 -5
- package/src/frames/shared.ts +15 -10
- package/src/frames/split-frame/shell.ts +1 -1
- package/src/frames/tabs-frame/shell.ts +2 -1
- package/src/frames/tabs-frame/wiring.ts +1 -0
- package/src/frames/top-main-frame.ts +2 -2
- package/src/frames/workspace-frame/extras.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +2 -2
- package/src/frames/workspace-frame/view.ts +141 -33
- package/src/generated/kit-grammar-runtime.ts +239 -55
- package/src/i18n/kit-text.ts +63 -4
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/object-renderer/arrange.ts +42 -8
- package/src/object-renderer/collection-parts.ts +241 -60
- package/src/object-renderer/collection-table.ts +109 -5
- package/src/object-renderer/collection.ts +174 -36
- package/src/object-renderer/compile-data.ts +28 -3
- package/src/object-renderer/defaults.ts +30 -2
- package/src/object-renderer/display-checks.ts +1 -1
- package/src/object-renderer/emit-events.ts +43 -9
- package/src/object-renderer/emit-static.ts +370 -30
- package/src/object-renderer/form-detail.ts +1 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/render-object.ts +54 -6
- package/src/object-renderer/request-actions.ts +4 -2
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +135 -27
- package/src/object-renderer/table-tools.ts +12 -11
- package/src/object-renderer/types.ts +78 -7
- package/src/object-renderer/view-binding.ts +205 -8
- package/src/page-target/intent-schema.ts +11 -0
- package/src/page-target/target.ts +5 -1
- package/src/recipes/container.ts +46 -1
- package/src/recipes/control.ts +70 -12
- package/src/recipes/index.ts +49 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +75 -17
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +34 -5
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +40 -3
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +13 -1
- package/src/shared/confirm-decl.ts +118 -0
- package/src/shared/envelope.ts +2 -2
- package/src/shared/paged-list-adapter.ts +15 -240
- package/src/shared/theme-runtime-shared.ts +6 -1
- package/src/theme/index.ts +1 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +372 -12
- package/src/theme/kit-theme.tpl +372 -12
- package/src/theme/nine-dim-structure.ts +177 -7
- package/src/theme/surface-layers.ts +4 -0
- package/src/theme/theme-tokens.ts +53 -13
- package/src/theme/theme-types.ts +32 -0
- package/src/biz/shared/remove-key.ts +0 -6
|
@@ -27,8 +27,12 @@ import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
|
27
27
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
28
28
|
import { bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
29
29
|
import { kitIcon } from '../base/icons';
|
|
30
|
+
import { markCheckBox } from '../base/check-core';
|
|
30
31
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
31
|
-
import { setKitFace } from '../recipes';
|
|
32
|
+
import { kitControlRecipe, setKitFace } from '../recipes';
|
|
33
|
+
import {
|
|
34
|
+
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
35
|
+
} from '../recipes/overlay';
|
|
32
36
|
import { kitBusyOf, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
33
37
|
import { classTokens, keyMap, mk, recOf } from './shape-util';
|
|
34
38
|
import { envelopeOf } from './permission-tree';
|
|
@@ -36,7 +40,7 @@ import { attrEsc } from './d9-util';
|
|
|
36
40
|
|
|
37
41
|
// ── 类串表:全部完整写死,不拼接片段 ──
|
|
38
42
|
|
|
39
|
-
const ROOT_CLASS =
|
|
43
|
+
const ROOT_CLASS = `@container flex h-full flex-col gap-4 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
|
|
40
44
|
const HELP_CLASS = 'text-sm text-fg-muted';
|
|
41
45
|
const SUBJECT_CLASS = 'flex flex-wrap items-center gap-4';
|
|
42
46
|
const SUBJECT_ITEM_CLASS = 'flex items-center gap-2';
|
|
@@ -45,8 +49,6 @@ const STRONG_CLASS = 'text-sm font-semibold text-fg';
|
|
|
45
49
|
const ALERT_CLASS = 'rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
46
50
|
const GRID_CLASS = 'grid grid-cols-12 gap-4';
|
|
47
51
|
const MAIN_FULL_CLASS = 'col-span-12';
|
|
48
|
-
const MAIN_SPLIT_CLASS = 'col-span-12 @md:col-span-7';
|
|
49
|
-
const SIDE_CLASS = 'col-span-12 @md:col-span-5';
|
|
50
52
|
const MAIN_INNER_CLASS = 'flex flex-col gap-3';
|
|
51
53
|
const SIDE_INNER_CLASS = 'flex flex-col gap-2';
|
|
52
54
|
const HEAD_CLASS = 'flex items-center justify-between gap-3';
|
|
@@ -55,16 +57,16 @@ const SUMMARY_CLASS = 'text-sm text-fg-muted';
|
|
|
55
57
|
const CHANGES_CLASS = 'text-sm text-fg-muted';
|
|
56
58
|
const TOOLS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
57
59
|
const SEARCH_CLASS = 'block h-9 min-w-40 flex-1 appearance-none autofill-clear rounded-md border border-border bg-surface px-3 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
58
|
-
const TOOL_BTN_CLASS = 'inline-flex h-9 items-center justify-center rounded-md border border-
|
|
59
|
-
const LIST_CLASS = 'flex flex-col
|
|
60
|
-
const GROUP_CLASS = 'flex flex-col
|
|
60
|
+
const TOOL_BTN_CLASS = 'inline-flex h-9 items-center justify-center rounded-md border border-button-edge bg-surface px-3 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50';
|
|
61
|
+
const LIST_CLASS = 'flex flex-col overflow-hidden rounded-md border border-border-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
62
|
+
const GROUP_CLASS = 'flex flex-col';
|
|
61
63
|
const GROUP_HEAD_CLASS = 'flex items-center justify-between gap-2 rounded-md bg-surface-sunken px-3 py-1.5 text-xs font-medium text-fg-muted';
|
|
62
|
-
const GROUP_BTN_CLASS = 'rounded-md border border-border-subtle bg-surface px-2 py-0.5 text-xs text-primary-on-soft transition-colors
|
|
63
|
-
const ITEM_CLASS = 'flex cursor-pointer items-center gap-3
|
|
64
|
-
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3
|
|
65
|
-
const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3
|
|
66
|
-
const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3
|
|
67
|
-
const CURSOR_CLASS = 'ring-2 ring-ring';
|
|
64
|
+
const GROUP_BTN_CLASS = 'rounded-md border border-border-subtle bg-surface px-2 py-0.5 text-xs text-primary-on-soft transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50';
|
|
65
|
+
const ITEM_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-surface px-3 py-2 text-fg transition-colors last:border-b-0 state-layer';
|
|
66
|
+
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3 border-b border-border-divider bg-surface px-3 py-2 text-fg-subtle last:border-b-0';
|
|
67
|
+
const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-success-soft px-3 py-2 text-success-on-soft transition-colors last:border-b-0';
|
|
68
|
+
const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3 border-b border-border-divider bg-danger-soft px-3 py-2 text-danger-on-soft transition-colors last:border-b-0';
|
|
69
|
+
const CURSOR_CLASS = 'ring-2 ring-inset ring-ring';
|
|
68
70
|
const BOX_OFF_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-border bg-surface text-xs';
|
|
69
71
|
const BOX_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-fg';
|
|
70
72
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
@@ -79,17 +81,19 @@ const FIELD_LABEL_CLASS = 'flex items-center gap-1 text-sm text-fg';
|
|
|
79
81
|
const STAR_CLASS = 'text-danger-on-soft';
|
|
80
82
|
const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md border border-border bg-surface px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
81
83
|
const FIELD_ERROR_CLASS = 'text-xs text-danger-on-soft';
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
// mt-auto:根随容器拉高时按钮区贴在面板底部,不悬在中间
|
|
85
|
+
const FOOT_CLASS = 'mt-auto flex items-center justify-end gap-2 pt-1';
|
|
86
|
+
// 保存 / 取消(返回):标准高度(32)的实心 / 描边按钮,与对话框底栏、授权树同一配方(原手写 h-9 = 36)
|
|
87
|
+
const SAVE_CLASS = kitControlRecipe({ variant: 'primary' });
|
|
88
|
+
const CANCEL_CLASS = kitControlRecipe({ variant: 'neutral' });
|
|
85
89
|
|
|
86
90
|
export const KIT_ASSIGNMENT_PICKER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
87
91
|
ROOT_CLASS, HELP_CLASS, SUBJECT_CLASS, SUBJECT_ITEM_CLASS, CAPTION_CLASS, STRONG_CLASS, ALERT_CLASS, GRID_CLASS, MAIN_FULL_CLASS,
|
|
88
|
-
|
|
92
|
+
MAIN_INNER_CLASS, SIDE_INNER_CLASS, HEAD_CLASS, TITLE_CLASS, SUMMARY_CLASS, CHANGES_CLASS, TOOLS_CLASS, 'hidden',
|
|
89
93
|
SEARCH_CLASS, TOOL_BTN_CLASS, LIST_CLASS, GROUP_CLASS, GROUP_HEAD_CLASS, GROUP_BTN_CLASS, ITEM_CLASS, ITEM_OFF_CLASS, ITEM_ADDED_CLASS,
|
|
90
94
|
ITEM_REMOVED_CLASS, CURSOR_CLASS, BOX_OFF_CLASS, BOX_ON_CLASS, TEXT_CLASS, LABEL_CLASS, SUB_CLASS, CHIP_BASE, CHIP_KEPT_CLASS,
|
|
91
95
|
CHIP_ADDED_CLASS, CHIP_REMOVED_CLASS, EMPTY_CLASS, FIELD_LABEL_CLASS, STAR_CLASS, AREA_CLASS, FIELD_ERROR_CLASS, FOOT_CLASS,
|
|
92
|
-
SAVE_CLASS, CANCEL_CLASS, 'hidden', 'flex', 'flex-1',
|
|
96
|
+
SAVE_CLASS, CANCEL_CLASS, KIT_OVERLAY_FORM_FOOTER_CLASS, kitOverlayFormScrollClass('gap-4'), 'hidden', 'flex', 'flex-1', 'rounded-full',
|
|
93
97
|
);
|
|
94
98
|
|
|
95
99
|
// ── 数据规整纯函数:解析、对比、过滤、分组、文案 ──
|
|
@@ -238,6 +242,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
238
242
|
value: { type: 'array', default: null, desc: '原有已授予 id(view.value 绑定);给了就覆盖 data 里的 value' },
|
|
239
243
|
object: { type: 'string', default: '', desc: '数据对象名(saved 载荷的 object)' },
|
|
240
244
|
mode: { type: 'string', default: 'edit', desc: '模式(saved 载荷的 mode)' },
|
|
245
|
+
multiple: { type: 'boolean', default: true, desc: '多选(缺省);false = 单选:点另一项即换选,勾选标记画成单选圆点,不出「全选」与分组「全选」钮(清空仍在)' },
|
|
241
246
|
save_label: { type: 'string', default: '', desc: '非空时底部出现保存钮,点击校验后抛 saved' },
|
|
242
247
|
...KIT_BUSY_PROP_DEFS,
|
|
243
248
|
cancel_label: { type: 'string', default: '', desc: '非空时底部出现取消钮,点击抛 cancel 并还原草稿' },
|
|
@@ -316,11 +321,18 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
316
321
|
|
|
317
322
|
const emitChange = (): void => { api.emit('change', payload()); };
|
|
318
323
|
|
|
324
|
+
const multiple = (): boolean => P().multiple !== false && P().multiple !== 'false';
|
|
325
|
+
|
|
319
326
|
const toggle = (id: string): void => {
|
|
320
327
|
const item = byId().get(id);
|
|
321
328
|
if (!item || !canToggle(item)) return;
|
|
322
329
|
cursor = id;
|
|
323
|
-
if (now.has(id)) now.delete(id);
|
|
330
|
+
if (now.has(id)) now.delete(id);
|
|
331
|
+
else {
|
|
332
|
+
// 单选:先清掉已选再选这一项(换选)
|
|
333
|
+
if (!multiple()) now.clear();
|
|
334
|
+
now.add(id);
|
|
335
|
+
}
|
|
324
336
|
reasonError = '';
|
|
325
337
|
notice = '';
|
|
326
338
|
paint();
|
|
@@ -383,7 +395,9 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
383
395
|
if (state !== '') row.setAttribute('data-kit-change', state);
|
|
384
396
|
const tone = !ok ? ITEM_OFF_CLASS : state === 'added' ? ITEM_ADDED_CLASS : state === 'removed' ? ITEM_REMOVED_CLASS : ITEM_CLASS;
|
|
385
397
|
row.className = cursor === item.id ? `${tone} ${CURSOR_CLASS}` : tone;
|
|
386
|
-
const
|
|
398
|
+
const boxClass = on ? BOX_ON_CLASS : BOX_OFF_CLASS;
|
|
399
|
+
const box = mk('span', multiple() ? boxClass : boxClass.replace('rounded-md', 'rounded-full'), '');
|
|
400
|
+
if (multiple()) markCheckBox(box);
|
|
387
401
|
if (on) box.appendChild(kitIcon('check', 'xs'));
|
|
388
402
|
box.setAttribute('aria-hidden', 'true');
|
|
389
403
|
const text = mk('span', TEXT_CLASS);
|
|
@@ -402,7 +416,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
402
416
|
listEl.textContent = '';
|
|
403
417
|
groupBarEl.textContent = '';
|
|
404
418
|
groupBarEl.className = 'hidden';
|
|
405
|
-
listEl.setAttribute('aria-multiselectable', 'true');
|
|
419
|
+
listEl.setAttribute('aria-multiselectable', multiple() ? 'true' : 'false');
|
|
406
420
|
if (vis.length === 0) {
|
|
407
421
|
const empty = mk('div', EMPTY_CLASS, str(P().empty_text) || t.empty);
|
|
408
422
|
empty.setAttribute('role', 'status');
|
|
@@ -432,8 +446,10 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
432
446
|
btn.disabled = locked() || pickable.length === 0;
|
|
433
447
|
btn.setAttribute('data-kit-group', g.name);
|
|
434
448
|
btn.setAttribute('data-kit-group-on', allOn ? 'off' : 'on');
|
|
435
|
-
|
|
436
|
-
|
|
449
|
+
if (multiple()) {
|
|
450
|
+
groupBarEl.appendChild(btn);
|
|
451
|
+
groupBarEl.className = TOOLS_CLASS;
|
|
452
|
+
}
|
|
437
453
|
}
|
|
438
454
|
for (const item of g.items) wrap.appendChild(buildItem(item, t));
|
|
439
455
|
frag.appendChild(wrap);
|
|
@@ -478,12 +494,13 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
478
494
|
search.placeholder = t.search;
|
|
479
495
|
search.setAttribute('aria-label', t.search);
|
|
480
496
|
allBtn.textContent = t.select_all;
|
|
497
|
+
// 单选没有「全选」:钮收起(显隐落在类名上,外包层的 inline-flex 会盖住 [hidden])
|
|
498
|
+
allBtn.className = multiple() ? TOOL_BTN_CLASS : 'hidden';
|
|
481
499
|
clearBtn.textContent = t.clear;
|
|
482
500
|
allBtn.disabled = locked();
|
|
483
501
|
clearBtn.disabled = locked();
|
|
484
502
|
const reasonLabel = str(p.reason_label);
|
|
485
503
|
sideBox.hidden = reasonLabel === '';
|
|
486
|
-
mainBox.className = reasonLabel === '' ? MAIN_FULL_CLASS : MAIN_SPLIT_CLASS;
|
|
487
504
|
fieldLabel.textContent = '';
|
|
488
505
|
if (bool(p.reason_required)) {
|
|
489
506
|
const star = mk('span', STAR_CLASS, '*');
|
|
@@ -585,12 +602,14 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
585
602
|
fieldError = mk('p', FIELD_ERROR_CLASS);
|
|
586
603
|
fieldError.setAttribute('role', 'alert');
|
|
587
604
|
errorBox = boxOf(fieldError);
|
|
605
|
+
// 申请原因:列表下方的整宽多行文本字段(不再是右侧分栏小框)
|
|
606
|
+
// 外层不带 flex(flex 会盖住 [hidden]),布局在内层
|
|
588
607
|
const sideInner = mk('div', SIDE_INNER_CLASS);
|
|
589
608
|
sideInner.append(fieldLabel, area, errorBox);
|
|
590
|
-
sideBox = mk('div',
|
|
609
|
+
sideBox = mk('div', '');
|
|
591
610
|
sideBox.appendChild(sideInner);
|
|
592
611
|
const grid = mk('div', GRID_CLASS);
|
|
593
|
-
grid.append(mainBox
|
|
612
|
+
grid.append(mainBox);
|
|
594
613
|
cancelBtn = mk('button', CANCEL_CLASS); cancelBtn.type = 'button';
|
|
595
614
|
saveBtn = mk('button', SAVE_CLASS); saveBtn.type = 'button';
|
|
596
615
|
setKitFace(cancelBtn, 'raised');
|
|
@@ -600,8 +619,15 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
600
619
|
const foot = mk('div', FOOT_CLASS);
|
|
601
620
|
foot.append(cancelBox, saveBox);
|
|
602
621
|
footBox = boxOf(foot);
|
|
622
|
+
// 浮层滚动体里底栏吸底并贴着浮层底边(外包层是 sticky 元素;变体只在 group-data-kit-overlay-scroll 祖先下生效)
|
|
623
|
+
footBox.className = KIT_OVERLAY_FORM_FOOTER_CLASS;
|
|
624
|
+
// 滚动区(底栏之外的内容):页面级 contents、浮层里 flex-1 min-h-0 overflow-y-auto;底栏在它之外,不随内容滚动
|
|
625
|
+
const scrollArea = mk('div', kitOverlayFormScrollClass('gap-4'));
|
|
626
|
+
scrollArea.setAttribute(KIT_OVERLAY_FORM_SCROLL_ATTR, '');
|
|
627
|
+
scrollArea.append(helpEl, subjectEl, alertEl, grid, sideBox);
|
|
628
|
+
footBox.setAttribute(KIT_OVERLAY_FOOT_ATTR, '');
|
|
603
629
|
host.textContent = '';
|
|
604
|
-
host.append(
|
|
630
|
+
host.append(scrollArea, footBox);
|
|
605
631
|
|
|
606
632
|
const on = (target: HTMLElement, type: string, fn: (event: Event) => void): void => {
|
|
607
633
|
target.addEventListener(type, fn);
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// result:{ title?, summary?, tone?, lines[{ label?, text }] },非空才出结果框;tone 取 neutral / info / success / warning / danger(默认 info)。
|
|
7
7
|
// adopt_label 非空出「采纳」钮,dismiss_label 非空出「忽略」钮。
|
|
8
8
|
// 指令输入(show_prompt,默认真)是组件内草稿,重画不丢焦点;change 时抛 `prompt_change { value }`,点运行抛 `run { prompt }`。
|
|
9
|
+
// 无内容态:空闲且没有标题 / 副标题、指令框、运行钮、状态行、结果时,画共享三态空面板 +「暂无结果」词条(soma.kit.async_idle),
|
|
10
|
+
// 不留一张空白卡;页面不必(也不应)为此写装饰性的标题 + 说明。
|
|
9
11
|
// 不改数据:运行 / 取消 / 采纳 / 忽略都只抛事件,状态由页面经 data 下行。
|
|
10
12
|
|
|
11
13
|
import type { SomaComponentDefinition, SomaDataPort } from 'soma-core';
|
|
@@ -16,13 +18,16 @@ import {
|
|
|
16
18
|
type KitLoadingGate,
|
|
17
19
|
type KitLoadingPhase,
|
|
18
20
|
} from '../base/loading-gate';
|
|
21
|
+
import { kitEmptyPanel } from '../base/state-panel';
|
|
19
22
|
import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
23
|
+
import { KIT_MS_ASIDE_IDLE_ATTR, KIT_MS_ROOT_ATTR } from '../recipes/container';
|
|
20
24
|
import { kitText } from '../i18n/kit-text';
|
|
21
25
|
import { setKitFace } from '../recipes';
|
|
22
26
|
import { KIT_BUSY_PROP_DEFS, cancelKitAction, kitBusyOf } from '../base/action-busy';
|
|
23
27
|
import {
|
|
24
28
|
actionButton, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
|
|
25
29
|
} from './shape-util';
|
|
30
|
+
import { TEXT_ACTION_CLASS_TOKENS, textActionButton } from './text-action-button';
|
|
26
31
|
|
|
27
32
|
const ROOT_CLASS = 'flex flex-col gap-3';
|
|
28
33
|
const HEAD_CLASS = 'flex flex-col gap-1';
|
|
@@ -41,7 +46,7 @@ const LINE_LABEL = 'font-medium';
|
|
|
41
46
|
|
|
42
47
|
export const KIT_ASYNC_RESULT_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
43
48
|
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, SUBTITLE_CLASS, LABEL_WRAP, LABEL_CLASS, AREA_CLASS, BUTTONS_CLASS, MESSAGE_CLASS, MESSAGE_FAILED,
|
|
44
|
-
RESULT_BASE, RESULT_TITLE, LINE_CLASS, LINE_LABEL, BADGE_BASE, Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS,
|
|
49
|
+
RESULT_BASE, RESULT_TITLE, LINE_CLASS, LINE_LABEL, BADGE_BASE, Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS, TEXT_ACTION_CLASS_TOKENS,
|
|
45
50
|
);
|
|
46
51
|
|
|
47
52
|
export type KitAsyncStatus = 'idle' | 'busy' | 'ready' | 'failed';
|
|
@@ -74,12 +79,22 @@ export function asyncResultOf(raw: unknown): KitAsyncResult | null {
|
|
|
74
79
|
export function outcomePanelData(o: KitOutcome): Record<string, unknown> {
|
|
75
80
|
switch (o.status) {
|
|
76
81
|
case 'pending': return { status: 'busy' };
|
|
77
|
-
|
|
82
|
+
// 业务失败(通道成功、展示对象 ctx.failOutcome 判为否):保留响应体里的阶段行,整体换成危险语气(响应体自带 warning 语气的保留)
|
|
83
|
+
case 'failed':
|
|
84
|
+
if (o.business === true) return { status: 'failed', message: o.message, result: businessFailureResult(o.data) };
|
|
85
|
+
return { status: 'failed', message: o.message };
|
|
86
|
+
case 'conflict': case 'held': return { status: 'failed', message: o.message };
|
|
78
87
|
case 'saved': return { status: 'ready', result: outcomeResultOf(o.data) };
|
|
79
88
|
default: return { status: 'idle' };
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
91
|
|
|
92
|
+
/** 业务失败的结果框:同成功时一样从响应体取阶段行,语气只许 warning / danger(其余一律 danger) */
|
|
93
|
+
export function businessFailureResult(body: unknown): Record<string, unknown> {
|
|
94
|
+
const result = outcomeResultOf(body);
|
|
95
|
+
return { ...result, tone: result.tone === 'warning' ? 'warning' : 'danger' };
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
export function outcomeResultOf(body: unknown): Record<string, unknown> {
|
|
84
99
|
const top = recOf(body);
|
|
85
100
|
const payload = recOf(top.data !== undefined && top.data !== null && typeof top.data === 'object' ? top.data : top);
|
|
@@ -108,6 +123,8 @@ interface PanelState {
|
|
|
108
123
|
btnSlot: HTMLElement | null;
|
|
109
124
|
msg: HTMLElement | null;
|
|
110
125
|
resSlot: HTMLElement | null;
|
|
126
|
+
/** 无内容时的空面板(共享三态空面板,惰性创建) */
|
|
127
|
+
idle: HTMLElement | null;
|
|
111
128
|
/** 加载反馈三阈值状态机 */
|
|
112
129
|
gate: KitLoadingGate;
|
|
113
130
|
wasBusy: boolean;
|
|
@@ -141,6 +158,7 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
141
158
|
btnSlot: null,
|
|
142
159
|
msg: null,
|
|
143
160
|
resSlot: null,
|
|
161
|
+
idle: null,
|
|
144
162
|
gate,
|
|
145
163
|
wasBusy: false,
|
|
146
164
|
};
|
|
@@ -188,7 +206,7 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
188
206
|
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>('[data-kit-action]');
|
|
189
207
|
if (!btn || btn.disabled) return;
|
|
190
208
|
const key = btn.getAttribute('data-kit-action');
|
|
191
|
-
if (key === 'run') api.emit('run', { prompt: stateOf(root).area?.value ?? '' });
|
|
209
|
+
if (key === 'run' || key === 'retry') api.emit('run', { prompt: stateOf(root).area?.value ?? '' });
|
|
192
210
|
else if (key === 'cancel' || key === 'adopt' || key === 'dismiss') {
|
|
193
211
|
// 所接 request 动作声明了 cancelable:真正中止在途请求(没声明则只发 cancel 事件,行为同前)
|
|
194
212
|
if (key === 'cancel') {
|
|
@@ -254,6 +272,7 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
254
272
|
|
|
255
273
|
if (!st.top || !st.mid || !st.bottom) {
|
|
256
274
|
root.textContent = '';
|
|
275
|
+
st.idle = null;
|
|
257
276
|
st.top = mk('div', '');
|
|
258
277
|
st.mid = mk('div', '');
|
|
259
278
|
st.bottom = mk('div', '');
|
|
@@ -327,6 +346,10 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
327
346
|
}));
|
|
328
347
|
if (actionBusy) (buttons.firstElementChild as HTMLElement).setAttribute('aria-busy', 'true');
|
|
329
348
|
}
|
|
349
|
+
// 失败行的「重试」:主色文字链接(不与同行的危险色错误文案同红),等同再点一次运行
|
|
350
|
+
if (status === 'failed' && !isBusy && p.show_run !== false && !bool(p.run_disabled)) {
|
|
351
|
+
buttons.appendChild(textActionButton('retry', kitText('soma.kit.ct_retry', undefined, root), 'primary'));
|
|
352
|
+
}
|
|
330
353
|
if (busy) buttons.appendChild(actionButton({ key: 'cancel', label: str(p.cancel_label, kitText('soma.kit.cancel', undefined, root)), tone: 'neutral', disabled: false, reason: '' }));
|
|
331
354
|
st.btnSlot.replaceChildren(buttons);
|
|
332
355
|
const message = textOf(data.message);
|
|
@@ -358,6 +381,29 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
358
381
|
}
|
|
359
382
|
body.appendChild(box);
|
|
360
383
|
}
|
|
384
|
+
// 没有任何可画的内容(空闲、无标题 / 副标题、无指令框、无运行钮、无状态行、无结果):不留一张空白卡,
|
|
385
|
+
// 画共享的三态空面板 + 中性词条「暂无结果」(不是装饰性标题 + 说明);一有内容立刻让位
|
|
386
|
+
const quiet = status === 'idle' && !isBusy && textOf(data.title) === '' && textOf(data.subtitle) === ''
|
|
387
|
+
&& !showPrompt && p.show_run === false && message === '' && !result;
|
|
388
|
+
bottom.hidden = quiet;
|
|
389
|
+
// 主从工作台的辅助栏(aside)里放它时:尚无结果(quiet)整栏收起、中栏占满,有结果再出现——只切根上的状态标记,
|
|
390
|
+
// 外观由壳上已写好的变体类(group-data-kit-aside-idle/ms:)决定,不写内联样式
|
|
391
|
+
const msRoot = root.closest<HTMLElement>(`[${KIT_MS_ROOT_ATTR}]`);
|
|
392
|
+
if (msRoot !== null) {
|
|
393
|
+
if (quiet) msRoot.setAttribute(KIT_MS_ASIDE_IDLE_ATTR, ''); else msRoot.removeAttribute(KIT_MS_ASIDE_IDLE_ATTR);
|
|
394
|
+
}
|
|
395
|
+
if (quiet) {
|
|
396
|
+
const text = kitText('soma.kit.async_idle', undefined, root);
|
|
397
|
+
if (st.idle === null) {
|
|
398
|
+
st.idle = kitEmptyPanel(document, text, true);
|
|
399
|
+
root.appendChild(st.idle);
|
|
400
|
+
} else if (st.idle.textContent !== text) {
|
|
401
|
+
st.idle.textContent = text;
|
|
402
|
+
}
|
|
403
|
+
st.idle.hidden = false;
|
|
404
|
+
} else if (st.idle !== null) {
|
|
405
|
+
st.idle.hidden = true;
|
|
406
|
+
}
|
|
361
407
|
},
|
|
362
408
|
})),
|
|
363
409
|
};
|
package/src/data/breadcrumbs.ts
CHANGED
|
@@ -19,10 +19,11 @@ const ROOT_SCROLL_CLASS = 'flex min-w-0 items-center overflow-x-auto text-sm tex
|
|
|
19
19
|
const LIST_CLASS = 'flex min-w-0 flex-wrap items-center gap-1';
|
|
20
20
|
const LIST_SCROLL_CLASS = 'flex flex-nowrap items-center gap-1 whitespace-nowrap';
|
|
21
21
|
const ITEM_CLASS = 'flex min-w-0 items-center gap-1';
|
|
22
|
-
|
|
22
|
+
// border-0 bg-transparent p-0:按钮型面包屑项没有 preflight 时带浏览器默认 6px 横向内边距,会让分隔符两侧间距不等、首项比当前项缩进多 6px
|
|
23
|
+
const LINK_CLASS = `min-w-0 cursor-pointer truncate rounded-sm border-0 bg-transparent p-0 text-start text-fg-muted transition-colors hover:text-fg hover:underline ${FOCUS}`;
|
|
23
24
|
const CURRENT_CLASS = 'min-w-0 truncate font-medium text-fg';
|
|
24
25
|
const SEP_CLASS = 'shrink-0 text-fg-subtle';
|
|
25
|
-
const ELLIPSIS_CLASS = `inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-sm px-1 text-fg-muted transition-colors hover:bg-
|
|
26
|
+
const ELLIPSIS_CLASS = `inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-sm px-1 text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ${FOCUS}`;
|
|
26
27
|
const ELLIPSIS_STATIC_CLASS = 'shrink-0 px-1 text-fg-muted';
|
|
27
28
|
|
|
28
29
|
/** 本组件自带的全部类(供编译器并入候选类,页面框静态页头同用) */
|
package/src/data/calendar.ts
CHANGED
|
@@ -26,14 +26,14 @@ const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
|
26
26
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
27
27
|
const TITLE_CLASS = 'min-w-24 text-base font-semibold text-fg';
|
|
28
28
|
const SPACER_CLASS = 'flex-1';
|
|
29
|
-
const BTN_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-
|
|
29
|
+
const BTN_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-button-edge bg-surface px-3 text-sm text-fg transition-colors state-layer active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
30
30
|
const BTN_ON_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-primary bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
31
31
|
const GRID_CLASS = 'flex flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface';
|
|
32
32
|
const ROW_CLASS = 'grid grid-cols-7 border-border-subtle';
|
|
33
33
|
const ROW_BORDER = 'border-t';
|
|
34
34
|
const HEADCELL_CLASS = 'px-2 py-1.5 text-center text-xs font-medium text-fg-muted';
|
|
35
35
|
// 网格外层 overflow-hidden 会把外扩的焦点环切掉,格子与事件块的焦点环一律画在里面(ring-inset)
|
|
36
|
-
const CELL_CLASS = 'flex min-h-24 flex-col gap-1 border-border-subtle p-1.5 text-start transition-colors hover:bg-
|
|
36
|
+
const CELL_CLASS = 'flex min-h-24 flex-col gap-1 border-border-subtle p-1.5 text-start transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
37
37
|
const CELL_WEEK = 'min-h-48';
|
|
38
38
|
const CELL_BORDER = 'border-s';
|
|
39
39
|
const CELL_OUT = 'bg-surface-sunken text-fg-subtle';
|
package/src/data/carousel.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// 事件:`change { index, item }`(换张)、`select { index, item }`(slide 布局下点当前张内容)。`current` prop 变化时覆盖当前张。
|
|
14
14
|
|
|
15
15
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
|
-
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
16
|
+
import { KIT_CAROUSEL_LIMITS, KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
17
17
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
18
18
|
import { kitIcon } from '../base/icons';
|
|
19
19
|
import { kitText } from '../i18n/kit-text';
|
|
@@ -37,10 +37,12 @@ const TITLE_CLASS = 'text-lg font-semibold';
|
|
|
37
37
|
const TEXT_CLASS = 'text-sm text-fg-muted';
|
|
38
38
|
const CARD_TEXT_CLASS = 'text-sm';
|
|
39
39
|
const BAR_CLASS = 'flex items-center justify-between gap-3';
|
|
40
|
-
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md border border-border bg-surface px-2 text-sm text-fg transition-colors
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
40
|
+
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md border border-border bg-surface px-2 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
41
|
+
// 圆点尺寸与间距取 design 真源 kit-limits#carousel(间距步数,乘 --spacing);排容器 hit-gap-N 写 gap 与 --kit-hit-gap,
|
|
42
|
+
// 圆点用 hit-area-row(读 hitTarget;沿排热区 = min(命中边长, 中心距),相邻热区相接零重叠,垂直方向仍是完整命中边长),不手写外扩。
|
|
43
|
+
const DOTS_CLASS = `flex flex-1 items-center justify-center hit-gap-${KIT_CAROUSEL_LIMITS.dotGapStep}`;
|
|
44
|
+
const DOT_CLASS = `hit-area-row size-${KIT_CAROUSEL_LIMITS.dotSizeStep} p-0 rounded-full bg-border transition-colors hover:bg-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-kit-selected:bg-primary`;
|
|
45
|
+
const TOGGLE_CLASS = 'inline-flex h-8 items-center justify-center rounded-md px-2 text-xs text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
44
46
|
|
|
45
47
|
// stack 布局
|
|
46
48
|
const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
@@ -50,7 +52,7 @@ const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
|
50
52
|
end: 'grid pe-6',
|
|
51
53
|
});
|
|
52
54
|
const STACK_CARD_BASE = 'col-start-1 row-start-1 flex min-h-32 flex-col gap-2 rounded-lg border border-border-subtle bg-surface p-4 text-start shadow-md motion-safe:transition-transform';
|
|
53
|
-
const STACK_TOP = 'z-30 cursor-pointer hover:bg-
|
|
55
|
+
const STACK_TOP = 'z-30 cursor-pointer hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
54
56
|
/** 后面两张牌的位置:edge × 深度(1、2) */
|
|
55
57
|
const STACK_BEHIND: Readonly<Record<KitCarouselEdge, readonly [string, string]>> = Object.freeze({
|
|
56
58
|
top: ['z-20 -translate-y-3 scale-95 pointer-events-none', 'z-10 -translate-y-6 scale-90 pointer-events-none'],
|