soma-kit 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1278
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// 单对象排布:KitArrange + 字段引用 -> KitLayoutIR(grid / rows / flex)。
|
|
2
2
|
|
|
3
3
|
import { KIT_CLASS_DEFAULTS, KIT_SUMMARY_EMPTY, KIT_TYPES, KIT_WIDTH } from './defaults';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { KIT_METRIC_HIGHLIGHT_CLASS, resolveFieldEmphasisClass } from './form-detail';
|
|
5
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_CELL_LABEL_CLASS = kitTypographyRecipe('label');
|
|
8
|
+
const DEFAULT_CELL_VALUE_CLASS = KIT_CLASS_DEFAULTS.value;
|
|
9
|
+
import { builtinEmitsOf, optionsFromOf, staticOptionsOf } from './linkage';
|
|
6
10
|
import { checkClasses, mergeClass } from './merge-class';
|
|
11
|
+
import { hintOf, nameSuggestion } from '../compile/hints';
|
|
7
12
|
import { pickComponent } from './pick-component';
|
|
8
13
|
import {
|
|
9
14
|
colsLevels,
|
|
@@ -42,14 +47,14 @@ export interface KitCellEnv {
|
|
|
42
47
|
path: string;
|
|
43
48
|
/** summary 的空值口径:hide = 整格不渲染(hideEmpty);text = 空值显示文案(Text / Tag 的 placeholder)。只在 summary 视图的 env 上设 */
|
|
44
49
|
empty?: { hide: boolean; text: string };
|
|
45
|
-
/** 当前视图槽位(字段联动键
|
|
50
|
+
/** 当前视图槽位(字段联动键 when 按槽位判定可用性) */
|
|
46
51
|
slot?: 'list' | 'summary' | 'filter' | 'form';
|
|
47
52
|
/** 必填星号位置(view.form.requiredMark,缺省 end) */
|
|
48
53
|
requiredMark?: 'start' | 'end';
|
|
49
|
-
/** 字段策略表(view.form.policy 规整后的结果,只在 form 视图的 env 上设) */
|
|
50
|
-
policy?: KitFieldPolicyIR;
|
|
51
54
|
/** 页面语言(布尔列缺省「是 / 否」等编译期文案);缺省取 zh-CN */
|
|
52
55
|
locale?: string;
|
|
56
|
+
/** 写死形状组件(FlowEditor / RowEditor 等作字段控件)的契约 props 键;给了才核 fields[].props 的键(闭集,不静默透传) */
|
|
57
|
+
staticPropKeys?: (component: string) => readonly string[] | undefined;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
export function normalizeRef(item: string | KitFieldRef | KitDividerItem): KitFieldRef {
|
|
@@ -80,8 +85,14 @@ function fieldProps(field: KitFieldSchema, ref: KitFieldRef, mode: KitMode): Rec
|
|
|
80
85
|
const props: Record<string, unknown> = {};
|
|
81
86
|
const staticOptions = staticOptionsOf(field);
|
|
82
87
|
if (staticOptions && staticOptions.length > 0) props.options = staticOptions;
|
|
83
|
-
const format = field.format ?? (mode === 'show' ? KIT_TYPES[field.type]?.format : undefined);
|
|
88
|
+
const format = field.format ?? (mode === 'show' ? (KIT_TYPES[field.type]?.format ?? (field.type === 'daterange' ? 'daterange' : undefined)) : undefined);
|
|
84
89
|
if (format && mode === 'show') props.format = format;
|
|
90
|
+
const rawField = field as unknown as Record<string, unknown>;
|
|
91
|
+
const rawRef = ref as unknown as Record<string, unknown>;
|
|
92
|
+
const unit = typeof rawRef.unit === 'string' && rawRef.unit !== '' ? rawRef.unit : typeof rawField.unit === 'string' && rawField.unit !== '' ? rawField.unit : undefined;
|
|
93
|
+
const currency = typeof rawRef.currency === 'string' && rawRef.currency !== '' ? rawRef.currency : typeof rawField.currency === 'string' && rawField.currency !== '' ? rawField.currency : undefined;
|
|
94
|
+
if (unit !== undefined) props.unit = unit;
|
|
95
|
+
if (currency !== undefined) props.currency = currency;
|
|
85
96
|
// K-3:逐视图占位文案只在编辑态生效(只读组件没有 placeholder)
|
|
86
97
|
if (mode === 'edit' && typeof ref.placeholder === 'string' && ref.placeholder !== '') props.placeholder = ref.placeholder;
|
|
87
98
|
return { ...props, ...(ref.props ?? {}) };
|
|
@@ -102,8 +113,15 @@ function dividerCell(ref: KitFieldRef, env: KitCellEnv, index: number, spanClass
|
|
|
102
113
|
if (typeof d.label === 'string' && d.label !== '') props.label = d.label;
|
|
103
114
|
if (d.vertical === true) props.direction = 'vertical';
|
|
104
115
|
if (d.dashed === true) props.dashed = true;
|
|
105
|
-
if (d.align
|
|
106
|
-
|
|
116
|
+
if (d.align !== undefined) {
|
|
117
|
+
if (d.align === 'start' || d.align === 'end') props.align = d.align;
|
|
118
|
+
else if (d.align !== 'center') env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.divider.align`, message: 'divider.align 只许 start / center / end' });
|
|
119
|
+
}
|
|
120
|
+
if (d.tone !== undefined) {
|
|
121
|
+
const allowedTones = ['neutral', 'primary', 'info', 'success', 'warning', 'danger'];
|
|
122
|
+
if (typeof d.tone === 'string' && allowedTones.includes(d.tone)) props.tone = d.tone;
|
|
123
|
+
else env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.divider.tone`, message: `divider.tone 只许 ${allowedTones.join(' / ')}` });
|
|
124
|
+
}
|
|
107
125
|
return {
|
|
108
126
|
field: ref.name === DIVIDER_FIELD ? `${DIVIDER_FIELD}_${index}` : ref.name,
|
|
109
127
|
component: 'KitDivider',
|
|
@@ -139,35 +157,49 @@ export function buildCell(
|
|
|
139
157
|
const field = env.schema[ref.name];
|
|
140
158
|
const where = `${env.path}.fields[${index}]`;
|
|
141
159
|
if (!field) {
|
|
142
|
-
env.diagnostics.push({ code: 'KIT-OBJ-001', path: where, message: `view 引用了 schema 中不存在的字段 ${ref.name}
|
|
160
|
+
env.diagnostics.push({ code: 'KIT-OBJ-001', path: where, message: `view 引用了 schema 中不存在的字段 ${ref.name}`, ...hintOf(nameSuggestion(ref.name, Object.keys(env.schema))) });
|
|
143
161
|
return null;
|
|
144
162
|
}
|
|
145
163
|
const mode = env.modeFor(field);
|
|
146
|
-
// 场景显隐(字段项 when):只读视图(list / summary / 只读 form)只看 view;可编辑 form 按 add / edit 在运行期求值(cell.scenes);filter 不接受
|
|
147
|
-
let scenes: Array<'add' | 'edit'> | undefined;
|
|
148
|
-
if (ref.when !== undefined) {
|
|
149
|
-
const list = scenesOf(ref.when, `${where}.when`, env.diagnostics);
|
|
150
|
-
if (list === null) return null;
|
|
151
|
-
if (env.slot === 'filter') {
|
|
152
|
-
env.diagnostics.push({ code: 'KIT-FORM-001', path: `${where}.when`, message: 'filter 视图的字段不接受场景 when(筛选条件与新建 / 编辑无关)' });
|
|
153
|
-
} else if (mode === 'edit') {
|
|
154
|
-
scenes = list.filter((s): s is 'add' | 'edit' => s !== KIT_COND.viewScene);
|
|
155
|
-
if (scenes.length === 0) return null;
|
|
156
|
-
if (scenes.length === 2) scenes = undefined;
|
|
157
|
-
} else if (!list.includes(KIT_COND.viewScene as 'view')) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
164
|
const pick = pickComponent(field, ref, mode, env.registered);
|
|
162
165
|
if (pick.unknownType) {
|
|
163
166
|
env.diagnostics.push({ code: 'KIT-TYPE-001', path: where, message: `字段 ${ref.name} 的 type ${field.type} 未在 types 表登记` });
|
|
164
167
|
} else if (pick.unregistered) {
|
|
165
168
|
env.diagnostics.push({ code: 'KIT-COMP-001', path: where, message: `字段 ${ref.name} 选出的组件 ${pick.component} 未登记` });
|
|
166
169
|
}
|
|
170
|
+
const contractKeys = env.staticPropKeys?.(pick.component);
|
|
171
|
+
if (contractKeys !== undefined && ref.props !== null && typeof ref.props === 'object') {
|
|
172
|
+
for (const k of Object.keys(ref.props)) {
|
|
173
|
+
if (!contractKeys.includes(k)) {
|
|
174
|
+
env.diagnostics.push({ code: 'KIT-STATIC-001', path: `${where}.props.${k}`, message: `组件 ${pick.component} 没有 prop ${k}(契约 props:${contractKeys.join(' / ')})` });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
167
178
|
for (const [k, v] of [['class', ref.class], ['labelClass', ref.labelClass], ['valueClass', ref.valueClass]] as const) {
|
|
168
179
|
env.diagnostics.push(...checkClasses(v, `${where}.${k}`));
|
|
169
180
|
}
|
|
170
|
-
const
|
|
181
|
+
const rawEmphasis = ref.emphasis ?? field.emphasis;
|
|
182
|
+
let fieldEmphasis: 'strong' | 'muted' | undefined;
|
|
183
|
+
if (rawEmphasis !== undefined) {
|
|
184
|
+
if (rawEmphasis === 'strong' || rawEmphasis === 'muted') {
|
|
185
|
+
fieldEmphasis = rawEmphasis;
|
|
186
|
+
} else {
|
|
187
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.emphasis`, message: `字段 ${ref.name} 的 emphasis 只许 strong / muted,收到 "${String(rawEmphasis)}"` });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const rawHighlight = ref.highlight ?? field.highlight;
|
|
191
|
+
let fieldHighlight = false;
|
|
192
|
+
if (rawHighlight !== undefined) {
|
|
193
|
+
if (typeof rawHighlight === 'boolean') {
|
|
194
|
+
fieldHighlight = rawHighlight;
|
|
195
|
+
} else {
|
|
196
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.highlight`, message: `字段 ${ref.name} 的 highlight 必须是布尔值` });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const baseWithHighlight = fieldHighlight ? mergeClass(`${spanClass} ${extraBase}`.trim(), KIT_METRIC_HIGHLIGHT_CLASS) : `${spanClass} ${extraBase}`.trim();
|
|
200
|
+
const base = mergeClass(baseWithHighlight, view.cellClass, view.replaceClass);
|
|
201
|
+
const baseVal = SELF_COLORED_COMPONENTS.has(pick.component) ? '' : DEFAULT_CELL_VALUE_CLASS;
|
|
202
|
+
const valWithEmphasis = fieldEmphasis !== undefined ? mergeClass(baseVal, resolveFieldEmphasisClass(fieldEmphasis)) : baseVal;
|
|
171
203
|
const cell: KitCell = {
|
|
172
204
|
field: ref.name,
|
|
173
205
|
component: pick.component,
|
|
@@ -178,13 +210,13 @@ export function buildCell(
|
|
|
178
210
|
props: fieldProps(field, ref, mode),
|
|
179
211
|
parts,
|
|
180
212
|
cellClass: mergeClass(base, ref.class),
|
|
181
|
-
labelClass: mergeClass(
|
|
182
|
-
valueClass:
|
|
213
|
+
labelClass: mergeClass(DEFAULT_CELL_LABEL_CLASS, ref.labelClass),
|
|
214
|
+
valueClass: mergeClass(valWithEmphasis, ref.valueClass),
|
|
183
215
|
errorClass: KIT_CLASS_DEFAULTS.error,
|
|
216
|
+
...(fieldEmphasis !== undefined ? { emphasis: fieldEmphasis } : {}),
|
|
217
|
+
...(fieldHighlight ? { highlight: true } : {}),
|
|
184
218
|
};
|
|
185
219
|
if (ref.action) cell.action = ref.action;
|
|
186
|
-
// GB6:派生展示字段(form 视图的只读格)——KitObjectForm 按草稿渲染模板文字作为值;写法由 collectFieldValues 统一核
|
|
187
|
-
if (env.slot === 'form' && mode === 'show' && typeof field.derive?.template === 'string') cell.derive = { template: field.derive.template };
|
|
188
220
|
// 字段 action 绑定的事件(fields[].on):闭集 = 该内置组件契约 emits 里的事件名;缺省 Button / Link 绑 click、其余绑 change
|
|
189
221
|
if (ref.on !== undefined) {
|
|
190
222
|
const emits = builtinEmitsOf(pick.component);
|
|
@@ -198,22 +230,20 @@ export function buildCell(
|
|
|
198
230
|
cell.event = ref.on;
|
|
199
231
|
}
|
|
200
232
|
}
|
|
201
|
-
|
|
202
|
-
const fill = fillOf(ref.fill, ref.name, env.schema, `${where}.fill`, env.diagnostics, 'KIT-FORM-003');
|
|
203
|
-
if (fill !== null && Object.keys(fill).length > 0) cell.fill = fill;
|
|
204
|
-
}
|
|
205
|
-
linkCell(cell, field, ref, mode, scenes, env, where);
|
|
233
|
+
linkCell(cell, field, ref, mode, env, where);
|
|
206
234
|
if (ref.help !== undefined) {
|
|
207
235
|
if (typeof ref.help !== 'string') {
|
|
208
|
-
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.help`, message: 'help
|
|
236
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.help`, message: 'help 必须是字符串' });
|
|
209
237
|
} else if (ref.help !== '' && mode === 'edit') {
|
|
210
238
|
cell.help = ref.help; // 只读视图不显示 help
|
|
211
239
|
}
|
|
212
240
|
}
|
|
213
241
|
if (env.empty !== undefined && mode === 'show') {
|
|
214
242
|
if (env.empty.hide) {
|
|
215
|
-
//
|
|
216
|
-
|
|
243
|
+
// 发射成纯路径绑定 show[id].when = 字段值路径(只判真值),数字 / 布尔字段的 0 / false 会被误隐,故不许 hideEmpty
|
|
244
|
+
if (KIT_SUMMARY_EMPTY.hideEmptyForbiddenTypes.includes(field.type)) {
|
|
245
|
+
env.diagnostics.push({ code: 'KIT-OBJ-008', path: `${where}`, message: `字段 ${ref.name} 的类型 ${field.type} 不许 hideEmpty(0 / false 是有值)` });
|
|
246
|
+
} else cell.hideEmpty = true;
|
|
217
247
|
} else if (env.empty.text !== '' && KIT_SUMMARY_EMPTY.placeholderComponents.includes(pick.component) && cell.props.placeholder === undefined) {
|
|
218
248
|
cell.props.placeholder = env.empty.text;
|
|
219
249
|
}
|
|
@@ -266,7 +296,7 @@ export function arrange(input: KitArrangeInput, refs: KitFieldRef[], view: KitVi
|
|
|
266
296
|
if ('cols' in a) {
|
|
267
297
|
let n = a.cols;
|
|
268
298
|
if (!isColsAllowed(n)) {
|
|
269
|
-
env.diagnostics.push({ code: 'KIT-OBJ-003', path: `${path}.cols`, message: `cols: ${n} 不是 12
|
|
299
|
+
env.diagnostics.push({ code: 'KIT-OBJ-003', path: `${path}.cols`, message: `cols: ${n} 不是 12 的约数` });
|
|
270
300
|
n = 1;
|
|
271
301
|
}
|
|
272
302
|
const levels = colsLevels(n);
|
|
@@ -298,7 +328,7 @@ export function arrange(input: KitArrangeInput, refs: KitFieldRef[], view: KitVi
|
|
|
298
328
|
const slots = rowsN * C;
|
|
299
329
|
let use = refs;
|
|
300
330
|
if (refs.length > slots) {
|
|
301
|
-
env.diagnostics.push({ code: 'KIT-OBJ-002', path: `${path}.matrix`, message: `字段个数 ${refs.length} 超过矩阵 ${rowsN} x ${C} 的容量 ${slots}
|
|
331
|
+
env.diagnostics.push({ code: 'KIT-OBJ-002', path: `${path}.matrix`, message: `字段个数 ${refs.length} 超过矩阵 ${rowsN} x ${C} 的容量 ${slots}` });
|
|
302
332
|
use = refs.slice(0, slots);
|
|
303
333
|
}
|
|
304
334
|
const levels = gridLevels(C);
|
|
@@ -363,46 +393,10 @@ function requiredOf(label: string, field: { rules?: Array<{ required?: boolean }
|
|
|
363
393
|
}
|
|
364
394
|
|
|
365
395
|
/**
|
|
366
|
-
*
|
|
367
|
-
* 场景 when 已在上面过滤;远程选项只给可编辑格。写法不对记 KIT-FORM-001 / 003 并忽略该键。
|
|
396
|
+
* 字段联动(M 波 G3):远程选项只给可编辑格。写法不对记 KIT-FORM-003 并忽略该键。
|
|
368
397
|
*/
|
|
369
|
-
function linkCell(cell: KitCell, field: KitFieldSchema, ref: KitFieldRef, mode: KitMode,
|
|
370
|
-
const names = new Set(Object.keys(env.schema));
|
|
398
|
+
function linkCell(cell: KitCell, field: KitFieldSchema, ref: KitFieldRef, mode: KitMode, env: KitCellEnv, where: string): void {
|
|
371
399
|
const editable = mode === 'edit';
|
|
372
|
-
const pred = (key: 'showWhen' | 'disabledWhen' | 'requiredWhen', allowed: boolean, why: string): void => {
|
|
373
|
-
const raw = ref[key];
|
|
374
|
-
if (raw === undefined) return;
|
|
375
|
-
if (!allowed) {
|
|
376
|
-
env.diagnostics.push({ code: 'KIT-FORM-001', path: `${where}.${key}`, message: `${key} ${why}` });
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
const core = predicateToCore(raw, `${where}.${key}`, names, env.diagnostics);
|
|
380
|
-
if (core !== null) cell[key] = core;
|
|
381
|
-
};
|
|
382
|
-
if (!editable && ref.showWhen !== undefined) {
|
|
383
|
-
// 只读视图:编成 Show 的对象谓词 when(core 已支持),只许单个叶子条件
|
|
384
|
-
const core = predicateToCore(ref.showWhen, `${where}.showWhen`, names, env.diagnostics);
|
|
385
|
-
if (core !== null) {
|
|
386
|
-
if ('field' in core) cell.showWhen = core;
|
|
387
|
-
else env.diagnostics.push({ code: 'KIT-FORM-001', path: `${where}.showWhen`, message: '只读视图的 showWhen 只许单个条件 { field, op, value? },不支持 all / any 组合' });
|
|
388
|
-
}
|
|
389
|
-
} else {
|
|
390
|
-
pred('showWhen', editable, '只用于 form / filter / 只读视图');
|
|
391
|
-
}
|
|
392
|
-
pred('disabledWhen', editable, '只用于可编辑的 form / filter 视图');
|
|
393
|
-
pred('requiredWhen', editable && env.slot === 'form', '只用于可编辑的 form 视图');
|
|
394
|
-
// 字段策略表(view.form.policy):并入三个条件,与字段上另写的同名条件叠加
|
|
395
|
-
if (editable && env.slot === 'form' && env.policy !== undefined) {
|
|
396
|
-
const extra = policyConditions(env.policy, ref.name);
|
|
397
|
-
for (const key of ['showWhen', 'disabledWhen', 'requiredWhen'] as const) {
|
|
398
|
-
const add = extra[key];
|
|
399
|
-
if (add === undefined) continue;
|
|
400
|
-
const merged = andPredicate(cell[key], add);
|
|
401
|
-
if (merged === null) env.diagnostics.push({ code: 'KIT-FORM-008', path: `${where}.${key}`, message: `字段上的 ${key} 是 any 组合,无法与字段策略表叠加;请改写成 all 或拆开` });
|
|
402
|
-
else cell[key] = merged;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if (scenes !== undefined) cell.scenes = scenes;
|
|
406
400
|
if (!Array.isArray(field.options) && field.options !== undefined) {
|
|
407
401
|
if (!editable) return;
|
|
408
402
|
const ir = optionsFromOf(field.options, ref.name, field.type, env.schema, `${where}.options`, env.diagnostics, cell.component);
|
|
@@ -55,7 +55,7 @@ export function createKitCollapseWiring(): SomaComponentDefinition {
|
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
templateHtml: '<div data-soma-id="root" hidden></div>',
|
|
58
|
-
controllerFactory: createKitController({
|
|
58
|
+
controllerFactory: createKitController(() => ({
|
|
59
59
|
attach(root, api) {
|
|
60
60
|
const prev = api.host.previousElementSibling;
|
|
61
61
|
const scope: HTMLElement | null = prev !== null && prev.hasAttribute('data-kit-collapse-root')
|
|
@@ -94,6 +94,6 @@ export function createKitCollapseWiring(): SomaComponentDefinition {
|
|
|
94
94
|
const state = STATES.get(root);
|
|
95
95
|
if (state) state.accordion = bool(p.accordion);
|
|
96
96
|
},
|
|
97
|
-
}),
|
|
97
|
+
})),
|
|
98
98
|
};
|
|
99
99
|
}
|
|
@@ -71,8 +71,8 @@ export function parseExpandDecl(decl: unknown, path: string, env: ExpandParseEnv
|
|
|
71
71
|
if (extra.length > 0) return bad(`expand 的 list 形只认 list / link,多出:${extra.join(' / ')}`);
|
|
72
72
|
if (typeof decl.list !== 'string' || !IDENT.test(decl.list)) return bad('expand.list 必须是同产品里子对象的名字(标识符)');
|
|
73
73
|
if (typeof decl.link !== 'string' || !IDENT.test(decl.link)) return bad('expand.link 必须是子对象读接口的关联参数名(标识符)');
|
|
74
|
-
if (env.expandHosts === undefined) return bad('expand.list 目前只能用在 StandardCrud 的 entity 列表里(需要协调组件,子对象写在 objects.overlays 里 kind: expand
|
|
75
|
-
if (env.scroll) return bad('expand.list 暂不支持滚动模式(固定列 / min / toolbar.columns / columnGroups / resizable
|
|
74
|
+
if (env.expandHosts === undefined) return bad('expand.list 目前只能用在 StandardCrud 的 entity 列表里(需要协调组件,子对象写在 objects.overlays 里 kind: expand);当前位置不支持');
|
|
75
|
+
if (env.scroll) return bad('expand.list 暂不支持滚动模式(固定列 / min / toolbar.columns / columnGroups / resizable 会进入滚动模式)');
|
|
76
76
|
if (!env.expandHosts.has(decl.list)) {
|
|
77
77
|
return bad(`expand.list "${decl.list}" 不是已声明的子对象(须在 product.objects.overlays 里写 kind: expand 的同名对象)`);
|
|
78
78
|
}
|