soma-kit 0.1.14 → 0.1.16
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 +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -1,6 +1,61 @@
|
|
|
1
|
+
import { kitIsNextPipeline, kitWithCompilePipeline, type KitRenderPipeline } from './pipeline-mode';
|
|
1
2
|
import { kitRowActionsNarrowCap } from 'soma-foundation/kit-layout';
|
|
3
|
+
import {
|
|
4
|
+
kitActionFallbackVariant,
|
|
5
|
+
kitActionRegionResolve,
|
|
6
|
+
kitPlainActionRecipe,
|
|
7
|
+
kitStatusPillProps,
|
|
8
|
+
type KitActionFunction,
|
|
9
|
+
type KitActionRegion,
|
|
10
|
+
} from '../recipes/emphasis';
|
|
11
|
+
import { kitMatchSemanticStatusTone, type KitSemanticStatusTone } from '../recipes/color-role';
|
|
12
|
+
import { buttonVariantOfControl, type ButtonVariant } from '../base/button';
|
|
2
13
|
import { esc } from '../shared/escape';
|
|
3
14
|
import { getCompileEnvelope } from '../shared/envelope';
|
|
15
|
+
import {
|
|
16
|
+
KIT_ATTR_ACTION_GROUP,
|
|
17
|
+
KIT_ATTR_AG_ITEM,
|
|
18
|
+
KIT_ATTR_AG_LABEL,
|
|
19
|
+
KIT_ATTR_AG_TONE,
|
|
20
|
+
KIT_ATTR_COL,
|
|
21
|
+
KIT_ATTR_COLLAPSE_MARK,
|
|
22
|
+
KIT_ATTR_COLLAPSE_ROOT,
|
|
23
|
+
KIT_ATTR_COLLAPSE_TOGGLE,
|
|
24
|
+
KIT_ATTR_COMPACT,
|
|
25
|
+
KIT_ATTR_CONTAINER,
|
|
26
|
+
KIT_ATTR_CTX,
|
|
27
|
+
KIT_ATTR_CTXHOST,
|
|
28
|
+
KIT_ATTR_EDITABLE,
|
|
29
|
+
KIT_ATTR_ELLIPSIS,
|
|
30
|
+
KIT_ATTR_EMPHASIS,
|
|
31
|
+
KIT_ATTR_EXPAND_BODY,
|
|
32
|
+
KIT_ATTR_EXPAND_ROW,
|
|
33
|
+
KIT_ATTR_FILTER_OVERFLOW,
|
|
34
|
+
KIT_ATTR_GRID,
|
|
35
|
+
KIT_ATTR_GROUP_COLS,
|
|
36
|
+
KIT_ATTR_HIGHLIGHT,
|
|
37
|
+
KIT_ATTR_LEAD,
|
|
38
|
+
KIT_ATTR_MARK_CLOSED,
|
|
39
|
+
KIT_ATTR_MARK_OPEN,
|
|
40
|
+
KIT_ATTR_MERGE,
|
|
41
|
+
KIT_ATTR_PART,
|
|
42
|
+
KIT_ATTR_RESIZABLE,
|
|
43
|
+
KIT_ATTR_ROW,
|
|
44
|
+
KIT_ATTR_ROWS,
|
|
45
|
+
KIT_ATTR_SERIAL,
|
|
46
|
+
KIT_ATTR_SKELETON_BODY,
|
|
47
|
+
KIT_ATTR_SURFACE,
|
|
48
|
+
KIT_ATTR_TABLE,
|
|
49
|
+
KIT_ATTR_TABLE_OF,
|
|
50
|
+
KIT_ATTR_TABS_FRAME,
|
|
51
|
+
KIT_ATTR_TAB_FACE,
|
|
52
|
+
KIT_ATTR_TAB_PANEL,
|
|
53
|
+
KIT_ATTR_TITLE_ROW,
|
|
54
|
+
KIT_ATTR_TREE_CTL,
|
|
55
|
+
KIT_ATTR_TREE_FOR,
|
|
56
|
+
KIT_ATTR_TREE_OF,
|
|
57
|
+
KIT_ATTR_VSCROLL,
|
|
58
|
+
} from '../shared/dom-attrs';
|
|
4
59
|
// emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
|
|
5
60
|
//
|
|
6
61
|
// 两种发射:
|
|
@@ -18,28 +73,36 @@ import { checkRowPath, checkViewPath, classifyDisabledReason, isRowPath, isViewP
|
|
|
18
73
|
import type {
|
|
19
74
|
KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
|
|
20
75
|
} from './types';
|
|
21
|
-
import { KIT_CLASS_DEFAULTS,
|
|
76
|
+
import { KIT_CLASS_DEFAULTS, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
|
|
22
77
|
import type { KitSkeletonCol, KitSkeletonConfig } from './skeleton';
|
|
23
|
-
import { isNumericColumnType } from './collection-table';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
78
|
+
import { KIT_PART_TABLE, KIT_PART_TABLE_CELL, KIT_PART_TABLE_HEAD, KIT_PART_TABLE_ROW, isNumericColumnType } from './collection-table';
|
|
79
|
+
import { projectActionGroup, projectTabOverflow, type KitActionImportance } from './action-group';
|
|
80
|
+
import { KIT_TAB_BAR_FACE_CLASS, KIT_TAB_TEXT_ATTR, kitTabRecipe } from '../recipes/tabs';
|
|
81
|
+
import { KIT_NATURAL_W_ATTR, KIT_TABLE_FIT_ATTR } from '../recipes/container';
|
|
27
82
|
import { KIT_TABLE_GAP_HEAD_ATTR, tableGapReasonField } from '../recipes/table-gap';
|
|
28
|
-
import { kitTextActionRecipe } from '../recipes/control';
|
|
29
|
-
import { kitStatusPillProps } from '../recipes/emphasis';
|
|
30
83
|
import { KIT_OVERLAY_FORM_HOST_CLASS } from '../recipes/overlay';
|
|
31
|
-
import {
|
|
84
|
+
import { KIT_STRIP_HEAD_MIN_CLASS } from '../recipes/strip';
|
|
85
|
+
import { KIT_DESC_GROUP_DESC_CLASS } from '../recipes/desc-list';
|
|
86
|
+
import { KIT_PANEL_TITLE_CLASS, kitDefaultPanelIcon, kitPanelTitleHtml } from '../recipes/title-row';
|
|
32
87
|
import { headAnchor } from './compile-data';
|
|
33
|
-
import { KIT_STATE_DEFAULT_TEXT } from './collection';
|
|
88
|
+
import { KIT_STATE_DEFAULT_TEXT, kitIsExactFilterField } from './collection';
|
|
34
89
|
import { kitText } from '../i18n/kit-text';
|
|
35
90
|
import { KIT_TIPS_SCOPE_ATTR, kitHelpButtonHtml } from '../base/hint-tips';
|
|
36
91
|
import { expandHostId } from './collection-expand';
|
|
37
|
-
import { busyActionOf } from '../base/action-busy';
|
|
92
|
+
import { busyActionOf, kitEncodeKeyField, kitObjectBusyChannel } from '../base/action-busy';
|
|
93
|
+
import { KIT_ROWS_PINNED_ATTR } from '../base/row-fresh';
|
|
38
94
|
import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
|
|
39
|
-
import { KIT_PART_CARD, KIT_PART_SECTION, KIT_PART_TITLE_SECTION, kitContainerPartOf, type KitFormDetail } from './form-detail';
|
|
40
|
-
import {
|
|
95
|
+
import { KIT_PART_CARD, KIT_PART_SECTION, KIT_PART_TITLE_SECTION, kitContainerPartOf, kitDetailRelationIds, kitRelationIdFields, type KitFormDetail } from './form-detail';
|
|
96
|
+
import { noteRequestRelationFields } from './request-actions';
|
|
41
97
|
import { readStatePathsOf } from './crud-bridge';
|
|
98
|
+
import { KIT_FILTER_TOOLBAR_ACTIONS, KIT_FILTER_TOOLBAR_MARK, KIT_FILTER_TOOLBAR_WRAP, filterToolbarCells, filterToolbarCollapse } from './filter-toolbar';
|
|
42
99
|
import { primaryKeyFieldOf } from './key-field';
|
|
100
|
+
import { KIT_OPS_CELL_ATTR, KIT_OPS_HEAD_ATTR, kitActionFunctionOfDecl } from './table-actions';
|
|
101
|
+
import { kitLevelAttr, kitPartAttr } from '../data/kit-contract';
|
|
102
|
+
import { kitSelfAttrs } from '../shared/page-attrs-runtime';
|
|
103
|
+
import { kitSingleValueClasses } from '../recipes/pipeline-runtime';
|
|
104
|
+
import { kitValuePresentProps } from './value-present';
|
|
105
|
+
import { KIT_TAG_TONES_PROP, kitCategoryTagTones } from './category-tone';
|
|
43
106
|
|
|
44
107
|
/** 行变量按对象取(`kit_row_<对象>`):core 的 varMap 按变量名建,同页两个列表共用一个名字会撞 */
|
|
45
108
|
export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
@@ -47,6 +110,32 @@ export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
|
47
110
|
// ---------------------------------------------------------------- 锚点命名
|
|
48
111
|
|
|
49
112
|
export function viewAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}`; }
|
|
113
|
+
/**
|
|
114
|
+
* 视图面板标题(`<h3 data-soma-id="...">`)的静态锚点:
|
|
115
|
+
* - `list` 槽沿用 `<对象>__list__title`(字段 `title` 已由 `KIT_RESERVED_LIST_ANCHORS` 规整为 `title_cell`,永不撞名);
|
|
116
|
+
* - 非 `list` 槽(`summary` / `form` / `filter`)当 schema 中存在同名字段 `title` 或槽体内已出现同锚点时,
|
|
117
|
+
* 确定性切到 `__panel_title`(再兜底 `__view_heading` / `__heading` / `__panel_title_<n>`),彻底杜绝 `SomaContractError` 静态锚点重复。
|
|
118
|
+
*/
|
|
119
|
+
export function viewTitleAnchor(object: string, slot: KitViewSlot, schema?: KitSchema, bodyHtml?: string): string {
|
|
120
|
+
const base = viewAnchor(object, slot);
|
|
121
|
+
const defaultId = `${base}__title`;
|
|
122
|
+
if (slot === 'list') return defaultId;
|
|
123
|
+
const collides = (schema !== undefined && Object.prototype.hasOwnProperty.call(schema, 'title'))
|
|
124
|
+
|| (bodyHtml !== undefined && bodyHtml.includes(`data-soma-id="${defaultId}"`));
|
|
125
|
+
if (!collides) return defaultId;
|
|
126
|
+
for (const suffix of ['panel_title', 'view_heading', 'heading']) {
|
|
127
|
+
const candidate = `${base}__${suffix}`;
|
|
128
|
+
const taken = (schema !== undefined && Object.prototype.hasOwnProperty.call(schema, suffix))
|
|
129
|
+
|| (bodyHtml !== undefined && bodyHtml.includes(`data-soma-id="${candidate}"`));
|
|
130
|
+
if (!taken) return candidate;
|
|
131
|
+
}
|
|
132
|
+
let n = 1;
|
|
133
|
+
while (
|
|
134
|
+
(schema !== undefined && Object.prototype.hasOwnProperty.call(schema, `panel_title_${n}`))
|
|
135
|
+
|| (bodyHtml !== undefined && bodyHtml.includes(`data-soma-id="${base}__panel_title_${n}"`))
|
|
136
|
+
) n += 1;
|
|
137
|
+
return `${base}__panel_title_${n}`;
|
|
138
|
+
}
|
|
50
139
|
/**
|
|
51
140
|
* 同槽(`<对象>__list__`)里集合自己的实例后缀:字段名撞上它们会让页面锚点重复(CORE-ANCHOR-DUPLICATE,整页 500)。
|
|
52
141
|
* `state` / `title` / `meta` 都是常见的业务字段名,所以字段单元锚点遇到这些后缀时追加 `_cell`,字段名不受限。
|
|
@@ -56,6 +145,25 @@ export function cellAnchor(object: string, slot: KitViewSlot, field: string): st
|
|
|
56
145
|
return `${object}__${slot}__${slot === 'list' && KIT_RESERVED_LIST_ANCHORS.has(field) ? `${field}_cell` : field}`;
|
|
57
146
|
}
|
|
58
147
|
export function rowsAnchor(object: string): string { return `${object}__list__rows`; }
|
|
148
|
+
/** 置顶行容器(B1-3):与常规行同一个行模板、同一份行内事件(业务组件编译把 rowsAnchor 的嵌套事件同样写给它) */
|
|
149
|
+
export function pinnedRowsAnchor(object: string): string { return `${object}__list__pinned`; }
|
|
150
|
+
/** 置顶副本行内锚点的后缀(与常规行模板里的同名锚点区分,页面统一寻址空间不重名) */
|
|
151
|
+
const PINNED_ANCHOR_SUFFIX = '__pin';
|
|
152
|
+
function pinnedRowTemplate(html: string): string {
|
|
153
|
+
return html.replace(/data-soma-id="([^"]+)"/g, (_m, id: string) => `data-soma-id="${id}${PINNED_ANCHOR_SUFFIX}"`);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 行内锚点为键的表(行模板的 show、行容器下的嵌套事件 `<锚点>.<事件>`)→ 置顶副本的同一张表:键的锚点段加后缀。
|
|
157
|
+
* 业务组件编译把常规行的嵌套事件经它写给置顶行容器。
|
|
158
|
+
*/
|
|
159
|
+
export function pinnedRowKeys<T>(table: Record<string, T>): Record<string, T> {
|
|
160
|
+
const out: Record<string, T> = {};
|
|
161
|
+
for (const [k, v] of Object.entries(table)) {
|
|
162
|
+
const dot = k.indexOf('.');
|
|
163
|
+
out[dot < 0 ? `${k}${PINNED_ANCHOR_SUFFIX}` : `${k.slice(0, dot)}${PINNED_ANCHOR_SUFFIX}${k.slice(dot)}`] = v;
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
59
167
|
export function opsAnchor(object: string): string { return `${object}__list__ops`; }
|
|
60
168
|
/** 右键菜单实例(Q 波 G6):行模板里每行一个,虚拟滚动表 / 树表是页面里一个 */
|
|
61
169
|
export function ctxMenuAnchor(object: string): string { return `${object}__list__ctx`; }
|
|
@@ -128,16 +236,37 @@ export interface KitStaticOptions {
|
|
|
128
236
|
* KitTableActions(选择态存在协调组件的 focus 切片里);不给保持存量的惰性 Checkbox
|
|
129
237
|
*/
|
|
130
238
|
selectedPath?: string;
|
|
239
|
+
/** 当前打开项镜像的路径(如枢纽选中行):只管行操作实例的选中高亮(picked 入参),与勾选集合 selectedPath 分开 */
|
|
240
|
+
pickedPath?: string;
|
|
131
241
|
/** 行删除在途置灰读的协调组件作用域;忙闲通道名 = 作用域 + 行主键,必须与 KitCrudBridge 的 scope 一致;缺省用本对象作用域(standard-crud 两者相同) */
|
|
132
242
|
removeScope?: string;
|
|
243
|
+
/** 选中切换加载态监听的区域作用域(联动场景传链接作用域 link,供 KitCollectionState 监听 selection / focus 切片) */
|
|
244
|
+
readonly selectionScope?: string;
|
|
245
|
+
/** 选中签名取的主键字段(跨线契约 C3:枢纽的主键字段名,业务组件编译与 selectionScope 一起下发):原样透传给 KitCollectionState 的 config */
|
|
246
|
+
readonly selectionKeyField?: string;
|
|
133
247
|
/** 展开子表(Q 波 G5):协调组件 focus 切片 expandId 镜像的路径;给了,list 形展开的开关才读它判断本行是否展开 */
|
|
134
248
|
expandPath?: string;
|
|
249
|
+
/**
|
|
250
|
+
* 新建回声的置顶行(B1-3):协调组件 focus 切片 pinned(0 或 1 条保存回包记录)镜像的路径。给了,普通表格在表头与常规行之间
|
|
251
|
+
* 另出一个同行模板的置顶行容器(data-kit-pinned-rows);常规行里同主键的那一行由行组件隐去
|
|
252
|
+
*/
|
|
253
|
+
pinnedPath?: string;
|
|
254
|
+
/**
|
|
255
|
+
* 工具条内联上限(窄头部条用,如主从页左窗格头):主操作恒内联,其余超过上限的一律收进「更多」(被收起的只有 1 项也不内联);
|
|
256
|
+
* 不给 = 按宽度档逐个收起(缺省)
|
|
257
|
+
*/
|
|
258
|
+
toolbarInlineCap?: number;
|
|
135
259
|
/** behavior.validateOn(已校验):KitObjectForm 在 change / blur 时即时校验 */
|
|
136
260
|
validateOn?: string[];
|
|
137
261
|
/** behavior.leaveGuard 生效(confirm):KitObjectForm 草稿有改动时拦截离开 */
|
|
138
262
|
leaveGuard?: boolean;
|
|
139
263
|
/** behavior.detail(已校验):编辑表单打开时先取详情(KitObjectForm 的 detail prop) */
|
|
140
264
|
formDetail?: KitFormDetail;
|
|
265
|
+
/**
|
|
266
|
+
* 主题流水线模式:next 时在产物里补组件契约的自报属性(层级角色、元素部件),并按单一值输出去掉会被页面线判定覆盖的缺省呈现;
|
|
267
|
+
* 缺省(legacy)产物逐字节不变
|
|
268
|
+
*/
|
|
269
|
+
pipeline?: KitRenderPipeline;
|
|
141
270
|
}
|
|
142
271
|
|
|
143
272
|
export interface KitStaticEmit {
|
|
@@ -161,6 +290,16 @@ function attr(name: string, value: string): string {
|
|
|
161
290
|
const OVERLAY_FOOTER_HOSTS: ReadonlySet<string> = new Set(['KitObjectForm', 'Transfer', 'PermissionTree', 'AssignmentPicker']);
|
|
162
291
|
const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitTableGap', 'KitCollectionState', 'Pager']);
|
|
163
292
|
|
|
293
|
+
/**
|
|
294
|
+
* 按真实内容求列宽的表(KT-P-compose C6,栅格 + 子栅格):表内层与行之间的宿主(可排序表头的组件宿主、合计行宿主、行容器)不占列——取 display: contents,
|
|
295
|
+
* 它们画出的行(子栅格)直接落在表内层的栅格里;行里不画东西的接线宿主(无按钮的行动作件)不进列,取 hidden。
|
|
296
|
+
*/
|
|
297
|
+
const CONTENT_TRACK_PASS_CLASS = 'contents';
|
|
298
|
+
const CONTENT_TRACK_IDLE_CLASS = 'hidden';
|
|
299
|
+
function trackHost(component: string, id: string, cls: string): string {
|
|
300
|
+
return `<div data-soma-component="${esc(component)}" data-soma-id="${esc(id)}" class="${cls}"></div>`;
|
|
301
|
+
}
|
|
302
|
+
|
|
164
303
|
function host(component: string, id: string): string {
|
|
165
304
|
// 自带底栏的表单 / 穿梭框 / 授权树,其宿主在浮层滚动体里是体的 flex 子项并撑满体高(底栏才能落在浮层底部);变体只在 group-data-kit-overlay-scroll 祖先下生效
|
|
166
305
|
// 根常带 hidden 的辅助宿主(表格工具位 / 三态面板 / 分页器):宿主 display: contents,不占 flex 子项的位——
|
|
@@ -172,19 +311,25 @@ function host(component: string, id: string): string {
|
|
|
172
311
|
const opsHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_ops', undefined, ctx.options.locale ?? '');
|
|
173
312
|
const selectHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_select', undefined, ctx.options.locale ?? '');
|
|
174
313
|
const cellRoleAttr = (role: string): string => (role === '' ? '' : ` role="${role}"`);
|
|
314
|
+
const reorderHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_reorder', undefined, ctx.options.locale ?? '');
|
|
315
|
+
const serialHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_serial', undefined, ctx.options.locale ?? '');
|
|
316
|
+
/** 序号节点:空壳,行位置由 KitTableTools 回填(data-kit-serial);等宽数字、弱文字 */
|
|
317
|
+
const SERIAL_NODE = `<span ${KIT_ATTR_SERIAL}="" class="min-w-0 truncate text-xs tabular-nums text-fg-subtle"></span>`;
|
|
318
|
+
/** 序号与勾选框同格时的横排壳 */
|
|
319
|
+
const SERIAL_BESIDE_OPEN = '<div class="flex min-w-0 items-center gap-1">';
|
|
175
320
|
/** 视图标题行(K-4):语义色名 + utilityScales 里有的尺度 */
|
|
176
321
|
|
|
177
322
|
/** 显式 `bordered: true`(完整网格线)的表格外壳标 data-kit-grid:主题结构 CSS 只对没有这个标记的表壳去掉容器卡片外观(圆角 / 边框 / 阴影 / 底色) */
|
|
178
323
|
function gridMark(layout: { bordered?: boolean }): string {
|
|
179
|
-
return layout.bordered === true ?
|
|
324
|
+
return layout.bordered === true ? ` ${KIT_ATTR_GRID}=""` : '';
|
|
180
325
|
}
|
|
181
326
|
|
|
182
327
|
/** 树表「全部展开 / 全部收起」:文字链接形态,放在表格工具位(与刷新同一行、标题行右侧);点击由 KitTreeTable 按 data-kit-tree-for 认领 */
|
|
183
328
|
function renderTreeControls(ctx: Ctx): string {
|
|
184
329
|
const locale = ctx.options.locale ?? '';
|
|
185
|
-
const cls =
|
|
330
|
+
const cls = kitPlainActionRecipe('expand');
|
|
186
331
|
const one = (act: 'expand' | 'collapse', key: 'soma.kit.expand_all' | 'soma.kit.collapse_all'): string =>
|
|
187
|
-
`<button type="button"
|
|
332
|
+
`<button type="button" ${KIT_ATTR_TREE_CTL}="${act}" ${KIT_ATTR_TREE_FOR}="${esc(ctx.object)}"${attr('class', cls)}>${esc(kitText(key, undefined, locale))}</button>`;
|
|
188
333
|
return `${one('expand', 'soma.kit.expand_all')}${one('collapse', 'soma.kit.collapse_all')}`;
|
|
189
334
|
}
|
|
190
335
|
|
|
@@ -198,10 +343,74 @@ function joinClasses(a: string, b: string): string {
|
|
|
198
343
|
return [a, b].filter((s) => s !== '').join(' ');
|
|
199
344
|
}
|
|
200
345
|
|
|
346
|
+
// ---------------------------------------------------------------- 组件契约(主题流水线 next)
|
|
347
|
+
|
|
348
|
+
/** next 下补的层级角色 / 元素部件属性串;legacy 恒为空串,产物不变 */
|
|
349
|
+
const nextLevel = (ctx: { next: boolean }, level: Parameters<typeof kitLevelAttr>[0]): string => (ctx.next ? kitLevelAttr(level) : '');
|
|
350
|
+
/**
|
|
351
|
+
* 写了 nextLevel 的同一节点上的类(单一值输出):next 下按层级角色剥掉取值表负责的那组类(底色、边框与分隔线、圆角、阴影、内边距),
|
|
352
|
+
* 与 nextLevel 同一判据 ctx.next;legacy 原样返回,产物不变
|
|
353
|
+
*/
|
|
354
|
+
const nextLevelClass = (ctx: { next: boolean }, level: Parameters<typeof kitLevelAttr>[0], cls: string): string => (ctx.next ? kitSingleValueClasses(level, cls) : cls);
|
|
355
|
+
const nextPart = (ctx: { next: boolean }, part: Parameters<typeof kitPartAttr>[0]): string => (ctx.next ? kitPartAttr(part) : '');
|
|
356
|
+
/** 给宿主 div(host / trackHost 的输出,恒以 `></div>` 结尾)补属性 */
|
|
357
|
+
function withHostAttrs(hostHtml: string, extra: string): string {
|
|
358
|
+
return extra === '' ? hostHtml : hostHtml.replace(/><\/div>$/, `${extra}></div>`);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* 单一值输出(业务功能描述 §4.4):next 下页面线会把字段的值呈现形态、语义色调、分类色序号、逻辑对齐、溢出策略写进
|
|
363
|
+
* 本格值组件的 props.kit(字段锚点 = 本格的单元锚点,spatial/expand#cellAnchor)。同一节点同一维度只留一个值:
|
|
364
|
+
* 字段值的呈现以类型呈现真源给的缺省(present / copyable,type-presentation#formFields.readonlyPresent,按 38 种数据类型分形态,
|
|
365
|
+
* 与主题无关)及页面显式写的值为准,页面线的值呈现形态不再改它(页面线只有 13 种字段类型,分不清整数与金额、日期与日期时间);
|
|
366
|
+
* 本函数只处理一样东西:标签色表(tag_tones 里按主题定的自动位 '@k' 归分类色序号,运行期推导,这里清掉未解析的自动位);
|
|
367
|
+
* 页面显式写的色表条目一律保留,其余入参不动。状态圆点变体不在这里去掉:cellProps 在页面线判定能到达本格(owned)时不再补它。
|
|
368
|
+
* 下面「全为显式色表」那一支只核对、不改动(保留作者显式指定的 cN,避免运行期丢失)。
|
|
369
|
+
* 值组件类串里的对齐 / 截断类不去掉(SCON-137):它们是集合按形态与列声明给的(表格单元格单行省略、列上写了不省略就折词、
|
|
370
|
+
* 条目里数值不截断)或页面自己写在值类上的,比页面线按字段类型给的缺省知道得更细;页面线的溢出策略与逻辑对齐只在类串里
|
|
371
|
+
* 没有同一维度的类时补上(base/kit-contract.ts#kitHasOwnOverflow / kitHasOwnAlign),两种模式下值组件拿到的类串因此相同。
|
|
372
|
+
*/
|
|
373
|
+
function samePlain(a: unknown, b: unknown): boolean {
|
|
374
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
375
|
+
}
|
|
376
|
+
function dropPipelineOwned(ctx: Ctx, cell: KitCell, props: Record<string, unknown>): void {
|
|
377
|
+
const field = ctx.options.schema?.[cell.field];
|
|
378
|
+
if (field !== undefined && cell.mode === 'show') {
|
|
379
|
+
const schema = ctx.options.schema!;
|
|
380
|
+
const dflt = [true, false].map((block) => kitValuePresentProps(field, { copy: block, block, schema, name: cell.field }));
|
|
381
|
+
// D-057(SCON-128):字段值的 present / copyable 保留类型呈现真源(38 种数据类型)给的缺省,页面线粗分类不再删它;
|
|
382
|
+
// 分类色色表(tag_tones):在 next 模式下自动位('@k')交由运行期按 --kit-cat-auto + props.kit.categoryIndex 推导,
|
|
383
|
+
// 若存在显式指定的 c1..c8 / neutral 条目则予以保留,仅清除未解析的 '@k' 自动位(全为自动位时整键删除);
|
|
384
|
+
// 只剩显式条目时,其余选项由运行期按声明顺序接续取色(base/look.ts#kitCategoryTonesByOrder 的 explicit,E→D)。
|
|
385
|
+
// 没有页面线锚点的格不经过这里:色表里的自动位留给运行期按主题自动序列解析(recipes/mark.ts#kitCategoryToneFor 的 auto,与编译期同一规则)
|
|
386
|
+
const rawTones = props[KIT_TAG_TONES_PROP];
|
|
387
|
+
if (rawTones !== undefined && typeof rawTones === 'object' && rawTones !== null && !Array.isArray(rawTones)) {
|
|
388
|
+
const entries = Object.entries(rawTones as Record<string, unknown>);
|
|
389
|
+
const hasAuto = entries.some(([, v]) => typeof v === 'string' && v.startsWith('@'));
|
|
390
|
+
if (hasAuto) {
|
|
391
|
+
const explicit: Record<string, unknown> = {};
|
|
392
|
+
for (const [k, v] of entries) {
|
|
393
|
+
if (typeof v !== 'string' || !v.startsWith('@')) explicit[k] = v;
|
|
394
|
+
}
|
|
395
|
+
if (Object.keys(explicit).length > 0) props[KIT_TAG_TONES_PROP] = explicit;
|
|
396
|
+
else delete props[KIT_TAG_TONES_PROP];
|
|
397
|
+
} else if (dflt.some((d) => samePlain(d[KIT_TAG_TONES_PROP], rawTones)) || samePlain(kitCategoryTagTones(schema, cell.field), rawTones)) {
|
|
398
|
+
// 全为显式色表时保留显式色,避免运行期 kitCategoryTonesByOrder 丢失作者显式指定的 cN
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
201
404
|
/** 选中行高亮:行内的 KitTableActions 实例读已选行镜像与主键,给所在行标 data-kit-selected(给了 selectedPath 才有) */
|
|
202
405
|
function selectedProps(ctx: Ctx): Record<string, unknown> {
|
|
203
|
-
|
|
204
|
-
|
|
406
|
+
const { selectedPath, pickedPath } = ctx.options;
|
|
407
|
+
if (selectedPath === undefined && pickedPath === undefined) return {};
|
|
408
|
+
// pickedPath = 当前打开项(枢纽选中镜像):只管行高亮,写到 picked;selected 仍是勾选集合,勾选态与 bulkLock 读它
|
|
409
|
+
return {
|
|
410
|
+
...(selectedPath !== undefined ? { selected: selectedPath } : {}),
|
|
411
|
+
...(pickedPath !== undefined ? { picked: pickedPath } : {}),
|
|
412
|
+
keyField: keysOf(ctx.options.schema)[0] ?? '',
|
|
413
|
+
};
|
|
205
414
|
}
|
|
206
415
|
|
|
207
416
|
/** 行操作组件读「本行删除在途」:协调组件按作用域 + 行主键经忙闲通道登记,这里只给出作用域与主键字段名(作用域空则不绑) */
|
|
@@ -228,6 +437,10 @@ interface Ctx {
|
|
|
228
437
|
filterId?: string;
|
|
229
438
|
/** 表头筛选写进 view 切片的键(列表是带表头筛选的表格时非空) */
|
|
230
439
|
columnParams?: string[];
|
|
440
|
+
/** 主题流水线 next:只有它为真时才输出组件契约的新增属性(legacy 产物逐字节不变) */
|
|
441
|
+
next: boolean;
|
|
442
|
+
/** 正在画分组(groups)里的格:分组里的字段在页面线上没有锚点(spatial/expand 只给顶层字段配单元锚点),拿不到页面线判定 */
|
|
443
|
+
groupDepth: number;
|
|
231
444
|
}
|
|
232
445
|
|
|
233
446
|
/**
|
|
@@ -259,8 +472,60 @@ const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
|
|
|
259
472
|
'Switch', 'Checkbox', 'Range', 'Rating', 'Input', 'Textarea', 'Number', 'Select',
|
|
260
473
|
]);
|
|
261
474
|
|
|
262
|
-
/**
|
|
263
|
-
|
|
475
|
+
/**
|
|
476
|
+
* 动作触发的忙闲通道名:submit 写的应用动作 → 动作名(含之后会被联动枢纽转发的那些,转发前后动作名不变);
|
|
477
|
+
* 声明式 request 动作 → kitObjectBusyChannel(对象名, action.id)(D-08:动作 id 只在对象内唯一,KitActionHost 用同一个函数登记,跨线契约 C2)。
|
|
478
|
+
* 声明式 download、`view.<方法>`、`data.*`、`kit.*` 与内置动作没有忙闲通道,返回 undefined。
|
|
479
|
+
*/
|
|
480
|
+
function namedActionOf(action: KitAction | undefined, object: string): string | undefined {
|
|
481
|
+
if (action === undefined || action.download !== undefined) return undefined;
|
|
482
|
+
if (action.request !== undefined) return typeof action.id === 'string' && action.id !== '' ? kitObjectBusyChannel(object, action.id) : undefined;
|
|
483
|
+
const s = action.submit;
|
|
484
|
+
if (typeof s !== 'string' || s === '') return undefined;
|
|
485
|
+
if (s.startsWith('view.') || s.startsWith('data.') || s.startsWith('kit.')) return undefined;
|
|
486
|
+
return s;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* busy_action 名字列表里的本对象声明式请求(SCON-176):点名的是 actions 里 request / download 的 id 时换成按对象的通道名
|
|
491
|
+
* kitObjectBusyChannel(对象, id)——KitActionHost 按它登记(C2 / D-08),手写的与自动注入的同一口径;具名动作名与不认识的名字原样保留。
|
|
492
|
+
* 名字按逗号 / 空白切开(与 base/action-busy 同一切法),有替换时按逗号连接;一个都没换时原串返回(产物与改前一致)
|
|
493
|
+
*/
|
|
494
|
+
export function kitOwnBusyChannels(raw: string, actions: readonly KitAction[], object: string): string {
|
|
495
|
+
let changed = false;
|
|
496
|
+
const names = raw.split(/[\s,]+/).filter((n) => n !== '').map((n) => {
|
|
497
|
+
if (!actions.some((a) => a.id === n && (a.request !== undefined || a.download !== undefined))) return n;
|
|
498
|
+
changed = true;
|
|
499
|
+
return kitObjectBusyChannel(object, n);
|
|
500
|
+
});
|
|
501
|
+
return changed ? names.join(',') : raw;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** 补充常见日志 / 通知级别词(kitMatchSemanticStatusTone 覆盖「错误 / error / warn / warning」等核心闭集,此处补齐「警告 / 信息 / info」避免回落为无语义分类色) */
|
|
505
|
+
const EXTRA_SEMANTIC_OPTION_TONES: Readonly<Record<string, KitSemanticStatusTone>> = Object.freeze({
|
|
506
|
+
警告: 'warning',
|
|
507
|
+
信息: 'info',
|
|
508
|
+
info: 'info',
|
|
509
|
+
information: 'info',
|
|
510
|
+
notice: 'info',
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
function matchOptionSemanticTone(label: unknown, value: unknown): KitSemanticStatusTone | null {
|
|
514
|
+
const lbl = typeof label === 'string' ? label.trim() : '';
|
|
515
|
+
const val = typeof value === 'string' ? value.trim() : '';
|
|
516
|
+
return (
|
|
517
|
+
kitMatchSemanticStatusTone(lbl)
|
|
518
|
+
?? kitMatchSemanticStatusTone(val)
|
|
519
|
+
?? EXTRA_SEMANTIC_OPTION_TONES[lbl]
|
|
520
|
+
?? EXTRA_SEMANTIC_OPTION_TONES[val.toLowerCase()]
|
|
521
|
+
?? null
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** 单元的 props:字段值绑定 + IR 里的 props + 值类;inRow = 本格在列表的行模板里(表格列、卡片 / 堆叠条目、紧凑条目、展开详情) */
|
|
526
|
+
function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string, anchored = false, inRow = false): Record<string, unknown> {
|
|
527
|
+
// anchored:本格锚点就是页面线的字段锚点(表格列、紧凑列表、列表 / 摘要的顶层字段);只有这时页面线判定能到达本格
|
|
528
|
+
const owned = ctx.next && anchored;
|
|
264
529
|
const props: Record<string, unknown> = { value: valuePath };
|
|
265
530
|
for (const [k, v] of Object.entries(cell.props)) props[k] = v;
|
|
266
531
|
// 字段项 props 绑 row.<字段>(RV-1119):行模板里 core 逐行求值(行变量.<字段>),业务对象逐行给值,页面不算
|
|
@@ -269,14 +534,64 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Rec
|
|
|
269
534
|
props.aria_label = cell.label;
|
|
270
535
|
}
|
|
271
536
|
if (cell.valueClass !== '') props.class = cell.valueClass;
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
//
|
|
275
|
-
if (cell.component === '
|
|
537
|
+
// 页面手写的 busy_action(SCON-176):点名本对象声明式 request / download 的 id 时换成按对象的通道名(与下面的自动注入同口径),其余名字原样
|
|
538
|
+
if (typeof props.busy_action === 'string' && props.busy_action !== '') props.busy_action = kitOwnBusyChannels(props.busy_action, ctx.options.actions ?? [], ctx.object);
|
|
539
|
+
// 字段按钮 / 开关触发具名动作:按动作名注入 busy_action,组件自己订阅忙闲通道、在 render 里合并置灰与 aria-busy(页面手写的优先)
|
|
540
|
+
if ((cell.component === 'Button' || cell.component === 'Switch') && cell.action !== undefined && props.busy_action === undefined && props.busy === undefined) {
|
|
541
|
+
const hit = ctx.options.actions?.find((a) => a.id === cell.action);
|
|
542
|
+
const named = namedActionOf(hit, ctx.object);
|
|
543
|
+
if (named !== undefined) {
|
|
544
|
+
props.busy_action = named;
|
|
545
|
+
// 行模板里的字段动作(跨线契约 C2,D-02):按行忙闲。busy_row = 本行主键值,组件只看本行的通道(别的行在途不置灰本行);
|
|
546
|
+
// kit_key_field = 主键字段名、kit_row = 本行,随 click / change 载荷带出(行内单元动作的载荷带 row 与 kit_key_field):
|
|
547
|
+
// 具名动作由执行器、声明式 request 由 KitActionHost 据此给本行登记同一条通道(kitRowBusyChannel(busy_action, 行键))。没有主键字段时照旧按动作名
|
|
548
|
+
const keyField = inRow ? primaryKeyFieldOf(ctx.options.schema) : undefined;
|
|
549
|
+
if (keyField !== undefined && keyField !== '') {
|
|
550
|
+
props.busy_row = `${ctx.rowVar}.${keyField}`;
|
|
551
|
+
// 安全编码为字面量,防止主键字段名与同页变量(如 role/user/order/code)同名时被 soma-core#resolvePropValue 误求值为对象
|
|
552
|
+
props.kit_key_field = kitEncodeKeyField(keyField);
|
|
553
|
+
props.kit_row = ctx.rowVar;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
// 只读枚举 / 标签格的选项未显式指定 tone 时,先匹配语义状态词(如「错误」→ danger、「警告」→ warning、「信息」→ info),避免日志级别等隐式状态枚举退化为紫 / 粉分类色
|
|
558
|
+
if (cell.mode === 'show' && (cell.component === 'Text' || cell.component === 'Tag') && Array.isArray(props.options)) {
|
|
559
|
+
const field = ctx.options.schema?.[cell.field] as { type?: string } | undefined;
|
|
560
|
+
if (field?.type === 'enum' || field?.type === 'enums') {
|
|
561
|
+
let matchedAny = false;
|
|
562
|
+
const matchedKeys = new Set<string>();
|
|
563
|
+
const nextOpts = (props.options as unknown[]).map((o) => {
|
|
564
|
+
if (o === null || typeof o !== 'object' || Array.isArray(o)) return o;
|
|
565
|
+
const rec = o as Record<string, unknown>;
|
|
566
|
+
if (rec.tone !== undefined) return o;
|
|
567
|
+
const matched = matchOptionSemanticTone(rec.label, rec.value);
|
|
568
|
+
if (matched === null) return o;
|
|
569
|
+
matchedAny = true;
|
|
570
|
+
if (rec.value !== undefined) matchedKeys.add(String(rec.value));
|
|
571
|
+
return { ...rec, tone: matched };
|
|
572
|
+
});
|
|
573
|
+
if (matchedAny) {
|
|
574
|
+
props.options = nextOpts;
|
|
575
|
+
const rawTones = props[KIT_TAG_TONES_PROP];
|
|
576
|
+
if (rawTones !== undefined && typeof rawTones === 'object' && rawTones !== null && !Array.isArray(rawTones)) {
|
|
577
|
+
const rest: Record<string, unknown> = {};
|
|
578
|
+
for (const [k, v] of Object.entries(rawTones as Record<string, unknown>)) {
|
|
579
|
+
if (!matchedKeys.has(k)) rest[k] = v;
|
|
580
|
+
}
|
|
581
|
+
if (Object.keys(rest).length > 0) props[KIT_TAG_TONES_PROP] = rest;
|
|
582
|
+
else delete props[KIT_TAG_TONES_PROP];
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
// 状态类字段(单选枚举且选项带 tone)默认呈现为状态(emphasis.status = dot:圆点 + 语义色文字,没有容器;常态用中性灰),全应用统一,与紧凑列表、表格一致
|
|
588
|
+
// next 且页面线判定能到达本格时,状态的呈现形态(状态点)由页面线的值呈现形态给出,不再补缺省变体(单一值输出)
|
|
589
|
+
if (!owned && cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) {
|
|
276
590
|
const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
|
|
277
|
-
const opts = Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
591
|
+
const opts = Array.isArray(props.options) ? (props.options as unknown[]) : Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
278
592
|
if (field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>))) Object.assign(props, kitStatusPillProps());
|
|
279
593
|
}
|
|
594
|
+
if (owned) dropPipelineOwned(ctx, cell, props);
|
|
280
595
|
return props;
|
|
281
596
|
}
|
|
282
597
|
|
|
@@ -293,35 +608,46 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
|
|
|
293
608
|
}
|
|
294
609
|
const id = idOf ? idOf(cell.field) : cellAnchor(ctx.object, slot, cell.field);
|
|
295
610
|
ctx.components.add(cell.component);
|
|
296
|
-
|
|
611
|
+
// 页面线给列表 / 摘要 / 只读表单的全部字段(含分组内字段)配单元锚点(spatial/expand):展开行详情(idOf)无页面线节点,缺省照旧
|
|
612
|
+
const anchored = idOf === undefined && (slot === 'list' || slot === 'summary' || slot === 'form');
|
|
613
|
+
// 行模板里的格(卡片 / 堆叠条目、展开详情)写进行模板自己的 show(rowShow),页面级的格写进 ctx.show
|
|
614
|
+
showInto[id] = { props: cellProps(ctx, cell, valuePath, at, anchored, showInto !== ctx.show) };
|
|
297
615
|
const star = cell.required === undefined ? '' : `<span${attr('class', KIT_REQUIRED_STAR_CLASS[cell.required])} aria-hidden="true">*</span>`;
|
|
298
616
|
// 只读格的字段说明(J9):标签旁一个「i」图标钮(没有 help 的格不出节点);气泡由 base/hint-tips 的委托在悬停 / 聚焦时才建
|
|
299
617
|
const helpBtn = !cell.label ? '' : kitHelpButtonHtml(cell.helpTip ?? '', cell.label, ctx.options.locale ?? '');
|
|
300
|
-
|
|
618
|
+
// 描述列表语义(desc):键 = dt、值 = dd(dd 取 contents,值宿主仍是栅格项;有标签的格才有 dt / dd)
|
|
619
|
+
const asDesc = cell.desc === true && Boolean(cell.label);
|
|
620
|
+
const labelTag = asDesc ? 'dt' : 'span';
|
|
621
|
+
const label = !cell.label ? '' : `<${labelTag}${attr('class', cell.labelClass)}${nextPart(ctx, 'field-name')}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}${helpBtn}</${labelTag}>`;
|
|
301
622
|
// 值可能被截断(格 / 值类里带 truncate)的格标出提示作用范围,截断了才有全文提示(J10);不截断的格输出不变
|
|
302
623
|
const truncating = TRUNCATING_CLASS_RE.test(`${cell.cellClass} ${cell.valueClass}`);
|
|
303
|
-
|
|
624
|
+
// 值宿主:只读描述列表整行字段的值从第二轨跨到末轨(cell.hostClass,KT-P-compose C6b)
|
|
625
|
+
const hostHtml = cell.hostClass !== undefined ? trackHost(cell.component, id, cell.hostClass) : host(cell.component, id);
|
|
626
|
+
// next:字段(描述项)自报条目,值位自报元素部件「值」(描述列表挂在 dd 上,其余挂在值宿主上)
|
|
627
|
+
const valueHost = asDesc ? `<dd class="contents"${nextPart(ctx, 'value')}>${hostHtml}</dd>` : withHostAttrs(hostHtml, nextPart(ctx, 'value'));
|
|
628
|
+
const cellExtraAttrs = `${cell.emphasis !== undefined ? ` ${KIT_ATTR_EMPHASIS}="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ` ${KIT_ATTR_HIGHLIGHT}="true"` : ''}${cell.overflow === true ? ` ${KIT_ATTR_FILTER_OVERFLOW}="true"` : ''}${truncating ? ` ${KIT_TIPS_SCOPE_ATTR}=""` : ''}${nextLevel(ctx, 'item')}`;
|
|
304
629
|
// summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
|
|
305
630
|
if (cell.hideEmpty === true) {
|
|
306
631
|
const cellId = `${id}__cell`;
|
|
307
632
|
// 纯路径绑定(不发射对象形 when);数字 / 布尔字段由 buildCell 拒收
|
|
308
633
|
showInto[cellId] = { when: valuePath };
|
|
309
|
-
return `<div data-soma-id="${esc(cellId)}"${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${
|
|
634
|
+
return `<div data-soma-id="${esc(cellId)}"${cellExtraAttrs}${attr('class', nextLevelClass(ctx, 'item', cell.cellClass))}>${label}${valueHost}</div>`;
|
|
310
635
|
}
|
|
311
|
-
return `<div${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${
|
|
636
|
+
return `<div${cellExtraAttrs}${attr('class', nextLevelClass(ctx, 'item', cell.cellClass))}>${label}${valueHost}</div>`;
|
|
312
637
|
}
|
|
313
638
|
|
|
314
639
|
/** 表格行里的列单元:无 label,只有值组件 */
|
|
315
640
|
function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string, unknown>, marked = false, cellRole = ''): string {
|
|
316
641
|
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
317
642
|
ctx.components.add(cell.component);
|
|
318
|
-
|
|
643
|
+
// 表格列的单元锚点即页面线的字段锚点:next 下按单一值输出去掉会被判定覆盖的缺省
|
|
644
|
+
showInto[id] = { props: cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at, true, true) };
|
|
319
645
|
// KitTableTools 按这些标记接管:列显隐(data-kit-col)、省略 title、就地编辑
|
|
320
|
-
const cellKnobAttrs = `${cell.emphasis !== undefined ? `
|
|
646
|
+
const cellKnobAttrs = `${cell.emphasis !== undefined ? ` ${KIT_ATTR_EMPHASIS}="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ` ${KIT_ATTR_HIGHLIGHT}="true"` : ''}`;
|
|
321
647
|
const marks = marked
|
|
322
|
-
? `
|
|
648
|
+
? ` ${KIT_ATTR_COL}="${esc(cell.field)}"${cell.ellipsis === true ? ` ${KIT_ATTR_ELLIPSIS}=""` : ''}${cell.mergeSame === true ? ` ${KIT_ATTR_MERGE}=""` : ''}${cell.editable === true ? ` ${KIT_ATTR_EDITABLE}=""` : ''}`
|
|
323
649
|
: '';
|
|
324
|
-
return `<div${marks}${cellKnobAttrs}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)}
|
|
650
|
+
return `<div${marks}${cellKnobAttrs}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)} ${KIT_ATTR_PART}="${KIT_PART_TABLE_CELL}">${host(cell.component, id)}</div>`;
|
|
325
651
|
}
|
|
326
652
|
|
|
327
653
|
// ---------------------------------------------------------------- 排布
|
|
@@ -329,25 +655,34 @@ function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string
|
|
|
329
655
|
function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, valueOf: (field: string) => string, at: string, showInto: Record<string, unknown>, idOf?: IdOf): string {
|
|
330
656
|
switch (layout.kind) {
|
|
331
657
|
case 'grid': {
|
|
332
|
-
|
|
333
|
-
|
|
658
|
+
// 只读描述列表(每格都是有标签的键值格):栅格容器是 dl,格是 dl > div > dt + dd;有分隔 / 占位格时不是纯键值对,保持 div(格不带 desc)
|
|
659
|
+
const isDl = layout.cells.length > 0 && layout.cells.every((c) => c.desc === true && c.placeholder !== true && Boolean(c.label));
|
|
660
|
+
const cells = layout.cells.map((c, i) => keyedCell(ctx, slot, isDl ? c : { ...c, desc: false }, valueOf(c.field), `${at}.cells[${i}]`, showInto, idOf)).join('');
|
|
661
|
+
const gridTag = isDl ? 'dl' : 'div';
|
|
662
|
+
return `<div${attr('class', layout.wrapClass)}><${gridTag}${attr('class', layout.gridClass)}>${cells}</${gridTag}></div>`;
|
|
334
663
|
}
|
|
335
664
|
case 'rows': {
|
|
336
665
|
const rows = layout.rows.map((row, r) => {
|
|
337
|
-
const cells = row.map((c, i) => keyedCell(ctx, slot, c, valueOf(c.field), `${at}.rows[${r}][${i}]`, showInto, idOf)).join('');
|
|
666
|
+
const cells = row.map((c, i) => keyedCell(ctx, slot, { ...c, desc: false }, valueOf(c.field), `${at}.rows[${r}][${i}]`, showInto, idOf)).join('');
|
|
338
667
|
return `<div${attr('class', layout.rowClass)}>${cells}</div>`;
|
|
339
668
|
}).join('');
|
|
340
669
|
return `<div${attr('class', layout.wrapClass)}>${rows}</div>`;
|
|
341
670
|
}
|
|
342
671
|
case 'flex': {
|
|
343
|
-
const cells = layout.cells.map((c, i) => keyedCell(ctx, slot, c, valueOf(c.field), `${at}.cells[${i}]`, showInto, idOf)).join('');
|
|
672
|
+
const cells = layout.cells.map((c, i) => keyedCell(ctx, slot, { ...c, desc: false }, valueOf(c.field), `${at}.cells[${i}]`, showInto, idOf)).join('');
|
|
344
673
|
return `<div${attr('class', layout.wrapClass)}>${cells}</div>`;
|
|
345
674
|
}
|
|
346
675
|
case 'groups': {
|
|
347
676
|
if (layout.tabs === true) return renderGroupTabs(ctx, slot, layout, valueOf, at, showInto, idOf);
|
|
348
677
|
const markers = KIT_GROUP_MARKERS[layout.marker];
|
|
349
678
|
const sections = layout.groups.map((g, i) => {
|
|
350
|
-
|
|
679
|
+
ctx.groupDepth += 1;
|
|
680
|
+
let inner: string;
|
|
681
|
+
try {
|
|
682
|
+
inner = renderArrangement(ctx, slot, g.layout, valueOf, `${at}.groups[${i}]`, showInto, idOf);
|
|
683
|
+
} finally {
|
|
684
|
+
ctx.groupDepth -= 1;
|
|
685
|
+
}
|
|
351
686
|
// 节上方的分隔线(KitDivider 实例;文字为空 = 纯线)
|
|
352
687
|
let divider = '';
|
|
353
688
|
if (g.divider !== false) {
|
|
@@ -357,19 +692,28 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
357
692
|
divider = host('KitDivider', did);
|
|
358
693
|
}
|
|
359
694
|
const grpPart = g.surface !== undefined ? kitContainerPartOf(g.surface) : KIT_PART_SECTION;
|
|
360
|
-
|
|
695
|
+
// next:对象内的分组自报「节」;data-kit-part 已有存量值(section / 容器部件),按约定保留不改
|
|
696
|
+
const grpAttrs = `${g.surface !== undefined ? ` ${KIT_ATTR_SURFACE}="${esc(g.surface)}"` : ''}${g.emphasis !== undefined ? ` ${KIT_ATTR_EMPHASIS}="${esc(g.emphasis)}"` : ''} ${KIT_ATTR_PART}="${esc(grpPart)}"${nextLevel(ctx, 'section')}`;
|
|
697
|
+
// summary 分组 section 吃容器边框/圆角规则,在抽屉等非 flat 容器内需有卡片内边距,避免文字紧贴圆角边框
|
|
698
|
+
const sectionCls = nextLevelClass(ctx, 'section', slot === 'summary' ? joinClasses(layout.sectionClass, 'p-card') : layout.sectionClass);
|
|
699
|
+
// 节说明(groups[i].description):节标题下一行弱化小字;描述列表节(summary)的 section 由标题命名(aria-labelledby,描述列表卡 §2)
|
|
700
|
+
const descHtml = g.description !== undefined ? `<p${attr('class', KIT_DESC_GROUP_DESC_CLASS)}>${esc(g.description)}</p>` : '';
|
|
701
|
+
const labelled = slot === 'summary' ? ` aria-labelledby="${esc(g.id)}__title"` : '';
|
|
702
|
+
// next:静态分组 section 补与 spatial/expand 1:1 对应的锚点(sectionAnchor),legacy 不变
|
|
703
|
+
const secAnchorAttr = ctx.next && idOf === undefined ? ` data-soma-id="${esc(sectionAnchor(ctx.object, slot, i))}"` : '';
|
|
361
704
|
if (!g.collapsible) {
|
|
362
|
-
|
|
705
|
+
// 外观声明(D-08):分组 section 声明 card(与删标签名规则前渲染一致)
|
|
706
|
+
return `${divider}<section${secAnchorAttr} ${KIT_ATTR_CONTAINER}="card"${grpAttrs}${labelled}${attr('class', sectionCls)}><h4${slot === 'summary' ? ` id="${esc(g.id)}__title"` : ''}${attr('class', layout.titleClass)} ${KIT_ATTR_PART}="${KIT_PART_TITLE_SECTION}">${esc(g.title)}</h4>${descHtml}${inner}</section>`;
|
|
363
707
|
}
|
|
364
708
|
// 可折叠:标题是 h4 里的 button(aria-expanded + aria-controls),折叠体是块级 div(hidden 不和 flex / grid 同元素),初态按 open 写好
|
|
365
|
-
const btn = `<button type="button" id="${esc(g.id)}__btn"${attr('class', KIT_CLASS_DEFAULTS.groupToggle)}
|
|
709
|
+
const btn = `<button type="button" id="${esc(g.id)}__btn"${attr('class', KIT_CLASS_DEFAULTS.groupToggle)} ${KIT_ATTR_COLLAPSE_TOGGLE}="" aria-expanded="${g.open ? 'true' : 'false'}" aria-controls="${esc(g.id)}">`
|
|
366
710
|
+ `<span>${esc(g.title)}</span>`
|
|
367
|
-
+ `<span${attr('class', KIT_CLASS_DEFAULTS.groupMark)} aria-hidden="true"
|
|
711
|
+
+ `<span${attr('class', KIT_CLASS_DEFAULTS.groupMark)} aria-hidden="true" ${KIT_ATTR_COLLAPSE_MARK}="" ${KIT_ATTR_MARK_OPEN}="${markers[1]}" ${KIT_ATTR_MARK_CLOSED}="${markers[0]}">${g.open ? markers[1] : markers[0]}</span>`
|
|
368
712
|
+ '</button>';
|
|
369
|
-
const body = `<div id="${esc(g.id)}" role="region" aria-labelledby="${esc(g.id)}__btn"${attr('class', g.open ? '' : 'hidden')}>${inner}</div>`;
|
|
370
|
-
return `${divider}<section${grpAttrs}${attr('class',
|
|
713
|
+
const body = `<div id="${esc(g.id)}" role="region" aria-labelledby="${esc(g.id)}__btn" ${KIT_ATTR_CONTAINER}="plain"${attr('class', g.open ? '' : 'hidden')}>${inner}</div>`;
|
|
714
|
+
return `${divider}<section${secAnchorAttr} ${KIT_ATTR_CONTAINER}="card"${grpAttrs}${attr('class', sectionCls)}><h4${attr('class', layout.titleClass)} ${KIT_ATTR_PART}="${KIT_PART_TITLE_SECTION}">${btn}</h4>${descHtml}${body}</section>`;
|
|
371
715
|
}).join('');
|
|
372
|
-
const wrap = `<div${attr('class', layout.wrapClass)}${layout.collapsible ?
|
|
716
|
+
const wrap = `<div${attr('class', layout.wrapClass)}${layout.collapsible ? ` ${KIT_ATTR_COLLAPSE_ROOT}=""` : ''}>${sections}</div>`;
|
|
373
717
|
if (!layout.collapsible) return wrap;
|
|
374
718
|
// 隐藏接线件紧跟在折叠根之后(放进根里会在 flex 容器里多占一个 gap)
|
|
375
719
|
const wireId = `${layout.groups[0]!.id}__wire`;
|
|
@@ -387,11 +731,12 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
387
731
|
|
|
388
732
|
export function groupTabBarAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gbar`; }
|
|
389
733
|
export function groupTabAnchor(object: string, slot: KitViewSlot, index: number | string): string { return `${object}__${slot}__gtab__${index}`; }
|
|
734
|
+
export function sectionAnchor(object: string, slot: KitViewSlot, index: number): string { return `${object}__${slot}__sec_${index}`; }
|
|
390
735
|
export function groupPanelAnchor(object: string, slot: KitViewSlot, index: number | string): string { return `${object}__${slot}__gpanel__${index}`; }
|
|
391
736
|
export function groupTabWireAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gwire`; }
|
|
392
737
|
|
|
393
738
|
// 分组页签的类:页签呈现唯一出口 recipes/tabs(与页内页签 / 外壳页签条同一套)
|
|
394
|
-
const GROUPS_AS = { barClass: `mb-4 ${kitTabRecipe().bar}
|
|
739
|
+
const GROUPS_AS = { barClass: `mb-4 ${kitTabRecipe().bar}` };
|
|
395
740
|
|
|
396
741
|
/**
|
|
397
742
|
* groups 呈现为页签:tablist + 若干 tab 按钮 + 各组面板(首签显示,其余外层 hidden)。
|
|
@@ -409,7 +754,13 @@ function renderGroupTabs(
|
|
|
409
754
|
): string {
|
|
410
755
|
const object = ctx.object;
|
|
411
756
|
const panelHtml = layout.groups.map((g, i) => {
|
|
412
|
-
|
|
757
|
+
ctx.groupDepth += 1;
|
|
758
|
+
let inner: string;
|
|
759
|
+
try {
|
|
760
|
+
inner = renderArrangement(ctx, slot, g.layout, valueOf, `${at}.groups[${i}]`, showInto, idOf);
|
|
761
|
+
} finally {
|
|
762
|
+
ctx.groupDepth -= 1;
|
|
763
|
+
}
|
|
413
764
|
let divider = '';
|
|
414
765
|
if (g.divider !== false) {
|
|
415
766
|
const did = `${g.id}__div`;
|
|
@@ -434,9 +785,18 @@ export function groupTabsFrame(
|
|
|
434
785
|
wrapClass: string,
|
|
435
786
|
showInto: Record<string, unknown>,
|
|
436
787
|
components: Set<string>,
|
|
788
|
+
/** 看板的面板组页签:整块是一张页签面、页签条是面头(通栏贴面上缘);缺省 = 在对象面里,下划线页签条 */
|
|
789
|
+
onCanvas = false,
|
|
437
790
|
): string {
|
|
438
|
-
|
|
439
|
-
|
|
791
|
+
// data-kit-tab-text:结构 CSS 按选中字重预留宽度,切换选中不位移(KT-K-tabs-2)
|
|
792
|
+
// KT-K-tabs-3(§6.1 G-16):放不下的尾部页签编译期估宽、按容器档隐藏并收进「更多」,选中页签恒可见
|
|
793
|
+
const overflow = projectTabOverflow(titles, kitTabRecipe().tab);
|
|
794
|
+
const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}" ${KIT_TAB_TEXT_ATTR}="${esc(title)}"${attr('class', overflow.tabClasses[i])}>${esc(title)}</button>`).join('');
|
|
795
|
+
const moreShell = overflow.hasMore
|
|
796
|
+
? `<div${attr('class', `${overflow.moreClass} -mb-px`)}><div data-soma-component="KitActionMore" data-soma-id="${esc(`${object}__${slot}__gmore`)}"></div></div>`
|
|
797
|
+
: '';
|
|
798
|
+
if (overflow.hasMore) components.add('KitActionMore');
|
|
799
|
+
const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}" ${KIT_ATTR_TAB_PANEL}=""${i === 0 ? '' : ' hidden'}>${inner}</div>`).join('');
|
|
440
800
|
const wireId = groupTabWireAnchor(object, slot);
|
|
441
801
|
components.add('KitTabsWiring');
|
|
442
802
|
showInto[wireId] = {
|
|
@@ -447,9 +807,14 @@ export function groupTabsFrame(
|
|
|
447
807
|
ids: titles.map((_t, i) => String(i)),
|
|
448
808
|
},
|
|
449
809
|
};
|
|
450
|
-
const bar = `<div data-soma-id="${esc(groupTabBarAnchor(object, slot))}" role="tablist"${attr('class', GROUPS_AS.barClass)}>${buttons}</div>`;
|
|
810
|
+
const bar = `<div data-soma-id="${esc(groupTabBarAnchor(object, slot))}" role="tablist"${attr('class', onCanvas ? KIT_TAB_BAR_FACE_CLASS : GROUPS_AS.barClass)}>${buttons}${moreShell}</div>`;
|
|
451
811
|
const wiring = `<div data-soma-component="KitTabsWiring" data-soma-id="${esc(wireId)}" hidden></div>`;
|
|
452
|
-
|
|
812
|
+
// 页签面(看板的面板组页签,§11.17 第 2 组):外层是一张面(类由调用方给 KIT_TAB_FACE_CLASS),页签条是面头
|
|
813
|
+
// next 下自报「面」层级并按单一值输出剥离 wrapClass 的面外观类,不再输出旧 data-kit-container="card";legacy 逐字节不变
|
|
814
|
+
const nextFace = onCanvas && kitIsNextPipeline();
|
|
815
|
+
const face = onCanvas ? ` ${KIT_ATTR_TAB_FACE}=""${nextFace ? kitSelfAttrs({ level: 'face' }) : ` ${KIT_ATTR_CONTAINER}="card"`}` : '';
|
|
816
|
+
const finalWrapClass = nextFace ? kitSingleValueClasses('face', wrapClass) : wrapClass;
|
|
817
|
+
return `<div ${KIT_ATTR_TABS_FRAME}=""${face}${attr('class', finalWrapClass)}>${bar}${wiring}${panelEls}</div>`;
|
|
453
818
|
}
|
|
454
819
|
|
|
455
820
|
// ---------------------------------------------------------------- list
|
|
@@ -458,7 +823,11 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
|
|
|
458
823
|
return actions.map((a) => ({
|
|
459
824
|
id: a.id,
|
|
460
825
|
name: a.name,
|
|
826
|
+
...(typeof a.icon === 'string' && a.icon !== '' ? { icon: a.icon } : {}),
|
|
827
|
+
...(a.iconOnly === true || (typeof a.icon === 'string' && a.icon !== '' && a.name === '') ? { iconOnly: true } : {}),
|
|
461
828
|
...(a.tone !== undefined ? { tone: a.tone } : {}),
|
|
829
|
+
// SCON-169:功能名透传(声明的,或按 builtin / id 推断的;推不出不带)——行操作 / 右键菜单 / 详情头按钮组按功能名取角色,显式 tone 仍优先
|
|
830
|
+
...functionItemOf(a),
|
|
462
831
|
...(a.builtin !== undefined ? { builtin: a.builtin } : {}),
|
|
463
832
|
...(a.targetOverlay !== undefined ? { target: a.targetOverlay } : {}),
|
|
464
833
|
// K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
|
|
@@ -469,6 +838,12 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
|
|
|
469
838
|
}));
|
|
470
839
|
}
|
|
471
840
|
|
|
841
|
+
/** 动作项的功能名(SCON-169):判据 actionFunctionOf(= table-actions#kitActionFunctionOfDecl);推不出不带这个键 */
|
|
842
|
+
function functionItemOf(a: KitAction): { function?: KitActionFunction } {
|
|
843
|
+
const fn = actionFunctionOf(a);
|
|
844
|
+
return fn !== null ? { function: fn } : {};
|
|
845
|
+
}
|
|
846
|
+
|
|
472
847
|
/** 动作的置灰原因:字面量文案(非空)原样带;路径形与非法值不带(路径进 actionState,非法值已在入口记诊断) */
|
|
473
848
|
function literalReason(a: KitAction): { disabledReason?: string } {
|
|
474
849
|
const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
|
|
@@ -480,6 +855,15 @@ function literalReason(a: KitAction): { disabledReason?: string } {
|
|
|
480
855
|
* { 动作id: { hidden?, disabled? } },叶子是 core 行路径(行变量.<字段>),由 core 在行模板里逐行求值。
|
|
481
856
|
* 返回要并进 prop 的 { actionState };没有绑定返回空对象。非法写法已在 emitStatic 入口记过诊断,这里只收合法的。
|
|
482
857
|
*/
|
|
858
|
+
/**
|
|
859
|
+
* 主从页详情头动作区(KitTableActions look: button)的 props:与行内操作同一套动作项与行级状态绑定(disabled / hidden / disabledReason),
|
|
860
|
+
* 只是「行」换成选中行镜像(rowPath = 链接作用域上的 link_sel_row 路径):`row.<字段>` 编成 `<rowPath>.<字段>`,点击抛的 row 载荷也取它,与行内点击发出的同形。
|
|
861
|
+
*/
|
|
862
|
+
export function headActionProps(actions: readonly KitAction[], rowPath: string): Record<string, unknown> {
|
|
863
|
+
const stub = { rowVar: rowPath } as Ctx;
|
|
864
|
+
return { actions: actionItems(actions, stub), ...actionStateProp(actions, stub), row: rowPath };
|
|
865
|
+
}
|
|
866
|
+
|
|
483
867
|
function actionStateProp(actions: readonly KitAction[], ctx: Ctx): { actionState?: Record<string, Record<string, string>> } {
|
|
484
868
|
const state: Record<string, Record<string, string>> = {};
|
|
485
869
|
for (const a of actions) {
|
|
@@ -545,7 +929,11 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
545
929
|
|
|
546
930
|
const tools = layout.tools === true && layout.tree === null;
|
|
547
931
|
const selHead = layout.selectHeadClass ?? layout.selectClass;
|
|
548
|
-
|
|
932
|
+
// 操作列表头的对齐跟行内操作格走(集合规划给的类里带 justify-start = 按内容求列宽,从起始边排;否则靠末端)
|
|
933
|
+
const actBase = layout.actionsHeadClass ?? layout.actionsClass;
|
|
934
|
+
const actHead = joinClasses(actBase, /(?:^|\s)justify-start(?:\s|$)/.test(actBase) ? 'whitespace-nowrap text-start' : 'whitespace-nowrap text-end justify-end');
|
|
935
|
+
const moreHeadBase = layout.moreActionsHeadClass ?? layout.moreActionsClass ?? '';
|
|
936
|
+
const moreHead = layout.hasMoreColumn === true ? joinClasses(moreHeadBase, 'whitespace-nowrap text-center justify-center') : '';
|
|
549
937
|
// 表格语义(W3C table 模式:table > row > columnheader / cell,aria-sort 在 columnheader 上):
|
|
550
938
|
// 树表(外壳由 KitTreeTable 自带 treegrid,表头在它之外)与展开详情行(行下挂非 row 的开关与详情体)不满足 table 的结构要求,这两种不写表格角色
|
|
551
939
|
const semTable = layout.tree === null && layout.expand === null;
|
|
@@ -556,6 +944,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
556
944
|
// 可排序 / 可筛选表头:页面直接实例 KitTableHead(view 切片 sort / order / cf_<字段> 的写者);整行由组件渲染
|
|
557
945
|
const cells: Array<Record<string, unknown>> = [];
|
|
558
946
|
if (layout.select !== 'none') cells.push({ label: '', sr: selectHeadLabel(ctx), class: selHead });
|
|
947
|
+
else if (layout.serial === true) cells.push({ label: '#', sr: serialHeadLabel(ctx), class: selHead });
|
|
948
|
+
else if (layout.reorder !== undefined) cells.push({ label: '', sr: reorderHeadLabel(ctx), class: selHead });
|
|
559
949
|
for (const h of layout.head) {
|
|
560
950
|
cells.push({
|
|
561
951
|
label: h.label, class: h.class,
|
|
@@ -568,7 +958,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
568
958
|
...(h.col !== undefined && gapCols.has(h.col) ? { gapField: h.col } : {}),
|
|
569
959
|
});
|
|
570
960
|
}
|
|
571
|
-
if (layout.rowActions.length > 0)
|
|
961
|
+
if (layout.rowActions.length > 0) {
|
|
962
|
+
cells.push({ label: opsHeadLabel(ctx), class: actHead, ops: true });
|
|
963
|
+
if (layout.hasMoreColumn === true) cells.push({ label: layout.moreHeader ?? '', class: moreHead, ops: true });
|
|
964
|
+
}
|
|
572
965
|
ctx.components.add('KitTableHead');
|
|
573
966
|
ctx.show[headAnchor(object)] = {
|
|
574
967
|
props: {
|
|
@@ -579,10 +972,12 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
579
972
|
...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
|
|
580
973
|
},
|
|
581
974
|
};
|
|
582
|
-
head = host('KitTableHead', headAnchor(object));
|
|
975
|
+
head = layout.contentTracks === true ? trackHost('KitTableHead', headAnchor(object), CONTENT_TRACK_PASS_CLASS) : host('KitTableHead', headAnchor(object));
|
|
583
976
|
} else {
|
|
584
977
|
const headParts: string[] = [];
|
|
585
978
|
if (layout.select !== 'none') headParts.push(`<div${headRole}${attr('class', selHead)}><span class="sr-only">${esc(selectHeadLabel(ctx))}</span></div>`);
|
|
979
|
+
else if (layout.serial !== true && layout.reorder !== undefined) headParts.push(`<div${headRole}${attr('class', selHead)}><span class="sr-only">${esc(reorderHeadLabel(ctx))}</span></div>`);
|
|
980
|
+
else if (layout.serial === true) headParts.push(`<div${headRole}${attr('class', selHead)}><span aria-hidden="true">#</span><span class="sr-only">${esc(serialHeadLabel(ctx))}</span></div>`);
|
|
586
981
|
// 多级表头:同组的连续叶子收进一个组块(flex 列:组标题格 + 叶子行);块与叶子行是 presentation,叶子 / 标题格仍直属表头行
|
|
587
982
|
const groups = layout.headGroups ?? [];
|
|
588
983
|
let openGroup = -1;
|
|
@@ -592,13 +987,13 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
592
987
|
const g = groups[openGroup]!;
|
|
593
988
|
const pres = semTable ? ' role="presentation"' : '';
|
|
594
989
|
const title = `<div${semTable ? ` role="columnheader" aria-colspan="${g.span}"` : ''}${attr('class', g.titleClass)}>${esc(g.title)}</div>`;
|
|
595
|
-
headParts.push(`<div${pres}
|
|
990
|
+
headParts.push(`<div${pres} ${KIT_ATTR_GROUP_COLS}="${esc(g.cols.join(','))}"${attr('class', g.blockClass)}>${title}<div${pres}${attr('class', g.leavesClass)}>${leaves.join('')}</div></div>`);
|
|
596
991
|
openGroup = -1;
|
|
597
992
|
leaves = [];
|
|
598
993
|
};
|
|
599
994
|
for (const h of layout.head) {
|
|
600
995
|
if (h.group !== openGroup) flushGroup();
|
|
601
|
-
const leaf = `<div${headRole}${tools && h.col !== undefined ? `
|
|
996
|
+
const leaf = `<div${headRole}${tools && h.col !== undefined ? ` ${KIT_ATTR_COL}="${esc(h.col)}"` : ''}${h.col !== undefined && gapCols.has(h.col) ? ` ${KIT_TABLE_GAP_HEAD_ATTR}="${esc(h.col)}"` : ''}${tools && h.resizable === true ? ` ${KIT_ATTR_RESIZABLE}=""` : ''}${attr('class', h.class)}${nextPart(ctx, 'field-name')}>${esc(h.label)}${kitHelpButtonHtml(h.help ?? '', h.label, ctx.options.locale ?? '')}</div>`;
|
|
602
997
|
if (h.group === undefined) headParts.push(leaf);
|
|
603
998
|
else {
|
|
604
999
|
openGroup = h.group;
|
|
@@ -606,8 +1001,17 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
606
1001
|
}
|
|
607
1002
|
}
|
|
608
1003
|
flushGroup();
|
|
609
|
-
if (layout.rowActions.length > 0)
|
|
610
|
-
|
|
1004
|
+
if (layout.rowActions.length > 0) {
|
|
1005
|
+
headParts.push(`<div${headRole} ${KIT_OPS_HEAD_ATTR}=""${attr('class', actHead)}${nextPart(ctx, 'field-name')}>${esc(opsHeadLabel(ctx))}</div>`);
|
|
1006
|
+
if (layout.hasMoreColumn === true) {
|
|
1007
|
+
headParts.push(`<div${headRole} ${KIT_OPS_HEAD_ATTR}=""${attr('class', moreHead)}${nextPart(ctx, 'field-name')}>${esc(layout.moreHeader ?? '')}</div>`);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
// next:表头带自报「面头」(data-kit-part 已是存量值 table-head,保留);
|
|
1011
|
+
// value-table 对 table-head 显式排除了 head 的 padding-inline,因此必须保回与数据行共享的水平内边距(px-/ps-/pe-),避免表头与数据行错位
|
|
1012
|
+
const headInlinePad = layout.headClass.split(/\s+/).filter((t) => /^(?:@[a-z0-9-]+:)?p[xse]-/.test(t)).join(' ');
|
|
1013
|
+
const headClassOut = joinClasses(nextLevelClass(ctx, 'head', layout.headClass), headInlinePad);
|
|
1014
|
+
head = `<div${semTable ? ' role="row"' : ''}${attr('class', headClassOut)} ${KIT_ATTR_PART}="${KIT_PART_TABLE_HEAD}"${nextLevel(ctx, 'head')}>${headParts.join('')}</div>`;
|
|
611
1015
|
}
|
|
612
1016
|
|
|
613
1017
|
// 树表:列 / 表头 / 三态 / 分页与普通表格同一条路径,只有表体换成 KitTreeTable(层级 + 展开状态在组件里)
|
|
@@ -638,12 +1042,13 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
638
1042
|
let treeCtx = '';
|
|
639
1043
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
640
1044
|
ctx.components.add('KitContextMenu');
|
|
641
|
-
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
|
|
1045
|
+
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host', ...removeBusyProps(ctx) } };
|
|
642
1046
|
treeCtx = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
643
1047
|
}
|
|
644
1048
|
const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
645
|
-
const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
646
|
-
const
|
|
1049
|
+
const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)} ${KIT_ATTR_CONTAINER}="plain"` : '';
|
|
1050
|
+
const treeInstAnchor = ctx.next ? ` data-soma-id="${esc(viewAnchor(object, 'list'))}"` : '';
|
|
1051
|
+
const treeBody = `<div${treeInstAnchor}${attr('class', layout.wrapClass)}${treeWrapA11y}${treeCtx !== '' ? ` ${KIT_ATTR_CTXHOST}=""` : ''}${gridMark(layout)} ${KIT_ATTR_TREE_OF}="${esc(object)}" ${KIT_TIPS_SCOPE_ATTR}=""><div${attr('class', layout.innerClass)}>${head}${host('KitTreeTable', id)}${treeCtx}</div></div>`;
|
|
647
1052
|
return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
648
1053
|
}
|
|
649
1054
|
|
|
@@ -664,43 +1069,69 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
664
1069
|
...removeBusyProps(ctx),
|
|
665
1070
|
},
|
|
666
1071
|
};
|
|
667
|
-
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('KitTableActions', selAnchor(object))}</div>`);
|
|
1072
|
+
rowParts.push(`<div${cellRoleAttr(cellRole)} ${KIT_ATTR_LEAD}="" ${KIT_ATTR_PART}="${KIT_PART_TABLE_CELL}"${attr('class', layout.selectClass)}>${layout.serial === true ? `${SERIAL_BESIDE_OPEN}${host('KitTableActions', selAnchor(object))}${SERIAL_NODE}</div>` : host('KitTableActions', selAnchor(object))}</div>`);
|
|
668
1073
|
} else {
|
|
669
1074
|
ctx.components.add('Checkbox');
|
|
670
1075
|
rowShow[selAnchor(object)] = { props: {} };
|
|
671
|
-
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('Checkbox', selAnchor(object))}</div>`);
|
|
1076
|
+
rowParts.push(`<div${cellRoleAttr(cellRole)} ${KIT_ATTR_LEAD}="" ${KIT_ATTR_PART}="${KIT_PART_TABLE_CELL}"${attr('class', layout.selectClass)}>${layout.serial === true ? `${SERIAL_BESIDE_OPEN}${host('Checkbox', selAnchor(object))}${SERIAL_NODE}</div>` : host('Checkbox', selAnchor(object))}</div>`);
|
|
672
1077
|
}
|
|
1078
|
+
} else if (layout.serial === true || layout.reorder !== undefined) {
|
|
1079
|
+
// 只有序号列 / 拖拽柄:与选择列同槽位同宽(data-kit-lead 供 KitTableTools 放拖拽柄),序号列格内一个空序号节点
|
|
1080
|
+
rowParts.push(`<div${cellRoleAttr(cellRole)} ${KIT_ATTR_LEAD}="" ${KIT_ATTR_PART}="${KIT_PART_TABLE_CELL}"${attr('class', layout.selectClass)}>${layout.serial === true ? SERIAL_NODE : ''}</div>`);
|
|
673
1081
|
}
|
|
674
1082
|
layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, gapCols.get(c.field) ?? c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
|
|
675
1083
|
if (layout.rowActions.length > 0) {
|
|
676
1084
|
ctx.components.add('KitTableActions');
|
|
677
1085
|
rowShow[opsAnchor(object)] = {
|
|
678
|
-
props: {
|
|
1086
|
+
props: {
|
|
1087
|
+
actions: actionItems(layout.rowActions, ctx),
|
|
1088
|
+
...(layout.maxInline !== undefined ? { maxInline: layout.maxInline } : {}),
|
|
1089
|
+
...(layout.hasMoreColumn === true
|
|
1090
|
+
? {
|
|
1091
|
+
splitMoreColumn: true,
|
|
1092
|
+
inlineCellClass: layout.actionsClass,
|
|
1093
|
+
moreCellClass: layout.moreActionsClass ?? '',
|
|
1094
|
+
...(cellRole !== '' ? { cellRole } : {}),
|
|
1095
|
+
}
|
|
1096
|
+
: (layout.maxInline !== undefined ? { hideMore: true } : {})),
|
|
1097
|
+
...actionStateProp(layout.rowActions, ctx),
|
|
1098
|
+
row: ctx.rowVar,
|
|
1099
|
+
...rowToneProp(layout, ctx),
|
|
1100
|
+
...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
|
|
1101
|
+
...removeBusyProps(ctx),
|
|
1102
|
+
...selectedProps(ctx),
|
|
1103
|
+
...(layout.tools === true && (layout.batch?.length ?? 0) > 0 && ctx.options.selectedPath !== undefined ? { bulkLock: true } : {}),
|
|
1104
|
+
},
|
|
679
1105
|
};
|
|
680
|
-
|
|
1106
|
+
if (layout.hasMoreColumn === true) {
|
|
1107
|
+
rowParts.push(trackHost('KitTableActions', opsAnchor(object), CONTENT_TRACK_PASS_CLASS));
|
|
1108
|
+
} else {
|
|
1109
|
+
rowParts.push(`<div${cellRoleAttr(cellRole)} ${KIT_ATTR_PART}="${KIT_PART_TABLE_CELL}" ${KIT_OPS_CELL_ATTR}=""${attr('class', layout.actionsClass)}>${host('KitTableActions', opsAnchor(object))}</div>`);
|
|
1110
|
+
}
|
|
681
1111
|
}
|
|
682
1112
|
// pickOnRow 或行样式档位(rowTone)且没有行操作列:补一个无按钮的 KitTableActions 实例,专管行点击 / 行样式
|
|
683
1113
|
if ((ctx.options.pickOnRow === true || layout.rowTone !== undefined) && layout.rowActions.length === 0) {
|
|
684
1114
|
ctx.components.add('KitTableActions');
|
|
685
1115
|
rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) } };
|
|
686
|
-
rowParts.push(host('KitTableActions', opsAnchor(object)));
|
|
1116
|
+
rowParts.push(layout.contentTracks === true ? trackHost('KitTableActions', opsAnchor(object), CONTENT_TRACK_IDLE_CLASS) : host('KitTableActions', opsAnchor(object)));
|
|
687
1117
|
}
|
|
688
1118
|
// 右键菜单(Q 波 G6):行内一个 KitContextMenu 实例(包在 hidden 壳里,不占栅格列),行容器标 data-kit-ctx 供它监听
|
|
689
1119
|
const ctxItems = layout.contextMenu ?? [];
|
|
690
1120
|
if (ctxItems.length > 0) {
|
|
691
1121
|
ctx.components.add('KitContextMenu');
|
|
692
|
-
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
|
|
1122
|
+
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar, ...removeBusyProps(ctx) } };
|
|
693
1123
|
rowParts.push(`<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`);
|
|
694
1124
|
}
|
|
695
1125
|
const rowClass = ctx.options.pickOnRow === true ? joinClasses(layout.rowClass, 'cursor-pointer') : layout.rowClass;
|
|
696
1126
|
// 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
|
|
697
1127
|
const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
|
|
698
|
-
const rowMark = `${marked ?
|
|
1128
|
+
const rowMark = `${marked ? ` ${KIT_ATTR_ROW}=""` : ''}${ctxItems.length > 0 ? ` ${KIT_ATTR_CTX}=""` : ''}`;
|
|
699
1129
|
// 普通表格的行容器首子节点是 <template>,数据行从第 2 个子节点起:斑马纹用 odd 键(树表 / 虚拟表无 template,走 IR 里的 even 键)
|
|
700
1130
|
const striped = layout.stripeClass !== '';
|
|
701
1131
|
const stripe = striped ? KIT_CLASS_DEFAULTS.tableRowStripedAfterTemplate : '';
|
|
702
1132
|
const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInnerAfterTemplate) : rowClass;
|
|
703
|
-
|
|
1133
|
+
// next:每一行自报「条目」(data-kit-part 已是存量值 table-row,保留;元素部件「行」因此不另写)
|
|
1134
|
+
const rowEl = `<div${semTable ? ' role="row"' : ''}${attr('class', nextLevelClass(ctx, 'item', layout.expand === null ? joinClasses(rowClass, stripe) : expandRowClass))}${rowMark} ${KIT_ATTR_PART}="${KIT_PART_TABLE_ROW}"${nextLevel(ctx, 'item')}>${rowParts.join('')}</div>`;
|
|
704
1135
|
let itemHtml = rowEl;
|
|
705
1136
|
if (layout.expand !== null) {
|
|
706
1137
|
// 展开行:行下一条“展开详情”开关(KitTableActions expand)+ 默认 hidden 的详情体;开合状态在开关组件里
|
|
@@ -716,17 +1147,26 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
716
1147
|
const detail = listExpand !== undefined ? '' : renderArrangement(
|
|
717
1148
|
ctx, 'summary', layout.expand.layout, (f) => `${ctx.rowVar}.${f}`, `${at}.expand`, rowShow, (f) => expandCellAnchor(object, f),
|
|
718
1149
|
);
|
|
719
|
-
itemHtml = `<div${attr('class', striped ? joinClasses(stripe, KIT_CLASS_DEFAULTS.tableRowStripedExpandOuter) : stripe)}
|
|
1150
|
+
itemHtml = `<div${attr('class', striped ? joinClasses(stripe, KIT_CLASS_DEFAULTS.tableRowStripedExpandOuter) : stripe)} ${KIT_ATTR_EXPAND_ROW}="">${rowEl}`
|
|
720
1151
|
+ `<div${attr('class', EXPAND_TOGGLE_CLASS)}>${host('KitTableActions', expandToggleAnchor(object))}</div>`
|
|
721
|
-
|
|
1152
|
+
// next:嵌在行里的展开内容自报「子块」
|
|
1153
|
+
+ `<div class="hidden" ${KIT_ATTR_EXPAND_BODY}=""><div${attr('class', nextLevelClass(ctx, 'sub', joinClasses(layout.bordered === false ? 'sub-block px-4 py-3' : EXPAND_BODY_CLASS, layout.scroll === true ? EXPAND_VIEWPORT_CLASS : '')))}${nextLevel(ctx, 'sub')}>${detail}</div></div></div>`;
|
|
722
1154
|
}
|
|
723
1155
|
const rowTemplate = `<template data-soma-role="item">${itemHtml}</template>`;
|
|
724
|
-
const
|
|
1156
|
+
const passClass = layout.contentTracks === true ? ` class="${CONTENT_TRACK_PASS_CLASS}"` : '';
|
|
1157
|
+
const rows = `<div data-soma-id="${esc(rowsAnchor(object))}"${tools ? ` ${KIT_ATTR_ROWS}=""` : ''}${passClass}>${rowTemplate}</div>`;
|
|
1158
|
+
// 置顶行(B1-3):同一个行模板绑 focus.pinned 镜像,排在常规行之前(与排序无关);不标 data-kit-rows(不算本页行,全选本页不含它)
|
|
1159
|
+
const pinnedPath = ctx.options.pinnedPath;
|
|
1160
|
+
// 页面是一个统一寻址空间(core CORE-ANCHOR-DUPLICATE:行模板里的锚点也算):置顶副本的行内锚点一律加后缀,show / 事件同样改名
|
|
1161
|
+
const pinnedRows = pinnedPath !== undefined && pinnedPath !== ''
|
|
1162
|
+
? `<div data-soma-id="${esc(pinnedRowsAnchor(object))}" ${KIT_ROWS_PINNED_ATTR}=""${passClass}>${pinnedRowTemplate(rowTemplate)}</div>`
|
|
1163
|
+
: '';
|
|
1164
|
+
if (pinnedRows !== '') ctx.show[pinnedRowsAnchor(object)] = { bind: { obj: pinnedPath!, var: ctx.rowVar }, show: pinnedRowKeys(structuredClone(rowShow)) };
|
|
725
1165
|
|
|
726
1166
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
727
1167
|
|
|
728
1168
|
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
729
|
-
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
1169
|
+
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)} ${KIT_ATTR_CONTAINER}="plain"` : '';
|
|
730
1170
|
const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
|
|
731
1171
|
const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
|
|
732
1172
|
// 静态表头(不可排序)的整列缺失原因标注由 KitTableGap 接线件画;可排序表头由 KitTableHead 自己画(上面已给 rows)
|
|
@@ -737,7 +1177,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
737
1177
|
ctx.show[gapId] = { props: { rows: ctx.rowsPath, fields: [...gapCols.keys()] } };
|
|
738
1178
|
gapHost = host('KitTableGap', gapId);
|
|
739
1179
|
}
|
|
740
|
-
|
|
1180
|
+
// 按真实内容求列宽的表壳打标记(体检事实;表恒铺满所在的面,不随内容收窄)
|
|
1181
|
+
const fitMark = layout.contentTracks === true ? ` ${KIT_TABLE_FIT_ATTR}=""` : '';
|
|
1182
|
+
const listInstAnchor = ctx.next ? ` data-soma-id="${esc(viewAnchor(object, 'list'))}"` : '';
|
|
1183
|
+
const body = `<div${listInstAnchor}${attr('class', layout.wrapClass)}${fitMark}${wrapA11y}${tools ? ` ${KIT_ATTR_TABLE}="" ${KIT_ATTR_TABLE_OF}="${esc(toolsAnchor(object))}"` : ''} ${KIT_ATTR_PART}="${KIT_PART_TABLE}"${gridMark(layout)} ${KIT_TIPS_SCOPE_ATTR}=""><div${tableA11y}${attr('class', layout.innerClass)}>${gapHost}${head}${pinnedRows}${rows}${summary}</div></div>`;
|
|
741
1184
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
742
1185
|
}
|
|
743
1186
|
|
|
@@ -778,12 +1221,13 @@ function renderVirtualTable(
|
|
|
778
1221
|
let ctxHost = '';
|
|
779
1222
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
780
1223
|
ctx.components.add('KitContextMenu');
|
|
781
|
-
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), rows: ctx.rowsPath, mode: 'virtual' } };
|
|
1224
|
+
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), rows: ctx.rowsPath, mode: 'virtual', ...removeBusyProps(ctx) } };
|
|
782
1225
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
783
1226
|
}
|
|
784
1227
|
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
785
|
-
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
|
|
786
|
-
const
|
|
1228
|
+
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)} ${KIT_ATTR_CONTAINER}="plain"` : '';
|
|
1229
|
+
const virtInstAnchor = ctx.next ? ` data-soma-id="${esc(viewAnchor(object, 'list'))}"` : '';
|
|
1230
|
+
const body = `<div${virtInstAnchor}${attr('class', layout.wrapClass)}${wrapA11y} ${KIT_ATTR_VSCROLL}=""${gridMark(layout)} ${KIT_TIPS_SCOPE_ATTR}=""${tools ? ` ${KIT_ATTR_TABLE}="" ${KIT_ATTR_TABLE_OF}="${esc(toolsAnchor(object))}"` : ''}>`
|
|
787
1231
|
+ `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
|
|
788
1232
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
789
1233
|
}
|
|
@@ -812,13 +1256,16 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
812
1256
|
items: layout.toolbar ?? [],
|
|
813
1257
|
scroll: layout.scroll === true,
|
|
814
1258
|
editMode: layout.editMode ?? '',
|
|
1259
|
+
...(layout.groupBy !== undefined ? { groupBy: layout.groupBy } : {}),
|
|
1260
|
+
...(layout.reorder !== undefined ? { reorder: layout.reorder } : {}),
|
|
815
1261
|
selectMode: layout.select,
|
|
816
1262
|
selectScope: layout.selectScope ?? 'all',
|
|
817
1263
|
...(batchOn
|
|
818
1264
|
? {
|
|
819
1265
|
selected: ctx.options.selectedPath,
|
|
820
1266
|
batch: batch.map((b) => {
|
|
821
|
-
|
|
1267
|
+
// 批量条的忙态名:批量动作所接的具名动作名(不是动作所在位置 on)
|
|
1268
|
+
const busyAction = namedActionOf(b.action, ctx.object);
|
|
822
1269
|
return {
|
|
823
1270
|
id: b.id,
|
|
824
1271
|
name: b.name,
|
|
@@ -840,24 +1287,37 @@ function renderSummary(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>
|
|
|
840
1287
|
if (layout.summary === undefined || layout.summary === null || layout.tree !== null) return '';
|
|
841
1288
|
const id = summaryAnchor(ctx.object);
|
|
842
1289
|
ctx.components.add('KitTableSummary');
|
|
1290
|
+
// 合计行固定选择/操作角格用与合计行一致的实底 bg-surface-band(合计行属于「带」,collection 线统一)与 z-20,防止横向滚动数字穿透固定列
|
|
1291
|
+
const summaryCorner = (cls: string): string => cls
|
|
1292
|
+
.replace(/\bbefore:bg-(?:surface-band|layer-head)\b/g, 'before:bg-surface-band')
|
|
1293
|
+
.replace(/\bbg-(?:surface-band|layer-head)\b/g, 'bg-surface-band')
|
|
1294
|
+
.replace(/\bz-10\b/g, 'z-20');
|
|
1295
|
+
const moreSummaryHead = layout.hasMoreColumn === true ? summaryCorner(layout.moreActionsHeadClass ?? layout.moreActionsClass ?? '') : '';
|
|
843
1296
|
ctx.show[id] = {
|
|
844
1297
|
props: {
|
|
845
1298
|
rows: ctx.rowsPath,
|
|
846
1299
|
class: layout.summaryRowClass ?? '',
|
|
847
1300
|
...(semTable ? { semantics: 'table' } : {}),
|
|
848
|
-
selectClass: layout.select !== 'none' ? selHead : '',
|
|
849
|
-
actionsClass: layout.rowActions.length > 0 ? actHead : '',
|
|
1301
|
+
selectClass: layout.select !== 'none' || layout.serial === true || layout.reorder !== undefined ? summaryCorner(selHead) : '',
|
|
1302
|
+
actionsClass: layout.rowActions.length > 0 ? (layout.hasMoreColumn === true ? moreSummaryHead : summaryCorner(actHead)) : '',
|
|
850
1303
|
label: layout.summary.label,
|
|
851
1304
|
labelField: layout.summary.labelField,
|
|
852
|
-
columns:
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1305
|
+
columns: [
|
|
1306
|
+
...layout.cells.map((c, i) => ({
|
|
1307
|
+
field: c.field,
|
|
1308
|
+
class: layout.summaryCellClasses?.[i] ?? '',
|
|
1309
|
+
...(layout.summary!.fields[c.field] !== undefined ? { op: layout.summary!.fields[c.field] } : {}),
|
|
1310
|
+
...(typeof c.props.format === 'string' ? { format: c.props.format } : {}),
|
|
1311
|
+
// D-09 ②:合计格与正文用同一组格式化 helper(base/text#kitFormatMeasureValue),正文值组件拿到的单位 / 币种 / 小数位一并交给合计行
|
|
1312
|
+
...(typeof c.props.unit === 'string' && c.props.unit !== '' ? { unit: c.props.unit } : {}),
|
|
1313
|
+
...(typeof c.props.currency === 'string' && c.props.currency !== '' ? { currency: c.props.currency } : {}),
|
|
1314
|
+
...(typeof c.props.decimals === 'number' ? { decimals: c.props.decimals } : {}),
|
|
1315
|
+
})),
|
|
1316
|
+
...(layout.rowActions.length > 0 && layout.hasMoreColumn === true ? [{ field: '', class: summaryCorner(actHead) }] : []),
|
|
1317
|
+
],
|
|
858
1318
|
},
|
|
859
1319
|
};
|
|
860
|
-
return host('KitTableSummary', id);
|
|
1320
|
+
return layout.contentTracks === true ? trackHost('KitTableSummary', id, CONTENT_TRACK_PASS_CLASS) : host('KitTableSummary', id);
|
|
861
1321
|
}
|
|
862
1322
|
|
|
863
1323
|
/** 骨架屏的形态参数:表格按列的跨度类(含选择 / 操作列),cards / stack 沿用列表容器类 */
|
|
@@ -876,7 +1336,7 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
|
|
|
876
1336
|
return shape === 'text' ? h.class : { cls: h.class, shape };
|
|
877
1337
|
});
|
|
878
1338
|
const cols: Array<string | KitSkeletonCol> = [
|
|
879
|
-
...(layout.select !== 'none' && layout.selectClass !== '' ? [layout.selectClass] : []),
|
|
1339
|
+
...((layout.select !== 'none' || layout.serial === true || layout.reorder !== undefined) && layout.selectClass !== '' ? [layout.selectClass] : []),
|
|
880
1340
|
...dataCols,
|
|
881
1341
|
...(layout.rowActions.length > 0 && layout.actionsClass !== '' ? [layout.actionsClass] : []),
|
|
882
1342
|
];
|
|
@@ -887,20 +1347,30 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
|
|
|
887
1347
|
|
|
888
1348
|
/** 展开行的开关条与详情体(语义色名 + 内置尺度) */
|
|
889
1349
|
const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
|
|
890
|
-
|
|
1350
|
+
// 展开行的内容是凹槽面:与上下行之间已有面差,不再加线(一处分隔一种手段,KT-B5 / D-30)
|
|
1351
|
+
// 展开行内容 = 子块角色(--soma-layer-sub),不直写井色
|
|
1352
|
+
const EXPAND_BODY_CLASS = 'sub-block px-4 py-3';
|
|
1353
|
+
/** 滚动模式(固定列 / min / columns / columnGroups / resizable)下的展开体:宽 = 表格可视宽(具名尺寸令牌 `--spacing-table-view` = 100cqw,表壳是 @container),横向滚动时贴起始边不跟着滚走 */
|
|
1354
|
+
const EXPAND_VIEWPORT_CLASS = 'sticky start-0 w-table-view max-w-table-view';
|
|
891
1355
|
|
|
892
1356
|
/** 标题与它旁边的集合辅助文字(共 N 条 / 已筛选提示)同一组:基线对齐、窄时换行 */
|
|
893
1357
|
const TITLE_GROUP_CLASS = 'flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1';
|
|
894
1358
|
|
|
1359
|
+
/** 集合空态/异常态舞台类:宿主保持 display:contents 并把直接子根(*:not-aria-busy)撑满居中,避免 0 行空态塌成左上角窄条,同时不干扰加载骨架且不波及孙级图标圆环 */
|
|
1360
|
+
const COLLECTION_STATE_ROOT_CLASS = 'flex flex-1 flex-col';
|
|
1361
|
+
const COLLECTION_STATE_HOST_CLASS = 'contents *:not-aria-busy:flex-1 *:not-aria-busy:flex-col *:not-aria-busy:items-center *:not-aria-busy:justify-center *:not-aria-busy:min-h-60 *:not-aria-busy:py-12 *:not-aria-busy:text-center *:not-aria-busy:gap-3';
|
|
1362
|
+
|
|
895
1363
|
/** 集合三态面板:列表之后、分页器之前 */
|
|
896
1364
|
function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
|
|
897
1365
|
if (state === null) return '';
|
|
898
1366
|
const id = stateAnchor(ctx.object);
|
|
899
1367
|
ctx.components.add('KitCollectionState');
|
|
1368
|
+
const stageCenter = state.errorOnly !== true;
|
|
900
1369
|
ctx.show[id] = {
|
|
901
1370
|
props: {
|
|
902
1371
|
data: ctx.basePath,
|
|
903
1372
|
rows: ctx.rowsPath,
|
|
1373
|
+
...(stageCenter ? { class: COLLECTION_STATE_ROOT_CLASS } : {}),
|
|
904
1374
|
config: {
|
|
905
1375
|
object: ctx.object,
|
|
906
1376
|
rowsPath: ctx.options.listShape.rows,
|
|
@@ -914,10 +1384,16 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
|
|
|
914
1384
|
...(state.errorOnly === true ? { mode: 'errorOnly' } : {}),
|
|
915
1385
|
// 筛选无结果 / 无数据的区分:本对象有筛选栏或表头筛选时,把作用域与清除入口交给三态面板(没有筛选的页面配置不变)
|
|
916
1386
|
...filteredConfig(ctx),
|
|
1387
|
+
// 选中切换加载态监听的作用域:无论对象有无筛选条,只要调用方给了 selectionScope 就下发给三态面板
|
|
1388
|
+
...(typeof ctx.options.selectionScope === 'string' && ctx.options.selectionScope !== '' ? { selectionScope: ctx.options.selectionScope } : {}),
|
|
1389
|
+
// 选中签名的主键字段(C3):调用方给了就原样下发,三态面板按它取选中键,与 focus.id 同一字符串口径
|
|
1390
|
+
...(typeof ctx.options.selectionKeyField === 'string' && ctx.options.selectionKeyField !== '' ? { selectionKeyField: ctx.options.selectionKeyField } : {}),
|
|
917
1391
|
},
|
|
918
1392
|
},
|
|
919
1393
|
};
|
|
920
|
-
return
|
|
1394
|
+
return stageCenter
|
|
1395
|
+
? `<div data-soma-component="KitCollectionState" data-soma-id="${esc(id)}" class="${COLLECTION_STATE_HOST_CLASS}"></div>`
|
|
1396
|
+
: host('KitCollectionState', id);
|
|
921
1397
|
}
|
|
922
1398
|
|
|
923
1399
|
/** 集合被筛选状态判断所需的配置:区域作用域、筛选栏宿主锚点(清除时优先点它的「重置」)、表头筛选键;对象没有任何筛选则为空 */
|
|
@@ -957,13 +1433,19 @@ function renderMeta(ctx: Ctx, plan: { count: boolean; hint: boolean }): string {
|
|
|
957
1433
|
}
|
|
958
1434
|
|
|
959
1435
|
/** 面板标题绑展示对象只读成员(view.list.title: view.<成员>):h3 里放一个 Text 实例,值是 page.<成员>,成员变了标题被动刷新 */
|
|
960
|
-
function renderDynamicTitle(ctx: Ctx, slot: KitViewSlot, path: string): string {
|
|
961
|
-
const id =
|
|
1436
|
+
function renderDynamicTitle(ctx: Ctx, slot: KitViewSlot, path: string, icon?: { readonly icon: string }, bodyHtml?: string): string {
|
|
1437
|
+
const id = viewTitleAnchor(ctx.object, slot, ctx.options.schema, bodyHtml);
|
|
962
1438
|
const textId = `${id}__text`;
|
|
963
1439
|
ctx.components.add('Text');
|
|
964
1440
|
ctx.show[textId] = { props: { value: viewPathToCore(path) } };
|
|
965
|
-
|
|
1441
|
+
if (icon !== undefined) {
|
|
1442
|
+
// 带标题图标:图标与标题行同一个出口(title-row),标题文字位换成绑定展示对象成员的 Text
|
|
1443
|
+
return kitPanelTitleHtml({ title: DYNAMIC_TITLE_SLOT, id, icon }).replace(`<span>${DYNAMIC_TITLE_SLOT}</span>`, `<span>${host('Text', textId)}</span>`);
|
|
1444
|
+
}
|
|
1445
|
+
return `<h3 data-soma-id="${esc(id)}" ${KIT_ATTR_PART}="${KIT_PART_TITLE_SECTION}" class="${KIT_PANEL_TITLE_CLASS}">${host('Text', textId)}</h3>`;
|
|
966
1446
|
}
|
|
1447
|
+
/** 动态标题在标题出口里的占位文字(不含 HTML 特殊字符,转义后原样,随即换成 Text 宿主) */
|
|
1448
|
+
const DYNAMIC_TITLE_SLOT = 'kit-dynamic-title-slot';
|
|
967
1449
|
|
|
968
1450
|
function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boolean; mode?: string; layout?: string; showTotal?: boolean } | null): string {
|
|
969
1451
|
if (pager === null) return '';
|
|
@@ -990,31 +1472,91 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
|
|
|
990
1472
|
function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>['compact']>, rowShow: Record<string, unknown>): string {
|
|
991
1473
|
const D = KIT_CLASS_DEFAULTS;
|
|
992
1474
|
const at = 'views.list.layout.compact';
|
|
1475
|
+
// 紧凑列表的格锚点即列表槽的单元锚点(页面线字段锚点),next 下按单一值输出处理
|
|
993
1476
|
const sized = (cell: KitCell): Record<string, unknown> => {
|
|
994
|
-
const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at);
|
|
1477
|
+
const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at, true, true);
|
|
995
1478
|
if (cell.component === 'Text' || cell.component === 'Tag') props.size ??= 'sm';
|
|
996
1479
|
return props;
|
|
997
1480
|
};
|
|
998
1481
|
const titleId = cellAnchor(ctx.object, 'list', compact.title.field);
|
|
999
1482
|
ctx.components.add(compact.title.component);
|
|
1000
|
-
|
|
1001
|
-
|
|
1483
|
+
const titleProps = sized(compact.title);
|
|
1484
|
+
// 紧凑列表标题文本自带 block min-w-0 truncate,避免长客户名 / 长接口名硬切或压盖右侧状态点与金额
|
|
1485
|
+
if (compact.title.component === 'Text' || compact.title.component === 'Link') {
|
|
1486
|
+
titleProps.class = joinClasses(typeof titleProps.class === 'string' ? titleProps.class : '', 'block min-w-0 truncate');
|
|
1487
|
+
}
|
|
1488
|
+
rowShow[titleId] = { props: titleProps };
|
|
1489
|
+
// 左窗格条目(主从页):第一行 = 名称 + 右侧状态(第一个 Tag 字段),第二行 = 等宽编码(其余文本字段,「·」分隔)+ 右侧类型标签(其余 Tag 字段)
|
|
1490
|
+
if (compact.pane === true) {
|
|
1491
|
+
// 标签类字段:Tag 组件,或枚举 / 布尔类型的字段(枚举的只读展示组件是 Text,按类型判)
|
|
1492
|
+
const isTag = (c: KitCell): boolean => {
|
|
1493
|
+
const type = ctx.options.schema?.[c.field]?.type;
|
|
1494
|
+
return c.component === 'Tag' || type === 'enum' || type === 'enums' || type === 'bool';
|
|
1495
|
+
};
|
|
1496
|
+
const tags = compact.meta.filter(isTag);
|
|
1497
|
+
const texts = compact.meta.filter((c) => !isTag(c));
|
|
1498
|
+
const tagHtml = (cell: KitCell): string => {
|
|
1499
|
+
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
1500
|
+
// 状态 / 类型标签一律是圆点 + 语义色文字(没有容器):枚举的只读展示组件是 Text(徽标呈现),在条目里换成 Tag 的 dot 变体(同一份 options / value)
|
|
1501
|
+
const comp = cell.component === 'Text' ? 'Tag' : cell.component;
|
|
1502
|
+
ctx.components.add(comp);
|
|
1503
|
+
const props = sized(cell);
|
|
1504
|
+
// 值带语气(单选枚举、选项带 tone)= 状态 → 圆点 + 文字;不带语气的分类 / 多值 / 布尔 = 标签(浅底小圆角)——状态与标签永不同形(KT-K-status-3)
|
|
1505
|
+
const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
|
|
1506
|
+
const opts = Array.isArray(props.options) ? (props.options as unknown[]) : Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
1507
|
+
const toned = field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>));
|
|
1508
|
+
// next:状态点形态归页面线的值呈现形态(单一值输出)
|
|
1509
|
+
if (!ctx.next && toned && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1510
|
+
rowShow[id] = { props };
|
|
1511
|
+
return `<span${attr('class', D.paneTag)}>${host(comp, id)}</span>`;
|
|
1512
|
+
};
|
|
1513
|
+
const textHtml = texts.map((cell, i) => {
|
|
1514
|
+
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
1515
|
+
ctx.components.add(cell.component);
|
|
1516
|
+
const props = sized(cell);
|
|
1517
|
+
const type = ctx.options.schema?.[cell.field]?.type;
|
|
1518
|
+
const numeric = isNumericColumnType(type);
|
|
1519
|
+
if (cell.component === 'Text') {
|
|
1520
|
+
props.class = joinClasses(typeof props.class === 'string' ? props.class : '', numeric ? D.paneCode : `${D.paneCode} block min-w-0 truncate`);
|
|
1521
|
+
}
|
|
1522
|
+
rowShow[id] = { props };
|
|
1523
|
+
const hideable = !numeric && type !== 'enum' && type !== 'enums' && type !== 'bool';
|
|
1524
|
+
const itemCls = numeric ? joinClasses(D.compactMetaItem, 'shrink-0') : D.compactMetaItem;
|
|
1525
|
+
const sep = i > 0 ? `<span${attr('class', D.compactSep)} aria-hidden="true">·</span>` : '';
|
|
1526
|
+
if (!hideable) return `<span${attr('class', itemCls)}>${sep}${host(cell.component, id)}</span>`;
|
|
1527
|
+
const wid = `${id}__item`;
|
|
1528
|
+
rowShow[wid] = { when: `${ctx.rowVar}.${cell.field}` };
|
|
1529
|
+
return `<span data-soma-id="${esc(wid)}"${attr('class', itemCls)}>${sep}${host(cell.component, id)}</span>`;
|
|
1530
|
+
});
|
|
1531
|
+
const [status, ...kinds] = tags;
|
|
1532
|
+
// 状态紧跟标题(KT-P-compose C6b:有关系的两样东西挨着放,不把状态推到行尾);标题过长时仍可收缩省略
|
|
1533
|
+
const row1 = `<div${attr('class', D.paneRow)}><div${attr('class', `${D.compactTitle} min-w-0 overflow-hidden`)} ${KIT_TIPS_SCOPE_ATTR}="">${host(compact.title.component, titleId)}</div>${status !== undefined ? tagHtml(status) : ''}</div>`;
|
|
1534
|
+
const row2 = textHtml.length > 0 || kinds.length > 0
|
|
1535
|
+
? `<div${attr('class', `${D.paneRow} text-fg-muted`)}>${textHtml.length > 0 ? `<div${attr('class', `${D.compactMeta} min-w-0`)}>${textHtml.join('')}</div>` : ''}${kinds.map(tagHtml).join('')}</div>`
|
|
1536
|
+
: '';
|
|
1537
|
+
return `<div${attr('class', D.compactBody)}>${row1}${row2}</div>`;
|
|
1538
|
+
}
|
|
1539
|
+
const title = `<div${attr('class', `${D.compactTitle} overflow-hidden`)} ${KIT_TIPS_SCOPE_ATTR}="">${host(compact.title.component, titleId)}</div>`;
|
|
1002
1540
|
const items = compact.meta.map((cell, i) => {
|
|
1003
1541
|
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
1004
1542
|
ctx.components.add(cell.component);
|
|
1005
1543
|
const props = sized(cell);
|
|
1006
|
-
// 状态字段:状态徽标(浅色底 + on-soft 字 + 圆点,emphasis.status);其余文本沿用组件默认外观
|
|
1007
|
-
if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1008
|
-
// 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上)
|
|
1009
|
-
if (cell.component === 'Text') props.class = joinClasses(typeof props.class === 'string' ? props.class : '', 'text-fg-muted');
|
|
1010
|
-
rowShow[id] = { props };
|
|
1011
1544
|
const type = ctx.options.schema?.[cell.field]?.type;
|
|
1012
|
-
const
|
|
1545
|
+
const numeric = isNumericColumnType(type);
|
|
1546
|
+
// 状态字段:圆点 + 文字、没有容器(emphasis.status = dot);其余文本沿用组件默认外观
|
|
1547
|
+
if (!ctx.next && cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1548
|
+
// 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上),非数值文本带省略防压盖金额 / 状态点
|
|
1549
|
+
if (cell.component === 'Text') {
|
|
1550
|
+
props.class = joinClasses(typeof props.class === 'string' ? props.class : '', numeric ? 'text-fg-muted' : 'text-fg-muted block min-w-0 truncate');
|
|
1551
|
+
}
|
|
1552
|
+
rowShow[id] = { props };
|
|
1553
|
+
const hideable = cell.component !== 'Tag' && !numeric && type !== 'enum' && type !== 'enums' && type !== 'bool';
|
|
1554
|
+
const itemCls = cell.component === 'Tag' || numeric ? joinClasses(D.compactMetaItem, 'shrink-0') : D.compactMetaItem;
|
|
1013
1555
|
const sep = i > 0 ? `<span${attr('class', D.compactSep)} aria-hidden="true">·</span>` : '';
|
|
1014
|
-
if (!hideable) return `<span${attr('class',
|
|
1556
|
+
if (!hideable) return `<span${attr('class', itemCls)}>${sep}${host(cell.component, id)}</span>`;
|
|
1015
1557
|
const wid = `${id}__item`;
|
|
1016
1558
|
rowShow[wid] = { when: `${ctx.rowVar}.${cell.field}` };
|
|
1017
|
-
return `<span data-soma-id="${esc(wid)}"${attr('class',
|
|
1559
|
+
return `<span data-soma-id="${esc(wid)}"${attr('class', itemCls)}>${sep}${host(cell.component, id)}</span>`;
|
|
1018
1560
|
});
|
|
1019
1561
|
const meta = items.length > 0 ? `<div${attr('class', D.compactMeta)}>${items.join('')}</div>` : '';
|
|
1020
1562
|
return `<div${attr('class', D.compactBody)}>${title}${meta}</div>`;
|
|
@@ -1049,18 +1591,21 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
1049
1591
|
let ctxHost = '';
|
|
1050
1592
|
if (ctxItems.length > 0) {
|
|
1051
1593
|
ctx.components.add('KitContextMenu');
|
|
1052
|
-
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
|
|
1594
|
+
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar, ...removeBusyProps(ctx) } };
|
|
1053
1595
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
1054
1596
|
}
|
|
1055
|
-
const itemPart = layout.kind === 'cards' ? `
|
|
1597
|
+
const itemPart = layout.kind === 'cards' ? ` ${KIT_ATTR_PART}="${KIT_PART_CARD}"` : '';
|
|
1598
|
+
// next:卡片网格的每张卡自报「对象面」(data-kit-part 已是存量值 card,保留);纵列条目自报「条目」+ 元素部件「行」
|
|
1599
|
+
const itemSelf = layout.kind === 'cards' ? nextLevel(ctx, 'face') : `${nextLevel(ctx, 'item')}${nextPart(ctx, 'line')}`;
|
|
1056
1600
|
const itemClass = pickOnly ? joinClasses(layout.itemClass, 'cursor-pointer') : layout.itemClass;
|
|
1057
|
-
const rowMark = layout.rowTone !== undefined || pickOnly ?
|
|
1601
|
+
const rowMark = layout.rowTone !== undefined || pickOnly ? ` ${KIT_ATTR_ROW}=""` : '';
|
|
1058
1602
|
const actionsPart = compact !== undefined && actions !== '' ? `<div${attr('class', KIT_CLASS_DEFAULTS.compactActions)}>${actions}</div>` : actions;
|
|
1059
|
-
const compactMark = compact !== undefined ?
|
|
1060
|
-
const template = `<template data-soma-role="item"><div${attr('class', itemClass)}${rowMark}${compactMark}${ctxItems.length > 0 ?
|
|
1603
|
+
const compactMark = compact !== undefined ? ` ${KIT_ATTR_COMPACT}=""` : '';
|
|
1604
|
+
const template = `<template data-soma-role="item"><div${attr('class', nextLevelClass(ctx, layout.kind === 'cards' ? 'face' : 'item', itemClass))}${rowMark}${compactMark}${ctxItems.length > 0 ? ` ${KIT_ATTR_CTX}=""` : ''}${itemPart}${itemSelf}>${inner}${actionsPart}${ctxHost}</div></template>`;
|
|
1061
1605
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
1062
1606
|
const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
|
|
1063
|
-
|
|
1607
|
+
const colInstAnchor = ctx.next ? ` data-soma-id="${esc(viewAnchor(object, 'list'))}"` : '';
|
|
1608
|
+
return `<div${colInstAnchor}${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
1064
1609
|
}
|
|
1065
1610
|
|
|
1066
1611
|
// ---------------------------------------------------------------- static(写死形状数据组件)
|
|
@@ -1076,10 +1621,17 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
1076
1621
|
// view.props:配置类 prop 原样透传(保留键已在 renderObject 剔除);view.value:可编辑件的值绑定路径
|
|
1077
1622
|
if (layout.props !== undefined) for (const [k, v] of Object.entries(layout.props)) props[k] = v;
|
|
1078
1623
|
if (layout.value !== undefined) props.value = layout.value;
|
|
1079
|
-
// view.on 接了具名动作的写入 / 提交类事件:自动带上该动作的 busy 绑定;页面手写的 busy_action
|
|
1080
|
-
|
|
1624
|
+
// view.on 接了具名动作的写入 / 提交类事件:自动带上该动作的 busy 绑定;页面手写的 busy_action 优先。
|
|
1625
|
+
// 本对象声明式 request / download 的 id(view.on 写的,或页面手写在 props.busy_action 里的,SCON-176)一律换成按对象的通道名
|
|
1626
|
+
// (C2,与 KitActionHost 登记的同名,D-08;同一个函数 kitOwnBusyChannels);具名动作名与不认识的名字原样
|
|
1627
|
+
const own = ctx.options.actions ?? [];
|
|
1628
|
+
if (typeof props.busy_action === 'string' && props.busy_action !== '') {
|
|
1629
|
+
props.busy_action = kitOwnBusyChannels(props.busy_action, own, ctx.object);
|
|
1630
|
+
} else if (props.busy_action === undefined) {
|
|
1631
|
+
// 自动注入:声明式 download 与 namedActionOf 口径一致,不注忙态(K2-P2-1);手写的照上一支按对象改名
|
|
1081
1632
|
const busyNames = busyActionOf(layout.component, layout.on);
|
|
1082
|
-
|
|
1633
|
+
const autoNames = busyNames === null ? [] : busyNames.split(/[\s,]+/).filter((n) => n !== '' && !own.some((a) => a.id === n && a.download !== undefined));
|
|
1634
|
+
if (autoNames.length > 0) props.busy_action = kitOwnBusyChannels(autoNames.join(','), own, ctx.object);
|
|
1083
1635
|
}
|
|
1084
1636
|
// view.on 接了 data.orderMove,或可写静态组件走内置 data.submit:缺省补本对象名与作用域
|
|
1085
1637
|
if (props.object === undefined && (layout.dataSubmit === true || Object.values(layout.on ?? {}).some((v) => (typeof v === 'string' ? v : v.action) === 'data.orderMove'))) {
|
|
@@ -1108,14 +1660,14 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
1108
1660
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
1109
1661
|
ctx.components.add('KitContextMenu');
|
|
1110
1662
|
const menuId = staticCtxAnchor(ctx.object, slot);
|
|
1111
|
-
ctx.show[menuId] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
|
|
1112
|
-
return `<div class="contents"
|
|
1663
|
+
ctx.show[menuId] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host', ...removeBusyProps(ctx) } };
|
|
1664
|
+
return `<div class="contents" ${KIT_ATTR_CTXHOST}="">${host(layout.component, id)}<div class="hidden">${host('KitContextMenu', menuId)}</div></div>`;
|
|
1113
1665
|
}
|
|
1114
1666
|
const hasStatHighlight = layout.component === 'StatGroup'
|
|
1115
1667
|
&& Array.isArray(props.items)
|
|
1116
1668
|
&& props.items.some((it) => it !== null && typeof it === 'object' && (it as { highlight?: unknown }).highlight === true);
|
|
1117
1669
|
const rawHost = host(layout.component, id);
|
|
1118
|
-
return hasStatHighlight ? rawHost.replace('></div>',
|
|
1670
|
+
return hasStatHighlight ? rawHost.replace('></div>', ` ${KIT_ATTR_HIGHLIGHT}="true"></div>`) : rawHost;
|
|
1119
1671
|
}
|
|
1120
1672
|
|
|
1121
1673
|
// ---------------------------------------------------------------- KitObjectForm(filter / 可编辑 form)
|
|
@@ -1155,6 +1707,7 @@ export function formFieldsAndClasses(layout: KitLayoutIR): { fields: KitCell[];
|
|
|
1155
1707
|
cellClass: 'col-span-12', labelClass: layout.titleClass, valueClass: '', errorClass: '',
|
|
1156
1708
|
group: {
|
|
1157
1709
|
id: g.id, head: true, collapsible: g.collapsible, open: g.open, accordion: layout.accordion, marker: layout.marker,
|
|
1710
|
+
...(g.description !== undefined ? { description: g.description } : {}),
|
|
1158
1711
|
fields: inner.fields.filter((f) => f.placeholder !== true && f.component !== '').map((f) => f.field),
|
|
1159
1712
|
},
|
|
1160
1713
|
});
|
|
@@ -1180,8 +1733,25 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1180
1733
|
}
|
|
1181
1734
|
const id = viewAnchor(ctx.object, slot);
|
|
1182
1735
|
ctx.components.add('KitObjectForm');
|
|
1736
|
+
// 表单 / 筛选字段格上页面手写的 busy_action(SCON-176):与 cellProps / renderStaticComponent 同口径,点名本对象声明式 request / download 的 id
|
|
1737
|
+
// 时换成按对象的通道名(KitActionHost 按它登记);其余名字原样,一个都没换时格子原样(产物与改前一致)
|
|
1738
|
+
const ownActions = ctx.options.actions ?? [];
|
|
1739
|
+
packed.fields = packed.fields.map((c) => {
|
|
1740
|
+
const raw = c.props?.busy_action;
|
|
1741
|
+
if (typeof raw !== 'string' || raw === '') return c;
|
|
1742
|
+
const next = kitOwnBusyChannels(raw, ownActions, ctx.object);
|
|
1743
|
+
return next === raw ? c : { ...c, props: { ...c.props, busy_action: next } };
|
|
1744
|
+
});
|
|
1183
1745
|
// 底栏动作组的「更多」入口(可编辑表单;筛选表单没有)
|
|
1184
1746
|
if (slot === 'form') ctx.components.add('KitActionMore');
|
|
1747
|
+
// 精确文本条件(SCON-171,schema.<字段>.filterOp):画带字段名标签的筛选输入框(筛选栏的现有画法)——有它时整块筛选不进工具条形体
|
|
1748
|
+
// (工具条把文本输入画成无标签的搜索框),窄容器 / 收纳形态里也不当关键词框(KitObjectForm 的 exactFields)
|
|
1749
|
+
const exactFields = slot === 'filter'
|
|
1750
|
+
? packed.fields.filter((c) => c.placeholder !== true && c.divider !== true && kitIsExactFilterField(ctx.options.schema?.[c.field])).map((c) => c.field)
|
|
1751
|
+
: [];
|
|
1752
|
+
// 筛选工具条(风格档案 SPACE_MATERIAL):简单筛选改成「搜索框 + 分段 / 下拉」一条工具条(见 filter-toolbar.ts),不合格返回 null 照旧排布
|
|
1753
|
+
const toolbarCells = slot === 'filter' && layout.kind === 'grid' && exactFields.length === 0 ? filterToolbarCells(packed.fields, ctx.options.locale ?? '') : null;
|
|
1754
|
+
if (toolbarCells !== null) packed.fields = toolbarCells;
|
|
1185
1755
|
for (const c of packed.fields) if (c.component !== '') ctx.components.add(c.component);
|
|
1186
1756
|
// 可编辑 form 的 mode / initial 可绑镜像路径(字符串路径由 core 解析成绑定);filter 恒为字面量
|
|
1187
1757
|
const bindMode = slot === 'form' ? ctx.options.formModePath : undefined;
|
|
@@ -1200,12 +1770,34 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1200
1770
|
// 本页有效信封(与 detail.envelope 同一来源:编译期页面 > 应用);筛选与可编辑表单的远程选项、句柄 envelope() 据此解包。未声明不写这个 prop
|
|
1201
1771
|
const envelope = getCompileEnvelope();
|
|
1202
1772
|
if (envelope !== undefined) props.envelope = envelope;
|
|
1773
|
+
// 精确文本条件的字段名(SCON-171):没有时不写这个 prop(产物与改前一致)
|
|
1774
|
+
if (exactFields.length > 0) props.exactFields = exactFields;
|
|
1775
|
+
// 按 id 取值的关联字段(SCON-177):可编辑 form 里会编辑 / 提交的引用形态关联字段(编辑格 + 隐藏草稿字段)——初值与 $row 详情参数取 id;
|
|
1776
|
+
// 只读格不在其中(PersonCell / Identifier 要 { id, name } 才画得出名称);没有时不写这个 prop
|
|
1777
|
+
if (slot === 'form') {
|
|
1778
|
+
const relationIds = new Set(kitRelationIdFields(ctx.options.schema));
|
|
1779
|
+
const relationFields = relationIds.size === 0 ? [] : [...new Set([
|
|
1780
|
+
...packed.fields.filter((c) => c.placeholder !== true && c.mode === 'edit' && relationIds.has(c.field)).map((c) => c.field),
|
|
1781
|
+
...(ir.fieldValue?.hidden ?? []).filter((f) => relationIds.has(f)),
|
|
1782
|
+
])];
|
|
1783
|
+
if (relationFields.length > 0) props.relationFields = relationFields;
|
|
1784
|
+
}
|
|
1203
1785
|
// M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
|
|
1204
1786
|
const fo = ir.views[slot]?.formOpts;
|
|
1205
1787
|
// 筛选栏(cols 排布):排布引擎的投影(filter-plan.ts)——根容器左起流式换行、字段按类型取 [最小, 理想, 最大] 定宽(不拉伸)、
|
|
1206
1788
|
// 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段并对齐到控件那一行;档位(即时 / 提交 / 更多)与钉住个数作为 props,运行时不量宽
|
|
1207
|
-
const proj = slot === 'filter' && layout.kind === 'grid' ? layout.filterProjection : undefined;
|
|
1208
|
-
|
|
1789
|
+
const proj = slot === 'filter' && layout.kind === 'grid' && toolbarCells === null ? layout.filterProjection : undefined;
|
|
1790
|
+
// 工具条窄档收纳(KT-D9-1,solveStrip 载体 filter-row):窄于收纳线时只留关键词框,其余收进「筛选」浮层(与主从左窗格同一套入口与浮层)
|
|
1791
|
+
const collapse = toolbarCells !== null ? filterToolbarCollapse(toolbarCells) : null;
|
|
1792
|
+
// 浮层里分段画回下拉(object-form popRows):页面要带上 Select 组件
|
|
1793
|
+
if (toolbarCells !== null && toolbarCells.some((c) => c.component === 'Radio')) ctx.components.add('Select');
|
|
1794
|
+
if (toolbarCells !== null) {
|
|
1795
|
+
props.classes = { wrap: KIT_FILTER_TOOLBAR_WRAP, grid: 'contents', actions: KIT_FILTER_TOOLBAR_ACTIONS, pad: 'hidden', notice: 'w-full' };
|
|
1796
|
+
if (collapse !== null && collapse.tier !== null) {
|
|
1797
|
+
props.filterCollapse = collapse.tier;
|
|
1798
|
+
props.fields = props.fields.map((c) => (c.placeholder === true || collapse.cellClass[c.field] === undefined ? c : { ...c, cellClass: joinClasses(c.cellClass, collapse.cellClass[c.field]!) }));
|
|
1799
|
+
}
|
|
1800
|
+
} else if (proj !== undefined && layout.kind === 'grid') {
|
|
1209
1801
|
props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, proj.widthClasses[i] ?? '') }));
|
|
1210
1802
|
const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
|
|
1211
1803
|
props.classes = {
|
|
@@ -1226,7 +1818,11 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1226
1818
|
if (slot === 'form') {
|
|
1227
1819
|
if (ctx.options.validateOn !== undefined) props.validateOn = ctx.options.validateOn;
|
|
1228
1820
|
if (ctx.options.leaveGuard === true) props.leaveGuard = true;
|
|
1229
|
-
if (ctx.options.formDetail !== undefined)
|
|
1821
|
+
if (ctx.options.formDetail !== undefined) {
|
|
1822
|
+
// 详情参数里单段 `$row.<关联字段>` 取 id(SCON-177):名单按 schema 与 params 算,不随表单的 relationFields(只读 / 没进表单的关联字段同样要取 id)
|
|
1823
|
+
const detailRelationIds = kitDetailRelationIds(ctx.options.formDetail, ctx.options.schema);
|
|
1824
|
+
props.detail = detailRelationIds.length > 0 ? { ...ctx.options.formDetail, relationIds: detailRelationIds } : ctx.options.formDetail;
|
|
1825
|
+
}
|
|
1230
1826
|
if (fo?.footerActions !== undefined) {
|
|
1231
1827
|
const items = fo.footerActions.flatMap((aid) => {
|
|
1232
1828
|
const a = ctx.options.actions?.find((x) => x.id === aid);
|
|
@@ -1261,28 +1857,69 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1261
1857
|
// 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
|
|
1262
1858
|
const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
|
|
1263
1859
|
let html = host('KitObjectForm', id);
|
|
1860
|
+
if (toolbarCells !== null) html = html.replace('></div>', ` ${KIT_FILTER_TOOLBAR_MARK}=""></div>`);
|
|
1861
|
+
// 收纳线的容器查询以工具条宿主为准(块级满宽,宽度不由内容决定——查询容器宿主的物理前提,KT-D9-2),条带标记供 W06′ / W11
|
|
1862
|
+
if (collapse !== null && collapse.tier !== null) {
|
|
1863
|
+
html = html.replace('></div>', ` ${collapse.strip.mark}></div>`);
|
|
1864
|
+
html = html.includes(' class="') ? html.replace(' class="', ` class="${KIT_WIDTH.containerClass} `) : html.replace('></div>', ` class="${KIT_WIDTH.containerClass}"></div>`);
|
|
1865
|
+
}
|
|
1264
1866
|
// 容器查询只对后代生效:表单根上的字段宽度 / 动作区变体类(@<档>:w-N)要查到宿主这一层,所以宿主做查询容器
|
|
1265
1867
|
if (proj !== undefined) {
|
|
1266
1868
|
html = html.includes(' class="') ? html.replace(' class="', ` class="${KIT_WIDTH.containerClass} `) : html.replace('></div>', ` class="${KIT_WIDTH.containerClass}"></div>`);
|
|
1267
1869
|
}
|
|
1870
|
+
// 工具条式筛选的条带自然宽(全部内联的需求宽)记在宿主上(体检事实;面恒铺满,现无读取方)
|
|
1871
|
+
if (collapse !== null) html = html.replace('></div>', ` ${KIT_NATURAL_W_ATTR}="${collapse.strip.naturalUnits}"></div>`);
|
|
1268
1872
|
return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
|
|
1269
1873
|
}
|
|
1270
1874
|
|
|
1271
1875
|
// ---------------------------------------------------------------- 工具栏
|
|
1272
1876
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1877
|
+
/**
|
|
1878
|
+
* 动作功能名(SCON-116):页面写的 function 优先,其次按 builtin / id 推断(真源 emphasis.actions.inferFromId),再认 export 前缀的 id;推不出为 null。
|
|
1879
|
+
* 判据唯一出处 table-actions#kitActionFunctionOfDecl(SCON-169:工具栏取色、行操作 / 详情头的功能名透传与操作列估宽同一个)
|
|
1880
|
+
*/
|
|
1881
|
+
function actionFunctionOf(a: KitAction): KitActionFunction | null {
|
|
1882
|
+
return kitActionFunctionOfDecl(a);
|
|
1883
|
+
}
|
|
1275
1884
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1885
|
+
/** 页面显式写的 tone(旧写法,优先于功能名)→ Button 变体;没写返回 undefined */
|
|
1886
|
+
function explicitActionVariant(a: KitAction): ButtonVariant | undefined {
|
|
1887
|
+
if (a.tone === 'danger' || a.tone === 'neutral' || a.tone === 'primary' || a.tone === 'ghost' || a.tone === 'tonal') return a.tone;
|
|
1280
1888
|
if (a.tone === 'info' || a.tone === 'success') return 'primary';
|
|
1281
1889
|
if (a.tone === 'warning') return 'tonal';
|
|
1282
|
-
|
|
1283
|
-
|
|
1890
|
+
return undefined;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
* 一组同区动作(工具栏、表单底栏…)的按钮变体:按声明序逐个取色,功能名 → 操作角色 → 变体(真源 emphasis.actions);
|
|
1895
|
+
* 推进类占区内主动作名额(第一个 primary,其余降 neutral),页面显式 tone: primary 也占一个名额。没有功能名且推断不出的取缺省角色(中性)。
|
|
1896
|
+
*/
|
|
1897
|
+
function actionVariantsOf(actions: readonly KitAction[], region: KitActionRegion): Map<string, ButtonVariant> {
|
|
1898
|
+
const out = new Map<string, ButtonVariant>();
|
|
1899
|
+
// 一次交给区域求解(主色名额、决定区、操作色族 ≤ 2 都在参考实现里):显式 tone: primary 的动作用推进类占位,占一个实心名额;
|
|
1900
|
+
// 其余显式 tone 与推断不出功能名的动作不进求解(显式 tone 取旧写法,推不出取缺省角色)
|
|
1901
|
+
const solve: Array<{ id: string; fn: KitActionFunction }> = [];
|
|
1902
|
+
for (const a of actions) {
|
|
1903
|
+
const explicit = explicitActionVariant(a);
|
|
1904
|
+
if (explicit !== undefined) {
|
|
1905
|
+
out.set(a.id, explicit);
|
|
1906
|
+
if (explicit === 'primary') solve.push({ id: '', fn: 'confirm' });
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
const fn = actionFunctionOf(a);
|
|
1910
|
+
if (fn === null) { out.set(a.id, buttonVariantOfControl(kitActionFallbackVariant())); continue; }
|
|
1911
|
+
solve.push({ id: a.id, fn });
|
|
1284
1912
|
}
|
|
1285
|
-
|
|
1913
|
+
kitActionRegionResolve(solve.map((s) => s.fn), region).forEach((hit, i) => {
|
|
1914
|
+
const id = solve[i]!.id;
|
|
1915
|
+
if (id !== '') out.set(id, buttonVariantOfControl(hit.variant));
|
|
1916
|
+
});
|
|
1917
|
+
return out;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/** 变体 → 语气标记(action-more 读 data-kit-ag-tone 判危险项:软 / 实心危险钮都记 danger) */
|
|
1921
|
+
function actionToneMark(v: ButtonVariant): string {
|
|
1922
|
+
return v === 'dangerSolid' ? 'danger' : v;
|
|
1286
1923
|
}
|
|
1287
1924
|
|
|
1288
1925
|
/** 工具栏按钮的置灰原因 prop(Button 的 disabled_reason);没写 disabled 或来源是行路径 / 非法值时不带 */
|
|
@@ -1294,9 +1931,8 @@ function toolbarReasonProp(a: KitAction): { disabled_reason?: string } {
|
|
|
1294
1931
|
}
|
|
1295
1932
|
|
|
1296
1933
|
/** 动作在动作组里的重要度:primary 语气 = 主操作(恒在行尾、恒可见);danger 语气最后保留;其余为次要 */
|
|
1297
|
-
function toolbarImportance(
|
|
1298
|
-
|
|
1299
|
-
return t === 'primary' ? 'primary' : t === 'danger' ? 'danger' : 'secondary';
|
|
1934
|
+
function toolbarImportance(v: ButtonVariant): KitActionImportance {
|
|
1935
|
+
return v === 'primary' ? 'primary' : v === 'danger' || v === 'dangerSolid' ? 'danger' : 'secondary';
|
|
1300
1936
|
}
|
|
1301
1937
|
|
|
1302
1938
|
/**
|
|
@@ -1307,7 +1943,14 @@ function toolbarImportance(a: KitAction): KitActionImportance {
|
|
|
1307
1943
|
function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
1308
1944
|
const declared = actions.filter((a) => a.on === 'toolbar');
|
|
1309
1945
|
if (declared.length === 0) return '';
|
|
1310
|
-
const
|
|
1946
|
+
const cap = ctx.options.toolbarInlineCap;
|
|
1947
|
+
const variants = actionVariantsOf(declared, 'toolbar');
|
|
1948
|
+
const projection = projectActionGroup(
|
|
1949
|
+
declared.map((a) => ({ id: a.id, label: a.name, importance: toolbarImportance(variants.get(a.id)!) })),
|
|
1950
|
+
// 非内容项 N17(头部条只收一项时直接摆出)试过放开 loneInline:主从左窗格头(mcp 接口配置)里主动作从图标钮变回带字钮、
|
|
1951
|
+
// 「更多」被窗格右缘裁掉(实拍 2026-11-26)——窗格头的宽度预算是按「图标主钮 + 更多」算的,放开要连同条带求解一起改,本处维持原样
|
|
1952
|
+
cap !== undefined ? { inlineCap: cap, loneInline: false } : {},
|
|
1953
|
+
);
|
|
1311
1954
|
const byId = new Map(declared.map((a) => [a.id, a] as const));
|
|
1312
1955
|
const list = projection.order.flatMap((id) => { const a = byId.get(id); return a === undefined ? [] : [a]; });
|
|
1313
1956
|
const parts = list.map((a) => {
|
|
@@ -1316,32 +1959,47 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
|
1316
1959
|
ctx.show[id] = {
|
|
1317
1960
|
props: {
|
|
1318
1961
|
label: a.name,
|
|
1319
|
-
variant:
|
|
1962
|
+
variant: variants.get(a.id)!,
|
|
1963
|
+
// 动作语义是「新建」(内置 openCreate)时由框架给前置加号图标,页面不写
|
|
1964
|
+
...(a.builtin === 'openCreate' ? { icon: 'plus' } : {}),
|
|
1320
1965
|
// 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
|
|
1321
1966
|
...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
|
|
1322
1967
|
// 置灰原因(disabled 为真时 Button 才显示):字面量原样带,view.<成员> 编成页面变量路径;row. 路径在入口已报 KIT-VIEW-001
|
|
1323
1968
|
...toolbarReasonProp(a),
|
|
1969
|
+
// 触发具名动作:按动作名注入 busy_action(动作在途期间按钮置灰、aria-busy,随忙闲通道恢复;不从外部改 DOM)
|
|
1970
|
+
...(namedActionOf(a, ctx.object) !== undefined ? { busy_action: namedActionOf(a, ctx.object) } : {}),
|
|
1324
1971
|
// K1-2:Button 读 permission 服务,无权不渲染
|
|
1325
1972
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
1326
1973
|
},
|
|
1327
1974
|
};
|
|
1328
1975
|
// 外壳承载「按档隐藏」类与「更多」菜单要读的标记(标签 / 语气);壳里是真按钮,菜单选中即对它 click() 回放
|
|
1329
|
-
|
|
1976
|
+
// next:工具条动作自报元素部件「动作」(挂在外壳上:外壳是可见性与「更多」菜单的单位)
|
|
1977
|
+
return `<div${attr('class', projection.itemClass[a.id] ?? 'shrink-0')} ${KIT_ATTR_AG_ITEM}="${esc(a.id)}" ${KIT_ATTR_AG_LABEL}="${esc(a.name)}" ${KIT_ATTR_AG_TONE}="${esc(actionToneMark(variants.get(a.id)!))}"${nextPart(ctx, 'action')}>${host('Button', id)}</div>`;
|
|
1330
1978
|
});
|
|
1331
1979
|
let more = '';
|
|
1332
|
-
if (projection.plan.hasMore) {
|
|
1980
|
+
if (projection.plan.hasMore || projection.moreClass !== 'hidden') {
|
|
1333
1981
|
ctx.components.add('KitActionMore');
|
|
1334
1982
|
more = `<div${attr('class', projection.moreClass)}>${host('KitActionMore', `${ctx.object}__tb_more`)}</div>`;
|
|
1335
1983
|
}
|
|
1336
|
-
return `<div${attr('class', projection.hostClass)}
|
|
1984
|
+
return `<div${attr('class', projection.hostClass)} ${KIT_ATTR_ACTION_GROUP}=""><div${attr('class', projection.rowClass)}>${parts.join('')}${more}</div></div>`;
|
|
1337
1985
|
}
|
|
1338
1986
|
|
|
1339
1987
|
// ---------------------------------------------------------------- 主函数
|
|
1340
1988
|
|
|
1341
1989
|
const SLOT_ORDER: readonly KitViewSlot[] = ['filter', 'list', 'summary', 'form'];
|
|
1342
1990
|
|
|
1991
|
+
/**
|
|
1992
|
+
* 输出里两种模式判断必须一致:属性按 ctx.next(= options.pipeline === 'next')写,同一份输出里的 kitHelpButtonHtml、kitTableNativeSpanAttr()、
|
|
1993
|
+
* 动作配方按 kitIsNextRuntime() 判断——所以整段在 ctx.next 对应模式的编译段里执行(kitWithCompilePipeline;已在同模式的编译段内时不重复设置)。
|
|
1994
|
+
*/
|
|
1343
1995
|
export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStaticEmit {
|
|
1996
|
+
return kitWithCompilePipeline(options.pipeline === 'next' ? 'next' : 'legacy', () => emitStaticIn(ir, options));
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
function emitStaticIn(ir: KitObjectIR, options: KitStaticOptions): KitStaticEmit {
|
|
1344
2000
|
const object = ir.object;
|
|
2001
|
+
// SCON-177:本对象按 id 取值的关联字段登记给声明式请求 / 下载(页面编译收集期内;早于本对象的事件编译,emitObject 先发静态后编事件)
|
|
2002
|
+
noteRequestRelationFields(object, kitRelationIdFields(options.schema));
|
|
1345
2003
|
const wrapped = options.wrapped ?? ir.views.list !== undefined;
|
|
1346
2004
|
const base = options.singlePath ?? `page.data.${object}`;
|
|
1347
2005
|
// 摘要 / 只读 form / 写死形状(single)读 summaryPath(如焦点切片里的当前行);缺省同 base。行数组与总数仍按 base
|
|
@@ -1363,6 +2021,8 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1363
2021
|
scope: () => ir.scope,
|
|
1364
2022
|
...(ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static' ? { filterId: viewAnchor(object, 'filter') } : {}),
|
|
1365
2023
|
...(columnParams.length > 0 ? { columnParams } : {}),
|
|
2024
|
+
next: options.pipeline === 'next',
|
|
2025
|
+
groupDepth: 0,
|
|
1366
2026
|
};
|
|
1367
2027
|
|
|
1368
2028
|
// 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
|
|
@@ -1413,10 +2073,18 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1413
2073
|
} else if (slot === 'list') {
|
|
1414
2074
|
if (layout.kind === 'table') html = renderTable(ctx, layout);
|
|
1415
2075
|
else if (layout.kind === 'cards' || layout.kind === 'stack') html = renderCollection(ctx, layout);
|
|
1416
|
-
else
|
|
2076
|
+
else {
|
|
2077
|
+
html = renderArrangement(ctx, slot, layout, (f) => `${ctx.rowVar}.${f}`, at, ctx.show);
|
|
2078
|
+
if (ctx.next && html !== '' && !/^<[a-zA-Z0-9-]+[^>]*\bdata-soma-id=/.test(html)) {
|
|
2079
|
+
html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 data-soma-id="${esc(viewAnchor(object, slot))}"$2`);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
1417
2082
|
} else {
|
|
1418
2083
|
// summary / 只读 form:单对象字段值
|
|
1419
2084
|
html = renderArrangement(ctx, slot, layout, (f) => `${summaryBase}.${f}`, at, ctx.show);
|
|
2085
|
+
if (ctx.next && html !== '' && !/^<[a-zA-Z0-9-]+[^>]*\bdata-soma-id=/.test(html)) {
|
|
2086
|
+
html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 data-soma-id="${esc(viewAnchor(object, slot))}"$2`);
|
|
2087
|
+
}
|
|
1420
2088
|
}
|
|
1421
2089
|
// view.loading: skeleton:同一个 KitCollectionState(single 形态)画表单骨架,并藏起紧随其后的内容体
|
|
1422
2090
|
if (html !== '' && view.skeleton === true) {
|
|
@@ -1424,13 +2092,13 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1424
2092
|
ctx.components.add('KitCollectionState');
|
|
1425
2093
|
const rsPaths = readStatePathsOf(object, summaryBase);
|
|
1426
2094
|
ctx.show[sid] = { props: { data: summaryBase, config: { object, mode: 'single', readStatePath: rsPaths.readStatePath, errorMessagePath: rsPaths.errorMessagePath, loading: kitText('soma.kit.loading', undefined, ctx.options.locale ?? ''), skeleton: { kind: 'single' } } } };
|
|
1427
|
-
html = `${host('KitCollectionState', sid)}<div
|
|
2095
|
+
html = `${host('KitCollectionState', sid)}<div ${KIT_ATTR_SKELETON_BODY}="">${html}</div>`;
|
|
1428
2096
|
}
|
|
1429
2097
|
if (html !== '' && (view.surface !== undefined || view.emphasis !== undefined || view.highlight === true)) {
|
|
1430
2098
|
const slotAttrs = [
|
|
1431
|
-
view.surface !== undefined ?
|
|
1432
|
-
view.emphasis !== undefined ?
|
|
1433
|
-
view.highlight === true ?
|
|
2099
|
+
view.surface !== undefined ? `${KIT_ATTR_PART}="${esc(kitContainerPartOf(view.surface))}" ${KIT_ATTR_SURFACE}="${esc(view.surface)}"` : '',
|
|
2100
|
+
view.emphasis !== undefined ? `${KIT_ATTR_EMPHASIS}="${esc(view.emphasis)}"` : '',
|
|
2101
|
+
view.highlight === true ? `${KIT_ATTR_HIGHLIGHT}="true"` : '',
|
|
1434
2102
|
].filter(Boolean).join(' ');
|
|
1435
2103
|
if (slotAttrs !== '') {
|
|
1436
2104
|
html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
|
|
@@ -1445,20 +2113,25 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1445
2113
|
if (html !== '' && view.title !== undefined && view.title !== '') {
|
|
1446
2114
|
// 标题写成 view.<成员> 纯路径:被动绑定展示对象的只读成员(如选中项名称),不是字面量
|
|
1447
2115
|
const dynamicTitle: boolean = isViewPath(view.title);
|
|
2116
|
+
// 图表视图自带标题(看板面板没写面板标题、标题写在 view.list.title 上):与图表面板同一个缺省标题图标(CS22),不只落在面板标题行
|
|
2117
|
+
const titleIcon = layout.kind === 'static' ? kitDefaultPanelIcon(layout.component) : undefined;
|
|
1448
2118
|
const titleEl = dynamicTitle
|
|
1449
|
-
? renderDynamicTitle(ctx, slot, view.title)
|
|
1450
|
-
: kitPanelTitleHtml({ title: view.title, id:
|
|
1451
|
-
//
|
|
1452
|
-
const mergeToolbar = slot === 'list' && secondaryToolbar && parts.toolbar !== undefined;
|
|
1453
|
-
if (slot === 'list' &&
|
|
2119
|
+
? renderDynamicTitle(ctx, slot, view.title, titleIcon, html)
|
|
2120
|
+
: kitPanelTitleHtml({ title: view.title, id: viewTitleAnchor(object, slot, options.schema, html), ...(titleIcon !== undefined ? { icon: titleIcon } : {}) });
|
|
2121
|
+
// 工具栏(含主操作,主操作在最右)与列表(或无列表时的摘要)标题同一行靠右,不再独占一整行(评审 S5 / 第三轮);工具栏并入标题行后不再单独出
|
|
2122
|
+
const mergeToolbar = (slot === 'list' || (slot === 'summary' && ir.views.list === undefined)) && secondaryToolbar && parts.toolbar !== undefined;
|
|
2123
|
+
if (mergeToolbar || (slot === 'list' && treeCtl !== '')) {
|
|
1454
2124
|
const right = treeCtl !== ''
|
|
1455
2125
|
? `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${mergeToolbar ? parts.toolbar! : ''}</div>`
|
|
1456
2126
|
: parts.toolbar!;
|
|
1457
2127
|
// 集合辅助文字紧随标题作标题行的直接子项(宿主 display: contents,其根自带 me-auto 把工具区推到最右)
|
|
1458
|
-
|
|
2128
|
+
// 带工具的列表标题行是面内的头部条(strip.headPx 下限,内容垂直居中):不设下限时工具钮贴着面板顶边,
|
|
2129
|
+
// 钮的上描边与面板上边相距 0 成双线(边框普查 B01,外壳用户授权「导出」)
|
|
2130
|
+
// next:标题行(标题 + 工具条)是面内的头部条,自报「面头」
|
|
2131
|
+
html = `<div ${KIT_ATTR_TITLE_ROW}="" class="${KIT_CLASS_DEFAULTS.toolbarTitleRow} ${KIT_STRIP_HEAD_MIN_CLASS}"${nextLevel(ctx, 'head')}>${titleEl}${metaHtml}${right}</div>${html}`;
|
|
1459
2132
|
if (mergeToolbar) delete parts.toolbar;
|
|
1460
2133
|
} else {
|
|
1461
|
-
html = `${metaHtml === '' ? titleEl : `<div
|
|
2134
|
+
html = `${metaHtml === '' ? titleEl : `<div ${KIT_ATTR_TITLE_ROW}="" class="${TITLE_GROUP_CLASS}"${nextLevel(ctx, 'head')}>${titleEl}${metaHtml}</div>`}${html}`;
|
|
1462
2135
|
}
|
|
1463
2136
|
} else {
|
|
1464
2137
|
if (treeCtl !== '') {
|
|
@@ -1466,17 +2139,22 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1466
2139
|
else html = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}</div>${html}`;
|
|
1467
2140
|
}
|
|
1468
2141
|
// 没有标题行:只有「已筛选」提示(共 N 条需要标题行),放在列表上方;包一层标题行壳,与有标题时同走对齐轴的内缩规则(文字落在轴上)
|
|
1469
|
-
if (metaHtml !== '') html = `<div
|
|
2142
|
+
if (metaHtml !== '') html = `<div ${KIT_ATTR_TITLE_ROW}="" class="${TITLE_GROUP_CLASS}"${nextLevel(ctx, 'head')}>${metaHtml}</div>${html}`;
|
|
1470
2143
|
}
|
|
1471
2144
|
parts[slot] = html;
|
|
1472
2145
|
}
|
|
1473
2146
|
|
|
1474
|
-
//
|
|
2147
|
+
// 次要工具栏没并入标题行时,紧贴列表(或无列表时的摘要)上方靠右(顺序:筛选 → 工具 → 列表/摘要),不压在筛选之前
|
|
1475
2148
|
const slotParts = SLOT_ORDER.map((s) => parts[s]);
|
|
1476
2149
|
let leading = parts.toolbar;
|
|
1477
|
-
if (secondaryToolbar && parts.toolbar !== undefined
|
|
1478
|
-
|
|
1479
|
-
|
|
2150
|
+
if (secondaryToolbar && parts.toolbar !== undefined) {
|
|
2151
|
+
if (parts.list !== undefined && parts.list !== '') {
|
|
2152
|
+
slotParts.splice(SLOT_ORDER.indexOf('list'), 0, parts.toolbar);
|
|
2153
|
+
leading = undefined;
|
|
2154
|
+
} else if (parts.summary !== undefined && parts.summary !== '') {
|
|
2155
|
+
slotParts.splice(SLOT_ORDER.indexOf('summary'), 0, parts.toolbar);
|
|
2156
|
+
leading = undefined;
|
|
2157
|
+
}
|
|
1480
2158
|
}
|
|
1481
2159
|
const ordered = [leading, ...slotParts].filter((p): p is string => p !== undefined && p !== '');
|
|
1482
2160
|
return {
|