soma-kit 0.1.14 → 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 +4 -2
- package/spec/generated/kit-page.schema.json +72 -2
- package/spec/kit-grammar.json +163 -57
- package/spec/kit-grammar.schema.json +0 -24
- package/src/app/app-config.ts +1 -1
- 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 +7 -7
- package/src/app/kit-view-context.ts +11 -2
- 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 +30 -15
- 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/fab.ts +11 -6
- package/src/base/gap-value.ts +1 -1
- package/src/base/hint-tips.ts +1 -1
- package/src/base/index.ts +15 -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 +63 -27
- 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 +2 -2
- 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 +35 -36
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +43 -7
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +53 -59
- package/src/base/text.ts +37 -13
- 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 +21 -13
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +2 -2
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +2 -2
- package/src/biz/category-crud/compile.ts +17 -4
- package/src/biz/category-crud/shell.ts +7 -5
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +7 -6
- package/src/biz/compose.ts +3 -3
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +6 -4
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +5 -4
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +162 -19
- package/src/biz/master-sub/detail-head.ts +7 -6
- package/src/biz/master-sub/index.ts +3 -3
- package/src/biz/master-sub/shell.ts +90 -53
- package/src/biz/multi-board/compile.ts +3 -3
- package/src/biz/multi-board/index.ts +24 -9
- package/src/biz/multi-board/prose-fold.ts +2 -2
- package/src/biz/multi-board/shell.ts +17 -13
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +9 -2
- package/src/biz/page-templates/domain-templates.ts +6 -2
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- 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 +4 -4
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +4 -4
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +8 -5
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +4 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +48 -18
- package/src/biz/shared/overlay-shell.ts +63 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +8 -4
- package/src/biz/standard-crud/compile.ts +11 -4
- package/src/biz/standard-crud/shell.ts +26 -9
- package/src/biz/standard-crud/summary.ts +3 -1
- 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 +6 -4
- package/src/biz/types.ts +11 -4
- 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/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +29 -234
- package/src/compile/component-candidates.ts +2 -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 +43 -13
- package/src/compile/page-composition.ts +33 -31
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +70 -32
- package/src/compile/types.ts +2 -2
- package/src/data/amount-breakdown.ts +4 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +9 -4
- package/src/data/assignment-picker.ts +28 -18
- package/src/data/async-result-panel.ts +6 -2
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +4 -3
- package/src/data/carousel.ts +11 -5
- package/src/data/chart.ts +153 -23
- package/src/data/checklist.ts +5 -4
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +7 -2
- package/src/data/confirm-dialog.ts +56 -13
- 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 +12 -6
- package/src/data/flow-editor.ts +105 -29
- package/src/data/footer.ts +6 -2
- package/src/data/gantt.ts +11 -8
- package/src/data/hero.ts +6 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +12 -5
- package/src/data/item-list.ts +6 -5
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +11 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +23 -14
- 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 +15 -9
- package/src/data/mockup.ts +9 -5
- package/src/data/modal-dialog.ts +39 -88
- package/src/data/navbar.ts +11 -7
- package/src/data/notice-list.ts +1 -1
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +129 -48
- package/src/data/pager.ts +12 -8
- package/src/data/panel-head.ts +1 -1
- package/src/data/permission-matrix.ts +15 -8
- package/src/data/permission-tree.ts +24 -11
- package/src/data/pricing-table.ts +8 -3
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +13 -9
- 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 +0 -12
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +10 -5
- package/src/data/rule-builder.ts +14 -8
- package/src/data/shape-util.ts +14 -3
- package/src/data/stat-group.ts +63 -22
- package/src/data/static-lazy.ts +3 -0
- package/src/data/static-registry.ts +8 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +9 -3
- package/src/data/system-switcher.ts +15 -6
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +6 -3
- package/src/data/transfer.ts +19 -10
- package/src/data/tree-table.ts +77 -12
- package/src/data/tree.ts +5 -2
- package/src/data/virtual-rows.ts +17 -7
- package/src/data/wrap.ts +2 -2
- package/src/frames/index.ts +3 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +59 -36
- package/src/frames/page-bar.ts +4 -2
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +18 -14
- 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 +12 -6
- package/src/frames/types.ts +3 -2
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +2 -1
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/view.ts +125 -76
- package/src/generated/kit-grammar-runtime.ts +61 -39
- package/src/i18n/kit-text.ts +114 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +31 -1
- package/src/object-renderer/action-more.ts +28 -12
- package/src/object-renderer/arrange.ts +37 -7
- package/src/object-renderer/collection-parts.ts +38 -7
- package/src/object-renderer/collection-table.ts +68 -23
- package/src/object-renderer/collection.ts +63 -30
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +8 -0
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +3 -0
- package/src/object-renderer/emit-static.ts +140 -37
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/layout-facts.ts +37 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/render-object.ts +1 -1
- package/src/object-renderer/table-actions.ts +70 -23
- package/src/object-renderer/table-tools.ts +12 -5
- package/src/object-renderer/types.ts +9 -15
- 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 +25 -15
- package/src/recipes/control.ts +21 -3
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +12 -8
- package/src/recipes/frame-bleed.ts +3 -3
- package/src/recipes/index.ts +11 -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 +112 -26
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +1 -1
- package/src/recipes/stat-state.ts +1 -1
- package/src/recipes/state.ts +10 -8
- package/src/recipes/status.ts +13 -12
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +1 -1
- package/src/recipes/table-native-edit.ts +4 -4
- package/src/recipes/table-row.ts +11 -8
- package/src/recipes/tabs.ts +108 -31
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +4 -2
- package/src/recipes/typography.ts +2 -2
- 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 +38 -14
- package/src/theme/kit-theme.tpl +38 -14
- package/src/theme/nine-dim-structure.ts +66 -41
- package/src/theme/surface-layers.ts +11 -3
- package/src/theme/theme-tokens.ts +5 -1
- 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
|
@@ -26,12 +26,15 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
26
26
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
27
27
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
28
28
|
import { bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
29
|
-
import { kitIcon } from '../
|
|
29
|
+
import { kitIcon } from '../shared/icons';
|
|
30
30
|
import { markCheckBox } from '../base/check-core';
|
|
31
31
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
32
32
|
import { kitControlRecipe, setKitFace } from '../recipes';
|
|
33
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
34
|
+
import { kitDivideRecipe, kitDividerRecipe } from '../recipes/divider';
|
|
35
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
33
36
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
34
|
-
import { mergeClass } from '../
|
|
37
|
+
import { mergeClass } from '../shared/merge-class';
|
|
35
38
|
import {
|
|
36
39
|
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
37
40
|
} from '../recipes/overlay';
|
|
@@ -44,34 +47,41 @@ import { kitTypographyRecipe } from '../recipes/typography';
|
|
|
44
47
|
|
|
45
48
|
// ── 类串表:全部完整写死,不拼接片段 ──
|
|
46
49
|
|
|
47
|
-
const ROOT_CLASS = `@container flex h-full flex-col gap-
|
|
50
|
+
const ROOT_CLASS = `@container flex h-full flex-col gap-3 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
|
|
48
51
|
const HELP_CLASS = 'text-sm text-fg-muted';
|
|
49
52
|
const SUBJECT_CLASS = 'flex flex-wrap items-center gap-4';
|
|
50
53
|
const SUBJECT_ITEM_CLASS = 'flex items-center gap-2';
|
|
51
54
|
const CAPTION_CLASS = 'text-sm text-fg-muted';
|
|
52
55
|
const STRONG_CLASS = 'text-sm font-semibold text-fg';
|
|
53
56
|
const ALERT_CLASS = 'rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
54
|
-
const GRID_CLASS = 'grid grid-cols-12 gap-
|
|
57
|
+
const GRID_CLASS = 'grid grid-cols-12 gap-3';
|
|
55
58
|
const MAIN_FULL_CLASS = 'col-span-12';
|
|
56
|
-
|
|
57
|
-
const
|
|
59
|
+
// 间距只取 4 的倍数阶梯(尺寸规格 §1;接入核对 C2:10 / 6px 收回 8 / 12)
|
|
60
|
+
const MAIN_INNER_CLASS = 'flex flex-col gap-2';
|
|
61
|
+
const SIDE_TOP_LINE = kitDividerRecipe('top');
|
|
62
|
+
const ROWS_DIVIDE = kitDivideRecipe('y');
|
|
63
|
+
const BOX_EDGE = kitControlEdgeRecipe({ wrapper: true });
|
|
64
|
+
const SIDE_INNER_CLASS = `flex flex-col gap-2 ${SIDE_TOP_LINE} pt-3`;
|
|
58
65
|
const HEAD_CLASS = 'flex items-center justify-between gap-3';
|
|
59
66
|
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
60
67
|
const SUMMARY_CLASS = 'text-sm text-fg-muted';
|
|
61
68
|
const CHANGES_CLASS = 'text-sm text-fg-muted';
|
|
62
69
|
const TOOLS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
// 搜索框 = 标准输入(控件配方,KT-B1 / §4 C6),工具钮与它同高(控件档)
|
|
71
|
+
const SEARCH_CLASS = mergeClass(kitControlRecipe(), 'min-w-40 flex-1');
|
|
72
|
+
const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
73
|
+
// 列表框外缘 = 壳配方(容器边,KT-B2);条目之间的线由父出(kitDivideRecipe,KT-B5);
|
|
74
|
+
// 分组:灰底组头与条目之间、组与组之间已有面差,不再画线(D-30)
|
|
75
|
+
const LIST_CLASS = mergeClass('flex max-h-36 flex-col overflow-y-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', `${kitShellRecipe({ tone: 'base', shadow: false })} ${kitDivideRecipe('y')}`);
|
|
76
|
+
const GROUP_CLASS = `flex flex-col border-b-0 ${ROWS_DIVIDE}`;
|
|
77
|
+
const GROUP_HEAD_CLASS = 'flex items-center justify-between gap-2 rounded-md bg-surface-sunken px-3 py-1.5 text-xs font-medium text-fg-muted border-b-0';
|
|
68
78
|
const GROUP_BTN_CLASS = kitEmphasisButtonRecipe('button.quiet', { size: 'sm' });
|
|
69
|
-
const ITEM_CLASS = 'flex cursor-pointer items-center gap-3
|
|
70
|
-
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3
|
|
71
|
-
const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3
|
|
72
|
-
const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3
|
|
79
|
+
const ITEM_CLASS = 'flex cursor-pointer items-center gap-3 bg-surface px-3 py-2 text-fg transition-colors state-layer';
|
|
80
|
+
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-3 bg-surface px-3 py-2 text-fg-subtle';
|
|
81
|
+
const ITEM_ADDED_CLASS = 'flex cursor-pointer items-center gap-3 bg-success-soft px-3 py-2 text-success-on-soft transition-colors';
|
|
82
|
+
const ITEM_REMOVED_CLASS = 'flex cursor-pointer items-center gap-3 bg-danger-soft px-3 py-2 text-danger-on-soft transition-colors';
|
|
73
83
|
const CURSOR_CLASS = 'ring-2 ring-inset ring-ring';
|
|
74
|
-
const BOX_OFF_CLASS =
|
|
84
|
+
const BOX_OFF_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-md ${BOX_EDGE} bg-surface text-xs`;
|
|
75
85
|
const BOX_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-fg';
|
|
76
86
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
77
87
|
const LABEL_CLASS = 'truncate text-sm';
|
|
@@ -83,7 +93,7 @@ const CHIP_REMOVED_CLASS = 'bg-danger-soft text-danger-on-soft';
|
|
|
83
93
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
84
94
|
const FIELD_LABEL_CLASS = 'flex items-center gap-1 text-sm text-fg';
|
|
85
95
|
const STAR_CLASS = 'text-danger-on-soft';
|
|
86
|
-
const AREA_CLASS =
|
|
96
|
+
const AREA_CLASS = mergeClass(kitControlRecipe({ multiline: true }), 'resize-none');
|
|
87
97
|
const FIELD_ERROR_CLASS = 'text-xs text-danger-on-soft';
|
|
88
98
|
// mt-auto:根随容器拉高时按钮区贴在面板底部,不悬在中间
|
|
89
99
|
const FOOT_CLASS = 'mt-auto flex items-center justify-end gap-2 pt-1';
|
|
@@ -600,7 +610,7 @@ export function createAssignmentPicker(): SomaComponentDefinition {
|
|
|
600
610
|
fieldLabel = mk('label', FIELD_LABEL_CLASS);
|
|
601
611
|
area = mk('textarea', AREA_CLASS);
|
|
602
612
|
setKitFace(area, 'field');
|
|
603
|
-
area.rows =
|
|
613
|
+
area.rows = 2;
|
|
604
614
|
const areaId = `${uid}-reason`;
|
|
605
615
|
area.id = areaId;
|
|
606
616
|
fieldLabel.htmlFor = areaId;
|
|
@@ -23,6 +23,10 @@ import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
|
23
23
|
import { KIT_MS_ASIDE_IDLE_ATTR, KIT_MS_ROOT_ATTR } from '../recipes/container';
|
|
24
24
|
import { kitText } from '../i18n/kit-text';
|
|
25
25
|
import { setKitFace } from '../recipes';
|
|
26
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
27
|
+
|
|
28
|
+
/** 多行输入的边 = 控件轮廓出口(KT-B1 / §4 C6) */
|
|
29
|
+
const AREA_EDGE = kitControlEdgeRecipe();
|
|
26
30
|
import { KIT_BUSY_PROP_DEFS, cancelKitAction, kitBusyOf } from '../base/action-busy';
|
|
27
31
|
import {
|
|
28
32
|
actionButton, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
|
|
@@ -35,7 +39,7 @@ const TITLE_CLASS = 'text-sm font-semibold text-fg';
|
|
|
35
39
|
const SUBTITLE_CLASS = 'text-xs text-fg-subtle';
|
|
36
40
|
const LABEL_WRAP = 'flex flex-col gap-1';
|
|
37
41
|
const LABEL_CLASS = 'text-xs font-medium text-fg-muted';
|
|
38
|
-
const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md
|
|
42
|
+
const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-md ' + AREA_EDGE + ' bg-surface px-3 py-2 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
39
43
|
const BUTTONS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
40
44
|
const MESSAGE_CLASS = 'text-xs text-fg-subtle';
|
|
41
45
|
const MESSAGE_FAILED = 'text-xs text-danger-on-soft';
|
|
@@ -198,7 +202,7 @@ export function createAsyncResultPanel(): SomaComponentDefinition {
|
|
|
198
202
|
},
|
|
199
203
|
},
|
|
200
204
|
services: ['data'],
|
|
201
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
205
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
202
206
|
controllerFactory: createKitController(() => ({
|
|
203
207
|
busyAware: true,
|
|
204
208
|
attach(root, api) {
|
package/src/data/breadcrumbs.ts
CHANGED
|
@@ -11,16 +11,20 @@ import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
|
11
11
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
12
12
|
import { safeHref } from '../base/link';
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
|
-
import { kitIcon, kitIconHtml } from '../
|
|
14
|
+
import { kitIcon, kitIconHtml } from '../shared/icons';
|
|
15
15
|
import { classSet, FOCUS, h, isRec, recList, textOf, type Child, type Rec } from './menu-dom';
|
|
16
16
|
|
|
17
17
|
const ROOT_CLASS = 'flex min-w-0 items-center text-sm text-fg-muted';
|
|
18
18
|
const ROOT_SCROLL_CLASS = 'flex min-w-0 items-center overflow-x-auto text-sm text-fg-muted';
|
|
19
|
-
|
|
19
|
+
// 溢出策略 = 单行、不折行(面包屑在 40 高的条带里,折行会被条带裁掉上下,@320 外壳顶栏);放不下时上级先收缩成「…」、当前项保整(AR45):
|
|
20
|
+
// 上级项最窄收到一个省略号宽(min-w-5 + truncate,项本身不设 min-w-0,最小宽 = 分隔符 + 省略号),当前项不收缩(shrink-0,只在独占整行仍放不下时才省略)
|
|
21
|
+
const LIST_CLASS = 'flex min-w-0 flex-nowrap items-center gap-1';
|
|
20
22
|
const LIST_SCROLL_CLASS = 'flex flex-nowrap items-center gap-1 whitespace-nowrap';
|
|
21
|
-
const ITEM_CLASS = 'flex
|
|
23
|
+
const ITEM_CLASS = 'flex items-center gap-1';
|
|
24
|
+
const CURRENT_ITEM_CLASS = 'flex min-w-0 max-w-full shrink-0 items-center gap-1';
|
|
22
25
|
// border-0 bg-transparent p-0:按钮型面包屑项没有 preflight 时带浏览器默认 6px 横向内边距,会让分隔符两侧间距不等、首项比当前项缩进多 6px
|
|
23
|
-
const LINK_CLASS = `min-w-
|
|
26
|
+
const LINK_CLASS = `min-w-5 cursor-pointer truncate rounded-sm border-0 bg-transparent px-0 py-1 -my-1 text-start text-fg-muted transition-colors hover:text-fg hover:underline ${FOCUS}`;
|
|
27
|
+
const ANCESTOR_TEXT_CLASS = 'min-w-5 truncate';
|
|
24
28
|
const CURRENT_CLASS = 'min-w-0 truncate font-medium text-fg';
|
|
25
29
|
const SEP_CLASS = 'shrink-0 text-fg-subtle';
|
|
26
30
|
const ELLIPSIS_CLASS = `inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-sm px-1 text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ${FOCUS}`;
|
|
@@ -28,7 +32,7 @@ const ELLIPSIS_STATIC_CLASS = 'shrink-0 px-1 text-fg-muted';
|
|
|
28
32
|
|
|
29
33
|
/** 本组件自带的全部类(供编译器并入候选类,页面框静态页头同用) */
|
|
30
34
|
export const KIT_BREADCRUMBS_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
31
|
-
ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, LINK_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
|
|
35
|
+
ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, CURRENT_ITEM_CLASS, LINK_CLASS, ANCESTOR_TEXT_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
|
|
32
36
|
);
|
|
33
37
|
|
|
34
38
|
export const KIT_BREADCRUMBS_DEFAULT_MAX: number = KIT_STATIC_COMPONENT_LIMITS.navigation.breadcrumbs.defaultMaxItems;
|
|
@@ -92,11 +96,11 @@ export function breadcrumbsHtml(items: readonly { label: string; href?: string }
|
|
|
92
96
|
return `<li class="${ITEM_CLASS}">${lead}<span title="${esc(title)}" class="${ELLIPSIS_STATIC_CLASS}">…</span></li>`;
|
|
93
97
|
}
|
|
94
98
|
const { crumb, current } = p;
|
|
95
|
-
if (current) return `<li class="${
|
|
99
|
+
if (current) return `<li class="${CURRENT_ITEM_CLASS}">${lead}<span aria-current="page" class="${CURRENT_CLASS}">${esc(crumb.label)}</span></li>`;
|
|
96
100
|
const href = crumb.href !== '' ? safeHref(crumb.href) : '';
|
|
97
101
|
const inner = href !== ''
|
|
98
102
|
? `<a href="${esc(href)}" class="${LINK_CLASS}">${esc(crumb.label)}</a>`
|
|
99
|
-
: `<span class="
|
|
103
|
+
: `<span class="${ANCESTOR_TEXT_CLASS}">${esc(crumb.label)}</span>`;
|
|
100
104
|
return `<li class="${ITEM_CLASS}">${lead}${inner}</li>`;
|
|
101
105
|
});
|
|
102
106
|
const id = opts.anchorId !== undefined ? ` data-soma-id="${esc(opts.anchorId)}"` : '';
|
|
@@ -126,7 +130,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
|
|
|
126
130
|
root.setAttribute('aria-label', str(props.label, kitText('soma.kit.nav_breadcrumb', undefined, root)));
|
|
127
131
|
const list = h('ol', scroll ? LIST_SCROLL_CLASS : LIST_CLASS);
|
|
128
132
|
breadcrumbParts(crumbs, max, expanded).forEach((p, i) => {
|
|
129
|
-
const li = h('li', ITEM_CLASS);
|
|
133
|
+
const li = h('li', p.kind !== 'ellipsis' && p.current ? CURRENT_ITEM_CLASS : ITEM_CLASS);
|
|
130
134
|
if (i > 0) li.append(h('span', SEP_CLASS, { 'aria-hidden': 'true' }, str(props.marker) === 'chevron' ? kitIcon('chevron-right', 'xs', 'rtl:-scale-x-100') : sep));
|
|
131
135
|
if (p.kind === 'ellipsis') {
|
|
132
136
|
const title = p.hidden.map((c) => c.label).join(' / ');
|
|
@@ -142,7 +146,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
|
|
|
142
146
|
const href = crumb.href !== '' ? safeHref(crumb.href) : '';
|
|
143
147
|
if (isRec(crumb.raw) && crumb.raw.inert === true) {
|
|
144
148
|
// inert:只是层级文字(如菜单分组名),不可点
|
|
145
|
-
li.append(h('span',
|
|
149
|
+
li.append(h('span', ANCESTOR_TEXT_CLASS, {}, ...text));
|
|
146
150
|
} else {
|
|
147
151
|
const el = href !== ''
|
|
148
152
|
? h('a', LINK_CLASS, { href }, ...text)
|
package/src/data/calendar.ts
CHANGED
|
@@ -17,7 +17,8 @@ import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, type Month
|
|
|
17
17
|
import { markKitEdge } from '../recipes/surface-edge';
|
|
18
18
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
19
19
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
20
|
-
import { mergeClass } from '../
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
21
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
21
22
|
import {
|
|
22
23
|
addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
|
|
23
24
|
} from './d9-util';
|
|
@@ -32,7 +33,7 @@ const TITLE_CLASS = mergeClass('min-w-24', kitTypographyRecipe('sectionTitle'));
|
|
|
32
33
|
const SPACER_CLASS = 'flex-1';
|
|
33
34
|
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
34
35
|
const BTN_ON_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-primary bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
35
|
-
const GRID_CLASS = 'flex flex-col overflow-hidden
|
|
36
|
+
const GRID_CLASS = mergeClass('flex flex-col overflow-hidden', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
36
37
|
const ROW_CLASS = 'grid grid-cols-7 border-border-subtle';
|
|
37
38
|
const ROW_BORDER = 'border-t';
|
|
38
39
|
const HEADCELL_CLASS = 'px-2 py-1.5 text-center text-xs font-medium text-fg-muted';
|
|
@@ -121,7 +122,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
121
122
|
},
|
|
122
123
|
keyboard: { layout: 'grid', date_grid: true, wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
123
124
|
},
|
|
124
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
125
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
125
126
|
controllerFactory: createKitController((api) => {
|
|
126
127
|
const P = (): Record<string, unknown> => api.props();
|
|
127
128
|
let root: HTMLElement | null = null;
|
package/src/data/carousel.ts
CHANGED
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
16
|
import { KIT_CAROUSEL_LIMITS, KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
17
17
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
18
|
-
import { kitIcon } from '../
|
|
18
|
+
import { kitIcon } from '../shared/icons';
|
|
19
19
|
import { kitText } from '../i18n/kit-text';
|
|
20
20
|
import { setKitFace } from '../recipes';
|
|
21
|
+
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
22
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
21
23
|
import { kitKey } from '../i18n/kit-text';
|
|
22
24
|
import { classTokens, emptyNode, mk, textOf, type Rec } from './shape-util';
|
|
23
25
|
import { clampInt, keyOfRow, listOf, prefersReducedMotion, urlOf } from './display-util';
|
|
@@ -29,7 +31,11 @@ export const KIT_CAROUSEL_EDGES = ['top', 'bottom', 'start', 'end'] as const;
|
|
|
29
31
|
export type KitCarouselEdge = (typeof KIT_CAROUSEL_EDGES)[number];
|
|
30
32
|
|
|
31
33
|
const ROOT_CLASS = 'flex flex-col gap-3 text-fg';
|
|
32
|
-
|
|
34
|
+
// 视窗 / 叠卡 = 壳配方(容器边,KT-B2);切换钮 = 带文字中性按钮描边(KT-B1)
|
|
35
|
+
const VIEWPORT_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
36
|
+
const NAV_EDGE = kitButtonEdgeRecipe();
|
|
37
|
+
const STACK_EDGE = kitShellRecipe({ tone: 'base' });
|
|
38
|
+
const VIEWPORT_CLASS = `overflow-hidden ${VIEWPORT_EDGE}`;
|
|
33
39
|
const SLIDE_IMAGE_CLASS = 'flex flex-col';
|
|
34
40
|
const IMG_CLASS = 'aspect-16/9 w-full object-cover';
|
|
35
41
|
const CAPTION_CLASS = 'flex flex-col gap-1 px-4 py-3';
|
|
@@ -38,7 +44,7 @@ const TITLE_CLASS = 'text-lg font-semibold';
|
|
|
38
44
|
const TEXT_CLASS = 'text-sm text-fg-muted';
|
|
39
45
|
const CARD_TEXT_CLASS = 'text-sm';
|
|
40
46
|
const BAR_CLASS = 'flex items-center justify-between gap-3';
|
|
41
|
-
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md
|
|
47
|
+
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md ' + NAV_EDGE + ' bg-surface px-2 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
42
48
|
// 圆点尺寸与间距取 design 真源 kit-limits#carousel(间距步数,乘 --spacing);排容器 hit-gap-N 写 gap 与 --kit-hit-gap,
|
|
43
49
|
// 圆点用 hit-area-row(读 hitTarget;沿排热区 = min(命中边长, 中心距),相邻热区相接零重叠,垂直方向仍是完整命中边长),不手写外扩。
|
|
44
50
|
const DOTS_CLASS = `flex flex-1 items-center justify-center hit-gap-${KIT_CAROUSEL_LIMITS.dotGapStep}`;
|
|
@@ -52,7 +58,7 @@ const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
|
52
58
|
start: 'grid ps-6',
|
|
53
59
|
end: 'grid pe-6',
|
|
54
60
|
});
|
|
55
|
-
const STACK_CARD_BASE =
|
|
61
|
+
const STACK_CARD_BASE = `col-start-1 row-start-1 flex min-h-32 flex-col gap-2 ${STACK_EDGE} p-4 text-start motion-safe:transition-transform`;
|
|
56
62
|
const STACK_TOP = 'z-30 cursor-pointer hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
57
63
|
/** 后面两张牌的位置:edge × 深度(1、2) */
|
|
58
64
|
const STACK_BEHIND: Readonly<Record<KitCarouselEdge, readonly [string, string]>> = Object.freeze({
|
|
@@ -274,7 +280,7 @@ export function createCarousel(): SomaComponentDefinition {
|
|
|
274
280
|
select: { payload: { index: { type: 'number' }, item: { type: 'object' } }, desc: 'slide 布局下点当前张的内容' },
|
|
275
281
|
},
|
|
276
282
|
},
|
|
277
|
-
templateHtml: `<section data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
|
|
283
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
|
|
278
284
|
controllerFactory: createKitController(() => ({
|
|
279
285
|
attach(root, api) {
|
|
280
286
|
const s = stateOf(root);
|
package/src/data/chart.ts
CHANGED
|
@@ -23,8 +23,9 @@ import {
|
|
|
23
23
|
chartMarkDashPattern, defaultReadoutColumn, formatReadoutValue, parseChartMarks, parseReadout, resolveChartMarks, stepChartColumn,
|
|
24
24
|
type ChartMark, type ChartMarkSpec, type ReadoutConfig, type ResolvedChartMark, type VizTone,
|
|
25
25
|
} from 'soma-foundation/kit-viz';
|
|
26
|
-
import { classCandidates } from '../
|
|
27
|
-
import { mergeClass } from '../
|
|
26
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
27
|
+
import { mergeClass } from '../shared/merge-class';
|
|
28
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
28
29
|
import { kitFocusRingRecipe } from '../recipes/state';
|
|
29
30
|
import { KIT_NOTICE_HEADLINE, KIT_STAT_VALUES_NUM, KIT_STAT_VALUES_ROW } from '../recipes/status';
|
|
30
31
|
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
@@ -87,7 +88,8 @@ const ROOT_CLASS = 'relative w-full';
|
|
|
87
88
|
/** 图已就绪的根标记:引擎加载完并出过图后才有(截图 / 渲染测量据此判断,不靠固定等待) */
|
|
88
89
|
export const KIT_CHART_READY_ATTR = 'data-kit-chart-ready';
|
|
89
90
|
const STAGE_CLASS = 'h-72 w-full';
|
|
90
|
-
|
|
91
|
+
// 空态框 = 凹槽面的壳配方(容器边,KT-B2)
|
|
92
|
+
const EMPTY_INNER_CLASS = mergeClass('flex h-72 w-full items-center justify-center text-sm text-fg-muted', kitShellRecipe({ tone: 'sunken', shadow: false }));
|
|
91
93
|
|
|
92
94
|
/**
|
|
93
95
|
* 逐列读数区的类:排版与表面取 kit 配方(说明条标题 / StatGroup 多值行的字阶与等宽数字),不手写字阶;
|
|
@@ -105,7 +107,7 @@ const READOUT_BOTTOM_CLASS = 'mt-2';
|
|
|
105
107
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
106
108
|
export const KIT_CHART_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
107
109
|
['relative', 'absolute', 'inset-0', 'invisible', 'w-full', 'h-72', 'hidden', 'sr-only',
|
|
108
|
-
|
|
110
|
+
EMPTY_INNER_CLASS],
|
|
109
111
|
KIT_STATE_PANEL_CLASS_CANDIDATES,
|
|
110
112
|
READOUT_CLASS, READOUT_TITLE_CLASS, READOUT_ITEM_CLASS, READOUT_VALUE_CLASS, READOUT_NOTE_CLASS, ROOT_FOCUS_CLASS,
|
|
111
113
|
READOUT_TOP_CLASS, READOUT_BOTTOM_CLASS,
|
|
@@ -168,9 +170,36 @@ export function engineSeriesOf(type: KitChartType): string {
|
|
|
168
170
|
return type === 'area' ? 'line' : type === 'donut' ? 'pie' : type === 'combo' ? 'bar' : type;
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
/** 一张图要装的全部引擎系列类型(combo = bar + line) */
|
|
172
|
-
export function engineSeriesListOf(type: KitChartType): string[] {
|
|
173
|
-
|
|
173
|
+
/** 一张图要装的全部引擎系列类型(combo = bar + line;bar 等直角图含 baseline / ideal / projection / line 系列时补齐 line) */
|
|
174
|
+
export function engineSeriesListOf(type: KitChartType, config?: Pick<KitChartConfig, 'roles' | 'line'>): string[] {
|
|
175
|
+
const out = type === 'combo' ? ['bar', 'line'] : [engineSeriesOf(type)];
|
|
176
|
+
const needsLine = (config?.line?.length ?? 0) > 0
|
|
177
|
+
|| Object.values(config?.roles ?? {}).some((r) => r === 'ideal' || r === 'baseline' || r === 'projection');
|
|
178
|
+
if (needsLine && !out.includes('line')) out.push('line');
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** 扫描实际产出的 option.series,补齐全部引擎系列类型(防止 bar + baseline/line 等运行时报未导入系列) */
|
|
183
|
+
function renderedSeriesTypesOf(config: KitChartConfig, option: Record<string, unknown>): string[] {
|
|
184
|
+
const types = new Set(engineSeriesListOf(config.type, config));
|
|
185
|
+
if (Array.isArray(option.series)) {
|
|
186
|
+
for (const s of option.series) {
|
|
187
|
+
if (s !== null && typeof s === 'object' && typeof (s as { type?: unknown }).type === 'string') {
|
|
188
|
+
types.add((s as { type: string }).type);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return [...types];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** 角色后缀去重:字段名已含同义角色词(如「预测」「理想」)时不拼成「预测(预测)」「理想(理想)」 */
|
|
196
|
+
function appendRoleSuffix(name: string, suffix: string): string {
|
|
197
|
+
if (suffix === '') return name;
|
|
198
|
+
const trimmed = name.trim();
|
|
199
|
+
if (trimmed === '') return name;
|
|
200
|
+
const core = suffix.replace(/^[\s((]+|[\s))]+$/g, '').trim().toLowerCase();
|
|
201
|
+
if (core !== '' && trimmed.toLowerCase().includes(core)) return name;
|
|
202
|
+
return `${name}${suffix}`;
|
|
174
203
|
}
|
|
175
204
|
|
|
176
205
|
/** 数据要求:除 x / y 外还必须给的字段,以及 y 最少几个字段(纯函数,chartConfigOf 用) */
|
|
@@ -459,29 +488,118 @@ export function buildChartOption(
|
|
|
459
488
|
const style = MARK_SPEC.roles[role]!;
|
|
460
489
|
return { color: toneColor(style.tone), dash: chartMarkDashPattern(style.dash), symbol: style.symbol };
|
|
461
490
|
};
|
|
491
|
+
const hasY2 = config.type === 'combo' && (config.y2?.length ?? 0) > 0;
|
|
492
|
+
/** 估算参考线标签像素宽(中文约 12px、ASCII 约 7px),避免在无布局环境下被 SVG 右边界裁切 */
|
|
493
|
+
const estimateLabelPx = (text: string): number => {
|
|
494
|
+
let px = 0;
|
|
495
|
+
for (const ch of text) px += ch.charCodeAt(0) > 127 ? 12 : 7;
|
|
496
|
+
return px;
|
|
497
|
+
};
|
|
498
|
+
/** 估算参考线的数值坐标(用于判定右侧相邻标签是否过近并错开 y 偏移) */
|
|
499
|
+
const primaryValues = (): number[] => {
|
|
500
|
+
const firstY = config.y[0];
|
|
501
|
+
if (firstY === undefined) return [];
|
|
502
|
+
const k = src(firstY);
|
|
503
|
+
return rows.map((r) => num(r[k])).filter((v): v is number => v !== null);
|
|
504
|
+
};
|
|
505
|
+
const statValueOf = (stat: KitChartRefLine['stat'], vals: readonly number[]): number | null => {
|
|
506
|
+
if (vals.length === 0 || stat === undefined) return null;
|
|
507
|
+
if (stat === 'max') return Math.max(...vals);
|
|
508
|
+
if (stat === 'min') return Math.min(...vals);
|
|
509
|
+
if (stat === 'average') return vals.reduce((a, b) => a + b, 0) / vals.length;
|
|
510
|
+
const sorted = [...vals].sort((a, b) => a - b);
|
|
511
|
+
const mid = Math.floor(sorted.length / 2);
|
|
512
|
+
return sorted.length % 2 === 1 ? sorted[mid]! : (sorted[mid - 1]! + sorted[mid]!) / 2;
|
|
513
|
+
};
|
|
462
514
|
/** 参考线与标记竖线 / 横线合并成引擎 markLine,只挂在第一条系列上(虚线 / 实线由角色定,不带 tooltip) */
|
|
463
515
|
const markLineOf = (): Record<string, unknown> => {
|
|
464
516
|
const refs = config.refLines ?? [];
|
|
465
517
|
const lines = resolvedMarks.filter((m) => m.kind === 'line');
|
|
466
518
|
if (refs.length === 0 && lines.length === 0) return {};
|
|
519
|
+
const vals = primaryValues();
|
|
520
|
+
const yLines: Array<{ key: string; yVal: number | null; label: string }> = [];
|
|
521
|
+
refs.forEach((r, idx) => {
|
|
522
|
+
if (r.label !== '') yLines.push({ key: `r:${idx}`, yVal: r.value !== undefined ? r.value : statValueOf(r.stat, vals), label: r.label });
|
|
523
|
+
});
|
|
524
|
+
lines.forEach((m, idx) => {
|
|
525
|
+
if (m.axis === 'y' && m.label !== '') yLines.push({ key: `m:${idx}`, yVal: typeof m.at === 'number' ? m.at : null, label: m.label });
|
|
526
|
+
});
|
|
527
|
+
const numericVals = [...vals, ...yLines.map((x) => x.yVal).filter((v): v is number => v !== null)];
|
|
528
|
+
// 直角坐标值轴默认含 0,估算可见纵轴跨度时把 0 纳入上下界,避免相邻参考线被误判为相距甚远
|
|
529
|
+
const ySpan = numericVals.length > 0 ? Math.max(0, ...numericVals) - Math.min(0, ...numericVals) : 0;
|
|
530
|
+
const closeGap = ySpan > 0 ? ySpan * 0.14 : 0;
|
|
531
|
+
const dyByKey = new Map<string, number>();
|
|
532
|
+
const posByKey = new Map<string, 'end' | 'insideEndTop' | 'insideEndBottom'>();
|
|
533
|
+
if (yLines.length > 0) {
|
|
534
|
+
const sorted = [...yLines].sort((a, b) => (b.yVal ?? 0) - (a.yVal ?? 0));
|
|
535
|
+
const clusters: Array<typeof sorted> = [];
|
|
536
|
+
for (const item of sorted) {
|
|
537
|
+
const lastCluster = clusters[clusters.length - 1];
|
|
538
|
+
const prev = lastCluster?.[lastCluster.length - 1];
|
|
539
|
+
const isClose = prev !== undefined && (
|
|
540
|
+
item.yVal === null || prev.yVal === null || Math.abs(prev.yVal - item.yVal) <= closeGap
|
|
541
|
+
);
|
|
542
|
+
if (lastCluster && isClose) lastCluster.push(item);
|
|
543
|
+
else clusters.push([item]);
|
|
544
|
+
}
|
|
545
|
+
for (const cluster of clusters) {
|
|
546
|
+
if (cluster.length === 1) {
|
|
547
|
+
posByKey.set(cluster[0]!.key, hasY2 ? 'insideEndTop' : 'end');
|
|
548
|
+
dyByKey.set(cluster[0]!.key, 0);
|
|
549
|
+
} else {
|
|
550
|
+
const mid = (cluster.length - 1) / 2;
|
|
551
|
+
cluster.forEach((item, i) => {
|
|
552
|
+
if (hasY2) {
|
|
553
|
+
posByKey.set(item.key, i <= mid ? 'insideEndTop' : 'insideEndBottom');
|
|
554
|
+
dyByKey.set(item.key, Math.round((i - mid) * 14));
|
|
555
|
+
} else {
|
|
556
|
+
posByKey.set(item.key, 'end');
|
|
557
|
+
dyByKey.set(item.key, Math.round((i - mid) * 16));
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
467
563
|
return {
|
|
468
564
|
markLine: {
|
|
469
565
|
silent: true,
|
|
470
566
|
symbol: 'none',
|
|
471
567
|
data: [
|
|
472
|
-
...refs.map((r) =>
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
568
|
+
...refs.map((r, idx) => {
|
|
569
|
+
const key = `r:${idx}`;
|
|
570
|
+
const dy = dyByKey.get(key) ?? 0;
|
|
571
|
+
const position = posByKey.get(key) ?? (hasY2 ? 'insideEndTop' : 'end');
|
|
572
|
+
return {
|
|
573
|
+
...(r.value !== undefined ? { yAxis: r.value } : { type: r.stat }),
|
|
574
|
+
name: r.label,
|
|
575
|
+
lineStyle: { type: 'dashed', color: toneColor(r.tone) },
|
|
576
|
+
label: {
|
|
577
|
+
show: r.label !== '',
|
|
578
|
+
formatter: r.label,
|
|
579
|
+
color: toneColor(r.tone),
|
|
580
|
+
position,
|
|
581
|
+
...(dy !== 0 ? { offset: [0, dy] } : {}),
|
|
582
|
+
},
|
|
583
|
+
};
|
|
584
|
+
}),
|
|
585
|
+
...lines.map((m, idx) => {
|
|
479
586
|
const s = roleOf(m.role);
|
|
587
|
+
const key = `m:${idx}`;
|
|
588
|
+
const isY = m.axis === 'y';
|
|
589
|
+
const dy = isY ? (dyByKey.get(key) ?? 0) : 0;
|
|
590
|
+
const position = isY ? (posByKey.get(key) ?? (hasY2 ? 'insideEndTop' : 'end')) : 'end';
|
|
480
591
|
return {
|
|
481
592
|
...(m.axis === 'x' ? { xAxis: m.at } : { yAxis: m.at }),
|
|
482
593
|
name: m.label,
|
|
483
594
|
lineStyle: { type: s.dash === null ? 'solid' : [...s.dash], color: s.color, width: CHART_NUM.marks.lineWidth },
|
|
484
|
-
label: {
|
|
595
|
+
label: {
|
|
596
|
+
show: m.label !== '',
|
|
597
|
+
formatter: m.label,
|
|
598
|
+
color: s.color,
|
|
599
|
+
position,
|
|
600
|
+
rotate: 0,
|
|
601
|
+
...(dy !== 0 ? { offset: [0, dy] } : {}),
|
|
602
|
+
},
|
|
485
603
|
};
|
|
486
604
|
}),
|
|
487
605
|
],
|
|
@@ -532,9 +650,18 @@ export function buildChartOption(
|
|
|
532
650
|
},
|
|
533
651
|
};
|
|
534
652
|
};
|
|
535
|
-
/** 直角坐标系的 grid:底部图例留 32,顶部图例把上沿让到 40 */
|
|
653
|
+
/** 直角坐标系的 grid:底部图例留 32,顶部图例把上沿让到 40;有右侧参考线外置标签时按标签宽留出右边距避免裁切 */
|
|
654
|
+
const rightMarkLabels = hasY2
|
|
655
|
+
? []
|
|
656
|
+
: [
|
|
657
|
+
...(config.refLines ?? []).map((r) => r.label).filter((s) => s !== ''),
|
|
658
|
+
...resolvedMarks.filter((m) => m.kind === 'line' && m.axis === 'y' && m.label !== '').map((m) => m.label),
|
|
659
|
+
];
|
|
660
|
+
const rightLabelPad = rightMarkLabels.length > 0
|
|
661
|
+
? Math.min(136, Math.max(48, Math.max(...rightMarkLabels.map(estimateLabelPx)) + 20))
|
|
662
|
+
: 8;
|
|
536
663
|
const gridFor = (multi: boolean): Record<string, unknown> => ({
|
|
537
|
-
left: 8, right:
|
|
664
|
+
left: 8, right: rightLabelPad, containLabel: true,
|
|
538
665
|
top: legendShown(multi) && config.legend === 'top' ? 40 : 24,
|
|
539
666
|
bottom: legendShown(multi) && config.legend !== 'top' ? 32 : 8,
|
|
540
667
|
});
|
|
@@ -729,7 +856,7 @@ export function buildChartOption(
|
|
|
729
856
|
const plainYs = [...basicYs.filter((y) => toneOfRole(y) === null), ...basicYs.filter((y) => toneOfRole(y) !== null)];
|
|
730
857
|
const idealYs = config.y.filter(isIdeal);
|
|
731
858
|
const projectionYs = config.y.filter(isProjection);
|
|
732
|
-
const projectionName = (y: string): string =>
|
|
859
|
+
const projectionName = (y: string): string => appendRoleSuffix(y, theme.projectionSuffix ?? '');
|
|
733
860
|
/** 空值(null / undefined / 非数)保持 null:引擎据此断线留白,不补零不插值 */
|
|
734
861
|
const cell = (r: Record<string, unknown>, key: string): number | null => num(r[key]);
|
|
735
862
|
const idealSeries = idealYs.map((y) => {
|
|
@@ -885,12 +1012,14 @@ export function chartAltOf(
|
|
|
885
1012
|
}
|
|
886
1013
|
}
|
|
887
1014
|
const withNotes = noteByRow.size > 0;
|
|
1015
|
+
const idealSuffix = kitText('soma.kit.chart_ideal', { name: '' }, at);
|
|
1016
|
+
const projSuffix = kitText('soma.kit.chart_projection', { name: '' }, at);
|
|
888
1017
|
return {
|
|
889
1018
|
label,
|
|
890
|
-
// 理想线 / 预测线的表头标注;空值(null /
|
|
1019
|
+
// 理想线 / 预测线的表头标注;空值(null / 缺值)单元格为空串(字段名已含角色词时不拼成「预测(预测)」)
|
|
891
1020
|
columns: [
|
|
892
|
-
...fields.map((f) => (config.roles?.[f] === 'ideal' ?
|
|
893
|
-
: config.roles?.[f] === 'projection' ?
|
|
1021
|
+
...fields.map((f) => (config.roles?.[f] === 'ideal' ? appendRoleSuffix(f, idealSuffix)
|
|
1022
|
+
: config.roles?.[f] === 'projection' ? appendRoleSuffix(f, projSuffix) : f)),
|
|
894
1023
|
...(withNotes ? [kitText('soma.kit.chart_marks_col', undefined, at)] : []),
|
|
895
1024
|
],
|
|
896
1025
|
rows: shown.slice(0, cap).map((r, i) => [...fields.map((f) => cell(r[src(f)])), ...(withNotes ? [(noteByRow.get(i) ?? []).join('、')] : [])]),
|
|
@@ -1336,11 +1465,12 @@ export function createChart(): SomaComponentDefinition {
|
|
|
1336
1465
|
drawn = { config, rows, theme, map: p.map, reduceMotion };
|
|
1337
1466
|
syncInteractive(config, rows, str(p.aria_label) !== '' ? str(p.aria_label) : alt.label);
|
|
1338
1467
|
const marked = chartMarkComponentsOf(config);
|
|
1468
|
+
const requiredSeries = renderedSeriesTypesOf(config, option);
|
|
1339
1469
|
if (instance === null) {
|
|
1340
1470
|
if (creating === null) {
|
|
1341
1471
|
creating = (async () => {
|
|
1342
1472
|
try {
|
|
1343
|
-
await port.ensure(
|
|
1473
|
+
await port.ensure(requiredSeries, engineComponentsOf(config.type, marked.markLine, marked.extra));
|
|
1344
1474
|
const locale = str(p.locale);
|
|
1345
1475
|
const created = await port.create(stage!, { theme: { color: theme.palette }, ...(locale !== '' ? { locale } : {}) });
|
|
1346
1476
|
if (!alive) { created.dispose(); return; }
|
|
@@ -1364,7 +1494,7 @@ export function createChart(): SomaComponentDefinition {
|
|
|
1364
1494
|
}
|
|
1365
1495
|
// 异步期间又有新一轮 paint 或已卸载:交给最新一轮
|
|
1366
1496
|
if (!alive || mine !== seq || instance === null) return;
|
|
1367
|
-
await port.ensure(
|
|
1497
|
+
await port.ensure(requiredSeries, engineComponentsOf(config.type, marked.markLine, marked.extra));
|
|
1368
1498
|
if (!alive || mine !== seq) return;
|
|
1369
1499
|
instance.setOption(option, 'replace');
|
|
1370
1500
|
endEngineWait();
|
package/src/data/checklist.ts
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
10
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
11
11
|
import { createCheck, markInput } from '../base/check-core';
|
|
12
|
-
import { kitIcon } from '../
|
|
13
|
-
import { mergeClass } from '../
|
|
12
|
+
import { kitIcon } from '../shared/icons';
|
|
13
|
+
import { mergeClass } from '../shared/merge-class';
|
|
14
14
|
import { kitStateMarkRecipe } from '../recipes/state';
|
|
15
15
|
import { kitText } from '../i18n/kit-text';
|
|
16
16
|
import { markKitEdge } from '../recipes/surface-edge';
|
|
17
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
17
18
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
18
19
|
import {
|
|
19
20
|
actionButton, actionsOf, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, mkProgressBar, PROGRESS_BAR_CLASS_TOKENS, recOf, setProgressBar, rowsOf, shapeToneOf, textOf,
|
|
@@ -25,7 +26,7 @@ export const KIT_CHECKLIST_ITEM_DEFAULT_MAP = Object.freeze({ id: 'id', label: '
|
|
|
25
26
|
|
|
26
27
|
export type KitCheckStatus = 'done' | 'blocked' | 'pending';
|
|
27
28
|
|
|
28
|
-
const ROOT_CLASS = 'flex flex-col gap-3
|
|
29
|
+
const ROOT_CLASS = mergeClass('flex flex-col gap-3 p-5 text-sm text-fg', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
29
30
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
30
31
|
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
31
32
|
const COUNT_CLASS = 'ms-auto text-xs text-fg-muted';
|
|
@@ -109,7 +110,7 @@ export function createChecklist(): SomaComponentDefinition {
|
|
|
109
110
|
action: { payload: { key: { type: 'string' } }, desc: '点底部动作' },
|
|
110
111
|
},
|
|
111
112
|
},
|
|
112
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
113
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
113
114
|
controllerFactory: createKitController(() => ({
|
|
114
115
|
attach(root, api) {
|
|
115
116
|
const onChange = (event: Event): void => {
|