soma-kit 0.1.11 → 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 +106 -112
- package/bin/soma-kit.mjs +32 -2
- package/bin/soma.mjs +22 -0
- package/package.json +14 -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 +929 -37
- package/spec/generated/kit-page.schema.json +1684 -161
- package/spec/kit-grammar.json +1176 -584
- package/spec/kit-grammar.schema.json +1971 -393
- package/src/app/app-config.ts +449 -347
- package/src/app/component-gate.ts +283 -28
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +176 -33
- package/src/app/define-kit-view.ts +104 -0
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +29 -6
- package/src/app/kit-view-context.ts +439 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +11 -3
- package/src/app/server.ts +530 -103
- 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 +667 -0
- package/src/base/action-busy.ts +103 -6
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +58 -0
- package/src/base/alert.ts +5 -3
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +99 -37
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +9 -1
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +49 -28
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +16 -11
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +10 -6
- package/src/base/context-menu.ts +10 -7
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +32 -18
- package/src/base/date.ts +135 -28
- package/src/base/delta.ts +72 -0
- package/src/base/divider.ts +2 -2
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +12 -5
- 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/image.ts +1 -1
- package/src/base/index.ts +35 -11
- 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 +56 -35
- package/src/base/loading-gate.ts +186 -0
- package/src/base/mentions.ts +7 -6
- package/src/base/menu-button.ts +28 -12
- package/src/base/menu-core.ts +41 -8
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +3 -3
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +3 -3
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +9 -5
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +48 -16
- package/src/base/popup.ts +143 -19
- package/src/base/portal-core.ts +4 -0
- 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 +14 -8
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +21 -4
- package/src/base/rating.ts +12 -7
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +27 -21
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +387 -49
- 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 +10 -7
- package/src/base/switch.ts +11 -6
- package/src/base/tag-input.ts +20 -16
- package/src/base/tag.ts +68 -34
- package/src/base/text.ts +80 -18
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +18 -13
- package/src/base/tree-select.ts +21 -12
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +48 -14
- package/src/base/view-transition.ts +77 -0
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +23 -37
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +22 -5
- package/src/biz/checkout-page/shell.ts +4 -3
- 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 +5 -4
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +69 -22
- package/src/biz/link/shared.ts +127 -119
- package/src/biz/master-sub/compile.ts +127 -48
- 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 +38 -50
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +32 -20
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/notification-center/shell.ts +6 -4
- 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/result-page/shell.ts +2 -1
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +48 -43
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +7 -5
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +97 -211
- package/src/biz/shared/compile-helpers.ts +98 -0
- package/src/biz/shared/coordinator.ts +472 -92
- package/src/biz/shared/index.ts +13 -2
- 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 +209 -0
- package/src/biz/shared/pipes.ts +50 -31
- package/src/biz/shared/remove-wire.ts +14 -0
- package/src/biz/shared/runtime-hub.ts +226 -24
- package/src/biz/single-form/compile.ts +16 -37
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +72 -255
- package/src/biz/standard-crud/shell.ts +21 -99
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/step-form/shell.ts +5 -5
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +254 -25
- package/src/cli/kit-init.ts +227 -0
- 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/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 +761 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +570 -0
- package/src/compile/compile-page.ts +267 -76
- package/src/compile/component-candidates.ts +13 -2
- 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/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/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/remove-guard.ts +10 -7
- package/src/compile/styles.ts +63 -2
- package/src/compile/types.ts +31 -3
- package/src/compile/view-check.ts +284 -0
- package/src/data/amount-breakdown.ts +8 -3
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +3 -3
- package/src/data/assignment-picker.ts +92 -55
- package/src/data/async-result-panel.ts +111 -9
- package/src/data/breadcrumbs.ts +5 -4
- package/src/data/calendar.ts +24 -27
- package/src/data/carousel.ts +13 -8
- package/src/data/chart.ts +183 -44
- package/src/data/checklist.ts +20 -7
- package/src/data/code-view.ts +12 -6
- package/src/data/comment-thread.ts +7 -4
- package/src/data/confirm-dialog.ts +81 -18
- 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 +3 -3
- package/src/data/embed.ts +233 -30
- package/src/data/field-mapper.ts +35 -30
- package/src/data/flow-editor-contract.ts +8 -1
- package/src/data/flow-editor.ts +113 -108
- package/src/data/flow-node-options.ts +120 -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 +19 -19
- package/src/data/hero.ts +4 -3
- package/src/data/image-viewer.ts +27 -30
- package/src/data/index.ts +5 -2
- package/src/data/item-list.ts +48 -31
- package/src/data/kanban.ts +82 -52
- package/src/data/media-grid.ts +20 -20
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +47 -15
- package/src/data/mockup.ts +10 -6
- package/src/data/modal-dialog.ts +49 -25
- package/src/data/navbar.ts +12 -7
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +250 -0
- package/src/data/object-form.ts +1360 -666
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +80 -34
- package/src/data/permission-matrix.ts +52 -31
- package/src/data/permission-tree.ts +71 -44
- package/src/data/pricing-table.ts +30 -14
- package/src/data/prompt-dialog.ts +124 -194
- package/src/data/reaction-bar.ts +83 -92
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +26 -5
- package/src/data/record-picker.ts +104 -55
- 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 +8 -4
- package/src/data/rich-text.ts +61 -55
- package/src/data/row-editor.ts +362 -76
- package/src/data/rule-builder.ts +26 -20
- package/src/data/shape-util.ts +27 -9
- package/src/data/stat-group.ts +392 -109
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +24 -11
- package/src/data/steps.ts +10 -5
- package/src/data/survey.ts +27 -32
- package/src/data/system-switcher.ts +3 -3
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +19 -8
- package/src/data/tour-guide.ts +23 -30
- package/src/data/transfer.ts +62 -38
- package/src/data/tree-table.ts +152 -78
- package/src/data/tree.ts +49 -36
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +133 -82
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +26 -24
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +9 -7
- package/src/frames/shared.ts +36 -25
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +6 -6
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +4 -14
- package/src/frames/tabs-frame/wiring.ts +5 -8
- package/src/frames/top-main-frame.ts +3 -2
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +21 -5
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +250 -48
- package/src/generated/kit-grammar-runtime.ts +645 -397
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +84 -29
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +112 -84
- 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 +401 -104
- package/src/object-renderer/collection-table.ts +287 -45
- package/src/object-renderer/collection.ts +258 -104
- package/src/object-renderer/compile-data.ts +112 -102
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +38 -16
- package/src/object-renderer/display-checks.ts +4 -25
- package/src/object-renderer/emit-events.ts +224 -176
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +533 -151
- 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 +111 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -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/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +456 -89
- package/src/object-renderer/request-actions.ts +232 -249
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +319 -111
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +429 -94
- package/src/object-renderer/types.ts +204 -127
- package/src/object-renderer/view-binding.ts +393 -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 +165 -28
- package/src/page-target/target.ts +262 -51
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +210 -0
- package/src/recipes/control.ts +277 -0
- package/src/recipes/index.ts +312 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +240 -0
- 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 +99 -0
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +88 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +99 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/confirm-decl.ts +118 -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 +15 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +180 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +407 -10
- package/src/theme/kit-theme.tpl +407 -10
- package/src/theme/nine-dim-structure.ts +247 -0
- package/src/theme/surface-layers.ts +101 -0
- package/src/theme/theme-tokens.ts +130 -84
- package/src/theme/theme-types.ts +103 -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/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,44 +8,37 @@
|
|
|
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
|
-
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
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { primaryKeyFieldOf } from '../../object-renderer/key-field';
|
|
18
|
+
import { actionPipeline, rowActionSlotsOf } from '../../object-renderer/emit-events';
|
|
20
19
|
import { checkExpandChild, expandHolderHtml, expandHostId } from '../../object-renderer/collection-expand';
|
|
21
20
|
import { ctxMenuAnchor, opsAnchor, rowsAnchor, staticCtxAnchor, toolbarAnchor, treeAnchor, viewAnchor, virtualAnchor } from '../../object-renderer/emit-static';
|
|
22
|
-
import type { KitAction, KitDiagnostic, KitObject,
|
|
21
|
+
import type { KitAction, KitDiagnostic, KitObject, KitViewForm } from '../../object-renderer/types';
|
|
23
22
|
import type { KitFragment } from '../../compile/fragment';
|
|
24
|
-
import type { KitBizContext, KitBizInput
|
|
25
|
-
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS,
|
|
26
|
-
import {
|
|
27
|
-
import { busyActionOf } from '../../base/action-busy';
|
|
28
|
-
import { removeConfirmPlaceholders } from '../../compile/remove-guard';
|
|
29
|
-
import { actionSteps, createEventName, pipeTails, semanticPipe, wireDialogForm } from '../shared/pipes';
|
|
30
|
-
import { prefillOf } from '../../object-renderer/action-gate';
|
|
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';
|
|
31
26
|
import {
|
|
32
|
-
|
|
27
|
+
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
28
|
+
} from '../shared/compile-helpers';
|
|
29
|
+
import { IDENT, labelDiagnostics, newParts, normalizeList, type Parts } from '../link/shared';
|
|
30
|
+
import { pipeTails, semanticPipe, wireDialogForm } from '../shared/pipes';
|
|
31
|
+
import { removePipe } from '../shared/remove-wire';
|
|
32
|
+
import { KIT_ACTION_SLOT_BASE } from '../../base/action-slots';
|
|
33
|
+
import { StandardCrud } from './index';
|
|
34
|
+
import {
|
|
35
|
+
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, dialogWidthOf, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
33
36
|
} from './shell';
|
|
34
37
|
|
|
35
38
|
type Rec = Record<string, unknown>;
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/** 浮层里数据组件的约定事件 -> 角色(K-1) */
|
|
40
|
-
const OVERLAY_EVENT_ROLES: Record<string, string> = KIT_GRAMMAR.overlayEventRoles.conventional as Record<string, string>;
|
|
41
|
-
const OVERLAY_ROLE_SEMANTIC: Record<string, string> = {
|
|
42
|
-
saved: KIT_COORD_EVENTS.saved,
|
|
43
|
-
close: KIT_COORD_EVENTS.close,
|
|
44
|
-
reload: KIT_COORD_EVENTS.reload,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/** 关联键镜像:当前行主键(附加对象的 from.params 引用) */
|
|
48
|
-
export const KIT_CRUD_LINK_KEY = 'crud_link';
|
|
40
|
+
/** 关联键镜像:当前行主键(附加对象的 from.params 引用);附加浮层的共用编译在 shared/overlay-compile.ts,这里原样 re-export */
|
|
41
|
+
export { KIT_CRUD_LINK_KEY };
|
|
49
42
|
|
|
50
43
|
function isRec(v: unknown): v is Rec {
|
|
51
44
|
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -53,22 +46,16 @@ function isRec(v: unknown): v is Rec {
|
|
|
53
46
|
|
|
54
47
|
/** 主对象名:`${槽名}_entity`,槽名即 pageId(保留名由编译器前置校验) */
|
|
55
48
|
export function crudObjectName(pageId: string): string {
|
|
56
|
-
return
|
|
49
|
+
return bizObjectName(pageId, 'entity');
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
function mirrorPath(scope: string, key: string): string {
|
|
60
53
|
return regionMirrorStatePath(scope, key);
|
|
61
54
|
}
|
|
62
55
|
|
|
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
56
|
// ---------------------------------------------------------------- 动作
|
|
70
57
|
|
|
71
|
-
//
|
|
58
|
+
// 行操作各抛各的槽位事件 row_action_<序号>,每个动作各绑一条管道;具名动作做完的重取由 defineKitActions 在有协调组件的页面里固定执行。
|
|
72
59
|
|
|
73
60
|
/** 一个行动作的单管道(尾段由 pipeTails 给);返回 null 表示该动作不是本壳解释的、交 actionPipeline */
|
|
74
61
|
function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagnostic[]): string | null {
|
|
@@ -76,8 +63,8 @@ function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagno
|
|
|
76
63
|
switch (a.builtin) {
|
|
77
64
|
case 'openEdit': return semanticPipe(scope, KIT_COORD_EVENTS.openEdit, tails());
|
|
78
65
|
case 'openOverlay': return semanticPipe(scope, KIT_COORD_EVENTS.openOverlay, tails());
|
|
79
|
-
// 带行占位的确认({字段})由 KitCrudBridge
|
|
80
|
-
case 'remove': return
|
|
66
|
+
// 带行占位的确认({字段})由 KitCrudBridge 按被删行插值后再问:尾段规则在 shared/remove-wire.ts(与 link 系共用)
|
|
67
|
+
case 'remove': return removePipe(scope, a, at, diagnostics);
|
|
81
68
|
// K-2:刷新内置动作,经协调组件重取
|
|
82
69
|
case 'reload': return semanticPipe(scope, KIT_COORD_EVENTS.reload, tails());
|
|
83
70
|
default: return null;
|
|
@@ -86,29 +73,8 @@ function ownPipe(a: KitAction, scope: string, at: string, diagnostics: KitDiagno
|
|
|
86
73
|
|
|
87
74
|
// ---------------------------------------------------------------- 浮层视图规整
|
|
88
75
|
|
|
89
|
-
/** 浮层的 view 允许直接写成一个视图(如 `staticComponent` 写在 view 下):list 型放 list 槽,single 型放 summary 槽 */
|
|
90
|
-
function normalizeOverlayView(view: unknown): KitView | undefined {
|
|
91
|
-
if (!isRec(view)) return undefined;
|
|
92
|
-
if (KIT_VIEW_SLOTS.some((s) => s in view)) return view as KitView;
|
|
93
|
-
if (Object.keys(view).some((k) => KIT_VIEW_FORM_KEYS.has(k))) {
|
|
94
|
-
const form = view as unknown as KitViewForm;
|
|
95
|
-
return form.accept === 'single' ? { summary: form } : { list: form };
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
76
|
// ---------------------------------------------------------------- 累积
|
|
101
77
|
|
|
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
78
|
function addEmit(into: Parts, r: KitEmitResult): void {
|
|
113
79
|
Object.assign(into.show, r.ui.show);
|
|
114
80
|
Object.assign(into.data, r.ui.data);
|
|
@@ -136,22 +102,6 @@ function patchProps(show: Rec, id: string, props: Rec): boolean {
|
|
|
136
102
|
return true;
|
|
137
103
|
}
|
|
138
104
|
|
|
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
105
|
// ---------------------------------------------------------------- 主函数
|
|
156
106
|
|
|
157
107
|
export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
@@ -159,35 +109,32 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
159
109
|
const EDIT_COPY = kitText('soma.kit.edit', undefined, ctx.locale);
|
|
160
110
|
const CLOSE_LABEL = kitText('soma.kit.close', undefined, ctx.locale);
|
|
161
111
|
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
|
-
};
|
|
112
|
+
const out = newParts(['Button', 'KitCrudBridge']);
|
|
168
113
|
const fail = (code: string, message: string, path: string): void => { out.diagnostics.push({ code, message, path }); };
|
|
169
114
|
|
|
170
115
|
const rawEntity = input.objects.entity;
|
|
171
116
|
if (!isRec(rawEntity) || !isRec(rawEntity.schema) || !isRec(rawEntity.behavior)) {
|
|
172
117
|
fail('KIT-BIZ-001', 'StandardCrud 缺少必填对象角色槽 entity(需含 schema 与 behavior)', 'product.objects.entity');
|
|
173
|
-
return
|
|
118
|
+
return finishBizCompile(out, '');
|
|
174
119
|
}
|
|
175
120
|
const entityRaw = rawEntity as unknown as KitObject;
|
|
176
121
|
const entity: KitObject = isRec(entityRaw.view) && isRec((entityRaw.view as Rec).list)
|
|
177
122
|
? { ...entityRaw, view: { ...entityRaw.view, list: normalizeList((entityRaw.view as Rec).list as KitViewForm & Rec) } }
|
|
178
123
|
: 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
|
-
}
|
|
124
|
+
validateBizAreaClass(input, 'StandardCrud', STANDARD_CRUD_AREAS, out.diagnostics);
|
|
184
125
|
const areaClass = input.areaClass ?? {};
|
|
185
126
|
|
|
186
127
|
const object = crudObjectName(ctx.pageId);
|
|
187
128
|
const scope = `${object}_scope`;
|
|
188
|
-
const keyField =
|
|
129
|
+
const keyField = primaryKeyFieldOf(entity.schema);
|
|
189
130
|
const actions = entity.behavior.actions ?? [];
|
|
190
131
|
|
|
132
|
+
const listColl = isRec(entity.view) && isRec((entity.view as Rec).list) ? ((entity.view as Rec).list as Rec).collection : undefined;
|
|
133
|
+
const expandDecl = isRec(listColl) && isRec(listColl.expand) ? listColl.expand : undefined;
|
|
134
|
+
if (!(expandDecl !== undefined && expandDecl.view === 'summary')) {
|
|
135
|
+
checkRoleAllowedViews('entity', entity, StandardCrud.roles.entity, out.diagnostics, 'product.objects.entity');
|
|
136
|
+
}
|
|
137
|
+
|
|
191
138
|
const hasList = entity.view?.list !== undefined;
|
|
192
139
|
const hasForm = entity.view?.form !== undefined;
|
|
193
140
|
if (!hasList) fail('KIT-BIZ-001', 'StandardCrud 的 entity 必须有 list 视图(主列表)', 'product.objects.entity.view.list');
|
|
@@ -196,21 +143,8 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
196
143
|
}
|
|
197
144
|
|
|
198
145
|
const overlays = input.overlays ?? {};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
else if (name === 'entity') fail('KIT-PAGE-001', '附加浮层名不能叫 entity(与主对象角色槽同名)', `product.overlays.${name}`);
|
|
202
|
-
}
|
|
203
|
-
// E3:只读浮层的 editOverlay 必须指向另一个存在的浮层(点「编辑」切过去,当前行保留)
|
|
204
|
-
const showEdit: Record<string, string> = {};
|
|
205
|
-
for (const [name, decl] of Object.entries(overlays)) {
|
|
206
|
-
if (decl.editOverlay === undefined) continue;
|
|
207
|
-
const at = `product.overlays.${name}.editOverlay`;
|
|
208
|
-
if (typeof decl.editOverlay !== 'string' || !(decl.editOverlay in overlays) || decl.editOverlay === name) {
|
|
209
|
-
fail('KIT-BIZ-003', `浮层 ${name} 的 editOverlay "${String(decl.editOverlay)}" 必须是另一个已声明的浮层名`, at);
|
|
210
|
-
} else {
|
|
211
|
-
showEdit[name] = decl.editOverlay;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
146
|
+
// 浮层名 / editOverlay 校验与 MasterSub 同一份(shared/overlay-compile.ts)
|
|
147
|
+
const showEdit = validateOverlayNames(overlays, ['entity'], fail);
|
|
214
148
|
// 整行点击:至多一个浮层写 rowClick: true;点行 / 行聚焦按 Enter 以当前行打开它
|
|
215
149
|
const rowClickNames = Object.entries(overlays).filter(([, d]) => d.rowClick !== undefined && d.rowClick !== false).map(([n]) => n);
|
|
216
150
|
for (const [name, decl] of Object.entries(overlays)) {
|
|
@@ -233,12 +167,10 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
233
167
|
fail('KIT-EVT-001', `动作 ${a.id}:${a.builtin} 只能是行操作(要带当前行)`, at);
|
|
234
168
|
}
|
|
235
169
|
});
|
|
236
|
-
if (out.diagnostics.length > 0) return
|
|
170
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
237
171
|
|
|
238
172
|
// ---- 展开行子表(Q 波 G5):kind: expand 的附加对象不画浮层,由 entity 的 collection.expand.list 引用
|
|
239
173
|
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
174
|
const expandRef = expandDecl !== undefined && typeof expandDecl.list === 'string' && typeof expandDecl.link === 'string' && expandNames.has(expandDecl.list)
|
|
243
175
|
? { list: expandDecl.list, link: expandDecl.link }
|
|
244
176
|
: undefined;
|
|
@@ -278,27 +210,19 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
278
210
|
|
|
279
211
|
// 工具栏:openCreate 改走语义事件
|
|
280
212
|
let createCopy = CREATE_COPY;
|
|
281
|
-
// GA5:带 prefill 的「新建」钮各占一个语义事件,协调组件按事件名查预填表(事件名 -> { 字段: $filter.x | 字面量 })
|
|
282
|
-
const createPrefills: Record<string, Record<string, unknown>> = {};
|
|
283
213
|
actions.forEach((a, i) => {
|
|
284
214
|
if (a.on !== 'toolbar') return;
|
|
285
215
|
const at = `behavior.actions[${i}]`;
|
|
286
216
|
const click = `${toolbarAnchor(object, a.id)}.click`;
|
|
287
217
|
if (a.builtin === 'openCreate') {
|
|
288
218
|
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));
|
|
219
|
+
out.events[click] = semanticPipe(scope, KIT_COORD_EVENTS.openCreate, pipeTails(a, at, out.diagnostics));
|
|
292
220
|
} else if (a.builtin === 'reload') {
|
|
293
221
|
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
222
|
}
|
|
299
223
|
});
|
|
300
224
|
|
|
301
|
-
//
|
|
225
|
+
// 行操作:同一个实例,每个动作按它在操作列里的位置绑自己的槽位事件,尾段写在对应管道上;事件整段重写
|
|
302
226
|
const listHtml = entityEmit.parts.list ?? '';
|
|
303
227
|
let editCopy = EDIT_COPY;
|
|
304
228
|
const rowActions = actions.filter((a) => a.on === 'row');
|
|
@@ -309,37 +233,39 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
309
233
|
const nested: Rec = isRec(out.events[rowsKey]) ? { ...(out.events[rowsKey] as Rec) } : {};
|
|
310
234
|
// 只有行模板真的产出了操作列锚点(原事件表里有它)才写回;虚拟表 / 树表 / 看板 / 只配右键菜单的表没有这个节点,写了会在挂载期缺事件源
|
|
311
235
|
// 仅整行点击无行操作时事件表没有这一项,但 html 里补了无按钮的操作列实例,也要写(否则行点击接线丢失)
|
|
312
|
-
const
|
|
313
|
-
|
|
236
|
+
const slotPrefix = `${ops}.${KIT_ACTION_SLOT_BASE.row}_`;
|
|
237
|
+
const hadRowOps = Object.keys(nested).some((k) => k.startsWith(slotPrefix)) || listHtml.includes(`data-soma-id="${ops}"`);
|
|
314
238
|
for (const a of rowActions) if (a.builtin === 'openEdit') editCopy = a.name;
|
|
315
239
|
|
|
316
|
-
const
|
|
240
|
+
const routes: KitRowActionRoute[] = [];
|
|
317
241
|
for (const a of rowActions) {
|
|
318
242
|
const at = `behavior.actions.${a.id}`;
|
|
319
|
-
const when = rowActionGate(a);
|
|
320
243
|
const own = ownPipe(a, scope, at, out.diagnostics);
|
|
321
244
|
if (own !== null) {
|
|
322
|
-
|
|
245
|
+
routes.push({ id: a.id, pipe: own });
|
|
323
246
|
continue;
|
|
324
247
|
}
|
|
325
248
|
// 具名动作 / 其它内置:D 的管道串;诊断 emitObject 已报过一次,用一次性数组吞掉重复
|
|
326
249
|
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
|
-
}
|
|
332
|
-
}
|
|
333
|
-
// 整行点击:KitTableActions 的行点击抛 row_action(kit_action: select),这里接到打开浮层(协调组件按 overlayActions.select 反查目标)
|
|
334
|
-
if (rowClickName !== undefined) {
|
|
335
|
-
steps.push({ when: { field: 'kit_action', op: 'eq', value: 'select' }, do: semanticPipe(scope, KIT_COORD_EVENTS.openOverlay) });
|
|
250
|
+
if (pipe !== null) routes.push({ id: a.id, pipe });
|
|
336
251
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
252
|
+
// 整行点击:KitTableActions 的行点击抛 row_pick,这里接到打开浮层(协调组件按 overlayActions.select 反查目标)
|
|
253
|
+
if (rowClickName !== undefined) routes.push({ id: 'select', pipe: semanticPipe(scope, KIT_COORD_EVENTS.openOverlay) });
|
|
254
|
+
if (routes.length > 0) {
|
|
255
|
+
const slots = rowActionSlotsOf(entityEmit.ir);
|
|
256
|
+
rewriteRowActions({
|
|
257
|
+
events: out.events, nested, routes, hadRowOps,
|
|
258
|
+
ops: { anchor: ops, ids: slots.rows, pick: true },
|
|
259
|
+
nestedTargets: [{ anchor: ctxMenuAnchor(object), ids: slots.menu }],
|
|
260
|
+
// 页面级表体(虚拟滚动 / 树表)与各右键菜单实例的事件不在 rowsKey 之下,同样改写(否则 openEdit 等内置动作在这些视图里不生效)
|
|
261
|
+
pageTargets: [
|
|
262
|
+
{ anchor: virtualAnchor(object), ids: slots.rows, pick: true },
|
|
263
|
+
{ anchor: treeAnchor(object), ids: slots.rows, pick: true },
|
|
264
|
+
{ anchor: ctxMenuAnchor(object), ids: slots.menu },
|
|
265
|
+
{ anchor: staticCtxAnchor(object, 'list'), ids: slots.staticMenus.list ?? [] },
|
|
266
|
+
{ anchor: staticCtxAnchor(object, 'summary'), ids: slots.staticMenus.summary ?? [] },
|
|
267
|
+
],
|
|
268
|
+
});
|
|
343
269
|
}
|
|
344
270
|
if (Object.keys(nested).length > 0) out.events[rowsKey] = nested;
|
|
345
271
|
}
|
|
@@ -389,117 +315,16 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
389
315
|
expandHolder = expandHolderHtml(expandHostId(object, name), childEmit.html, '');
|
|
390
316
|
continue;
|
|
391
317
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const ovObject = `${ctx.pageId}_${name}`;
|
|
403
|
-
const ovScope = `${ovObject}_scope`;
|
|
404
|
-
overlayObjects[name] = ovObject;
|
|
405
|
-
const linkKey = decl.behavior?.linkKey ?? keyField;
|
|
406
|
-
const params: Record<string, string> = { ...(decl.behavior?.params ?? {}) };
|
|
407
|
-
if (linkKey !== undefined && keyField !== undefined) params[linkKey] = `$${mirrorPath(scope, KIT_CRUD_LINK_KEY)}`;
|
|
408
|
-
const dynParams = Object.entries(params).filter(([, v]) => typeof v === 'string' && v.startsWith('$')).map(([k]) => k);
|
|
409
|
-
const reqParams = [...new Set([...(decl.behavior?.requireParams ?? []), ...(linkKey !== undefined && keyField !== undefined ? [linkKey] : []), ...dynParams])];
|
|
410
|
-
const ovObj: KitObject = {
|
|
411
|
-
schema: decl.schema ?? {},
|
|
412
|
-
behavior: {
|
|
413
|
-
...(decl.behavior ?? {}),
|
|
414
|
-
params,
|
|
415
|
-
...(reqParams.length > 0 ? { requireParams: reqParams } : {}),
|
|
416
|
-
},
|
|
417
|
-
view,
|
|
418
|
-
};
|
|
419
|
-
// K-9:浮层没有自己的读接口(无 behavior.from)时,当前行(协调组件 focus.row 的镜像)就是它的数据:
|
|
420
|
-
// 写死形状组件的 data、表单的 initial 都注入这一行,不必按主键回查
|
|
421
|
-
const rowPath = mirrorPath(scope, m.row.key);
|
|
422
|
-
const injectRow = decl.behavior?.from === undefined;
|
|
423
|
-
const ovEmit = labelDiagnostics(emitObject(
|
|
424
|
-
ovObj,
|
|
425
|
-
{ object: ovObject, scope: ovScope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
426
|
-
{ registeredActions: ctx.registeredActions, formMode: 'edit', ...(injectRow ? { summaryPath: rowPath } : {}) },
|
|
427
|
-
), ovObject);
|
|
428
|
-
addEmit(out, ovEmit);
|
|
429
|
-
if (decl.behavior?.from !== undefined) {
|
|
430
|
-
out.scopes[ovScope] = withScopeParts(out.scopes[ovScope], { id: ovScope, object: ovObject }, [], []);
|
|
431
|
-
}
|
|
432
|
-
// 浮层里的可编辑表单:编辑取回的单对象(或注入的当前行),保存后关窗并刷新
|
|
433
|
-
const ovFormId = viewAnchor(ovObject, 'form');
|
|
434
|
-
if (view.form !== undefined) {
|
|
435
|
-
patchProps(out.show, ovFormId, { mode: 'edit', initial: injectRow ? rowPath : `page.data.${ovObject}`, scope: `${ovObject}__form`, cancelLabel: CANCEL_LABEL });
|
|
436
|
-
wireDialogForm(out.events, ovFormId, scope);
|
|
437
|
-
}
|
|
438
|
-
// K-1 / M1-3:浮层里的写死形状数据组件(应用组件)按约定抛 saved / cancel / close / reload,由协调组件接;
|
|
439
|
-
// overlays.<名>.events 可再把自定义事件名映射到这四种之一。组件没抛的事件不会触发(core 对未声明的 emit 选择器惰性)
|
|
440
|
-
for (const slot of ['list', 'summary'] as const) {
|
|
441
|
-
const staticComp = view[slot]?.staticComponent;
|
|
442
|
-
if (staticComp === undefined) continue;
|
|
443
|
-
const knownEmits = ctx.staticComponents[staticComp]?.emits;
|
|
444
|
-
const explicitEvents = decl.events ?? {};
|
|
445
|
-
const anchor = viewAnchor(ovObject, slot);
|
|
446
|
-
// 接了具名动作的事件:编完后自动带上该动作的 busy 绑定(手写 busy_action 优先)
|
|
447
|
-
const namedOn: Record<string, string> = {};
|
|
448
|
-
for (const [emitName, role] of Object.entries<string | KitOverlayEventAction>({ ...OVERLAY_EVENT_ROLES, ...explicitEvents })) {
|
|
449
|
-
if (!(emitName in explicitEvents) && knownEmits !== undefined && !knownEmits.includes(emitName)) continue;
|
|
450
|
-
if (typeof role !== 'string') {
|
|
451
|
-
// M1-5:{ action, then }——先执行具名动作,成功后再走 then(缺省不追加)
|
|
452
|
-
const epath = `${at}.events.${emitName}`;
|
|
453
|
-
if (!isRec(role) || typeof role.action !== 'string' || role.action === '') {
|
|
454
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} 必须是角色名或 { action, then }`, epath);
|
|
455
|
-
continue;
|
|
456
|
-
}
|
|
457
|
-
// action 可以是主对象 behavior.actions 里的 request / download 动作 id(声明式请求,交页面级 KitActionHost),否则必须是登记的具名动作
|
|
458
|
-
const declared = actions.find((a) => a.id === role.action && isRequestLikeAction(a));
|
|
459
|
-
let actionPipe = `ACTION | ${role.action}`;
|
|
460
|
-
if (declared !== undefined) {
|
|
461
|
-
// 请求由宿主异步执行:then(关窗)必须等请求成功才做,由宿主在成功后关窗,这里不再追加 then 步骤(失败时窗口保留,编辑不丢)
|
|
462
|
-
const registered = registerRequestAction(declared, object, `${epath}.action`, out.diagnostics, { closeOnSuccess: role.then !== undefined });
|
|
463
|
-
if (registered === null) continue;
|
|
464
|
-
actionPipe = registered;
|
|
465
|
-
} else if (!ctx.registeredActions.has(role.action)) {
|
|
466
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName}.action "${role.action}" 未在应用的具名动作中登记`, `${epath}.action`);
|
|
467
|
-
continue;
|
|
468
|
-
}
|
|
469
|
-
const thenSem = role.then === undefined ? undefined : OVERLAY_ROLE_SEMANTIC[role.then];
|
|
470
|
-
if (role.then !== undefined && thenSem === undefined) {
|
|
471
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName}.then = "${String(role.then)}" 不在 ${Object.keys(OVERLAY_ROLE_SEMANTIC).join(' / ')} 内`, `${epath}.then`);
|
|
472
|
-
continue;
|
|
473
|
-
}
|
|
474
|
-
const steps: Array<{ do: string }> = [{ do: actionPipe }];
|
|
475
|
-
if (thenSem !== undefined && declared === undefined) steps.push({ do: semanticPipe(scope, thenSem) });
|
|
476
|
-
out.events[`${anchor}.${emitName}`] = { steps };
|
|
477
|
-
namedOn[emitName] = role.action;
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
const sem = OVERLAY_ROLE_SEMANTIC[role];
|
|
481
|
-
if (sem === undefined) {
|
|
482
|
-
fail('KIT-EVT-001', `附加浮层 ${name} 的 events.${emitName} = "${role}" 不在 ${Object.keys(OVERLAY_ROLE_SEMANTIC).join(' / ')} 内`, `${at}.events.${emitName}`);
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
out.events[`${anchor}.${emitName}`] = semanticPipe(scope, sem);
|
|
486
|
-
}
|
|
487
|
-
const busyNames = busyActionOf(view[slot]!.staticComponent!, namedOn);
|
|
488
|
-
const shown = out.show[anchor];
|
|
489
|
-
if (busyNames !== null && isRec(shown) && isRec(shown.props) && shown.props.busy_action === undefined) {
|
|
490
|
-
patchProps(out.show, anchor, { busy_action: busyNames });
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
const ids = overlayIds(object, name);
|
|
494
|
-
overlayMirrors.push({ key: overlayMirrorKey(name), slice: 'focus', path: `ov.${name}`, as: 'truthy' });
|
|
495
|
-
out.show[ids.layer] = { when: mirrorPath(scope, overlayMirrorKey(name)) };
|
|
496
|
-
out.events[`${ids.close}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.close);
|
|
497
|
-
const withEdit = name in showEdit;
|
|
498
|
-
if (withEdit) {
|
|
499
|
-
out.show[ids.edit] = { props: { label: EDIT_COPY, variant: 'neutral', size: 'sm' } };
|
|
500
|
-
out.events[`${ids.edit}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.showEdit);
|
|
501
|
-
}
|
|
502
|
-
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);
|
|
503
328
|
}
|
|
504
329
|
|
|
505
330
|
// 主对象作用域:补 focus 切片(owner 是协调组件)与镜像
|
|
@@ -514,17 +339,9 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
514
339
|
);
|
|
515
340
|
|
|
516
341
|
// ---- 壳
|
|
517
|
-
const removeConfirms: Record<string, string> = Object.fromEntries(
|
|
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
|
-
);
|
|
522
342
|
out.show[coordinatorId(object)] = {
|
|
523
343
|
props: {
|
|
524
|
-
scope, object, keyField: keyField ?? '', reloads: [], overlays: overlayObjects, showEdit, ...(expandObject !== '' ? { expandObject } : {}),
|
|
525
|
-
// 带行占位的删除确认:动作 id -> 确认文案模板(运行期按被删行插值)
|
|
526
|
-
...(Object.keys(removeConfirms).length > 0 ? { removeConfirms } : {}),
|
|
527
|
-
...(Object.keys(createPrefills).length > 0 ? { createPrefills } : {}),
|
|
344
|
+
scope, object, keyField: keyField ?? '', reloads: [], overlays: overlayObjects, showEdit, rowsPath: entityEmit.compiled.listShape.rows, ...(expandObject !== '' ? { expandObject } : {}),
|
|
528
345
|
overlayActions: {
|
|
529
346
|
...Object.fromEntries(actions.filter((a) => a.builtin === 'openOverlay' && a.targetOverlay !== undefined).map((a) => [a.id, a.targetOverlay as string])),
|
|
530
347
|
...(rowClickName !== undefined ? { select: rowClickName } : {}),
|
|
@@ -541,7 +358,7 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
541
358
|
out.events[`${ids.dialogClose}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.close);
|
|
542
359
|
// K-7:form 视图的 title(字符串两态通用,或 { create, edit })覆写弹窗标题;缺省取动作名
|
|
543
360
|
const titles = dialogTitles((entity.view?.form as KitViewForm | undefined)?.title, { create: createCopy, edit: editCopy });
|
|
544
|
-
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 }));
|
|
545
362
|
}
|
|
546
363
|
|
|
547
364
|
const main = mainHtml({ filter: entityEmit.parts.filter ?? '', toolbar: entityEmit.parts.toolbar ?? '', list: listHtml }, areaClass);
|
|
@@ -550,5 +367,5 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
550
367
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
551
368
|
for (const c of Object.values(CRUD_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
552
369
|
|
|
553
|
-
return
|
|
370
|
+
return finishBizCompile(out, html);
|
|
554
371
|
}
|