soma-kit 0.1.12 → 0.1.14
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 +172 -4
- package/spec/generated/kit-page.schema.json +164 -5
- package/spec/kit-grammar.json +598 -96
- package/spec/kit-grammar.schema.json +12 -6
- package/src/app/app-config.ts +92 -8
- 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 +29 -5
- package/src/app/kit-view-context.ts +181 -15
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +55 -8
- 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 +62 -15
- 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 +61 -0
- package/src/base/fab.ts +1 -1
- package/src/base/gap-value.ts +168 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +95 -0
- package/src/base/index.ts +32 -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 +16 -18
- 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 +10 -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 +36 -24
- package/src/base/shared.ts +180 -36
- package/src/base/state-panel.ts +367 -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 +76 -41
- package/src/base/text.ts +43 -14
- 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 -9
- package/src/base/view-transition.ts +77 -0
- package/src/biz/approval-desk/shell.ts +15 -11
- package/src/biz/auth-panel/shell.ts +9 -7
- package/src/biz/category-crud/compile.ts +5 -4
- package/src/biz/category-crud/shell.ts +5 -3
- package/src/biz/checkout-page/compile.ts +2 -1
- package/src/biz/checkout-page/shell.ts +10 -8
- package/src/biz/compose.ts +2 -2
- package/src/biz/data-components.ts +4 -0
- package/src/biz/import-wizard/shell.ts +13 -10
- package/src/biz/landing-page/shell.ts +2 -2
- package/src/biz/link/hub.ts +23 -5
- package/src/biz/link/shared.ts +23 -12
- package/src/biz/master-sub/compile.ts +207 -16
- package/src/biz/master-sub/detail-head.ts +61 -0
- package/src/biz/master-sub/index.ts +7 -3
- package/src/biz/master-sub/shell.ts +133 -24
- package/src/biz/multi-board/compile.ts +167 -9
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +1 -1
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +94 -23
- package/src/biz/notification-center/shell.ts +10 -7
- package/src/biz/page-templates/domain-templates.ts +2 -2
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- package/src/biz/page-templates/sign-in-page/shell.ts +16 -16
- package/src/biz/record-detail/compile.ts +2 -2
- package/src/biz/record-detail/shell.ts +13 -10
- package/src/biz/settings-center/compile.ts +2 -1
- package/src/biz/settings-center/shell.ts +12 -9
- package/src/biz/shared/action-host.ts +6 -0
- package/src/biz/shared/compile-helpers.ts +97 -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 +281 -0
- package/src/biz/shared/overlay-shell.ts +142 -11
- 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 +9 -6
- package/src/biz/standard-crud/compile.ts +36 -161
- package/src/biz/standard-crud/shell.ts +23 -60
- package/src/biz/standard-crud/summary.ts +40 -0
- package/src/biz/step-form/shell.ts +15 -13
- package/src/biz/types.ts +6 -1
- 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/access-gate-attach.ts +27 -0
- package/src/compile/closed-set.ts +65 -4
- package/src/compile/compile-page.ts +66 -11
- package/src/compile/component-candidates.ts +14 -1
- package/src/compile/fragment.ts +11 -0
- 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 +267 -0
- package/src/compile/layout-lint/rules-form.ts +191 -0
- package/src/compile/layout-lint/rules-table.ts +278 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -0
- package/src/compile/page-composition.ts +189 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/remove-guard.ts +10 -7
- package/src/compile/styles.ts +46 -8
- package/src/compile/types.ts +16 -2
- package/src/compile/view-check.ts +149 -16
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +9 -2
- package/src/data/approval-flow.ts +5 -2
- package/src/data/assignment-picker.ts +59 -28
- package/src/data/async-result-panel.ts +49 -3
- package/src/data/breadcrumbs.ts +3 -2
- package/src/data/calendar.ts +8 -3
- package/src/data/carousel.ts +10 -6
- package/src/data/chart.ts +744 -46
- package/src/data/checklist.ts +22 -6
- package/src/data/code-view.ts +8 -4
- package/src/data/comment-thread.ts +3 -2
- package/src/data/confirm-dialog.ts +72 -25
- 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 +7 -4
- package/src/data/flow-editor-contract.ts +7 -0
- package/src/data/flow-editor.ts +26 -9
- package/src/data/flow-node-options.ts +33 -3
- package/src/data/footer.ts +2 -0
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +4 -1
- package/src/data/image-viewer.ts +7 -4
- package/src/data/index.ts +16 -4
- package/src/data/item-list.ts +27 -12
- package/src/data/kanban.ts +41 -10
- package/src/data/matrix.ts +391 -0
- 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 +60 -16
- package/src/data/mockup.ts +5 -1
- package/src/data/modal-dialog.ts +146 -26
- package/src/data/navbar.ts +8 -6
- package/src/data/notice-list.ts +301 -0
- package/src/data/notify-renderer.ts +21 -6
- package/src/data/object-form.ts +409 -87
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +19 -8
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +36 -11
- package/src/data/permission-tree.ts +52 -23
- package/src/data/pricing-table.ts +22 -11
- package/src/data/prompt-dialog.ts +165 -0
- package/src/data/reaction-bar.ts +6 -4
- package/src/data/record-card.ts +40 -7
- package/src/data/record-picker.ts +13 -7
- package/src/data/resident.ts +8 -0
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +17 -1
- package/src/data/row-editor.ts +77 -24
- package/src/data/rule-builder.ts +14 -9
- package/src/data/shape-util.ts +27 -12
- package/src/data/stat-group.ts +459 -74
- package/src/data/static-lazy.ts +5 -0
- package/src/data/static-registry.ts +8 -0
- package/src/data/steps.ts +8 -3
- package/src/data/survey.ts +7 -4
- package/src/data/system-switcher.ts +3 -2
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +17 -6
- package/src/data/tour-guide.ts +3 -2
- package/src/data/transfer.ts +40 -16
- package/src/data/tree-table.ts +65 -37
- package/src/data/tree.ts +22 -2
- package/src/data/virtual-rows.ts +21 -11
- package/src/data/wrapped-candidates.ts +32 -1
- package/src/frames/index.ts +1 -0
- package/src/frames/list-summary.ts +100 -0
- package/src/frames/page-bar.ts +7 -14
- package/src/frames/page-status.ts +7 -5
- package/src/frames/shared.ts +34 -13
- package/src/frames/split-frame/shell.ts +1 -1
- package/src/frames/tabs-frame/shell.ts +9 -6
- package/src/frames/tabs-frame/wiring.ts +1 -0
- package/src/frames/top-main-frame.ts +3 -3
- package/src/frames/types.ts +3 -1
- package/src/frames/workspace-frame/extras.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +4 -4
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +168 -44
- package/src/generated/kit-grammar-runtime.ts +390 -59
- package/src/i18n/kit-text.ts +90 -4
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/object-renderer/action-group.ts +139 -0
- package/src/object-renderer/action-more.ts +144 -0
- package/src/object-renderer/arrange.ts +71 -7
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +264 -62
- package/src/object-renderer/collection-table.ts +177 -5
- package/src/object-renderer/collection.ts +188 -37
- package/src/object-renderer/compile-data.ts +28 -3
- package/src/object-renderer/defaults.ts +27 -2
- package/src/object-renderer/display-checks.ts +1 -1
- package/src/object-renderer/emit-events.ts +43 -9
- package/src/object-renderer/emit-object.ts +4 -0
- package/src/object-renderer/emit-static.ts +434 -41
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/form-detail.ts +1 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +5 -0
- package/src/object-renderer/layout-facts.ts +394 -0
- package/src/object-renderer/layout-plan.ts +225 -0
- package/src/object-renderer/layout-plan.types.ts +59 -0
- package/src/object-renderer/parts.ts +6 -7
- package/src/object-renderer/render-object.ts +107 -46
- package/src/object-renderer/request-actions.ts +4 -2
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +172 -32
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +62 -30
- package/src/object-renderer/types.ts +84 -13
- 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 +77 -1
- package/src/recipes/control.ts +76 -116
- package/src/recipes/emphasis.ts +56 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +72 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +120 -17
- package/src/recipes/placeholder.ts +95 -0
- package/src/recipes/rail-grid.ts +48 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +40 -21
- package/src/recipes/status.ts +147 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +146 -3
- package/src/recipes/tabs.ts +49 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +30 -37
- 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 +384 -13
- package/src/theme/kit-theme.tpl +384 -13
- package/src/theme/nine-dim-structure.ts +244 -7
- package/src/theme/surface-layers.ts +10 -1
- package/src/theme/theme-tokens.ts +63 -16
- package/src/theme/theme-types.ts +32 -0
- package/src/theme/typography.ts +21 -17
- package/src/biz/shared/remove-key.ts +0 -6
|
@@ -12,6 +12,8 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
12
12
|
import { bool, createKitController, formatValue, joinClass, str } from '../base/shared';
|
|
13
13
|
import { kitIcon, type KitIconName } from '../base/icons';
|
|
14
14
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
15
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
16
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
15
17
|
import {
|
|
16
18
|
actionButton, actionsOf, BADGE_BASE, classTokens, BUTTON_CLASS_TOKENS, emptyNode, keyMap, mk, recOf, rowsOf, textOf,
|
|
17
19
|
TONE_DOT, TONE_SOFT, TONE_SOLID, type ShapeTone,
|
|
@@ -58,7 +60,7 @@ const NEEDS_REASON: readonly KitApprovalStatus[] = Object.freeze(['blocked', 're
|
|
|
58
60
|
const ROOT_CLASS = 'flex flex-col gap-4 rounded-lg border border-border-subtle bg-surface p-5 text-sm text-fg';
|
|
59
61
|
const HEAD_CLASS = 'flex flex-col gap-1';
|
|
60
62
|
const HEAD_ROW = 'flex flex-wrap items-center gap-2';
|
|
61
|
-
const TITLE_CLASS = '
|
|
63
|
+
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
62
64
|
const META_CLASS = 'text-fg-muted';
|
|
63
65
|
const SUMMARY_CLASS = 'text-fg';
|
|
64
66
|
const BANNER_BASE = 'flex flex-col gap-1 rounded-md px-3 py-2';
|
|
@@ -72,7 +74,7 @@ const LINE_CLASS = 'min-h-4 w-0.5 flex-1 rounded-full bg-border-subtle';
|
|
|
72
74
|
const BODY_CLASS = 'flex flex-1 flex-col gap-1 pb-4';
|
|
73
75
|
const NAME_ROW = 'flex flex-wrap items-center gap-x-2 gap-y-1';
|
|
74
76
|
const NAME_CLASS = 'font-medium text-fg';
|
|
75
|
-
const NAME_BUTTON = 'rounded-md font-medium text-fg transition-colors hover:bg-
|
|
77
|
+
const NAME_BUTTON = 'rounded-md font-medium text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
76
78
|
const TIME_CLASS = 'text-xs text-fg-subtle';
|
|
77
79
|
const COMMENT_CLASS = 'text-fg-muted';
|
|
78
80
|
const REASON_BASE = 'rounded-md px-2 py-1 text-xs';
|
|
@@ -170,6 +172,7 @@ export function createApprovalFlow(): SomaComponentDefinition {
|
|
|
170
172
|
},
|
|
171
173
|
render(root, p) {
|
|
172
174
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
175
|
+
markKitEdge(root);
|
|
173
176
|
root.textContent = '';
|
|
174
177
|
const m = keyMap(KIT_APPROVAL_DEFAULT_MAP, p.map);
|
|
175
178
|
const data = recOf(p.data);
|
|
@@ -27,16 +27,24 @@ 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 { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
34
|
+
import { mergeClass } from '../object-renderer/merge-class';
|
|
35
|
+
import {
|
|
36
|
+
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
37
|
+
} from '../recipes/overlay';
|
|
32
38
|
import { kitBusyOf, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
33
39
|
import { classTokens, keyMap, mk, recOf } from './shape-util';
|
|
34
40
|
import { envelopeOf } from './permission-tree';
|
|
35
41
|
import { attrEsc } from './d9-util';
|
|
42
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
43
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
36
44
|
|
|
37
45
|
// ── 类串表:全部完整写死,不拼接片段 ──
|
|
38
46
|
|
|
39
|
-
const ROOT_CLASS =
|
|
47
|
+
const ROOT_CLASS = `@container flex h-full flex-col gap-4 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
|
|
40
48
|
const HELP_CLASS = 'text-sm text-fg-muted';
|
|
41
49
|
const SUBJECT_CLASS = 'flex flex-wrap items-center gap-4';
|
|
42
50
|
const SUBJECT_ITEM_CLASS = 'flex items-center gap-2';
|
|
@@ -45,26 +53,24 @@ const STRONG_CLASS = 'text-sm font-semibold text-fg';
|
|
|
45
53
|
const ALERT_CLASS = 'rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
46
54
|
const GRID_CLASS = 'grid grid-cols-12 gap-4';
|
|
47
55
|
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
56
|
const MAIN_INNER_CLASS = 'flex flex-col gap-3';
|
|
51
57
|
const SIDE_INNER_CLASS = 'flex flex-col gap-2';
|
|
52
58
|
const HEAD_CLASS = 'flex items-center justify-between gap-3';
|
|
53
|
-
const TITLE_CLASS = '
|
|
59
|
+
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
54
60
|
const SUMMARY_CLASS = 'text-sm text-fg-muted';
|
|
55
61
|
const CHANGES_CLASS = 'text-sm text-fg-muted';
|
|
56
62
|
const TOOLS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
57
63
|
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 = '
|
|
59
|
-
const LIST_CLASS = 'flex flex-col
|
|
60
|
-
const GROUP_CLASS = 'flex flex-col
|
|
64
|
+
const TOOL_BTN_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'h-9');
|
|
65
|
+
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';
|
|
66
|
+
const GROUP_CLASS = 'flex flex-col';
|
|
61
67
|
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 = '
|
|
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';
|
|
68
|
+
const GROUP_BTN_CLASS = kitEmphasisButtonRecipe('button.quiet', { size: 'sm' });
|
|
69
|
+
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';
|
|
70
|
+
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';
|
|
71
|
+
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';
|
|
72
|
+
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';
|
|
73
|
+
const CURSOR_CLASS = 'ring-2 ring-inset ring-ring';
|
|
68
74
|
const BOX_OFF_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-border bg-surface text-xs';
|
|
69
75
|
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
76
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
@@ -79,17 +85,19 @@ const FIELD_LABEL_CLASS = 'flex items-center gap-1 text-sm text-fg';
|
|
|
79
85
|
const STAR_CLASS = 'text-danger-on-soft';
|
|
80
86
|
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
87
|
const FIELD_ERROR_CLASS = 'text-xs text-danger-on-soft';
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
88
|
+
// mt-auto:根随容器拉高时按钮区贴在面板底部,不悬在中间
|
|
89
|
+
const FOOT_CLASS = 'mt-auto flex items-center justify-end gap-2 pt-1';
|
|
90
|
+
// 保存 / 取消(返回):标准高度(32)的实心 / 描边按钮,与对话框底栏、授权树同一配方(原手写 h-9 = 36)
|
|
91
|
+
const SAVE_CLASS = kitControlRecipe({ variant: 'primary' });
|
|
92
|
+
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
85
93
|
|
|
86
94
|
export const KIT_ASSIGNMENT_PICKER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
87
95
|
ROOT_CLASS, HELP_CLASS, SUBJECT_CLASS, SUBJECT_ITEM_CLASS, CAPTION_CLASS, STRONG_CLASS, ALERT_CLASS, GRID_CLASS, MAIN_FULL_CLASS,
|
|
88
|
-
|
|
96
|
+
MAIN_INNER_CLASS, SIDE_INNER_CLASS, HEAD_CLASS, TITLE_CLASS, SUMMARY_CLASS, CHANGES_CLASS, TOOLS_CLASS, 'hidden',
|
|
89
97
|
SEARCH_CLASS, TOOL_BTN_CLASS, LIST_CLASS, GROUP_CLASS, GROUP_HEAD_CLASS, GROUP_BTN_CLASS, ITEM_CLASS, ITEM_OFF_CLASS, ITEM_ADDED_CLASS,
|
|
90
98
|
ITEM_REMOVED_CLASS, CURSOR_CLASS, BOX_OFF_CLASS, BOX_ON_CLASS, TEXT_CLASS, LABEL_CLASS, SUB_CLASS, CHIP_BASE, CHIP_KEPT_CLASS,
|
|
91
99
|
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',
|
|
100
|
+
SAVE_CLASS, CANCEL_CLASS, KIT_OVERLAY_FORM_FOOTER_CLASS, kitOverlayFormScrollClass('gap-4'), 'hidden', 'flex', 'flex-1', 'rounded-full',
|
|
93
101
|
);
|
|
94
102
|
|
|
95
103
|
// ── 数据规整纯函数:解析、对比、过滤、分组、文案 ──
|
|
@@ -238,6 +246,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
238
246
|
value: { type: 'array', default: null, desc: '原有已授予 id(view.value 绑定);给了就覆盖 data 里的 value' },
|
|
239
247
|
object: { type: 'string', default: '', desc: '数据对象名(saved 载荷的 object)' },
|
|
240
248
|
mode: { type: 'string', default: 'edit', desc: '模式(saved 载荷的 mode)' },
|
|
249
|
+
multiple: { type: 'boolean', default: true, desc: '多选(缺省);false = 单选:点另一项即换选,勾选标记画成单选圆点,不出「全选」与分组「全选」钮(清空仍在)' },
|
|
241
250
|
save_label: { type: 'string', default: '', desc: '非空时底部出现保存钮,点击校验后抛 saved' },
|
|
242
251
|
...KIT_BUSY_PROP_DEFS,
|
|
243
252
|
cancel_label: { type: 'string', default: '', desc: '非空时底部出现取消钮,点击抛 cancel 并还原草稿' },
|
|
@@ -316,11 +325,18 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
316
325
|
|
|
317
326
|
const emitChange = (): void => { api.emit('change', payload()); };
|
|
318
327
|
|
|
328
|
+
const multiple = (): boolean => P().multiple !== false && P().multiple !== 'false';
|
|
329
|
+
|
|
319
330
|
const toggle = (id: string): void => {
|
|
320
331
|
const item = byId().get(id);
|
|
321
332
|
if (!item || !canToggle(item)) return;
|
|
322
333
|
cursor = id;
|
|
323
|
-
if (now.has(id)) now.delete(id);
|
|
334
|
+
if (now.has(id)) now.delete(id);
|
|
335
|
+
else {
|
|
336
|
+
// 单选:先清掉已选再选这一项(换选)
|
|
337
|
+
if (!multiple()) now.clear();
|
|
338
|
+
now.add(id);
|
|
339
|
+
}
|
|
324
340
|
reasonError = '';
|
|
325
341
|
notice = '';
|
|
326
342
|
paint();
|
|
@@ -383,7 +399,9 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
383
399
|
if (state !== '') row.setAttribute('data-kit-change', state);
|
|
384
400
|
const tone = !ok ? ITEM_OFF_CLASS : state === 'added' ? ITEM_ADDED_CLASS : state === 'removed' ? ITEM_REMOVED_CLASS : ITEM_CLASS;
|
|
385
401
|
row.className = cursor === item.id ? `${tone} ${CURSOR_CLASS}` : tone;
|
|
386
|
-
const
|
|
402
|
+
const boxClass = on ? BOX_ON_CLASS : BOX_OFF_CLASS;
|
|
403
|
+
const box = mk('span', multiple() ? boxClass : boxClass.replace('rounded-md', 'rounded-full'), '');
|
|
404
|
+
if (multiple()) markCheckBox(box);
|
|
387
405
|
if (on) box.appendChild(kitIcon('check', 'xs'));
|
|
388
406
|
box.setAttribute('aria-hidden', 'true');
|
|
389
407
|
const text = mk('span', TEXT_CLASS);
|
|
@@ -402,7 +420,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
402
420
|
listEl.textContent = '';
|
|
403
421
|
groupBarEl.textContent = '';
|
|
404
422
|
groupBarEl.className = 'hidden';
|
|
405
|
-
listEl.setAttribute('aria-multiselectable', 'true');
|
|
423
|
+
listEl.setAttribute('aria-multiselectable', multiple() ? 'true' : 'false');
|
|
406
424
|
if (vis.length === 0) {
|
|
407
425
|
const empty = mk('div', EMPTY_CLASS, str(P().empty_text) || t.empty);
|
|
408
426
|
empty.setAttribute('role', 'status');
|
|
@@ -432,8 +450,10 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
432
450
|
btn.disabled = locked() || pickable.length === 0;
|
|
433
451
|
btn.setAttribute('data-kit-group', g.name);
|
|
434
452
|
btn.setAttribute('data-kit-group-on', allOn ? 'off' : 'on');
|
|
435
|
-
|
|
436
|
-
|
|
453
|
+
if (multiple()) {
|
|
454
|
+
groupBarEl.appendChild(btn);
|
|
455
|
+
groupBarEl.className = TOOLS_CLASS;
|
|
456
|
+
}
|
|
437
457
|
}
|
|
438
458
|
for (const item of g.items) wrap.appendChild(buildItem(item, t));
|
|
439
459
|
frag.appendChild(wrap);
|
|
@@ -478,12 +498,13 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
478
498
|
search.placeholder = t.search;
|
|
479
499
|
search.setAttribute('aria-label', t.search);
|
|
480
500
|
allBtn.textContent = t.select_all;
|
|
501
|
+
// 单选没有「全选」:钮收起(显隐落在类名上,外包层的 inline-flex 会盖住 [hidden])
|
|
502
|
+
allBtn.className = multiple() ? TOOL_BTN_CLASS : 'hidden';
|
|
481
503
|
clearBtn.textContent = t.clear;
|
|
482
504
|
allBtn.disabled = locked();
|
|
483
505
|
clearBtn.disabled = locked();
|
|
484
506
|
const reasonLabel = str(p.reason_label);
|
|
485
507
|
sideBox.hidden = reasonLabel === '';
|
|
486
|
-
mainBox.className = reasonLabel === '' ? MAIN_FULL_CLASS : MAIN_SPLIT_CLASS;
|
|
487
508
|
fieldLabel.textContent = '';
|
|
488
509
|
if (bool(p.reason_required)) {
|
|
489
510
|
const star = mk('span', STAR_CLASS, '*');
|
|
@@ -569,6 +590,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
569
590
|
tools.append(searchBox, allBtn, clearBtn);
|
|
570
591
|
groupBarEl = mk('div', 'hidden');
|
|
571
592
|
listEl = mk('div', LIST_CLASS);
|
|
593
|
+
markKitEdge(listEl);
|
|
572
594
|
listEl.setAttribute('role', 'listbox');
|
|
573
595
|
listEl.tabIndex = 0;
|
|
574
596
|
const mainInner = mk('div', MAIN_INNER_CLASS);
|
|
@@ -585,12 +607,14 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
585
607
|
fieldError = mk('p', FIELD_ERROR_CLASS);
|
|
586
608
|
fieldError.setAttribute('role', 'alert');
|
|
587
609
|
errorBox = boxOf(fieldError);
|
|
610
|
+
// 申请原因:列表下方的整宽多行文本字段(不再是右侧分栏小框)
|
|
611
|
+
// 外层不带 flex(flex 会盖住 [hidden]),布局在内层
|
|
588
612
|
const sideInner = mk('div', SIDE_INNER_CLASS);
|
|
589
613
|
sideInner.append(fieldLabel, area, errorBox);
|
|
590
|
-
sideBox = mk('div',
|
|
614
|
+
sideBox = mk('div', '');
|
|
591
615
|
sideBox.appendChild(sideInner);
|
|
592
616
|
const grid = mk('div', GRID_CLASS);
|
|
593
|
-
grid.append(mainBox
|
|
617
|
+
grid.append(mainBox);
|
|
594
618
|
cancelBtn = mk('button', CANCEL_CLASS); cancelBtn.type = 'button';
|
|
595
619
|
saveBtn = mk('button', SAVE_CLASS); saveBtn.type = 'button';
|
|
596
620
|
setKitFace(cancelBtn, 'raised');
|
|
@@ -600,8 +624,15 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
600
624
|
const foot = mk('div', FOOT_CLASS);
|
|
601
625
|
foot.append(cancelBox, saveBox);
|
|
602
626
|
footBox = boxOf(foot);
|
|
627
|
+
// 浮层滚动体里底栏吸底并贴着浮层底边(外包层是 sticky 元素;变体只在 group-data-kit-overlay-scroll 祖先下生效)
|
|
628
|
+
footBox.className = KIT_OVERLAY_FORM_FOOTER_CLASS;
|
|
629
|
+
// 滚动区(底栏之外的内容):页面级 contents、浮层里 flex-1 min-h-0 overflow-y-auto;底栏在它之外,不随内容滚动
|
|
630
|
+
const scrollArea = mk('div', kitOverlayFormScrollClass('gap-4'));
|
|
631
|
+
scrollArea.setAttribute(KIT_OVERLAY_FORM_SCROLL_ATTR, '');
|
|
632
|
+
scrollArea.append(helpEl, subjectEl, alertEl, grid, sideBox);
|
|
633
|
+
footBox.setAttribute(KIT_OVERLAY_FOOT_ATTR, '');
|
|
603
634
|
host.textContent = '';
|
|
604
|
-
host.append(
|
|
635
|
+
host.append(scrollArea, footBox);
|
|
605
636
|
|
|
606
637
|
const on = (target: HTMLElement, type: string, fn: (event: Event) => void): void => {
|
|
607
638
|
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);
|
|
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
|
@@ -14,6 +14,10 @@ import { kitText } from '../i18n/kit-text';
|
|
|
14
14
|
import { setKitFace } from '../recipes';
|
|
15
15
|
import { classTokens, keyMap, mk, rowsOf, shapeToneOf, textOf, TONE_SOFT, type Rec } from './shape-util';
|
|
16
16
|
import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, type MonthGridRange } from '../base/month-grid';
|
|
17
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
18
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
19
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
20
|
+
import { mergeClass } from '../object-renderer/merge-class';
|
|
17
21
|
import {
|
|
18
22
|
addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
|
|
19
23
|
} from './d9-util';
|
|
@@ -24,16 +28,16 @@ export type KitCalendarView = 'month' | 'week';
|
|
|
24
28
|
|
|
25
29
|
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
26
30
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
27
|
-
const TITLE_CLASS = 'min-w-24
|
|
31
|
+
const TITLE_CLASS = mergeClass('min-w-24', kitTypographyRecipe('sectionTitle'));
|
|
28
32
|
const SPACER_CLASS = 'flex-1';
|
|
29
|
-
const BTN_CLASS = '
|
|
33
|
+
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
30
34
|
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
35
|
const GRID_CLASS = 'flex flex-col overflow-hidden rounded-lg border border-border-subtle bg-surface';
|
|
32
36
|
const ROW_CLASS = 'grid grid-cols-7 border-border-subtle';
|
|
33
37
|
const ROW_BORDER = 'border-t';
|
|
34
38
|
const HEADCELL_CLASS = 'px-2 py-1.5 text-center text-xs font-medium text-fg-muted';
|
|
35
39
|
// 网格外层 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-
|
|
40
|
+
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
41
|
const CELL_WEEK = 'min-h-48';
|
|
38
42
|
const CELL_BORDER = 'border-s';
|
|
39
43
|
const CELL_OUT = 'bg-surface-sunken text-fg-subtle';
|
|
@@ -247,6 +251,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
247
251
|
|
|
248
252
|
// 网格
|
|
249
253
|
const grid = mk('div', GRID_CLASS);
|
|
254
|
+
markKitEdge(grid);
|
|
250
255
|
grid.setAttribute('role', 'grid');
|
|
251
256
|
grid.setAttribute('aria-label', title.textContent ?? '');
|
|
252
257
|
const hr = mk('div', ROW_CLASS);
|
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';
|
|
@@ -21,6 +21,7 @@ import { setKitFace } from '../recipes';
|
|
|
21
21
|
import { kitKey } from '../i18n/kit-text';
|
|
22
22
|
import { classTokens, emptyNode, mk, textOf, type Rec } from './shape-util';
|
|
23
23
|
import { clampInt, keyOfRow, listOf, prefersReducedMotion, urlOf } from './display-util';
|
|
24
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
24
25
|
|
|
25
26
|
export const KIT_CAROUSEL_LAYOUTS = ['slide', 'stack'] as const;
|
|
26
27
|
export type KitCarouselLayout = (typeof KIT_CAROUSEL_LAYOUTS)[number];
|
|
@@ -37,10 +38,12 @@ const TITLE_CLASS = 'text-lg font-semibold';
|
|
|
37
38
|
const TEXT_CLASS = 'text-sm text-fg-muted';
|
|
38
39
|
const CARD_TEXT_CLASS = 'text-sm';
|
|
39
40
|
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
|
|
41
|
+
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';
|
|
42
|
+
// 圆点尺寸与间距取 design 真源 kit-limits#carousel(间距步数,乘 --spacing);排容器 hit-gap-N 写 gap 与 --kit-hit-gap,
|
|
43
|
+
// 圆点用 hit-area-row(读 hitTarget;沿排热区 = min(命中边长, 中心距),相邻热区相接零重叠,垂直方向仍是完整命中边长),不手写外扩。
|
|
44
|
+
const DOTS_CLASS = `flex flex-1 items-center justify-center hit-gap-${KIT_CAROUSEL_LIMITS.dotGapStep}`;
|
|
45
|
+
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`;
|
|
46
|
+
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
47
|
|
|
45
48
|
// stack 布局
|
|
46
49
|
const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
@@ -50,7 +53,7 @@ const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
|
50
53
|
end: 'grid pe-6',
|
|
51
54
|
});
|
|
52
55
|
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-
|
|
56
|
+
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
57
|
/** 后面两张牌的位置:edge × 深度(1、2) */
|
|
55
58
|
const STACK_BEHIND: Readonly<Record<KitCarouselEdge, readonly [string, string]>> = Object.freeze({
|
|
56
59
|
top: ['z-20 -translate-y-3 scale-95 pointer-events-none', 'z-10 -translate-y-6 scale-90 pointer-events-none'],
|
|
@@ -365,6 +368,7 @@ export function createCarousel(): SomaComponentDefinition {
|
|
|
365
368
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root))));
|
|
366
369
|
} else {
|
|
367
370
|
const viewport = mk('div', layout === 'stack' ? STACK_PAD[edge] : VIEWPORT_CLASS);
|
|
371
|
+
if (layout !== 'stack') markKitEdge(viewport);
|
|
368
372
|
slides.forEach((slide, i) => viewport.appendChild(buildSlide(slide, i, slides.length, layout)));
|
|
369
373
|
root.appendChild(viewport);
|
|
370
374
|
}
|