soma-kit 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1473
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 } 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 { removeConfirmTemplates, 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 */
|
|
@@ -139,13 +142,10 @@ export function normalizeMember(raw: unknown, opts: NormalizeOptions): { obj: Ki
|
|
|
139
142
|
if (view.summary === undefined) { view.summary = listView; delete view.list; }
|
|
140
143
|
else fail('list 与 summary 不能同时是写死形状件', `${opts.path}.view.list`);
|
|
141
144
|
}
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
delete view[slot];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
145
|
+
// 槽位白名单(单一真源消费 roleDef.views)
|
|
146
|
+
const roleName = opts.roleName ?? opts.path.split('.').pop() ?? 'object';
|
|
147
|
+
const roleDef = opts.roleDef;
|
|
148
|
+
checkRoleAllowedViews(roleName, { view }, roleDef, diagnostics, opts.path);
|
|
149
149
|
if (isRec(view.list)) view.list = normalizeList(view.list as KitViewForm & Rec);
|
|
150
150
|
|
|
151
151
|
// 缺省视图
|
|
@@ -210,40 +210,55 @@ export function normalizeMember(raw: unknown, opts: NormalizeOptions): { obj: Ki
|
|
|
210
210
|
|
|
211
211
|
const PLAIN_ACTION = /^ACTION \| (?!kit\.)(?!data\.)/;
|
|
212
212
|
|
|
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
213
|
/** 字段动作的语义事件回传 id:由字段与动作名拼出,小写 snake_case */
|
|
226
214
|
export function fieldActionId(field: string, action: string): string {
|
|
227
215
|
return `${field}_${action}`.toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
|
228
216
|
}
|
|
229
217
|
|
|
230
218
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
219
|
+
* 枢纽字段动作槽位表:每项是一条要绑在枢纽 `field_action_<序号>` 上的管道(序号 = 数组位置)。
|
|
220
|
+
* 摘要字段 / 工具栏 / 矩阵保存等点击拿不到选中行,改成:事件 -> `SCOPE | semantic | link_field_<序号>`(枢纽持有当前选中行)
|
|
221
|
+
* -> 枢纽抛 `field_action_<序号> { value, row }` -> 这条管道(ACTION | 名字)。每个动作各占一个槽位,不分流。
|
|
222
|
+
*/
|
|
223
|
+
export type FieldSlots = string[];
|
|
224
|
+
|
|
225
|
+
/** 登记一条字段动作管道,返回要绑在源事件上的语义管道 */
|
|
226
|
+
export function addFieldSlot(slots: FieldSlots, link: string, pipe: string): string {
|
|
227
|
+
const index = slots.length;
|
|
228
|
+
slots.push(pipe);
|
|
229
|
+
return semanticPipe(link, `${KIT_LINK_EVENTS.fieldPrefix}${index}`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** 把字段动作槽位表绑到枢纽的 field_action_<序号> 事件上;超过槽位上限记 KIT-EVT-001 */
|
|
233
|
+
export function bindFieldSlots(events: Rec, hubId: string, slots: readonly string[], diagnostics: KitDiagnostic[]): void {
|
|
234
|
+
const overflow = actionSlotOverflow(slots.length, '联动枢纽的字段动作');
|
|
235
|
+
if (overflow !== null) diagnostics.push({ code: 'KIT-EVT-001', path: 'product', message: overflow });
|
|
236
|
+
slots.forEach((pipe, i) => { events[`${hubId}.${actionSlotEvent(KIT_ACTION_SLOT_BASE.field, i)}`] = pipe; });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 选中项变化后要重取的各依赖作用域:枢纽按 pickSlots 依次抛 picked_0 … picked_<n-1>,每个作用域的重取各绑一条
|
|
241
|
+
* `SCOPE | window-reload` 管道(不共用一个事件)。枢纽的 show 必须已登记(本函数补 pickSlots)。
|
|
242
|
+
*/
|
|
243
|
+
export function bindPickedReloads(parts: Parts, hubId: string, scopes: readonly string[]): void {
|
|
244
|
+
const overflow = actionSlotOverflow(scopes.length, '联动枢纽的选中项重取');
|
|
245
|
+
if (overflow !== null) parts.diagnostics.push({ code: 'KIT-EVT-001', path: 'product', message: overflow });
|
|
246
|
+
const shown = parts.show[hubId];
|
|
247
|
+
if (isRec(shown) && isRec(shown.props)) shown.props.pickSlots = scopes.length;
|
|
248
|
+
scopes.forEach((s, i) => { parts.events[`${hubId}.${actionSlotEvent('picked', i)}`] = reloadPipe(s); });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* 摘要里的字段动作(Switch 等 change 事件)载荷只有 `{ value }`,不知道是哪一行(core 不替字段事件补 row):
|
|
253
|
+
* 把事件里的具名动作管道换成枢纽语义事件,管道本身登记进字段动作槽位表。
|
|
234
254
|
*/
|
|
235
|
-
export function liftFieldActions(object: string, link: string, events: Rec):
|
|
236
|
-
const steps: Array<Rec> = [];
|
|
255
|
+
export function liftFieldActions(object: string, link: string, events: Rec, slots: FieldSlots): void {
|
|
237
256
|
const prefix = `${object}__summary__`;
|
|
257
|
+
const ctxPrefix = `${staticCtxAnchor(object, 'summary')}.`;
|
|
238
258
|
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 });
|
|
259
|
+
if (!k.startsWith(prefix) || k.startsWith(ctxPrefix) || typeof v !== 'string' || !PLAIN_ACTION.test(v)) continue;
|
|
260
|
+
events[k] = addFieldSlot(slots, link, v);
|
|
245
261
|
}
|
|
246
|
-
return steps;
|
|
247
262
|
}
|
|
248
263
|
|
|
249
264
|
export interface MemberArgs {
|
|
@@ -254,15 +269,11 @@ export interface MemberArgs {
|
|
|
254
269
|
/** 链接作用域:所有语义事件发往这里 */
|
|
255
270
|
link: string;
|
|
256
271
|
hubId: string;
|
|
257
|
-
/** 应用动作之后要追加的刷新管道(如协调组件的 kit_reload) */
|
|
258
|
-
refresh: readonly string[];
|
|
259
272
|
/** 列表行可点选(行点击抛 row_action,kit_action: select) */
|
|
260
273
|
pick?: boolean;
|
|
261
274
|
emitInput?: KitEmitInput;
|
|
262
|
-
/**
|
|
263
|
-
fieldSteps?:
|
|
264
|
-
/** 累积带预填的「新建」钮(H1a):语义事件名 -> { 字段: 字面量 },调用方整表交给协调组件的 createPrefills */
|
|
265
|
-
createPrefills?: Record<string, Record<string, unknown>>;
|
|
275
|
+
/** 累积枢纽字段动作槽位(绑到枢纽的 field_action_<序号> 事件上,见 bindFieldSlots) */
|
|
276
|
+
fieldSteps?: FieldSlots;
|
|
266
277
|
}
|
|
267
278
|
|
|
268
279
|
export interface MemberResult {
|
|
@@ -289,6 +300,8 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
289
300
|
{ object, scope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
290
301
|
{
|
|
291
302
|
registeredActions: ctx.registeredActions,
|
|
303
|
+
// 删除在途忙态的作用域:协调组件用 link 登记(通道名带对象名,不同成员不串)
|
|
304
|
+
removeScope: link,
|
|
292
305
|
formMode: 'create',
|
|
293
306
|
...(a.pick === true ? { pickOnRow: true } : {}),
|
|
294
307
|
...(a.emitInput ?? {}),
|
|
@@ -302,70 +315,31 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
302
315
|
const rowsEv = events[rowsAnchor(object)];
|
|
303
316
|
const selKey = `${selAnchor(object)}.row_select`;
|
|
304
317
|
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 }>();
|
|
318
|
+
if (a.fieldSteps !== undefined) liftFieldActions(object, link, events, a.fieldSteps);
|
|
319
|
+
// ③:工具栏具名动作点击没有载荷、拿不到选中的主单。改成「点击 -> 枢纽语义事件 -> 枢纽抛 field_action_<序号> { row: 当前选中行 }
|
|
320
|
+
// -> ACTION | 名字」,动作回调的 row 就是当前选中主单;动作之后的重取由 defineKitActions 在有协调组件的页面里固定执行
|
|
309
321
|
if (a.fieldSteps !== undefined) {
|
|
310
322
|
for (const act of actions) {
|
|
311
323
|
if (act.on !== 'toolbar') continue;
|
|
312
324
|
const click = `${toolbarAnchor(object, act.id)}.click`;
|
|
313
325
|
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 });
|
|
326
|
+
if (typeof cur === 'string' && PLAIN_ACTION.test(cur)) events[click] = addFieldSlot(a.fieldSteps, link, cur);
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
328
330
|
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
331
|
if (act.on !== 'toolbar') return;
|
|
333
332
|
const click = `${toolbarAnchor(object, act.id)}.click`;
|
|
334
333
|
if (act.builtin === LINK_BUILTIN.create) {
|
|
335
|
-
// H1a:联动型业务组件的「新建」钮也可带预填(多个预设类型的新建钮各写各的 prefill);联动对象没有筛选来源,只许字面量
|
|
336
334
|
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));
|
|
335
|
+
events[click] = semanticPipe(link, KIT_COORD_EVENTS.openCreate, pipeTails(act, at, out.diagnostics));
|
|
362
336
|
} else if (act.builtin === 'reload') {
|
|
363
337
|
// K-2:刷新内置动作
|
|
364
338
|
events[click] = semanticPipe(link, KIT_COORD_EVENTS.reload, pipeTails(act, `behavior.actions[${i}]`, out.diagnostics));
|
|
365
339
|
}
|
|
366
340
|
});
|
|
367
341
|
|
|
368
|
-
// ----
|
|
342
|
+
// ---- 行操作:同一个实例,每个行动作各抛 row_action_<序号>,按它在操作列 actions 里的位置各绑一条管道(尾段写在对应管道上)
|
|
369
343
|
const listHtml = r.parts.list ?? '';
|
|
370
344
|
const rowActs = actions.filter((x) => x.on === 'row');
|
|
371
345
|
const pick = a.pick === true;
|
|
@@ -376,29 +350,38 @@ export function emitMember(out: Parts, a: MemberArgs): MemberResult {
|
|
|
376
350
|
const nested: Rec = isRec(events[rowsKey]) ? { ...(events[rowsKey] as Rec) } : {};
|
|
377
351
|
// 只有行模板真的产出了操作列锚点(原事件表里有它)才写回;虚拟表 / 树表 / 看板 / 只配右键菜单的表没有这个节点,写了会在挂载期缺事件源
|
|
378
352
|
// 仅行点击(pickOnRow)无行操作时事件表没有这一项,但 html 里补了无按钮的操作列实例,也要写(否则行点击接线丢失)
|
|
379
|
-
const hadRowOps = nested
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
353
|
+
const hadRowOps = Object.keys(nested).some((k) => k.startsWith(`${ops}.${KIT_ACTION_SLOT_BASE.row}_`)) || listHtml.includes(`data-soma-id="${ops}"`);
|
|
354
|
+
for (const k of Object.keys(nested)) if (k.startsWith(`${ops}.${KIT_ACTION_SLOT_BASE.row}_`)) delete nested[k];
|
|
355
|
+
const slots = rowActionSlotsOf(r.ir);
|
|
356
|
+
const routes: KitRowActionRoute[] = [];
|
|
357
|
+
// 本成员有内置删除:登记「对象 -> 主键字段名」与带行占位的确认模板,由模板经 linkRemoveProps 展开进协调组件 props
|
|
358
|
+
if (rowActs.some((x) => x.builtin === 'remove')) {
|
|
359
|
+
out.removeKeys[object] = keyFieldOf(obj) ?? '';
|
|
360
|
+
Object.assign(out.removeConfirms, removeConfirmTemplates(rowActs, object, true));
|
|
361
|
+
}
|
|
362
|
+
if (pick) routes.push({ id: 'select', pipe: semanticPipe(link, KIT_LINK_EVENTS.pick) });
|
|
363
|
+
for (const act of rowActs) {
|
|
384
364
|
const at = `behavior.actions.${act.id}`;
|
|
385
|
-
if (act.builtin === LINK_BUILTIN.edit)
|
|
386
|
-
if (act.builtin === 'reload')
|
|
365
|
+
if (act.builtin === LINK_BUILTIN.edit) { routes.push({ id: act.id, pipe: semanticPipe(link, KIT_COORD_EVENTS.openEdit, pipeTails(act, at, out.diagnostics)) }); continue; }
|
|
366
|
+
if (act.builtin === 'reload') { routes.push({ id: act.id, pipe: semanticPipe(link, KIT_COORD_EVENTS.reload, pipeTails(act, at, out.diagnostics)) }); continue; }
|
|
367
|
+
// 内置删除:经协调组件 kit_remove(尾段规则与 StandardCrud 同一份,见 shared/remove-wire.ts)
|
|
368
|
+
if (act.builtin === 'remove') { routes.push({ id: act.id, pipe: removePipe(link, act, at, out.diagnostics) }); continue; }
|
|
387
369
|
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 });
|
|
370
|
+
if (pipe !== null) routes.push({ id: act.id, pipe });
|
|
395
371
|
}
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
372
|
+
if (routes.length > 0) {
|
|
373
|
+
rewriteRowActions({
|
|
374
|
+
events, nested, routes, hadRowOps,
|
|
375
|
+
ops: { anchor: ops, ids: slots.rows, pick: true },
|
|
376
|
+
nestedTargets: [{ anchor: ctxMenuAnchor(object), ids: slots.menu }],
|
|
377
|
+
pageTargets: [
|
|
378
|
+
{ anchor: virtualAnchor(object), ids: slots.rows, pick: true },
|
|
379
|
+
{ anchor: treeAnchor(object), ids: slots.rows, pick: true },
|
|
380
|
+
{ anchor: ctxMenuAnchor(object), ids: slots.menu },
|
|
381
|
+
{ anchor: staticCtxAnchor(object, 'list'), ids: slots.staticMenus.list ?? [] },
|
|
382
|
+
{ anchor: staticCtxAnchor(object, 'summary'), ids: slots.staticMenus.summary ?? [] },
|
|
383
|
+
],
|
|
384
|
+
});
|
|
402
385
|
}
|
|
403
386
|
if (Object.keys(nested).length > 0) events[rowsKey] = nested;
|
|
404
387
|
}
|
|
@@ -415,12 +398,25 @@ export interface Parts {
|
|
|
415
398
|
components: Set<string>;
|
|
416
399
|
candidates: Set<string>;
|
|
417
400
|
diagnostics: KitDiagnostic[];
|
|
401
|
+
/** 有内置删除行动作的成员对象 -> 主键字段名(emitMember 累积;协调组件 removeKeys) */
|
|
402
|
+
removeKeys: Record<string, string>;
|
|
403
|
+
/** 带行占位的删除确认模板,键 `${对象}:${动作id}`(emitMember 累积;协调组件 removeConfirms) */
|
|
404
|
+
removeConfirms: Record<string, string>;
|
|
418
405
|
}
|
|
419
406
|
|
|
420
407
|
export function newParts(components: readonly string[]): Parts {
|
|
421
408
|
return {
|
|
422
409
|
show: {}, data: {}, scopes: {}, events: {},
|
|
423
410
|
components: new Set(components), candidates: new Set<string>(), diagnostics: [],
|
|
411
|
+
removeKeys: {}, removeConfirms: {},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** 协调组件 props 里与成员删除有关的两项(removeKeys / removeConfirms,空的不写):各 link 系模板只管展开,计算只此一份 */
|
|
416
|
+
export function linkRemoveProps(parts: Pick<Parts, 'removeKeys' | 'removeConfirms'>): Rec {
|
|
417
|
+
return {
|
|
418
|
+
...(Object.keys(parts.removeKeys).length > 0 ? { removeKeys: { ...parts.removeKeys } } : {}),
|
|
419
|
+
...(Object.keys(parts.removeConfirms).length > 0 ? { removeConfirms: { ...parts.removeConfirms } } : {}),
|
|
424
420
|
};
|
|
425
421
|
}
|
|
426
422
|
|
|
@@ -437,8 +433,10 @@ export function addEmit(into: Parts, r: KitEmitResult): void {
|
|
|
437
433
|
/** 保证对象有作用域声明(window-reload 按它取对象名);没有就补一个只带 results 切片、owner 是枢纽的最小声明 */
|
|
438
434
|
export function ensureScope(parts: Parts, id: string, object: string, ownerId: string): SomaScopeDecl {
|
|
439
435
|
const have = parts.scopes[id];
|
|
440
|
-
|
|
441
|
-
|
|
436
|
+
// emitObject 为「带 from 的独立表单」补的是 slices 为空的最小声明(供 window-reload 按作用域取对象);
|
|
437
|
+
// 成员需要的是 results 切片,空声明不算已有,原地补上(保留 mirrors 等其余字段)
|
|
438
|
+
if (have !== undefined && have.slices.length > 0) return have;
|
|
439
|
+
const decl: SomaScopeDecl = { ...(have ?? {}), id, object, slices: [{ name: 'results', owner: ownerId }] };
|
|
442
440
|
parts.scopes[id] = decl;
|
|
443
441
|
return decl;
|
|
444
442
|
}
|
|
@@ -478,9 +476,8 @@ export function classesIn(html: string): string[] {
|
|
|
478
476
|
return [...out];
|
|
479
477
|
}
|
|
480
478
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
479
|
+
import { esc } from '../../shared/escape';
|
|
480
|
+
export { esc };
|
|
484
481
|
|
|
485
482
|
export function cls(value: string): string {
|
|
486
483
|
return value === '' ? '' : ` class="${esc(value)}"`;
|
|
@@ -17,30 +17,19 @@ import type { KitObject } from '../../object-renderer/types';
|
|
|
17
17
|
import type { KitFragment } from '../../compile/fragment';
|
|
18
18
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
19
19
|
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS } from '../shared/coordinator';
|
|
20
|
+
import { bizObjectName, finishBizCompile, validateBizAreaClass } from '../shared/compile-helpers';
|
|
20
21
|
import { wireDialogForm } from '../shared/pipes';
|
|
21
|
-
import {
|
|
22
|
+
import { OVERLAY_SHELL_CLASS, dialogHtml, dialogIds, dialogTitles } from '../shared/overlay-shell';
|
|
22
23
|
import { KIT_LINK_MIRRORS, KIT_SEL_PATH } from '../link/hub';
|
|
23
24
|
import {
|
|
24
|
-
IDENT,
|
|
25
|
-
normalizeMember, patchProps,
|
|
25
|
+
IDENT, bindFieldSlots, bindPickedReloads, classesIn, emitMember, grantPageReset, isRec, keyFieldOf, linkRemoveProps, mirrorPath, newParts,
|
|
26
|
+
normalizeMember, patchProps, semanticPipe, sortMirrors, type FieldSlots, type Rec,
|
|
26
27
|
} from '../link/shared';
|
|
28
|
+
import { MasterSubWorkstation } from './index';
|
|
27
29
|
import { MASTER_SUB_AREAS, MASTER_SUB_CLASS, masterSubHtml, masterSubIds, type SubBlock } from './shell';
|
|
28
30
|
|
|
29
|
-
const RESERVED = new Set(['page', 'p', 'ctrl', 'frame', 'tabs']);
|
|
30
31
|
export function masterSubObjectName(pageId: string, role: string): string {
|
|
31
|
-
|
|
32
|
-
return RESERVED.has(name) ? `${name}_obj` : name;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function finish(out: Parts, html: string): KitFragment {
|
|
36
|
-
return {
|
|
37
|
-
html,
|
|
38
|
-
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
39
|
-
events: out.events,
|
|
40
|
-
components: [...out.components].sort(),
|
|
41
|
-
candidates: [...out.candidates].sort(),
|
|
42
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
43
|
-
};
|
|
32
|
+
return bizObjectName(pageId, role);
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
@@ -54,17 +43,13 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
54
43
|
const rawAside = input.objects.aside;
|
|
55
44
|
if (!isRec(rawMaster) || !isRec(rawMaster.schema) || !isRec(rawMaster.behavior)) {
|
|
56
45
|
fail('KIT-BIZ-001', 'MasterSubWorkstation 缺少必填对象角色槽 master(需含 schema 与 behavior)', 'product.objects.master');
|
|
57
|
-
return
|
|
46
|
+
return finishBizCompile(out, '');
|
|
58
47
|
}
|
|
59
48
|
if (!isRec(rawSubs) || Object.keys(rawSubs).length === 0) {
|
|
60
49
|
fail('KIT-BIZ-001', 'MasterSubWorkstation 缺少必填对象角色槽 subs(至少 1 个从属对象)', 'product.objects.subs');
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
for (const key of Object.keys(input.areaClass ?? {})) {
|
|
64
|
-
if (!(MASTER_SUB_AREAS as readonly string[]).includes(key)) {
|
|
65
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 MasterSubWorkstation 的区域闭集 ${MASTER_SUB_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
66
|
-
}
|
|
50
|
+
return finishBizCompile(out, '');
|
|
67
51
|
}
|
|
52
|
+
validateBizAreaClass(input, 'MasterSubWorkstation', MASTER_SUB_AREAS, out.diagnostics);
|
|
68
53
|
// 可选辅助栏(aside,单个对象):写 behavior.from 时按选中行取数;只放写死形状组件(如 AsyncResultPanel 的 outcome)时不需要 behavior
|
|
69
54
|
if (rawAside !== undefined && !isRec(rawAside)) {
|
|
70
55
|
fail('KIT-BIZ-001', 'aside 必须是对象声明(可选辅助栏:behavior.from 按选中行取数,或 view.summary.staticComponent 放写死形状组件)', 'product.objects.aside');
|
|
@@ -72,6 +57,9 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
72
57
|
const subNames = Object.keys(rawSubs);
|
|
73
58
|
for (const n of subNames) {
|
|
74
59
|
if (!IDENT.test(n)) fail('KIT-PAGE-001', `从属对象名 "${n}" 必须是标识符(字母数字下划线)`, `product.objects.subs.${n}`);
|
|
60
|
+
if (n === 'master' || n === 'aside') {
|
|
61
|
+
fail('KIT-BIZ-001', `从属对象名 "${n}" 与保留角色名撞名,禁止静默覆盖主对象或辅助栏`, `product.objects.subs.${n}`);
|
|
62
|
+
}
|
|
75
63
|
const s = rawSubs[n];
|
|
76
64
|
// 写死形状的数据组件(staticComponent)按 map 取值,不需要 schema
|
|
77
65
|
const v = isRec(s) && isRec(s.view) ? s.view : undefined;
|
|
@@ -80,7 +68,7 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
80
68
|
fail('KIT-BIZ-001', `subs.${n} 必须是对象声明(schema / behavior;写死形状组件可省 schema)`, `product.objects.subs.${n}`);
|
|
81
69
|
}
|
|
82
70
|
}
|
|
83
|
-
if (out.diagnostics.length > 0) return
|
|
71
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
84
72
|
|
|
85
73
|
const ids = masterSubIds(ctx.pageId);
|
|
86
74
|
const areaClass = input.areaClass ?? {};
|
|
@@ -91,8 +79,9 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
91
79
|
// ---- 主对象
|
|
92
80
|
const masterNorm = normalizeMember(rawMaster, {
|
|
93
81
|
path: 'product.objects.master',
|
|
82
|
+
roleName: 'master',
|
|
94
83
|
// filter:主列表的筛选条(语义同 StandardCrud:提交写 filter 切片并重取主列表;选中行失效时枢纽回退到首行并重取各从属对象)
|
|
95
|
-
|
|
84
|
+
roleDef: MasterSubWorkstation.roles.master,
|
|
96
85
|
ensure: ['list', 'summary'],
|
|
97
86
|
withForm: true,
|
|
98
87
|
...(ctx.locale !== undefined ? { locale: ctx.locale } : {}),
|
|
@@ -102,7 +91,7 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
102
91
|
const masterKey = keyFieldOf(master);
|
|
103
92
|
if (masterKey === undefined) {
|
|
104
93
|
fail('KIT-BIZ-001', 'master 的 schema 必须有 key 字段(或名为 id 的字段):从属对象靠它关联', 'product.objects.master.schema');
|
|
105
|
-
return
|
|
94
|
+
return finishBizCompile(out, '');
|
|
106
95
|
}
|
|
107
96
|
const selKey = mirrorPath(link, KIT_LINK_MIRRORS.selKey);
|
|
108
97
|
const selRow = mirrorPath(link, KIT_LINK_MIRRORS.selRow);
|
|
@@ -116,7 +105,8 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
116
105
|
const linkKey = typeof behavior.linkKey === 'string' && behavior.linkKey !== '' ? behavior.linkKey : masterKey;
|
|
117
106
|
const norm = normalizeMember(raw, {
|
|
118
107
|
path: `product.objects.subs.${n}`,
|
|
119
|
-
|
|
108
|
+
roleName: 'subs',
|
|
109
|
+
roleDef: MasterSubWorkstation.roles.subs,
|
|
120
110
|
ensure: 'any',
|
|
121
111
|
withForm: false,
|
|
122
112
|
params: { [linkKey]: `$${selKey}` },
|
|
@@ -134,7 +124,8 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
134
124
|
const linkKey = typeof behavior.linkKey === 'string' && behavior.linkKey !== '' ? behavior.linkKey : masterKey;
|
|
135
125
|
const norm = normalizeMember(rawAside, {
|
|
136
126
|
path: 'product.objects.aside',
|
|
137
|
-
|
|
127
|
+
roleName: 'aside',
|
|
128
|
+
roleDef: MasterSubWorkstation.roles.aside,
|
|
138
129
|
ensure: 'any',
|
|
139
130
|
withForm: false,
|
|
140
131
|
...(linked ? { params: { [linkKey]: `$${selKey}` }, requireLink: true } : {}),
|
|
@@ -143,15 +134,11 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
143
134
|
const object = masterSubObjectName(ctx.pageId, 'aside');
|
|
144
135
|
aside = { object, scope: `${object}_scope`, obj: norm.obj, linked };
|
|
145
136
|
}
|
|
146
|
-
if (out.diagnostics.length > 0) return
|
|
137
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
147
138
|
|
|
148
|
-
|
|
149
|
-
const refresh = [semanticPipe(link, KIT_COORD_EVENTS.reload)];
|
|
150
|
-
const fieldSteps: Array<Rec> = [];
|
|
151
|
-
// H1a:带预填的「新建」钮(语义事件名 -> { 字段: 字面量 }),整表交协调组件
|
|
152
|
-
const createPrefills: Record<string, Record<string, unknown>> = {};
|
|
139
|
+
const fieldSteps: FieldSlots = [];
|
|
153
140
|
const m = emitMember(out, {
|
|
154
|
-
object: masterName, scope: masterScope, obj: master, ctx, link, hubId: ids.hub,
|
|
141
|
+
object: masterName, scope: masterScope, obj: master, ctx, link, hubId: ids.hub, pick: true, fieldSteps,
|
|
155
142
|
emitInput: {
|
|
156
143
|
summaryPath: selRow,
|
|
157
144
|
formModePath: mirrorPath(link, mk.mode.key),
|
|
@@ -163,7 +150,7 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
163
150
|
const subBlocks: SubBlock[] = [];
|
|
164
151
|
const pageScopes: string[] = [];
|
|
165
152
|
for (const s of subs) {
|
|
166
|
-
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.hub,
|
|
153
|
+
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.hub, fieldSteps });
|
|
167
154
|
subBlocks.push({
|
|
168
155
|
title: s.title,
|
|
169
156
|
html: [sm.r.parts.toolbar ?? '', sm.r.parts.filter ?? '', sm.listHtml, sm.r.parts.summary ?? ''].filter((x) => x !== '').join('\n'),
|
|
@@ -172,7 +159,7 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
172
159
|
}
|
|
173
160
|
let asideHtml = '';
|
|
174
161
|
if (aside !== undefined) {
|
|
175
|
-
const am = emitMember(out, { object: aside.object, scope: aside.scope, obj: aside.obj, ctx, link, hubId: ids.hub,
|
|
162
|
+
const am = emitMember(out, { object: aside.object, scope: aside.scope, obj: aside.obj, ctx, link, hubId: ids.hub, fieldSteps });
|
|
176
163
|
asideHtml = [am.r.parts.toolbar ?? '', am.r.parts.filter ?? '', am.listHtml, am.r.parts.summary ?? ''].filter((x) => x !== '').join('\n');
|
|
177
164
|
if (aside.linked && grantPageReset(out, aside.scope, ids.hub)) pageScopes.push(aside.scope);
|
|
178
165
|
}
|
|
@@ -209,7 +196,7 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
209
196
|
const createName = master.behavior.actions?.find((a) => a.builtin === 'openCreate')?.name ?? kitText('soma.kit.create', undefined, ctx.locale);
|
|
210
197
|
const editName = master.behavior.actions?.find((a) => a.builtin === 'openEdit')?.name ?? kitText('soma.kit.edit', undefined, ctx.locale);
|
|
211
198
|
dialog = dialogHtml(d, dialogTitles(master.view.form.title, { create: createName, edit: editName }), m.r.parts.form ?? '', { dialog: areaClass.dialog ?? '' }, CLOSE_LABEL);
|
|
212
|
-
for (const c of Object.values(
|
|
199
|
+
for (const c of Object.values(OVERLAY_SHELL_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
213
200
|
}
|
|
214
201
|
|
|
215
202
|
// ---- 枢纽与协调组件
|
|
@@ -219,17 +206,17 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
219
206
|
};
|
|
220
207
|
out.show[ids.coord] = {
|
|
221
208
|
props: {
|
|
222
|
-
scope: link, object: masterName, keyField: masterKey, reloads: reloadTargets.map((s) => s.object), overlays: {},
|
|
223
|
-
...(
|
|
209
|
+
scope: link, object: masterName, keyField: masterKey, reloads: reloadTargets.map((s) => s.object), overlays: {}, rowsPath: m.r.compiled.listShape.rows,
|
|
210
|
+
...linkRemoveProps(out),
|
|
224
211
|
},
|
|
225
212
|
};
|
|
226
|
-
out
|
|
227
|
-
|
|
213
|
+
bindPickedReloads(out, ids.hub, reloadTargets.map((s) => s.scope));
|
|
214
|
+
bindFieldSlots(out.events, ids.hub, fieldSteps, out.diagnostics);
|
|
228
215
|
|
|
229
216
|
// ---- 壳
|
|
230
217
|
const masterHtml = [m.r.parts.toolbar ?? '', m.r.parts.filter ?? '', m.listHtml].filter((x) => x !== '').join('\n');
|
|
231
218
|
const html = masterSubHtml(ids, { master: masterHtml, summary: m.r.parts.summary ?? '', subs: subBlocks, dialog, aside: asideHtml }, areaClass, input.class);
|
|
232
219
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
233
220
|
for (const c of Object.values(MASTER_SUB_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
234
|
-
return
|
|
221
|
+
return finishBizCompile(out, html);
|
|
235
222
|
}
|