soma-kit 0.1.15 → 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/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 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +934 -92
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- 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 +67 -23
- package/src/app/theme-runtime.ts +414 -85
- 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 +104 -59
- package/src/base/anchored-layer.ts +7 -6
- 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 +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -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 +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- 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 +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -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 +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- 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 +141 -22
- 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 +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- 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 +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +186 -57
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +130 -28
- package/src/biz/shared/coordinator.ts +628 -147
- 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 +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- 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 +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -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/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- 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 +382 -46
- 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/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- 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 +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- 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 +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- 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 +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1015 -53
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- 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 +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- 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 +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +424 -103
- 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 +428 -128
- package/src/object-renderer/types.ts +91 -2
- 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/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- 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 +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- 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/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- 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/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- 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 +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
|
@@ -1,7 +1,61 @@
|
|
|
1
|
+
import { kitIsNextPipeline, kitWithCompilePipeline, type KitRenderPipeline } from './pipeline-mode';
|
|
1
2
|
import { kitRowActionsNarrowCap } from 'soma-foundation/kit-layout';
|
|
2
|
-
import {
|
|
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';
|
|
3
13
|
import { esc } from '../shared/escape';
|
|
4
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';
|
|
5
59
|
// emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
|
|
6
60
|
//
|
|
7
61
|
// 两种发射:
|
|
@@ -19,30 +73,36 @@ import { checkRowPath, checkViewPath, classifyDisabledReason, isRowPath, isViewP
|
|
|
19
73
|
import type {
|
|
20
74
|
KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
|
|
21
75
|
} from './types';
|
|
22
|
-
import { KIT_CLASS_DEFAULTS,
|
|
76
|
+
import { KIT_CLASS_DEFAULTS, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
|
|
23
77
|
import type { KitSkeletonCol, KitSkeletonConfig } from './skeleton';
|
|
24
|
-
import { isNumericColumnType } from './collection-table';
|
|
25
|
-
import { mergeClass } from '../shared/merge-class';
|
|
78
|
+
import { KIT_PART_TABLE, KIT_PART_TABLE_CELL, KIT_PART_TABLE_HEAD, KIT_PART_TABLE_ROW, isNumericColumnType } from './collection-table';
|
|
26
79
|
import { projectActionGroup, projectTabOverflow, type KitActionImportance } from './action-group';
|
|
27
|
-
import { KIT_TAB_TEXT_ATTR, kitTabRecipe } from '../recipes/tabs';
|
|
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';
|
|
28
82
|
import { KIT_TABLE_GAP_HEAD_ATTR, tableGapReasonField } from '../recipes/table-gap';
|
|
29
|
-
import { kitTextActionRecipe } from '../recipes/control';
|
|
30
|
-
import { kitStatusPillProps } from '../recipes/emphasis';
|
|
31
83
|
import { KIT_OVERLAY_FORM_HOST_CLASS } from '../recipes/overlay';
|
|
32
84
|
import { KIT_STRIP_HEAD_MIN_CLASS } from '../recipes/strip';
|
|
33
|
-
import {
|
|
85
|
+
import { KIT_DESC_GROUP_DESC_CLASS } from '../recipes/desc-list';
|
|
86
|
+
import { KIT_PANEL_TITLE_CLASS, kitDefaultPanelIcon, kitPanelTitleHtml } from '../recipes/title-row';
|
|
34
87
|
import { headAnchor } from './compile-data';
|
|
35
|
-
import { KIT_STATE_DEFAULT_TEXT } from './collection';
|
|
88
|
+
import { KIT_STATE_DEFAULT_TEXT, kitIsExactFilterField } from './collection';
|
|
36
89
|
import { kitText } from '../i18n/kit-text';
|
|
37
90
|
import { KIT_TIPS_SCOPE_ATTR, kitHelpButtonHtml } from '../base/hint-tips';
|
|
38
91
|
import { expandHostId } from './collection-expand';
|
|
39
|
-
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';
|
|
40
94
|
import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
|
|
41
|
-
import { KIT_PART_CARD, KIT_PART_SECTION, KIT_PART_TITLE_SECTION, kitContainerPartOf, type KitFormDetail } from './form-detail';
|
|
42
|
-
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';
|
|
43
97
|
import { readStatePathsOf } from './crud-bridge';
|
|
44
|
-
import { KIT_FILTER_TOOLBAR_ACTIONS, KIT_FILTER_TOOLBAR_MARK, KIT_FILTER_TOOLBAR_WRAP, filterToolbarCells } from './filter-toolbar';
|
|
98
|
+
import { KIT_FILTER_TOOLBAR_ACTIONS, KIT_FILTER_TOOLBAR_MARK, KIT_FILTER_TOOLBAR_WRAP, filterToolbarCells, filterToolbarCollapse } from './filter-toolbar';
|
|
45
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';
|
|
46
106
|
|
|
47
107
|
/** 行变量按对象取(`kit_row_<对象>`):core 的 varMap 按变量名建,同页两个列表共用一个名字会撞 */
|
|
48
108
|
export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
@@ -50,6 +110,32 @@ export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
|
50
110
|
// ---------------------------------------------------------------- 锚点命名
|
|
51
111
|
|
|
52
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
|
+
}
|
|
53
139
|
/**
|
|
54
140
|
* 同槽(`<对象>__list__`)里集合自己的实例后缀:字段名撞上它们会让页面锚点重复(CORE-ANCHOR-DUPLICATE,整页 500)。
|
|
55
141
|
* `state` / `title` / `meta` 都是常见的业务字段名,所以字段单元锚点遇到这些后缀时追加 `_cell`,字段名不受限。
|
|
@@ -59,6 +145,25 @@ export function cellAnchor(object: string, slot: KitViewSlot, field: string): st
|
|
|
59
145
|
return `${object}__${slot}__${slot === 'list' && KIT_RESERVED_LIST_ANCHORS.has(field) ? `${field}_cell` : field}`;
|
|
60
146
|
}
|
|
61
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
|
+
}
|
|
62
167
|
export function opsAnchor(object: string): string { return `${object}__list__ops`; }
|
|
63
168
|
/** 右键菜单实例(Q 波 G6):行模板里每行一个,虚拟滚动表 / 树表是页面里一个 */
|
|
64
169
|
export function ctxMenuAnchor(object: string): string { return `${object}__list__ctx`; }
|
|
@@ -124,8 +229,6 @@ export interface KitStaticOptions {
|
|
|
124
229
|
formInitialPath?: string;
|
|
125
230
|
/** 分页条的附加类(业务壳给:列表页贴工作面底 sticky + 轴内边距) */
|
|
126
231
|
pagerClass?: string;
|
|
127
|
-
/** 列表默认紧凑档(见 emit-object):原生表格外壳标 data-kit-dense */
|
|
128
|
-
defaultDense?: boolean;
|
|
129
232
|
/** 表格行可点选:行容器标 data-kit-row,KitTableActions 开 pickOnRow,行点击抛 row_action(builtin select) */
|
|
130
233
|
pickOnRow?: boolean;
|
|
131
234
|
/**
|
|
@@ -133,16 +236,37 @@ export interface KitStaticOptions {
|
|
|
133
236
|
* KitTableActions(选择态存在协调组件的 focus 切片里);不给保持存量的惰性 Checkbox
|
|
134
237
|
*/
|
|
135
238
|
selectedPath?: string;
|
|
239
|
+
/** 当前打开项镜像的路径(如枢纽选中行):只管行操作实例的选中高亮(picked 入参),与勾选集合 selectedPath 分开 */
|
|
240
|
+
pickedPath?: string;
|
|
136
241
|
/** 行删除在途置灰读的协调组件作用域;忙闲通道名 = 作用域 + 行主键,必须与 KitCrudBridge 的 scope 一致;缺省用本对象作用域(standard-crud 两者相同) */
|
|
137
242
|
removeScope?: string;
|
|
243
|
+
/** 选中切换加载态监听的区域作用域(联动场景传链接作用域 link,供 KitCollectionState 监听 selection / focus 切片) */
|
|
244
|
+
readonly selectionScope?: string;
|
|
245
|
+
/** 选中签名取的主键字段(跨线契约 C3:枢纽的主键字段名,业务组件编译与 selectionScope 一起下发):原样透传给 KitCollectionState 的 config */
|
|
246
|
+
readonly selectionKeyField?: string;
|
|
138
247
|
/** 展开子表(Q 波 G5):协调组件 focus 切片 expandId 镜像的路径;给了,list 形展开的开关才读它判断本行是否展开 */
|
|
139
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;
|
|
140
259
|
/** behavior.validateOn(已校验):KitObjectForm 在 change / blur 时即时校验 */
|
|
141
260
|
validateOn?: string[];
|
|
142
261
|
/** behavior.leaveGuard 生效(confirm):KitObjectForm 草稿有改动时拦截离开 */
|
|
143
262
|
leaveGuard?: boolean;
|
|
144
263
|
/** behavior.detail(已校验):编辑表单打开时先取详情(KitObjectForm 的 detail prop) */
|
|
145
264
|
formDetail?: KitFormDetail;
|
|
265
|
+
/**
|
|
266
|
+
* 主题流水线模式:next 时在产物里补组件契约的自报属性(层级角色、元素部件),并按单一值输出去掉会被页面线判定覆盖的缺省呈现;
|
|
267
|
+
* 缺省(legacy)产物逐字节不变
|
|
268
|
+
*/
|
|
269
|
+
pipeline?: KitRenderPipeline;
|
|
146
270
|
}
|
|
147
271
|
|
|
148
272
|
export interface KitStaticEmit {
|
|
@@ -166,6 +290,16 @@ function attr(name: string, value: string): string {
|
|
|
166
290
|
const OVERLAY_FOOTER_HOSTS: ReadonlySet<string> = new Set(['KitObjectForm', 'Transfer', 'PermissionTree', 'AssignmentPicker']);
|
|
167
291
|
const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitTableGap', 'KitCollectionState', 'Pager']);
|
|
168
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
|
+
|
|
169
303
|
function host(component: string, id: string): string {
|
|
170
304
|
// 自带底栏的表单 / 穿梭框 / 授权树,其宿主在浮层滚动体里是体的 flex 子项并撑满体高(底栏才能落在浮层底部);变体只在 group-data-kit-overlay-scroll 祖先下生效
|
|
171
305
|
// 根常带 hidden 的辅助宿主(表格工具位 / 三态面板 / 分页器):宿主 display: contents,不占 flex 子项的位——
|
|
@@ -177,19 +311,25 @@ function host(component: string, id: string): string {
|
|
|
177
311
|
const opsHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_ops', undefined, ctx.options.locale ?? '');
|
|
178
312
|
const selectHeadLabel = (ctx: { options: KitStaticOptions }): string => kitText('soma.kit.head_select', undefined, ctx.options.locale ?? '');
|
|
179
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">';
|
|
180
320
|
/** 视图标题行(K-4):语义色名 + utilityScales 里有的尺度 */
|
|
181
321
|
|
|
182
322
|
/** 显式 `bordered: true`(完整网格线)的表格外壳标 data-kit-grid:主题结构 CSS 只对没有这个标记的表壳去掉容器卡片外观(圆角 / 边框 / 阴影 / 底色) */
|
|
183
323
|
function gridMark(layout: { bordered?: boolean }): string {
|
|
184
|
-
return layout.bordered === true ?
|
|
324
|
+
return layout.bordered === true ? ` ${KIT_ATTR_GRID}=""` : '';
|
|
185
325
|
}
|
|
186
326
|
|
|
187
327
|
/** 树表「全部展开 / 全部收起」:文字链接形态,放在表格工具位(与刷新同一行、标题行右侧);点击由 KitTreeTable 按 data-kit-tree-for 认领 */
|
|
188
328
|
function renderTreeControls(ctx: Ctx): string {
|
|
189
329
|
const locale = ctx.options.locale ?? '';
|
|
190
|
-
const cls =
|
|
330
|
+
const cls = kitPlainActionRecipe('expand');
|
|
191
331
|
const one = (act: 'expand' | 'collapse', key: 'soma.kit.expand_all' | 'soma.kit.collapse_all'): string =>
|
|
192
|
-
`<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>`;
|
|
193
333
|
return `${one('expand', 'soma.kit.expand_all')}${one('collapse', 'soma.kit.collapse_all')}`;
|
|
194
334
|
}
|
|
195
335
|
|
|
@@ -203,10 +343,74 @@ function joinClasses(a: string, b: string): string {
|
|
|
203
343
|
return [a, b].filter((s) => s !== '').join(' ');
|
|
204
344
|
}
|
|
205
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
|
+
|
|
206
404
|
/** 选中行高亮:行内的 KitTableActions 实例读已选行镜像与主键,给所在行标 data-kit-selected(给了 selectedPath 才有) */
|
|
207
405
|
function selectedProps(ctx: Ctx): Record<string, unknown> {
|
|
208
|
-
|
|
209
|
-
|
|
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
|
+
};
|
|
210
414
|
}
|
|
211
415
|
|
|
212
416
|
/** 行操作组件读「本行删除在途」:协调组件按作用域 + 行主键经忙闲通道登记,这里只给出作用域与主键字段名(作用域空则不绑) */
|
|
@@ -233,6 +437,10 @@ interface Ctx {
|
|
|
233
437
|
filterId?: string;
|
|
234
438
|
/** 表头筛选写进 view 切片的键(列表是带表头筛选的表格时非空) */
|
|
235
439
|
columnParams?: string[];
|
|
440
|
+
/** 主题流水线 next:只有它为真时才输出组件契约的新增属性(legacy 产物逐字节不变) */
|
|
441
|
+
next: boolean;
|
|
442
|
+
/** 正在画分组(groups)里的格:分组里的字段在页面线上没有锚点(spatial/expand 只给顶层字段配单元锚点),拿不到页面线判定 */
|
|
443
|
+
groupDepth: number;
|
|
236
444
|
}
|
|
237
445
|
|
|
238
446
|
/**
|
|
@@ -264,8 +472,60 @@ const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
|
|
|
264
472
|
'Switch', 'Checkbox', 'Range', 'Rating', 'Input', 'Textarea', 'Number', 'Select',
|
|
265
473
|
]);
|
|
266
474
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
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;
|
|
269
529
|
const props: Record<string, unknown> = { value: valuePath };
|
|
270
530
|
for (const [k, v] of Object.entries(cell.props)) props[k] = v;
|
|
271
531
|
// 字段项 props 绑 row.<字段>(RV-1119):行模板里 core 逐行求值(行变量.<字段>),业务对象逐行给值,页面不算
|
|
@@ -274,12 +534,64 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Rec
|
|
|
274
534
|
props.aria_label = cell.label;
|
|
275
535
|
}
|
|
276
536
|
if (cell.valueClass !== '') props.class = cell.valueClass;
|
|
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
|
+
}
|
|
277
587
|
// 状态类字段(单选枚举且选项带 tone)默认呈现为状态(emphasis.status = dot:圆点 + 语义色文字,没有容器;常态用中性灰),全应用统一,与紧凑列表、表格一致
|
|
278
|
-
|
|
588
|
+
// next 且页面线判定能到达本格时,状态的呈现形态(状态点)由页面线的值呈现形态给出,不再补缺省变体(单一值输出)
|
|
589
|
+
if (!owned && cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) {
|
|
279
590
|
const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
|
|
280
|
-
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[]) : [];
|
|
281
592
|
if (field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>))) Object.assign(props, kitStatusPillProps());
|
|
282
593
|
}
|
|
594
|
+
if (owned) dropPipelineOwned(ctx, cell, props);
|
|
283
595
|
return props;
|
|
284
596
|
}
|
|
285
597
|
|
|
@@ -296,35 +608,46 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
|
|
|
296
608
|
}
|
|
297
609
|
const id = idOf ? idOf(cell.field) : cellAnchor(ctx.object, slot, cell.field);
|
|
298
610
|
ctx.components.add(cell.component);
|
|
299
|
-
|
|
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) };
|
|
300
615
|
const star = cell.required === undefined ? '' : `<span${attr('class', KIT_REQUIRED_STAR_CLASS[cell.required])} aria-hidden="true">*</span>`;
|
|
301
616
|
// 只读格的字段说明(J9):标签旁一个「i」图标钮(没有 help 的格不出节点);气泡由 base/hint-tips 的委托在悬停 / 聚焦时才建
|
|
302
617
|
const helpBtn = !cell.label ? '' : kitHelpButtonHtml(cell.helpTip ?? '', cell.label, ctx.options.locale ?? '');
|
|
303
|
-
|
|
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}>`;
|
|
304
622
|
// 值可能被截断(格 / 值类里带 truncate)的格标出提示作用范围,截断了才有全文提示(J10);不截断的格输出不变
|
|
305
623
|
const truncating = TRUNCATING_CLASS_RE.test(`${cell.cellClass} ${cell.valueClass}`);
|
|
306
|
-
|
|
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')}`;
|
|
307
629
|
// summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
|
|
308
630
|
if (cell.hideEmpty === true) {
|
|
309
631
|
const cellId = `${id}__cell`;
|
|
310
632
|
// 纯路径绑定(不发射对象形 when);数字 / 布尔字段由 buildCell 拒收
|
|
311
633
|
showInto[cellId] = { when: valuePath };
|
|
312
|
-
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>`;
|
|
313
635
|
}
|
|
314
|
-
return `<div${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${
|
|
636
|
+
return `<div${cellExtraAttrs}${attr('class', nextLevelClass(ctx, 'item', cell.cellClass))}>${label}${valueHost}</div>`;
|
|
315
637
|
}
|
|
316
638
|
|
|
317
639
|
/** 表格行里的列单元:无 label,只有值组件 */
|
|
318
640
|
function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string, unknown>, marked = false, cellRole = ''): string {
|
|
319
641
|
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
320
642
|
ctx.components.add(cell.component);
|
|
321
|
-
|
|
643
|
+
// 表格列的单元锚点即页面线的字段锚点:next 下按单一值输出去掉会被判定覆盖的缺省
|
|
644
|
+
showInto[id] = { props: cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at, true, true) };
|
|
322
645
|
// KitTableTools 按这些标记接管:列显隐(data-kit-col)、省略 title、就地编辑
|
|
323
|
-
const cellKnobAttrs = `${cell.emphasis !== undefined ? `
|
|
646
|
+
const cellKnobAttrs = `${cell.emphasis !== undefined ? ` ${KIT_ATTR_EMPHASIS}="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ` ${KIT_ATTR_HIGHLIGHT}="true"` : ''}`;
|
|
324
647
|
const marks = marked
|
|
325
|
-
? `
|
|
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}=""` : ''}`
|
|
326
649
|
: '';
|
|
327
|
-
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>`;
|
|
328
651
|
}
|
|
329
652
|
|
|
330
653
|
// ---------------------------------------------------------------- 排布
|
|
@@ -332,25 +655,34 @@ function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string
|
|
|
332
655
|
function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, valueOf: (field: string) => string, at: string, showInto: Record<string, unknown>, idOf?: IdOf): string {
|
|
333
656
|
switch (layout.kind) {
|
|
334
657
|
case 'grid': {
|
|
335
|
-
|
|
336
|
-
|
|
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>`;
|
|
337
663
|
}
|
|
338
664
|
case 'rows': {
|
|
339
665
|
const rows = layout.rows.map((row, r) => {
|
|
340
|
-
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('');
|
|
341
667
|
return `<div${attr('class', layout.rowClass)}>${cells}</div>`;
|
|
342
668
|
}).join('');
|
|
343
669
|
return `<div${attr('class', layout.wrapClass)}>${rows}</div>`;
|
|
344
670
|
}
|
|
345
671
|
case 'flex': {
|
|
346
|
-
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('');
|
|
347
673
|
return `<div${attr('class', layout.wrapClass)}>${cells}</div>`;
|
|
348
674
|
}
|
|
349
675
|
case 'groups': {
|
|
350
676
|
if (layout.tabs === true) return renderGroupTabs(ctx, slot, layout, valueOf, at, showInto, idOf);
|
|
351
677
|
const markers = KIT_GROUP_MARKERS[layout.marker];
|
|
352
678
|
const sections = layout.groups.map((g, i) => {
|
|
353
|
-
|
|
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
|
+
}
|
|
354
686
|
// 节上方的分隔线(KitDivider 实例;文字为空 = 纯线)
|
|
355
687
|
let divider = '';
|
|
356
688
|
if (g.divider !== false) {
|
|
@@ -360,22 +692,28 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
360
692
|
divider = host('KitDivider', did);
|
|
361
693
|
}
|
|
362
694
|
const grpPart = g.surface !== undefined ? kitContainerPartOf(g.surface) : KIT_PART_SECTION;
|
|
363
|
-
|
|
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')}`;
|
|
364
697
|
// summary 分组 section 吃容器边框/圆角规则,在抽屉等非 flat 容器内需有卡片内边距,避免文字紧贴圆角边框
|
|
365
|
-
const sectionCls = slot === 'summary' ? joinClasses(layout.sectionClass, 'p-card') : layout.sectionClass;
|
|
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))}"` : '';
|
|
366
704
|
if (!g.collapsible) {
|
|
367
705
|
// 外观声明(D-08):分组 section 声明 card(与删标签名规则前渲染一致)
|
|
368
|
-
return `${divider}<section
|
|
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>`;
|
|
369
707
|
}
|
|
370
708
|
// 可折叠:标题是 h4 里的 button(aria-expanded + aria-controls),折叠体是块级 div(hidden 不和 flex / grid 同元素),初态按 open 写好
|
|
371
|
-
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)}">`
|
|
372
710
|
+ `<span>${esc(g.title)}</span>`
|
|
373
|
-
+ `<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>`
|
|
374
712
|
+ '</button>';
|
|
375
|
-
const body = `<div id="${esc(g.id)}" role="region" aria-labelledby="${esc(g.id)}__btn"${attr('class', g.open ? '' : 'hidden')}>${inner}</div>`;
|
|
376
|
-
return `${divider}<section
|
|
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>`;
|
|
377
715
|
}).join('');
|
|
378
|
-
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>`;
|
|
379
717
|
if (!layout.collapsible) return wrap;
|
|
380
718
|
// 隐藏接线件紧跟在折叠根之后(放进根里会在 flex 容器里多占一个 gap)
|
|
381
719
|
const wireId = `${layout.groups[0]!.id}__wire`;
|
|
@@ -393,6 +731,7 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
393
731
|
|
|
394
732
|
export function groupTabBarAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gbar`; }
|
|
395
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}`; }
|
|
396
735
|
export function groupPanelAnchor(object: string, slot: KitViewSlot, index: number | string): string { return `${object}__${slot}__gpanel__${index}`; }
|
|
397
736
|
export function groupTabWireAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gwire`; }
|
|
398
737
|
|
|
@@ -415,7 +754,13 @@ function renderGroupTabs(
|
|
|
415
754
|
): string {
|
|
416
755
|
const object = ctx.object;
|
|
417
756
|
const panelHtml = layout.groups.map((g, i) => {
|
|
418
|
-
|
|
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
|
+
}
|
|
419
764
|
let divider = '';
|
|
420
765
|
if (g.divider !== false) {
|
|
421
766
|
const did = `${g.id}__div`;
|
|
@@ -440,6 +785,8 @@ export function groupTabsFrame(
|
|
|
440
785
|
wrapClass: string,
|
|
441
786
|
showInto: Record<string, unknown>,
|
|
442
787
|
components: Set<string>,
|
|
788
|
+
/** 看板的面板组页签:整块是一张页签面、页签条是面头(通栏贴面上缘);缺省 = 在对象面里,下划线页签条 */
|
|
789
|
+
onCanvas = false,
|
|
443
790
|
): string {
|
|
444
791
|
// data-kit-tab-text:结构 CSS 按选中字重预留宽度,切换选中不位移(KT-K-tabs-2)
|
|
445
792
|
// KT-K-tabs-3(§6.1 G-16):放不下的尾部页签编译期估宽、按容器档隐藏并收进「更多」,选中页签恒可见
|
|
@@ -449,7 +796,7 @@ export function groupTabsFrame(
|
|
|
449
796
|
? `<div${attr('class', `${overflow.moreClass} -mb-px`)}><div data-soma-component="KitActionMore" data-soma-id="${esc(`${object}__${slot}__gmore`)}"></div></div>`
|
|
450
797
|
: '';
|
|
451
798
|
if (overflow.hasMore) components.add('KitActionMore');
|
|
452
|
-
const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}"
|
|
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('');
|
|
453
800
|
const wireId = groupTabWireAnchor(object, slot);
|
|
454
801
|
components.add('KitTabsWiring');
|
|
455
802
|
showInto[wireId] = {
|
|
@@ -460,9 +807,14 @@ export function groupTabsFrame(
|
|
|
460
807
|
ids: titles.map((_t, i) => String(i)),
|
|
461
808
|
},
|
|
462
809
|
};
|
|
463
|
-
const bar = `<div data-soma-id="${esc(groupTabBarAnchor(object, slot))}" role="tablist"${attr('class', GROUPS_AS.barClass)}>${buttons}${moreShell}</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>`;
|
|
464
811
|
const wiring = `<div data-soma-component="KitTabsWiring" data-soma-id="${esc(wireId)}" hidden></div>`;
|
|
465
|
-
|
|
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>`;
|
|
466
818
|
}
|
|
467
819
|
|
|
468
820
|
// ---------------------------------------------------------------- list
|
|
@@ -471,7 +823,11 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
|
|
|
471
823
|
return actions.map((a) => ({
|
|
472
824
|
id: a.id,
|
|
473
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 } : {}),
|
|
474
828
|
...(a.tone !== undefined ? { tone: a.tone } : {}),
|
|
829
|
+
// SCON-169:功能名透传(声明的,或按 builtin / id 推断的;推不出不带)——行操作 / 右键菜单 / 详情头按钮组按功能名取角色,显式 tone 仍优先
|
|
830
|
+
...functionItemOf(a),
|
|
475
831
|
...(a.builtin !== undefined ? { builtin: a.builtin } : {}),
|
|
476
832
|
...(a.targetOverlay !== undefined ? { target: a.targetOverlay } : {}),
|
|
477
833
|
// K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
|
|
@@ -482,6 +838,12 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
|
|
|
482
838
|
}));
|
|
483
839
|
}
|
|
484
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
|
+
|
|
485
847
|
/** 动作的置灰原因:字面量文案(非空)原样带;路径形与非法值不带(路径进 actionState,非法值已在入口记诊断) */
|
|
486
848
|
function literalReason(a: KitAction): { disabledReason?: string } {
|
|
487
849
|
const source = classifyDisabledReason(a[KIT_ACTION_REASON_KEY]);
|
|
@@ -567,7 +929,11 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
567
929
|
|
|
568
930
|
const tools = layout.tools === true && layout.tree === null;
|
|
569
931
|
const selHead = layout.selectHeadClass ?? layout.selectClass;
|
|
570
|
-
|
|
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') : '';
|
|
571
937
|
// 表格语义(W3C table 模式:table > row > columnheader / cell,aria-sort 在 columnheader 上):
|
|
572
938
|
// 树表(外壳由 KitTreeTable 自带 treegrid,表头在它之外)与展开详情行(行下挂非 row 的开关与详情体)不满足 table 的结构要求,这两种不写表格角色
|
|
573
939
|
const semTable = layout.tree === null && layout.expand === null;
|
|
@@ -578,6 +944,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
578
944
|
// 可排序 / 可筛选表头:页面直接实例 KitTableHead(view 切片 sort / order / cf_<字段> 的写者);整行由组件渲染
|
|
579
945
|
const cells: Array<Record<string, unknown>> = [];
|
|
580
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 });
|
|
581
949
|
for (const h of layout.head) {
|
|
582
950
|
cells.push({
|
|
583
951
|
label: h.label, class: h.class,
|
|
@@ -590,7 +958,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
590
958
|
...(h.col !== undefined && gapCols.has(h.col) ? { gapField: h.col } : {}),
|
|
591
959
|
});
|
|
592
960
|
}
|
|
593
|
-
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
|
+
}
|
|
594
965
|
ctx.components.add('KitTableHead');
|
|
595
966
|
ctx.show[headAnchor(object)] = {
|
|
596
967
|
props: {
|
|
@@ -601,10 +972,12 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
601
972
|
...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
|
|
602
973
|
},
|
|
603
974
|
};
|
|
604
|
-
head = host('KitTableHead', headAnchor(object));
|
|
975
|
+
head = layout.contentTracks === true ? trackHost('KitTableHead', headAnchor(object), CONTENT_TRACK_PASS_CLASS) : host('KitTableHead', headAnchor(object));
|
|
605
976
|
} else {
|
|
606
977
|
const headParts: string[] = [];
|
|
607
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>`);
|
|
608
981
|
// 多级表头:同组的连续叶子收进一个组块(flex 列:组标题格 + 叶子行);块与叶子行是 presentation,叶子 / 标题格仍直属表头行
|
|
609
982
|
const groups = layout.headGroups ?? [];
|
|
610
983
|
let openGroup = -1;
|
|
@@ -614,13 +987,13 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
614
987
|
const g = groups[openGroup]!;
|
|
615
988
|
const pres = semTable ? ' role="presentation"' : '';
|
|
616
989
|
const title = `<div${semTable ? ` role="columnheader" aria-colspan="${g.span}"` : ''}${attr('class', g.titleClass)}>${esc(g.title)}</div>`;
|
|
617
|
-
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>`);
|
|
618
991
|
openGroup = -1;
|
|
619
992
|
leaves = [];
|
|
620
993
|
};
|
|
621
994
|
for (const h of layout.head) {
|
|
622
995
|
if (h.group !== openGroup) flushGroup();
|
|
623
|
-
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>`;
|
|
624
997
|
if (h.group === undefined) headParts.push(leaf);
|
|
625
998
|
else {
|
|
626
999
|
openGroup = h.group;
|
|
@@ -628,8 +1001,17 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
628
1001
|
}
|
|
629
1002
|
}
|
|
630
1003
|
flushGroup();
|
|
631
|
-
if (layout.rowActions.length > 0)
|
|
632
|
-
|
|
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>`;
|
|
633
1015
|
}
|
|
634
1016
|
|
|
635
1017
|
// 树表:列 / 表头 / 三态 / 分页与普通表格同一条路径,只有表体换成 KitTreeTable(层级 + 展开状态在组件里)
|
|
@@ -660,12 +1042,13 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
660
1042
|
let treeCtx = '';
|
|
661
1043
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
662
1044
|
ctx.components.add('KitContextMenu');
|
|
663
|
-
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) } };
|
|
664
1046
|
treeCtx = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
665
1047
|
}
|
|
666
1048
|
const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
667
|
-
const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
668
|
-
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>`;
|
|
669
1052
|
return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
670
1053
|
}
|
|
671
1054
|
|
|
@@ -686,43 +1069,69 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
686
1069
|
...removeBusyProps(ctx),
|
|
687
1070
|
},
|
|
688
1071
|
};
|
|
689
|
-
rowParts.push(`<div${cellRoleAttr(cellRole)}
|
|
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>`);
|
|
690
1073
|
} else {
|
|
691
1074
|
ctx.components.add('Checkbox');
|
|
692
1075
|
rowShow[selAnchor(object)] = { props: {} };
|
|
693
|
-
rowParts.push(`<div${cellRoleAttr(cellRole)}
|
|
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>`);
|
|
694
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>`);
|
|
695
1081
|
}
|
|
696
1082
|
layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, gapCols.get(c.field) ?? c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
|
|
697
1083
|
if (layout.rowActions.length > 0) {
|
|
698
1084
|
ctx.components.add('KitTableActions');
|
|
699
1085
|
rowShow[opsAnchor(object)] = {
|
|
700
|
-
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
|
+
},
|
|
701
1105
|
};
|
|
702
|
-
|
|
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
|
+
}
|
|
703
1111
|
}
|
|
704
1112
|
// pickOnRow 或行样式档位(rowTone)且没有行操作列:补一个无按钮的 KitTableActions 实例,专管行点击 / 行样式
|
|
705
1113
|
if ((ctx.options.pickOnRow === true || layout.rowTone !== undefined) && layout.rowActions.length === 0) {
|
|
706
1114
|
ctx.components.add('KitTableActions');
|
|
707
1115
|
rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) } };
|
|
708
|
-
rowParts.push(host('KitTableActions', opsAnchor(object)));
|
|
1116
|
+
rowParts.push(layout.contentTracks === true ? trackHost('KitTableActions', opsAnchor(object), CONTENT_TRACK_IDLE_CLASS) : host('KitTableActions', opsAnchor(object)));
|
|
709
1117
|
}
|
|
710
1118
|
// 右键菜单(Q 波 G6):行内一个 KitContextMenu 实例(包在 hidden 壳里,不占栅格列),行容器标 data-kit-ctx 供它监听
|
|
711
1119
|
const ctxItems = layout.contextMenu ?? [];
|
|
712
1120
|
if (ctxItems.length > 0) {
|
|
713
1121
|
ctx.components.add('KitContextMenu');
|
|
714
|
-
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) } };
|
|
715
1123
|
rowParts.push(`<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`);
|
|
716
1124
|
}
|
|
717
1125
|
const rowClass = ctx.options.pickOnRow === true ? joinClasses(layout.rowClass, 'cursor-pointer') : layout.rowClass;
|
|
718
1126
|
// 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
|
|
719
1127
|
const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
|
|
720
|
-
const rowMark = `${marked ?
|
|
1128
|
+
const rowMark = `${marked ? ` ${KIT_ATTR_ROW}=""` : ''}${ctxItems.length > 0 ? ` ${KIT_ATTR_CTX}=""` : ''}`;
|
|
721
1129
|
// 普通表格的行容器首子节点是 <template>,数据行从第 2 个子节点起:斑马纹用 odd 键(树表 / 虚拟表无 template,走 IR 里的 even 键)
|
|
722
1130
|
const striped = layout.stripeClass !== '';
|
|
723
1131
|
const stripe = striped ? KIT_CLASS_DEFAULTS.tableRowStripedAfterTemplate : '';
|
|
724
1132
|
const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInnerAfterTemplate) : rowClass;
|
|
725
|
-
|
|
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>`;
|
|
726
1135
|
let itemHtml = rowEl;
|
|
727
1136
|
if (layout.expand !== null) {
|
|
728
1137
|
// 展开行:行下一条“展开详情”开关(KitTableActions expand)+ 默认 hidden 的详情体;开合状态在开关组件里
|
|
@@ -738,17 +1147,26 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
738
1147
|
const detail = listExpand !== undefined ? '' : renderArrangement(
|
|
739
1148
|
ctx, 'summary', layout.expand.layout, (f) => `${ctx.rowVar}.${f}`, `${at}.expand`, rowShow, (f) => expandCellAnchor(object, f),
|
|
740
1149
|
);
|
|
741
|
-
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}`
|
|
742
1151
|
+ `<div${attr('class', EXPAND_TOGGLE_CLASS)}>${host('KitTableActions', expandToggleAnchor(object))}</div>`
|
|
743
|
-
|
|
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>`;
|
|
744
1154
|
}
|
|
745
1155
|
const rowTemplate = `<template data-soma-role="item">${itemHtml}</template>`;
|
|
746
|
-
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)) };
|
|
747
1165
|
|
|
748
1166
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
749
1167
|
|
|
750
1168
|
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
751
|
-
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"` : '';
|
|
752
1170
|
const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
|
|
753
1171
|
const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
|
|
754
1172
|
// 静态表头(不可排序)的整列缺失原因标注由 KitTableGap 接线件画;可排序表头由 KitTableHead 自己画(上面已给 rows)
|
|
@@ -759,7 +1177,10 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
759
1177
|
ctx.show[gapId] = { props: { rows: ctx.rowsPath, fields: [...gapCols.keys()] } };
|
|
760
1178
|
gapHost = host('KitTableGap', gapId);
|
|
761
1179
|
}
|
|
762
|
-
|
|
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>`;
|
|
763
1184
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
764
1185
|
}
|
|
765
1186
|
|
|
@@ -800,12 +1221,13 @@ function renderVirtualTable(
|
|
|
800
1221
|
let ctxHost = '';
|
|
801
1222
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
802
1223
|
ctx.components.add('KitContextMenu');
|
|
803
|
-
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) } };
|
|
804
1225
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
805
1226
|
}
|
|
806
1227
|
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
807
|
-
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
|
|
808
|
-
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))}"` : ''}>`
|
|
809
1231
|
+ `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
|
|
810
1232
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
811
1233
|
}
|
|
@@ -834,13 +1256,16 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
834
1256
|
items: layout.toolbar ?? [],
|
|
835
1257
|
scroll: layout.scroll === true,
|
|
836
1258
|
editMode: layout.editMode ?? '',
|
|
1259
|
+
...(layout.groupBy !== undefined ? { groupBy: layout.groupBy } : {}),
|
|
1260
|
+
...(layout.reorder !== undefined ? { reorder: layout.reorder } : {}),
|
|
837
1261
|
selectMode: layout.select,
|
|
838
1262
|
selectScope: layout.selectScope ?? 'all',
|
|
839
1263
|
...(batchOn
|
|
840
1264
|
? {
|
|
841
1265
|
selected: ctx.options.selectedPath,
|
|
842
1266
|
batch: batch.map((b) => {
|
|
843
|
-
|
|
1267
|
+
// 批量条的忙态名:批量动作所接的具名动作名(不是动作所在位置 on)
|
|
1268
|
+
const busyAction = namedActionOf(b.action, ctx.object);
|
|
844
1269
|
return {
|
|
845
1270
|
id: b.id,
|
|
846
1271
|
name: b.name,
|
|
@@ -862,29 +1287,37 @@ function renderSummary(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>
|
|
|
862
1287
|
if (layout.summary === undefined || layout.summary === null || layout.tree !== null) return '';
|
|
863
1288
|
const id = summaryAnchor(ctx.object);
|
|
864
1289
|
ctx.components.add('KitTableSummary');
|
|
865
|
-
// 合计行固定选择/操作角格用与合计行一致的实底 bg-surface-
|
|
1290
|
+
// 合计行固定选择/操作角格用与合计行一致的实底 bg-surface-band(合计行属于「带」,collection 线统一)与 z-20,防止横向滚动数字穿透固定列
|
|
866
1291
|
const summaryCorner = (cls: string): string => cls
|
|
867
|
-
.replace(/\bbefore:bg-surface-band\b/g, 'before:bg-surface-
|
|
868
|
-
.replace(/\bbg-surface-band\b/g, 'bg-surface-
|
|
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')
|
|
869
1294
|
.replace(/\bz-10\b/g, 'z-20');
|
|
1295
|
+
const moreSummaryHead = layout.hasMoreColumn === true ? summaryCorner(layout.moreActionsHeadClass ?? layout.moreActionsClass ?? '') : '';
|
|
870
1296
|
ctx.show[id] = {
|
|
871
1297
|
props: {
|
|
872
1298
|
rows: ctx.rowsPath,
|
|
873
1299
|
class: layout.summaryRowClass ?? '',
|
|
874
1300
|
...(semTable ? { semantics: 'table' } : {}),
|
|
875
|
-
selectClass: layout.select !== 'none' ? summaryCorner(selHead) : '',
|
|
876
|
-
actionsClass: layout.rowActions.length > 0 ? summaryCorner(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)) : '',
|
|
877
1303
|
label: layout.summary.label,
|
|
878
1304
|
labelField: layout.summary.labelField,
|
|
879
|
-
columns:
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
+
],
|
|
885
1318
|
},
|
|
886
1319
|
};
|
|
887
|
-
return host('KitTableSummary', id);
|
|
1320
|
+
return layout.contentTracks === true ? trackHost('KitTableSummary', id, CONTENT_TRACK_PASS_CLASS) : host('KitTableSummary', id);
|
|
888
1321
|
}
|
|
889
1322
|
|
|
890
1323
|
/** 骨架屏的形态参数:表格按列的跨度类(含选择 / 操作列),cards / stack 沿用列表容器类 */
|
|
@@ -903,7 +1336,7 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
|
|
|
903
1336
|
return shape === 'text' ? h.class : { cls: h.class, shape };
|
|
904
1337
|
});
|
|
905
1338
|
const cols: Array<string | KitSkeletonCol> = [
|
|
906
|
-
...(layout.select !== 'none' && layout.selectClass !== '' ? [layout.selectClass] : []),
|
|
1339
|
+
...((layout.select !== 'none' || layout.serial === true || layout.reorder !== undefined) && layout.selectClass !== '' ? [layout.selectClass] : []),
|
|
907
1340
|
...dataCols,
|
|
908
1341
|
...(layout.rowActions.length > 0 && layout.actionsClass !== '' ? [layout.actionsClass] : []),
|
|
909
1342
|
];
|
|
@@ -915,20 +1348,29 @@ function skeletonShapeOf(layout: Extract<KitLayoutIR, { kind: 'table' | 'cards'
|
|
|
915
1348
|
/** 展开行的开关条与详情体(语义色名 + 内置尺度) */
|
|
916
1349
|
const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
|
|
917
1350
|
// 展开行的内容是凹槽面:与上下行之间已有面差,不再加线(一处分隔一种手段,KT-B5 / D-30)
|
|
918
|
-
|
|
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';
|
|
919
1355
|
|
|
920
1356
|
/** 标题与它旁边的集合辅助文字(共 N 条 / 已筛选提示)同一组:基线对齐、窄时换行 */
|
|
921
1357
|
const TITLE_GROUP_CLASS = 'flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1';
|
|
922
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
|
+
|
|
923
1363
|
/** 集合三态面板:列表之后、分页器之前 */
|
|
924
1364
|
function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
|
|
925
1365
|
if (state === null) return '';
|
|
926
1366
|
const id = stateAnchor(ctx.object);
|
|
927
1367
|
ctx.components.add('KitCollectionState');
|
|
1368
|
+
const stageCenter = state.errorOnly !== true;
|
|
928
1369
|
ctx.show[id] = {
|
|
929
1370
|
props: {
|
|
930
1371
|
data: ctx.basePath,
|
|
931
1372
|
rows: ctx.rowsPath,
|
|
1373
|
+
...(stageCenter ? { class: COLLECTION_STATE_ROOT_CLASS } : {}),
|
|
932
1374
|
config: {
|
|
933
1375
|
object: ctx.object,
|
|
934
1376
|
rowsPath: ctx.options.listShape.rows,
|
|
@@ -942,10 +1384,16 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
|
|
|
942
1384
|
...(state.errorOnly === true ? { mode: 'errorOnly' } : {}),
|
|
943
1385
|
// 筛选无结果 / 无数据的区分:本对象有筛选栏或表头筛选时,把作用域与清除入口交给三态面板(没有筛选的页面配置不变)
|
|
944
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 } : {}),
|
|
945
1391
|
},
|
|
946
1392
|
},
|
|
947
1393
|
};
|
|
948
|
-
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);
|
|
949
1397
|
}
|
|
950
1398
|
|
|
951
1399
|
/** 集合被筛选状态判断所需的配置:区域作用域、筛选栏宿主锚点(清除时优先点它的「重置」)、表头筛选键;对象没有任何筛选则为空 */
|
|
@@ -985,13 +1433,19 @@ function renderMeta(ctx: Ctx, plan: { count: boolean; hint: boolean }): string {
|
|
|
985
1433
|
}
|
|
986
1434
|
|
|
987
1435
|
/** 面板标题绑展示对象只读成员(view.list.title: view.<成员>):h3 里放一个 Text 实例,值是 page.<成员>,成员变了标题被动刷新 */
|
|
988
|
-
function renderDynamicTitle(ctx: Ctx, slot: KitViewSlot, path: string): string {
|
|
989
|
-
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);
|
|
990
1438
|
const textId = `${id}__text`;
|
|
991
1439
|
ctx.components.add('Text');
|
|
992
1440
|
ctx.show[textId] = { props: { value: viewPathToCore(path) } };
|
|
993
|
-
|
|
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>`;
|
|
994
1446
|
}
|
|
1447
|
+
/** 动态标题在标题出口里的占位文字(不含 HTML 特殊字符,转义后原样,随即换成 Text 宿主) */
|
|
1448
|
+
const DYNAMIC_TITLE_SLOT = 'kit-dynamic-title-slot';
|
|
995
1449
|
|
|
996
1450
|
function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boolean; mode?: string; layout?: string; showTotal?: boolean } | null): string {
|
|
997
1451
|
if (pager === null) return '';
|
|
@@ -1018,8 +1472,9 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
|
|
|
1018
1472
|
function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, { kind: 'cards' | 'stack' }>['compact']>, rowShow: Record<string, unknown>): string {
|
|
1019
1473
|
const D = KIT_CLASS_DEFAULTS;
|
|
1020
1474
|
const at = 'views.list.layout.compact';
|
|
1475
|
+
// 紧凑列表的格锚点即列表槽的单元锚点(页面线字段锚点),next 下按单一值输出处理
|
|
1021
1476
|
const sized = (cell: KitCell): Record<string, unknown> => {
|
|
1022
|
-
const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at);
|
|
1477
|
+
const props = cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at, true, true);
|
|
1023
1478
|
if (cell.component === 'Text' || cell.component === 'Tag') props.size ??= 'sm';
|
|
1024
1479
|
return props;
|
|
1025
1480
|
};
|
|
@@ -1048,9 +1503,10 @@ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, {
|
|
|
1048
1503
|
const props = sized(cell);
|
|
1049
1504
|
// 值带语气(单选枚举、选项带 tone)= 状态 → 圆点 + 文字;不带语气的分类 / 多值 / 布尔 = 标签(浅底小圆角)——状态与标签永不同形(KT-K-status-3)
|
|
1050
1505
|
const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
|
|
1051
|
-
const opts = Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
1506
|
+
const opts = Array.isArray(props.options) ? (props.options as unknown[]) : Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
1052
1507
|
const toned = field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>));
|
|
1053
|
-
|
|
1508
|
+
// next:状态点形态归页面线的值呈现形态(单一值输出)
|
|
1509
|
+
if (!ctx.next && toned && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1054
1510
|
rowShow[id] = { props };
|
|
1055
1511
|
return `<span${attr('class', D.paneTag)}>${host(comp, id)}</span>`;
|
|
1056
1512
|
};
|
|
@@ -1073,9 +1529,10 @@ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, {
|
|
|
1073
1529
|
return `<span data-soma-id="${esc(wid)}"${attr('class', itemCls)}>${sep}${host(cell.component, id)}</span>`;
|
|
1074
1530
|
});
|
|
1075
1531
|
const [status, ...kinds] = tags;
|
|
1076
|
-
|
|
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>`;
|
|
1077
1534
|
const row2 = textHtml.length > 0 || kinds.length > 0
|
|
1078
|
-
? `<div${attr('class', `${D.paneRow} text-fg-muted`)}
|
|
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>`
|
|
1079
1536
|
: '';
|
|
1080
1537
|
return `<div${attr('class', D.compactBody)}>${row1}${row2}</div>`;
|
|
1081
1538
|
}
|
|
@@ -1087,7 +1544,7 @@ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, {
|
|
|
1087
1544
|
const type = ctx.options.schema?.[cell.field]?.type;
|
|
1088
1545
|
const numeric = isNumericColumnType(type);
|
|
1089
1546
|
// 状态字段:圆点 + 文字、没有容器(emphasis.status = dot);其余文本沿用组件默认外观
|
|
1090
|
-
if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1547
|
+
if (!ctx.next && cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
1091
1548
|
// 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上),非数值文本带省略防压盖金额 / 状态点
|
|
1092
1549
|
if (cell.component === 'Text') {
|
|
1093
1550
|
props.class = joinClasses(typeof props.class === 'string' ? props.class : '', numeric ? 'text-fg-muted' : 'text-fg-muted block min-w-0 truncate');
|
|
@@ -1134,18 +1591,21 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
1134
1591
|
let ctxHost = '';
|
|
1135
1592
|
if (ctxItems.length > 0) {
|
|
1136
1593
|
ctx.components.add('KitContextMenu');
|
|
1137
|
-
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) } };
|
|
1138
1595
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
1139
1596
|
}
|
|
1140
|
-
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')}`;
|
|
1141
1600
|
const itemClass = pickOnly ? joinClasses(layout.itemClass, 'cursor-pointer') : layout.itemClass;
|
|
1142
|
-
const rowMark = layout.rowTone !== undefined || pickOnly ?
|
|
1601
|
+
const rowMark = layout.rowTone !== undefined || pickOnly ? ` ${KIT_ATTR_ROW}=""` : '';
|
|
1143
1602
|
const actionsPart = compact !== undefined && actions !== '' ? `<div${attr('class', KIT_CLASS_DEFAULTS.compactActions)}>${actions}</div>` : actions;
|
|
1144
|
-
const compactMark = compact !== undefined ?
|
|
1145
|
-
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>`;
|
|
1146
1605
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
1147
1606
|
const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
|
|
1148
|
-
|
|
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)}`;
|
|
1149
1609
|
}
|
|
1150
1610
|
|
|
1151
1611
|
// ---------------------------------------------------------------- static(写死形状数据组件)
|
|
@@ -1161,10 +1621,17 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
1161
1621
|
// view.props:配置类 prop 原样透传(保留键已在 renderObject 剔除);view.value:可编辑件的值绑定路径
|
|
1162
1622
|
if (layout.props !== undefined) for (const [k, v] of Object.entries(layout.props)) props[k] = v;
|
|
1163
1623
|
if (layout.value !== undefined) props.value = layout.value;
|
|
1164
|
-
// view.on 接了具名动作的写入 / 提交类事件:自动带上该动作的 busy 绑定;页面手写的 busy_action
|
|
1165
|
-
|
|
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);手写的照上一支按对象改名
|
|
1166
1632
|
const busyNames = busyActionOf(layout.component, layout.on);
|
|
1167
|
-
|
|
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);
|
|
1168
1635
|
}
|
|
1169
1636
|
// view.on 接了 data.orderMove,或可写静态组件走内置 data.submit:缺省补本对象名与作用域
|
|
1170
1637
|
if (props.object === undefined && (layout.dataSubmit === true || Object.values(layout.on ?? {}).some((v) => (typeof v === 'string' ? v : v.action) === 'data.orderMove'))) {
|
|
@@ -1193,14 +1660,14 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
1193
1660
|
if ((layout.contextMenu ?? []).length > 0) {
|
|
1194
1661
|
ctx.components.add('KitContextMenu');
|
|
1195
1662
|
const menuId = staticCtxAnchor(ctx.object, slot);
|
|
1196
|
-
ctx.show[menuId] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
|
|
1197
|
-
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>`;
|
|
1198
1665
|
}
|
|
1199
1666
|
const hasStatHighlight = layout.component === 'StatGroup'
|
|
1200
1667
|
&& Array.isArray(props.items)
|
|
1201
1668
|
&& props.items.some((it) => it !== null && typeof it === 'object' && (it as { highlight?: unknown }).highlight === true);
|
|
1202
1669
|
const rawHost = host(layout.component, id);
|
|
1203
|
-
return hasStatHighlight ? rawHost.replace('></div>',
|
|
1670
|
+
return hasStatHighlight ? rawHost.replace('></div>', ` ${KIT_ATTR_HIGHLIGHT}="true"></div>`) : rawHost;
|
|
1204
1671
|
}
|
|
1205
1672
|
|
|
1206
1673
|
// ---------------------------------------------------------------- KitObjectForm(filter / 可编辑 form)
|
|
@@ -1240,6 +1707,7 @@ export function formFieldsAndClasses(layout: KitLayoutIR): { fields: KitCell[];
|
|
|
1240
1707
|
cellClass: 'col-span-12', labelClass: layout.titleClass, valueClass: '', errorClass: '',
|
|
1241
1708
|
group: {
|
|
1242
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 } : {}),
|
|
1243
1711
|
fields: inner.fields.filter((f) => f.placeholder !== true && f.component !== '').map((f) => f.field),
|
|
1244
1712
|
},
|
|
1245
1713
|
});
|
|
@@ -1265,10 +1733,24 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1265
1733
|
}
|
|
1266
1734
|
const id = viewAnchor(ctx.object, slot);
|
|
1267
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
|
+
});
|
|
1268
1745
|
// 底栏动作组的「更多」入口(可编辑表单;筛选表单没有)
|
|
1269
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
|
+
: [];
|
|
1270
1752
|
// 筛选工具条(风格档案 SPACE_MATERIAL):简单筛选改成「搜索框 + 分段 / 下拉」一条工具条(见 filter-toolbar.ts),不合格返回 null 照旧排布
|
|
1271
|
-
const toolbarCells = slot === 'filter' && layout.kind === 'grid' ? filterToolbarCells(packed.fields, ctx.options.locale ?? '') : null;
|
|
1753
|
+
const toolbarCells = slot === 'filter' && layout.kind === 'grid' && exactFields.length === 0 ? filterToolbarCells(packed.fields, ctx.options.locale ?? '') : null;
|
|
1272
1754
|
if (toolbarCells !== null) packed.fields = toolbarCells;
|
|
1273
1755
|
for (const c of packed.fields) if (c.component !== '') ctx.components.add(c.component);
|
|
1274
1756
|
// 可编辑 form 的 mode / initial 可绑镜像路径(字符串路径由 core 解析成绑定);filter 恒为字面量
|
|
@@ -1288,13 +1770,33 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1288
1770
|
// 本页有效信封(与 detail.envelope 同一来源:编译期页面 > 应用);筛选与可编辑表单的远程选项、句柄 envelope() 据此解包。未声明不写这个 prop
|
|
1289
1771
|
const envelope = getCompileEnvelope();
|
|
1290
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
|
+
}
|
|
1291
1785
|
// M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
|
|
1292
1786
|
const fo = ir.views[slot]?.formOpts;
|
|
1293
1787
|
// 筛选栏(cols 排布):排布引擎的投影(filter-plan.ts)——根容器左起流式换行、字段按类型取 [最小, 理想, 最大] 定宽(不拉伸)、
|
|
1294
1788
|
// 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段并对齐到控件那一行;档位(即时 / 提交 / 更多)与钉住个数作为 props,运行时不量宽
|
|
1295
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');
|
|
1296
1794
|
if (toolbarCells !== null) {
|
|
1297
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
|
+
}
|
|
1298
1800
|
} else if (proj !== undefined && layout.kind === 'grid') {
|
|
1299
1801
|
props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, proj.widthClasses[i] ?? '') }));
|
|
1300
1802
|
const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
|
|
@@ -1316,7 +1818,11 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1316
1818
|
if (slot === 'form') {
|
|
1317
1819
|
if (ctx.options.validateOn !== undefined) props.validateOn = ctx.options.validateOn;
|
|
1318
1820
|
if (ctx.options.leaveGuard === true) props.leaveGuard = true;
|
|
1319
|
-
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
|
+
}
|
|
1320
1826
|
if (fo?.footerActions !== undefined) {
|
|
1321
1827
|
const items = fo.footerActions.flatMap((aid) => {
|
|
1322
1828
|
const a = ctx.options.actions?.find((x) => x.id === aid);
|
|
@@ -1352,36 +1858,68 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1352
1858
|
const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
|
|
1353
1859
|
let html = host('KitObjectForm', id);
|
|
1354
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
|
+
}
|
|
1355
1866
|
// 容器查询只对后代生效:表单根上的字段宽度 / 动作区变体类(@<档>:w-N)要查到宿主这一层,所以宿主做查询容器
|
|
1356
1867
|
if (proj !== undefined) {
|
|
1357
1868
|
html = html.includes(' class="') ? html.replace(' class="', ` class="${KIT_WIDTH.containerClass} `) : html.replace('></div>', ` class="${KIT_WIDTH.containerClass}"></div>`);
|
|
1358
1869
|
}
|
|
1870
|
+
// 工具条式筛选的条带自然宽(全部内联的需求宽)记在宿主上(体检事实;面恒铺满,现无读取方)
|
|
1871
|
+
if (collapse !== null) html = html.replace('></div>', ` ${KIT_NATURAL_W_ATTR}="${collapse.strip.naturalUnits}"></div>`);
|
|
1359
1872
|
return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
|
|
1360
1873
|
}
|
|
1361
1874
|
|
|
1362
1875
|
// ---------------------------------------------------------------- 工具栏
|
|
1363
1876
|
|
|
1364
|
-
/**
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
if (a.tone === 'danger' || a.tone === 'neutral' || a.tone === 'primary' || a.tone === 'ghost' || a.tone === 'tonal') {
|
|
1376
|
-
return a.tone;
|
|
1377
|
-
}
|
|
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
|
+
}
|
|
1884
|
+
|
|
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;
|
|
1378
1888
|
if (a.tone === 'info' || a.tone === 'success') return 'primary';
|
|
1379
1889
|
if (a.tone === 'warning') return 'tonal';
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
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 });
|
|
1912
|
+
}
|
|
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;
|
|
1385
1923
|
}
|
|
1386
1924
|
|
|
1387
1925
|
/** 工具栏按钮的置灰原因 prop(Button 的 disabled_reason);没写 disabled 或来源是行路径 / 非法值时不带 */
|
|
@@ -1393,9 +1931,8 @@ function toolbarReasonProp(a: KitAction): { disabled_reason?: string } {
|
|
|
1393
1931
|
}
|
|
1394
1932
|
|
|
1395
1933
|
/** 动作在动作组里的重要度:primary 语气 = 主操作(恒在行尾、恒可见);danger 语气最后保留;其余为次要 */
|
|
1396
|
-
function toolbarImportance(
|
|
1397
|
-
|
|
1398
|
-
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';
|
|
1399
1936
|
}
|
|
1400
1937
|
|
|
1401
1938
|
/**
|
|
@@ -1406,7 +1943,14 @@ function toolbarImportance(a: KitAction): KitActionImportance {
|
|
|
1406
1943
|
function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
1407
1944
|
const declared = actions.filter((a) => a.on === 'toolbar');
|
|
1408
1945
|
if (declared.length === 0) return '';
|
|
1409
|
-
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
|
+
);
|
|
1410
1954
|
const byId = new Map(declared.map((a) => [a.id, a] as const));
|
|
1411
1955
|
const list = projection.order.flatMap((id) => { const a = byId.get(id); return a === undefined ? [] : [a]; });
|
|
1412
1956
|
const parts = list.map((a) => {
|
|
@@ -1415,34 +1959,47 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
|
1415
1959
|
ctx.show[id] = {
|
|
1416
1960
|
props: {
|
|
1417
1961
|
label: a.name,
|
|
1418
|
-
variant:
|
|
1962
|
+
variant: variants.get(a.id)!,
|
|
1419
1963
|
// 动作语义是「新建」(内置 openCreate)时由框架给前置加号图标,页面不写
|
|
1420
1964
|
...(a.builtin === 'openCreate' ? { icon: 'plus' } : {}),
|
|
1421
1965
|
// 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
|
|
1422
1966
|
...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
|
|
1423
1967
|
// 置灰原因(disabled 为真时 Button 才显示):字面量原样带,view.<成员> 编成页面变量路径;row. 路径在入口已报 KIT-VIEW-001
|
|
1424
1968
|
...toolbarReasonProp(a),
|
|
1969
|
+
// 触发具名动作:按动作名注入 busy_action(动作在途期间按钮置灰、aria-busy,随忙闲通道恢复;不从外部改 DOM)
|
|
1970
|
+
...(namedActionOf(a, ctx.object) !== undefined ? { busy_action: namedActionOf(a, ctx.object) } : {}),
|
|
1425
1971
|
// K1-2:Button 读 permission 服务,无权不渲染
|
|
1426
1972
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
1427
1973
|
},
|
|
1428
1974
|
};
|
|
1429
1975
|
// 外壳承载「按档隐藏」类与「更多」菜单要读的标记(标签 / 语气);壳里是真按钮,菜单选中即对它 click() 回放
|
|
1430
|
-
|
|
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>`;
|
|
1431
1978
|
});
|
|
1432
1979
|
let more = '';
|
|
1433
|
-
if (projection.plan.hasMore) {
|
|
1980
|
+
if (projection.plan.hasMore || projection.moreClass !== 'hidden') {
|
|
1434
1981
|
ctx.components.add('KitActionMore');
|
|
1435
1982
|
more = `<div${attr('class', projection.moreClass)}>${host('KitActionMore', `${ctx.object}__tb_more`)}</div>`;
|
|
1436
1983
|
}
|
|
1437
|
-
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>`;
|
|
1438
1985
|
}
|
|
1439
1986
|
|
|
1440
1987
|
// ---------------------------------------------------------------- 主函数
|
|
1441
1988
|
|
|
1442
1989
|
const SLOT_ORDER: readonly KitViewSlot[] = ['filter', 'list', 'summary', 'form'];
|
|
1443
1990
|
|
|
1991
|
+
/**
|
|
1992
|
+
* 输出里两种模式判断必须一致:属性按 ctx.next(= options.pipeline === 'next')写,同一份输出里的 kitHelpButtonHtml、kitTableNativeSpanAttr()、
|
|
1993
|
+
* 动作配方按 kitIsNextRuntime() 判断——所以整段在 ctx.next 对应模式的编译段里执行(kitWithCompilePipeline;已在同模式的编译段内时不重复设置)。
|
|
1994
|
+
*/
|
|
1444
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 {
|
|
1445
2000
|
const object = ir.object;
|
|
2001
|
+
// SCON-177:本对象按 id 取值的关联字段登记给声明式请求 / 下载(页面编译收集期内;早于本对象的事件编译,emitObject 先发静态后编事件)
|
|
2002
|
+
noteRequestRelationFields(object, kitRelationIdFields(options.schema));
|
|
1446
2003
|
const wrapped = options.wrapped ?? ir.views.list !== undefined;
|
|
1447
2004
|
const base = options.singlePath ?? `page.data.${object}`;
|
|
1448
2005
|
// 摘要 / 只读 form / 写死形状(single)读 summaryPath(如焦点切片里的当前行);缺省同 base。行数组与总数仍按 base
|
|
@@ -1464,6 +2021,8 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1464
2021
|
scope: () => ir.scope,
|
|
1465
2022
|
...(ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static' ? { filterId: viewAnchor(object, 'filter') } : {}),
|
|
1466
2023
|
...(columnParams.length > 0 ? { columnParams } : {}),
|
|
2024
|
+
next: options.pipeline === 'next',
|
|
2025
|
+
groupDepth: 0,
|
|
1467
2026
|
};
|
|
1468
2027
|
|
|
1469
2028
|
// 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
|
|
@@ -1514,10 +2073,18 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1514
2073
|
} else if (slot === 'list') {
|
|
1515
2074
|
if (layout.kind === 'table') html = renderTable(ctx, layout);
|
|
1516
2075
|
else if (layout.kind === 'cards' || layout.kind === 'stack') html = renderCollection(ctx, layout);
|
|
1517
|
-
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
|
+
}
|
|
1518
2082
|
} else {
|
|
1519
2083
|
// summary / 只读 form:单对象字段值
|
|
1520
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
|
+
}
|
|
1521
2088
|
}
|
|
1522
2089
|
// view.loading: skeleton:同一个 KitCollectionState(single 形态)画表单骨架,并藏起紧随其后的内容体
|
|
1523
2090
|
if (html !== '' && view.skeleton === true) {
|
|
@@ -1525,13 +2092,13 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1525
2092
|
ctx.components.add('KitCollectionState');
|
|
1526
2093
|
const rsPaths = readStatePathsOf(object, summaryBase);
|
|
1527
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' } } } };
|
|
1528
|
-
html = `${host('KitCollectionState', sid)}<div
|
|
2095
|
+
html = `${host('KitCollectionState', sid)}<div ${KIT_ATTR_SKELETON_BODY}="">${html}</div>`;
|
|
1529
2096
|
}
|
|
1530
2097
|
if (html !== '' && (view.surface !== undefined || view.emphasis !== undefined || view.highlight === true)) {
|
|
1531
2098
|
const slotAttrs = [
|
|
1532
|
-
view.surface !== undefined ?
|
|
1533
|
-
view.emphasis !== undefined ?
|
|
1534
|
-
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"` : '',
|
|
1535
2102
|
].filter(Boolean).join(' ');
|
|
1536
2103
|
if (slotAttrs !== '') {
|
|
1537
2104
|
html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
|
|
@@ -1546,22 +2113,25 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1546
2113
|
if (html !== '' && view.title !== undefined && view.title !== '') {
|
|
1547
2114
|
// 标题写成 view.<成员> 纯路径:被动绑定展示对象的只读成员(如选中项名称),不是字面量
|
|
1548
2115
|
const dynamicTitle: boolean = isViewPath(view.title);
|
|
2116
|
+
// 图表视图自带标题(看板面板没写面板标题、标题写在 view.list.title 上):与图表面板同一个缺省标题图标(CS22),不只落在面板标题行
|
|
2117
|
+
const titleIcon = layout.kind === 'static' ? kitDefaultPanelIcon(layout.component) : undefined;
|
|
1549
2118
|
const titleEl = dynamicTitle
|
|
1550
|
-
? renderDynamicTitle(ctx, slot, view.title)
|
|
1551
|
-
: kitPanelTitleHtml({ title: view.title, id:
|
|
1552
|
-
//
|
|
1553
|
-
const mergeToolbar = slot === 'list' && secondaryToolbar && parts.toolbar !== undefined;
|
|
1554
|
-
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 !== '')) {
|
|
1555
2124
|
const right = treeCtl !== ''
|
|
1556
2125
|
? `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${mergeToolbar ? parts.toolbar! : ''}</div>`
|
|
1557
2126
|
: parts.toolbar!;
|
|
1558
2127
|
// 集合辅助文字紧随标题作标题行的直接子项(宿主 display: contents,其根自带 me-auto 把工具区推到最右)
|
|
1559
2128
|
// 带工具的列表标题行是面内的头部条(strip.headPx 下限,内容垂直居中):不设下限时工具钮贴着面板顶边,
|
|
1560
2129
|
// 钮的上描边与面板上边相距 0 成双线(边框普查 B01,外壳用户授权「导出」)
|
|
1561
|
-
|
|
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}`;
|
|
1562
2132
|
if (mergeToolbar) delete parts.toolbar;
|
|
1563
2133
|
} else {
|
|
1564
|
-
html = `${metaHtml === '' ? titleEl : `<div
|
|
2134
|
+
html = `${metaHtml === '' ? titleEl : `<div ${KIT_ATTR_TITLE_ROW}="" class="${TITLE_GROUP_CLASS}"${nextLevel(ctx, 'head')}>${titleEl}${metaHtml}</div>`}${html}`;
|
|
1565
2135
|
}
|
|
1566
2136
|
} else {
|
|
1567
2137
|
if (treeCtl !== '') {
|
|
@@ -1569,17 +2139,22 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1569
2139
|
else html = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}</div>${html}`;
|
|
1570
2140
|
}
|
|
1571
2141
|
// 没有标题行:只有「已筛选」提示(共 N 条需要标题行),放在列表上方;包一层标题行壳,与有标题时同走对齐轴的内缩规则(文字落在轴上)
|
|
1572
|
-
if (metaHtml !== '') html = `<div
|
|
2142
|
+
if (metaHtml !== '') html = `<div ${KIT_ATTR_TITLE_ROW}="" class="${TITLE_GROUP_CLASS}"${nextLevel(ctx, 'head')}>${metaHtml}</div>${html}`;
|
|
1573
2143
|
}
|
|
1574
2144
|
parts[slot] = html;
|
|
1575
2145
|
}
|
|
1576
2146
|
|
|
1577
|
-
//
|
|
2147
|
+
// 次要工具栏没并入标题行时,紧贴列表(或无列表时的摘要)上方靠右(顺序:筛选 → 工具 → 列表/摘要),不压在筛选之前
|
|
1578
2148
|
const slotParts = SLOT_ORDER.map((s) => parts[s]);
|
|
1579
2149
|
let leading = parts.toolbar;
|
|
1580
|
-
if (secondaryToolbar && parts.toolbar !== undefined
|
|
1581
|
-
|
|
1582
|
-
|
|
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
|
+
}
|
|
1583
2158
|
}
|
|
1584
2159
|
const ordered = [leading, ...slotParts].filter((p): p is string => p !== undefined && p !== '');
|
|
1585
2160
|
return {
|