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/recipes/control.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
// 控件配方(control.ts
|
|
1
|
+
// 控件配方(control.ts):覆盖单行输入、选择器触发器、多行文本(多行不进胶囊圆角)、按钮与徽标、行内文字链接、分段按钮、说明钮,
|
|
2
2
|
// 统一高度(sm / md / lg)、内边距、边框与圆角,并提供 data-kit-part 常量标识。
|
|
3
|
+
//
|
|
4
|
+
// 本文件只做「配方出口」:高度 / 内边距 / 间距 / 字号档 / 圆角 / 变体的面与状态层 / 焦点环 / 禁用态的取值与类集合全部在
|
|
5
|
+
// soma-design/spec/pipeline/kit-control.json,求解在 soma-foundation/kit-control(控件几何引擎,E6),这里不写任何 h-* / px-* / text-* / rounded-* 字面。
|
|
6
|
+
// 按钮、输入、选择器、徽标、分段、行内操作、说明钮一律经 kitControlRecipe / kitTextActionRecipe / kitSegmentRecipe / kitHelpTriggerRecipe 取类串,
|
|
7
|
+
// 不再手写各自的按钮类串(原六套并存已迁入)。
|
|
3
8
|
|
|
4
|
-
import {
|
|
5
|
-
import { classCandidates } from '../
|
|
6
|
-
import type { KitSize } from '../
|
|
7
|
-
import { kitDisabledRecipe, kitFocusRingRecipe, kitInvalidRecipe } from './state';
|
|
8
|
-
|
|
9
|
-
/** 小号控件高度类(间距单位倍数,读 design 真源 kit-nine-dim.json#structure.smallControlHeightUnits:标准密度 6 × 4 = 24px,随密度同比走) */
|
|
10
|
-
const SMALL_CONTROL_H = `h-${KIT_NINE_DIM.structure.smallControlHeightUnits}`;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 按钮按下反馈:自定义工具类 press-feedback(kit-theme.tpl),按下时 transform 取 --soma-lift-press(design motion.json#lift.pressScale 0.985);
|
|
14
|
-
* 只在 prefers-reduced-motion: no-preference 下生效,减少动效下令牌同时被 design reducedMotion 归 none。
|
|
15
|
-
*/
|
|
16
|
-
const PRESS_FEEDBACK = 'press-feedback';
|
|
9
|
+
import { controlClasses, controlRecipe, controlSizeClasses } from 'soma-foundation/kit-control';
|
|
10
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
11
|
+
import type { KitSize } from '../shared/primitives-types';
|
|
17
12
|
|
|
18
13
|
export const KIT_PART_CONTROL = 'control' as const;
|
|
19
14
|
export const KIT_PART_BUTTON = 'button' as const;
|
|
@@ -35,6 +30,9 @@ export type KitControlVariant =
|
|
|
35
30
|
| 'danger'
|
|
36
31
|
| 'ghost'
|
|
37
32
|
| 'tonal'
|
|
33
|
+
| 'dangerSoft'
|
|
34
|
+
| 'dangerOutline'
|
|
35
|
+
| 'quiet'
|
|
38
36
|
| 'badge';
|
|
39
37
|
|
|
40
38
|
export interface KitControlRecipeOptions {
|
|
@@ -43,39 +41,23 @@ export interface KitControlRecipeOptions {
|
|
|
43
41
|
invalid?: boolean;
|
|
44
42
|
disabled?: boolean;
|
|
45
43
|
multiline?: boolean;
|
|
44
|
+
/** 工具条按钮:横向内边距降一档(四元组其余不变);只对按钮变体生效 */
|
|
45
|
+
tight?: boolean;
|
|
46
|
+
/** 鼠标指针(cursor-pointer):<button> 在页头 / 外壳里要手形时给 */
|
|
47
|
+
pointer?: boolean;
|
|
48
|
+
/** <a> 链接宿主:没有 enabled 伪类,换成裸伪类并加 no-underline */
|
|
49
|
+
link?: boolean;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
const SINGLE_LINE_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string }>> = Object.freeze({
|
|
49
|
-
// 控件高度档(默认主题):小号读真源 structure.smallControlHeightUnits(24)、标准 32 = h-8(间距单位 4 × 8,与 design 真源 density.controlUnits = 8 同值)
|
|
50
|
-
sm: { h: SMALL_CONTROL_H, px: 'px-2.5', text: 'text-sm' },
|
|
51
|
-
md: { h: 'h-8', px: 'px-3', text: 'text-sm' },
|
|
52
|
-
lg: { h: 'h-10', px: 'px-4', text: 'text-base' },
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const BUTTON_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string; gap: string }>> = Object.freeze({
|
|
56
|
-
sm: { h: SMALL_CONTROL_H, px: 'px-3', text: 'text-sm', gap: 'gap-1' },
|
|
57
|
-
md: { h: 'h-8', px: 'px-4', text: 'text-sm', gap: 'gap-2' },
|
|
58
|
-
lg: { h: 'h-10', px: 'px-5', text: 'text-base', gap: 'gap-2' },
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const MULTILINE_SIZE_CLASS: Readonly<Record<KitControlSize, { minH: string; px: string; py: string; text: string }>> = Object.freeze({
|
|
62
|
-
sm: { minH: 'min-h-20', px: 'px-2.5', py: 'py-1.5', text: 'text-sm' },
|
|
63
|
-
md: { minH: 'min-h-24', px: 'px-3', py: 'py-2', text: 'text-sm' },
|
|
64
|
-
lg: { minH: 'min-h-28', px: 'px-4', py: 'py-2.5', text: 'text-base' },
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const BADGE_SIZE_CLASS: Readonly<Record<KitControlSize, string>> = Object.freeze({
|
|
68
|
-
sm: 'h-5 px-1.5 text-xs gap-1',
|
|
69
|
-
md: 'h-6 px-2 text-xs gap-1',
|
|
70
|
-
lg: 'h-7 px-2.5 text-sm gap-1.5',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
52
|
const BUTTON_VARIANTS: ReadonlySet<KitControlVariant> = new Set([
|
|
74
53
|
'primary',
|
|
75
54
|
'neutral',
|
|
76
55
|
'danger',
|
|
77
56
|
'ghost',
|
|
78
57
|
'tonal',
|
|
58
|
+
'dangerSoft',
|
|
59
|
+
'dangerOutline',
|
|
60
|
+
'quiet',
|
|
79
61
|
]);
|
|
80
62
|
|
|
81
63
|
/**
|
|
@@ -90,14 +72,24 @@ export function kitButtonEdgeRecipe(): string {
|
|
|
90
72
|
return BUTTON_EDGE_CLASS;
|
|
91
73
|
}
|
|
92
74
|
|
|
75
|
+
/**
|
|
76
|
+
* 控件轮廓的边(KT-B1「控件轮廓」角色、§4 C6):只取控件引擎 field 部件该变体的描边类(宽 + 控件轮廓色 + 悬停色),与 kitControlRecipe 的输入框逐个相同(D-16 同一条线)。
|
|
77
|
+
* 给自绘的多段控件外壳用(多选框 / 标签输入 / 步进器 / 自绘选择框 / 复选框外圈)——它们的尺寸与布局不是标准输入框,但边必须是同一条控件线。
|
|
78
|
+
* wrapper:外壳不是表单元素(div / span 没有 :enabled),悬停变体去掉 enabled:;hover: false = 禁用 / 只读态整串(不出悬停色)。
|
|
79
|
+
*/
|
|
80
|
+
export function kitControlEdgeRecipe(options: { variant?: 'outline' | 'filled'; wrapper?: boolean; hover?: boolean } = {}): string {
|
|
81
|
+
const tokens = controlClasses({ part: 'field', variant: options.variant ?? 'outline' })
|
|
82
|
+
.filter((t) => /^(?:enabled:hover:)?border(?:-|$)/.test(t))
|
|
83
|
+
.filter((t) => options.hover !== false || !t.includes('hover:'));
|
|
84
|
+
return (options.wrapper === true ? tokens.map((t) => t.replace(/^enabled:/, '')) : tokens).join(' ');
|
|
85
|
+
}
|
|
86
|
+
|
|
93
87
|
/**
|
|
94
88
|
* 控件尺寸子配方函数(返回单行控件尺寸类串:高度 h-*、横向内边距 px-*、字号 text-*)。
|
|
95
89
|
* 供 input.ts 的 BOX_SIZE 等直接同源调用,严禁 .split / .find 回捞。
|
|
96
90
|
*/
|
|
97
91
|
export function kitControlSizeRecipe(size: KitControlSize = 'md'): string {
|
|
98
|
-
|
|
99
|
-
const sz = SINGLE_LINE_SIZE_CLASS[normalized];
|
|
100
|
-
return `${sz.h} ${sz.px} ${sz.text}`;
|
|
92
|
+
return controlSizeClasses('field', size).join(' ');
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
/**
|
|
@@ -111,124 +103,41 @@ export function kitControlPartOf(options: KitControlRecipeOptions = {}): KitCont
|
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
/**
|
|
114
|
-
* 控件配方纯函数:按「骨架 + 变体 + 档位(size / variant / invalid / disabled / multiline)」返回标准 Tailwind
|
|
106
|
+
* 控件配方纯函数:按「骨架 + 变体 + 档位(size / variant / invalid / disabled / multiline)」返回标准 Tailwind 类串(取自控件几何引擎)。
|
|
115
107
|
* 多行文本(multiline: true)固定采用容器级圆角 rounded-md,不进入单行胶囊圆角(rounded-full)。
|
|
116
108
|
*/
|
|
117
109
|
export function kitControlRecipe(options: KitControlRecipeOptions = {}): string {
|
|
118
|
-
const size: KitControlSize = options.size === 'sm' || options.size === 'lg' ? options.size : 'md';
|
|
119
110
|
const variant: KitControlVariant = options.variant ?? 'outline';
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const parts = [
|
|
126
|
-
'inline-flex items-center justify-center rounded-full transition-colors',
|
|
127
|
-
BADGE_SIZE_CLASS[size],
|
|
128
|
-
'bg-surface-sunken font-medium text-fg-muted',
|
|
129
|
-
];
|
|
130
|
-
if (invalid) parts.push(kitInvalidRecipe(true));
|
|
131
|
-
if (disabled) parts.push(kitDisabledRecipe('text'));
|
|
132
|
-
return parts.filter(Boolean).join(' ');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const isButton = !multiline && BUTTON_VARIANTS.has(variant);
|
|
136
|
-
const focusCls = kitFocusRingRecipe(isButton ? 'button' : 'control');
|
|
137
|
-
const disabledCls = kitDisabledRecipe(isButton ? 'button' : 'control');
|
|
138
|
-
const activeDisabledCls = disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
139
|
-
const invalidCls = kitInvalidRecipe(invalid);
|
|
140
|
-
|
|
141
|
-
if (isButton) {
|
|
142
|
-
const sz = BUTTON_SIZE_CLASS[size];
|
|
143
|
-
let middle = '';
|
|
144
|
-
switch (variant) {
|
|
145
|
-
case 'primary':
|
|
146
|
-
middle = `bg-primary ${sz.px} ${sz.text} font-medium text-primary-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-primary-hover enabled:active:bg-primary-active`;
|
|
147
|
-
break;
|
|
148
|
-
case 'neutral':
|
|
149
|
-
// 带文字的中性按钮的描边走「按钮描边」令牌(--soma-button-border-color,随九维边界维度求解:无边框 / 色块档降为弱描边,其余档 = 控件描边);
|
|
150
|
-
// 输入框 / 选择框 / 多行文本仍走 border-input(≥ 3:1,不豁免)
|
|
151
|
-
middle = `${BUTTON_EDGE_CLASS} bg-surface ${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} state-layer enabled:hover:border-button-edge-hover`;
|
|
152
|
-
// 悬停 / 按下 = 白底上叠统一状态层(state-layer 工具类,8% / 12%,底色不换,三态各自可辨);文字对比由 G82 的状态层配对判;按下与悬停同时命中时描边已是悬停描边(控件描边)
|
|
153
|
-
break;
|
|
154
|
-
case 'danger':
|
|
155
|
-
middle = `bg-danger ${sz.px} ${sz.text} font-medium text-danger-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-danger-hover enabled:active:bg-danger-active`;
|
|
156
|
-
break;
|
|
157
|
-
case 'ghost':
|
|
158
|
-
// 悬停 / 按下读统一状态层阶梯(真源 structure.stateLayer:墨色 4% / 8%),不再散写 bg-fg/8、/12
|
|
159
|
-
middle = `${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-hover enabled:active:bg-state-layer-press`;
|
|
160
|
-
break;
|
|
161
|
-
case 'tonal':
|
|
162
|
-
// 柔和底(primary-soft)上的悬停 / 按下:同一阶梯百分比叠主色(--soma-state-layer-tonal-*),不再用 /70 /50 透明度
|
|
163
|
-
middle = `bg-primary-soft ${sz.px} ${sz.text} font-medium text-primary-on-soft transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-tonal-hover enabled:active:bg-state-layer-tonal-press`;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
return [
|
|
167
|
-
`inline-flex ${sz.h} items-center justify-center ${sz.gap} whitespace-nowrap rounded-md`,
|
|
168
|
-
middle,
|
|
169
|
-
focusCls,
|
|
170
|
-
disabledCls,
|
|
171
|
-
activeDisabledCls,
|
|
172
|
-
invalidCls,
|
|
173
|
-
].filter(Boolean).join(' ');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (multiline) {
|
|
177
|
-
const sz = MULTILINE_SIZE_CLASS[size];
|
|
178
|
-
return [
|
|
179
|
-
'block w-full appearance-none autofill-clear resize-none rounded-md border border-input bg-surface',
|
|
180
|
-
sz.px,
|
|
181
|
-
sz.py,
|
|
182
|
-
sz.text,
|
|
183
|
-
'text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover',
|
|
184
|
-
focusCls,
|
|
185
|
-
disabledCls,
|
|
186
|
-
'read-only:bg-surface-sunken',
|
|
187
|
-
activeDisabledCls,
|
|
188
|
-
invalidCls,
|
|
189
|
-
].filter(Boolean).join(' ');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// 单行控件(Input / Select / Date 等)
|
|
193
|
-
const sz = SINGLE_LINE_SIZE_CLASS[size];
|
|
194
|
-
|
|
195
|
-
if (variant === 'filled') {
|
|
196
|
-
return [
|
|
197
|
-
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-transparent bg-surface-sunken ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-border focus-visible:bg-surface`,
|
|
198
|
-
focusCls,
|
|
199
|
-
disabledCls,
|
|
200
|
-
'read-only:bg-surface-sunken',
|
|
201
|
-
activeDisabledCls,
|
|
202
|
-
invalidCls,
|
|
203
|
-
].filter(Boolean).join(' ');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return [
|
|
207
|
-
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-input bg-surface ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover`,
|
|
208
|
-
focusCls,
|
|
209
|
-
disabledCls,
|
|
210
|
-
'read-only:bg-surface-sunken',
|
|
211
|
-
activeDisabledCls,
|
|
212
|
-
invalidCls,
|
|
213
|
-
].filter(Boolean).join(' ');
|
|
111
|
+
const common = { size: options.size, invalid: options.invalid, disabled: options.disabled };
|
|
112
|
+
if (options.multiline) return controlRecipe({ part: 'multiline', ...common });
|
|
113
|
+
if (variant === 'badge') return controlRecipe({ part: 'badge', ...common });
|
|
114
|
+
if (BUTTON_VARIANTS.has(variant)) return controlRecipe({ part: 'button', variant, tight: options.tight, pointer: options.pointer, link: options.link, ...common });
|
|
115
|
+
return controlRecipe({ part: 'field', variant, ...common });
|
|
214
116
|
}
|
|
215
117
|
|
|
216
|
-
export type KitTextActionTone = 'primary' | 'neutral' | 'danger';
|
|
118
|
+
export type KitTextActionTone = 'primary' | 'neutral' | 'danger' | 'quiet';
|
|
217
119
|
|
|
218
120
|
/**
|
|
219
121
|
* 行内操作的文字链接配方(表格 / 树表 / 虚拟表的操作列与「更多」触发器):
|
|
220
122
|
* 无底无描边,primary / neutral 同为主色文字(primary-on-soft 压表面,配对 primary-on-soft-surface),danger 为危险语义色文字(danger-on-soft-surface);
|
|
221
|
-
* 点击热区高度
|
|
123
|
+
* 点击热区高度 = 标准控件高(不低于原按钮),负外边距把它在行里的占高收回到一行文字(表格行高因此固定一档,不被操作列撑高);焦点环与禁用态走控件引擎。
|
|
124
|
+
* px-0:<button> 没有 preflight,浏览器默认左右内边距 6px 会让文字比表头「操作」缩进 6px,显式清零使首个操作与表头同一左缘。
|
|
222
125
|
*/
|
|
223
126
|
export function kitTextActionRecipe(tone: KitTextActionTone = 'primary'): string {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
127
|
+
return controlRecipe({ part: 'textAction', tone });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** 分段按钮(工具条里的视图 / 密度切换等):on 为选中态(主色浅底),off 为待命态;选中项不加字重差(两态字重同为 medium,宽度不跳)。 */
|
|
131
|
+
export function kitSegmentRecipe(on = false): string {
|
|
132
|
+
return controlRecipe({ part: 'segment', on });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 说明气泡触发钮(字段 help 的「i」小图标钮:列头 / 摘要标签旁;点读气泡走 kitTooltip,按需挂载,见 base/hint-tips.ts)。
|
|
137
|
+
* 小圆钮、弱化色、悬停转正文色;焦点环统一走 button 档。
|
|
138
|
+
*/
|
|
139
|
+
export function kitHelpTriggerRecipe(): string {
|
|
140
|
+
return controlRecipe({ part: 'help' });
|
|
232
141
|
}
|
|
233
142
|
|
|
234
143
|
const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
|
|
@@ -239,6 +148,9 @@ const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
|
|
|
239
148
|
'danger',
|
|
240
149
|
'ghost',
|
|
241
150
|
'tonal',
|
|
151
|
+
'dangerSoft',
|
|
152
|
+
'dangerOutline',
|
|
153
|
+
'quiet',
|
|
242
154
|
'badge',
|
|
243
155
|
]);
|
|
244
156
|
const ALL_SIZES: readonly KitControlSize[] = Object.freeze(['sm', 'md', 'lg']);
|
|
@@ -255,23 +167,31 @@ function collectControlRecipeCandidates(): string[] {
|
|
|
255
167
|
}
|
|
256
168
|
}
|
|
257
169
|
}
|
|
170
|
+
// 宿主选项(工具条 tight / 手形 / 链接宿主)只对按钮变体生效
|
|
171
|
+
if (BUTTON_VARIANTS.has(variant)) {
|
|
172
|
+
classes.push(kitControlRecipe({ variant, size, tight: true }));
|
|
173
|
+
classes.push(kitControlRecipe({ variant, size, pointer: true }));
|
|
174
|
+
classes.push(kitControlRecipe({ variant, size, pointer: true, link: true }));
|
|
175
|
+
classes.push(kitControlRecipe({ variant, size, tight: true, pointer: true }));
|
|
176
|
+
}
|
|
258
177
|
}
|
|
259
178
|
}
|
|
260
179
|
return classes;
|
|
261
180
|
}
|
|
262
181
|
|
|
263
|
-
/**
|
|
264
|
-
* 说明气泡触发钮(字段 help 的「i」小图标钮:列头 / 摘要标签旁;点读气泡走 kitTooltip,按需挂载,见 base/hint-tips.ts)。
|
|
265
|
-
* 小圆钮、弱化色、悬停转正文色;焦点环统一走 button 档。
|
|
266
|
-
*/
|
|
267
|
-
const HELP_TRIGGER_CLASS = 'hit-area ms-1 inline-flex h-5 w-5 shrink-0 p-0 items-center justify-center rounded-full align-middle text-fg-subtle transition-colors hover:text-fg';
|
|
268
|
-
export function kitHelpTriggerRecipe(): string {
|
|
269
|
-
return `${HELP_TRIGGER_CLASS} ${kitFocusRingRecipe('button')}`;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
182
|
export const KIT_CONTROL_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
273
183
|
collectControlRecipeCandidates(),
|
|
274
184
|
kitHelpTriggerRecipe(),
|
|
275
185
|
kitTextActionRecipe('primary'),
|
|
186
|
+
kitTextActionRecipe('neutral'),
|
|
276
187
|
kitTextActionRecipe('danger'),
|
|
188
|
+
kitTextActionRecipe('quiet'),
|
|
189
|
+
kitSegmentRecipe(false),
|
|
190
|
+
kitSegmentRecipe(true),
|
|
191
|
+
kitButtonEdgeRecipe(),
|
|
192
|
+
kitControlEdgeRecipe(),
|
|
193
|
+
kitControlEdgeRecipe({ wrapper: true }),
|
|
194
|
+
kitControlEdgeRecipe({ variant: 'filled' }),
|
|
195
|
+
kitControlEdgeRecipe({ variant: 'filled', wrapper: true }),
|
|
277
196
|
);
|
|
197
|
+
// hover: false 只是上面各串的子集,不另列候选
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// 描述列表(只读详情的键值对,knowledge/Kit主题规则与算法.md §10.13 KT-K-desc-1 / 2,二-16):
|
|
2
|
+
// 标签在左、固定宽标签列(sizeSpec.field.labelColPx),值在右;可多列(栏数仍由 solveKitSummary 定);窄于容器档时转为标签在上;
|
|
3
|
+
// 标签弱化墨(muted 角色:正文字号、400、次级墨)、不加冒号,值正文墨;缺失值「—」由 summaryEmpty.emptyDefault 给(Text 的占位弱化)。
|
|
4
|
+
import { kitTypographyRecipe } from './typography';
|
|
5
|
+
import { KIT_FIELD_LABEL_COL_CLASS } from './strip';
|
|
6
|
+
import { mergeClass } from '../shared/merge-class';
|
|
7
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
8
|
+
|
|
9
|
+
/** 键值格:一行两段(标签列定宽 + 值占余下),基线对齐;容器窄于 @sm 档时纵排(标签在上) */
|
|
10
|
+
export const KIT_DESC_CELL_CLASS = 'flex min-w-0 items-baseline gap-x-3 @max-sm:flex-col @max-sm:gap-y-1';
|
|
11
|
+
/** 键名:弱化墨、正文字号,定宽标签列(sizeSpec.field.labelColPx),窄档取自然宽 */
|
|
12
|
+
export const KIT_DESC_LABEL_CLASS = mergeClass(kitTypographyRecipe('muted'), `${KIT_FIELD_LABEL_COL_CLASS} shrink-0 @max-sm:w-auto`);
|
|
13
|
+
|
|
14
|
+
export const KIT_DESC_CLASS_CANDIDATES: readonly string[] = classCandidates(KIT_DESC_CELL_CLASS, KIT_DESC_LABEL_CLASS);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// 分隔线配方(knowledge/Kit主题规则与算法.md KT-B5 分隔线归父、KT-B6 贴边不重线;线宽 D-03 发丝档、线色 D-01 分隔类一个灰):
|
|
2
|
+
// 面内的分隔线只从这里取类串,构件不再各写 `border-b border-border-*`。
|
|
3
|
+
// · 条带线:头部条只画朝内容的底线、底栏只画朝内容的顶线、窗格只画朝邻窗格的一侧——贴着容器外缘的那一侧不画(容器的边就是它的边);
|
|
4
|
+
// · 子项间线由父出:列表 / 行 / 并排窗格之间的线由父容器的 divide-* 给(非末项),子项自己不画朝外的线。
|
|
5
|
+
// 宽 = --soma-border-width-hairline(类 border-<边>-hairline / divide-<轴>-hairline,主题头映射),色 = border-border-subtle(--soma-border-hairline)。
|
|
6
|
+
// 本文件不认识任何具体构件。
|
|
7
|
+
|
|
8
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
9
|
+
|
|
10
|
+
/** 条带线的朝向:bottom = 头部条底线,top = 底栏顶线,start / end = 窗格朝邻窗格的一侧 */
|
|
11
|
+
export type KitDividerSide = 'top' | 'bottom' | 'start' | 'end';
|
|
12
|
+
|
|
13
|
+
const SIDE: Readonly<Record<KitDividerSide, string>> = Object.freeze({ top: 't', bottom: 'b', start: 's', end: 'e' });
|
|
14
|
+
|
|
15
|
+
/** 分隔线色(D-01:分隔类只有一个灰;容器外缘另取 border-border-container,控件另取控件配方) */
|
|
16
|
+
export const KIT_DIVIDER_COLOR_CLASS = 'border-border-subtle';
|
|
17
|
+
|
|
18
|
+
/** 一条条带线(只画一侧) */
|
|
19
|
+
export function kitDividerRecipe(side: KitDividerSide): string {
|
|
20
|
+
return `border-${SIDE[side]}-hairline ${KIT_DIVIDER_COLOR_CLASS}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 带变体前缀的条带线(如网格表格的列间竖线 not-last:、窄档换向 @<档>:),两个类都带同一前缀 */
|
|
24
|
+
export function kitDividerVariantRecipe(side: KitDividerSide, variant: string): string {
|
|
25
|
+
return `${variant}:border-${SIDE[side]}-hairline ${variant}:${KIT_DIVIDER_COLOR_CLASS}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 边界类判据(剥离用):宽(border / border-<边> / -edge / -hairline / -emphasis / 数字宽)与线色(border-border-*) */
|
|
29
|
+
const BOUNDARY_TOKEN = /^(?:[a-z0-9@-]+:)*border(?:-[tbselrxy])?(?:-(?:hairline|edge|emphasis|[0-9]+))?$|^(?:[a-z0-9@-]+:)*border-border(?:-[a-z]+)?$/;
|
|
30
|
+
/**
|
|
31
|
+
* 去掉一段类串里的边界类(`bordered: false` 的集合条目 / 汇总行 / 外壳:外框与线都不画,由所在面板给边,KT-B6 / KT-B8 第 4 点);
|
|
32
|
+
* 只剥宽与线色,不动圆角、底色、内边距。
|
|
33
|
+
*/
|
|
34
|
+
export function kitStripBoundaryClasses(cls: string): string {
|
|
35
|
+
return cls.split(/\s+/).filter((t) => t !== '' && !BOUNDARY_TOKEN.test(t)).join(' ');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 头部条(窗口头 / 窗格头 / 面板头 / 页签条)的底线 */
|
|
39
|
+
export const KIT_DIVIDER_HEAD_CLASS = kitDividerRecipe('bottom');
|
|
40
|
+
/** 底栏(窗口底栏 / 分页条 / 面板底栏)的顶线 */
|
|
41
|
+
export const KIT_DIVIDER_FOOT_CLASS = kitDividerRecipe('top');
|
|
42
|
+
|
|
43
|
+
/** 父出的子项间分隔:y = 纵向排列的子项之间(列表行),x = 横向并排的子项之间(窗格中缝、统计块之间);只画非末项一侧 */
|
|
44
|
+
export function kitDivideRecipe(axis: 'x' | 'y'): string {
|
|
45
|
+
return `divide-${axis}-hairline divide-border-subtle`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const KIT_DIVIDER_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
49
|
+
...(['top', 'bottom', 'start', 'end'] as const).map(kitDividerRecipe),
|
|
50
|
+
kitDividerVariantRecipe('end', 'not-last'),
|
|
51
|
+
kitDivideRecipe('x'),
|
|
52
|
+
kitDivideRecipe('y'),
|
|
53
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// 强调等级配方(emphasis.ts):元素按「角色」由编译器自动定级,等级 → 外观的映射只有一张表(真源 kit-limits#emphasis,生成投影 KIT_EMPHASIS)。
|
|
2
|
+
//
|
|
3
|
+
// 视觉语言落地第 1 期(R01 / R10 / R12 / R18):问题不是缺变体(kit-control 早有 primary / tonal / ghost / quiet / dangerSoft),
|
|
4
|
+
// 而是各构件默认全部写死 `neutral`(灰描边线框),有限的对比手段被平均撒开。这里把「该元素在本屏有多重要」变成一个输入:
|
|
5
|
+
// 四档各有固定形体(以静态参照稿为目标;真源 KIT_EMPHASIS.levelForms,编译器按动作的语义角色 semanticRoles 定档,页面不写样式):
|
|
6
|
+
// · button.region 主:区域主动作(每个页面 / 页签 / 叠层至多一个,primaryPerPage)→ 实心品牌色
|
|
7
|
+
// · button.toolbar 次:取消 / 返回 / 关闭 / 刷新 / 重置 / 分页 / 工具条常规动作 → 白底 1px 描边的中性钮
|
|
8
|
+
// · button.brandAlt 次(品牌性备选):与主动作并列的重要备选 → 色调(品牌浅色填充);只由页面显式 tone: tonal 得到
|
|
9
|
+
// · button.text 三级:纯文字钮
|
|
10
|
+
// · button.quiet 安静:仅图标或灰色文字(「更多」触发器、行内次要动作)
|
|
11
|
+
// · button.danger 危险:平时中性灰字、悬停才变红;button.dangerConfirm 只给确认弹层的确认钮(实心红)
|
|
12
|
+
// · status 状态:圆点 + 文字,没有容器(与按钮、标签三种形体一眼可分)
|
|
13
|
+
// · rowAction.lead / rest / danger 行内动作:首个为主(品牌色)、其余退后(弱化色)、危险动作保持危险色并与前者隔开(间距另有 dangerSeparatorRem)
|
|
14
|
+
// · status 带语气的状态 → 状态徽标(浅色底 + on-soft 字 + 6px 圆点)
|
|
15
|
+
// · stat.value 统计数字保持中性墨色(有语义时才用语义色,且彩色文字只走 on-soft 角色)
|
|
16
|
+
// 取值(角色 → 变体 / 语气 / 形态)只在真源,这里不写任何一个变体名字面量以外的取值;各构件取变体一律经本文件,不再各写 'neutral'。
|
|
17
|
+
|
|
18
|
+
import { KIT_EMPHASIS } from 'soma-foundation/kit-limits';
|
|
19
|
+
import { kitControlRecipe, kitTextActionRecipe, type KitControlRecipeOptions, type KitControlVariant, type KitTextActionTone } from './control';
|
|
20
|
+
|
|
21
|
+
type EmphasisRoles = typeof KIT_EMPHASIS.roles;
|
|
22
|
+
/** 按钮角色(取变体的角色) */
|
|
23
|
+
export type KitEmphasisButtonRole = Extract<keyof EmphasisRoles, `button.${string}`>;
|
|
24
|
+
/** 行内动作的秩 */
|
|
25
|
+
export type KitRowActionRank = 'lead' | 'rest' | 'danger';
|
|
26
|
+
|
|
27
|
+
/** 每屏主焦点数的上限(一个页面 / 每个页签 / 每个叠层各至多这么多个 primary;编译期级联 compile/page-composition#capActionEmphasis(经 foundation 的 arrangeActionEmphasis)与渲染判定 CP01 读它) */
|
|
28
|
+
export const KIT_EMPHASIS_PRIMARY_PER_PAGE: number = KIT_EMPHASIS.primaryPerPage;
|
|
29
|
+
|
|
30
|
+
/** 按钮角色 → 控件变体(真源 roles.<角色>.variant) */
|
|
31
|
+
export function kitEmphasisVariant(role: KitEmphasisButtonRole): KitControlVariant {
|
|
32
|
+
return KIT_EMPHASIS.roles[role].variant as KitControlVariant;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 强调等级 → 控件变体(编译期级联降级后改写按钮 variant 用):取该等级下的 button.* 角色(危险角色不参与,危险有自己的语气);没有对应角色的等级取最弱的按钮角色 */
|
|
36
|
+
export function kitEmphasisVariantOfLevel(level: string): KitControlVariant {
|
|
37
|
+
const buttons = (Object.keys(KIT_EMPHASIS.roles) as Array<keyof EmphasisRoles>).filter((k): k is KitEmphasisButtonRole => k.startsWith('button.') && k !== 'button.danger' && k !== 'button.dangerConfirm');
|
|
38
|
+
const hit = buttons.find((k) => KIT_EMPHASIS.roles[k].level === level) ?? buttons[buttons.length - 1]!;
|
|
39
|
+
return kitEmphasisVariant(hit);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 按角色取按钮配方类串(控件引擎的按钮配方 + 角色对应的变体;宿主选项同 kitControlRecipe) */
|
|
43
|
+
export function kitEmphasisButtonRecipe(role: KitEmphasisButtonRole, options: Omit<KitControlRecipeOptions, 'variant'> = {}): string {
|
|
44
|
+
return kitControlRecipe({ ...options, variant: kitEmphasisVariant(role) });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 行内动作的秩 → 文字链接语气(真源 roles.rowAction.<秩>.tone) */
|
|
48
|
+
export function kitRowActionTone(rank: KitRowActionRank): KitTextActionTone {
|
|
49
|
+
return KIT_EMPHASIS.roles[`rowAction.${rank}`].tone as KitTextActionTone;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 行内动作配方类串(按秩取语气) */
|
|
53
|
+
export function kitRowActionRecipe(rank: KitRowActionRank): string {
|
|
54
|
+
return kitTextActionRecipe(kitRowActionTone(rank));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 状态的 Tag 属性:真源 roles.status.form = dot → 圆点 + 文字、没有容器(全应用统一;此前的浅底徽标已删除:与标签、色调按钮同形导致混淆,一屏几十个彩色徽标造成强调泛滥) */
|
|
58
|
+
export function kitStatusPillProps(): { readonly variant: 'dot' } {
|
|
59
|
+
return { variant: 'dot' };
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// 页面框通栏(frame.bleed)配方:画布不留页边距、页头自带水平 / 顶部页边距与下分隔线、页签栏水平页边距。
|
|
2
|
+
// 页边距读真源 density.pageMarginPx(--soma-page-margin,经 px-page / pt-page 工具类),标题到首块间距读 --soma-title-block-gap(pb-title-block);
|
|
3
|
+
// 本文件没有数字。内容容器去圆角 / 去外描边由主题结构规则(nine-dim-structure 的 frame-bleed 块,据 data-kit-frame-bleed 标记)负责。
|
|
4
|
+
|
|
5
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
6
|
+
import { mergeClass } from '../shared/merge-class';
|
|
7
|
+
|
|
8
|
+
const BLEED_CANVAS_CLASS = 'bg-surface-sunken min-h-screen text-sm text-fg';
|
|
9
|
+
const BLEED_HEADER_CLASS = 'px-page pt-page pb-title-block border-b-hairline border-border-subtle @container';
|
|
10
|
+
const BLEED_HEADER_STICKY_CLASS = 'sticky top-0 z-10 bg-surface-sunken';
|
|
11
|
+
const BLEED_TAB_BAR_CLASS = 'px-page';
|
|
12
|
+
|
|
13
|
+
/** 通栏画布:与普通画布只差页边距(无 p-page) */
|
|
14
|
+
export function kitFrameBleedCanvasRecipe(): string {
|
|
15
|
+
return BLEED_CANVAS_CLASS;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 通栏页头:自带 px-page / pt-page 与下发丝线;吸顶版再加吸顶与画布底色(盖住滚上来的内容) */
|
|
19
|
+
export function kitFrameBleedHeaderRecipe(sticky: boolean): string {
|
|
20
|
+
return sticky ? mergeClass(BLEED_HEADER_STICKY_CLASS, BLEED_HEADER_CLASS) : BLEED_HEADER_CLASS;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 通栏页签栏:水平页边距 */
|
|
24
|
+
export function kitFrameBleedTabBarRecipe(): string {
|
|
25
|
+
return BLEED_TAB_BAR_CLASS;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const KIT_FRAME_BLEED_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
29
|
+
BLEED_CANVAS_CLASS,
|
|
30
|
+
BLEED_HEADER_CLASS,
|
|
31
|
+
BLEED_HEADER_STICKY_CLASS,
|
|
32
|
+
BLEED_TAB_BAR_CLASS,
|
|
33
|
+
);
|
package/src/recipes/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// soma-kit 六份配方层统一出口(control / container / typography / table-row / overlay / state)
|
|
2
2
|
// 与 data-kit-part 标准部件协议常量。
|
|
3
3
|
|
|
4
|
-
import { classCandidates } from '../
|
|
4
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
5
5
|
import { KIT_STATUS_RECIPE_CLASS_CANDIDATES } from './status';
|
|
6
6
|
import {
|
|
7
7
|
KIT_STATE_RECIPE_CLASS_CANDIDATES,
|
|
@@ -26,7 +26,9 @@ import {
|
|
|
26
26
|
kitControlRecipe,
|
|
27
27
|
kitControlSizeRecipe,
|
|
28
28
|
kitButtonEdgeRecipe,
|
|
29
|
+
kitControlEdgeRecipe,
|
|
29
30
|
kitHelpTriggerRecipe,
|
|
31
|
+
kitSegmentRecipe,
|
|
30
32
|
kitTextActionRecipe,
|
|
31
33
|
type KitControlPart,
|
|
32
34
|
type KitControlRecipeOptions,
|
|
@@ -46,6 +48,9 @@ import {
|
|
|
46
48
|
kitContainerEmphasisRecipe,
|
|
47
49
|
kitContainerPartOf,
|
|
48
50
|
kitContainerRecipe,
|
|
51
|
+
KIT_PAIR_BALANCE_CLASS_CANDIDATES,
|
|
52
|
+
kitPairBalanceRecipe,
|
|
53
|
+
type KitPairBalanceClasses,
|
|
49
54
|
kitHighlightRecipe,
|
|
50
55
|
kitShellRecipe,
|
|
51
56
|
kitSlotSurfaceRecipe,
|
|
@@ -84,9 +89,12 @@ import {
|
|
|
84
89
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
85
90
|
kitTableCellRecipe,
|
|
86
91
|
kitTableNativeCellRecipe,
|
|
92
|
+
kitTableNativeTrack,
|
|
87
93
|
type KitTableAlign,
|
|
88
94
|
type KitTableCellRecipeOptions,
|
|
89
95
|
type KitTableNativeCellRecipeOptions,
|
|
96
|
+
type KitTableNativeTrack,
|
|
97
|
+
type KitTableNativeTrackColumn,
|
|
90
98
|
type KitTablePart,
|
|
91
99
|
} from './table-row';
|
|
92
100
|
import {
|
|
@@ -104,6 +112,7 @@ import {
|
|
|
104
112
|
kitToastActionRecipe,
|
|
105
113
|
kitToastCloseRecipe,
|
|
106
114
|
kitToastTitleRecipe,
|
|
115
|
+
KIT_TOAST_TOP_CLASS,
|
|
107
116
|
type KitOverlayKind,
|
|
108
117
|
type KitOverlayPart,
|
|
109
118
|
type KitOverlayRecipeOptions,
|
|
@@ -142,7 +151,9 @@ export {
|
|
|
142
151
|
kitControlRecipe,
|
|
143
152
|
kitControlSizeRecipe,
|
|
144
153
|
kitButtonEdgeRecipe,
|
|
154
|
+
kitControlEdgeRecipe,
|
|
145
155
|
kitHelpTriggerRecipe,
|
|
156
|
+
kitSegmentRecipe,
|
|
146
157
|
kitTextActionRecipe,
|
|
147
158
|
kitControlPartOf,
|
|
148
159
|
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
@@ -152,6 +163,8 @@ export {
|
|
|
152
163
|
KIT_PART_SECTION,
|
|
153
164
|
KIT_PART_WELL,
|
|
154
165
|
kitContainerRecipe,
|
|
166
|
+
kitPairBalanceRecipe,
|
|
167
|
+
KIT_PAIR_BALANCE_CLASS_CANDIDATES,
|
|
155
168
|
kitContainerPartOf,
|
|
156
169
|
kitSlotSurfaceRecipe,
|
|
157
170
|
kitContainerEmphasisRecipe,
|
|
@@ -180,10 +193,13 @@ export {
|
|
|
180
193
|
KIT_PART_TABLE_CELL,
|
|
181
194
|
kitTableCellRecipe,
|
|
182
195
|
kitTableNativeCellRecipe,
|
|
196
|
+
kitTableNativeTrack,
|
|
183
197
|
KIT_TABLE_NATIVE_CLASS,
|
|
184
198
|
KIT_TABLE_NATIVE_CLASS_CANDIDATES,
|
|
185
199
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
186
200
|
type KitTableNativeCellRecipeOptions,
|
|
201
|
+
type KitTableNativeTrack,
|
|
202
|
+
type KitTableNativeTrackColumn,
|
|
187
203
|
// title-row
|
|
188
204
|
KIT_PANEL_TITLE_CLASS,
|
|
189
205
|
KIT_PANEL_TITLE_CLASS_CANDIDATES,
|
|
@@ -199,6 +215,7 @@ export {
|
|
|
199
215
|
kitToastActionRecipe,
|
|
200
216
|
kitToastCloseRecipe,
|
|
201
217
|
kitToastTitleRecipe,
|
|
218
|
+
KIT_TOAST_TOP_CLASS,
|
|
202
219
|
kitOverlayHeaderRecipe,
|
|
203
220
|
kitOverlayBodyRecipe,
|
|
204
221
|
kitOverlayFooterRecipe,
|
|
@@ -208,6 +225,7 @@ export {
|
|
|
208
225
|
};
|
|
209
226
|
|
|
210
227
|
export type {
|
|
228
|
+
KitPairBalanceClasses,
|
|
211
229
|
KitFocusRingKind,
|
|
212
230
|
KitDisabledKind,
|
|
213
231
|
KitSelectedTone,
|
|
@@ -299,14 +317,29 @@ export const KIT_PARTS = Object.freeze({
|
|
|
299
317
|
export type KitPartValue = (typeof KIT_PARTS)[keyof typeof KIT_PARTS];
|
|
300
318
|
|
|
301
319
|
export * from './status';
|
|
320
|
+
export { kitEmphasisButtonRecipe, kitRowActionRecipe, kitStatusPillProps } from './emphasis';
|
|
321
|
+
export * from './table-native-edit';
|
|
322
|
+
export * from './tabs';
|
|
323
|
+
import { KIT_TAB_RECIPE_CLASS_CANDIDATES } from './tabs';
|
|
324
|
+
import { KIT_TABLE_NATIVE_EDIT_SPAN_CLASS_CANDIDATES } from './table-native-edit';
|
|
325
|
+
import { KIT_FRAME_BLEED_CLASS_CANDIDATES } from './frame-bleed';
|
|
326
|
+
import { KIT_DIVIDER_CLASS_CANDIDATES } from './divider';
|
|
327
|
+
import { KIT_COMPACT_GROUP_CLASS_CANDIDATES } from './compact-group';
|
|
328
|
+
export * from './divider';
|
|
329
|
+
export * from './compact-group';
|
|
302
330
|
|
|
303
331
|
export const KIT_RECIPES_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
332
|
+
KIT_DIVIDER_CLASS_CANDIDATES,
|
|
333
|
+
KIT_COMPACT_GROUP_CLASS_CANDIDATES,
|
|
304
334
|
KIT_STATUS_RECIPE_CLASS_CANDIDATES,
|
|
305
335
|
KIT_STATE_RECIPE_CLASS_CANDIDATES,
|
|
306
336
|
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
307
337
|
KIT_CONTAINER_RECIPE_CLASS_CANDIDATES,
|
|
308
338
|
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
309
339
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
340
|
+
KIT_TABLE_NATIVE_EDIT_SPAN_CLASS_CANDIDATES,
|
|
341
|
+
KIT_FRAME_BLEED_CLASS_CANDIDATES,
|
|
310
342
|
KIT_PANEL_TITLE_CLASS_CANDIDATES,
|
|
311
343
|
KIT_OVERLAY_RECIPE_CLASS_CANDIDATES,
|
|
344
|
+
KIT_TAB_RECIPE_CLASS_CANDIDATES,
|
|
312
345
|
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// 应用级继承外壳(header / sidebar / footer)与产品旋钮(emphasis / surface)的类串配方。
|
|
2
|
+
// 组件 / 页面框不手写类串:frames/inherited-shell 只按角色取这里的出口(G101)。
|
|
3
|
+
|
|
4
|
+
// in-data-kit-embed:hidden:嵌入工作台 iframe(文档根带 data-kit-embed,见 shared/theme-runtime-shared)时不画继承的应用顶栏(不出双顶栏);
|
|
5
|
+
// 规则归页面框配方,不写在主题 CSS 里(主题不认识外壳,接入核对 C6)
|
|
6
|
+
export const KIT_SHELL_HEADER_CLASS = 'border-b-hairline border-border-subtle bg-surface px-6 py-3 flex items-center justify-between gap-4 in-data-kit-embed:hidden';
|
|
7
|
+
export const KIT_SHELL_HEADER_LEFT_CLASS = 'flex items-center gap-6';
|
|
8
|
+
export const KIT_SHELL_BRAND_LINK_CLASS = 'font-semibold text-fg hover:text-primary-on-soft transition-colors';
|
|
9
|
+
export const KIT_SHELL_BRAND_TEXT_CLASS = 'font-semibold text-fg';
|
|
10
|
+
export const KIT_SHELL_NAV_CLASS = 'flex items-center gap-4';
|
|
11
|
+
export const KIT_SHELL_NAV_LINK_CLASS = 'text-sm text-fg-muted hover:text-fg transition-colors';
|
|
12
|
+
export const KIT_SHELL_ACTIONS_CLASS = 'flex items-center gap-3';
|
|
13
|
+
export const KIT_SHELL_ACTION_LINK_CLASS = 'text-sm font-medium text-fg hover:text-primary-on-soft transition-colors';
|
|
14
|
+
|
|
15
|
+
export const KIT_SHELL_SIDEBAR_TITLE_CLASS = 'mb-4 text-xs font-semibold uppercase tracking-wider text-fg-muted';
|
|
16
|
+
export const KIT_SHELL_SIDEBAR_MENU_CLASS = 'flex flex-col gap-1';
|
|
17
|
+
export const KIT_SHELL_SIDEBAR_ITEM_CLASS = 'rounded px-2 py-1.5 text-sm text-fg hover:bg-surface transition-colors';
|
|
18
|
+
export const KIT_SHELL_BODY_CLASS = 'flex min-h-screen';
|
|
19
|
+
export const KIT_SHELL_MAIN_CLASS = 'flex-1 min-w-0';
|
|
20
|
+
/** 侧栏外壳类(宽度类由调用方按档拼在前面) */
|
|
21
|
+
export const KIT_SHELL_SIDEBAR_CLASS = 'shrink-0 border-e-hairline border-border-subtle bg-surface-sunken p-4';
|
|
22
|
+
|
|
23
|
+
export const KIT_SHELL_FOOTER_CLASS = 'border-t-hairline border-border-subtle bg-surface-sunken px-6 py-3 text-xs text-fg-muted flex items-center justify-between gap-4';
|
|
24
|
+
export const KIT_SHELL_FOOTER_LINKS_CLASS = 'flex items-center gap-4';
|
|
25
|
+
export const KIT_SHELL_FOOTER_LINK_CLASS = 'hover:text-fg transition-colors';
|
|
26
|
+
|
|
27
|
+
export const KIT_PRODUCT_EMPHASIS_CLASSES: Readonly<Record<string, string>> = {
|
|
28
|
+
primary: 'rounded-lg border border-primary bg-surface-raised p-4 shadow-sm',
|
|
29
|
+
// 容器外缘只读容器令牌(KT-B2:边界档、嵌套去框都管得到):圆角 rounded-card、宽 border-edge、色 border-border-container
|
|
30
|
+
normal: 'rounded-card border-edge border-border-container bg-surface p-4',
|
|
31
|
+
subtle: 'rounded-card border-edge border-border-container bg-surface-sunken p-3 text-fg-muted',
|
|
32
|
+
};
|
|
33
|
+
export const KIT_PRODUCT_SURFACE_CLASSES: Readonly<Record<string, string>> = {
|
|
34
|
+
card: 'rounded-card border-edge border-border-container bg-surface p-4 shadow-xs',
|
|
35
|
+
flush: 'p-0 border-0 bg-surface',
|
|
36
|
+
plain: 'p-0 border-0 bg-transparent shadow-none',
|
|
37
|
+
};
|