soma-kit 0.1.11 → 0.1.12
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 +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1473
|
@@ -8,26 +8,31 @@
|
|
|
8
8
|
// 写入成功 表单 saved -> semantic kit_saved -> 协调组件关窗 + services.data.reload
|
|
9
9
|
// 删除 builtin remove -> semantic kit_remove -> 协调组件调 services.data.remove(对象需声明 write.delete)后重取
|
|
10
10
|
//
|
|
11
|
-
//
|
|
11
|
+
// 行操作每个动作各抛各的槽位事件(见 base/action-slots.ts),各绑一条单管道,尾段(confirm / permission)由 core 在该管道上执行。
|
|
12
12
|
|
|
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
16
|
import { KIT_GRAMMAR, KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
17
17
|
import { emitObject, type KitEmitResult } from '../../object-renderer/emit-object';
|
|
18
|
-
import {
|
|
18
|
+
import { primaryKeyFieldOf } from '../../object-renderer/key-field';
|
|
19
|
+
import { actionPipeline, rowActionSlotsOf } from '../../object-renderer/emit-events';
|
|
19
20
|
import { isRequestLikeAction, registerRequestAction } from '../../object-renderer/request-actions';
|
|
20
21
|
import { checkExpandChild, expandHolderHtml, expandHostId } from '../../object-renderer/collection-expand';
|
|
21
22
|
import { ctxMenuAnchor, opsAnchor, rowsAnchor, staticCtxAnchor, toolbarAnchor, treeAnchor, viewAnchor, virtualAnchor } from '../../object-renderer/emit-static';
|
|
22
23
|
import type { KitAction, KitDiagnostic, KitObject, KitView, KitViewForm } from '../../object-renderer/types';
|
|
23
24
|
import type { KitFragment } from '../../compile/fragment';
|
|
24
25
|
import type { KitBizContext, KitBizInput, KitOverlayEventAction } from '../types';
|
|
25
|
-
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS, overlayMirrorKey,
|
|
26
|
-
import {
|
|
26
|
+
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS, overlayMirrorKey, rewriteRowActions, type KitRowActionRoute } from '../shared/coordinator';
|
|
27
|
+
import {
|
|
28
|
+
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
29
|
+
} from '../shared/compile-helpers';
|
|
30
|
+
import { labelDiagnostics, newParts, normalizeList, type Parts } from '../link/shared';
|
|
27
31
|
import { busyActionOf } from '../../base/action-busy';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
32
|
+
import { pipeTails, semanticPipe, wireDialogForm } from '../shared/pipes';
|
|
33
|
+
import { removeConfirmTemplates, removePipe } from '../shared/remove-wire';
|
|
34
|
+
import { KIT_ACTION_SLOT_BASE } from '../../base/action-slots';
|
|
35
|
+
import { StandardCrud } from './index';
|
|
31
36
|
import {
|
|
32
37
|
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
33
38
|
} from './shell';
|
|
@@ -53,22 +58,16 @@ function isRec(v: unknown): v is Rec {
|
|
|
53
58
|
|
|
54
59
|
/** 主对象名:`${槽名}_entity`,槽名即 pageId(保留名由编译器前置校验) */
|
|
55
60
|
export function crudObjectName(pageId: string): string {
|
|
56
|
-
return
|
|
61
|
+
return bizObjectName(pageId, 'entity');
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
function mirrorPath(scope: string, key: string): string {
|
|
60
65
|
return regionMirrorStatePath(scope, key);
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
function keyFieldOf(obj: KitObject): string | undefined {
|
|
64
|
-
const hit = Object.entries(obj.schema).find(([, f]) => f.key === true)?.[0];
|
|
65
|
-
if (hit !== undefined) return hit;
|
|
66
|
-
return 'id' in obj.schema ? 'id' : undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
68
|
// ---------------------------------------------------------------- 动作
|
|
70
69
|
|
|
71
|
-
//
|
|
70
|
+
// 行操作各抛各的槽位事件 row_action_<序号>,每个动作各绑一条管道;具名动作做完的重取由 defineKitActions 在有协调组件的页面里固定执行。
|
|
72
71
|
|
|
73
72
|
/** 一个行动作的单管道(尾段由 pipeTails 给);返回 null 表示该动作不是本壳解释的、交 actionPipeline */
|
|
74
73
|
function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagnostic[]): string | null {
|
|
@@ -76,8 +75,8 @@ function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagno
|
|
|
76
75
|
switch (a.builtin) {
|
|
77
76
|
case 'openEdit': return semanticPipe(scope, KIT_COORD_EVENTS.openEdit, tails());
|
|
78
77
|
case 'openOverlay': return semanticPipe(scope, KIT_COORD_EVENTS.openOverlay, tails());
|
|
79
|
-
// 带行占位的确认({字段})由 KitCrudBridge
|
|
80
|
-
case 'remove': return
|
|
78
|
+
// 带行占位的确认({字段})由 KitCrudBridge 按被删行插值后再问:尾段规则在 shared/remove-wire.ts(与 link 系共用)
|
|
79
|
+
case 'remove': return removePipe(scope, a, at, diagnostics);
|
|
81
80
|
// K-2:刷新内置动作,经协调组件重取
|
|
82
81
|
case 'reload': return semanticPipe(scope, KIT_COORD_EVENTS.reload, tails());
|
|
83
82
|
default: return null;
|
|
@@ -99,16 +98,6 @@ function normalizeOverlayView(view: unknown): KitView | undefined {
|
|
|
99
98
|
|
|
100
99
|
// ---------------------------------------------------------------- 累积
|
|
101
100
|
|
|
102
|
-
interface Parts {
|
|
103
|
-
show: Rec;
|
|
104
|
-
data: Rec;
|
|
105
|
-
scopes: Record<string, SomaScopeDecl>;
|
|
106
|
-
events: Rec;
|
|
107
|
-
components: Set<string>;
|
|
108
|
-
candidates: Set<string>;
|
|
109
|
-
diagnostics: KitDiagnostic[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
101
|
function addEmit(into: Parts, r: KitEmitResult): void {
|
|
113
102
|
Object.assign(into.show, r.ui.show);
|
|
114
103
|
Object.assign(into.data, r.ui.data);
|
|
@@ -136,22 +125,6 @@ function patchProps(show: Rec, id: string, props: Rec): boolean {
|
|
|
136
125
|
return true;
|
|
137
126
|
}
|
|
138
127
|
|
|
139
|
-
function finish(out: Parts, html: string): KitFragment {
|
|
140
|
-
return {
|
|
141
|
-
html,
|
|
142
|
-
ui: {
|
|
143
|
-
data: out.data,
|
|
144
|
-
// 键 = 作用域 id;core 的 `scopes:` 是数组,编译器输出 `_ui.yaml` 时取 Object.values
|
|
145
|
-
scopes: out.scopes as unknown as Record<string, unknown>,
|
|
146
|
-
show: out.show,
|
|
147
|
-
},
|
|
148
|
-
events: out.events,
|
|
149
|
-
components: [...out.components].sort(),
|
|
150
|
-
candidates: [...out.candidates].sort(),
|
|
151
|
-
diagnostics: out.diagnostics,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
128
|
// ---------------------------------------------------------------- 主函数
|
|
156
129
|
|
|
157
130
|
export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
@@ -159,35 +132,32 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
159
132
|
const EDIT_COPY = kitText('soma.kit.edit', undefined, ctx.locale);
|
|
160
133
|
const CLOSE_LABEL = kitText('soma.kit.close', undefined, ctx.locale);
|
|
161
134
|
const CANCEL_LABEL = kitText('soma.kit.cancel', undefined, ctx.locale);
|
|
162
|
-
const out
|
|
163
|
-
show: {}, data: {}, scopes: {}, events: {},
|
|
164
|
-
components: new Set<string>(['Button', 'KitCrudBridge']),
|
|
165
|
-
candidates: new Set<string>(),
|
|
166
|
-
diagnostics: [],
|
|
167
|
-
};
|
|
135
|
+
const out = newParts(['Button', 'KitCrudBridge']);
|
|
168
136
|
const fail = (code: string, message: string, path: string): void => { out.diagnostics.push({ code, message, path }); };
|
|
169
137
|
|
|
170
138
|
const rawEntity = input.objects.entity;
|
|
171
139
|
if (!isRec(rawEntity) || !isRec(rawEntity.schema) || !isRec(rawEntity.behavior)) {
|
|
172
140
|
fail('KIT-BIZ-001', 'StandardCrud 缺少必填对象角色槽 entity(需含 schema 与 behavior)', 'product.objects.entity');
|
|
173
|
-
return
|
|
141
|
+
return finishBizCompile(out, '');
|
|
174
142
|
}
|
|
175
143
|
const entityRaw = rawEntity as unknown as KitObject;
|
|
176
144
|
const entity: KitObject = isRec(entityRaw.view) && isRec((entityRaw.view as Rec).list)
|
|
177
145
|
? { ...entityRaw, view: { ...entityRaw.view, list: normalizeList((entityRaw.view as Rec).list as KitViewForm & Rec) } }
|
|
178
146
|
: entityRaw;
|
|
179
|
-
|
|
180
|
-
if (!(STANDARD_CRUD_AREAS as readonly string[]).includes(key)) {
|
|
181
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 StandardCrud 的区域闭集 ${STANDARD_CRUD_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
147
|
+
validateBizAreaClass(input, 'StandardCrud', STANDARD_CRUD_AREAS, out.diagnostics);
|
|
184
148
|
const areaClass = input.areaClass ?? {};
|
|
185
149
|
|
|
186
150
|
const object = crudObjectName(ctx.pageId);
|
|
187
151
|
const scope = `${object}_scope`;
|
|
188
|
-
const keyField =
|
|
152
|
+
const keyField = primaryKeyFieldOf(entity.schema);
|
|
189
153
|
const actions = entity.behavior.actions ?? [];
|
|
190
154
|
|
|
155
|
+
const listColl = isRec(entity.view) && isRec((entity.view as Rec).list) ? ((entity.view as Rec).list as Rec).collection : undefined;
|
|
156
|
+
const expandDecl = isRec(listColl) && isRec(listColl.expand) ? listColl.expand : undefined;
|
|
157
|
+
if (!(expandDecl !== undefined && expandDecl.view === 'summary')) {
|
|
158
|
+
checkRoleAllowedViews('entity', entity, StandardCrud.roles.entity, out.diagnostics, 'product.objects.entity');
|
|
159
|
+
}
|
|
160
|
+
|
|
191
161
|
const hasList = entity.view?.list !== undefined;
|
|
192
162
|
const hasForm = entity.view?.form !== undefined;
|
|
193
163
|
if (!hasList) fail('KIT-BIZ-001', 'StandardCrud 的 entity 必须有 list 视图(主列表)', 'product.objects.entity.view.list');
|
|
@@ -233,12 +203,10 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
233
203
|
fail('KIT-EVT-001', `动作 ${a.id}:${a.builtin} 只能是行操作(要带当前行)`, at);
|
|
234
204
|
}
|
|
235
205
|
});
|
|
236
|
-
if (out.diagnostics.length > 0) return
|
|
206
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
237
207
|
|
|
238
208
|
// ---- 展开行子表(Q 波 G5):kind: expand 的附加对象不画浮层,由 entity 的 collection.expand.list 引用
|
|
239
209
|
const expandNames = new Set(Object.entries(overlays).filter(([, d]) => d.kind === 'expand').map(([n]) => n));
|
|
240
|
-
const listColl = isRec(entity.view) && isRec((entity.view as Rec).list) ? ((entity.view as Rec).list as Rec).collection : undefined;
|
|
241
|
-
const expandDecl = isRec(listColl) && isRec(listColl.expand) ? listColl.expand : undefined;
|
|
242
210
|
const expandRef = expandDecl !== undefined && typeof expandDecl.list === 'string' && typeof expandDecl.link === 'string' && expandNames.has(expandDecl.list)
|
|
243
211
|
? { list: expandDecl.list, link: expandDecl.link }
|
|
244
212
|
: undefined;
|
|
@@ -278,27 +246,19 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
278
246
|
|
|
279
247
|
// 工具栏:openCreate 改走语义事件
|
|
280
248
|
let createCopy = CREATE_COPY;
|
|
281
|
-
// GA5:带 prefill 的「新建」钮各占一个语义事件,协调组件按事件名查预填表(事件名 -> { 字段: $filter.x | 字面量 })
|
|
282
|
-
const createPrefills: Record<string, Record<string, unknown>> = {};
|
|
283
249
|
actions.forEach((a, i) => {
|
|
284
250
|
if (a.on !== 'toolbar') return;
|
|
285
251
|
const at = `behavior.actions[${i}]`;
|
|
286
252
|
const click = `${toolbarAnchor(object, a.id)}.click`;
|
|
287
253
|
if (a.builtin === 'openCreate') {
|
|
288
254
|
createCopy = a.name;
|
|
289
|
-
|
|
290
|
-
if (prefill !== undefined && prefill !== null) createPrefills[createEventName(a)] = prefill;
|
|
291
|
-
out.events[click] = semanticPipe(scope, prefill === undefined || prefill === null ? KIT_COORD_EVENTS.openCreate : createEventName(a), pipeTails(a, at, out.diagnostics));
|
|
255
|
+
out.events[click] = semanticPipe(scope, KIT_COORD_EVENTS.openCreate, pipeTails(a, at, out.diagnostics));
|
|
292
256
|
} else if (a.builtin === 'reload') {
|
|
293
257
|
out.events[click] = semanticPipe(scope, KIT_COORD_EVENTS.reload, pipeTails(a, at, out.diagnostics));
|
|
294
|
-
} else if (a.after === 'reload') {
|
|
295
|
-
// K-5:声明 after: reload 的工具栏动作,执行后经协调组件重取
|
|
296
|
-
const pipe = actionPipeline(a, at, { hasWrite: entity.behavior.write !== undefined, object, registeredActions: ctx.registeredActions }, []);
|
|
297
|
-
if (pipe !== null) out.events[click] ={ steps: actionSteps(pipe, [semanticPipe(scope, KIT_COORD_EVENTS.reload)]) };
|
|
298
258
|
}
|
|
299
259
|
});
|
|
300
260
|
|
|
301
|
-
//
|
|
261
|
+
// 行操作:同一个实例,每个动作按它在操作列里的位置绑自己的槽位事件,尾段写在对应管道上;事件整段重写
|
|
302
262
|
const listHtml = entityEmit.parts.list ?? '';
|
|
303
263
|
let editCopy = EDIT_COPY;
|
|
304
264
|
const rowActions = actions.filter((a) => a.on === 'row');
|
|
@@ -309,37 +269,39 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
309
269
|
const nested: Rec = isRec(out.events[rowsKey]) ? { ...(out.events[rowsKey] as Rec) } : {};
|
|
310
270
|
// 只有行模板真的产出了操作列锚点(原事件表里有它)才写回;虚拟表 / 树表 / 看板 / 只配右键菜单的表没有这个节点,写了会在挂载期缺事件源
|
|
311
271
|
// 仅整行点击无行操作时事件表没有这一项,但 html 里补了无按钮的操作列实例,也要写(否则行点击接线丢失)
|
|
312
|
-
const
|
|
313
|
-
|
|
272
|
+
const slotPrefix = `${ops}.${KIT_ACTION_SLOT_BASE.row}_`;
|
|
273
|
+
const hadRowOps = Object.keys(nested).some((k) => k.startsWith(slotPrefix)) || listHtml.includes(`data-soma-id="${ops}"`);
|
|
314
274
|
for (const a of rowActions) if (a.builtin === 'openEdit') editCopy = a.name;
|
|
315
275
|
|
|
316
|
-
const
|
|
276
|
+
const routes: KitRowActionRoute[] = [];
|
|
317
277
|
for (const a of rowActions) {
|
|
318
278
|
const at = `behavior.actions.${a.id}`;
|
|
319
|
-
const when = rowActionGate(a);
|
|
320
279
|
const own = ownPipe(a, scope, at, out.diagnostics);
|
|
321
280
|
if (own !== null) {
|
|
322
|
-
|
|
281
|
+
routes.push({ id: a.id, pipe: own });
|
|
323
282
|
continue;
|
|
324
283
|
}
|
|
325
284
|
// 具名动作 / 其它内置:D 的管道串;诊断 emitObject 已报过一次,用一次性数组吞掉重复
|
|
326
285
|
const pipe = actionPipeline(a, at, { hasWrite: entity.behavior.write !== undefined, object, registeredActions: ctx.registeredActions }, []);
|
|
327
|
-
if (pipe !== null) {
|
|
328
|
-
steps.push({ when, do: pipe });
|
|
329
|
-
for (const p of actionThenPipes(a, scope)) steps.push({ when, do: p });
|
|
330
|
-
steps.push({ when, do: semanticPipe(scope, KIT_COORD_EVENTS.reload) });
|
|
331
|
-
}
|
|
286
|
+
if (pipe !== null) routes.push({ id: a.id, pipe });
|
|
332
287
|
}
|
|
333
|
-
// 整行点击:KitTableActions 的行点击抛
|
|
334
|
-
if (rowClickName !== undefined) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
288
|
+
// 整行点击:KitTableActions 的行点击抛 row_pick,这里接到打开浮层(协调组件按 overlayActions.select 反查目标)
|
|
289
|
+
if (rowClickName !== undefined) routes.push({ id: 'select', pipe: semanticPipe(scope, KIT_COORD_EVENTS.openOverlay) });
|
|
290
|
+
if (routes.length > 0) {
|
|
291
|
+
const slots = rowActionSlotsOf(entityEmit.ir);
|
|
292
|
+
rewriteRowActions({
|
|
293
|
+
events: out.events, nested, routes, hadRowOps,
|
|
294
|
+
ops: { anchor: ops, ids: slots.rows, pick: true },
|
|
295
|
+
nestedTargets: [{ anchor: ctxMenuAnchor(object), ids: slots.menu }],
|
|
296
|
+
// 页面级表体(虚拟滚动 / 树表)与各右键菜单实例的事件不在 rowsKey 之下,同样改写(否则 openEdit 等内置动作在这些视图里不生效)
|
|
297
|
+
pageTargets: [
|
|
298
|
+
{ anchor: virtualAnchor(object), ids: slots.rows, pick: true },
|
|
299
|
+
{ anchor: treeAnchor(object), ids: slots.rows, pick: true },
|
|
300
|
+
{ anchor: ctxMenuAnchor(object), ids: slots.menu },
|
|
301
|
+
{ anchor: staticCtxAnchor(object, 'list'), ids: slots.staticMenus.list ?? [] },
|
|
302
|
+
{ anchor: staticCtxAnchor(object, 'summary'), ids: slots.staticMenus.summary ?? [] },
|
|
303
|
+
],
|
|
304
|
+
});
|
|
343
305
|
}
|
|
344
306
|
if (Object.keys(nested).length > 0) out.events[rowsKey] = nested;
|
|
345
307
|
}
|
|
@@ -448,32 +410,30 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
448
410
|
for (const [emitName, role] of Object.entries<string | KitOverlayEventAction>({ ...OVERLAY_EVENT_ROLES, ...explicitEvents })) {
|
|
449
411
|
if (!(emitName in explicitEvents) && knownEmits !== undefined && !knownEmits.includes(emitName)) continue;
|
|
450
412
|
if (typeof role !== 'string') {
|
|
451
|
-
//
|
|
413
|
+
// { action }:绑一条具名动作 / request / download 管道;动作之后的提示 / 重取 / 关窗写在具名动作处理函数里
|
|
452
414
|
const epath = `${at}.events.${emitName}`;
|
|
453
415
|
if (!isRec(role) || typeof role.action !== 'string' || role.action === '') {
|
|
454
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} 必须是角色名或 { action
|
|
416
|
+
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} 必须是角色名或 { action }`, epath);
|
|
455
417
|
continue;
|
|
456
418
|
}
|
|
457
419
|
// action 可以是主对象 behavior.actions 里的 request / download 动作 id(声明式请求,交页面级 KitActionHost),否则必须是登记的具名动作
|
|
458
420
|
const declared = actions.find((a) => a.id === role.action && isRequestLikeAction(a));
|
|
459
421
|
let actionPipe = `ACTION | ${role.action}`;
|
|
460
422
|
if (declared !== undefined) {
|
|
461
|
-
//
|
|
462
|
-
const registered = registerRequestAction(declared, object, `${epath}.action`, out.diagnostics, { closeOnSuccess:
|
|
423
|
+
// 请求由宿主异步执行:浮层事件绑的请求是这个浮层的「提交」,成功后由宿主固定关窗并重取(失败时窗口保留,编辑不丢)
|
|
424
|
+
const registered = registerRequestAction(declared, object, `${epath}.action`, out.diagnostics, { closeOnSuccess: true });
|
|
463
425
|
if (registered === null) continue;
|
|
464
426
|
actionPipe = registered;
|
|
465
427
|
} else if (!ctx.registeredActions.has(role.action)) {
|
|
466
428
|
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName}.action "${role.action}" 未在应用的具名动作中登记`, `${epath}.action`);
|
|
467
429
|
continue;
|
|
468
430
|
}
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
471
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName}
|
|
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);
|
|
472
434
|
continue;
|
|
473
435
|
}
|
|
474
|
-
|
|
475
|
-
if (thenSem !== undefined && declared === undefined) steps.push({ do: semanticPipe(scope, thenSem) });
|
|
476
|
-
out.events[`${anchor}.${emitName}`] = { steps };
|
|
436
|
+
out.events[`${anchor}.${emitName}`] = actionPipe;
|
|
477
437
|
namedOn[emitName] = role.action;
|
|
478
438
|
continue;
|
|
479
439
|
}
|
|
@@ -514,17 +474,12 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
514
474
|
);
|
|
515
475
|
|
|
516
476
|
// ---- 壳
|
|
517
|
-
const removeConfirms
|
|
518
|
-
actions
|
|
519
|
-
.filter((a) => a.builtin === 'remove' && a.confirm !== undefined && removeConfirmPlaceholders(a.confirm).length > 0)
|
|
520
|
-
.map((a) => [a.id, a.confirm as string]),
|
|
521
|
-
);
|
|
477
|
+
const removeConfirms = removeConfirmTemplates(actions);
|
|
522
478
|
out.show[coordinatorId(object)] = {
|
|
523
479
|
props: {
|
|
524
|
-
scope, object, keyField: keyField ?? '', reloads: [], overlays: overlayObjects, showEdit, ...(expandObject !== '' ? { expandObject } : {}),
|
|
480
|
+
scope, object, keyField: keyField ?? '', reloads: [], overlays: overlayObjects, showEdit, rowsPath: entityEmit.compiled.listShape.rows, ...(expandObject !== '' ? { expandObject } : {}),
|
|
525
481
|
// 带行占位的删除确认:动作 id -> 确认文案模板(运行期按被删行插值)
|
|
526
482
|
...(Object.keys(removeConfirms).length > 0 ? { removeConfirms } : {}),
|
|
527
|
-
...(Object.keys(createPrefills).length > 0 ? { createPrefills } : {}),
|
|
528
483
|
overlayActions: {
|
|
529
484
|
...Object.fromEntries(actions.filter((a) => a.builtin === 'openOverlay' && a.targetOverlay !== undefined).map((a) => [a.id, a.targetOverlay as string])),
|
|
530
485
|
...(rowClickName !== undefined ? { select: rowClickName } : {}),
|
|
@@ -550,5 +505,5 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
550
505
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
551
506
|
for (const c of Object.values(CRUD_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
552
507
|
|
|
553
|
-
return
|
|
508
|
+
return finishBizCompile(out, html);
|
|
554
509
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { esc } from '../../shared/escape';
|
|
1
2
|
// StandardCrud 的 HTML 代码壳:只有结构和 Tailwind 类(语义色名 + utilityScales 里有的尺度),不写原生 CSS。
|
|
2
3
|
// 层次基准取规格 7.2:第 2 层分区容器 `bg-surface-raised rounded-lg border border-border-subtle`。
|
|
3
4
|
// 显隐层统一用 `fixed inset-0` 的遮罩 + 内层 flex 容器:显隐只靠 core 写 `hidden` 属性,不在遮罩自身叠 display 类。
|
|
4
5
|
|
|
5
6
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
6
|
-
import {
|
|
7
|
+
import { KIT_FIXED_ATTRIBUTE, KIT_PART_DIALOG, KIT_PART_DRAWER, KIT_PART_TITLE_DIALOG } from '../../recipes';
|
|
8
|
+
import { OVERLAY_SHELL_CLASS, classAttr, closeButtonHtml, dialogHtml, dialogIds, dialogTitles } from '../shared/overlay-shell';
|
|
9
|
+
|
|
10
|
+
// 弹窗外壳的公共部分已下沉到 biz/shared/overlay-shell;这里原样 re-export,保持原导出名可用
|
|
11
|
+
export { closeButtonHtml, dialogHtml, dialogIds, dialogTitles };
|
|
7
12
|
|
|
8
13
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
9
14
|
export const STANDARD_CRUD_AREAS = ['root', 'filter', 'list', 'dialog', 'drawer'] as const;
|
|
@@ -14,31 +19,10 @@ export const CRUD_CLASS = {
|
|
|
14
19
|
filter: 'bg-surface rounded-lg border border-border-strong p-4',
|
|
15
20
|
list: 'bg-surface rounded-lg border border-border-strong p-4 flex flex-col gap-3',
|
|
16
21
|
listHeadRow: 'flex flex-wrap items-center justify-between gap-2',
|
|
17
|
-
|
|
18
|
-
// 最外层只放 core 写的 hidden 属性,不带任何类(core 样式引擎没有 preflight,hidden 与 flex 同元素会失效);fixed / flex 在内层
|
|
19
|
-
dialogRow: 'fixed inset-0 z-50 flex items-center justify-center bg-fg/50 p-4',
|
|
20
|
-
dialog: 'flex max-h-full w-full max-w-lg flex-col overflow-y-auto rounded-lg border border-border-strong bg-surface-raised shadow-xl',
|
|
21
|
-
drawerRow: 'fixed inset-0 z-50 flex justify-end bg-fg/50',
|
|
22
|
-
drawer: 'flex h-full w-96 flex-col overflow-y-auto border-s border-border-strong bg-surface-raised shadow-xl',
|
|
23
|
-
header: 'flex items-center justify-between gap-4 border-b border-border-subtle px-5 py-3',
|
|
24
|
-
title: 'text-base font-semibold text-fg',
|
|
25
|
-
close: 'inline-flex size-8 shrink-0 border-0 bg-transparent p-0 cursor-pointer items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
26
|
-
headerActions: 'flex items-center gap-2',
|
|
27
|
-
body: 'flex-1 p-5',
|
|
22
|
+
...OVERLAY_SHELL_CLASS,
|
|
28
23
|
} as const;
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
export function closeButtonHtml(id: string, label: string): string {
|
|
32
|
-
return `<button type="button" data-soma-id="${esc(id)}" aria-label="${esc(label)}" class="${CRUD_CLASS.close}">${kitIconHtml('close', 'md')}</button>`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function esc(text: string): string {
|
|
36
|
-
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function cls(value: string): string {
|
|
40
|
-
return value === '' ? '' : ` class="${esc(value)}"`;
|
|
41
|
-
}
|
|
25
|
+
const cls = classAttr;
|
|
42
26
|
|
|
43
27
|
function host(component: string, id: string): string {
|
|
44
28
|
return `<div data-soma-component="${component}" data-soma-id="${esc(id)}"></div>`;
|
|
@@ -48,33 +32,12 @@ export interface CrudShellIds {
|
|
|
48
32
|
root: string;
|
|
49
33
|
coordinator: string;
|
|
50
34
|
dialogLayer: string;
|
|
35
|
+
dialogTitle: string;
|
|
51
36
|
dialogTitleCreate: string;
|
|
52
37
|
dialogTitleEdit: string;
|
|
53
38
|
dialogClose: string;
|
|
54
39
|
}
|
|
55
40
|
|
|
56
|
-
export function dialogIds(object: string): Pick<CrudShellIds, 'dialogLayer' | 'dialogTitleCreate' | 'dialogTitleEdit' | 'dialogClose'> {
|
|
57
|
-
return {
|
|
58
|
-
dialogLayer: `${object}__dlg_layer`,
|
|
59
|
-
dialogTitleCreate: `${object}__dlg_title_create`,
|
|
60
|
-
dialogTitleEdit: `${object}__dlg_title_edit`,
|
|
61
|
-
dialogClose: `${object}__dlg_close`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** K-7:弹窗标题。form 视图的 title(字符串两态通用,或 { create, edit })覆写缺省(动作名) */
|
|
66
|
-
export function dialogTitles(formTitle: unknown, dflt: { create: string; edit: string }): { create: string; edit: string } {
|
|
67
|
-
if (typeof formTitle === 'string' && formTitle !== '') return { create: formTitle, edit: formTitle };
|
|
68
|
-
if (formTitle !== null && typeof formTitle === 'object') {
|
|
69
|
-
const t = formTitle as { create?: unknown; edit?: unknown };
|
|
70
|
-
return {
|
|
71
|
-
create: typeof t.create === 'string' && t.create !== '' ? t.create : dflt.create,
|
|
72
|
-
edit: typeof t.edit === 'string' && t.edit !== '' ? t.edit : dflt.edit,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return dflt;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
41
|
export function overlayIds(object: string, name: string): { layer: string; title: string; close: string; edit: string } {
|
|
79
42
|
return {
|
|
80
43
|
layer: `${object}__ov_${name}_layer`, title: `${object}__ov_${name}_title`, close: `${object}__ov_${name}_close`,
|
|
@@ -109,21 +72,6 @@ export function mainHtml(parts: { filter: string; toolbar: string; list: string
|
|
|
109
72
|
return blocks.join('\n');
|
|
110
73
|
}
|
|
111
74
|
|
|
112
|
-
/** 新增 / 编辑弹窗:标题按 creating / editing 两个真值显隐,正文是 KitObjectForm */
|
|
113
|
-
export function dialogHtml(ids: ReturnType<typeof dialogIds>, copy: { create: string; edit: string }, body: string, areaClass: Record<string, string>, closeLabel = 'Close'): string {
|
|
114
|
-
const panel = mergeClass(CRUD_CLASS.dialog, areaClass.dialog);
|
|
115
|
-
return `<div data-soma-id="${esc(ids.dialogLayer)}">`
|
|
116
|
-
+ `<div data-kit-scrim=""${cls(CRUD_CLASS.dialogRow)}>`
|
|
117
|
-
+ `<div role="dialog" aria-modal="true"${cls(panel)}>`
|
|
118
|
-
+ `<div${cls(CRUD_CLASS.header)}>`
|
|
119
|
-
+ `<h2${cls(CRUD_CLASS.title)}><span data-soma-id="${esc(ids.dialogTitleCreate)}">${esc(copy.create)}</span>`
|
|
120
|
-
+ `<span data-soma-id="${esc(ids.dialogTitleEdit)}">${esc(copy.edit)}</span></h2>`
|
|
121
|
-
+ closeButtonHtml(ids.dialogClose, closeLabel)
|
|
122
|
-
+ '</div>'
|
|
123
|
-
+ `<div${cls(CRUD_CLASS.body)}>${body}</div>`
|
|
124
|
-
+ '</div></div></div>';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
75
|
/** 附加浮层(dialog / drawer):`panelClass` 是声明里的 `class`,按同族规则覆写基准 */
|
|
128
76
|
export function overlayHtml(
|
|
129
77
|
ids: ReturnType<typeof overlayIds>,
|
|
@@ -134,18 +82,20 @@ export function overlayHtml(
|
|
|
134
82
|
areaClass: Record<string, string>,
|
|
135
83
|
withEdit = false,
|
|
136
84
|
closeLabel = 'Close',
|
|
85
|
+
footer = '',
|
|
137
86
|
): string {
|
|
138
87
|
const isDrawer = kind === 'drawer';
|
|
139
88
|
const base = isDrawer ? CRUD_CLASS.drawer : CRUD_CLASS.dialog;
|
|
140
89
|
const panel = mergeClass(mergeClass(base, areaClass[kind]), panelClass);
|
|
141
90
|
return `<div data-soma-id="${esc(ids.layer)}">`
|
|
142
|
-
+ `<div data-kit-scrim=""${cls(isDrawer ? CRUD_CLASS.drawerRow : CRUD_CLASS.dialogRow)}>`
|
|
143
|
-
+ `<div role="dialog" aria-modal="true"${cls(panel)}>`
|
|
144
|
-
+ `<div${cls(CRUD_CLASS.header)}>`
|
|
145
|
-
+ `<h2 data-soma-id="${esc(ids.title)}"${cls(CRUD_CLASS.title)}>${esc(title)}</h2>`
|
|
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>`
|
|
146
95
|
+ (withEdit ? `<div${cls(CRUD_CLASS.headerActions)}>${host('Button', ids.edit)}${closeButtonHtml(ids.close, closeLabel)}</div>` : closeButtonHtml(ids.close, closeLabel))
|
|
147
96
|
+ '</div>'
|
|
148
|
-
+ `<div${cls(CRUD_CLASS.body)}>${body}</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>` : '')
|
|
149
99
|
+ '</div></div></div>';
|
|
150
100
|
}
|
|
151
101
|
|