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
package/src/biz/link/hub.ts
CHANGED
|
@@ -6,14 +6,18 @@
|
|
|
6
6
|
// · 行选中(语义事件 link_pick,载荷带整行)→ 写 selection;行数据到达时默认选首行(autoSelect);
|
|
7
7
|
// · 选中项一变(不论谁写的):把依赖对象的 view 切片回第 1 页(经路径写者 `page`),等镜像落地后上抛 picked { id, item, prefill },
|
|
8
8
|
// 页面再接 `SCOPE | window-reload`(MasterSub)或 `SCOPE | semantic kit_pick`(CategoryCrud,交给协调组件写预填并重取);
|
|
9
|
-
// · 摘要字段动作(语义事件 link_field_
|
|
9
|
+
// · 摘要字段动作(语义事件 link_field_<序号>):字段事件自己的载荷只有 { value },由本组件补上当前选中行后抛槽位事件 field_action_<序号> { value, row },
|
|
10
|
+
// 页面给每个槽位各绑一条管道。
|
|
10
11
|
// 为什么走 SCOPE | semantic:行内组件写切片会被拒收(切片写者必须是页面直接声明的实例),这是唯一没有写者核对的通路。
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
+
import type { SomaComponentDefinition, SomaRegionPort } from 'soma-core';
|
|
14
|
+
import { createKitController } from '../../base/shared';
|
|
15
|
+
import { withKitViewTransition } from '../../base/view-transition';
|
|
16
|
+
import { KIT_ACTION_SLOT_BASE, KIT_PICK_SLOT_MAX, actionSlotEmits, actionSlotEvent, emitActionSlot } from '../../base/action-slots';
|
|
13
17
|
|
|
14
18
|
export const KIT_LINK_EVENTS = {
|
|
15
19
|
pick: 'link_pick',
|
|
16
|
-
/** 摘要字段动作:`link_field_
|
|
20
|
+
/** 摘要字段动作:`link_field_<序号>`(序号 = 动作槽位) */
|
|
17
21
|
fieldPrefix: 'link_field_',
|
|
18
22
|
} as const;
|
|
19
23
|
|
|
@@ -21,10 +25,16 @@ export const KIT_LINK_EVENTS = {
|
|
|
21
25
|
export const KIT_LINK_MIRRORS = {
|
|
22
26
|
selKey: 'link_sel_key',
|
|
23
27
|
selRow: 'link_sel_row',
|
|
28
|
+
/** 有选中项时为真(MasterSub 从属区面板的显隐) */
|
|
29
|
+
selHas: 'link_sel_has',
|
|
30
|
+
/** 互补真值:没有选中项时为真(MasterSub 未选中空态的显隐) */
|
|
31
|
+
selNone: 'link_sel_none',
|
|
24
32
|
} as const;
|
|
25
33
|
|
|
26
34
|
/** selection 切片里存选中项的路径:值形如 { row: <选中项> }(镜像路径 `row` / `row.<主键>`) */
|
|
27
35
|
export const KIT_SEL_PATH = 'row';
|
|
36
|
+
/** selection 切片里「当前没有选中项」的互补布尔路径(枢纽写,MasterSub 的未选中空态读它) */
|
|
37
|
+
export const KIT_NONE_PATH = 'none';
|
|
28
38
|
|
|
29
39
|
type Rec = Record<string, unknown>;
|
|
30
40
|
|
|
@@ -103,24 +113,34 @@ export function createKitLinkHub(): SomaComponentDefinition {
|
|
|
103
113
|
rows: { type: 'array', default: [], desc: '主列表的行数据(autoSelect 用)' },
|
|
104
114
|
afterRemove: { type: 'string', default: '', desc: "选中项从行里消失后的去向:'next' = 原位置的下一条(没有就上一条);空 = 首行" },
|
|
105
115
|
pageScopes: { type: 'array', default: [], desc: '选中项变化时要回第 1 页的作用域 id(它们 view 切片的 page 路径写者是本组件)' },
|
|
116
|
+
pickSlots: { type: 'number', default: 0, desc: '选中项变化时依次抛 picked_0 … picked_<n-1> 的个数(每个依赖对象的重取各绑一个槽位;0 = 只抛 picked)' },
|
|
117
|
+
watchFilters: { type: 'array', default: [], desc: '筛选条的作用域 id:它们的 filter 切片一变(每次提交 / 重置都算,值没变也算)就回第 1 页并上抛 picked,页面据此重取(MultiObjectBoard 的全局筛选)' },
|
|
106
118
|
},
|
|
107
119
|
emits: {
|
|
108
120
|
picked: { payload: { id: { type: 'string' }, item: { type: 'object' }, prefill: { type: 'object' } }, desc: '选中项变化(页面据此重取依赖对象)' },
|
|
109
|
-
|
|
121
|
+
...actionSlotEmits('picked', { id: { type: 'string' }, item: { type: 'object' }, prefill: { type: 'object' } }, '选中项变化的分发槽位(pickSlots 个):依赖多个对象要各自重取时,每个对象的重取各绑一个槽位', KIT_PICK_SLOT_MAX),
|
|
122
|
+
...actionSlotEmits(KIT_ACTION_SLOT_BASE.field, { value: { type: 'string' }, row: { type: 'object' } }, '摘要字段动作 / 工具栏具名动作:载荷带当前选中行(字段事件自己只有 { value })'),
|
|
110
123
|
},
|
|
111
124
|
scope: { slices: ['selection', 'view'] },
|
|
112
125
|
},
|
|
113
126
|
services: ['region'],
|
|
114
127
|
templateHtml: '<div data-soma-id="root" class="hidden"></div>',
|
|
115
|
-
controllerFactory: (
|
|
116
|
-
const props = (): Rec =>
|
|
128
|
+
controllerFactory: createKitController((api) => {
|
|
129
|
+
const props = (): Rec => api.props() as Rec;
|
|
117
130
|
let offs: Array<() => void> = [];
|
|
118
131
|
let lastKey: string | null | undefined;
|
|
119
132
|
let alive = false;
|
|
120
133
|
let lastRows: readonly unknown[] = [];
|
|
121
134
|
|
|
135
|
+
/** 选中项变化:抛 picked,并按 pickSlots 依次抛 picked_0 … picked_<n-1>(页面给每个依赖对象的重取各绑一条管道,不共用一个事件) */
|
|
136
|
+
const emitPicked = (payload: Rec): void => {
|
|
137
|
+
api.emit('picked', payload);
|
|
138
|
+
const n = Math.min(Math.max(0, Math.floor(Number(props().pickSlots) || 0)), KIT_PICK_SLOT_MAX);
|
|
139
|
+
for (let i = 0; i < n; i += 1) api.emit(actionSlotEvent('picked', i), payload);
|
|
140
|
+
};
|
|
141
|
+
|
|
122
142
|
const regionOf = (id: string): SomaRegionPort | null => {
|
|
123
|
-
const svc = (
|
|
143
|
+
const svc = (api.services as { region?: (scopeId: string) => SomaRegionPort | null } | undefined)?.region;
|
|
124
144
|
return id !== '' && typeof svc === 'function' ? svc(id) : null;
|
|
125
145
|
};
|
|
126
146
|
const port = (): SomaRegionPort | null => regionOf(strOf(props().scope));
|
|
@@ -129,7 +149,10 @@ export function createKitLinkHub(): SomaComponentDefinition {
|
|
|
129
149
|
const setSelection = (row: unknown): void => {
|
|
130
150
|
try {
|
|
131
151
|
// 写在 row 路径下:core 对 selection 整槽写有形状判据(对象带 scope 字段且不在 page / all-matching 内即拒收),业务行有 scope 字段时整槽写会静默失败
|
|
132
|
-
port()?.slice('selection')
|
|
152
|
+
const sel = port()?.slice('selection');
|
|
153
|
+
sel?.set(row, KIT_SEL_PATH);
|
|
154
|
+
// 「当前没有选中项」的互补真值:页面语法没有取反,未选中态的显隐只能读它
|
|
155
|
+
sel?.set(!isRec(row), KIT_NONE_PATH);
|
|
133
156
|
} catch (err) {
|
|
134
157
|
// 不是 selection 的写者(CategoryCrud 由分类树自己写):忽略
|
|
135
158
|
console.debug('[soma-kit] KitLinkHub 无权写 selection', err);
|
|
@@ -188,13 +211,28 @@ export function createKitLinkHub(): SomaComponentDefinition {
|
|
|
188
211
|
await tick();
|
|
189
212
|
// 卸载了,或等待期间选中项又变了(后一次调用会自己通知):不再上抛过期的选中
|
|
190
213
|
if (!alive || lastKey !== key) return;
|
|
191
|
-
|
|
214
|
+
emitPicked({
|
|
192
215
|
id: key ?? '',
|
|
193
216
|
item: isRec(row) ? row : {},
|
|
194
217
|
prefill: createPrefill(row, keyField(), strOf(props().linkKey)),
|
|
195
218
|
});
|
|
196
219
|
};
|
|
197
220
|
|
|
221
|
+
// 筛选条提交 / 重置:filter 切片每写一次就通知一次(值没变也通知),按“选中项变了”同一条路回第 1 页、等镜像落地后上抛 picked
|
|
222
|
+
const watchFilters = (): void => {
|
|
223
|
+
for (const id of listOf(props().watchFilters)) {
|
|
224
|
+
const slice = regionOf(id)?.slice('filter');
|
|
225
|
+
if (!slice) continue;
|
|
226
|
+
offs.push(slice.subscribe(() => {
|
|
227
|
+
if (!alive) return;
|
|
228
|
+
resetPages();
|
|
229
|
+
void tick().then(() => {
|
|
230
|
+
if (alive) emitPicked({ id: '', item: {}, prefill: {} });
|
|
231
|
+
});
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
198
236
|
const syncDefault = (): void => {
|
|
199
237
|
const p = props();
|
|
200
238
|
if (p.autoSelect !== true && p.autoSelect !== 'true') return;
|
|
@@ -209,14 +247,18 @@ export function createKitLinkHub(): SomaComponentDefinition {
|
|
|
209
247
|
|
|
210
248
|
const onSemantic = (name: string, payload: Readonly<Rec>): void => {
|
|
211
249
|
if (name === KIT_LINK_EVENTS.pick) {
|
|
212
|
-
|
|
250
|
+
// 用户点行换选中项:右侧内容区走页面过渡(不支持 / 减弱动效时直接写,与原行为一致);默认选中等程序写入不走过渡
|
|
251
|
+
if (isRec(payload.row)) {
|
|
252
|
+
const row = payload.row;
|
|
253
|
+
withKitViewTransition(() => setSelection(row));
|
|
254
|
+
}
|
|
213
255
|
return;
|
|
214
256
|
}
|
|
215
257
|
if (name.startsWith(KIT_LINK_EVENTS.fieldPrefix)) {
|
|
216
258
|
// 字段动作的载荷只有 { value }:补上当前选中行,不依赖 core 补 row
|
|
217
259
|
const row = selectedOf(port()?.slice('selection')?.get());
|
|
218
|
-
|
|
219
|
-
|
|
260
|
+
const slot = Number(name.slice(KIT_LINK_EVENTS.fieldPrefix.length));
|
|
261
|
+
if (Number.isInteger(slot)) emitActionSlot((n, p) => api.emit(n, p), KIT_ACTION_SLOT_BASE.field, slot, {
|
|
220
262
|
value: payload.value,
|
|
221
263
|
row: isRec(row) ? row : {},
|
|
222
264
|
});
|
|
@@ -224,30 +266,35 @@ export function createKitLinkHub(): SomaComponentDefinition {
|
|
|
224
266
|
};
|
|
225
267
|
|
|
226
268
|
return {
|
|
227
|
-
|
|
269
|
+
attach() {
|
|
228
270
|
alive = true;
|
|
229
271
|
const p = port();
|
|
230
272
|
if (!p) return;
|
|
231
273
|
lastKey = linkKeyOf(selectedOf(p.slice('selection')?.get()), keyField());
|
|
274
|
+
// 初始没有选中项:先把互补真值置真(行数据到达后默认选中会置回假)
|
|
275
|
+
if (lastKey === null) {
|
|
276
|
+
try { p.slice('selection')?.set(true, KIT_NONE_PATH); } catch { /* 非 selection 写者(分类树自己写):忽略 */ }
|
|
277
|
+
}
|
|
232
278
|
offs.push(p.onSemantic(onSemantic));
|
|
233
279
|
const sel = p.slice('selection');
|
|
234
280
|
if (sel) offs.push(sel.subscribe(() => { void onSelection(); }));
|
|
235
281
|
watchSort();
|
|
282
|
+
watchFilters();
|
|
236
283
|
syncDefault();
|
|
284
|
+
return () => {
|
|
285
|
+
alive = false;
|
|
286
|
+
for (const off of offs) off();
|
|
287
|
+
offs = [];
|
|
288
|
+
sortWatching.clear();
|
|
289
|
+
sortSeen.clear();
|
|
290
|
+
};
|
|
237
291
|
},
|
|
238
|
-
|
|
292
|
+
render() {
|
|
239
293
|
watchSort();
|
|
240
294
|
syncDefault();
|
|
241
295
|
},
|
|
242
|
-
onUnmount(): void {
|
|
243
|
-
alive = false;
|
|
244
|
-
for (const off of offs) off();
|
|
245
|
-
offs = [];
|
|
246
|
-
sortWatching.clear();
|
|
247
|
-
sortSeen.clear();
|
|
248
|
-
},
|
|
249
296
|
};
|
|
250
|
-
},
|
|
297
|
+
}),
|
|
251
298
|
};
|
|
252
299
|
}
|
|
253
300
|
|
package/src/biz/link/shared.ts
CHANGED
|
@@ -10,16 +10,19 @@ import { regionMirrorStatePath } from 'soma-core';
|
|
|
10
10
|
import { kitText } from '../../i18n/kit-text';
|
|
11
11
|
import type { SomaScopeDecl, SomaScopeMirrorDecl, SomaScopeSliceDecl } from 'soma-core';
|
|
12
12
|
import { KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
13
|
-
import { actionPipeline } from '../../object-renderer/emit-events';
|
|
13
|
+
import { actionPipeline, rowActionSlotsOf } from '../../object-renderer/emit-events';
|
|
14
|
+
import { KIT_ACTION_SLOT_BASE, actionSlotEvent, actionSlotOverflow, pickSlotOverflow } from '../../base/action-slots';
|
|
14
15
|
import { emitObject, type KitEmitInput, type KitEmitResult } from '../../object-renderer/emit-object';
|
|
16
|
+
import { primaryKeyFieldOf } from '../../object-renderer/key-field';
|
|
15
17
|
import { ctxMenuAnchor, opsAnchor, rowsAnchor, selAnchor, staticCtxAnchor, toolbarAnchor, treeAnchor, virtualAnchor } from '../../object-renderer/emit-static';
|
|
16
18
|
import type {
|
|
17
|
-
KitAction, KitCollection, KitDiagnostic, KitObject, KitType, KitViewForm,
|
|
19
|
+
KitAction, KitCollection, KitDiagnostic, KitObject, KitType, KitViewForm,
|
|
18
20
|
} from '../../object-renderer/types';
|
|
19
|
-
import { KIT_COORD_EVENTS,
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
21
|
+
import { KIT_COORD_EVENTS, rewriteRowActions, type KitRowActionRoute } from '../shared/coordinator';
|
|
22
|
+
import { checkRoleAllowedViews } from '../shared/compile-helpers';
|
|
23
|
+
import { pipeTails, reloadPipe, semanticPipe } from '../shared/pipes';
|
|
24
|
+
import { removePipe } from '../shared/remove-wire';
|
|
25
|
+
import type { KitBizContext, KitBizRole } from '../types';
|
|
23
26
|
import { KIT_LINK_EVENTS } from './hub';
|
|
24
27
|
|
|
25
28
|
export type Rec = Record<string, unknown>;
|
|
@@ -41,9 +44,7 @@ export function mirrorPath(scope: string, key: string): string {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export function keyFieldOf(obj: KitObject): string | undefined {
|
|
44
|
-
|
|
45
|
-
if (hit !== undefined) return hit;
|
|
46
|
-
return 'id' in obj.schema ? 'id' : undefined;
|
|
47
|
+
return primaryKeyFieldOf(obj.schema);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export function patchProps(show: Rec, id: string, props: Rec): boolean {
|
|
@@ -62,8 +63,10 @@ function clone<T>(v: T): T {
|
|
|
62
63
|
export interface NormalizeOptions {
|
|
63
64
|
/** 诊断路径前缀,如 `product.objects.master` */
|
|
64
65
|
path: string;
|
|
65
|
-
/**
|
|
66
|
-
|
|
66
|
+
/** 角色名(缺省取 path 末尾段) */
|
|
67
|
+
roleName?: string;
|
|
68
|
+
/** 该角色的契约定义(从业务组件 roles[roleName] 读取允许的视图槽闭集) */
|
|
69
|
+
roleDef?: Pick<KitBizRole, 'views'>;
|
|
67
70
|
/** 缺失时补缺省 {} 的视图;'any' = list / summary 都没有时补 list */
|
|
68
71
|
ensure: ReadonlyArray<'list' | 'summary'> | 'any';
|
|
69
72
|
/** true:有 write 则补 form、合成新增 / 编辑;false:写了 form 视图报 KIT-BIZ-003 */
|
|
@@ -84,6 +87,7 @@ function toCollection(raw: unknown): KitCollection {
|
|
|
84
87
|
if (isRec(raw)) return { ...(raw as unknown as KitCollection) };
|
|
85
88
|
if (raw === 'cards') return { type: 'cards', cols: 1 };
|
|
86
89
|
if (raw === 'stack') return { type: 'stack' };
|
|
90
|
+
if (raw === 'compact-list') return { type: 'compact-list' };
|
|
87
91
|
return { type: 'table' };
|
|
88
92
|
}
|
|
89
93
|
|
|
@@ -139,13 +143,10 @@ export function normalizeMember(raw: unknown, opts: NormalizeOptions): { obj: Ki
|
|
|
139
143
|
if (view.summary === undefined) { view.summary = listView; delete view.list; }
|
|
140
144
|
else fail('list 与 summary 不能同时是写死形状件', `${opts.path}.view.list`);
|
|
141
145
|
}
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
delete view[slot];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
146
|
+
// 槽位白名单(单一真源消费 roleDef.views)
|
|
147
|
+
const roleName = opts.roleName ?? opts.path.split('.').pop() ?? 'object';
|
|
148
|
+
const roleDef = opts.roleDef;
|
|
149
|
+
checkRoleAllowedViews(roleName, { view }, roleDef, diagnostics, opts.path);
|
|
149
150
|
if (isRec(view.list)) view.list = normalizeList(view.list as KitViewForm & Rec);
|
|
150
151
|
|
|
151
152
|
// 缺省视图
|
|
@@ -210,40 +211,55 @@ export function normalizeMember(raw: unknown, opts: NormalizeOptions): { obj: Ki
|
|
|
210
211
|
|
|
211
212
|
const PLAIN_ACTION = /^ACTION \| (?!kit\.)(?!data\.)/;
|
|
212
213
|
|
|
213
|
-
/** 具名应用动作(非 kit 内置、非 data.submit)之后追加刷新步骤:规格 5.3「写入成功后协同刷新」 */
|
|
214
|
-
function wrapActions(node: Rec, refresh: readonly string[], link: string): void {
|
|
215
|
-
for (const [k, v] of Object.entries(node)) {
|
|
216
|
-
if (typeof v === 'string' && PLAIN_ACTION.test(v)) {
|
|
217
|
-
// 尾段(confirm / permission)直接带在 ACTION 步骤上,被拒则刷新不执行
|
|
218
|
-
node[k] = { steps: actionSteps(v, refresh) };
|
|
219
|
-
} else if (isRec(v) && !Array.isArray(v.steps)) {
|
|
220
|
-
wrapActions(v, refresh, link);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
214
|
/** 字段动作的语义事件回传 id:由字段与动作名拼出,小写 snake_case */
|
|
226
215
|
export function fieldActionId(field: string, action: string): string {
|
|
227
216
|
return `${field}_${action}`.toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
|
228
217
|
}
|
|
229
218
|
|
|
230
219
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
220
|
+
* 枢纽字段动作槽位表:每项是一条要绑在枢纽 `field_action_<序号>` 上的管道(序号 = 数组位置)。
|
|
221
|
+
* 摘要字段 / 工具栏 / 矩阵保存等点击拿不到选中行,改成:事件 -> `SCOPE | semantic | link_field_<序号>`(枢纽持有当前选中行)
|
|
222
|
+
* -> 枢纽抛 `field_action_<序号> { value, row }` -> 这条管道(ACTION | 名字)。每个动作各占一个槽位,不分流。
|
|
223
|
+
*/
|
|
224
|
+
export type FieldSlots = string[];
|
|
225
|
+
|
|
226
|
+
/** 登记一条字段动作管道,返回要绑在源事件上的语义管道 */
|
|
227
|
+
export function addFieldSlot(slots: FieldSlots, link: string, pipe: string): string {
|
|
228
|
+
const index = slots.length;
|
|
229
|
+
slots.push(pipe);
|
|
230
|
+
return semanticPipe(link, `${KIT_LINK_EVENTS.fieldPrefix}${index}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** 把字段动作槽位表绑到枢纽的 field_action_<序号> 事件上;超过槽位上限记 KIT-EVT-001 */
|
|
234
|
+
export function bindFieldSlots(events: Rec, hubId: string, slots: readonly string[], diagnostics: KitDiagnostic[]): void {
|
|
235
|
+
const overflow = actionSlotOverflow(slots.length, '联动枢纽的字段动作');
|
|
236
|
+
if (overflow !== null) diagnostics.push({ code: 'KIT-EVT-001', path: 'product', message: overflow });
|
|
237
|
+
slots.forEach((pipe, i) => { events[`${hubId}.${actionSlotEvent(KIT_ACTION_SLOT_BASE.field, i)}`] = pipe; });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 选中项变化后要重取的各依赖作用域:枢纽按 pickSlots 依次抛 picked_0 … picked_<n-1>,每个作用域的重取各绑一条
|
|
242
|
+
* `SCOPE | window-reload` 管道(不共用一个事件)。枢纽的 show 必须已登记(本函数补 pickSlots)。
|
|
243
|
+
*/
|
|
244
|
+
export function bindPickedReloads(parts: Parts, hubId: string, scopes: readonly string[]): void {
|
|
245
|
+
const overflow = pickSlotOverflow(scopes.length);
|
|
246
|
+
if (overflow !== null) parts.diagnostics.push({ code: 'KIT-EVT-001', path: 'product', message: overflow });
|
|
247
|
+
const shown = parts.show[hubId];
|
|
248
|
+
if (isRec(shown) && isRec(shown.props)) shown.props.pickSlots = scopes.length;
|
|
249
|
+
scopes.forEach((s, i) => { parts.events[`${hubId}.${actionSlotEvent('picked', i)}`] = reloadPipe(s); });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 摘要里的字段动作(Switch 等 change 事件)载荷只有 `{ value }`,不知道是哪一行(core 不替字段事件补 row):
|
|
254
|
+
* 把事件里的具名动作管道换成枢纽语义事件,管道本身登记进字段动作槽位表。
|
|
234
255
|
*/
|
|
235
|
-
export function liftFieldActions(object: string, link: string, events: Rec):
|
|
236
|
-
const steps: Array<Rec> = [];
|
|
256
|
+
export function liftFieldActions(object: string, link: string, events: Rec, slots: FieldSlots): void {
|
|
237
257
|
const prefix = `${object}__summary__`;
|
|
258
|
+
const ctxPrefix = `${staticCtxAnchor(object, 'summary')}.`;
|
|
238
259
|
for (const [k, v] of Object.entries(events)) {
|
|
239
|
-
if (!k.startsWith(prefix) || typeof v !== 'string' || !PLAIN_ACTION.test(v)) continue;
|
|
240
|
-
|
|
241
|
-
const act = v.split(' | ')[1] ?? '';
|
|
242
|
-
const sid = fieldActionId(anchor.slice(prefix.length), act);
|
|
243
|
-
events[k] = semanticPipe(link, `${KIT_LINK_EVENTS.fieldPrefix}${sid}`);
|
|
244
|
-
steps.push({ when: { field: 'id', op: 'eq', value: sid }, do: v });
|
|
260
|
+
if (!k.startsWith(prefix) || k.startsWith(ctxPrefix) || typeof v !== 'string' || !PLAIN_ACTION.test(v)) continue;
|
|
261
|
+
events[k] = addFieldSlot(slots, link, v);
|
|
245
262
|
}
|
|
246
|
-
return steps;
|
|
247
263
|
}
|
|
248
264
|
|
|
249
265
|
export interface MemberArgs {
|
|
@@ -254,15 +270,16 @@ export interface MemberArgs {
|
|
|
254
270
|
/** 链接作用域:所有语义事件发往这里 */
|
|
255
271
|
link: string;
|
|
256
272
|
hubId: string;
|
|
257
|
-
/** 应用动作之后要追加的刷新管道(如协调组件的 kit_reload) */
|
|
258
|
-
refresh: readonly string[];
|
|
259
273
|
/** 列表行可点选(行点击抛 row_action,kit_action: select) */
|
|
260
274
|
pick?: boolean;
|
|
261
275
|
emitInput?: KitEmitInput;
|
|
262
|
-
/**
|
|
263
|
-
fieldSteps?:
|
|
264
|
-
/**
|
|
265
|
-
|
|
276
|
+
/** 累积枢纽字段动作槽位(绑到枢纽的 field_action_<序号> 事件上,见 bindFieldSlots) */
|
|
277
|
+
fieldSteps?: FieldSlots;
|
|
278
|
+
/**
|
|
279
|
+
* 本组件声明的附加浮层名(overlays.*)。给了才解释行动作 `builtin: openOverlay`:目标在表内的接协调组件的 crud_open_overlay
|
|
280
|
+
* (载荷带当前行;浮层目标由协调组件按动作 id 反查);不给(没有浮层的 link 系组件)保持原样。
|
|
281
|
+
*/
|
|
282
|
+
overlayTargets?: ReadonlySet<string>;
|
|
266
283
|
}
|
|
267
284
|
|
|
268
285
|
export interface MemberResult {
|
|
@@ -289,6 +306,8 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
289
306
|
{ object, scope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
290
307
|
{
|
|
291
308
|
registeredActions: ctx.registeredActions,
|
|
309
|
+
// 删除在途忙态的作用域:协调组件用 link 登记(通道名带对象名,不同成员不串)
|
|
310
|
+
removeScope: link,
|
|
292
311
|
formMode: 'create',
|
|
293
312
|
...(a.pick === true ? { pickOnRow: true } : {}),
|
|
294
313
|
...(a.emitInput ?? {}),
|
|
@@ -302,70 +321,31 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
302
321
|
const rowsEv = events[rowsAnchor(object)];
|
|
303
322
|
const selKey = `${selAnchor(object)}.row_select`;
|
|
304
323
|
if (isRec(rowsEv) && selKey in rowsEv) rowsEv[selKey] = semanticPipe(link, KIT_COORD_EVENTS.select);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
//
|
|
308
|
-
const toolbarNamed = new Map<string, { id: string; pipe: string }>();
|
|
324
|
+
if (a.fieldSteps !== undefined) liftFieldActions(object, link, events, a.fieldSteps);
|
|
325
|
+
// ③:工具栏具名动作点击没有载荷、拿不到选中的主单。改成「点击 -> 枢纽语义事件 -> 枢纽抛 field_action_<序号> { row: 当前选中行 }
|
|
326
|
+
// -> ACTION | 名字」,动作回调的 row 就是当前选中主单;动作之后的重取由 defineKitActions 在有协调组件的页面里固定执行
|
|
309
327
|
if (a.fieldSteps !== undefined) {
|
|
310
328
|
for (const act of actions) {
|
|
311
329
|
if (act.on !== 'toolbar') continue;
|
|
312
330
|
const click = `${toolbarAnchor(object, act.id)}.click`;
|
|
313
331
|
const cur = events[click];
|
|
314
|
-
if (typeof cur === 'string' && PLAIN_ACTION.test(cur))
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
wrapActions(events, a.refresh, link);
|
|
318
|
-
// ③:工具栏点击没有载荷、拿不到选中的主单。改成「点击 -> 枢纽语义事件 -> 枢纽抛 field_action { id, row: 当前选中行 } ->
|
|
319
|
-
// 页面按 id 分流到原动作」,动作回调的 row 就是当前选中主单;动作之后的刷新由枢纽事件末尾统一追加
|
|
320
|
-
if (a.fieldSteps !== undefined) {
|
|
321
|
-
for (const [click, { id, pipe }] of toolbarNamed) {
|
|
322
|
-
const sid = fieldActionId('toolbar', id);
|
|
323
|
-
events[click] = semanticPipe(link, `${KIT_LINK_EVENTS.fieldPrefix}${sid}`);
|
|
324
|
-
a.fieldSteps.push({ when: { field: 'id', op: 'eq', value: sid }, do: pipe });
|
|
332
|
+
if (typeof cur === 'string' && PLAIN_ACTION.test(cur)) events[click] = addFieldSlot(a.fieldSteps, link, cur);
|
|
325
333
|
}
|
|
326
334
|
}
|
|
327
335
|
|
|
328
336
|
actions.forEach((act, i) => {
|
|
329
|
-
if (act.prefill !== undefined && act.builtin !== LINK_BUILTIN.create) {
|
|
330
|
-
out.diagnostics.push({ code: 'KIT-ACT-007', path: `behavior.actions[${i}].prefill`, message: `动作 ${act.id} 的 prefill 只用于 builtin: openCreate` });
|
|
331
|
-
}
|
|
332
337
|
if (act.on !== 'toolbar') return;
|
|
333
338
|
const click = `${toolbarAnchor(object, act.id)}.click`;
|
|
334
339
|
if (act.builtin === LINK_BUILTIN.create) {
|
|
335
|
-
// H1a:联动型业务组件的「新建」钮也可带预填(多个预设类型的新建钮各写各的 prefill);联动对象没有筛选来源,只许字面量
|
|
336
340
|
const at = `behavior.actions[${i}]`;
|
|
337
|
-
|
|
338
|
-
if (act.prefill !== undefined) {
|
|
339
|
-
const dollar = Object.entries(act.prefill as Rec).filter(([, v]) => typeof v === 'string' && v.startsWith('$'));
|
|
340
|
-
if (a.createPrefills === undefined) {
|
|
341
|
-
out.diagnostics.push({ code: 'KIT-ACT-007', path: `${at}.prefill`, message: `动作 ${act.id} 写了 prefill,但这个位置的新建不带预填(预填只在 StandardCrud、MasterSub 的主对象、CategoryCrud 的明细对象的新建钮上生效)` });
|
|
342
|
-
} else if (dollar.length > 0) {
|
|
343
|
-
out.diagnostics.push({
|
|
344
|
-
code: 'KIT-ACT-007', path: `${at}.prefill.${dollar[0]![0]}`,
|
|
345
|
-
message: `动作 ${act.id} 的 prefill.${dollar[0]![0]} 写了取值路径 ${String(dollar[0]![1])}:联动型业务组件(主从 / 分类 / 多对象)的新建没有筛选来源,预填只许字面量;需要按筛选预填请用 StandardCrud`,
|
|
346
|
-
});
|
|
347
|
-
} else {
|
|
348
|
-
const prefill = prefillOf(act, new Set(Object.keys(obj.schema)), false, at, out.diagnostics);
|
|
349
|
-
if (prefill !== undefined && prefill !== null) {
|
|
350
|
-
eventName = createEventName(act);
|
|
351
|
-
const table = a.createPrefills;
|
|
352
|
-
if (table !== undefined) {
|
|
353
|
-
if (eventName in table && JSON.stringify(table[eventName]) !== JSON.stringify(prefill)) {
|
|
354
|
-
out.diagnostics.push({ code: 'KIT-ACT-007', path: `${at}.id`, message: `动作 ${act.id} 的 id 归一化后与同组件里另一个新建钮重名(${eventName})而预填不同,请换一个动作 id` });
|
|
355
|
-
}
|
|
356
|
-
table[eventName] = prefill;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
events[click] = semanticPipe(link, eventName, pipeTails(act, at, out.diagnostics));
|
|
341
|
+
events[click] = semanticPipe(link, KIT_COORD_EVENTS.openCreate, pipeTails(act, at, out.diagnostics));
|
|
362
342
|
} else if (act.builtin === 'reload') {
|
|
363
343
|
// K-2:刷新内置动作
|
|
364
344
|
events[click] = semanticPipe(link, KIT_COORD_EVENTS.reload, pipeTails(act, `behavior.actions[${i}]`, out.diagnostics));
|
|
365
345
|
}
|
|
366
346
|
});
|
|
367
347
|
|
|
368
|
-
// ----
|
|
348
|
+
// ---- 行操作:同一个实例,每个行动作各抛 row_action_<序号>,按它在操作列 actions 里的位置各绑一条管道(尾段写在对应管道上)
|
|
369
349
|
const listHtml = r.parts.list ?? '';
|
|
370
350
|
const rowActs = actions.filter((x) => x.on === 'row');
|
|
371
351
|
const pick = a.pick === true;
|
|
@@ -376,29 +356,42 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
376
356
|
const nested: Rec = isRec(events[rowsKey]) ? { ...(events[rowsKey] as Rec) } : {};
|
|
377
357
|
// 只有行模板真的产出了操作列锚点(原事件表里有它)才写回;虚拟表 / 树表 / 看板 / 只配右键菜单的表没有这个节点,写了会在挂载期缺事件源
|
|
378
358
|
// 仅行点击(pickOnRow)无行操作时事件表没有这一项,但 html 里补了无按钮的操作列实例,也要写(否则行点击接线丢失)
|
|
379
|
-
const hadRowOps = nested
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
359
|
+
const hadRowOps = Object.keys(nested).some((k) => k.startsWith(`${ops}.${KIT_ACTION_SLOT_BASE.row}_`)) || listHtml.includes(`data-soma-id="${ops}"`);
|
|
360
|
+
for (const k of Object.keys(nested)) if (k.startsWith(`${ops}.${KIT_ACTION_SLOT_BASE.row}_`)) delete nested[k];
|
|
361
|
+
const slots = rowActionSlotsOf(r.ir);
|
|
362
|
+
const routes: KitRowActionRoute[] = [];
|
|
363
|
+
// 本成员有内置删除:登记「对象 -> 主键字段名」,由模板经 linkRemoveProps 展开进协调组件 props(确认文案走 core 的 confirm 尾段,不再登记模板)
|
|
364
|
+
if (rowActs.some((x) => x.builtin === 'remove')) {
|
|
365
|
+
out.removeKeys[object] = keyFieldOf(obj) ?? '';
|
|
366
|
+
}
|
|
367
|
+
if (pick) routes.push({ id: 'select', pipe: semanticPipe(link, KIT_LINK_EVENTS.pick) });
|
|
368
|
+
for (const act of rowActs) {
|
|
384
369
|
const at = `behavior.actions.${act.id}`;
|
|
385
|
-
if (act.builtin === LINK_BUILTIN.edit)
|
|
386
|
-
if (act.builtin === 'reload')
|
|
370
|
+
if (act.builtin === LINK_BUILTIN.edit) { routes.push({ id: act.id, pipe: semanticPipe(link, KIT_COORD_EVENTS.openEdit, pipeTails(act, at, out.diagnostics)) }); continue; }
|
|
371
|
+
if (act.builtin === 'reload') { routes.push({ id: act.id, pipe: semanticPipe(link, KIT_COORD_EVENTS.reload, pipeTails(act, at, out.diagnostics)) }); continue; }
|
|
372
|
+
// 附加浮层(与 StandardCrud 同一条协调组件管道;目标存在性由业务组件编译前置校验)
|
|
373
|
+
if (act.builtin === 'openOverlay' && a.overlayTargets !== undefined && act.targetOverlay !== undefined && a.overlayTargets.has(act.targetOverlay)) {
|
|
374
|
+
routes.push({ id: act.id, pipe: semanticPipe(link, KIT_COORD_EVENTS.openOverlay, pipeTails(act, at, out.diagnostics)) });
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
// 内置删除:经协调组件 kit_remove(尾段规则与 StandardCrud 同一份,见 shared/remove-wire.ts)
|
|
378
|
+
if (act.builtin === 'remove') { routes.push({ id: act.id, pipe: removePipe(link, act, at, out.diagnostics) }); continue; }
|
|
387
379
|
const pipe = actionPipeline(act, at, { hasWrite: true, object, registeredActions: ctx.registeredActions }, []);
|
|
388
|
-
if (pipe
|
|
389
|
-
return [{ do: pipe }, ...(withRefresh ? a.refresh.map((p) => ({ do: p })) : [])];
|
|
390
|
-
};
|
|
391
|
-
for (const act of rowActs) {
|
|
392
|
-
const list = route(act, true);
|
|
393
|
-
if (list === null) continue;
|
|
394
|
-
for (const s of list) steps.push({ when: { field: 'kit_action', op: 'eq', value: act.id }, ...s });
|
|
380
|
+
if (pipe !== null) routes.push({ id: act.id, pipe });
|
|
395
381
|
}
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
382
|
+
if (routes.length > 0) {
|
|
383
|
+
rewriteRowActions({
|
|
384
|
+
events, nested, routes, hadRowOps,
|
|
385
|
+
ops: { anchor: ops, ids: slots.rows, pick: true },
|
|
386
|
+
nestedTargets: [{ anchor: ctxMenuAnchor(object), ids: slots.menu }],
|
|
387
|
+
pageTargets: [
|
|
388
|
+
{ anchor: virtualAnchor(object), ids: slots.rows, pick: true },
|
|
389
|
+
{ anchor: treeAnchor(object), ids: slots.rows, pick: true },
|
|
390
|
+
{ anchor: ctxMenuAnchor(object), ids: slots.menu },
|
|
391
|
+
{ anchor: staticCtxAnchor(object, 'list'), ids: slots.staticMenus.list ?? [] },
|
|
392
|
+
{ anchor: staticCtxAnchor(object, 'summary'), ids: slots.staticMenus.summary ?? [] },
|
|
393
|
+
],
|
|
394
|
+
});
|
|
402
395
|
}
|
|
403
396
|
if (Object.keys(nested).length > 0) events[rowsKey] = nested;
|
|
404
397
|
}
|
|
@@ -415,12 +408,22 @@ export interface Parts {
|
|
|
415
408
|
components: Set<string>;
|
|
416
409
|
candidates: Set<string>;
|
|
417
410
|
diagnostics: KitDiagnostic[];
|
|
411
|
+
/** 有内置删除行动作的成员对象 -> 主键字段名(emitMember 累积;协调组件 removeKeys) */
|
|
412
|
+
removeKeys: Record<string, string>;
|
|
418
413
|
}
|
|
419
414
|
|
|
420
415
|
export function newParts(components: readonly string[]): Parts {
|
|
421
416
|
return {
|
|
422
417
|
show: {}, data: {}, scopes: {}, events: {},
|
|
423
418
|
components: new Set(components), candidates: new Set<string>(), diagnostics: [],
|
|
419
|
+
removeKeys: {},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** 协调组件 props 里与成员删除有关的一项(removeKeys,空的不写):各 link 系模板只管展开,计算只此一份 */
|
|
424
|
+
export function linkRemoveProps(parts: Pick<Parts, 'removeKeys'>): Rec {
|
|
425
|
+
return {
|
|
426
|
+
...(Object.keys(parts.removeKeys).length > 0 ? { removeKeys: { ...parts.removeKeys } } : {}),
|
|
424
427
|
};
|
|
425
428
|
}
|
|
426
429
|
|
|
@@ -437,8 +440,10 @@ export function addEmit(into: Parts, r: KitEmitResult): void {
|
|
|
437
440
|
/** 保证对象有作用域声明(window-reload 按它取对象名);没有就补一个只带 results 切片、owner 是枢纽的最小声明 */
|
|
438
441
|
export function ensureScope(parts: Parts, id: string, object: string, ownerId: string): SomaScopeDecl {
|
|
439
442
|
const have = parts.scopes[id];
|
|
440
|
-
|
|
441
|
-
|
|
443
|
+
// emitObject 为「带 from 的独立表单」补的是 slices 为空的最小声明(供 window-reload 按作用域取对象);
|
|
444
|
+
// 成员需要的是 results 切片,空声明不算已有,原地补上(保留 mirrors 等其余字段)
|
|
445
|
+
if (have !== undefined && have.slices.length > 0) return have;
|
|
446
|
+
const decl: SomaScopeDecl = { ...(have ?? {}), id, object, slices: [{ name: 'results', owner: ownerId }] };
|
|
442
447
|
parts.scopes[id] = decl;
|
|
443
448
|
return decl;
|
|
444
449
|
}
|
|
@@ -478,16 +483,19 @@ export function classesIn(html: string): string[] {
|
|
|
478
483
|
return [...out];
|
|
479
484
|
}
|
|
480
485
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
486
|
+
import { esc } from '../../shared/escape';
|
|
487
|
+
export { esc };
|
|
484
488
|
|
|
485
489
|
export function cls(value: string): string {
|
|
486
490
|
return value === '' ? '' : ` class="${esc(value)}"`;
|
|
487
491
|
}
|
|
488
492
|
|
|
493
|
+
/** 无界面协作宿主(只持有切片 / 事件的数据组件):不占版面,不然业务壳根的 flex gap 会给每个零高度宿主各多量出一份间距(页面标题到首块多出 16~32px) */
|
|
494
|
+
const HEADLESS_HOSTS: ReadonlySet<string> = new Set(['KitLinkHub', 'KitCrudBridge']);
|
|
495
|
+
|
|
489
496
|
export function host(component: string, id: string): string {
|
|
490
|
-
|
|
497
|
+
const cls = HEADLESS_HOSTS.has(component) ? ' class="hidden"' : '';
|
|
498
|
+
return `<div data-soma-component="${component}" data-soma-id="${esc(id)}"${cls}></div>`;
|
|
491
499
|
}
|
|
492
500
|
|
|
493
501
|
export { reloadPipe, semanticPipe };
|