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/menu.ts
CHANGED
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
// 或一个短字符(emoji 或符号,原样画);缺省收起态取标签首字;badge 是徽标文字或数字。
|
|
10
10
|
// `map` 改写键名(组件期望的键 -> 数据里的键)。当前项由 `selected`(id)给出,祖先分支自动展开;
|
|
11
11
|
// `collapsed` 为真时收成仅图标窄栏:只画一级项,分支点击抛 toggle { rail: true } 交宿主决定(通常是展开侧栏)。
|
|
12
|
-
//
|
|
12
|
+
// 语义 = 导航(nav > ul > li > a / 披露按钮):叶子是链接(当前项 aria-current=page),分支是 button aria-expanded + aria-controls,不用 tree 角色。
|
|
13
|
+
// 项上 `actions: [{ key, label }]` 在项尾画悬停 / 聚焦才显示的动作位(触屏常显),点击抛 `action { item, key }`。
|
|
14
|
+
// 键盘:Tab 按文档序进出,Enter / Space 走原生链接 / 按钮(选中或切换分组);↑↓ 走可见项、→ 展开 / ← 折叠(core 键盘接线 layout: tree)是增强。
|
|
13
15
|
// 展开状态是组件内部状态;选中抛 `select { item }`,展开折叠抛 `toggle { item, open }`。
|
|
14
16
|
|
|
17
|
+
import { kitApplyLevelClass } from './level-class';
|
|
15
18
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
19
|
import { kitText } from '../i18n/kit-text';
|
|
17
20
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
@@ -19,11 +22,21 @@ import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
|
19
22
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
20
23
|
import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
|
|
21
24
|
import { FOCUS_INSET } from '../shared/focus-ring';
|
|
25
|
+
import { kitSelectedRecipe } from '../recipes/state';
|
|
26
|
+
import { kitClosedValueRecipe, kitGroupLabelRecipe, kitIdentRecipe } from '../recipes/field-text';
|
|
27
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
28
|
+
import { mergeClass } from '../shared/merge-class';
|
|
22
29
|
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
23
|
-
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
30
|
+
import { bool, createKitController, joinClass, nextUid, str } from '../base/shared';
|
|
31
|
+
import { safeHref } from '../base/link';
|
|
32
|
+
import { actionButton, actionsOf, BUTTON_CLASS_TOKENS } from './shape-util';
|
|
24
33
|
import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
|
|
25
34
|
import { classSet, cssEscape, firstChar, h, isRec, textOf, type Rec } from './menu-dom';
|
|
26
35
|
import { mountKitMegaMenu } from './mega-menu';
|
|
36
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
37
|
+
import { buildSkeleton, KIT_SKELETON_CLASS_CANDIDATES } from '../object-renderer/skeleton';
|
|
38
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
39
|
+
import { KIT_ATTR_ACTION, KIT_ATTR_ACTION_OF, KIT_ATTR_BADGE, KIT_ATTR_KEY, KIT_ATTR_TIP, KIT_ATTR_TOGGLE, kitAttrSel } from '../shared/dom-attrs';
|
|
27
40
|
|
|
28
41
|
// ───────── 样式常量:类串与 Tailwind 候选清单 ─────────
|
|
29
42
|
|
|
@@ -44,16 +57,29 @@ export function menuChildInsetUnits(parentHasIcon: boolean): number {
|
|
|
44
57
|
const PAD_TOP = `px-${MENU_INDENT.rowInsetUnits}`;
|
|
45
58
|
const padChild = (parentHasIcon: boolean): string => `ps-${menuChildInsetUnits(parentHasIcon)} pe-${MENU_INDENT.rowInsetUnits}`;
|
|
46
59
|
// 侧栏项焦点 = 集合项焦点出口(KT-K0-3:2px 环内收,不被侧栏滚动区裁切)
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
60
|
+
// 焦点环画在可聚焦的链接 / 披露按钮上(FACE_CLASS),li 只是容器;li 相对定位以放悬停动作位
|
|
61
|
+
const ITEM_CLASS = 'group/item relative flex flex-col gap-1 rounded-item';
|
|
62
|
+
const ITEM_RAIL_CLASS = 'relative flex w-full flex-col rounded-item';
|
|
63
|
+
// 链接 / 披露按钮:铺满项宽,去掉按钮默认底边与内边距,文字起点与行一致
|
|
64
|
+
const FACE_CLASS = `block w-full rounded-item border-0 bg-transparent p-0 text-start ${FOCUS_INSET}`;
|
|
65
|
+
// 项尾悬停动作位:绝对定位在行尾,悬停 / 键盘聚焦该项时显示(触屏常显);按钮是 li 里与链接并列的兄弟,Tab 可达
|
|
66
|
+
const ACTIONS_CLASS = 'absolute inset-y-0 end-1 flex items-center gap-1 opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 pointer-coarse:opacity-100';
|
|
67
|
+
const ACTION_CLASS = 'shrink-0';
|
|
68
|
+
const rowClass = (pad: string): string => `flex ${ROW_H} cursor-pointer items-center gap-2 rounded-item ${pad} text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
|
|
50
69
|
// 选中项也有悬停 / 按下(同一档状态层,取 tonal 版:叠在主色浅底上),底色切换带过渡
|
|
51
|
-
const rowActiveClass = (pad: string): string =>
|
|
52
|
-
|
|
70
|
+
const rowActiveClass = (pad: string): string => mergeClass(
|
|
71
|
+
kitSelectedRecipe(),
|
|
72
|
+
`flex ${ROW_H} cursor-pointer items-center gap-2 rounded-item ${pad} text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
|
|
73
|
+
);
|
|
74
|
+
const rowDisabledClass = (pad: string): string => `flex ${ROW_H} cursor-not-allowed items-center gap-2 rounded-item ${pad} text-sm text-fg-disabled`;
|
|
53
75
|
const PADS: readonly string[] = [PAD_TOP, padChild(true), padChild(false)];
|
|
54
|
-
const ROW_RAIL_CLASS = `flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-
|
|
55
|
-
const ROW_RAIL_ACTIVE_CLASS =
|
|
56
|
-
|
|
76
|
+
const ROW_RAIL_CLASS = `flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-item text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
|
|
77
|
+
const ROW_RAIL_ACTIVE_CLASS = mergeClass(
|
|
78
|
+
kitSelectedRecipe(),
|
|
79
|
+
`flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-item text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
|
|
80
|
+
);
|
|
81
|
+
// 分组标题照 shadcn SidebarGroupLabel:高 32(h-8)、组间距 8(mt-2),字阶与墨色经 kitGroupLabelRecipe 统一出口
|
|
82
|
+
const HEADING_CLASS = mergeClass('mt-2 flex h-8 items-center px-3', kitGroupLabelRecipe());
|
|
57
83
|
const ICON_CLASS = 'w-5 shrink-0 text-center';
|
|
58
84
|
/** icon 写 kit 图标名时画 SVG:容器居中,不依赖字符基线 */
|
|
59
85
|
const ICON_SVG_CLASS = 'flex w-5 shrink-0 items-center justify-center';
|
|
@@ -73,18 +99,20 @@ function menuIconNode(icon: string): HTMLElement | null {
|
|
|
73
99
|
}
|
|
74
100
|
const LABEL_CLASS = 'min-w-0 flex-1 truncate';
|
|
75
101
|
const CARET_CLASS = 'w-4 shrink-0 text-center text-xs text-fg-subtle';
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
102
|
+
// 项尾徽标 = 数量 / 标记,必须有底(F7):补齐 tabular-nums 并锁定 rounded-item 统一几何(激活态不突变为圆胶囊)
|
|
103
|
+
const BADGE_GEOM = 'shrink-0 rounded-item tabular-nums';
|
|
104
|
+
const BADGE_CLASS = mergeClass(kitIdentRecipe(), BADGE_GEOM);
|
|
105
|
+
const BADGE_PRIMARY_CLASS = mergeClass(kitClosedValueRecipe('primary'), BADGE_GEOM);
|
|
106
|
+
const BADGE_DANGER_CLASS = mergeClass(kitClosedValueRecipe('danger'), BADGE_GEOM);
|
|
107
|
+
const BADGE_ACTIVE_CLASS = mergeClass(mergeClass(kitClosedValueRecipe('primary'), BADGE_GEOM), 'bg-surface text-primary-on-soft');
|
|
108
|
+
const SEP_CLASS = mergeClass(kitDividerRecipe('top', 'item'), 'my-1 w-full');
|
|
81
109
|
|
|
82
110
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
83
111
|
export const KIT_MENU_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
84
|
-
ROOT_CLASS, LIST_CLASS, LIST_RAIL_CLASS, GROUP_CLASS, ITEM_CLASS, ITEM_RAIL_CLASS,
|
|
112
|
+
ROOT_CLASS, LIST_CLASS, LIST_RAIL_CLASS, GROUP_CLASS, ITEM_CLASS, ITEM_RAIL_CLASS, FACE_CLASS, ACTIONS_CLASS, ACTION_CLASS, BUTTON_CLASS_TOKENS,
|
|
85
113
|
PADS.flatMap((pad) => [rowClass(pad), rowActiveClass(pad), rowDisabledClass(pad)]),
|
|
86
114
|
ROW_RAIL_CLASS, ROW_RAIL_ACTIVE_CLASS, HEADING_CLASS, ICON_CLASS, LABEL_CLASS, CARET_CLASS, BADGE_CLASS, BADGE_PRIMARY_CLASS,
|
|
87
|
-
BADGE_DANGER_CLASS, BADGE_ACTIVE_CLASS, SEP_CLASS, ICON_SVG_CLASS,
|
|
115
|
+
BADGE_DANGER_CLASS, BADGE_ACTIVE_CLASS, SEP_CLASS, ICON_SVG_CLASS, KIT_SKELETON_CLASS_CANDIDATES,
|
|
88
116
|
);
|
|
89
117
|
|
|
90
118
|
// ───────── 数据规整纯函数:键名对照、节点树、祖先链、可见项 ─────────
|
|
@@ -279,7 +307,7 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
279
307
|
|
|
280
308
|
const focusCursor = (): void => {
|
|
281
309
|
if (cursor === null) return;
|
|
282
|
-
root.querySelector<HTMLElement>(`[
|
|
310
|
+
root.querySelector<HTMLElement>(`[${KIT_ATTR_KEY}="${cssEscape(cursor)}"]`)?.focus();
|
|
283
311
|
};
|
|
284
312
|
|
|
285
313
|
const setOpen = (key: string, on: boolean): void => {
|
|
@@ -325,7 +353,8 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
325
353
|
sig = `cyclic:${Math.random()}`;
|
|
326
354
|
}
|
|
327
355
|
const expandAll = bool(props.expand_all);
|
|
328
|
-
|
|
356
|
+
// 独立 Menu 缺省不手风琴(用户已验收:换分支不收起其它);工作台外壳经 sidebar.accordion 显式传 true(缺省开启在外壳那一层)
|
|
357
|
+
const accordion = props.accordion === true || props.accordion === 'true';
|
|
329
358
|
if (sig !== dataSig) {
|
|
330
359
|
dataSig = sig;
|
|
331
360
|
nodes = buildMenuNodes(props.data, map);
|
|
@@ -357,29 +386,45 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
357
386
|
rail = bool(props.collapsed);
|
|
358
387
|
};
|
|
359
388
|
|
|
360
|
-
|
|
389
|
+
// 导航 = nav > ul > li > 链接 / 披露按钮(WAI 导航写法,不用 tree / treeitem):
|
|
390
|
+
// 叶子 = <a href>(没有地址退为 button);分支 = <button aria-expanded aria-controls=子列表>;当前页 aria-current=page;
|
|
391
|
+
// 项上悬停动作位 = li 里与链接并列的按钮(不嵌进链接),Tab 可达;全部项按文档序 Tab 进出,↑↓ 在可见项间移动是增强
|
|
392
|
+
const menuUid = nextUid('kit-menu');
|
|
393
|
+
const subId = (key: string): string => `${menuUid}-${key.replace(/\s+/g, '_')}`;
|
|
394
|
+
const buildItem = (n: KitMenuNode): Node[] => {
|
|
361
395
|
if (n.divider) return [h('li', SEP_CLASS, { role: 'presentation' })];
|
|
362
396
|
if (n.group) {
|
|
363
|
-
if (rail) return [h('li', SEP_CLASS, { role: 'presentation' }), ...n.children.flatMap((c) => buildItem(c
|
|
364
|
-
const
|
|
365
|
-
|
|
397
|
+
if (rail) return [h('li', SEP_CLASS, { role: 'presentation' }), ...n.children.flatMap((c) => buildItem(c))];
|
|
398
|
+
const heading = h('li', HEADING_CLASS, { role: 'presentation' }, n.label);
|
|
399
|
+
// 分组名是块标题
|
|
400
|
+
kitMarkPart(heading, 'block-title');
|
|
401
|
+
const out: Node[] = [heading];
|
|
402
|
+
for (const c of n.children) out.push(...buildItem(c));
|
|
366
403
|
return out;
|
|
367
404
|
}
|
|
368
405
|
const branch = n.children.length > 0;
|
|
369
406
|
const isOpen = branch && open.has(n.key) && !rail;
|
|
370
407
|
const active = n.key === selected;
|
|
371
|
-
const li = h('li', rail ? ITEM_RAIL_CLASS : ITEM_CLASS
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
408
|
+
const li = h('li', rail ? ITEM_RAIL_CLASS : ITEM_CLASS);
|
|
409
|
+
const href = !branch && n.href !== '' && !n.disabled ? safeHref(n.href) : '';
|
|
410
|
+
const face = h(href !== '' ? 'a' : 'button', FACE_CLASS, {
|
|
411
|
+
type: href !== '' ? undefined : 'button',
|
|
412
|
+
href: href !== '' ? href : undefined,
|
|
413
|
+
// 当前页(卡 SidebarMenu:当前项 aria-current=page);分支不是页,不写
|
|
414
|
+
'aria-current': active && !branch ? 'page' : undefined,
|
|
375
415
|
'aria-expanded': branch && !rail ? (isOpen ? 'true' : 'false') : undefined,
|
|
416
|
+
'aria-controls': isOpen ? subId(n.key) : undefined,
|
|
376
417
|
'aria-disabled': n.disabled ? 'true' : undefined,
|
|
377
418
|
'aria-label': rail ? n.label : undefined,
|
|
378
419
|
// 收起态的悬停提示走 kit 气泡(hint-tips 委托,data-kit-tip),不用原生 title(原生提示延迟长、不随主题、截图 / 触屏都没有)
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
tabindex: n.key === tabbable ? '0' : '-1',
|
|
420
|
+
[KIT_ATTR_TIP]: rail ? n.label : undefined,
|
|
421
|
+
[KIT_ATTR_KEY]: n.key,
|
|
382
422
|
});
|
|
423
|
+
// 菜单项是条目,可点的项面是动作;当前页自报「当前」(aria-current=page 已在上面写,帮手不覆盖)
|
|
424
|
+
kitMarkLevel(li, 'item'); kitApplyLevelClass(li);
|
|
425
|
+
kitMarkPart(face, 'action');
|
|
426
|
+
kitMarkPicked(face, 'current', active && !branch, null);
|
|
427
|
+
li.append(face);
|
|
383
428
|
let row: HTMLElement;
|
|
384
429
|
if (rail) {
|
|
385
430
|
row = h('div', active ? ROW_RAIL_ACTIVE_CLASS : ROW_RAIL_CLASS, {},
|
|
@@ -393,13 +438,20 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
393
438
|
row = h('div', n.disabled ? rowDisabledClass(pad) : active ? rowActiveClass(pad) : rowClass(pad), {},
|
|
394
439
|
menuIconNode(n.icon),
|
|
395
440
|
h('span', LABEL_CLASS, { [KIT_TIPS_SCOPE_ATTR]: '' }, n.label),
|
|
396
|
-
n.badge !== '' ? h('span', badgeClass, {
|
|
397
|
-
branch ? h('span', CARET_CLASS, { 'aria-hidden': 'true',
|
|
441
|
+
n.badge !== '' ? h('span', badgeClass, { [KIT_ATTR_BADGE]: '' }, n.badge) : null,
|
|
442
|
+
branch ? h('span', CARET_CLASS, { 'aria-hidden': 'true', [KIT_ATTR_TOGGLE]: '' }, kitIcon(isOpen ? 'chevron-down' : 'chevron-right', 'sm', 'rtl:-scale-x-100')) : null);
|
|
443
|
+
}
|
|
444
|
+
face.append(row);
|
|
445
|
+
// 项尾悬停动作位:悬停 / 键盘聚焦该项时显示(触屏常显),与链接并列、Tab 可达
|
|
446
|
+
const acts = rail || n.disabled ? [] : actionsOf(isRec(n.raw) ? n.raw.actions : undefined);
|
|
447
|
+
if (acts.length > 0) {
|
|
448
|
+
const box = h('span', ACTIONS_CLASS, { [KIT_ATTR_ACTION_OF]: n.key });
|
|
449
|
+
for (const a of acts) box.append(actionButton(a, ACTION_CLASS));
|
|
450
|
+
li.append(box);
|
|
398
451
|
}
|
|
399
|
-
li.append(row);
|
|
400
452
|
if (isOpen) {
|
|
401
|
-
const group = h('ul', GROUP_CLASS, {
|
|
402
|
-
for (const child of n.children) for (const node of buildItem(child
|
|
453
|
+
const group = h('ul', GROUP_CLASS, { id: subId(n.key) });
|
|
454
|
+
for (const child of n.children) for (const node of buildItem(child)) group.append(node);
|
|
403
455
|
li.append(group);
|
|
404
456
|
}
|
|
405
457
|
return [li];
|
|
@@ -407,37 +459,65 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
407
459
|
|
|
408
460
|
function paint(): void {
|
|
409
461
|
if (destroyed) return;
|
|
410
|
-
const visible = menuVisible(nodes, open, rail);
|
|
411
|
-
const tabbable = cursor !== null && visible.some((n) => n.key === cursor)
|
|
412
|
-
? cursor
|
|
413
|
-
: (visible.find((n) => n.key === selected)?.key ?? visible[0]?.key ?? null);
|
|
414
462
|
const hadFocus = root.contains(root.ownerDocument.activeElement);
|
|
415
|
-
const list = h('ul', rail ? LIST_RAIL_CLASS : LIST_CLASS
|
|
416
|
-
for (const n of nodes) for (const el of buildItem(n
|
|
417
|
-
root.replaceChildren(list);
|
|
463
|
+
const list = h('ul', rail ? LIST_RAIL_CLASS : LIST_CLASS);
|
|
464
|
+
for (const n of nodes) for (const el of buildItem(n)) list.append(el);
|
|
418
465
|
root.className = joinClass(ROOT_CLASS, props.class);
|
|
419
466
|
const label = str(props.label, kitText('soma.kit.menu', undefined, root));
|
|
420
467
|
root.setAttribute('aria-label', label);
|
|
468
|
+
root.textContent = '';
|
|
469
|
+
// 数据状态自报(与读状态面板的 data-kit-state 并存)
|
|
470
|
+
kitMarkDataFacts(root, { error: str(props.error_text) !== '', loading: props.loading === true || props.loading === 'true', empty: nodes.length === 0 });
|
|
471
|
+
// 读状态(加载中 = 与项同结构的骨架行;读取失败 + 重试):同集合三态(base/state-panel.ts);没有读状态时不碰根
|
|
472
|
+
if (applyKitReadState(root, props, {
|
|
473
|
+
hasContent: nodes.length > 0,
|
|
474
|
+
onRetry: () => emit('retry', {}),
|
|
475
|
+
repaint: paint,
|
|
476
|
+
skeleton: () => buildSkeleton(root.ownerDocument, { kind: 'stack' }),
|
|
477
|
+
})) return;
|
|
478
|
+
root.appendChild(list);
|
|
421
479
|
if (hadFocus) focusCursor();
|
|
422
480
|
}
|
|
423
481
|
|
|
424
482
|
const onClick = (event: Event): void => {
|
|
425
483
|
const target = event.target as HTMLElement | null;
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
484
|
+
// 悬停动作位:抛 action { item, key },不触发选中 / 展开
|
|
485
|
+
const actBtn = target?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
486
|
+
if (actBtn !== null && actBtn !== undefined) {
|
|
487
|
+
const owner = actBtn.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION_OF))?.getAttribute(KIT_ATTR_ACTION_OF);
|
|
488
|
+
const node = owner !== undefined && owner !== null ? byKey.get(owner) : undefined;
|
|
489
|
+
if (node !== undefined && !actBtn.disabled) emit('action', { item: node.raw, key: actBtn.getAttribute(KIT_ATTR_ACTION) ?? '' });
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const face = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
493
|
+
const key = face?.getAttribute(KIT_ATTR_KEY);
|
|
494
|
+
if (!face || !key) return;
|
|
495
|
+
// 链接由宿主路由接管(select 事件):不触发浏览器跳转;带修饰键(新标签打开等)放行
|
|
496
|
+
const me = event as MouseEvent;
|
|
497
|
+
if (face instanceof HTMLAnchorElement && !(me.ctrlKey || me.metaKey || me.shiftKey || me.altKey)) event.preventDefault();
|
|
498
|
+
cursor = key;
|
|
429
499
|
activate(key);
|
|
430
500
|
};
|
|
431
501
|
const onKeydown = (event: Event): void => {
|
|
432
502
|
const e = event as KeyboardEvent;
|
|
503
|
+
const keyed = (e.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
504
|
+
if (!keyed) return;
|
|
505
|
+
// Enter / Space 交给原生链接 / 按钮(切换分组或选中走 click),不重复接管
|
|
506
|
+
if (e.key === 'Enter' || e.key === ' ') return;
|
|
433
507
|
if (cursor === null) {
|
|
434
|
-
const first =
|
|
508
|
+
const first = keyed.getAttribute(KIT_ATTR_KEY);
|
|
435
509
|
if (first) cursor = first;
|
|
436
510
|
}
|
|
437
511
|
if (wiring.onKeydown(e)) e.preventDefault();
|
|
438
512
|
};
|
|
513
|
+
// 焦点(Tab / 点击)到哪一项,方向键就从哪一项走
|
|
514
|
+
const onFocusin = (event: Event): void => {
|
|
515
|
+
const key = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
|
|
516
|
+
if (key) cursor = key;
|
|
517
|
+
};
|
|
439
518
|
root.addEventListener('click', onClick);
|
|
440
519
|
root.addEventListener('keydown', onKeydown);
|
|
520
|
+
root.addEventListener('focusin', onFocusin);
|
|
441
521
|
|
|
442
522
|
return {
|
|
443
523
|
update(next) {
|
|
@@ -449,6 +529,7 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
449
529
|
destroyed = true;
|
|
450
530
|
root.removeEventListener('click', onClick);
|
|
451
531
|
root.removeEventListener('keydown', onKeydown);
|
|
532
|
+
root.removeEventListener('focusin', onFocusin);
|
|
452
533
|
},
|
|
453
534
|
};
|
|
454
535
|
}
|
|
@@ -465,17 +546,20 @@ export function createMenu(): SomaComponentDefinition {
|
|
|
465
546
|
data: { type: 'array', default: [], desc: '菜单数据 [{ id, label, icon?, badge?, badge_tone?, href?, disabled?, openable?, group?, open?, children? }];group 为分组标题;icon 可写 kit 图标名(画 SVG)或短字符。layout=columns 时见 layout' },
|
|
466
547
|
map: { type: 'object', default: {}, desc: '键名对照 { id, label, children, icon, badge, href }:组件期望的键 -> 数据里的键' },
|
|
467
548
|
selected: { type: 'string', default: '', desc: '当前项 id;祖先分支自动展开' },
|
|
468
|
-
accordion: { type: 'boolean', default: false, desc: '
|
|
549
|
+
accordion: { type: 'boolean', default: false, desc: '手风琴(独立 Menu 缺省关闭;工作台外壳缺省开启):选中项变化时只展开其所在的一级分支(其余收起);用户手动展开的分支保留,直到选中项落进另一个一级分支。expand_all 初始全展开时不受影响;写 false 关闭。工作台侧栏同款(sidebar.accordion)' },
|
|
469
550
|
collapsed: { type: 'boolean', default: false, desc: '收起成仅图标窄栏(只画一级,分支点击抛 toggle { rail: true })' },
|
|
470
551
|
expand_all: { type: 'boolean', default: false, desc: '初始全部展开' },
|
|
471
552
|
label: { type: 'string', default: '', desc: '导航区域的可访问名;缺省取内置文案(按页面语言)' },
|
|
553
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
472
554
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
473
555
|
},
|
|
474
556
|
emits: {
|
|
475
557
|
select: { payload: { item: { type: 'object' } }, desc: '选中某项(点击、Enter、Space);item 是源数据里的原对象' },
|
|
476
558
|
toggle: { payload: { item: { type: 'object' }, open: { type: 'boolean' }, rail: { type: 'boolean' } }, desc: '分支展开 / 折叠;收起态点击分支时 rail 为真' },
|
|
559
|
+
action: { payload: { item: { type: 'object' }, key: { type: 'string' } }, desc: '点项尾悬停动作位(项上 actions [{ key, label, tone?, disabled? }]);item 是该项源对象,key 是动作键;只上抛意图' },
|
|
477
560
|
open: { payload: { id: { type: 'string' } }, desc: 'layout=columns:面板打开' },
|
|
478
561
|
close: { payload: { id: { type: 'string' } }, desc: 'layout=columns:面板关闭' },
|
|
562
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
479
563
|
},
|
|
480
564
|
keyboard: { layout: 'tree', wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
481
565
|
},
|
package/src/data/mockup.ts
CHANGED
|
@@ -11,10 +11,16 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
11
11
|
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
12
12
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
|
-
import { classTokens, emptyNode, mk, shapeToneOf, textOf,
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { classTokens, emptyNode, mk, shapeToneOf, textOf, TONE_TEXT, type Rec, type ShapeTone } from './shape-util';
|
|
15
|
+
import { imageUrlOf, singleOf } from './display-util';
|
|
16
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
17
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
18
|
+
import { KIT_FACE_EDGE_CLASS, kitWellRecipe } from '../recipes/surface';
|
|
17
19
|
import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
|
|
20
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
21
|
+
import { mergeClass } from '../shared/merge-class';
|
|
22
|
+
import { kitHasProps } from './kit-contract';
|
|
23
|
+
import { KIT_ATTR_ADDRESS, KIT_ATTR_LINE, KIT_ATTR_VARIANT } from '../shared/dom-attrs';
|
|
18
24
|
|
|
19
25
|
export const KIT_MOCKUP_VARIANTS = ['browser', 'phone', 'window', 'code'] as const;
|
|
20
26
|
export type KitMockupVariant = (typeof KIT_MOCKUP_VARIANTS)[number];
|
|
@@ -23,36 +29,34 @@ const KEYS = ['url', 'title', 'text', 'image', 'alt', 'lines'] as const;
|
|
|
23
29
|
|
|
24
30
|
const ROOT_CLASS = 'm-0 text-fg';
|
|
25
31
|
// 示意框(浏览器 / 窗口 / 手机 / 代码)外缘 = 壳配方(容器边 + 容器阴影令牌,KT-B2);标题条只画朝内的一条分隔线(分隔线出口)
|
|
26
|
-
|
|
32
|
+
// 外框底 = 带色(surface-band);代码区 PRE_CLASS 才是井
|
|
33
|
+
const FRAME = `${KIT_FACE_EDGE_CLASS} bg-surface-band shadow-xs`;
|
|
27
34
|
const BROWSER_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
28
35
|
const WINDOW_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
29
36
|
const PHONE_CLASS = `mx-auto flex w-64 flex-col gap-2 ${FRAME} p-2 ring-2 ring-border-subtle`;
|
|
30
37
|
const CODE_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
31
38
|
const BAR_CLASS = `flex items-center gap-3 ${KIT_DIVIDER_HEAD_CLASS} px-3 py-2`;
|
|
32
39
|
const DOTS_CLASS = 'flex items-center gap-1.5';
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
40
|
+
// 窗口三点 / 刘海是装饰轮廓:用线角色描边,不拿线令牌当填充
|
|
41
|
+
const DOT_CLASS = mergeClass('size-2.5 rounded-full', kitControlEdgeRecipe({ wrapper: true, hover: false }));
|
|
42
|
+
const ADDRESS_CLASS = mergeClass(mergeClass('min-w-0 flex-1 truncate rounded-item bg-surface px-3 py-1', kitTypographyRecipe('captionPlain')), 'text-fg-muted');
|
|
43
|
+
const TITLE_CLASS = mergeClass(mergeClass('min-w-0 flex-1 truncate text-center', kitTypographyRecipe('menuGroup')), 'text-fg-muted');
|
|
36
44
|
const SPACER_CLASS = 'w-10 shrink-0';
|
|
37
|
-
const NOTCH_CLASS = 'mx-auto h-1.5 w-16 rounded-full
|
|
38
|
-
const SCREEN_CLASS = 'flex h-96 flex-col overflow-hidden rounded-
|
|
45
|
+
const NOTCH_CLASS = mergeClass('mx-auto h-1.5 w-16 rounded-full', kitControlEdgeRecipe({ wrapper: true, hover: false }));
|
|
46
|
+
const SCREEN_CLASS = 'flex h-96 flex-col overflow-hidden rounded-item bg-surface';
|
|
39
47
|
const BODY_CLASS = 'flex min-h-40 flex-col bg-surface p-4 text-sm';
|
|
40
48
|
const IMG_CLASS = 'size-full object-cover';
|
|
41
|
-
const TEXT_CLASS = 'text
|
|
42
|
-
const PRE_CLASS = 'flex flex-col overflow-auto
|
|
49
|
+
const TEXT_CLASS = kitTypographyRecipe('text');
|
|
50
|
+
const PRE_CLASS = mergeClass(mergeClass('flex flex-col overflow-auto', kitWellRecipe()), 'p-4 font-mono text-sm');
|
|
43
51
|
const LINE_CLASS = 'flex gap-3';
|
|
44
|
-
const NUM_CLASS = 'w-8 shrink-0 select-none text-end text-fg-subtle';
|
|
52
|
+
const NUM_CLASS = 'w-8 shrink-0 select-none text-end tabular-nums text-fg-subtle';
|
|
45
53
|
const PREFIX_CLASS = 'shrink-0 select-none text-fg-subtle';
|
|
46
54
|
const LINE_TEXT_CLASS = 'min-w-0 flex-1 whitespace-pre-wrap break-all';
|
|
47
55
|
|
|
48
|
-
/**
|
|
56
|
+
/** 代码行的语气:只给文字着色(彩色走 -on-soft 令牌,常态行保持正文墨色) */
|
|
49
57
|
const LINE_TONE: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
58
|
+
...TONE_TEXT,
|
|
50
59
|
neutral: 'text-fg',
|
|
51
|
-
primary: TONE_SOFT.primary,
|
|
52
|
-
info: TONE_SOFT.info,
|
|
53
|
-
success: TONE_SOFT.success,
|
|
54
|
-
warning: TONE_SOFT.warning,
|
|
55
|
-
danger: TONE_SOFT.danger,
|
|
56
60
|
});
|
|
57
61
|
|
|
58
62
|
export const KIT_MOCKUP_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -83,7 +87,7 @@ export function mockupLinesOf(raw: unknown, start = 1): KitMockupLine[] {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
function content(src: Rec): HTMLElement | null {
|
|
86
|
-
const image =
|
|
90
|
+
const image = imageUrlOf(src.image);
|
|
87
91
|
if (image !== '') {
|
|
88
92
|
const img = mk('img', IMG_CLASS);
|
|
89
93
|
img.setAttribute('src', image);
|
|
@@ -122,11 +126,13 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
122
126
|
root.textContent = '';
|
|
123
127
|
const variant = mockupVariantOf(p.variant);
|
|
124
128
|
const src = singleOf(p.data, p, KEYS);
|
|
125
|
-
root.setAttribute(
|
|
129
|
+
root.setAttribute(KIT_ATTR_VARIANT, variant);
|
|
126
130
|
if (variant === 'code') {
|
|
127
131
|
const lines = mockupLinesOf(src.lines, num(p.start) ?? 1);
|
|
128
132
|
if (lines.length === 0) { root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root)))); return; }
|
|
129
133
|
const frame = mk('div', CODE_CLASS);
|
|
134
|
+
// C 项:外框去留原按祖先判断;新流水线下交取值表,组件不再标
|
|
135
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
130
136
|
const bar = mk('div', BAR_CLASS);
|
|
131
137
|
const dots = mk('div', DOTS_CLASS);
|
|
132
138
|
for (let i = 0; i < 3; i += 1) dots.appendChild(mk('span', DOT_CLASS));
|
|
@@ -137,7 +143,7 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
137
143
|
pre.setAttribute('aria-label', kitText('soma.kit.mk_code', undefined, root));
|
|
138
144
|
for (const line of lines) {
|
|
139
145
|
const row = mk('div', LINE_CLASS);
|
|
140
|
-
row.setAttribute(
|
|
146
|
+
row.setAttribute(KIT_ATTR_LINE, String(line.no));
|
|
141
147
|
row.appendChild(mk('span', NUM_CLASS, String(line.no)));
|
|
142
148
|
if (line.prefix !== '') row.appendChild(mk('span', PREFIX_CLASS, line.prefix));
|
|
143
149
|
row.appendChild(mk('span', `${LINE_TEXT_CLASS} ${LINE_TONE[line.tone]}`, line.text));
|
|
@@ -150,6 +156,7 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
150
156
|
const body = content(src);
|
|
151
157
|
if (variant === 'phone') {
|
|
152
158
|
const frame = mk('div', PHONE_CLASS);
|
|
159
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
153
160
|
frame.appendChild(mk('div', NOTCH_CLASS));
|
|
154
161
|
const screen = mk('div', SCREEN_CLASS);
|
|
155
162
|
if (body) screen.appendChild(body); else screen.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root))));
|
|
@@ -158,13 +165,14 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
158
165
|
return;
|
|
159
166
|
}
|
|
160
167
|
const frame = mk('div', variant === 'browser' ? BROWSER_CLASS : WINDOW_CLASS);
|
|
168
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
161
169
|
const bar = mk('div', BAR_CLASS);
|
|
162
170
|
const dots = mk('div', DOTS_CLASS);
|
|
163
171
|
for (let i = 0; i < 3; i += 1) dots.appendChild(mk('span', DOT_CLASS));
|
|
164
172
|
bar.appendChild(dots);
|
|
165
173
|
if (variant === 'browser') {
|
|
166
174
|
const address = mk('div', ADDRESS_CLASS, textOf(src.url));
|
|
167
|
-
address.setAttribute(
|
|
175
|
+
address.setAttribute(KIT_ATTR_ADDRESS, '');
|
|
168
176
|
address.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
169
177
|
bar.appendChild(address);
|
|
170
178
|
} else {
|
package/src/data/modal-dialog.ts
CHANGED
|
@@ -19,8 +19,11 @@ import { mountKitOverlay } from './overlay-portal';
|
|
|
19
19
|
import { trapTab } from '../base/popup';
|
|
20
20
|
import { kitShellClasses, kitShellDom, type KitShellKind } from '../base/overlay-shell';
|
|
21
21
|
import { KIT_DRAWER_WIDTHS, kitDrawerFocusRecipe, type KitDialogTier, type KitDrawerWidth } from '../recipes/overlay';
|
|
22
|
+
import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
|
|
22
23
|
import { beginKitLeave, type KitLeaveHandle } from '../base/overlay-runtime';
|
|
23
24
|
import { lockDocumentScroll } from 'soma-core/behavior';
|
|
25
|
+
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
26
|
+
import { KIT_ATTR_LAYER } from '../shared/dom-attrs';
|
|
24
27
|
import type { OverlayMount } from 'soma-core/behavior';
|
|
25
28
|
|
|
26
29
|
/** 命令式对话框宽度档:confirm 400(确认 / 提示)、sm 480、md 640、lg 800(与声明式表单窗口的三档同一组数,px 在 kit-limits#overlay) */
|
|
@@ -30,11 +33,25 @@ export type { KitDrawerWidth };
|
|
|
30
33
|
const MODAL_TIER: Readonly<Record<KitModalSize, KitDialogTier>> = Object.freeze({ confirm: 'confirm', sm: 'default', md: 'wide', lg: 'xwide' });
|
|
31
34
|
// 面板自己(tabindex -1)获得焦点时不画轮廓,焦点环只给内部可操作元素(对话框与抽屉同一条)
|
|
32
35
|
const PANEL_FOCUS_CLASS = kitDrawerFocusRecipe();
|
|
36
|
+
/** 抽屉在窄舞台内防越界溢出(grid-cols-1 = minmax(0, 1fr) 令固有最小宽为 0、最大宽随面板,V1 Mode B 窄容器零侵入邻列,线上 fixed 态同时防进场横滚条闪烁) */
|
|
37
|
+
const DRAWER_SCRIM_SAFE_CLASS = 'grid grid-cols-1 justify-items-end min-w-0 max-w-full overflow-hidden';
|
|
38
|
+
const DRAWER_PANEL_SAFE_CLASS = 'min-w-0 max-w-full shrink overflow-hidden';
|
|
39
|
+
/** 标题长文案截断防撑爆窄抽屉头部 */
|
|
40
|
+
const OVERLAY_TITLE_SAFE_CLASS = 'min-w-0 truncate';
|
|
41
|
+
/** 引导头(确认类窗口)标题允许折行完整展示具体问句与对象名,避免删除前截断隐藏关键信息 */
|
|
42
|
+
const OVERLAY_LEAD_TITLE_SAFE_CLASS = 'min-w-0 break-words';
|
|
43
|
+
/** 关闭钮定尺寸(32×32px 闭集像素 + 柔和圆角 rounded-item + 轻按触感 press-feedback,杜绝 touch-pill 档膨胀成 44×44px 巨圆;显式保留 p-0 满足候选门禁) */
|
|
44
|
+
const OVERLAY_CLOSE_SIZE_TOKENS = ['h-[32px]', 'w-[32px]', 'rounded-item', 'p-0', 'press-feedback'] as const;
|
|
33
45
|
|
|
34
|
-
// 类串全部来自外壳的一份配方(base/overlay-shell):四档居中窗口 + 两档抽屉
|
|
46
|
+
// 类串全部来自外壳的一份配方(base/overlay-shell):四档居中窗口 + 两档抽屉 + 窄舞台安全与精致关闭钮类
|
|
35
47
|
export const KIT_MODAL_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
36
48
|
...(Object.values(MODAL_TIER).map((t) => Object.values(kitShellClasses({ kind: 'dialog', dialogTier: t, panelExtra: PANEL_FOCUS_CLASS })))),
|
|
37
49
|
...KIT_DRAWER_WIDTHS.map((w) => Object.values(kitShellClasses({ kind: 'drawer', drawerWidth: w, panelExtra: PANEL_FOCUS_CLASS }))),
|
|
50
|
+
DRAWER_SCRIM_SAFE_CLASS,
|
|
51
|
+
DRAWER_PANEL_SAFE_CLASS,
|
|
52
|
+
OVERLAY_TITLE_SAFE_CLASS,
|
|
53
|
+
OVERLAY_LEAD_TITLE_SAFE_CLASS,
|
|
54
|
+
OVERLAY_CLOSE_SIZE_TOKENS,
|
|
38
55
|
);
|
|
39
56
|
|
|
40
57
|
/** 命令式浮层(对话框 / 抽屉)共用的选项 */
|
|
@@ -64,10 +81,12 @@ export interface KitModalOptions extends KitOverlayShellOptions {
|
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
export interface KitDrawerOptions extends KitOverlayShellOptions {
|
|
67
|
-
/** 宽度档
|
|
84
|
+
/** 宽度档 default / wide(数字只在 kit-limits#overlay.drawerPx;小屏不超过视口宽),缺省 default */
|
|
68
85
|
width?: KitDrawerWidth;
|
|
69
86
|
/** 贴靠侧:目前只有 end(行内结束侧,RTL 自动换向),缺省 end */
|
|
70
87
|
side?: 'end';
|
|
88
|
+
/** 模态,缺省 true;false = 非模态侧栏详情:无遮罩、role=complementary、不锁页面滚动、不陷焦点,页面其余部分照常可操作 */
|
|
89
|
+
modal?: boolean;
|
|
71
90
|
}
|
|
72
91
|
|
|
73
92
|
export interface KitModalHandle {
|
|
@@ -91,14 +110,50 @@ export interface KitModalHandle {
|
|
|
91
110
|
export type KitDrawerHandle = KitModalHandle;
|
|
92
111
|
|
|
93
112
|
/**
|
|
94
|
-
* 命令式 Promise
|
|
113
|
+
* 命令式 Promise 对话框的卸载兜底:打开期间层锚点(或附带追踪节点如触发锚点)脱离文档时调 onGone,调用方据此收口 Promise,await 不会永久挂起。
|
|
114
|
+
* 仅观察各目标直系祖先链的 childList(禁用 document.body 的 subtree: true 全树监听),无关子树高频更新零回调。
|
|
95
115
|
* 返回停止监听的函数(收口时调用)。无 MutationObserver(SSR / 测试环境)时返回空操作。
|
|
96
116
|
*/
|
|
97
|
-
export function watchKitModalDetached(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
export function watchKitModalDetached(
|
|
118
|
+
layer: HTMLElement,
|
|
119
|
+
doc: Document,
|
|
120
|
+
onGone: () => void,
|
|
121
|
+
extraTargets?: readonly (Node | null | undefined)[],
|
|
122
|
+
): () => void {
|
|
123
|
+
const View = doc.defaultView;
|
|
124
|
+
const MO = View !== null && typeof View.MutationObserver === 'function'
|
|
125
|
+
? View.MutationObserver
|
|
126
|
+
: typeof MutationObserver !== 'undefined' ? MutationObserver : null;
|
|
127
|
+
if (MO === null) return () => {};
|
|
128
|
+
const targets: Node[] = [layer];
|
|
129
|
+
if (extraTargets !== undefined) {
|
|
130
|
+
for (const t of extraTargets) {
|
|
131
|
+
if (t !== null && t !== undefined) targets.push(t);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const observed = new Set<Node>();
|
|
135
|
+
const bindChain = (obs: MutationObserver): void => {
|
|
136
|
+
for (const t of targets) {
|
|
137
|
+
for (let anc = t.parentNode; anc !== null; anc = anc.parentNode) {
|
|
138
|
+
if (observed.has(anc)) break;
|
|
139
|
+
observed.add(anc);
|
|
140
|
+
obs.observe(anc, { childList: true });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
let watch: MutationObserver | null = null;
|
|
145
|
+
watch = new MO((records) => {
|
|
146
|
+
if (!records.some((r) => r.removedNodes.length > 0)) return;
|
|
147
|
+
for (const t of targets) {
|
|
148
|
+
if (!t.isConnected) { onGone(); return; }
|
|
149
|
+
}
|
|
150
|
+
if (watch !== null) bindChain(watch);
|
|
151
|
+
});
|
|
152
|
+
bindChain(watch);
|
|
153
|
+
return () => {
|
|
154
|
+
watch?.disconnect();
|
|
155
|
+
observed.clear();
|
|
156
|
+
};
|
|
102
157
|
}
|
|
103
158
|
|
|
104
159
|
/** 两种形态之间的差异只有哪一种窗口与档位(外壳结构、类串、标记全部在 base/overlay-shell,两种形态同一份) */
|
|
@@ -108,6 +163,8 @@ interface ShellVariant {
|
|
|
108
163
|
drawerWidth?: KitDrawerWidth;
|
|
109
164
|
/** 页脚没有任何内容时不占位(抽屉的页脚带上描边与内边距,空着会留一条空栏) */
|
|
110
165
|
hideEmptyFooter: boolean;
|
|
166
|
+
/** 非模态抽屉:false(缺省模态) */
|
|
167
|
+
modal?: boolean;
|
|
111
168
|
}
|
|
112
169
|
|
|
113
170
|
function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions, doc: Document): KitModalHandle {
|
|
@@ -115,6 +172,7 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
|
|
|
115
172
|
kind: variant.kind,
|
|
116
173
|
...(variant.dialogTier !== undefined ? { dialogTier: variant.dialogTier } : {}),
|
|
117
174
|
...(variant.drawerWidth !== undefined ? { drawerWidth: variant.drawerWidth } : {}),
|
|
175
|
+
...(variant.modal === false ? { modal: false } : {}),
|
|
118
176
|
panelExtra: PANEL_FOCUS_CLASS,
|
|
119
177
|
title: opts.title,
|
|
120
178
|
ariaLabel: opts.title,
|
|
@@ -124,6 +182,20 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
|
|
|
124
182
|
});
|
|
125
183
|
const { panel, title, body } = shell;
|
|
126
184
|
const closeBtn = shell.closeButton ?? doc.createElement('button');
|
|
185
|
+
// 抽屉在窄容器内用单轨网格(grid-cols-1 justify-items-end)收缩与裁切,杜绝向右/向左溢出侵入邻列;长标题单行省略
|
|
186
|
+
if (variant.kind === 'drawer') {
|
|
187
|
+
shell.scrim.classList.remove('flex', 'justify-end');
|
|
188
|
+
for (const c of DRAWER_SCRIM_SAFE_CLASS.split(' ')) shell.scrim.classList.add(c);
|
|
189
|
+
for (const c of DRAWER_PANEL_SAFE_CLASS.split(' ')) panel.classList.add(c);
|
|
190
|
+
}
|
|
191
|
+
const titleSafeClass = opts.lead !== undefined ? OVERLAY_LEAD_TITLE_SAFE_CLASS : OVERLAY_TITLE_SAFE_CLASS;
|
|
192
|
+
for (const c of titleSafeClass.split(' ')) title.classList.add(c);
|
|
193
|
+
title.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
194
|
+
// 关闭钮在 touch-pill 档保持精致 32×32px 柔和圆角方块(不随 density=touch + shape=pill 膨胀为 44×44px 巨圆)
|
|
195
|
+
if (shell.closeButton !== null) {
|
|
196
|
+
closeBtn.classList.remove('size-8', 'rounded-control', 'rounded-float');
|
|
197
|
+
for (const c of OVERLAY_CLOSE_SIZE_TOKENS) closeBtn.classList.add(c);
|
|
198
|
+
}
|
|
127
199
|
// opts.footer === false:页脚仍是脱离文档的空元素,写进去不显示
|
|
128
200
|
const footer = shell.footer ?? doc.createElement('div');
|
|
129
201
|
panel.tabIndex = -1;
|
|
@@ -133,6 +205,9 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
|
|
|
133
205
|
layer.hidden = true;
|
|
134
206
|
const scrim = shell.scrim;
|
|
135
207
|
scrim.setAttribute('role', 'presentation');
|
|
208
|
+
scrim.setAttribute('data-soma-host', '');
|
|
209
|
+
// 旧的表面层标记仅在 legacy 且面板尚未携带 data-kit-layer 时兜底写入;next 模式已由 overlay-shell 自报 data-kit-level="overlay",绝不裸写或覆写 data-kit-layer
|
|
210
|
+
if (!kitIsNextRuntime() && !panel.hasAttribute(KIT_ATTR_LAYER)) panel.setAttribute(KIT_ATTR_LAYER, 'float');
|
|
136
211
|
if (opts.at) {
|
|
137
212
|
const lang = opts.at.closest('[lang]')?.getAttribute('lang');
|
|
138
213
|
const dir = opts.at.closest('[dir]')?.getAttribute('dir');
|
|
@@ -173,9 +248,11 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
|
|
|
173
248
|
}
|
|
174
249
|
|
|
175
250
|
// Esc 不在这里:mountKitOverlay 的 onEscape 走层栈
|
|
176
|
-
const
|
|
251
|
+
const free = variant.modal === false;
|
|
252
|
+
// 非模态抽屉不陷焦点、没有遮罩可点
|
|
253
|
+
const onKey = (e: KeyboardEvent): void => { if (!free) trapTab(e, panel); };
|
|
177
254
|
const onScrim = (e: MouseEvent): void => {
|
|
178
|
-
if (opts.dismissOnScrim === true && e.target === scrim) opts.onClose();
|
|
255
|
+
if (!free && opts.dismissOnScrim === true && e.target === scrim) opts.onClose();
|
|
179
256
|
};
|
|
180
257
|
const onCloseClick = (): void => opts.onClose();
|
|
181
258
|
scrim.addEventListener('keydown', onKey);
|
|
@@ -191,7 +268,7 @@ function mountOverlayShell(variant: ShellVariant, opts: KitOverlayShellOptions,
|
|
|
191
268
|
prev = doc.activeElement;
|
|
192
269
|
layer.hidden = false;
|
|
193
270
|
if (variant.hideEmptyFooter && opts.footer !== false) syncFooter();
|
|
194
|
-
releaseScroll = lockDocumentScroll(doc);
|
|
271
|
+
if (!free) releaseScroll = lockDocumentScroll(doc);
|
|
195
272
|
if (leaving !== null) {
|
|
196
273
|
// 退场未结束又被打开:取消退场,遮罩仍挂着,原地复用(不重复挂载、不串状态)
|
|
197
274
|
leaving.cancel();
|
|
@@ -249,9 +326,9 @@ export function mountKitModal(opts: KitModalOptions, doc: Document = document):
|
|
|
249
326
|
|
|
250
327
|
/**
|
|
251
328
|
* 命令式抽屉:与 mountKitModal 同一份壳实现,面板贴 end 侧(RTL 自动换向)、从 end 侧滑入(250ms 进 / 200ms 出,读 motion 令牌;减弱动效只淡入淡出)。
|
|
252
|
-
*
|
|
329
|
+
* 宽度两档 default / wide;未知取值回 default(页面 DSL 的抽屉宽度非法值走 KIT-BIZ-003 诊断,命令式只在类型上约束)。
|
|
253
330
|
*/
|
|
254
331
|
export function mountKitDrawer(opts: KitDrawerOptions, doc: Document = document): KitDrawerHandle {
|
|
255
332
|
const width: KitDrawerWidth = (KIT_DRAWER_WIDTHS as readonly string[]).includes(opts.width ?? 'default') ? (opts.width ?? 'default') : 'default';
|
|
256
|
-
return mountOverlayShell({ kind: 'drawer', drawerWidth: width, hideEmptyFooter: true }, opts, doc);
|
|
333
|
+
return mountOverlayShell({ kind: 'drawer', drawerWidth: width, hideEmptyFooter: true, ...(opts.modal === false ? { modal: false } : {}) }, opts, doc);
|
|
257
334
|
}
|