soma-kit 0.1.15 → 0.1.17
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 +935 -93
- 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 +188 -62
- 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 +152 -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 +1016 -54
- 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 +423 -104
- 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
|
@@ -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 {
|
|
50
|
+
import { KIT_TIP_ATTR } from '../base/hint-tips';
|
|
51
|
+
import { kitDisabledRecipe, setKitFace } from '../recipes';
|
|
52
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
28
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,9 +111,10 @@ 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
|
-
|
|
51
|
-
const
|
|
114
|
+
// 行内「更多」触发器 = 只有「…」图标的淡底钮(次级钮配方 button.text 的紧凑形:各层级档自动取本档的次钮形体——纸面中性淡底、色调主色淡底、细线描边、扁平链接色),
|
|
115
|
+
// 不再是「更多 + 下箭头」的文字链接:一列十几行各一个蓝字太抢,样本三套都只出图标
|
|
116
|
+
const MORE_TRIGGER_CLASS = kitActionRecipe('more', { tight: true, region: 'row', size: 'sm' });
|
|
117
|
+
const MORE_PLACE: PopPlace = { side: 'bottom', align: 'end' };
|
|
52
118
|
const MORE_MENU_SHOWN = KIT_MENU_PANEL.classForTextTrigger(MORE_PLACE);
|
|
53
119
|
export const MORE_MENU_CLASSES: MenuClasses = KIT_MENU_ITEM_CLASSES;
|
|
54
120
|
/**
|
|
@@ -61,40 +127,98 @@ type ActionTone = 'primary' | 'neutral' | 'danger';
|
|
|
61
127
|
|
|
62
128
|
// 工具栏 / 批量条按钮:控件引擎的按钮配方 + 工具条宿主选项(tight:横向内边距降一档);变体按强调等级取(区域主动作 = 实心、次级 = 色调、危险 = 透明底危险文字)
|
|
63
129
|
export const ACTION_BUTTON_CLASS: Record<ActionTone, string> = {
|
|
64
|
-
primary
|
|
65
|
-
|
|
66
|
-
|
|
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' }),
|
|
67
135
|
};
|
|
68
136
|
|
|
69
137
|
/**
|
|
70
|
-
* 行内操作(表格 / 树表 /
|
|
71
|
-
*
|
|
72
|
-
*
|
|
138
|
+
* 行内操作(表格 / 树表 / 虚拟表的操作列):轻按钮(SCON-116,设计稿 §3.1″)——有后果的操作一律是按钮:按钮的内边距、可点区、焦点环与尺寸档(sm),
|
|
139
|
+
* 静止只有字色,悬停 / 聚焦才显出底与圆角(控件变体 subtle,行内区的 neutral 角色);不再用文字链接。行内至多露 2 个、其余进「更多」,危险动作只在菜单里
|
|
140
|
+
* (孤立的危险动作才行内,取软危险色)。工具栏 / 批量条仍用 ACTION_BUTTON_CLASS。
|
|
73
141
|
*/
|
|
74
142
|
export const ROW_ACTION_BUTTON_CLASS: Record<KitRowActionRank, string> = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
danger: kitRowActionRecipe('danger'),
|
|
143
|
+
rest: kitActionRecipe('edit', { region: 'row', size: 'sm' }),
|
|
144
|
+
danger: kitActionRecipe('delete', { region: 'row', size: 'sm' }),
|
|
78
145
|
};
|
|
79
146
|
|
|
80
|
-
/**
|
|
81
|
-
const
|
|
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' }),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** 详情头动作区(look: button)的秩:只有这里还有「主」一档(显式 primary 的实心主钮);text = 条带描边超预算后降成的文字钮 */
|
|
154
|
+
type HeadActionRank = 'lead' | 'text' | KitRowActionRank;
|
|
155
|
+
|
|
156
|
+
/** 详情头动作区(look: button):秩 → 按钮配方(主 = 区域主动作实心、次 = 描边中性、文字 = 超预算降级、危险 = 透明底灰字悬停变危险色);「更多」是安静按钮 */
|
|
157
|
+
const HEAD_BUTTON_CLASS: Record<HeadActionRank, string> = {
|
|
82
158
|
lead: ACTION_BUTTON_CLASS.primary,
|
|
83
159
|
rest: ACTION_BUTTON_CLASS.neutral,
|
|
160
|
+
text: kitActionRecipe('edit', { tight: true, region: 'row' }),
|
|
84
161
|
danger: ACTION_BUTTON_CLASS.danger,
|
|
85
162
|
};
|
|
86
|
-
|
|
163
|
+
// 「更多」= 带下箭头的淡底钮(与 action-more 同一出口;2026-11-25 裁决:按钮至少有颜色或图形之一)
|
|
164
|
+
const HEAD_MORE_TRIGGER_CLASS = kitActionRecipe('more', { tight: true });
|
|
87
165
|
const HEAD_ROOT_CLASS = 'flex flex-wrap items-center justify-end gap-2';
|
|
88
166
|
|
|
89
167
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
168
|
+
* 行内文字链接动作(表格 / 树表 / 虚拟表 / 条目行)的秩(强调等级 R12;KT-E1 第 4 点、CS09 行为着色修订):危险动作 = danger(弱化、悬停转危险色、与前者隔开),
|
|
169
|
+
* 其余一律 rest(链接色文字,同一行同色;「更多」触发同色)——不按位置分出「一个蓝其余黑」。取值(语气)只在真源 kit-limits#emphasis.roles.rowAction.*。
|
|
92
170
|
*/
|
|
93
171
|
export function rowActionRanks(items: readonly { readonly tone?: ActionTone }[]): KitRowActionRank[] {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
}
|
|
98
222
|
}
|
|
99
223
|
|
|
100
224
|
// 行操作根:链接不收缩、不折行(flex-nowrap + whitespace-nowrap,行高保持一行),项间距 16px(gap-x-4);放不下的由切分(splitRowActions)并入「更多」,不靠换行;
|
|
@@ -102,11 +226,11 @@ export function rowActionRanks(items: readonly { readonly tone?: ActionTone }[])
|
|
|
102
226
|
// 操作列恒贴尾侧:动作右对齐,末尾动作的文字右缘 = 操作列右缘(列表页右轴:页头主按钮 / 操作列末尾 / 分页右端同一条线);表头「操作」同向右对齐
|
|
103
227
|
const ROOT_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
104
228
|
/** 展开行开关按钮(文字钮,不带底色) */
|
|
105
|
-
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;
|
|
106
230
|
/** 整行点击不响应的行内交互元素(它们有自己的事件):按钮 / 链接 / 输入 / 菜单 / 勾选列 / 就地编辑格 */
|
|
107
|
-
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}]`;
|
|
108
232
|
/** 整行可点时行容器的焦点环(键盘 Enter 进入) */
|
|
109
|
-
const ROW_FOCUS_CLASS =
|
|
233
|
+
const ROW_FOCUS_CLASS = KIT_FOCUS_RING.item;
|
|
110
234
|
/** 已加上焦点属性的行容器(卸载时还原) */
|
|
111
235
|
const FOCUSABLE_ROWS = new WeakSet<HTMLElement>();
|
|
112
236
|
/** 还焦点:勾选标记(label)自身不可聚焦,落到里面的原生 input */
|
|
@@ -136,17 +260,15 @@ function selectedRowsOf(raw: unknown): readonly unknown[] | null {
|
|
|
136
260
|
return null;
|
|
137
261
|
}
|
|
138
262
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const v = (row as Record<string, unknown>)[keyField];
|
|
142
|
-
return keyField !== '' && v !== undefined && v !== null ? String(v) : JSON.stringify(row);
|
|
143
|
-
}
|
|
263
|
+
/** 行主键的字符串键:全仓共用 shared/row-key.ts 的 kitRowKey(主键值是字符串 / 数字取它,否则整行 JSON;非对象行为空串) */
|
|
264
|
+
const rowKeyOf = kitRowKey;
|
|
144
265
|
|
|
145
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* 行主键的字符串键(行在途通道名、协调组件删除目标共用):委托 kitRowKey,保留导出名供行视图组件引用。
|
|
268
|
+
* 与旧实现的差别只在「行不是对象」:旧版当 {} 取 '{}',现在是空串(调用方本来就拿不到行)。
|
|
269
|
+
*/
|
|
146
270
|
export function removeKeyOf(row: unknown, keyField: string): string {
|
|
147
|
-
|
|
148
|
-
const v = keyField !== '' ? rec[keyField] : undefined;
|
|
149
|
-
return typeof v === 'string' || typeof v === 'number' ? String(v) : JSON.stringify(rec);
|
|
271
|
+
return kitRowKey(row, keyField);
|
|
150
272
|
}
|
|
151
273
|
|
|
152
274
|
/** 行在途(内置删除与具名行动作共用)的忙闲通道名:作用域 + 对象名 + 行主键三段(同作用域下不同对象主键相同也不撞名;base/action-busy 以空白 / 逗号切名字,故各段做 URI 编码);协调组件(内置删除)与动作执行器(具名行动作,按载荷 kit_row_busy)登记,本组件读 */
|
|
@@ -160,6 +282,25 @@ function removeBusyOf(p: Record<string, unknown>): boolean {
|
|
|
160
282
|
return scope !== '' && object !== '' && isKitActionBusy(rowBusyName(scope, object, removeKeyOf(p.row, str(p.removeKeyField))));
|
|
161
283
|
}
|
|
162
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
|
+
|
|
163
304
|
/** 供候选类汇总(candidates.ts)。 */
|
|
164
305
|
export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
165
306
|
ROOT_CLASS,
|
|
@@ -168,6 +309,9 @@ export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
|
168
309
|
EXPAND_BUTTON_CLASS,
|
|
169
310
|
...Object.values(ACTION_BUTTON_CLASS),
|
|
170
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',
|
|
171
315
|
HEAD_ROOT_CLASS, HEAD_MORE_TRIGGER_CLASS, ...Object.values(HEAD_BUTTON_CLASS),
|
|
172
316
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
173
317
|
...Object.values(KIT_ITEM_TONE_CLASS),
|
|
@@ -181,7 +325,13 @@ export const KIT_TABLE_ACTIONS_CLASS_CANDIDATES: readonly string[] = [
|
|
|
181
325
|
export interface KitTableActionItem {
|
|
182
326
|
id: string;
|
|
183
327
|
name: string;
|
|
328
|
+
/** 动作图标名(内置 kitIcon 闭集名或短符号) */
|
|
329
|
+
icon?: string;
|
|
330
|
+
/** 仅渲染图标按钮(aria-label / title 回落到 name || id) */
|
|
331
|
+
iconOnly?: boolean;
|
|
184
332
|
tone?: ActionTone;
|
|
333
|
+
/** 动作功能名(rec.function,按 §8b 解析危险 / 主操作语义) */
|
|
334
|
+
function?: string;
|
|
185
335
|
builtin?: string;
|
|
186
336
|
target?: string;
|
|
187
337
|
permission?: string;
|
|
@@ -195,29 +345,38 @@ export interface KitTableActionItem {
|
|
|
195
345
|
* 行内 / 「更多」切分(纯函数,排布引擎的行操作投影):shown = 已过权限与行级隐藏的动作(声明序)。
|
|
196
346
|
* 保留序、危险动作折叠都取自排布引擎(action-group.ts#planActionGroup,行操作 `dangerFold`):
|
|
197
347
|
* - 危险动作默认收进「更多」:动作数达到真源阈值(kit-arrange#actionGroup.dangerFoldMinActions)且还有非危险动作时,危险项恒进更多;
|
|
348
|
+
* 当 maxInline === Infinity(DSL maxInline: 'all')或显式 keepDangerInline 为真时,宽档不强制折叠危险项;
|
|
198
349
|
* - 宽档:其余非 more 动作按引擎保留序取前 maxInline 个行内(第一个 primary 恒在行内),其余并入更多;more: true 的恒进更多;
|
|
199
350
|
* - 窄档(容器低于 design 窄档线,行内上限取 design maxInline.narrow,且不超过 maxInline):最多保留 cap 个,同一保留序;
|
|
200
351
|
* 保留者仍按声明序排列;进更多的项:普通项在前、危险项置末(菜单渲染时用 menuOrderDangerLast 加分隔线)。
|
|
201
352
|
* 进更多的每一项,置灰与置灰原因仍由菜单项读 actionState / disabledReason(见 render 的 items),不在此丢失。
|
|
202
353
|
*/
|
|
203
354
|
export function splitRowActions(
|
|
204
|
-
shown: readonly KitTableActionItem[], maxInline: number, narrow: boolean,
|
|
355
|
+
shown: readonly KitTableActionItem[], maxInline: number, narrow: boolean, keepDangerInline = false,
|
|
205
356
|
): { inline: KitTableActionItem[]; folded: KitTableActionItem[]; separated: Set<string> } {
|
|
206
357
|
const forced = shown.filter((i) => i.more === true);
|
|
207
358
|
const candidates = shown.filter((i) => i.more !== true);
|
|
208
|
-
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);
|
|
209
362
|
// 静态切分整个交给引擎(inlineCap):保留序、危险折叠、内联危险项置末并分隔。
|
|
210
363
|
// 「被收起的只有 1 项时直接内联」不再用于行内动作:常驻至多 cap 个是硬上限(KT-K-table-4,2026-11-25 裁决;
|
|
211
364
|
// 第二轮真实使用测试见 talent 我的风险 3 个动作全常驻——cap 2 + 只溢出 1 项被这条豁免放回行内)
|
|
212
|
-
const plan = planActionGroup(candidates.map((i) => ({ id: i.id, label: i.name, importance: i.tone === 'primary' ? 'primary' : i.tone === 'danger' ? 'danger' : 'secondary' })), { dangerFold:
|
|
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 });
|
|
213
366
|
const byId = new Map(candidates.map((i) => [i.id, i] as const));
|
|
214
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);
|
|
215
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
|
+
}
|
|
216
375
|
return {
|
|
217
|
-
inline
|
|
376
|
+
inline,
|
|
218
377
|
// 进更多:声明序,more: true 的排在最后(菜单渲染再统一危险置末加分隔线)
|
|
219
378
|
folded: [...candidates.filter((i) => foldedIds.has(i.id)), ...forced],
|
|
220
|
-
separated
|
|
379
|
+
separated,
|
|
221
380
|
};
|
|
222
381
|
}
|
|
223
382
|
|
|
@@ -229,11 +388,20 @@ export function itemsOf(raw: unknown): KitTableActionItem[] {
|
|
|
229
388
|
const rec = item as Record<string, unknown>;
|
|
230
389
|
const id = str(rec.id);
|
|
231
390
|
if (id === '') continue;
|
|
232
|
-
|
|
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);
|
|
233
398
|
out.push({
|
|
234
399
|
id,
|
|
235
|
-
name
|
|
400
|
+
name,
|
|
401
|
+
...(icon !== '' ? { icon } : {}),
|
|
402
|
+
...(iconOnly ? { iconOnly: true } : {}),
|
|
236
403
|
tone,
|
|
404
|
+
...(fnRaw !== '' ? { function: fnRaw } : {}),
|
|
237
405
|
...(str(rec.builtin) !== '' ? { builtin: str(rec.builtin) } : {}),
|
|
238
406
|
...(str(rec.target) !== '' ? { target: str(rec.target) } : {}),
|
|
239
407
|
...(str(rec.permission) !== '' ? { permission: str(rec.permission) } : {}),
|
|
@@ -270,8 +438,16 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
270
438
|
name: 'KitTableActions',
|
|
271
439
|
layer: 'data',
|
|
272
440
|
props: {
|
|
273
|
-
actions: { type: 'array', default: [], desc: '行操作 [{ id, name, tone?, builtin?, target?, permission?, more?, disabledReason? }];permission 非空且无权限时不渲染该按钮;disabledReason
|
|
274
|
-
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)' },
|
|
275
451
|
actionState: { type: 'object', default: {}, desc: '行级动作状态 { 动作id: { hidden, disabled } }:叶子是行字段路径(业务对象逐行给出),core 逐行求值;hidden 为真该行不显示这个动作,disabled 为真置灰且点不到;叶子 disabledReason(可选)= 置灰原因文案(行字段 / 展示对象成员求值成字符串):置灰且非空时按钮保持可聚焦(只留 aria-disabled),原因经气泡与 aria-describedby 给出,「更多」菜单项带描述文字;字面量原因写在 actions 项的 disabledReason' },
|
|
276
452
|
rowTone: { type: 'string', default: '', desc: '行样式档位名(行字段取值,业务对象逐行给出):属于语法真源 viewObject.rowState.toneTiers 闭集时,给所在行容器(data-kit-row)加该档位的类串;不在闭集不加类(rowToneSet 为 item 时取 itemToneTiers)' },
|
|
277
453
|
rowToneSet: { type: 'string', default: 'row', desc: '行样式档位用哪张闭集表:row = toneTiers(表格行底色);item = itemToneTiers(cards / stack 条目自带底色与边框,只用描边 / 透明度);其它值按 row' },
|
|
@@ -280,6 +456,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
280
456
|
pickOnRow: { type: 'boolean', default: false, desc: '开启后点击所在行(data-kit-row 容器)抛 row_pick,builtin 为 select' },
|
|
281
457
|
selectMode: { type: 'string', default: 'none', desc: '勾选列模式 none / single / multi;非 none 时渲染选择框并抛 row_select' },
|
|
282
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' },
|
|
283
460
|
keyField: { type: 'string', default: '', desc: '行主键字段名(比对已选行;空 = 按整行内容)' },
|
|
284
461
|
bulkLock: { type: 'boolean', default: false, desc: '表格有批量动作时为真:已有选中行(批量条出现)期间本行的行内操作整体禁用' },
|
|
285
462
|
removeScope: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):协调组件的作用域 id;本行在途(经忙闲通道登记)时,本行全部操作置灰、容器挂 aria-busy;空 = 不读' },
|
|
@@ -325,16 +502,26 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
325
502
|
services: ['permission'],
|
|
326
503
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
327
504
|
controllerFactory: createKitController((api) => {
|
|
328
|
-
const check = permissionCheckerOf(api as unknown as any);
|
|
329
505
|
let moreMenu: MenuHandle | null = null;
|
|
330
506
|
// 上次渲染依赖的 props 签名:props 没变就不重绘(保住焦点与已开的更多菜单)
|
|
331
507
|
let lastSig: string | null = null;
|
|
332
508
|
let lastRoot: HTMLElement | null = null;
|
|
333
509
|
// 最近一次渲染时本行是否处于删除在途(忙闲通道变化时据此判断要不要重绘)
|
|
334
510
|
let renderedBusy = false;
|
|
511
|
+
// 最近一次渲染时本行的回声状态(高亮 / 置顶隐去;回声通道变化时据此判断要不要重绘)
|
|
512
|
+
let renderedEcho = '';
|
|
513
|
+
// 最近一次渲染时动作数组的权限判定签名(权限异步到达 / 收回 / 切换判定器时仅在结果变化时重绘)
|
|
514
|
+
let renderedPerm = '';
|
|
515
|
+
const permStateOf = (p: KitProps, check = permissionCheckerOf(api as unknown as any)): string => {
|
|
516
|
+
const items = itemsOf(p.actions);
|
|
517
|
+
if (!items.some((item) => item.permission !== undefined)) return '';
|
|
518
|
+
return items.map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? '1' : '0') : '-')).join('');
|
|
519
|
+
};
|
|
335
520
|
// 在途期间按钮被禁用会丢焦点:记下用户点的是哪个控件,落定恢复后还给它(仅当焦点已落到 body)
|
|
336
521
|
let lastActed: { attr: string; val: string } | null = null;
|
|
337
522
|
let wasBusy = false;
|
|
523
|
+
// 页面线对危险动作下发的二次确认(props.kit.actions[动作].confirm):点击与「更多」菜单选中共用一份,没有判定时同步触发
|
|
524
|
+
const rowConfirm = createKitRowConfirm(() => api.isCurrent());
|
|
338
525
|
// 窄档折叠是纯样式(容器查询):行内次要操作带 `@max-<档>:hidden`,「更多」触发器常驻 DOM,窄档由 CSS 显示;
|
|
339
526
|
// 「更多」菜单的内容在打开时按「当前不可见的行内项」现算,没有重复 DOM、不观察宽度。
|
|
340
527
|
// 只有行操作在表格容器里才标次要操作(容器查询以表格自己的查询容器为准;cards / stack 条目里不折叠)。
|
|
@@ -348,22 +535,23 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
348
535
|
attach(root) {
|
|
349
536
|
queueMicrotask(() => { if (root.isConnected && renderedInTable !== null && inTableOf(root) !== renderedInTable) api.refresh(); });
|
|
350
537
|
const onClick = (event: Event): void => {
|
|
351
|
-
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
538
|
+
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_ACT}]`);
|
|
352
539
|
if (!hit || !root.contains(hit)) return;
|
|
353
|
-
const id = hit.getAttribute(
|
|
540
|
+
const id = hit.getAttribute(KIT_ATTR_ACT) ?? '';
|
|
354
541
|
const item = itemsOf(api.props().actions).find((a) => a.id === id);
|
|
355
542
|
if (!item) return;
|
|
356
543
|
if (rowActionState(api.props().actionState, item.id).disabled || removeBusyOf(api.props())) return;
|
|
357
|
-
lastActed = { attr:
|
|
358
|
-
|
|
544
|
+
lastActed = { attr: KIT_ATTR_ACT, val: id };
|
|
545
|
+
const index = itemsOf(api.props().actions).findIndex((a) => a.id === id);
|
|
546
|
+
rowConfirm.guard(api.props(), item.id, hit, item.name, () => emitRowAction(api, item, index));
|
|
359
547
|
};
|
|
360
548
|
root.addEventListener('click', onClick);
|
|
361
549
|
// 展开行:开合状态存在本组件里;详情体由 emitStatic 标 data-kit-expand-body 并默认带 hidden
|
|
362
550
|
let opened = false;
|
|
363
551
|
const bodyEl = (): HTMLElement | null =>
|
|
364
|
-
root.closest<HTMLElement>(
|
|
552
|
+
root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
365
553
|
const onExpand = (event: Event): void => {
|
|
366
|
-
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
554
|
+
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_EXPAND}]`);
|
|
367
555
|
if (!hit || !root.contains(hit)) return;
|
|
368
556
|
// list 形(展开子表):开合由协调组件的 expandId 决定,这里只抛意图;手风琴(换行即收旧行)也在那边
|
|
369
557
|
if (str(api.props().expandHost) !== '') {
|
|
@@ -381,7 +569,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
381
569
|
root.addEventListener('click', onExpand);
|
|
382
570
|
// 勾选列:自绘勾选标记(check-core),点击 / 空格抛 row_select;已选的单选再点不重复抛
|
|
383
571
|
const offMark = attachMarkEvents(root, (mark, next) => {
|
|
384
|
-
if (mark.getAttribute(
|
|
572
|
+
if (mark.getAttribute(KIT_ATTR_SEL) === null) return;
|
|
385
573
|
const mode = str(api.props().selectMode, 'none');
|
|
386
574
|
if (mode !== 'single' && mode !== 'multi') return;
|
|
387
575
|
// 本行删除在途:勾选标记已禁用(render 里 disabled),事件层再兜一道,不抛 row_select
|
|
@@ -395,7 +583,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
395
583
|
});
|
|
396
584
|
// pickOnRow:行点击抛 row_action(builtin: 'select')。行容器由 emitStatic 标 data-kit-row;
|
|
397
585
|
// 点在按钮 / 输入类控件上不算选行(它们有自己的事件)
|
|
398
|
-
const rowEl = root.closest<HTMLElement>(
|
|
586
|
+
const rowEl = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
399
587
|
const pickOn = (): boolean => api.props().pickOnRow === true || api.props().pickOnRow === 'true';
|
|
400
588
|
const emitSelect = (): void => {
|
|
401
589
|
// 本行删除在途:整行点击 / Enter 都不抛选行事件(行会随删除落定消失或恢复)
|
|
@@ -422,10 +610,10 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
422
610
|
const onRowKey = (event: KeyboardEvent): void => {
|
|
423
611
|
if (!pickOn() || event.target !== rowEl) return;
|
|
424
612
|
// 条目列表(主从页左窗格):↑ ↓ 把焦点与选中移到相邻条目(点击相邻条目的同一条路径:焦点跟着走、抛 row_pick)
|
|
425
|
-
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && rowEl?.hasAttribute(
|
|
613
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && rowEl?.hasAttribute(KIT_ATTR_COMPACT)) {
|
|
426
614
|
const side = event.key === 'ArrowDown' ? 'nextElementSibling' : 'previousElementSibling';
|
|
427
615
|
let near = rowEl[side] as HTMLElement | null;
|
|
428
|
-
while (near !== null && !near.hasAttribute(
|
|
616
|
+
while (near !== null && !near.hasAttribute(KIT_ATTR_ROW)) near = near[side] as HTMLElement | null;
|
|
429
617
|
if (near !== null) {
|
|
430
618
|
event.preventDefault();
|
|
431
619
|
near.focus();
|
|
@@ -442,8 +630,18 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
442
630
|
const offRemoveBusy = onKitActionBusy(() => {
|
|
443
631
|
if (removeBusyOf(api.props()) !== renderedBusy) api.refresh();
|
|
444
632
|
});
|
|
633
|
+
const offEcho = onKitRowFresh(() => {
|
|
634
|
+
if (rowEchoState(api.props(), root) !== renderedEcho) api.refresh();
|
|
635
|
+
});
|
|
636
|
+
const offPerm = registerLivePermissionGate(() => {
|
|
637
|
+
if (permStateOf(api.props()) !== renderedPerm) api.refresh();
|
|
638
|
+
});
|
|
445
639
|
return () => {
|
|
640
|
+
rowConfirm.dispose();
|
|
446
641
|
offRemoveBusy();
|
|
642
|
+
offEcho();
|
|
643
|
+
offPerm();
|
|
644
|
+
renderedPerm = '';
|
|
447
645
|
offEdge?.();
|
|
448
646
|
offEdge = null;
|
|
449
647
|
root.removeEventListener('click', onClick);
|
|
@@ -468,8 +666,29 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
468
666
|
};
|
|
469
667
|
},
|
|
470
668
|
render(root: HTMLElement, p: KitProps, api: KitApi): void {
|
|
669
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
471
670
|
const busy = removeBusyOf(p);
|
|
472
671
|
renderedBusy = busy;
|
|
672
|
+
renderedPerm = permStateOf(p, check);
|
|
673
|
+
// 保存回声:所在行容器打 / 摘 data-kit-fresh(行类的 data-kit-fresh 变体画底色,摘掉时 transition-colors 淡出);
|
|
674
|
+
// 常规行里正被置顶的那条记录隐去(置顶行容器里的副本不隐),不出现两份。只改行容器属性、不动本组件内容,放在签名跳过之前
|
|
675
|
+
const echo = rowEchoState(p, root);
|
|
676
|
+
renderedEcho = echo;
|
|
677
|
+
const echoRow = p.look === 'button' ? null : root.closest<HTMLElement>(FRESH_ROW_SELECTOR);
|
|
678
|
+
if (echoRow) {
|
|
679
|
+
if (echo.includes('f')) echoRow.setAttribute(KIT_ROW_FRESH_ATTR, '');
|
|
680
|
+
else echoRow.removeAttribute(KIT_ROW_FRESH_ATTR);
|
|
681
|
+
// 隐去挂在数据项最外层(展开行外壳 / 行容器本身),与模板克隆的单位一致
|
|
682
|
+
const item = echoRow.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`) ?? echoRow;
|
|
683
|
+
// 只撤销自己加的 hidden(data-kit-pinned-hidden 记着),不碰别的显隐来源;用 toggleKitHidden 防止 flex/grid 覆盖 [hidden]
|
|
684
|
+
if (echo.includes('h')) {
|
|
685
|
+
toggleKitHidden(item, true);
|
|
686
|
+
item.setAttribute(KIT_ATTR_PINNED_HIDDEN, '');
|
|
687
|
+
} else if (item.hasAttribute(KIT_ATTR_PINNED_HIDDEN)) {
|
|
688
|
+
toggleKitHidden(item, false);
|
|
689
|
+
item.removeAttribute(KIT_ATTR_PINNED_HIDDEN);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
473
692
|
// 批量条出现期间(表格有批量动作且已有选中行)行内操作整体禁用:批量条替换了工具条,此时单行操作不与批量操作并行(排布规则:选中期间行内操作禁用);勾选框不受影响
|
|
474
693
|
const locked = p.bulkLock === true && Array.isArray(p.selected) && p.selected.length > 0;
|
|
475
694
|
// 跳过判定的签名 = props(已选集合只并入「本行是否被选中」)+ 渲染另外读取的 DOM / 权限输入:
|
|
@@ -479,19 +698,21 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
479
698
|
try {
|
|
480
699
|
const rest: Record<string, unknown> = { ...p };
|
|
481
700
|
delete rest.selected;
|
|
701
|
+
delete rest.picked;
|
|
482
702
|
const keyF = str(p.keyField);
|
|
483
703
|
const selState = Array.isArray(p.selected) ? (p.selected.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0) : -1;
|
|
484
|
-
const
|
|
485
|
-
|
|
704
|
+
const pickedRows = selectedRowsOf(p.picked);
|
|
705
|
+
const pickState = pickedRows === null ? -1 : (pickedRows.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0);
|
|
706
|
+
return JSON.stringify([rest, selState, pickState, renderedPerm]) + (busy ? '|busy' : '') + (locked ? '|lock' : '');
|
|
486
707
|
} catch {
|
|
487
708
|
return null; // 含环等不可序列化:不跳过
|
|
488
709
|
}
|
|
489
710
|
})();
|
|
490
711
|
const sigOf = (): string | null => {
|
|
491
712
|
if (propsPart === null) return null;
|
|
492
|
-
const expandRow = root.closest<HTMLElement>(
|
|
493
|
-
const expandBody = expandRow?.querySelector<HTMLElement>(
|
|
494
|
-
return propsPart + JSON.stringify([elementId(root.closest(
|
|
713
|
+
const expandRow = root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`);
|
|
714
|
+
const expandBody = expandRow?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
715
|
+
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]);
|
|
495
716
|
};
|
|
496
717
|
// 无 expandHost 的展开钮读的是 DOM 上详情体当前显隐(不在 props 里),不能凭签名跳过
|
|
497
718
|
const domDriven = (p.expand === true || p.expand === 'true') && str(p.expandHost) === '';
|
|
@@ -504,31 +725,35 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
504
725
|
};
|
|
505
726
|
// 必须重绘:记下焦点所在的勾选框 / 动作钮,重绘后还给同值元素
|
|
506
727
|
const activeEl = root.ownerDocument.activeElement;
|
|
507
|
-
const focusedIn = activeEl && root.contains(activeEl) ? activeEl.closest<HTMLElement>(
|
|
728
|
+
const focusedIn = activeEl && root.contains(activeEl) ? activeEl.closest<HTMLElement>(`[${KIT_ATTR_SEL}], [${KIT_ATTR_ACT}]`) : null;
|
|
508
729
|
const focusKey = focusedIn
|
|
509
|
-
? focusedIn.hasAttribute(
|
|
730
|
+
? 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) ?? '' }
|
|
510
731
|
: null;
|
|
511
732
|
try {
|
|
512
733
|
moreMenu?.destroy();
|
|
513
734
|
moreMenu = null;
|
|
514
735
|
// 旧按钮的原因气泡可能正挂在浮层根里:整片重画前先摘(锚点随旧树丢弃)
|
|
515
736
|
releaseReasonTipsIn(root);
|
|
516
|
-
|
|
737
|
+
// 动作级判定(props.kit.actions[动作id],emit 侧汇总后生效):语气为危险的按危险档画(不占主色、置末进「更多」);
|
|
738
|
+
// 没有判定时按原来的 tone / function 推档
|
|
739
|
+
const items = itemsOf(p.actions).map((item) => (kitActionPropsOf(p, item.id).tone === 'danger' && item.tone !== 'danger' ? { ...item, tone: 'danger' as const } : item));
|
|
517
740
|
const asButton = p.look === 'button';
|
|
518
|
-
|
|
741
|
+
const splitMore = !asButton && p.splitMoreColumn === true;
|
|
742
|
+
root.className = splitMore ? 'contents' : joinClass(asButton ? HEAD_ROOT_CLASS : ROOT_CLASS, p.class);
|
|
519
743
|
root.replaceChildren();
|
|
520
744
|
if (busy) root.setAttribute('aria-busy', 'true');
|
|
521
745
|
else root.removeAttribute('aria-busy');
|
|
522
746
|
if (p.expand === true || p.expand === 'true') {
|
|
523
747
|
const btn = root.ownerDocument.createElement('button');
|
|
524
748
|
btn.setAttribute('type', 'button');
|
|
525
|
-
btn.setAttribute(
|
|
749
|
+
btn.setAttribute(KIT_ATTR_EXPAND, '');
|
|
750
|
+
kitMarkPart(btn, 'action');
|
|
526
751
|
// list 形(展开子表):本行是否展开 = expandId 等于本行主键;展开则把页面级子表承载壳挪进详情体,否则(若在本行里)挪回
|
|
527
752
|
const host = str(p.expandHost);
|
|
528
753
|
if (host !== '') {
|
|
529
754
|
const mine = expandKeyOf(p.row, str(p.keyField));
|
|
530
755
|
const open = mine !== '' && str(p.expandId) === mine;
|
|
531
|
-
const bodyOuter = root.closest<HTMLElement>(
|
|
756
|
+
const bodyOuter = root.closest<HTMLElement>(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector<HTMLElement>(`[${KIT_ATTR_EXPAND_BODY}]`) ?? null;
|
|
532
757
|
const target = (bodyOuter?.firstElementChild as HTMLElement | null) ?? bodyOuter;
|
|
533
758
|
if (target !== null) {
|
|
534
759
|
if (open) moveExpandChild(root.ownerDocument, host, target);
|
|
@@ -537,7 +762,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
537
762
|
bodyOuter?.classList.toggle('hidden', !open);
|
|
538
763
|
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
539
764
|
} else {
|
|
540
|
-
btn.setAttribute('aria-expanded', root.closest(
|
|
765
|
+
btn.setAttribute('aria-expanded', root.closest(`[${KIT_ATTR_EXPAND_ROW}]`)?.querySelector(`[${KIT_ATTR_EXPAND_BODY}]:not(.hidden)`) ? 'true' : 'false');
|
|
541
766
|
}
|
|
542
767
|
btn.className = EXPAND_BUTTON_CLASS;
|
|
543
768
|
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));
|
|
@@ -546,7 +771,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
546
771
|
return;
|
|
547
772
|
}
|
|
548
773
|
// 行样式档位:先摘掉上次加的档位类,再按本行当前档位重加(类串来自语法真源闭集,已进候选类)
|
|
549
|
-
const toneRow = root.closest<HTMLElement>(
|
|
774
|
+
const toneRow = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
550
775
|
if (toneRow) {
|
|
551
776
|
// 两张档位表(行底色 / 条目描边)的类串都摘,换档位集或换档位都不残留
|
|
552
777
|
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 !== ''));
|
|
@@ -555,7 +780,7 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
555
780
|
}
|
|
556
781
|
// 整行可点(pickOnRow):行本身进 Tab 序并有焦点环,Enter 触发(键盘等价于点行)
|
|
557
782
|
if (p.pickOnRow === true || p.pickOnRow === 'true') {
|
|
558
|
-
const pickRow = root.closest<HTMLElement>(
|
|
783
|
+
const pickRow = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
559
784
|
if (pickRow && !FOCUSABLE_ROWS.has(pickRow)) {
|
|
560
785
|
FOCUSABLE_ROWS.add(pickRow);
|
|
561
786
|
pickRow.setAttribute('tabindex', '0');
|
|
@@ -569,16 +794,22 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
569
794
|
// 选中行高亮:给所在行容器(data-kit-row)标 data-kit-selected,行类里的 data-kit-selected 变体生效(静态类,不拼类名);
|
|
570
795
|
// 表格是无 role 的 div,不写 aria-selected(它只在 grid / treegrid 的 row 上合法);已选语义由勾选列 checkbox / radio 承担。
|
|
571
796
|
// 勾选列实例与 pickOnRow 实例都读同一份已选行镜像,结论一致
|
|
572
|
-
|
|
573
|
-
|
|
797
|
+
// 给了 picked(当前打开项)时高亮只看它;没给按已选集合(勾选态 picked 变量仍只看已选集合)
|
|
798
|
+
const openRows = selectedRowsOf(p.picked);
|
|
799
|
+
const highlightRows = openRows !== null ? openRows : selectedRows;
|
|
800
|
+
const highlighted = highlightRows !== null && highlightRows.some((r) => rowKeyOf(r, keyField) === rowKeyOf(p.row, keyField));
|
|
801
|
+
if (highlightRows !== null) {
|
|
802
|
+
const rowEl = root.closest<HTMLElement>(`[${KIT_ATTR_ROW}]`);
|
|
574
803
|
if (rowEl) {
|
|
575
|
-
if (
|
|
576
|
-
else rowEl.removeAttribute(
|
|
804
|
+
if (highlighted) rowEl.setAttribute(KIT_ATTR_SELECTED, '');
|
|
805
|
+
else rowEl.removeAttribute(KIT_ATTR_SELECTED);
|
|
806
|
+
// 交互状态自报「选中」;行是无 role 的 div,aria 不写(理由同上)
|
|
807
|
+
kitMarkPicked(rowEl, 'selected', highlighted, null);
|
|
577
808
|
}
|
|
578
809
|
}
|
|
579
810
|
if (mode === 'single' || mode === 'multi') {
|
|
580
811
|
const box = createCheck(root.ownerDocument, mode === 'single' ? 'radio' : 'checkbox', { checked: picked, ...(busy ? { disabled: true } : {}) });
|
|
581
|
-
box.setAttribute(
|
|
812
|
+
box.setAttribute(KIT_ATTR_SEL, '');
|
|
582
813
|
// 可访问名带行主键,读屏用户能分清是哪一行;没有主键字段时退回通用文案
|
|
583
814
|
const keyVal = keyField !== '' ? rowKeyOf(p.row, keyField) : '';
|
|
584
815
|
setMarkLabel(box, keyVal !== '' ? kitText('soma.kit.select_row_of', { key: keyVal }, root) : kitText('soma.kit.select_this_row', undefined, root));
|
|
@@ -593,10 +824,14 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
593
824
|
const unexplained = st.disabled === true && disabledReasonOf(p.actionState, item) === '';
|
|
594
825
|
return !(item.permission !== undefined && check !== null && !check(item.permission)) && !st.hidden && !unexplained;
|
|
595
826
|
});
|
|
596
|
-
const
|
|
597
|
-
const
|
|
827
|
+
const isAllInline = p.maxInline === 'all';
|
|
828
|
+
const explicitMaxInline = p.maxInline !== undefined && p.maxInline !== null && p.maxInline !== '';
|
|
829
|
+
const maxRaw = isAllInline ? Infinity : Number(p.maxInline);
|
|
830
|
+
const maxInline = isAllInline ? Infinity : (Number.isFinite(maxRaw) && maxRaw >= 1 ? Math.floor(maxRaw) : DEFAULT_MAX_INLINE);
|
|
831
|
+
const nonMoreCount = shown.filter((i) => i.more !== true).length;
|
|
832
|
+
const keepDangerInline = isAllInline || p.keepDangerInline === true || (explicitMaxInline && maxInline >= nonMoreCount);
|
|
598
833
|
if (offEdge === null) {
|
|
599
|
-
const wrap = root.closest<HTMLElement>(
|
|
834
|
+
const wrap = root.closest<HTMLElement>(`[${KIT_ATTR_PART}="table"]`);
|
|
600
835
|
if (wrap !== null) offEdge = watchEndEdge(wrap);
|
|
601
836
|
}
|
|
602
837
|
renderedInTable = inTableOf(root);
|
|
@@ -607,28 +842,90 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
607
842
|
};
|
|
608
843
|
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(recheck); else queueMicrotask(recheck);
|
|
609
844
|
// 宽档切分:前 maxInline 个行内,其余并入「更多」。窄档保留者(primary 优先,上限取 design maxInline.narrow)取自宽档行内项,其余行内项标次要
|
|
610
|
-
const { inline, folded, separated } = splitRowActions(shown, maxInline, false);
|
|
611
|
-
const inCompact = !asButton && !renderedInTable && root.closest(
|
|
845
|
+
const { inline, folded, separated } = splitRowActions(shown, maxInline, false, keepDangerInline);
|
|
846
|
+
const inCompact = !asButton && !renderedInTable && root.closest(`[${KIT_ATTR_COMPACT}]`) !== null;
|
|
612
847
|
// 详情头按钮组(look: button)也按容器窄档收起次要项:查询容器是详情头(biz/master-sub/shell detailHead 带 @container),
|
|
613
848
|
// 窄于窄档线时只留主动作 +「更多」,次要按钮进菜单——不再整组换行后仍向右溢出被裁(look6 mcp 接口配置 @320)
|
|
614
|
-
|
|
849
|
+
// maxInline === 'all' 时显式要求全量行内展示,不在窄档生成隐藏的「…」触发钮
|
|
850
|
+
const narrowKeep = isAllInline
|
|
851
|
+
? new Set(inline)
|
|
852
|
+
: (asButton || renderedInTable || inCompact ? new Set(splitRowActions(inline, maxInline, true).inline) : new Set(inline));
|
|
615
853
|
const secondary = inline.filter((i) => !narrowKeep.has(i));
|
|
616
854
|
const secondaryButtons = new Map<string, HTMLButtonElement>();
|
|
617
855
|
const ranks = rowActionRanks(inline);
|
|
618
|
-
|
|
619
|
-
|
|
856
|
+
const headRanks = asButton ? headActionRanks(inline, kitHasActionProps(p) ? (id) => kitActionPropsOf(p, id).solid === true : undefined) : [];
|
|
857
|
+
const doc = root.ownerDocument;
|
|
858
|
+
const allowInline = p.slot !== 'more' && p.onlyMore !== true;
|
|
859
|
+
const allowMore = p.slot !== 'inline' && p.hideMore !== true;
|
|
860
|
+
let inlineHost: HTMLElement = root;
|
|
861
|
+
let moreHost: HTMLElement = root;
|
|
862
|
+
let splitInlineCell: HTMLElement | null = null;
|
|
863
|
+
let splitMoreCell: HTMLElement | null = null;
|
|
864
|
+
if (splitMore) {
|
|
865
|
+
const role = str(p.cellRole);
|
|
866
|
+
splitInlineCell = doc.createElement('div');
|
|
867
|
+
if (role !== '') splitInlineCell.setAttribute('role', role);
|
|
868
|
+
splitInlineCell.setAttribute(KIT_ATTR_PART, KIT_PART_TABLE_CELL);
|
|
869
|
+
splitInlineCell.setAttribute(KIT_OPS_CELL_ATTR, '');
|
|
870
|
+
splitInlineCell.className = str(p.inlineCellClass);
|
|
871
|
+
const innerWrap = doc.createElement('div');
|
|
872
|
+
innerWrap.className = joinClass(ROOT_CLASS, p.class);
|
|
873
|
+
splitInlineCell.appendChild(innerWrap);
|
|
874
|
+
inlineHost = innerWrap;
|
|
875
|
+
splitMoreCell = doc.createElement('div');
|
|
876
|
+
if (role !== '') splitMoreCell.setAttribute('role', role);
|
|
877
|
+
splitMoreCell.setAttribute(KIT_ATTR_PART, KIT_PART_TABLE_CELL);
|
|
878
|
+
splitMoreCell.setAttribute(KIT_OPS_CELL_ATTR, '');
|
|
879
|
+
splitMoreCell.className = str(p.moreCellClass);
|
|
880
|
+
moreHost = splitMoreCell;
|
|
881
|
+
root.append(splitInlineCell, splitMoreCell);
|
|
882
|
+
}
|
|
883
|
+
const appendActionIcon = (parent: HTMLElement, icon: string): void => {
|
|
884
|
+
const iconName = resolveKitIconName(icon);
|
|
885
|
+
if (iconName !== null) {
|
|
886
|
+
parent.appendChild(kitIcon(iconName, 'sm'));
|
|
887
|
+
} else {
|
|
888
|
+
const sym = doc.createElement('span');
|
|
889
|
+
sym.setAttribute('aria-hidden', 'true');
|
|
890
|
+
sym.textContent = icon;
|
|
891
|
+
parent.appendChild(sym);
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
if (allowInline) for (const [at, item] of inline.entries()) {
|
|
895
|
+
const btn = doc.createElement('button');
|
|
620
896
|
btn.setAttribute('type', 'button');
|
|
621
|
-
btn.setAttribute(
|
|
622
|
-
|
|
897
|
+
btn.setAttribute(KIT_ATTR_ACT, item.id);
|
|
898
|
+
// 行内动作 / 详情头动作的按钮:元素部件「动作」
|
|
899
|
+
kitMarkPart(btn, 'action');
|
|
900
|
+
const hasIcon = typeof item.icon === 'string' && item.icon !== '';
|
|
901
|
+
const isIconOnly = hasIcon && (item.iconOnly === true || item.name === '');
|
|
902
|
+
btn.className = asButton
|
|
903
|
+
? HEAD_BUTTON_CLASS[headRanks[at]!]
|
|
904
|
+
: isIconOnly
|
|
905
|
+
? ROW_ACTION_ICON_ONLY_BUTTON_CLASS[ranks[at]!]
|
|
906
|
+
: ROW_ACTION_BUTTON_CLASS[ranks[at]!];
|
|
907
|
+
if (asButton) setKitFace(btn, 'raised');
|
|
623
908
|
// 内联的危险动作置末并与前一项分隔:在项间距(gap-x-4)之外再加大一截(取值 kit-arrange#actionGroup.dangerSeparatorRem);按钮形态(详情头)按钮自带轮廓,不加
|
|
624
909
|
if (!asButton && separated.has(item.id)) btn.className = `${btn.className} ${DANGER_SEPARATOR_CLASS}`;
|
|
625
910
|
if (!narrowKeep.has(item)) {
|
|
626
|
-
btn.setAttribute(
|
|
911
|
+
btn.setAttribute(KIT_ATTR_ACT_SECONDARY, '');
|
|
627
912
|
btn.className = `${btn.className} ${inCompact ? COMPACT_SECONDARY_CLASS : ROW_ACTION_SECONDARY_CLASS}`;
|
|
628
913
|
secondaryButtons.set(item.id, btn);
|
|
629
914
|
}
|
|
630
|
-
// 文字链接形态:无面(不标 raised
|
|
631
|
-
|
|
915
|
+
// 文字链接形态:无面(不标 raised);支持纯文字 / 仅图标 / 图标+文字三种渲染形态
|
|
916
|
+
if (isIconOnly) {
|
|
917
|
+
const label = item.name !== '' ? item.name : item.id;
|
|
918
|
+
btn.setAttribute('aria-label', label);
|
|
919
|
+
btn.setAttribute('title', label);
|
|
920
|
+
appendActionIcon(btn, item.icon!);
|
|
921
|
+
} else if (hasIcon) {
|
|
922
|
+
appendActionIcon(btn, item.icon!);
|
|
923
|
+
const labelSpan = doc.createElement('span');
|
|
924
|
+
labelSpan.textContent = item.name;
|
|
925
|
+
btn.appendChild(labelSpan);
|
|
926
|
+
} else {
|
|
927
|
+
btn.textContent = item.name;
|
|
928
|
+
}
|
|
632
929
|
// 置灰原因(动作置灰且原因非空,本行没在删除在途):不用原生 disabled,只留 aria-disabled 保持可聚焦,原因经气泡 + aria-describedby 给出;点击由 onClick 的置灰判断拦下
|
|
633
930
|
const reason = busy || locked ? '' : disabledReasonOf(p.actionState, item);
|
|
634
931
|
if (reason !== '') {
|
|
@@ -639,21 +936,22 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
639
936
|
btn.disabled = true;
|
|
640
937
|
btn.setAttribute('aria-disabled', 'true');
|
|
641
938
|
}
|
|
642
|
-
|
|
939
|
+
inlineHost.appendChild(btn);
|
|
643
940
|
if (reason !== '') syncReasonTip(btn, reason);
|
|
644
941
|
}
|
|
645
|
-
if (folded.length > 0 || secondary.length > 0) {
|
|
646
|
-
const doc = root.ownerDocument;
|
|
942
|
+
if (allowMore && (folded.length > 0 || secondary.length > 0)) {
|
|
647
943
|
const wrap = doc.createElement('div');
|
|
648
944
|
// 没有常驻折叠项(宽档全部行内)时触发器只在窄档出现;有常驻折叠项时恒显示
|
|
649
945
|
wrap.className = folded.length > 0 ? MORE_ROOT_CLASS : inCompact ? COMPACT_MORE_ROOT_NARROW_ONLY_CLASS : MORE_ROOT_NARROW_ONLY_CLASS;
|
|
650
|
-
wrap.setAttribute(
|
|
946
|
+
wrap.setAttribute(KIT_ATTR_MORE_ROOT, folded.length > 0 ? '' : 'narrow');
|
|
651
947
|
const trigger = doc.createElement('button');
|
|
652
948
|
trigger.setAttribute('type', 'button');
|
|
653
949
|
trigger.setAttribute('aria-haspopup', 'menu');
|
|
654
950
|
trigger.setAttribute('aria-label', kitText('soma.kit.more_actions', undefined, root));
|
|
655
951
|
trigger.className = asButton ? HEAD_MORE_TRIGGER_CLASS : MORE_TRIGGER_CLASS;
|
|
656
|
-
trigger
|
|
952
|
+
if (asButton) setKitFace(trigger, 'raised');
|
|
953
|
+
trigger.setAttribute(KIT_ATTR_MORE, '');
|
|
954
|
+
kitMarkPart(trigger, 'action');
|
|
657
955
|
const win = doc.defaultView;
|
|
658
956
|
const menuEntries = (): KitTableActionItem[] => {
|
|
659
957
|
const hiddenSecondary = secondary.filter((i) => {
|
|
@@ -662,12 +960,18 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
662
960
|
});
|
|
663
961
|
return [...hiddenSecondary, ...folded.filter((i) => i.more !== true), ...folded.filter((i) => i.more === true)];
|
|
664
962
|
};
|
|
665
|
-
|
|
666
|
-
|
|
963
|
+
if (asButton) {
|
|
964
|
+
trigger.textContent = kitText('soma.kit.more_menu', undefined, root);
|
|
965
|
+
trigger.appendChild(kitIcon('chevron-down', 'sm'));
|
|
966
|
+
} else {
|
|
967
|
+
// 行内溢出动作各档只出「…」图标钮(§11.17 成套对齐「行内动作」2026-11-26 裁决):可访问名 = 「更多操作」,同一句进悬停 / 聚焦提示(表壳是提示作用域)
|
|
968
|
+
trigger.appendChild(kitIcon('more', 'sm'));
|
|
969
|
+
trigger.setAttribute(KIT_TIP_ATTR, kitText('soma.kit.more_actions', undefined, root));
|
|
970
|
+
}
|
|
667
971
|
const menu = doc.createElement('div');
|
|
668
972
|
menu.className = 'hidden';
|
|
669
973
|
wrap.append(trigger, menu);
|
|
670
|
-
|
|
974
|
+
moreHost.appendChild(wrap);
|
|
671
975
|
// 本行删除在途 / 批量条出现期间:「更多」触发钮置灰,菜单不接线(打不开)
|
|
672
976
|
if (busy || locked) {
|
|
673
977
|
trigger.disabled = true;
|
|
@@ -685,21 +989,36 @@ export function createKitTableActions(): SomaComponentDefinition {
|
|
|
685
989
|
// 置灰项的原因作为该项的描述文字(可见的第二段文字 + aria-describedby),菜单项本身是 aria-disabled 的 div,读屏可取到
|
|
686
990
|
// 菜单内容在打开 / 取项时现算:常驻折叠项 + 当前被容器查询隐藏的次要行内项(display:none 即不可见),次序 = 隐藏的次要项(声明序)→ 常驻折叠的普通项 → more:true 项
|
|
687
991
|
// 危险项置末并与前面的项以分隔线隔开(动作组统一规则,menuOrderDangerLast)
|
|
688
|
-
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) }))),
|
|
992
|
+
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) }))),
|
|
689
993
|
locked: () => false,
|
|
690
994
|
onPick: (picked) => {
|
|
691
995
|
const hit = menuEntries().find((i) => i.id === picked.key);
|
|
692
996
|
if (hit) {
|
|
693
|
-
lastActed = { attr:
|
|
694
|
-
|
|
997
|
+
lastActed = { attr: KIT_ATTR_MORE, val: '' };
|
|
998
|
+
// 菜单项选中后菜单已关,确认锚在「更多」的触发钮上
|
|
999
|
+
rowConfirm.guard(api.props(), hit.id, trigger, hit.name || hit.id, () => emitRowAction(api, hit, items.findIndex((a) => a.id === hit.id)));
|
|
695
1000
|
}
|
|
696
1001
|
},
|
|
697
1002
|
});
|
|
698
1003
|
}
|
|
1004
|
+
// 空操作列收列(KT-P-list):本行可见动作数为 0(权限全拒 / 行级 hidden / 不可用)在所在操作格上记一笔,交整表汇总
|
|
1005
|
+
if (splitInlineCell !== null && splitMoreCell !== null) {
|
|
1006
|
+
const isEmpty = shown.length === 0 && mode === 'none';
|
|
1007
|
+
splitInlineCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, isEmpty);
|
|
1008
|
+
splitMoreCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, isEmpty);
|
|
1009
|
+
scheduleOpsColumnSync(splitInlineCell);
|
|
1010
|
+
} else {
|
|
1011
|
+
const opsCell = asButton ? null : root.closest<HTMLElement>(`[${KIT_OPS_CELL_ATTR}]`);
|
|
1012
|
+
if (opsCell !== null) {
|
|
1013
|
+
opsCell.toggleAttribute(KIT_OPS_EMPTY_ATTR, shown.length === 0 && mode === 'none');
|
|
1014
|
+
scheduleOpsColumnSync(opsCell);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
699
1017
|
commit();
|
|
700
1018
|
} catch (error) {
|
|
701
1019
|
lastSig = null;
|
|
702
1020
|
lastRoot = null;
|
|
1021
|
+
renderedPerm = '';
|
|
703
1022
|
throw error;
|
|
704
1023
|
} finally {
|
|
705
1024
|
if (focusKey !== null) {
|