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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// 结构化查看配方(JsonView,内容展示批次 ③ 后半):树行、缩进、记号外的字阶、命中高亮、代码井、头部的类串只从这里取(G101:组件文件不手写圆角 / 字阶 / 焦点环)。
|
|
2
|
+
// 记号色与 CodeView 同一张表(recipes/code-view.ts#TOKEN_CLASS)。
|
|
3
|
+
|
|
4
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
5
|
+
import { mergeClass } from '../shared/merge-class';
|
|
6
|
+
import { kitControlRecipe } from './control';
|
|
7
|
+
import { kitShellRecipe } from './container';
|
|
8
|
+
|
|
9
|
+
const WELL_EDGE = kitShellRecipe({ tone: 'sunken', shadow: false });
|
|
10
|
+
|
|
11
|
+
export const KIT_JSON_ROOT_CLASS = 'flex flex-col gap-2';
|
|
12
|
+
export const KIT_JSON_HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
13
|
+
export const KIT_JSON_TITLE_CLASS = 'text-sm font-medium text-fg';
|
|
14
|
+
export const KIT_JSON_COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
15
|
+
export const KIT_JSON_SPACER_CLASS = 'flex-1';
|
|
16
|
+
export const KIT_JSON_SEARCH_CLASS = mergeClass(kitControlRecipe(), 'min-w-40 max-w-64 flex-1');
|
|
17
|
+
export const KIT_JSON_SEARCH_COUNT_CLASS = 'text-xs tabular-nums text-fg-subtle';
|
|
18
|
+
/** 代码井 = 凹槽面的壳配方(容器边,嵌套在面板里由层级规则去框) */
|
|
19
|
+
export const KIT_JSON_WELL_CLASS = mergeClass(WELL_EDGE, 'm-0 p-2 font-mono text-xs text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring');
|
|
20
|
+
export const KIT_JSON_HEIGHT_CLASS: Readonly<Record<string, string>> = Object.freeze({
|
|
21
|
+
none: 'overflow-x-auto',
|
|
22
|
+
sm: 'max-h-40 overflow-auto',
|
|
23
|
+
md: 'max-h-80 overflow-auto',
|
|
24
|
+
lg: 'max-h-96 overflow-auto',
|
|
25
|
+
});
|
|
26
|
+
export const KIT_JSON_ROW_CLASS = 'group flex cursor-pointer items-start gap-1 rounded-sm px-1 py-0.5 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';
|
|
27
|
+
/** 每层 4 个间距单位,最多 11 层,更深保持同一缩进(与 Tree 的扁平缩进同一组字面量) */
|
|
28
|
+
export const KIT_JSON_INDENT: readonly string[] = Object.freeze(['ms-0', 'ms-4', 'ms-8', 'ms-12', 'ms-16', 'ms-20', 'ms-24', 'ms-28', 'ms-32', 'ms-36', 'ms-40', 'ms-44']);
|
|
29
|
+
export const KIT_JSON_TOGGLE_CLASS = 'inline-flex w-4 shrink-0 justify-center text-fg-subtle';
|
|
30
|
+
export const KIT_JSON_INDEX_CLASS = 'shrink-0 text-fg-subtle';
|
|
31
|
+
export const KIT_JSON_KEY_CLASS = 'shrink-0 whitespace-nowrap';
|
|
32
|
+
export const KIT_JSON_COLON_CLASS = 'shrink-0';
|
|
33
|
+
export const KIT_JSON_VALUE_CLASS = 'min-w-0 whitespace-pre-wrap break-all';
|
|
34
|
+
export const KIT_JSON_SUMMARY_CLASS = 'text-fg-subtle';
|
|
35
|
+
export const KIT_JSON_CLIP_NOTE_CLASS = 'ms-1 text-fg-subtle';
|
|
36
|
+
export const KIT_JSON_MORE_CLASS = 'text-primary-on-soft';
|
|
37
|
+
export const KIT_JSON_ACTIONS_CLASS = 'ms-auto flex shrink-0 gap-2 opacity-0 group-hover:opacity-100 group-focus:opacity-100 motion-safe:transition-opacity';
|
|
38
|
+
/** 搜索命中:与 Tree 的命中高亮同一画法;当前命中加下划线(第二线索) */
|
|
39
|
+
export const KIT_JSON_HIT_CLASS = 'rounded-sm bg-warning-soft px-0.5 text-warning-on-soft';
|
|
40
|
+
export const KIT_JSON_HIT_CURRENT_CLASS = 'rounded-sm bg-warning-soft px-0.5 text-warning-on-soft underline';
|
|
41
|
+
export const KIT_JSON_ERROR_DETAIL_CLASS = 'text-xs text-fg-muted break-all';
|
|
42
|
+
export const KIT_JSON_FAIL_BOX_CLASS = 'flex flex-col gap-0.5';
|
|
43
|
+
|
|
44
|
+
export const KIT_JSON_VIEW_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
45
|
+
KIT_JSON_ROOT_CLASS, KIT_JSON_HEAD_CLASS, KIT_JSON_TITLE_CLASS, KIT_JSON_COUNT_CLASS, KIT_JSON_SPACER_CLASS, KIT_JSON_SEARCH_CLASS,
|
|
46
|
+
KIT_JSON_SEARCH_COUNT_CLASS, KIT_JSON_WELL_CLASS, Object.values(KIT_JSON_HEIGHT_CLASS), KIT_JSON_ROW_CLASS, KIT_JSON_INDENT, KIT_JSON_TOGGLE_CLASS,
|
|
47
|
+
KIT_JSON_INDEX_CLASS, KIT_JSON_KEY_CLASS, KIT_JSON_COLON_CLASS, KIT_JSON_VALUE_CLASS, KIT_JSON_SUMMARY_CLASS, KIT_JSON_CLIP_NOTE_CLASS, KIT_JSON_MORE_CLASS, KIT_JSON_ACTIONS_CLASS,
|
|
48
|
+
KIT_JSON_HIT_CLASS, KIT_JSON_HIT_CURRENT_CLASS, KIT_JSON_ERROR_DETAIL_CLASS, KIT_JSON_FAIL_BOX_CLASS,
|
|
49
|
+
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Markdown 正文配方(MarkdownView,内容展示批次 ④):版心、字阶、段距、缩进、列表、引用、行内代码、表格、分割线的类串只从这里取。
|
|
2
|
+
// 依据:参考文本差异组件笔记 C.3 / E4;裁决 #4(顶层成段正文首行缩进两字;列表项、引用、表格单元格内的段落不缩进;
|
|
3
|
+
// 只有一句话的短内容不缩进;缩进后段间距取小档;行高 1.7;版心 ≤ 40 字)。
|
|
4
|
+
// 排印尺度(暂行,待令牌):行高 1.7、40 字版心、两字缩进、标题 1.5 / 1.3 / 1.15 倍需要主题单链上的排印尺度(handoff 需对方 N-3),
|
|
5
|
+
// 到位前暂借 kit-theme 已有阶梯里最接近的类(leading-6 = 1.5rem ≈ 1.7×14px、max-w-2xl = 48rem、indent-8 = 2rem),只在本文件的 MD_TYPE 一张表;到位后只改这张表。
|
|
6
|
+
|
|
7
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
8
|
+
import { mergeClass } from '../shared/merge-class';
|
|
9
|
+
import { kitShellRecipe } from './container';
|
|
10
|
+
import { kitDividerRecipe } from './divider';
|
|
11
|
+
|
|
12
|
+
const MD_TYPE = Object.freeze({
|
|
13
|
+
/** 正文容器:版心与行高 */
|
|
14
|
+
body: 'max-w-2xl text-sm leading-6 text-fg break-words',
|
|
15
|
+
/** 段落:缺省段距;首行缩进两字的段落段距取小档;紧凑列表 / 单元格里的段落无段距 */
|
|
16
|
+
p: 'my-3',
|
|
17
|
+
pIndent: 'my-1 indent-8',
|
|
18
|
+
pTight: 'my-0',
|
|
19
|
+
h1: 'mt-6 mb-2 text-xl font-semibold text-fg',
|
|
20
|
+
h2: 'mt-5 mb-2 text-lg font-semibold text-fg',
|
|
21
|
+
h3: 'mt-4 mb-1.5 text-base font-semibold text-fg',
|
|
22
|
+
h4: 'mt-3 mb-1 text-sm font-semibold text-fg',
|
|
23
|
+
list: 'my-2 ps-8',
|
|
24
|
+
li: 'my-1',
|
|
25
|
+
task: 'my-1 flex list-none items-start gap-2',
|
|
26
|
+
quote: `my-3 border-s-emphasis border-border-subtle ps-3 text-fg-muted`,
|
|
27
|
+
code: 'rounded-sm bg-surface-sunken px-1 py-0.5 font-mono text-xs',
|
|
28
|
+
table: 'my-3 overflow-x-auto',
|
|
29
|
+
th: mergeClass(kitDividerRecipe('bottom'), 'px-3 py-1.5 align-top font-medium'),
|
|
30
|
+
td: mergeClass(kitDividerRecipe('bottom'), 'px-3 py-1.5 align-top'),
|
|
31
|
+
hr: mergeClass(kitDividerRecipe('top'), 'my-5'),
|
|
32
|
+
img: 'my-2 block max-w-full rounded-md',
|
|
33
|
+
html: 'my-2 whitespace-pre-wrap font-mono text-xs text-fg-muted',
|
|
34
|
+
footnotes: mergeClass(kitDividerRecipe('top'), 'mt-6 pt-3 text-xs text-fg-muted'),
|
|
35
|
+
fnref: 'ms-0.5 align-super text-xs',
|
|
36
|
+
strong: 'font-semibold',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// ── MarkdownView 组件外框与附件(目录、代码块、任务框、图片失败、纯文本降级) ──
|
|
40
|
+
export const KIT_MD_STRONG_CLASS = MD_TYPE.strong;
|
|
41
|
+
export const KIT_MD_ROOT_CLASS = 'flex flex-col gap-2';
|
|
42
|
+
/** 代码块井 = 凹槽面的壳配方 */
|
|
43
|
+
export const KIT_MD_CODE_WELL_CLASS = mergeClass(kitShellRecipe({ tone: 'sunken', shadow: false }), 'my-3 p-3 font-mono text-xs text-fg');
|
|
44
|
+
export const KIT_MD_CODE_HEAD_CLASS = 'mb-2 flex items-center justify-between gap-2';
|
|
45
|
+
export const KIT_MD_TASK_BOX_CLASS = 'mt-1 inline-flex size-4 shrink-0 items-center justify-center rounded-sm bg-surface-sunken text-primary-on-soft';
|
|
46
|
+
export const KIT_MD_EXT_ICON_CLASS = 'ms-0.5 inline align-baseline';
|
|
47
|
+
export const KIT_MD_IMG_FAIL_CLASS = 'my-2 block text-xs text-fg-subtle';
|
|
48
|
+
export const KIT_MD_TOC_CLASS = 'flex flex-col gap-1 text-sm';
|
|
49
|
+
export const KIT_MD_TOC_TITLE_CLASS = 'text-xs font-medium text-fg-muted';
|
|
50
|
+
export const KIT_MD_TOC_ITEM_CLASS: Readonly<Record<number, string>> = Object.freeze({ 1: 'ps-0', 2: 'ps-0', 3: 'ps-4' });
|
|
51
|
+
export const KIT_MD_PLAIN_P_CLASS = 'my-2 whitespace-pre-wrap';
|
|
52
|
+
const MD_PARTS: readonly string[] = Object.freeze([
|
|
53
|
+
KIT_MD_ROOT_CLASS, KIT_MD_CODE_WELL_CLASS, KIT_MD_CODE_HEAD_CLASS, KIT_MD_TASK_BOX_CLASS, KIT_MD_EXT_ICON_CLASS, KIT_MD_IMG_FAIL_CLASS,
|
|
54
|
+
KIT_MD_TOC_CLASS, KIT_MD_TOC_TITLE_CLASS, ...Object.values(KIT_MD_TOC_ITEM_CLASS), KIT_MD_PLAIN_P_CLASS,
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export const KIT_MD_BODY_CLASS = MD_TYPE.body;
|
|
58
|
+
export const KIT_MD_P_CLASS = MD_TYPE.p;
|
|
59
|
+
export const KIT_MD_P_INDENT_CLASS = MD_TYPE.pIndent;
|
|
60
|
+
export const KIT_MD_P_TIGHT_CLASS = MD_TYPE.pTight;
|
|
61
|
+
export const KIT_MD_LIST_CLASS = MD_TYPE.list;
|
|
62
|
+
export const KIT_MD_LI_CLASS = MD_TYPE.li;
|
|
63
|
+
export const KIT_MD_TASK_CLASS = MD_TYPE.task;
|
|
64
|
+
export const KIT_MD_QUOTE_CLASS = MD_TYPE.quote;
|
|
65
|
+
export const KIT_MD_CODE_CLASS = MD_TYPE.code;
|
|
66
|
+
export const KIT_MD_TABLE_WRAP_CLASS = MD_TYPE.table;
|
|
67
|
+
export const KIT_MD_TABLE_CLASS = 'min-w-full';
|
|
68
|
+
export const KIT_MD_TH_CLASS = MD_TYPE.th;
|
|
69
|
+
export const KIT_MD_TD_CLASS = MD_TYPE.td;
|
|
70
|
+
export const KIT_MD_HR_CLASS = MD_TYPE.hr;
|
|
71
|
+
export const KIT_MD_IMG_CLASS = MD_TYPE.img;
|
|
72
|
+
export const KIT_MD_HTML_CLASS = MD_TYPE.html;
|
|
73
|
+
export const KIT_MD_FOOTNOTES_CLASS = MD_TYPE.footnotes;
|
|
74
|
+
export const KIT_MD_FNREF_CLASS = MD_TYPE.fnref;
|
|
75
|
+
export const KIT_MD_LINK_CLASS = 'text-primary-on-soft underline underline-offset-2 hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm';
|
|
76
|
+
export const KIT_MD_DEL_CLASS = 'line-through';
|
|
77
|
+
export const KIT_MD_LIST_STYLE: Readonly<Record<'ul' | 'ol', string>> = Object.freeze({ ul: 'list-disc', ol: 'list-decimal' });
|
|
78
|
+
|
|
79
|
+
/** 标题深度(已叠加起始层级偏移)→ 类 */
|
|
80
|
+
export function kitMdHeadingClass(depth: number): string {
|
|
81
|
+
return depth <= 1 ? MD_TYPE.h1 : depth === 2 ? MD_TYPE.h2 : depth === 3 ? MD_TYPE.h3 : MD_TYPE.h4;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const KIT_MARKDOWN_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
85
|
+
Object.values(MD_TYPE), KIT_MD_TABLE_CLASS, KIT_MD_LINK_CLASS, KIT_MD_DEL_CLASS, Object.values(KIT_MD_LIST_STYLE), MD_PARTS,
|
|
86
|
+
);
|
package/src/recipes/overlay.ts
CHANGED
|
@@ -1,25 +1,86 @@
|
|
|
1
1
|
// 浮层配方(overlay.ts):覆盖 dialog / drawer / popover / toast 四类浮层容器,
|
|
2
2
|
// 以及头(shrink-0)、体(flex-1 min-h-0 overflow-y-auto)、尾(shrink-0)三段式固定外壳子配方。
|
|
3
3
|
|
|
4
|
-
import { classCandidates } from '../
|
|
5
|
-
import { KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
|
|
6
|
-
import {
|
|
4
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
5
|
+
import { KIT_OVERLAY_LIMITS, KIT_SIZE_SPEC } from 'soma-foundation/kit-limits';
|
|
6
|
+
import { KIT_INSET_SURFACE_CLASS, KIT_INSET_SURFACE_X_CLASS, KIT_STRIP_FOOT_CLASS, KIT_STRIP_HEAD_CLASS } from './strip';
|
|
7
|
+
import { mergeClass } from '../shared/merge-class';
|
|
7
8
|
import { KIT_SURFACE_EDGE_CLASS, kitSurfaceRecipe } from './surface';
|
|
9
|
+
import { KIT_DIVIDER_FOOT_CLASS, KIT_DIVIDER_HEAD_CLASS } from './divider';
|
|
10
|
+
import { kitTypographyRecipe } from './typography';
|
|
11
|
+
import { kitFocusRingRecipe } from './state';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
|
-
* 浮层宽度(
|
|
14
|
+
* 浮层宽度(KT-K-overlay-1):确认窗口一档、对话框三档(默认 / 宽 / 特宽)、抽屉两档;数字只在 design 真源 kit-limits#overlay(宽度阶梯 sizeSpec.ladders.width),
|
|
11
15
|
* 这里把它翻成任意值 px 类(与侧栏宽度同一做法)。
|
|
12
16
|
*/
|
|
13
17
|
/** 对话框面板的表面:浮层级(圆角 xl + hairline 描边 + overlay 底 + 双层阴影 + 高光边,见 recipes/surface.ts);业务浮层壳 / 命令式模态 / 对话框配方共用这一份 */
|
|
14
18
|
export const KIT_DIALOG_SURFACE_CLASS = mergeClass('overflow-hidden', kitSurfaceRecipe('overlay'));
|
|
15
19
|
|
|
20
|
+
/** 抽屉宽度三档(同对话框三档的结构:数字在 kit-limits#overlay.drawerPx 的 narrow / default / wide);小屏下 max-w-full 不超过视口宽 */
|
|
21
|
+
export type KitDrawerWidth = 'default' | 'wide';
|
|
22
|
+
export const KIT_DRAWER_WIDTHS: readonly KitDrawerWidth[] = Object.freeze(['default', 'wide'] as const);
|
|
23
|
+
|
|
24
|
+
export const KIT_DRAWER_WIDTH_CLASS: Readonly<Record<KitDrawerWidth, string>> = Object.freeze({
|
|
25
|
+
default: `w-[${KIT_OVERLAY_LIMITS.drawerPx.default}px] max-w-full`,
|
|
26
|
+
wide: `w-[${KIT_OVERLAY_LIMITS.drawerPx.wide}px] max-w-full`,
|
|
27
|
+
});
|
|
28
|
+
|
|
16
29
|
export const KIT_OVERLAY_WIDTH_CLASS = Object.freeze({
|
|
30
|
+
confirm: `max-w-[${KIT_OVERLAY_LIMITS.confirmPx}px]`,
|
|
17
31
|
dialog: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.default}px]`,
|
|
18
32
|
dialogWide: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.wide}px]`,
|
|
19
33
|
dialogXWide: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.xwide}px]`,
|
|
20
|
-
drawer:
|
|
34
|
+
drawer: KIT_DRAWER_WIDTH_CLASS.default,
|
|
35
|
+
drawerWide: KIT_DRAWER_WIDTH_CLASS.wide,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** 窗口宽度档名:确认 400 / 表单 480 · 640 · 800(px 读 kit-limits#overlay;档位由内容经引擎推导,页面不写) */
|
|
39
|
+
export type KitDialogTier = 'confirm' | 'default' | 'wide' | 'xwide';
|
|
40
|
+
|
|
41
|
+
const DIALOG_TIER_WIDTH_CLASS: Readonly<Record<KitDialogTier, string>> = Object.freeze({
|
|
42
|
+
confirm: KIT_OVERLAY_WIDTH_CLASS.confirm,
|
|
43
|
+
default: KIT_OVERLAY_WIDTH_CLASS.dialog,
|
|
44
|
+
wide: KIT_OVERLAY_WIDTH_CLASS.dialogWide,
|
|
45
|
+
xwide: KIT_OVERLAY_WIDTH_CLASS.dialogXWide,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 居中窗口面板类串(声明式与命令式共用的唯一一份):宽度档上限 + 最大高度占满遮罩内容盒(遮罩给顶边 96、底留白 48,故最大高 = 视口高 − 144)、
|
|
50
|
+
* 纵向 flex(头 / 底栏 shrink-0,正文滚动)、浮层级表面与入场动画。
|
|
51
|
+
*/
|
|
52
|
+
export function kitDialogPanelClass(tier: KitDialogTier): string {
|
|
53
|
+
return `flex max-h-full w-full ${DIALOG_TIER_WIDTH_CLASS[tier]} flex-col ${KIT_DIALOG_SURFACE_CLASS} motion-safe:animate-kit-dialog-in`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 遮罩行类串(遮罩本身 = 定位行,一层):居中窗口顶边固定在内容面上沿下 topPx、底部留 bottomGapPx、左右各留 narrowMarginPx
|
|
58
|
+
* (窄屏下窗口宽 = 视口 − 2 × 边距,档位上限自然失效);窗口不垂直居中,内容多少只改高度、不改顶边。抽屉贴 end 侧整高。
|
|
59
|
+
*/
|
|
60
|
+
export const KIT_OVERLAY_SCRIM_CLASS = Object.freeze({
|
|
61
|
+
dialog: `fixed inset-0 z-50 flex items-start justify-center bg-scrim pt-[${KIT_OVERLAY_LIMITS.topPx}px] pb-[${KIT_OVERLAY_LIMITS.bottomGapPx}px] px-[${KIT_OVERLAY_LIMITS.narrowMarginPx}px] motion-safe:animate-kit-fade`,
|
|
62
|
+
drawer: 'fixed inset-0 z-50 flex justify-end bg-scrim motion-safe:animate-kit-fade',
|
|
21
63
|
});
|
|
22
64
|
|
|
65
|
+
/** 对话框宽度档名(页面 DSL 的 kind: dialog 的 width;档位与像素只读 kit-limits#overlay.dialogPx:default / wide / xwide) */
|
|
66
|
+
export const KIT_DIALOG_WIDTH_TIERS: readonly string[] = Object.freeze(Object.keys(KIT_OVERLAY_LIMITS.dialogPx));
|
|
67
|
+
export function isKitDialogWidth(value: unknown): value is 'default' | 'wide' | 'xwide' {
|
|
68
|
+
return typeof value === 'string' && KIT_DIALOG_WIDTH_TIERS.includes(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 是抽屉宽度档名(命令式选项与页面 DSL 共用的判据) */
|
|
72
|
+
export function isKitDrawerWidth(value: unknown): value is KitDrawerWidth {
|
|
73
|
+
return typeof value === 'string' && (KIT_DRAWER_WIDTHS as readonly string[]).includes(value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 抽屉面板类串(命令式 mountKitDrawer 与页面 DSL 的抽屉外壳共用一份):贴 end 侧的纵向 flex 列(头 / 底栏 shrink-0、体滚动由调用方的体子配方给),
|
|
78
|
+
* 表面是浮层级贴边表面(kitSurfaceRecipe('overlay') 的无圆角对应物),进场从 end 侧滑入(RTL 自动换向),宽度三档。
|
|
79
|
+
*/
|
|
80
|
+
export function kitDrawerPanelClass(width: KitDrawerWidth = 'default'): string {
|
|
81
|
+
return `flex h-full ${KIT_DRAWER_WIDTH_CLASS[width]} flex-col overflow-hidden border-s-edge border-border-container ${KIT_SURFACE_EDGE_CLASS} motion-safe:animate-kit-drawer-in-end rtl:motion-safe:animate-kit-drawer-in-start`;
|
|
82
|
+
}
|
|
83
|
+
|
|
23
84
|
export const KIT_PART_DIALOG = 'dialog' as const;
|
|
24
85
|
export const KIT_PART_DRAWER = 'drawer' as const;
|
|
25
86
|
export const KIT_PART_POPOVER = 'popover' as const;
|
|
@@ -61,15 +122,20 @@ const POPOVER_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.free
|
|
|
61
122
|
xl: 'w-96',
|
|
62
123
|
});
|
|
63
124
|
|
|
125
|
+
// 轻提示宽度(KT-K-feedback-2,§6.1 G-10):随内容(w-max),上限 kit-limits#overlay.toastPx——居中落在页头标题与动作之间的留白里;
|
|
126
|
+
// 单行高 = 页头标题行高(sizeSpec.strip.pageTitleRowPx),与标题行同一条带。尺寸档只留一种宽度规则(一个值一个键)
|
|
127
|
+
const TOAST_WIDTH_CLASS = `w-max max-w-[${KIT_OVERLAY_LIMITS.toastPx}px] min-h-[${KIT_SIZE_SPEC.strip.pageTitleRowPx}px]`;
|
|
64
128
|
const TOAST_SIZE_CLASS: Readonly<Record<KitOverlaySize, string>> = Object.freeze({
|
|
65
|
-
sm:
|
|
66
|
-
md:
|
|
67
|
-
lg:
|
|
68
|
-
xl:
|
|
129
|
+
sm: TOAST_WIDTH_CLASS,
|
|
130
|
+
md: TOAST_WIDTH_CLASS,
|
|
131
|
+
lg: TOAST_WIDTH_CLASS,
|
|
132
|
+
xl: TOAST_WIDTH_CLASS,
|
|
69
133
|
});
|
|
134
|
+
/** 轻提示容器的上偏移(KT-K-feedback-2,§6.1 G-10):= 页边距 sizeSpec.inset.pageMarginPx(标准密度),与页头标题行顶对齐 */
|
|
135
|
+
export const KIT_TOAST_TOP_CLASS = `top-[${KIT_SIZE_SPEC.inset.pageMarginPx.standard}px]`;
|
|
70
136
|
|
|
71
137
|
const TOAST_TONED_SKELETON_CLASS =
|
|
72
|
-
'flex items-start gap-3 rounded-lg border-hairline border-border-subtle px-4 py-3 text-sm shadow-raised
|
|
138
|
+
'flex items-start gap-3 rounded-lg border-hairline border-border-subtle px-4 py-3 text-sm shadow-raised';
|
|
73
139
|
|
|
74
140
|
const OVERLAY_SKELETON_CLASS: Readonly<Record<KitOverlayKind, string>> = Object.freeze({
|
|
75
141
|
dialog:
|
|
@@ -80,21 +146,46 @@ const OVERLAY_SKELETON_CLASS: Readonly<Record<KitOverlayKind, string>> = Object.
|
|
|
80
146
|
popover:
|
|
81
147
|
mergeClass(kitSurfaceRecipe('raised'), 'text-fg'),
|
|
82
148
|
toast:
|
|
83
|
-
mergeClass('flex items-
|
|
149
|
+
mergeClass('flex items-center gap-3 px-4 py-2 text-sm text-fg', kitSurfaceRecipe('raised')),
|
|
84
150
|
});
|
|
85
151
|
|
|
86
152
|
// 面板内边距 16(间距阶 4 / 8 / 12 / 16 / 24);body 带 group:自带底栏的表单据 group-data-kit-overlay-scroll 变体在浮层里改成「滚动区 + 底栏」两段
|
|
153
|
+
// 头 / 底栏 / 面内边距不是窗口自己的数:取通用条带配方(recipes/strip.ts,读 kit-limits#sizeSpec),与页面头部条、面板头、分页栏同一个出口
|
|
154
|
+
const STRIP_HEAD = KIT_STRIP_HEAD_CLASS;
|
|
155
|
+
const STRIP_FOOT = KIT_STRIP_FOOT_CLASS;
|
|
156
|
+
const INSET_SURFACE = KIT_INSET_SURFACE_CLASS;
|
|
157
|
+
const INSET_SURFACE_X = KIT_INSET_SURFACE_X_CLASS;
|
|
87
158
|
const OVERLAY_HEADER_CLASS =
|
|
88
|
-
|
|
159
|
+
`flex ${STRIP_HEAD} shrink-0 items-center justify-between gap-4 ${KIT_DIVIDER_HEAD_CLASS} ${INSET_SURFACE_X}`;
|
|
89
160
|
/** 体里含自带底栏的表单(底栏带 data-kit-overlay-foot)时:体自己不滚动、不留内边距,由表单内的滚动区滚动、底栏贴浮层底 */
|
|
90
161
|
export const KIT_OVERLAY_FOOT_ATTR = 'data-kit-overlay-foot' as const;
|
|
91
162
|
const OVERLAY_BODY_FOOT_CLASS = [`has-${KIT_OVERLAY_FOOT_ATTR}:overflow-hidden`, `has-${KIT_OVERLAY_FOOT_ATTR}:p-0`].join(' ');
|
|
92
163
|
// 体是纵向 flex 且 min-h-0:浮层(对话框 max-h / 抽屉 h-full)是 flex-col,头 shrink-0、体 flex-1 min-h-0、尾 shrink-0,体内容超长时体滚动(无自带底栏的内容);
|
|
93
164
|
// 自带底栏的表单见 KIT_OVERLAY_FORM_* 三件:宿主 / 表单 flex-1 min-h-0,滚动区 overflow-y-auto,底栏 shrink-0 不在滚动区里
|
|
94
165
|
const OVERLAY_BODY_CLASS =
|
|
95
|
-
`group flex flex-1 min-h-0 flex-col overflow-y-auto
|
|
166
|
+
`group flex flex-1 min-h-0 flex-col overflow-y-auto ${INSET_SURFACE} ${OVERLAY_BODY_FOOT_CLASS}`;
|
|
96
167
|
const OVERLAY_FOOTER_CLASS =
|
|
97
|
-
|
|
168
|
+
`flex ${STRIP_FOOT} shrink-0 items-center justify-end gap-2 ${KIT_DIVIDER_FOOT_CLASS} ${INSET_SURFACE_X}`;
|
|
169
|
+
/**
|
|
170
|
+
* 确认类窗口(确认 / 危险确认)的引导头(C 稿:没有头部条与空泛标题):语气图标块 + 一列「具体问句标题 / 后果说明」,四周面内边距;
|
|
171
|
+
* 正文槽只装键入短语 / 勾选同意之类的附加控件(没有就不占位),底栏仍是 56 的「取消 + 具体动词」。
|
|
172
|
+
*/
|
|
173
|
+
const OVERLAY_LEAD_HEADER_CLASS = `flex shrink-0 items-start gap-4 ${INSET_SURFACE_X} pt-[${KIT_SIZE_SPEC.inset.surfacePx}px] pb-[${KIT_SIZE_SPEC.inset.surfacePx}px]`;
|
|
174
|
+
export const KIT_OVERLAY_LEAD_TEXT_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
175
|
+
const LEAD_ICON_BASE = 'inline-flex size-10 shrink-0 items-center justify-center rounded-md';
|
|
176
|
+
/** 语气图标块:危险确认 = 危险浅底 + 警示图标,普通确认 = 主色浅底 + 信息图标(危险与普通一眼可辨,颜色只用 soft / on-soft 配对) */
|
|
177
|
+
export const KIT_OVERLAY_LEAD_ICON = Object.freeze({
|
|
178
|
+
danger: { cls: `${LEAD_ICON_BASE} bg-danger-soft text-danger-on-soft`, icon: 'warning' as const },
|
|
179
|
+
primary: { cls: `${LEAD_ICON_BASE} bg-primary-soft text-primary-on-soft`, icon: 'info' as const },
|
|
180
|
+
});
|
|
181
|
+
export function kitOverlayLeadHeaderRecipe(): string {
|
|
182
|
+
return OVERLAY_LEAD_HEADER_CLASS;
|
|
183
|
+
}
|
|
184
|
+
/** 引导头窗口的正文槽:上边距并进引导头(不再叠一份 24) */
|
|
185
|
+
export function kitOverlayLeadBodyRecipe(): string {
|
|
186
|
+
return mergeClass(kitOverlayContentRecipe(), 'pt-0 empty:hidden');
|
|
187
|
+
}
|
|
188
|
+
|
|
98
189
|
/** 滚动体标记属性:表单的 group-data-kit-overlay-scroll 变体靠它命中 */
|
|
99
190
|
export const KIT_OVERLAY_SCROLL_ATTR = 'data-kit-overlay-scroll' as const;
|
|
100
191
|
|
|
@@ -103,8 +194,9 @@ const inOverlay = (classes: readonly string[]): string => classes.map((c) => `gr
|
|
|
103
194
|
/**
|
|
104
195
|
* 表单底栏在浮层里的类串(U1c 重做):底栏是浮层 flex 链上的 shrink-0 兄弟(在滚动区之外),不是滚动容器里的 sticky 元素——
|
|
105
196
|
* 内容不足一屏时它贴浮层底,内容超长时它不随内容滚动。只在祖先是带 group 的浮层体时生效,页面级表单不受影响。
|
|
197
|
+
* 按钮在底栏条带里垂直居中(items-center 压过页面级表单动作行的 items-end):与外壳底栏(OVERLAY_FOOTER_CLASS)同一排法,按钮不贴浮层底边。
|
|
106
198
|
*/
|
|
107
|
-
export const KIT_OVERLAY_FORM_FOOTER_CLASS = inOverlay(['mt-0', 'shrink-0', 'border-t', 'border-border-subtle', 'bg-surface-overlay',
|
|
199
|
+
export const KIT_OVERLAY_FORM_FOOTER_CLASS = inOverlay(['mt-0', 'shrink-0', 'items-center', 'border-t-hairline', 'border-border-subtle', 'bg-surface-overlay', INSET_SURFACE_X, STRIP_FOOT]); // 底栏顶线 = 分隔线出口同一组类(recipes/divider KIT_DIVIDER_FOOT_CLASS,逐类加变体前缀)
|
|
108
200
|
|
|
109
201
|
/**
|
|
110
202
|
* 浮层里表单的撑高链(host 与 form 各一份):host 是体的 flex 子项并本身成 flex 列(flex-1 min-h-0,才能被体 / 浮层高度压住),
|
|
@@ -121,7 +213,7 @@ export const KIT_OVERLAY_FORM_SCROLL_ATTR = 'data-kit-overlay-form-scroll' as co
|
|
|
121
213
|
* 自带 16 内边距(体在含底栏时去了内边距)。gap 是原根的段间距(gap-3 / gap-4 两档)。
|
|
122
214
|
*/
|
|
123
215
|
export function kitOverlayFormScrollClass(gap: 'gap-3' | 'gap-4' | 'gap-0' = 'gap-0'): string {
|
|
124
|
-
return `contents ${inOverlay(['flex', 'flex-col', 'flex-1', 'min-h-0', 'overflow-y-auto',
|
|
216
|
+
return `contents ${inOverlay(['flex', 'flex-col', 'flex-1', 'min-h-0', 'overflow-y-auto', INSET_SURFACE, gap])}`;
|
|
125
217
|
}
|
|
126
218
|
|
|
127
219
|
/**
|
|
@@ -173,6 +265,30 @@ export function kitOverlayBodyRecipe(): string {
|
|
|
173
265
|
return OVERLAY_BODY_CLASS;
|
|
174
266
|
}
|
|
175
267
|
|
|
268
|
+
/**
|
|
269
|
+
* 命令式浮层(确认 / 提示 / 抽屉 / 选择器)的内容区子配方:浮层主体(独立滚动区)+ 纵向间距 + 正文字号 / 辅助色。
|
|
270
|
+
* 与页面 DSL 的外壳不同,命令式浮层的 body 由调用方塞内容,这里给内容的默认排版;对话框与抽屉同一份。
|
|
271
|
+
*/
|
|
272
|
+
export function kitOverlayContentRecipe(): string {
|
|
273
|
+
return mergeClass(OVERLAY_BODY_CLASS, 'gap-3 text-sm text-fg-muted');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** 浮层标题类串(对话框、抽屉同一份:弹窗标题字阶,去默认外距) */
|
|
277
|
+
export function kitOverlayTitleRecipe(): string {
|
|
278
|
+
return mergeClass(kitTypographyRecipe('dialogTitle'), 'm-0');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 浮层头右侧操作区(编辑钮 + 关闭钮)类串 */
|
|
282
|
+
export const KIT_OVERLAY_HEAD_ACTIONS_CLASS = 'flex items-center gap-cluster';
|
|
283
|
+
|
|
284
|
+
/** 浮层关闭钮类串(图标钮,各浮层外壳共用一份) */
|
|
285
|
+
export const KIT_OVERLAY_CLOSE_CLASS = 'inline-flex size-8 shrink-0 border-0 bg-transparent p-0 cursor-pointer items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
286
|
+
|
|
287
|
+
/** 命令式抽屉面板的焦点处理:面板自己(tabindex -1)获得焦点时不画轮廓,焦点环只给内部可操作元素 */
|
|
288
|
+
export function kitDrawerFocusRecipe(): string {
|
|
289
|
+
return 'focus-visible:outline-none';
|
|
290
|
+
}
|
|
291
|
+
|
|
176
292
|
/**
|
|
177
293
|
* 浮层尾部子配方(固定底部操作栏 shrink-0,不随主体滚动)。
|
|
178
294
|
*/
|
|
@@ -192,8 +308,11 @@ export function kitOverlayFooterRecipe(): string {
|
|
|
192
308
|
|
|
193
309
|
const TOAST_ACTION_CLASS =
|
|
194
310
|
'ms-auto rounded-md px-1 font-medium underline transition-colors hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
195
|
-
|
|
196
|
-
|
|
311
|
+
// 轻提示关闭钮(KT-K-feedback-2):kit 无 preflight,显式清掉原生按钮的边与底(第二轮改后取证发现原生灰框);悬停走状态层;焦点 = 块焦点(外偏移)
|
|
312
|
+
const TOAST_CLOSE_CLASS = mergeClass(
|
|
313
|
+
'ms-auto inline-flex h-6 w-6 min-h-6 min-w-6 shrink-0 appearance-none items-center justify-center rounded-md border-0 bg-transparent p-0 text-fg-muted transition-colors hover:bg-state-layer-hover hover:text-fg',
|
|
314
|
+
kitFocusRingRecipe('button'),
|
|
315
|
+
);
|
|
197
316
|
const TOAST_TITLE_CLASS = 'font-semibold';
|
|
198
317
|
|
|
199
318
|
/**
|
|
@@ -222,8 +341,20 @@ export const KIT_OVERLAY_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandi
|
|
|
222
341
|
TOAST_TONED_SKELETON_CLASS,
|
|
223
342
|
Object.values(DIALOG_SIZE_CLASS),
|
|
224
343
|
Object.values(DRAWER_SIZE_CLASS),
|
|
344
|
+
KIT_DRAWER_WIDTHS.map((w) => kitDrawerPanelClass(w)),
|
|
345
|
+
(Object.keys(DIALOG_TIER_WIDTH_CLASS) as KitDialogTier[]).map((t) => kitDialogPanelClass(t)),
|
|
346
|
+
Object.values(KIT_OVERLAY_SCRIM_CLASS),
|
|
347
|
+
kitOverlayContentRecipe(),
|
|
348
|
+
kitOverlayTitleRecipe(),
|
|
349
|
+
OVERLAY_LEAD_HEADER_CLASS,
|
|
350
|
+
KIT_OVERLAY_LEAD_TEXT_CLASS,
|
|
351
|
+
Object.values(KIT_OVERLAY_LEAD_ICON).map((t) => t.cls),
|
|
352
|
+
kitOverlayLeadBodyRecipe(),
|
|
353
|
+
KIT_OVERLAY_HEAD_ACTIONS_CLASS,
|
|
354
|
+
KIT_OVERLAY_CLOSE_CLASS,
|
|
225
355
|
Object.values(POPOVER_SIZE_CLASS),
|
|
226
356
|
Object.values(TOAST_SIZE_CLASS),
|
|
357
|
+
KIT_TOAST_TOP_CLASS,
|
|
227
358
|
OVERLAY_HEADER_CLASS,
|
|
228
359
|
OVERLAY_BODY_CLASS,
|
|
229
360
|
OVERLAY_FOOTER_CLASS,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 页面版心宽度的通用配方:单对象表单 / 分步表单 / 阅读型页面的最大宽度类串唯一出口,只读真源生成物 kit-limits#sizeSpec(page.formMaxPx / readMaxPx / wideMaxPx,宽度模数阶梯上的值)。
|
|
2
|
+
// 页面框的 max_width 档位(narrow / medium / wide)与表单类页面壳读同一份,不各写一个 max-w-2xl / 3xl。本文件不认识任何具体构件或页面类型。
|
|
3
|
+
|
|
4
|
+
import { KIT_SIZE_SPEC } from 'soma-foundation/kit-limits';
|
|
5
|
+
|
|
6
|
+
/** 单对象表单 / 分步表单版心(page.formMaxPx,720) */
|
|
7
|
+
export const KIT_PAGE_FORM_WIDTH_CLASS = `max-w-[${KIT_SIZE_SPEC.page.formMaxPx}px]`;
|
|
8
|
+
/** 阅读型页面 / 导入向导版心(page.readMaxPx,800) */
|
|
9
|
+
export const KIT_PAGE_READ_WIDTH_CLASS = `max-w-[${KIT_SIZE_SPEC.page.readMaxPx}px]`;
|
|
10
|
+
/** 宽版心(page.wideMaxPx,960) */
|
|
11
|
+
export const KIT_PAGE_WIDE_WIDTH_CLASS = `max-w-[${KIT_SIZE_SPEC.page.wideMaxPx}px]`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 并排时才生效的定宽面(窗格 / 侧轨):容器宽不小于 tier 时宽 = px、不被挤压;窄于 tier 时不定宽(上下堆叠占满整行)。
|
|
15
|
+
* px 必须是宽度模数阶梯上的值(由排布引擎选档,如 arrangePaneWidth),tier 是容器档名;固定 px 类由 compile/styles 的闭集注入器出规则。
|
|
16
|
+
*/
|
|
17
|
+
export function kitFixedPaneClass(px: number, tier: string): string {
|
|
18
|
+
if (!(KIT_SIZE_SPEC.ladders.width as readonly number[]).includes(px)) throw new Error(`[soma-kit] 定宽面 ${px}px 不在宽度模数阶梯上`);
|
|
19
|
+
return `@${tier}:w-[${px}px] @${tier}:shrink-0`;
|
|
20
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// 占位配方(placeholder.ts):骨架屏占位条 / 骨架行与卡 / 集合空态盒的类串(G101:圆角、边框色、字阶等受控类只在 recipes/)。
|
|
2
2
|
// 全部是整串字面量,调用方整串取用,不拆 token 回捞。
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
5
|
+
import { mergeClass } from '../shared/merge-class';
|
|
6
|
+
import { kitShellRecipe } from './container';
|
|
7
|
+
import { kitControlRecipe, kitTextActionRecipe } from './control';
|
|
6
8
|
import { kitTypographyRecipe } from './typography';
|
|
7
9
|
|
|
8
10
|
export const KIT_SKELETON_BAR_BASE = 'rounded-md bg-surface-sunken motion-safe:animate-kit-pulse';
|
|
@@ -39,7 +41,14 @@ export const KIT_SKELETON_SINGLE_PAIR = 'flex flex-col gap-1';
|
|
|
39
41
|
export const KIT_LOADING_HELD_ATTR = 'data-kit-loading-held';
|
|
40
42
|
export const KIT_STATE_LOADING_BOX ='flex items-center justify-center py-5 text-sm text-fg-muted';
|
|
41
43
|
export const KIT_STATE_ERROR_BOX = 'flex flex-wrap items-center justify-center gap-x-3 gap-y-1 py-5 text-center text-sm text-danger-on-soft';
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* 空态只有两种口径(取代原来的 BOX / COMPACT / 集合三种写法):
|
|
46
|
+
* · 集合内空态 EMPTY_BOX(表格、列表、主从右栏、面板内、各数据组件):一行标题 + 至多一个操作,无插画、无框,总高 <= 真源 structure.emptyState.maxHeightPx(88);
|
|
47
|
+
* · 整页 / 首次使用空态 EMPTY_PAGE:才带插画,标题 + 一行说明 + 至多一个操作。
|
|
48
|
+
*/
|
|
49
|
+
// 2026-11-21:收成紧凑一行——左对齐(落在所在面板的文字轴上)、上下内边距取真源 structure.emptyState.padYUnits,不保留主体高度
|
|
50
|
+
export const KIT_STATE_EMPTY_BOX = `flex flex-wrap items-center justify-start gap-x-3 gap-y-1 py-${KIT_NINE_DIM.structure.emptyState.padYUnits} text-left text-sm text-fg-muted`;
|
|
51
|
+
export const KIT_STATE_EMPTY_PAGE = 'flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-fg-muted';
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* 三态面板新增三态(未就绪 / 上游断供 / 无权限)的盒与重试钮尾:
|
|
@@ -50,6 +59,13 @@ export const KIT_STATE_EMPTY_COMPACT = 'py-4 text-center text-sm text-fg-subtle'
|
|
|
50
59
|
export const KIT_STATE_NOT_READY_BOX = 'flex flex-col items-center justify-center gap-1 py-5 text-center text-sm text-fg-muted';
|
|
51
60
|
export const KIT_STATE_UPSTREAM_BOX = 'flex flex-wrap items-center justify-center gap-x-3 gap-y-1 py-5 text-center text-sm text-warning-on-soft';
|
|
52
61
|
export const KIT_STATE_DENIED_BOX = 'flex flex-col items-center justify-center gap-1 py-5 text-center text-sm text-fg-muted';
|
|
62
|
+
/**
|
|
63
|
+
* 整页无权访问(KitAccessGate):页面框整块隐藏后唯一可见的状态,按空状态同一套规则呈现——
|
|
64
|
+
* 在页面边距内的一张面板里水平垂直居中(宿主 WRAP 给页边距,面板取面板配方),标题 + 一句说明两级字号,标题不带句号,不加图标 / 插画。
|
|
65
|
+
*/
|
|
66
|
+
export const KIT_STATE_DENIED_WRAP = 'px-page pt-page';
|
|
67
|
+
export const KIT_STATE_DENIED_PAGE = mergeClass(kitShellRecipe(), 'flex flex-col items-center justify-center gap-2 py-24 text-center text-sm text-fg-muted');
|
|
68
|
+
export const KIT_STATE_DENIED_TITLE = kitTypographyRecipe('sectionTitle');
|
|
53
69
|
|
|
54
70
|
export type KitRetryTone = 'neutral' | 'danger' | 'warning';
|
|
55
71
|
|
|
@@ -72,8 +88,8 @@ export const KIT_STATE_RETRY_CLASS_CANDIDATES: readonly string[] = Object.freeze
|
|
|
72
88
|
[kitRetryRecipe('neutral'), kitRetryRecipe('danger'), kitRetryRecipe('warning')].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')),
|
|
73
89
|
);
|
|
74
90
|
|
|
75
|
-
/**
|
|
76
|
-
export const
|
|
91
|
+
/** 空态里的操作(「清除筛选」/ 页面主操作同名入口):文字操作形态,与行内文字操作同一配方 */
|
|
92
|
+
export const KIT_STATE_EMPTY_ACTION = kitTextActionRecipe('primary');
|
|
77
93
|
/** 三态块里的标题(半粗正文色)与说明(次要色):字阶取自文字配方 */
|
|
78
94
|
export const KIT_STATE_TITLE_CLASS = kitTypographyRecipe('bodyStrong');
|
|
79
95
|
export const KIT_STATE_DESC_CLASS = kitTypographyRecipe('muted');
|
package/src/recipes/rail-grid.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// 调用方在类串里显式写 grid-cols-* / @md:grid-cols-* 时以类串为准(层内规则弱于无层工具类)。
|
|
9
9
|
|
|
10
10
|
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
11
|
+
import { markKitEdge } from './surface-edge';
|
|
11
12
|
|
|
12
13
|
/** 导轨拼合容器标记 */
|
|
13
14
|
export const KIT_RAIL_ATTR = 'data-kit-rail';
|
|
@@ -32,6 +33,8 @@ export function kitRailGridRecipe(): KitRailGridRecipe {
|
|
|
32
33
|
/** 给容器打导轨标记(幂等) */
|
|
33
34
|
export function markKitRail(el: Element): void {
|
|
34
35
|
if (!el.hasAttribute(KIT_RAIL_ATTR)) el.setAttribute(KIT_RAIL_ATTR, '');
|
|
36
|
+
// 导轨容器自带外圈:处在面板内时由 surface-edge 规则去掉,只留块间细线
|
|
37
|
+
markKitEdge(el);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
/** 取值(真源 structure.railGrid):只读投影,供测试与调用方核对,不在这里另写数字 */
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// 统计块三态配方(stat-state.ts):StatGroup 单项的 ready / missing / error 呈现。
|
|
2
|
+
//
|
|
3
|
+
// 状态由数据给(页面不写逻辑);本文件只做「状态词 -> 外观」的对照。取值(占位文字、每个非 ready 态的语义色、
|
|
4
|
+
// 同组原因相同时提到组级的最少项数)只在真源 soma-design 的 kit-limits#statStates(生成投影 KIT_STAT_STATES),这里不写取值:
|
|
5
|
+
// · 缺失项主位只显示「—」(次级色);原因是辅助色小字,不画圆圈 / 图标类标记;
|
|
6
|
+
// · 同一组里多项缺失 / 出错且原因相同(达到 groupReasonMin)时,原因只在组底写一次(组级说明行),各项只留「—」;
|
|
7
|
+
// · 重试 = 行内文字钮(kitTextActionRecipe),与整块可点分属两个目标;组级说明行带一个重试入口。
|
|
8
|
+
|
|
9
|
+
import { KIT_STAT_STATES } from 'soma-foundation/kit-limits';
|
|
10
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
11
|
+
import { kitTextActionRecipe } from './control';
|
|
12
|
+
|
|
13
|
+
export type KitStatState = 'ready' | 'missing' | 'error';
|
|
14
|
+
type KitStatNonReady = Exclude<KitStatState, 'ready'>;
|
|
15
|
+
type KitStatTone = 'neutral' | 'warning' | 'danger';
|
|
16
|
+
|
|
17
|
+
const PRESENTATION = KIT_STAT_STATES.presentation as unknown as Readonly<Record<KitStatNonReady, { tone: KitStatTone }>>;
|
|
18
|
+
|
|
19
|
+
/** 缺失态主数值位的占位文字(真源 kit-limits#statStates.placeholder) */
|
|
20
|
+
export const KIT_STAT_PLACEHOLDER: string = KIT_STAT_STATES.placeholder as string;
|
|
21
|
+
/** 同组原因相同的非 ready 项达到这个数,原因提到组级(真源 kit-limits#statStates.groupReasonMin) */
|
|
22
|
+
export const KIT_STAT_GROUP_REASON_MIN: number = KIT_STAT_STATES.groupReasonMin as number;
|
|
23
|
+
|
|
24
|
+
/** 状态词归一:只认 missing / error,其余(含空、gap / unknown 旧词)一律 ready 由原有逻辑处理 */
|
|
25
|
+
export function statStateOf(raw: unknown): KitStatState {
|
|
26
|
+
return raw === 'missing' || raw === 'error' ? raw : 'ready';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 警告语气的指标名前圆点(图形标记,aria-hidden;数字本身不着色,彩色大号文字不用警告色,评审 §1.2) */
|
|
30
|
+
export const KIT_STAT_WARN_DOT_CLASS = 'me-1.5 inline-block h-1.5 w-1.5 rounded-full bg-warning align-middle';
|
|
31
|
+
|
|
32
|
+
/** 状态行:原因文字单行;min-w-0 让原因在窄块里截断 */
|
|
33
|
+
export const KIT_STAT_STATE_ROW = 'flex min-w-0 items-center gap-1.5 text-xs';
|
|
34
|
+
/** 原因文字:单行截断(悬停 / 聚焦被截断时由 hint-tips 挂全文气泡,作用范围由行上的 data-kit-tips 标出) */
|
|
35
|
+
export const KIT_STAT_STATE_REASON = 'min-w-0 truncate';
|
|
36
|
+
/** 组级说明行:统计组底部一行,原因全文(可换行,不截断)+ 重试入口 */
|
|
37
|
+
export const KIT_STAT_GROUP_NOTE = 'flex flex-wrap items-center gap-x-3 gap-y-1 px-1 pt-2 text-xs';
|
|
38
|
+
|
|
39
|
+
const TEXT_TONE: Readonly<Record<KitStatTone, string>> = Object.freeze({
|
|
40
|
+
neutral: 'text-fg-muted',
|
|
41
|
+
warning: 'text-warning-on-soft',
|
|
42
|
+
danger: 'text-danger-on-soft',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/** 状态原因行的类(含语义色文字) */
|
|
46
|
+
export function kitStatStateRowClass(state: KitStatNonReady): string {
|
|
47
|
+
return `${KIT_STAT_STATE_ROW} ${TEXT_TONE[PRESENTATION[state].tone]}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 组级说明行的类(含语义色文字;同一行里 missing 与 error 分行,各自取色) */
|
|
51
|
+
export function kitStatGroupNoteClass(state: KitStatNonReady): string {
|
|
52
|
+
return `${KIT_STAT_GROUP_NOTE} ${TEXT_TONE[PRESENTATION[state].tone]}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 重试钮:行内文字钮 */
|
|
56
|
+
export const KIT_STAT_RETRY_CLASS = kitTextActionRecipe('primary');
|
|
57
|
+
|
|
58
|
+
/** StatGroup 三态自带的全部类(并入 StatGroup 候选) */
|
|
59
|
+
export const KIT_STAT_STATE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
60
|
+
KIT_STAT_STATE_ROW,
|
|
61
|
+
KIT_STAT_STATE_REASON,
|
|
62
|
+
KIT_STAT_GROUP_NOTE,
|
|
63
|
+
Object.values(TEXT_TONE),
|
|
64
|
+
KIT_STAT_RETRY_CLASS,
|
|
65
|
+
);
|
package/src/recipes/state.ts
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
// 状态配方(state.ts):焦点环、禁用态、选中态、错误态四类纯函数配方。
|
|
2
2
|
// 统一采用单一焦点环(消除双环与非预期蓝色轮廓;高对比度模式由 kit-theme.tpl @media (forced-colors: active) 保底);
|
|
3
|
-
//
|
|
3
|
+
// 禁用态只用专用令牌(底 control-disabled、字 fg-disabled,KT-K0-4 第 1 点,二-6),不整体降透明度;去掉架空 cursor-not-allowed 的指针事件阻断类。
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { controlDisabled, controlFocus, controlInvalid } from 'soma-foundation/kit-control';
|
|
6
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
export type
|
|
8
|
+
/** 焦点宿主(KT-K0-3):control 输入类、wrapper 输入装饰外框(focus-within 版)、button 可点的块、item 集合内的项 */
|
|
9
|
+
export type KitFocusRingKind = 'control' | 'wrapper' | 'button' | 'item';
|
|
10
|
+
/** quiet = 无底的文字 / 幽灵类:禁用只换字色 */
|
|
11
|
+
export type KitDisabledKind = 'control' | 'button' | 'quiet' | 'text' | 'aria';
|
|
9
12
|
export type KitSelectedTone = 'primary' | 'subtle';
|
|
10
13
|
|
|
11
14
|
// 焦点环 = 实心描边(G82 判它 ≥ 3:1:控件 1px 主色描边 + ring-1、按钮 / 条目 2px 环,宽度见真源 structure.focusRing)
|
|
12
15
|
// + 外侧柔和外晕(shadow-focus-halo*,主色低透明度,纯装饰,不判对比度;外晕半径 = 环宽 + structure.stateLayer.focusHaloPx)。
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
control:
|
|
24
|
-
'disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
|
|
25
|
-
button:
|
|
26
|
-
'disabled:cursor-not-allowed disabled:opacity-60',
|
|
27
|
-
text:
|
|
28
|
-
'cursor-not-allowed text-fg-subtle opacity-60',
|
|
29
|
-
// 带原因的置灰(只留 aria-disabled、不用原生 disabled,保持可聚焦):伪类 disabled: 不生效,直接写静态类
|
|
30
|
-
aria:
|
|
31
|
-
'cursor-not-allowed opacity-60',
|
|
32
|
-
});
|
|
16
|
+
// 焦点环(按宿主)、禁用态(专用令牌 + 统一透明度,带原因的置灰用静态类 aria)、错误态的类集合都在 soma-design/spec/pipeline/kit-control.json,
|
|
17
|
+
// 求解在 soma-foundation/kit-control;本文件只给出口,不写字面。
|
|
18
|
+
const FOCUS_RING_KINDS: readonly KitFocusRingKind[] = Object.freeze(['control', 'wrapper', 'button', 'item']);
|
|
19
|
+
const DISABLED_KINDS: readonly KitDisabledKind[] = Object.freeze(['control', 'button', 'quiet', 'text', 'aria']);
|
|
20
|
+
const FOCUS_RING_MAP: Readonly<Record<KitFocusRingKind, string>> = Object.freeze(
|
|
21
|
+
Object.fromEntries(FOCUS_RING_KINDS.map((k) => [k, controlFocus(k).join(' ')])) as Record<KitFocusRingKind, string>,
|
|
22
|
+
);
|
|
23
|
+
const DISABLED_MAP: Readonly<Record<KitDisabledKind, string>> = Object.freeze(
|
|
24
|
+
Object.fromEntries(DISABLED_KINDS.map((k) => [k, controlDisabled(k).join(' ')])) as Record<KitDisabledKind, string>,
|
|
25
|
+
);
|
|
33
26
|
|
|
34
27
|
const SELECTED_MAP: Readonly<Record<KitSelectedTone, string>> = Object.freeze({
|
|
35
|
-
// 选中 =
|
|
28
|
+
// 选中 = 主色状态层(百分比只在真源 structure.stateLayer.selectedPct,D-11:注释不抄数字),文字 primary-on-soft 余量只增不减
|
|
36
29
|
primary: 'bg-state-layer-selected text-primary-on-soft font-medium',
|
|
37
30
|
subtle: 'bg-surface-sunken text-fg font-medium',
|
|
38
31
|
});
|
|
39
32
|
|
|
40
|
-
const INVALID_CLASS =
|
|
41
|
-
'border-danger focus-visible:border-danger focus-visible:ring-danger focus-within:border-danger focus-within:ring-danger';
|
|
33
|
+
const INVALID_CLASS = controlInvalid(true).join(' ');
|
|
42
34
|
|
|
43
35
|
/**
|
|
44
36
|
* 焦点环配方:统一使用单一焦点环,消除双焦点指示。
|
|
@@ -48,7 +40,7 @@ export function kitFocusRingRecipe(kind: KitFocusRingKind = 'control'): string {
|
|
|
48
40
|
}
|
|
49
41
|
|
|
50
42
|
/**
|
|
51
|
-
*
|
|
43
|
+
* 禁用态配方:控件引擎出口(kit-control#disabled:专用令牌,不降透明度),无指针事件阻断类。
|
|
52
44
|
*/
|
|
53
45
|
export function kitDisabledRecipe(kind: KitDisabledKind = 'control'): string {
|
|
54
46
|
return DISABLED_MAP[kind] ?? DISABLED_MAP.control;
|