soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/base/popup.ts
CHANGED
|
@@ -8,26 +8,50 @@
|
|
|
8
8
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
9
9
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
10
10
|
import { kitDirAt } from '../i18n/kit-text';
|
|
11
|
+
import { mergeClass } from '../shared/merge-class';
|
|
12
|
+
import { KIT_ATTR_BOUNDARY, KIT_ATTR_QUIET } from '../shared/dom-attrs';
|
|
13
|
+
import { KIT_INVERSE_TOOLTIP_SURFACE_CLASS } from '../recipes/color-role';
|
|
11
14
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
15
|
+
import { kitSelectedRecipe } from '../recipes/state';
|
|
16
|
+
import { KIT_MENU_ITEM_HEIGHT_TOKEN, KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
|
|
12
17
|
import { leaveAnchored, markAnchored, unmarkAnchored } from './anchored-layer';
|
|
18
|
+
import { kitReportSelf } from './kit-contract';
|
|
19
|
+
import { kitLevelClassFor } from '../recipes/pipeline-runtime';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 锚定浮起面板(下拉、联想、菜单、气泡、提示)的层级角色自报:「浮起」。全部锚定面板都经本文件的落位出口显示,
|
|
23
|
+
* 所以在落位出口统一自报,各组件不必各写一遍;不覆盖面板上已有的层级角色(组件自己报了更准的就以它为准)。
|
|
24
|
+
*/
|
|
25
|
+
function reportFloat(panel: HTMLElement): void {
|
|
26
|
+
// 反色提示气泡(role="tooltip")是成对的 bg-surface-inverse + text-fg-inverse,不自报 float,
|
|
27
|
+
// 避免 next 模式取值表覆写浮起面底色/边框/阴影导致字底撞色
|
|
28
|
+
if (panel.getAttribute('role') === 'tooltip') return;
|
|
29
|
+
kitReportSelf(panel, { level: 'float' });
|
|
30
|
+
}
|
|
13
31
|
import type { KitLeaveHandle } from './overlay-runtime';
|
|
14
32
|
import {
|
|
15
33
|
createPanelPortalWith, KIT_PANEL_PORTAL_CLASS_CANDIDATES, showAtPoint,
|
|
16
34
|
type PanelPortal, type PointPanel, type PointPanelOptions, type PointXY,
|
|
17
35
|
} from './portal-core';
|
|
18
36
|
|
|
19
|
-
import { KIT_DROPDOWN_LIMITS } from 'soma-foundation/kit-limits';
|
|
37
|
+
import { KIT_DROPDOWN_LIMITS, KIT_OVERLAY_LIMITS } from 'soma-foundation/kit-limits';
|
|
20
38
|
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
21
39
|
|
|
22
40
|
type WiringOptions = Parameters<typeof createKeyboardWiring>[0];
|
|
23
41
|
|
|
24
|
-
//
|
|
25
|
-
// (最大高 = 整数行 +
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
42
|
+
// 下拉面板高度与浮层阴影档的真源:阴影 / 描边类读 spec/kit-grammar.json#dropdown;行高 = 条带阶梯的菜单项行高 sizeSpec.strip.menuItemPx(AR42),
|
|
43
|
+
// 内边距与行数档读 design 的 kit-limits.json#dropdown(最大高 = 内边距 + (整数行 + 半行) × 项高;行数从大到小)。
|
|
44
|
+
// 项高随密度(令牌 --soma-menu-item-height = R2(8 · u),主题公式 F1),所以类按行数写成 max-h-menu-rows-<行数>,规则由 compile/styles 注入、在 CSS 里按项高令牌算;
|
|
45
|
+
// px 是标准密度下的标称值(真源 clamps),运行期挑档时按面板上读到的项高重算(见 clampDropdownClass)
|
|
46
|
+
type DropdownRules = { panelShadowClass: string; panelBorderClass: string };
|
|
30
47
|
const DD = (grammarJson as unknown as { dropdown: DropdownRules }).dropdown;
|
|
48
|
+
|
|
49
|
+
/** 空间不足时面板内部滚动的 max-h 闭集档位,从大到小;每档都是「整数行 + 半行」(真源 dropdown.clamps),空间不够也不腰斩一行 */
|
|
50
|
+
export const DROPDOWN_CLAMPS: readonly { cls: string; px: number; rows: number }[] = Object.freeze(
|
|
51
|
+
KIT_DROPDOWN_LIMITS.clamps.map((c) => ({ cls: `max-h-menu-rows-${c.rows}`, px: c.px, rows: c.rows })),
|
|
52
|
+
);
|
|
53
|
+
/** 下拉面板的默认最大高(最大一档:visibleRows 行 + 半行) */
|
|
54
|
+
export const KIT_DROPDOWN_PANEL_MAX_CLASS: string = DROPDOWN_CLAMPS[0]!.cls;
|
|
31
55
|
/** 下拉 / 菜单面板的表面:浮起级(圆角 + 发丝描边 + 浮起底色 + 双层阴影 + 高光边,recipes/surface.ts 唯一拼装处) */
|
|
32
56
|
const SURFACE_RAISED = kitSurfaceRecipe('raised');
|
|
33
57
|
|
|
@@ -91,8 +115,9 @@ export function createListNav(o: ListNavOptions): ListNav {
|
|
|
91
115
|
};
|
|
92
116
|
}
|
|
93
117
|
|
|
94
|
-
/**
|
|
118
|
+
/** 点组件之外的地方时收起;监听归属 scope.ownerDocument(兼容 iframe 工作区),返回摘除函数 */
|
|
95
119
|
export function onOutsidePress(scope: HTMLElement, isOpen: () => boolean, close: () => void, alsoInside?: (node: Node) => boolean): () => void {
|
|
120
|
+
const doc = scope.ownerDocument ?? document;
|
|
96
121
|
const handler = (event: Event): void => {
|
|
97
122
|
if (!isOpen()) return;
|
|
98
123
|
const target = event.target as Node | null;
|
|
@@ -100,8 +125,8 @@ export function onOutsidePress(scope: HTMLElement, isOpen: () => boolean, close:
|
|
|
100
125
|
if (target && (scope.contains(target) || alsoInside?.(target) === true || inDropdownPortalOf(scope, target))) return;
|
|
101
126
|
close();
|
|
102
127
|
};
|
|
103
|
-
|
|
104
|
-
return () =>
|
|
128
|
+
doc.addEventListener('pointerdown', handler, true);
|
|
129
|
+
return () => doc.removeEventListener('pointerdown', handler, true);
|
|
105
130
|
}
|
|
106
131
|
|
|
107
132
|
export function cssEscape(value: string): string {
|
|
@@ -119,10 +144,10 @@ export function scrollIntoViewIfAny(el: Element | null): void {
|
|
|
119
144
|
// 记最近一次交互是不是指针(文档级捕获监听只装一次);是指针则落点标 data-kit-quiet,
|
|
120
145
|
// 类串里的 data-kit-quiet:focus-visible:ring-0 把环压掉;键盘一动由面板的 keydown 摘掉标记。
|
|
121
146
|
let lastInputIsPointer = false;
|
|
122
|
-
|
|
147
|
+
const trackedModalityDocs = new WeakSet<Document>();
|
|
123
148
|
export function trackInputModality(doc: Document): void {
|
|
124
|
-
if (
|
|
125
|
-
|
|
149
|
+
if (trackedModalityDocs.has(doc)) return;
|
|
150
|
+
trackedModalityDocs.add(doc);
|
|
126
151
|
doc.addEventListener('pointerdown', () => { lastInputIsPointer = true; }, true);
|
|
127
152
|
doc.addEventListener('mousedown', () => { lastInputIsPointer = true; }, true);
|
|
128
153
|
doc.addEventListener('keydown', () => { lastInputIsPointer = false; }, true);
|
|
@@ -131,24 +156,32 @@ export function trackInputModality(doc: Document): void {
|
|
|
131
156
|
/** 程序化落焦:最近交互是鼠标则压掉焦点环;键盘操作照常显示。落焦不滚动页面 */
|
|
132
157
|
export function focusCellQuiet(node: HTMLElement | null | undefined): void {
|
|
133
158
|
if (!node) return;
|
|
134
|
-
if (lastInputIsPointer) node.setAttribute(
|
|
135
|
-
else node.removeAttribute(
|
|
159
|
+
if (lastInputIsPointer) node.setAttribute(KIT_ATTR_QUIET, '');
|
|
160
|
+
else node.removeAttribute(KIT_ATTR_QUIET);
|
|
136
161
|
node.focus({ preventScroll: true });
|
|
137
162
|
}
|
|
138
163
|
|
|
164
|
+
/** 下拉 / 菜单面板宽度上限(kit-limits#overlay.menuMaxPx = 320,宽度模数阶梯):按最长项取宽到上限,更长的项在行内省略;下限是触发器宽(min-w-full) */
|
|
165
|
+
const MENU_MAX_WIDTH_CLASS = `max-w-[${KIT_OVERLAY_LIMITS.menuMaxPx}px]`;
|
|
166
|
+
|
|
139
167
|
/** 默认的整串面板类:显隐只换整串,`hidden` 不与布局类并存 */
|
|
140
168
|
export const PANEL_HIDDEN_CLASS = 'hidden';
|
|
141
169
|
export const PANEL_SHOWN_CLASS =
|
|
142
|
-
`absolute start-0 top-full z-10 mt-1 ${
|
|
170
|
+
`absolute start-0 top-full z-10 mt-1 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} p-1`;
|
|
143
171
|
|
|
144
|
-
//
|
|
145
|
-
const ROW =
|
|
172
|
+
// 选项行高固定(条带阶梯的菜单项行高 strip.menuItemPx),面板最大高才能算成「整数行 + 半行」
|
|
173
|
+
const ROW = KIT_STRIP_MENU_ITEM_CLASS;
|
|
146
174
|
export const OPTION_CLASS = {
|
|
147
|
-
idle: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press`,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
idle: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press`,
|
|
176
|
+
// 键盘当前项与鼠标悬停同一层;选中项 = 主色淡底,选中项上的悬停 / 当前 = tonal 层(第三级,KT-K0-2 / KT-K-select-3)
|
|
177
|
+
active: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 bg-state-layer-hover px-3 text-sm text-fg transition-colors`,
|
|
178
|
+
selected: mergeClass(
|
|
179
|
+
mergeClass(`flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2`, kitSelectedRecipe()),
|
|
180
|
+
'px-3 text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press',
|
|
181
|
+
),
|
|
182
|
+
selectedActive: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 bg-state-layer-tonal-hover px-3 text-sm font-medium text-primary-on-soft transition-colors`,
|
|
183
|
+
// 置灰项 = 禁用字色令牌(KT-K-select-5 / KT-K0-4),不降透明度
|
|
184
|
+
disabled: `flex ${ROW} cursor-not-allowed items-center whitespace-nowrap rounded-item gap-2 px-3 text-sm text-fg-disabled`,
|
|
152
185
|
} as const;
|
|
153
186
|
|
|
154
187
|
export const EMPTY_ROW_CLASS = `flex ${ROW} items-center whitespace-nowrap px-3 text-sm text-fg-subtle`;
|
|
@@ -161,12 +194,19 @@ export function optionClass(selected: boolean, active: boolean, disabled: boolea
|
|
|
161
194
|
|
|
162
195
|
/** 本文件自带的类(供各组件并入候选类清单) */
|
|
163
196
|
export const KIT_POPUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
197
|
+
...new Set([
|
|
198
|
+
'hidden', 'absolute', 'start-0', 'top-full', 'z-10', 'mt-1', KIT_DROPDOWN_PANEL_MAX_CLASS, KIT_STRIP_MENU_ITEM_CLASS, 'w-full', 'w-max', 'min-w-full', MENU_MAX_WIDTH_CLASS, 'overflow-auto',
|
|
199
|
+
'rounded-float', 'rounded-item', 'border', 'border-border', 'border-border-subtle', 'bg-surface-raised', 'p-1', 'py-1', DD.panelShadowClass, 'shadow-sm',
|
|
200
|
+
...SURFACE_RAISED.split(/\s+/),
|
|
201
|
+
...PANEL_SHOWN_CLASS.split(/\s+/),
|
|
202
|
+
...Object.values(OPTION_CLASS).flatMap((s) => s.split(/\s+/)),
|
|
203
|
+
...EMPTY_ROW_CLASS.split(/\s+/),
|
|
204
|
+
'px-3', 'py-2',
|
|
205
|
+
// Popover / Popconfirm / 行内气泡确认在未静态声明 Popover 的页面命令式挂载时也需保留默认宽高约束(PW2-Biz P2-6)
|
|
206
|
+
'min-w-52', 'min-w-60', 'w-64', 'w-80', 'max-w-80',
|
|
207
|
+
...kitSelectedRecipe().split(/\s+/),
|
|
208
|
+
...KIT_INVERSE_TOOLTIP_SURFACE_CLASS.split(/\s+/),
|
|
209
|
+
].filter(Boolean)),
|
|
170
210
|
]);
|
|
171
211
|
|
|
172
212
|
/**
|
|
@@ -174,8 +214,10 @@ export const KIT_POPUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
|
|
|
174
214
|
* 通用 `tooltip` prop(shared.ts 的 withTooltip)取用;Popover / Popconfirm 的面板另用 PANEL_*。
|
|
175
215
|
*/
|
|
176
216
|
export const POPUP_TIP_HIDDEN_CLASS = PANEL_HIDDEN_CLASS;
|
|
177
|
-
export const POPUP_TIP_BASE =
|
|
178
|
-
'absolute z-10 w-max max-w-
|
|
217
|
+
export const POPUP_TIP_BASE = mergeClass(
|
|
218
|
+
'absolute z-10 w-max max-w-60 rounded-float px-2 py-1 text-sm font-normal pointer-events-none',
|
|
219
|
+
KIT_INVERSE_TOOLTIP_SURFACE_CLASS,
|
|
220
|
+
);
|
|
179
221
|
|
|
180
222
|
// ── 贴边自动翻转 ──────────────────────────────────────────────
|
|
181
223
|
//
|
|
@@ -196,22 +238,25 @@ const POP_POS: Readonly<Record<PopSide, Readonly<Record<PopAlign, string>>>> = {
|
|
|
196
238
|
start: { start: 'end-full top-0', end: 'bottom-0 end-full' },
|
|
197
239
|
end: { start: 'start-full top-0', end: 'bottom-0 start-full' },
|
|
198
240
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
241
|
+
/** 锚定层与触发器的间距:只此一个值(真源 dropdown.gapPx),所有锚定浮层(下拉 / 菜单 / 气泡 / 筛选面板)共用,构件不自带偏移 */
|
|
242
|
+
export const ANCHORED_GAP_PX: number = KIT_DROPDOWN_LIMITS.gapPx;
|
|
243
|
+
const GAP_UNIT = ANCHORED_GAP_PX / 4;
|
|
244
|
+
const POP_GAP: Readonly<Record<PopSide, string>> = {
|
|
245
|
+
bottom: `mt-${GAP_UNIT}`,
|
|
246
|
+
top: `mb-${GAP_UNIT}`,
|
|
247
|
+
start: `me-${GAP_UNIT}`,
|
|
248
|
+
end: `ms-${GAP_UNIT}`,
|
|
204
249
|
};
|
|
205
250
|
|
|
206
|
-
/** 位置类串(不含 absolute / z /
|
|
207
|
-
export function popPlaceClass(place: PopPlace
|
|
208
|
-
return `${POP_POS[place.side][place.align]} ${POP_GAP[place.side]
|
|
251
|
+
/** 位置类串(不含 absolute / z / 外观类,由组件自己拼):左缘(start)或右缘(end)与触发器对齐 + 真源间距 */
|
|
252
|
+
export function popPlaceClass(place: PopPlace): string {
|
|
253
|
+
return `${POP_POS[place.side][place.align]} ${POP_GAP[place.side]}`;
|
|
209
254
|
}
|
|
210
255
|
|
|
211
256
|
/** 全部位置类(供类名候选清单) */
|
|
212
257
|
export const KIT_POPUP_PLACE_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
213
258
|
[...new Set((['top', 'bottom', 'start', 'end'] as const).flatMap((s) =>
|
|
214
|
-
(['start', 'end'] as const).flatMap((a) => `${POP_POS[s][a]} ${POP_GAP[s]
|
|
259
|
+
(['start', 'end'] as const).flatMap((a) => `${POP_POS[s][a]} ${POP_GAP[s]}`.split(' '))))],
|
|
215
260
|
);
|
|
216
261
|
|
|
217
262
|
const FLIP_OPPOSITE: Readonly<Record<PopSide, PopSide>> = { top: 'bottom', bottom: 'top', start: 'end', end: 'start' };
|
|
@@ -222,7 +267,7 @@ export function resolvePopPlace(
|
|
|
222
267
|
size: { width: number; height: number },
|
|
223
268
|
viewport: { width: number; height: number },
|
|
224
269
|
pref: PopPlace,
|
|
225
|
-
gapPx =
|
|
270
|
+
gapPx = ANCHORED_GAP_PX,
|
|
226
271
|
rtl = false,
|
|
227
272
|
): PopPlace {
|
|
228
273
|
const { width: w, height: h } = size;
|
|
@@ -268,14 +313,42 @@ export function showPopupFitted(
|
|
|
268
313
|
anchor: HTMLElement,
|
|
269
314
|
pref: PopPlace,
|
|
270
315
|
classFor: (place: PopPlace) => string,
|
|
271
|
-
gapPx =
|
|
316
|
+
gapPx = ANCHORED_GAP_PX,
|
|
272
317
|
): PopPlace {
|
|
318
|
+
// 先自报、后落类:贴边翻转里的类由调用方的 classFor 经 kitLevelClassFor 按面板上的层级角色出(气泡提示是反色面,取值表给不了,调用方不剥)
|
|
319
|
+
reportFloat(panel);
|
|
273
320
|
const place = fitPopupPlace(panel, anchor, pref, classFor, gapPx);
|
|
274
321
|
// 锚定浮层统一标记(anchored-layer.ts):落位后的实际方向,重定位 / 翻转时随之更新
|
|
275
322
|
markAnchored(panel, place);
|
|
276
323
|
return place;
|
|
277
324
|
}
|
|
278
325
|
|
|
326
|
+
/** 定位边界标记(KT-D9-5):窗格、窗口正文、页面内容区由各自的配方打;浮层不跨出锚点所在的这一块 */
|
|
327
|
+
export { KIT_ATTR_BOUNDARY as KIT_BOUNDARY_ATTR } from '../shared/dom-attrs';
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 浮层落位的边界(封闭清单 ②,只读矩形):锚点最近的 `[data-kit-boundary]` 祖先与视口的交集(横向;纵向取视口);没有标记取视口。
|
|
331
|
+
* 返回边界矩形与「把锚点矩形换算到边界坐标系」后的锚点——resolvePopPlace / resolveDropdown 的纯函数只认「原点在 0 的视口」,
|
|
332
|
+
* 换算后同一份翻转 / 对齐判定就以窗格为界,不另写第二套。视口宽高为 0(无布局环境)返回 null。
|
|
333
|
+
*/
|
|
334
|
+
export function placementFrame(anchor: HTMLElement): { anchor: { left: number; right: number; top: number; bottom: number }; viewport: { width: number; height: number } } | null {
|
|
335
|
+
const doc = anchor.ownerDocument ?? document;
|
|
336
|
+
const win = doc.defaultView;
|
|
337
|
+
const vw = doc.documentElement.clientWidth || win?.innerWidth || (typeof window !== 'undefined' ? window.innerWidth : 0);
|
|
338
|
+
const vh = doc.documentElement.clientHeight || win?.innerHeight || (typeof window !== 'undefined' ? window.innerHeight : 0);
|
|
339
|
+
if (vw === 0 || vh === 0) return null;
|
|
340
|
+
let left = 0; let top = 0; let right = vw; let bottom = vh;
|
|
341
|
+
const box = anchor.closest(`[${KIT_ATTR_BOUNDARY}]`);
|
|
342
|
+
if (box !== null) {
|
|
343
|
+
const r = box.getBoundingClientRect();
|
|
344
|
+
// 只收行内方向(左右):「不盖住相邻窗格」是横向的事;纵向仍以视口为界(窗口正文 / 窗格底部离触发器很近时,下拉照常越过它,不被压成一两行)
|
|
345
|
+
if (r.width > 0 && r.height > 0) { left = Math.max(left, r.left); right = Math.min(right, r.right); }
|
|
346
|
+
}
|
|
347
|
+
if (right - left <= 0 || bottom - top <= 0) { left = 0; top = 0; right = vw; bottom = vh; }
|
|
348
|
+
const a = anchor.getBoundingClientRect();
|
|
349
|
+
return { anchor: { left: a.left - left, right: a.right - left, top: a.top - top, bottom: a.bottom - top }, viewport: { width: right - left, height: bottom - top } };
|
|
350
|
+
}
|
|
351
|
+
|
|
279
352
|
function fitPopupPlace(
|
|
280
353
|
panel: HTMLElement,
|
|
281
354
|
anchor: HTMLElement,
|
|
@@ -285,19 +358,17 @@ function fitPopupPlace(
|
|
|
285
358
|
): PopPlace {
|
|
286
359
|
panel.className = classFor(pref);
|
|
287
360
|
if (typeof panel.getBoundingClientRect !== 'function') return pref;
|
|
288
|
-
const
|
|
361
|
+
const frame = placementFrame(anchor);
|
|
362
|
+
if (frame === null) return pref;
|
|
289
363
|
const b = panel.getBoundingClientRect();
|
|
290
|
-
const
|
|
291
|
-
const vh = document.documentElement.clientHeight || (typeof window !== 'undefined' ? window.innerHeight : 0);
|
|
292
|
-
if (vw === 0 || vh === 0) return pref;
|
|
293
|
-
const place = resolvePopPlace(a, { width: b.width, height: b.height }, { width: vw, height: vh }, pref, gapPx, kitDirAt(anchor) === 'rtl');
|
|
364
|
+
const place = resolvePopPlace(frame.anchor, { width: b.width, height: b.height }, frame.viewport, pref, gapPx, kitDirAt(anchor) === 'rtl');
|
|
294
365
|
if (place.side !== pref.side || place.align !== pref.align) panel.className = classFor(place);
|
|
295
366
|
return place;
|
|
296
367
|
}
|
|
297
368
|
|
|
298
369
|
/** 气泡的偏好位置:目标下方、左对齐;贴边时由 showPopupFitted 翻转 */
|
|
299
370
|
export const POPUP_TIP_PREF: PopPlace = { side: 'bottom', align: 'start' };
|
|
300
|
-
export const popupTipClass = (place: PopPlace): string => `${POPUP_TIP_BASE} ${popPlaceClass(place
|
|
371
|
+
export const popupTipClass = (place: PopPlace): string => `${POPUP_TIP_BASE} ${popPlaceClass(place)}`;
|
|
301
372
|
export const POPUP_TIP_SHOWN_CLASS = popupTipClass(POPUP_TIP_PREF);
|
|
302
373
|
|
|
303
374
|
// ── 下拉面板的贴边翻转(Select / Combobox / Cascader / TreeSelect / TimePicker / ColorPicker / Mentions / TagInput / Navbar / Menu columns 共用)──
|
|
@@ -309,12 +380,7 @@ export const POPUP_TIP_SHOWN_CLASS = popupTipClass(POPUP_TIP_PREF);
|
|
|
309
380
|
|
|
310
381
|
/** 下拉面板外观类(不含位置类):与 PANEL_SHOWN_CLASS 同一份外观 */
|
|
311
382
|
export const PANEL_BASE_CLASS =
|
|
312
|
-
`absolute z-10 ${
|
|
313
|
-
|
|
314
|
-
/** 空间不足时面板内部滚动的 max-h 闭集档位(px = 刻度 x 4),从大到小;每档都是「整数行 + 半行」(真源 dropdown.clamps),空间不够也不腰斩一行 */
|
|
315
|
-
export const DROPDOWN_CLAMPS: readonly { cls: string; px: number }[] = Object.freeze(
|
|
316
|
-
DD.clamps.map((c, i) => ({ cls: c.cls, px: KIT_DROPDOWN_LIMITS.clamps[i]!.px })),
|
|
317
|
-
);
|
|
383
|
+
`absolute z-10 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} p-1`;
|
|
318
384
|
|
|
319
385
|
/** 下拉翻转用到的全部类(位置类、间距类、max-h 档位、滚动) */
|
|
320
386
|
export const KIT_DROPDOWN_CLASS_CANDIDATES: readonly string[] = Object.freeze([
|
|
@@ -334,7 +400,7 @@ export function resolveDropdown(
|
|
|
334
400
|
size: { width: number; height: number },
|
|
335
401
|
viewport: { width: number; height: number },
|
|
336
402
|
prefAlign: PopAlign = 'start',
|
|
337
|
-
gapPx =
|
|
403
|
+
gapPx = ANCHORED_GAP_PX,
|
|
338
404
|
rtl = false,
|
|
339
405
|
): { place: PopPlace; clampPx: number | null } {
|
|
340
406
|
if (size.width === 0 && size.height === 0) return { place: { side: 'bottom', align: prefAlign }, clampPx: null };
|
|
@@ -357,9 +423,11 @@ export function resolveDropdown(
|
|
|
357
423
|
}
|
|
358
424
|
|
|
359
425
|
/** 去掉 max-h-* 后按档位加上放得下的一档(内部滚动);没有 overflow 类时补 overflow-y-auto */
|
|
360
|
-
export function clampDropdownClass(cls: string, clampPx: number): string {
|
|
426
|
+
export function clampDropdownClass(cls: string, clampPx: number, itemPx: number | null = null): string {
|
|
361
427
|
const tokens = cls.split(/\s+/).filter((t) => t !== '' && !t.startsWith('max-h-'));
|
|
362
|
-
|
|
428
|
+
// 每档的实际最大高:给了当前项高就按「内边距 + (行数 + 半行) × 项高」现算(随密度),没给取标准密度的标称值
|
|
429
|
+
const pxOf = (c: { px: number; rows: number }): number => (itemPx === null ? c.px : KIT_DROPDOWN_LIMITS.panelPadYPx + (c.rows + KIT_DROPDOWN_LIMITS.partialRow) * itemPx);
|
|
430
|
+
const step = DROPDOWN_CLAMPS.find((c) => pxOf(c) <= clampPx) ?? DROPDOWN_CLAMPS[DROPDOWN_CLAMPS.length - 1]!;
|
|
363
431
|
tokens.push(step.cls);
|
|
364
432
|
if (!tokens.some((t) => t.startsWith('overflow-'))) tokens.push('overflow-y-auto');
|
|
365
433
|
return tokens.join(' ');
|
|
@@ -374,9 +442,10 @@ export function showDropdownFitted(
|
|
|
374
442
|
anchor: HTMLElement,
|
|
375
443
|
base: string,
|
|
376
444
|
prefAlign: PopAlign = 'start',
|
|
377
|
-
gap: 1 | 2 = 1,
|
|
378
445
|
): PopPlace {
|
|
379
|
-
|
|
446
|
+
// 先自报、后落类:下拉面板的类经 kitLevelClassFor 按面板上实际的层级角色出(新模式剥掉取值表负责的外观类)
|
|
447
|
+
reportFloat(panel);
|
|
448
|
+
const place = fitDropdownPlace(panel, anchor, base, prefAlign);
|
|
380
449
|
markAnchored(panel, place);
|
|
381
450
|
return place;
|
|
382
451
|
}
|
|
@@ -386,23 +455,27 @@ function fitDropdownPlace(
|
|
|
386
455
|
anchor: HTMLElement,
|
|
387
456
|
base: string,
|
|
388
457
|
prefAlign: PopAlign,
|
|
389
|
-
gap: 1 | 2,
|
|
390
458
|
): PopPlace {
|
|
391
|
-
const classFor = (place: PopPlace): string => `${base} ${popPlaceClass(place
|
|
459
|
+
const classFor = (place: PopPlace): string => kitLevelClassFor(panel, `${base} ${popPlaceClass(place)}`);
|
|
392
460
|
const pref: PopPlace = { side: 'bottom', align: prefAlign };
|
|
393
461
|
panel.className = classFor(pref);
|
|
394
462
|
if (typeof panel.getBoundingClientRect !== 'function') return pref;
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
if (vw === 0 || vh === 0) return pref;
|
|
398
|
-
const a = anchor.getBoundingClientRect();
|
|
463
|
+
const frame = placementFrame(anchor);
|
|
464
|
+
if (frame === null) return pref;
|
|
399
465
|
const b = panel.getBoundingClientRect();
|
|
400
|
-
const { place, clampPx } = resolveDropdown(
|
|
401
|
-
const next = clampPx === null ? classFor(place) : `${clampDropdownClass(base, clampPx)} ${popPlaceClass(place
|
|
466
|
+
const { place, clampPx } = resolveDropdown(frame.anchor, { width: b.width, height: b.height }, frame.viewport, prefAlign, ANCHORED_GAP_PX, kitDirAt(anchor) === 'rtl');
|
|
467
|
+
const next = clampPx === null ? classFor(place) : kitLevelClassFor(panel, `${clampDropdownClass(base, clampPx, menuItemPxAt(panel))} ${popPlaceClass(place)}`);
|
|
402
468
|
if (panel.className !== next) panel.className = next;
|
|
403
469
|
return place;
|
|
404
470
|
}
|
|
405
471
|
|
|
472
|
+
/** 面板所在处的菜单项高(px,读令牌 --soma-menu-item-height);读不到(无 DOM、令牌表没有它)回 null,挑档退回标称值 */
|
|
473
|
+
function menuItemPxAt(panel: HTMLElement): number | null {
|
|
474
|
+
if (typeof getComputedStyle !== 'function') return null;
|
|
475
|
+
const px = Number.parseFloat(getComputedStyle(panel).getPropertyValue(KIT_MENU_ITEM_HEIGHT_TOKEN));
|
|
476
|
+
return Number.isFinite(px) && px > 0 ? px : null;
|
|
477
|
+
}
|
|
478
|
+
|
|
406
479
|
// ── 浮层端口挂载(下拉 / 菜单默认走这里,只此一份实现)──
|
|
407
480
|
//
|
|
408
481
|
// 下拉面板默认挂到 core 的浮层挂载点(body 下专用根),不再受触发器祖先的 overflow / transform 裁切。
|
|
@@ -419,6 +492,7 @@ export function createPanelPortal(owner: Element | null): PanelPortal {
|
|
|
419
492
|
* 几何只在 portal-core 的 placeAtPoint 写一次。端口不可用返回 null(调用方走就地绝对定位,不写 CSSOM)。
|
|
420
493
|
*/
|
|
421
494
|
export function showMenuAtPoint(panel: HTMLElement, point: PointXY, opts: Omit<PointPanelOptions, 'resolve' | 'rtl'> & { anchor: Element }): PointPanel | null {
|
|
495
|
+
reportFloat(panel);
|
|
422
496
|
return showAtPoint(panel, point, { ...opts, rtl: kitDirAt(opts.anchor) === 'rtl', resolve: resolvePopPlace });
|
|
423
497
|
}
|
|
424
498
|
|
|
@@ -487,6 +561,23 @@ export function queryWithDropdowns(scope: Element, selector: string): HTMLElemen
|
|
|
487
561
|
return null;
|
|
488
562
|
}
|
|
489
563
|
|
|
564
|
+
/** scope 内锚点挂出去的、当前在浮层里的面板中全部匹配 selector 的节点(含面板本身);不含 scope 自己后代里的匹配 */
|
|
565
|
+
export function queryAllWithDropdowns(scope: Element, selector: string): HTMLElement[] {
|
|
566
|
+
const out: HTMLElement[] = [];
|
|
567
|
+
for (const panel of livePanelsIn(scope)) {
|
|
568
|
+
if (panel.matches(selector)) out.push(panel);
|
|
569
|
+
out.push(...Array.from(panel.querySelectorAll<HTMLElement>(selector)));
|
|
570
|
+
}
|
|
571
|
+
return out;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/** 面板新挂到浮层端口时的回调(组件骨架据此补写面板里的自报,见 base/shared.ts#ensurePanelHook);返回撤销函数 */
|
|
575
|
+
const PANEL_MOUNT_HOOKS = new Set<(anchor: HTMLElement, panel: HTMLElement) => void>();
|
|
576
|
+
export function onKitPanelMounted(hook: (anchor: HTMLElement, panel: HTMLElement) => void): () => void {
|
|
577
|
+
PANEL_MOUNT_HOOKS.add(hook);
|
|
578
|
+
return () => { PANEL_MOUNT_HOOKS.delete(hook); };
|
|
579
|
+
}
|
|
580
|
+
|
|
490
581
|
/** 焦点是否落在 scope 内或它挂出去的下拉面板里;是则返回聚焦元素 */
|
|
491
582
|
export function activeWithDropdowns(scope: Element): HTMLElement | null {
|
|
492
583
|
const active = scope.ownerDocument.activeElement as HTMLElement | null;
|
|
@@ -500,6 +591,15 @@ export function releaseDropdownsIn(scope: Element): void {
|
|
|
500
591
|
for (const m of [...DROPDOWN_LIVE]) if (scope.contains(m.anchor)) releaseDropdown(m.panel, false);
|
|
501
592
|
}
|
|
502
593
|
|
|
594
|
+
/** 端口被销毁时要通知的属主(一次性面板登记:整树重画的 releaseDropdownsIn 直接销毁端口,属主据此按取消收口、摘监听) */
|
|
595
|
+
const DESTROY_HOOKS = new WeakMap<HTMLElement, () => void>();
|
|
596
|
+
|
|
597
|
+
/** 登记 / 撤销面板端口被销毁时的回调(cb 为 null 撤销);回调只触发一次,触发前先撤销登记 */
|
|
598
|
+
export function onDropdownDestroyed(panel: HTMLElement, cb: (() => void) | null): void {
|
|
599
|
+
if (cb === null) DESTROY_HOOKS.delete(panel);
|
|
600
|
+
else DESTROY_HOOKS.set(panel, cb);
|
|
601
|
+
}
|
|
602
|
+
|
|
503
603
|
/** 收起并放回原位(restore)或直接销毁(组件卸载) */
|
|
504
604
|
export function releaseDropdown(panel: HTMLElement, restore = true): void {
|
|
505
605
|
cancelLeave(panel);
|
|
@@ -508,7 +608,11 @@ export function releaseDropdown(panel: HTMLElement, restore = true): void {
|
|
|
508
608
|
DROPDOWN_MOUNTS.delete(panel);
|
|
509
609
|
DROPDOWN_LIVE.delete(m);
|
|
510
610
|
if (restore) m.portal.hide(true);
|
|
511
|
-
else
|
|
611
|
+
else {
|
|
612
|
+
m.portal.destroy();
|
|
613
|
+
const hook = DESTROY_HOOKS.get(panel);
|
|
614
|
+
if (hook !== undefined) { DESTROY_HOOKS.delete(panel); hook(); }
|
|
615
|
+
}
|
|
512
616
|
}
|
|
513
617
|
|
|
514
618
|
// ── 锚定面板的出场 ──
|
|
@@ -521,8 +625,15 @@ function cancelLeave(panel: HTMLElement): void {
|
|
|
521
625
|
LEAVING.delete(panel);
|
|
522
626
|
}
|
|
523
627
|
|
|
524
|
-
/**
|
|
525
|
-
function retireAnchored(panel: HTMLElement): void {
|
|
628
|
+
/** 收起锚定面板:已挂出且有退场动画(且非 immediate) -> 播完再放回 + hidden;否则立即放回 + hidden */
|
|
629
|
+
function retireAnchored(panel: HTMLElement, immediate = false): void {
|
|
630
|
+
if (immediate) {
|
|
631
|
+
cancelLeave(panel);
|
|
632
|
+
releaseDropdown(panel);
|
|
633
|
+
panel.className = PANEL_HIDDEN_CLASS;
|
|
634
|
+
unmarkAnchored(panel);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
526
637
|
if (LEAVING.has(panel)) return;
|
|
527
638
|
const finish = (): void => {
|
|
528
639
|
LEAVING.delete(panel);
|
|
@@ -538,13 +649,29 @@ function retireAnchored(panel: HTMLElement): void {
|
|
|
538
649
|
if (handle !== null) LEAVING.set(panel, handle);
|
|
539
650
|
}
|
|
540
651
|
|
|
652
|
+
export interface SyncOverlayOptions {
|
|
653
|
+
/** Esc 回调(走层栈栈顶:多浮层叠放时只关栈顶一层) */
|
|
654
|
+
onEscape?: () => void;
|
|
655
|
+
/** 收起时立即释放浮层端口与隐藏(选定提交 / Esc 关闭等避免残留半透明残影或滞留层栈) */
|
|
656
|
+
immediate?: boolean;
|
|
657
|
+
}
|
|
658
|
+
|
|
541
659
|
/** 挂到端口并落位;返回实际锚点,端口不可用返回 null(调用方走原位) */
|
|
542
|
-
function mountAnchored(
|
|
660
|
+
function mountAnchored(
|
|
661
|
+
panel: HTMLElement,
|
|
662
|
+
anchor: HTMLElement | undefined,
|
|
663
|
+
pref: PopPlace,
|
|
664
|
+
fit: (p: HTMLElement, box: HTMLElement) => PopPlace,
|
|
665
|
+
onEscape?: () => void,
|
|
666
|
+
): HTMLElement | null {
|
|
543
667
|
const prev = DROPDOWN_MOUNTS.get(panel);
|
|
544
668
|
const at = anchor ?? prev?.anchor ?? panel.parentElement ?? panel;
|
|
545
669
|
const portal = prev?.portal ?? createPanelPortal(at);
|
|
546
670
|
// 端口给的 box 是内部零宽高包裹盒,不能当锚点测视口空间;贴边翻转一律用真实触发器
|
|
547
|
-
const placed = portal.show(panel, at, pref, () => '', {
|
|
671
|
+
const placed = portal.show(panel, at, pref, () => '', {
|
|
672
|
+
fit: (p) => fit(p, at),
|
|
673
|
+
...(onEscape ? { onEscape } : {}),
|
|
674
|
+
});
|
|
548
675
|
if (placed === null) {
|
|
549
676
|
if (prev) DROPDOWN_LIVE.delete(prev);
|
|
550
677
|
DROPDOWN_MOUNTS.delete(panel);
|
|
@@ -554,6 +681,7 @@ function mountAnchored(panel: HTMLElement, anchor: HTMLElement | undefined, pref
|
|
|
554
681
|
const m: DropdownMount = { portal, anchor: at, panel };
|
|
555
682
|
DROPDOWN_MOUNTS.set(panel, m);
|
|
556
683
|
DROPDOWN_LIVE.add(m);
|
|
684
|
+
for (const hook of PANEL_MOUNT_HOOKS) hook(at, panel);
|
|
557
685
|
}
|
|
558
686
|
return at;
|
|
559
687
|
}
|
|
@@ -562,14 +690,21 @@ function mountAnchored(panel: HTMLElement, anchor: HTMLElement | undefined, pref
|
|
|
562
690
|
* 下拉显隐一步到位:收起 = 放回原位 + 整串 hidden;展开 = 挂到浮层端口并贴边翻转(锚点缺省取面板的父盒,
|
|
563
691
|
* 面板已挂出时取上次的锚点)。端口不可用时退回原位绝对定位。
|
|
564
692
|
*/
|
|
565
|
-
export function syncDropdown(
|
|
693
|
+
export function syncDropdown(
|
|
694
|
+
panel: HTMLElement,
|
|
695
|
+
open: boolean,
|
|
696
|
+
base: string = PANEL_BASE_CLASS,
|
|
697
|
+
anchor?: HTMLElement,
|
|
698
|
+
prefAlign: PopAlign = 'start',
|
|
699
|
+
opts?: SyncOverlayOptions,
|
|
700
|
+
): void {
|
|
566
701
|
if (!open) {
|
|
567
|
-
retireAnchored(panel);
|
|
702
|
+
retireAnchored(panel, opts?.immediate === true);
|
|
568
703
|
return;
|
|
569
704
|
}
|
|
570
705
|
cancelLeave(panel);
|
|
571
706
|
const live = `${base} ${DROPDOWN_LIVE_CLASS}`;
|
|
572
|
-
const at = mountAnchored(panel, anchor, { side: 'bottom', align: prefAlign }, (p, box) => showDropdownFitted(p, box, live, prefAlign));
|
|
707
|
+
const at = mountAnchored(panel, anchor, { side: 'bottom', align: prefAlign }, (p, box) => showDropdownFitted(p, box, live, prefAlign), opts?.onEscape);
|
|
573
708
|
if (at === null) showDropdownFitted(panel, anchor ?? panel.parentElement ?? panel, base, prefAlign);
|
|
574
709
|
}
|
|
575
710
|
|
|
@@ -578,15 +713,21 @@ export function syncDropdown(panel: HTMLElement, open: boolean, base: string = P
|
|
|
578
713
|
* classFor 给位置类 + 外观类。端口不可用时退回原位。
|
|
579
714
|
*/
|
|
580
715
|
export function syncAnchored(
|
|
581
|
-
panel: HTMLElement,
|
|
716
|
+
panel: HTMLElement,
|
|
717
|
+
open: boolean,
|
|
718
|
+
anchor: HTMLElement,
|
|
719
|
+
pref: PopPlace,
|
|
720
|
+
classFor: (place: PopPlace) => string,
|
|
721
|
+
gapPx?: number,
|
|
722
|
+
opts?: SyncOverlayOptions,
|
|
582
723
|
): void {
|
|
583
724
|
if (!open) {
|
|
584
|
-
retireAnchored(panel);
|
|
725
|
+
retireAnchored(panel, opts?.immediate === true);
|
|
585
726
|
return;
|
|
586
727
|
}
|
|
587
728
|
cancelLeave(panel);
|
|
588
729
|
const live = (place: PopPlace): string => `${classFor(place)} ${DROPDOWN_LIVE_CLASS}`;
|
|
589
|
-
const at = mountAnchored(panel, anchor, pref, (p, box) => showPopupFitted(p, box, pref, live, gapPx));
|
|
730
|
+
const at = mountAnchored(panel, anchor, pref, (p, box) => showPopupFitted(p, box, pref, live, gapPx), opts?.onEscape);
|
|
590
731
|
if (at === null) showPopupFitted(panel, anchor, pref, classFor, gapPx);
|
|
591
732
|
}
|
|
592
733
|
|