soma-kit 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +34 -17
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +73 -50
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +7 -6
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +16 -12
- package/src/biz/types.ts +15 -3
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/base/alert.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
6
6
|
import { kitText } from '../i18n/kit-text';
|
|
7
7
|
import { KIT_PART_ATTRIBUTE, KIT_PART_TOAST, kitOverlayPartOf } from '../recipes';
|
|
8
|
-
|
|
8
|
+
// 就地提示条(knowledge/Kit主题规则与算法.md KT-K-feedback-1,2026-11-25 裁决):浅底 + 语气图标 + 正文,不描边、无左色条;中性 = 凹槽浅底
|
|
9
|
+
const NEUTRAL_BOX = 'rounded-lg bg-surface-sunken';
|
|
10
|
+
import { kitIcon, type KitIconName } from '../shared/icons';
|
|
9
11
|
import {
|
|
10
12
|
CLASS_PROP, SIZE_PROP,
|
|
11
13
|
bool, createKitController, joinClass, setAttr, sizeOf, str, toneOf,
|
|
@@ -16,42 +18,43 @@ import {
|
|
|
16
18
|
const OUTER_SHOWN = 'block';
|
|
17
19
|
const OUTER_HIDDEN = 'hidden';
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
/** 提示条配方(KT-K-feedback-1;就地错误提示条 base/inline-error.ts 复用,§6.1 G-17) */
|
|
22
|
+
export const BOX_CLASS: Record<KitSize, Record<KitTone, string>> = {
|
|
20
23
|
sm: {
|
|
21
|
-
neutral: 'flex items-start gap-2
|
|
22
|
-
info: 'flex items-start gap-2 rounded-lg
|
|
23
|
-
success: 'flex items-start gap-2 rounded-lg
|
|
24
|
-
warning: 'flex items-start gap-2 rounded-lg
|
|
25
|
-
danger: 'flex items-start gap-2 rounded-lg
|
|
24
|
+
neutral: 'flex items-start gap-2 ' + NEUTRAL_BOX + ' px-3 py-2 text-xs text-fg-muted',
|
|
25
|
+
info: 'flex items-start gap-2 rounded-lg bg-info-soft px-3 py-2 text-xs text-info-on-soft',
|
|
26
|
+
success: 'flex items-start gap-2 rounded-lg bg-success-soft px-3 py-2 text-xs text-success-on-soft',
|
|
27
|
+
warning: 'flex items-start gap-2 rounded-lg bg-warning-soft px-3 py-2 text-xs text-warning-on-soft',
|
|
28
|
+
danger: 'flex items-start gap-2 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger-on-soft',
|
|
26
29
|
},
|
|
27
30
|
md: {
|
|
28
|
-
neutral: 'flex items-start gap-3
|
|
29
|
-
info: 'flex items-start gap-3 rounded-lg
|
|
30
|
-
success: 'flex items-start gap-3 rounded-lg
|
|
31
|
-
warning: 'flex items-start gap-3 rounded-lg
|
|
32
|
-
danger: 'flex items-start gap-3 rounded-lg
|
|
31
|
+
neutral: 'flex items-start gap-3 ' + NEUTRAL_BOX + ' px-4 py-3 text-sm text-fg-muted',
|
|
32
|
+
info: 'flex items-start gap-3 rounded-lg bg-info-soft px-4 py-3 text-sm text-info-on-soft',
|
|
33
|
+
success: 'flex items-start gap-3 rounded-lg bg-success-soft px-4 py-3 text-sm text-success-on-soft',
|
|
34
|
+
warning: 'flex items-start gap-3 rounded-lg bg-warning-soft px-4 py-3 text-sm text-warning-on-soft',
|
|
35
|
+
danger: 'flex items-start gap-3 rounded-lg bg-danger-soft px-4 py-3 text-sm text-danger-on-soft',
|
|
33
36
|
},
|
|
34
37
|
lg: {
|
|
35
|
-
neutral: 'flex items-start gap-3
|
|
36
|
-
info: 'flex items-start gap-3 rounded-lg
|
|
37
|
-
success: 'flex items-start gap-3 rounded-lg
|
|
38
|
-
warning: 'flex items-start gap-3 rounded-lg
|
|
39
|
-
danger: 'flex items-start gap-3 rounded-lg
|
|
38
|
+
neutral: 'flex items-start gap-3 ' + NEUTRAL_BOX + ' px-5 py-4 text-base text-fg-muted',
|
|
39
|
+
info: 'flex items-start gap-3 rounded-lg bg-info-soft px-5 py-4 text-base text-info-on-soft',
|
|
40
|
+
success: 'flex items-start gap-3 rounded-lg bg-success-soft px-5 py-4 text-base text-success-on-soft',
|
|
41
|
+
warning: 'flex items-start gap-3 rounded-lg bg-warning-soft px-5 py-4 text-base text-warning-on-soft',
|
|
42
|
+
danger: 'flex items-start gap-3 rounded-lg bg-danger-soft px-5 py-4 text-base text-danger-on-soft',
|
|
40
43
|
},
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
// 图标位:圆形实心徽(实心底只配 -fg);neutral 用灰底
|
|
44
|
-
const ICON_CLASS: Record<KitTone, string> = {
|
|
47
|
+
export const ICON_CLASS: Record<KitTone, string> = {
|
|
45
48
|
neutral: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-border text-xs font-medium text-fg-muted',
|
|
46
49
|
info: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-info text-xs font-medium text-info-fg',
|
|
47
50
|
success: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-success text-xs font-medium text-success-fg',
|
|
48
51
|
warning: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-warning text-xs font-medium text-warning-fg',
|
|
49
52
|
danger: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-danger text-xs font-medium text-danger-fg',
|
|
50
53
|
};
|
|
51
|
-
const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
54
|
+
export const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
52
55
|
const TITLE_CLASS = 'font-medium';
|
|
53
56
|
const CONTENT_CLASS = 'block';
|
|
54
|
-
const CLOSE_CLASS = 'shrink-0 cursor-pointer rounded-md px-1 opacity-70 transition-colors hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
57
|
+
export const CLOSE_CLASS = 'shrink-0 cursor-pointer rounded-md px-1 opacity-70 transition-colors hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
55
58
|
|
|
56
59
|
const ICON_NAME: Record<KitTone, KitIconName> = {
|
|
57
60
|
neutral: 'minus',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 锚盒跟随触发点、随滚动与尺寸变化重定位);
|
|
6
6
|
// - 标记(本文件):面板根标 data-kit-anchored 与 data-kit-placement="top|bottom|start|end"(落位后的实际方向,翻转 / 重定位后随之更新)。
|
|
7
7
|
// 样式只认这两个属性(nine-dim-structure 的「载体与布局构件」规则(carrierRules)):进场 120ms / 出场 80ms(motion.json 的 popover 意图令牌),从锚点方向小位移 + 缩放 + 淡入,
|
|
8
|
-
// 减弱动效只淡入淡出;表面(浮起面 +
|
|
8
|
+
// 减弱动效只淡入淡出;表面(浮起面 + 发丝描边 + 双层阴影,不叠顶部内高光——D-05 / KT-B4)读 --soma-surface-raised / --soma-elevation-raised;
|
|
9
9
|
// - 出场(本文件的 leaveAnchored):复用 overlay-runtime 的隐藏前过渡机制(beginKitLeave:标 data-kit-leaving + inert,等退场动画结束再收尾,
|
|
10
10
|
// 带超时兜底,没有退场动画则立即收尾)。
|
|
11
11
|
// 层栈与焦点域仍各有唯一裁决者:Esc 只关栈顶由 core 浮层挂载点登记的层栈裁决,焦点隔离 / 回焦归各组件的 focus-scope;本文件不另立。
|
package/src/base/button.ts
CHANGED
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
kitDisabledRecipe,
|
|
18
18
|
setKitFace,
|
|
19
19
|
} from '../recipes';
|
|
20
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
21
|
+
import { KIT_CONTROL } from 'soma-foundation/kit-control';
|
|
22
|
+
import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
|
|
20
23
|
import { KIT_REASON_TIP_CLASS_CANDIDATES, releaseReasonTip, syncReasonTip } from './reason-tip';
|
|
21
24
|
import { KIT_BUSY_SPIN_ATTR, KIT_BUSY_SPIN_CLASS_CANDIDATES } from './action-busy';
|
|
22
25
|
|
|
@@ -33,42 +36,50 @@ export type ButtonVariant = 'primary' | 'neutral' | 'danger' | 'ghost' | 'tonal'
|
|
|
33
36
|
|
|
34
37
|
// 变体 × 档位,直接由 kitControlRecipe 生成
|
|
35
38
|
export const BUTTON_CLASS: Record<ButtonVariant, Record<KitSize, string>> = {
|
|
39
|
+
// tonal = 与主动作并列的品牌性备选(品牌浅色填充;页面显式写 tone: tonal 才有,默认的次级动作是描边中性钮)
|
|
36
40
|
tonal: {
|
|
37
|
-
sm:
|
|
38
|
-
md:
|
|
39
|
-
lg:
|
|
41
|
+
sm: kitEmphasisButtonRecipe('button.brandAlt', { size: 'sm' }),
|
|
42
|
+
md: kitEmphasisButtonRecipe('button.brandAlt', { size: 'md' }),
|
|
43
|
+
lg: kitEmphasisButtonRecipe('button.brandAlt', { size: 'lg' }),
|
|
40
44
|
},
|
|
41
45
|
primary: {
|
|
42
46
|
sm: kitControlRecipe({ variant: 'primary', size: 'sm' }),
|
|
43
47
|
md: kitControlRecipe({ variant: 'primary', size: 'md' }),
|
|
44
48
|
lg: kitControlRecipe({ variant: 'primary', size: 'lg' }),
|
|
45
49
|
},
|
|
50
|
+
// neutral = 次级动作(取消 / 返回 / 关闭 / 刷新 / 重置):白底 1px 描边的中性钮(强调四档的第二档),不是色调填充
|
|
46
51
|
neutral: {
|
|
47
|
-
sm:
|
|
48
|
-
md:
|
|
49
|
-
lg:
|
|
52
|
+
sm: kitEmphasisButtonRecipe('button.toolbar', { size: 'sm' }),
|
|
53
|
+
md: kitEmphasisButtonRecipe('button.toolbar', { size: 'md' }),
|
|
54
|
+
lg: kitEmphasisButtonRecipe('button.toolbar', { size: 'lg' }),
|
|
50
55
|
},
|
|
56
|
+
// danger = 危险:平时中性灰字、悬停才变红(实心危险色只给确认弹层的确认钮,见 data/shape-util 的 ACTION_BUTTON_CONFIRM_DANGER)
|
|
51
57
|
danger: {
|
|
52
|
-
sm:
|
|
53
|
-
md:
|
|
54
|
-
lg:
|
|
58
|
+
sm: kitEmphasisButtonRecipe('button.danger', { size: 'sm' }),
|
|
59
|
+
md: kitEmphasisButtonRecipe('button.danger', { size: 'md' }),
|
|
60
|
+
lg: kitEmphasisButtonRecipe('button.danger', { size: 'lg' }),
|
|
55
61
|
},
|
|
62
|
+
// ghost = 安静:仅图标或灰色文字
|
|
56
63
|
ghost: {
|
|
57
|
-
sm:
|
|
58
|
-
md:
|
|
59
|
-
lg:
|
|
64
|
+
sm: kitEmphasisButtonRecipe('button.quiet', { size: 'sm' }),
|
|
65
|
+
md: kitEmphasisButtonRecipe('button.quiet', { size: 'md' }),
|
|
66
|
+
lg: kitEmphasisButtonRecipe('button.quiet', { size: 'lg' }),
|
|
60
67
|
},
|
|
61
68
|
};
|
|
62
69
|
|
|
63
70
|
const SPINNER_WRAP_CLASS = 'absolute inset-0 flex items-center justify-center';
|
|
64
71
|
const SPINNER_CLASS = KIT_SPINNER_CLASS;
|
|
65
72
|
|
|
66
|
-
// icon_only
|
|
67
|
-
const ICON_ONLY_WIDTH: Record<KitSize, string> = {
|
|
73
|
+
// icon_only:宽度等于同档高度(正方形,KT-K0-1 / KT-K-button-3),宽与高读同一个真源键 KC heightUnits;文字藏起来只留符号
|
|
74
|
+
const ICON_ONLY_WIDTH: Record<KitSize, string> = {
|
|
75
|
+
sm: `w-${KIT_CONTROL.heightUnits.sm}`,
|
|
76
|
+
md: `w-${KIT_CONTROL.heightUnits.md}`,
|
|
77
|
+
lg: `w-${KIT_CONTROL.heightUnits.lg}`,
|
|
78
|
+
};
|
|
68
79
|
|
|
69
80
|
export const KIT_BUTTON_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
70
81
|
Object.values(BUTTON_CLASS).flatMap((m) => Object.values(m)), Object.values(ICON_ONLY_WIDTH), SPINNER_WRAP_CLASS, SPINNER_CLASS,
|
|
71
|
-
KIT_BUSY_SPIN_CLASS_CANDIDATES, 'hidden', 'inline-block', 'relative',
|
|
82
|
+
KIT_BUSY_SPIN_CLASS_CANDIDATES, 'hidden', 'inline-block', 'inline-flex', 'relative',
|
|
72
83
|
KIT_BADGE_CLASS_CANDIDATES, KIT_REASON_TIP_CLASS_CANDIDATES, kitDisabledRecipe('aria'),
|
|
73
84
|
);
|
|
74
85
|
|
|
@@ -153,8 +164,14 @@ export function createButton(): SomaComponentDefinition {
|
|
|
153
164
|
}
|
|
154
165
|
if (icon) {
|
|
155
166
|
const glyph = str(p.icon);
|
|
156
|
-
icon
|
|
157
|
-
|
|
167
|
+
// icon 写 kit 图标名(如新建的 plus)画 SVG,其余按短符号原样画
|
|
168
|
+
if ((KIT_ICON_NAMES as readonly string[]).includes(glyph)) {
|
|
169
|
+
icon.replaceChildren(kitIcon(glyph as KitIconName, 'sm'));
|
|
170
|
+
icon.className = 'inline-flex';
|
|
171
|
+
} else {
|
|
172
|
+
icon.textContent = glyph;
|
|
173
|
+
icon.className = glyph !== '' ? 'inline-block' : 'hidden';
|
|
174
|
+
}
|
|
158
175
|
}
|
|
159
176
|
if (label) {
|
|
160
177
|
label.textContent = str(p.label);
|
package/src/base/cascader.ts
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
14
14
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
15
15
|
import { kitKey, kitText } from '../i18n/kit-text';
|
|
16
|
-
import { kitIcon } from '
|
|
16
|
+
import { kitIcon } from '../shared/icons';
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
19
|
+
import { kitDivideRecipe } from '../recipes/divider';
|
|
17
20
|
import type { CollectionItem } from 'soma-core/keyboard';
|
|
18
21
|
import {
|
|
19
|
-
EMPTY_ROW_CLASS, KIT_POPUP_CLASS_CANDIDATES, KIT_DROPDOWN_CLASS_CANDIDATES, PANEL_BASE_CLASS,
|
|
22
|
+
EMPTY_ROW_CLASS, KIT_POPUP_CLASS_CANDIDATES, KIT_DROPDOWN_CLASS_CANDIDATES, KIT_DROPDOWN_PANEL_MAX_CLASS, PANEL_BASE_CLASS,
|
|
20
23
|
syncDropdown, releaseDropdown, cssEscape, createListNav, onOutsidePress, optionClass, scrollIntoViewIfAny,
|
|
21
24
|
} from './popup';
|
|
22
25
|
import {
|
|
@@ -31,9 +34,10 @@ const WRAP = 'relative block w-full';
|
|
|
31
34
|
const STATUS = 'sr-only';
|
|
32
35
|
const PANEL_HIDDEN = 'hidden';
|
|
33
36
|
// 位置类(left-0 top-full mt-1 或翻转后的整串)由 popup.ts 的 syncDropdown 拼上,这里只写外观
|
|
34
|
-
|
|
37
|
+
// 多列面板 = 浮起表面(KT-B4);列与列之间的线由父出(kitDivideRecipe,KT-B5)
|
|
38
|
+
const PANEL_COLUMNS = mergeClass('absolute z-10 flex max-w-full overflow-auto', `${kitSurfaceRecipe('raised')} ${kitDivideRecipe('x')}`);
|
|
35
39
|
const PANEL_FLAT = PANEL_BASE_CLASS;
|
|
36
|
-
const COLUMN =
|
|
40
|
+
const COLUMN = `${KIT_DROPDOWN_PANEL_MAX_CLASS} min-w-40 overflow-auto py-1`;
|
|
37
41
|
const CHEVRON = 'ms-auto text-fg-subtle';
|
|
38
42
|
const LABEL = 'min-w-0 truncate';
|
|
39
43
|
|
package/src/base/check-core.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// 状态同时由 JS 着色(paintCheck);用户操作后浏览器已翻转 checked,交互层只在回调里交出「想切到的值」。
|
|
16
16
|
|
|
17
17
|
import { classCandidates, type KitSize } from './shared';
|
|
18
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
18
19
|
|
|
19
20
|
export type CheckKind = 'checkbox' | 'radio';
|
|
20
21
|
export type CheckState = boolean | 'mixed';
|
|
@@ -41,16 +42,18 @@ const INPUT = 'peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appea
|
|
|
41
42
|
const INPUT_RO = 'peer absolute inset-0 z-10 m-0 h-full w-full cursor-default appearance-none opacity-0';
|
|
42
43
|
|
|
43
44
|
const FRAME = 'col-start-1 row-start-1 transition-colors group-hover:border-primary peer-checked:border-primary peer-checked:bg-primary peer-indeterminate:border-primary peer-indeterminate:bg-primary peer-focus-visible:ring-2 peer-focus-visible:ring-ring';
|
|
45
|
+
// 复选 / 单选外圈 = 控件轮廓(KT-B1「复选 / 单选框外圈」,§4 C6);悬停变色由 FRAME 的 group-hover 给
|
|
46
|
+
const EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
44
47
|
const BOX: Record<CheckKind, Record<KitSize, string>> = {
|
|
45
48
|
checkbox: {
|
|
46
|
-
sm: `${FRAME} h-4 w-4 rounded-sm
|
|
47
|
-
md: `${FRAME} h-4 w-4 rounded-sm
|
|
48
|
-
lg: `${FRAME} h-5 w-5 rounded-sm
|
|
49
|
+
sm: `${FRAME} h-4 w-4 rounded-sm ${EDGE} bg-surface`,
|
|
50
|
+
md: `${FRAME} h-4 w-4 rounded-sm ${EDGE} bg-surface`,
|
|
51
|
+
lg: `${FRAME} h-5 w-5 rounded-sm ${EDGE} bg-surface`,
|
|
49
52
|
},
|
|
50
53
|
radio: {
|
|
51
|
-
sm: `${FRAME} h-4 w-4 rounded-full
|
|
52
|
-
md: `${FRAME} h-4 w-4 rounded-full
|
|
53
|
-
lg: `${FRAME} h-5 w-5 rounded-full
|
|
54
|
+
sm: `${FRAME} h-4 w-4 rounded-full ${EDGE} bg-surface`,
|
|
55
|
+
md: `${FRAME} h-4 w-4 rounded-full ${EDGE} bg-surface`,
|
|
56
|
+
lg: `${FRAME} h-5 w-5 rounded-full ${EDGE} bg-surface`,
|
|
54
57
|
},
|
|
55
58
|
};
|
|
56
59
|
const TICK: Record<KitSize, string> = {
|
package/src/base/color-picker.ts
CHANGED
|
@@ -14,8 +14,9 @@ import { createKeyboardWiring } from 'soma-core/keyboard';
|
|
|
14
14
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
15
15
|
import { part, wirePopLayer } from './popover';
|
|
16
16
|
import { KIT_DROPDOWN_CLASS_CANDIDATES } from './popup';
|
|
17
|
-
import { mergeClass } from '../
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
18
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
19
|
+
import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
|
|
19
20
|
import {
|
|
20
21
|
CLASS_PROP, ID_PROPS, INVALID_PROPS, SIZE_PROP,
|
|
21
22
|
applyCommon, applyCompositeField, bool, classCandidates, createKitController, joinClass, nextUid, setAttr, sizeOf, str,
|
|
@@ -64,10 +65,13 @@ export function presetsOf(raw: unknown): string[] {
|
|
|
64
65
|
// ── 类串 ──────────────────────────────────────────────────────
|
|
65
66
|
|
|
66
67
|
const ROOT = 'relative block w-full';
|
|
68
|
+
// 触发钮 / 色块 / 自定义输入的边 = 控件轮廓出口(KT-B1 / §4 C6)
|
|
69
|
+
const EDGE = kitControlEdgeRecipe();
|
|
70
|
+
const CHIP_EDGE = kitControlEdgeRecipe({ wrapper: true });
|
|
67
71
|
const TRIGGER: Record<KitSize, string> = {
|
|
68
|
-
sm:
|
|
69
|
-
md:
|
|
70
|
-
lg:
|
|
72
|
+
sm: `inline-flex h-6 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-2.5 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
|
|
73
|
+
md: `inline-flex h-8 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-3 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
|
|
74
|
+
lg: `inline-flex h-10 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-4 text-base text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
|
|
71
75
|
};
|
|
72
76
|
const TRIGGER_TEXT = 'min-w-0 flex-1 truncate text-start';
|
|
73
77
|
const TRIGGER_TEXT_EMPTY = 'min-w-0 flex-1 truncate text-start text-fg-subtle';
|
|
@@ -76,11 +80,11 @@ const SWATCH_RECT = 'stroke-border stroke-1';
|
|
|
76
80
|
const PANEL = mergeClass('absolute z-10 w-64 p-3 focus-visible:outline-none', kitSurfaceRecipe('raised'));
|
|
77
81
|
const HIDDEN = 'hidden';
|
|
78
82
|
const PRESETS = 'flex flex-wrap gap-2';
|
|
79
|
-
const CHIP_IDLE =
|
|
83
|
+
const CHIP_IDLE = `inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md ${CHIP_EDGE} transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;
|
|
80
84
|
const CHIP_ON = 'inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md border-2 border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
81
85
|
const CHIP_SVG = 'h-4 w-4';
|
|
82
86
|
const CUSTOM = 'mt-3 flex flex-col gap-1';
|
|
83
|
-
const CUSTOM_INPUT =
|
|
87
|
+
const CUSTOM_INPUT = kitControlRecipe();
|
|
84
88
|
const CUSTOM_INPUT_BAD = 'block h-8 w-full rounded-md border border-danger-on-soft bg-surface px-2.5 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
85
89
|
const ERROR = 'text-xs text-danger-on-soft';
|
|
86
90
|
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
14
|
import { setKitFace, setKitFixed } from '../recipes';
|
|
15
|
+
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
16
|
+
import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
|
|
17
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
18
|
+
import { mergeClass } from '../shared/merge-class';
|
|
15
19
|
import type { CollectionItem } from 'soma-core/keyboard';
|
|
16
20
|
import {
|
|
17
21
|
EMPTY_ROW_CLASS, cssEscape, createListNav, optionClass, scrollIntoViewIfAny,
|
|
@@ -22,12 +26,14 @@ import {
|
|
|
22
26
|
} from './shared';
|
|
23
27
|
|
|
24
28
|
const ROOT = 'inline-block';
|
|
25
|
-
|
|
26
|
-
const
|
|
29
|
+
// 触发钮 = 带文字中性按钮描边(KT-B1);快捷键提示 = 浅底芯片(无描边);面板 = 浮层表面(KT-B4);搜索框只画朝内的一条分隔线
|
|
30
|
+
const TRIGGER_EDGE = kitButtonEdgeRecipe();
|
|
31
|
+
const TRIGGER = `inline-flex h-8 cursor-pointer items-center gap-3 rounded-md ${TRIGGER_EDGE} bg-surface px-3 text-sm text-fg-muted transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60`;
|
|
32
|
+
const TRIGGER_KEYS = 'rounded-sm bg-surface-sunken px-1.5 py-0.5 text-xs text-fg-subtle';
|
|
27
33
|
const HIDDEN = 'hidden';
|
|
28
34
|
const OVERLAY = 'fixed inset-0 z-50 flex items-start justify-center bg-scrim p-4';
|
|
29
|
-
const DIALOG = 'mt-24 flex max-h-96 w-full max-w-lg flex-col overflow-hidden
|
|
30
|
-
const SEARCH =
|
|
35
|
+
const DIALOG = mergeClass('mt-24 flex max-h-96 w-full max-w-lg flex-col overflow-hidden motion-safe:animate-kit-rise', kitSurfaceRecipe('overlay'));
|
|
36
|
+
const SEARCH = `block h-10 w-full appearance-none autofill-clear ${KIT_DIVIDER_HEAD_CLASS} bg-transparent px-4 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none`;
|
|
31
37
|
const LIST = 'min-h-0 flex-1 overflow-auto py-1';
|
|
32
38
|
const GROUP_LABEL = 'px-4 pb-1 pt-2 text-xs font-semibold text-fg-subtle';
|
|
33
39
|
const STATUS = 'sr-only';
|
package/src/base/context-menu.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// 3. 触发区的外观:虚线框的「右键此处」区域。
|
|
9
9
|
|
|
10
10
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
11
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
11
12
|
import { classCandidates } from './shared';
|
|
12
13
|
|
|
13
14
|
export type Corner = 'tl' | 'tr' | 'bl' | 'br';
|
|
@@ -22,8 +23,10 @@ export const CONTEXT_SHOWN: Record<Corner, string> = {
|
|
|
22
23
|
};
|
|
23
24
|
/** 按点挂浮层时的面板类(fixed,几何由 portal-core 的 showAtPoint 一次写入;无 style= 字面量;进场由 showAtPoint 打的 data-kit-anchored 规则统一驱动) */
|
|
24
25
|
export const CONTEXT_POINT_PANEL = `fixed z-50 flex min-w-40 flex-col ${MENU_PANEL_SURFACE} p-1`;
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
// 右键触发区 = 控件(虚线控件轮廓,与上传投放区同一出口,KT-B1 / §4 C6)
|
|
27
|
+
const AREA_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
28
|
+
export const CONTEXT_AREA ='block w-full cursor-context-menu rounded-lg ' + AREA_EDGE + ' border-dashed bg-surface px-4 py-6 text-center text-sm text-fg-muted transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
29
|
+
export const CONTEXT_AREA_OFF = 'block w-full cursor-not-allowed rounded-lg ' + AREA_EDGE + ' border-dashed bg-surface-sunken px-4 py-6 text-center text-sm text-fg-subtle opacity-60';
|
|
27
30
|
const LONG_PRESS_MS = 500;
|
|
28
31
|
|
|
29
32
|
export const KIT_CONTEXT_MENU_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
package/src/base/date-range.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from './date';
|
|
19
19
|
import { weekStartProp } from './month-grid';
|
|
20
20
|
import { setKitFace } from '../recipes';
|
|
21
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
21
22
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
22
23
|
|
|
23
24
|
const RANGE_CLASS: Record<KitSize, string> = {
|
|
@@ -28,15 +29,17 @@ const RANGE_CLASS: Record<KitSize, string> = {
|
|
|
28
29
|
|
|
29
30
|
const FIELDS_CLASS = 'relative inline-flex items-center gap-2';
|
|
30
31
|
const HIDDEN_CLASS = 'hidden';
|
|
32
|
+
// 两个日期框与日历钮的边 = 控件轮廓出口(KT-B1 / §4 C6)
|
|
33
|
+
const EDGE = kitControlEdgeRecipe();
|
|
31
34
|
const DATE_CLASS: Record<KitSize, string> = {
|
|
32
|
-
sm:
|
|
33
|
-
md:
|
|
34
|
-
lg:
|
|
35
|
+
sm: `block h-6 w-32 rounded-md ${EDGE} bg-surface px-2.5 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger`,
|
|
36
|
+
md: `block h-8 w-36 rounded-md ${EDGE} bg-surface px-3 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger`,
|
|
37
|
+
lg: `block h-10 w-40 rounded-md ${EDGE} bg-surface px-4 text-base text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger`,
|
|
35
38
|
};
|
|
36
39
|
const OPEN_BTN_CLASS: Record<KitSize, string> = {
|
|
37
|
-
sm:
|
|
38
|
-
md:
|
|
39
|
-
lg:
|
|
40
|
+
sm: `inline-flex size-6 shrink-0 p-0 cursor-pointer items-center justify-center rounded-md ${EDGE} bg-surface text-fg-subtle transition-colors enabled:hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60`,
|
|
41
|
+
md: `inline-flex size-8 shrink-0 p-0 cursor-pointer items-center justify-center rounded-md ${EDGE} bg-surface text-fg-subtle transition-colors enabled:hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60`,
|
|
42
|
+
lg: `inline-flex size-10 shrink-0 p-0 cursor-pointer items-center justify-center rounded-md ${EDGE} bg-surface text-fg-subtle transition-colors enabled:hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60`,
|
|
40
43
|
};
|
|
41
44
|
const ICON_CLASS = 'size-4 pointer-events-none';
|
|
42
45
|
|
package/src/base/date.ts
CHANGED
|
@@ -20,9 +20,13 @@ import {
|
|
|
20
20
|
CLASS_PROP, FIELD_INVALID_CLASS, ID_PROPS, INVALID_PROPS, SIZE_PROP,
|
|
21
21
|
applyCommon, classCandidates, bool, createKitController, joinClass, nextUid, setAttr, sizeOf, str, withInvalid, type KitApi, type KitProps, type KitSize,
|
|
22
22
|
} from './shared';
|
|
23
|
-
import { kitIcon } from '
|
|
23
|
+
import { kitIcon } from '../shared/icons';
|
|
24
24
|
import { setKitFace } from '../recipes';
|
|
25
|
-
import {
|
|
25
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
26
|
+
|
|
27
|
+
// 日期框的边 = 控件轮廓出口(KT-B1 / §4 C6,与输入框同一条控件线)
|
|
28
|
+
const CONTROL_EDGE = kitControlEdgeRecipe();
|
|
29
|
+
import { mergeClass } from '../shared/merge-class';
|
|
26
30
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
27
31
|
import { KIT_DROPDOWN_CLASS_CANDIDATES, focusCellQuiet, handoffTab, onOutsidePress, releaseDropdown, syncDropdown, trackInputModality } from './popup';
|
|
28
32
|
|
|
@@ -31,15 +35,15 @@ import { KIT_DROPDOWN_CLASS_CANDIDATES, focusCellQuiet, handoffTab, onOutsidePre
|
|
|
31
35
|
const ROOT_CLASS = 'relative block w-full';
|
|
32
36
|
const HIDDEN_CLASS = 'hidden';
|
|
33
37
|
const INPUT_CLASS: Record<KitSize, string> = {
|
|
34
|
-
sm: 'block h-6 w-full appearance-none autofill-clear rounded-md
|
|
35
|
-
md: 'block h-8 w-full appearance-none autofill-clear rounded-md
|
|
36
|
-
lg: 'block h-10 w-full appearance-none autofill-clear rounded-md
|
|
38
|
+
sm: 'block h-6 w-full appearance-none autofill-clear rounded-md ' + CONTROL_EDGE + ' bg-surface ps-2.5 pe-8 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger',
|
|
39
|
+
md: 'block h-8 w-full appearance-none autofill-clear rounded-md ' + CONTROL_EDGE + ' bg-surface ps-3 pe-8 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger',
|
|
40
|
+
lg: 'block h-10 w-full appearance-none autofill-clear rounded-md ' + CONTROL_EDGE + ' bg-surface ps-4 pe-9 text-base text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken aria-invalid:border-danger',
|
|
37
41
|
};
|
|
38
42
|
const OPEN_BTN_CLASS = 'absolute end-0 top-0 border-0 bg-transparent flex h-full w-8 p-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle transition-colors enabled:hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
39
43
|
const CLEAR_BTN_CLASS = 'absolute end-8 top-0 border-0 bg-transparent flex h-full w-6 p-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
40
44
|
const ICON_CLASS = 'size-4 pointer-events-none';
|
|
41
45
|
|
|
42
|
-
const PANEL_BASE = mergeClass('absolute z-10 flex w-max flex-col gap-2 p-4', kitSurfaceRecipe('raised'));
|
|
46
|
+
const PANEL_BASE = mergeClass('absolute z-10 flex w-max min-w-full flex-col gap-2 p-4', kitSurfaceRecipe('raised'));
|
|
43
47
|
const MONTHS_CLASS = 'flex gap-4';
|
|
44
48
|
const MONTH_CLASS = 'flex flex-col gap-1';
|
|
45
49
|
const MONTH_HEAD_CLASS = 'flex items-center justify-between gap-2';
|
package/src/base/delta.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
6
6
|
import { kitLocaleAt, kitText } from '../i18n/kit-text';
|
|
7
|
-
import { kitIcon } from '
|
|
7
|
+
import { kitIcon } from '../shared/icons';
|
|
8
8
|
import {
|
|
9
9
|
CLASS_PROP, ID_PROPS, SIZE_PROP,
|
|
10
10
|
classCandidates, createKitController, formatValue, joinClass, num, setAttr, sizeOf, str,
|
|
@@ -14,11 +14,13 @@ import { trendTone, type TrendTone } from './trend-tone';
|
|
|
14
14
|
import { KIT_DELTA_TEXT } from '../recipes/typography';
|
|
15
15
|
|
|
16
16
|
const ROOT: Readonly<Record<KitSize, string>> = KIT_DELTA_TEXT;
|
|
17
|
-
|
|
17
|
+
/** 涨跌语气 → 文字色(彩色文字只用 -on-soft):KitDelta 与 StatGroup 的趋势共用这一份(趋势 = 文字 + 箭头,无底,不借标签形;KT-K-stat-4) */
|
|
18
|
+
export const KIT_DELTA_TONE_CLASS: Readonly<Record<TrendTone, string>> = {
|
|
18
19
|
good: 'text-success-on-soft',
|
|
19
20
|
bad: 'text-danger-on-soft',
|
|
20
21
|
flat: 'text-fg-muted',
|
|
21
22
|
};
|
|
23
|
+
const TONE_CLASS = KIT_DELTA_TONE_CLASS;
|
|
22
24
|
const SR_ONLY = 'sr-only';
|
|
23
25
|
const EMPTY_TEXT = '—';
|
|
24
26
|
|
package/src/base/divider.ts
CHANGED
|
@@ -7,78 +7,27 @@
|
|
|
7
7
|
|
|
8
8
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
9
9
|
import { CLASS_PROP, bool, createKitController, joinClass, str, type KitTone } from './shared';
|
|
10
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
10
11
|
|
|
11
12
|
export type KitDividerTone = 'neutral' | 'primary' | KitTone;
|
|
12
13
|
const TONES: readonly KitDividerTone[] = ['neutral', 'primary', 'info', 'success', 'warning', 'danger'];
|
|
13
14
|
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
neutral: '
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
danger: 'flex-1 border-t border-danger',
|
|
22
|
-
};
|
|
23
|
-
const LINE_DASHED: Record<KitDividerTone, string> = {
|
|
24
|
-
neutral: 'flex-1 border-t border-dashed border-border-subtle',
|
|
25
|
-
primary: 'flex-1 border-t border-dashed border-primary',
|
|
26
|
-
info: 'flex-1 border-t border-dashed border-info',
|
|
27
|
-
success: 'flex-1 border-t border-dashed border-success',
|
|
28
|
-
warning: 'flex-1 border-t border-dashed border-warning',
|
|
29
|
-
danger: 'flex-1 border-t border-dashed border-danger',
|
|
30
|
-
};
|
|
15
|
+
// 线体:中性线只经分隔线出口(发丝宽、分隔灰,KT-B1 / KT-B5);语气线同宽(发丝档)、取语气色
|
|
16
|
+
const lineOf = (side: 'top' | 'start', tone: KitDividerTone): string =>
|
|
17
|
+
tone === 'neutral' ? kitDividerRecipe(side) : `border-${side === 'top' ? 't' : 's'}-hairline border-${tone}`;
|
|
18
|
+
const table = (layout: string, side: 'top' | 'start', dashed: boolean): Record<KitDividerTone, string> =>
|
|
19
|
+
Object.fromEntries(TONES.map((t) => [t, `${layout} ${lineOf(side, t)}${dashed ? ' border-dashed' : ''}`])) as Record<KitDividerTone, string>;
|
|
20
|
+
const LINE_SOLID = table('flex-1', 'top', false);
|
|
21
|
+
const LINE_DASHED = table('flex-1', 'top', true);
|
|
31
22
|
// 靠前 / 靠后时短的那一侧(定宽)
|
|
32
|
-
const LINE_SHORT_SOLID
|
|
33
|
-
|
|
34
|
-
primary: 'w-6 shrink-0 border-t border-primary',
|
|
35
|
-
info: 'w-6 shrink-0 border-t border-info',
|
|
36
|
-
success: 'w-6 shrink-0 border-t border-success',
|
|
37
|
-
warning: 'w-6 shrink-0 border-t border-warning',
|
|
38
|
-
danger: 'w-6 shrink-0 border-t border-danger',
|
|
39
|
-
};
|
|
40
|
-
const LINE_SHORT_DASHED: Record<KitDividerTone, string> = {
|
|
41
|
-
neutral: 'w-6 shrink-0 border-t border-dashed border-border-subtle',
|
|
42
|
-
primary: 'w-6 shrink-0 border-t border-dashed border-primary',
|
|
43
|
-
info: 'w-6 shrink-0 border-t border-dashed border-info',
|
|
44
|
-
success: 'w-6 shrink-0 border-t border-dashed border-success',
|
|
45
|
-
warning: 'w-6 shrink-0 border-t border-dashed border-warning',
|
|
46
|
-
danger: 'w-6 shrink-0 border-t border-dashed border-danger',
|
|
47
|
-
};
|
|
23
|
+
const LINE_SHORT_SOLID = table('w-6 shrink-0', 'top', false);
|
|
24
|
+
const LINE_SHORT_DASHED = table('w-6 shrink-0', 'top', true);
|
|
48
25
|
// 无文字的整条水平线(根自己就是线)
|
|
49
|
-
const BARE_SOLID
|
|
50
|
-
|
|
51
|
-
primary: 'block w-full border-t border-primary',
|
|
52
|
-
info: 'block w-full border-t border-info',
|
|
53
|
-
success: 'block w-full border-t border-success',
|
|
54
|
-
warning: 'block w-full border-t border-warning',
|
|
55
|
-
danger: 'block w-full border-t border-danger',
|
|
56
|
-
};
|
|
57
|
-
const BARE_DASHED: Record<KitDividerTone, string> = {
|
|
58
|
-
neutral: 'block w-full border-t border-dashed border-border-subtle',
|
|
59
|
-
primary: 'block w-full border-t border-dashed border-primary',
|
|
60
|
-
info: 'block w-full border-t border-dashed border-info',
|
|
61
|
-
success: 'block w-full border-t border-dashed border-success',
|
|
62
|
-
warning: 'block w-full border-t border-dashed border-warning',
|
|
63
|
-
danger: 'block w-full border-t border-dashed border-danger',
|
|
64
|
-
};
|
|
26
|
+
const BARE_SOLID = table('block w-full', 'top', false);
|
|
27
|
+
const BARE_DASHED = table('block w-full', 'top', true);
|
|
65
28
|
// 竖线(行内,如操作项之间)
|
|
66
|
-
const VERTICAL_SOLID
|
|
67
|
-
|
|
68
|
-
primary: 'inline-block h-4 border-l border-primary',
|
|
69
|
-
info: 'inline-block h-4 border-l border-info',
|
|
70
|
-
success: 'inline-block h-4 border-l border-success',
|
|
71
|
-
warning: 'inline-block h-4 border-l border-warning',
|
|
72
|
-
danger: 'inline-block h-4 border-l border-danger',
|
|
73
|
-
};
|
|
74
|
-
const VERTICAL_DASHED: Record<KitDividerTone, string> = {
|
|
75
|
-
neutral: 'inline-block h-4 border-l border-dashed border-border-subtle',
|
|
76
|
-
primary: 'inline-block h-4 border-l border-dashed border-primary',
|
|
77
|
-
info: 'inline-block h-4 border-l border-dashed border-info',
|
|
78
|
-
success: 'inline-block h-4 border-l border-dashed border-success',
|
|
79
|
-
warning: 'inline-block h-4 border-l border-dashed border-warning',
|
|
80
|
-
danger: 'inline-block h-4 border-l border-dashed border-danger',
|
|
81
|
-
};
|
|
29
|
+
const VERTICAL_SOLID = table('inline-block h-4', 'start', false);
|
|
30
|
+
const VERTICAL_DASHED = table('inline-block h-4', 'start', true);
|
|
82
31
|
const LABELED_ROOT = 'flex w-full items-center gap-3';
|
|
83
32
|
const LABEL_CLASS = 'shrink-0 text-xs text-fg-muted';
|
|
84
33
|
|
|
@@ -128,7 +77,7 @@ export function createKitDivider(): SomaComponentDefinition {
|
|
|
128
77
|
class: CLASS_PROP,
|
|
129
78
|
},
|
|
130
79
|
},
|
|
131
|
-
templateHtml:
|
|
80
|
+
templateHtml: `<div data-soma-id="root" role="separator" class="${BARE_SOLID.neutral}"></div>`,
|
|
132
81
|
controllerFactory: createKitController(() => ({
|
|
133
82
|
render(root, p) {
|
|
134
83
|
const plan = dividerPlan(p);
|
package/src/base/end-edge.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// 表壳右侧遮挡标记(量滚动余量,不是版式切换:版式切换走容器查询,不在脚本里量宽度)。
|
|
2
2
|
// 表壳右侧还有被遮住的内容时标 `data-kit-edge-r`,贴右固定的操作格据此出分隔线与阴影;滚动 / 尺寸变化时重算。
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 表壳两侧是否还有被遮住的内容(唯一口径):右侧容差 4px——列轨最小宽之和与容器只差几个像素(取整 / 边框)时不算「还有内容」,
|
|
6
|
+
* 不出分隔线与阴影。table-tools 的 applyEdges 与 watchEndEdge 共用本函数,不各写一份判据。
|
|
7
|
+
*/
|
|
8
|
+
export function measureEdges(el: HTMLElement): { readonly left: boolean; readonly right: boolean } {
|
|
9
|
+
return { left: el.scrollLeft > 0, right: el.scrollLeft + el.clientWidth < el.scrollWidth - 4 };
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
const EDGES = new WeakMap<HTMLElement, { count: number; stop: () => void }>();
|
|
5
13
|
|
|
6
14
|
/**
|
|
@@ -15,8 +23,7 @@ export function watchEndEdge(el: HTMLElement | null): () => void {
|
|
|
15
23
|
return () => release(el);
|
|
16
24
|
}
|
|
17
25
|
const apply = (): void => {
|
|
18
|
-
|
|
19
|
-
if (hidden) el.setAttribute('data-kit-edge-r', '');
|
|
26
|
+
if (measureEdges(el).right) el.setAttribute('data-kit-edge-r', '');
|
|
20
27
|
else el.removeAttribute('data-kit-edge-r');
|
|
21
28
|
};
|
|
22
29
|
apply();
|
|
@@ -27,7 +34,12 @@ export function watchEndEdge(el: HTMLElement | null): () => void {
|
|
|
27
34
|
if (ro !== null) {
|
|
28
35
|
ro.observe(el);
|
|
29
36
|
if (el.firstElementChild !== null) ro.observe(el.firstElementChild);
|
|
37
|
+
// 表头 / 首行的尺寸变化(字体就绪、列轨重算)不改变壳与首子元素的尺寸,但会改 scrollWidth:一并观察,避免没有溢出时残留分隔线
|
|
38
|
+
for (const part of Array.from(el.querySelectorAll('[data-kit-part="table-head"], [data-kit-part="table-row"]')).slice(0, 2)) ro.observe(part);
|
|
30
39
|
}
|
|
40
|
+
// 字体就绪后列宽才定:再量一次(旧值可能是回退字体下的宽度)
|
|
41
|
+
const fonts = (el.ownerDocument as Document & { fonts?: { ready?: Promise<unknown> } }).fonts;
|
|
42
|
+
void fonts?.ready?.then(apply);
|
|
31
43
|
EDGES.set(el, {
|
|
32
44
|
count: 1,
|
|
33
45
|
stop: () => {
|