soma-kit 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +11 -9
- package/spec/generated/kit-page.schema.json +3 -0
- package/spec/kit-grammar.json +4652 -563
- package/src/app/app-config.ts +10 -3
- package/src/app/index.ts +3 -0
- package/src/base/text.ts +2 -0
- package/src/biz/approval-desk/shell.ts +5 -5
- package/src/biz/auth-panel/shell.ts +1 -1
- package/src/biz/category-crud/compile.ts +5 -2
- package/src/biz/category-crud/shell.ts +1 -1
- package/src/biz/checkout-page/shell.ts +3 -3
- package/src/biz/import-wizard/shell.ts +1 -1
- package/src/biz/master-sub/compile.ts +5 -2
- package/src/biz/master-sub/shell.ts +5 -5
- package/src/biz/multi-board/shell.ts +2 -2
- package/src/biz/notification-center/shell.ts +3 -3
- package/src/biz/page-templates/result-page/shell.ts +1 -1
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +5 -5
- package/src/biz/settings-center/compile.ts +3 -1
- package/src/biz/settings-center/shell.ts +4 -4
- package/src/biz/single-form/shell.ts +1 -1
- package/src/biz/standard-crud/compile.ts +10 -2
- package/src/biz/standard-crud/shell.ts +20 -9
- package/src/biz/step-form/shell.ts +1 -1
- package/src/compile/compile-page.ts +1 -0
- package/src/data/object-form.ts +1 -1
- package/src/frames/blank-frame.ts +1 -1
- package/src/frames/shared.ts +19 -11
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/view.ts +42 -21
- package/src/generated/kit-grammar-runtime.ts +16 -13
- package/src/index.ts +4 -0
- package/src/object-renderer/arrange.ts +3 -3
- package/src/object-renderer/collection.ts +29 -8
- package/src/object-renderer/emit-static.ts +14 -1
- package/src/object-renderer/types.ts +4 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +3 -0
- package/src/theme/kit-theme.tpl +3 -0
- package/src/theme/theme-tokens.ts +6 -0
- package/src/theme/typography.ts +44 -0
package/src/app/app-config.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface KitAppTheme {
|
|
|
9
9
|
fontScheme?: string;
|
|
10
10
|
color?: string;
|
|
11
11
|
mode?: string;
|
|
12
|
+
/** 界面规格密度档:compact(默认,中后台紧凑标准)| standard(宽松均衡档) */
|
|
13
|
+
density?: 'compact' | 'standard';
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export interface KitAppConfig {
|
|
@@ -26,7 +28,8 @@ export interface KitAppConfig {
|
|
|
26
28
|
|
|
27
29
|
const APP_NAME = /^App[A-Z][A-Za-z0-9]*$/;
|
|
28
30
|
const TOP_KEYS = ['style', 'theme', 'baseComponents', 'staticObjectComponents', 'envelope'];
|
|
29
|
-
const THEME_KEYS = ['palette_scheme', 'font_scheme', 'color', 'mode'];
|
|
31
|
+
const THEME_KEYS = ['palette_scheme', 'font_scheme', 'color', 'mode', 'density'];
|
|
32
|
+
const DENSITY_VALUES = ['compact', 'standard'] as const;
|
|
30
33
|
const STATIC_KEYS = ['accept', 'desc'];
|
|
31
34
|
|
|
32
35
|
function isRecord(v: unknown): v is Record<string, unknown> {
|
|
@@ -57,7 +60,7 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
57
60
|
if (envelope !== undefined) cfg.envelope = envelope;
|
|
58
61
|
}
|
|
59
62
|
if (raw.theme !== undefined) {
|
|
60
|
-
if (!isRecord(raw.theme)) bad('kit.app.yaml.theme', 'theme 必须是 { palette_scheme?, font_scheme?, color?, mode? }', diagnostics);
|
|
63
|
+
if (!isRecord(raw.theme)) bad('kit.app.yaml.theme', 'theme 必须是 { palette_scheme?, font_scheme?, color?, mode?, density? }', diagnostics);
|
|
61
64
|
else {
|
|
62
65
|
const theme: KitAppTheme = {};
|
|
63
66
|
for (const [k, v] of Object.entries(raw.theme)) {
|
|
@@ -66,7 +69,11 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
66
69
|
else if (k === 'palette_scheme') theme.paletteScheme = v.trim();
|
|
67
70
|
else if (k === 'font_scheme') theme.fontScheme = v.trim();
|
|
68
71
|
else if (k === 'color') theme.color = v.trim();
|
|
69
|
-
else
|
|
72
|
+
else if (k === 'density') {
|
|
73
|
+
const dv = v.trim();
|
|
74
|
+
if (!(DENSITY_VALUES as readonly string[]).includes(dv)) bad('kit.app.yaml.theme.density', `density「${dv}」只能是 ${DENSITY_VALUES.join(' / ')}`, diagnostics);
|
|
75
|
+
else theme.density = dv as 'compact' | 'standard';
|
|
76
|
+
} else theme.mode = v.trim();
|
|
70
77
|
}
|
|
71
78
|
cfg.theme = theme;
|
|
72
79
|
}
|
package/src/app/index.ts
CHANGED
|
@@ -43,6 +43,9 @@ export { wrapKitDataComponent, composeKitDataComponents, mapKeys } from '../data
|
|
|
43
43
|
export type { PackProps, WrapDataOptions, WrapOptions, ComposeDataPart, ComposeDataOptions, ComposeEventForward } from '../data/wrap';
|
|
44
44
|
export { mountKitComponent, mountKitSelectField, createKitEmbedBag } from '../data/embed';
|
|
45
45
|
export { declareKitUses } from '../data/wrapped-candidates';
|
|
46
|
+
export { classCandidates } from '../base/shared';
|
|
47
|
+
export { KIT_TYPOGRAPHY, KIT_TYPOGRAPHY_CLASS_CANDIDATES } from '../theme/typography';
|
|
48
|
+
export type { KitTypographyRole } from '../theme/typography';
|
|
46
49
|
export type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole, KitOverlayDecl } from '../biz/types';
|
|
47
50
|
export type { KitFrameDefinition, KitFrameInput, KitPageMeta } from '../frames/types';
|
|
48
51
|
export { emptyFragment, mergeFragments, fragmentFromEmit } from '../compile/fragment';
|
package/src/base/text.ts
CHANGED
|
@@ -108,6 +108,8 @@ export function createText(): SomaComponentDefinition {
|
|
|
108
108
|
const raw = p.value;
|
|
109
109
|
const empty = raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0);
|
|
110
110
|
root.textContent = text;
|
|
111
|
+
if (!empty && text !== "") root.title = text;
|
|
112
|
+
else root.removeAttribute("title");
|
|
111
113
|
if (bool(p.copyable) && !empty) {
|
|
112
114
|
const s = stateOf(root);
|
|
113
115
|
const btn = document.createElement('button');
|
|
@@ -11,10 +11,10 @@ export type ApprovalDeskArea = (typeof APPROVAL_DESK_AREAS)[number];
|
|
|
11
11
|
export const APPROVAL_DESK_CLASS = {
|
|
12
12
|
root: '@container flex flex-col gap-4',
|
|
13
13
|
grid: 'grid grid-cols-12 gap-4',
|
|
14
|
-
queue: 'col-span-12 @md:col-span-3 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
15
|
-
request: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
16
|
-
history: 'col-span-12 @md:col-span-4 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
17
|
-
title: 'text-base font-semibold text-fg',
|
|
14
|
+
queue: 'col-span-12 @md:col-span-3 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
15
|
+
request: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
16
|
+
history: 'col-span-12 @md:col-span-4 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
17
|
+
title: 'min-w-0 truncate text-base font-semibold text-fg',
|
|
18
18
|
} as const;
|
|
19
19
|
|
|
20
20
|
export function approvalDeskIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
@@ -40,7 +40,7 @@ export function approvalDeskHtml(
|
|
|
40
40
|
};
|
|
41
41
|
// 没有历史栏时,审批单栏吃掉右侧 4 份
|
|
42
42
|
const requestBase = parts.history === null
|
|
43
|
-
? 'col-span-12 @md:col-span-9 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
43
|
+
? 'col-span-12 @md:col-span-9 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs'
|
|
44
44
|
: undefined;
|
|
45
45
|
const cols = [col('queue', parts.queue), col('request', parts.request, requestBase)];
|
|
46
46
|
if (parts.history !== null) cols.push(col('history', parts.history));
|
|
@@ -8,7 +8,7 @@ import { cls, esc, host } from '../link/shared';
|
|
|
8
8
|
export const AUTH_PANEL_AREAS = ['root', 'user', 'roles', 'matrix'] as const;
|
|
9
9
|
export type AuthPanelArea = (typeof AUTH_PANEL_AREAS)[number];
|
|
10
10
|
|
|
11
|
-
const CARD = 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
11
|
+
const CARD = 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs';
|
|
12
12
|
|
|
13
13
|
export const AUTH_PANEL_CLASS = {
|
|
14
14
|
root: '@container flex flex-col gap-4',
|
|
@@ -140,8 +140,11 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
140
140
|
let dialog = '';
|
|
141
141
|
if (item.view?.form !== undefined) {
|
|
142
142
|
const formId = viewAnchor(itemName, 'form');
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const formHtml = it.r.parts.form ?? '';
|
|
144
|
+
if (formHtml.includes(`data-soma-id="${formId}"`)) {
|
|
145
|
+
patchProps(out.show, formId, { scope: `${itemName}__form`, cancelLabel: CANCEL_LABEL });
|
|
146
|
+
wireDialogForm(out.events, formId, link);
|
|
147
|
+
}
|
|
145
148
|
const d = dialogIds(itemName);
|
|
146
149
|
out.show[d.dialogLayer] = { when: mirrorPath(link, mk.openForm.key) };
|
|
147
150
|
out.show[d.dialogTitleCreate] = { when: mirrorPath(link, mk.creating.key) };
|
|
@@ -8,7 +8,7 @@ export const CATEGORY_CRUD_AREAS = ['root', 'categorySidebar', 'itemWorkspace',
|
|
|
8
8
|
|
|
9
9
|
export const CATEGORY_CRUD_CLASS = {
|
|
10
10
|
root: '@container flex flex-col gap-4 @md:flex-row',
|
|
11
|
-
categorySidebar: 'w-full shrink-0 @md:w-56 rounded-lg border border-border-
|
|
11
|
+
categorySidebar: 'w-full shrink-0 @md:w-56 rounded-lg border border-border-strong bg-surface-raised p-3 shadow-xs flex flex-col gap-2',
|
|
12
12
|
itemWorkspace: 'flex min-w-0 flex-1 flex-col gap-4',
|
|
13
13
|
} as const;
|
|
14
14
|
|
|
@@ -10,10 +10,10 @@ export type CheckoutPageArea = (typeof CHECKOUT_PAGE_AREAS)[number];
|
|
|
10
10
|
|
|
11
11
|
export const CHECKOUT_PAGE_CLASS = {
|
|
12
12
|
root: '@container grid grid-cols-12 gap-4',
|
|
13
|
-
form: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-4 rounded-lg border border-border-
|
|
13
|
+
form: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-4 rounded-lg border border-border-strong bg-surface-raised p-6 shadow-xs',
|
|
14
14
|
summary: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-4',
|
|
15
|
-
items: 'flex flex-col gap-3 rounded-lg border border-border-
|
|
16
|
-
amounts: 'flex flex-col gap-3 rounded-lg border border-border-
|
|
15
|
+
items: 'flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
16
|
+
amounts: 'flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-sunken p-4',
|
|
17
17
|
title: 'text-base font-semibold text-fg',
|
|
18
18
|
/** 表单底部提交栏(表单 actions 区) */
|
|
19
19
|
footer: 'mt-2 flex flex-wrap items-end gap-2 border-t border-border-subtle pt-4',
|
|
@@ -18,7 +18,7 @@ export const IMPORT_WIZARD_STEP_TITLES = [
|
|
|
18
18
|
|
|
19
19
|
export const IMPORT_WIZARD_CLASS = {
|
|
20
20
|
root: '@container flex justify-center',
|
|
21
|
-
card: 'flex w-full max-w-3xl flex-col gap-6 rounded-lg border border-border-
|
|
21
|
+
card: 'flex w-full max-w-3xl flex-col gap-6 rounded-lg border border-border-strong bg-surface-raised p-6 shadow-xs',
|
|
22
22
|
title: 'text-lg font-semibold text-fg',
|
|
23
23
|
steps: 'flex flex-wrap items-center gap-2',
|
|
24
24
|
stepItem: 'flex items-center gap-2',
|
|
@@ -196,8 +196,11 @@ export function compileMasterSub(input: KitBizInput, ctx: KitBizContext): KitFra
|
|
|
196
196
|
let dialog = '';
|
|
197
197
|
if (master.view?.form !== undefined) {
|
|
198
198
|
const formId = viewAnchor(masterName, 'form');
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
const formHtml = m.r.parts.form ?? '';
|
|
200
|
+
if (formHtml.includes(`data-soma-id="${formId}"`)) {
|
|
201
|
+
patchProps(out.show, formId, { scope: `${masterName}__form`, cancelLabel: CANCEL_LABEL });
|
|
202
|
+
wireDialogForm(out.events, formId, link);
|
|
203
|
+
}
|
|
201
204
|
const d = dialogIds(masterName);
|
|
202
205
|
out.show[d.dialogLayer] = { when: mirrorPath(link, mk.openForm.key) };
|
|
203
206
|
out.show[d.dialogTitleCreate] = { when: mirrorPath(link, mk.creating.key) };
|
|
@@ -12,15 +12,15 @@ export type MasterSubArea = (typeof MASTER_SUB_AREAS)[number];
|
|
|
12
12
|
export const MASTER_SUB_CLASS = {
|
|
13
13
|
root: '@container flex flex-col gap-4',
|
|
14
14
|
grid: 'grid grid-cols-12 gap-4',
|
|
15
|
-
masterList: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-4 rounded-lg border border-border-
|
|
15
|
+
masterList: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-4 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
16
16
|
masterSummary: 'flex min-w-0 flex-col gap-3',
|
|
17
17
|
subWorkspace: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-4',
|
|
18
|
-
subBlock: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
19
|
-
subTitle: 'text-base font-semibold text-fg',
|
|
18
|
+
subBlock: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
19
|
+
subTitle: 'min-w-0 truncate text-base font-semibold text-fg',
|
|
20
20
|
/** 有辅助栏(aside)时的三栏:4 / 5 / 3 */
|
|
21
|
-
masterListWithAside: 'col-span-12 @md:col-span-4 flex min-w-0 flex-col gap-4 rounded-lg border border-border-
|
|
21
|
+
masterListWithAside: 'col-span-12 @md:col-span-4 flex min-w-0 flex-col gap-4 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
22
22
|
subWorkspaceWithAside: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-4',
|
|
23
|
-
aside: 'col-span-12 @md:col-span-3 flex min-w-0 flex-col gap-4 rounded-lg border border-border-
|
|
23
|
+
aside: 'col-span-12 @md:col-span-3 flex min-w-0 flex-col gap-4 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
24
24
|
} as const;
|
|
25
25
|
|
|
26
26
|
export function masterSubIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
@@ -10,9 +10,9 @@ export type MultiBoardArea = (typeof MULTI_BOARD_AREAS)[number];
|
|
|
10
10
|
|
|
11
11
|
export const MULTI_BOARD_CLASS = {
|
|
12
12
|
root: '@container flex flex-col gap-4',
|
|
13
|
-
filter: 'rounded-lg border border-border-
|
|
13
|
+
filter: 'rounded-lg border border-border-strong bg-surface-raised p-4',
|
|
14
14
|
panels: 'grid grid-cols-12 gap-4',
|
|
15
|
-
panel: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
15
|
+
panel: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4',
|
|
16
16
|
panelTitle: 'text-base font-semibold text-fg',
|
|
17
17
|
} as const;
|
|
18
18
|
|
|
@@ -11,9 +11,9 @@ export type NotificationCenterArea = (typeof NOTIFICATION_CENTER_AREAS)[number];
|
|
|
11
11
|
export const NOTIFICATION_CENTER_CLASS = {
|
|
12
12
|
root: '@container flex flex-col gap-4',
|
|
13
13
|
grid: 'grid grid-cols-12 gap-4',
|
|
14
|
-
list: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
15
|
-
detail: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
16
|
-
title: 'text-base font-semibold text-fg',
|
|
14
|
+
list: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
15
|
+
detail: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
16
|
+
title: 'min-w-0 truncate text-base font-semibold text-fg',
|
|
17
17
|
} as const;
|
|
18
18
|
|
|
19
19
|
export function notificationCenterIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
@@ -10,7 +10,7 @@ export type ResultPageArea = (typeof RESULT_PAGE_AREAS)[number];
|
|
|
10
10
|
|
|
11
11
|
export const RESULT_PAGE_CLASS = {
|
|
12
12
|
root: '@container flex w-full min-h-screen items-center justify-center p-6',
|
|
13
|
-
card: 'flex w-full max-w-xl flex-col rounded-lg border border-border-
|
|
13
|
+
card: 'flex w-full max-w-xl flex-col rounded-lg border border-border-strong bg-surface-raised shadow-xs',
|
|
14
14
|
detail: 'border-t border-border-subtle p-6',
|
|
15
15
|
} as const;
|
|
16
16
|
|
|
@@ -266,8 +266,11 @@ export function compileRecordDetail(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
266
266
|
let dialog = '';
|
|
267
267
|
if (hasWrite && record.view?.form !== undefined) {
|
|
268
268
|
const formId = viewAnchor(recName, 'form');
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
const formHtml = m.r.parts.form ?? '';
|
|
270
|
+
if (formHtml.includes(`data-soma-id="${formId}"`)) {
|
|
271
|
+
patchProps(out.show, formId, { scope: `${recName}__form`, cancelLabel: CANCEL_LABEL });
|
|
272
|
+
wireDialogForm(out.events, formId, link);
|
|
273
|
+
}
|
|
271
274
|
const d = dialogIds(recName);
|
|
272
275
|
out.show[d.dialogLayer] = { when: mirrorPath(link, mk.openForm.key) };
|
|
273
276
|
out.show[d.dialogTitleCreate] = { when: mirrorPath(link, mk.creating.key) };
|
|
@@ -11,13 +11,13 @@ export type RecordDetailArea = (typeof RECORD_DETAIL_AREAS)[number];
|
|
|
11
11
|
|
|
12
12
|
export const RECORD_DETAIL_CLASS = {
|
|
13
13
|
root: '@container flex flex-col gap-4',
|
|
14
|
-
header: 'flex flex-wrap items-start justify-between gap-4 rounded-lg border border-border-
|
|
14
|
+
header: 'flex flex-wrap items-start justify-between gap-4 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
15
15
|
summary: 'min-w-0 flex-1',
|
|
16
|
-
actions: 'flex flex-wrap items-center gap-2',
|
|
16
|
+
actions: 'flex shrink-0 flex-wrap items-center gap-2',
|
|
17
17
|
groups: 'grid grid-cols-12 gap-4',
|
|
18
|
-
group: 'col-span-12 @md:col-span-6 flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
19
|
-
sub: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-
|
|
20
|
-
blockTitle: 'text-base font-semibold text-fg',
|
|
18
|
+
group: 'col-span-12 @md:col-span-6 flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
19
|
+
sub: 'flex min-w-0 flex-col gap-3 rounded-lg border border-border-strong bg-surface-raised p-4 shadow-xs',
|
|
20
|
+
blockTitle: 'min-w-0 truncate text-base font-semibold text-fg',
|
|
21
21
|
} as const;
|
|
22
22
|
|
|
23
23
|
export function recordDetailIds(pageId: string): {
|
|
@@ -84,7 +84,9 @@ export function compileSettingsCenter(input: KitBizInput, ctx: KitBizContext): K
|
|
|
84
84
|
resetLabel: RESET_LABEL,
|
|
85
85
|
classes: { ...classes, actions: SETTINGS_CENTER_CLASS.footer },
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
if ((r.parts.form ?? "").includes(`data-soma-id="${formId}"`)) {
|
|
88
|
+
out.events[`${formId}.saved`] = { steps: [{ do: `NOTIFY | success | ${SAVED_NOTICE}` }] };
|
|
89
|
+
}
|
|
88
90
|
|
|
89
91
|
const formTitle = formView.title;
|
|
90
92
|
const title = typeof raw.title === 'string' && raw.title !== ''
|
|
@@ -11,11 +11,11 @@ export type SettingsCenterArea = (typeof SETTINGS_CENTER_AREAS)[number];
|
|
|
11
11
|
|
|
12
12
|
export const SETTINGS_CENTER_CLASS = {
|
|
13
13
|
root: '@container flex flex-col gap-6 @md:flex-row @md:items-start',
|
|
14
|
-
nav: 'flex w-full shrink-0 flex-col gap-1 rounded-lg border border-border-
|
|
15
|
-
navLink: 'flex h-9 items-center rounded-md px-3 text-sm text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring',
|
|
14
|
+
nav: 'flex w-full shrink-0 flex-col gap-1 rounded-lg border border-border-strong bg-surface-raised p-2 shadow-xs @md:sticky @md:top-4 @md:w-56',
|
|
15
|
+
navLink: 'flex h-9 min-w-0 items-center truncate rounded-md px-3 text-sm text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring',
|
|
16
16
|
content: 'flex min-w-0 flex-1 flex-col gap-6',
|
|
17
|
-
section: 'flex flex-col gap-4 rounded-lg border border-border-
|
|
18
|
-
title: 'text-lg font-semibold text-fg',
|
|
17
|
+
section: 'flex flex-col gap-4 rounded-lg border border-border-strong bg-surface-raised p-6 shadow-xs',
|
|
18
|
+
title: 'min-w-0 truncate text-lg font-semibold text-fg',
|
|
19
19
|
/** 分区保存栏:贴卡内底部,上方分隔线 */
|
|
20
20
|
footer: 'mt-2 flex flex-wrap items-end gap-2 border-t border-border-subtle pt-4',
|
|
21
21
|
} as const;
|
|
@@ -10,7 +10,7 @@ export type SingleFormArea = (typeof SINGLE_FORM_AREAS)[number];
|
|
|
10
10
|
|
|
11
11
|
export const SINGLE_FORM_CLASS = {
|
|
12
12
|
root: '@container flex justify-center',
|
|
13
|
-
card: 'flex w-full max-w-2xl flex-col rounded-lg border border-border-
|
|
13
|
+
card: 'flex w-full max-w-2xl flex-col rounded-lg border border-border-strong bg-surface-raised',
|
|
14
14
|
header: 'border-b border-border-subtle px-6 py-4',
|
|
15
15
|
title: 'text-lg font-semibold text-fg',
|
|
16
16
|
body: 'p-6',
|
|
@@ -61,7 +61,9 @@ function mirrorPath(scope: string, key: string): string {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function keyFieldOf(obj: KitObject): string | undefined {
|
|
64
|
-
|
|
64
|
+
const hit = Object.entries(obj.schema).find(([, f]) => f.key === true)?.[0];
|
|
65
|
+
if (hit !== undefined) return hit;
|
|
66
|
+
return 'id' in obj.schema ? 'id' : undefined;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
// ---------------------------------------------------------------- 动作
|
|
@@ -403,9 +405,15 @@ export function compileStandardCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
403
405
|
const linkKey = decl.behavior?.linkKey ?? keyField;
|
|
404
406
|
const params: Record<string, string> = { ...(decl.behavior?.params ?? {}) };
|
|
405
407
|
if (linkKey !== undefined && keyField !== undefined) params[linkKey] = `$${mirrorPath(scope, KIT_CRUD_LINK_KEY)}`;
|
|
408
|
+
const dynParams = Object.entries(params).filter(([, v]) => typeof v === 'string' && v.startsWith('$')).map(([k]) => k);
|
|
409
|
+
const reqParams = [...new Set([...(decl.behavior?.requireParams ?? []), ...(linkKey !== undefined && keyField !== undefined ? [linkKey] : []), ...dynParams])];
|
|
406
410
|
const ovObj: KitObject = {
|
|
407
411
|
schema: decl.schema ?? {},
|
|
408
|
-
behavior: {
|
|
412
|
+
behavior: {
|
|
413
|
+
...(decl.behavior ?? {}),
|
|
414
|
+
params,
|
|
415
|
+
...(reqParams.length > 0 ? { requireParams: reqParams } : {}),
|
|
416
|
+
},
|
|
409
417
|
view,
|
|
410
418
|
};
|
|
411
419
|
// K-9:浮层没有自己的读接口(无 behavior.from)时,当前行(协调组件 focus.row 的镜像)就是它的数据:
|
|
@@ -10,20 +10,21 @@ export const STANDARD_CRUD_AREAS = ['root', 'filter', 'list', 'dialog', 'drawer'
|
|
|
10
10
|
export type StandardCrudArea = (typeof STANDARD_CRUD_AREAS)[number];
|
|
11
11
|
|
|
12
12
|
export const CRUD_CLASS = {
|
|
13
|
-
root: 'flex flex-col gap-
|
|
14
|
-
filter: 'bg-surface
|
|
15
|
-
list: 'bg-surface
|
|
13
|
+
root: 'flex flex-col gap-3',
|
|
14
|
+
filter: 'bg-surface rounded-lg border border-border-strong p-4',
|
|
15
|
+
list: 'bg-surface rounded-lg border border-border-strong p-4 flex flex-col gap-3',
|
|
16
|
+
listHeadRow: 'flex flex-wrap items-center justify-between gap-2',
|
|
16
17
|
// 浮层
|
|
17
18
|
// 最外层只放 core 写的 hidden 属性,不带任何类(core 样式引擎没有 preflight,hidden 与 flex 同元素会失效);fixed / flex 在内层
|
|
18
19
|
dialogRow: 'fixed inset-0 z-50 flex items-center justify-center bg-fg/50 p-4',
|
|
19
|
-
dialog: 'flex max-h-full w-full max-w-lg flex-col overflow-y-auto rounded-lg border border-border-
|
|
20
|
+
dialog: 'flex max-h-full w-full max-w-lg flex-col overflow-y-auto rounded-lg border border-border-strong bg-surface-raised shadow-xl',
|
|
20
21
|
drawerRow: 'fixed inset-0 z-50 flex justify-end bg-fg/50',
|
|
21
|
-
drawer: 'flex h-full w-96 flex-col overflow-y-auto border-s border-border-
|
|
22
|
-
header: 'flex items-center justify-between gap-4 border-b border-border-subtle px-
|
|
23
|
-
title: 'text-
|
|
22
|
+
drawer: 'flex h-full w-96 flex-col overflow-y-auto border-s border-border-strong bg-surface-raised shadow-xl',
|
|
23
|
+
header: 'flex items-center justify-between gap-4 border-b border-border-subtle px-5 py-3',
|
|
24
|
+
title: 'text-base font-semibold text-fg',
|
|
24
25
|
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-surface-sunken hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
25
26
|
headerActions: 'flex items-center gap-2',
|
|
26
|
-
body: 'flex-1 p-
|
|
27
|
+
body: 'flex-1 p-5',
|
|
27
28
|
} as const;
|
|
28
29
|
|
|
29
30
|
/** 弹窗关闭钮(SVG 图标钮,类串与 data/modal-dialog 的关闭钮同一套):五处弹窗外壳共用 */
|
|
@@ -90,10 +91,20 @@ export function coordinatorId(object: string): string {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
/** 主区:筛选卡 + 列表卡(工具栏在列表卡里,排在列表之前)。区域类按 7.3 同族规则覆写。 */
|
|
94
|
+
const LIST_TITLE_RE = /^(<h3\b[^>]*__list__title"[^>]*>[\s\S]*?<\/h3>)([\s\S]*)$/;
|
|
95
|
+
|
|
93
96
|
export function mainHtml(parts: { filter: string; toolbar: string; list: string }, areaClass: Record<string, string>): string {
|
|
94
97
|
const blocks: string[] = [];
|
|
95
98
|
if (parts.filter !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.filter, areaClass.filter))}>${parts.filter}</section>`);
|
|
96
|
-
|
|
99
|
+
let listInner = '';
|
|
100
|
+
const m = parts.toolbar !== '' ? LIST_TITLE_RE.exec(parts.list) : null;
|
|
101
|
+
if (m !== null) {
|
|
102
|
+
const titleH3 = m[1]!.replace(/\bmb-\d+(?:\.\d+)?\s*/g, '');
|
|
103
|
+
const restList = m[2]!;
|
|
104
|
+
listInner = [`<div${cls(CRUD_CLASS.listHeadRow)}>${titleH3}${parts.toolbar}</div>`, restList].filter((p) => p !== '').join('\n');
|
|
105
|
+
} else {
|
|
106
|
+
listInner = [parts.toolbar, parts.list].filter((p) => p !== '').join('\n');
|
|
107
|
+
}
|
|
97
108
|
if (listInner !== '') blocks.push(`<section${cls(mergeClass(CRUD_CLASS.list, areaClass.list))}>${listInner}</section>`);
|
|
98
109
|
return blocks.join('\n');
|
|
99
110
|
}
|
|
@@ -13,7 +13,7 @@ export type StepFormArea = (typeof STEP_FORM_AREAS)[number];
|
|
|
13
13
|
|
|
14
14
|
export const STEP_FORM_CLASS = {
|
|
15
15
|
root: '@container flex justify-center',
|
|
16
|
-
card: 'flex w-full max-w-2xl flex-col gap-6 rounded-lg border border-border-
|
|
16
|
+
card: 'flex w-full max-w-2xl flex-col gap-6 rounded-lg border border-border-strong bg-surface-raised p-6 shadow-xs',
|
|
17
17
|
title: 'text-lg font-semibold text-fg',
|
|
18
18
|
steps: 'flex flex-wrap items-center gap-2',
|
|
19
19
|
stepItem: 'flex items-center gap-2',
|
|
@@ -318,6 +318,7 @@ async function compileKitPageCore(page: unknown, app: KitAppContext): Promise<Ki
|
|
|
318
318
|
const frameInput: KitFrameInput = { page: decl.page, slots: slotFragments };
|
|
319
319
|
frameInput.registeredActions = app.registeredActions;
|
|
320
320
|
frameInput.locale = pageLocale;
|
|
321
|
+
if (app.themeConfig?.density !== undefined) frameInput.density = app.themeConfig.density;
|
|
321
322
|
if (decl.frame.class !== undefined) frameInput.class = decl.frame.class;
|
|
322
323
|
if (decl.frame.slotClass !== undefined) frameInput.slotClass = decl.frame.slotClass;
|
|
323
324
|
if (decl.frame.config !== undefined) frameInput.config = decl.frame.config;
|
package/src/data/object-form.ts
CHANGED
|
@@ -1019,7 +1019,7 @@ function createController(
|
|
|
1019
1019
|
const shownByCond = (c: KitCell, vals: Rec): boolean => sceneOk(c) && (c.showWhen === undefined || holds(c.showWhen, vals));
|
|
1020
1020
|
/** 必填星号位置:静态必填取编译期结果,条件必填(requiredWhen)按草稿求值;'' = 不标 */
|
|
1021
1021
|
const starOf = (c: KitCell, vals: Rec): 'start' | 'end' | '' => {
|
|
1022
|
-
if (c.placeholder === true || c.label === '') return '';
|
|
1022
|
+
if (mode() === 'filter' || c.placeholder === true || c.label === '') return '';
|
|
1023
1023
|
if (c.required !== undefined) return c.required;
|
|
1024
1024
|
if (c.requiredWhen === undefined || !holds(c.requiredWhen, vals)) return '';
|
|
1025
1025
|
return P().requiredMark === 'start' ? 'start' : 'end';
|
|
@@ -5,7 +5,7 @@ import type { KitFrameDefinition } from './types';
|
|
|
5
5
|
import { checkFrameClasses, checkNoHeaderExtras, checkSlots, classAttr, finishFrame, rootClass, slotFragment, slotWrapper } from './shared';
|
|
6
6
|
|
|
7
7
|
/** 画布无内边距(N-2):只有底色与满屏高度;要内边距由 frame.class 自加 */
|
|
8
|
-
const BLANK_CANVAS_CLASS = 'bg-surface-sunken min-h-screen';
|
|
8
|
+
const BLANK_CANVAS_CLASS = 'bg-surface-sunken min-h-screen text-sm text-fg';
|
|
9
9
|
|
|
10
10
|
export const blankFrame: KitFrameDefinition = {
|
|
11
11
|
kind: 'blank-frame',
|
package/src/frames/shared.ts
CHANGED
|
@@ -14,9 +14,11 @@ export function esc(text: string): string {
|
|
|
14
14
|
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/** 第 1
|
|
18
|
-
export const CANVAS_CLASS = 'bg-surface-sunken p-
|
|
19
|
-
const
|
|
17
|
+
/** 第 1 层:页面框画布(默认中后台紧凑标准 p-4 + 14px 基准字号;theme.density: standard 切 p-6) */
|
|
18
|
+
export const CANVAS_CLASS = 'bg-surface-sunken p-4 min-h-screen text-sm text-fg';
|
|
19
|
+
export const CANVAS_STANDARD_CLASS = 'bg-surface-sunken p-6 min-h-screen text-sm text-fg';
|
|
20
|
+
const TITLE_CLASS = 'text-base font-semibold text-fg';
|
|
21
|
+
const TITLE_STANDARD_CLASS = 'text-xl font-semibold text-fg';
|
|
20
22
|
const EYEBROW_CLASS = 'mb-1 text-xs font-medium text-primary';
|
|
21
23
|
const SUBTITLE_CLASS = 'mt-1 text-sm text-fg-muted';
|
|
22
24
|
|
|
@@ -25,8 +27,10 @@ export function classAttr(value: string): string {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
// 页头扩展(F1):页头成为容器查询的容器(动作区随它折叠);吸顶时盖住滚上来的内容
|
|
28
|
-
const HEADER_BAR_CLASS = 'mb-
|
|
29
|
-
const
|
|
30
|
+
const HEADER_BAR_CLASS = 'mb-3 @container';
|
|
31
|
+
const HEADER_BAR_STANDARD_CLASS = 'mb-5 @container';
|
|
32
|
+
const HEADER_STICKY_CLASS = 'sticky top-0 z-10 mb-3 bg-surface-sunken pb-2 @container';
|
|
33
|
+
const HEADER_STICKY_STANDARD_CLASS = 'sticky top-0 z-10 mb-5 bg-surface-sunken pb-3 @container';
|
|
30
34
|
const TITLE_ROW_CLASS = 'flex flex-wrap items-center gap-2';
|
|
31
35
|
const TOP_ROW_CLASS = 'flex flex-wrap items-start justify-between gap-3';
|
|
32
36
|
const BACK_WRAP_CLASS = 'mb-2';
|
|
@@ -41,7 +45,7 @@ const WIDTH_WRAP_CLASS = 'mx-auto w-full';
|
|
|
41
45
|
|
|
42
46
|
/** 页头用到的全部固定类(含页头部件 KitPageBar 自带类),并入候选 */
|
|
43
47
|
const HEADER_EXTRA_CANDIDATES: readonly string[] = [
|
|
44
|
-
...new Set([HEADER_BAR_CLASS, HEADER_STICKY_CLASS, TITLE_ROW_CLASS, TOP_ROW_CLASS, BACK_WRAP_CLASS, ...Object.values(STATUS_CLASS), ...KIT_PAGE_BAR_CLASS_CANDIDATES, ...KIT_PAGE_STATUS_CLASS_CANDIDATES]
|
|
48
|
+
...new Set([HEADER_BAR_CLASS, HEADER_BAR_STANDARD_CLASS, HEADER_STICKY_CLASS, HEADER_STICKY_STANDARD_CLASS, TITLE_CLASS, TITLE_STANDARD_CLASS, TITLE_ROW_CLASS, TOP_ROW_CLASS, BACK_WRAP_CLASS, ...Object.values(STATUS_CLASS), ...KIT_PAGE_BAR_CLASS_CANDIDATES, ...KIT_PAGE_STATUS_CLASS_CANDIDATES]
|
|
45
49
|
.flatMap((s) => s.split(/\s+/)).filter((c) => c !== '')),
|
|
46
50
|
];
|
|
47
51
|
|
|
@@ -90,10 +94,11 @@ export function checkNoMaxWidth(kind: string, input: KitFrameInput): KitDiagnost
|
|
|
90
94
|
export function headerFragment(input: KitFrameInput, prefix = ''): KitFragment {
|
|
91
95
|
const hid = `${prefix}frame__header`;
|
|
92
96
|
const out = emptyFragment();
|
|
97
|
+
const isStandard = input.density === 'standard';
|
|
93
98
|
const { page } = input;
|
|
94
99
|
const { title, subtitle, eyebrow, breadcrumbs } = page;
|
|
95
100
|
const crumbs = breadcrumbs !== undefined && breadcrumbs.length > 0
|
|
96
|
-
? `<div data-soma-id="${esc(`${hid}__crumbs`)}" class="mb-4">${breadcrumbsHtml(breadcrumbs, { anchorId: `${hid}__crumbs_nav`, locale: input.locale ?? '' })}</div>`
|
|
101
|
+
? `<div data-soma-id="${esc(`${hid}__crumbs`)}" class="${isStandard ? 'mb-4' : 'mb-2'}">${breadcrumbsHtml(breadcrumbs, { anchorId: `${hid}__crumbs_nav`, locale: input.locale ?? '' })}</div>`
|
|
97
102
|
: '';
|
|
98
103
|
const eye = eyebrow !== undefined && eyebrow !== ''
|
|
99
104
|
? `<p data-soma-id="${esc(`${hid}__eyebrow`)}"${classAttr(EYEBROW_CLASS)}>${esc(eyebrow)}</p>`
|
|
@@ -139,8 +144,10 @@ export function headerFragment(input: KitFrameInput, prefix = ''): KitFragment {
|
|
|
139
144
|
if (steps.length > 0) out.events[`${id}.action`] = { steps };
|
|
140
145
|
actionsHtml = `<div data-soma-component="KitPageBar" data-soma-id="${esc(id)}" class="shrink-0"></div>`;
|
|
141
146
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
147
|
+
const titleCls = isStandard ? TITLE_STANDARD_CLASS : TITLE_CLASS;
|
|
148
|
+
const barCls = page.sticky === true ? (isStandard ? HEADER_STICKY_STANDARD_CLASS : HEADER_STICKY_CLASS) : (isStandard ? HEADER_BAR_STANDARD_CLASS : HEADER_BAR_CLASS);
|
|
149
|
+
const titleBlock = `<div class="min-w-0"><div${classAttr(TITLE_ROW_CLASS)}><h1 data-soma-id="${esc(`${hid}__title`)}"${classAttr(titleCls)}>${esc(title)}</h1>${status}</div>${sub}${liveHtml}</div>`;
|
|
150
|
+
out.html = `<header data-soma-id="${esc(hid)}"${classAttr(barCls)}>${crumbs}${backHtml}${eye}<div${classAttr(TOP_ROW_CLASS)}>${titleBlock}${actionsHtml}</div></header>`;
|
|
144
151
|
if (Object.keys(show).length > 0) out.ui.show = show;
|
|
145
152
|
const used: string[] = [];
|
|
146
153
|
if (backHtml !== '' || actionsHtml !== '') used.push('KitPageBar');
|
|
@@ -207,8 +214,9 @@ export function finishFrame(slotParts: KitFragment[], html: string, extraCandida
|
|
|
207
214
|
};
|
|
208
215
|
}
|
|
209
216
|
|
|
210
|
-
export function rootClass(input: KitFrameInput, base
|
|
211
|
-
|
|
217
|
+
export function rootClass(input: KitFrameInput, base?: string): string {
|
|
218
|
+
const dflt = base ?? (input.density === 'standard' ? CANVAS_STANDARD_CLASS : CANVAS_CLASS);
|
|
219
|
+
return mergeClass(dflt, input.class);
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
export function slotWrapper(slot: string, base: string, input: KitFrameInput, inner: string): string {
|
package/src/frames/types.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface KitFrameInput {
|
|
|
62
62
|
registeredActions?: ReadonlySet<string>;
|
|
63
63
|
/** 页面语言(同 KitBizContext.locale):页面框写进产物的内置文案按它取 */
|
|
64
64
|
locale?: string;
|
|
65
|
+
/** 界面规格密度档:缺省 compact(中后台紧凑标准),standard 为宽松均衡档 */
|
|
66
|
+
density?: 'compact' | 'standard';
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface KitFrameDefinition {
|
|
@@ -74,7 +74,8 @@ function checkMenu(list: unknown, path: string, depth: number, counter: { n: num
|
|
|
74
74
|
if (typeof raw.label !== 'string' || raw.label.trim() === '') out.push(bad(`${p}.label`, `${p}.label 必填`));
|
|
75
75
|
checkUrl(raw.url, `${p}.url`, out);
|
|
76
76
|
checkUrl(raw.href, `${p}.href`, out);
|
|
77
|
-
if (raw.
|
|
77
|
+
if (raw.group === true && depth > 1) out.push(bad(`${p}.group`, '菜单分组标题 group: true 只能放在顶层'));
|
|
78
|
+
if (raw.children !== undefined) checkMenu(raw.children, `${p}.children`, raw.group === true ? depth : depth + 1, counter, out);
|
|
78
79
|
for (const k of Object.keys(raw)) {
|
|
79
80
|
if (k === 'class') out.push(bad(`${p}.class`, '菜单项不接受样式类'));
|
|
80
81
|
}
|
|
@@ -260,7 +261,7 @@ export function checkWorkspaceConfig(config: Rec | undefined): KitDiagnostic[] {
|
|
|
260
261
|
if (sb.resizable !== true && (sb.min !== undefined || sb.max !== undefined || sb.remember !== undefined)) out.push(bad('sidebar', 'min / max / remember 只在 resizable: true 时有意义'));
|
|
261
262
|
} else if (config.sidebar !== undefined) out.push(bad('sidebar', 'sidebar 必须是对象 { resizable?, width?, min?, max?, remember? }'));
|
|
262
263
|
if (config.watermark !== undefined && !isRec(config.watermark)) out.push(bad('watermark', 'watermark 必须是对象(见 Watermark 数据)'));
|
|
263
|
-
for (const flag of ['collapsed', 'collapsible', 'favorites', 'theme_panel', 'fullscreen', 'share_hash'] as const) {
|
|
264
|
+
for (const flag of ['collapsed', 'collapsible', 'favorites', 'theme_panel', 'fullscreen', 'share_hash', 'custom_stage'] as const) {
|
|
264
265
|
if (config[flag] !== undefined && typeof config[flag] !== 'boolean') out.push(bad(flag, `${flag} 必须是布尔`));
|
|
265
266
|
}
|
|
266
267
|
return out;
|