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/data/diff.ts
CHANGED
|
@@ -14,11 +14,14 @@ import { setKitFace } from '../recipes';
|
|
|
14
14
|
import { createKitController, joinClass, str } from '../base/shared';
|
|
15
15
|
import { classTokens, mk, recOf, textOf, type Rec } from './shape-util';
|
|
16
16
|
import { clampInt, singleOf, urlOf } from './display-util';
|
|
17
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
17
18
|
|
|
18
19
|
export const KIT_DIFF_STEP: number = KIT_STATIC_COMPONENT_LIMITS.display.Diff.positionStep;
|
|
19
20
|
export const KIT_DIFF_STEPS = 20;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
// 外缘 = 壳配方(容器边,KT-B2)
|
|
23
|
+
const ROOT_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
24
|
+
const ROOT_CLASS = `relative aspect-16/9 w-full select-none overflow-hidden ${ROOT_EDGE} touch-none`;
|
|
22
25
|
const LAYER_CLASS = 'absolute inset-0';
|
|
23
26
|
const BEFORE_BOX_BASE = 'absolute inset-y-0 left-0 overflow-hidden';
|
|
24
27
|
const INNER_CLASS = 'relative h-full shrink-0';
|
package/src/data/dock.ts
CHANGED
|
@@ -11,8 +11,12 @@ import { kitText } from '../i18n/kit-text';
|
|
|
11
11
|
import { createKitController, joinClass, str } from '../base/shared';
|
|
12
12
|
import { classTokens, mk, textOf, type Rec } from './shape-util';
|
|
13
13
|
import { keyOfRow, listOf, rovingTabIndex, wireRovingRow } from './display-util';
|
|
14
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
/** 外缘 = 壳配方(容器边 + 容器阴影令牌,KT-B2) */
|
|
17
|
+
const ROOT_EDGE = kitShellRecipe({ tone: 'base' });
|
|
18
|
+
|
|
19
|
+
const ROOT_CLASS = `flex items-stretch justify-around gap-1 ${ROOT_EDGE} p-1`;
|
|
16
20
|
const ITEM_CLASS = 'relative flex min-w-14 flex-1 flex-col items-center justify-center gap-0.5 rounded-md px-2 py-1.5 text-xs text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 data-kit-selected:bg-primary-soft data-kit-selected:text-primary-on-soft';
|
|
17
21
|
const ICON_CLASS = 'text-lg';
|
|
18
22
|
const LABEL_CLASS = 'font-medium';
|
package/src/data/embed.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { createInput } from '../base/input';
|
|
|
12
12
|
import { createTextarea } from '../base/textarea';
|
|
13
13
|
import { createCheckbox } from '../base/checkbox';
|
|
14
14
|
import { hintUndeclaredKitUse } from './wrapped-candidates';
|
|
15
|
-
import { kitFail } from '../
|
|
15
|
+
import { kitFail } from '../shared/kit-error';
|
|
16
16
|
|
|
17
17
|
export type KitEmitHandlers = Record<string, (payload: any) => void>;
|
|
18
18
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// kit 取用 core 引擎端口的唯一路径(端口标准形式,见 handoff 端口标准形式.md):
|
|
2
|
+
// 组件契约声明 `services: ['engines']`,运行时取 `api.services.engines.<端口>`;
|
|
3
|
+
// kit 不 import core 的引擎子路径(`soma-core/diff` 等属「收回 core 内部」的出口),这里按结构写一份只读形状。
|
|
4
|
+
// 形状与 soma-core/core/client/engines/<端口>/port.ts 对齐;core 改形状时这里同步(契约测试由测试同学补)。
|
|
5
|
+
|
|
6
|
+
// ── 文本差异端口(engines.diff) ──────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
export interface KitDiffFragment { readonly v: string; readonly op: 'eq' | 'ins' | 'del' }
|
|
9
|
+
export interface KitProseBlock { readonly op: 'eq' | 'ins' | 'del' | 'mod'; readonly fragments: readonly KitDiffFragment[] }
|
|
10
|
+
export type KitProseDegraded = 'timeout' | 'too-large' | 'no-segmenter';
|
|
11
|
+
export interface KitProseDiff {
|
|
12
|
+
readonly kind: 'same' | 'inline' | 'rewrite';
|
|
13
|
+
readonly formatOnly: boolean;
|
|
14
|
+
readonly similarity: number;
|
|
15
|
+
readonly blocks: readonly KitProseBlock[];
|
|
16
|
+
readonly stats: { readonly insChars: number; readonly delChars: number; readonly changes: number };
|
|
17
|
+
readonly granularity: 'words-zh' | 'words' | 'chars';
|
|
18
|
+
readonly degraded?: KitProseDegraded;
|
|
19
|
+
}
|
|
20
|
+
export interface KitItemFieldSpec { readonly name: string; readonly label: string; readonly type: 'text' | 'value' }
|
|
21
|
+
export type KitItemState = 'added' | 'removed' | 'modified' | 'moved' | 'moved-modified' | 'same';
|
|
22
|
+
export interface KitItemFieldDiff {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly type: 'text' | 'value';
|
|
26
|
+
readonly state: 'same' | 'changed' | 'added' | 'removed';
|
|
27
|
+
readonly before: unknown;
|
|
28
|
+
readonly after: unknown;
|
|
29
|
+
readonly prose?: KitProseDiff;
|
|
30
|
+
}
|
|
31
|
+
export interface KitItemDiffEntry {
|
|
32
|
+
readonly state: KitItemState;
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly beforeIndex?: number;
|
|
35
|
+
readonly afterIndex?: number;
|
|
36
|
+
readonly title: string;
|
|
37
|
+
readonly fields: readonly KitItemFieldDiff[];
|
|
38
|
+
readonly magnitude: number;
|
|
39
|
+
}
|
|
40
|
+
export interface KitItemDiff {
|
|
41
|
+
readonly items: readonly KitItemDiffEntry[];
|
|
42
|
+
readonly stats: { readonly total: number; readonly added: number; readonly removed: number; readonly modified: number; readonly moved: number; readonly same: number };
|
|
43
|
+
readonly pairing: 'key' | 'content';
|
|
44
|
+
readonly fields: readonly KitItemFieldSpec[];
|
|
45
|
+
readonly movesSkipped: boolean;
|
|
46
|
+
readonly degraded?: KitProseDegraded | 'too-many-items';
|
|
47
|
+
}
|
|
48
|
+
export interface KitDiffPart { readonly op: 'equal' | 'insert' | 'delete'; readonly text: string }
|
|
49
|
+
export interface KitDiffEnginePort {
|
|
50
|
+
diff(a: string, b: string, mode: 'chars' | 'words' | 'lines' | 'words-zh'): Promise<readonly KitDiffPart[]>;
|
|
51
|
+
diffProse(a: string, b: string): Promise<KitProseDiff>;
|
|
52
|
+
diffItems(before: readonly unknown[], after: readonly unknown[], options?: { key?: string; fields?: readonly KitItemFieldSpec[]; title?: string }): Promise<KitItemDiff>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ── 代码高亮端口(engines.highlight) ─────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
export interface KitCodeToken { readonly text: string; readonly kind: string }
|
|
58
|
+
export interface KitCodeResult {
|
|
59
|
+
readonly language: string;
|
|
60
|
+
readonly lines: readonly (readonly KitCodeToken[])[];
|
|
61
|
+
readonly plainFrom: number;
|
|
62
|
+
readonly fallback?: 'unknown-language' | 'too-large' | 'timeout' | 'engine-load-failed';
|
|
63
|
+
}
|
|
64
|
+
export interface KitHighlightEnginePort {
|
|
65
|
+
resolveLanguage(hint: { language?: string; filename?: string; fence?: string; firstLine?: string; sample?: string }): string;
|
|
66
|
+
highlight(code: string, language: string): Promise<KitCodeResult>;
|
|
67
|
+
languageLabel(id: string): string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ── 结构化文本端口(engines.structured) ─────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
export type KitStructuredFormat = 'json' | 'yaml';
|
|
73
|
+
export type KitStructuredParseResult =
|
|
74
|
+
| { readonly ok: true; readonly format: KitStructuredFormat; readonly value: unknown; readonly nodes: number; readonly cycles: number }
|
|
75
|
+
| {
|
|
76
|
+
readonly ok: false; readonly format: KitStructuredFormat;
|
|
77
|
+
readonly reason: 'syntax' | 'too-large' | 'too-many-nodes' | 'not-structured' | 'engine-load-failed';
|
|
78
|
+
readonly line?: number; readonly column?: number; readonly message?: string;
|
|
79
|
+
};
|
|
80
|
+
export interface KitStructuredEnginePort {
|
|
81
|
+
detect(text: string, hint?: { format?: string; filename?: string }): KitStructuredFormat;
|
|
82
|
+
parse(text: string, format?: KitStructuredFormat | 'auto'): Promise<KitStructuredParseResult>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ── Markdown 解析端口(engines.markdown) ───────────────────────────────────
|
|
86
|
+
|
|
87
|
+
export type KitMdSrc = readonly [number, number];
|
|
88
|
+
export type KitMdInline =
|
|
89
|
+
| { readonly t: 'text'; readonly v: string }
|
|
90
|
+
| { readonly t: 'strong' | 'em' | 'del'; readonly c: readonly KitMdInline[] }
|
|
91
|
+
| { readonly t: 'code'; readonly v: string }
|
|
92
|
+
| { readonly t: 'br' }
|
|
93
|
+
| { readonly t: 'link'; readonly href: string; readonly external: boolean; readonly title?: string; readonly c: readonly KitMdInline[] }
|
|
94
|
+
| { readonly t: 'image'; readonly src: string; readonly alt: string; readonly title?: string }
|
|
95
|
+
| { readonly t: 'fnref'; readonly id: string; readonly n: number };
|
|
96
|
+
export type KitMdBlock =
|
|
97
|
+
| { readonly t: 'heading'; readonly depth: 1 | 2 | 3 | 4 | 5 | 6; readonly id: string; readonly inline: readonly KitMdInline[]; readonly src: KitMdSrc }
|
|
98
|
+
| { readonly t: 'paragraph'; readonly inline: readonly KitMdInline[]; readonly tight: boolean; readonly src: KitMdSrc }
|
|
99
|
+
| { readonly t: 'list'; readonly ordered: boolean; readonly start?: number; readonly items: readonly { readonly task: boolean | null; readonly blocks: readonly KitMdBlock[] }[]; readonly src: KitMdSrc }
|
|
100
|
+
| { readonly t: 'quote'; readonly blocks: readonly KitMdBlock[]; readonly src: KitMdSrc }
|
|
101
|
+
| { readonly t: 'code'; readonly lang: string; readonly text: string; readonly closed: boolean; readonly src: KitMdSrc }
|
|
102
|
+
| { readonly t: 'table'; readonly align: readonly ('left' | 'center' | 'right' | null)[]; readonly head: readonly (readonly KitMdInline[])[]; readonly rows: readonly (readonly (readonly KitMdInline[])[])[]; readonly src: KitMdSrc }
|
|
103
|
+
| { readonly t: 'hr'; readonly src: KitMdSrc }
|
|
104
|
+
| { readonly t: 'html'; readonly text: string; readonly src: KitMdSrc }
|
|
105
|
+
| { readonly t: 'footnotes'; readonly items: readonly { readonly id: string; readonly n: number; readonly blocks: readonly KitMdBlock[] }[]; readonly src: KitMdSrc };
|
|
106
|
+
export interface KitMdMeta {
|
|
107
|
+
readonly outline: readonly { readonly depth: number; readonly text: string; readonly id: string }[];
|
|
108
|
+
readonly plainText: string;
|
|
109
|
+
readonly summary: string;
|
|
110
|
+
readonly counts: { readonly chars: number; readonly blocks: number; readonly images: number; readonly links: number; readonly codeBlocks: number; readonly tables: number };
|
|
111
|
+
readonly dropped: { readonly html: number; readonly unsafeUrls: number };
|
|
112
|
+
readonly truncated: boolean;
|
|
113
|
+
}
|
|
114
|
+
export type KitMdResult =
|
|
115
|
+
| { readonly ok: true; readonly blocks: readonly KitMdBlock[]; readonly meta: KitMdMeta }
|
|
116
|
+
| { readonly ok: false; readonly reason: 'too-long' | 'parse-error' | 'engine-load-failed'; readonly plainText: string };
|
|
117
|
+
export interface KitMarkdownEnginePort {
|
|
118
|
+
parse(source: string, options?: { footnotes?: boolean }): Promise<KitMdResult>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** 取一个引擎端口;宿主没装配(纯 Node 单测、无运行时)返回 null,组件按「引擎加载失败」降级 */
|
|
122
|
+
export function kitEnginePort<T>(services: unknown, id: string): T | null {
|
|
123
|
+
const engines = (services as { engines?: Record<string, unknown> } | undefined)?.engines;
|
|
124
|
+
const port = engines?.[id];
|
|
125
|
+
return port !== undefined && port !== null ? (port as T) : null;
|
|
126
|
+
}
|
package/src/data/field-mapper.ts
CHANGED
|
@@ -13,34 +13,42 @@
|
|
|
13
13
|
|
|
14
14
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
15
15
|
import { bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
16
|
-
import { kitIcon } from '../
|
|
16
|
+
import { kitIcon } from '../shared/icons';
|
|
17
17
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
18
18
|
import { setKitFace } from '../recipes';
|
|
19
|
+
import { kitControlRecipe } from '../recipes/control';
|
|
20
|
+
import { KIT_DIVIDER_FOOT_CLASS, kitDivideRecipe } from '../recipes/divider';
|
|
21
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
22
|
+
import { mergeClass } from '../shared/merge-class';
|
|
19
23
|
import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
20
24
|
import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
|
|
21
25
|
import { createKitEmbedBag, mountKitSelectField, type KitSelectField } from './embed';
|
|
26
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
27
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
22
28
|
|
|
23
29
|
// ───────── 样式常量:Tailwind 类串与候选类清单 ─────────
|
|
24
30
|
|
|
25
31
|
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
26
|
-
|
|
27
|
-
const
|
|
32
|
+
// 映射行之间的线由父出(kitDivideRecipe,KT-B5);来源框 = 控件配方;预览表外缘 = 壳配方,行线 = 分隔线出口
|
|
33
|
+
const ROWS_DIVIDE = kitDivideRecipe('y');
|
|
34
|
+
const LIST_CLASS = `flex flex-col ${ROWS_DIVIDE}`;
|
|
35
|
+
const ROW_CLASS = 'flex flex-wrap items-center gap-2 py-2';
|
|
28
36
|
const ROW_MISSING_CLASS = 'flex flex-wrap items-center gap-2 rounded-md border border-danger bg-danger-soft px-2 py-2';
|
|
29
37
|
const TARGET_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
30
38
|
const LABEL_CLASS = 'text-fg';
|
|
31
39
|
const KEY_CLASS = 'text-xs text-fg-muted';
|
|
32
40
|
const REQ_CLASS = 'ms-1 text-xs text-danger-on-soft';
|
|
33
41
|
const ARROW_CLASS = 'shrink-0 text-fg-subtle';
|
|
34
|
-
const CONTROL_CLASS = '
|
|
42
|
+
const CONTROL_CLASS = mergeClass(kitControlRecipe(), 'w-48 max-w-full');
|
|
35
43
|
const REMOVE_CLASS = 'inline-flex h-8 items-center justify-center rounded-md px-2 text-sm text-danger-on-soft hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
36
44
|
const ADD_ROW_CLASS = 'flex flex-wrap items-center gap-2 pt-2';
|
|
37
|
-
const BTN_CLASS = '
|
|
45
|
+
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
38
46
|
const NOTICE_CLASS = 'rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-on-soft';
|
|
39
47
|
const PREVIEW_TITLE_CLASS = 'text-xs text-fg-muted';
|
|
40
|
-
const PREVIEW_WRAP_CLASS = 'overflow-x-auto
|
|
48
|
+
const PREVIEW_WRAP_CLASS = mergeClass('overflow-x-auto', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
41
49
|
const PREVIEW_TABLE_CLASS = 'w-full text-start text-xs';
|
|
42
50
|
const PREVIEW_HEAD_CLASS = 'bg-surface-sunken px-2 py-1 font-medium text-fg-muted';
|
|
43
|
-
const PREVIEW_CELL_CLASS =
|
|
51
|
+
const PREVIEW_CELL_CLASS = `${KIT_DIVIDER_FOOT_CLASS} px-2 py-1 text-fg`;
|
|
44
52
|
/** 来源下拉(自绘 Select)根上的宽度类,和文本框来源控件同宽 */
|
|
45
53
|
const SELECT_ROOT_CLASS = 'w-48 max-w-full';
|
|
46
54
|
const FOOT_CLASS ='flex items-center justify-end gap-2';
|
|
@@ -391,6 +399,7 @@ export function createFieldMapper(): SomaComponentDefinition {
|
|
|
391
399
|
previewBox.appendChild(inner);
|
|
392
400
|
inner.appendChild(el('div', PREVIEW_TITLE_CLASS, tx('soma.kit.fm_preview')));
|
|
393
401
|
const wrap = el('div', PREVIEW_WRAP_CLASS);
|
|
402
|
+
markKitEdge(wrap);
|
|
394
403
|
const table = el('table', PREVIEW_TABLE_CLASS);
|
|
395
404
|
const thead = el('thead', '');
|
|
396
405
|
const hr = el('tr', '');
|
package/src/data/flow-editor.ts
CHANGED
|
@@ -20,7 +20,12 @@ import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
|
20
20
|
import { applyCommon, bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
21
21
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
22
22
|
import { setKitFace } from '../recipes';
|
|
23
|
-
import {
|
|
23
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
24
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
25
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
27
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
28
|
+
import { kitIcon, type KitIconName } from '../shared/icons';
|
|
24
29
|
import { createInput, KIT_INPUT_CLASS_CANDIDATES } from '../base/input';
|
|
25
30
|
import { createTextarea, KIT_TEXTAREA_CLASS_CANDIDATES } from '../base/textarea';
|
|
26
31
|
import { createSwitch, KIT_SWITCH_CLASS_CANDIDATES } from '../base/switch';
|
|
@@ -193,15 +198,19 @@ export function fmt(template: string, vars: Record<string, string | number>): st
|
|
|
193
198
|
// hidden 与布局类分写两层:外层只管显隐,内层管布局。
|
|
194
199
|
// ════════════════════════════════════════════════════════════════
|
|
195
200
|
|
|
201
|
+
const EDGE_STILL = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
202
|
+
const EDGE_LIVE = kitControlEdgeRecipe({ wrapper: true });
|
|
196
203
|
export const FLOW_CLASS = Object.freeze({
|
|
197
204
|
root: 'flex w-full flex-col gap-2',
|
|
198
205
|
toolbar: 'flex flex-wrap items-center gap-2',
|
|
199
|
-
|
|
206
|
+
btnGroup: 'inline-flex shrink-0 flex-nowrap items-center gap-1',
|
|
207
|
+
btn: mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'shrink-0 whitespace-nowrap'),
|
|
200
208
|
btnPrimary: 'inline-flex h-8 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border border-primary bg-primary px-3 text-sm text-primary-fg transition-colors hover:bg-primary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60',
|
|
201
209
|
zoomLabel: 'text-xs text-fg-muted',
|
|
202
210
|
row: 'flex w-full items-start gap-2',
|
|
203
211
|
panelOuter: 'w-80 shrink-0',
|
|
204
|
-
|
|
212
|
+
// 配置面板与画布外缘 = 壳配方(容器边,KT-B2);节点 / 端口 / 节点条的轮廓 = 控件轮廓(KT-B1);右键菜单 = 浮起表面(KT-B4)
|
|
213
|
+
panel: mergeClass('flex h-120 flex-col gap-3 overflow-y-auto p-3', kitShellRecipe({ tone: 'base', shadow: false })),
|
|
205
214
|
panelTitle: 'text-sm font-semibold text-fg',
|
|
206
215
|
panelField: 'flex flex-col gap-1',
|
|
207
216
|
panelFull: 'w-full',
|
|
@@ -209,7 +218,7 @@ export const FLOW_CLASS = Object.freeze({
|
|
|
209
218
|
panelReq: 'ms-1 text-danger-on-soft',
|
|
210
219
|
panelHelp: 'text-xs text-fg-muted',
|
|
211
220
|
panelWarn: 'rounded-md bg-warning-soft px-2 py-1 text-xs text-warning-on-soft',
|
|
212
|
-
stage: 'relative h-120 w-full touch-none select-none overflow-hidden
|
|
221
|
+
stage: mergeClass('relative h-120 w-full touch-none select-none overflow-hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', kitShellRecipe({ tone: 'sunken', shadow: false })),
|
|
213
222
|
svgRoot: 'absolute left-0 top-0 h-full w-full',
|
|
214
223
|
gridDot: 'fill-border',
|
|
215
224
|
gridRect: 'h-full w-full',
|
|
@@ -225,9 +234,9 @@ export const FLOW_CLASS = Object.freeze({
|
|
|
225
234
|
lineError: 'truncate text-xs text-danger-on-soft',
|
|
226
235
|
lineWarning: 'truncate text-xs text-warning-on-soft',
|
|
227
236
|
cfgBtn: 'shrink-0 rounded-sm px-1 text-xs text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
228
|
-
inPort:
|
|
229
|
-
outPort:
|
|
230
|
-
bar:
|
|
237
|
+
inPort: `pointer-events-none absolute -left-1 top-10 -mt-1 h-2 w-2 rounded-full ${EDGE_STILL} bg-surface`,
|
|
238
|
+
outPort: `absolute -right-2 top-10 -mt-2 h-4 w-4 p-0 cursor-crosshair rounded-full ${EDGE_LIVE} bg-surface hover:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,
|
|
239
|
+
bar: `box-border flex h-full w-full max-w-full items-center gap-1 overflow-hidden rounded-md ${EDGE_STILL} bg-surface px-2 text-xs text-fg shadow-sm`,
|
|
231
240
|
edgeG: 'group cursor-pointer outline-none',
|
|
232
241
|
edgeHit: 'fill-none stroke-transparent stroke-12',
|
|
233
242
|
edgeLabel: 'fill-fg-muted text-xs',
|
|
@@ -237,7 +246,7 @@ export const FLOW_CLASS = Object.freeze({
|
|
|
237
246
|
errorInner: 'rounded-md border border-danger bg-danger-soft px-3 py-2 text-sm text-danger-on-soft',
|
|
238
247
|
marqueeRect: 'fill-primary-soft stroke-primary opacity-50',
|
|
239
248
|
menuFo: 'pointer-events-auto overflow-visible',
|
|
240
|
-
menuInner: 'box-border flex w-full flex-col gap-1
|
|
249
|
+
menuInner: mergeClass('box-border flex w-full flex-col gap-1 p-1', kitSurfaceRecipe('raised')),
|
|
241
250
|
menuItem: 'rounded-sm px-2 py-1 text-start text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring',
|
|
242
251
|
menuItemDanger: 'rounded-sm px-2 py-1 text-start text-sm text-danger-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring',
|
|
243
252
|
status: 'text-xs text-fg-muted',
|
|
@@ -254,7 +263,7 @@ export const FLOW_NODE_BG = Object.freeze({
|
|
|
254
263
|
});
|
|
255
264
|
|
|
256
265
|
export const FLOW_NODE_BORDER = Object.freeze({
|
|
257
|
-
normal:
|
|
266
|
+
normal: kitControlEdgeRecipe({ wrapper: true, hover: false }),
|
|
258
267
|
error: 'border-danger',
|
|
259
268
|
warning: 'border-warning',
|
|
260
269
|
ghost: 'border-dashed border-primary',
|
|
@@ -1744,12 +1753,47 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
1744
1753
|
gridDot.setAttribute('cy', String(step / 2));
|
|
1745
1754
|
}
|
|
1746
1755
|
};
|
|
1756
|
+
let userAdjustedView = false;
|
|
1757
|
+
let lastStageW = 0;
|
|
1758
|
+
let lastStageH = 0;
|
|
1759
|
+
const isFormField = (): boolean => typeof P().name === 'string' && P().name !== '';
|
|
1747
1760
|
const stageSize = (): { w: number; h: number } => ({ w: stage.clientWidth || 0, h: stage.clientHeight || 0 });
|
|
1748
|
-
|
|
1761
|
+
/** 计算全部 AI 建议条的画布落位:在锚点右侧可能超界时改按锚点右缘对齐,并纳入 fitView 包围盒 */
|
|
1762
|
+
const suggestionBarLayout = (gh: { nodes: Array<FlowNode & { sid?: string }>; edges: Array<FlowEdge & { sid?: string }> }): Array<{ suggestion: FlowSuggestion; at: Pt; width: number }> => {
|
|
1763
|
+
const list: Array<{ suggestion: FlowSuggestion; at: Pt; width: number }> = [];
|
|
1764
|
+
const allNodes = [...posCache.values(), ...ghostPosCache.values()];
|
|
1765
|
+
const maxRight = allNodes.length > 0 ? Math.max(...allNodes.map((p) => p.x + FLOW_GEOMETRY.nodeW)) : 0;
|
|
1766
|
+
const barW = FLOW_GEOMETRY.barW;
|
|
1767
|
+
for (const s of visibleSuggestions()) {
|
|
1768
|
+
const first = gh.nodes.find((n) => n.sid === s.id);
|
|
1769
|
+
const anchor = first ? ghostPosCache.get(first.id) : undefined;
|
|
1770
|
+
const firstEdge = gh.edges.find((e) => e.sid === s.id);
|
|
1771
|
+
const mid = firstEdge && posOf(firstEdge.from) && posOf(firstEdge.to) ? edgeGeometry(posOf(firstEdge.from)!, posOf(firstEdge.to)!).mid : undefined;
|
|
1772
|
+
const rawAt = anchor ? { x: anchor.x, y: anchor.y + FLOW_GEOMETRY.nodeH + 4 } : mid;
|
|
1773
|
+
if (!rawAt) continue;
|
|
1774
|
+
const x = anchor && barW > FLOW_GEOMETRY.nodeW && rawAt.x + barW > maxRight
|
|
1775
|
+
? Math.min(rawAt.x, maxRight - barW)
|
|
1776
|
+
: rawAt.x;
|
|
1777
|
+
list.push({ suggestion: s, at: { x, y: rawAt.y }, width: barW });
|
|
1778
|
+
}
|
|
1779
|
+
return list;
|
|
1780
|
+
};
|
|
1781
|
+
const allRects = (): Rect[] => {
|
|
1782
|
+
const rects = [...posCache.values(), ...ghostPosCache.values()].map(nodeRect);
|
|
1783
|
+
for (const item of suggestionBarLayout(ghostsOf())) {
|
|
1784
|
+
rects.push({ x: item.at.x, y: item.at.y, w: item.width, h: FLOW_GEOMETRY.barH });
|
|
1785
|
+
}
|
|
1786
|
+
return rects;
|
|
1787
|
+
};
|
|
1749
1788
|
function fit(): void {
|
|
1750
1789
|
const { w, h } = stageSize();
|
|
1751
1790
|
view = w > 0 && h > 0 ? fitView(allRects(), w, h) : { zoom: 1, panX: 0, panY: 0 };
|
|
1752
|
-
|
|
1791
|
+
if (w > 0 && h > 0) {
|
|
1792
|
+
needFit = false;
|
|
1793
|
+
userAdjustedView = false;
|
|
1794
|
+
lastStageW = w;
|
|
1795
|
+
lastStageH = h;
|
|
1796
|
+
}
|
|
1753
1797
|
applyView();
|
|
1754
1798
|
updateZoomLabel();
|
|
1755
1799
|
}
|
|
@@ -1757,6 +1801,7 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
1757
1801
|
const { w, h } = stageSize();
|
|
1758
1802
|
view = zoomAt(view, factor, w / 2, h / 2);
|
|
1759
1803
|
needFit = false;
|
|
1804
|
+
userAdjustedView = true;
|
|
1760
1805
|
applyView();
|
|
1761
1806
|
updateZoomLabel();
|
|
1762
1807
|
};
|
|
@@ -1801,28 +1846,41 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
1801
1846
|
|
|
1802
1847
|
const paintToolbar = (): void => {
|
|
1803
1848
|
toolbar.textContent = '';
|
|
1849
|
+
const group = (...btns: HTMLButtonElement[]): HTMLElement => {
|
|
1850
|
+
const g = el('div', FLOW_CLASS.btnGroup);
|
|
1851
|
+
g.append(...btns);
|
|
1852
|
+
return g;
|
|
1853
|
+
};
|
|
1804
1854
|
if (editable()) {
|
|
1805
1855
|
const types = Object.values(cfg.nodeTypes);
|
|
1806
1856
|
if (types.length === 0) toolbar.appendChild(mkButton('add:', t('add', { type: t('nodeDefault') })));
|
|
1807
1857
|
for (const ty of types) toolbar.appendChild(mkButton(`add:${ty.type}`, t('add', { type: ty.label })));
|
|
1808
|
-
toolbar.appendChild(
|
|
1809
|
-
|
|
1858
|
+
toolbar.appendChild(group(
|
|
1859
|
+
mkButton('undo', t('undo'), { disabled: !canUndo(history) }),
|
|
1860
|
+
mkButton('redo', t('redo'), { disabled: !canRedo(history) }),
|
|
1861
|
+
));
|
|
1810
1862
|
toolbar.appendChild(mkButton('del', t('del'), { disabled: selected.size === 0 }));
|
|
1811
1863
|
toolbar.appendChild(mkButton('connect', t('connect'), { disabled: selectedNodeIds().length !== 1 }));
|
|
1812
1864
|
const one = selectedNodeIds().length === 1 && selectedEdgeIds().length === 0;
|
|
1813
1865
|
toolbar.appendChild(mkButton('insert-above', t('insertAbove'), { disabled: !one, icon: 'plus' }));
|
|
1814
|
-
|
|
1815
|
-
toolbar.appendChild(
|
|
1866
|
+
// 成对动作(↑ 上移 / ↓ 下移)保持同组不拆行
|
|
1867
|
+
toolbar.appendChild(group(
|
|
1868
|
+
mkButton('move-up', t('moveUp'), { disabled: !one, icon: 'arrow-up' }),
|
|
1869
|
+
mkButton('move-down', t('moveDown'), { disabled: !one, icon: 'arrow-down' }),
|
|
1870
|
+
));
|
|
1816
1871
|
if (cfg.layout === 'manual') toolbar.appendChild(mkButton('layout', t('layout'), { disabled: graph.nodes.length === 0 }));
|
|
1817
1872
|
}
|
|
1818
|
-
toolbar.appendChild(
|
|
1819
|
-
|
|
1820
|
-
|
|
1873
|
+
toolbar.appendChild(group(
|
|
1874
|
+
mkButton('zoom-out', t('zoomOut')),
|
|
1875
|
+
mkButton('zoom-in', t('zoomIn')),
|
|
1876
|
+
mkButton('fit', t('fit')),
|
|
1877
|
+
));
|
|
1821
1878
|
const z = el('span', FLOW_CLASS.zoomLabel, { 'data-flow-zoom': '' });
|
|
1822
1879
|
z.textContent = t('zoomLabel', { n: Math.round(view.zoom * 100) });
|
|
1823
1880
|
toolbar.appendChild(z);
|
|
1824
1881
|
toolbar.appendChild(el('span', FLOW_CLASS.zoomLabel, { 'data-flow-hint': '' })).textContent = t('zoomHint');
|
|
1825
|
-
|
|
1882
|
+
// 作为表单字段嵌入时不画独立主色蓝底「保存」,避免与弹窗底栏主按钮冲突
|
|
1883
|
+
if (editable() && !isFormField()) toolbar.appendChild(mkButton('save', t('save'), { primary: true }));
|
|
1826
1884
|
};
|
|
1827
1885
|
|
|
1828
1886
|
const nodeClass = (sel: boolean, level: Level, ghost: boolean, canMove: boolean): string => {
|
|
@@ -2028,15 +2086,10 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
2028
2086
|
const gh = ghostsOf();
|
|
2029
2087
|
const sugLabels = new Map(visibleSuggestions().map((s) => [s.id, s.label] as const));
|
|
2030
2088
|
for (const n of gh.nodes) nodesLayer.appendChild(buildNode(n, ghostPosCache.get(n.id) ?? { x: 0, y: 0 }, { ghost: true, ghostOf: n.sid === undefined ? undefined : sugLabels.get(n.sid) }));
|
|
2031
|
-
for (const
|
|
2032
|
-
const
|
|
2033
|
-
const anchor = first ? ghostPosCache.get(first.id) : undefined;
|
|
2034
|
-
const firstEdge = gh.edges.find((e) => e.sid === s.id);
|
|
2035
|
-
const mid = firstEdge && posOf(firstEdge.from) && posOf(firstEdge.to) ? edgeGeometry(posOf(firstEdge.from)!, posOf(firstEdge.to)!).mid : undefined;
|
|
2036
|
-
const at = anchor ? { x: anchor.x, y: anchor.y + FLOW_GEOMETRY.nodeH + 4 } : mid;
|
|
2037
|
-
if (!at) continue;
|
|
2089
|
+
for (const item of suggestionBarLayout(gh)) {
|
|
2090
|
+
const { suggestion: s, at, width } = item;
|
|
2038
2091
|
const barFo = svg('foreignObject', FLOW_CLASS.fo);
|
|
2039
|
-
place(barFo, at,
|
|
2092
|
+
place(barFo, at, width, FLOW_GEOMETRY.barH);
|
|
2040
2093
|
const bar = el('div', FLOW_CLASS.bar, { role: 'group', 'data-flow-bar': s.id, 'aria-label': t('suggestion', { label: s.label }) });
|
|
2041
2094
|
barFo.appendChild(bar);
|
|
2042
2095
|
const cap = el('span', FLOW_CLASS.barCap);
|
|
@@ -2084,7 +2137,7 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
2084
2137
|
emptyOuter.className = empty ? '' : FLOW_CLASS.hidden;
|
|
2085
2138
|
emptyInner.textContent = bool(p.loading) ? t('loading') : cfg.readonly ? t('emptyReadonly') : t('empty');
|
|
2086
2139
|
|
|
2087
|
-
if (needFit && graph.nodes.length > 0 && stage.clientWidth > 0) fit();
|
|
2140
|
+
if (needFit && (graph.nodes.length > 0 || gh.nodes.length > 0) && stage.clientWidth > 0 && stage.clientHeight > 0) fit();
|
|
2088
2141
|
applyView();
|
|
2089
2142
|
|
|
2090
2143
|
const errors = [...issues.values()].flat().filter((i) => i.level === 'error').length;
|
|
@@ -2550,7 +2603,7 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
2550
2603
|
statusEl = el('p', FLOW_CLASS.status, { role: 'status', 'aria-live': 'polite' });
|
|
2551
2604
|
// 画布 + 右侧配置面板同一行;面板外层只管显隐,内层管样式
|
|
2552
2605
|
panelOuter = el('div', FLOW_CLASS.hidden);
|
|
2553
|
-
panelInner = el('div', FLOW_CLASS.panel, { role: 'region' });
|
|
2606
|
+
panelInner = el('div', FLOW_CLASS.panel, { role: 'region', 'data-kit-container': 'card' });
|
|
2554
2607
|
panelOuter.appendChild(panelInner);
|
|
2555
2608
|
panelId = '';
|
|
2556
2609
|
panelVals = '';
|
|
@@ -2592,6 +2645,30 @@ export function createFlowEditor(): SomaComponentDefinition {
|
|
|
2592
2645
|
on(root, 'contextmenu', onContextMenu as (e: Event) => void);
|
|
2593
2646
|
on(root, 'keydown', onKeydown as (e: Event) => void);
|
|
2594
2647
|
on(root, 'focusin', onFocusIn as (e: Event) => void);
|
|
2648
|
+
// 弹窗打开或容器尺寸变化后重新居中适配画布节点(避免挂载时 0×0 或弹窗显隐切换后节点沉底 / 出屏)
|
|
2649
|
+
const refitIfNeeded = (): void => {
|
|
2650
|
+
const { w, h } = stageSize();
|
|
2651
|
+
if (w <= 0 || h <= 0) return;
|
|
2652
|
+
if (graph.nodes.length === 0 && ghostsOf().nodes.length === 0) return;
|
|
2653
|
+
if (needFit || (!userAdjustedView && (w !== lastStageW || h !== lastStageH))) fit();
|
|
2654
|
+
};
|
|
2655
|
+
if (typeof IntersectionObserver === 'function') {
|
|
2656
|
+
const io = new IntersectionObserver((entries) => {
|
|
2657
|
+
if (entries.some((entry) => entry.isIntersecting)) refitIfNeeded();
|
|
2658
|
+
});
|
|
2659
|
+
io.observe(stage);
|
|
2660
|
+
removers.push(() => io.disconnect());
|
|
2661
|
+
}
|
|
2662
|
+
const win = root.ownerDocument.defaultView;
|
|
2663
|
+
if (win) {
|
|
2664
|
+
const onWinResize = (): void => refitIfNeeded();
|
|
2665
|
+
win.addEventListener('resize', onWinResize);
|
|
2666
|
+
removers.push(() => win.removeEventListener('resize', onWinResize));
|
|
2667
|
+
if (typeof win.requestAnimationFrame === 'function') {
|
|
2668
|
+
const rafId = win.requestAnimationFrame(() => refitIfNeeded());
|
|
2669
|
+
removers.push(() => win.cancelAnimationFrame(rafId));
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2595
2672
|
const port = dndPort();
|
|
2596
2673
|
if (port) {
|
|
2597
2674
|
offMove = port.onMove((intent) => {
|
package/src/data/footer.ts
CHANGED
|
@@ -12,10 +12,15 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
12
12
|
import { createKitController, joinClass } from '../base/shared';
|
|
13
13
|
import { classTokens, mk, rowsOf, textOf, type Rec } from './shape-util';
|
|
14
14
|
import { singleOf, urlOf } from './display-util';
|
|
15
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
16
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
17
|
+
import { KIT_DIVIDER_FOOT_CLASS } from '../recipes/divider';
|
|
15
18
|
|
|
16
19
|
const KEYS = ['brand', 'columns', 'copyright', 'social'] as const;
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
// 外缘 = 凹槽面的壳配方(容器边,KT-B2);底部版权行的线 = 分隔线出口
|
|
22
|
+
const ROOT_EDGE = kitShellRecipe({ tone: 'sunken', shadow: false });
|
|
23
|
+
const ROOT_CLASS = `@container flex flex-col gap-6 ${ROOT_EDGE} px-6 py-8 text-sm text-fg-muted`;
|
|
19
24
|
const TOP_CLASS = 'flex flex-col gap-6';
|
|
20
25
|
const BRAND_CLASS = 'text-lg font-semibold text-fg';
|
|
21
26
|
const GRID_CLASS = 'grid grid-cols-1 gap-6 @md:grid-cols-2 @xl:grid-cols-4';
|
|
@@ -24,7 +29,7 @@ const COL_TITLE_CLASS = 'text-xs font-semibold text-fg';
|
|
|
24
29
|
const LIST_CLASS = 'flex flex-col gap-1.5';
|
|
25
30
|
const LINK_CLASS = 'rounded-sm text-fg-muted underline-offset-2 transition-colors hover:text-fg hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring';
|
|
26
31
|
const PLAIN_CLASS = 'text-fg-subtle';
|
|
27
|
-
const BOTTOM_CLASS =
|
|
32
|
+
const BOTTOM_CLASS = `flex flex-col gap-3 ${KIT_DIVIDER_FOOT_CLASS} pt-4 @md:flex-row @md:items-center @md:justify-between`;
|
|
28
33
|
const COPY_CLASS = 'text-xs text-fg-subtle';
|
|
29
34
|
const SOCIAL_CLASS = 'flex flex-wrap items-center gap-2';
|
|
30
35
|
const SOCIAL_LINK_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md px-2 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
@@ -105,6 +110,7 @@ export function createFooter(): SomaComponentDefinition {
|
|
|
105
110
|
},
|
|
106
111
|
render(root, p) {
|
|
107
112
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
113
|
+
markKitEdge(root);
|
|
108
114
|
root.textContent = '';
|
|
109
115
|
const src = singleOf(p.data, p, KEYS);
|
|
110
116
|
const brand = textOf(src.brand);
|