soma-kit 0.1.10 → 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 -1278
|
@@ -3,43 +3,28 @@
|
|
|
3
3
|
|
|
4
4
|
import { KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
5
5
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
6
|
-
import type { KitDiagnostic, KitObject
|
|
6
|
+
import type { KitDiagnostic, KitObject } from '../../object-renderer/types';
|
|
7
7
|
import type { KitFragment } from '../../compile/fragment';
|
|
8
|
-
import type { KitBizContext, KitBizInput } from '../types';
|
|
8
|
+
import type { KitBizContext, KitBizInput, KitBizRole } from '../types';
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
11
|
+
} from '../shared/compile-helpers';
|
|
12
|
+
import {
|
|
13
|
+
addEmit, isRec, normalizeMember, type Parts, type Rec,
|
|
11
14
|
} from '../link/shared';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** `<页面槽>_<角色或名字>`;撞保留名时加 `_obj` */
|
|
16
|
+
/** `<页面槽>_<角色或名字>` */
|
|
16
17
|
export function templateObjectName(pageId: string, name: string): string {
|
|
17
|
-
|
|
18
|
-
return TEMPLATE_RESERVED.has(full) ? `${full}_obj` : full;
|
|
18
|
+
return bizObjectName(pageId, name);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function finishTemplate(out: Parts, html: string): KitFragment {
|
|
22
|
-
return
|
|
23
|
-
html,
|
|
24
|
-
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
25
|
-
events: out.events,
|
|
26
|
-
components: [...out.components].sort(),
|
|
27
|
-
candidates: [...out.candidates].sort(),
|
|
28
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
29
|
-
};
|
|
22
|
+
return finishBizCompile(out, html);
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
/** areaClass 的键必须在区域闭集内(越界报 KIT-PAGE-001) */
|
|
33
26
|
export function checkAreas(input: KitBizInput, kind: string, areas: readonly string[], out: Parts): void {
|
|
34
|
-
|
|
35
|
-
if (!areas.includes(key)) {
|
|
36
|
-
out.diagnostics.push({
|
|
37
|
-
code: 'KIT-PAGE-001',
|
|
38
|
-
message: `areaClass 里的区域名 "${key}" 不在 ${kind} 的区域闭集 ${areas.join(' / ')} 内`,
|
|
39
|
-
path: `product.areaClass.${key}`,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
27
|
+
validateBizAreaClass(input, kind, areas, out.diagnostics);
|
|
43
28
|
}
|
|
44
29
|
|
|
45
30
|
/** 把候选类串里的各个类并入 out.candidates */
|
|
@@ -48,10 +33,16 @@ export function addClassTokens(out: Parts, classes: Record<string, string>): voi
|
|
|
48
33
|
}
|
|
49
34
|
|
|
50
35
|
/**
|
|
51
|
-
* 表单对象规整:只许 form
|
|
36
|
+
* 表单对象规整:只许 roleDef.views(缺省 form)视图,必须有 behavior.write,不支持 behavior.actions(提交 / 重置由表单自带按钮承担)。
|
|
52
37
|
* view 顶层的表单键(arrange / fields 等)归到 form 槽;缺省补 form: {}。
|
|
53
38
|
*/
|
|
54
|
-
export function normalizeFormObject(
|
|
39
|
+
export function normalizeFormObject(
|
|
40
|
+
raw: Rec,
|
|
41
|
+
path: string,
|
|
42
|
+
role: string,
|
|
43
|
+
diagnostics: KitDiagnostic[],
|
|
44
|
+
roleDef: Pick<KitBizRole, 'views'> = { views: ['form'] },
|
|
45
|
+
): KitObject {
|
|
55
46
|
const fail = (message: string, at: string): void => { diagnostics.push({ code: 'KIT-BIZ-003', message, path: at }); };
|
|
56
47
|
const view: Rec = isRec(raw.view) ? { ...raw.view } : {};
|
|
57
48
|
const slotKeys = Object.keys(view).filter((k) => (KIT_VIEW_SLOTS as readonly string[]).includes(k));
|
|
@@ -65,12 +56,7 @@ export function normalizeFormObject(raw: Rec, path: string, role: string, diagno
|
|
|
65
56
|
view.form = form;
|
|
66
57
|
}
|
|
67
58
|
}
|
|
68
|
-
|
|
69
|
-
if (slot !== 'form' && view[slot] !== undefined) {
|
|
70
|
-
fail(`${role} 只有 form 视图,不允许 ${slot}`, `${path}.view.${slot}`);
|
|
71
|
-
delete view[slot];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
59
|
+
checkRoleAllowedViews(role, { view }, roleDef, diagnostics, path);
|
|
74
60
|
if (view.form === undefined) view.form = {};
|
|
75
61
|
const behavior: Rec = isRec(raw.behavior) ? { ...raw.behavior } : {};
|
|
76
62
|
if (behavior.write === undefined) fail(`${role} 必须声明 behavior.write(提交走 write)`, `${path}.behavior.write`);
|
|
@@ -93,13 +79,25 @@ export interface ReadOnlyMember {
|
|
|
93
79
|
export function emitReadOnlyMember(
|
|
94
80
|
out: Parts,
|
|
95
81
|
raw: unknown,
|
|
96
|
-
opts: {
|
|
82
|
+
opts: {
|
|
83
|
+
object: string;
|
|
84
|
+
path: string;
|
|
85
|
+
roleName?: string;
|
|
86
|
+
roleDef?: Pick<KitBizRole, 'views'>;
|
|
87
|
+
ctx: KitBizContext;
|
|
88
|
+
},
|
|
97
89
|
): ReadOnlyMember | undefined {
|
|
98
|
-
const { object, path,
|
|
90
|
+
const { object, path, roleName, roleDef, ctx } = opts;
|
|
99
91
|
const before = out.diagnostics.length;
|
|
100
92
|
const src: Rec = isRec(raw) ? { ...raw } : {};
|
|
101
93
|
if (!isRec(src.behavior)) src.behavior = {};
|
|
102
|
-
const norm = normalizeMember(src, {
|
|
94
|
+
const norm = normalizeMember(src, {
|
|
95
|
+
path,
|
|
96
|
+
...(roleName !== undefined ? { roleName } : {}),
|
|
97
|
+
...(roleDef !== undefined ? { roleDef } : {}),
|
|
98
|
+
ensure: 'any',
|
|
99
|
+
withForm: false,
|
|
100
|
+
});
|
|
103
101
|
out.diagnostics.push(...norm.diagnostics);
|
|
104
102
|
const obj = norm.obj;
|
|
105
103
|
if ((obj.behavior.actions ?? []).length > 0) {
|
|
@@ -17,40 +17,38 @@
|
|
|
17
17
|
|
|
18
18
|
import type { SomaScopeMirrorDecl } from 'soma-core';
|
|
19
19
|
import { kitText } from '../../i18n/kit-text';
|
|
20
|
-
import {
|
|
20
|
+
import { KIT_GRAMMAR_RUNTIME } from '../../generated/kit-grammar-runtime';
|
|
21
|
+
import { KIT_CLASS_DEFAULTS, KIT_VIEW_FORM_KEYS } from '../../object-renderer/defaults';
|
|
21
22
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
22
|
-
import {
|
|
23
|
-
import { KIT_CLASS_DEFAULTS } from '../../object-renderer/defaults';
|
|
23
|
+
import { groupTabsFrame, toolbarAnchor, viewAnchor } from '../../object-renderer/emit-static';
|
|
24
24
|
import type { KitAction, KitObject } from '../../object-renderer/types';
|
|
25
25
|
import type { KitFragment } from '../../compile/fragment';
|
|
26
26
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
27
27
|
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS } from '../shared/coordinator';
|
|
28
|
+
import {
|
|
29
|
+
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
30
|
+
} from '../shared/compile-helpers';
|
|
28
31
|
import { pipeTails, wireDialogForm } from '../shared/pipes';
|
|
29
|
-
import {
|
|
32
|
+
import { OVERLAY_SHELL_CLASS, dialogHtml, dialogIds, dialogTitles } from '../shared/overlay-shell';
|
|
30
33
|
import {
|
|
31
|
-
IDENT, classesIn,
|
|
32
|
-
patchProps, semanticPipe, sortMirrors, type
|
|
34
|
+
IDENT, classesIn, emitMember, isRec, keyFieldOf, linkRemoveProps, mirrorPath, newParts, normalizeMember,
|
|
35
|
+
patchProps, semanticPipe, sortMirrors, type Rec,
|
|
33
36
|
} from '../link/shared';
|
|
37
|
+
import { RecordDetail } from './index';
|
|
34
38
|
import {
|
|
35
39
|
RECORD_DETAIL_AREAS, RECORD_DETAIL_CLASS, recordDetailHtml, recordDetailIds, type DetailBlock, type DetailTabs,
|
|
36
40
|
} from './shell';
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return RESERVED.has(name) ? `${name}_obj` : name;
|
|
42
|
+
interface GrammarRuntimeNarrow {
|
|
43
|
+
readonly objectLayer: {
|
|
44
|
+
readonly subsLayout: readonly string[];
|
|
45
|
+
};
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
events: out.events,
|
|
50
|
-
components: [...out.components].sort(),
|
|
51
|
-
candidates: [...out.candidates].sort(),
|
|
52
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
53
|
-
};
|
|
48
|
+
const SUBS_LAYOUT_VALUES: readonly string[] = (KIT_GRAMMAR_RUNTIME as unknown as GrammarRuntimeNarrow).objectLayer.subsLayout;
|
|
49
|
+
|
|
50
|
+
export function recordDetailObjectName(pageId: string, role: string): string {
|
|
51
|
+
return bizObjectName(pageId, role);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
function clone<T>(v: T): T {
|
|
@@ -69,7 +67,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
69
67
|
const rawSubs = input.objects.subs;
|
|
70
68
|
if (!isRec(rawRecord) || !isRec(rawRecord.schema) || !isRec(rawRecord.behavior)) {
|
|
71
69
|
fail('KIT-BIZ-001', 'RecordDetail 缺少必填对象角色槽 record(需含 schema 与 behavior)', 'product.objects.record');
|
|
72
|
-
return
|
|
70
|
+
return finishBizCompile(out, '');
|
|
73
71
|
}
|
|
74
72
|
if (rawRecord.behavior.from === undefined) {
|
|
75
73
|
fail('KIT-BIZ-003', 'RecordDetail 的 record 必须声明 behavior.from(挂载时取回单记录)', 'product.objects.record.behavior.from');
|
|
@@ -85,22 +83,27 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
85
83
|
}
|
|
86
84
|
// E5:关联子对象的布局(stack 缺省,逐块堆叠;tabs 合成一块,页签条切换)。键在 record 上,不开 product.config
|
|
87
85
|
const subsLayoutRaw = (rawRecord as unknown as Rec).subsLayout;
|
|
88
|
-
if (subsLayoutRaw !== undefined && subsLayoutRaw !== '
|
|
89
|
-
fail('KIT-BIZ-003', `subsLayout 取值 ${String(subsLayoutRaw)} 不在
|
|
86
|
+
if (subsLayoutRaw !== undefined && (typeof subsLayoutRaw !== 'string' || !SUBS_LAYOUT_VALUES.includes(subsLayoutRaw))) {
|
|
87
|
+
fail('KIT-BIZ-003', `subsLayout 取值 ${String(subsLayoutRaw)} 不在 ${SUBS_LAYOUT_VALUES.join(' / ')} 内`, 'product.objects.record.subsLayout');
|
|
90
88
|
}
|
|
91
89
|
const subsAsTabs = subsLayoutRaw === 'tabs';
|
|
92
90
|
if (rawGroups !== undefined && !isRec(rawGroups)) fail('KIT-BIZ-001', 'groups 必须是 { 名字: 分组声明 }', 'product.objects.groups');
|
|
93
91
|
if (rawSubs !== undefined && !isRec(rawSubs)) fail('KIT-BIZ-001', 'subs 必须是 { 名字: 对象声明 }', 'product.objects.subs');
|
|
94
|
-
|
|
95
|
-
if (!(RECORD_DETAIL_AREAS as readonly string[]).includes(key)) {
|
|
96
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 RecordDetail 的区域闭集 ${RECORD_DETAIL_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
92
|
+
validateBizAreaClass(input, 'RecordDetail', RECORD_DETAIL_AREAS, out.diagnostics);
|
|
99
93
|
const groupNames = isRec(rawGroups) ? Object.keys(rawGroups) : [];
|
|
100
94
|
const subNames = isRec(rawSubs) ? Object.keys(rawSubs) : [];
|
|
101
|
-
for (const n of groupNames)
|
|
95
|
+
for (const n of groupNames) {
|
|
96
|
+
if (!IDENT.test(n)) fail('KIT-PAGE-001', `分组名 "${n}" 必须是标识符(字母数字下划线)`, `product.objects.groups.${n}`);
|
|
97
|
+
if (n === 'record') fail('KIT-BIZ-001', `分组名 "${n}" 与保留角色名撞名,禁止静默覆盖主记录对象`, `product.objects.groups.${n}`);
|
|
98
|
+
}
|
|
102
99
|
for (const n of subNames) {
|
|
103
100
|
if (!IDENT.test(n)) fail('KIT-PAGE-001', `从属对象名 "${n}" 必须是标识符(字母数字下划线)`, `product.objects.subs.${n}`);
|
|
101
|
+
if (n === 'record') {
|
|
102
|
+
fail('KIT-BIZ-001', `从属对象名 "${n}" 与保留角色名撞名,禁止静默覆盖主记录对象`, `product.objects.subs.${n}`);
|
|
103
|
+
}
|
|
104
|
+
if (groupNames.includes(n)) {
|
|
105
|
+
fail('KIT-BIZ-001', `从属对象名 "${n}" 与分组名重名,禁止同名碰撞`, `product.objects.subs.${n}`);
|
|
106
|
+
}
|
|
104
107
|
const s = (rawSubs as Rec)[n];
|
|
105
108
|
const v = isRec(s) && isRec(s.view) ? s.view : undefined;
|
|
106
109
|
const isStatic = !!v && (v.staticComponent !== undefined || (isRec(v.summary) && v.summary.staticComponent !== undefined) || (isRec(v.list) && v.list.staticComponent !== undefined));
|
|
@@ -108,7 +111,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
108
111
|
fail('KIT-BIZ-001', `subs.${n} 必须是对象声明(schema / behavior;写死形状组件可省 schema)`, `product.objects.subs.${n}`);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
if (out.diagnostics.length > 0) return
|
|
114
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
112
115
|
|
|
113
116
|
const ids = recordDetailIds(ctx.pageId);
|
|
114
117
|
const areaClass = input.areaClass ?? {};
|
|
@@ -127,7 +130,8 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
127
130
|
if (!hasWrite && formView !== undefined) fail('KIT-BIZ-003', '声明了 form 视图但没有 behavior.write', 'product.objects.record.view.form');
|
|
128
131
|
const norm = normalizeMember(recSrc, {
|
|
129
132
|
path: 'product.objects.record',
|
|
130
|
-
|
|
133
|
+
roleName: 'record',
|
|
134
|
+
roleDef: RecordDetail.roles.record,
|
|
131
135
|
ensure: ['summary'],
|
|
132
136
|
withForm: false,
|
|
133
137
|
});
|
|
@@ -142,7 +146,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
142
146
|
if (a.on === 'row') fail('KIT-BIZ-003', `record 的动作 ${a.id}:详情台没有行,动作只许 on: toolbar / field`, `product.objects.record.behavior.actions[${i}].on`);
|
|
143
147
|
if (a.builtin === 'openCreate') fail('KIT-BIZ-003', `record 的动作 ${a.id}:详情台不能新增,builtin 只许 openEdit / reload`, `product.objects.record.behavior.actions[${i}].builtin`);
|
|
144
148
|
});
|
|
145
|
-
if (out.diagnostics.length > 0) return
|
|
149
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
146
150
|
if (hasWrite && !actions.some((a) => a.builtin === 'openEdit')) {
|
|
147
151
|
actions.unshift({ id: 'edit', name: EDIT_LABEL, on: 'toolbar', builtin: 'openEdit', tone: 'primary' });
|
|
148
152
|
}
|
|
@@ -163,7 +167,8 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
163
167
|
}
|
|
164
168
|
const sn = normalizeMember(raw, {
|
|
165
169
|
path: `product.objects.subs.${n}`,
|
|
166
|
-
|
|
170
|
+
roleName: 'subs',
|
|
171
|
+
roleDef: RecordDetail.roles.subs,
|
|
167
172
|
ensure: 'any',
|
|
168
173
|
withForm: false,
|
|
169
174
|
...(wantLink && linkKey !== undefined && recKey !== undefined ? { params: { [linkKey]: `$${recName}.${recKey}` }, requireLink: true } : {}),
|
|
@@ -172,13 +177,12 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
172
177
|
const object = recordDetailObjectName(ctx.pageId, `sub_${n}`);
|
|
173
178
|
subs.push({ object, scope: `${object}_scope`, obj: sn.obj, title: typeof raw.title === 'string' ? raw.title : '' });
|
|
174
179
|
}
|
|
175
|
-
if (out.diagnostics.length > 0) return
|
|
180
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
176
181
|
|
|
177
182
|
// ---- 发射
|
|
178
|
-
const refresh = [semanticPipe(link, KIT_COORD_EVENTS.reload)];
|
|
179
183
|
const mk = KIT_COORD_MIRRORS;
|
|
180
184
|
const m = emitMember(out, {
|
|
181
|
-
object: recName, scope: recScope, obj: record, ctx, link, hubId: ids.coord,
|
|
185
|
+
object: recName, scope: recScope, obj: record, ctx, link, hubId: ids.coord,
|
|
182
186
|
emitInput: { formMode: 'edit', formInitialPath: recPath },
|
|
183
187
|
});
|
|
184
188
|
// 工具栏内置动作:编辑 / 刷新交协调组件
|
|
@@ -201,10 +205,11 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
201
205
|
for (const k of loose) { s[k] = view[k]; delete view[k]; }
|
|
202
206
|
view.summary = s;
|
|
203
207
|
}
|
|
208
|
+
checkRoleAllowedViews('groups', { view }, RecordDetail.roles.groups, out.diagnostics, at);
|
|
204
209
|
for (const k of Object.keys(view)) if (k !== 'summary') fail('KIT-BIZ-003', `分组只有 summary 视图,不允许 ${k}`, `${at}.view.${k}`);
|
|
205
210
|
if (!isRec(view.summary)) fail('KIT-BIZ-001', `groups.${n} 必须有 view.summary(分组字段排布)`, `${at}.view`);
|
|
206
211
|
if (raw.schema !== undefined || raw.behavior !== undefined) fail('KIT-BIZ-003', `groups.${n} 不写 schema / behavior:字段字典继承 record,值读记录本身`, at);
|
|
207
|
-
if (out.diagnostics.length > 0) return
|
|
212
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
208
213
|
const object = recordDetailObjectName(ctx.pageId, `grp_${n}`);
|
|
209
214
|
const gobj = { schema: record.schema, behavior: {}, view: { summary: view.summary } } as unknown as KitObject;
|
|
210
215
|
const r = emitObject(
|
|
@@ -223,13 +228,13 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
223
228
|
|
|
224
229
|
const subBlocks: DetailBlock[] = [];
|
|
225
230
|
for (const s of subs) {
|
|
226
|
-
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.coord
|
|
231
|
+
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.coord });
|
|
227
232
|
subBlocks.push({
|
|
228
233
|
title: s.title,
|
|
229
234
|
html: [sm.r.parts.toolbar ?? '', sm.r.parts.filter ?? '', sm.listHtml, sm.r.parts.summary ?? ''].filter((x) => x !== '').join('\n'),
|
|
230
235
|
});
|
|
231
236
|
}
|
|
232
|
-
// 页签呈现:与视图 groups as: tabs 同一个实现(emit-static 的 groupTabsFrame
|
|
237
|
+
// 页签呈现:与视图 groups as: tabs 同一个实现(emit-static 的 groupTabsFrame,面板显隐与键盘都由 KitTabsWiring 接,没有页签事件)
|
|
233
238
|
let subsTabs: DetailTabs | undefined;
|
|
234
239
|
if (subsAsTabs && subs.length > 0) {
|
|
235
240
|
const tabObject = `${ctx.pageId}__rd_subs`;
|
|
@@ -243,7 +248,6 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
243
248
|
out.components,
|
|
244
249
|
),
|
|
245
250
|
};
|
|
246
|
-
Object.assign(out.events, groupTabEvents(tabObject, 'list', subs.length));
|
|
247
251
|
subBlocks.length = 0;
|
|
248
252
|
}
|
|
249
253
|
|
|
@@ -259,6 +263,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
259
263
|
out.show[ids.coord] = {
|
|
260
264
|
props: {
|
|
261
265
|
scope: link, object: recName, keyField: recKey ?? '', reloads: subs.map((s) => s.object), overlays: {}, record: recPath,
|
|
266
|
+
...linkRemoveProps(out),
|
|
262
267
|
},
|
|
263
268
|
};
|
|
264
269
|
|
|
@@ -278,7 +283,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
278
283
|
out.events[`${d.dialogClose}.click`] = semanticPipe(link, KIT_COORD_EVENTS.close);
|
|
279
284
|
const editName = actions.find((a) => a.builtin === 'openEdit')?.name ?? EDIT_LABEL;
|
|
280
285
|
dialog = dialogHtml(d, dialogTitles(record.view.form.title, { create: editName, edit: editName }), m.r.parts.form ?? '', { dialog: areaClass.dialog ?? '' }, CLOSE_LABEL);
|
|
281
|
-
for (const c of Object.values(
|
|
286
|
+
for (const c of Object.values(OVERLAY_SHELL_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
282
287
|
}
|
|
283
288
|
|
|
284
289
|
const html = recordDetailHtml(
|
|
@@ -289,5 +294,5 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
289
294
|
);
|
|
290
295
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
291
296
|
for (const c of Object.values(RECORD_DETAIL_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
292
|
-
return
|
|
297
|
+
return finishBizCompile(out, html);
|
|
293
298
|
}
|
|
@@ -3,14 +3,24 @@
|
|
|
3
3
|
// groups(可选,对象表:每项只写 title 与 view.summary,字段字典继承 record)、
|
|
4
4
|
// subs(可选,对象表:关联子对象,list / summary 或写死形状件,如 Timeline)。
|
|
5
5
|
|
|
6
|
+
import { KIT_GRAMMAR_RUNTIME } from '../../generated/kit-grammar-runtime';
|
|
6
7
|
import { defineKitBizComponent } from '../define';
|
|
7
8
|
import { compileRecordDetail } from './compile';
|
|
8
9
|
import { RECORD_DETAIL_AREAS } from './shell';
|
|
9
10
|
|
|
11
|
+
interface GrammarRuntimeNarrow {
|
|
12
|
+
readonly objectLayer: {
|
|
13
|
+
readonly recordRoleExtraKeys: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const RECORD_ROLE_EXTRA_KEYS: readonly string[] =
|
|
18
|
+
(KIT_GRAMMAR_RUNTIME as unknown as GrammarRuntimeNarrow).objectLayer.recordRoleExtraKeys;
|
|
19
|
+
|
|
10
20
|
export const RecordDetail = defineKitBizComponent({
|
|
11
21
|
kind: 'RecordDetail',
|
|
12
22
|
roles: {
|
|
13
|
-
record: { required: true, views: ['summary', 'form'] },
|
|
23
|
+
record: { required: true, views: ['summary', 'form'], extraKeys: RECORD_ROLE_EXTRA_KEYS },
|
|
14
24
|
groups: { required: false, views: ['summary'], many: true },
|
|
15
25
|
subs: { required: false, views: ['list', 'summary'], many: true },
|
|
16
26
|
},
|
|
@@ -15,11 +15,11 @@ import { IDENT, addEmit, classesIn, isRec, newParts, patchProps, type Rec } from
|
|
|
15
15
|
import {
|
|
16
16
|
addClassTokens, checkAreas, finishTemplate, normalizeFormObject, templateObjectName,
|
|
17
17
|
} from '../page-templates/shared';
|
|
18
|
+
import { SettingsCenter } from './index';
|
|
18
19
|
import {
|
|
19
20
|
SETTINGS_CENTER_AREAS, SETTINGS_CENTER_CLASS, settingsCenterHtml, settingsCenterIds, type SettingsBlock,
|
|
20
21
|
} from './shell';
|
|
21
22
|
|
|
22
|
-
|
|
23
23
|
export function settingsCenterObjectName(pageId: string, section: string): string {
|
|
24
24
|
return templateObjectName(pageId, section);
|
|
25
25
|
}
|
|
@@ -53,15 +53,16 @@ export function compileSettingsCenter(input: KitBizInput, ctx: KitBizContext): K
|
|
|
53
53
|
for (const n of names) {
|
|
54
54
|
const raw = (rawSections as Rec)[n] as Rec;
|
|
55
55
|
const path = `product.objects.sections.${n}`;
|
|
56
|
-
const target = normalizeFormObject(raw, path, `分区 ${n}`, out.diagnostics);
|
|
56
|
+
const target = normalizeFormObject(raw, path, `分区 ${n}`, out.diagnostics, SettingsCenter.roles.sections);
|
|
57
57
|
if (out.diagnostics.length > 0) return finishTemplate(out, '');
|
|
58
58
|
|
|
59
59
|
const object = settingsCenterObjectName(ctx.pageId, n);
|
|
60
|
+
const scope = `${object}_scope`;
|
|
60
61
|
const hasFrom = target.behavior.from !== undefined;
|
|
61
62
|
const formView = (target.view?.form ?? {}) as KitViewForm;
|
|
62
63
|
const r = emitObject(
|
|
63
64
|
target as KitObject,
|
|
64
|
-
{ object, scope
|
|
65
|
+
{ object, scope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
65
66
|
{
|
|
66
67
|
registeredActions: ctx.registeredActions,
|
|
67
68
|
formMode: hasFrom ? 'edit' : 'create',
|
|
@@ -84,8 +85,8 @@ export function compileSettingsCenter(input: KitBizInput, ctx: KitBizContext): K
|
|
|
84
85
|
resetLabel: RESET_LABEL,
|
|
85
86
|
classes: { ...classes, actions: SETTINGS_CENTER_CLASS.footer },
|
|
86
87
|
});
|
|
87
|
-
if ((r.parts.form ??
|
|
88
|
-
out.events[`${formId}.saved`] =
|
|
88
|
+
if ((r.parts.form ?? '').includes(`data-soma-id="${formId}"`)) {
|
|
89
|
+
out.events[`${formId}.saved`] = `NOTIFY | success | ${SAVED_NOTICE}`;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
const formTitle = formView.title;
|