soma-kit 0.1.18 → 0.1.20
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/package.json +2 -2
- package/spec/generated/kit-page.schema.json +15 -1
- package/spec/kit-grammar.json +142 -18
- package/spec/kit-grammar.schema.json +4 -0
- package/src/app/component-gate.ts +247 -16
- package/src/app/index.ts +4 -1
- package/src/app/kit-view-context.ts +44 -2
- package/src/app/server.ts +11 -2
- package/src/base/button.ts +11 -1
- package/src/biz/compose.ts +66 -0
- package/src/biz/define.ts +8 -0
- package/src/biz/index.ts +1 -0
- package/src/biz/layout-contracts.ts +119 -4
- package/src/biz/link/hub.ts +31 -0
- package/src/biz/master-sub/compile.ts +45 -3
- package/src/biz/master-sub/index.ts +3 -1
- package/src/biz/multi-board/compile.ts +5 -1
- package/src/biz/multi-board/prose-fold.ts +78 -5
- package/src/biz/multi-board/shell.ts +10 -3
- package/src/biz/record-detail/compile.ts +120 -10
- package/src/biz/shared/coordinator.ts +245 -48
- package/src/biz/shared/index.ts +5 -1
- package/src/biz/shared/object-aliases.ts +14 -3
- package/src/biz/shared/overlay-compile.ts +56 -5
- package/src/biz/shared/overlay-shell.ts +5 -2
- package/src/biz/shared/page-form.ts +9 -5
- package/src/biz/shared/page-overlay-host.ts +126 -0
- package/src/biz/shared/page-overlay-names.ts +27 -0
- package/src/biz/shared/runtime-hub.ts +37 -2
- package/src/biz/single-form/compile.ts +60 -5
- package/src/biz/single-form/index.ts +2 -1
- package/src/biz/standard-crud/compile.ts +9 -2
- package/src/biz/types.ts +18 -0
- package/src/cli/kit-cli.ts +1 -0
- package/src/cli/view-writes.ts +130 -3
- package/src/compile/compile-page.ts +49 -4
- package/src/compile/page-pipeline.ts +4 -0
- package/src/compile/parse.ts +14 -0
- package/src/compile/stages.ts +5 -4
- package/src/compile/types.ts +1 -1
- package/src/compile/view-check.ts +50 -19
- package/src/data/comment-thread.ts +78 -18
- package/src/data/navbar.ts +4 -0
- package/src/data/object-form.ts +17 -3
- package/src/data/prompt-dialog.ts +102 -15
- package/src/frames/page-header.ts +11 -2
- package/src/frames/shared.ts +6 -0
- package/src/frames/types.ts +2 -0
- package/src/generated/kit-grammar-runtime.ts +48 -8
- package/src/i18n/kit-text.ts +1 -0
- package/src/object-renderer/emit-static.ts +10 -3
- package/src/object-renderer/request-actions.ts +145 -17
- package/src/object-renderer/types.ts +7 -0
- package/src/shared/dom-attrs-registry.ts +9 -5
- package/src/shared/dom-attrs.ts +4 -0
- package/src/spatial/declared-actions.ts +6 -3
- package/src/spatial/emit.ts +1 -1
- package/src/spatial/expand.ts +7 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { kitNeutralClass, kitNeutralSpanClass, kitObjectAnchor } from '../shared/pipeline';
|
|
5
5
|
import { kitSelfAttrs } from '../../shared/page-attrs-runtime';
|
|
6
6
|
import {
|
|
7
|
-
KIT_ATTR_BAND, KIT_ATTR_BOARD, KIT_ATTR_BOARD_PANEL, KIT_ATTR_CONTAINER, KIT_ATTR_EMPHASIS, KIT_ATTR_FACE_GRID, KIT_ATTR_HEAD_BAND, KIT_ATTR_HERO_STATS,
|
|
7
|
+
KIT_ATTR_BAND, KIT_ATTR_BOARD, KIT_ATTR_BOARD_PANEL, KIT_ATTR_BOARD_PANEL_WHEN_EMPTY, KIT_ATTR_CONTAINER, KIT_ATTR_EMPHASIS, KIT_ATTR_FACE_GRID, KIT_ATTR_HEAD_BAND, KIT_ATTR_HERO_STATS,
|
|
8
8
|
KIT_ATTR_PANEL_FOOTER, KIT_ATTR_PANEL_HEAD, KIT_ATTR_PART, KIT_ATTR_ROLE, KIT_ATTR_SLOT, KIT_ATTR_SUMMARY, KIT_ATTR_TOP_BAND,
|
|
9
9
|
} from '../../shared/dom-attrs';
|
|
10
10
|
import { KIT_ARRANGE, arrangeSplit } from 'soma-foundation/arrange';
|
|
@@ -118,6 +118,13 @@ export interface BoardPanelBlock {
|
|
|
118
118
|
icon?: { readonly icon: string; readonly tone?: string };
|
|
119
119
|
/** 新模式下面板对象的运行期名(面板容器锚点据它拼);旧版不给 */
|
|
120
120
|
object?: string;
|
|
121
|
+
/** 面板声明 `whenEmpty: hide`:主体只剩空态时整块面板不渲染(运行期由 KitBoardProse 按标记收起 / 还原) */
|
|
122
|
+
hideWhenEmpty?: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** 面板壳上的「空时隐藏」标记(没声明则为空串) */
|
|
126
|
+
function whenEmptyMark(p: BoardPanelBlock): string {
|
|
127
|
+
return p.hideWhenEmpty === true ? ` ${KIT_ATTR_BOARD_PANEL_WHEN_EMPTY}="hide"` : '';
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/** 视图标题(view.list.title 编出的 h3 标题出口,data-kit-part="title-section"):面板内容开头(之前只有空白)的第一个 */
|
|
@@ -170,7 +177,7 @@ export function boardGridHtml(blocks: readonly BoardPanelBlock[], areaClass: Rec
|
|
|
170
177
|
// 有卡的面板才是 section(p-card 标准内边距)。唯一主体不套卡时内容落在页面对齐轴上
|
|
171
178
|
const tag = plain ? 'div' : 'section';
|
|
172
179
|
const titled = title !== '' || body !== p.html;
|
|
173
|
-
return `<${tag}${cls(klass)}${plain ? '' : KIT_SHELL_FLAT_MARK}${compose} ${KIT_ATTR_BOARD_PANEL}="${titled ? 'titled' : 'bare'}">${title}${topBand}${plain && p.inFace !== true ? tablesOnCanvas(body) : body}${band}</${tag}>`;
|
|
180
|
+
return `<${tag}${cls(klass)}${plain ? '' : KIT_SHELL_FLAT_MARK}${compose} ${KIT_ATTR_BOARD_PANEL}="${titled ? 'titled' : 'bare'}"${whenEmptyMark(p)}>${title}${topBand}${plain && p.inFace !== true ? tablesOnCanvas(body) : body}${band}</${tag}>`;
|
|
174
181
|
});
|
|
175
182
|
// data-kit-face-grid:面排布(结构 CSS 按层级策略取面间距,细线档 1px 让相邻面的外缘线并成一条贯通线)
|
|
176
183
|
return `<div ${KIT_ATTR_FACE_GRID}=""${cls(mergeClass(MULTI_BOARD_CLASS.panels, areaClass.panels))}>\n${sections.join('\n')}\n</div>`;
|
|
@@ -189,7 +196,7 @@ function boardPanelNext(p: BoardPanelBlock, title: string, body: string, areaCla
|
|
|
189
196
|
const topBand = p.topBand === undefined || p.topBand === '' ? '' : `<div ${KIT_ATTR_TOP_BAND}="" class="w-full min-w-0">${p.topBand}</div>`;
|
|
190
197
|
const mark = p.object !== undefined ? ` data-soma-id="${esc(kitObjectAnchor(p.object))}"` : '';
|
|
191
198
|
const titled = title !== '' || body !== p.html;
|
|
192
|
-
return `<div${mark}${cls(klass)} ${KIT_ATTR_BOARD_PANEL}="${titled ? 'titled' : 'bare'}">${title}${topBand}${body}${band}</div>`;
|
|
199
|
+
return `<div${mark}${cls(klass)} ${KIT_ATTR_BOARD_PANEL}="${titled ? 'titled' : 'bare'}"${whenEmptyMark(p)}>${title}${topBand}${body}${band}</div>`;
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
/** 整个壳:协作组件宿主 + 筛选卡 + 面板栅格。区域类按 7.3 同族规则覆写 */
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// 应用动作 record 的具名工具栏动作之后追加 kit_reload;载荷里没有行(工具栏无 row),动作用 `focusRow()` 取当前记录:
|
|
13
13
|
// KitCrudBridge 的 record prop 绑 `page.data.<记录对象>`,focus 没有当前行时 focusRow() 退回它(记录取回即可用)。
|
|
14
14
|
// 选此路而非「取回后写 focus.row」:后者要订阅取数完成、且会污染编辑表单回填的 row,绑定读取无副作用、重取后自动刷新
|
|
15
|
+
// 附加浮层 overlays.<名>(dialog / drawer):从属对象的行动作 builtin: openOverlay + targetOverlay 打开,被点的行是浮层表单初值;
|
|
16
|
+
// 浮层编译、事件映射、请求动作提交(成功关窗并重取记录与全部从属对象)与 StandardCrud / MasterSub 共用 shared/overlay-compile.ts。
|
|
17
|
+
// 记录头(record 工具栏动作 builtin: openOverlay)也能打开:点击载荷为空,按钮编成独立语义事件 crud_open_overlay_<动作 id>,
|
|
18
|
+
// 经协调组件 recordOverlayEvents 以当前记录(props.record)为行、按编辑模式打开(记录未取回时不响应)
|
|
15
19
|
// 限制:record.from 的接口必须直接返回记录对象(不带响应外壳 / 列表信封);写了 behavior.into 或非字符串 from 报 KIT-BIZ-003。
|
|
16
20
|
// 子对象的关联键写 from[].require(core 的 CORE-DATA-REQUIRE):记录尚未取回、关联键为空时子对象不发请求(状态 idle),不再依赖后端「缺关联键返回空」。
|
|
17
21
|
|
|
@@ -32,7 +36,7 @@ import {
|
|
|
32
36
|
} from '../shared/compile-helpers';
|
|
33
37
|
import { pipeTails, wireDialogForm } from '../shared/pipes';
|
|
34
38
|
import { OVERLAY_SHELL_CLASS, dialogHtml, dialogIds, dialogTitles } from '../shared/overlay-shell';
|
|
35
|
-
import { adviseDialogFooter } from '../shared/overlay-compile';
|
|
39
|
+
import { KIT_CRUD_LINK_KEY, adviseDialogFooter, compileOverlay, isAutoRowlessOverlay, validateOverlayNames } from '../shared/overlay-compile';
|
|
36
40
|
import { dialogWidthOf, editContainerOf } from '../../object-renderer/overlay-decide';
|
|
37
41
|
import { PAGE_FORM_FOCUS_INITIAL, pageBrowsingMirror, wireMainPageForm } from '../shared/page-form';
|
|
38
42
|
import {
|
|
@@ -60,6 +64,18 @@ function clone<T>(v: T): T {
|
|
|
60
64
|
return JSON.parse(JSON.stringify(v)) as T;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
/**
|
|
68
|
+
* 记录头浮层的语义事件名:crud_open_overlay_<动作 id 的 snake_case>(与 StandardCrud 工具条浮层 rowlessOverlayEvent 同一拼法;
|
|
69
|
+
* core 的语义事件名只许小写 snake_case);撞名或与行动作的 crud_open_overlay 相同时补序号
|
|
70
|
+
*/
|
|
71
|
+
function recordOverlayEvent(actionId: string, taken: Readonly<Record<string, string>>): string {
|
|
72
|
+
const snake = actionId.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/[^a-z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_|_$/g, '');
|
|
73
|
+
const base = snake === '' ? KIT_COORD_EVENTS.openOverlay : `${KIT_COORD_EVENTS.openOverlay}_${snake}`;
|
|
74
|
+
let name = base;
|
|
75
|
+
for (let n = 2; name === KIT_COORD_EVENTS.openOverlay || Object.hasOwn(taken, name); n += 1) name = `${base}_${n}`;
|
|
76
|
+
return name;
|
|
77
|
+
}
|
|
78
|
+
|
|
63
79
|
export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
64
80
|
const CLOSE_LABEL = kitText('soma.kit.close', undefined, ctx.locale);
|
|
65
81
|
const CANCEL_LABEL = kitText('soma.kit.cancel', undefined, ctx.locale);
|
|
@@ -152,6 +168,14 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
152
168
|
actions.forEach((a, i) => {
|
|
153
169
|
if (a.on === 'row') fail('KIT-BIZ-003', `record 的动作 ${a.id}:详情台没有行,动作只许 on: toolbar / field`, `product.objects.record.behavior.actions[${i}].on`);
|
|
154
170
|
if (a.builtin === 'openCreate') fail('KIT-BIZ-003', `record 的动作 ${a.id}:详情台不能新增,builtin 只许 openEdit / reload`, `product.objects.record.behavior.actions[${i}].builtin`);
|
|
171
|
+
// 记录头打开附加浮层:只许工具条动作(on: row 上一行已拒),目标必须是已声明的浮层;以当前记录为行、按编辑打开(协调组件 recordOverlayEvents)
|
|
172
|
+
if (a.builtin === 'openOverlay') {
|
|
173
|
+
const at = `product.objects.record.behavior.actions[${i}]`;
|
|
174
|
+
if (a.on !== 'toolbar' && a.on !== 'row') fail('KIT-EVT-001', `record 的动作 ${a.id}:openOverlay 只能是记录头工具条动作(on: toolbar,以当前记录打开浮层)`, at);
|
|
175
|
+
if (a.targetOverlay === undefined || !Object.hasOwn(input.overlays ?? {}, a.targetOverlay)) {
|
|
176
|
+
fail('KIT-EVT-001', `动作 ${a.id} 的 targetOverlay "${a.targetOverlay ?? ''}" 不在 overlays 里`, `${at}.targetOverlay`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
155
179
|
});
|
|
156
180
|
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
157
181
|
// 缺省「编辑」补不补:声明里已有「功能为编辑」的动作(builtin: openEdit、id: edit、写了 function: edit …)就不补,
|
|
@@ -163,7 +187,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
163
187
|
if (hasWrite) record.view = { ...record.view, form: isRec(formView) ? (formView as KitObject['view'] & Rec as never) : {} };
|
|
164
188
|
|
|
165
189
|
// ---- 子对象
|
|
166
|
-
const subs: Array<{ object: string; scope: string; obj: KitObject; title: string }> = [];
|
|
190
|
+
const subs: Array<{ object: string; scope: string; obj: KitObject; title: string; name: string }> = [];
|
|
167
191
|
for (const n of subNames) {
|
|
168
192
|
const raw = (rawSubs as Rec)[n] as Rec;
|
|
169
193
|
const behavior = raw.behavior as Rec;
|
|
@@ -184,23 +208,68 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
184
208
|
});
|
|
185
209
|
out.diagnostics.push(...sn.diagnostics);
|
|
186
210
|
const object = recordDetailObjectName(ctx.pageId, `sub_${n}`);
|
|
187
|
-
subs.push({ object, scope: `${object}_scope`, obj: sn.obj, title: typeof raw.title === 'string' ? raw.title : '' });
|
|
211
|
+
subs.push({ object, scope: `${object}_scope`, obj: sn.obj, title: typeof raw.title === 'string' ? raw.title : '', name: n });
|
|
188
212
|
}
|
|
189
213
|
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
190
214
|
|
|
215
|
+
// ---- 附加浮层(overlays.*):与 StandardCrud / MasterSubWorkstation 同一份校验与编译(shared/overlay-compile.ts)。
|
|
216
|
+
// 从属对象的行动作 builtin: openOverlay + targetOverlay -> crud_open_overlay(载荷带被点的行)-> 协调组件写 focus(浮层显隐镜像 + 当前行);
|
|
217
|
+
// 浮层表单 initial 绑当前行,提交走表单 write / 浮层事件 { action }(request 动作登记在记录对象名下),成功后关窗并重取记录与全部从属对象
|
|
218
|
+
const overlays = input.overlays ?? {};
|
|
219
|
+
const hasOverlays = Object.keys(overlays).length > 0;
|
|
220
|
+
const showEdit = validateOverlayNames(overlays, ['record', ...groupNames, ...subNames], fail);
|
|
221
|
+
for (const [name, decl] of Object.entries(overlays)) {
|
|
222
|
+
const at = `product.overlays.${name}`;
|
|
223
|
+
if (decl.kind !== undefined && decl.kind !== 'dialog' && decl.kind !== 'drawer') {
|
|
224
|
+
fail('KIT-BIZ-003', `RecordDetail 的附加浮层 ${name} 只支持 kind: dialog / drawer(expand 展开行子表只属于 StandardCrud)`, `${at}.kind`);
|
|
225
|
+
}
|
|
226
|
+
if (decl.rowClick !== undefined) {
|
|
227
|
+
fail('KIT-BIZ-003', `浮层 ${name} 的 rowClick 只属于 StandardCrud;详情台用从属对象的行动作 builtin: openOverlay 打开浮层`, `${at}.rowClick`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/** 行动作 id -> 浮层名;同 id 在不同从属对象里指向不同浮层时协调组件无法反查,直接拒收 */
|
|
231
|
+
const overlayActions: Record<string, string> = {};
|
|
232
|
+
/** 浮层事件 { action } 可引用的声明式请求 / 下载动作池:记录动作在前,各从属对象的动作按声明序 */
|
|
233
|
+
const requestPool: KitAction[] = [...actions];
|
|
234
|
+
for (const s of subs) {
|
|
235
|
+
(s.obj.behavior.actions ?? []).forEach((a, i) => {
|
|
236
|
+
requestPool.push(a);
|
|
237
|
+
if (a.builtin !== 'openOverlay') return;
|
|
238
|
+
const where = `product.objects.subs.${s.name}.behavior.actions[${i}]`;
|
|
239
|
+
if (a.on !== 'row') fail('KIT-EVT-001', `动作 ${a.id}:openOverlay 只能是行操作(以被点的行打开浮层)`, where);
|
|
240
|
+
if (a.targetOverlay === undefined || !(a.targetOverlay in overlays)) {
|
|
241
|
+
fail('KIT-EVT-001', `动作 ${a.id} 的 targetOverlay "${a.targetOverlay ?? ''}" 不在 overlays 里`, `${where}.targetOverlay`);
|
|
242
|
+
} else if (overlayActions[a.id] !== undefined && overlayActions[a.id] !== a.targetOverlay) {
|
|
243
|
+
fail('KIT-EVT-001', `动作 id ${a.id} 在多个从属对象里指向不同浮层(${overlayActions[a.id]} / ${a.targetOverlay}):协调组件按动作 id 反查浮层,请改成不同的动作 id`, `${where}.targetOverlay`);
|
|
244
|
+
} else {
|
|
245
|
+
overlayActions[a.id] = a.targetOverlay;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
250
|
+
const overlayTargets = hasOverlays ? new Set(Object.keys(overlays)) : undefined;
|
|
251
|
+
|
|
191
252
|
// ---- 发射
|
|
192
253
|
const mk = KIT_COORD_MIRRORS;
|
|
193
254
|
const m = emitMember(out, {
|
|
194
255
|
object: recName, scope: recScope, obj: record, ctx, link, hubId: ids.coord,
|
|
195
256
|
emitInput: { formMode: 'edit', formInitialPath: recPath },
|
|
196
257
|
});
|
|
197
|
-
// 工具栏内置动作:编辑 /
|
|
258
|
+
// 工具栏内置动作:编辑 / 刷新 / 打开浮层交协调组件
|
|
259
|
+
/** 记录头浮层:语义事件名 -> 浮层名(协调组件 props.recordOverlayEvents;没有这类动作时不带) */
|
|
260
|
+
const recordOverlayEvents: Record<string, string> = {};
|
|
198
261
|
actions.forEach((act, i) => {
|
|
199
262
|
if (act.on !== 'toolbar') return;
|
|
200
263
|
const click = `${toolbarAnchor(recName, act.id)}.click`;
|
|
201
264
|
const tails = (): string[] => pipeTails(act, `behavior.actions[${i}]`, out.diagnostics);
|
|
202
265
|
if (act.builtin === 'openEdit') out.events[click] = semanticPipe(link, KIT_COORD_EVENTS.openEdit, tails());
|
|
203
266
|
else if (act.builtin === 'reload') out.events[click] = semanticPipe(link, KIT_COORD_EVENTS.reload, tails());
|
|
267
|
+
else if (act.builtin === 'openOverlay' && act.targetOverlay !== undefined) {
|
|
268
|
+
// 记录头浮层:按钮点击载荷为空,每个动作一个独立语义事件名(与 StandardCrud 工具条浮层同一拼法),协调组件按 recordOverlayEvents 反查目标、以 props.record 为行打开
|
|
269
|
+
const event = recordOverlayEvent(act.id, recordOverlayEvents);
|
|
270
|
+
recordOverlayEvents[event] = act.targetOverlay;
|
|
271
|
+
out.events[click] = semanticPipe(link, event, tails());
|
|
272
|
+
}
|
|
204
273
|
});
|
|
205
274
|
|
|
206
275
|
const groups: DetailBlock[] = [];
|
|
@@ -237,7 +306,7 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
237
306
|
|
|
238
307
|
const subBlocks: DetailBlock[] = [];
|
|
239
308
|
for (const s of subs) {
|
|
240
|
-
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.coord });
|
|
309
|
+
const sm = emitMember(out, { object: s.object, scope: s.scope, obj: s.obj, ctx, link, hubId: ids.coord, ...(overlayTargets !== undefined ? { overlayTargets } : {}) });
|
|
241
310
|
subBlocks.push({
|
|
242
311
|
title: s.title,
|
|
243
312
|
html: [sm.r.parts.toolbar ?? '', sm.r.parts.filter ?? '', sm.listHtml, sm.r.parts.summary ?? ''].filter((x) => x !== '').join('\n'),
|
|
@@ -261,26 +330,62 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
261
330
|
subBlocks.length = 0;
|
|
262
331
|
}
|
|
263
332
|
|
|
333
|
+
// ---- 附加浮层:协调组件是 focus 切片 owner,显隐镜像、当前行镜像与关联键镜像(当前行主键)声明在链接作用域上
|
|
334
|
+
const overlayHtmls: string[] = [];
|
|
335
|
+
const overlayMirrors: SomaScopeMirrorDecl[] = [];
|
|
336
|
+
const overlayObjects: Record<string, string> = {};
|
|
337
|
+
/** 编辑表单按容器公式得整页的附加浮层(协调组件 pageOverlays) */
|
|
338
|
+
const pageOverlays: string[] = [];
|
|
339
|
+
const rowTriggeredOverlays = new Set<string>([...Object.values(overlayActions), ...Object.values(recordOverlayEvents), ...Object.values(showEdit)]);
|
|
340
|
+
const rowlessOverlays = new Set<string>(
|
|
341
|
+
Object.entries(overlays).filter(([n, d]) => isAutoRowlessOverlay(d, rowTriggeredOverlays.has(n))).map(([n]) => n),
|
|
342
|
+
);
|
|
343
|
+
for (const [name, decl] of Object.entries(overlays)) {
|
|
344
|
+
const compiled = compileOverlay(
|
|
345
|
+
{ out, ctx, scope: link, object: recName, keyField: recKey, actions: requestPool, areaClass, closeLabel: CLOSE_LABEL, cancelLabel: CANCEL_LABEL, editLabel: EDIT_LABEL, showEdit, ...(rowlessOverlays.size > 0 ? { rowless: rowlessOverlays } : {}) },
|
|
346
|
+
name,
|
|
347
|
+
decl,
|
|
348
|
+
);
|
|
349
|
+
if (compiled === undefined) continue;
|
|
350
|
+
if (compiled.page) pageOverlays.push(name);
|
|
351
|
+
overlayObjects[name] = compiled.object;
|
|
352
|
+
overlayMirrors.push(compiled.mirror);
|
|
353
|
+
overlayHtmls.push(compiled.html);
|
|
354
|
+
}
|
|
355
|
+
|
|
264
356
|
// ---- 链接作用域:focus 归协调组件
|
|
265
357
|
const mirrors: SomaScopeMirrorDecl[] = [];
|
|
266
358
|
for (const x of [mk.openForm, mk.creating, mk.editing]) mirrors.push({ key: x.key, slice: 'focus', path: x.path, as: x.as });
|
|
359
|
+
// 有附加浮层才声明:当前行镜像(浮层表单 initial / 写死形状组件 data 注入被点的行)、各浮层显隐镜像、关联键镜像(产物在未声明 overlays 时与改前一致)
|
|
360
|
+
if (hasOverlays) {
|
|
361
|
+
mirrors.push({ key: mk.row.key, slice: 'focus', path: mk.row.path, as: mk.row.as }, ...overlayMirrors);
|
|
362
|
+
if (rowlessOverlays.size > 0) mirrors.push({ key: mk.ovMode.key, slice: 'focus', path: mk.ovMode.path, as: mk.ovMode.as });
|
|
363
|
+
if (recKey !== undefined && Object.keys(overlayObjects).length > 0) mirrors.push({ key: KIT_CRUD_LINK_KEY, slice: 'focus', path: `row.${recKey}`, as: 'value' });
|
|
364
|
+
}
|
|
267
365
|
// 编辑表单的容器(KT-P-window;只有编辑,永不分步):对话框,或同页切换的整页表单视图(详情区让位)
|
|
268
366
|
const pageForm = hasWrite && record.view?.form !== undefined && editContainerOf({ form: record.view.form, schema: record.schema }, { edit: true }).container === 'page';
|
|
269
|
-
|
|
367
|
+
// 整页(记录编辑表单或附加浮层的编辑表单)打开时详情区让位(绑协调组件的「浏览中」镜像)
|
|
368
|
+
const yields = pageForm || pageOverlays.length > 0;
|
|
369
|
+
if (yields) mirrors.push(pageBrowsingMirror());
|
|
270
370
|
out.scopes[link] = {
|
|
271
371
|
id: link,
|
|
272
372
|
object: recName,
|
|
273
|
-
slices: [{ name: 'focus', owner: ids.coord, ...(
|
|
373
|
+
slices: [{ name: 'focus', owner: ids.coord, ...(yields ? { initial: PAGE_FORM_FOCUS_INITIAL } : {}) }],
|
|
274
374
|
mirrors: sortMirrors(mirrors),
|
|
275
375
|
};
|
|
276
376
|
out.show[ids.coord] = {
|
|
277
377
|
props: {
|
|
278
|
-
scope: link, object: recName, keyField: recKey ?? '', reloads: subs.map((s) => s.object), overlays:
|
|
378
|
+
scope: link, object: recName, keyField: recKey ?? '', reloads: subs.map((s) => s.object), overlays: overlayObjects, record: recPath,
|
|
379
|
+
// 行动作 id -> 附加浮层名(行字段盖掉载荷 target 时按动作 id 反查);只读浮层 -> 编辑浮层
|
|
380
|
+
...(hasOverlays ? { overlayActions, showEdit } : {}),
|
|
381
|
+
// 记录头浮层(工具条 openOverlay):语义事件名 -> 浮层名,协调组件以 props.record 为行、按编辑打开;没有这类动作时不带(产物与改前一致)
|
|
382
|
+
...(Object.keys(recordOverlayEvents).length > 0 ? { recordOverlayEvents } : {}),
|
|
279
383
|
...(pageForm ? { pageForm: true } : {}),
|
|
384
|
+
...(pageOverlays.length > 0 ? { pageOverlays } : {}),
|
|
280
385
|
...linkRemoveProps(out),
|
|
281
386
|
},
|
|
282
387
|
};
|
|
283
|
-
if (
|
|
388
|
+
if (yields) out.show[`${ids.root}_browse`] = { when: mirrorPath(link, KIT_COORD_MIRRORS.browsing.key) };
|
|
284
389
|
|
|
285
390
|
// ---- 编辑表单
|
|
286
391
|
let dialog = '';
|
|
@@ -316,10 +421,15 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
316
421
|
adviseDialogFooter(ctx, record.view.form, 'product.objects.record.view.form.footerActions');
|
|
317
422
|
for (const c of Object.values(OVERLAY_SHELL_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
318
423
|
}
|
|
424
|
+
// 附加浮层的窗口 / 抽屉 / 整页编辑面跟在记录编辑弹窗之后(与 MasterSub 同一拼法;没有浮层时 dialog 原样)
|
|
425
|
+
if (overlayHtmls.length > 0) {
|
|
426
|
+
dialog = [dialog, ...overlayHtmls].filter((x) => x !== '').join('\n');
|
|
427
|
+
for (const c of Object.values(OVERLAY_SHELL_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
428
|
+
}
|
|
319
429
|
|
|
320
430
|
const html = recordDetailHtml(
|
|
321
431
|
ids,
|
|
322
|
-
{ summary: m.r.parts.summary ?? '', actions: m.r.parts.toolbar ?? '', groups, subs: subBlocks, dialog, ...(subsTabs !== undefined ? { subsTabs } : {}), ...(
|
|
432
|
+
{ summary: m.r.parts.summary ?? '', actions: m.r.parts.toolbar ?? '', groups, subs: subBlocks, dialog, ...(subsTabs !== undefined ? { subsTabs } : {}), ...(yields ? { browseId: `${ids.root}_browse` } : {}), ...(next ? { next: { record: recName } } : {}) },
|
|
323
433
|
areaClass,
|
|
324
434
|
input.class,
|
|
325
435
|
);
|