soma-kit 0.1.13 → 0.1.15
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 +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +34 -17
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +73 -50
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +7 -6
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +16 -12
- package/src/biz/types.ts +15 -3
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -22,7 +22,50 @@ import type { KitBizContext, KitOverlayDecl, KitOverlayEventAction } from '../ty
|
|
|
22
22
|
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS, overlayMirrorKey } from './coordinator';
|
|
23
23
|
import { addEmit, IDENT, isRec, labelDiagnostics, mirrorPath, patchProps, type Parts, type Rec } from '../link/shared';
|
|
24
24
|
import { semanticPipe, wireDialogForm } from './pipes';
|
|
25
|
-
import {
|
|
25
|
+
import { overlayHtml, overlayIds } from './overlay-shell';
|
|
26
|
+
import { dialogWidthOf, drawerWidthOf, footerPlanOf } from '../../object-renderer/overlay-decide';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 抽屉里有没有提交动作:返回原因(无则 null)。判据:表单视图、behavior.write、事件接到具名动作 / saved 语义、
|
|
30
|
+
* 静态组件声明了提交类事件(语法真源 kit-grammar.json#overlayEventRoles.conventional 里映射到 saved 的事件名,现为 saved)。
|
|
31
|
+
*/
|
|
32
|
+
export function drawerSubmitReason(decl: KitOverlayDecl, view: KitView, staticComponents: Readonly<Record<string, { emits?: readonly string[] } | undefined>>): string | null {
|
|
33
|
+
if (view.form !== undefined) return '含表单视图 view.form';
|
|
34
|
+
if (decl.behavior?.write !== undefined) return '含 behavior.write';
|
|
35
|
+
const submit: readonly string[] = ['saved', ...Object.entries(OVERLAY_EVENT_ROLES).filter(([, r]) => r === 'saved').map(([k]) => k)];
|
|
36
|
+
for (const [ev, role] of Object.entries(decl.events ?? {})) {
|
|
37
|
+
if (typeof role !== 'string') return `events.${ev} 绑了具名动作`;
|
|
38
|
+
if (submit.includes(role)) return `events.${ev} 映射为 ${role}`;
|
|
39
|
+
}
|
|
40
|
+
for (const slot of ['list', 'summary'] as const) {
|
|
41
|
+
const comp = view[slot]?.staticComponent;
|
|
42
|
+
const emits = comp === undefined ? undefined : staticComponents[comp]?.emits;
|
|
43
|
+
if (comp !== undefined && emits !== undefined && emits.some((e) => submit.includes(e))) return `静态组件 ${comp} 声明了 ${emits.filter((e) => submit.includes(e)).join(' / ')} 事件`;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const FOOTER_REASON: Readonly<Record<string, string>> = Object.freeze({
|
|
49
|
+
'left-over': '左侧次级动作超过上限',
|
|
50
|
+
extras: '有动作想放进底栏却没有位置',
|
|
51
|
+
'visible-over': '底栏可见按钮总数超过上限',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 窗口底栏排法(KIT-OVL-004,先以告警落地):右侧固定「取消 + 一个主动作」,左侧至多一个次级动作,其余进「更多」或改成正文控件。
|
|
56
|
+
* 判定在引擎(arrangeOverlayFooter,规则 kit-arrange#overlay.footer),这里只取事实(表单的 footerActions 数)并出诊断。
|
|
57
|
+
*/
|
|
58
|
+
export function adviseDialogFooter(ctx: KitBizContext, formView: unknown, path: string): void {
|
|
59
|
+
if (ctx.advise === undefined) return;
|
|
60
|
+
const plan = footerPlanOf(formView);
|
|
61
|
+
if (plan.ok) return;
|
|
62
|
+
ctx.advise({
|
|
63
|
+
code: 'KIT-OVL-004',
|
|
64
|
+
path,
|
|
65
|
+
message: `窗口底栏排不下:${FOOTER_REASON[plan.reason] ?? plan.reason}(按钮 ${plan.visible} 个)`,
|
|
66
|
+
hint: '底栏右侧只放「取消 + 主动作」,左侧至多一个次级动作;其余收进更多,或改成正文里的控件',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
26
69
|
|
|
27
70
|
/** 浮层里数据组件的约定事件 -> 角色(K-1) */
|
|
28
71
|
const OVERLAY_EVENT_ROLES: Record<string, string> = KIT_GRAMMAR.overlayEventRoles.conventional as Record<string, string>;
|
|
@@ -108,11 +151,32 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
108
151
|
const fail: Fail = (code, message, path) => { out.diagnostics.push({ code, message, path } as KitDiagnostic); };
|
|
109
152
|
const at = `product.overlays.${name}`;
|
|
110
153
|
if (!IDENT.test(name)) return undefined;
|
|
154
|
+
// 抽屉宽度档:width 只对 kind: drawer 有效(对话框宽度由内容定档),取值闭集 narrow / default / wide
|
|
155
|
+
// 窗口的大小与外观由框架按内容推导(确认 400、表单 480 / 640 / 800、只读抽屉 480 / 640,尺寸规格 §5),页面不写 width / class(KIT-OVL-003)
|
|
156
|
+
// 过渡期:KIT-OVL-002 / 003 先以告警落地(不挡编译,kit check 的弃用提示段带出),应用按 apps-todo 改完后升为错误
|
|
157
|
+
const warn = (code: string, message: string, path: string, hint: string): void => {
|
|
158
|
+
if (ctx.advise !== undefined) ctx.advise({ code, path, message, hint });
|
|
159
|
+
else fail(code, message, path);
|
|
160
|
+
};
|
|
161
|
+
for (const key of ['width', 'class'] as const) {
|
|
162
|
+
if (decl[key] !== undefined) warn('KIT-OVL-003', `浮层 ${name} 写了 ${key}:窗口的宽度与外观由框架按内容推导,该键已不生效`, `${at}.${key}`, `删掉 ${key};要换档请改内容(栏数 arrange、组件):单列 480、两列或宽组件 640、三列或画布 800、只读抽屉 480 / 640`);
|
|
163
|
+
}
|
|
111
164
|
const view = normalizeOverlayView(decl.view);
|
|
112
165
|
if (view === undefined) {
|
|
113
166
|
fail('KIT-BIZ-001', `附加浮层 ${name} 缺少 view`, `${at}.view`);
|
|
114
167
|
return undefined;
|
|
115
168
|
}
|
|
169
|
+
// 抽屉只承载只读详情;要填写并提交、或确认后写入的浮层一律居中模态(KIT-OVL-001)
|
|
170
|
+
if (decl.kind === 'drawer') {
|
|
171
|
+
const why = drawerSubmitReason(decl, view, ctx.staticComponents);
|
|
172
|
+
if (why !== null) {
|
|
173
|
+
fail('KIT-OVL-001', `浮层 ${name} 是抽屉却承载提交动作(${why}):填写并提交、或确认后写入的浮层改写 kind: dialog(宽度由栏数与宽组件推导),抽屉只用于只读详情`, `${at}.kind`);
|
|
174
|
+
}
|
|
175
|
+
} else if (decl.kind === 'dialog' && drawerSubmitReason(decl, view, ctx.staticComponents) === null) {
|
|
176
|
+
// 只读内容一律抽屉(KIT-OVL-002):没有表单、写入、提交动作的居中窗口是错类型
|
|
177
|
+
warn('KIT-OVL-002', `浮层 ${name} 是居中窗口却只读(没有表单视图、behavior.write、具名动作或 saved 事件)`, `${at}.kind`, '只读内容改写 kind: drawer;居中窗口只给确认与带提交的表单');
|
|
178
|
+
}
|
|
179
|
+
if (decl.kind === 'dialog') adviseDialogFooter(ctx, view.form, `${at}.view.form.footerActions`);
|
|
116
180
|
// 编辑详情(behavior.detail)与读通道(behavior.from)二选一:from 已是「按关联键取浮层对象」的读口
|
|
117
181
|
if (decl.behavior?.from !== undefined && decl.behavior?.detail !== undefined) {
|
|
118
182
|
fail('KIT-DET-001', `附加浮层 ${name} 同时写了 behavior.from 与 behavior.detail:二选一(from 已按关联键取浮层对象,detail 用于以当前行为初值的编辑表单)`, `${at}.behavior.detail`);
|
|
@@ -157,6 +221,7 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
157
221
|
}
|
|
158
222
|
// K-1 / M1-3:浮层里的写死形状数据组件(应用组件)按约定抛 saved / cancel / close / reload,由协调组件接;
|
|
159
223
|
// overlays.<名>.events 可再把自定义事件名映射到这四种之一。组件没抛的事件不会触发(core 对未声明的 emit 选择器惰性)
|
|
224
|
+
const submitActions = new Set<string>();
|
|
160
225
|
for (const slot of ['list', 'summary'] as const) {
|
|
161
226
|
const staticComp = view[slot]?.staticComponent;
|
|
162
227
|
if (staticComp === undefined) continue;
|
|
@@ -193,6 +258,8 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
193
258
|
}
|
|
194
259
|
out.events[`${anchor}.${emitName}`] = actionPipe;
|
|
195
260
|
namedOn[emitName] = role.action;
|
|
261
|
+
// 提交类事件(saved 语义)绑的应用具名动作:登记为本浮层的提交动作,成功后框架默认关窗 + 成功反馈(request 类已由宿主 closeOnSuccess)
|
|
262
|
+
if (declared === undefined && (emitName === 'saved' || OVERLAY_EVENT_ROLES[emitName] === 'saved')) submitActions.add(role.action);
|
|
196
263
|
continue;
|
|
197
264
|
}
|
|
198
265
|
// view.<方法>:浮层里组件抛出的事件调展示对象方法(载荷 = 组件 emit 的载荷;不关窗不重取,要请求走 ctx.request / ctx.action)
|
|
@@ -227,12 +294,17 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
227
294
|
out.events[`${ids.edit}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.showEdit);
|
|
228
295
|
}
|
|
229
296
|
return {
|
|
230
|
-
//
|
|
231
|
-
html: overlayHtml(ids, decl.kind === 'drawer' ? 'drawer' : 'dialog', decl.title ?? name, ovEmit.html,
|
|
297
|
+
// 窗口宽度档只由内容经引擎推导(overlay-decide),外壳只渲染档名;页面写的宽度类(class / areaClass)被壳忽略
|
|
298
|
+
html: overlayHtml(ids, decl.kind === 'drawer' ? 'drawer' : 'dialog', decl.title ?? name, ovEmit.html, undefined, areaClass, withEdit, h.closeLabel, '', dialogWidthOf({
|
|
299
|
+
form: view.form,
|
|
300
|
+
schema: decl.schema,
|
|
301
|
+
staticComponent: view.list?.staticComponent ?? view.summary?.staticComponent,
|
|
302
|
+
}), drawerWidthOf({
|
|
232
303
|
form: view.form,
|
|
233
304
|
schema: decl.schema,
|
|
234
305
|
staticComponent: view.list?.staticComponent ?? view.summary?.staticComponent,
|
|
235
|
-
|
|
306
|
+
tableList: view.list !== undefined && view.list.staticComponent === undefined && (view.list.collection === undefined || view.list.collection.type === 'table'),
|
|
307
|
+
}), [...submitActions]),
|
|
236
308
|
mirror: { key: overlayMirrorKey(name), slice: 'focus', path: `ov.${name}`, as: 'truthy' },
|
|
237
309
|
object: ovObject,
|
|
238
310
|
};
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
1
|
+
// 业务组件共用的弹窗外壳(声明式调用方):浮层 id / 标题、显隐宿主、弹窗 HTML 生成。
|
|
2
|
+
// 外壳结构只在 base/overlay-shell 一份(命令式的确认 / 提示 / 选择器 / 抽屉调同一份),这里只传「决定」:哪种窗口、哪一档宽度、标题与正文是什么。
|
|
3
3
|
// 增删改查(standard-crud)、分类增删改查、主从、记录详情都用同一套弹窗壳,放在这里避免业务组件横向依赖增删改查的外壳;
|
|
4
4
|
// standard-crud/shell.ts 从这里 import 并原样 re-export。只有结构和 Tailwind 类,不写原生 CSS。
|
|
5
5
|
// 显隐层统一用 `fixed inset-0` 的遮罩 + 内层 flex 容器:显隐只靠 core 写 `hidden` 属性,不在遮罩自身叠 display 类。
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { kitIconHtml } from '../../
|
|
12
|
-
import {
|
|
13
|
-
KIT_FIXED_ATTRIBUTE, KIT_PART_DIALOG, KIT_PART_DRAWER, KIT_PART_TITLE_DIALOG,
|
|
14
|
-
kitOverlayBodyRecipe, kitOverlayFooterRecipe, kitOverlayHeaderRecipe, kitTypographyRecipe,
|
|
15
|
-
} from '../../recipes';
|
|
16
|
-
|
|
17
|
-
/** 对话框面板类串:只在这里写一份,三档宽度各传自己的宽度类(480 / 720 / 960) */
|
|
18
|
-
function dialogPanelClass(width: string): string {
|
|
19
|
-
return `flex max-h-full w-full ${width} flex-col ${KIT_DIALOG_SURFACE_CLASS} motion-safe:animate-kit-dialog-in`;
|
|
20
|
-
}
|
|
7
|
+
import { esc } from '../../shared/escape';
|
|
8
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
9
|
+
import type { KitDialogTier, KitDrawerWidth } from '../../recipes/overlay';
|
|
10
|
+
import { kitShellClasses, kitShellHtml } from '../../base/overlay-shell';
|
|
11
|
+
import { kitIconHtml } from '../../shared/icons';
|
|
21
12
|
|
|
22
13
|
/**
|
|
23
14
|
* 浮层显隐外层(只放 core 写的 hidden 属性):定位类 fixed 让它出流——它自己 0 高,留在业务壳根的 flex 流里就会为每个浮层多量出一份 gap
|
|
@@ -27,8 +18,15 @@ function dialogPanelClass(width: string): string {
|
|
|
27
18
|
*/
|
|
28
19
|
export const LAYER_HOST_CLASS_ATTR = ' class="fixed z-50"';
|
|
29
20
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 浮层显隐外层上的「提交动作」标记:值是空格分隔的具名动作名。具名动作从这个浮层里触发且成功时,
|
|
23
|
+
* 框架默认关窗并给成功反馈(每个处理函数都要记得写的事归框架);处理函数调 keepOpen() 可显式不关。
|
|
24
|
+
*/
|
|
25
|
+
export const KIT_SUBMIT_ACTIONS_ATTR = 'data-kit-submit-actions';
|
|
26
|
+
|
|
27
|
+
/** 表单窗口宽度档:default 480、wide 640(两列 / 宽组件)、xwide 800(三列 / 画布) */
|
|
28
|
+
import type { KitDialogWidth } from '../../object-renderer/overlay-decide';
|
|
29
|
+
export type { KitDialogWidth };
|
|
32
30
|
|
|
33
31
|
/** 宽度类(`w-*` / `min-w-*` / `max-w-*`,含任意变体前缀):浮层宽度只由内容档位决定,页面写的宽度类不参与 */
|
|
34
32
|
const WIDTH_CLASS_TOKEN = /^(?:[^:]+:)*-?(?:min-w|max-w|w)-/;
|
|
@@ -40,76 +38,27 @@ export function stripOverlayWidthClasses(cls: string | undefined): string | unde
|
|
|
40
38
|
return kept.length === 0 ? undefined : kept.join(' ');
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
const DIALOG = kitShellClasses({ kind: 'dialog', dialogTier: 'default' });
|
|
42
|
+
const DRAWER = kitShellClasses({ kind: 'drawer', drawerWidth: 'default' });
|
|
43
|
+
|
|
44
|
+
/** 外壳各段类串(候选类收集与测试读;全部来自 base/overlay-shell 的一份配方) */
|
|
43
45
|
export const OVERLAY_SHELL_CLASS = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
close: 'inline-flex size-8 shrink-0 border-0 bg-transparent p-0 cursor-pointer items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
57
|
-
headerActions: 'flex items-center gap-2',
|
|
58
|
-
body: kitOverlayBodyRecipe(),
|
|
59
|
-
footer: kitOverlayFooterRecipe(),
|
|
46
|
+
dialogRow: DIALOG.scrim,
|
|
47
|
+
dialog: DIALOG.panel,
|
|
48
|
+
dialogWide: kitShellClasses({ kind: 'dialog', dialogTier: 'wide' }).panel,
|
|
49
|
+
dialogXWide: kitShellClasses({ kind: 'dialog', dialogTier: 'xwide' }).panel,
|
|
50
|
+
drawerRow: DRAWER.scrim,
|
|
51
|
+
drawer: DRAWER.panel,
|
|
52
|
+
header: DIALOG.header,
|
|
53
|
+
title: DIALOG.title,
|
|
54
|
+
close: DIALOG.close,
|
|
55
|
+
headerActions: DIALOG.headActions,
|
|
56
|
+
body: DIALOG.body,
|
|
57
|
+
footer: DIALOG.footer,
|
|
60
58
|
} as const;
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* 入参是 form 视图声明(view.form);读不出字段时回 480 档。
|
|
65
|
-
*/
|
|
66
|
-
export function dialogIsWide(formView: unknown, schema?: SchemaLike): boolean {
|
|
67
|
-
const fields = formFieldsOf(formView);
|
|
68
|
-
if (fields.length > KIT_OVERLAY_LIMITS.wideFieldCount) return true;
|
|
69
|
-
return fields.some((f) => componentOfField(f, schema) === 'Transfer');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** 字段声明所在的 schema(只读 edit / component 两个键:字段控件常常写在 schema 里,而不是视图字段项里) */
|
|
73
|
-
type SchemaLike = Readonly<Record<string, { edit?: unknown; component?: unknown } | undefined>>;
|
|
74
|
-
|
|
75
|
-
/** 字段声明用的控件名:字段项自己写的 component 优先,其次 schema 里该字段的 edit / component */
|
|
76
|
-
function componentOfField(decl: unknown, schema: SchemaLike | undefined): string {
|
|
77
|
-
const name = typeof decl === 'string' ? decl : decl !== null && typeof decl === 'object' ? (decl as { name?: unknown }).name : undefined;
|
|
78
|
-
const own = decl !== null && typeof decl === 'object' ? (decl as { component?: unknown }).component : undefined;
|
|
79
|
-
if (typeof own === 'string' && own !== '') return own;
|
|
80
|
-
const fromSchema = typeof name === 'string' ? schema?.[name] : undefined;
|
|
81
|
-
const c = fromSchema?.edit ?? fromSchema?.component;
|
|
82
|
-
return typeof c === 'string' ? c : '';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** form 视图的全部字段声明:顶层 fields 与 groups[].fields 合并(分组表单的字段在 groups 里,也算长表单) */
|
|
86
|
-
function formFieldsOf(formView: unknown): unknown[] {
|
|
87
|
-
if (formView === null || typeof formView !== 'object') return [];
|
|
88
|
-
const v = formView as { fields?: unknown; groups?: unknown };
|
|
89
|
-
const out: unknown[] = Array.isArray(v.fields) ? [...v.fields] : [];
|
|
90
|
-
if (Array.isArray(v.groups)) {
|
|
91
|
-
for (const g of v.groups) {
|
|
92
|
-
const gf = g !== null && typeof g === 'object' ? (g as { fields?: unknown }).fields : undefined;
|
|
93
|
-
if (Array.isArray(gf)) out.push(...gf);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 对话框宽度三档:form 含画布(component: FlowEditor)走 960;含穿梭框(Transfer,字段或浮层的静态组件)或字段数超阈值走 720;其余 480。
|
|
101
|
-
* 入参是浮层内容:form 视图声明与静态组件名;页面写的宽度类不参与(见 stripOverlayWidthClasses)。
|
|
102
|
-
*/
|
|
103
|
-
export function dialogWidthOf(content: { form?: unknown; staticComponent?: unknown; schema?: SchemaLike }): KitDialogWidth {
|
|
104
|
-
const fields = formFieldsOf(content.form);
|
|
105
|
-
if (fields.some((f) => componentOfField(f, content.schema) === 'FlowEditor')) return 'xwide';
|
|
106
|
-
if (content.staticComponent === 'Transfer') return 'wide';
|
|
107
|
-
return dialogIsWide(content.form, content.schema) ? 'wide' : 'default';
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function dialogPanelOf(width: boolean | KitDialogWidth): string {
|
|
111
|
-
const tier: KitDialogWidth = width === true ? 'wide' : width === false ? 'default' : width;
|
|
112
|
-
return tier === 'xwide' ? OVERLAY_SHELL_CLASS.dialogXWide : tier === 'wide' ? OVERLAY_SHELL_CLASS.dialogWide : OVERLAY_SHELL_CLASS.dialog;
|
|
60
|
+
function tierOf(width: boolean | KitDialogWidth): KitDialogTier {
|
|
61
|
+
return width === true ? 'wide' : width === false ? 'default' : width;
|
|
113
62
|
}
|
|
114
63
|
|
|
115
64
|
/** 空串不出 class 属性,否则 ` class="..."` */
|
|
@@ -117,9 +66,9 @@ export function classAttr(value: string): string {
|
|
|
117
66
|
return value === '' ? '' : ` class="${esc(value)}"`;
|
|
118
67
|
}
|
|
119
68
|
|
|
120
|
-
/** 弹窗关闭钮(SVG
|
|
69
|
+
/** 弹窗关闭钮(SVG 图标钮,类串与命令式浮层的关闭钮同一份):各弹窗外壳共用 */
|
|
121
70
|
export function closeButtonHtml(id: string, label: string): string {
|
|
122
|
-
return `<button type="button" data-soma-id="${esc(id)}" aria-label="${esc(label)}"
|
|
71
|
+
return `<button type="button" data-soma-id="${esc(id)}" aria-label="${esc(label)}"${classAttr(OVERLAY_SHELL_CLASS.close)}>${kitIconHtml('close', 'md')}</button>`;
|
|
123
72
|
}
|
|
124
73
|
|
|
125
74
|
export interface DialogShellIds {
|
|
@@ -155,18 +104,17 @@ export function dialogTitles(formTitle: unknown, dflt: { create: string; edit: s
|
|
|
155
104
|
|
|
156
105
|
/** 新增 / 编辑弹窗:标题按 creating / editing 两个真值显隐,正文是 KitObjectForm */
|
|
157
106
|
export function dialogHtml(ids: DialogShellIds, copy: { create: string; edit: string }, body: string, areaClass: Record<string, string>, closeLabel = 'Close', footer = '', wide: boolean | KitDialogWidth = false): string {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
+ '</div></div></div>';
|
|
107
|
+
const decision = { kind: 'dialog', dialogTier: tierOf(wide) } as const;
|
|
108
|
+
const panelClass = mergeClass(kitShellClasses(decision).panel, stripOverlayWidthClasses(areaClass.dialog));
|
|
109
|
+
return `<div data-soma-id="${esc(ids.dialogLayer)}"${LAYER_HOST_CLASS_ATTR}>${kitShellHtml({
|
|
110
|
+
...decision,
|
|
111
|
+
panelClass,
|
|
112
|
+
titleId: ids.dialogTitle,
|
|
113
|
+
titleHtml: `<span data-soma-id="${esc(ids.dialogTitleCreate)}">${esc(copy.create)}</span><span data-soma-id="${esc(ids.dialogTitleEdit)}">${esc(copy.edit)}</span>`,
|
|
114
|
+
close: { label: closeLabel, somaId: ids.dialogClose },
|
|
115
|
+
bodyHtml: body,
|
|
116
|
+
footerHtml: footer !== '' ? footer : null,
|
|
117
|
+
})}</div>`;
|
|
170
118
|
}
|
|
171
119
|
|
|
172
120
|
// ---------------------------------------------------------------- 附加浮层(dialog / drawer)
|
|
@@ -191,19 +139,24 @@ export function overlayHtml(
|
|
|
191
139
|
closeLabel = 'Close',
|
|
192
140
|
footer = '',
|
|
193
141
|
wide: boolean | KitDialogWidth = false,
|
|
142
|
+
/** 抽屉宽度档(页面 DSL 浮层声明的 width;只对 kind: drawer 有效,缺省 default) */
|
|
143
|
+
drawerWidth: KitDrawerWidth = 'default',
|
|
144
|
+
/** 本浮层的「提交」具名动作(提交类事件绑的应用动作):成功后由框架默认关窗并给成功反馈(见 app/define-kit-actions) */
|
|
145
|
+
submitActions: readonly string[] = [],
|
|
194
146
|
): string {
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const panel = mergeClass(mergeClass(base, stripOverlayWidthClasses(areaClass[kind])), stripOverlayWidthClasses(panelClass));
|
|
147
|
+
const decision = kind === 'drawer' ? { kind, drawerWidth } as const : { kind, dialogTier: tierOf(wide) } as const;
|
|
148
|
+
const panel = mergeClass(mergeClass(kitShellClasses(decision).panel, stripOverlayWidthClasses(areaClass[kind])), stripOverlayWidthClasses(panelClass));
|
|
198
149
|
const editHost = `<div data-soma-component="Button" data-soma-id="${esc(ids.edit)}"></div>`;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
150
|
+
const submitMark = submitActions.length > 0 ? ` ${KIT_SUBMIT_ACTIONS_ATTR}="${esc(submitActions.join(' '))}"` : '';
|
|
151
|
+
return `<div data-soma-id="${esc(ids.layer)}"${submitMark}${LAYER_HOST_CLASS_ATTR}>${kitShellHtml({
|
|
152
|
+
...decision,
|
|
153
|
+
panelClass: panel,
|
|
154
|
+
titleId: ids.title,
|
|
155
|
+
titleSomaId: ids.title,
|
|
156
|
+
titleHtml: esc(title),
|
|
157
|
+
...(withEdit ? { headActionsHtml: editHost } : {}),
|
|
158
|
+
close: { label: closeLabel, somaId: ids.close },
|
|
159
|
+
bodyHtml: body,
|
|
160
|
+
footerHtml: footer !== '' ? footer : null,
|
|
161
|
+
})}</div>`;
|
|
209
162
|
}
|
|
@@ -17,9 +17,9 @@ import { emitObject } from '../../object-renderer/emit-object';
|
|
|
17
17
|
import { savedNoticePipe } from '../../object-renderer/form-notify';
|
|
18
18
|
import { viewAnchor } from '../../object-renderer/emit-static';
|
|
19
19
|
import type { KitDiagnostic, KitObject, KitViewForm } from '../../object-renderer/types';
|
|
20
|
-
import type { KitFragment } from '../../
|
|
20
|
+
import type { KitFragment } from '../../object-renderer/fragment';
|
|
21
21
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
22
|
-
import { mergeClass } from '../../
|
|
22
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
23
23
|
import {
|
|
24
24
|
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
25
25
|
} from '../shared/compile-helpers';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// SingleObjectForm 的 HTML 代码壳:居中定宽的表单卡 + 卡内标题。只有结构与 Tailwind 类(语义色名 + utilityScales 里有的尺度),不写原生 CSS。
|
|
2
2
|
// 底部固定的保存 / 重置栏是 KitObjectForm 的按钮行(actions 区),这里只给它一组 sticky 底栏类(经 classes.actions 传入)。
|
|
3
3
|
|
|
4
|
-
import { mergeClass } from '../../
|
|
4
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
5
5
|
import { kitShellRecipe } from '../../recipes/container';
|
|
6
|
+
import { KIT_DIVIDER_FOOT_CLASS, KIT_DIVIDER_HEAD_CLASS } from '../../recipes/divider';
|
|
7
|
+
import { KIT_PAGE_FORM_WIDTH_CLASS } from '../../recipes/page-width';
|
|
8
|
+
import { KIT_INSET_SURFACE_X_CLASS, KIT_STRIP_FOOT_MIN_CLASS, KIT_STRIP_HEAD_CLASS } from '../../recipes/strip';
|
|
9
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
6
10
|
import { cls, esc } from '../link/shared';
|
|
7
11
|
|
|
8
12
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -11,12 +15,13 @@ export type SingleFormArea = (typeof SINGLE_FORM_AREAS)[number];
|
|
|
11
15
|
|
|
12
16
|
export const SINGLE_FORM_CLASS = {
|
|
13
17
|
root: '@container flex justify-center',
|
|
14
|
-
card: mergeClass(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
card: mergeClass(`flex w-full ${KIT_PAGE_FORM_WIDTH_CLASS} flex-col`, kitShellRecipe({ shadow: false })),
|
|
19
|
+
// 头 = 通用头部条(strip.headPx 56,左右 inset.surfacePx 24),与窗口头 / 窗格头同一出口
|
|
20
|
+
header: `flex ${KIT_STRIP_HEAD_CLASS} items-center ${KIT_DIVIDER_HEAD_CLASS} ${KIT_INSET_SURFACE_X_CLASS}`,
|
|
21
|
+
title: kitTypographyRecipe('sectionTitle'),
|
|
22
|
+
body: 'p-inset-roomy',
|
|
18
23
|
/** 底栏:贴着可滚动祖先的底边,带分隔线与卡面底色(页面里的卡面 = bg-surface;写 raised 在暗色里比卡面亮一档,底栏成了一条亮带;浮层里的底栏另有 group 变体取浮层面) */
|
|
19
|
-
footer:
|
|
24
|
+
footer: `sticky bottom-0 mt-4 flex ${KIT_STRIP_FOOT_MIN_CLASS} flex-wrap items-center gap-cluster ${KIT_DIVIDER_FOOT_CLASS} bg-surface py-3`,
|
|
20
25
|
} as const;
|
|
21
26
|
|
|
22
27
|
export function singleFormIds(pageId: string): { root: string } {
|
|
@@ -33,7 +38,8 @@ export function singleFormHtml(
|
|
|
33
38
|
? ''
|
|
34
39
|
: `<div${cls(SINGLE_FORM_CLASS.header)}><h2${cls(SINGLE_FORM_CLASS.title)}>${esc(parts.title)}</h2></div>`;
|
|
35
40
|
const body = `<div${cls(mergeClass(SINGLE_FORM_CLASS.body, areaClass.body))}>${parts.form}</div>`;
|
|
36
|
-
|
|
41
|
+
// 唯一主体 = 页面(C2):表单卡是 E1 主体
|
|
42
|
+
const card = `<section data-kit-emphasis="primary" data-kit-role="subject" data-kit-container="card"${cls(mergeClass(SINGLE_FORM_CLASS.card, areaClass.card))}>${header}${body}</section>`;
|
|
37
43
|
const root = mergeClass(mergeClass(SINGLE_FORM_CLASS.root, areaClass.root), extra);
|
|
38
44
|
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${card}\n</div>`;
|
|
39
45
|
}
|
|
@@ -19,10 +19,10 @@ import { actionPipeline, rowActionSlotsOf } from '../../object-renderer/emit-eve
|
|
|
19
19
|
import { checkExpandChild, expandHolderHtml, expandHostId } from '../../object-renderer/collection-expand';
|
|
20
20
|
import { ctxMenuAnchor, opsAnchor, rowsAnchor, staticCtxAnchor, toolbarAnchor, treeAnchor, viewAnchor, virtualAnchor } from '../../object-renderer/emit-static';
|
|
21
21
|
import type { KitAction, KitDiagnostic, KitObject, KitViewForm } from '../../object-renderer/types';
|
|
22
|
-
import type { KitFragment } from '../../
|
|
22
|
+
import type { KitFragment } from '../../object-renderer/fragment';
|
|
23
23
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
24
24
|
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS, rewriteRowActions, type KitRowActionRoute } from '../shared/coordinator';
|
|
25
|
-
import { KIT_CRUD_LINK_KEY, compileOverlay, normalizeOverlayView, validateOverlayNames } from '../shared/overlay-compile';
|
|
25
|
+
import { KIT_CRUD_LINK_KEY, adviseDialogFooter, compileOverlay, normalizeOverlayView, validateOverlayNames } from '../shared/overlay-compile';
|
|
26
26
|
import {
|
|
27
27
|
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
28
28
|
} from '../shared/compile-helpers';
|
|
@@ -31,9 +31,12 @@ import { pipeTails, semanticPipe, wireDialogForm } from '../shared/pipes';
|
|
|
31
31
|
import { removePipe } from '../shared/remove-wire';
|
|
32
32
|
import { KIT_ACTION_SLOT_BASE } from '../../base/action-slots';
|
|
33
33
|
import { StandardCrud } from './index';
|
|
34
|
+
import { esc } from '../../shared/escape';
|
|
35
|
+
import { facetsPathOf, listSummaryFields, listSummaryHoist } from './summary';
|
|
34
36
|
import {
|
|
35
|
-
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles,
|
|
37
|
+
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
36
38
|
} from './shell';
|
|
39
|
+
import { dialogWidthOf } from '../../object-renderer/overlay-decide';
|
|
37
40
|
|
|
38
41
|
type Rec = Record<string, unknown>;
|
|
39
42
|
|
|
@@ -186,6 +189,9 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
186
189
|
registeredActions: ctx.registeredActions,
|
|
187
190
|
expandPath: expandMirrorPath,
|
|
188
191
|
formMode: 'create',
|
|
192
|
+
pagerClass: CRUD_CLASS.pager,
|
|
193
|
+
// 页面类型默认密度:列表页默认紧凑档
|
|
194
|
+
defaultDense: true,
|
|
189
195
|
...(rowClickName !== undefined ? { pickOnRow: true } : {}),
|
|
190
196
|
// 弹窗表单的 mode / initial 绑 focus 镜像
|
|
191
197
|
formModePath: mirrorPath(scope, KIT_COORD_MIRRORS.mode.key),
|
|
@@ -359,9 +365,23 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
359
365
|
// K-7:form 视图的 title(字符串两态通用,或 { create, edit })覆写弹窗标题;缺省取动作名
|
|
360
366
|
const titles = dialogTitles((entity.view?.form as KitViewForm | undefined)?.title, { create: createCopy, edit: editCopy });
|
|
361
367
|
dialog = dialogHtml(ids, titles, entityEmit.parts.form ?? '', areaClass, CLOSE_LABEL, '', dialogWidthOf({ form: entity.view?.form, schema: entity.schema }));
|
|
368
|
+
adviseDialogFooter(ctx, entity.view?.form, 'product.objects.entity.view.form.footerActions');
|
|
362
369
|
}
|
|
363
370
|
|
|
364
|
-
|
|
371
|
+
// 页头概况行:筛选区有枚举字段才给;总数 / facets 取列表响应(facets 是总数的同级兄弟字段,接口不给就整行不渲染)
|
|
372
|
+
const summaryFields = hasList ? listSummaryFields(entity) : [];
|
|
373
|
+
let summary = '';
|
|
374
|
+
const totalPath = `page.data.${object}.${entityEmit.compiled.listShape.total}`;
|
|
375
|
+
// 筛选工具条的分段计数:同一份列表响应 facets(没给就不显示计数)
|
|
376
|
+
const filterShow = out.show[`${object}__filter`] as { props?: Record<string, unknown> } | undefined;
|
|
377
|
+
if (hasList && filterShow?.props !== undefined) filterShow.props.facets = facetsPathOf(totalPath);
|
|
378
|
+
if (summaryFields.length > 0) {
|
|
379
|
+
const sid = `${object}__list_summary`;
|
|
380
|
+
out.components.add('KitListSummary');
|
|
381
|
+
out.show[sid] = { props: { total: totalPath, facets: facetsPathOf(totalPath), fields: summaryFields } };
|
|
382
|
+
summary = listSummaryHoist(`<div data-soma-component="KitListSummary" data-soma-id="${esc(sid)}"></div>`);
|
|
383
|
+
}
|
|
384
|
+
const main = mainHtml({ filter: entityEmit.parts.filter ?? '', toolbar: entityEmit.parts.toolbar ?? '', list: listHtml, summary }, areaClass);
|
|
365
385
|
const html = rootHtml(object, [main, coordinatorHtml(object), dialog, ...overlayHtmls, expandHolder], areaClass, input.class);
|
|
366
386
|
|
|
367
387
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
@@ -3,23 +3,38 @@ import { esc } from '../../shared/escape';
|
|
|
3
3
|
// 层次基准取规格 7.2:第 2 层分区容器 `bg-surface-raised rounded-lg border border-border-subtle`。
|
|
4
4
|
// 显隐层统一用 `fixed inset-0` 的遮罩 + 内层 flex 容器:显隐只靠 core 写 `hidden` 属性,不在遮罩自身叠 display 类。
|
|
5
5
|
|
|
6
|
-
import { mergeClass } from '../../
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
7
|
+
import { KIT_LIST_BAR_FLAT_CLASS } from '../../recipes/container';
|
|
8
|
+
import { kitSurfaceRecipe } from '../../recipes/surface';
|
|
9
|
+
import { KIT_FILTER_TOOLBAR_MARK } from '../../object-renderer/filter-toolbar';
|
|
10
|
+
import { KIT_STRIP_FOOT_CLASS } from '../../recipes/strip';
|
|
11
|
+
import { KIT_DIVIDER_FOOT_CLASS } from '../../recipes/divider';
|
|
12
|
+
import { KIT_LIST_PANEL_CLASS, hoistedToolbarHtml, listPanelParts } from '../shared/compile-helpers';
|
|
13
|
+
import { OVERLAY_SHELL_CLASS, classAttr, closeButtonHtml, dialogHtml, dialogIds, dialogTitles, overlayHtml, overlayIds } from '../shared/overlay-shell';
|
|
10
14
|
|
|
11
15
|
// 弹窗外壳与附加浮层壳的公共部分已下沉到 biz/shared/overlay-shell(主从工作台同用);这里原样 re-export,保持原导出名可用
|
|
12
|
-
export { closeButtonHtml, dialogHtml, dialogIds,
|
|
16
|
+
export { closeButtonHtml, dialogHtml, dialogIds, dialogTitles, overlayHtml, overlayIds };
|
|
13
17
|
|
|
14
18
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
15
19
|
export const STANDARD_CRUD_AREAS = ['root', 'filter', 'list', 'dialog', 'drawer'] as const;
|
|
16
20
|
export type StandardCrudArea = (typeof STANDARD_CRUD_AREAS)[number];
|
|
17
21
|
|
|
18
22
|
export const CRUD_CLASS = {
|
|
19
|
-
root: 'flex flex-col gap-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
root: 'flex flex-col gap-region',
|
|
24
|
+
/** 筛选带(列表为空 / 无集合时单独出现):自带圆角的下沉带,与列表工作面里的筛选带同一份类(不再是独立卡) */
|
|
25
|
+
filter: KIT_LIST_BAR_FLAT_CLASS,
|
|
26
|
+
/** 筛选工具条(搜索 + 分段 / 下拉):画布上的一行,不进工作面;块级(表单宿主是容器查询根,在 flex 行里会塌成 0 宽,所以这里不是 flex) */
|
|
27
|
+
toolbar: 'min-w-0',
|
|
28
|
+
/** 复杂筛选:一张白色分组面(面 + 内边距),在画布上、工作面之前 */
|
|
29
|
+
filterFace: mergeClass('flex flex-col', mergeClass(kitSurfaceRecipe('panel'), 'p-card')),
|
|
30
|
+
/** 列表工作面:唯一主体 = 页面上唯一一张工作面(白色面落在统一画布上,与别的页型的卡同一种边缘处理);面本身不带内边距,文字落在对齐轴上,筛选带贴顶通栏 */
|
|
31
|
+
// overflow-clip:表头带 / 底栏带的四角随面的圆角裁切(clip 不建滚动容器,底栏的 sticky 仍相对页面滚动);面内段与段贴合(表头带 / 数据行 / 底栏),不留 gap
|
|
32
|
+
list: mergeClass('flex flex-col overflow-clip', kitSurfaceRecipe('panel')),
|
|
33
|
+
listHeadRow: KIT_LIST_PANEL_CLASS.listHeadRow,
|
|
34
|
+
/** 分页条:贴工作面底(内容不足一屏时在表后自然位置,超出一屏时粘在底)、底色同工作面、文字落在对齐轴上(轴内边距同 p-card 角色) */
|
|
35
|
+
// 底栏 = 面内一条底栏(高 sizeSpec.strip.footPx,与表体之间一条分隔线),底色同工作面(粘底时盖住滚上来的行);
|
|
36
|
+
// 一处分隔只用一种手段(边框普查 B05 / 公开规范摘要 M19):已有分隔线就不再另铺浅带(此前浅带 + 线 = 面差与线叠加)
|
|
37
|
+
pager: `sticky bottom-0 z-10 ${KIT_STRIP_FOOT_CLASS} ${KIT_DIVIDER_FOOT_CLASS} bg-surface px-card`,
|
|
23
38
|
...OVERLAY_SHELL_CLASS,
|
|
24
39
|
} as const;
|
|
25
40
|
|
|
@@ -48,27 +63,20 @@ export function coordinatorId(object: string): string {
|
|
|
48
63
|
return `${object}__link`;
|
|
49
64
|
}
|
|
50
65
|
|
|
51
|
-
/** 主区:筛选卡 + 列表卡(工具栏在列表卡里,排在列表之前)。区域类按 7.3
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const restList = m[2]!;
|
|
66
|
-
listInner = [`<div${cls(CRUD_CLASS.listHeadRow)}>${titleH3}${parts.toolbar}</div>`, restList].filter((p) => p !== '').join('\n');
|
|
67
|
-
} else {
|
|
68
|
-
listInner = [parts.toolbar, parts.list].filter((p) => p !== '').join('\n');
|
|
69
|
-
}
|
|
70
|
-
if (listInner !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.list, areaClass.list))}>${listInner}</section>`);
|
|
71
|
-
return blocks.join('\n');
|
|
66
|
+
/** 主区:筛选卡 + 列表卡(工具栏在列表卡里,排在列表之前)。区域类按 7.3 同族规则覆写。拆分规则与主从 / 分类壳共用 shared/compile-helpers#listPanelParts */
|
|
67
|
+
export function mainHtml(parts: { filter: string; toolbar: string; list: string; summary?: string }, areaClass: Record<string, string>): string {
|
|
68
|
+
const hoist = parts.toolbar !== '';
|
|
69
|
+
const { filterInner, listInner } = listPanelParts(hoist ? { filter: parts.filter, toolbar: '', list: parts.list } : parts);
|
|
70
|
+
if (listInner === '') return parts.filter === '' ? '' : `<div${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${filterInner}</div>`;
|
|
71
|
+
// 页面构成(C2 唯一主体 = 页面本身):列表就是页面——不再包一张卡(container: plain、强调 primary),页面底取面板面(data-kit-canvas-hint,页面编译写 data-kit-canvas);
|
|
72
|
+
// 筛选带是自带圆角的下沉带,区域主动作打搬运标记由页面编译搬进页头尾端(页头一行 = 标题 + 主动作)
|
|
73
|
+
// 用 div 而不是 section:section 会被主题当容器画外框(描边 / 圆角 / 阴影),而本工作面是无容器的页面本体
|
|
74
|
+
// 风格档案 SPACE_MATERIAL:筛选工具条在画布上(不进白色工作面),工作面 = 表头浅带 + 数据行 + 底栏分页;
|
|
75
|
+
// 复杂筛选(不是搜索 + 分段 / 下拉工具条)仍收在一张白色分组面里,免得表单字段直接散在画布上
|
|
76
|
+
const hoisted = hoistedToolbarHtml(parts.toolbar);
|
|
77
|
+
const toolbar = filterInner.includes(KIT_FILTER_TOOLBAR_MARK);
|
|
78
|
+
const bar = filterInner === '' ? '' : `<div${cls(toolbar ? mergeClass(CRUD_CLASS.toolbar, areaClass.filter) : mergeClass(CRUD_CLASS.filterFace, areaClass.filter))}>${filterInner}</div>`;
|
|
79
|
+
return `${bar}<div data-kit-emphasis="primary" data-kit-role="subject" data-kit-axis=""${cls(mergeClass(CRUD_CLASS.list, areaClass.list))}>${parts.summary ?? ''}${hoisted}${listInner}</div>`;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
export function rootHtml(object: string, children: string[], areaClass: Record<string, string>, extra: string | undefined): string {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// StandardCrud 页头概况行的编译期部分:从筛选区的枚举字段取分面字段(名 + 枚举值 → 标签),给 KitListSummary 的静态 props。
|
|
2
|
+
// 总数 / facets 的取值路径由列表响应的总数路径推出(facets 与总数同级的兄弟字段);响应没给 facets 时组件整行不渲染。
|
|
3
|
+
|
|
4
|
+
import { esc } from '../../shared/escape';
|
|
5
|
+
import type { KitListSummaryField } from '../../frames/list-summary';
|
|
6
|
+
import { KIT_HOIST_ATTR, KIT_HOIST_HEADER_SUMMARY } from '../shared/compile-helpers';
|
|
7
|
+
|
|
8
|
+
type Rec = Record<string, unknown>;
|
|
9
|
+
|
|
10
|
+
function isRec(v: unknown): v is Rec {
|
|
11
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 筛选区里的枚举字段(按筛选字段序):字段声明了 options({ value, label })才算;没有枚举字段 → 空数组(页头不给概况)。 */
|
|
15
|
+
export function listSummaryFields(entity: { schema: unknown; view?: unknown }): KitListSummaryField[] {
|
|
16
|
+
const view = isRec(entity.view) ? entity.view : undefined;
|
|
17
|
+
const filter = view !== undefined && isRec(view.filter) ? view.filter : undefined;
|
|
18
|
+
const names = Array.isArray(filter?.fields)
|
|
19
|
+
? (filter.fields as unknown[]).map((f) => (typeof f === 'string' ? f : isRec(f) ? Object.keys(f)[0] : undefined)).filter((n): n is string => n !== undefined)
|
|
20
|
+
: [];
|
|
21
|
+
const schema = isRec(entity.schema) ? entity.schema : {};
|
|
22
|
+
const out: KitListSummaryField[] = [];
|
|
23
|
+
for (const field of names) {
|
|
24
|
+
const decl = schema[field];
|
|
25
|
+
if (!isRec(decl) || decl.type !== 'enum' || !Array.isArray(decl.options)) continue;
|
|
26
|
+
const options = (decl.options as unknown[]).flatMap((o) => (isRec(o) && typeof o.value === 'string'
|
|
27
|
+
? [{ value: o.value, label: typeof o.label === 'string' ? o.label : o.value, ...(typeof o.tone === 'string' ? { tone: o.tone } : {}) }]
|
|
28
|
+
: []));
|
|
29
|
+
if (options.length > 0) out.push({ field, options });
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 列表响应总数路径的同级 facets 路径(`a.b.total` → `a.b.facets`)。 */
|
|
35
|
+
export function facetsPathOf(totalPath: string): string {
|
|
36
|
+
return totalPath.includes('.') ? totalPath.replace(/\.[^.]+$/, '.facets') : 'facets';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 概况行的搬运块(标记 + 宿主);调用方保证宿主 id 与 show 条目已登记。 */
|
|
40
|
+
export function listSummaryHoist(hostHtml: string): string {
|
|
41
|
+
return `<div ${KIT_HOIST_ATTR}="${esc(KIT_HOIST_HEADER_SUMMARY)}" class="contents">${hostHtml}</div>`;
|
|
42
|
+
}
|