soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -9,9 +9,31 @@
|
|
|
9
9
|
// 组件只渲染按钮、抛事件;不改数据、不弹确认(`confirm:` / `permission:` 在 _event 的管道尾段)。
|
|
10
10
|
|
|
11
11
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
12
|
-
import { CLASS_PROP, createKitController, joinClass, str, type KitApi, type KitProps } from '../base/shared';
|
|
13
|
-
import { permissionCheckerOf } from '../base/permission-gate';
|
|
14
|
-
import {
|
|
12
|
+
import { CLASS_PROP, createKitController, joinClass, str, toggleKitHidden, type KitApi, type KitProps } from '../base/shared';
|
|
13
|
+
import { permissionCheckerOf, registerLivePermissionGate } from '../base/permission-gate';
|
|
14
|
+
import {
|
|
15
|
+
KIT_ATTR_ACT,
|
|
16
|
+
KIT_ATTR_ACT_SECONDARY,
|
|
17
|
+
KIT_ATTR_COMPACT,
|
|
18
|
+
KIT_ATTR_EXPAND,
|
|
19
|
+
KIT_ATTR_EXPAND_BODY,
|
|
20
|
+
KIT_ATTR_EXPAND_ROW,
|
|
21
|
+
KIT_ATTR_MORE,
|
|
22
|
+
KIT_ATTR_MORE_ROOT,
|
|
23
|
+
KIT_ATTR_OPS_CELL,
|
|
24
|
+
KIT_ATTR_OPS_EMPTY,
|
|
25
|
+
KIT_ATTR_OPS_HEAD,
|
|
26
|
+
KIT_ATTR_OPS_OFF,
|
|
27
|
+
KIT_ATTR_PART,
|
|
28
|
+
KIT_ATTR_PINNED_HIDDEN,
|
|
29
|
+
KIT_ATTR_ROW,
|
|
30
|
+
KIT_ATTR_SEL,
|
|
31
|
+
KIT_ATTR_SELECTED,
|
|
32
|
+
KIT_ATTR_VSCROLL,
|
|
33
|
+
} from '../shared/dom-attrs';
|
|
34
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon, resolveKitIconName } from '../shared/icons';
|
|
35
|
+
import { KIT_PART_TABLE_CELL } from './collection-table';
|
|
36
|
+
import { kitRowKey } from '../shared/row-key';
|
|
15
37
|
import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, isMark, markInput, setMarkLabel } from '../base/check-core';
|
|
16
38
|
import { wireMenu, type MenuClasses, type MenuHandle } from '../base/menu-core';
|
|
17
39
|
import { KIT_POPUP_PLACE_CLASS_CANDIDATES, type PopPlace } from '../base/popup';
|
|
@@ -19,26 +41,69 @@ import { KIT_MENU_BUTTON_CLASS_CANDIDATES, KIT_MENU_ITEM_CLASSES, KIT_MENU_PANEL
|
|
|
19
41
|
import { createPanelPortal, KIT_PANEL_PORTAL_CLASS_CANDIDATES } from '../data/overlay-portal';
|
|
20
42
|
import { expandKeyOf, moveExpandChild, returnExpandChild } from './collection-expand';
|
|
21
43
|
import { kitText } from '../i18n/kit-text';
|
|
22
|
-
import {
|
|
44
|
+
import { kitActionFunctionOfId, kitActionRecipe, kitActionResolve, type KitActionFunction, type KitRowActionRank } from '../recipes/emphasis';
|
|
23
45
|
import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
|
|
24
46
|
import { KIT_ITEM_TONE_CLASS, KIT_ROW_TONE_CLASS, disabledReasonOf, rowActionState, rowToneClass } from './view-binding';
|
|
25
47
|
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
48
|
+
import { KIT_ROW_FRESH_ATTR, KIT_ROWS_PINNED_ATTR, isKitRowFresh, isKitRowPinned, onKitRowFresh } from '../base/row-fresh';
|
|
26
49
|
import { KIT_REASON_TIP_CLASS_CANDIDATES, releaseReasonTipsIn, syncReasonTip } from '../base/reason-tip';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
50
|
+
import { KIT_TIP_ATTR } from '../base/hint-tips';
|
|
51
|
+
import { kitDisabledRecipe, setKitFace } from '../recipes';
|
|
52
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
53
|
+
import { kitRowActionsNarrowCap, kitRowActionsNarrowTier, kitRuleTableOf } from 'soma-foundation/kit-layout';
|
|
29
54
|
import { watchEndEdge } from '../base/end-edge';
|
|
30
55
|
import { KIT_ACTION_GROUP_CLASS_CANDIDATES, menuOrderDangerLast, planActionGroup } from './action-group';
|
|
31
|
-
import { KIT_ARRANGE } from 'soma-foundation/arrange';
|
|
56
|
+
import { KIT_ARRANGE, arrangeRemToSteps } from 'soma-foundation/arrange';
|
|
57
|
+
import { kitActionPropsOf, kitHasActionProps, kitMarkPart, kitMarkPicked } from '../data/kit-contract';
|
|
58
|
+
import { createKitRowConfirm } from '../data/row-confirm';
|
|
32
59
|
|
|
33
60
|
/** 行操作所在的表格容器(窄档判定用):普通表 / 虚拟表的外壳;不在表格里(cards / stack 条目等)= 无,按宽档 */
|
|
34
|
-
const TABLE_CONTAINER =
|
|
61
|
+
const TABLE_CONTAINER = `[${KIT_ATTR_PART}="table"], [${KIT_ATTR_VSCROLL}]`;
|
|
62
|
+
|
|
63
|
+
// ── 空操作列收列(KT-P-list:所有行的可见动作都为 0,含权限全拒 → 不画操作列,表头与单元格一起收)──
|
|
64
|
+
// 判定在底座:每行的行操作组件按「本行可见动作数」给所在操作格记 data-kit-ops-empty,整表汇总后统一收 / 放(页面不写条件)。
|
|
65
|
+
/** 行里的操作格(编译期 emit-static 标) */
|
|
66
|
+
export const KIT_OPS_CELL_ATTR = KIT_ATTR_OPS_CELL;
|
|
67
|
+
/** 操作列表头格(静态表头 emit-static 标;可排序表头由 KitTableHead 按 cells[].ops 标) */
|
|
68
|
+
export const KIT_OPS_HEAD_ATTR = KIT_ATTR_OPS_HEAD;
|
|
69
|
+
/** 本行没有可见动作 */
|
|
70
|
+
const KIT_OPS_EMPTY_ATTR = KIT_ATTR_OPS_EMPTY;
|
|
71
|
+
/** 收列时本模块加上的 hidden 类的记号(只撤销自己加的,不碰别的显隐来源) */
|
|
72
|
+
const KIT_OPS_OFF_ATTR = KIT_ATTR_OPS_OFF;
|
|
73
|
+
const OPS_SYNC_PENDING = new WeakSet<Element>();
|
|
74
|
+
|
|
75
|
+
/** 整表汇总:有操作格且每一格都没有可见动作 → 操作格与操作列表头一起收起;任一格有动作 → 放回 */
|
|
76
|
+
export function syncOpsColumn(table: Element): void {
|
|
77
|
+
const cells = [...table.querySelectorAll<HTMLElement>(`[${KIT_OPS_CELL_ATTR}]`)];
|
|
78
|
+
const off = cells.length > 0 && cells.every((c) => c.hasAttribute(KIT_OPS_EMPTY_ATTR));
|
|
79
|
+
for (const el of [...cells, ...table.querySelectorAll<HTMLElement>(`[${KIT_OPS_HEAD_ATTR}]`)]) {
|
|
80
|
+
if (off) {
|
|
81
|
+
el.classList.add('hidden');
|
|
82
|
+
el.setAttribute(KIT_OPS_OFF_ATTR, '');
|
|
83
|
+
} else if (el.hasAttribute(KIT_OPS_OFF_ATTR)) {
|
|
84
|
+
el.classList.remove('hidden');
|
|
85
|
+
el.removeAttribute(KIT_OPS_OFF_ATTR);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 同一张表一拍只汇总一次(各行组件同一轮渲染完再算) */
|
|
91
|
+
function scheduleOpsColumnSync(cell: Element): void {
|
|
92
|
+
const table = cell.closest(`[${KIT_ATTR_PART}="table"]`);
|
|
93
|
+
if (table === null || OPS_SYNC_PENDING.has(table)) return;
|
|
94
|
+
OPS_SYNC_PENDING.add(table);
|
|
95
|
+
queueMicrotask(() => {
|
|
96
|
+
OPS_SYNC_PENDING.delete(table);
|
|
97
|
+
if (table.isConnected) syncOpsColumn(table);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
35
100
|
|
|
36
101
|
// B8:行操作超过 maxInline 个(或动作写了 more: true)折叠进「更多」菜单(与 MenuButton 共用 menu-core 的菜单内核)
|
|
37
102
|
const MORE_ROOT_CLASS = 'relative inline-block shrink-0';
|
|
38
103
|
// 窄档折叠的容器查询档名读 design(type-presentation#/action/maxInline.narrowBelowTier),与表格窄栅格同一档;
|
|
39
104
|
// 次要行内操作窄档隐藏,宽档全部行内时「更多」触发器只在窄档显示(容器查询变体 `@max-<档>:`,本文件不写数字)
|
|
40
105
|
const NARROW_TIER = kitRowActionsNarrowTier();
|
|
41
|
-
const DANGER_SEPARATOR_CLASS = `ms-${
|
|
106
|
+
const DANGER_SEPARATOR_CLASS = `ms-${arrangeRemToSteps(KIT_ARRANGE.actionGroup.dangerSeparatorRem)}`;
|
|
42
107
|
const ROW_ACTION_SECONDARY_CLASS = `@max-${NARROW_TIER}:hidden`;
|
|
43
108
|
const MORE_ROOT_NARROW_ONLY_CLASS = `relative shrink-0 hidden @max-${NARROW_TIER}:inline-block`;
|
|
44
109
|
// 紧凑列表(主从窄栏):列表自身是容器,窄档线是另一条(kit-arrange#actionGroup.compactNarrowTier),条目里的行操作按列表宽收起次要项
|
|
@@ -46,43 +111,114 @@ const COMPACT_TIER = KIT_ARRANGE.actionGroup.compactNarrowTier;
|
|
|
46
111
|
const COMPACT_SECONDARY_CLASS = `@max-${COMPACT_TIER}:hidden`;
|
|
47
112
|
const COMPACT_MORE_ROOT_NARROW_ONLY_CLASS = `relative shrink-0 hidden @max-${COMPACT_TIER}:inline-block`;
|
|
48
113
|
// 外观只有一份:触发钮 / 面板 / 菜单项类全部取自 base/menu-button(KIT_MENU_PANEL、KIT_MENU_ITEM_CLASSES),这里不再手抄
|
|
49
|
-
//
|
|
50
|
-
|
|
114
|
+
// 行内「更多」触发器 = 只有「…」图标的淡底钮(次级钮配方 button.text 的紧凑形:各层级档自动取本档的次钮形体——纸面中性淡底、色调主色淡底、细线描边、扁平链接色),
|
|
115
|
+
// 不再是「更多 + 下箭头」的文字链接:一列十几行各一个蓝字太抢,样本三套都只出图标
|
|
116
|
+
const MORE_TRIGGER_CLASS = kitActionRecipe('more', { tight: true, region: 'row', size: 'sm' });
|
|
51
117
|
const MORE_PLACE: PopPlace = { side: 'bottom', align: 'end' };
|
|
52
|
-
const MORE_MENU_SHOWN = KIT_MENU_PANEL.
|
|
118
|
+
const MORE_MENU_SHOWN = KIT_MENU_PANEL.classForTextTrigger(MORE_PLACE);
|
|
53
119
|
export const MORE_MENU_CLASSES: MenuClasses = KIT_MENU_ITEM_CLASSES;
|
|
54
|
-
/**
|
|
55
|
-
|
|
120
|
+
/**
|
|
121
|
+
* 默认内联上限(超过则把多出的折叠进「更多」):读真源 type-presentation#/action/maxInline/wide(经 kit-layout 规则表),不写字面量。
|
|
122
|
+
* 第二轮真实使用测试发现:这里原写死 3,表格行没传 maxInline 时宽档封顶没有随裁决改成 2(KT-K-table-4)
|
|
123
|
+
*/
|
|
124
|
+
const DEFAULT_MAX_INLINE = kitRuleTableOf().rowActions.maxInline.wide;
|
|
56
125
|
|
|
57
126
|
type ActionTone = 'primary' | 'neutral' | 'danger';
|
|
58
127
|
|
|
59
128
|
// 工具栏 / 批量条按钮:控件引擎的按钮配方 + 工具条宿主选项(tight:横向内边距降一档);变体按强调等级取(区域主动作 = 实心、次级 = 色调、危险 = 透明底危险文字)
|
|
60
129
|
export const ACTION_BUTTON_CLASS: Record<ActionTone, string> = {
|
|
61
|
-
primary
|
|
62
|
-
|
|
63
|
-
|
|
130
|
+
// 按功能名取色(SCON-116):primary = 推进类 create,neutral = 一般操作 edit,danger = 危险类 delete(非确认区取软危险色)
|
|
131
|
+
primary: kitActionRecipe('create', { tight: true, region: 'toolbar' }),
|
|
132
|
+
// 次级 = 淡底钮(工具栏 / 批量条都在对象面里:纸面条带的次级动作不描边,推荐方案 §4;2026-11-25 找回丢失)
|
|
133
|
+
neutral: kitActionRecipe('edit', { tight: true, region: 'toolbar' }),
|
|
134
|
+
danger: kitActionRecipe('delete', { tight: true, region: 'toolbar' }),
|
|
64
135
|
};
|
|
65
136
|
|
|
66
137
|
/**
|
|
67
|
-
* 行内操作(表格 / 树表 /
|
|
68
|
-
*
|
|
69
|
-
*
|
|
138
|
+
* 行内操作(表格 / 树表 / 虚拟表的操作列):轻按钮(SCON-116,设计稿 §3.1″)——有后果的操作一律是按钮:按钮的内边距、可点区、焦点环与尺寸档(sm),
|
|
139
|
+
* 静止只有字色,悬停 / 聚焦才显出底与圆角(控件变体 subtle,行内区的 neutral 角色);不再用文字链接。行内至多露 2 个、其余进「更多」,危险动作只在菜单里
|
|
140
|
+
* (孤立的危险动作才行内,取软危险色)。工具栏 / 批量条仍用 ACTION_BUTTON_CLASS。
|
|
70
141
|
*/
|
|
71
142
|
export const ROW_ACTION_BUTTON_CLASS: Record<KitRowActionRank, string> = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
143
|
+
rest: kitActionRecipe('edit', { region: 'row', size: 'sm' }),
|
|
144
|
+
danger: kitActionRecipe('delete', { region: 'row', size: 'sm' }),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** 仅图标行内动作(iconOnly / 空 name + 有 icon):紧凑内边距 */
|
|
148
|
+
const ROW_ACTION_ICON_ONLY_BUTTON_CLASS: Record<KitRowActionRank, string> = {
|
|
149
|
+
rest: kitActionRecipe('edit', { tight: true, region: 'row', size: 'sm' }),
|
|
150
|
+
danger: kitActionRecipe('delete', { tight: true, region: 'row', size: 'sm' }),
|
|
75
151
|
};
|
|
76
152
|
|
|
153
|
+
/** 详情头动作区(look: button)的秩:只有这里还有「主」一档(显式 primary 的实心主钮);text = 条带描边超预算后降成的文字钮 */
|
|
154
|
+
type HeadActionRank = 'lead' | 'text' | KitRowActionRank;
|
|
155
|
+
|
|
156
|
+
/** 详情头动作区(look: button):秩 → 按钮配方(主 = 区域主动作实心、次 = 描边中性、文字 = 超预算降级、危险 = 透明底灰字悬停变危险色);「更多」是安静按钮 */
|
|
157
|
+
const HEAD_BUTTON_CLASS: Record<HeadActionRank, string> = {
|
|
158
|
+
lead: ACTION_BUTTON_CLASS.primary,
|
|
159
|
+
rest: ACTION_BUTTON_CLASS.neutral,
|
|
160
|
+
text: kitActionRecipe('edit', { tight: true, region: 'row' }),
|
|
161
|
+
danger: ACTION_BUTTON_CLASS.danger,
|
|
162
|
+
};
|
|
163
|
+
// 「更多」= 带下箭头的淡底钮(与 action-more 同一出口;2026-11-25 裁决:按钮至少有颜色或图形之一)
|
|
164
|
+
const HEAD_MORE_TRIGGER_CLASS = kitActionRecipe('more', { tight: true });
|
|
165
|
+
const HEAD_ROOT_CLASS = 'flex flex-wrap items-center justify-end gap-2';
|
|
166
|
+
|
|
77
167
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
168
|
+
* 行内文字链接动作(表格 / 树表 / 虚拟表 / 条目行)的秩(强调等级 R12;KT-E1 第 4 点、CS09 行为着色修订):危险动作 = danger(弱化、悬停转危险色、与前者隔开),
|
|
169
|
+
* 其余一律 rest(链接色文字,同一行同色;「更多」触发同色)——不按位置分出「一个蓝其余黑」。取值(语气)只在真源 kit-limits#emphasis.roles.rowAction.*。
|
|
80
170
|
*/
|
|
81
171
|
export function rowActionRanks(items: readonly { readonly tone?: ActionTone }[]): KitRowActionRank[] {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
172
|
+
return items.map((i) => (i.tone === 'danger' ? 'danger' : 'rest'));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 详情头按钮组(look: button)的秩:主动作 = lead(实心,至多一个:第一个按功能名取到主色角色的动作,见 kitActionItemTone),危险 = danger,
|
|
177
|
+
* 其余 = text(淡底钮)。详情头在对象面(纸面)里,纸面条带的次级动作是淡底钮而不是描边钮(推荐方案 §4),所以不再有 rest(描边)这一档出口。
|
|
178
|
+
*/
|
|
179
|
+
export function headActionRanks(
|
|
180
|
+
items: readonly { readonly tone?: ActionTone; readonly id?: string }[],
|
|
181
|
+
solidOf?: (id: string) => boolean,
|
|
182
|
+
): HeadActionRank[] {
|
|
183
|
+
// 主动作按功能名取角色(SCON-169):itemsOf 已把显式 tone: primary 与功能名解析出的主色角色(推进 / 创建 / 肯定类)并进 tone,
|
|
184
|
+
// 这里取第一个 primary;一条里至多一个实心。不再按位置取「第一个非危险动作」(2026-11-25 IA20 的位置规则由功能名取代):
|
|
185
|
+
// 推不出功能名、功能是中性的动作不升主钮。其余次级动作在对象面(纸面)条带里 = 淡底钮(button.text → kit-control#variants.ghost)。
|
|
186
|
+
// 页面线判定下发时(solidOf 给了,C-05):实心主按钮只看判定的 solid(本屏唯一实心名额);行动作在页面线里 solid 恒为假,
|
|
187
|
+
// 所以详情头不再自选一个实心钮,避免与同屏页头 / 工具条的实心主动作重复(每屏至多一个实心)。
|
|
188
|
+
const leadAt = solidOf !== undefined
|
|
189
|
+
? items.findIndex((i) => i.id !== undefined && solidOf(i.id))
|
|
190
|
+
: items.findIndex((i) => i.tone === 'primary');
|
|
191
|
+
const ranks: HeadActionRank[] = items.map((i, n) => (i.tone === 'danger' ? 'danger' : n === leadAt ? 'lead' : 'rest'));
|
|
192
|
+
return ranks.map((r) => (r === 'rest' ? 'text' : r));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 动作的功能名(SCON-116 / SCON-169,判据唯一出处):页面写的 function 优先,其次按 builtin / id 推断(真源 emphasis.actions.inferFromId),
|
|
197
|
+
* 再认 export 开头的 id;推不出为 null。工具栏取色(emit-static#actionVariantsOf)、行操作 / 右键菜单 / 详情头的功能名透传(emit-static#actionItems)
|
|
198
|
+
* 与操作列估宽(collection.ts)都读这一个。
|
|
199
|
+
*/
|
|
200
|
+
export function kitActionFunctionOfDecl(a: { readonly function?: KitActionFunction; readonly builtin?: string; readonly id: string }): KitActionFunction | null {
|
|
201
|
+
if (a.function !== undefined) return a.function;
|
|
202
|
+
return kitActionFunctionOfId(a.builtin, a.id) ?? (/^export(?:[A-Z_-]|$)/.test(a.id) ? 'export' : null);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 行操作 / 右键菜单 / 详情头动作项的语气(SCON-169):显式 tone 优先(tone 优先于 function:primary / danger 原样,其余显式值一律中性);
|
|
207
|
+
* 没写 tone 时按功能名取角色(真源 emphasis.actions,求解在 foundation):危险类 → danger,取到主色角色的推进 / 创建 / 肯定类 → primary,
|
|
208
|
+
* 其余与推不出 / 不合法的功能名 → neutral。组件(itemsOf)与编译期操作列估宽(collection.ts)同一个判据。
|
|
209
|
+
*/
|
|
210
|
+
export function kitActionItemTone(tone: unknown, fn: unknown): ActionTone {
|
|
211
|
+
if (tone === 'primary' || tone === 'danger') return tone;
|
|
212
|
+
if (typeof tone === 'string' && tone !== '') return 'neutral';
|
|
213
|
+
if (typeof fn !== 'string' || fn === '') return 'neutral';
|
|
214
|
+
try {
|
|
215
|
+
const resolved = kitActionResolve(fn as KitActionFunction);
|
|
216
|
+
if (resolved.role === 'danger' || resolved.cls === 'danger') return 'danger';
|
|
217
|
+
return resolved.role === 'primary' ? 'primary' : 'neutral';
|
|
218
|
+
} catch {
|
|
219
|
+
// 未知功能名:中性
|
|
220
|
+
return 'neutral';
|
|
221
|
+
}
|
|
86
222
|
}
|
|
87
223
|
|
|
88
224
|
// 行操作根:链接不收缩、不折行(flex-nowrap + whitespace-nowrap,行高保持一行),项间距 16px(gap-x-4);放不下的由切分(splitRowActions)并入「更多」,不靠换行;
|
|
@@ -90,11 +226,11 @@ export function rowActionRanks(items: readonly { readonly tone?: ActionTone }[])
|
|
|
90
226
|
// 操作列恒贴尾侧:动作右对齐,末尾动作的文字右缘 = 操作列右缘(列表页右轴:页头主按钮 / 操作列末尾 / 分页右端同一条线);表头「操作」同向右对齐
|
|
91
227
|
const ROOT_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
92
228
|
/** 展开行开关按钮(文字钮,不带底色) */
|
|
93
|
-
const EXPAND_BUTTON_CLASS = 'inline-flex items-center text-xs text-fg-muted hover:text-fg
|
|
229
|
+
const EXPAND_BUTTON_CLASS = 'inline-flex items-center text-xs text-fg-muted hover:text-fg ' + KIT_FOCUS_RING.button;
|
|
94
230
|
/** 整行点击不响应的行内交互元素(它们有自己的事件):按钮 / 链接 / 输入 / 菜单 / 勾选列 / 就地编辑格 */
|
|
95
|
-
const ROW_INTERACTIVE =
|
|
231
|
+
const ROW_INTERACTIVE = `button, a, input, select, textarea, label, [${KIT_ATTR_ACT}], [role="menu"], [role="menuitem"], [role="checkbox"], [role="radio"], [role="switch"], [${KIT_ATTR_SEL}]`;
|
|
96
232
|
/** 整行可点时行容器的焦点环(键盘 Enter 进入) */
|
|
97
|
-
const ROW_FOCUS_CLASS =
|
|
233
|
+
const ROW_FOCUS_CLASS = KIT_FOCUS_RING.item;
|
|
98
234
|
/** 已加上焦点属性的行容器(卸载时还原) */
|
|
99
235
|
const FOCUSABLE_ROWS = new WeakSet<HTMLElement>();
|
|
100
236
|
/** 还焦点:勾选标记(label)自身不可聚焦,落到里面的原生 input */
|
|
@@ -117,17 +253,22 @@ function elementId(el: Element | null): number {
|
|
|
117
253
|
|
|
118
254
|
type SelectMode = 'none' | 'single' | 'multi';
|
|
119
255
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
256
|
+
/** 已选行:数组原样;单个对象(主从页的选中行镜像)= 只选了这一行(空对象 = 没选);其它 = 没有已选行镜像(null) */
|
|
257
|
+
function selectedRowsOf(raw: unknown): readonly unknown[] | null {
|
|
258
|
+
if (Array.isArray(raw)) return raw;
|
|
259
|
+
if (raw !== null && typeof raw === 'object') return Object.keys(raw as Record<string, unknown>).length > 0 ? [raw] : [];
|
|
260
|
+
return null;
|
|
124
261
|
}
|
|
125
262
|
|
|
126
|
-
/**
|
|
263
|
+
/** 行主键的字符串键:全仓共用 shared/row-key.ts 的 kitRowKey(主键值是字符串 / 数字取它,否则整行 JSON;非对象行为空串) */
|
|
264
|
+
const rowKeyOf = kitRowKey;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* 行主键的字符串键(行在途通道名、协调组件删除目标共用):委托 kitRowKey,保留导出名供行视图组件引用。
|
|
268
|
+
* 与旧实现的差别只在「行不是对象」:旧版当 {} 取 '{}',现在是空串(调用方本来就拿不到行)。
|
|
269
|
+
*/
|
|
127
270
|
export function removeKeyOf(row: unknown, keyField: string): string {
|
|
128
|
-
|
|
129
|
-
const v = keyField !== '' ? rec[keyField] : undefined;
|
|
130
|
-
return typeof v === 'string' || typeof v === 'number' ? String(v) : JSON.stringify(rec);
|
|
271
|
+
return kitRowKey(row, keyField);
|
|
131
272
|
}
|
|
132
273
|
|
|
133
274
|
/** 行在途(内置删除与具名行动作共用)的忙闲通道名:作用域 + 对象名 + 行主键三段(同作用域下不同对象主键相同也不撞名;base/action-busy 以空白 / 逗号切名字,故各段做 URI 编码);协调组件(内置删除)与动作执行器(具名行动作,按载荷 kit_row_busy)登记,本组件读 */
|
|
@@ -141,6 +282,25 @@ function removeBusyOf(p: Record<string, unknown>): boolean {
|
|
|
141
282
|
return scope !== '' && object !== '' && isKitActionBusy(rowBusyName(scope, object, removeKeyOf(p.row, str(p.removeKeyField))));
|
|
142
283
|
}
|
|
143
284
|
|
|
285
|
+
/** 本行的回声通道名(B1-3,与行在途同一规则);详情头按钮组 look: button 不是行,不读;拿不到作用域 / 对象为 '' */
|
|
286
|
+
function rowEchoName(p: Record<string, unknown>): string {
|
|
287
|
+
if (p.look === 'button') return '';
|
|
288
|
+
const scope = str(p.removeScope);
|
|
289
|
+
const object = str(p.removeObject);
|
|
290
|
+
return scope !== '' && object !== '' ? rowBusyName(scope, object, removeKeyOf(p.row, str(p.removeKeyField))) : '';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** 回声标记落在哪个元素上:所在行容器(表格行 / 条目 / 卡片),与选中高亮、行档位同一个容器 */
|
|
294
|
+
const FRESH_ROW_SELECTOR = `[${KIT_ATTR_ROW}], [${KIT_ATTR_PART}="table-row"], [${KIT_ATTR_COMPACT}], [${KIT_ATTR_PART}="card"]`;
|
|
295
|
+
|
|
296
|
+
/** 本行此刻的回声状态签名:f = 高亮中,h = 常规行里的置顶记录(隐去,置顶副本不隐) */
|
|
297
|
+
function rowEchoState(p: Record<string, unknown>, root: HTMLElement): string {
|
|
298
|
+
const name = rowEchoName(p);
|
|
299
|
+
if (name === '') return '';
|
|
300
|
+
const hide = isKitRowPinned(name) && root.closest(`[${KIT_ROWS_PINNED_ATTR}]`) === null;
|
|
301
|
+
return `${isKitRowFresh(name) ? 'f' : ''}${hide ? 'h' : ''}`;
|
|
302
|
+
}
|
|
303
|
+
|
|
144
304
|
/** 供候选类汇总(candidates.ts)。 */
|
|
145
305
|
export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
146
306
|
ROOT_CLASS,
|
|
@@ -149,6 +309,10 @@ export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
|
149
309
|
EXPAND_BUTTON_CLASS,
|
|
150
310
|
...Object.values(ACTION_BUTTON_CLASS),
|
|
151
311
|
...Object.values(ROW_ACTION_BUTTON_CLASS),
|
|
312
|
+
...Object.values(ROW_ACTION_ICON_ONLY_BUTTON_CLASS),
|
|
313
|
+
...KIT_ICON_CLASS_CANDIDATES,
|
|
314
|
+
'contents', 'w-11', 'min-w-11', 'justify-center',
|
|
315
|
+
HEAD_ROOT_CLASS, HEAD_MORE_TRIGGER_CLASS, ...Object.values(HEAD_BUTTON_CLASS),
|
|
152
316
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
153
317
|
...Object.values(KIT_ITEM_TONE_CLASS),
|
|
154
318
|
...KIT_ACTION_GROUP_CLASS_CANDIDATES, DANGER_SEPARATOR_CLASS,
|
|
@@ -161,7 +325,13 @@ export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
|
161
325
|
export interface KitTableActionItem {
|
|
162
326
|
id: string;
|
|
163
327
|
name: string;
|
|
328
|
+
/** 动作图标名(内置 kitIcon 闭集名或短符号) */
|
|
329
|
+
icon?: string;
|
|
330
|
+
/** 仅渲染图标按钮(aria-label / title 回落到 name || id) */
|
|
331
|
+
iconOnly?: boolean;
|
|
164
332
|
tone?: ActionTone;
|
|
333
|
+
/** 动作功能名(rec.function,按 §8b 解析危险 / 主操作语义) */
|
|
334
|
+
function?: string;
|
|
165
335
|
builtin?: string;
|
|
166
336
|
target?: string;
|
|
167
337
|
permission?: string;
|
|
@@ -175,27 +345,38 @@ export interface KitTableActionItem {
|
|
|
175
345
|
* 行内 / 「更多」切分(纯函数,排布引擎的行操作投影):shown = 已过权限与行级隐藏的动作(声明序)。
|
|
176
346
|
* 保留序、危险动作折叠都取自排布引擎(action-group.ts#planActionGroup,行操作 `dangerFold`):
|
|
177
347
|
* - 危险动作默认收进「更多」:动作数达到真源阈值(kit-arrange#actionGroup.dangerFoldMinActions)且还有非危险动作时,危险项恒进更多;
|
|
348
|
+
* 当 maxInline === Infinity(DSL maxInline: 'all')或显式 keepDangerInline 为真时,宽档不强制折叠危险项;
|
|
178
349
|
* - 宽档:其余非 more 动作按引擎保留序取前 maxInline 个行内(第一个 primary 恒在行内),其余并入更多;more: true 的恒进更多;
|
|
179
350
|
* - 窄档(容器低于 design 窄档线,行内上限取 design maxInline.narrow,且不超过 maxInline):最多保留 cap 个,同一保留序;
|
|
180
351
|
* 保留者仍按声明序排列;进更多的项:普通项在前、危险项置末(菜单渲染时用 menuOrderDangerLast 加分隔线)。
|
|
181
352
|
* 进更多的每一项,置灰与置灰原因仍由菜单项读 actionState / disabledReason(见 render 的 items),不在此丢失。
|
|
182
353
|
*/
|
|
183
354
|
export function splitRowActions(
|
|
184
|
-
shown: readonly KitTableActionItem[], maxInline: number, narrow: boolean,
|
|
355
|
+
shown: readonly KitTableActionItem[], maxInline: number, narrow: boolean, keepDangerInline = false,
|
|
185
356
|
): { inline: KitTableActionItem[]; folded: KitTableActionItem[]; separated: Set<string> } {
|
|
186
357
|
const forced = shown.filter((i) => i.more === true);
|
|
187
358
|
const candidates = shown.filter((i) => i.more !== true);
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
359
|
+
const allInline = !narrow && maxInline === Infinity;
|
|
360
|
+
const noDangerFold = !narrow && (allInline || keepDangerInline);
|
|
361
|
+
const cap = narrow ? Math.max(1, Math.min(maxInline, kitRowActionsNarrowCap())) : (allInline ? Math.max(1, candidates.length) : maxInline);
|
|
362
|
+
// 静态切分整个交给引擎(inlineCap):保留序、危险折叠、内联危险项置末并分隔。
|
|
363
|
+
// 「被收起的只有 1 项时直接内联」不再用于行内动作:常驻至多 cap 个是硬上限(KT-K-table-4,2026-11-25 裁决;
|
|
364
|
+
// 第二轮真实使用测试见 talent 我的风险 3 个动作全常驻——cap 2 + 只溢出 1 项被这条豁免放回行内)
|
|
365
|
+
const plan = planActionGroup(candidates.map((i) => ({ id: i.id, label: i.name, importance: i.tone === 'primary' ? 'primary' : i.tone === 'danger' ? 'danger' : 'secondary' })), { dangerFold: !noDangerFold, inlineCap: cap, loneInline: false });
|
|
191
366
|
const byId = new Map(candidates.map((i) => [i.id, i] as const));
|
|
192
367
|
const pick = (ids: readonly string[]): KitTableActionItem[] => ids.flatMap((id) => { const it = byId.get(id); return it === undefined ? [] : [it]; });
|
|
368
|
+
const inline = pick(plan.rowInline);
|
|
193
369
|
const foldedIds = new Set(plan.rowFolded);
|
|
370
|
+
const separated = new Set(plan.separated.filter((id) => plan.rowInline.includes(id)));
|
|
371
|
+
if (noDangerFold && inline.some((i) => i.tone !== 'danger')) {
|
|
372
|
+
const firstDanger = inline.find((i) => i.tone === 'danger');
|
|
373
|
+
if (firstDanger !== undefined) separated.add(firstDanger.id);
|
|
374
|
+
}
|
|
194
375
|
return {
|
|
195
|
-
inline
|
|
376
|
+
inline,
|
|
196
377
|
// 进更多:声明序,more: true 的排在最后(菜单渲染再统一危险置末加分隔线)
|
|
197
378
|
folded: [...candidates.filter((i) => foldedIds.has(i.id)), ...forced],
|
|
198
|
-
separated
|
|
379
|
+
separated,
|
|
199
380
|
};
|
|
200
381
|
}
|
|
201
382
|
|
|
@@ -207,11 +388,20 @@ export function itemsOf(raw: unknown): KitTableActionItem[] {
|
|
|
207
388
|
const rec = item as Record<string, unknown>;
|
|
208
389
|
const id = str(rec.id);
|
|
209
390
|
if (id === '') continue;
|
|
210
|
-
|
|
391
|
+
// 功能名(SCON-169:编译器透传声明的或推断的 function)与显式 tone 一起定语气,判据见 kitActionItemTone(tone 优先)
|
|
392
|
+
const fnRaw = str(rec.function, str(rec.fn));
|
|
393
|
+
const tone: ActionTone = kitActionItemTone(rec.tone, fnRaw);
|
|
394
|
+
const icon = str(rec.icon);
|
|
395
|
+
const explicitEmptyName = typeof rec.name === 'string' && rec.name === '';
|
|
396
|
+
const iconOnly = rec.iconOnly === true || (icon !== '' && explicitEmptyName);
|
|
397
|
+
const name = explicitEmptyName && icon !== '' ? '' : str(rec.name, id);
|
|
211
398
|
out.push({
|
|
212
399
|
id,
|
|
213
|
-
name
|
|
400
|
+
name,
|
|
401
|
+
...(icon !== '' ? { icon } : {}),
|
|
402
|
+
...(iconOnly ? { iconOnly: true } : {}),
|
|
214
403
|
tone,
|
|
404
|
+
...(fnRaw !== '' ? { function: fnRaw } : {}),
|
|
215
405
|
...(str(rec.builtin) !== '' ? { builtin: str(rec.builtin) } : {}),
|
|
216
406
|
...(str(rec.target) !== '' ? { target: str(rec.target) } : {}),
|
|
217
407
|
...(str(rec.permission) !== '' ? { permission: str(rec.permission) } : {}),
|
|
@@ -248,15 +438,25 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
248
438
|
name: 'KitTableActions',
|
|
249
439
|
layer: 'data',
|
|
250
440
|
props: {
|
|
251
|
-
actions: { type: 'array', default: [], desc: '行操作 [{ id, name, tone?, builtin?, target?, permission?, more?, disabledReason? }];permission 非空且无权限时不渲染该按钮;disabledReason
|
|
252
|
-
maxInline: { type: 'number', default: DEFAULT_MAX_INLINE, desc: '
|
|
441
|
+
actions: { type: 'array', default: [], desc: '行操作 [{ id, name, icon?, iconOnly?, tone?, function?, builtin?, target?, permission?, more?, disabledReason? }];permission 非空且无权限时不渲染该按钮;disabledReason 是置灰原因的字面量文案(动作置灰时才显示);function 是动作功能名(编译器透传声明的或按 builtin / id 推断的,SCON-169):没写 tone 时按它取角色——危险类按危险项(行内恒进「更多」、菜单置末),主色角色的推进 / 创建 / 肯定类按主动作(行内保留序第一、排首位;look: button 时取实心主钮);显式 tone 优先' },
|
|
442
|
+
maxInline: { type: 'number', default: DEFAULT_MAX_INLINE, desc: "行内最多直接显示的按钮数(正整数或 'all'),超过的折叠进「更多」菜单;动作项 more: true 恒折叠" },
|
|
443
|
+
slot: { type: 'string', default: 'both', desc: "渲染槽位:both(缺省)/ inline(仅行内按钮,不出「…」)/ more(仅「…」溢出菜单)" },
|
|
444
|
+
hideMore: { type: 'boolean', default: false, desc: '隐藏「…」溢出触发钮(与 slot: inline 等价)' },
|
|
445
|
+
onlyMore: { type: 'boolean', default: false, desc: '仅渲染「…」溢出触发钮(与 slot: more 等价)' },
|
|
446
|
+
keepDangerInline: { type: 'boolean', default: false, desc: '宽档不强制将危险动作折叠进「更多」' },
|
|
447
|
+
splitMoreColumn: { type: 'boolean', default: false, desc: '独立「…」尾随列模式:root 取 display: contents,依次渲染行内操作格与独立「…」格' },
|
|
448
|
+
inlineCellClass: { type: 'string', default: '', desc: 'splitMoreColumn 模式下的行内操作格类串' },
|
|
449
|
+
moreCellClass: { type: 'string', default: '', desc: 'splitMoreColumn 模式下的独立「…」格类串' },
|
|
450
|
+
cellRole: { type: 'string', default: '', desc: 'splitMoreColumn 模式下两个单元格的 ARIA role(如 cell)' },
|
|
253
451
|
actionState: { type: 'object', default: {}, desc: '行级动作状态 { 动作id: { hidden, disabled } }:叶子是行字段路径(业务对象逐行给出),core 逐行求值;hidden 为真该行不显示这个动作,disabled 为真置灰且点不到;叶子 disabledReason(可选)= 置灰原因文案(行字段 / 展示对象成员求值成字符串):置灰且非空时按钮保持可聚焦(只留 aria-disabled),原因经气泡与 aria-describedby 给出,「更多」菜单项带描述文字;字面量原因写在 actions 项的 disabledReason' },
|
|
254
452
|
rowTone: { type: 'string', default: '', desc: '行样式档位名(行字段取值,业务对象逐行给出):属于语法真源 viewObject.rowState.toneTiers 闭集时,给所在行容器(data-kit-row)加该档位的类串;不在闭集不加类(rowToneSet 为 item 时取 itemToneTiers)' },
|
|
255
453
|
rowToneSet: { type: 'string', default: 'row', desc: '行样式档位用哪张闭集表:row = toneTiers(表格行底色);item = itemToneTiers(cards / stack 条目自带底色与边框,只用描边 / 透明度);其它值按 row' },
|
|
256
454
|
row: { type: 'object', default: {}, desc: '当前行数据,原样随 row_action 上抛' },
|
|
455
|
+
look: { type: 'string', default: 'link', desc: '外观:link = 行内文字链接(表格 / 条目的行操作);button = 按钮组(主从页右窗格详情头:主动作实心、次级描边、「更多」安静灰字、危险平时灰字悬停变红;详情头窄于窄档线时次要按钮收进「更多」)' },
|
|
257
456
|
pickOnRow: { type: 'boolean', default: false, desc: '开启后点击所在行(data-kit-row 容器)抛 row_pick,builtin 为 select' },
|
|
258
457
|
selectMode: { type: 'string', default: 'none', desc: '勾选列模式 none / single / multi;非 none 时渲染选择框并抛 row_select' },
|
|
259
458
|
selected: { type: 'array', default: [], desc: '已选行数组(协调组件 focus 切片 sel 的镜像);选择框的勾选态与所在行(data-kit-row)的 data-kit-selected 选中高亮由它推出' },
|
|
459
|
+
picked: { type: 'object', default: null, desc: '当前打开项(如枢纽选中行镜像:单个行对象,空对象 = 没有):只管所在行的 data-kit-selected 高亮;给了它高亮只看它,不看 selected;勾选态与 bulkLock 仍读 selected(勾选集合);null = 未给,高亮按 selected' },
|
|
260
460
|
keyField: { type: 'string', default: '', desc: '行主键字段名(比对已选行;空 = 按整行内容)' },
|
|
261
461
|
bulkLock: { type: 'boolean', default: false, desc: '表格有批量动作时为真:已有选中行(批量条出现)期间本行的行内操作整体禁用' },
|
|
262
462
|
removeScope: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):协调组件的作用域 id;本行在途(经忙闲通道登记)时,本行全部操作置灰、容器挂 aria-busy;空 = 不读' },
|
|
@@ -302,16 +502,27 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
302
502
|
services: ['permission'],
|
|
303
503
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
304
504
|
controllerFactory: createKitController((api) => {
|
|
305
|
-
const check = permissionCheckerOf(api as unknown as any);
|
|
306
505
|
let moreMenu: MenuHandle | null = null;
|
|
307
506
|
// 上次渲染依赖的 props 签名:props 没变就不重绘(保住焦点与已开的更多菜单)
|
|
308
507
|
let lastSig: string | null = null;
|
|
309
508
|
let lastRoot: HTMLElement | null = null;
|
|
310
509
|
// 最近一次渲染时本行是否处于删除在途(忙闲通道变化时据此判断要不要重绘)
|
|
311
510
|
let renderedBusy = false;
|
|
511
|
+
// 最近一次渲染时本行的回声状态(高亮 / 置顶隐去;回声通道变化时据此判断要不要重绘)
|
|
512
|
+
let renderedEcho = '';
|
|
513
|
+
// 最近一次渲染时动作数组的权限判定签名(权限异步到达 / 收回 / 切换判定器时仅在结果变化时重绘)
|
|
514
|
+
let renderedPerm = '';
|
|
515
|
+
const permStateOf = (p: KitProps): string => {
|
|
516
|
+
const items = itemsOf(p.actions);
|
|
517
|
+
if (!items.some((item) => item.permission !== undefined)) return '';
|
|
518
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
519
|
+
return items.map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? '1' : '0') : '-')).join('');
|
|
520
|
+
};
|
|
312
521
|
// 在途期间按钮被禁用会丢焦点:记下用户点的是哪个控件,落定恢复后还给它(仅当焦点已落到 body)
|
|
313
522
|
let lastActed: { attr: string; val: string } | null = null;
|
|
314
523
|
let wasBusy = false;
|
|
524
|
+
// 页面线对危险动作下发的二次确认(props.kit.actions[动作].confirm):点击与「更多」菜单选中共用一份,没有判定时同步触发
|
|
525
|
+
const rowConfirm = createKitRowConfirm(() => api.isCurrent());
|
|
315
526
|
// 窄档折叠是纯样式(容器查询):行内次要操作带 `@max-<档>:hidden`,「更多」触发器常驻 DOM,窄档由 CSS 显示;
|
|
316
527
|
// 「更多」菜单的内容在打开时按「当前不可见的行内项」现算,没有重复 DOM、不观察宽度。
|
|
317
528
|
// 只有行操作在表格容器里才标次要操作(容器查询以表格自己的查询容器为准;cards / stack 条目里不折叠)。
|
|
@@ -325,22 +536,23 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
325
536
|
attach(root) {
|
|
326
537
|
queueMicrotask(() => { if (root.isConnected && renderedInTable !== null && inTableOf(root) !== renderedInTable) api.refresh(); });
|
|
327
538
|
const onClick = (event: Event): void => {
|
|
328
|
-
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
539
|
+
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_ACT}]`);
|
|
329
540
|
if (!hit || !root.contains(hit)) return;
|
|
330
|
-
const id = hit.getAttribute(
|
|
541
|
+
const id = hit.getAttribute(KIT_ATTR_ACT) ?? '';
|
|
331
542
|
const item = itemsOf(api.props().actions).find((a) => a.id === id);
|
|
332
543
|
if (!item) return;
|
|
333
544
|
if (rowActionState(api.props().actionState, item.id).disabled || removeBusyOf(api.props())) return;
|
|
334
|
-
lastActed = { attr:
|
|
335
|
-
|
|
545
|
+
lastActed = { attr: KIT_ATTR_ACT, val: id };
|
|
546
|
+
const index = itemsOf(api.props().actions).findIndex((a) => a.id === id);
|
|
547
|
+
rowConfirm.guard(api.props(), item.id, hit, item.name, () => emitRowAction(api, item, index));
|
|
336
548
|
};
|
|
337
549
|
root.addEventListener('click', onClick);
|
|
338
550
|
// 展开行:开合状态存在本组件里;详情体由 emitStatic 标 data-kit-expand-body 并默认带 hidden
|
|
339
551
|
let opened = false;
|
|
340
552
|
const bodyEl = (): HTMLElement | null =>
|
|
341
|
-
root.closest<HTMLElement>(
|
|
553
|
+
root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
342
554
|
const onExpand = (event: Event): void => {
|
|
343
|
-
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
555
|
+
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_EXPAND}]`);
|
|
344
556
|
if (!hit || !root.contains(hit)) return;
|
|
345
557
|
// list 形(展开子表):开合由协调组件的 expandId 决定,这里只抛意图;手风琴(换行即收旧行)也在那边
|
|
346
558
|
if (str(api.props().expandHost) !== '') {
|
|
@@ -358,7 +570,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
358
570
|
root.addEventListener('click', onExpand);
|
|
359
571
|
// 勾选列:自绘勾选标记(check-core),点击 / 空格抛 row_select;已选的单选再点不重复抛
|
|
360
572
|
const offMark = attachMarkEvents(root, (mark, next) => {
|
|
361
|
-
if (mark.getAttribute(
|
|
573
|
+
if (mark.getAttribute(KIT_ATTR_SEL) === null) return;
|
|
362
574
|
const mode = str(api.props().selectMode, 'none');
|
|
363
575
|
if (mode !== 'single' && mode !== 'multi') return;
|
|
364
576
|
// 本行删除在途:勾选标记已禁用(render 里 disabled),事件层再兜一道,不抛 row_select
|
|
@@ -372,7 +584,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
372
584
|
});
|
|
373
585
|
// pickOnRow:行点击抛 row_action(builtin: 'select')。行容器由 emitStatic 标 data-kit-row;
|
|
374
586
|
// 点在按钮 / 输入类控件上不算选行(它们有自己的事件)
|
|
375
|
-
const rowEl = root.closest<HTMLElement>(
|
|
587
|
+
const rowEl = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
376
588
|
const pickOn = (): boolean => api.props().pickOnRow === true || api.props().pickOnRow === 'true';
|
|
377
589
|
const emitSelect = (): void => {
|
|
378
590
|
// 本行删除在途:整行点击 / Enter 都不抛选行事件(行会随删除落定消失或恢复)
|
|
@@ -397,7 +609,20 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
397
609
|
};
|
|
398
610
|
// 键盘:行本身有焦点时 Enter 等同点行(行内按钮 / 输入框上的 Enter 归它们自己)
|
|
399
611
|
const onRowKey = (event: KeyboardEvent): void => {
|
|
400
|
-
if (!pickOn() || event.
|
|
612
|
+
if (!pickOn() || event.target !== rowEl) return;
|
|
613
|
+
// 条目列表(主从页左窗格):↑ ↓ 把焦点与选中移到相邻条目(点击相邻条目的同一条路径:焦点跟着走、抛 row_pick)
|
|
614
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && rowEl?.hasAttribute(KIT_ATTR_COMPACT)) {
|
|
615
|
+
const side = event.key === 'ArrowDown' ? 'nextElementSibling' : 'previousElementSibling';
|
|
616
|
+
let near = rowEl[side] as HTMLElement | null;
|
|
617
|
+
while (near !== null && !near.hasAttribute(KIT_ATTR_ROW)) near = near[side] as HTMLElement | null;
|
|
618
|
+
if (near !== null) {
|
|
619
|
+
event.preventDefault();
|
|
620
|
+
near.focus();
|
|
621
|
+
near.click();
|
|
622
|
+
}
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (event.key !== 'Enter') return;
|
|
401
626
|
event.preventDefault();
|
|
402
627
|
emitSelect();
|
|
403
628
|
};
|
|
@@ -406,8 +631,18 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
406
631
|
const offRemoveBusy = onKitActionBusy(() => {
|
|
407
632
|
if (removeBusyOf(api.props()) !== renderedBusy) api.refresh();
|
|
408
633
|
});
|
|
634
|
+
const offEcho = onKitRowFresh(() => {
|
|
635
|
+
if (rowEchoState(api.props(), root) !== renderedEcho) api.refresh();
|
|
636
|
+
});
|
|
637
|
+
const offPerm = registerLivePermissionGate(() => {
|
|
638
|
+
if (permStateOf(api.props()) !== renderedPerm) api.refresh();
|
|
639
|
+
});
|
|
409
640
|
return () => {
|
|
641
|
+
rowConfirm.dispose();
|
|
410
642
|
offRemoveBusy();
|
|
643
|
+
offEcho();
|
|
644
|
+
offPerm();
|
|
645
|
+
renderedPerm = '';
|
|
411
646
|
offEdge?.();
|
|
412
647
|
offEdge = null;
|
|
413
648
|
root.removeEventListener('click', onClick);
|
|
@@ -432,8 +667,29 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
432
667
|
};
|
|
433
668
|
},
|
|
434
669
|
render(root: HTMLElement, p: KitProps, api: KitApi): void {
|
|
670
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
435
671
|
const busy = removeBusyOf(p);
|
|
436
672
|
renderedBusy = busy;
|
|
673
|
+
renderedPerm = permStateOf(p);
|
|
674
|
+
// 保存回声:所在行容器打 / 摘 data-kit-fresh(行类的 data-kit-fresh 变体画底色,摘掉时 transition-colors 淡出);
|
|
675
|
+
// 常规行里正被置顶的那条记录隐去(置顶行容器里的副本不隐),不出现两份。只改行容器属性、不动本组件内容,放在签名跳过之前
|
|
676
|
+
const echo = rowEchoState(p, root);
|
|
677
|
+
renderedEcho = echo;
|
|
678
|
+
const echoRow = p.look === 'button' ? null : root.closest<HTMLElement>(FRESH_ROW_SELECTOR);
|
|
679
|
+
if (echoRow) {
|
|
680
|
+
if (echo.includes('f')) echoRow.setAttribute(KIT_ROW_FRESH_ATTR, '');
|
|
681
|
+
else echoRow.removeAttribute(KIT_ROW_FRESH_ATTR);
|
|
682
|
+
// 隐去挂在数据项最外层(展开行外壳 / 行容器本身),与模板克隆的单位一致
|
|
683
|
+
const item = echoRow.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`) ?? echoRow;
|
|
684
|
+
// 只撤销自己加的 hidden(data-kit-pinned-hidden 记着),不碰别的显隐来源;用 toggleKitHidden 防止 flex/grid 覆盖 [hidden]
|
|
685
|
+
if (echo.includes('h')) {
|
|
686
|
+
toggleKitHidden(item, true);
|
|
687
|
+
item.setAttribute(KIT_ATTR_PINNED_HIDDEN, '');
|
|
688
|
+
} else if (item.hasAttribute(KIT_ATTR_PINNED_HIDDEN)) {
|
|
689
|
+
toggleKitHidden(item, false);
|
|
690
|
+
item.removeAttribute(KIT_ATTR_PINNED_HIDDEN);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
437
693
|
// 批量条出现期间(表格有批量动作且已有选中行)行内操作整体禁用:批量条替换了工具条,此时单行操作不与批量操作并行(排布规则:选中期间行内操作禁用);勾选框不受影响
|
|
438
694
|
const locked = p.bulkLock === true && Array.isArray(p.selected) && p.selected.length > 0;
|
|
439
695
|
// 跳过判定的签名 = props(已选集合只并入「本行是否被选中」)+ 渲染另外读取的 DOM / 权限输入:
|
|
@@ -443,19 +699,22 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
443
699
|
try {
|
|
444
700
|
const rest: Record<string, unknown> = { ...p };
|
|
445
701
|
delete rest.selected;
|
|
702
|
+
delete rest.picked;
|
|
446
703
|
const keyF = str(p.keyField);
|
|
447
704
|
const selState = Array.isArray(p.selected) ? (p.selected.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0) : -1;
|
|
705
|
+
const pickedRows = selectedRowsOf(p.picked);
|
|
706
|
+
const pickState = pickedRows === null ? -1 : (pickedRows.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0);
|
|
448
707
|
const perms = itemsOf(p.actions).map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? 1 : 0) : -1));
|
|
449
|
-
return JSON.stringify([rest, selState, perms]) + (busy ? '|busy' : '') + (locked ? '|lock' : '');
|
|
708
|
+
return JSON.stringify([rest, selState, pickState, perms]) + (busy ? '|busy' : '') + (locked ? '|lock' : '');
|
|
450
709
|
} catch {
|
|
451
710
|
return null; // 含环等不可序列化:不跳过
|
|
452
711
|
}
|
|
453
712
|
})();
|
|
454
713
|
const sigOf = (): string | null => {
|
|
455
714
|
if (propsPart === null) return null;
|
|
456
|
-
const expandRow = root.closest<HTMLElement>(
|
|
457
|
-
const expandBody = expandRow?.querySelector<HTMLElement>(
|
|
458
|
-
return propsPart + JSON.stringify([elementId(root.closest(
|
|
715
|
+
const expandRow = root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`);
|
|
716
|
+
const expandBody = expandRow?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
717
|
+
return propsPart + JSON.stringify([elementId(root.closest(`[${KIT_ATTR_ROW}]`)), elementId(expandRow), expandBody === null ? -1 : expandBody.classList.contains('hidden') ? 0 : 1, inTableOf(root) ? 1 : 0]);
|
|
459
718
|
};
|
|
460
719
|
// 无 expandHost 的展开钮读的是 DOM 上详情体当前显隐(不在 props 里),不能凭签名跳过
|
|
461
720
|
const domDriven = (p.expand === true || p.expand === 'true') && str(p.expandHost) === '';
|
|
@@ -468,30 +727,35 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
468
727
|
};
|
|
469
728
|
// 必须重绘:记下焦点所在的勾选框 / 动作钮,重绘后还给同值元素
|
|
470
729
|
const activeEl = root.ownerDocument.activeElement;
|
|
471
|
-
const focusedIn = activeEl && root.contains(activeEl) ? activeEl.closest<HTMLElement>(
|
|
730
|
+
const focusedIn = activeEl && root.contains(activeEl) ? activeEl.closest<HTMLElement>(`[${KIT_ATTR_SEL}], [${KIT_ATTR_ACT}]`) : null;
|
|
472
731
|
const focusKey = focusedIn
|
|
473
|
-
? focusedIn.hasAttribute(
|
|
732
|
+
? focusedIn.hasAttribute(KIT_ATTR_SEL) ? { attr: KIT_ATTR_SEL, val: focusedIn.getAttribute(KIT_ATTR_SEL) ?? '' } : { attr: KIT_ATTR_ACT, val: focusedIn.getAttribute(KIT_ATTR_ACT) ?? '' }
|
|
474
733
|
: null;
|
|
475
734
|
try {
|
|
476
735
|
moreMenu?.destroy();
|
|
477
736
|
moreMenu = null;
|
|
478
737
|
// 旧按钮的原因气泡可能正挂在浮层根里:整片重画前先摘(锚点随旧树丢弃)
|
|
479
738
|
releaseReasonTipsIn(root);
|
|
480
|
-
|
|
481
|
-
|
|
739
|
+
// 动作级判定(props.kit.actions[动作id],emit 侧汇总后生效):语气为危险的按危险档画(不占主色、置末进「更多」);
|
|
740
|
+
// 没有判定时按原来的 tone / function 推档
|
|
741
|
+
const items = itemsOf(p.actions).map((item) => (kitActionPropsOf(p, item.id).tone === 'danger' && item.tone !== 'danger' ? { ...item, tone: 'danger' as const } : item));
|
|
742
|
+
const asButton = p.look === 'button';
|
|
743
|
+
const splitMore = !asButton && p.splitMoreColumn === true;
|
|
744
|
+
root.className = splitMore ? 'contents' : joinClass(asButton ? HEAD_ROOT_CLASS : ROOT_CLASS, p.class);
|
|
482
745
|
root.replaceChildren();
|
|
483
746
|
if (busy) root.setAttribute('aria-busy', 'true');
|
|
484
747
|
else root.removeAttribute('aria-busy');
|
|
485
748
|
if (p.expand === true || p.expand === 'true') {
|
|
486
749
|
const btn = root.ownerDocument.createElement('button');
|
|
487
750
|
btn.setAttribute('type', 'button');
|
|
488
|
-
btn.setAttribute(
|
|
751
|
+
btn.setAttribute(KIT_ATTR_EXPAND, '');
|
|
752
|
+
kitMarkPart(btn, 'action');
|
|
489
753
|
// list 形(展开子表):本行是否展开 = expandId 等于本行主键;展开则把页面级子表承载壳挪进详情体,否则(若在本行里)挪回
|
|
490
754
|
const host = str(p.expandHost);
|
|
491
755
|
if (host !== '') {
|
|
492
756
|
const mine = expandKeyOf(p.row, str(p.keyField));
|
|
493
757
|
const open = mine !== '' && str(p.expandId) === mine;
|
|
494
|
-
const bodyOuter = root.closest<HTMLElement>(
|
|
758
|
+
const bodyOuter = root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
495
759
|
const target = (bodyOuter?.firstElementChild as HTMLElement | null) ?? bodyOuter;
|
|
496
760
|
if (target !== null) {
|
|
497
761
|
if (open) moveExpandChild(root.ownerDocument, host, target);
|
|
@@ -500,7 +764,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
500
764
|
bodyOuter?.classList.toggle('hidden', !open);
|
|
501
765
|
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
502
766
|
} else {
|
|
503
|
-
btn.setAttribute('aria-expanded', root.closest(
|
|
767
|
+
btn.setAttribute('aria-expanded', root.closest(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector(`[${KIT_ATTR_EXPAND_BODY}]:not(.hidden)`) ? 'true' : 'false');
|
|
504
768
|
}
|
|
505
769
|
btn.className = EXPAND_BUTTON_CLASS;
|
|
506
770
|
btn.textContent = btn.getAttribute('aria-expanded') === 'true' ? str(p.collapseLabel, kitText('soma.kit.collapse', undefined, root)) : str(p.expandLabel, kitText('soma.kit.expand_detail', undefined, root));
|
|
@@ -509,7 +773,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
509
773
|
return;
|
|
510
774
|
}
|
|
511
775
|
// 行样式档位:先摘掉上次加的档位类,再按本行当前档位重加(类串来自语法真源闭集,已进候选类)
|
|
512
|
-
const toneRow = root.closest<HTMLElement>(
|
|
776
|
+
const toneRow = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
513
777
|
if (toneRow) {
|
|
514
778
|
// 两张档位表(行底色 / 条目描边)的类串都摘,换档位集或换档位都不残留
|
|
515
779
|
for (const cls of [...Object.values(KIT_ROW_TONE_CLASS), ...Object.values(KIT_ITEM_TONE_CLASS)]) toneRow.classList.remove(...cls.split(/\s+/).filter((t) => t !== ''));
|
|
@@ -518,7 +782,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
518
782
|
}
|
|
519
783
|
// 整行可点(pickOnRow):行本身进 Tab 序并有焦点环,Enter 触发(键盘等价于点行)
|
|
520
784
|
if (p.pickOnRow === true || p.pickOnRow === 'true') {
|
|
521
|
-
const pickRow = root.closest<HTMLElement>(
|
|
785
|
+
const pickRow = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
522
786
|
if (pickRow && !FOCUSABLE_ROWS.has(pickRow)) {
|
|
523
787
|
FOCUSABLE_ROWS.add(pickRow);
|
|
524
788
|
pickRow.setAttribute('tabindex', '0');
|
|
@@ -527,32 +791,49 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
527
791
|
}
|
|
528
792
|
const mode = str(p.selectMode, 'none') as SelectMode;
|
|
529
793
|
const keyField = str(p.keyField);
|
|
530
|
-
const
|
|
794
|
+
const selectedRows = selectedRowsOf(p.selected);
|
|
795
|
+
const picked = selectedRows !== null && selectedRows.some((r) => rowKeyOf(r, keyField) === rowKeyOf(p.row, keyField));
|
|
531
796
|
// 选中行高亮:给所在行容器(data-kit-row)标 data-kit-selected,行类里的 data-kit-selected 变体生效(静态类,不拼类名);
|
|
532
797
|
// 表格是无 role 的 div,不写 aria-selected(它只在 grid / treegrid 的 row 上合法);已选语义由勾选列 checkbox / radio 承担。
|
|
533
798
|
// 勾选列实例与 pickOnRow 实例都读同一份已选行镜像,结论一致
|
|
534
|
-
|
|
535
|
-
|
|
799
|
+
// 给了 picked(当前打开项)时高亮只看它;没给按已选集合(勾选态 picked 变量仍只看已选集合)
|
|
800
|
+
const openRows = selectedRowsOf(p.picked);
|
|
801
|
+
const highlightRows = openRows !== null ? openRows : selectedRows;
|
|
802
|
+
const highlighted = highlightRows !== null && highlightRows.some((r) => rowKeyOf(r, keyField) === rowKeyOf(p.row, keyField));
|
|
803
|
+
if (highlightRows !== null) {
|
|
804
|
+
const rowEl = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
536
805
|
if (rowEl) {
|
|
537
|
-
if (
|
|
538
|
-
else rowEl.removeAttribute(
|
|
806
|
+
if (highlighted) rowEl.setAttribute(KIT_ATTR_SELECTED, '');
|
|
807
|
+
else rowEl.removeAttribute(KIT_ATTR_SELECTED);
|
|
808
|
+
// 交互状态自报「选中」;行是无 role 的 div,aria 不写(理由同上)
|
|
809
|
+
kitMarkPicked(rowEl, 'selected', highlighted, null);
|
|
539
810
|
}
|
|
540
811
|
}
|
|
541
812
|
if (mode === 'single' || mode === 'multi') {
|
|
542
813
|
const box = createCheck(root.ownerDocument, mode === 'single' ? 'radio' : 'checkbox', { checked: picked, ...(busy ? { disabled: true } : {}) });
|
|
543
|
-
box.setAttribute(
|
|
814
|
+
box.setAttribute(KIT_ATTR_SEL, '');
|
|
544
815
|
// 可访问名带行主键,读屏用户能分清是哪一行;没有主键字段时退回通用文案
|
|
545
816
|
const keyVal = keyField !== '' ? rowKeyOf(p.row, keyField) : '';
|
|
546
817
|
setMarkLabel(box, keyVal !== '' ? kitText('soma.kit.select_row_of', { key: keyVal }, root) : kitText('soma.kit.select_this_row', undefined, root));
|
|
547
818
|
root.appendChild(box);
|
|
548
819
|
}
|
|
549
|
-
// K1-2:无权限的动作不渲染(check 为 null =
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const
|
|
820
|
+
// K1-2:无权限的动作不渲染(check 为 null = 未装配权限,保持渲染);
|
|
821
|
+
// 本行不可用的动作(actionState 的 hidden 或 disabled)一律隐藏而不是置灰(knowledge/Kit主题规则与算法.md KT-K-table-4,2026-11-25 裁决);
|
|
822
|
+
// 例外:作者为置灰写了原因(disabledReason 求值非空)——「为什么不能点」本身是要告诉用户的信息,保留置灰 + 原因气泡(AC07);
|
|
823
|
+
// 删除在途 / 批量锁定这类短暂的忙态仍是整行置灰(不是「不可用」)
|
|
824
|
+
const shown = items.filter((item) => {
|
|
825
|
+
const st = rowActionState(p.actionState, item.id);
|
|
826
|
+
const unexplained = st.disabled === true && disabledReasonOf(p.actionState, item) === '';
|
|
827
|
+
return !(item.permission !== undefined && check !== null && !check(item.permission)) && !st.hidden && !unexplained;
|
|
828
|
+
});
|
|
829
|
+
const isAllInline = p.maxInline === 'all';
|
|
830
|
+
const explicitMaxInline = p.maxInline !== undefined && p.maxInline !== null && p.maxInline !== '';
|
|
831
|
+
const maxRaw = isAllInline ? Infinity : Number(p.maxInline);
|
|
832
|
+
const maxInline = isAllInline ? Infinity : (Number.isFinite(maxRaw) && maxRaw >= 1 ? Math.floor(maxRaw) : DEFAULT_MAX_INLINE);
|
|
833
|
+
const nonMoreCount = shown.filter((i) => i.more !== true).length;
|
|
834
|
+
const keepDangerInline = isAllInline || p.keepDangerInline === true || (explicitMaxInline && maxInline >= nonMoreCount);
|
|
554
835
|
if (offEdge === null) {
|
|
555
|
-
const wrap = root.closest<HTMLElement>(
|
|
836
|
+
const wrap = root.closest<HTMLElement>(`[${KIT_ATTR_PART}="table"]`);
|
|
556
837
|
if (wrap !== null) offEdge = watchEndEdge(wrap);
|
|
557
838
|
}
|
|
558
839
|
renderedInTable = inTableOf(root);
|
|
@@ -563,50 +844,116 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
563
844
|
};
|
|
564
845
|
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(recheck); else queueMicrotask(recheck);
|
|
565
846
|
// 宽档切分:前 maxInline 个行内,其余并入「更多」。窄档保留者(primary 优先,上限取 design maxInline.narrow)取自宽档行内项,其余行内项标次要
|
|
566
|
-
const { inline, folded, separated } = splitRowActions(shown, maxInline, false);
|
|
567
|
-
const inCompact = !renderedInTable && root.closest(
|
|
568
|
-
|
|
847
|
+
const { inline, folded, separated } = splitRowActions(shown, maxInline, false, keepDangerInline);
|
|
848
|
+
const inCompact = !asButton && !renderedInTable && root.closest(`[${KIT_ATTR_COMPACT}]`) !== null;
|
|
849
|
+
// 详情头按钮组(look: button)也按容器窄档收起次要项:查询容器是详情头(biz/master-sub/shell detailHead 带 @container),
|
|
850
|
+
// 窄于窄档线时只留主动作 +「更多」,次要按钮进菜单——不再整组换行后仍向右溢出被裁(look6 mcp 接口配置 @320)
|
|
851
|
+
// maxInline === 'all' 时显式要求全量行内展示,不在窄档生成隐藏的「…」触发钮
|
|
852
|
+
const narrowKeep = isAllInline
|
|
853
|
+
? new Set(inline)
|
|
854
|
+
: (asButton || renderedInTable || inCompact ? new Set(splitRowActions(inline, maxInline, true).inline) : new Set(inline));
|
|
569
855
|
const secondary = inline.filter((i) => !narrowKeep.has(i));
|
|
570
856
|
const secondaryButtons = new Map<string, HTMLButtonElement>();
|
|
571
857
|
const ranks = rowActionRanks(inline);
|
|
572
|
-
|
|
573
|
-
|
|
858
|
+
const headRanks = asButton ? headActionRanks(inline, kitHasActionProps(p) ? (id) => kitActionPropsOf(p, id).solid === true : undefined) : [];
|
|
859
|
+
const doc = root.ownerDocument;
|
|
860
|
+
const allowInline = p.slot !== 'more' && p.onlyMore !== true;
|
|
861
|
+
const allowMore = p.slot !== 'inline' && p.hideMore !== true;
|
|
862
|
+
let inlineHost: HTMLElement = root;
|
|
863
|
+
let moreHost: HTMLElement = root;
|
|
864
|
+
let splitInlineCell: HTMLElement | null = null;
|
|
865
|
+
let splitMoreCell: HTMLElement | null = null;
|
|
866
|
+
if (splitMore) {
|
|
867
|
+
const role = str(p.cellRole);
|
|
868
|
+
splitInlineCell = doc.createElement('div');
|
|
869
|
+
if (role !== '') splitInlineCell.setAttribute('role', role);
|
|
870
|
+
splitInlineCell.setAttribute(KIT_ATTR_PART, KIT_PART_TABLE_CELL);
|
|
871
|
+
splitInlineCell.setAttribute(KIT_OPS_CELL_ATTR, '');
|
|
872
|
+
splitInlineCell.className = str(p.inlineCellClass);
|
|
873
|
+
const innerWrap = doc.createElement('div');
|
|
874
|
+
innerWrap.className = joinClass(ROOT_CLASS, p.class);
|
|
875
|
+
splitInlineCell.appendChild(innerWrap);
|
|
876
|
+
inlineHost = innerWrap;
|
|
877
|
+
splitMoreCell = doc.createElement('div');
|
|
878
|
+
if (role !== '') splitMoreCell.setAttribute('role', role);
|
|
879
|
+
splitMoreCell.setAttribute(KIT_ATTR_PART, KIT_PART_TABLE_CELL);
|
|
880
|
+
splitMoreCell.setAttribute(KIT_OPS_CELL_ATTR, '');
|
|
881
|
+
splitMoreCell.className = str(p.moreCellClass);
|
|
882
|
+
moreHost = splitMoreCell;
|
|
883
|
+
root.append(splitInlineCell, splitMoreCell);
|
|
884
|
+
}
|
|
885
|
+
const appendActionIcon = (parent: HTMLElement, icon: string): void => {
|
|
886
|
+
const iconName = resolveKitIconName(icon);
|
|
887
|
+
if (iconName !== null) {
|
|
888
|
+
parent.appendChild(kitIcon(iconName, 'sm'));
|
|
889
|
+
} else {
|
|
890
|
+
const sym = doc.createElement('span');
|
|
891
|
+
sym.setAttribute('aria-hidden', 'true');
|
|
892
|
+
sym.textContent = icon;
|
|
893
|
+
parent.appendChild(sym);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
if (allowInline) for (const [at, item] of inline.entries()) {
|
|
897
|
+
const btn = doc.createElement('button');
|
|
574
898
|
btn.setAttribute('type', 'button');
|
|
575
|
-
btn.setAttribute(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
899
|
+
btn.setAttribute(KIT_ATTR_ACT, item.id);
|
|
900
|
+
// 行内动作 / 详情头动作的按钮:元素部件「动作」
|
|
901
|
+
kitMarkPart(btn, 'action');
|
|
902
|
+
const hasIcon = typeof item.icon === 'string' && item.icon !== '';
|
|
903
|
+
const isIconOnly = hasIcon && (item.iconOnly === true || item.name === '');
|
|
904
|
+
btn.className = asButton
|
|
905
|
+
? HEAD_BUTTON_CLASS[headRanks[at]!]
|
|
906
|
+
: isIconOnly
|
|
907
|
+
? ROW_ACTION_ICON_ONLY_BUTTON_CLASS[ranks[at]!]
|
|
908
|
+
: ROW_ACTION_BUTTON_CLASS[ranks[at]!];
|
|
909
|
+
if (asButton) setKitFace(btn, 'raised');
|
|
910
|
+
// 内联的危险动作置末并与前一项分隔:在项间距(gap-x-4)之外再加大一截(取值 kit-arrange#actionGroup.dangerSeparatorRem);按钮形态(详情头)按钮自带轮廓,不加
|
|
911
|
+
if (!asButton && separated.has(item.id)) btn.className = `${btn.className} ${DANGER_SEPARATOR_CLASS}`;
|
|
579
912
|
if (!narrowKeep.has(item)) {
|
|
580
|
-
btn.setAttribute(
|
|
913
|
+
btn.setAttribute(KIT_ATTR_ACT_SECONDARY, '');
|
|
581
914
|
btn.className = `${btn.className} ${inCompact ? COMPACT_SECONDARY_CLASS : ROW_ACTION_SECONDARY_CLASS}`;
|
|
582
915
|
secondaryButtons.set(item.id, btn);
|
|
583
916
|
}
|
|
584
|
-
// 文字链接形态:无面(不标 raised
|
|
585
|
-
|
|
917
|
+
// 文字链接形态:无面(不标 raised);支持纯文字 / 仅图标 / 图标+文字三种渲染形态
|
|
918
|
+
if (isIconOnly) {
|
|
919
|
+
const label = item.name !== '' ? item.name : item.id;
|
|
920
|
+
btn.setAttribute('aria-label', label);
|
|
921
|
+
btn.setAttribute('title', label);
|
|
922
|
+
appendActionIcon(btn, item.icon!);
|
|
923
|
+
} else if (hasIcon) {
|
|
924
|
+
appendActionIcon(btn, item.icon!);
|
|
925
|
+
const labelSpan = doc.createElement('span');
|
|
926
|
+
labelSpan.textContent = item.name;
|
|
927
|
+
btn.appendChild(labelSpan);
|
|
928
|
+
} else {
|
|
929
|
+
btn.textContent = item.name;
|
|
930
|
+
}
|
|
586
931
|
// 置灰原因(动作置灰且原因非空,本行没在删除在途):不用原生 disabled,只留 aria-disabled 保持可聚焦,原因经气泡 + aria-describedby 给出;点击由 onClick 的置灰判断拦下
|
|
587
932
|
const reason = busy || locked ? '' : disabledReasonOf(p.actionState, item);
|
|
588
933
|
if (reason !== '') {
|
|
589
934
|
btn.setAttribute('aria-disabled', 'true');
|
|
590
|
-
|
|
935
|
+
// 置灰是静态类(与 cursor-pointer 同特异度,谁在样式表里靠后谁赢):先摘掉可点光标,光标只剩 not-allowed
|
|
936
|
+
btn.className = `${btn.className.split(/\s+/).filter((c) => c !== 'cursor-pointer').join(' ')} ${kitDisabledRecipe('aria')}`;
|
|
591
937
|
} else if (busy || locked || rowActionState(p.actionState, item.id).disabled) {
|
|
592
938
|
btn.disabled = true;
|
|
593
939
|
btn.setAttribute('aria-disabled', 'true');
|
|
594
940
|
}
|
|
595
|
-
|
|
941
|
+
inlineHost.appendChild(btn);
|
|
596
942
|
if (reason !== '') syncReasonTip(btn, reason);
|
|
597
943
|
}
|
|
598
|
-
if (folded.length > 0 || secondary.length > 0) {
|
|
599
|
-
const doc = root.ownerDocument;
|
|
944
|
+
if (allowMore && (folded.length > 0 || secondary.length > 0)) {
|
|
600
945
|
const wrap = doc.createElement('div');
|
|
601
946
|
// 没有常驻折叠项(宽档全部行内)时触发器只在窄档出现;有常驻折叠项时恒显示
|
|
602
947
|
wrap.className = folded.length > 0 ? MORE_ROOT_CLASS : inCompact ? COMPACT_MORE_ROOT_NARROW_ONLY_CLASS : MORE_ROOT_NARROW_ONLY_CLASS;
|
|
603
|
-
wrap.setAttribute(
|
|
948
|
+
wrap.setAttribute(KIT_ATTR_MORE_ROOT, folded.length > 0 ? '' : 'narrow');
|
|
604
949
|
const trigger = doc.createElement('button');
|
|
605
950
|
trigger.setAttribute('type', 'button');
|
|
606
951
|
trigger.setAttribute('aria-haspopup', 'menu');
|
|
607
952
|
trigger.setAttribute('aria-label', kitText('soma.kit.more_actions', undefined, root));
|
|
608
|
-
trigger.className = MORE_TRIGGER_CLASS;
|
|
609
|
-
trigger
|
|
953
|
+
trigger.className = asButton ? HEAD_MORE_TRIGGER_CLASS : MORE_TRIGGER_CLASS;
|
|
954
|
+
if (asButton) setKitFace(trigger, 'raised');
|
|
955
|
+
trigger.setAttribute(KIT_ATTR_MORE, '');
|
|
956
|
+
kitMarkPart(trigger, 'action');
|
|
610
957
|
const win = doc.defaultView;
|
|
611
958
|
const menuEntries = (): KitTableActionItem[] => {
|
|
612
959
|
const hiddenSecondary = secondary.filter((i) => {
|
|
@@ -615,12 +962,18 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
615
962
|
});
|
|
616
963
|
return [...hiddenSecondary, ...folded.filter((i) => i.more !== true), ...folded.filter((i) => i.more === true)];
|
|
617
964
|
};
|
|
618
|
-
|
|
619
|
-
|
|
965
|
+
if (asButton) {
|
|
966
|
+
trigger.textContent = kitText('soma.kit.more_menu', undefined, root);
|
|
967
|
+
trigger.appendChild(kitIcon('chevron-down', 'sm'));
|
|
968
|
+
} else {
|
|
969
|
+
// 行内溢出动作各档只出「…」图标钮(§11.17 成套对齐「行内动作」2026-11-26 裁决):可访问名 = 「更多操作」,同一句进悬停 / 聚焦提示(表壳是提示作用域)
|
|
970
|
+
trigger.appendChild(kitIcon('more', 'sm'));
|
|
971
|
+
trigger.setAttribute(KIT_TIP_ATTR, kitText('soma.kit.more_actions', undefined, root));
|
|
972
|
+
}
|
|
620
973
|
const menu = doc.createElement('div');
|
|
621
974
|
menu.className = 'hidden';
|
|
622
975
|
wrap.append(trigger, menu);
|
|
623
|
-
|
|
976
|
+
moreHost.appendChild(wrap);
|
|
624
977
|
// 本行删除在途 / 批量条出现期间:「更多」触发钮置灰,菜单不接线(打不开)
|
|
625
978
|
if (busy || locked) {
|
|
626
979
|
trigger.disabled = true;
|
|
@@ -633,26 +986,41 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
633
986
|
hiddenClass: 'hidden',
|
|
634
987
|
// 挂到浮层根下,不被表格外层 overflow 裁切;定位仍走 popup 的贴边翻转
|
|
635
988
|
portal: createPanelPortal(trigger),
|
|
636
|
-
fitted: () => ({ pref: MORE_PLACE, classFor: KIT_MENU_PANEL.
|
|
989
|
+
fitted: () => ({ pref: MORE_PLACE, classFor: KIT_MENU_PANEL.classForTextTrigger }),
|
|
637
990
|
classes: MORE_MENU_CLASSES,
|
|
638
991
|
// 置灰项的原因作为该项的描述文字(可见的第二段文字 + aria-describedby),菜单项本身是 aria-disabled 的 div,读屏可取到
|
|
639
992
|
// 菜单内容在打开 / 取项时现算:常驻折叠项 + 当前被容器查询隐藏的次要行内项(display:none 即不可见),次序 = 隐藏的次要项(声明序)→ 常驻折叠的普通项 → more:true 项
|
|
640
993
|
// 危险项置末并与前面的项以分隔线隔开(动作组统一规则,menuOrderDangerLast)
|
|
641
|
-
items: () => menuOrderDangerLast(menuEntries().map((i) => ({ key: i.id, label: i.name, icon: '', disabled: rowActionState(p.actionState, i.id).disabled, danger: i.tone === 'danger', divider: false, reason: disabledReasonOf(p.actionState, i) }))),
|
|
994
|
+
items: () => menuOrderDangerLast(menuEntries().map((i) => ({ key: i.id, label: i.name || i.id, icon: i.icon ?? '', disabled: rowActionState(p.actionState, i.id).disabled, danger: i.tone === 'danger', divider: false, reason: disabledReasonOf(p.actionState, i) }))),
|
|
642
995
|
locked: () => false,
|
|
643
996
|
onPick: (picked) => {
|
|
644
997
|
const hit = menuEntries().find((i) => i.id === picked.key);
|
|
645
998
|
if (hit) {
|
|
646
|
-
lastActed = { attr:
|
|
647
|
-
|
|
999
|
+
lastActed = { attr: KIT_ATTR_MORE, val: '' };
|
|
1000
|
+
// 菜单项选中后菜单已关,确认锚在「更多」的触发钮上
|
|
1001
|
+
rowConfirm.guard(api.props(), hit.id, trigger, hit.name || hit.id, () => emitRowAction(api, hit, items.findIndex((a) => a.id === hit.id)));
|
|
648
1002
|
}
|
|
649
1003
|
},
|
|
650
1004
|
});
|
|
651
1005
|
}
|
|
1006
|
+
// 空操作列收列(KT-P-list):本行可见动作数为 0(权限全拒 / 行级 hidden / 不可用)在所在操作格上记一笔,交整表汇总
|
|
1007
|
+
if (splitInlineCell !== null && splitMoreCell !== null) {
|
|
1008
|
+
const isEmpty = shown.length === 0 && mode === 'none';
|
|
1009
|
+
splitInlineCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, isEmpty);
|
|
1010
|
+
splitMoreCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, isEmpty);
|
|
1011
|
+
scheduleOpsColumnSync(splitInlineCell);
|
|
1012
|
+
} else {
|
|
1013
|
+
const opsCell = asButton ? null : root.closest<HTMLElement>(`[${KIT_OPS_CELL_ATTR}]`);
|
|
1014
|
+
if (opsCell !== null) {
|
|
1015
|
+
opsCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, shown.length === 0 && mode === 'none');
|
|
1016
|
+
scheduleOpsColumnSync(opsCell);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
652
1019
|
commit();
|
|
653
1020
|
} catch (error) {
|
|
654
1021
|
lastSig = null;
|
|
655
1022
|
lastRoot = null;
|
|
1023
|
+
renderedPerm = '';
|
|
656
1024
|
throw error;
|
|
657
1025
|
} finally {
|
|
658
1026
|
if (focusKey !== null) {
|