soma-kit 0.1.11 → 0.1.13
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 +106 -112
- package/bin/soma-kit.mjs +32 -2
- package/bin/soma.mjs +22 -0
- package/package.json +14 -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 +929 -37
- package/spec/generated/kit-page.schema.json +1684 -161
- package/spec/kit-grammar.json +1176 -584
- package/spec/kit-grammar.schema.json +1971 -393
- package/src/app/app-config.ts +449 -347
- package/src/app/component-gate.ts +283 -28
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +176 -33
- package/src/app/define-kit-view.ts +104 -0
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +29 -6
- package/src/app/kit-view-context.ts +439 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +11 -3
- package/src/app/server.ts +530 -103
- 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 +667 -0
- package/src/base/action-busy.ts +103 -6
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +58 -0
- package/src/base/alert.ts +5 -3
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +99 -37
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +9 -1
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +49 -28
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +16 -11
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +10 -6
- package/src/base/context-menu.ts +10 -7
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +32 -18
- package/src/base/date.ts +135 -28
- package/src/base/delta.ts +72 -0
- package/src/base/divider.ts +2 -2
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +12 -5
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +35 -11
- 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 +56 -35
- package/src/base/loading-gate.ts +186 -0
- package/src/base/mentions.ts +7 -6
- package/src/base/menu-button.ts +28 -12
- package/src/base/menu-core.ts +41 -8
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +3 -3
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +3 -3
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +9 -5
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +48 -16
- package/src/base/popup.ts +143 -19
- package/src/base/portal-core.ts +4 -0
- 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 +14 -8
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +21 -4
- package/src/base/rating.ts +12 -7
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +27 -21
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +387 -49
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +10 -7
- package/src/base/switch.ts +11 -6
- package/src/base/tag-input.ts +20 -16
- package/src/base/tag.ts +68 -34
- package/src/base/text.ts +80 -18
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +18 -13
- package/src/base/tree-select.ts +21 -12
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +48 -14
- package/src/base/view-transition.ts +77 -0
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +23 -37
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +22 -5
- package/src/biz/checkout-page/shell.ts +4 -3
- 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 +5 -4
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +69 -22
- package/src/biz/link/shared.ts +127 -119
- package/src/biz/master-sub/compile.ts +127 -48
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +38 -50
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +32 -20
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/notification-center/shell.ts +6 -4
- 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/result-page/shell.ts +2 -1
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +48 -43
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +7 -5
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +97 -211
- package/src/biz/shared/compile-helpers.ts +98 -0
- package/src/biz/shared/coordinator.ts +472 -92
- package/src/biz/shared/index.ts +13 -2
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +209 -0
- package/src/biz/shared/pipes.ts +50 -31
- package/src/biz/shared/remove-wire.ts +14 -0
- package/src/biz/shared/runtime-hub.ts +226 -24
- package/src/biz/single-form/compile.ts +16 -37
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +72 -255
- package/src/biz/standard-crud/shell.ts +21 -99
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/step-form/shell.ts +5 -5
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +254 -25
- package/src/cli/kit-init.ts +227 -0
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -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 +761 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +570 -0
- package/src/compile/compile-page.ts +267 -76
- package/src/compile/component-candidates.ts +13 -2
- 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/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -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/remove-guard.ts +10 -7
- package/src/compile/styles.ts +63 -2
- package/src/compile/types.ts +31 -3
- package/src/compile/view-check.ts +284 -0
- package/src/data/amount-breakdown.ts +8 -3
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +3 -3
- package/src/data/assignment-picker.ts +92 -55
- package/src/data/async-result-panel.ts +111 -9
- package/src/data/breadcrumbs.ts +5 -4
- package/src/data/calendar.ts +24 -27
- package/src/data/carousel.ts +13 -8
- package/src/data/chart.ts +183 -44
- package/src/data/checklist.ts +20 -7
- package/src/data/code-view.ts +12 -6
- package/src/data/comment-thread.ts +7 -4
- package/src/data/confirm-dialog.ts +81 -18
- 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 +3 -3
- package/src/data/embed.ts +233 -30
- package/src/data/field-mapper.ts +35 -30
- package/src/data/flow-editor-contract.ts +8 -1
- package/src/data/flow-editor.ts +113 -108
- package/src/data/flow-node-options.ts +120 -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 +19 -19
- package/src/data/hero.ts +4 -3
- package/src/data/image-viewer.ts +27 -30
- package/src/data/index.ts +5 -2
- package/src/data/item-list.ts +48 -31
- package/src/data/kanban.ts +82 -52
- package/src/data/media-grid.ts +20 -20
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +47 -15
- package/src/data/mockup.ts +10 -6
- package/src/data/modal-dialog.ts +49 -25
- package/src/data/navbar.ts +12 -7
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +250 -0
- package/src/data/object-form.ts +1360 -666
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +80 -34
- package/src/data/permission-matrix.ts +52 -31
- package/src/data/permission-tree.ts +71 -44
- package/src/data/pricing-table.ts +30 -14
- package/src/data/prompt-dialog.ts +124 -194
- package/src/data/reaction-bar.ts +83 -92
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +26 -5
- package/src/data/record-picker.ts +104 -55
- 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 +8 -4
- package/src/data/rich-text.ts +61 -55
- package/src/data/row-editor.ts +362 -76
- package/src/data/rule-builder.ts +26 -20
- package/src/data/shape-util.ts +27 -9
- package/src/data/stat-group.ts +392 -109
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +24 -11
- package/src/data/steps.ts +10 -5
- package/src/data/survey.ts +27 -32
- package/src/data/system-switcher.ts +3 -3
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +19 -8
- package/src/data/tour-guide.ts +23 -30
- package/src/data/transfer.ts +62 -38
- package/src/data/tree-table.ts +152 -78
- package/src/data/tree.ts +49 -36
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +133 -82
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +26 -24
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +9 -7
- package/src/frames/shared.ts +36 -25
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +6 -6
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +4 -14
- package/src/frames/tabs-frame/wiring.ts +5 -8
- package/src/frames/top-main-frame.ts +3 -2
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +21 -5
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +250 -48
- package/src/generated/kit-grammar-runtime.ts +645 -397
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +84 -29
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +112 -84
- 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 +401 -104
- package/src/object-renderer/collection-table.ts +287 -45
- package/src/object-renderer/collection.ts +258 -104
- package/src/object-renderer/compile-data.ts +112 -102
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +38 -16
- package/src/object-renderer/display-checks.ts +4 -25
- package/src/object-renderer/emit-events.ts +224 -176
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +533 -151
- 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 +111 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +456 -89
- package/src/object-renderer/request-actions.ts +232 -249
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +319 -111
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +429 -94
- package/src/object-renderer/types.ts +204 -127
- package/src/object-renderer/view-binding.ts +393 -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 +165 -28
- package/src/page-target/target.ts +262 -51
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +210 -0
- package/src/recipes/control.ts +277 -0
- package/src/recipes/index.ts +312 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +240 -0
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +99 -0
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +88 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +99 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/confirm-decl.ts +118 -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 +15 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +180 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +407 -10
- package/src/theme/kit-theme.tpl +407 -10
- package/src/theme/nine-dim-structure.ts +247 -0
- package/src/theme/surface-layers.ts +101 -0
- package/src/theme/theme-tokens.ts +130 -84
- package/src/theme/theme-types.ts +103 -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/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
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
// 集合排布:table / cards / stack -> KitLayoutIR。table 用 div 栅格表,列在编译期展开。
|
|
2
2
|
|
|
3
|
+
import { kitRowActionsNarrowTier, kitRuleTableOf, kitTextWidthEm } from 'soma-foundation/kit-layout';
|
|
3
4
|
import { arrange, buildCell, type KitCellEnv } from './arrange';
|
|
4
5
|
import {
|
|
5
|
-
KIT_CLASS_DEFAULTS, KIT_CONTEXT_MENU,
|
|
6
|
-
type KitTableDensity,
|
|
6
|
+
KIT_CLASS_DEFAULTS, KIT_CONTEXT_MENU, KIT_OBJECT_DEFAULTS, KIT_SKELETON, KIT_TABLE_EXT, KIT_TABLE_VIRTUAL, KIT_TREE_TABLE, KIT_WIDTH,
|
|
7
7
|
} from './defaults';
|
|
8
8
|
import {
|
|
9
9
|
actionsStepOf, alignClass, columnFilterOf, columnMetaOf, parseBatch, parseColExt, parseColumnGroups, parseEditMode, parseSelect, parseSummary, parseToolbar,
|
|
10
|
-
plainRowClass, pyTokens, resolveResizable, scrollRowClass, stepOf, stickyPlan, type ColExt, type ColGroup,
|
|
10
|
+
narrowGridPlan, plainRowClass, pyTokens, resolveResizable, resolveStickyCombo, scrollRowClass, STICKY_HEAD_CLASS, STICKY_HEAD_COMBO_CLASS, stepOf, stickyPlan, treeColumnWeight, type ColExt, type ColGroup,
|
|
11
11
|
} from './collection-table';
|
|
12
12
|
import { expandListIR, parseExpandDecl } from './collection-expand';
|
|
13
13
|
import { checkClasses, mergeClass } from './merge-class';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { hintOf, nameSuggestion } from '../compile/hints';
|
|
15
|
+
import { checkRowPath } from './view-binding';
|
|
16
|
+
import { fixedSpan, gridColsClasses, gridLevels, partsOverflow, splitParts, weightedParts } from './parts';
|
|
17
|
+
|
|
18
|
+
/** 表头 / 行的栅格间距与横向内边距类(含容器查询变体 @lg:):带边框的整格网格模式里由单元格自己的内边距接管,整组去掉 */
|
|
19
|
+
const GRID_SPACING_TOKEN = /^(?:@[a-z0-9]+:)?(?:gap-\d+|gap-x-\d+|px-\d+)$/;
|
|
16
20
|
import type {
|
|
17
21
|
KitAction,
|
|
18
22
|
KitDiagnostic,
|
|
@@ -49,7 +53,8 @@ const STATE_DEFAULTS = { loading: '加载中…', empty: '暂无数据', error:
|
|
|
49
53
|
export const KIT_STATE_DEFAULT_TEXT = STATE_DEFAULTS;
|
|
50
54
|
|
|
51
55
|
function stateOf(c: KitCollectionStateDecl, env: KitCollectionEnv, path: string): KitStateIR | null {
|
|
52
|
-
|
|
56
|
+
// state: false 只关加载 / 空态;失败必须可见,仍发射三态组件并限定为 errorOnly 模式(文案取缺省,不画加载 / 空态)
|
|
57
|
+
if (c.state === false) return { ...STATE_DEFAULTS, skeleton: false, errorOnly: true };
|
|
53
58
|
const text = (key: 'loading' | 'empty' | 'error'): string => {
|
|
54
59
|
const v = c[key];
|
|
55
60
|
if (v === undefined) return STATE_DEFAULTS[key];
|
|
@@ -131,16 +136,22 @@ function treeOf(c: { tree?: KitTreeDecl }, cells: KitCell[], env: KitCollectionE
|
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
|
|
134
|
-
/** 表格粘性表头:表头钉在视口顶,放弃表内横滚(sticky 在滚动容器里不生效) */
|
|
135
|
-
const STICKY_HEAD_CLASS = 'sticky top-0 z-10 shadow-xs';
|
|
136
|
-
|
|
137
139
|
function resolveRowActions(ids: string[] | undefined, env: KitCollectionEnv): KitAction[] {
|
|
138
140
|
const out: KitAction[] = [];
|
|
139
|
-
(
|
|
141
|
+
const bad = (message: string, path: string): void => { env.diagnostics.push({ code: 'KIT-EVT-001', path, message }); };
|
|
142
|
+
if (ids !== undefined && !Array.isArray(ids)) {
|
|
143
|
+
bad('rowActions 必须是 @动作id 的列表', `${env.path}.collection.rowActions`);
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
(ids ?? []).forEach((raw: unknown, i) => {
|
|
147
|
+
if (typeof raw !== 'string' || raw === '') {
|
|
148
|
+
bad('rowActions 的项必须是 @动作id 字符串', `${env.path}.collection.rowActions[${i}]`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
140
151
|
const id = raw.startsWith('@') ? raw.slice(1) : raw; // 规格书写面 `@edit`
|
|
141
152
|
const act = env.actions.find((a) => a.id === id);
|
|
142
153
|
if (!act) {
|
|
143
|
-
env.diagnostics.push({ code: 'KIT-EVT-001', path: `${env.path}.collection.rowActions[${i}]`, message: `动作 @${id}
|
|
154
|
+
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
155
|
return;
|
|
145
156
|
}
|
|
146
157
|
out.push(act);
|
|
@@ -158,7 +169,7 @@ function resolveContextMenu(c: KitCollection, rowActions: readonly KitAction[],
|
|
|
158
169
|
if (raw === undefined) return [];
|
|
159
170
|
const at = `${env.path}.collection.contextMenu`;
|
|
160
171
|
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(' / ')}
|
|
172
|
+
env.diagnostics.push({ code: 'KIT-MENU-001', path: at, message: `contextMenu 只用于 ${KIT_CONTEXT_MENU.collections.join(' / ')} 集合` });
|
|
162
173
|
return [];
|
|
163
174
|
}
|
|
164
175
|
return resolveContextMenuItems(raw, rowActions, env.actions, at, env.diagnostics);
|
|
@@ -175,7 +186,7 @@ export function resolveContextMenuItems(
|
|
|
175
186
|
return [];
|
|
176
187
|
}
|
|
177
188
|
const out: KitAction[] = [];
|
|
178
|
-
if (raw.length > KIT_CONTEXT_MENU.maxItems) bad(`contextMenu 至多 ${KIT_CONTEXT_MENU.maxItems}
|
|
189
|
+
if (raw.length > KIT_CONTEXT_MENU.maxItems) bad(`contextMenu 至多 ${KIT_CONTEXT_MENU.maxItems} 项`);
|
|
179
190
|
raw.slice(0, KIT_CONTEXT_MENU.maxItems).forEach((item: unknown, i) => {
|
|
180
191
|
if (typeof item !== 'string' || item === '') {
|
|
181
192
|
bad('contextMenu 的项必须是 @动作id 字符串', `${at}[${i}]`);
|
|
@@ -210,24 +221,44 @@ function pagerOf(page: KitPageDecl | undefined): KitPagerIR | null {
|
|
|
210
221
|
}
|
|
211
222
|
|
|
212
223
|
const PAGE_MODES: readonly string[] = ['pager', 'more', 'infinite'];
|
|
213
|
-
|
|
224
|
+
const PAGE_DECL_KEYS: readonly string[] = ['size', 'sizes', 'jump', 'mode', 'layout', 'show_total'];
|
|
225
|
+
/** collection.page 的键与值核对(B9 / C11) */
|
|
214
226
|
function checkPageDecl(c: KitCollection, env: KitCollectionEnv): void {
|
|
215
|
-
const page = (c as { page?:
|
|
216
|
-
if (page === undefined || page === false
|
|
227
|
+
const page = (c as { page?: unknown }).page;
|
|
228
|
+
if (page === undefined || page === false) return;
|
|
217
229
|
const at = `${env.path}.collection.page`;
|
|
218
|
-
if (page
|
|
230
|
+
if (page === null || typeof page !== 'object' || Array.isArray(page)) {
|
|
231
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: at, message: 'collection.page 必须是 false 或对象 { size, sizes?, jump?, mode?, layout?, show_total? }' });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const rec = page as Record<string, unknown>;
|
|
235
|
+
for (const k of Object.keys(rec)) {
|
|
236
|
+
if (!PAGE_DECL_KEYS.includes(k)) {
|
|
237
|
+
env.diagnostics.push({ code: 'KIT-PAGE-001', path: `${at}.${k}`, message: `未知键 ${k}(${at} 允许:${PAGE_DECL_KEYS.join(' / ')})` });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (rec.size !== undefined && (typeof rec.size !== 'number' || !Number.isInteger(rec.size) || rec.size < 1)) {
|
|
241
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.size`, message: 'page.size 必须是正整数' });
|
|
242
|
+
}
|
|
243
|
+
if (rec.sizes !== undefined && (!Array.isArray(rec.sizes) || rec.sizes.length === 0 || rec.sizes.some((n) => typeof n !== 'number' || !Number.isInteger(n) || n < 1))) {
|
|
244
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.sizes`, message: 'page.sizes 必须是非空正整数数组' });
|
|
245
|
+
}
|
|
246
|
+
if (rec.jump !== undefined && typeof rec.jump !== 'boolean') {
|
|
247
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.jump`, message: 'page.jump 必须是布尔' });
|
|
248
|
+
}
|
|
249
|
+
if (rec.mode !== undefined && !PAGE_MODES.includes(rec.mode as string)) {
|
|
219
250
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.mode`, message: `page.mode 取 ${PAGE_MODES.join(' / ')}` });
|
|
220
|
-
delete
|
|
251
|
+
delete rec.mode;
|
|
221
252
|
}
|
|
222
|
-
if (
|
|
253
|
+
if (rec.mode !== undefined && rec.mode !== 'pager' && c.type === 'treeTable') {
|
|
223
254
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.mode`, message: 'treeTable 只支持 page.mode: pager' });
|
|
224
|
-
delete
|
|
255
|
+
delete rec.mode;
|
|
225
256
|
}
|
|
226
|
-
if (
|
|
257
|
+
if (rec.layout !== undefined && !['simple', 'pages', 'full'].includes(rec.layout as string)) {
|
|
227
258
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${at}.layout`, message: 'page.layout 取 simple / pages / full' });
|
|
228
|
-
delete
|
|
259
|
+
delete rec.layout;
|
|
229
260
|
}
|
|
230
|
-
if (
|
|
261
|
+
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
262
|
}
|
|
232
263
|
|
|
233
264
|
type VirtualTier = 'sm' | 'md' | 'lg';
|
|
@@ -241,23 +272,23 @@ function parseVirtual(c: KitCollection, env: KitCollectionEnv, isTree: boolean):
|
|
|
241
272
|
if (raw === undefined) return null;
|
|
242
273
|
const at = `${env.path}.collection.virtual`;
|
|
243
274
|
const bad = (message: string): void => { env.diagnostics.push({ code: 'KIT-OBJ-009', path: at, message }); };
|
|
244
|
-
if (isTree) { bad('treeTable 不支持 virtual(它有自己的 windowThreshold
|
|
275
|
+
if (isTree) { bad('treeTable 不支持 virtual(它有自己的 windowThreshold 分批)'); return null; }
|
|
245
276
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) { bad(`virtual 必须写成 { rowHeight: ${KIT_TABLE_VIRTUAL.tiers.join(' | ')} }`); return null; }
|
|
246
277
|
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
|
|
278
|
+
for (const k of Object.keys(r)) if (!KIT_TABLE_VIRTUAL.keys.includes(k)) bad(`virtual 没有键 ${k}(允许:${KIT_TABLE_VIRTUAL.keys.join(' / ')})`);
|
|
279
|
+
if (r.rowHeight === undefined) { bad('virtual 必须显式给 rowHeight 档位名(sm / md / lg);没有固定行高就不虚拟化'); return null; }
|
|
249
280
|
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)}
|
|
281
|
+
bad(`virtual.rowHeight 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')} 档位名(不接受像素数字),收到 ${JSON.stringify(r.rowHeight)}`);
|
|
251
282
|
return null;
|
|
252
283
|
}
|
|
253
284
|
let height: VirtualTier = KIT_TABLE_VIRTUAL.viewportDefault;
|
|
254
285
|
if (r.height !== undefined) {
|
|
255
286
|
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)}
|
|
287
|
+
else bad(`virtual.height 只许 ${KIT_TABLE_VIRTUAL.tiers.join(' / ')},收到 ${JSON.stringify(r.height)}`);
|
|
257
288
|
}
|
|
258
289
|
const page = (c as { page?: KitPageDecl }).page;
|
|
259
290
|
if (page !== undefined && page !== false && typeof page === 'object' && page.mode === 'infinite') {
|
|
260
|
-
bad('virtual 不与 page.mode: infinite
|
|
291
|
+
bad('virtual 不与 page.mode: infinite 并用(哨兵恒在视口内,会一路加载到底)');
|
|
261
292
|
(page as { mode?: string }).mode = 'more';
|
|
262
293
|
}
|
|
263
294
|
return { rowHeight: r.rowHeight as VirtualTier, height };
|
|
@@ -268,35 +299,10 @@ function optionalPagerOf(page: KitPageDecl | undefined): KitPagerIR | null {
|
|
|
268
299
|
return page === undefined || page === false ? null : pagerOf(page);
|
|
269
300
|
}
|
|
270
301
|
|
|
271
|
-
/**
|
|
272
|
-
function
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const path = `${env.path}.rowClassWhen`;
|
|
276
|
-
if (!isTable) {
|
|
277
|
-
env.diagnostics.push({ code: 'KIT-OBJ-009', path, message: 'rowClassWhen 只用于 collection: table' });
|
|
278
|
-
return [];
|
|
279
|
-
}
|
|
280
|
-
const max = (KIT_FORM_LINKAGE as unknown as { rowClassWhen: { maxItems: number } }).rowClassWhen.maxItems;
|
|
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;
|
|
302
|
+
/** 行样式档位 view.list.rowTone: row.<字段>:纯行路径;所有集合(table 含树表 / 虚拟滚动表、cards、stack)都支持,同一套 KIT-ROW-003 检查。返回字段名 */
|
|
303
|
+
function rowToneOf(view: KitViewForm, env: KitCellEnv): string | undefined {
|
|
304
|
+
if (view.rowTone === undefined) return undefined;
|
|
305
|
+
return checkRowPath(view.rowTone, `${env.path}.rowTone`, 'rowTone', env.diagnostics, env.schema);
|
|
300
306
|
}
|
|
301
307
|
|
|
302
308
|
function styleChecks(view: KitViewForm, c: { class?: string }, env: KitCellEnv): void {
|
|
@@ -306,6 +312,56 @@ function styleChecks(view: KitViewForm, c: { class?: string }, env: KitCellEnv):
|
|
|
306
312
|
env.diagnostics.push(...checkClasses(view.rowClass, `${env.path}.rowClass`));
|
|
307
313
|
}
|
|
308
314
|
|
|
315
|
+
/** 窄档留在行内的行操作(主操作优先,没有取第一个非「更多」项,与 splitRowActions 同一选法)的文案宽(em);没有行操作为 undefined */
|
|
316
|
+
function keptInlineActionEm(actions: ReadonlyArray<{ name: string; tone?: string; more?: boolean }>): number | undefined {
|
|
317
|
+
const plain = actions.filter((a) => a.more !== true);
|
|
318
|
+
const kept = plain.find((a) => a.tone === 'primary') ?? plain[0];
|
|
319
|
+
return kept === undefined ? undefined : kitTextWidthEm(kept.name);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** 日期类列内容宽(em,真源 narrowGrid.dateEms 按类型给);非日期类型为 0 */
|
|
323
|
+
function dateContentEm(type: string | undefined): number {
|
|
324
|
+
if (type === undefined || !KIT_TREE_TABLE.columnWeightRules.dateTypes.includes(type)) return 0;
|
|
325
|
+
return KIT_TABLE_EXT.narrowGrid.dateEms[type] ?? 0;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** 枚举 / 标签列最长选项文案宽(em;非标签列或没有选项为 0) */
|
|
329
|
+
function tagLabelEm(cell: KitCell | undefined): number {
|
|
330
|
+
if (cell === undefined || cell.component !== 'Tag') return 0;
|
|
331
|
+
const options = Array.isArray(cell.props.options) ? (cell.props.options as Array<{ label?: unknown; value?: unknown }>) : [];
|
|
332
|
+
return options.reduce((m, o) => Math.max(m, kitTextWidthEm(typeof o.label === 'string' && o.label !== '' ? o.label : typeof o.value === 'string' ? o.value : '')), 0);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 窄容器档贴右固定操作格的类:classDefaults.tableNarrowStickyEnd + 抵消行纵向内边距(py-N → -my-N 再补回 py-N,内容仍居中),
|
|
337
|
+
* 整串加 `@max-<档>:` 前缀,窄档线以上(含)不生效、宽表输出不变。
|
|
338
|
+
*/
|
|
339
|
+
export function narrowStickyEnd(rowPy: readonly string[], tier: string): string {
|
|
340
|
+
const pad = rowPy.flatMap((t) => {
|
|
341
|
+
const m = /^((?:[^:]+:)*)py-(.+)$/.exec(t);
|
|
342
|
+
return m === null ? [] : [`${m[1]}-my-${m[2]}`, t];
|
|
343
|
+
});
|
|
344
|
+
return [...KIT_CLASS_DEFAULTS.tableNarrowStickyEnd.split(/\s+/), ...KIT_CLASS_DEFAULTS.tableEdgeRight.split(/\s+/), ...pad].filter((t) => t !== '').map((t) => `@max-${tier}:${t}`).join(' ');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 表壳内层类:列轨最小宽之和(narrowGrid.innerMinUnits)超过默认窄最小宽时,把内层最小宽抬到它,容器放不下由外壳(overflow-x-auto)横向滚动;
|
|
349
|
+
* 窄档线以上(含)恢复默认宽档最小宽。放得下(和不超过默认窄最小宽)或不适用时原样返回默认类串,宽表输出不变。
|
|
350
|
+
*/
|
|
351
|
+
export function narrowInnerClass(base: string, plan: { innerMinUnits: number } | null, tier: string): string {
|
|
352
|
+
if (plan === null) return base;
|
|
353
|
+
const toks = base.split(/\s+/).filter((t) => t !== '');
|
|
354
|
+
const narrowMin = toks.map((t) => /^min-w-(\d+)$/.exec(t)).find((m) => m !== null);
|
|
355
|
+
const wideMin = toks.map((t) => /^(@[a-z0-9]+):min-w-(\d+)$/.exec(t)).find((m) => m !== null);
|
|
356
|
+
if (narrowMin === undefined || narrowMin === null || wideMin === undefined || wideMin === null) return base;
|
|
357
|
+
const nMin = Number(narrowMin[1]);
|
|
358
|
+
const wMin = Number(wideMin[2]);
|
|
359
|
+
const need = plan.innerMinUnits;
|
|
360
|
+
if (need <= nMin) return base;
|
|
361
|
+
const rest = toks.filter((t) => !/^(?:@[a-z0-9]+:)?min-w-\d+$/.test(t));
|
|
362
|
+
return [...rest, `min-w-${need}`, `${wideMin[1]}:min-w-${Math.max(wMin, need)}`, ...(need > wMin ? [`@${tier}:min-w-${wMin}`] : [])].join(' ');
|
|
363
|
+
}
|
|
364
|
+
|
|
309
365
|
export function collection(
|
|
310
366
|
c: KitCollection,
|
|
311
367
|
refs: KitFieldRef[],
|
|
@@ -317,7 +373,12 @@ export function collection(
|
|
|
317
373
|
const contextMenu = resolveContextMenu(c, rowActions, env);
|
|
318
374
|
const ctxMenuIr = contextMenu.length > 0 ? { contextMenu } : {};
|
|
319
375
|
checkPageDecl(c, env);
|
|
320
|
-
|
|
376
|
+
// collection.count:标题旁「共 N 条」的开关(缺省自动显示;只有 false 有意义);非布尔报 KIT-OBJ-009 并忽略
|
|
377
|
+
const rawCount = (c as { count?: unknown }).count;
|
|
378
|
+
if (rawCount !== undefined && typeof rawCount !== 'boolean') {
|
|
379
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.count`, message: 'collection.count 必须是布尔(false 关闭标题旁的「共 N 条」)' });
|
|
380
|
+
}
|
|
381
|
+
const countIr = rawCount === false ? { showCount: false } : {};
|
|
321
382
|
|
|
322
383
|
if (c.type === 'table' || c.type === 'treeTable') {
|
|
323
384
|
// 树表不是另一套表格:treeTable = table + tree 参数(`type: table` 带 `tree:` 等价),同一条列 / 表头 / 密度 / 三态 / 分页路径,只有表体换成 KitTreeTable
|
|
@@ -326,32 +387,44 @@ export function collection(
|
|
|
326
387
|
// 分隔线项只属于单对象排布;列里写了丢弃
|
|
327
388
|
const kept = refs.filter((r, i) => {
|
|
328
389
|
if (r.divider === undefined) return true;
|
|
329
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}]`, message: '
|
|
390
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}]`, message: '分隔线不能写在表格的列里' });
|
|
330
391
|
return false;
|
|
331
392
|
});
|
|
332
393
|
refs = kept;
|
|
333
394
|
const { mode: select, scope: selectScope } = parseSelect(c.select, (KIT_OBJECT_DEFAULTS.list.collection as { select: 'none' | 'single' | 'multi' }).select, env);
|
|
334
395
|
const virt = parseVirtual(c, env, isTree);
|
|
396
|
+
const rowTone = rowToneOf(view, env);
|
|
335
397
|
// 虚拟滚动自带竖向滚动视口:表头恒吸顶,固定列与吸顶同在一个滚动容器里,不再互斥(所以显式 stickyHeader 在 virtual 下不单独算)
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
398
|
+
const stickyReq = c.stickyHeader === true && virt === null;
|
|
399
|
+
// Z5:显式 stickyHeader + 固定列 + 表格自身限高(view.class 有 h-* / max-h-*)→ 外壳同时横滚与纵滚,两者并存,不走互斥
|
|
400
|
+
// 整体替换类(replaceClass)生效时外壳类整串被换掉,并存路径加的纵向滚动类会丢:按不限高处理(与旧互斥一致,报 KIT-OBJ-009)
|
|
401
|
+
const rawReplace: unknown = view.replaceClass;
|
|
402
|
+
const classReplaced = (typeof rawReplace === 'string' && rawReplace.trim() !== '') || rawReplace === true;
|
|
403
|
+
const comboWant = resolveStickyCombo({
|
|
404
|
+
stickyHeader: stickyReq, isTree, virtual: virt !== null,
|
|
405
|
+
hasFixed: refs.some((r) => r.fixed !== undefined && (KIT_TABLE_EXT.scroll.fixedValues as readonly string[]).includes(r.fixed)),
|
|
406
|
+
viewClass: classReplaced ? undefined : view.class,
|
|
407
|
+
});
|
|
408
|
+
let sticky = stickyReq && !comboWant;
|
|
342
409
|
if (c.striped !== undefined && typeof c.striped !== 'boolean') {
|
|
343
410
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.striped`, message: 'striped 必须是布尔' });
|
|
344
411
|
}
|
|
345
412
|
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
346
413
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
347
414
|
}
|
|
348
|
-
const dens =
|
|
415
|
+
const dens = { head: D.tableHead, row: D.tableRow };
|
|
349
416
|
const striped = c.striped === true;
|
|
350
417
|
const bordered = c.bordered === true;
|
|
351
418
|
const unbordered = c.bordered === false;
|
|
352
419
|
|
|
353
420
|
// ---- M 波 G2:列模型 / 滚动模式 / 工具栏
|
|
354
|
-
|
|
421
|
+
// 树表承载缩进 / 展开钮的列(tree.indentField,缺省首列)不右对齐;与 treeOf 的 indentField 取值同规则
|
|
422
|
+
const treeIndent = isTree ? (c as { tree?: { indentField?: unknown } }).tree?.indentField : undefined;
|
|
423
|
+
const indentName = typeof treeIndent === 'string' && refs.some((r) => r.name === treeIndent) ? treeIndent : refs[0]?.name;
|
|
424
|
+
const ext = parseColExt(refs, env, { isTree, sticky, ...(indentName !== undefined ? { indentName } : {}) });
|
|
425
|
+
// 固定列全被丢弃(不连续等)时没有可并存的东西,退回单独吸顶
|
|
426
|
+
const combo = comboWant && ext.some((e) => e.fixed !== undefined);
|
|
427
|
+
if (comboWant && !combo) sticky = stickyReq;
|
|
355
428
|
const toolbar = parseToolbar((c as { toolbar?: unknown }).toolbar, env, isTree);
|
|
356
429
|
// ---- Q 波 G4:多级表头 / 列宽拖拽(都视同进入滚动模式;treeTable、virtual、stickyHeader 下忽略并报码)
|
|
357
430
|
const rawGroups = (c as { columnGroups?: unknown }).columnGroups;
|
|
@@ -361,7 +434,7 @@ export function collection(
|
|
|
361
434
|
let groups: ColGroup[] = [];
|
|
362
435
|
if (isTree) {
|
|
363
436
|
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}
|
|
437
|
+
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
438
|
}
|
|
366
439
|
} else {
|
|
367
440
|
// B1 D 组:columnGroups / resizable 与 virtual 可并用——表头是静态结构,虚拟行的格自带 data-kit-col + w-N 列类,
|
|
@@ -385,20 +458,38 @@ export function collection(
|
|
|
385
458
|
|
|
386
459
|
const fixed = KIT_WIDTH.tableFixedParts;
|
|
387
460
|
const selectParts = select === 'none' ? 0 : fixed.select;
|
|
388
|
-
const actionParts = rowActions.length > 0 ? fixed.actions : 0;
|
|
389
|
-
const avail = KIT_WIDTH.totalParts - selectParts - actionParts;
|
|
390
461
|
const widths = refs.map((r) => r.width);
|
|
391
|
-
|
|
462
|
+
// 操作列份数:行内直接显示的按钮(不含 more: true 恒折叠项)达到真源阈值时加宽,免得三个文字按钮挤成一团;
|
|
463
|
+
// 页面显式列宽加宽后放不下(原宽放得下)时退回原宽,不让存量页面因此报超宽
|
|
464
|
+
// 「更多」触发钮也占一格:行内平铺(不含 more: true、至多 DEFAULT 上限)+ 一个「更多」入口达到阈值时就加宽,操作列按内容放得下、不折行
|
|
465
|
+
const nonMore = rowActions.filter((a) => a.more !== true).length;
|
|
466
|
+
const inlineMax = kitRuleTableOf().rowActions.maxInline.wide;
|
|
467
|
+
const hasMoreEntry = nonMore > inlineMax || nonMore < rowActions.length;
|
|
468
|
+
const inlineActions = Math.min(nonMore, inlineMax) + (hasMoreEntry ? 1 : 0);
|
|
469
|
+
const wideWanted = inlineActions >= fixed.actionsWideFromInline;
|
|
470
|
+
const baseActionParts = rowActions.length > 0 ? fixed.actions : 0;
|
|
471
|
+
const wideFits = !partsOverflow(widths, KIT_WIDTH.totalParts - selectParts - fixed.actionsWide);
|
|
472
|
+
const actionParts = rowActions.length > 0 && wideWanted && (wideFits || partsOverflow(widths, KIT_WIDTH.totalParts - selectParts - baseActionParts))
|
|
473
|
+
? fixed.actionsWide
|
|
474
|
+
: baseActionParts;
|
|
475
|
+
const avail = KIT_WIDTH.totalParts - selectParts - actionParts;
|
|
476
|
+
// 树表的 width 是权重(不要求和为 12、不报超出):没写的列按内容类型取默认权重,按比例分满可用份数
|
|
477
|
+
const treeWeights = isTree
|
|
478
|
+
? refs.map((r) => (typeof r.width === 'number' && r.width > 0 ? r.width : treeColumnWeight(r.name, env.schema[r.name]?.type, Array.isArray(env.schema[r.name]?.options))))
|
|
479
|
+
: null;
|
|
480
|
+
if (!scroll && treeWeights === null && partsOverflow(widths, avail)) {
|
|
392
481
|
env.diagnostics.push({
|
|
393
482
|
code: 'KIT-OBJ-004',
|
|
394
483
|
path: `${env.path}.collection`,
|
|
395
484
|
message: `列宽份数超出可用 ${avail} 份(总 ${KIT_WIDTH.totalParts},选择列 ${selectParts},操作列 ${actionParts})`,
|
|
396
485
|
});
|
|
397
486
|
}
|
|
398
|
-
const parts = scroll ? refs.map(() => 1) : splitParts(widths, avail);
|
|
487
|
+
const parts = scroll ? refs.map(() => 1) : treeWeights !== null ? weightedParts(treeWeights, avail) : splitParts(widths, avail);
|
|
399
488
|
const steps = refs.map((r, i) => stepOf(ext[i]!, r.width));
|
|
400
489
|
const selectStep = select === 'none' ? 0 : X.scroll.selectStep;
|
|
401
490
|
const actionsStep = actionsStepOf(rowActions.length);
|
|
491
|
+
// 表头行层级:并存、或虚拟滚动 + 固定列时抬到 z-20(表体固定格 z-10,同层时 DOM 靠后者在上,会盖住表头)
|
|
492
|
+
const headAboveFixed = scroll && (combo || (virt !== null && ext.some((e) => e.fixed !== undefined)));
|
|
402
493
|
const plan = scroll ? stickyPlan(steps, ext, selectStep, actionsStep) : null;
|
|
403
494
|
const densityToolbar = toolbar.includes('density');
|
|
404
495
|
const bodyPy = pyTokens(dens.row);
|
|
@@ -408,6 +499,10 @@ export function collection(
|
|
|
408
499
|
const stripeSticky = striped ? D.tableCellStickyStriped : '';
|
|
409
500
|
const join = (...xs: Array<string | readonly string[]>): string => xs.flatMap((x) => (typeof x === 'string' ? [x] : [...x])).filter((x) => x !== '').join(' ');
|
|
410
501
|
|
|
502
|
+
// 窄容器栅格列轨(非滚动、非树表、非吸顶表):容器低于 design 窄档线时行换成横排弹性行(见 collection-table.narrowGridPlan)
|
|
503
|
+
const narrowGridOn = !scroll && !isTree && !sticky;
|
|
504
|
+
const narrowTier = narrowGridOn ? kitRowActionsNarrowTier() : '';
|
|
505
|
+
const keptParts: number[] = [];
|
|
411
506
|
const cells: KitCell[] = [];
|
|
412
507
|
const head: KitHeadCell[] = [];
|
|
413
508
|
const colExt: ColExt[] = [];
|
|
@@ -420,15 +515,19 @@ export function collection(
|
|
|
420
515
|
if (!cell) return;
|
|
421
516
|
if (isTree && cell.action !== undefined) {
|
|
422
517
|
// 树表体是整体渲染的写死形状组件,单元格里没有可挂事件的字段实例
|
|
423
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'treeTable 不支持字段级 action
|
|
518
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'treeTable 不支持字段级 action(请改用 rowActions)' });
|
|
424
519
|
delete cell.action;
|
|
425
520
|
}
|
|
426
521
|
if (virt !== null && cell.action !== undefined) {
|
|
427
522
|
// 虚拟滚动的表体由 KitVirtualRows 整体渲染,单元格里没有可挂事件的字段实例
|
|
428
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'virtual 表格不支持字段级 action
|
|
523
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.fields[${i}].action`, message: 'virtual 表格不支持字段级 action(请改用 rowActions)' });
|
|
429
524
|
delete cell.action;
|
|
430
525
|
}
|
|
431
|
-
|
|
526
|
+
// 树表数值列(右对齐的非缩进列)加等宽数字,表头同款
|
|
527
|
+
// 右对齐的数值列与其后一列之间留 24px:栅格间距 16px + 列尾内边距 8px(pe-2);滚动模式格自带左右内边距、完整网格线格自带 px-3,不再加;
|
|
528
|
+
// 最后一个数据列且没有操作列时后面没有邻列,也不加(数字贴齐表格右缘)
|
|
529
|
+
const trailsNext = !scroll && !bordered && ex.align === 'end' && (i < refs.length - 1 || rowActions.length > 0);
|
|
530
|
+
const al = join(alignClass(ex.align, scroll), isTree && ex.align === 'end' ? 'tabular-nums' : '', trailsNext ? 'pe-2' : '');
|
|
432
531
|
const stk = plan !== null && plan.offset[i] !== '';
|
|
433
532
|
const edge = plan === null ? '' : plan.edgeLeft === i ? D.tableEdgeLeft : plan.edgeRight === i ? D.tableEdgeRight : '';
|
|
434
533
|
const gridBorderCell = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...bodyPy, ...denseRow] : [];
|
|
@@ -455,6 +554,7 @@ export function collection(
|
|
|
455
554
|
}
|
|
456
555
|
}
|
|
457
556
|
cells.push(cell);
|
|
557
|
+
keptParts.push(p);
|
|
458
558
|
colExt.push(ex);
|
|
459
559
|
// 固定列组:sticky / 偏移 / 边缘类挂在组块上(叶子格不再各自 sticky);左固定取首列偏移,右固定取末列偏移
|
|
460
560
|
const gi = groupOfName.get(r.name) ?? -1;
|
|
@@ -468,15 +568,10 @@ export function collection(
|
|
|
468
568
|
}
|
|
469
569
|
}
|
|
470
570
|
const headGridBorder = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...headPy, ...denseHead] : [];
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
: bordered
|
|
474
|
-
? 'not-last:border-e not-last:border-border-subtle'
|
|
475
|
-
: scroll
|
|
476
|
-
? 'not-last:border-e not-last:border-border-divider'
|
|
477
|
-
: 'not-last:border-e not-last:border-border-divider not-last:pe-3';
|
|
571
|
+
// 表头列间竖分隔线只在显式 bordered: true(完整网格线)时有;默认表头只有下分隔线(2026-11-17 评审 S6)
|
|
572
|
+
const headTick = bordered ? 'not-last:border-e not-last:border-border-subtle' : '';
|
|
478
573
|
const headCls = join(
|
|
479
|
-
widthCls, 'truncate', al,
|
|
574
|
+
widthCls, 'truncate', 'whitespace-nowrap', al,
|
|
480
575
|
scroll ? [...headPy, ...denseHead] : headGridBorder,
|
|
481
576
|
headTick,
|
|
482
577
|
stk && gi < 0 ? [D.tableHeadCellSticky, plan!.offset[i]!, edge] : '',
|
|
@@ -485,6 +580,7 @@ export function collection(
|
|
|
485
580
|
const h: KitHeadCell = {
|
|
486
581
|
label: cell.label, class: headCls, col: cell.field, ...(r.sortable === true ? { sort: cell.field } : {}),
|
|
487
582
|
...(gi >= 0 ? { group: gi } : {}), ...(ex.resizable === true ? { resizable: true } : {}),
|
|
583
|
+
...(cell.helpTip !== undefined ? { help: cell.helpTip } : {}),
|
|
488
584
|
};
|
|
489
585
|
if (ex.filter !== undefined) {
|
|
490
586
|
const filter = columnFilterOf(ex.filter, cell, schemaField?.type ?? '', env, `${env.path}.fields[${i}].columnFilter`);
|
|
@@ -497,6 +593,25 @@ export function collection(
|
|
|
497
593
|
stk ? [D.tableHeadCellSticky, plan!.offset[i]!, edge] : '',
|
|
498
594
|
));
|
|
499
595
|
});
|
|
596
|
+
const narrowGrid = narrowGridOn && head.length > 0
|
|
597
|
+
? narrowGridPlan({
|
|
598
|
+
widthEms: head.map((h) => kitTextWidthEm(h.label)),
|
|
599
|
+
// 枚举 / 标签列的格子内容是带内边距的药丸,最短也要放得下最长的那个选项文案,否则药丸在窄格里竖着折成一字一行
|
|
600
|
+
tagEms: head.map((_, i) => tagLabelEm(cells[i])),
|
|
601
|
+
// 日期类列(schema 类型属于 kit-grammar#treeTable.columnWeightRules.dateTypes)最小宽按内容(真源 narrowGrid.dateEms)
|
|
602
|
+
dateEms: head.map((_, i) => dateContentEm(env.schema[cells[i]?.field ?? '']?.type)),
|
|
603
|
+
actionLabelEm: keptInlineActionEm(rowActions),
|
|
604
|
+
parts: keptParts, hasSelect: selectParts > 0, actionCount: actionParts > 0 ? rowActions.length : 0, tier: narrowTier,
|
|
605
|
+
})
|
|
606
|
+
: null;
|
|
607
|
+
if (narrowGrid !== null) {
|
|
608
|
+
// 各数据列的窄档类并到行格、表头格与汇总格上(三处同一套列宽)
|
|
609
|
+
narrowGrid.cellClasses.forEach((cls, i) => {
|
|
610
|
+
if (cells[i] !== undefined) cells[i]!.cellClass = join(cells[i]!.cellClass, cls);
|
|
611
|
+
if (head[i] !== undefined) head[i]!.class = join(head[i]!.class, cls);
|
|
612
|
+
if (summaryCellClasses[i] !== undefined) summaryCellClasses[i] = join(summaryCellClasses[i]!, cls);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
500
615
|
const batch = parseBatch((c as { batchActions?: unknown }).batchActions, env, { isTree, mode: select });
|
|
501
616
|
const summary = parseSummary((c as { summary?: KitSummaryDecl }).summary, cells, env, { isTree });
|
|
502
617
|
const anyEditable = colExt.some((e) => e.editable);
|
|
@@ -532,9 +647,9 @@ export function collection(
|
|
|
532
647
|
let expand: KitExpandIR | null = null;
|
|
533
648
|
const expandDecl = (c as { expand?: unknown }).expand;
|
|
534
649
|
if (isTree && expandDecl !== undefined) {
|
|
535
|
-
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.collection.expand`, message: 'treeTable 不支持 expand
|
|
650
|
+
env.diagnostics.push({ code: 'KIT-OBJ-010', path: `${env.path}.collection.expand`, message: 'treeTable 不支持 expand 详情行(行本身就能展开子项)' });
|
|
536
651
|
} else if (expandDecl !== undefined && virt !== null) {
|
|
537
|
-
env.diagnostics.push({ code: 'KIT-TBL-005', path: `${env.path}.collection.expand`, message: 'virtual 表格不支持 expand
|
|
652
|
+
env.diagnostics.push({ code: 'KIT-TBL-005', path: `${env.path}.collection.expand`, message: 'virtual 表格不支持 expand(展开会改变行高,与固定行高的窗口定位冲突);需要行详情请改用行操作打开详情浮层,或用分页表格 + expand' });
|
|
538
653
|
} else if (expandDecl !== undefined) {
|
|
539
654
|
// Q 波 G5:view 形(详情字段)与 list 形(展开子表)二选一,解析与拒收归 collection-expand.ts
|
|
540
655
|
const parsedExpand = parseExpandDecl(expandDecl, env.path, { diagnostics: env.diagnostics, expandHosts: env.expandHosts, scroll });
|
|
@@ -546,23 +661,24 @@ export function collection(
|
|
|
546
661
|
}
|
|
547
662
|
// 选择列 / 操作列:滚动模式下定宽,有固定列时 sticky(行里底色随行,表头里随表头)
|
|
548
663
|
const lead = (headRow: boolean): string => join(
|
|
549
|
-
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(selectParts), ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
550
|
-
|
|
664
|
+
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(selectParts), narrowGrid?.selectClass ?? '', ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
665
|
+
bordered ? (headRow ? 'not-last:border-e not-last:border-border-subtle' : 'not-last:border-e not-last:border-border-divider') : '',
|
|
551
666
|
plan !== null && plan.selectSticky ? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'left-0'] : '',
|
|
552
667
|
);
|
|
553
668
|
const tail = (headRow: boolean): string => join(
|
|
554
|
-
scroll ? [D.tableScrollCell, `w-${actionsStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(actionParts), ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
669
|
+
scroll ? [D.tableScrollCell, `w-${actionsStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(actionParts), narrowGrid?.actionsClass ?? '', ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
555
670
|
plan !== null && plan.actionsSticky
|
|
556
671
|
? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'right-0', plan.edgeRight === -1 ? D.tableEdgeRight : '']
|
|
557
|
-
: '',
|
|
672
|
+
: '', // 窄容器档:栅格表在表壳内横滚时操作格贴右固定(不随数据列滚走),底色随行;行的纵向内边距用负外边距抵消,让格撑满行高
|
|
673
|
+
narrowGrid !== null && actionParts > 0 ? narrowStickyEnd(bordered ? [] : pyTokens(headRow ? dens.head : dens.row), narrowTier) : '',
|
|
558
674
|
);
|
|
559
675
|
const selectRow = selectParts > 0 ? lead(false) : '';
|
|
560
676
|
const actionsRow = actionParts > 0 ? tail(false) : '';
|
|
561
677
|
const selectHead = selectParts > 0 ? lead(true) : '';
|
|
562
678
|
const actionsHead = actionParts > 0 ? tail(true) : '';
|
|
563
|
-
const gridBorderedRow = (cls: string): string => cls.split(/\s+/).filter((t) => t !== '' && t
|
|
564
|
-
const rowBase = scroll ? scrollRowClass(dens.row) : bordered ? gridBorderedRow(dens.row) : dens.row;
|
|
565
|
-
const headBase = scroll ? scrollRowClass(dens.head) : bordered ? gridBorderedRow(dens.head) : dens.head;
|
|
679
|
+
const gridBorderedRow = (cls: string): string => cls.split(/\s+/).filter((t) => t !== '' && !GRID_SPACING_TOKEN.test(t) && t !== 'items-center' && !/^py-/.test(t)).concat(['gap-0', 'items-stretch']).join(' ');
|
|
680
|
+
const rowBase = join(scroll ? scrollRowClass(dens.row) : bordered ? gridBorderedRow(dens.row) : dens.row, narrowGrid?.rowClass ?? '');
|
|
681
|
+
const headBase = join(scroll ? scrollRowClass(dens.head) : bordered ? gridBorderedRow(dens.head) : dens.head, narrowGrid?.rowClass ?? '');
|
|
566
682
|
const rawSummaryRow = D.tableSummaryRow;
|
|
567
683
|
const summaryRowBase = unbordered
|
|
568
684
|
? rawSummaryRow.split(/\s+/).filter((t) => t !== "" && t !== "border-t" && !t.startsWith("border-border")).join(" ")
|
|
@@ -572,37 +688,37 @@ export function collection(
|
|
|
572
688
|
const wrapBase = unbordered
|
|
573
689
|
? rawWrapBase.split(/\s+/).filter((t) => t !== '' && t !== 'border' && !t.startsWith('border-border')).join(' ')
|
|
574
690
|
: rawWrapBase;
|
|
575
|
-
const rcw = rowClassWhenOf(view, !isTree, env);
|
|
576
691
|
return {
|
|
577
692
|
kind: 'table',
|
|
578
693
|
tree: isTree ? treeOf(c, cells, env) : null,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
694
|
+
// 表壳恒是查询容器(普通 / 滚动 / 吸顶 / 虚拟 / 树表同一条):行操作窄档折叠、窄栅格的 `@max-<档>:` 变体都依赖最近的查询容器
|
|
695
|
+
wrapClass: mergeClass(join(/(^|\s)@container(\/\S+)?(\s|$)/.test(wrapBase) ? '' : '@container', wrapBase, (densityToolbar && !scroll) || (narrowGrid !== null && actionParts > 0) ? 'group/tbl' : '', virt !== null ? [KIT_TABLE_VIRTUAL.viewportBase, KIT_TABLE_VIRTUAL.viewportClass[virt.height]] : combo ? KIT_TABLE_VIRTUAL.viewportBase : ''), view.class, view.replaceClass),
|
|
696
|
+
innerClass: scroll ? D.tableScrollInner : sticky ? D.tableInner.split(/\s+/).filter((t) => !/^(?:@[a-z0-9]+:)?min-w-/.test(t)).join(' ') : narrowInnerClass(D.tableInner, narrowGrid, narrowTier),
|
|
697
|
+
headClass: join(headBase, headAboveFixed ? STICKY_HEAD_COMBO_CLASS : sticky || virt !== null ? STICKY_HEAD_CLASS : '', !scroll ? denseHead : ''),
|
|
582
698
|
head,
|
|
583
699
|
rowClass: mergeClass(join(rowBase, !scroll ? denseRow : ''), view.rowClass, view.replaceClass),
|
|
700
|
+
...(rowTone !== undefined ? { rowTone } : {}),
|
|
584
701
|
cells,
|
|
585
702
|
rowActions,
|
|
586
703
|
select,
|
|
587
704
|
selectClass: selectRow,
|
|
588
705
|
actionsClass: actionsRow,
|
|
589
706
|
pager: isTree ? optionalPagerOf(c.page) : pagerOf(c.page),
|
|
707
|
+
...countIr,
|
|
590
708
|
sort: head.some((h) => h.sort !== undefined || h.filter !== undefined),
|
|
591
|
-
stickyHeader: sticky,
|
|
709
|
+
stickyHeader: sticky || combo,
|
|
592
710
|
stripeClass: striped ? D.tableRowStriped : '',
|
|
593
711
|
...(c.bordered !== undefined ? { bordered: c.bordered } : {}),
|
|
594
|
-
density,
|
|
595
712
|
expand,
|
|
596
713
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
597
714
|
...(scroll ? { scroll: true } : {}),
|
|
598
|
-
...(rcw.length > 0 ? { rowClassWhen: rcw } : {}),
|
|
599
715
|
...(toolbar.length > 0 ? { toolbar } : {}),
|
|
600
716
|
...(batch.length > 0 ? { batch } : {}),
|
|
601
717
|
...(batch.length > 0 ? { selectScope } : {}),
|
|
602
718
|
...(summary !== null ? { summary, summaryCellClasses, summaryRowClass } : {}),
|
|
603
719
|
...(editMode !== null ? { editMode } : {}),
|
|
604
720
|
...(tools ? { columns } : {}),
|
|
605
|
-
...(scroll && (selectHead !== selectRow || actionsHead !== actionsRow) ? { selectHeadClass: selectHead, actionsHeadClass: actionsHead } : {}),
|
|
721
|
+
...((scroll || narrowGrid !== null) && (selectHead !== selectRow || actionsHead !== actionsRow) ? { selectHeadClass: selectHead, actionsHeadClass: actionsHead } : {}),
|
|
606
722
|
...(tools ? { tools: true } : {}),
|
|
607
723
|
...(virt !== null ? { virtual: { rowHeight: virt.rowHeight } } : {}),
|
|
608
724
|
...(headGroups.length > 0 ? { headGroups } : {}),
|
|
@@ -614,17 +730,18 @@ export function collection(
|
|
|
614
730
|
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
615
731
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
616
732
|
}
|
|
617
|
-
for (const k of ['
|
|
733
|
+
for (const k of ['striped', 'virtual', 'columnGroups', 'resizable'] as const) {
|
|
618
734
|
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
|
|
735
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `${k} 仅用于 table 集合` });
|
|
620
736
|
}
|
|
621
737
|
}
|
|
622
738
|
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
|
|
739
|
+
if (r.resizable !== undefined) env.diagnostics.push({ code: 'KIT-TBL-004', path: `${env.path}.fields[${i}].resizable`, message: 'resizable 仅用于 table 集合的列' });
|
|
624
740
|
});
|
|
625
741
|
const innerArrange = view.arrange ?? (c.type === 'cards' ? KIT_OBJECT_DEFAULTS.cardsArrange : KIT_OBJECT_DEFAULTS.stackArrange);
|
|
626
742
|
// 卡内 / 块内的布局不再叠加 view.class(它属于列表容器)
|
|
627
743
|
const inner = arrange(innerArrange, refs, { ...view, class: undefined, replaceClass: undefined }, env);
|
|
744
|
+
const itemRowTone = rowToneOf(view, env);
|
|
628
745
|
|
|
629
746
|
if (c.type === 'cards') {
|
|
630
747
|
let cols = c.cols ?? KIT_OBJECT_DEFAULTS.cardsColsDefault;
|
|
@@ -644,8 +761,33 @@ export function collection(
|
|
|
644
761
|
itemClass: mergeClass(cardsItem, view.rowClass, view.replaceClass),
|
|
645
762
|
inner,
|
|
646
763
|
rowActions,
|
|
764
|
+
...(itemRowTone !== undefined ? { rowTone: itemRowTone } : {}),
|
|
765
|
+
pager: optionalPagerOf(c.page),
|
|
766
|
+
...countIr,
|
|
767
|
+
state: stateOf(c, env, `${env.path}.collection`),
|
|
768
|
+
...ctxMenuIr,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// 紧凑列表:仍是 stack 形态(事件 / 分页 / 三态 / 右键菜单全走 stack 的路径),条目换成「主标题 + 次要信息」两行
|
|
773
|
+
if (c.type === 'compact-list') {
|
|
774
|
+
const shown = cellsOfInner(inner).filter((x) => x.placeholder !== true && x.divider !== true && x.component !== '');
|
|
775
|
+
const [titleCell, ...metaCells] = shown;
|
|
776
|
+
if (titleCell === undefined) {
|
|
777
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.type`, message: 'compact-list 至少要有一个字段(第一个字段是主标题,其余是次要信息)' });
|
|
778
|
+
}
|
|
779
|
+
return {
|
|
780
|
+
kind: 'stack',
|
|
781
|
+
wrapClass: '',
|
|
782
|
+
listClass: mergeClass(D.compactList, mergeClass(c.class ?? '', view.class), view.replaceClass),
|
|
783
|
+
itemClass: mergeClass(D.compactItem, view.rowClass, view.replaceClass),
|
|
784
|
+
inner,
|
|
785
|
+
rowActions,
|
|
786
|
+
...(itemRowTone !== undefined ? { rowTone: itemRowTone } : {}),
|
|
647
787
|
pager: optionalPagerOf(c.page),
|
|
788
|
+
...countIr,
|
|
648
789
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
790
|
+
...(titleCell !== undefined ? { compact: { title: titleCell, meta: metaCells } } : {}),
|
|
649
791
|
...ctxMenuIr,
|
|
650
792
|
};
|
|
651
793
|
}
|
|
@@ -661,8 +803,20 @@ export function collection(
|
|
|
661
803
|
itemClass: mergeClass(stackItem, view.rowClass, view.replaceClass),
|
|
662
804
|
inner,
|
|
663
805
|
rowActions,
|
|
806
|
+
...(itemRowTone !== undefined ? { rowTone: itemRowTone } : {}),
|
|
664
807
|
pager: optionalPagerOf(c.page),
|
|
808
|
+
...countIr,
|
|
665
809
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
666
810
|
...ctxMenuIr,
|
|
667
811
|
};
|
|
668
812
|
}
|
|
813
|
+
|
|
814
|
+
/** 排布里的字段格(grid / flex / rows 三种平铺排布;紧凑列表按声明顺序取格) */
|
|
815
|
+
function cellsOfInner(l: KitLayoutIR): KitCell[] {
|
|
816
|
+
switch (l.kind) {
|
|
817
|
+
case 'grid':
|
|
818
|
+
case 'flex': return l.cells;
|
|
819
|
+
case 'rows': return l.rows.flat();
|
|
820
|
+
default: return [];
|
|
821
|
+
}
|
|
822
|
+
}
|