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
package/src/data/virtual-rows.ts
CHANGED
|
@@ -20,13 +20,17 @@
|
|
|
20
20
|
// 窗口起点向下取偶数,保证斑马纹(nth-child 的 even)的奇偶不随窗口位置翻转。
|
|
21
21
|
// 卸载:摘事件、释放虚拟化器(观察者随之清掉)。
|
|
22
22
|
|
|
23
|
+
import { kitApplyLevelClass } from './level-class';
|
|
23
24
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
25
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
24
26
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
25
27
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
26
28
|
import { DOT_CORE, DOT_ROOT, DOT_TEXT, DOT_WRAP, TAG_CLASS } from '../base/tag';
|
|
27
|
-
import {
|
|
29
|
+
import { KIT_CELL_VALUE_CLASS_CANDIDATES, kitCellValueNode, kitCellValuePlan, type KitCellValuePlan } from './cell-value';
|
|
30
|
+
import { kitRowKey } from '../shared/row-key';
|
|
31
|
+
import { permissionCheckerOf, registerLivePermissionGate } from '../base/permission-gate';
|
|
28
32
|
import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, markChecked, paintCheck, setMarkLabel } from '../base/check-core';
|
|
29
|
-
import { CLASS_PROP, bool, createKitController,
|
|
33
|
+
import { CLASS_PROP, bool, createKitController, joinClass, str } from '../base/shared';
|
|
30
34
|
import { kitLocaleAt } from '../i18n/kit-text';
|
|
31
35
|
import {
|
|
32
36
|
KIT_VIRTUAL_CLASS_CANDIDATES, KIT_VIRTUAL_LABELS, KIT_VIRTUAL_ROW_CLASS, virtualRowPx,
|
|
@@ -39,12 +43,22 @@ import type { KitTableDensity } from '../object-renderer/defaults';
|
|
|
39
43
|
import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
|
|
40
44
|
import { KIT_PART_TABLE_ROW } from '../recipes/table-row';
|
|
41
45
|
import { kitStripBoundaryClasses } from '../recipes/divider';
|
|
46
|
+
import {
|
|
47
|
+
KIT_ATTR_ACT, KIT_ATTR_COL, KIT_ATTR_DENSE, KIT_ATTR_EDIT_CONTROL, KIT_ATTR_EDITABLE, KIT_ATTR_ELLIPSIS, KIT_ATTR_INDEX,
|
|
48
|
+
KIT_ATTR_KEY, KIT_ATTR_MARK, KIT_ATTR_PART, KIT_ATTR_ROOMY, KIT_ATTR_ROW, KIT_ATTR_ROWS, KIT_ATTR_SEL, KIT_ATTR_SELECTED, KIT_ATTR_TABLE,
|
|
49
|
+
KIT_ATTR_VSCROLL, kitAttrSel,
|
|
50
|
+
} from '../shared/dom-attrs';
|
|
51
|
+
import {
|
|
52
|
+
kitActionPropsOf, kitFieldPropsOf, kitHasOwnOverflow, kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked, kitMergeAlignOverflow,
|
|
53
|
+
} from './kit-contract';
|
|
54
|
+
import { createKitRowConfirm } from './row-confirm';
|
|
42
55
|
|
|
43
56
|
const ROOT_CLASS = 'flex flex-col focus-visible:outline-none';
|
|
44
57
|
const SPACER_CLASS = 'w-full';
|
|
45
58
|
const TEXT_CLASS = 'block min-w-0 truncate text-sm text-fg';
|
|
59
|
+
const TEXT_BASE_CLASS = 'block min-w-0 text-sm text-fg';
|
|
46
60
|
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
47
|
-
const ROW_FOCUS_CLASS = 'scroll-mt-10
|
|
61
|
+
const ROW_FOCUS_CLASS = 'scroll-mt-10 ' + KIT_FOCUS_RING.item;
|
|
48
62
|
const ROW_PICK_CLASS = 'cursor-pointer';
|
|
49
63
|
|
|
50
64
|
export const KIT_VIRTUAL_ROWS_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
@@ -54,6 +68,7 @@ export const KIT_VIRTUAL_ROWS_CLASS_CANDIDATES: readonly string[] = Object.freez
|
|
|
54
68
|
...Object.values(TAG_CLASS.md),
|
|
55
69
|
DOT_ROOT.md, DOT_WRAP.md, ...Object.values(DOT_TEXT), ...Object.values(DOT_CORE),
|
|
56
70
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
71
|
+
...KIT_CELL_VALUE_CLASS_CANDIDATES,
|
|
57
72
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
58
73
|
|
|
59
74
|
type Rec = Record<string, unknown>;
|
|
@@ -113,12 +128,6 @@ function stripBorderClasses(cls: string): string {
|
|
|
113
128
|
return kitStripBoundaryClasses(cls);
|
|
114
129
|
}
|
|
115
130
|
|
|
116
|
-
function rowKeyOf(row: unknown, keyField: string): string {
|
|
117
|
-
if (!isRec(row)) return '';
|
|
118
|
-
const v = row[keyField];
|
|
119
|
-
return keyField !== '' && v !== undefined && v !== null ? String(v) : JSON.stringify(row);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
131
|
/** 文本里的 {n} 占位 */
|
|
123
132
|
function fill(template: string, n: number): string {
|
|
124
133
|
return template.replace('{n}', String(n));
|
|
@@ -182,14 +191,23 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
182
191
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
183
192
|
controllerFactory: createKitController((api) => {
|
|
184
193
|
const P = (): Rec => api.props();
|
|
185
|
-
|
|
194
|
+
let renderedPerm = '';
|
|
195
|
+
const permStateOf = (p: Rec): string => {
|
|
196
|
+
const list = actionsOf(p.actions);
|
|
197
|
+
if (!list.some((a) => a.permission !== '')) return '';
|
|
198
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
199
|
+
return list.map((a) => (a.permission !== '' && check !== null ? (check(a.permission) ? '1' : '0') : '-')).join('');
|
|
200
|
+
};
|
|
186
201
|
let root: HTMLElement | null = null;
|
|
187
202
|
let top: HTMLElement | null = null;
|
|
188
203
|
let bottom: HTMLElement | null = null;
|
|
189
204
|
let win: VirtualWindow | null = null;
|
|
190
205
|
let rows: Rec[] = [];
|
|
191
206
|
let rowsRef: unknown = null;
|
|
192
|
-
let
|
|
207
|
+
let schemaSig = '';
|
|
208
|
+
let windowSig = '';
|
|
209
|
+
let selectedSet = new Set<string>();
|
|
210
|
+
let selectedKeyField = '';
|
|
193
211
|
let cursor = 0;
|
|
194
212
|
let pendingFocus: number | null = null;
|
|
195
213
|
let offs: Array<() => void> = [];
|
|
@@ -205,7 +223,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
205
223
|
};
|
|
206
224
|
/** 承载 aria-rowcount / colcount 的 grid:外壳内层,没有就是根自己 */
|
|
207
225
|
const gridEl = (): HTMLElement => (root?.parentElement?.closest<HTMLElement>('[role="grid"]') ?? root ?? api.host);
|
|
208
|
-
const scroller = (): HTMLElement | null => api.host.closest<HTMLElement>(
|
|
226
|
+
const scroller = (): HTMLElement | null => api.host.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VSCROLL));
|
|
209
227
|
const cells = (): CellDef[] => cellsOf(P().cells);
|
|
210
228
|
const mode = (): string => str(P().select, 'none');
|
|
211
229
|
/**
|
|
@@ -214,17 +232,17 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
214
232
|
*/
|
|
215
233
|
const densityNow = (): KitTableDensity => {
|
|
216
234
|
const sc = scroller();
|
|
217
|
-
if (sc !== null && sc.hasAttribute(
|
|
218
|
-
return sc.hasAttribute(
|
|
235
|
+
if (sc !== null && sc.hasAttribute(KIT_ATTR_TABLE)) {
|
|
236
|
+
return sc.hasAttribute(KIT_ATTR_DENSE) ? 'compact' : sc.hasAttribute(KIT_ATTR_ROOMY) ? 'spacious' : 'standard';
|
|
219
237
|
}
|
|
220
|
-
return '
|
|
238
|
+
return 'standard';
|
|
221
239
|
};
|
|
222
240
|
/** 有效行高档:rowHeight 是标准密度的档位,紧凑下移一档、宽松上移一档(夹在 sm..lg 内) */
|
|
223
241
|
const tier = (): KitRowTier => {
|
|
224
242
|
const base = rowTierOf(P().rowHeight);
|
|
225
243
|
const at = KIT_ROW_TIERS.indexOf(base);
|
|
226
244
|
const d = densityNow();
|
|
227
|
-
const shifted = d === '
|
|
245
|
+
const shifted = d === 'compact' ? at - 1 : d === 'spacious' ? at + 1 : at;
|
|
228
246
|
return KIT_ROW_TIERS[Math.max(0, Math.min(KIT_ROW_TIERS.length - 1, shifted))]!;
|
|
229
247
|
};
|
|
230
248
|
let appliedTier: KitRowTier | null = null;
|
|
@@ -249,15 +267,21 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
249
267
|
observedScroller = sc;
|
|
250
268
|
if (sc !== null && typeof MutationObserver === 'function') {
|
|
251
269
|
densityObserver = new MutationObserver(() => syncTier());
|
|
252
|
-
densityObserver.observe(sc, { attributes: true, attributeFilter: [
|
|
270
|
+
densityObserver.observe(sc, { attributes: true, attributeFilter: [KIT_ATTR_DENSE, KIT_ATTR_ROOMY] });
|
|
253
271
|
}
|
|
254
272
|
};
|
|
255
273
|
|
|
256
|
-
const
|
|
274
|
+
const rebuildSelectedSet = (): void => {
|
|
257
275
|
const sel = P().selected;
|
|
258
276
|
const kf = str(P().keyField);
|
|
259
|
-
|
|
277
|
+
selectedKeyField = kf;
|
|
278
|
+
if (!Array.isArray(sel) || sel.length === 0) {
|
|
279
|
+
selectedSet = new Set();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
selectedSet = new Set(sel.map((r) => kitRowKey(r, kf)));
|
|
260
283
|
};
|
|
284
|
+
const isPicked = (row: Rec): boolean => selectedSet.has(kitRowKey(row, selectedKeyField));
|
|
261
285
|
/** 本行删除在途:协调组件经忙闲通道登记(作用域 + 对象 + 行主键三段),与 KitTableActions 同一条规则 */
|
|
262
286
|
const rowBusy = (row: Rec): boolean => {
|
|
263
287
|
const p = P();
|
|
@@ -285,11 +309,11 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
285
309
|
const busy = rowBusy(row);
|
|
286
310
|
if (fresh ? !busy : (el.getAttribute('aria-busy') === 'true') === busy) return;
|
|
287
311
|
if (busy) el.setAttribute('aria-busy', 'true'); else el.removeAttribute('aria-busy');
|
|
288
|
-
for (const btn of Array.from(el.querySelectorAll<HTMLButtonElement>(
|
|
312
|
+
for (const btn of Array.from(el.querySelectorAll<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACT)))) {
|
|
289
313
|
btn.disabled = busy;
|
|
290
314
|
if (busy) btn.setAttribute('aria-disabled', 'true'); else btn.removeAttribute('aria-disabled');
|
|
291
315
|
}
|
|
292
|
-
const box = el.querySelector<HTMLElement>(
|
|
316
|
+
const box = el.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_SEL));
|
|
293
317
|
if (box) paintCheck(box, { checked: markChecked(box), disabled: busy });
|
|
294
318
|
};
|
|
295
319
|
const emitSelect = (row: Rec, checked: boolean): void => {
|
|
@@ -303,87 +327,143 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
303
327
|
api.emit('row_pick', { kit_action: 'select', id: 'select', name: '', builtin: 'select', target: '', row, ...objectPayload() });
|
|
304
328
|
};
|
|
305
329
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
330
|
+
interface PreparedCell {
|
|
331
|
+
readonly def: CellDef;
|
|
332
|
+
readonly cellClass: string;
|
|
333
|
+
/** 值呈现计划(与树表同一个函数 data/cell-value.ts:选项映射、格式、占位、分类色表、页面线判定) */
|
|
334
|
+
readonly value: KitCellValuePlan;
|
|
335
|
+
readonly textClass: string;
|
|
336
|
+
}
|
|
337
|
+
interface PreparedAction {
|
|
338
|
+
readonly id: string;
|
|
339
|
+
readonly name: string;
|
|
340
|
+
readonly btnClass: string;
|
|
341
|
+
}
|
|
342
|
+
interface RowRenderPlan {
|
|
343
|
+
readonly baseRowClass: string;
|
|
344
|
+
readonly toneField: string;
|
|
345
|
+
readonly mode: string;
|
|
346
|
+
readonly selectClass: string;
|
|
347
|
+
readonly cells: readonly PreparedCell[];
|
|
348
|
+
readonly hasActionsCol: boolean;
|
|
349
|
+
readonly actionsClass: string;
|
|
350
|
+
readonly actions: readonly PreparedAction[];
|
|
351
|
+
}
|
|
324
352
|
|
|
325
|
-
|
|
353
|
+
/** 单次 reconcile / 渲染批次的列与动作预计算计划:把 kitFieldPropsOf / kitActionPropsOf / optionsMapOf / kitLocaleAt / mergeClass 从 O(R·C) 行×列热循环提至 O(C) */
|
|
354
|
+
const createRowPlan = (): RowRenderPlan => {
|
|
326
355
|
const p = P();
|
|
327
|
-
const
|
|
328
|
-
const
|
|
356
|
+
const m = mode();
|
|
357
|
+
const borderless = p.bordered === false;
|
|
358
|
+
const baseRowClass = [
|
|
329
359
|
withoutPy(str(p.rowClass)), str(p.stripeClass), KIT_VIRTUAL_ROW_CLASS[tier()], 'items-center', ROW_FOCUS_CLASS,
|
|
330
360
|
bool(p.pickOnRow) ? ROW_PICK_CLASS : '',
|
|
331
|
-
// 行样式档位:行内容变了(含档位字段值变了)整行重建(见 syncRows 的签名),类串建行时现算,无旧档位残留
|
|
332
|
-
toneField === '' ? '' : rowToneClass(row[toneField]),
|
|
333
361
|
].filter((s) => s !== '').join(' ');
|
|
334
|
-
|
|
362
|
+
const rawSelect = m === 'single' || m === 'multi' ? withoutPy(str(p.selectClass)) : '';
|
|
363
|
+
const selectClass = borderless ? stripBorderClasses(rawSelect) : rawSelect;
|
|
364
|
+
const hostLocale = kitLocaleAt(api.host) || 'zh-CN';
|
|
365
|
+
const preparedCells: PreparedCell[] = [];
|
|
366
|
+
for (const col of cells()) {
|
|
367
|
+
const rawCell = withoutPy(col.cellClass);
|
|
368
|
+
const baseCellClass = borderless ? stripBorderClasses(rawCell) : rawCell;
|
|
369
|
+
const fk = kitFieldPropsOf(p, col.field);
|
|
370
|
+
const ownValOverflow = kitHasOwnOverflow(col.valueClass);
|
|
371
|
+
const ownCellOverflow = kitHasOwnOverflow(baseCellClass);
|
|
372
|
+
const cellClass = kitMergeAlignOverflow(baseCellClass, fk.align, ownValOverflow ? undefined : fk.overflow);
|
|
373
|
+
const textClass = ownValOverflow
|
|
374
|
+
? joinClass(TEXT_BASE_CLASS, col.valueClass)
|
|
375
|
+
: ownCellOverflow
|
|
376
|
+
? joinClass(/(?:^|\s)(?:[a-z0-9*@[\]=_/.-]+:)*truncate(?=\s|$)/.test(baseCellClass) ? TEXT_CLASS : TEXT_BASE_CLASS, col.valueClass)
|
|
377
|
+
: fk.overflow !== undefined && fk.overflow !== 'truncate' && fk.overflow !== 'middle'
|
|
378
|
+
? joinClass(kitMergeAlignOverflow(TEXT_BASE_CLASS, undefined, fk.overflow), col.valueClass)
|
|
379
|
+
: joinClass(TEXT_CLASS, col.valueClass);
|
|
380
|
+
preparedCells.push({
|
|
381
|
+
def: col,
|
|
382
|
+
cellClass,
|
|
383
|
+
value: kitCellValuePlan(col, fk, api.host, hostLocale),
|
|
384
|
+
textClass,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
const allActions = actionsOf(p.actions);
|
|
388
|
+
const hasActionsCol = allActions.length > 0;
|
|
389
|
+
const rawActionsClass = hasActionsCol ? withoutPy(str(p.actionsClass)) : '';
|
|
390
|
+
const actionsClass = borderless ? stripBorderClasses(rawActionsClass) : rawActionsClass;
|
|
391
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
392
|
+
const permitted = hasActionsCol
|
|
393
|
+
? allActions.filter((a) => (a.permission === '' || check === null || check(a.permission)))
|
|
394
|
+
: [];
|
|
395
|
+
const ranks = rowActionRanks(permitted);
|
|
396
|
+
const preparedActions: PreparedAction[] = permitted.map((a, at) => {
|
|
397
|
+
// 动作级判定的语义色调:只升不降——页面线判危险时升为危险档,否则保持动作自己的 tone 推的档(SCON-128 B4)
|
|
398
|
+
const rank = kitActionPropsOf(p, a.id).tone === 'danger' ? 'danger' : ranks[at]!;
|
|
399
|
+
return { id: a.id, name: a.name, btnClass: ROW_ACTION_BUTTON_CLASS[rank] };
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
baseRowClass,
|
|
403
|
+
toneField: str(p.rowToneField),
|
|
404
|
+
mode: m,
|
|
405
|
+
selectClass,
|
|
406
|
+
cells: preparedCells,
|
|
407
|
+
hasActionsCol,
|
|
408
|
+
actionsClass,
|
|
409
|
+
actions: preparedActions,
|
|
410
|
+
};
|
|
335
411
|
};
|
|
336
412
|
|
|
337
|
-
|
|
338
|
-
|
|
413
|
+
/** 单元格内容:与树表同一个函数(data/cell-value.ts),走预计算的选项 O(1) 映射;表体没有复制钮的事件接线,copyable 按缺省正文画 */
|
|
414
|
+
const cellContent = (cell: PreparedCell, row: Rec): HTMLElement =>
|
|
415
|
+
kitCellValueNode({ doc: doc(), host: api.host, copy: false }, cell.value, row[cell.def.field], cell.textClass);
|
|
416
|
+
|
|
417
|
+
const buildRow = (index: number, plan: RowRenderPlan): HTMLElement => {
|
|
339
418
|
const row = rows[index] ?? {};
|
|
340
|
-
const
|
|
419
|
+
const toneCls = plan.toneField === '' ? '' : rowToneClass(row[plan.toneField]);
|
|
420
|
+
const rowCls = toneCls === '' ? plan.baseRowClass : (plan.baseRowClass === '' ? toneCls : `${plan.baseRowClass} ${toneCls}`);
|
|
421
|
+
const el = mk('div', rowCls);
|
|
341
422
|
el.setAttribute('role', 'row');
|
|
342
423
|
el.setAttribute('aria-rowindex', String(index + 2));
|
|
343
|
-
el.setAttribute(
|
|
344
|
-
|
|
345
|
-
el
|
|
346
|
-
el.setAttribute('
|
|
424
|
+
el.setAttribute(KIT_ATTR_PART, KIT_PART_TABLE_ROW);
|
|
425
|
+
// 行 = 条目;部件位已被存量 table-row 占用(虚拟行定高的结构规则按它命中),kitMarkLevel 不覆盖
|
|
426
|
+
kitMarkLevel(el, 'item', 'line'); kitApplyLevelClass(el);
|
|
427
|
+
el.setAttribute(KIT_ATTR_ROW, '');
|
|
428
|
+
el.setAttribute(KIT_ATTR_INDEX, String(index));
|
|
429
|
+
el.setAttribute(KIT_ATTR_KEY, String(index));
|
|
347
430
|
el.tabIndex = index === cursor ? 0 : -1;
|
|
348
|
-
const m = mode
|
|
431
|
+
const m = plan.mode;
|
|
349
432
|
const picked = isPicked(row);
|
|
350
433
|
if (m !== 'none') el.setAttribute('aria-selected', picked ? 'true' : 'false');
|
|
351
|
-
if (picked) el.setAttribute(
|
|
434
|
+
if (picked) el.setAttribute(KIT_ATTR_SELECTED, '');
|
|
435
|
+
// 选中行交互状态自报;aria-selected 已按选择模式写在上一行
|
|
436
|
+
kitMarkPicked(el, 'selected', picked, null);
|
|
352
437
|
if (m === 'single' || m === 'multi') {
|
|
353
|
-
const
|
|
354
|
-
const selectClass = p.bordered === false ? stripBorderClasses(rawSelect) : rawSelect;
|
|
355
|
-
const cell = mk('div', selectClass);
|
|
438
|
+
const cell = mk('div', plan.selectClass);
|
|
356
439
|
cell.setAttribute('role', 'gridcell');
|
|
357
440
|
const box = createCheck(doc(), m === 'single' ? 'radio' : 'checkbox', { checked: picked });
|
|
358
|
-
box.setAttribute(
|
|
441
|
+
box.setAttribute(KIT_ATTR_SEL, '');
|
|
359
442
|
setMarkLabel(box, fill(KIT_VIRTUAL_LABELS.rowSelect ?? '', index + 1));
|
|
360
443
|
cell.appendChild(box);
|
|
361
444
|
el.appendChild(cell);
|
|
362
445
|
}
|
|
363
|
-
for (const col of cells
|
|
364
|
-
const
|
|
365
|
-
const cellClass = p.bordered === false ? stripBorderClasses(rawCell) : rawCell;
|
|
366
|
-
const cell = mk('div', cellClass);
|
|
446
|
+
for (const col of plan.cells) {
|
|
447
|
+
const cell = mk('div', col.cellClass);
|
|
367
448
|
cell.setAttribute('role', 'gridcell');
|
|
368
|
-
cell.setAttribute(
|
|
369
|
-
|
|
370
|
-
if (col.
|
|
449
|
+
cell.setAttribute(KIT_ATTR_COL, col.def.field);
|
|
450
|
+
kitMarkPart(cell, 'cell');
|
|
451
|
+
if (col.def.ellipsis) cell.setAttribute(KIT_ATTR_ELLIPSIS, '');
|
|
452
|
+
if (col.def.editable) cell.setAttribute(KIT_ATTR_EDITABLE, '');
|
|
371
453
|
cell.appendChild(cellContent(col, row));
|
|
372
454
|
el.appendChild(cell);
|
|
373
455
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const rawActions = withoutPy(str(p.actionsClass));
|
|
377
|
-
const actionsClass = p.bordered === false ? stripBorderClasses(rawActions) : rawActions;
|
|
378
|
-
const cell = mk('div', actionsClass);
|
|
456
|
+
if (plan.hasActionsCol) {
|
|
457
|
+
const cell = mk('div', plan.actionsClass);
|
|
379
458
|
cell.setAttribute('role', 'gridcell');
|
|
459
|
+
kitMarkPart(cell, 'cell');
|
|
380
460
|
const box = mk('div', ACTIONS_CELL_CLASS);
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
const btn = mk('button', ROW_ACTION_BUTTON_CLASS[ranks[at]!], a.name);
|
|
461
|
+
for (const a of plan.actions) {
|
|
462
|
+
const btn = mk('button', a.btnClass, a.name);
|
|
384
463
|
btn.setAttribute('type', 'button');
|
|
464
|
+
kitMarkPart(btn, 'action');
|
|
385
465
|
// 行动作:文字链接形态(无面,不标 raised)
|
|
386
|
-
btn.setAttribute(
|
|
466
|
+
btn.setAttribute(KIT_ATTR_ACT, a.id);
|
|
387
467
|
box.appendChild(btn);
|
|
388
468
|
}
|
|
389
469
|
cell.appendChild(box);
|
|
@@ -398,14 +478,20 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
398
478
|
rendered.clear();
|
|
399
479
|
};
|
|
400
480
|
|
|
401
|
-
/** 选中态刷新(不重建行):data-kit-selected / aria-selected /
|
|
481
|
+
/** 选中态刷新(不重建行):data-kit-selected / aria-selected / 勾选框,带脏检查避免无谓 DOM 写 */
|
|
402
482
|
const refreshSelection = (): void => {
|
|
483
|
+
const m = mode();
|
|
403
484
|
for (const [i, el] of rendered) {
|
|
404
485
|
const row = rows[i] ?? {};
|
|
405
486
|
const picked = isPicked(row);
|
|
406
|
-
if (picked) el.
|
|
407
|
-
if (
|
|
408
|
-
|
|
487
|
+
if (picked) { if (!el.hasAttribute(KIT_ATTR_SELECTED)) el.setAttribute(KIT_ATTR_SELECTED, ''); }
|
|
488
|
+
else if (el.hasAttribute(KIT_ATTR_SELECTED)) el.removeAttribute(KIT_ATTR_SELECTED);
|
|
489
|
+
if (m !== 'none') {
|
|
490
|
+
const nextAria = picked ? 'true' : 'false';
|
|
491
|
+
if (el.getAttribute('aria-selected') !== nextAria) el.setAttribute('aria-selected', nextAria);
|
|
492
|
+
}
|
|
493
|
+
kitMarkPicked(el, 'selected', picked, null);
|
|
494
|
+
const box = el.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_SEL));
|
|
409
495
|
if (box && markChecked(box) !== picked) paintCheck(box, { checked: picked, disabled: rowBusy(row) });
|
|
410
496
|
applyBusy(el, row); // 在途状态变化(忙闲通道通知后重绘走这里)
|
|
411
497
|
}
|
|
@@ -434,13 +520,15 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
434
520
|
const active = root.ownerDocument.activeElement;
|
|
435
521
|
for (const [i, el] of rendered) {
|
|
436
522
|
if (i >= start && i < end) continue;
|
|
437
|
-
if (active instanceof HTMLElement && el.contains(active)) root.focus({ preventScroll: true });
|
|
523
|
+
if (typeof HTMLElement !== 'undefined' && active instanceof HTMLElement && el.contains(active)) root.focus({ preventScroll: true });
|
|
438
524
|
el.remove();
|
|
439
525
|
rendered.delete(i);
|
|
440
526
|
}
|
|
527
|
+
let plan: RowRenderPlan | null = null;
|
|
441
528
|
for (let i = end - 1; i >= start; i--) {
|
|
442
529
|
if (rendered.has(i)) continue;
|
|
443
|
-
|
|
530
|
+
if (plan === null) plan = createRowPlan();
|
|
531
|
+
const el = buildRow(i, plan);
|
|
444
532
|
let next: Element = bottom;
|
|
445
533
|
for (let j = i + 1; j < end; j++) {
|
|
446
534
|
const hit = rendered.get(j);
|
|
@@ -471,8 +559,13 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
471
559
|
syncTier(false);
|
|
472
560
|
const p = P();
|
|
473
561
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
474
|
-
//
|
|
562
|
+
// 数据状态自报:没有行记「内容全空」(加载 / 出错由同页集合三态面板承载)
|
|
563
|
+
kitMarkDataFacts(root, { empty: rows.length === 0 });
|
|
564
|
+
// 外壳(emit-static)的内层已是 grid(含表头行),本组件的根是其中的 rowgroup;单独使用时根自己当 grid,
|
|
565
|
+
// 同时自标 data-kit-vscroll 使结构规则 `[data-kit-part="table-row"]:not([data-kit-vscroll] *)` 识别虚拟行按档位类定高,不叠加常规表行 min-height
|
|
475
566
|
root.setAttribute('role', gridEl() === root ? 'grid' : 'rowgroup');
|
|
567
|
+
if (scroller() === null) root.setAttribute(KIT_ATTR_VSCROLL, '');
|
|
568
|
+
else root.removeAttribute(KIT_ATTR_VSCROLL);
|
|
476
569
|
const label = str(p.label);
|
|
477
570
|
if (label !== '' && gridEl() === root) root.setAttribute('aria-label', label); else root.removeAttribute('aria-label');
|
|
478
571
|
const nCols = Number(p.colCount) > 0 ? Number(p.colCount) : cells().length + (mode() !== 'none' ? 1 : 0) + (actionsOf(p.actions).length > 0 ? 1 : 0);
|
|
@@ -481,21 +574,55 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
481
574
|
reconcile();
|
|
482
575
|
}
|
|
483
576
|
|
|
484
|
-
/**
|
|
577
|
+
/** 计算当前可见窗口与首尾边界的轻量浅签名(避免对万行全量数组做 JSON.stringify) */
|
|
578
|
+
const computeWindowSig = (list: readonly Rec[]): string => {
|
|
579
|
+
const indices = new Set<number>([0, Math.max(0, list.length - 1)]);
|
|
580
|
+
for (const idx of rendered.keys()) {
|
|
581
|
+
if (idx >= 0 && idx < list.length) indices.add(idx);
|
|
582
|
+
}
|
|
583
|
+
if (rendered.size === 0 && list.length > 0) {
|
|
584
|
+
const cap = Math.min(list.length, 32);
|
|
585
|
+
for (let i = 0; i < cap; i += 1) indices.add(i);
|
|
586
|
+
}
|
|
587
|
+
const sorted = [...indices].sort((a, b) => a - b).slice(0, 80);
|
|
588
|
+
const sample = sorted.map((i) => [i, list[i]]);
|
|
589
|
+
try {
|
|
590
|
+
return `${list.length}:${JSON.stringify(sample)}`;
|
|
591
|
+
} catch {
|
|
592
|
+
return `${list.length}:ref`;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
/** 引用 + 长度 + 窗口浅签名对账:禁止全量万行 JSON.stringify */
|
|
485
597
|
const syncRows = (): boolean => {
|
|
486
|
-
const
|
|
487
|
-
|
|
598
|
+
const p = P();
|
|
599
|
+
const permState = permStateOf(p);
|
|
600
|
+
renderedPerm = permState;
|
|
601
|
+
let nextSchema: string;
|
|
602
|
+
try {
|
|
603
|
+
nextSchema = JSON.stringify([p.cells, p.rowClass, p.stripeClass, p.actions, p.select, p.selectClass, p.actionsClass, p.bordered, p.pickOnRow, p.rowToneField, permState]);
|
|
604
|
+
} catch {
|
|
605
|
+
nextSchema = '';
|
|
606
|
+
}
|
|
607
|
+
const schemaChanged = nextSchema !== schemaSig;
|
|
608
|
+
schemaSig = nextSchema;
|
|
609
|
+
const next = p.rows;
|
|
610
|
+
if (next === rowsRef && !schemaChanged) return false;
|
|
611
|
+
const prevRows = rows;
|
|
488
612
|
rowsRef = next;
|
|
489
613
|
const list = Array.isArray(next) ? next.filter(isRec) : [];
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
614
|
+
const lenChanged = list.length !== prevRows.length;
|
|
615
|
+
const nextWinSig = computeWindowSig(list);
|
|
616
|
+
const renderedRefChanged = rendered.size > 80 && Array.from(rendered.keys()).some((i) => prevRows[i] !== list[i]);
|
|
617
|
+
const winChanged = nextWinSig !== windowSig || renderedRefChanged;
|
|
618
|
+
windowSig = nextWinSig;
|
|
494
619
|
rows = list;
|
|
495
|
-
items
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
620
|
+
if (lenChanged || items.length !== rows.length) {
|
|
621
|
+
items = rows.map((_r, i) => ({ key: String(i), text: '' }));
|
|
622
|
+
if (cursor >= rows.length) cursor = Math.max(0, rows.length - 1);
|
|
623
|
+
win?.setCount(rows.length);
|
|
624
|
+
}
|
|
625
|
+
return schemaChanged || lenChanged || winChanged;
|
|
499
626
|
};
|
|
500
627
|
|
|
501
628
|
const pageStep = SOMA_SIZE_UNITS.collection.keyboard.pageStep;
|
|
@@ -531,8 +658,9 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
531
658
|
bottom = mk('div', SPACER_CLASS);
|
|
532
659
|
bottom.setAttribute('aria-hidden', 'true');
|
|
533
660
|
root.replaceChildren(top, bottom);
|
|
534
|
-
root.setAttribute(
|
|
661
|
+
root.setAttribute(KIT_ATTR_ROWS, '');
|
|
535
662
|
root.tabIndex = -1;
|
|
663
|
+
rebuildSelectedSet();
|
|
536
664
|
syncRows();
|
|
537
665
|
appliedTier = tier();
|
|
538
666
|
win = createVirtualWindow({
|
|
@@ -546,11 +674,12 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
546
674
|
ensureDensityObserver();
|
|
547
675
|
const r = root;
|
|
548
676
|
const rowAt = (t: EventTarget | null): { el: HTMLElement; index: number } | null => {
|
|
549
|
-
const el = (t as HTMLElement | null)?.closest<HTMLElement>(
|
|
677
|
+
const el = (t as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_INDEX)) ?? null;
|
|
550
678
|
if (!el || !r.contains(el)) return null;
|
|
551
|
-
const index = Number(el.getAttribute(
|
|
679
|
+
const index = Number(el.getAttribute(KIT_ATTR_INDEX));
|
|
552
680
|
return Number.isInteger(index) ? { el, index } : null;
|
|
553
681
|
};
|
|
682
|
+
const rowConfirm = createKitRowConfirm(() => api.isCurrent());
|
|
554
683
|
const onClick = (event: Event): void => {
|
|
555
684
|
const hit = rowAt(event.target);
|
|
556
685
|
if (!hit) return;
|
|
@@ -559,30 +688,33 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
559
688
|
const t = event.target as HTMLElement;
|
|
560
689
|
cursor = hit.index;
|
|
561
690
|
syncTabindex();
|
|
562
|
-
const act = t.closest<HTMLElement>(
|
|
691
|
+
const act = t.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACT));
|
|
563
692
|
if (act) {
|
|
564
693
|
const list = actionsOf(P().actions);
|
|
565
|
-
const idx = list.findIndex((x) => x.id === act.getAttribute(
|
|
694
|
+
const idx = list.findIndex((x) => x.id === act.getAttribute(KIT_ATTR_ACT));
|
|
566
695
|
const a = list[idx];
|
|
567
|
-
|
|
696
|
+
// 页面线对危险动作下发的二次确认(props.kit.actions[动作].confirm):确认通过才抛槽位事件,没有判定时同步抛。
|
|
697
|
+
// 确认锁按行键(D-10,与右键菜单 / 列表行同一行在途键 removeKeyOf):窗口滚动后同一下标换了行也不会误锁;取不到行键才退到下标
|
|
698
|
+
const rowKey = removeKeyOf(row, str(P().removeKeyField));
|
|
699
|
+
if (a && !rowBusy(row)) rowConfirm.guard(P(), a.id, act, a.name, () => emitActionSlot((n, p) => api.emit(n, p), KIT_ACTION_SLOT_BASE.row, idx, { kit_action: a.id, id: a.id, name: a.name, builtin: a.builtin, target: a.target, row, ...objectPayload(), ...rowBusyPayload(row) }), rowKey !== '' ? rowKey : String(hit.index));
|
|
568
700
|
return;
|
|
569
701
|
}
|
|
570
|
-
if (t.closest(
|
|
571
|
-
if (t.closest(
|
|
702
|
+
if (t.closest(kitAttrSel(KIT_ATTR_SEL))) return; // change 事件处理
|
|
703
|
+
if (t.closest(`button, a, input, select, textarea, label, ${kitAttrSel(KIT_ATTR_EDITABLE)}`)) return;
|
|
572
704
|
const sel = typeof window !== 'undefined' && typeof window.getSelection === 'function' ? window.getSelection() : null;
|
|
573
705
|
if (sel !== null && !sel.isCollapsed && sel.toString() !== '') return;
|
|
574
706
|
if (bool(P().pickOnRow)) emitPick(row);
|
|
575
707
|
};
|
|
576
708
|
// 选择框是自绘勾选标记(base/check-core.ts):点击 / 空格 -> 抛选择
|
|
577
709
|
const offMark = attachMarkEvents(r, (mark, next) => {
|
|
578
|
-
if (mark.getAttribute(
|
|
710
|
+
if (mark.getAttribute(KIT_ATTR_SEL) === null) return;
|
|
579
711
|
const hit = rowAt(mark);
|
|
580
712
|
const row = hit ? rows[hit.index] : undefined;
|
|
581
713
|
if (row) emitSelect(row, next);
|
|
582
714
|
});
|
|
583
715
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
584
716
|
const t = event.target as HTMLElement | null;
|
|
585
|
-
if (!t || t.closest(
|
|
717
|
+
if (!t || t.closest(`input, select, textarea, ${kitAttrSel(KIT_ATTR_MARK)}, ${kitAttrSel(KIT_ATTR_ACT)}, ${kitAttrSel(KIT_ATTR_EDIT_CONTROL)}`)) return;
|
|
586
718
|
if (wiring.onKeydown(event)) event.preventDefault();
|
|
587
719
|
};
|
|
588
720
|
const onFocusIn = (event: Event): void => {
|
|
@@ -598,8 +730,14 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
598
730
|
if ((el.getAttribute('aria-busy') === 'true') !== rowBusy(rows[i] ?? {})) { api.refresh(); return; }
|
|
599
731
|
}
|
|
600
732
|
});
|
|
733
|
+
const offPerm = registerLivePermissionGate(() => {
|
|
734
|
+
if (permStateOf(P()) !== renderedPerm) api.refresh();
|
|
735
|
+
});
|
|
601
736
|
return () => {
|
|
737
|
+
rowConfirm.dispose();
|
|
602
738
|
offBusy();
|
|
739
|
+
offPerm();
|
|
740
|
+
renderedPerm = '';
|
|
603
741
|
r.removeEventListener('click', onClick);
|
|
604
742
|
offMark();
|
|
605
743
|
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
@@ -617,6 +755,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
617
755
|
},
|
|
618
756
|
render(rootEl) {
|
|
619
757
|
root = rootEl;
|
|
758
|
+
rebuildSelectedSet();
|
|
620
759
|
// 行样式档位字段换了:行元素复用会留旧档位类,整窗重建
|
|
621
760
|
const tone = str(P().rowToneField);
|
|
622
761
|
const toneChanged = tone !== appliedTone;
|
|
@@ -625,6 +764,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
625
764
|
else refreshSelection();
|
|
626
765
|
syncTier();
|
|
627
766
|
paint();
|
|
767
|
+
windowSig = computeWindowSig(rows);
|
|
628
768
|
},
|
|
629
769
|
};
|
|
630
770
|
}),
|