soma-kit 0.1.13 → 0.1.14
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/spec/generated/kit-app.schema.json +14 -0
- package/spec/generated/kit-page.schema.json +25 -0
- package/spec/kit-grammar.json +178 -27
- package/spec/kit-grammar.schema.json +1 -3
- package/src/app/app-config.ts +10 -4
- package/src/app/index.ts +13 -1
- package/src/app/kit-view-context.ts +19 -2
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/base/button.ts +5 -3
- package/src/base/end-edge.ts +14 -2
- package/src/base/gap-value.ts +24 -4
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +5 -0
- package/src/base/menu-button.ts +10 -23
- package/src/base/popover.ts +5 -4
- package/src/base/segmented.ts +14 -4
- package/src/base/shared.ts +11 -13
- package/src/base/state-panel.ts +34 -13
- package/src/base/tag.ts +18 -13
- package/src/base/text.ts +1 -1
- package/src/base/upload.ts +5 -4
- package/src/biz/approval-desk/shell.ts +8 -7
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +3 -2
- package/src/biz/category-crud/shell.ts +4 -3
- package/src/biz/checkout-page/shell.ts +9 -8
- package/src/biz/compose.ts +2 -2
- package/src/biz/data-components.ts +4 -0
- package/src/biz/import-wizard/shell.ts +12 -10
- package/src/biz/landing-page/shell.ts +2 -2
- package/src/biz/master-sub/compile.ts +114 -15
- package/src/biz/master-sub/detail-head.ts +61 -0
- package/src/biz/master-sub/index.ts +3 -2
- package/src/biz/master-sub/shell.ts +95 -63
- package/src/biz/multi-board/compile.ts +164 -9
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +1 -1
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +91 -23
- package/src/biz/notification-center/shell.ts +6 -5
- package/src/biz/page-templates/domain-templates.ts +2 -2
- package/src/biz/page-templates/result-page/shell.ts +2 -2
- package/src/biz/page-templates/sign-in-page/shell.ts +14 -14
- package/src/biz/record-detail/shell.ts +8 -7
- package/src/biz/settings-center/shell.ts +8 -7
- package/src/biz/shared/compile-helpers.ts +82 -3
- package/src/biz/shared/overlay-compile.ts +46 -4
- package/src/biz/shared/overlay-shell.ts +8 -6
- package/src/biz/single-form/shell.ts +6 -4
- package/src/biz/standard-crud/compile.ts +14 -1
- package/src/biz/standard-crud/shell.ts +18 -27
- package/src/biz/standard-crud/summary.ts +40 -0
- package/src/biz/step-form/shell.ts +11 -9
- package/src/biz/types.ts +6 -1
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/compile-page.ts +15 -4
- package/src/compile/component-candidates.ts +2 -0
- package/src/compile/fragment.ts +11 -0
- package/src/compile/layout-lint/rules-composition.ts +55 -6
- 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 +189 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/styles.ts +11 -1
- package/src/compile/types.ts +3 -1
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +3 -1
- package/src/data/approval-flow.ts +4 -1
- package/src/data/assignment-picker.ts +9 -4
- package/src/data/async-result-panel.ts +1 -1
- package/src/data/calendar.ts +7 -2
- package/src/data/carousel.ts +2 -0
- package/src/data/chart.ts +609 -42
- package/src/data/checklist.ts +4 -1
- package/src/data/comment-thread.ts +2 -1
- package/src/data/confirm-dialog.ts +4 -10
- package/src/data/field-mapper.ts +4 -1
- package/src/data/flow-editor.ts +2 -1
- package/src/data/footer.ts +2 -0
- package/src/data/gantt.ts +187 -25
- package/src/data/hero.ts +2 -0
- package/src/data/index.ts +10 -3
- package/src/data/item-list.ts +10 -3
- package/src/data/kanban.ts +3 -1
- package/src/data/matrix.ts +391 -0
- package/src/data/menu.ts +23 -11
- package/src/data/mockup.ts +3 -3
- package/src/data/modal-dialog.ts +118 -18
- package/src/data/navbar.ts +3 -1
- package/src/data/notice-list.ts +52 -19
- package/src/data/object-form.ts +128 -112
- package/src/data/pager.ts +3 -2
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +4 -1
- package/src/data/permission-tree.ts +6 -2
- package/src/data/pricing-table.ts +2 -1
- package/src/data/record-card.ts +18 -6
- package/src/data/resident.ts +8 -0
- package/src/data/row-editor.ts +2 -2
- package/src/data/rule-builder.ts +9 -4
- package/src/data/shape-util.ts +15 -14
- package/src/data/stat-group.ts +313 -69
- package/src/data/static-lazy.ts +4 -0
- package/src/data/static-registry.ts +6 -0
- package/src/data/survey.ts +4 -1
- package/src/data/system-switcher.ts +2 -1
- package/src/data/tour-guide.ts +2 -1
- package/src/data/transfer.ts +6 -2
- package/src/data/tree-table.ts +7 -5
- package/src/data/tree.ts +1 -1
- package/src/data/virtual-rows.ts +5 -4
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +1 -0
- package/src/frames/list-summary.ts +100 -0
- package/src/frames/page-bar.ts +6 -14
- package/src/frames/shared.ts +20 -4
- package/src/frames/tabs-frame/shell.ts +8 -6
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +3 -1
- package/src/frames/workspace-frame/shell.ts +2 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +41 -25
- package/src/generated/kit-grammar-runtime.ts +175 -28
- package/src/i18n/kit-text.ts +27 -0
- package/src/object-renderer/action-group.ts +139 -0
- package/src/object-renderer/action-more.ts +144 -0
- package/src/object-renderer/arrange.ts +49 -19
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +34 -13
- package/src/object-renderer/collection-table.ts +133 -65
- package/src/object-renderer/collection.ts +72 -59
- package/src/object-renderer/defaults.ts +2 -5
- package/src/object-renderer/emit-object.ts +4 -0
- package/src/object-renderer/emit-static.ts +116 -63
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/index.ts +5 -0
- package/src/object-renderer/layout-facts.ts +9 -1
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +59 -46
- package/src/object-renderer/table-actions.ts +72 -40
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +51 -20
- package/src/object-renderer/types.ts +7 -7
- package/src/recipes/container.ts +31 -0
- package/src/recipes/control.ts +57 -155
- package/src/recipes/emphasis.ts +56 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +23 -0
- package/src/recipes/overlay.ts +46 -1
- package/src/recipes/placeholder.ts +20 -4
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +12 -22
- package/src/recipes/status.ts +8 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +112 -6
- package/src/recipes/tabs.ts +49 -0
- package/src/recipes/title-row.ts +3 -3
- package/src/recipes/typography.ts +23 -42
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +13 -2
- package/src/theme/kit-theme.tpl +13 -2
- package/src/theme/nine-dim-structure.ts +77 -10
- package/src/theme/surface-layers.ts +6 -1
- package/src/theme/theme-tokens.ts +12 -5
- package/src/theme/typography.ts +21 -17
|
@@ -22,7 +22,28 @@ 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 { dialogWidthOf, overlayHtml, overlayIds } from './overlay-shell';
|
|
25
|
+
import { dialogWidthOf, overlayHtml, overlayIds, type KitDialogWidth } from './overlay-shell';
|
|
26
|
+
import { KIT_DIALOG_WIDTH_TIERS, KIT_DRAWER_WIDTHS, isKitDialogWidth, isKitDrawerWidth, type KitDrawerWidth } from '../../recipes/overlay';
|
|
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
|
+
}
|
|
26
47
|
|
|
27
48
|
/** 浮层里数据组件的约定事件 -> 角色(K-1) */
|
|
28
49
|
const OVERLAY_EVENT_ROLES: Record<string, string> = KIT_GRAMMAR.overlayEventRoles.conventional as Record<string, string>;
|
|
@@ -108,11 +129,32 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
108
129
|
const fail: Fail = (code, message, path) => { out.diagnostics.push({ code, message, path } as KitDiagnostic); };
|
|
109
130
|
const at = `product.overlays.${name}`;
|
|
110
131
|
if (!IDENT.test(name)) return undefined;
|
|
132
|
+
// 抽屉宽度档:width 只对 kind: drawer 有效(对话框宽度由内容定档),取值闭集 narrow / default / wide
|
|
133
|
+
let drawerWidth: KitDrawerWidth = 'default';
|
|
134
|
+
let dialogTier: KitDialogWidth | undefined;
|
|
135
|
+
if (decl.width !== undefined) {
|
|
136
|
+
if (decl.kind === 'drawer') {
|
|
137
|
+
if (!isKitDrawerWidth(decl.width)) fail('KIT-BIZ-003', `浮层 ${name} 的 width "${String(decl.width)}" 不在抽屉档内(${KIT_DRAWER_WIDTHS.join(' / ')})`, `${at}.width`);
|
|
138
|
+
else drawerWidth = decl.width;
|
|
139
|
+
} else if (decl.kind === 'dialog') {
|
|
140
|
+
if (!isKitDialogWidth(decl.width)) fail('KIT-BIZ-003', `浮层 ${name} 的 width "${String(decl.width)}" 不在对话框档内(${KIT_DIALOG_WIDTH_TIERS.join(' / ')})`, `${at}.width`);
|
|
141
|
+
else dialogTier = decl.width;
|
|
142
|
+
} else {
|
|
143
|
+
fail('KIT-BIZ-003', `浮层 ${name} 的 width 只对 kind: drawer / dialog 有效`, `${at}.width`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
111
146
|
const view = normalizeOverlayView(decl.view);
|
|
112
147
|
if (view === undefined) {
|
|
113
148
|
fail('KIT-BIZ-001', `附加浮层 ${name} 缺少 view`, `${at}.view`);
|
|
114
149
|
return undefined;
|
|
115
150
|
}
|
|
151
|
+
// 抽屉只承载只读详情;要填写并提交、或确认后写入的浮层一律居中模态(KIT-OVL-001)
|
|
152
|
+
if (decl.kind === 'drawer') {
|
|
153
|
+
const why = drawerSubmitReason(decl, view, ctx.staticComponents);
|
|
154
|
+
if (why !== null) {
|
|
155
|
+
fail('KIT-OVL-001', `浮层 ${name} 是抽屉却承载提交动作(${why}):填写并提交、或确认后写入的浮层改写 kind: dialog(内容多的加 width: wide),抽屉只用于只读详情`, `${at}.kind`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
116
158
|
// 编辑详情(behavior.detail)与读通道(behavior.from)二选一:from 已是「按关联键取浮层对象」的读口
|
|
117
159
|
if (decl.behavior?.from !== undefined && decl.behavior?.detail !== undefined) {
|
|
118
160
|
fail('KIT-DET-001', `附加浮层 ${name} 同时写了 behavior.from 与 behavior.detail:二选一(from 已按关联键取浮层对象,detail 用于以当前行为初值的编辑表单)`, `${at}.behavior.detail`);
|
|
@@ -227,12 +269,12 @@ export function compileOverlay(h: OverlayHostArgs, name: string, decl: KitOverla
|
|
|
227
269
|
out.events[`${ids.edit}.click`] = semanticPipe(scope, KIT_COORD_EVENTS.showEdit);
|
|
228
270
|
}
|
|
229
271
|
return {
|
|
230
|
-
// 对话框宽度只由内容定档(480 / 720 / 960,见 dialogWidthOf
|
|
231
|
-
html: overlayHtml(ids, decl.kind === 'drawer' ? 'drawer' : 'dialog', decl.title ?? name, ovEmit.html, decl.class, areaClass, withEdit, h.closeLabel, '', dialogWidthOf({
|
|
272
|
+
// 对话框宽度只由内容定档(480 / 720 / 960,见 dialogWidthOf),抽屉由 width 三档(缺省 560);页面写的宽度类(class / areaClass)被壳忽略
|
|
273
|
+
html: overlayHtml(ids, decl.kind === 'drawer' ? 'drawer' : 'dialog', decl.title ?? name, ovEmit.html, decl.class, areaClass, withEdit, h.closeLabel, '', dialogTier ?? dialogWidthOf({
|
|
232
274
|
form: view.form,
|
|
233
275
|
schema: decl.schema,
|
|
234
276
|
staticComponent: view.list?.staticComponent ?? view.summary?.staticComponent,
|
|
235
|
-
})),
|
|
277
|
+
}), drawerWidth),
|
|
236
278
|
mirror: { key: overlayMirrorKey(name), slice: 'focus', path: `ov.${name}`, as: 'truthy' },
|
|
237
279
|
object: ovObject,
|
|
238
280
|
};
|
|
@@ -6,8 +6,7 @@ import { esc } from '../../shared/escape';
|
|
|
6
6
|
|
|
7
7
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
8
8
|
import { KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
|
|
9
|
-
import { KIT_DIALOG_SURFACE_CLASS, KIT_OVERLAY_SCROLL_ATTR, KIT_OVERLAY_WIDTH_CLASS } from '../../recipes/overlay';
|
|
10
|
-
import { KIT_SURFACE_EDGE_CLASS } from '../../recipes/surface';
|
|
9
|
+
import { KIT_DIALOG_SURFACE_CLASS, KIT_OVERLAY_SCROLL_ATTR, KIT_OVERLAY_WIDTH_CLASS, kitDrawerPanelClass, type KitDrawerWidth } from '../../recipes/overlay';
|
|
11
10
|
import { kitIconHtml } from '../../base/icons';
|
|
12
11
|
import {
|
|
13
12
|
KIT_FIXED_ATTRIBUTE, KIT_PART_DIALOG, KIT_PART_DRAWER, KIT_PART_TITLE_DIALOG,
|
|
@@ -44,17 +43,18 @@ export const OVERLAY_SHELL_CLASS = {
|
|
|
44
43
|
// 最外层只放 core 写的 hidden 属性,不带任何类(core 样式引擎没有 preflight,hidden 与 flex 同元素会失效);fixed / flex 在内层
|
|
45
44
|
// 入场动画:core 切 hidden(display:none → 显示)时 CSS 动画自动重播;遮罩淡入、对话框缩放淡入、抽屉从 end 侧滑入(RTL 换向)
|
|
46
45
|
// 退场:显隐外层(_layer)经 core 的 renderPorts.hideTransition 钩子(base/overlay-runtime)退场:关闭时先标 data-kit-leaving 等退场动画结束再真隐藏(退场关键帧由主题侧补,没有则立即隐藏)
|
|
47
|
-
dialogRow: 'fixed inset-0 z-50 flex items-center justify-center bg-scrim p-
|
|
46
|
+
dialogRow: 'fixed inset-0 z-50 flex items-center justify-center bg-scrim p-card motion-safe:animate-kit-fade',
|
|
48
47
|
// 宽度两档 + 抽屉一档读 design 真源(kit-limits#overlay):对话框 480 默认、720 长表单(dialogWide)、抽屉 560
|
|
49
48
|
dialog: dialogPanelClass(KIT_OVERLAY_WIDTH_CLASS.dialog),
|
|
50
49
|
dialogWide: dialogPanelClass(KIT_OVERLAY_WIDTH_CLASS.dialogWide),
|
|
51
50
|
dialogXWide: dialogPanelClass(KIT_OVERLAY_WIDTH_CLASS.dialogXWide),
|
|
52
51
|
drawerRow: 'fixed inset-0 z-50 flex justify-end bg-scrim motion-safe:animate-kit-fade',
|
|
53
|
-
|
|
52
|
+
// 抽屉三档(narrow / default / wide)读 kit-limits#overlay.drawerPx;面板类串与命令式 mountKitDrawer 同一份(recipes/overlay.ts#kitDrawerPanelClass)
|
|
53
|
+
drawer: kitDrawerPanelClass('default'),
|
|
54
54
|
header: kitOverlayHeaderRecipe(),
|
|
55
55
|
title: kitTypographyRecipe('dialogTitle'),
|
|
56
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-
|
|
57
|
+
headerActions: 'flex items-center gap-cluster',
|
|
58
58
|
body: kitOverlayBodyRecipe(),
|
|
59
59
|
footer: kitOverlayFooterRecipe(),
|
|
60
60
|
} as const;
|
|
@@ -191,9 +191,11 @@ export function overlayHtml(
|
|
|
191
191
|
closeLabel = 'Close',
|
|
192
192
|
footer = '',
|
|
193
193
|
wide: boolean | KitDialogWidth = false,
|
|
194
|
+
/** 抽屉宽度档(页面 DSL 浮层声明的 width;只对 kind: drawer 有效,缺省 default) */
|
|
195
|
+
drawerWidth: KitDrawerWidth = 'default',
|
|
194
196
|
): string {
|
|
195
197
|
const isDrawer = kind === 'drawer';
|
|
196
|
-
const base = isDrawer ?
|
|
198
|
+
const base = isDrawer ? kitDrawerPanelClass(drawerWidth) : dialogPanelOf(wide);
|
|
197
199
|
const panel = mergeClass(mergeClass(base, stripOverlayWidthClasses(areaClass[kind])), stripOverlayWidthClasses(panelClass));
|
|
198
200
|
const editHost = `<div data-soma-component="Button" data-soma-id="${esc(ids.edit)}"></div>`;
|
|
199
201
|
return `<div data-soma-id="${esc(ids.layer)}"${LAYER_HOST_CLASS_ATTR}>`
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
5
5
|
import { kitShellRecipe } from '../../recipes/container';
|
|
6
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
6
7
|
import { cls, esc } from '../link/shared';
|
|
7
8
|
|
|
8
9
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -13,10 +14,10 @@ export const SINGLE_FORM_CLASS = {
|
|
|
13
14
|
root: '@container flex justify-center',
|
|
14
15
|
card: mergeClass('flex w-full max-w-2xl flex-col', kitShellRecipe({ shadow: false })),
|
|
15
16
|
header: 'border-b border-border-subtle px-6 py-4',
|
|
16
|
-
title: '
|
|
17
|
-
body: 'p-
|
|
17
|
+
title: kitTypographyRecipe('sectionTitle'),
|
|
18
|
+
body: 'p-inset-roomy',
|
|
18
19
|
/** 底栏:贴着可滚动祖先的底边,带分隔线与卡面底色(页面里的卡面 = bg-surface;写 raised 在暗色里比卡面亮一档,底栏成了一条亮带;浮层里的底栏另有 group 变体取浮层面) */
|
|
19
|
-
footer: 'sticky bottom-0 mt-4 flex flex-wrap items-end gap-
|
|
20
|
+
footer: 'sticky bottom-0 mt-4 flex flex-wrap items-end gap-cluster border-t border-border-subtle bg-surface py-3',
|
|
20
21
|
} as const;
|
|
21
22
|
|
|
22
23
|
export function singleFormIds(pageId: string): { root: string } {
|
|
@@ -33,7 +34,8 @@ export function singleFormHtml(
|
|
|
33
34
|
? ''
|
|
34
35
|
: `<div${cls(SINGLE_FORM_CLASS.header)}><h2${cls(SINGLE_FORM_CLASS.title)}>${esc(parts.title)}</h2></div>`;
|
|
35
36
|
const body = `<div${cls(mergeClass(SINGLE_FORM_CLASS.body, areaClass.body))}>${parts.form}</div>`;
|
|
36
|
-
|
|
37
|
+
// 唯一主体 = 页面(C2):表单卡是 E1 主体
|
|
38
|
+
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
39
|
const root = mergeClass(mergeClass(SINGLE_FORM_CLASS.root, areaClass.root), extra);
|
|
38
40
|
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${card}\n</div>`;
|
|
39
41
|
}
|
|
@@ -31,6 +31,8 @@ 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
37
|
CRUD_CLASS, STANDARD_CRUD_AREAS, classesIn, coordinatorHtml, coordinatorId, dialogHtml, dialogIds, dialogTitles, dialogWidthOf, mainHtml, overlayHtml, overlayIds, rootHtml,
|
|
36
38
|
} from './shell';
|
|
@@ -186,6 +188,7 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
186
188
|
registeredActions: ctx.registeredActions,
|
|
187
189
|
expandPath: expandMirrorPath,
|
|
188
190
|
formMode: 'create',
|
|
191
|
+
pagerClass: CRUD_CLASS.pager,
|
|
189
192
|
...(rowClickName !== undefined ? { pickOnRow: true } : {}),
|
|
190
193
|
// 弹窗表单的 mode / initial 绑 focus 镜像
|
|
191
194
|
formModePath: mirrorPath(scope, KIT_COORD_MIRRORS.mode.key),
|
|
@@ -361,7 +364,17 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
361
364
|
dialog = dialogHtml(ids, titles, entityEmit.parts.form ?? '', areaClass, CLOSE_LABEL, '', dialogWidthOf({ form: entity.view?.form, schema: entity.schema }));
|
|
362
365
|
}
|
|
363
366
|
|
|
364
|
-
|
|
367
|
+
// 页头概况行:筛选区有枚举字段才给;总数 / facets 取列表响应(facets 是总数的同级兄弟字段,接口不给就整行不渲染)
|
|
368
|
+
const summaryFields = hasList ? listSummaryFields(entity) : [];
|
|
369
|
+
let summary = '';
|
|
370
|
+
if (summaryFields.length > 0) {
|
|
371
|
+
const sid = `${object}__list_summary`;
|
|
372
|
+
const totalPath = `page.data.${object}.${entityEmit.compiled.listShape.total}`;
|
|
373
|
+
out.components.add('KitListSummary');
|
|
374
|
+
out.show[sid] = { props: { total: totalPath, facets: facetsPathOf(totalPath), fields: summaryFields } };
|
|
375
|
+
summary = listSummaryHoist(`<div data-soma-component="KitListSummary" data-soma-id="${esc(sid)}"></div>`);
|
|
376
|
+
}
|
|
377
|
+
const main = mainHtml({ filter: entityEmit.parts.filter ?? '', toolbar: entityEmit.parts.toolbar ?? '', list: listHtml, summary }, areaClass);
|
|
365
378
|
const html = rootHtml(object, [main, coordinatorHtml(object), dialog, ...overlayHtmls, expandHolder], areaClass, input.class);
|
|
366
379
|
|
|
367
380
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
@@ -4,8 +4,8 @@ import { esc } from '../../shared/escape';
|
|
|
4
4
|
// 显隐层统一用 `fixed inset-0` 的遮罩 + 内层 flex 容器:显隐只靠 core 写 `hidden` 属性,不在遮罩自身叠 display 类。
|
|
5
5
|
|
|
6
6
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { KIT_LIST_BAR_FLAT_CLASS } from '../../recipes/container';
|
|
8
|
+
import { KIT_LIST_PANEL_CLASS, flatListPanelHtml, listPanelParts } from '../shared/compile-helpers';
|
|
9
9
|
import { OVERLAY_SHELL_CLASS, classAttr, closeButtonHtml, dialogHtml, dialogIds, dialogIsWide, dialogTitles, dialogWidthOf, overlayHtml, overlayIds } from '../shared/overlay-shell';
|
|
10
10
|
|
|
11
11
|
// 弹窗外壳与附加浮层壳的公共部分已下沉到 biz/shared/overlay-shell(主从工作台同用);这里原样 re-export,保持原导出名可用
|
|
@@ -16,10 +16,14 @@ export const STANDARD_CRUD_AREAS = ['root', 'filter', 'list', 'dialog', 'drawer'
|
|
|
16
16
|
export type StandardCrudArea = (typeof STANDARD_CRUD_AREAS)[number];
|
|
17
17
|
|
|
18
18
|
export const CRUD_CLASS = {
|
|
19
|
-
root: 'flex flex-col gap-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
root: 'flex flex-col gap-region',
|
|
20
|
+
/** 筛选带(列表为空 / 无集合时单独出现):自带圆角的下沉带,与列表工作面里的筛选带同一份类(不再是独立卡) */
|
|
21
|
+
filter: KIT_LIST_BAR_FLAT_CLASS,
|
|
22
|
+
/** 列表工作面:无容器(唯一主体 = 页面本身),表头 / 数据行 / 计数分页直接铺在页面上 */
|
|
23
|
+
list: 'flex flex-col gap-region',
|
|
24
|
+
listHeadRow: KIT_LIST_PANEL_CLASS.listHeadRow,
|
|
25
|
+
/** 分页条:贴工作面底(内容不足一屏时在表后自然位置,超出一屏时粘在底)、底色同工作面、文字落在对齐轴上(轴内边距同 p-card 角色) */
|
|
26
|
+
pager: 'sticky bottom-0 z-10 bg-surface px-card py-2',
|
|
23
27
|
...OVERLAY_SHELL_CLASS,
|
|
24
28
|
} as const;
|
|
25
29
|
|
|
@@ -48,27 +52,14 @@ export function coordinatorId(object: string): string {
|
|
|
48
52
|
return `${object}__link`;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
/** 主区:筛选卡 + 列表卡(工具栏在列表卡里,排在列表之前)。区域类按 7.3
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
if (parts.filter !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${toolbarInFilter ? filterToolbarRow(parts.filter, parts.toolbar) : parts.filter}</section>`);
|
|
60
|
-
let listInner = '';
|
|
61
|
-
if (toolbarInFilter) {
|
|
62
|
-
listInner = parts.list;
|
|
63
|
-
} else if (m !== null) {
|
|
64
|
-
const titleH3 = m[1]!.replace(/\bmb-\d+(?:\.\d+)?\s*/g, '');
|
|
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');
|
|
55
|
+
/** 主区:筛选卡 + 列表卡(工具栏在列表卡里,排在列表之前)。区域类按 7.3 同族规则覆写。拆分规则与主从 / 分类壳共用 shared/compile-helpers#listPanelParts */
|
|
56
|
+
export function mainHtml(parts: { filter: string; toolbar: string; list: string; summary?: string }, areaClass: Record<string, string>): string {
|
|
57
|
+
const { filterInner, listInner } = listPanelParts(parts);
|
|
58
|
+
if (listInner === '') return parts.filter === '' ? '' : `<div${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${filterInner}</div>`;
|
|
59
|
+
// 页面构成(C2 唯一主体 = 页面本身):列表就是页面——不再包一张卡(container: plain、强调 primary),页面底取面板面(data-kit-canvas-hint,页面编译写 data-kit-canvas);
|
|
60
|
+
// 筛选带是自带圆角的下沉带,区域主动作打搬运标记由页面编译搬进页头尾端(页头一行 = 标题 + 主动作)
|
|
61
|
+
// 用 div 而不是 section:section 会被主题当容器画外框(描边 / 圆角 / 阴影),而本工作面是无容器的页面本体
|
|
62
|
+
return `<div data-kit-emphasis="primary" data-kit-role="subject" data-kit-container="plain" data-kit-canvas-hint="surface" data-kit-axis=""${cls(mergeClass(CRUD_CLASS.list, areaClass.list))}>${parts.summary ?? ''}${flatListPanelHtml(parts, areaClass.filter ?? '')}</div>`;
|
|
72
63
|
}
|
|
73
64
|
|
|
74
65
|
export function rootHtml(object: string, children: string[], areaClass: Record<string, string>, extra: string | undefined): string {
|
|
@@ -0,0 +1,40 @@
|
|
|
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' ? [{ value: o.value, label: typeof o.label === 'string' ? o.label : o.value }] : []));
|
|
27
|
+
if (options.length > 0) out.push({ field, options });
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 列表响应总数路径的同级 facets 路径(`a.b.total` → `a.b.facets`)。 */
|
|
33
|
+
export function facetsPathOf(totalPath: string): string {
|
|
34
|
+
return totalPath.includes('.') ? totalPath.replace(/\.[^.]+$/, '.facets') : 'facets';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 概况行的搬运块(标记 + 宿主);调用方保证宿主 id 与 show 条目已登记。 */
|
|
38
|
+
export function listSummaryHoist(hostHtml: string): string {
|
|
39
|
+
return `<div ${KIT_HOIST_ATTR}="${esc(KIT_HOIST_HEADER_SUMMARY)}" class="contents">${hostHtml}</div>`;
|
|
40
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
6
6
|
import { kitShellRecipe } from '../../recipes/container';
|
|
7
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
7
8
|
import { cls, esc, host } from '../link/shared';
|
|
8
9
|
import { kitIconHtml } from '../../base/icons';
|
|
9
10
|
|
|
@@ -13,10 +14,10 @@ export type StepFormArea = (typeof STEP_FORM_AREAS)[number];
|
|
|
13
14
|
|
|
14
15
|
export const STEP_FORM_CLASS = {
|
|
15
16
|
root: '@container flex justify-center',
|
|
16
|
-
card: mergeClass('flex w-full max-w-2xl flex-col gap-
|
|
17
|
-
title: '
|
|
18
|
-
steps: 'flex flex-wrap items-center gap-
|
|
19
|
-
stepItem: 'flex items-center gap-
|
|
17
|
+
card: mergeClass('flex w-full max-w-2xl flex-col gap-stack p-inset-roomy', kitShellRecipe()),
|
|
18
|
+
title: kitTypographyRecipe('sectionTitle'),
|
|
19
|
+
steps: 'flex flex-wrap items-center gap-cluster',
|
|
20
|
+
stepItem: 'flex items-center gap-cluster',
|
|
20
21
|
circle: 'flex h-6 w-6 items-center justify-center rounded-full text-sm font-medium',
|
|
21
22
|
circleAt: 'bg-primary text-primary-fg',
|
|
22
23
|
circlePast: 'bg-success text-success-fg',
|
|
@@ -25,10 +26,10 @@ export const STEP_FORM_CLASS = {
|
|
|
25
26
|
labelPast: 'text-sm text-fg',
|
|
26
27
|
labelFut: 'text-sm text-fg-muted',
|
|
27
28
|
joint: 'w-6 border-t border-border-subtle',
|
|
28
|
-
panel: 'flex flex-col gap-
|
|
29
|
-
panelTitle: '
|
|
30
|
-
done: 'flex flex-col items-start gap-
|
|
31
|
-
doneTitle: '
|
|
29
|
+
panel: 'flex flex-col gap-region',
|
|
30
|
+
panelTitle: kitTypographyRecipe('sectionTitle'),
|
|
31
|
+
done: 'flex flex-col items-start gap-region',
|
|
32
|
+
doneTitle: kitTypographyRecipe('sectionTitle'),
|
|
32
33
|
} as const;
|
|
33
34
|
|
|
34
35
|
export interface StepFormIds {
|
|
@@ -90,7 +91,8 @@ export function stepFormHtml(
|
|
|
90
91
|
const done = `<div data-soma-id="${esc(ids.done)}"><div${cls(mergeClass(C.done, areaClass.done))}>`
|
|
91
92
|
+ `<h3${cls(C.doneTitle)}>${esc(parts.doneTitle)}</h3>${host('Button', ids.restart)}</div></div>`;
|
|
92
93
|
const title = parts.title === '' ? '' : `<h2${cls(C.title)}>${esc(parts.title)}</h2>`;
|
|
93
|
-
|
|
94
|
+
// 唯一主体 = 页面(C2):表单卡是 E1 主体
|
|
95
|
+
const card = `<section data-kit-emphasis="primary" data-kit-role="subject" data-kit-container="card"${cls(mergeClass(C.card, areaClass.card))}>${title}${bar}${panels.join('')}${done}</section>`;
|
|
94
96
|
const root = mergeClass(mergeClass(C.root, areaClass.root), extra);
|
|
95
97
|
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${host('KitStepHub', ids.hub)}\n${card}\n</div>`;
|
|
96
98
|
}
|
package/src/biz/types.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface KitOverlayDecl {
|
|
|
15
15
|
*/
|
|
16
16
|
kind: 'dialog' | 'drawer' | 'expand';
|
|
17
17
|
title?: string;
|
|
18
|
+
/**
|
|
19
|
+
* 宽度档:kind: drawer 取 narrow / default / wide(缺省 default);kind: dialog 取 default / wide / xwide(缺省按内容定档:长表单 / 穿梭框 wide、画布 xwide);
|
|
20
|
+
* 档位与不属于该种类的取值报 KIT-BIZ-003。抽屉只用于只读详情,带提交动作的浮层必须是 dialog(KIT-OVL-001)
|
|
21
|
+
*/
|
|
22
|
+
width?: 'narrow' | 'default' | 'wide' | 'xwide';
|
|
18
23
|
/**
|
|
19
24
|
* 浮层里写死形状数据组件的事件映射(K-1):{ 组件抛出的事件名: 'saved' | 'close' | 'reload' }。
|
|
20
25
|
* 约定名 saved / cancel / close / reload 不用写,编译器自动接线;这里只补自定义事件名。
|
|
@@ -65,7 +70,7 @@ export interface KitBizContext {
|
|
|
65
70
|
/** 已登记的基础组件名(内置 13 个 + App*) */
|
|
66
71
|
registeredComponents: ReadonlySet<string>;
|
|
67
72
|
/** 已登记的写死形状数据组件 */
|
|
68
|
-
staticComponents: Record<string, { accept: 'single' | 'list'; emits?: readonly string[]; props?: readonly string[]; propTypes?: Readonly<Record<string, string
|
|
73
|
+
staticComponents: Record<string, { accept: 'single' | 'list'; emits?: readonly string[]; props?: readonly string[]; propTypes?: Readonly<Record<string, string>>; composition?: 'summary' | 'subject' | 'control' | 'note' }>;
|
|
69
74
|
/** 页面语言(`page.locale`,缺省应用 defaultLocale;未声明为空串):业务组件写进产物的内置文案按它取(`kitText(key, params, ctx.locale)`) */
|
|
70
75
|
locale?: string;
|
|
71
76
|
}
|
package/src/cli/layout-cli.ts
CHANGED
|
@@ -144,16 +144,16 @@ export function formatLayoutPlan(file: string, plan: KitLayoutPlan): string {
|
|
|
144
144
|
if (v === undefined) continue;
|
|
145
145
|
lines.push('', ` ${key} [${v.kind}]`);
|
|
146
146
|
if (v.kind === 'table') {
|
|
147
|
-
lines.push(` 模式 ${v.mode === 'parts' ? 'parts(每列都写了 width
|
|
148
|
-
lines.push(' 列 类 min / ideal / max (rem)
|
|
147
|
+
lines.push(` 模式 ${v.mode === 'parts' ? 'parts(每列都写了 width,按份数权重分余量)' : 'auto(引擎列轨:定宽列不拉伸、主列吸收余量)'};${v.layout === 'fit' ? '参考宽下放得下' : `参考宽下横滚(溢出 ${r1(v.overflowRem)}rem)`};从 ${v.fitFromTier ?? '(最宽档也放不下)'} 档起放得下;Σmin ${r1(v.sumMinRem)}rem`);
|
|
148
|
+
lines.push(' 列 类 min / ideal / max (rem) 主列 宽(rem) 对齐 来源');
|
|
149
149
|
for (const c of v.columns) {
|
|
150
|
-
lines.push(` ${c.field.padEnd(16)} ${c.
|
|
150
|
+
lines.push(` ${c.field.padEnd(16)} ${c.cls.padEnd(7)} ${`${r1(c.minRem)} / ${r1(c.idealRem)} / ${c.maxRem === 0 ? '不限' : r1(c.maxRem)}`.padEnd(26)} ${(c.grow ? '是' : '否').padStart(4)} ${r1(c.widthRem).padStart(6)} ${c.align.padEnd(5)} ${c.source === 'explicit' ? '显式(作者写了)' : '求解'}`);
|
|
151
151
|
}
|
|
152
|
-
lines.push(` 操作列 ${r1(v.actionsRem)}rem:平铺 [${v.actions.inline.join(', ')}],更多 [${v.actions.more.join(', ')}]${v.
|
|
152
|
+
lines.push(` 操作列 ${r1(v.actionsRem)}rem:平铺 [${v.actions.inline.join(', ')}],更多 [${v.actions.more.join(', ')}]${v.selectRem > 0 ? `;选择列 ${r1(v.selectRem)}rem` : ''}`);
|
|
153
153
|
} else if (v.kind === 'filter') {
|
|
154
|
-
lines.push(`
|
|
155
|
-
lines.push(`
|
|
156
|
-
lines.push(`
|
|
154
|
+
lines.push(` 档位 ${v.mode}(${v.count} 个字段:${v.instant ? '即时生效,不出查询 / 重置,有条件时出「清除」' : v.showMore ? `钉住前 ${v.pinnedCount} 个,其余 ${v.moreCount} 个进「更多筛选」` : '常驻字段条 + 查询 / 重置'})`);
|
|
155
|
+
lines.push(` 字段宽(rem,min / ideal / max):${v.widths.map((w) => `${w.cls} ${w.min}/${w.ideal}/${w.max}`).join(';')}`);
|
|
156
|
+
lines.push(` 最后字段与动作区同行起点档:${v.tailTier ?? '更宽的容器'}(需 ${v.tailRem}rem)`);
|
|
157
157
|
} else {
|
|
158
158
|
lines.push(` ${v.cols} 栏(${v.source === 'explicit' ? '显式 cols' : '求解'})`);
|
|
159
159
|
for (const c of v.cells) lines.push(` ${c.field.padEnd(16)} 跨 ${c.span} 宽档 ${c.widthStep.padEnd(4)}${c.fullRow ? ' 整行' : ''}${c.source === 'explicit' ? ' 显式 span' : ''}`);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// 页面里有带读接口(behavior.from)的数据对象时,把页面级 KitAccessGate 补进已装框的片段:
|
|
2
|
+
// 任一读取返回 403 → 整页收成一个「无权访问」状态(组件在运行期按数据对象的读状态判,见 data/access-gate.ts)。
|
|
3
|
+
// 只补一个宿主实例(html + show props:objects);没有读接口的页面不补。纯函数,就地改 framed。
|
|
4
|
+
|
|
5
|
+
import type { KitFragment } from './fragment';
|
|
6
|
+
|
|
7
|
+
/** 宿主组件名与锚点(运行期组件在 data/access-gate.ts) */
|
|
8
|
+
export const KIT_ACCESS_GATE = 'KitAccessGate';
|
|
9
|
+
const GATE_ANCHOR = 'kit-access-gate';
|
|
10
|
+
|
|
11
|
+
const isRec = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
12
|
+
|
|
13
|
+
/** 页面里声明了读接口的数据对象名(写通道合成的只写对象没有 from,不在内) */
|
|
14
|
+
export function readObjectNames(data: Record<string, unknown> | undefined): string[] {
|
|
15
|
+
return Object.entries(data ?? {}).filter(([, decl]) => isRec(decl) && decl.from !== undefined).map(([name]) => name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 就地补进 framed;返回是否补了宿主 */
|
|
19
|
+
export function attachAccessGate(framed: KitFragment): boolean {
|
|
20
|
+
const objects = readObjectNames(framed.ui.data);
|
|
21
|
+
if (objects.length === 0) return false;
|
|
22
|
+
const show = (framed.ui.show ??= {});
|
|
23
|
+
show[GATE_ANCHOR] = { props: { objects } };
|
|
24
|
+
framed.html = `${framed.html}\n<div data-soma-component="${KIT_ACCESS_GATE}" data-soma-id="${GATE_ANCHOR}"></div>`;
|
|
25
|
+
if (!framed.components.includes(KIT_ACCESS_GATE)) framed.components.push(KIT_ACCESS_GATE);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
@@ -18,6 +18,7 @@ import { abortRequestCollect, beginRequestCollect, endRequestCollect } from '../
|
|
|
18
18
|
import { endFilterReloadCollect, eventShapeProblems } from '../object-renderer/filter-reload';
|
|
19
19
|
import { checkGateRefs } from '../object-renderer/action-gate';
|
|
20
20
|
import { attachActionHost } from './action-host-attach';
|
|
21
|
+
import { attachAccessGate } from './access-gate-attach';
|
|
21
22
|
import { applyEnvelopeToData, setCompileEnvelope } from '../shared/envelope';
|
|
22
23
|
import { buildKitObjectNameMap, buildKitObjectNamesElement } from '../biz/shared/object-aliases';
|
|
23
24
|
import { buildKitThemeBootDataElement, toKitRuntimeTheme, type KitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
@@ -34,7 +35,9 @@ import { checkPageStyleCoverage, collectPageCandidates, compileStyles } from './
|
|
|
34
35
|
import type { KitAppTheme } from '../theme/theme-types';
|
|
35
36
|
import { expandKitAppThemePreset } from '../theme/theme-tokens';
|
|
36
37
|
import { annotateSurfaceLayers } from '../theme/surface-layers';
|
|
38
|
+
import { applyCanvasSurface, capActionEmphasis, dropRedundantListTitle, hoistHeaderActions, hoistHeaderSummary, tagAxisHeader } from './page-composition';
|
|
37
39
|
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
40
|
+
import { KIT_VERSION_PREFIX } from './producer-fingerprint';
|
|
38
41
|
import { KIT_WORKSPACE_FRAME_LIMITS } from 'soma-foundation/kit-limits';
|
|
39
42
|
import type {
|
|
40
43
|
KitAppContext,
|
|
@@ -613,6 +616,9 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
613
616
|
if (decl.page.sticky === undefined && appLayout.stickyHeader !== undefined) {
|
|
614
617
|
decl.page.sticky = appLayout.stickyHeader;
|
|
615
618
|
}
|
|
619
|
+
if (decl.frame.bleed === undefined && appLayout.bleed !== undefined) {
|
|
620
|
+
decl.frame.bleed = appLayout.bleed;
|
|
621
|
+
}
|
|
616
622
|
}
|
|
617
623
|
|
|
618
624
|
// 第 3 步:装入页面框
|
|
@@ -624,6 +630,7 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
624
630
|
if (appDensity !== undefined) frameInput.density = appDensity;
|
|
625
631
|
if (decl.frame.class !== undefined) frameInput.class = decl.frame.class;
|
|
626
632
|
if (decl.frame.slotClass !== undefined) frameInput.slotClass = decl.frame.slotClass;
|
|
633
|
+
if (decl.frame.bleed === true) frameInput.bleed = true;
|
|
627
634
|
if (decl.frame.config !== undefined) frameInput.config = decl.frame.config;
|
|
628
635
|
const tabSlot = slotNames.find((s) => Array.isArray(decl.frame.slots[s]));
|
|
629
636
|
if (tabSlot !== undefined) {
|
|
@@ -653,6 +660,8 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
653
660
|
const attached = attachActionHost(framed, requestSpecs, filterWatches);
|
|
654
661
|
if (attached.length > 0) return { diagnostics: attached };
|
|
655
662
|
}
|
|
663
|
+
// 页面级无权访问聚合:带读接口的页面补一个 KitAccessGate 宿主(任一读接口 403 → 整页只剩「无权访问」,见 data/access-gate.ts)
|
|
664
|
+
attachAccessGate(framed);
|
|
656
665
|
// 信封失败判定编进 core 数据声明:写通道与取数来源命中即按失败落账(outcome failed)
|
|
657
666
|
if (framed.ui.data !== undefined) applyEnvelopeToData(framed.ui.data as Record<string, unknown>, dataEnvelope);
|
|
658
667
|
setCompileEnvelope(undefined);
|
|
@@ -697,14 +706,16 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
697
706
|
// 没声明时另标 data-kit-lang-default:运行期 kitLocaleAt 把它当「未声明」,格式化 / 词条解析与改动前完全一致
|
|
698
707
|
const langAttr = pageLocale !== '' ? ` lang="${pageLocale}"` : ` lang="${KIT_UNDECLARED_PAGE_LANG}" ${KIT_LANG_DEFAULT_MARK}=""`;
|
|
699
708
|
const dirAttr = pageDir !== undefined && (pageLocale !== '' || decl.page.dir !== undefined) ? ` dir="${pageDir}"` : '';
|
|
700
|
-
const pageContent = shouldInheritLayout && (appLayout.header !== undefined || appLayout.sidebar !== undefined || appLayout.footer !== undefined)
|
|
709
|
+
const pageContent = tagAxisHeader(hoistHeaderSummary(hoistHeaderActions(dropRedundantListTitle(shouldInheritLayout && (appLayout.header !== undefined || appLayout.sidebar !== undefined || appLayout.footer !== undefined)
|
|
701
710
|
? renderInheritedLayout(framed.html, appLayout)
|
|
702
|
-
: framed.html;
|
|
711
|
+
: framed.html, typeof decl.page.title === 'string' ? decl.page.title : undefined))));
|
|
712
|
+
// 每屏唯一主焦点:按按钮在页面里的位置把超出名额 / 控件区域里的实心主动作降为色调(改 framed.ui.show 里的 variant;运行期不判)
|
|
713
|
+
capActionEmphasis(pageContent, framed.ui.show as Record<string, unknown> | undefined);
|
|
703
714
|
const themeAttrs = is9DimTheme && appTheme
|
|
704
715
|
? ` data-kit-palette="${appTheme.palette ?? KIT_NINE_DIM.palettes.default}" data-kit-boundary="${appTheme.boundary ?? KIT_NINE_DIM.dimensions.boundary.default}" data-kit-shape="${appTheme.shape ?? KIT_NINE_DIM.dimensions.shape.default}" data-kit-texture="${appTheme.surface_texture ?? appTheme.surfaceTexture ?? KIT_NINE_DIM.dimensions.surfaceTexture.default}" data-kit-density="${appTheme.density ?? KIT_NINE_DIM.dimensions.density.default}"${extendedThemeAttrs(appTheme)}`
|
|
705
716
|
: '';
|
|
706
717
|
// 九维主题:编译期按嵌套深度给表面容器写 data-kit-layer(层级不再由运行期 CSS 按标签名 / 类名猜)
|
|
707
|
-
const layeredContent = is9DimTheme ? annotateSurfaceLayers(pageContent) : pageContent;
|
|
718
|
+
const layeredContent = applyCanvasSurface(is9DimTheme ? annotateSurfaceLayers(pageContent) : pageContent);
|
|
708
719
|
// 页面根:有展示对象就是它的类名(html 的 host、_ui 的 bind.obj 与 domain: 同值),否则缺省根
|
|
709
720
|
const rootHost = decl.page.view ?? KIT_ROOT_HOST;
|
|
710
721
|
const appBaseTheme = toKitRuntimeTheme(appTheme);
|
|
@@ -795,7 +806,7 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
795
806
|
uiYaml,
|
|
796
807
|
eventYaml,
|
|
797
808
|
styles: [{ key: `kit-${style.digest}`, css: finalCss }],
|
|
798
|
-
version:
|
|
809
|
+
version: `${KIT_VERSION_PREFIX}${stableHash(html + uiYaml + eventYaml + style.digest)}`,
|
|
799
810
|
};
|
|
800
811
|
// 布局报告(RV-1117 T04 / T05):影子规划 + 体检 advisories + 质量分,只读 decl、不改产物;规则版本 0(缺省)下输出逐字节不变。
|
|
801
812
|
// 旁路:规划 / 体检内部任何异常都吞掉(不让一页编译失败),也不进 diagnostics。
|
|
@@ -66,6 +66,7 @@ import { KIT_NAVBAR_CLASS_CANDIDATES } from '../data/navbar';
|
|
|
66
66
|
import { KIT_WATERMARK_CLASS_CANDIDATES } from '../data/watermark';
|
|
67
67
|
import { KIT_PAGE_BAR_CLASS_CANDIDATES } from '../frames/page-bar';
|
|
68
68
|
import { KIT_PAGE_STATUS_CLASS_CANDIDATES } from '../frames/page-status';
|
|
69
|
+
import { KIT_LIST_SUMMARY_CLASS_CANDIDATES } from '../frames/list-summary';
|
|
69
70
|
import { KIT_NOTIFY_CLASS_CANDIDATES } from '../data/notify-renderer';
|
|
70
71
|
import { KIT_BASE_CLASS_CANDIDATES } from '../base';
|
|
71
72
|
import { KIT_BUSY_SPIN_CLASS_CANDIDATES } from '../base/action-busy';
|
|
@@ -135,6 +136,7 @@ export const KIT_EXTRA_COMPONENT_CANDIDATES: Readonly<Record<string, readonly st
|
|
|
135
136
|
AnchorNav: KIT_ANCHOR_NAV_CLASS_CANDIDATES,
|
|
136
137
|
KitPageBar: KIT_PAGE_BAR_CLASS_CANDIDATES,
|
|
137
138
|
KitPageStatus: KIT_PAGE_STATUS_CLASS_CANDIDATES,
|
|
139
|
+
KitListSummary: KIT_LIST_SUMMARY_CLASS_CANDIDATES,
|
|
138
140
|
});
|
|
139
141
|
|
|
140
142
|
/** 公共底座:每页并入(页面框 / 主题头 / 通知渲染器的类 + 早期基础件共用的写死清单) */
|
package/src/compile/fragment.ts
CHANGED
|
@@ -38,6 +38,16 @@ function uniq(list: string[]): string[] {
|
|
|
38
38
|
return [...new Set(list)];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 元素锚点重复的定位与改法:锚点形如 `<对象>__<槽>__<后缀>`;业务字段 / 对象 / 页签名与内置面板、状态锚点的后缀
|
|
43
|
+
* (state / head / rows / ops / meta / tools / sum / gbar / gwire / filter / pager …)重名会撞同一个锚点(整页 500)。
|
|
44
|
+
*/
|
|
45
|
+
function anchorDuplicateHint(key: string): string {
|
|
46
|
+
const parts = key.split('__');
|
|
47
|
+
const tail = parts.length > 1 ? parts[parts.length - 1]! : key;
|
|
48
|
+
return `锚点 ${key} 被两处生成:把名为「${tail}」的业务字段 / 对象 / 页签 id 改成不与内置锚点后缀(state、head、rows、ops、meta、tools、sum、tree、gbar、gwire、filter、pager 等)重名的名字;对象名不要含双下划线`;
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
/** 合并:ui 各段按键合并、重键报 KIT-PAGE-002;events 重键报 KIT-PAGE-002;数组去重拼接;html 顺序拼接 */
|
|
42
52
|
export function mergeFragments(...parts: KitFragment[]): KitFragment {
|
|
43
53
|
const out = emptyFragment();
|
|
@@ -54,6 +64,7 @@ export function mergeFragments(...parts: KitFragment[]): KitFragment {
|
|
|
54
64
|
code: 'KIT-PAGE-002',
|
|
55
65
|
message: `ui.${sec} 键重复:${k}`,
|
|
56
66
|
path: `ui.${sec}.${k}`,
|
|
67
|
+
hint: anchorDuplicateHint(k),
|
|
57
68
|
});
|
|
58
69
|
continue;
|
|
59
70
|
}
|