soma-kit 0.1.11 → 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 -1473
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrange, buildCell, type KitCellEnv } from './arrange';
|
|
4
4
|
import {
|
|
5
|
-
KIT_CLASS_DEFAULTS, KIT_CONTEXT_MENU,
|
|
6
|
-
type KitTableDensity,
|
|
5
|
+
KIT_CLASS_DEFAULTS, KIT_CONTEXT_MENU, KIT_OBJECT_DEFAULTS, KIT_SKELETON, KIT_TABLE_EXT, KIT_TABLE_VIRTUAL, KIT_TREE_TABLE, KIT_WIDTH,
|
|
7
6
|
} from './defaults';
|
|
8
7
|
import {
|
|
9
8
|
actionsStepOf, alignClass, columnFilterOf, columnMetaOf, parseBatch, parseColExt, parseColumnGroups, parseEditMode, parseSelect, parseSummary, parseToolbar,
|
|
10
|
-
plainRowClass, pyTokens, resolveResizable, scrollRowClass, stepOf, stickyPlan, type ColExt, type ColGroup,
|
|
9
|
+
plainRowClass, pyTokens, resolveResizable, resolveStickyCombo, scrollRowClass, STICKY_HEAD_CLASS, STICKY_HEAD_COMBO_CLASS, stepOf, stickyPlan, type ColExt, type ColGroup,
|
|
11
10
|
} from './collection-table';
|
|
12
11
|
import { expandListIR, parseExpandDecl } from './collection-expand';
|
|
13
12
|
import { checkClasses, mergeClass } from './merge-class';
|
|
14
|
-
import {
|
|
13
|
+
import { hintOf, nameSuggestion } from '../compile/hints';
|
|
14
|
+
import { checkRowPath } from './view-binding';
|
|
15
15
|
import { fixedSpan, gridColsClasses, gridLevels, partsOverflow, splitParts } from './parts';
|
|
16
16
|
import type {
|
|
17
17
|
KitAction,
|
|
@@ -49,7 +49,8 @@ const STATE_DEFAULTS = { loading: '加载中…', empty: '暂无数据', error:
|
|
|
49
49
|
export const KIT_STATE_DEFAULT_TEXT = STATE_DEFAULTS;
|
|
50
50
|
|
|
51
51
|
function stateOf(c: KitCollectionStateDecl, env: KitCollectionEnv, path: string): KitStateIR | null {
|
|
52
|
-
|
|
52
|
+
// state: false 只关加载 / 空态;失败必须可见,仍发射三态组件并限定为 errorOnly 模式(文案取缺省,不画加载 / 空态)
|
|
53
|
+
if (c.state === false) return { ...STATE_DEFAULTS, skeleton: false, errorOnly: true };
|
|
53
54
|
const text = (key: 'loading' | 'empty' | 'error'): string => {
|
|
54
55
|
const v = c[key];
|
|
55
56
|
if (v === undefined) return STATE_DEFAULTS[key];
|
|
@@ -131,16 +132,22 @@ function treeOf(c: { tree?: KitTreeDecl }, cells: KitCell[], env: KitCollectionE
|
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
/** 表格粘性表头:表头钉在视口顶,放弃表内横滚(sticky 在滚动容器里不生效) */
|
|
135
|
-
const STICKY_HEAD_CLASS = 'sticky top-0 z-10 shadow-xs';
|
|
136
|
-
|
|
137
135
|
function resolveRowActions(ids: string[] | undefined, env: KitCollectionEnv): KitAction[] {
|
|
138
136
|
const out: KitAction[] = [];
|
|
139
|
-
(
|
|
137
|
+
const bad = (message: string, path: string): void => { env.diagnostics.push({ code: 'KIT-EVT-001', path, message }); };
|
|
138
|
+
if (ids !== undefined && !Array.isArray(ids)) {
|
|
139
|
+
bad('rowActions 必须是 @动作id 的列表', `${env.path}.collection.rowActions`);
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
(ids ?? []).forEach((raw: unknown, i) => {
|
|
143
|
+
if (typeof raw !== 'string' || raw === '') {
|
|
144
|
+
bad('rowActions 的项必须是 @动作id 字符串', `${env.path}.collection.rowActions[${i}]`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
140
147
|
const id = raw.startsWith('@') ? raw.slice(1) : raw; // 规格书写面 `@edit`
|
|
141
148
|
const act = env.actions.find((a) => a.id === id);
|
|
142
149
|
if (!act) {
|
|
143
|
-
env.diagnostics.push({ code: 'KIT-EVT-001', path: `${env.path}.collection.rowActions[${i}]`, message: `动作 @${id}
|
|
150
|
+
env.diagnostics.push({ code: 'KIT-EVT-001', path: `${env.path}.collection.rowActions[${i}]`, message: `动作 @${id} 不存在`, ...hintOf(nameSuggestion(id, env.actions.map((a) => a.id))) });
|
|
144
151
|
return;
|
|
145
152
|
}
|
|
146
153
|
out.push(act);
|
|
@@ -158,7 +165,7 @@ function resolveContextMenu(c: KitCollection, rowActions: readonly KitAction[],
|
|
|
158
165
|
if (raw === undefined) return [];
|
|
159
166
|
const at = `${env.path}.collection.contextMenu`;
|
|
160
167
|
if (!KIT_CONTEXT_MENU.collections.includes(c.type)) {
|
|
161
|
-
env.diagnostics.push({ code: 'KIT-MENU-001', path: at, message: `contextMenu 只用于 ${KIT_CONTEXT_MENU.collections.join(' / ')}
|
|
168
|
+
env.diagnostics.push({ code: 'KIT-MENU-001', path: at, message: `contextMenu 只用于 ${KIT_CONTEXT_MENU.collections.join(' / ')} 集合` });
|
|
162
169
|
return [];
|
|
163
170
|
}
|
|
164
171
|
return resolveContextMenuItems(raw, rowActions, env.actions, at, env.diagnostics);
|
|
@@ -175,7 +182,7 @@ export function resolveContextMenuItems(
|
|
|
175
182
|
return [];
|
|
176
183
|
}
|
|
177
184
|
const out: KitAction[] = [];
|
|
178
|
-
if (raw.length > KIT_CONTEXT_MENU.maxItems) bad(`contextMenu 至多 ${KIT_CONTEXT_MENU.maxItems}
|
|
185
|
+
if (raw.length > KIT_CONTEXT_MENU.maxItems) bad(`contextMenu 至多 ${KIT_CONTEXT_MENU.maxItems} 项`);
|
|
179
186
|
raw.slice(0, KIT_CONTEXT_MENU.maxItems).forEach((item: unknown, i) => {
|
|
180
187
|
if (typeof item !== 'string' || item === '') {
|
|
181
188
|
bad('contextMenu 的项必须是 @动作id 字符串', `${at}[${i}]`);
|
|
@@ -210,24 +217,44 @@ function pagerOf(page: KitPageDecl | undefined): KitPagerIR | null {
|
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
const PAGE_MODES: readonly string[] = ['pager', 'more', 'infinite'];
|
|
213
|
-
|
|
220
|
+
const PAGE_DECL_KEYS: readonly string[] = ['size', 'sizes', 'jump', 'mode', 'layout', 'show_total'];
|
|
221
|
+
/** collection.page 的键与值核对(B9 / C11) */
|
|
214
222
|
function checkPageDecl(c: KitCollection, env: KitCollectionEnv): void {
|
|
215
|
-
const page = (c as { page?:
|
|
216
|
-
if (page === undefined || page === false
|
|
223
|
+
const page = (c as { page?: unknown }).page;
|
|
224
|
+
if (page === undefined || page === false) return;
|
|
217
225
|
const at = `${env.path}.collection.page`;
|
|
218
|
-
if (page
|
|
226
|
+
if (page === null || typeof page !== 'object' || Array.isArray(page)) {
|
|
227
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: at, message: 'collection.page 必须是 false 或对象 { size, sizes?, jump?, mode?, layout?, show_total? }' });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const rec = page as Record<string, unknown>;
|
|
231
|
+
for (const k of Object.keys(rec)) {
|
|
232
|
+
if (!PAGE_DECL_KEYS.includes(k)) {
|
|
233
|
+
env.diagnostics.push({ code: 'KIT-PAGE-001', path: `${at}.${k}`, message: `未知键 ${k}(${at} 允许:${PAGE_DECL_KEYS.join(' / ')})` });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (rec.size !== undefined && (typeof rec.size !== 'number' || !Number.isInteger(rec.size) || rec.size < 1)) {
|
|
237
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.size`, message: 'page.size 必须是正整数' });
|
|
238
|
+
}
|
|
239
|
+
if (rec.sizes !== undefined && (!Array.isArray(rec.sizes) || rec.sizes.length === 0 || rec.sizes.some((n) => typeof n !== 'number' || !Number.isInteger(n) || n < 1))) {
|
|
240
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.sizes`, message: 'page.sizes 必须是非空正整数数组' });
|
|
241
|
+
}
|
|
242
|
+
if (rec.jump !== undefined && typeof rec.jump !== 'boolean') {
|
|
243
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.jump`, message: 'page.jump 必须是布尔' });
|
|
244
|
+
}
|
|
245
|
+
if (rec.mode !== undefined && !PAGE_MODES.includes(rec.mode as string)) {
|
|
219
246
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.mode`, message: `page.mode 取 ${PAGE_MODES.join(' / ')}` });
|
|
220
|
-
delete
|
|
247
|
+
delete rec.mode;
|
|
221
248
|
}
|
|
222
|
-
if (
|
|
249
|
+
if (rec.mode !== undefined && rec.mode !== 'pager' && c.type === 'treeTable') {
|
|
223
250
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.mode`, message: 'treeTable 只支持 page.mode: pager' });
|
|
224
|
-
delete
|
|
251
|
+
delete rec.mode;
|
|
225
252
|
}
|
|
226
|
-
if (
|
|
253
|
+
if (rec.layout !== undefined && !['simple', 'pages', 'full'].includes(rec.layout as string)) {
|
|
227
254
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.layout`, message: 'page.layout 取 simple / pages / full' });
|
|
228
|
-
delete
|
|
255
|
+
delete rec.layout;
|
|
229
256
|
}
|
|
230
|
-
if (
|
|
257
|
+
if (rec.show_total !== undefined && typeof rec.show_total !== 'boolean') env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.show_total`, message: 'page.show_total 必须是布尔' });
|
|
231
258
|
}
|
|
232
259
|
|
|
233
260
|
type VirtualTier = 'sm' | 'md' | 'lg';
|
|
@@ -241,23 +268,23 @@ function parseVirtual(c: KitCollection, env: KitCollectionEnv, isTree: boolean):
|
|
|
241
268
|
if (raw === undefined) return null;
|
|
242
269
|
const at = `${env.path}.collection.virtual`;
|
|
243
270
|
const bad = (message: string): void => { env.diagnostics.push({ code: 'KIT-OBJ-009', path: at, message }); };
|
|
244
|
-
if (isTree) { bad('treeTable 不支持 virtual(它有自己的 windowThreshold
|
|
271
|
+
if (isTree) { bad('treeTable 不支持 virtual(它有自己的 windowThreshold 分批)'); return null; }
|
|
245
272
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) { bad(`virtual 必须写成 { rowHeight: ${KIT_TABLE_VIRTUAL.tiers.join(' | ')} }`); return null; }
|
|
246
273
|
const r = raw as Record<string, unknown>;
|
|
247
|
-
for (const k of Object.keys(r)) if (!KIT_TABLE_VIRTUAL.keys.includes(k)) bad(`virtual 没有键 ${k}(允许:${KIT_TABLE_VIRTUAL.keys.join(' / ')}
|
|
248
|
-
if (r.rowHeight === undefined) { bad('virtual 必须显式给 rowHeight 档位名(sm / md / lg
|
|
274
|
+
for (const k of Object.keys(r)) if (!KIT_TABLE_VIRTUAL.keys.includes(k)) bad(`virtual 没有键 ${k}(允许:${KIT_TABLE_VIRTUAL.keys.join(' / ')})`);
|
|
275
|
+
if (r.rowHeight === undefined) { bad('virtual 必须显式给 rowHeight 档位名(sm / md / lg);没有固定行高就不虚拟化'); return null; }
|
|
249
276
|
if (typeof r.rowHeight !== 'string' || !KIT_TABLE_VIRTUAL.tiers.includes(r.rowHeight as VirtualTier)) {
|
|
250
|
-
bad(`virtual.rowHeight 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')} 档位名(不接受像素数字),收到 ${JSON.stringify(r.rowHeight)}
|
|
277
|
+
bad(`virtual.rowHeight 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')} 档位名(不接受像素数字),收到 ${JSON.stringify(r.rowHeight)}`);
|
|
251
278
|
return null;
|
|
252
279
|
}
|
|
253
280
|
let height: VirtualTier = KIT_TABLE_VIRTUAL.viewportDefault;
|
|
254
281
|
if (r.height !== undefined) {
|
|
255
282
|
if (typeof r.height === 'string' && KIT_TABLE_VIRTUAL.tiers.includes(r.height as VirtualTier)) height = r.height as VirtualTier;
|
|
256
|
-
else bad(`virtual.height 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')},收到 ${JSON.stringify(r.height)}
|
|
283
|
+
else bad(`virtual.height 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')},收到 ${JSON.stringify(r.height)}`);
|
|
257
284
|
}
|
|
258
285
|
const page = (c as { page?: KitPageDecl }).page;
|
|
259
286
|
if (page !== undefined && page !== false && typeof page === 'object' && page.mode === 'infinite') {
|
|
260
|
-
bad('virtual 不与 page.mode: infinite
|
|
287
|
+
bad('virtual 不与 page.mode: infinite 并用(哨兵恒在视口内,会一路加载到底)');
|
|
261
288
|
(page as { mode?: string }).mode = 'more';
|
|
262
289
|
}
|
|
263
290
|
return { rowHeight: r.rowHeight as VirtualTier, height };
|
|
@@ -268,35 +295,15 @@ function optionalPagerOf(page: KitPageDecl | undefined): KitPagerIR | null {
|
|
|
268
295
|
return page === undefined || page === false ? null : pagerOf(page);
|
|
269
296
|
}
|
|
270
297
|
|
|
271
|
-
/**
|
|
272
|
-
function
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return [];
|
|
298
|
+
/** 行样式档位 view.list.rowTone: row.<字段>:纯行路径;只普通表格支持(treeTable / 虚拟滚动表 / cards / stack 报 KIT-ROW-002 并忽略)。返回字段名 */
|
|
299
|
+
function rowToneOf(view: KitViewForm, unsupported: string | null, env: KitCellEnv): string | undefined {
|
|
300
|
+
if (view.rowTone === undefined) return undefined;
|
|
301
|
+
const at = `${env.path}.rowTone`;
|
|
302
|
+
if (unsupported !== null) {
|
|
303
|
+
env.diagnostics.push({ code: 'KIT-ROW-002', path: at, message: `rowTone 只对普通表格生效,${unsupported}不支持` });
|
|
304
|
+
return undefined;
|
|
279
305
|
}
|
|
280
|
-
|
|
281
|
-
if (!Array.isArray(raw) || raw.length === 0 || raw.length > max) {
|
|
282
|
-
env.diagnostics.push({ code: 'KIT-OBJ-009', path, message: `rowClassWhen 必须是 1~${max} 项的数组` });
|
|
283
|
-
return [];
|
|
284
|
-
}
|
|
285
|
-
const out: Array<{ when: Record<string, unknown>; class: string }> = [];
|
|
286
|
-
raw.forEach((item, i) => {
|
|
287
|
-
const at = `${path}[${i}]`;
|
|
288
|
-
const cls = (item as { class?: unknown } | null)?.class;
|
|
289
|
-
if (item === null || typeof item !== 'object' || typeof cls !== 'string' || cls.trim() === '') {
|
|
290
|
-
env.diagnostics.push({ code: 'KIT-OBJ-009', path: at, message: 'rowClassWhen 项必须是 { when, class }' });
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const before = env.diagnostics.length;
|
|
294
|
-
env.diagnostics.push(...checkClasses(cls, `${at}.class`));
|
|
295
|
-
const when = predicateToCore((item as { when?: unknown }).when, `${at}.when`, new Set(Object.keys(env.schema)), env.diagnostics);
|
|
296
|
-
if (when === null || env.diagnostics.length > before) return;
|
|
297
|
-
out.push({ when, class: cls.trim() });
|
|
298
|
-
});
|
|
299
|
-
return out;
|
|
306
|
+
return checkRowPath(view.rowTone, at, 'rowTone', env.diagnostics, env.schema);
|
|
300
307
|
}
|
|
301
308
|
|
|
302
309
|
function styleChecks(view: KitViewForm, c: { class?: string }, env: KitCellEnv): void {
|
|
@@ -317,7 +324,7 @@ export function collection(
|
|
|
317
324
|
const contextMenu = resolveContextMenu(c, rowActions, env);
|
|
318
325
|
const ctxMenuIr = contextMenu.length > 0 ? { contextMenu } : {};
|
|
319
326
|
checkPageDecl(c, env);
|
|
320
|
-
if (view.
|
|
327
|
+
if (view.rowTone !== undefined && c.type !== 'table' && c.type !== 'treeTable') rowToneOf(view, c.type, env);
|
|
321
328
|
|
|
322
329
|
if (c.type === 'table' || c.type === 'treeTable') {
|
|
323
330
|
// 树表不是另一套表格:treeTable = table + tree 参数(`type: table` 带 `tree:` 等价),同一条列 / 表头 / 密度 / 三态 / 分页路径,只有表体换成 KitTreeTable
|
|
@@ -326,32 +333,41 @@ export function collection(
|
|
|
326
333
|
// 分隔线项只属于单对象排布;列里写了丢弃
|
|
327
334
|
const kept = refs.filter((r, i) => {
|
|
328
335
|
if (r.divider === undefined) return true;
|
|
329
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}]`, message: '
|
|
336
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}]`, message: '分隔线不能写在表格的列里' });
|
|
330
337
|
return false;
|
|
331
338
|
});
|
|
332
339
|
refs = kept;
|
|
333
340
|
const { mode: select, scope: selectScope } = parseSelect(c.select, (KIT_OBJECT_DEFAULTS.list.collection as { select: 'none' | 'single' | 'multi' }).select, env);
|
|
334
341
|
const virt = parseVirtual(c, env, isTree);
|
|
342
|
+
const rowTone = rowToneOf(view, isTree ? 'treeTable' : virt !== null ? '虚拟滚动表' : null, env);
|
|
335
343
|
// 虚拟滚动自带竖向滚动视口:表头恒吸顶,固定列与吸顶同在一个滚动容器里,不再互斥(所以显式 stickyHeader 在 virtual 下不单独算)
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
344
|
+
const stickyReq = c.stickyHeader === true && virt === null;
|
|
345
|
+
// Z5:显式 stickyHeader + 固定列 + 表格自身限高(view.class 有 h-* / max-h-*)→ 外壳同时横滚与纵滚,两者并存,不走互斥
|
|
346
|
+
// 整体替换类(replaceClass)生效时外壳类整串被换掉,并存路径加的纵向滚动类会丢:按不限高处理(与旧互斥一致,报 KIT-OBJ-009)
|
|
347
|
+
const rawReplace: unknown = view.replaceClass;
|
|
348
|
+
const classReplaced = (typeof rawReplace === 'string' && rawReplace.trim() !== '') || rawReplace === true;
|
|
349
|
+
const comboWant = resolveStickyCombo({
|
|
350
|
+
stickyHeader: stickyReq, isTree, virtual: virt !== null,
|
|
351
|
+
hasFixed: refs.some((r) => r.fixed !== undefined && (KIT_TABLE_EXT.scroll.fixedValues as readonly string[]).includes(r.fixed)),
|
|
352
|
+
viewClass: classReplaced ? undefined : view.class,
|
|
353
|
+
});
|
|
354
|
+
let sticky = stickyReq && !comboWant;
|
|
342
355
|
if (c.striped !== undefined && typeof c.striped !== 'boolean') {
|
|
343
356
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.striped`, message: 'striped 必须是布尔' });
|
|
344
357
|
}
|
|
345
358
|
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
346
359
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
347
360
|
}
|
|
348
|
-
const dens =
|
|
361
|
+
const dens = { head: D.tableHead, row: D.tableRow };
|
|
349
362
|
const striped = c.striped === true;
|
|
350
363
|
const bordered = c.bordered === true;
|
|
351
364
|
const unbordered = c.bordered === false;
|
|
352
365
|
|
|
353
366
|
// ---- M 波 G2:列模型 / 滚动模式 / 工具栏
|
|
354
367
|
const ext = parseColExt(refs, env, { isTree, sticky });
|
|
368
|
+
// 固定列全被丢弃(不连续等)时没有可并存的东西,退回单独吸顶
|
|
369
|
+
const combo = comboWant && ext.some((e) => e.fixed !== undefined);
|
|
370
|
+
if (comboWant && !combo) sticky = stickyReq;
|
|
355
371
|
const toolbar = parseToolbar((c as { toolbar?: unknown }).toolbar, env, isTree);
|
|
356
372
|
// ---- Q 波 G4:多级表头 / 列宽拖拽(都视同进入滚动模式;treeTable、virtual、stickyHeader 下忽略并报码)
|
|
357
373
|
const rawGroups = (c as { columnGroups?: unknown }).columnGroups;
|
|
@@ -361,7 +377,7 @@ export function collection(
|
|
|
361
377
|
let groups: ColGroup[] = [];
|
|
362
378
|
if (isTree) {
|
|
363
379
|
for (const k of ['columnGroups', 'resizable'] as const) {
|
|
364
|
-
if ((c as unknown as Record<string, unknown>)[k] !== undefined) env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `treeTable 不支持 ${k}
|
|
380
|
+
if ((c as unknown as Record<string, unknown>)[k] !== undefined) env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `treeTable 不支持 ${k}` });
|
|
365
381
|
}
|
|
366
382
|
} else {
|
|
367
383
|
// B1 D 组:columnGroups / resizable 与 virtual 可并用——表头是静态结构,虚拟行的格自带 data-kit-col + w-N 列类,
|
|
@@ -399,6 +415,8 @@ export function collection(
|
|
|
399
415
|
const steps = refs.map((r, i) => stepOf(ext[i]!, r.width));
|
|
400
416
|
const selectStep = select === 'none' ? 0 : X.scroll.selectStep;
|
|
401
417
|
const actionsStep = actionsStepOf(rowActions.length);
|
|
418
|
+
// 表头行层级:并存、或虚拟滚动 + 固定列时抬到 z-20(表体固定格 z-10,同层时 DOM 靠后者在上,会盖住表头)
|
|
419
|
+
const headAboveFixed = scroll && (combo || (virt !== null && ext.some((e) => e.fixed !== undefined)));
|
|
402
420
|
const plan = scroll ? stickyPlan(steps, ext, selectStep, actionsStep) : null;
|
|
403
421
|
const densityToolbar = toolbar.includes('density');
|
|
404
422
|
const bodyPy = pyTokens(dens.row);
|
|
@@ -420,12 +438,12 @@ export function collection(
|
|
|
420
438
|
if (!cell) return;
|
|
421
439
|
if (isTree && cell.action !== undefined) {
|
|
422
440
|
// 树表体是整体渲染的写死形状组件,单元格里没有可挂事件的字段实例
|
|
423
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'treeTable 不支持字段级 action
|
|
441
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'treeTable 不支持字段级 action(请改用 rowActions)' });
|
|
424
442
|
delete cell.action;
|
|
425
443
|
}
|
|
426
444
|
if (virt !== null && cell.action !== undefined) {
|
|
427
445
|
// 虚拟滚动的表体由 KitVirtualRows 整体渲染,单元格里没有可挂事件的字段实例
|
|
428
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'virtual 表格不支持字段级 action
|
|
446
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'virtual 表格不支持字段级 action(请改用 rowActions)' });
|
|
429
447
|
delete cell.action;
|
|
430
448
|
}
|
|
431
449
|
const al = alignClass(ex.align, scroll);
|
|
@@ -532,9 +550,9 @@ export function collection(
|
|
|
532
550
|
let expand: KitExpandIR | null = null;
|
|
533
551
|
const expandDecl = (c as { expand?: unknown }).expand;
|
|
534
552
|
if (isTree && expandDecl !== undefined) {
|
|
535
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.collection.expand`, message: 'treeTable 不支持 expand
|
|
553
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.collection.expand`, message: 'treeTable 不支持 expand 详情行(行本身就能展开子项)' });
|
|
536
554
|
} else if (expandDecl !== undefined && virt !== null) {
|
|
537
|
-
env.diagnostics.push({ code: 'KIT-TBL-005', path: `${env.path}.collection.expand`, message: 'virtual 表格不支持 expand
|
|
555
|
+
env.diagnostics.push({ code: 'KIT-TBL-005', path: `${env.path}.collection.expand`, message: 'virtual 表格不支持 expand(展开会改变行高,与固定行高的窗口定位冲突);需要行详情请改用行操作打开详情浮层,或用分页表格 + expand' });
|
|
538
556
|
} else if (expandDecl !== undefined) {
|
|
539
557
|
// Q 波 G5:view 形(详情字段)与 list 形(展开子表)二选一,解析与拒收归 collection-expand.ts
|
|
540
558
|
const parsedExpand = parseExpandDecl(expandDecl, env.path, { diagnostics: env.diagnostics, expandHosts: env.expandHosts, scroll });
|
|
@@ -572,15 +590,15 @@ export function collection(
|
|
|
572
590
|
const wrapBase = unbordered
|
|
573
591
|
? rawWrapBase.split(/\s+/).filter((t) => t !== '' && t !== 'border' && !t.startsWith('border-border')).join(' ')
|
|
574
592
|
: rawWrapBase;
|
|
575
|
-
const rcw = rowClassWhenOf(view, !isTree, env);
|
|
576
593
|
return {
|
|
577
594
|
kind: 'table',
|
|
578
595
|
tree: isTree ? treeOf(c, cells, env) : null,
|
|
579
|
-
wrapClass: mergeClass(join(wrapBase, densityToolbar && !scroll ? 'group/tbl' : '', virt !== null ? [KIT_TABLE_VIRTUAL.viewportBase, KIT_TABLE_VIRTUAL.viewportClass[virt.height]] : ''), view.class, view.replaceClass),
|
|
596
|
+
wrapClass: mergeClass(join(wrapBase, densityToolbar && !scroll ? 'group/tbl' : '', virt !== null ? [KIT_TABLE_VIRTUAL.viewportBase, KIT_TABLE_VIRTUAL.viewportClass[virt.height]] : combo ? KIT_TABLE_VIRTUAL.viewportBase : ''), view.class, view.replaceClass),
|
|
580
597
|
innerClass: scroll ? D.tableScrollInner : sticky ? D.tableInner.split(/\s+/).filter((t) => !t.startsWith('min-w-')).join(' ') : D.tableInner,
|
|
581
|
-
headClass: join(headBase, sticky || virt !== null ? STICKY_HEAD_CLASS : '', !scroll ? denseHead : ''),
|
|
598
|
+
headClass: join(headBase, headAboveFixed ? STICKY_HEAD_COMBO_CLASS : sticky || virt !== null ? STICKY_HEAD_CLASS : '', !scroll ? denseHead : ''),
|
|
582
599
|
head,
|
|
583
600
|
rowClass: mergeClass(join(rowBase, !scroll ? denseRow : ''), view.rowClass, view.replaceClass),
|
|
601
|
+
...(rowTone !== undefined ? { rowTone } : {}),
|
|
584
602
|
cells,
|
|
585
603
|
rowActions,
|
|
586
604
|
select,
|
|
@@ -588,14 +606,12 @@ export function collection(
|
|
|
588
606
|
actionsClass: actionsRow,
|
|
589
607
|
pager: isTree ? optionalPagerOf(c.page) : pagerOf(c.page),
|
|
590
608
|
sort: head.some((h) => h.sort !== undefined || h.filter !== undefined),
|
|
591
|
-
stickyHeader: sticky,
|
|
609
|
+
stickyHeader: sticky || combo,
|
|
592
610
|
stripeClass: striped ? D.tableRowStriped : '',
|
|
593
611
|
...(c.bordered !== undefined ? { bordered: c.bordered } : {}),
|
|
594
|
-
density,
|
|
595
612
|
expand,
|
|
596
613
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
597
614
|
...(scroll ? { scroll: true } : {}),
|
|
598
|
-
...(rcw.length > 0 ? { rowClassWhen: rcw } : {}),
|
|
599
615
|
...(toolbar.length > 0 ? { toolbar } : {}),
|
|
600
616
|
...(batch.length > 0 ? { batch } : {}),
|
|
601
617
|
...(batch.length > 0 ? { selectScope } : {}),
|
|
@@ -614,13 +630,13 @@ export function collection(
|
|
|
614
630
|
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
615
631
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
616
632
|
}
|
|
617
|
-
for (const k of ['
|
|
633
|
+
for (const k of ['striped', 'virtual', 'columnGroups', 'resizable'] as const) {
|
|
618
634
|
if ((c as unknown as Record<string, unknown>)[k] !== undefined) {
|
|
619
|
-
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `${k} 仅用于 table
|
|
635
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `${k} 仅用于 table 集合` });
|
|
620
636
|
}
|
|
621
637
|
}
|
|
622
638
|
refs.forEach((r, i) => {
|
|
623
|
-
if (r.resizable !== undefined) env.diagnostics.push({ code: 'KIT-TBL-004', path: `${env.path}.fields[${i}].resizable`, message: 'resizable 仅用于 table
|
|
639
|
+
if (r.resizable !== undefined) env.diagnostics.push({ code: 'KIT-TBL-004', path: `${env.path}.fields[${i}].resizable`, message: 'resizable 仅用于 table 集合的列' });
|
|
624
640
|
});
|
|
625
641
|
const innerArrange = view.arrange ?? (c.type === 'cards' ? KIT_OBJECT_DEFAULTS.cardsArrange : KIT_OBJECT_DEFAULTS.stackArrange);
|
|
626
642
|
// 卡内 / 块内的布局不再叠加 view.class(它属于列表容器)
|