soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/media-grid.ts
CHANGED
|
@@ -7,10 +7,23 @@
|
|
|
7
7
|
// 点图片抛 `select { id, item }`;视频自带控件,不抛事件。
|
|
8
8
|
|
|
9
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
10
11
|
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
12
|
+
import {
|
|
13
|
+
KIT_STATE_PANEL_CLASS_CANDIDATES, applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS,
|
|
14
|
+
} from '../base/state-panel';
|
|
11
15
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
12
16
|
import { classTokens, emptyNode, keyMap, mk, rowsOf, textOf } from './shape-util';
|
|
17
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitReadProps } from './kit-contract';
|
|
18
|
+
import { kitApplyLevelClass } from './level-class';
|
|
19
|
+
import { KIT_ATTR_COLLAPSE, KIT_ATTR_COLUMN, KIT_ATTR_LAYOUT, KIT_ATTR_MASONRY_TIER, KIT_ATTR_MEDIA, KIT_ATTR_PICK, KIT_ATTR_VIDEO_KEY, kitAttrSel } from '../shared/dom-attrs';
|
|
20
|
+
import { kitApplyCols, kitColsGrid, kitStripGridCols } from '../base/kit-contract';
|
|
21
|
+
import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
|
|
13
22
|
import { rowKey, safeImgSrc } from './d9-util';
|
|
23
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
24
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
25
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
14
27
|
import { kitText } from '../i18n/kit-text';
|
|
15
28
|
import { MEDIA_ASPECTS, MEDIA_COLUMNS, MEDIA_DEFAULT_COLUMNS, MEDIA_MAX, pickOf } from './d9-limits';
|
|
16
29
|
|
|
@@ -19,8 +32,12 @@ export const KIT_MEDIA_GRID_DEFAULT_MAP = Object.freeze({ id: 'id', src: 'src',
|
|
|
19
32
|
const ROOT_CLASS = '@container text-sm text-fg';
|
|
20
33
|
const CAPTION_CLASS = 'truncate px-1 text-xs text-fg-muted';
|
|
21
34
|
const ITEM_CLASS = 'flex flex-col gap-1';
|
|
22
|
-
|
|
23
|
-
const
|
|
35
|
+
// 媒体格 = 凹槽面的壳配方(容器边,KT-B2)
|
|
36
|
+
const FRAME_EDGE = kitShellRecipe({ tone: 'sunken', shadow: false });
|
|
37
|
+
const FRAME_STATIC = mergeClass('w-full overflow-hidden', FRAME_EDGE);
|
|
38
|
+
const FRAME_CLASS = mergeClass(mergeClass(FRAME_STATIC, 'transition-colors hover:bg-surface'), KIT_FOCUS_RING.item);
|
|
39
|
+
const SKELETON_CELL_BASE = mergeClass(mergeClass(FRAME_STATIC, kitWellRecipe()), 'motion-safe:animate-kit-pulse');
|
|
40
|
+
const MEDIA_FAIL_CLASS = mergeClass('flex min-h-24 size-full items-center justify-center p-3 text-center', kitTypographyRecipe('caption'));
|
|
24
41
|
const COVER_CLASS = 'size-full object-cover';
|
|
25
42
|
const FLOW_CLASS = 'block h-auto w-full';
|
|
26
43
|
const COLUMN_CLASS = 'flex min-w-0 flex-1 flex-col gap-3';
|
|
@@ -56,8 +73,9 @@ const ASPECT_CLASS: Readonly<Record<string, string>> = Object.freeze({
|
|
|
56
73
|
});
|
|
57
74
|
|
|
58
75
|
export const KIT_MEDIA_GRID_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
59
|
-
ROOT_CLASS, CAPTION_CLASS, ITEM_CLASS, FRAME_CLASS, FRAME_STATIC,
|
|
60
|
-
|
|
76
|
+
ROOT_CLASS, CAPTION_CLASS, ITEM_CLASS, FRAME_CLASS, FRAME_STATIC, SKELETON_CELL_BASE, MEDIA_FAIL_CLASS, COVER_CLASS, FLOW_CLASS,
|
|
77
|
+
COLUMN_CLASS, MASONRY_CLASS, MASONRY_NARROW_BOX, MASONRY_WIDE_BOX, MASONRY_MID_BOX, MASONRY_XL_BOX,
|
|
78
|
+
Object.values(GRID_COLS), Object.values(GRID_XL_COLS), Object.values(ASPECT_CLASS), KIT_STATE_PANEL_CLASS_CANDIDATES,
|
|
61
79
|
);
|
|
62
80
|
|
|
63
81
|
export interface KitMediaEntry {
|
|
@@ -119,10 +137,12 @@ export function createMediaGrid(): SomaComponentDefinition {
|
|
|
119
137
|
columns_by: { type: 'object', default: {}, desc: '分档列数 { md?, xl? }(同 columns 闭集):md = @md 档(缺省取 columns),xl = 容器达到 @xl 档(缺省同 md 档,不切换)' },
|
|
120
138
|
aspect: { type: 'string', default: 'square', desc: 'grid 排布的格形:square | video | portrait' },
|
|
121
139
|
empty_text: { type: 'string', default: '', desc: '无数据时的文案;缺省取内置文案(按页面语言)' },
|
|
140
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
122
141
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
123
142
|
},
|
|
124
143
|
emits: {
|
|
125
144
|
select: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点图片;item 是源数据行' },
|
|
145
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
126
146
|
},
|
|
127
147
|
},
|
|
128
148
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
@@ -130,9 +150,39 @@ export function createMediaGrid(): SomaComponentDefinition {
|
|
|
130
150
|
const P = (): Record<string, unknown> => api.props();
|
|
131
151
|
let root: HTMLElement | null = null;
|
|
132
152
|
|
|
133
|
-
|
|
153
|
+
/** 监听视频播放与容器分档切换:若隐藏分档里有正在播放的视频,把进度交接给可见分档对应视频并立即暂停隐藏副本防后台串音 */
|
|
154
|
+
const guardHiddenVideos = (): void => {
|
|
155
|
+
if (!root) return;
|
|
156
|
+
const win = root.ownerDocument.defaultView;
|
|
157
|
+
if (!win) return;
|
|
158
|
+
const tiers = Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_MASONRY_TIER)));
|
|
159
|
+
if (tiers.length <= 1) return;
|
|
160
|
+
const visibleTier = tiers.find((t) => win.getComputedStyle(t).display !== 'none') ?? null;
|
|
161
|
+
for (const tier of tiers) {
|
|
162
|
+
if (tier === visibleTier || win.getComputedStyle(tier).display !== 'none') continue;
|
|
163
|
+
for (const v of Array.from(tier.querySelectorAll<HTMLVideoElement>('video'))) {
|
|
164
|
+
if (v.paused) continue;
|
|
165
|
+
const key = v.getAttribute(KIT_ATTR_VIDEO_KEY) ?? '';
|
|
166
|
+
const curTime = v.currentTime;
|
|
167
|
+
v.pause();
|
|
168
|
+
if (visibleTier && key !== '') {
|
|
169
|
+
const target = Array.from(visibleTier.querySelectorAll<HTMLVideoElement>('video'))
|
|
170
|
+
.find((cand) => cand.getAttribute(KIT_ATTR_VIDEO_KEY) === key);
|
|
171
|
+
if (target) {
|
|
172
|
+
try { target.currentTime = curTime; } catch { /* 媒体未就绪忽略 */ }
|
|
173
|
+
void target.play()?.catch(() => { /* 自动播放策略拦截时静默 */ });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const itemNode = (e: KitMediaEntry, aspect: string, flow: boolean, withCaption: boolean, hostRoot: HTMLElement): HTMLElement => {
|
|
134
181
|
const box = mk('figure', ITEM_CLASS);
|
|
135
|
-
box.setAttribute(
|
|
182
|
+
box.setAttribute(KIT_ATTR_MEDIA, e.key);
|
|
183
|
+
// 每格是集合的条目(无自己的面,不是卡片)
|
|
184
|
+
kitMarkLevel(box, 'item', 'line'); kitApplyLevelClass(box);
|
|
185
|
+
const failText = (): string => (e.title !== '' ? e.title : kitText('soma.kit.img_failed', undefined, hostRoot));
|
|
136
186
|
let media: HTMLElement;
|
|
137
187
|
if (e.kind === 'video') {
|
|
138
188
|
const frame = mk('div', `${FRAME_STATIC}${flow ? '' : ` ${aspect}`}`);
|
|
@@ -140,25 +190,34 @@ export function createMediaGrid(): SomaComponentDefinition {
|
|
|
140
190
|
v.src = e.src;
|
|
141
191
|
v.controls = true;
|
|
142
192
|
v.preload = 'none';
|
|
193
|
+
v.setAttribute(KIT_ATTR_VIDEO_KEY, e.key);
|
|
143
194
|
if (e.poster !== '') v.poster = e.poster;
|
|
144
|
-
v.setAttribute('aria-label', e.title);
|
|
195
|
+
if (e.title !== '') v.setAttribute('aria-label', e.title);
|
|
196
|
+
v.addEventListener('error', () => {
|
|
197
|
+
v.replaceWith(mk('span', MEDIA_FAIL_CLASS, failText()));
|
|
198
|
+
}, { once: true });
|
|
145
199
|
frame.appendChild(v);
|
|
146
200
|
media = frame;
|
|
147
201
|
} else {
|
|
148
202
|
const btn = mk('button', `${FRAME_CLASS}${flow ? '' : ` ${aspect}`}`);
|
|
149
203
|
btn.type = 'button';
|
|
150
|
-
btn.setAttribute(
|
|
151
|
-
btn.setAttribute('aria-label', e.title
|
|
204
|
+
btn.setAttribute(KIT_ATTR_PICK, e.key);
|
|
205
|
+
if (e.title !== '') btn.setAttribute('aria-label', e.title);
|
|
206
|
+
else btn.setAttribute('aria-label', e.key);
|
|
152
207
|
const img = mk('img', flow ? FLOW_CLASS : COVER_CLASS);
|
|
153
208
|
img.src = e.src;
|
|
154
209
|
img.alt = e.title;
|
|
155
210
|
img.loading = 'lazy';
|
|
211
|
+
img.addEventListener('error', () => {
|
|
212
|
+
img.replaceWith(mk('span', MEDIA_FAIL_CLASS, failText()));
|
|
213
|
+
}, { once: true });
|
|
156
214
|
btn.appendChild(img);
|
|
157
215
|
media = btn;
|
|
158
216
|
}
|
|
159
217
|
box.appendChild(media);
|
|
160
218
|
if (withCaption && e.title !== '') {
|
|
161
219
|
const caption = mk('figcaption', CAPTION_CLASS, e.title);
|
|
220
|
+
kitMarkPart(caption, 'value');
|
|
162
221
|
caption.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
163
222
|
box.appendChild(caption);
|
|
164
223
|
}
|
|
@@ -167,57 +226,108 @@ export function createMediaGrid(): SomaComponentDefinition {
|
|
|
167
226
|
|
|
168
227
|
const paint = (): void => {
|
|
169
228
|
if (!root) return;
|
|
229
|
+
const r = root;
|
|
170
230
|
const p = P();
|
|
171
|
-
|
|
172
|
-
|
|
231
|
+
r.className = joinClass(ROOT_CLASS, p.class);
|
|
232
|
+
for (const v of Array.from(r.querySelectorAll<HTMLVideoElement>('video'))) {
|
|
233
|
+
if (!v.paused) v.pause();
|
|
234
|
+
}
|
|
235
|
+
r.textContent = '';
|
|
173
236
|
const list = mediaEntriesOf(p.data, p.map);
|
|
174
|
-
|
|
175
|
-
|
|
237
|
+
kitMarkDataFacts(r, { error: str(p.error_text).trim() !== '', loading: p.loading === true || p.loading === 'true', empty: list.length === 0 });
|
|
238
|
+
// 栅格列数:页面线布局写了闭集内多列(2..6)时用它;页面线缺省 columns=1 不压过组件自己的 columns / 缺省 3 列
|
|
239
|
+
const rawKitCols = kitReadProps(p).columns;
|
|
240
|
+
const kitCols = rawKitCols !== undefined && (MEDIA_COLUMNS as readonly number[]).includes(rawKitCols) ? rawKitCols : undefined;
|
|
241
|
+
const cols = pickOf(kitCols ?? num(p.columns) ?? MEDIA_DEFAULT_COLUMNS, MEDIA_COLUMNS, MEDIA_DEFAULT_COLUMNS);
|
|
176
242
|
const aspect = ASPECT_CLASS[pickOf(str(p.aspect), MEDIA_ASPECTS, 'square')]!;
|
|
177
243
|
const by = p.columns_by !== null && typeof p.columns_by === 'object' ? p.columns_by as Record<string, unknown> : {};
|
|
178
244
|
const mdCols = by.md === undefined ? cols : pickOf(num(by.md) ?? cols, MEDIA_COLUMNS, cols);
|
|
179
245
|
const xlCols = by.xl === undefined ? mdCols : pickOf(num(by.xl) ?? mdCols, MEDIA_COLUMNS, mdCols);
|
|
180
246
|
const gridClass = `${GRID_COLS[mdCols] ?? GRID_COLS[MEDIA_DEFAULT_COLUMNS]!}${xlCols !== mdCols ? ` ${GRID_XL_COLS[xlCols]!}` : ''}`;
|
|
247
|
+
const isGridMode = str(p.layout) !== 'masonry';
|
|
248
|
+
const nextCols = kitIsNextRuntime() && isGridMode && xlCols >= 2 ? xlCols : null;
|
|
249
|
+
// 查找从根 r 往上到本组件宿主是否存在外部 data-kit-collapse 声明(复用外部 to-single,尊重外部 none)
|
|
250
|
+
let externalCollapse: string | null = null;
|
|
251
|
+
for (let el: HTMLElement | null = r; el !== null; el = el.parentElement) {
|
|
252
|
+
const val = el.getAttribute(KIT_ATTR_COLLAPSE);
|
|
253
|
+
if (val !== null) {
|
|
254
|
+
externalCollapse = val;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
if (el.hasAttribute('data-soma-component')) break;
|
|
258
|
+
}
|
|
259
|
+
const outerVarTracks = externalCollapse === 'to-single'
|
|
260
|
+
? kitApplyCols(r, nextCols)
|
|
261
|
+
: kitApplyCols(r, null);
|
|
262
|
+
/** 栅格节点(骨架与正文共用):外部有 to-single 时复用外部容器,无外部声明时在栅格自身落 data-kit-collapse="to-single"(位于 @container 根内) */
|
|
263
|
+
const gridNode = (): HTMLElement => {
|
|
264
|
+
const g = mk('div', gridClass);
|
|
265
|
+
let varTracks = outerVarTracks;
|
|
266
|
+
if (externalCollapse === null && nextCols !== null) {
|
|
267
|
+
g.setAttribute(KIT_ATTR_COLLAPSE, 'to-single');
|
|
268
|
+
varTracks = kitApplyCols(g, nextCols);
|
|
269
|
+
}
|
|
270
|
+
if (varTracks) g.className = kitStripGridCols(gridClass);
|
|
271
|
+
kitColsGrid(g, varTracks);
|
|
272
|
+
return g;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
if (applyKitReadState(r, p, {
|
|
276
|
+
hasContent: list.length > 0,
|
|
277
|
+
onRetry: () => api.emit('retry', {}),
|
|
278
|
+
repaint: () => api.refresh(),
|
|
279
|
+
skeleton: () => {
|
|
280
|
+
const sk = gridNode();
|
|
281
|
+
sk.setAttribute('aria-hidden', 'true');
|
|
282
|
+
const count = Math.min(MEDIA_MAX, mdCols * 2);
|
|
283
|
+
for (let i = 0; i < count; i += 1) {
|
|
284
|
+
sk.appendChild(mk('div', `${SKELETON_CELL_BASE} ${aspect}`));
|
|
285
|
+
}
|
|
286
|
+
return sk;
|
|
287
|
+
},
|
|
288
|
+
})) return;
|
|
289
|
+
|
|
290
|
+
if (list.length === 0) {
|
|
291
|
+
kitApplyCols(r, null);
|
|
292
|
+
r.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, r))));
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
181
295
|
if (str(p.layout) === 'masonry') {
|
|
182
|
-
// 列数随容器收缩(与 grid 同档:容器窄于 @md 用 2 列,@md 起用设定列数):列分配与列数相关,
|
|
183
|
-
// 所以窄档、宽档各出一份列分配,用容器变体类(@md:hidden / @md:block)整块切换,不读宽度、不写内联样式。
|
|
184
|
-
// 设定列数就是 2 时只有一份,不切换。
|
|
185
296
|
const ratios = list.map((e) => e.ratio);
|
|
186
297
|
const build = (count: number): HTMLElement => {
|
|
187
298
|
const wrap = mk('div', MASONRY_CLASS);
|
|
188
|
-
wrap.setAttribute(
|
|
299
|
+
wrap.setAttribute(KIT_ATTR_LAYOUT, 'masonry');
|
|
189
300
|
for (const idxs of masonryColumns(ratios, count)) {
|
|
190
301
|
const col = mk('div', COLUMN_CLASS);
|
|
191
|
-
col.setAttribute(
|
|
192
|
-
for (const i of idxs) col.appendChild(itemNode(list[i]!, aspect, true, true));
|
|
302
|
+
col.setAttribute(KIT_ATTR_COLUMN, '');
|
|
303
|
+
for (const i of idxs) col.appendChild(itemNode(list[i]!, aspect, true, true, r));
|
|
193
304
|
wrap.appendChild(col);
|
|
194
305
|
}
|
|
195
306
|
return wrap;
|
|
196
307
|
};
|
|
308
|
+
const tierBox = (cls: string, count: number): HTMLElement => {
|
|
309
|
+
const tier = mk('div', cls);
|
|
310
|
+
tier.setAttribute(KIT_ATTR_MASONRY_TIER, '');
|
|
311
|
+
tier.appendChild(build(count));
|
|
312
|
+
return tier;
|
|
313
|
+
};
|
|
197
314
|
if (mdCols <= MASONRY_NARROW_COLUMNS && xlCols <= MASONRY_NARROW_COLUMNS) {
|
|
198
|
-
|
|
315
|
+
r.appendChild(build(MASONRY_NARROW_COLUMNS));
|
|
199
316
|
} else if (xlCols === mdCols) {
|
|
200
|
-
|
|
201
|
-
narrow.appendChild(build(MASONRY_NARROW_COLUMNS));
|
|
202
|
-
const wide = mk('div', MASONRY_WIDE_BOX);
|
|
203
|
-
wide.appendChild(build(mdCols));
|
|
204
|
-
root.append(narrow, wide);
|
|
317
|
+
r.append(tierBox(MASONRY_NARROW_BOX, MASONRY_NARROW_COLUMNS), tierBox(MASONRY_WIDE_BOX, mdCols));
|
|
205
318
|
} else {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const wide = mk('div', MASONRY_XL_BOX);
|
|
212
|
-
wide.appendChild(build(xlCols));
|
|
213
|
-
root.append(narrow, mid, wide);
|
|
319
|
+
r.append(
|
|
320
|
+
tierBox(MASONRY_NARROW_BOX, MASONRY_NARROW_COLUMNS),
|
|
321
|
+
tierBox(MASONRY_MID_BOX, mdCols),
|
|
322
|
+
tierBox(MASONRY_XL_BOX, xlCols),
|
|
323
|
+
);
|
|
214
324
|
}
|
|
215
325
|
return;
|
|
216
326
|
}
|
|
217
|
-
const wrap =
|
|
218
|
-
wrap.setAttribute(
|
|
219
|
-
for (const e of list) wrap.appendChild(itemNode(e, aspect, false, true));
|
|
220
|
-
|
|
327
|
+
const wrap = gridNode();
|
|
328
|
+
wrap.setAttribute(KIT_ATTR_LAYOUT, 'grid');
|
|
329
|
+
for (const e of list) wrap.appendChild(itemNode(e, aspect, false, true, r));
|
|
330
|
+
r.appendChild(wrap);
|
|
221
331
|
};
|
|
222
332
|
|
|
223
333
|
return {
|
|
@@ -225,14 +335,31 @@ export function createMediaGrid(): SomaComponentDefinition {
|
|
|
225
335
|
root = rootEl;
|
|
226
336
|
const r = root;
|
|
227
337
|
const onClick = (event: Event): void => {
|
|
228
|
-
const key = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
338
|
+
const key = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PICK))?.getAttribute(KIT_ATTR_PICK);
|
|
229
339
|
if (key === null || key === undefined) return;
|
|
230
340
|
const hit = mediaEntriesOf(P().data, P().map).find((e) => e.key === key);
|
|
231
341
|
if (hit) api.emit('select', { id: hit.key, item: hit.raw });
|
|
232
342
|
};
|
|
343
|
+
const onPlay = (event: Event): void => {
|
|
344
|
+
const playing = event.target;
|
|
345
|
+
if (!(playing instanceof HTMLVideoElement)) return;
|
|
346
|
+
for (const other of Array.from(r.querySelectorAll<HTMLVideoElement>('video'))) {
|
|
347
|
+
if (other !== playing && !other.paused) other.pause();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
const onTimeUpdate = (): void => {
|
|
351
|
+
guardHiddenVideos();
|
|
352
|
+
};
|
|
233
353
|
r.addEventListener('click', onClick);
|
|
354
|
+
r.addEventListener('play', onPlay, true);
|
|
355
|
+
r.addEventListener('timeupdate', onTimeUpdate, true);
|
|
234
356
|
return () => {
|
|
235
357
|
r.removeEventListener('click', onClick);
|
|
358
|
+
r.removeEventListener('play', onPlay, true);
|
|
359
|
+
r.removeEventListener('timeupdate', onTimeUpdate, true);
|
|
360
|
+
for (const v of Array.from(r.querySelectorAll<HTMLVideoElement>('video'))) {
|
|
361
|
+
if (!v.paused) v.pause();
|
|
362
|
+
}
|
|
236
363
|
root = null;
|
|
237
364
|
};
|
|
238
365
|
},
|
package/src/data/mega-menu.ts
CHANGED
|
@@ -6,24 +6,30 @@
|
|
|
6
6
|
// Home / End、Esc 关并回焦触发钮、Tab 离开即关;点外面关。选中抛 `select { item, trigger }`,有 href 的项画成 <a>(过 safeHref)。
|
|
7
7
|
// 面板开合抛 `open { id }` / `close { id }`。
|
|
8
8
|
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
9
10
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
10
11
|
import { joinClass, str } from '../base/shared';
|
|
11
|
-
import { kitIcon } from '../
|
|
12
|
+
import { kitIcon } from '../shared/icons';
|
|
12
13
|
import { kitKey, kitText } from '../i18n/kit-text';
|
|
13
14
|
import { safeHref } from '../base/link';
|
|
14
|
-
import { KIT_DROPDOWN_CLASS_CANDIDATES, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
15
|
+
import { KIT_DROPDOWN_CLASS_CANDIDATES, popPlaceClass, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
15
16
|
import { attrEsc } from './d9-util';
|
|
16
|
-
import { mergeClass } from '../
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
|
+
import { KIT_DIVIDER_FOOT_CLASS } from '../recipes/divider';
|
|
17
19
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
20
|
+
import { kitSelectedRecipe } from '../recipes/state';
|
|
21
|
+
import { kitClosedValueRecipe, kitGroupLabelRecipe } from '../recipes/field-text';
|
|
18
22
|
import { classSet, FOCUS, h, isRec, onOutsidePointer, recList, textOf, type Rec } from './menu-dom';
|
|
23
|
+
import { kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
24
|
+
import { KIT_ATTR_MEGA_ITEM, KIT_ATTR_MEGA_PANEL, KIT_ATTR_MEGA_TRIGGER, kitAttrSel } from '../shared/dom-attrs';
|
|
19
25
|
|
|
20
26
|
const ROOT_CLASS = 'relative flex flex-wrap items-center gap-1 text-sm text-fg';
|
|
21
|
-
const TRIGGER_CLASS = `inline-flex h-8 cursor-pointer items-center gap-1 rounded-
|
|
22
|
-
const TRIGGER_OPEN_CLASS =
|
|
27
|
+
const TRIGGER_CLASS = `inline-flex h-8 cursor-pointer items-center gap-1 rounded-control px-3 text-sm font-medium text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ${FOCUS}`;
|
|
28
|
+
const TRIGGER_OPEN_CLASS = mergeClass(mergeClass('inline-flex h-8 cursor-pointer items-center gap-1 rounded-control px-3 text-sm', kitSelectedRecipe()), FOCUS);
|
|
23
29
|
const CARET_CLASS = 'inline-flex';
|
|
24
30
|
// 位置类由 popup.ts 的 syncDropdown 贴边翻转时拼上(默认 left-0 top-full mt-1)
|
|
25
31
|
const PANEL_BASE_CLASS = mergeClass('absolute z-30 flex w-max max-w-full flex-col gap-3 p-4', kitSurfaceRecipe('raised'));
|
|
26
|
-
const PANEL_CLASS = `${PANEL_BASE_CLASS} start
|
|
32
|
+
const PANEL_CLASS = `${PANEL_BASE_CLASS} ${popPlaceClass({ side: 'bottom', align: 'start' })}`;
|
|
27
33
|
const GRID_CLASS: Record<number, string> = {
|
|
28
34
|
1: 'grid grid-cols-1 gap-6',
|
|
29
35
|
2: 'grid grid-cols-2 gap-6',
|
|
@@ -31,14 +37,14 @@ const GRID_CLASS: Record<number, string> = {
|
|
|
31
37
|
4: 'grid grid-cols-4 gap-6',
|
|
32
38
|
};
|
|
33
39
|
const COLUMN_CLASS = 'flex min-w-40 flex-col gap-1';
|
|
34
|
-
const COLUMN_TITLE_CLASS = 'px-3 pb-1
|
|
35
|
-
const ITEM_CLASS = `flex w-full cursor-pointer flex-col gap-0.5 rounded-
|
|
36
|
-
const ITEM_DISABLED_CLASS = 'flex w-full cursor-not-allowed flex-col gap-0.5 rounded-
|
|
40
|
+
const COLUMN_TITLE_CLASS = mergeClass('px-3 pb-1', kitGroupLabelRecipe());
|
|
41
|
+
const ITEM_CLASS = `flex w-full cursor-pointer flex-col gap-0.5 rounded-item px-3 py-2 text-start transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ${FOCUS}`;
|
|
42
|
+
const ITEM_DISABLED_CLASS = 'flex w-full cursor-not-allowed flex-col gap-0.5 rounded-item px-3 py-2 text-start text-fg-disabled **:text-fg-disabled'; // KT-K0-4
|
|
37
43
|
const ITEM_HEAD_CLASS = 'flex items-center justify-between gap-2';
|
|
38
44
|
const ITEM_LABEL_CLASS = 'min-w-0 truncate text-sm font-medium text-fg';
|
|
39
45
|
const ITEM_DESC_CLASS = 'text-xs text-fg-muted';
|
|
40
|
-
const BADGE_CLASS = 'shrink-0
|
|
41
|
-
const FOOTER_CLASS =
|
|
46
|
+
const BADGE_CLASS = mergeClass('shrink-0', kitClosedValueRecipe('primary'));
|
|
47
|
+
const FOOTER_CLASS = `${KIT_DIVIDER_FOOT_CLASS} pt-3 text-xs text-fg-muted`;
|
|
42
48
|
|
|
43
49
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
44
50
|
export const KIT_MEGA_MENU_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
@@ -82,7 +88,7 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
82
88
|
let openId = '';
|
|
83
89
|
let removeOutside: (() => void) | null = null;
|
|
84
90
|
|
|
85
|
-
const triggerEl = (id: string): HTMLElement | null => root.querySelector<HTMLElement>(`[
|
|
91
|
+
const triggerEl = (id: string): HTMLElement | null => root.querySelector<HTMLElement>(`[${KIT_ATTR_MEGA_TRIGGER}="${attrEsc(id)}"]`);
|
|
86
92
|
|
|
87
93
|
const close = (restore: boolean): void => {
|
|
88
94
|
if (openId === '') return;
|
|
@@ -108,7 +114,7 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
108
114
|
|
|
109
115
|
// 面板打开时挂在浮层端口里,不在 root 的后代中:先找面板,再在面板里找项
|
|
110
116
|
const items = (): HTMLElement[] =>
|
|
111
|
-
Array.from(queryWithDropdowns(root,
|
|
117
|
+
Array.from(queryWithDropdowns(root, kitAttrSel(KIT_ATTR_MEGA_PANEL))?.querySelectorAll<HTMLElement>(`${kitAttrSel(KIT_ATTR_MEGA_ITEM)}:not([aria-disabled="true"])`) ?? []);
|
|
112
118
|
|
|
113
119
|
function paint(): void {
|
|
114
120
|
const triggers = megaTriggersOf(props.data);
|
|
@@ -118,18 +124,24 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
118
124
|
for (const t of triggers) {
|
|
119
125
|
const isOpen = openId === t.id;
|
|
120
126
|
const b = h('button', isOpen ? TRIGGER_OPEN_CLASS : TRIGGER_CLASS, {
|
|
121
|
-
type: 'button', 'aria-haspopup': 'true', 'aria-expanded': String(isOpen),
|
|
127
|
+
type: 'button', 'aria-haspopup': 'true', 'aria-expanded': String(isOpen), [KIT_ATTR_MEGA_TRIGGER]: t.id, tabindex: '0',
|
|
122
128
|
}, h('span', '', {}, t.label), h('span', CARET_CLASS, { 'aria-hidden': 'true' }, kitIcon(isOpen ? 'chevron-up' : 'chevron-down', 'sm')));
|
|
129
|
+
kitMarkPart(b, 'action');
|
|
123
130
|
kids.push(b);
|
|
124
131
|
}
|
|
125
132
|
const current = triggers.find((t) => t.id === openId);
|
|
126
133
|
if (current) {
|
|
127
|
-
const panel = h('div', PANEL_CLASS, {
|
|
134
|
+
const panel = h('div', PANEL_CLASS, { [KIT_ATTR_MEGA_PANEL]: current.id, role: 'group', 'aria-label': current.label });
|
|
135
|
+
// 大菜单面板挂到浮层端口,是浮起(业务功能描述 §8.2)
|
|
136
|
+
kitMarkLevel(panel, 'float'); kitApplyLevelClass(panel);
|
|
128
137
|
for (let from = 0; from < current.columns.length; from += KIT_MEGA_MENU_MAX_COLUMNS) {
|
|
129
138
|
const slice = current.columns.slice(from, from + KIT_MEGA_MENU_MAX_COLUMNS);
|
|
130
139
|
const grid = h('div', GRID_CLASS[Math.min(slice.length, 4)] ?? GRID_CLASS[1]!);
|
|
131
140
|
for (const col of slice) {
|
|
132
|
-
const
|
|
141
|
+
const colTitle = col.title !== '' ? h('div', COLUMN_TITLE_CLASS, {}, col.title) : null;
|
|
142
|
+
// 栏目名是块标题
|
|
143
|
+
if (colTitle !== null) kitMarkPart(colTitle, 'block-title');
|
|
144
|
+
const c = h('div', COLUMN_CLASS, {}, colTitle);
|
|
133
145
|
col.items.forEach((it, i) => {
|
|
134
146
|
const id = textOf(it.id, `i${i}`);
|
|
135
147
|
const label = textOf(it.label, id);
|
|
@@ -141,19 +153,24 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
141
153
|
h('span', ITEM_HEAD_CLASS, {}, h('span', ITEM_LABEL_CLASS, {}, label), badge !== '' ? h('span', BADGE_CLASS, {}, badge) : null),
|
|
142
154
|
desc !== '' ? h('span', ITEM_DESC_CLASS, {}, desc) : null,
|
|
143
155
|
];
|
|
144
|
-
const attrs = {
|
|
156
|
+
const attrs = { [KIT_ATTR_MEGA_ITEM]: id, 'aria-disabled': disabled ? 'true' : undefined };
|
|
145
157
|
const el = disabled
|
|
146
158
|
? h('button', ITEM_DISABLED_CLASS, { ...attrs, type: 'button', disabled: true }, ...body)
|
|
147
159
|
: href !== ''
|
|
148
160
|
? h('a', ITEM_CLASS, { ...attrs, href }, ...body)
|
|
149
161
|
: h('button', ITEM_CLASS, { ...attrs, type: 'button' }, ...body);
|
|
150
162
|
if (!disabled) {
|
|
151
|
-
el.addEventListener('click', () => {
|
|
163
|
+
el.addEventListener('click', (event) => {
|
|
164
|
+
const me = event as MouseEvent;
|
|
165
|
+
if (el instanceof HTMLAnchorElement && !(me.ctrlKey || me.metaKey || me.shiftKey || me.altKey)) {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
}
|
|
152
168
|
const tid = openId;
|
|
153
169
|
close(true);
|
|
154
170
|
api.emit('select', { item: it, trigger: tid });
|
|
155
171
|
});
|
|
156
172
|
}
|
|
173
|
+
kitMarkPart(el, 'action');
|
|
157
174
|
c.append(el);
|
|
158
175
|
});
|
|
159
176
|
grid.append(c);
|
|
@@ -165,9 +182,9 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
165
182
|
}
|
|
166
183
|
releaseDropdownsIn(root);
|
|
167
184
|
root.replaceChildren(...kids);
|
|
168
|
-
const megaPanel = root.querySelector<HTMLElement>(
|
|
185
|
+
const megaPanel = root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_MEGA_PANEL));
|
|
169
186
|
if (megaPanel) {
|
|
170
|
-
syncDropdown(megaPanel, true, PANEL_BASE_CLASS, root);
|
|
187
|
+
syncDropdown(megaPanel, true, PANEL_BASE_CLASS, triggerEl(openId) ?? root);
|
|
171
188
|
// 面板挂到浮层后,面板内的键盘事件不再冒泡到 root:面板每次重画都是新元素,监听直接听在它上面
|
|
172
189
|
if (!root.contains(megaPanel)) megaPanel.addEventListener('keydown', onKeydown);
|
|
173
190
|
}
|
|
@@ -177,7 +194,7 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
177
194
|
const onKeydown = (event: Event): void => {
|
|
178
195
|
const e = event as KeyboardEvent;
|
|
179
196
|
const target = e.target as HTMLElement | null;
|
|
180
|
-
const trigger = target?.closest<HTMLElement>(
|
|
197
|
+
const trigger = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_MEGA_TRIGGER)) ?? null;
|
|
181
198
|
const triggers = megaTriggersOf(props.data);
|
|
182
199
|
if (e.key === 'Escape' && openId !== '') {
|
|
183
200
|
e.preventDefault();
|
|
@@ -185,7 +202,7 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
185
202
|
return;
|
|
186
203
|
}
|
|
187
204
|
if (trigger) {
|
|
188
|
-
const id = trigger.getAttribute(
|
|
205
|
+
const id = trigger.getAttribute(KIT_ATTR_MEGA_TRIGGER) ?? '';
|
|
189
206
|
if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {
|
|
190
207
|
e.preventDefault();
|
|
191
208
|
// 空格的原生 click 在 keyup 时才派发,部分浏览器 keydown 的 preventDefault 拦不住:已在这里切换过,吞掉随后那一下 click
|
|
@@ -204,10 +221,10 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
204
221
|
}
|
|
205
222
|
return;
|
|
206
223
|
}
|
|
207
|
-
if (target?.closest(
|
|
224
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_MEGA_PANEL))) {
|
|
208
225
|
const list = items();
|
|
209
226
|
if (list.length === 0) return;
|
|
210
|
-
const at = list.indexOf(target.closest<HTMLElement>(
|
|
227
|
+
const at = list.indexOf(target.closest<HTMLElement>(kitAttrSel(KIT_ATTR_MEGA_ITEM)) as HTMLElement);
|
|
211
228
|
let next = -1;
|
|
212
229
|
if (e.key === 'ArrowDown') next = at < 0 ? 0 : (at + 1) % list.length;
|
|
213
230
|
else if (e.key === 'ArrowUp') next = at <= 0 ? list.length - 1 : at - 1;
|
|
@@ -228,10 +245,10 @@ export function mountKitMegaMenu(root: HTMLElement, api: { emit(name: string, pa
|
|
|
228
245
|
setTimeout(() => { swallowSpaceClick = false; }, 0);
|
|
229
246
|
};
|
|
230
247
|
const onClick = (event: Event): void => {
|
|
231
|
-
const trigger = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
248
|
+
const trigger = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_MEGA_TRIGGER));
|
|
232
249
|
if (!trigger) return;
|
|
233
250
|
if (swallowSpaceClick) { swallowSpaceClick = false; return; }
|
|
234
|
-
const id = trigger.getAttribute(
|
|
251
|
+
const id = trigger.getAttribute(KIT_ATTR_MEGA_TRIGGER) ?? '';
|
|
235
252
|
if (openId === id) close(false); else open(id, false);
|
|
236
253
|
};
|
|
237
254
|
root.addEventListener('keydown', onKeydown);
|