soma-kit 0.1.12 → 0.1.13
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/README.md +5 -4
- package/bin/soma-kit.mjs +31 -1
- package/bin/soma.mjs +0 -0
- package/package.json +5 -4
- package/spec/generated/kit-app.schema.json +158 -4
- package/spec/generated/kit-page.schema.json +139 -5
- package/spec/kit-grammar.json +438 -87
- package/spec/kit-grammar.schema.json +11 -3
- package/src/app/app-config.ts +83 -5
- package/src/app/component-gate.ts +271 -13
- package/src/app/define-kit-app.ts +2 -2
- package/src/app/define-kit-view.ts +9 -5
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/index.ts +17 -5
- package/src/app/kit-view-context.ts +163 -14
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +3 -1
- package/src/app/server.ts +40 -3
- package/src/app/theme-runtime.ts +4 -0
- package/src/base/action-busy.ts +101 -4
- package/src/base/action-slots.ts +13 -2
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/button.ts +57 -12
- package/src/base/check-core.ts +8 -0
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +21 -2
- package/src/base/color-picker.ts +10 -5
- package/src/base/command-palette.ts +1 -1
- package/src/base/context-menu.ts +10 -7
- package/src/base/date-range.ts +7 -7
- package/src/base/date.ts +55 -16
- package/src/base/delta.ts +72 -0
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +1 -1
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/index.ts +27 -9
- package/src/base/listbox-core.ts +6 -5
- package/src/base/loading-gate.ts +140 -87
- package/src/base/mentions.ts +2 -1
- package/src/base/menu-button.ts +23 -12
- package/src/base/menu-core.ts +37 -8
- package/src/base/motion/hover-3d.ts +1 -1
- package/src/base/motion/marquee.ts +1 -1
- package/src/base/otp.ts +5 -4
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/popover.ts +9 -9
- package/src/base/popup.ts +67 -8
- package/src/base/portal-core.ts +4 -0
- package/src/base/qty-stepper.ts +5 -5
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +19 -2
- package/src/base/rating.ts +11 -6
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +24 -22
- package/src/base/shared.ts +169 -23
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +6 -6
- package/src/base/switch.ts +10 -5
- package/src/base/tag-input.ts +6 -6
- package/src/base/tag.ts +63 -33
- package/src/base/text.ts +42 -13
- package/src/base/time-picker.ts +7 -5
- package/src/base/tree-select.ts +6 -4
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +15 -10
- package/src/base/view-transition.ts +77 -0
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +2 -2
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +2 -1
- package/src/biz/checkout-page/shell.ts +4 -3
- package/src/biz/import-wizard/shell.ts +2 -1
- package/src/biz/link/hub.ts +23 -5
- package/src/biz/link/shared.ts +23 -12
- package/src/biz/master-sub/compile.ts +102 -10
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +4 -1
- package/src/biz/multi-board/shell.ts +8 -5
- package/src/biz/notification-center/shell.ts +6 -4
- package/src/biz/page-templates/result-page/shell.ts +2 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +2 -2
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +2 -1
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +6 -0
- package/src/biz/shared/compile-helpers.ts +18 -0
- package/src/biz/shared/coordinator.ts +7 -30
- package/src/biz/shared/index.ts +5 -0
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +139 -10
- package/src/biz/shared/pipes.ts +11 -5
- package/src/biz/shared/remove-wire.ts +4 -19
- package/src/biz/shared/runtime-hub.ts +10 -0
- package/src/biz/single-form/compile.ts +3 -2
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +22 -160
- package/src/biz/standard-crud/shell.ts +16 -44
- package/src/biz/step-form/shell.ts +5 -5
- package/src/cli/kit-cli.ts +138 -13
- package/src/cli/kit-init.ts +6 -1
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -0
- package/src/cli/view-writes.ts +69 -60
- package/src/compile/closed-set.ts +65 -4
- package/src/compile/compile-page.ts +51 -7
- package/src/compile/component-candidates.ts +12 -1
- package/src/compile/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -0
- package/src/compile/remove-guard.ts +10 -7
- package/src/compile/styles.ts +36 -8
- package/src/compile/types.ts +13 -1
- package/src/compile/view-check.ts +149 -16
- package/src/data/amount-breakdown.ts +6 -1
- package/src/data/approval-flow.ts +1 -1
- package/src/data/assignment-picker.ts +53 -27
- package/src/data/async-result-panel.ts +49 -3
- package/src/data/breadcrumbs.ts +3 -2
- package/src/data/calendar.ts +2 -2
- package/src/data/carousel.ts +8 -6
- package/src/data/chart.ts +141 -10
- package/src/data/checklist.ts +18 -5
- package/src/data/code-view.ts +8 -4
- package/src/data/comment-thread.ts +2 -2
- package/src/data/confirm-dialog.ts +71 -18
- package/src/data/context-menu.ts +3 -3
- package/src/data/dock.ts +1 -1
- package/src/data/embed.ts +231 -29
- package/src/data/field-mapper.ts +4 -4
- package/src/data/flow-editor-contract.ts +7 -0
- package/src/data/flow-editor.ts +25 -9
- package/src/data/flow-node-options.ts +33 -3
- package/src/data/gantt.ts +5 -2
- package/src/data/hero.ts +2 -1
- package/src/data/image-viewer.ts +7 -4
- package/src/data/index.ts +6 -1
- package/src/data/item-list.ts +18 -10
- package/src/data/kanban.ts +39 -10
- package/src/data/media-grid.ts +6 -1
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +45 -13
- package/src/data/mockup.ts +8 -4
- package/src/data/modal-dialog.ts +29 -9
- package/src/data/navbar.ts +5 -5
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +21 -6
- package/src/data/object-form.ts +354 -48
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +17 -7
- package/src/data/permission-matrix.ts +33 -11
- package/src/data/permission-tree.ts +47 -22
- package/src/data/pricing-table.ts +21 -11
- package/src/data/prompt-dialog.ts +165 -0
- package/src/data/reaction-bar.ts +6 -4
- package/src/data/record-card.ts +23 -2
- package/src/data/record-picker.ts +13 -7
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +17 -1
- package/src/data/row-editor.ts +79 -26
- package/src/data/rule-builder.ts +8 -8
- package/src/data/shape-util.ts +23 -9
- package/src/data/stat-group.ts +170 -29
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +2 -0
- package/src/data/steps.ts +8 -3
- package/src/data/survey.ts +3 -3
- package/src/data/system-switcher.ts +1 -1
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +17 -6
- package/src/data/tour-guide.ts +1 -1
- package/src/data/transfer.ts +36 -16
- package/src/data/tree-table.ts +62 -36
- package/src/data/tree.ts +22 -2
- package/src/data/virtual-rows.ts +19 -10
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/page-bar.ts +14 -13
- package/src/frames/page-status.ts +7 -5
- package/src/frames/shared.ts +15 -10
- package/src/frames/split-frame/shell.ts +1 -1
- package/src/frames/tabs-frame/shell.ts +2 -1
- package/src/frames/tabs-frame/wiring.ts +1 -0
- package/src/frames/top-main-frame.ts +2 -2
- package/src/frames/workspace-frame/extras.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +2 -2
- package/src/frames/workspace-frame/view.ts +141 -33
- package/src/generated/kit-grammar-runtime.ts +239 -55
- package/src/i18n/kit-text.ts +63 -4
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/object-renderer/arrange.ts +42 -8
- package/src/object-renderer/collection-parts.ts +241 -60
- package/src/object-renderer/collection-table.ts +109 -5
- package/src/object-renderer/collection.ts +174 -36
- package/src/object-renderer/compile-data.ts +28 -3
- package/src/object-renderer/defaults.ts +30 -2
- package/src/object-renderer/display-checks.ts +1 -1
- package/src/object-renderer/emit-events.ts +43 -9
- package/src/object-renderer/emit-static.ts +370 -30
- package/src/object-renderer/form-detail.ts +1 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/render-object.ts +54 -6
- package/src/object-renderer/request-actions.ts +4 -2
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +135 -27
- package/src/object-renderer/table-tools.ts +12 -11
- package/src/object-renderer/types.ts +78 -7
- package/src/object-renderer/view-binding.ts +205 -8
- package/src/page-target/intent-schema.ts +11 -0
- package/src/page-target/target.ts +5 -1
- package/src/recipes/container.ts +46 -1
- package/src/recipes/control.ts +70 -12
- package/src/recipes/index.ts +49 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +75 -17
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +34 -5
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +40 -3
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +13 -1
- package/src/shared/confirm-decl.ts +118 -0
- package/src/shared/envelope.ts +2 -2
- package/src/shared/paged-list-adapter.ts +15 -240
- package/src/shared/theme-runtime-shared.ts +6 -1
- package/src/theme/index.ts +1 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +372 -12
- package/src/theme/kit-theme.tpl +372 -12
- package/src/theme/nine-dim-structure.ts +177 -7
- package/src/theme/surface-layers.ts +4 -0
- package/src/theme/theme-tokens.ts +53 -13
- package/src/theme/theme-types.ts +32 -0
- package/src/biz/shared/remove-key.ts +0 -6
|
@@ -32,6 +32,8 @@ export interface KitHubEntry {
|
|
|
32
32
|
focusRow(): Record<string, unknown>;
|
|
33
33
|
/** 关掉当前打开的浮层(不问未保存修改:调用方是保存成功后的收尾) */
|
|
34
34
|
close?(): void;
|
|
35
|
+
/** 打开新建表单并带初值(展示对象 ctx.openCreate 用;初值盖在组件级预填之上,用户随后可改) */
|
|
36
|
+
openCreate?(prefill?: Record<string, unknown>): void;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** 按 scopeId / instanceId 索引的协调组件映射表(同 scope 多实例挂载时按栈保存,卸载时精确移除自身) */
|
|
@@ -227,6 +229,14 @@ export function closeKitHub(target?: string | HTMLElement): void {
|
|
|
227
229
|
resolveHub(target)?.close?.();
|
|
228
230
|
}
|
|
229
231
|
|
|
232
|
+
/** 在指定对象(或 scope)所属的协调组件上打开新建表单并带初值;没有协调组件 / 它不支持新建返回 false */
|
|
233
|
+
export function openKitHubCreate(target: string, prefill?: Record<string, unknown>): boolean {
|
|
234
|
+
const hub = resolveHub(target);
|
|
235
|
+
if (hub?.openCreate === undefined) return false;
|
|
236
|
+
hub.openCreate(prefill);
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
|
|
230
240
|
/** 页面上有没有协调组件登记(支持按 scope / 宿主查询;KitActionHost 据此决定刷新走协调组件还是直接重取动作所属对象) */
|
|
231
241
|
export function hasKitHub(target?: string | HTMLElement): boolean {
|
|
232
242
|
if (target !== undefined) return resolveHub(target) !== undefined;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { kitText } from '../../i18n/kit-text';
|
|
15
15
|
import { KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
16
16
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
17
|
+
import { savedNoticePipe } from '../../object-renderer/form-notify';
|
|
17
18
|
import { viewAnchor } from '../../object-renderer/emit-static';
|
|
18
19
|
import type { KitDiagnostic, KitObject, KitViewForm } from '../../object-renderer/types';
|
|
19
20
|
import type { KitFragment } from '../../compile/fragment';
|
|
@@ -110,8 +111,8 @@ export function compileSingleForm(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
110
111
|
return finishBizCompile(out, '');
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
//
|
|
114
|
-
out.events[`${formId}.saved`] =
|
|
114
|
+
// 写入成功:通知(单管道,文案可由 view.form.notify 字面量覆盖)。重取由 write.reload: self 完成;保存后的跳转等别的事归展示对象(ctx.onOutcome 订阅表单的写入结果)
|
|
115
|
+
out.events[`${formId}.saved`] = savedNoticePipe(formView, SAVED_NOTICE);
|
|
115
116
|
|
|
116
117
|
// 标题:string 两态通用;{ create, edit } 按有无读接口取
|
|
117
118
|
const t = formView.title;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// 底部固定的保存 / 重置栏是 KitObjectForm 的按钮行(actions 区),这里只给它一组 sticky 底栏类(经 classes.actions 传入)。
|
|
3
3
|
|
|
4
4
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
5
|
+
import { kitShellRecipe } from '../../recipes/container';
|
|
5
6
|
import { cls, esc } from '../link/shared';
|
|
6
7
|
|
|
7
8
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -10,12 +11,12 @@ export type SingleFormArea = (typeof SINGLE_FORM_AREAS)[number];
|
|
|
10
11
|
|
|
11
12
|
export const SINGLE_FORM_CLASS = {
|
|
12
13
|
root: '@container flex justify-center',
|
|
13
|
-
card: 'flex w-full max-w-2xl flex-col
|
|
14
|
+
card: mergeClass('flex w-full max-w-2xl flex-col', kitShellRecipe({ shadow: false })),
|
|
14
15
|
header: 'border-b border-border-subtle px-6 py-4',
|
|
15
16
|
title: 'text-lg font-semibold text-fg',
|
|
16
17
|
body: 'p-6',
|
|
17
|
-
/**
|
|
18
|
-
footer: 'sticky bottom-0 mt-4 flex flex-wrap items-end gap-2 border-t border-border-subtle bg-surface
|
|
18
|
+
/** 底栏:贴着可滚动祖先的底边,带分隔线与卡面底色(页面里的卡面 = bg-surface;写 raised 在暗色里比卡面亮一档,底栏成了一条亮带;浮层里的底栏另有 group 变体取浮层面) */
|
|
19
|
+
footer: 'sticky bottom-0 mt-4 flex flex-wrap items-end gap-2 border-t border-border-subtle bg-surface py-3',
|
|
19
20
|
} as const;
|
|
20
21
|
|
|
21
22
|
export function singleFormIds(pageId: string): { root: string } {
|
|
@@ -13,44 +13,32 @@
|
|
|
13
13
|
import { regionMirrorStatePath } from 'soma-core';
|
|
14
14
|
import { kitText } from '../../i18n/kit-text';
|
|
15
15
|
import type { SomaScopeDecl, SomaScopeMirrorDecl, SomaScopeSliceDecl } from 'soma-core';
|
|
16
|
-
import { KIT_GRAMMAR, KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
17
16
|
import { emitObject, type KitEmitResult } from '../../object-renderer/emit-object';
|
|
18
17
|
import { primaryKeyFieldOf } from '../../object-renderer/key-field';
|
|
19
18
|
import { actionPipeline, rowActionSlotsOf } from '../../object-renderer/emit-events';
|
|
20
|
-
import { isRequestLikeAction, registerRequestAction } from '../../object-renderer/request-actions';
|
|
21
19
|
import { checkExpandChild, expandHolderHtml, expandHostId } from '../../object-renderer/collection-expand';
|
|
22
20
|
import { ctxMenuAnchor, opsAnchor, rowsAnchor, staticCtxAnchor, toolbarAnchor, treeAnchor, viewAnchor, virtualAnchor } from '../../object-renderer/emit-static';
|
|
23
|
-
import type { KitAction, KitDiagnostic, KitObject,
|
|
21
|
+
import type { KitAction, KitDiagnostic, KitObject, KitViewForm } from '../../object-renderer/types';
|
|
24
22
|
import type { KitFragment } from '../../compile/fragment';
|
|
25
|
-
import type { KitBizContext, KitBizInput
|
|
26
|
-
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS,
|
|
23
|
+
import type { KitBizContext, KitBizInput } from '../types';
|
|
24
|
+
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS, rewriteRowActions, type KitRowActionRoute } from '../shared/coordinator';
|
|
25
|
+
import { KIT_CRUD_LINK_KEY, compileOverlay, normalizeOverlayView, validateOverlayNames } from '../shared/overlay-compile';
|
|
27
26
|
import {
|
|
28
27
|
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
29
28
|
} from '../shared/compile-helpers';
|
|
30
|
-
import { labelDiagnostics, newParts, normalizeList, type Parts } from '../link/shared';
|
|
31
|
-
import { busyActionOf } from '../../base/action-busy';
|
|
29
|
+
import { IDENT, labelDiagnostics, newParts, normalizeList, type Parts } from '../link/shared';
|
|
32
30
|
import { pipeTails, semanticPipe, wireDialogForm } from '../shared/pipes';
|
|
33
|
-
import {
|
|
31
|
+
import { removePipe } from '../shared/remove-wire';
|
|
34
32
|
import { KIT_ACTION_SLOT_BASE } from '../../base/action-slots';
|
|
35
33
|
import { StandardCrud } from './index';
|
|
36
34
|
import {
|
|
37
|
-
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
35
|
+
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, dialogWidthOf, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
38
36
|
} from './shell';
|
|
39
37
|
|
|
40
38
|
type Rec = Record<string, unknown>;
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/** 浮层里数据组件的约定事件 -> 角色(K-1) */
|
|
45
|
-
const OVERLAY_EVENT_ROLES: Record<string, string> = KIT_GRAMMAR.overlayEventRoles.conventional as Record<string, string>;
|
|
46
|
-
const OVERLAY_ROLE_SEMANTIC: Record<string, string> = {
|
|
47
|
-
saved: KIT_COORD_EVENTS.saved,
|
|
48
|
-
close: KIT_COORD_EVENTS.close,
|
|
49
|
-
reload: KIT_COORD_EVENTS.reload,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** 关联键镜像:当前行主键(附加对象的 from.params 引用) */
|
|
53
|
-
export const KIT_CRUD_LINK_KEY = 'crud_link';
|
|
40
|
+
/** 关联键镜像:当前行主键(附加对象的 from.params 引用);附加浮层的共用编译在 shared/overlay-compile.ts,这里原样 re-export */
|
|
41
|
+
export { KIT_CRUD_LINK_KEY };
|
|
54
42
|
|
|
55
43
|
function isRec(v: unknown): v is Rec {
|
|
56
44
|
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -85,17 +73,6 @@ function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagno
|
|
|
85
73
|
|
|
86
74
|
// ---------------------------------------------------------------- 浮层视图规整
|
|
87
75
|
|
|
88
|
-
/** 浮层的 view 允许直接写成一个视图(如 `staticComponent` 写在 view 下):list 型放 list 槽,single 型放 summary 槽 */
|
|
89
|
-
function normalizeOverlayView(view: unknown): KitView | undefined {
|
|
90
|
-
if (!isRec(view)) return undefined;
|
|
91
|
-
if (KIT_VIEW_SLOTS.some((s) => s in view)) return view as KitView;
|
|
92
|
-
if (Object.keys(view).some((k) => KIT_VIEW_FORM_KEYS.has(k))) {
|
|
93
|
-
const form = view as unknown as KitViewForm;
|
|
94
|
-
return form.accept === 'single' ? { summary: form } : { list: form };
|
|
95
|
-
}
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
76
|
// ---------------------------------------------------------------- 累积
|
|
100
77
|
|
|
101
78
|
function addEmit(into: Parts, r: KitEmitResult): void {
|
|
@@ -166,21 +143,8 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
166
143
|
}
|
|
167
144
|
|
|
168
145
|
const overlays = input.overlays ?? {};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
else if (name === 'entity') fail('KIT-PAGE-001', '附加浮层名不能叫 entity(与主对象角色槽同名)', `product.overlays.${name}`);
|
|
172
|
-
}
|
|
173
|
-
// E3:只读浮层的 editOverlay 必须指向另一个存在的浮层(点「编辑」切过去,当前行保留)
|
|
174
|
-
const showEdit: Record<string, string> = {};
|
|
175
|
-
for (const [name, decl] of Object.entries(overlays)) {
|
|
176
|
-
if (decl.editOverlay === undefined) continue;
|
|
177
|
-
const at = `product.overlays.${name}.editOverlay`;
|
|
178
|
-
if (typeof decl.editOverlay !== 'string' || !(decl.editOverlay in overlays) || decl.editOverlay === name) {
|
|
179
|
-
fail('KIT-BIZ-003', `浮层 ${name} 的 editOverlay "${String(decl.editOverlay)}" 必须是另一个已声明的浮层名`, at);
|
|
180
|
-
} else {
|
|
181
|
-
showEdit[name] = decl.editOverlay;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
146
|
+
// 浮层名 / editOverlay 校验与 MasterSub 同一份(shared/overlay-compile.ts)
|
|
147
|
+
const showEdit = validateOverlayNames(overlays, ['entity'], fail);
|
|
184
148
|
// 整行点击:至多一个浮层写 rowClick: true;点行 / 行聚焦按 Enter 以当前行打开它
|
|
185
149
|
const rowClickNames = Object.entries(overlays).filter(([, d]) => d.rowClick !== undefined && d.rowClick !== false).map(([n]) => n);
|
|
186
150
|
for (const [name, decl] of Object.entries(overlays)) {
|
|
@@ -351,115 +315,16 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
351
315
|
expandHolder = expandHolderHtml(expandHostId(object, name), childEmit.html, '');
|
|
352
316
|
continue;
|
|
353
317
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const ovObject = `${ctx.pageId}_${name}`;
|
|
365
|
-
const ovScope = `${ovObject}_scope`;
|
|
366
|
-
overlayObjects[name] = ovObject;
|
|
367
|
-
const linkKey = decl.behavior?.linkKey ?? keyField;
|
|
368
|
-
const params: Record<string, string> = { ...(decl.behavior?.params ?? {}) };
|
|
369
|
-
if (linkKey !== undefined && keyField !== undefined) params[linkKey] = `$${mirrorPath(scope, KIT_CRUD_LINK_KEY)}`;
|
|
370
|
-
const dynParams = Object.entries(params).filter(([, v]) => typeof v === 'string' && v.startsWith('$')).map(([k]) => k);
|
|
371
|
-
const reqParams = [...new Set([...(decl.behavior?.requireParams ?? []), ...(linkKey !== undefined && keyField !== undefined ? [linkKey] : []), ...dynParams])];
|
|
372
|
-
const ovObj: KitObject = {
|
|
373
|
-
schema: decl.schema ?? {},
|
|
374
|
-
behavior: {
|
|
375
|
-
...(decl.behavior ?? {}),
|
|
376
|
-
params,
|
|
377
|
-
...(reqParams.length > 0 ? { requireParams: reqParams } : {}),
|
|
378
|
-
},
|
|
379
|
-
view,
|
|
380
|
-
};
|
|
381
|
-
// K-9:浮层没有自己的读接口(无 behavior.from)时,当前行(协调组件 focus.row 的镜像)就是它的数据:
|
|
382
|
-
// 写死形状组件的 data、表单的 initial 都注入这一行,不必按主键回查
|
|
383
|
-
const rowPath = mirrorPath(scope, m.row.key);
|
|
384
|
-
const injectRow = decl.behavior?.from === undefined;
|
|
385
|
-
const ovEmit = labelDiagnostics(emitObject(
|
|
386
|
-
ovObj,
|
|
387
|
-
{ object: ovObject, scope: ovScope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
388
|
-
{ registeredActions: ctx.registeredActions, formMode: 'edit', ...(injectRow ? { summaryPath: rowPath } : {}) },
|
|
389
|
-
), ovObject);
|
|
390
|
-
addEmit(out, ovEmit);
|
|
391
|
-
if (decl.behavior?.from !== undefined) {
|
|
392
|
-
out.scopes[ovScope] = withScopeParts(out.scopes[ovScope], { id: ovScope, object: ovObject }, [], []);
|
|
393
|
-
}
|
|
394
|
-
// 浮层里的可编辑表单:编辑取回的单对象(或注入的当前行),保存后关窗并刷新
|
|
395
|
-
const ovFormId = viewAnchor(ovObject, 'form');
|
|
396
|
-
if (view.form !== undefined) {
|
|
397
|
-
patchProps(out.show, ovFormId, { mode: 'edit', initial: injectRow ? rowPath : `page.data.${ovObject}`, scope: `${ovObject}__form`, cancelLabel: CANCEL_LABEL });
|
|
398
|
-
wireDialogForm(out.events, ovFormId, scope);
|
|
399
|
-
}
|
|
400
|
-
// K-1 / M1-3:浮层里的写死形状数据组件(应用组件)按约定抛 saved / cancel / close / reload,由协调组件接;
|
|
401
|
-
// overlays.<名>.events 可再把自定义事件名映射到这四种之一。组件没抛的事件不会触发(core 对未声明的 emit 选择器惰性)
|
|
402
|
-
for (const slot of ['list', 'summary'] as const) {
|
|
403
|
-
const staticComp = view[slot]?.staticComponent;
|
|
404
|
-
if (staticComp === undefined) continue;
|
|
405
|
-
const knownEmits = ctx.staticComponents[staticComp]?.emits;
|
|
406
|
-
const explicitEvents = decl.events ?? {};
|
|
407
|
-
const anchor = viewAnchor(ovObject, slot);
|
|
408
|
-
// 接了具名动作的事件:编完后自动带上该动作的 busy 绑定(手写 busy_action 优先)
|
|
409
|
-
const namedOn: Record<string, string> = {};
|
|
410
|
-
for (const [emitName, role] of Object.entries<string | KitOverlayEventAction>({ ...OVERLAY_EVENT_ROLES, ...explicitEvents })) {
|
|
411
|
-
if (!(emitName in explicitEvents) && knownEmits !== undefined && !knownEmits.includes(emitName)) continue;
|
|
412
|
-
if (typeof role !== 'string') {
|
|
413
|
-
// { action }:绑一条具名动作 / request / download 管道;动作之后的提示 / 重取 / 关窗写在具名动作处理函数里
|
|
414
|
-
const epath = `${at}.events.${emitName}`;
|
|
415
|
-
if (!isRec(role) || typeof role.action !== 'string' || role.action === '') {
|
|
416
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} 必须是角色名或 { action }`, epath);
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
// action 可以是主对象 behavior.actions 里的 request / download 动作 id(声明式请求,交页面级 KitActionHost),否则必须是登记的具名动作
|
|
420
|
-
const declared = actions.find((a) => a.id === role.action && isRequestLikeAction(a));
|
|
421
|
-
let actionPipe = `ACTION | ${role.action}`;
|
|
422
|
-
if (declared !== undefined) {
|
|
423
|
-
// 请求由宿主异步执行:浮层事件绑的请求是这个浮层的「提交」,成功后由宿主固定关窗并重取(失败时窗口保留,编辑不丢)
|
|
424
|
-
const registered = registerRequestAction(declared, object, `${epath}.action`, out.diagnostics, { closeOnSuccess: true });
|
|
425
|
-
if (registered === null) continue;
|
|
426
|
-
actionPipe = registered;
|
|
427
|
-
} else if (!ctx.registeredActions.has(role.action)) {
|
|
428
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName}.action "${role.action}" 未在应用的具名动作中登记`, `${epath}.action`);
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
const extra = Object.keys(role).filter((k) => k !== 'action');
|
|
432
|
-
if (extra.length > 0) {
|
|
433
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} 只许 action 键(多余:${extra.join(' / ')};动作之后的事写在具名动作处理函数里)`, epath);
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
out.events[`${anchor}.${emitName}`] = actionPipe;
|
|
437
|
-
namedOn[emitName] = role.action;
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
const sem = OVERLAY_ROLE_SEMANTIC[role];
|
|
441
|
-
if (sem === undefined) {
|
|
442
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} = "${role}" 不在 ${Object.keys(OVERLAY_ROLE_SEMANTIC).join(' / ')} 内`, `${at}.events.${emitName}`);
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
out.events[`${anchor}.${emitName}`] = semanticPipe(scope, sem);
|
|
446
|
-
}
|
|
447
|
-
const busyNames = busyActionOf(view[slot]!.staticComponent!, namedOn);
|
|
448
|
-
const shown = out.show[anchor];
|
|
449
|
-
if (busyNames !== null && isRec(shown) && isRec(shown.props) && shown.props.busy_action === undefined) {
|
|
450
|
-
patchProps(out.show, anchor, { busy_action: busyNames });
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
const ids = overlayIds(object, name);
|
|
454
|
-
overlayMirrors.push({ key: overlayMirrorKey(name), slice: 'focus', path: `ov.${name}`, as: 'truthy' });
|
|
455
|
-
out.show[ids.layer] = { when: mirrorPath(scope, overlayMirrorKey(name)) };
|
|
456
|
-
out.events[`${ids.close}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.close);
|
|
457
|
-
const withEdit = name in showEdit;
|
|
458
|
-
if (withEdit) {
|
|
459
|
-
out.show[ids.edit] = { props: { label: EDIT_COPY, variant: 'neutral', size: 'sm' } };
|
|
460
|
-
out.events[`${ids.edit}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.showEdit);
|
|
461
|
-
}
|
|
462
|
-
overlayHtmls.push(overlayHtml(ids, decl.kind, decl.title ?? name, ovEmit.html, decl.class, areaClass, withEdit, CLOSE_LABEL));
|
|
318
|
+
// dialog / drawer 浮层的共用编译(shared/overlay-compile.ts,与 MasterSub 同一份)
|
|
319
|
+
const compiled = compileOverlay(
|
|
320
|
+
{ out, ctx, scope, object, keyField, actions, areaClass, closeLabel: CLOSE_LABEL, cancelLabel: CANCEL_LABEL, editLabel: EDIT_COPY, showEdit },
|
|
321
|
+
name,
|
|
322
|
+
decl,
|
|
323
|
+
);
|
|
324
|
+
if (compiled === undefined) continue;
|
|
325
|
+
overlayObjects[name] = compiled.object;
|
|
326
|
+
overlayMirrors.push(compiled.mirror);
|
|
327
|
+
overlayHtmls.push(compiled.html);
|
|
463
328
|
}
|
|
464
329
|
|
|
465
330
|
// 主对象作用域:补 focus 切片(owner 是协调组件)与镜像
|
|
@@ -474,12 +339,9 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
474
339
|
);
|
|
475
340
|
|
|
476
341
|
// ---- 壳
|
|
477
|
-
const removeConfirms = removeConfirmTemplates(actions);
|
|
478
342
|
out.show[coordinatorId(object)] = {
|
|
479
343
|
props: {
|
|
480
344
|
scope, object, keyField: keyField ?? '', reloads: [], overlays: overlayObjects, showEdit, rowsPath: entityEmit.compiled.listShape.rows, ...(expandObject !== '' ? { expandObject } : {}),
|
|
481
|
-
// 带行占位的删除确认:动作 id -> 确认文案模板(运行期按被删行插值)
|
|
482
|
-
...(Object.keys(removeConfirms).length > 0 ? { removeConfirms } : {}),
|
|
483
345
|
overlayActions: {
|
|
484
346
|
...Object.fromEntries(actions.filter((a) => a.builtin === 'openOverlay' && a.targetOverlay !== undefined).map((a) => [a.id, a.targetOverlay as string])),
|
|
485
347
|
...(rowClickName !== undefined ? { select: rowClickName } : {}),
|
|
@@ -496,7 +358,7 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
496
358
|
out.events[`${ids.dialogClose}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.close);
|
|
497
359
|
// K-7:form 视图的 title(字符串两态通用,或 { create, edit })覆写弹窗标题;缺省取动作名
|
|
498
360
|
const titles = dialogTitles((entity.view?.form as KitViewForm | undefined)?.title, { create: createCopy, edit: editCopy });
|
|
499
|
-
dialog = dialogHtml(ids, titles, entityEmit.parts.form ?? '', areaClass, CLOSE_LABEL);
|
|
361
|
+
dialog = dialogHtml(ids, titles, entityEmit.parts.form ?? '', areaClass, CLOSE_LABEL, '', dialogWidthOf({ form: entity.view?.form, schema: entity.schema }));
|
|
500
362
|
}
|
|
501
363
|
|
|
502
364
|
const main = mainHtml({ filter: entityEmit.parts.filter ?? '', toolbar: entityEmit.parts.toolbar ?? '', list: listHtml }, areaClass);
|
|
@@ -4,11 +4,12 @@ import { esc } from '../../shared/escape';
|
|
|
4
4
|
// 显隐层统一用 `fixed inset-0` 的遮罩 + 内层 flex 容器:显隐只靠 core 写 `hidden` 属性,不在遮罩自身叠 display 类。
|
|
5
5
|
|
|
6
6
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { kitShellRecipe } from '../../recipes/container';
|
|
8
|
+
import { filterToolbarRow } from '../shared/compile-helpers';
|
|
9
|
+
import { OVERLAY_SHELL_CLASS, classAttr, closeButtonHtml, dialogHtml, dialogIds, dialogIsWide, dialogTitles, dialogWidthOf, overlayHtml, overlayIds } from '../shared/overlay-shell';
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
export { closeButtonHtml, dialogHtml, dialogIds, dialogTitles };
|
|
11
|
+
// 弹窗外壳与附加浮层壳的公共部分已下沉到 biz/shared/overlay-shell(主从工作台同用);这里原样 re-export,保持原导出名可用
|
|
12
|
+
export { closeButtonHtml, dialogHtml, dialogIds, dialogIsWide, dialogTitles, dialogWidthOf, overlayHtml, overlayIds };
|
|
12
13
|
|
|
13
14
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
14
15
|
export const STANDARD_CRUD_AREAS = ['root', 'filter', 'list', 'dialog', 'drawer'] as const;
|
|
@@ -16,16 +17,17 @@ export type StandardCrudArea = (typeof STANDARD_CRUD_AREAS)[number];
|
|
|
16
17
|
|
|
17
18
|
export const CRUD_CLASS = {
|
|
18
19
|
root: 'flex flex-col gap-3',
|
|
19
|
-
filter: '
|
|
20
|
-
list: '
|
|
20
|
+
filter: mergeClass('p-4', kitShellRecipe({ tone: 'base', shadow: false })),
|
|
21
|
+
list: mergeClass('p-4 flex flex-col gap-3', kitShellRecipe({ tone: 'base', shadow: false })),
|
|
21
22
|
listHeadRow: 'flex flex-wrap items-center justify-between gap-2',
|
|
22
23
|
...OVERLAY_SHELL_CLASS,
|
|
23
24
|
} as const;
|
|
24
25
|
|
|
25
26
|
const cls = classAttr;
|
|
26
27
|
|
|
28
|
+
// 协作宿主(KitCrudBridge)没有界面:class=hidden 让它不占 flex 子项的位(否则根的 flex gap 为它多量出一份间距)
|
|
27
29
|
function host(component: string, id: string): string {
|
|
28
|
-
return `<div data-soma-component="${component}" data-soma-id="${esc(id)}"></div>`;
|
|
30
|
+
return `<div data-soma-component="${component}" data-soma-id="${esc(id)}" class="hidden"></div>`;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export interface CrudShellIds {
|
|
@@ -38,13 +40,6 @@ export interface CrudShellIds {
|
|
|
38
40
|
dialogClose: string;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
export function overlayIds(object: string, name: string): { layer: string; title: string; close: string; edit: string } {
|
|
42
|
-
return {
|
|
43
|
-
layer: `${object}__ov_${name}_layer`, title: `${object}__ov_${name}_title`, close: `${object}__ov_${name}_close`,
|
|
44
|
-
edit: `${object}__ov_${name}_edit`,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
43
|
export function rootId(object: string): string {
|
|
49
44
|
return `${object}__crud_root`;
|
|
50
45
|
}
|
|
@@ -58,10 +53,14 @@ const LIST_TITLE_RE = /^(<h3\b[^>]*__list__title"[^>]*>[\s\S]*?<\/h3>)([\s\S]*)$
|
|
|
58
53
|
|
|
59
54
|
export function mainHtml(parts: { filter: string; toolbar: string; list: string }, areaClass: Record<string, string>): string {
|
|
60
55
|
const blocks: string[] = [];
|
|
61
|
-
if (parts.filter !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${parts.filter}</section>`);
|
|
62
|
-
let listInner = '';
|
|
63
56
|
const m = parts.toolbar !== '' ? LIST_TITLE_RE.exec(parts.list) : null;
|
|
64
|
-
|
|
57
|
+
// 没有列表标题、又有筛选区:主操作并入筛选区那一行靠右(不再在列表卡里独占一行)
|
|
58
|
+
const toolbarInFilter = parts.toolbar !== '' && m === null && parts.filter !== '';
|
|
59
|
+
if (parts.filter !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${toolbarInFilter ? filterToolbarRow(parts.filter, parts.toolbar) : parts.filter}</section>`);
|
|
60
|
+
let listInner = '';
|
|
61
|
+
if (toolbarInFilter) {
|
|
62
|
+
listInner = parts.list;
|
|
63
|
+
} else if (m !== null) {
|
|
65
64
|
const titleH3 = m[1]!.replace(/\bmb-\d+(?:\.\d+)?\s*/g, '');
|
|
66
65
|
const restList = m[2]!;
|
|
67
66
|
listInner = [`<div${cls(CRUD_CLASS.listHeadRow)}>${titleH3}${parts.toolbar}</div>`, restList].filter((p) => p !== '').join('\n');
|
|
@@ -72,33 +71,6 @@ export function mainHtml(parts: { filter: string; toolbar: string; list: string
|
|
|
72
71
|
return blocks.join('\n');
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
/** 附加浮层(dialog / drawer):`panelClass` 是声明里的 `class`,按同族规则覆写基准 */
|
|
76
|
-
export function overlayHtml(
|
|
77
|
-
ids: ReturnType<typeof overlayIds>,
|
|
78
|
-
kind: 'dialog' | 'drawer',
|
|
79
|
-
title: string,
|
|
80
|
-
body: string,
|
|
81
|
-
panelClass: string | undefined,
|
|
82
|
-
areaClass: Record<string, string>,
|
|
83
|
-
withEdit = false,
|
|
84
|
-
closeLabel = 'Close',
|
|
85
|
-
footer = '',
|
|
86
|
-
): string {
|
|
87
|
-
const isDrawer = kind === 'drawer';
|
|
88
|
-
const base = isDrawer ? CRUD_CLASS.drawer : CRUD_CLASS.dialog;
|
|
89
|
-
const panel = mergeClass(mergeClass(base, areaClass[kind]), panelClass);
|
|
90
|
-
return `<div data-soma-id="${esc(ids.layer)}">`
|
|
91
|
-
+ `<div data-kit-scrim="" ${KIT_FIXED_ATTRIBUTE}=""${cls(isDrawer ? CRUD_CLASS.drawerRow : CRUD_CLASS.dialogRow)}>`
|
|
92
|
-
+ `<div role="dialog" aria-modal="true"${cls(panel)} data-kit-part="${isDrawer ? KIT_PART_DRAWER : KIT_PART_DIALOG}" aria-labelledby="${esc(ids.title)}">`
|
|
93
|
-
+ `<div data-kit-overlay-header=""${cls(CRUD_CLASS.header)}>`
|
|
94
|
-
+ `<h2 id="${esc(ids.title)}" data-soma-id="${esc(ids.title)}"${cls(CRUD_CLASS.title)} data-kit-part="${KIT_PART_TITLE_DIALOG}">${esc(title)}</h2>`
|
|
95
|
-
+ (withEdit ? `<div${cls(CRUD_CLASS.headerActions)}>${host('Button', ids.edit)}${closeButtonHtml(ids.close, closeLabel)}</div>` : closeButtonHtml(ids.close, closeLabel))
|
|
96
|
-
+ '</div>'
|
|
97
|
-
+ `<div data-kit-overlay-body=""${cls(CRUD_CLASS.body)}>${body}</div>`
|
|
98
|
-
+ (footer !== '' ? `<div data-kit-overlay-footer=""${cls(CRUD_CLASS.footer)}>${footer}</div>` : '')
|
|
99
|
-
+ '</div></div></div>';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
74
|
export function rootHtml(object: string, children: string[], areaClass: Record<string, string>, extra: string | undefined): string {
|
|
103
75
|
const klass = mergeClass(mergeClass(CRUD_CLASS.root, areaClass.root), extra);
|
|
104
76
|
return `<div data-soma-id="${esc(rootId(object))}"${cls(klass)}>\n${children.filter((c) => c !== '').join('\n')}\n</div>`;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// 显隐规则:面板 / 步骤条变体都是「外层只放 core 写的 hidden、内层放布局类」两层;各步表单一直挂着,只靠外层显隐切换。
|
|
4
4
|
|
|
5
5
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
6
|
+
import { kitShellRecipe } from '../../recipes/container';
|
|
6
7
|
import { cls, esc, host } from '../link/shared';
|
|
7
|
-
import { kitText } from '../../i18n/kit-text';
|
|
8
8
|
import { kitIconHtml } from '../../base/icons';
|
|
9
9
|
|
|
10
10
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -13,7 +13,7 @@ export type StepFormArea = (typeof STEP_FORM_AREAS)[number];
|
|
|
13
13
|
|
|
14
14
|
export const STEP_FORM_CLASS = {
|
|
15
15
|
root: '@container flex justify-center',
|
|
16
|
-
card: 'flex w-full max-w-2xl flex-col gap-6
|
|
16
|
+
card: mergeClass('flex w-full max-w-2xl flex-col gap-6 p-6', kitShellRecipe()),
|
|
17
17
|
title: 'text-lg font-semibold text-fg',
|
|
18
18
|
steps: 'flex flex-wrap items-center gap-2',
|
|
19
19
|
stepItem: 'flex items-center gap-2',
|
|
@@ -26,7 +26,6 @@ export const STEP_FORM_CLASS = {
|
|
|
26
26
|
labelFut: 'text-sm text-fg-muted',
|
|
27
27
|
joint: 'w-6 border-t border-border-subtle',
|
|
28
28
|
panel: 'flex flex-col gap-3',
|
|
29
|
-
progress: 'text-sm text-fg-muted',
|
|
30
29
|
panelTitle: 'text-base font-semibold text-fg',
|
|
31
30
|
done: 'flex flex-col items-start gap-3',
|
|
32
31
|
doneTitle: 'text-lg font-semibold text-fg',
|
|
@@ -67,7 +66,7 @@ export function stepFormHtml(
|
|
|
67
66
|
parts: { title: string; steps: StepBlock[]; doneTitle: string; /** abandon: delete 才有:每个面板放一个「取消」钮 */ withAbort?: boolean },
|
|
68
67
|
areaClass: Record<string, string>,
|
|
69
68
|
extra: string | undefined,
|
|
70
|
-
|
|
69
|
+
_locale?: string,
|
|
71
70
|
): string {
|
|
72
71
|
const total = parts.steps.length;
|
|
73
72
|
const C = STEP_FORM_CLASS;
|
|
@@ -84,7 +83,8 @@ export function stepFormHtml(
|
|
|
84
83
|
});
|
|
85
84
|
const bar = `<nav aria-label="steps"${cls(mergeClass(C.steps, areaClass.steps))}>${items.join('')}</nav>`;
|
|
86
85
|
const panels = parts.steps.map((s, i) => {
|
|
87
|
-
|
|
86
|
+
// 步骤条已表达进度,面板头只放步骤标题(不再有「第 n 步 / 共 m 步」)
|
|
87
|
+
const head = `<h3${cls(C.panelTitle)}>${esc(s.title)}</h3>`;
|
|
88
88
|
return `<div data-soma-id="${esc(ids.panel(i))}"><div${cls(mergeClass(C.panel, areaClass.panel))}>${head}${s.form}${parts.withAbort === true ? host('Button', ids.abort(i)) : ''}</div></div>`;
|
|
89
89
|
});
|
|
90
90
|
const done = `<div data-soma-id="${esc(ids.done)}"><div${cls(mergeClass(C.done, areaClass.done))}>`
|