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
|
@@ -10,46 +10,67 @@
|
|
|
10
10
|
// 受控:选中抛 select { value, label };开合抛 open_change { open };组件不改数据。
|
|
11
11
|
|
|
12
12
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
14
|
+
import { kitGroupLabelRecipe, kitIdentRecipe } from '../recipes/field-text';
|
|
13
15
|
import { kitText } from '../i18n/kit-text';
|
|
14
16
|
import { setKitFace, setKitFixed } from '../recipes';
|
|
15
17
|
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
16
18
|
import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
|
|
17
19
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
20
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon, kitIconHtml, resolveKitIconName } from '../shared/icons';
|
|
18
21
|
import { mergeClass } from '../shared/merge-class';
|
|
22
|
+
import { KIT_ATTR_KEY, KIT_ATTR_SCRIM } from '../shared/dom-attrs';
|
|
23
|
+
import { kitIsNextRuntime, kitLevelClassFor } from '../recipes/pipeline-runtime';
|
|
19
24
|
import type { CollectionItem } from 'soma-core/keyboard';
|
|
25
|
+
import { beginKitLeave, type KitLeaveHandle } from './overlay-runtime';
|
|
20
26
|
import {
|
|
21
27
|
EMPTY_ROW_CLASS, cssEscape, createListNav, optionClass, scrollIntoViewIfAny,
|
|
22
28
|
} from './popup';
|
|
23
29
|
import {
|
|
24
30
|
CLASS_PROP, FIELD_CLASS, ID_PROPS,
|
|
25
|
-
applyCommon, bool, classCandidates, createKitController, joinClass, nextUid, setAttr, str,
|
|
31
|
+
applyCommon, applyDisabled, bool, classCandidates, createKitController, joinClass, nextUid, setAttr, str,
|
|
32
|
+
kitMarkDataState, kitMarkInteract, kitSid,
|
|
26
33
|
} from './shared';
|
|
27
34
|
|
|
28
35
|
const ROOT = 'inline-block';
|
|
29
36
|
// 触发钮 = 带文字中性按钮描边(KT-B1);快捷键提示 = 浅底芯片(无描边);面板 = 浮层表面(KT-B4);搜索框只画朝内的一条分隔线
|
|
30
37
|
const TRIGGER_EDGE = kitButtonEdgeRecipe();
|
|
31
|
-
const TRIGGER = `inline-flex h-8 cursor-pointer items-center gap-3 rounded-
|
|
32
|
-
|
|
38
|
+
const TRIGGER = `inline-flex h-8 cursor-pointer items-center gap-3 rounded-control ${TRIGGER_EDGE} bg-surface px-3 text-sm text-fg-muted transition-colors state-layer ${KIT_FOCUS_RING.button} disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled`;
|
|
39
|
+
// 键帽 = 标识角色(中性淡底小块,field-text 的标识出口)
|
|
40
|
+
const TRIGGER_KEYS = kitIdentRecipe();
|
|
33
41
|
const HIDDEN = 'hidden';
|
|
42
|
+
// 没有可见触发钮时它仍在 DOM 里:带焦点环出口(可点的块宿主),G121 ⑥
|
|
43
|
+
const HIDDEN_TRIGGER = `hidden ${KIT_FOCUS_RING.button}`;
|
|
34
44
|
const OVERLAY = 'fixed inset-0 z-50 flex items-start justify-center bg-scrim p-4';
|
|
35
45
|
const DIALOG = mergeClass('mt-24 flex max-h-96 w-full max-w-lg flex-col overflow-hidden motion-safe:animate-kit-rise', kitSurfaceRecipe('overlay'));
|
|
36
|
-
const
|
|
46
|
+
const SEARCH_WRAP = `flex h-10 w-full shrink-0 items-center gap-2.5 ${KIT_DIVIDER_HEAD_CLASS} px-4`;
|
|
47
|
+
const SEARCH_ICON = 'pointer-events-none inline-flex shrink-0 text-fg-subtle';
|
|
48
|
+
const SEARCH = 'block h-full min-w-0 flex-1 appearance-none autofill-clear bg-transparent text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none';
|
|
37
49
|
const LIST = 'min-h-0 flex-1 overflow-auto py-1';
|
|
38
|
-
const GROUP_LABEL = 'px-4 pb-1 pt-2
|
|
50
|
+
const GROUP_LABEL = mergeClass('px-4 pb-1 pt-2', kitGroupLabelRecipe());
|
|
39
51
|
const STATUS = 'sr-only';
|
|
52
|
+
const ITEM_ICON = 'shrink-0 text-fg-muted';
|
|
40
53
|
const HINT = 'ms-auto shrink-0 text-xs text-fg-subtle';
|
|
41
54
|
const LABEL = 'min-w-0 truncate';
|
|
42
55
|
|
|
43
56
|
export const KIT_COMMAND_PALETTE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
44
|
-
ROOT, TRIGGER, TRIGGER_KEYS, HIDDEN, OVERLAY, DIALOG, SEARCH, LIST, GROUP_LABEL, STATUS, HINT, LABEL, EMPTY_ROW_CLASS,
|
|
45
|
-
FIELD_CLASS.md,
|
|
57
|
+
ROOT, TRIGGER, TRIGGER_KEYS, HIDDEN, HIDDEN_TRIGGER, OVERLAY, DIALOG, SEARCH_WRAP, SEARCH_ICON, SEARCH, LIST, GROUP_LABEL, STATUS, ITEM_ICON, HINT, LABEL, EMPTY_ROW_CLASS,
|
|
58
|
+
FIELD_CLASS.md, KIT_ICON_CLASS_CANDIDATES,
|
|
46
59
|
optionClass(false, false, false), optionClass(false, true, false), optionClass(false, false, true),
|
|
47
60
|
);
|
|
48
61
|
|
|
62
|
+
function isApplePlatform(): boolean {
|
|
63
|
+
if (typeof navigator === 'undefined') return false;
|
|
64
|
+
const uaData = (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData;
|
|
65
|
+
const platformText = `${uaData?.platform ?? ''} ${navigator.platform ?? ''} ${navigator.userAgent ?? ''}`;
|
|
66
|
+
return /mac|iphone|ipad|ipod/i.test(platformText);
|
|
67
|
+
}
|
|
68
|
+
|
|
49
69
|
export interface PaletteItem {
|
|
50
70
|
value: string;
|
|
51
71
|
raw: unknown;
|
|
52
72
|
label: string;
|
|
73
|
+
icon: string;
|
|
53
74
|
group: string;
|
|
54
75
|
hint: string;
|
|
55
76
|
keywords: string;
|
|
@@ -72,6 +93,7 @@ export function paletteItemsOf(raw: unknown): PaletteItem[] {
|
|
|
72
93
|
value,
|
|
73
94
|
raw: rec.value,
|
|
74
95
|
label: rec.label === undefined || rec.label === null ? value : String(rec.label),
|
|
96
|
+
icon: str(rec.icon),
|
|
75
97
|
group: rec.group === undefined || rec.group === null ? '' : String(rec.group),
|
|
76
98
|
hint: rec.hint === undefined || rec.hint === null ? '' : String(rec.hint),
|
|
77
99
|
keywords: Array.isArray(kw) ? kw.map((k) => String(k)).join(' ') : kw === undefined || kw === null ? '' : String(kw),
|
|
@@ -93,6 +115,39 @@ export function paletteFilter(items: readonly PaletteItem[], query: string): Pal
|
|
|
93
115
|
return order.flatMap((g) => hit.filter((it) => it.group === g));
|
|
94
116
|
}
|
|
95
117
|
|
|
118
|
+
// 全局热键(Ctrl/⌘ K)同页只由一个面板响应:同一文档里挂着多个实例时,响应的是最近打开或获得焦点的那个可响应实例(hotkey 未关闭且未禁用),
|
|
119
|
+
// 缺省是最近挂载的可响应实例;实例卸载或关闭热键 / 禁用后自动退到前一个可响应实例。每个文档一张有序名单。
|
|
120
|
+
type HotkeyOwner = { readonly eligible: () => boolean };
|
|
121
|
+
const HOTKEY_OWNERS = new WeakMap<Document, HotkeyOwner[]>();
|
|
122
|
+
function joinHotkeyOwners(doc: Document, owner: HotkeyOwner): void {
|
|
123
|
+
const list = HOTKEY_OWNERS.get(doc) ?? [];
|
|
124
|
+
list.push(owner);
|
|
125
|
+
HOTKEY_OWNERS.set(doc, list);
|
|
126
|
+
}
|
|
127
|
+
function leaveHotkeyOwners(doc: Document, owner: HotkeyOwner): void {
|
|
128
|
+
const list = HOTKEY_OWNERS.get(doc);
|
|
129
|
+
if (list === undefined) return;
|
|
130
|
+
const at = list.indexOf(owner);
|
|
131
|
+
if (at >= 0) list.splice(at, 1);
|
|
132
|
+
if (list.length === 0) HOTKEY_OWNERS.delete(doc);
|
|
133
|
+
}
|
|
134
|
+
function touchHotkeyOwner(doc: Document, owner: HotkeyOwner): void {
|
|
135
|
+
const list = HOTKEY_OWNERS.get(doc);
|
|
136
|
+
if (list === undefined || list[list.length - 1] === owner) return;
|
|
137
|
+
const at = list.indexOf(owner);
|
|
138
|
+
if (at < 0) return;
|
|
139
|
+
list.splice(at, 1);
|
|
140
|
+
list.push(owner);
|
|
141
|
+
}
|
|
142
|
+
function isHotkeyOwner(doc: Document, owner: HotkeyOwner): boolean {
|
|
143
|
+
const list = HOTKEY_OWNERS.get(doc);
|
|
144
|
+
if (list === undefined) return false;
|
|
145
|
+
for (let i = list.length - 1; i >= 0; i -= 1) {
|
|
146
|
+
if (list[i]!.eligible()) return list[i] === owner;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
96
151
|
function part(root: HTMLElement, id: string): HTMLElement {
|
|
97
152
|
return root.querySelector<HTMLElement>(`[data-soma-id="${id}"], [data-soma-scoped-id="${id}"]`) as HTMLElement;
|
|
98
153
|
}
|
|
@@ -109,7 +164,7 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
109
164
|
name: 'CommandPalette',
|
|
110
165
|
layer: 'basic',
|
|
111
166
|
props: {
|
|
112
|
-
items: { type: 'array', default: [], desc: '命令项 [{ value, label, group?, hint?, keywords?, disabled? }]' },
|
|
167
|
+
items: { type: 'array', default: [], desc: '命令项 [{ value, label, icon?, group?, hint?, keywords?, disabled? }]' },
|
|
113
168
|
open: { type: 'boolean', default: false, desc: '外部控制开合(值变化时采纳)' },
|
|
114
169
|
hotkey: { type: 'boolean', default: true, desc: '监听全局 Ctrl/⌘+K' },
|
|
115
170
|
trigger_label: { type: 'string', default: '', desc: '可见触发钮的文字;空则不画触发钮(只靠热键或 open)' },
|
|
@@ -127,14 +182,18 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
127
182
|
},
|
|
128
183
|
templateHtml:
|
|
129
184
|
`<div data-soma-id="root" class="${ROOT}">` +
|
|
130
|
-
|
|
131
|
-
|
|
185
|
+
// 自报(绘制时由骨架的 selfParts 写,见文件内 createKitController 的第二个参数):触发钮 = 控件;居中对话框 = 浮层(自成一屏),
|
|
186
|
+
// 其搜索行 = 面头,放大镜 = 图标,搜索框 = 控件;遮罩与根是纯包装不自报
|
|
187
|
+
`<button data-soma-id="trigger" type="button" aria-haspopup="dialog" class="${HIDDEN_TRIGGER}"></button>` +
|
|
188
|
+
`<div data-soma-id="overlay" ${KIT_ATTR_SCRIM}="" class="${HIDDEN}">` +
|
|
132
189
|
`<div data-soma-id="dialog" role="dialog" aria-modal="true" class="${DIALOG}">` +
|
|
133
|
-
`<
|
|
190
|
+
`<div data-soma-id="search-wrap" class="${SEARCH_WRAP}"><span aria-hidden="true" class="${SEARCH_ICON}">${kitIconHtml('search', 'sm')}</span>` +
|
|
191
|
+
`<input data-soma-id="search" type="text" role="combobox" aria-expanded="true" aria-autocomplete="list" autocomplete="off" class="${SEARCH}" /></div>` +
|
|
134
192
|
`<div data-soma-id="list" role="listbox" class="${LIST}"></div>` +
|
|
135
193
|
`<div data-soma-id="status" role="status" class="${STATUS}"></div></div></div></div>`,
|
|
136
194
|
controllerFactory: createKitController((api) => {
|
|
137
195
|
let open = false;
|
|
196
|
+
let leaving: KitLeaveHandle | null = null;
|
|
138
197
|
let query = '';
|
|
139
198
|
let cursor: string | null = null;
|
|
140
199
|
let composing = false;
|
|
@@ -145,6 +204,7 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
145
204
|
|
|
146
205
|
return {
|
|
147
206
|
attach(root, api) {
|
|
207
|
+
const doc = root.ownerDocument;
|
|
148
208
|
const trigger = part(root, 'trigger') as HTMLButtonElement;
|
|
149
209
|
const overlay = part(root, 'overlay');
|
|
150
210
|
const dialog = part(root, 'dialog');
|
|
@@ -163,26 +223,29 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
163
223
|
const shown = items();
|
|
164
224
|
list.textContent = '';
|
|
165
225
|
if (shown.length === 0) {
|
|
166
|
-
const row =
|
|
226
|
+
const row = doc.createElement('div');
|
|
167
227
|
row.className = EMPTY_ROW_CLASS;
|
|
168
228
|
row.textContent = str(p.empty_text, kitText('soma.kit.empty_command', undefined, list));
|
|
169
229
|
list.appendChild(row);
|
|
230
|
+
// 没有命中的命令 = 内容全空:自报在浮层根(对话框)上——面板挂在页面最外层,组件根留在原处只剩触发钮
|
|
231
|
+
kitMarkDataState(dialog, 'empty');
|
|
170
232
|
status.textContent = row.textContent;
|
|
171
233
|
search.removeAttribute('aria-activedescendant');
|
|
172
234
|
return;
|
|
173
235
|
}
|
|
174
236
|
status.textContent = '';
|
|
237
|
+
kitMarkDataState(dialog, 'normal');
|
|
175
238
|
let activeId = '';
|
|
176
239
|
let group: HTMLElement | null = null;
|
|
177
240
|
let lastGroup: string | null = null;
|
|
178
241
|
shown.forEach((it, index) => {
|
|
179
242
|
if (group === null || it.group !== lastGroup) {
|
|
180
243
|
lastGroup = it.group;
|
|
181
|
-
group =
|
|
244
|
+
group = doc.createElement('div');
|
|
182
245
|
group.setAttribute('role', 'group');
|
|
183
246
|
if (it.group !== '') {
|
|
184
247
|
const labelId = `${listId}-g${index}`;
|
|
185
|
-
const head =
|
|
248
|
+
const head = doc.createElement('div');
|
|
186
249
|
head.id = labelId;
|
|
187
250
|
head.className = GROUP_LABEL;
|
|
188
251
|
head.textContent = it.group;
|
|
@@ -191,21 +254,27 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
191
254
|
}
|
|
192
255
|
list.appendChild(group);
|
|
193
256
|
}
|
|
194
|
-
const el =
|
|
257
|
+
const el = doc.createElement('div');
|
|
195
258
|
const id = `${listId}-${index}`;
|
|
196
259
|
const active = cursor === it.value;
|
|
197
260
|
el.id = id;
|
|
198
261
|
el.setAttribute('role', 'option');
|
|
199
|
-
el.setAttribute(
|
|
262
|
+
el.setAttribute(KIT_ATTR_KEY, it.value);
|
|
200
263
|
el.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
201
264
|
if (it.disabled) el.setAttribute('aria-disabled', 'true');
|
|
202
265
|
el.className = optionClass(false, active, it.disabled);
|
|
203
|
-
|
|
266
|
+
// 键盘游标所在项 = 激活(当前项);aria-selected 已随游标写,结构交互状态另自报给取值表
|
|
267
|
+
kitMarkInteract(el, 'current', active);
|
|
268
|
+
const iconName = resolveKitIconName(it.icon);
|
|
269
|
+
if (iconName !== null) {
|
|
270
|
+
el.appendChild(kitIcon(iconName, 'sm', ITEM_ICON));
|
|
271
|
+
}
|
|
272
|
+
const label = doc.createElement('span');
|
|
204
273
|
label.className = LABEL;
|
|
205
274
|
label.textContent = it.label;
|
|
206
275
|
el.appendChild(label);
|
|
207
276
|
if (it.hint !== '') {
|
|
208
|
-
const hint =
|
|
277
|
+
const hint = doc.createElement('span');
|
|
209
278
|
hint.className = HINT;
|
|
210
279
|
hint.textContent = it.hint;
|
|
211
280
|
el.appendChild(hint);
|
|
@@ -217,17 +286,23 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
217
286
|
if (activeId !== '') scrollIntoViewIfAny(list.querySelector(`#${cssEscape(activeId)}`));
|
|
218
287
|
};
|
|
219
288
|
|
|
289
|
+
const finalizeClosedDom = (): void => {
|
|
290
|
+
overlay.className = HIDDEN;
|
|
291
|
+
setKitFixed(overlay, false);
|
|
292
|
+
list.textContent = '';
|
|
293
|
+
status.textContent = '';
|
|
294
|
+
search.removeAttribute('aria-activedescendant');
|
|
295
|
+
};
|
|
296
|
+
|
|
220
297
|
const paint = (): void => {
|
|
221
|
-
overlay.className = open ? OVERLAY : HIDDEN;
|
|
222
|
-
setKitFixed(overlay, open); // 仅展开时才是 fixed:闲置态不抑制祖先毛玻璃
|
|
223
298
|
trigger.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
224
299
|
if (open) {
|
|
300
|
+
overlay.className = OVERLAY;
|
|
301
|
+
setKitFixed(overlay, true); // 仅展开时才是 fixed:闲置态不抑制祖先毛玻璃
|
|
225
302
|
paintList();
|
|
226
303
|
if (search.value !== query) search.value = query;
|
|
227
|
-
} else {
|
|
228
|
-
|
|
229
|
-
status.textContent = '';
|
|
230
|
-
search.removeAttribute('aria-activedescendant');
|
|
304
|
+
} else if (leaving === null) {
|
|
305
|
+
finalizeClosedDom();
|
|
231
306
|
}
|
|
232
307
|
};
|
|
233
308
|
paintFn = paint;
|
|
@@ -237,8 +312,13 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
237
312
|
if (next && bool(api.props().disabled)) return;
|
|
238
313
|
open = next;
|
|
239
314
|
if (open) {
|
|
240
|
-
|
|
241
|
-
|
|
315
|
+
touchHotkeyOwner(doc, owner);
|
|
316
|
+
if (leaving !== null) {
|
|
317
|
+
leaving.cancel();
|
|
318
|
+
leaving = null;
|
|
319
|
+
}
|
|
320
|
+
returnTo = doc.activeElement instanceof HTMLElement && !root.contains(doc.activeElement)
|
|
321
|
+
? doc.activeElement
|
|
242
322
|
: trigger;
|
|
243
323
|
query = '';
|
|
244
324
|
cursor = firstEnabled();
|
|
@@ -246,7 +326,13 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
246
326
|
search.focus();
|
|
247
327
|
} else {
|
|
248
328
|
cursor = null;
|
|
249
|
-
|
|
329
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
330
|
+
const handle = beginKitLeave(overlay, () => {
|
|
331
|
+
leaving = null;
|
|
332
|
+
if (!open) finalizeClosedDom();
|
|
333
|
+
});
|
|
334
|
+
leaving = handle;
|
|
335
|
+
if (handle === null) finalizeClosedDom();
|
|
250
336
|
const back = returnTo;
|
|
251
337
|
returnTo = null;
|
|
252
338
|
if (back && back.isConnected && typeof back.focus === 'function') back.focus();
|
|
@@ -303,14 +389,24 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
303
389
|
};
|
|
304
390
|
const onListDown = (event: Event): void => { event.preventDefault(); };
|
|
305
391
|
const onListClick = (event: Event): void => {
|
|
306
|
-
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
307
|
-
const key = row?.getAttribute(
|
|
392
|
+
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_KEY}]`);
|
|
393
|
+
const key = row?.getAttribute(KIT_ATTR_KEY);
|
|
308
394
|
if (key !== null && key !== undefined) run(key);
|
|
309
395
|
};
|
|
310
396
|
const onTrigger = (): void => setOpen(!open);
|
|
397
|
+
const onFocusIn = (): void => touchHotkeyOwner(doc, owner);
|
|
398
|
+
const owner: HotkeyOwner = {
|
|
399
|
+
eligible: () => {
|
|
400
|
+
const p = api.props();
|
|
401
|
+
return p.hotkey !== false && p.hotkey !== 'false' && !bool(p.disabled);
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
joinHotkeyOwners(doc, owner);
|
|
311
405
|
const onCompStart = (): void => { composing = true; };
|
|
312
406
|
const onCompEnd = (): void => { composing = false; onSearchInput(); };
|
|
313
407
|
const onHotkey = (event: KeyboardEvent): void => {
|
|
408
|
+
// 同页多个面板:全局热键只由最近打开或获得焦点的可响应实例处理(跳过 hotkey: false 或 disabled 实例)
|
|
409
|
+
if (!isHotkeyOwner(doc, owner)) return;
|
|
314
410
|
const p = api.props();
|
|
315
411
|
if (p.hotkey === false || p.hotkey === 'false' || bool(p.disabled)) return;
|
|
316
412
|
if ((event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === 'k') {
|
|
@@ -327,8 +423,11 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
327
423
|
list.addEventListener('mousedown', onListDown);
|
|
328
424
|
list.addEventListener('click', onListClick);
|
|
329
425
|
trigger.addEventListener('click', onTrigger);
|
|
330
|
-
|
|
426
|
+
root.addEventListener('focusin', onFocusIn);
|
|
427
|
+
doc.addEventListener('keydown', onHotkey);
|
|
331
428
|
return () => {
|
|
429
|
+
leaveHotkeyOwners(doc, owner);
|
|
430
|
+
root.removeEventListener('focusin', onFocusIn);
|
|
332
431
|
search.removeEventListener('input', onSearchInput);
|
|
333
432
|
search.removeEventListener('compositionstart', onCompStart);
|
|
334
433
|
search.removeEventListener('compositionend', onCompEnd);
|
|
@@ -337,7 +436,9 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
337
436
|
list.removeEventListener('mousedown', onListDown);
|
|
338
437
|
list.removeEventListener('click', onListClick);
|
|
339
438
|
trigger.removeEventListener('click', onTrigger);
|
|
340
|
-
|
|
439
|
+
doc.removeEventListener('keydown', onHotkey);
|
|
440
|
+
leaving?.cancel();
|
|
441
|
+
leaving = null;
|
|
341
442
|
paintFn = null;
|
|
342
443
|
setOpenFn = null;
|
|
343
444
|
open = false;
|
|
@@ -345,26 +446,32 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
345
446
|
};
|
|
346
447
|
},
|
|
347
448
|
render(root, p) {
|
|
449
|
+
const doc = root.ownerDocument;
|
|
348
450
|
const trigger = part(root, 'trigger') as HTMLButtonElement;
|
|
451
|
+
const searchWrap = part(root, 'search-wrap');
|
|
349
452
|
const search = part(root, 'search') as HTMLInputElement;
|
|
350
453
|
const dialog = part(root, 'dialog');
|
|
351
454
|
const label = str(p.trigger_label);
|
|
352
455
|
trigger.textContent = '';
|
|
353
456
|
if (label !== '') {
|
|
354
|
-
const text =
|
|
457
|
+
const text = doc.createElement('span');
|
|
355
458
|
text.textContent = label;
|
|
356
|
-
const keys =
|
|
459
|
+
const keys = doc.createElement('span');
|
|
357
460
|
keys.className = TRIGGER_KEYS;
|
|
358
461
|
keys.setAttribute('aria-hidden', 'true');
|
|
359
|
-
keys.textContent = 'Ctrl K';
|
|
462
|
+
keys.textContent = isApplePlatform() ? '⌘K' : 'Ctrl K';
|
|
360
463
|
trigger.append(text, keys);
|
|
361
464
|
}
|
|
362
|
-
trigger.className = label === '' ?
|
|
465
|
+
trigger.className = label === '' ? HIDDEN_TRIGGER : TRIGGER;
|
|
363
466
|
// 触发钮带边框与底色,同 Button 标 raised(隐藏时无害)
|
|
364
467
|
setKitFace(trigger, 'raised');
|
|
365
|
-
|
|
468
|
+
// 原生 disabled + aria-disabled 同写(原来只写了原生 disabled)
|
|
469
|
+
applyDisabled(trigger, bool(p.disabled));
|
|
366
470
|
applyCommon(trigger, { id: p.id });
|
|
367
471
|
dialog.setAttribute('aria-label', str(p.label, kitText('soma.kit.command_palette', undefined, root)));
|
|
472
|
+
if (searchWrap) searchWrap.className = kitLevelClassFor(searchWrap, SEARCH_WRAP);
|
|
473
|
+
// 对话框在模板里自报了浮层、类只在模板里:新模式下按层级角色剥掉取值表负责的类(幂等;旧版不动)
|
|
474
|
+
if (kitIsNextRuntime()) dialog.className = kitLevelClassFor(dialog, dialog.className);
|
|
368
475
|
search.placeholder = str(p.placeholder, kitText('soma.kit.command_placeholder', undefined, root));
|
|
369
476
|
search.className = SEARCH;
|
|
370
477
|
root.className = joinClass(ROOT, p.class);
|
|
@@ -376,6 +483,11 @@ export function createCommandPalette(): SomaComponentDefinition {
|
|
|
376
483
|
paintFn?.();
|
|
377
484
|
},
|
|
378
485
|
};
|
|
486
|
+
}, {
|
|
487
|
+
selfParts: [
|
|
488
|
+
[kitSid('trigger'), { level: 'control' }], [kitSid('dialog'), { level: 'overlay' }], [kitSid('search-wrap'), { level: 'head' }],
|
|
489
|
+
['[data-soma-scoped-id="search-wrap"] > span, [data-soma-id="search-wrap"] > span', { part: 'icon' }], [kitSid('search'), { part: 'control' }],
|
|
490
|
+
],
|
|
379
491
|
}),
|
|
380
492
|
};
|
|
381
493
|
}
|
package/src/base/context-menu.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// 3. 触发区的外观:虚线框的「右键此处」区域。
|
|
9
9
|
|
|
10
10
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
11
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
11
12
|
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
12
13
|
import { classCandidates } from './shared';
|
|
13
14
|
|
|
@@ -25,9 +26,10 @@ export const CONTEXT_SHOWN: Record<Corner, string> = {
|
|
|
25
26
|
export const CONTEXT_POINT_PANEL = `fixed z-50 flex min-w-40 flex-col ${MENU_PANEL_SURFACE} p-1`;
|
|
26
27
|
// 右键触发区 = 控件(虚线控件轮廓,与上传投放区同一出口,KT-B1 / §4 C6)
|
|
27
28
|
const AREA_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
28
|
-
export const CONTEXT_AREA ='block w-full cursor-context-menu rounded-
|
|
29
|
-
export const CONTEXT_AREA_OFF = 'block w-full cursor-not-allowed rounded-
|
|
29
|
+
export const CONTEXT_AREA ='block w-full cursor-context-menu rounded-card ' + AREA_EDGE + ' border-dashed bg-surface px-4 py-6 text-center text-sm text-fg-muted transition-colors state-layer ' + KIT_FOCUS_RING.button;
|
|
30
|
+
export const CONTEXT_AREA_OFF = 'block w-full cursor-not-allowed rounded-card ' + AREA_EDGE + ' border-dashed bg-control-disabled px-4 py-6 text-center text-sm text-fg-disabled'; // KT-K0-4
|
|
30
31
|
const LONG_PRESS_MS = 500;
|
|
32
|
+
const LONG_PRESS_MOVE_TOLERANCE_PX = 8;
|
|
31
33
|
|
|
32
34
|
export const KIT_CONTEXT_MENU_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
33
35
|
Object.values(CONTEXT_SHOWN), CONTEXT_POINT_PANEL, CONTEXT_AREA, CONTEXT_AREA_OFF,
|
|
@@ -63,11 +65,15 @@ export interface ContextTriggerOptions {
|
|
|
63
65
|
export function wireContextTrigger(o: ContextTriggerOptions): () => void {
|
|
64
66
|
const { area } = o;
|
|
65
67
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
68
|
+
let startX = 0;
|
|
69
|
+
let startY = 0;
|
|
70
|
+
let pressPointerId: number | null = null;
|
|
66
71
|
const clearPress = (): void => {
|
|
67
72
|
if (timer !== null) {
|
|
68
73
|
clearTimeout(timer);
|
|
69
74
|
timer = null;
|
|
70
75
|
}
|
|
76
|
+
pressPointerId = null;
|
|
71
77
|
};
|
|
72
78
|
const onContext = (event: MouseEvent): void => {
|
|
73
79
|
if (!o.active() || o.accepts?.(event) === false) return;
|
|
@@ -84,18 +90,29 @@ export function wireContextTrigger(o: ContextTriggerOptions): () => void {
|
|
|
84
90
|
const onDown = (event: PointerEvent): void => {
|
|
85
91
|
if (!o.active() || event.pointerType === 'mouse' || !o.longPress() || o.accepts?.(event) === false) return;
|
|
86
92
|
clearPress();
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
startX = event.clientX;
|
|
94
|
+
startY = event.clientY;
|
|
95
|
+
pressPointerId = typeof event.pointerId === 'number' ? event.pointerId : null;
|
|
96
|
+
const x = startX;
|
|
97
|
+
const y = startY;
|
|
89
98
|
timer = setTimeout(() => {
|
|
90
99
|
timer = null;
|
|
100
|
+
pressPointerId = null;
|
|
91
101
|
o.openAt(cornerOf(x, y, area.getBoundingClientRect()), { x, y });
|
|
92
102
|
}, LONG_PRESS_MS);
|
|
93
103
|
};
|
|
104
|
+
const onMove = (event: PointerEvent): void => {
|
|
105
|
+
if (timer === null) return;
|
|
106
|
+
if (pressPointerId !== null && typeof event.pointerId === 'number' && event.pointerId !== pressPointerId) return;
|
|
107
|
+
const dx = event.clientX - startX;
|
|
108
|
+
const dy = event.clientY - startY;
|
|
109
|
+
if (Math.hypot(dx, dy) > LONG_PRESS_MOVE_TOLERANCE_PX) clearPress();
|
|
110
|
+
};
|
|
94
111
|
area.addEventListener('contextmenu', onContext);
|
|
95
112
|
area.addEventListener('keydown', onKey);
|
|
96
113
|
area.addEventListener('pointerdown', onDown);
|
|
97
114
|
area.addEventListener('pointerup', clearPress);
|
|
98
|
-
area.addEventListener('pointermove',
|
|
115
|
+
area.addEventListener('pointermove', onMove);
|
|
99
116
|
area.addEventListener('pointercancel', clearPress);
|
|
100
117
|
return () => {
|
|
101
118
|
clearPress();
|
|
@@ -103,7 +120,7 @@ export function wireContextTrigger(o: ContextTriggerOptions): () => void {
|
|
|
103
120
|
area.removeEventListener('keydown', onKey);
|
|
104
121
|
area.removeEventListener('pointerdown', onDown);
|
|
105
122
|
area.removeEventListener('pointerup', clearPress);
|
|
106
|
-
area.removeEventListener('pointermove',
|
|
123
|
+
area.removeEventListener('pointermove', onMove);
|
|
107
124
|
area.removeEventListener('pointercancel', clearPress);
|
|
108
125
|
};
|
|
109
126
|
}
|
package/src/base/countdown.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
8
8
|
import {
|
|
9
9
|
CLASS_PROP, ID_PROPS, SIZE_PROP,
|
|
10
10
|
applyCommon, classCandidates, createKitController, joinClass, num, sizeOf, str,
|
|
11
|
+
kitMarkDataState, kitOuterRoot, kitRootChild,
|
|
11
12
|
type KitApi, type KitSize, type KitView,
|
|
12
13
|
} from './shared';
|
|
13
14
|
import { kitText } from '../i18n/kit-text';
|
|
@@ -64,6 +65,7 @@ export function formatRemaining(totalSeconds: number, format: CountdownFormat):
|
|
|
64
65
|
interface State {
|
|
65
66
|
key: string;
|
|
66
67
|
deadline: number | null;
|
|
68
|
+
hadPositive: boolean;
|
|
67
69
|
fired: boolean;
|
|
68
70
|
timer: ReturnType<typeof setInterval> | null;
|
|
69
71
|
api: KitApi | null;
|
|
@@ -71,7 +73,20 @@ interface State {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
function makeView(): KitView {
|
|
74
|
-
const st: State = { key: '', deadline: null, fired: false, timer: null, api: null, root: null };
|
|
76
|
+
const st: State = { key: '', deadline: null, hadPositive: false, fired: false, timer: null, api: null, root: null };
|
|
77
|
+
|
|
78
|
+
const stopTimer = (): void => {
|
|
79
|
+
if (st.timer !== null) {
|
|
80
|
+
clearInterval(st.timer);
|
|
81
|
+
st.timer = null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const ensureTimer = (): void => {
|
|
86
|
+
if (st.timer === null && st.root !== null && st.deadline !== null && st.deadline > Date.now()) {
|
|
87
|
+
st.timer = setInterval(tick, 1000);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
75
90
|
|
|
76
91
|
const tick = (): void => {
|
|
77
92
|
const root = st.root;
|
|
@@ -92,15 +107,16 @@ function makeView(): KitView {
|
|
|
92
107
|
label.className = labelText === '' ? HIDDEN : LABEL_CLASS;
|
|
93
108
|
if (st.deadline !== null) {
|
|
94
109
|
if (done) live.textContent = finishedText;
|
|
95
|
-
else if (remaining % 60 === 0 || remaining === 30 || remaining === 10) live.textContent = kitText('soma.kit.cd_remaining', { label: labelText, time: formatRemaining(remaining,
|
|
110
|
+
else if (remaining % 60 === 0 || remaining === 30 || remaining === 10) live.textContent = kitText('soma.kit.cd_remaining', { label: labelText, time: formatRemaining(remaining, format) }, root).trim();
|
|
111
|
+
} else {
|
|
112
|
+
live.textContent = '';
|
|
96
113
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
if (st.
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
if (st.deadline === null || done) {
|
|
115
|
+
stopTimer();
|
|
116
|
+
if (done && st.deadline !== null && st.hadPositive && !st.fired) {
|
|
117
|
+
st.fired = true;
|
|
118
|
+
api.emit('complete', {});
|
|
102
119
|
}
|
|
103
|
-
api.emit('complete', {});
|
|
104
120
|
}
|
|
105
121
|
};
|
|
106
122
|
|
|
@@ -108,10 +124,9 @@ function makeView(): KitView {
|
|
|
108
124
|
attach(root, api) {
|
|
109
125
|
st.root = root;
|
|
110
126
|
st.api = api;
|
|
111
|
-
|
|
127
|
+
ensureTimer();
|
|
112
128
|
return () => {
|
|
113
|
-
|
|
114
|
-
st.timer = null;
|
|
129
|
+
stopTimer();
|
|
115
130
|
st.root = null;
|
|
116
131
|
st.api = null;
|
|
117
132
|
};
|
|
@@ -128,14 +143,19 @@ function makeView(): KitView {
|
|
|
128
143
|
if (key !== st.key) {
|
|
129
144
|
st.key = key;
|
|
130
145
|
st.fired = false;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
const now = Date.now();
|
|
147
|
+
st.deadline = targetMs !== null ? targetMs : secs !== null ? now + Math.max(0, secs) * 1000 : null;
|
|
148
|
+
const initialRemaining = st.deadline === null ? 0 : Math.max(0, Math.ceil((st.deadline - now) / 1000));
|
|
149
|
+
st.hadPositive = initialRemaining > 0;
|
|
150
|
+
if (st.hadPositive) ensureTimer();
|
|
151
|
+
else stopTimer();
|
|
134
152
|
}
|
|
135
153
|
root.className = joinClass(ROOT_CLASS[size], p.class);
|
|
136
154
|
(root.children[1] as HTMLElement).className = DIGITS_CLASS;
|
|
137
155
|
(root.children[2] as HTMLElement).className = SR_CLASS;
|
|
138
156
|
applyCommon(root, { id: p.id, aria_label: p.aria_label });
|
|
157
|
+
// 没给截止时刻也没给秒数 = 没有可倒数的值:组件根报「内容全空」
|
|
158
|
+
kitMarkDataState(kitOuterRoot(api.host, root), st.deadline === null ? 'empty' : 'normal');
|
|
139
159
|
tick();
|
|
140
160
|
},
|
|
141
161
|
};
|
|
@@ -162,7 +182,9 @@ export function createCountdown(): SomaComponentDefinition {
|
|
|
162
182
|
complete: { payload: {}, desc: '倒数归零时抛一次(target / seconds 变化后可再抛)' },
|
|
163
183
|
},
|
|
164
184
|
},
|
|
185
|
+
// 倒计时是值:根只报元素部件;数字前的说明文字是字段名
|
|
165
186
|
templateHtml: `<span data-soma-id="root" role="timer" class="${ROOT_CLASS.md}"><span class="${HIDDEN}"></span><span aria-hidden="true" class="${DIGITS_CLASS}"></span><span aria-live="polite" class="${SR_CLASS}"></span></span>`,
|
|
166
|
-
|
|
187
|
+
// 前缀标签位自报「字段名」:绘制时写(不拼进静态模板,模板求值时的模式不可靠)
|
|
188
|
+
controllerFactory: createKitController(() => makeView(), { self: { part: 'value' }, selfParts: [[kitRootChild('span:first-child'), { part: 'field-name' }]] }),
|
|
167
189
|
};
|
|
168
190
|
}
|