@kumix/ui 0.3.17 → 0.4.0
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 +30 -18
- package/dist/account-avatar-DILzuuvz.js +23 -0
- package/dist/account-avatar-DILzuuvz.js.map +1 -0
- package/dist/{cascader-types-BnH6wYD-.d.ts → cascader-types-DVT-znZ-.d.ts} +6 -3
- package/dist/cascader-types-DVT-znZ-.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/approval-card/index.js +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/message-bubble.js +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/voice-orb.d.ts +19 -0
- package/dist/components/agents/voice-orb.d.ts.map +1 -0
- package/dist/components/agents/voice-orb.js +389 -0
- package/dist/components/agents/voice-orb.js.map +1 -0
- package/dist/components/charts/bump-chart/context.d.ts +2 -0
- package/dist/components/charts/bump-chart/context.js +3 -0
- package/dist/components/charts/bump-chart/legend.d.ts +6 -0
- package/dist/components/charts/bump-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/legend.js +60 -0
- package/dist/components/charts/bump-chart/legend.js.map +1 -0
- package/dist/components/charts/bump-chart/plot.d.ts +6 -0
- package/dist/components/charts/bump-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/plot.js +3 -0
- package/dist/components/charts/bump-chart/point.d.ts +10 -0
- package/dist/components/charts/bump-chart/point.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/point.js +124 -0
- package/dist/components/charts/bump-chart/point.js.map +1 -0
- package/dist/components/charts/bump-chart/series.d.ts +11 -0
- package/dist/components/charts/bump-chart/series.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/series.js +101 -0
- package/dist/components/charts/bump-chart/series.js.map +1 -0
- package/dist/components/charts/bump-chart.d.ts +10 -0
- package/dist/components/charts/bump-chart.d.ts.map +1 -0
- package/dist/components/charts/bump-chart.js +23 -0
- package/dist/components/charts/bump-chart.js.map +1 -0
- package/dist/components/charts/composition-chart/context.d.ts +2 -0
- package/dist/components/charts/composition-chart/context.js +3 -0
- package/dist/components/charts/composition-chart/legend.d.ts +6 -0
- package/dist/components/charts/composition-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/legend.js +51 -0
- package/dist/components/charts/composition-chart/legend.js.map +1 -0
- package/dist/components/charts/composition-chart/plot.d.ts +6 -0
- package/dist/components/charts/composition-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/plot.js +174 -0
- package/dist/components/charts/composition-chart/plot.js.map +1 -0
- package/dist/components/charts/composition-chart/tooltip-content.d.ts +6 -0
- package/dist/components/charts/composition-chart/tooltip-content.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/tooltip-content.js +63 -0
- package/dist/components/charts/composition-chart/tooltip-content.js.map +1 -0
- package/dist/components/charts/composition-chart.d.ts +9 -0
- package/dist/components/charts/composition-chart.d.ts.map +1 -0
- package/dist/components/charts/composition-chart.js +26 -0
- package/dist/components/charts/composition-chart.js.map +1 -0
- package/dist/components/charts/funnel-chart.d.ts +50 -0
- package/dist/components/charts/funnel-chart.d.ts.map +1 -0
- package/dist/components/charts/funnel-chart.js +216 -0
- package/dist/components/charts/funnel-chart.js.map +1 -0
- package/dist/components/charts/heat-calendar/grid.d.ts +8 -0
- package/dist/components/charts/heat-calendar/grid.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar/grid.js +127 -0
- package/dist/components/charts/heat-calendar/grid.js.map +1 -0
- package/dist/components/charts/heat-calendar/legend.d.ts +6 -0
- package/dist/components/charts/heat-calendar/legend.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar/legend.js +48 -0
- package/dist/components/charts/heat-calendar/legend.js.map +1 -0
- package/dist/components/charts/heat-calendar/tooltip.d.ts +2 -0
- package/dist/components/charts/heat-calendar/tooltip.js +50 -0
- package/dist/components/charts/heat-calendar/tooltip.js.map +1 -0
- package/dist/components/charts/heat-calendar.d.ts +9 -0
- package/dist/components/charts/heat-calendar.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar.js +23 -0
- package/dist/components/charts/heat-calendar.js.map +1 -0
- package/dist/components/charts/liquidity-heatmap.d.ts +51 -0
- package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -0
- package/dist/components/charts/liquidity-heatmap.js +311 -0
- package/dist/components/charts/liquidity-heatmap.js.map +1 -0
- package/dist/components/charts/order-book/depth-row.d.ts +13 -0
- package/dist/components/charts/order-book/depth-row.d.ts.map +1 -0
- package/dist/components/charts/order-book/depth-row.js +99 -0
- package/dist/components/charts/order-book/depth-row.js.map +1 -0
- package/dist/components/charts/order-book.d.ts +57 -0
- package/dist/components/charts/order-book.d.ts.map +1 -0
- package/dist/components/charts/order-book.js +207 -0
- package/dist/components/charts/order-book.js.map +1 -0
- package/dist/components/charts/price-target-fan/header.d.ts +8 -0
- package/dist/components/charts/price-target-fan/header.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/header.js +43 -0
- package/dist/components/charts/price-target-fan/header.js.map +1 -0
- package/dist/components/charts/price-target-fan/plot.d.ts +16 -0
- package/dist/components/charts/price-target-fan/plot.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/plot.js +142 -0
- package/dist/components/charts/price-target-fan/plot.js.map +1 -0
- package/dist/components/charts/price-target-fan/series.d.ts +15 -0
- package/dist/components/charts/price-target-fan/series.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/series.js +238 -0
- package/dist/components/charts/price-target-fan/series.js.map +1 -0
- package/dist/components/charts/price-target-fan/tooltip.d.ts +2 -0
- package/dist/components/charts/price-target-fan/tooltip.js +58 -0
- package/dist/components/charts/price-target-fan/tooltip.js.map +1 -0
- package/dist/components/charts/price-target-fan.d.ts +10 -0
- package/dist/components/charts/price-target-fan.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan.js +24 -0
- package/dist/components/charts/price-target-fan.js.map +1 -0
- package/dist/components/charts/returns-calendar/grid.d.ts +8 -0
- package/dist/components/charts/returns-calendar/grid.d.ts.map +1 -0
- package/dist/components/charts/returns-calendar/grid.js +176 -0
- package/dist/components/charts/returns-calendar/grid.js.map +1 -0
- package/dist/components/charts/returns-calendar/tooltip.d.ts +2 -0
- package/dist/components/charts/returns-calendar/tooltip.js +55 -0
- package/dist/components/charts/returns-calendar/tooltip.js.map +1 -0
- package/dist/components/charts/returns-calendar.d.ts +48 -0
- package/dist/components/charts/returns-calendar.d.ts.map +1 -0
- package/dist/components/charts/returns-calendar.js +22 -0
- package/dist/components/charts/returns-calendar.js.map +1 -0
- package/dist/components/charts/status-bar/legend.d.ts +8 -0
- package/dist/components/charts/status-bar/legend.d.ts.map +1 -0
- package/dist/components/charts/status-bar/legend.js +37 -0
- package/dist/components/charts/status-bar/legend.js.map +1 -0
- package/dist/components/charts/status-bar/plot.d.ts +12 -0
- package/dist/components/charts/status-bar/plot.d.ts.map +1 -0
- package/dist/components/charts/status-bar/plot.js +176 -0
- package/dist/components/charts/status-bar/plot.js.map +1 -0
- package/dist/components/charts/status-bar/tooltip.d.ts +2 -0
- package/dist/components/charts/status-bar/tooltip.js +49 -0
- package/dist/components/charts/status-bar/tooltip.js.map +1 -0
- package/dist/components/charts/status-bar.d.ts +9 -0
- package/dist/components/charts/status-bar.d.ts.map +1 -0
- package/dist/components/charts/status-bar.js +64 -0
- package/dist/components/charts/status-bar.js.map +1 -0
- package/dist/components/charts/treemap/legend.d.ts +8 -0
- package/dist/components/charts/treemap/legend.d.ts.map +1 -0
- package/dist/components/charts/treemap/legend.js +35 -0
- package/dist/components/charts/treemap/legend.js.map +1 -0
- package/dist/components/charts/treemap/plot.d.ts +13 -0
- package/dist/components/charts/treemap/plot.d.ts.map +1 -0
- package/dist/components/charts/treemap/plot.js +123 -0
- package/dist/components/charts/treemap/plot.js.map +1 -0
- package/dist/components/charts/treemap/tile.d.ts +10 -0
- package/dist/components/charts/treemap/tile.d.ts.map +1 -0
- package/dist/components/charts/treemap/tile.js +114 -0
- package/dist/components/charts/treemap/tile.js.map +1 -0
- package/dist/components/charts/treemap/tooltip.d.ts +11 -0
- package/dist/components/charts/treemap/tooltip.d.ts.map +1 -0
- package/dist/components/charts/treemap/tooltip.js +73 -0
- package/dist/components/charts/treemap/tooltip.js.map +1 -0
- package/dist/components/charts/treemap.d.ts +56 -0
- package/dist/components/charts/treemap.d.ts.map +1 -0
- package/dist/components/charts/treemap.js +71 -0
- package/dist/components/charts/treemap.js.map +1 -0
- package/dist/components/charts/volume-profile/plot.d.ts +12 -0
- package/dist/components/charts/volume-profile/plot.d.ts.map +1 -0
- package/dist/components/charts/volume-profile/plot.js +211 -0
- package/dist/components/charts/volume-profile/plot.js.map +1 -0
- package/dist/components/charts/volume-profile/summary.d.ts +6 -0
- package/dist/components/charts/volume-profile/summary.d.ts.map +1 -0
- package/dist/components/charts/volume-profile/summary.js +76 -0
- package/dist/components/charts/volume-profile/summary.js.map +1 -0
- package/dist/components/charts/volume-profile/tooltip.d.ts +2 -0
- package/dist/components/charts/volume-profile/tooltip.js +84 -0
- package/dist/components/charts/volume-profile/tooltip.js.map +1 -0
- package/dist/components/charts/volume-profile.d.ts +111 -0
- package/dist/components/charts/volume-profile.d.ts.map +1 -0
- package/dist/components/charts/volume-profile.js +82 -0
- package/dist/components/charts/volume-profile.js.map +1 -0
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/alert.d.ts +40 -0
- package/dist/components/motion/alert.d.ts.map +1 -0
- package/dist/components/motion/alert.js +247 -0
- package/dist/components/motion/alert.js.map +1 -0
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/arc-picker.d.ts +28 -0
- package/dist/components/motion/arc-picker.d.ts.map +1 -0
- package/dist/components/motion/arc-picker.js +569 -0
- package/dist/components/motion/arc-picker.js.map +1 -0
- package/dist/components/motion/aspect-ratio.d.ts +23 -0
- package/dist/components/motion/aspect-ratio.d.ts.map +1 -0
- package/dist/components/motion/aspect-ratio.js +61 -0
- package/dist/components/motion/aspect-ratio.js.map +1 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +2 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/breadcrumb.d.ts +37 -0
- package/dist/components/motion/breadcrumb.d.ts.map +1 -0
- package/dist/components/motion/breadcrumb.js +259 -0
- package/dist/components/motion/breadcrumb.js.map +1 -0
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/collapsible.d.ts +34 -0
- package/dist/components/motion/collapsible.d.ts.map +1 -0
- package/dist/components/motion/collapsible.js +237 -0
- package/dist/components/motion/collapsible.js.map +1 -0
- package/dist/components/motion/color-selector.d.ts +28 -0
- package/dist/components/motion/color-selector.d.ts.map +1 -0
- package/dist/components/motion/color-selector.js +97 -0
- package/dist/components/motion/color-selector.js.map +1 -0
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/command-palette.js +1 -1
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/date-range-picker.d.ts +107 -0
- package/dist/components/motion/date-range-picker.d.ts.map +1 -0
- package/dist/components/motion/date-range-picker.js +907 -0
- package/dist/components/motion/date-range-picker.js.map +1 -0
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/knockout-bracket.d.ts +190 -0
- package/dist/components/motion/knockout-bracket.d.ts.map +1 -0
- package/dist/components/motion/knockout-bracket.js +952 -0
- package/dist/components/motion/knockout-bracket.js.map +1 -0
- package/dist/components/motion/knockout-wheel.d.ts +183 -0
- package/dist/components/motion/knockout-wheel.d.ts.map +1 -0
- package/dist/components/motion/knockout-wheel.js +1039 -0
- package/dist/components/motion/knockout-wheel.js.map +1 -0
- package/dist/components/motion/morphing-lightbox.d.ts +67 -0
- package/dist/components/motion/morphing-lightbox.d.ts.map +1 -0
- package/dist/components/motion/morphing-lightbox.js +499 -0
- package/dist/components/motion/morphing-lightbox.js.map +1 -0
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/popover-morph.d.ts +5 -1
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +78 -27
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/prediction-market-card.d.ts +37 -0
- package/dist/components/motion/prediction-market-card.d.ts.map +1 -0
- package/dist/components/motion/prediction-market-card.js +216 -0
- package/dist/components/motion/prediction-market-card.js.map +1 -0
- package/dist/components/motion/prediction-market.d.ts +49 -0
- package/dist/components/motion/prediction-market.d.ts.map +1 -0
- package/dist/components/motion/prediction-market.js +440 -0
- package/dist/components/motion/prediction-market.js.map +1 -0
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/sortable-list.d.ts +53 -0
- package/dist/components/motion/sortable-list.d.ts.map +1 -0
- package/dist/components/motion/sortable-list.js +254 -0
- package/dist/components/motion/sortable-list.js.map +1 -0
- package/dist/components/motion/sortable-stack.d.ts +2 -0
- package/dist/components/motion/sortable-stack.js +3 -0
- package/dist/components/motion/swap/controls.d.ts +22 -0
- package/dist/components/motion/swap/controls.d.ts.map +1 -0
- package/dist/components/motion/swap/controls.js +167 -0
- package/dist/components/motion/swap/controls.js.map +1 -0
- package/dist/components/motion/swap/field.d.ts +14 -0
- package/dist/components/motion/swap/field.d.ts.map +1 -0
- package/dist/components/motion/swap/field.js +107 -0
- package/dist/components/motion/swap/field.js.map +1 -0
- package/dist/components/motion/swap/quote-row.d.ts +13 -0
- package/dist/components/motion/swap/quote-row.d.ts.map +1 -0
- package/dist/components/motion/swap/quote-row.js +55 -0
- package/dist/components/motion/swap/quote-row.js.map +1 -0
- package/dist/components/motion/swap/token-badges.d.ts +19 -0
- package/dist/components/motion/swap/token-badges.d.ts.map +1 -0
- package/dist/components/motion/swap/token-badges.js +54 -0
- package/dist/components/motion/swap/token-badges.js.map +1 -0
- package/dist/components/motion/swap/token-picker.d.ts +14 -0
- package/dist/components/motion/swap/token-picker.d.ts.map +1 -0
- package/dist/components/motion/swap/token-picker.js +190 -0
- package/dist/components/motion/swap/token-picker.js.map +1 -0
- package/dist/components/motion/swap.d.ts +14 -0
- package/dist/components/motion/swap.d.ts.map +1 -0
- package/dist/components/motion/swap.js +378 -0
- package/dist/components/motion/swap.js.map +1 -0
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/tabs.d.ts +5 -9
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +14 -5
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/tooltip/positioner.d.ts +33 -0
- package/dist/components/motion/tooltip/positioner.d.ts.map +1 -0
- package/dist/components/motion/tooltip/positioner.js +3 -0
- package/dist/components/motion/tooltip-surface.d.ts +5 -4
- package/dist/components/motion/tooltip-surface.d.ts.map +1 -1
- package/dist/components/motion/tooltip-surface.js +22 -73
- package/dist/components/motion/tooltip-surface.js.map +1 -1
- package/dist/components/motion/tooltip.d.ts +3 -1
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +54 -103
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wallet-card/account-avatar.d.ts +8 -0
- package/dist/components/motion/wallet-card/account-avatar.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/account-avatar.js +3 -0
- package/dist/components/motion/wallet-card/account-switcher.d.ts +14 -0
- package/dist/components/motion/wallet-card/account-switcher.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/account-switcher.js +153 -0
- package/dist/components/motion/wallet-card/account-switcher.js.map +1 -0
- package/dist/components/motion/wallet-card/actions.d.ts +12 -0
- package/dist/components/motion/wallet-card/actions.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/actions.js +58 -0
- package/dist/components/motion/wallet-card/actions.js.map +1 -0
- package/dist/components/motion/wallet-card/balance-delta.d.ts +12 -0
- package/dist/components/motion/wallet-card/balance-delta.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/balance-delta.js +72 -0
- package/dist/components/motion/wallet-card/balance-delta.js.map +1 -0
- package/dist/components/motion/wallet-card/copy-button.d.ts +12 -0
- package/dist/components/motion/wallet-card/copy-button.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/copy-button.js +41 -0
- package/dist/components/motion/wallet-card/copy-button.js.map +1 -0
- package/dist/components/motion/wallet-card/index.d.ts +13 -0
- package/dist/components/motion/wallet-card/index.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/index.js +115 -0
- package/dist/components/motion/wallet-card/index.js.map +1 -0
- package/dist/components/motion/wallet-card/search-bar.d.ts +17 -0
- package/dist/components/motion/wallet-card/search-bar.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/search-bar.js +156 -0
- package/dist/components/motion/wallet-card/search-bar.js.map +1 -0
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +3 -2
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-async.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +4 -4
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts +12 -4
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-context.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts +2 -2
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +23 -17
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts +8 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.js +19 -11
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +6 -5
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -1
- package/dist/components/reui/cascader/cascader.d.ts +6 -2
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +59 -21
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +3 -3
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +18 -14
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -2
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +85 -61
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +7 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +68 -39
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +7 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +90 -26
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +157 -38
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +16 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +81 -51
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/filters/filters-advanced.js +2 -2
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts +1 -1
- package/dist/components/reui/filters/filters-builder.js +1 -1
- package/dist/components/reui/filters/filters-chip.js +2 -2
- package/dist/components/reui/filters/filters-editors.js +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +30 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/signature-pad.d.ts +160 -0
- package/dist/components/reui/signature-pad.d.ts.map +1 -0
- package/dist/components/reui/signature-pad.js +764 -0
- package/dist/components/reui/signature-pad.js.map +1 -0
- package/dist/components/reui/time-picker.d.ts +202 -0
- package/dist/components/reui/time-picker.d.ts.map +1 -0
- package/dist/components/reui/time-picker.js +1002 -0
- package/dist/components/reui/time-picker.js.map +1 -0
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/constants-CsKm9sSk.js +30 -0
- package/dist/constants-CsKm9sSk.js.map +1 -0
- package/dist/context-3_vY1jbv.js +141 -0
- package/dist/context-3_vY1jbv.js.map +1 -0
- package/dist/context-BE60udRT.js +99 -0
- package/dist/context-BE60udRT.js.map +1 -0
- package/dist/context-BYXeJQnz.d.ts +150 -0
- package/dist/context-BYXeJQnz.d.ts.map +1 -0
- package/dist/context-Bc6VC1HA.js +181 -0
- package/dist/context-Bc6VC1HA.js.map +1 -0
- package/dist/context-BqjZ1Z_w.js +111 -0
- package/dist/context-BqjZ1Z_w.js.map +1 -0
- package/dist/context-CZfRKkcZ.js +204 -0
- package/dist/context-CZfRKkcZ.js.map +1 -0
- package/dist/context-Cn-00gfW.js +169 -0
- package/dist/context-Cn-00gfW.js.map +1 -0
- package/dist/context-Cnlo53sV.d.ts +92 -0
- package/dist/context-Cnlo53sV.d.ts.map +1 -0
- package/dist/context-Rl5VCYA8.js +257 -0
- package/dist/context-Rl5VCYA8.js.map +1 -0
- package/dist/context-sD8DQga-.js +122 -0
- package/dist/context-sD8DQga-.js.map +1 -0
- package/dist/{copy-menu-TIKvPaAZ.js → copy-menu-C5GaT4Z-.js} +2 -2
- package/dist/{copy-menu-TIKvPaAZ.js.map → copy-menu-C5GaT4Z-.js.map} +1 -1
- package/dist/ease-B82HVmio.d.ts +50 -0
- package/dist/ease-B82HVmio.d.ts.map +1 -0
- package/dist/hooks/use-modal-scope.d.ts +6 -0
- package/dist/hooks/use-modal-scope.d.ts.map +1 -0
- package/dist/hooks/use-modal-scope.js +83 -0
- package/dist/hooks/use-modal-scope.js.map +1 -0
- package/dist/lib/ease.d.ts +2 -49
- package/dist/model-DfeFradZ.d.ts +9 -0
- package/dist/model-DfeFradZ.d.ts.map +1 -0
- package/dist/model-DlbIqCZg.d.ts +41 -0
- package/dist/model-DlbIqCZg.d.ts.map +1 -0
- package/dist/plot-CdFTbMI_.js +131 -0
- package/dist/plot-CdFTbMI_.js.map +1 -0
- package/dist/positioner-3mCqiebN.js +204 -0
- package/dist/positioner-3mCqiebN.js.map +1 -0
- package/dist/tooltip-BarafYiU.d.ts +67 -0
- package/dist/tooltip-BarafYiU.d.ts.map +1 -0
- package/dist/tooltip-BqxVD6D-.d.ts +64 -0
- package/dist/tooltip-BqxVD6D-.d.ts.map +1 -0
- package/dist/tooltip-C01qUgsW.d.ts +133 -0
- package/dist/tooltip-C01qUgsW.d.ts.map +1 -0
- package/dist/tooltip-C6qUs7px.d.ts +36 -0
- package/dist/tooltip-C6qUs7px.d.ts.map +1 -0
- package/dist/tooltip-DQ4DXgeu.d.ts +94 -0
- package/dist/tooltip-DQ4DXgeu.d.ts.map +1 -0
- package/dist/types-B_6p3LXz.d.ts +36 -0
- package/dist/types-B_6p3LXz.d.ts.map +1 -0
- package/dist/types-D6e3gWOA.d.ts +22 -0
- package/dist/types-D6e3gWOA.d.ts.map +1 -0
- package/dist/use-geometry-CH0foIo7.d.ts +9 -0
- package/dist/use-geometry-CH0foIo7.d.ts.map +1 -0
- package/dist/utils-B3YXTsDI.js +26 -0
- package/dist/utils-B3YXTsDI.js.map +1 -0
- package/package.json +14 -9
- package/dist/cascader-types-BnH6wYD-.d.ts.map +0 -1
- package/dist/lib/ease.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morphing-search.js","names":[],"sources":["../../../src/components/motion/morphing-search.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type KeyboardEvent as ReactKeyboardEvent,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport {\n AnimatePresence,\n LayoutGroup,\n motion,\n type Transition,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\n\n// Keeps the Wallet Card feel with a little more time to read the morph.\nconst SEARCH_MORPH: Transition = {\n type: \"spring\",\n duration: 0.58,\n bounce: 0.22,\n};\n\n// Keep the spring on the shell, but unfold complex clip-path values with the\n// same progressive tween as Morph Popover so the content never snaps ahead.\nconst SEARCH_CLIP_TRANSITION: Transition = {\n duration: 0.32,\n ease: EASE_OUT,\n};\n\nexport type MorphingSearchItem = {\n id: string;\n title: string;\n description?: string;\n keywords?: string[];\n icon?: LucideIcon;\n onSelect?: () => void;\n};\n\nexport interface MorphingSearchProps {\n items: MorphingSearchItem[];\n placeholder?: string;\n shortcut?: string;\n /** Render the closed trigger as a compact search icon. */\n iconOnly?: boolean;\n emptyMessage?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n onQueryChange?: (query: string) => void;\n onSelect?: (item: MorphingSearchItem) => void;\n className?: string;\n}\n\ntype AnchorRect = {\n top: number;\n left: number;\n width: number;\n};\n\nfunction isEditableTarget(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) return false;\n return (\n target.isContentEditable ||\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target instanceof HTMLSelectElement\n );\n}\n\nexport function MorphingSearch({\n items,\n placeholder = \"Search\",\n shortcut = \"f\",\n iconOnly = false,\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n onQueryChange,\n onSelect,\n className,\n}: MorphingSearchProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [query, setQuery] = useState(\"\");\n const [mounted, setMounted] = useState(false);\n const [backgroundScrollLocked, setBackgroundScrollLocked] = useState(defaultOpen);\n const [anchorRect, setAnchorRect] = useState<AnchorRect>({\n top: 16,\n left: 16,\n width: 288,\n });\n const open = controlledOpen ?? internalOpen;\n const controlled = controlledOpen !== undefined;\n const reduce = useReducedMotion();\n const uid = useId();\n const anchorRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const wasOpenRef = useRef(open);\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const morphTransition: Transition = reduce ? { duration: 0 } : SEARCH_MORPH;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const measureAnchor = useCallback(() => {\n const rect = anchorRef.current?.getBoundingClientRect();\n if (!rect || rect.width === 0) return;\n setAnchorRect({ top: rect.top, left: rect.left, width: rect.width });\n }, []);\n\n const openSearch = useCallback(() => {\n measureAnchor();\n setBackgroundScrollLocked(true);\n previousFocusRef.current =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n setOpen(true);\n }, [measureAnchor, setOpen]);\n\n const filteredItems = useMemo(() => {\n const needle = query.trim().toLowerCase();\n if (!needle) return items;\n\n return items.filter((item) =>\n [item.title, item.description ?? \"\", ...(item.keywords ?? [])]\n .join(\" \")\n .toLowerCase()\n .includes(needle),\n );\n }, [items, query]);\n\n const { activeIndex, moveTo, moveActive } = useRowCursor(filteredItems, query);\n\n // The cursor is stamped with the query, so changing it drops the highlight\n // without this having to say so.\n const updateQuery = useCallback(\n (next: string) => {\n setQuery(next);\n onQueryChange?.(next);\n },\n [onQueryChange],\n );\n\n const closeSearch = useCallback(() => {\n updateQuery(\"\");\n setOpen(false);\n }, [setOpen, updateQuery]);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (open) setBackgroundScrollLocked(true);\n }, [open]);\n\n useEffect(() => {\n measureAnchor();\n const anchor = anchorRef.current;\n const observer =\n anchor && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(measureAnchor) : null;\n if (anchor) observer?.observe(anchor);\n window.addEventListener(\"resize\", measureAnchor);\n document.addEventListener(\"scroll\", measureAnchor, true);\n window.visualViewport?.addEventListener(\"resize\", measureAnchor);\n window.visualViewport?.addEventListener(\"scroll\", measureAnchor);\n return () => {\n observer?.disconnect();\n window.removeEventListener(\"resize\", measureAnchor);\n document.removeEventListener(\"scroll\", measureAnchor, true);\n window.visualViewport?.removeEventListener(\"resize\", measureAnchor);\n window.visualViewport?.removeEventListener(\"scroll\", measureAnchor);\n };\n }, [measureAnchor]);\n\n useEffect(() => {\n if (!backgroundScrollLocked) return;\n\n const preventBackgroundWheel = (event: WheelEvent) => {\n const target = event.target;\n if (target instanceof Node && listRef.current?.contains(target)) return;\n event.preventDefault();\n };\n const preventBackgroundTouch = (event: TouchEvent) => {\n const target = event.target;\n if (target instanceof Node && listRef.current?.contains(target)) return;\n event.preventDefault();\n };\n\n document.addEventListener(\"wheel\", preventBackgroundWheel, {\n passive: false,\n });\n document.addEventListener(\"touchmove\", preventBackgroundTouch, {\n passive: false,\n });\n return () => {\n document.removeEventListener(\"wheel\", preventBackgroundWheel);\n document.removeEventListener(\"touchmove\", preventBackgroundTouch);\n };\n }, [backgroundScrollLocked]);\n\n useEffect(() => {\n const handleShortcut = (event: KeyboardEvent) => {\n if (event.key === \"Escape\" && open) {\n event.preventDefault();\n closeSearch();\n return;\n }\n\n if (\n !open &&\n shortcut &&\n event.key.toLowerCase() === shortcut.toLowerCase() &&\n !event.repeat &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.altKey &&\n !event.shiftKey &&\n !isEditableTarget(event.target)\n ) {\n event.preventDefault();\n openSearch();\n }\n };\n\n window.addEventListener(\"keydown\", handleShortcut);\n return () => window.removeEventListener(\"keydown\", handleShortcut);\n }, [closeSearch, open, openSearch, shortcut]);\n\n // Only this component's own state. Telling the consumer the query changed is\n // a side effect, so it waits for the effect below.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n // Keyed to `open` alone. `onQueryChange` is read through a ref because an\n // inline one changes identity on every keystroke, and this effect clearing\n // the field on every keystroke is exactly what that costs. Written after\n // commit for the reason `lib/hooks/use-row-cursor.ts` gives at length.\n const notifyQuery = useRef(onQueryChange);\n useLayoutEffect(() => {\n notifyQuery.current = onQueryChange;\n });\n\n useEffect(() => {\n if (open) {\n notifyQuery.current?.(\"\");\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }\n\n if (wasOpenRef.current) {\n const frame = requestAnimationFrame(() => {\n const previousFocus = previousFocusRef.current;\n const focusTarget = previousFocus?.isConnected ? previousFocus : triggerRef.current;\n focusTarget?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }\n }, [open]);\n\n useEffect(() => {\n wasOpenRef.current = open;\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n listRef.current\n ?.querySelector<HTMLElement>(`[data-index=\"${activeIndex}\"]`)\n ?.scrollIntoView({ block: \"nearest\" });\n }, [activeIndex, open]);\n\n const selectItem = useCallback(\n (item: MorphingSearchItem) => {\n item.onSelect?.();\n onSelect?.(item);\n closeSearch();\n },\n [closeSearch, onSelect],\n );\n\n const handleDialogKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n moveActive(1);\n return;\n }\n\n if (event.key === \"ArrowUp\") {\n event.preventDefault();\n moveActive(-1);\n return;\n }\n\n if (event.key === \"Enter\") {\n event.preventDefault();\n const item = filteredItems[activeIndex];\n if (item) selectItem(item);\n return;\n }\n\n if (event.key !== \"Tab\" || !dialogRef.current) return;\n const focusable = Array.from(\n dialogRef.current.querySelectorAll<HTMLElement>(\n 'input, button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n ),\n );\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) return;\n\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const shellLayoutId = `${uid}-shell`;\n const listboxId = `${uid}-results`;\n const panelWidth = mounted\n ? Math.max(anchorRect.width, Math.min(448, window.innerWidth - anchorRect.left - 16))\n : anchorRect.width;\n const resultsHeight = mounted\n ? Math.max(96, Math.min(288, window.innerHeight - anchorRect.top - 80))\n : 288;\n const collapsedContentClip = `inset(0px ${Math.max(\n 0,\n panelWidth - anchorRect.width,\n )}px ${resultsHeight}px 0px round 12px)`;\n const expandedContentClip = \"inset(0px 0px 0px 0px round 12px)\";\n\n // Neither grouping layer carries a box: they only hold `inert`/`aria-hidden`,\n // the z-index and the presence key, and every child below is `fixed` and\n // resolves against the viewport itself. The click catcher spans the viewport\n // edges but has no children and filters nothing, so it is not a sampling\n // layer either. See tests/fixed-overlay-edge-sampling.test.tsx.\n const overlay = mounted\n ? createPortal(\n <div\n aria-hidden={!open}\n inert={!open}\n className=\"pointer-events-none fixed top-0 left-0 z-50 size-0\"\n >\n <AnimatePresence\n initial={false}\n mode=\"popLayout\"\n onExitComplete={() => setBackgroundScrollLocked(false)}\n >\n {open ? (\n <motion.div key=\"morphing-search-overlay\" className=\"fixed top-0 left-0 size-0\">\n <button\n type=\"button\"\n aria-label=\"Close search\"\n className=\"pointer-events-auto fixed inset-0 cursor-default bg-transparent\"\n onClick={closeSearch}\n />\n\n <motion.div\n layoutId={shellLayoutId}\n aria-hidden=\"true\"\n className=\"fixed z-10 rounded-xl bg-background/90 backdrop-blur-xl\"\n style={{\n top: anchorRect.top,\n left: anchorRect.left,\n width: panelWidth,\n height: 48 + resultsHeight,\n boxShadow: \"inset 0 0 0 1px var(--color-border)\",\n }}\n transition={morphTransition}\n />\n\n <motion.div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Search\"\n onKeyDown={handleDialogKeyDown}\n initial={reduce ? false : { opacity: 0, clipPath: collapsedContentClip }}\n animate={{ opacity: 1, clipPath: expandedContentClip }}\n exit={{\n opacity: 0,\n clipPath: collapsedContentClip,\n transition: reduce\n ? { duration: 0 }\n : {\n clipPath: SEARCH_CLIP_TRANSITION,\n opacity: SEARCH_MORPH,\n },\n }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n clipPath: SEARCH_CLIP_TRANSITION,\n opacity: SEARCH_MORPH,\n }\n }\n className=\"pointer-events-auto fixed z-20 overflow-hidden rounded-xl\"\n style={{\n top: anchorRect.top,\n left: anchorRect.left,\n width: panelWidth,\n }}\n >\n <div\n className={cn(\n \"flex h-12 items-center gap-2.5 border-border border-b\",\n iconOnly ? \"px-4\" : \"px-3.5\",\n )}\n >\n <span className=\"shrink-0\">\n <Search className=\"size-4 text-muted-foreground\" />\n </span>\n <div className=\"flex h-10 min-w-0 flex-1 items-center\">\n <input\n ref={inputRef}\n value={query}\n onChange={(event) => updateQuery(event.target.value)}\n role=\"combobox\"\n aria-label={placeholder}\n aria-expanded=\"true\"\n aria-controls={listboxId}\n aria-autocomplete=\"list\"\n aria-activedescendant={\n filteredItems.length > 0 ? `${uid}-option-${activeIndex}` : undefined\n }\n placeholder={placeholder}\n className=\"size-full bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n <kbd className=\"flex h-7 shrink-0 items-center rounded-md border border-border px-2 text-muted-foreground text-xs\">\n Esc\n </kbd>\n </div>\n\n <motion.div\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label=\"Search results\"\n transition={reduce ? { duration: 0 } : undefined}\n variants={\n reduce\n ? undefined\n : {\n closed: {\n opacity: 0,\n transform: \"translateY(6px)\",\n transition: {\n duration: 0.16,\n delay: 0.18,\n ease: EASE_OUT,\n },\n },\n open: {\n opacity: 1,\n transform: \"translateY(0px)\",\n transition: {\n duration: 0.16,\n ease: EASE_OUT,\n },\n },\n }\n }\n initial={reduce ? { opacity: 1, transform: \"translateY(0px)\" } : \"closed\"}\n animate={reduce ? { opacity: 1, transform: \"translateY(0px)\" } : \"open\"}\n exit={reduce ? undefined : \"closed\"}\n className=\"overflow-y-auto overscroll-contain p-2\"\n style={{\n maxHeight: resultsHeight,\n }}\n >\n {filteredItems.length > 0 ? (\n filteredItems.map((item, index) => {\n const Icon = item.icon;\n const active = index === activeIndex;\n return (\n <button\n key={item.id}\n id={`${uid}-option-${index}`}\n type=\"button\"\n role=\"option\"\n aria-selected={active}\n data-index={index}\n onMouseMove={() => moveTo(item.id)}\n onFocus={() => moveTo(item.id)}\n onClick={() => selectItem(item)}\n className=\"relative flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\"\n >\n {active ? (\n <motion.span\n layoutId={`${uid}-active-result`}\n className=\"absolute inset-0 rounded-lg bg-foreground/5\"\n transition={transition}\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative size-4 shrink-0 text-muted-foreground\" />\n ) : null}\n <span className=\"relative min-w-0\">\n <span className=\"block truncate font-medium text-foreground text-sm\">\n {item.title}\n </span>\n {item.description ? (\n <span className=\"block truncate text-muted-foreground text-xs\">\n {item.description}\n </span>\n ) : null}\n </span>\n </button>\n );\n })\n ) : (\n <p className=\"px-3 py-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </p>\n )}\n </motion.div>\n </motion.div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>,\n document.body,\n )\n : null;\n\n return (\n <LayoutGroup id={uid}>\n <div\n ref={anchorRef}\n className={cn(\"relative\", iconOnly ? \"size-12\" : \"h-12 w-72 max-w-full\", className)}\n >\n {!open ? (\n <motion.button\n ref={triggerRef}\n key=\"morphing-search-trigger\"\n layoutId={shellLayoutId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded=\"false\"\n aria-label={placeholder}\n onClick={openSearch}\n transition={morphTransition}\n style={{\n boxShadow: \"inset 0 0 0 1px var(--search-trigger-stroke)\",\n }}\n className={cn(\n \"flex size-full items-center rounded-xl bg-background/60 text-left outline-none backdrop-blur-md [--search-trigger-stroke:var(--color-border)] focus-visible:ring-2 focus-visible:ring-ring hover:[--search-trigger-stroke:var(--color-border-strong)]\",\n iconOnly ? \"cursor-pointer justify-center\" : \"cursor-text px-3.5\",\n )}\n />\n ) : null}\n <motion.div\n aria-hidden=\"true\"\n initial={false}\n animate={{ opacity: open ? 0 : 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n duration: 0.1,\n delay: open ? 0.1 : 0.12,\n ease: EASE_OUT,\n }\n }\n className={cn(\n \"pointer-events-none absolute inset-0 flex items-center\",\n backgroundScrollLocked && \"z-60\",\n iconOnly ? \"justify-center\" : \"gap-2.5 px-3.5\",\n )}\n >\n <Search className=\"size-4 shrink-0 text-muted-foreground\" />\n {iconOnly ? null : (\n <>\n <span className=\"min-w-0 flex-1 truncate text-muted-foreground text-sm\">\n {placeholder}\n </span>\n {shortcut ? (\n <kbd className=\"flex h-7 min-w-7 shrink-0 items-center justify-center rounded-md border border-border px-2 text-muted-foreground text-xs\">\n {shortcut.toUpperCase()}\n </kbd>\n ) : null}\n </>\n )}\n </motion.div>\n </div>\n {overlay}\n </LayoutGroup>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,MAAM,eAA2B;CAC/B,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAIA,MAAM,yBAAqC;CACzC,UAAU;CACV,MAAM;AACR;AAgCA,SAAS,iBAAiB,QAA4B;CACpD,IAAI,EAAE,kBAAkB,cAAc,OAAO;CAC7C,OACE,OAAO,qBACP,kBAAkB,oBAClB,kBAAkB,uBAClB,kBAAkB;AAEtB;AAEA,SAAgB,eAAe,EAC7B,OACA,cAAc,UACd,WAAW,KACX,WAAW,OACX,eAAe,qBACf,MAAM,gBACN,cAAc,OACd,cACA,eACA,UACA,aACsB;CACtB,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,wBAAwB,6BAA6B,SAAS,WAAW;CAChF,MAAM,CAAC,YAAY,iBAAiB,SAAqB;EACvD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WAAU;KACZ,UAAA,SAAS,YAAY;IACnB,CAAA,IACH,IACJ,EAAA,CAAA,CAEM;GACT,CAAA,CAAA;EACJ,CAAA,GAAA,OACU;;AAEjB"}
|
|
1
|
+
{"version":3,"file":"morphing-search.js","names":[],"sources":["../../../src/components/motion/morphing-search.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type KeyboardEvent as ReactKeyboardEvent,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport {\n AnimatePresence,\n LayoutGroup,\n motion,\n type Transition,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\n\n// Keeps the Wallet Card feel with a little more time to read the morph.\nconst SEARCH_MORPH: Transition = {\n type: \"spring\",\n duration: 0.58,\n bounce: 0.22,\n};\n\n// Keep the spring on the shell, but unfold complex clip-path values with the\n// same progressive tween as Morph Popover so the content never snaps ahead.\nconst SEARCH_CLIP_TRANSITION: Transition = {\n duration: 0.32,\n ease: EASE_OUT,\n};\n\nexport type MorphingSearchItem = {\n id: string;\n title: string;\n description?: string;\n keywords?: string[];\n icon?: LucideIcon;\n onSelect?: () => void;\n};\n\nexport interface MorphingSearchProps {\n items: MorphingSearchItem[];\n placeholder?: string;\n shortcut?: string;\n /** Render the closed trigger as a compact search icon. */\n iconOnly?: boolean;\n emptyMessage?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n onQueryChange?: (query: string) => void;\n onSelect?: (item: MorphingSearchItem) => void;\n className?: string;\n}\n\ntype AnchorRect = {\n top: number;\n left: number;\n width: number;\n};\n\nfunction isEditableTarget(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) return false;\n return (\n target.isContentEditable ||\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target instanceof HTMLSelectElement\n );\n}\n\nexport function MorphingSearch({\n items,\n placeholder = \"Search\",\n shortcut = \"f\",\n iconOnly = false,\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n onQueryChange,\n onSelect,\n className,\n}: MorphingSearchProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [query, setQuery] = useState(\"\");\n const [mounted, setMounted] = useState(false);\n const [backgroundScrollLocked, setBackgroundScrollLocked] = useState(defaultOpen);\n const [anchorRect, setAnchorRect] = useState<AnchorRect>({\n top: 16,\n left: 16,\n width: 288,\n });\n const open = controlledOpen ?? internalOpen;\n const controlled = controlledOpen !== undefined;\n const reduce = useReducedMotion();\n const uid = useId();\n const anchorRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const wasOpenRef = useRef(open);\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const morphTransition: Transition = reduce ? { duration: 0 } : SEARCH_MORPH;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const measureAnchor = useCallback(() => {\n const rect = anchorRef.current?.getBoundingClientRect();\n if (!rect || rect.width === 0) return;\n setAnchorRect({ top: rect.top, left: rect.left, width: rect.width });\n }, []);\n\n const openSearch = useCallback(() => {\n measureAnchor();\n setBackgroundScrollLocked(true);\n previousFocusRef.current =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n setOpen(true);\n }, [measureAnchor, setOpen]);\n\n const filteredItems = useMemo(() => {\n const needle = query.trim().toLowerCase();\n if (!needle) return items;\n\n return items.filter((item) =>\n [item.title, item.description ?? \"\", ...(item.keywords ?? [])]\n .join(\" \")\n .toLowerCase()\n .includes(needle),\n );\n }, [items, query]);\n\n const { activeIndex, moveTo, moveActive } = useRowCursor(filteredItems, query);\n\n // The cursor is stamped with the query, so changing it drops the highlight\n // without this having to say so.\n const updateQuery = useCallback(\n (next: string) => {\n setQuery(next);\n onQueryChange?.(next);\n },\n [onQueryChange],\n );\n\n const closeSearch = useCallback(() => {\n updateQuery(\"\");\n setOpen(false);\n }, [setOpen, updateQuery]);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (open) setBackgroundScrollLocked(true);\n }, [open]);\n\n useEffect(() => {\n measureAnchor();\n const anchor = anchorRef.current;\n const observer =\n anchor && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(measureAnchor) : null;\n if (anchor) observer?.observe(anchor);\n window.addEventListener(\"resize\", measureAnchor);\n document.addEventListener(\"scroll\", measureAnchor, true);\n window.visualViewport?.addEventListener(\"resize\", measureAnchor);\n window.visualViewport?.addEventListener(\"scroll\", measureAnchor);\n return () => {\n observer?.disconnect();\n window.removeEventListener(\"resize\", measureAnchor);\n document.removeEventListener(\"scroll\", measureAnchor, true);\n window.visualViewport?.removeEventListener(\"resize\", measureAnchor);\n window.visualViewport?.removeEventListener(\"scroll\", measureAnchor);\n };\n }, [measureAnchor]);\n\n useEffect(() => {\n if (!backgroundScrollLocked) return;\n\n const preventBackgroundWheel = (event: WheelEvent) => {\n const target = event.target;\n if (target instanceof Node && listRef.current?.contains(target)) return;\n event.preventDefault();\n };\n const preventBackgroundTouch = (event: TouchEvent) => {\n const target = event.target;\n if (target instanceof Node && listRef.current?.contains(target)) return;\n event.preventDefault();\n };\n\n document.addEventListener(\"wheel\", preventBackgroundWheel, {\n passive: false,\n });\n document.addEventListener(\"touchmove\", preventBackgroundTouch, {\n passive: false,\n });\n return () => {\n document.removeEventListener(\"wheel\", preventBackgroundWheel);\n document.removeEventListener(\"touchmove\", preventBackgroundTouch);\n };\n }, [backgroundScrollLocked]);\n\n useEffect(() => {\n const handleShortcut = (event: KeyboardEvent) => {\n if (event.key === \"Escape\" && open) {\n event.preventDefault();\n closeSearch();\n return;\n }\n\n if (\n !open &&\n shortcut &&\n event.key.toLowerCase() === shortcut.toLowerCase() &&\n !event.repeat &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.altKey &&\n !event.shiftKey &&\n !isEditableTarget(event.target)\n ) {\n event.preventDefault();\n openSearch();\n }\n };\n\n window.addEventListener(\"keydown\", handleShortcut);\n return () => window.removeEventListener(\"keydown\", handleShortcut);\n }, [closeSearch, open, openSearch, shortcut]);\n\n // Only this component's own state. Telling the consumer the query changed is\n // a side effect, so it waits for the effect below.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n // Keyed to `open` alone. `onQueryChange` is read through a ref because an\n // inline one changes identity on every keystroke, and this effect clearing\n // the field on every keystroke is exactly what that costs. Written after\n // commit for the reason `lib/hooks/use-row-cursor.ts` gives at length.\n const notifyQuery = useRef(onQueryChange);\n useLayoutEffect(() => {\n notifyQuery.current = onQueryChange;\n });\n\n useEffect(() => {\n if (open) {\n notifyQuery.current?.(\"\");\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }\n\n if (wasOpenRef.current) {\n const frame = requestAnimationFrame(() => {\n const previousFocus = previousFocusRef.current;\n const focusTarget = previousFocus?.isConnected ? previousFocus : triggerRef.current;\n focusTarget?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }\n }, [open]);\n\n useEffect(() => {\n wasOpenRef.current = open;\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n listRef.current\n ?.querySelector<HTMLElement>(`[data-index=\"${activeIndex}\"]`)\n ?.scrollIntoView({ block: \"nearest\" });\n }, [activeIndex, open]);\n\n const selectItem = useCallback(\n (item: MorphingSearchItem) => {\n item.onSelect?.();\n onSelect?.(item);\n closeSearch();\n },\n [closeSearch, onSelect],\n );\n\n const handleDialogKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n moveActive(1);\n return;\n }\n\n if (event.key === \"ArrowUp\") {\n event.preventDefault();\n moveActive(-1);\n return;\n }\n\n if (event.key === \"Enter\") {\n event.preventDefault();\n const item = filteredItems[activeIndex];\n if (item) selectItem(item);\n return;\n }\n\n if (event.key !== \"Tab\" || !dialogRef.current) return;\n const focusable = Array.from(\n dialogRef.current.querySelectorAll<HTMLElement>(\n 'input, button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n ),\n );\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) return;\n\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const shellLayoutId = `${uid}-shell`;\n const listboxId = `${uid}-results`;\n const panelWidth = mounted\n ? Math.max(anchorRect.width, Math.min(448, window.innerWidth - anchorRect.left - 16))\n : anchorRect.width;\n const resultsHeight = mounted\n ? Math.max(96, Math.min(288, window.innerHeight - anchorRect.top - 80))\n : 288;\n const collapsedContentClip = `inset(0px ${Math.max(\n 0,\n panelWidth - anchorRect.width,\n )}px ${resultsHeight}px 0px round 12px)`;\n const expandedContentClip = \"inset(0px 0px 0px 0px round 12px)\";\n\n // Neither grouping layer carries a box: they only hold `inert`/`aria-hidden`,\n // the z-index and the presence key, and every child below is `fixed` and\n // resolves against the viewport itself. The click catcher spans the viewport\n // edges but has no children and filters nothing, so it is not a sampling\n // layer either.\n const overlay = mounted\n ? createPortal(\n <div\n aria-hidden={!open}\n inert={!open}\n className=\"pointer-events-none fixed top-0 left-0 z-50 size-0\"\n >\n <AnimatePresence\n initial={false}\n mode=\"popLayout\"\n onExitComplete={() => setBackgroundScrollLocked(false)}\n >\n {open ? (\n <motion.div key=\"morphing-search-overlay\" className=\"fixed top-0 left-0 size-0\">\n <button\n type=\"button\"\n aria-label=\"Close search\"\n className=\"pointer-events-auto fixed inset-0 cursor-default bg-transparent\"\n onClick={closeSearch}\n />\n\n <motion.div\n layoutId={shellLayoutId}\n aria-hidden=\"true\"\n className=\"fixed z-10 rounded-xl bg-background/90 backdrop-blur-xl\"\n style={{\n top: anchorRect.top,\n left: anchorRect.left,\n width: panelWidth,\n height: 48 + resultsHeight,\n boxShadow: \"inset 0 0 0 1px var(--color-border)\",\n }}\n transition={morphTransition}\n />\n\n <motion.div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Search\"\n onKeyDown={handleDialogKeyDown}\n initial={reduce ? false : { opacity: 0, clipPath: collapsedContentClip }}\n animate={{ opacity: 1, clipPath: expandedContentClip }}\n exit={{\n opacity: 0,\n clipPath: collapsedContentClip,\n transition: reduce\n ? { duration: 0 }\n : {\n clipPath: SEARCH_CLIP_TRANSITION,\n opacity: SEARCH_MORPH,\n },\n }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n clipPath: SEARCH_CLIP_TRANSITION,\n opacity: SEARCH_MORPH,\n }\n }\n className=\"pointer-events-auto fixed z-20 overflow-hidden rounded-xl\"\n style={{\n top: anchorRect.top,\n left: anchorRect.left,\n width: panelWidth,\n }}\n >\n <div\n className={cn(\n \"flex h-12 items-center gap-2.5 border-border border-b\",\n iconOnly ? \"px-4\" : \"px-3.5\",\n )}\n >\n <span className=\"shrink-0\">\n <Search className=\"size-4 text-muted-foreground\" />\n </span>\n <div className=\"flex h-10 min-w-0 flex-1 items-center\">\n <input\n ref={inputRef}\n value={query}\n onChange={(event) => updateQuery(event.target.value)}\n role=\"combobox\"\n aria-label={placeholder}\n aria-expanded=\"true\"\n aria-controls={listboxId}\n aria-autocomplete=\"list\"\n aria-activedescendant={\n filteredItems.length > 0 ? `${uid}-option-${activeIndex}` : undefined\n }\n placeholder={placeholder}\n className=\"size-full bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n <kbd className=\"flex h-7 shrink-0 items-center rounded-md border border-border px-2 text-muted-foreground text-xs\">\n Esc\n </kbd>\n </div>\n\n <motion.div\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label=\"Search results\"\n transition={reduce ? { duration: 0 } : undefined}\n variants={\n reduce\n ? undefined\n : {\n closed: {\n opacity: 0,\n transform: \"translateY(6px)\",\n transition: {\n duration: 0.16,\n delay: 0.18,\n ease: EASE_OUT,\n },\n },\n open: {\n opacity: 1,\n transform: \"translateY(0px)\",\n transition: {\n duration: 0.16,\n ease: EASE_OUT,\n },\n },\n }\n }\n initial={reduce ? { opacity: 1, transform: \"translateY(0px)\" } : \"closed\"}\n animate={reduce ? { opacity: 1, transform: \"translateY(0px)\" } : \"open\"}\n exit={reduce ? undefined : \"closed\"}\n className=\"overflow-y-auto overscroll-contain p-2\"\n style={{\n maxHeight: resultsHeight,\n }}\n >\n {filteredItems.length > 0 ? (\n filteredItems.map((item, index) => {\n const Icon = item.icon;\n const active = index === activeIndex;\n return (\n <button\n key={item.id}\n id={`${uid}-option-${index}`}\n type=\"button\"\n role=\"option\"\n aria-selected={active}\n data-index={index}\n onMouseMove={() => moveTo(item.id)}\n onFocus={() => moveTo(item.id)}\n onClick={() => selectItem(item)}\n className=\"relative flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\"\n >\n {active ? (\n <motion.span\n layoutId={`${uid}-active-result`}\n className=\"absolute inset-0 rounded-lg bg-foreground/5\"\n transition={transition}\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative size-4 shrink-0 text-muted-foreground\" />\n ) : null}\n <span className=\"relative min-w-0\">\n <span className=\"block truncate font-medium text-foreground text-sm\">\n {item.title}\n </span>\n {item.description ? (\n <span className=\"block truncate text-muted-foreground text-xs\">\n {item.description}\n </span>\n ) : null}\n </span>\n </button>\n );\n })\n ) : (\n <p className=\"px-3 py-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </p>\n )}\n </motion.div>\n </motion.div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>,\n document.body,\n )\n : null;\n\n return (\n <LayoutGroup id={uid}>\n <div\n ref={anchorRef}\n className={cn(\"relative\", iconOnly ? \"size-12\" : \"h-12 w-72 max-w-full\", className)}\n >\n {!open ? (\n <motion.button\n ref={triggerRef}\n key=\"morphing-search-trigger\"\n layoutId={shellLayoutId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded=\"false\"\n aria-label={placeholder}\n onClick={openSearch}\n transition={morphTransition}\n style={{\n boxShadow: \"inset 0 0 0 1px var(--search-trigger-stroke)\",\n }}\n className={cn(\n \"flex size-full items-center rounded-xl bg-background/60 text-left outline-none backdrop-blur-md [--search-trigger-stroke:var(--color-border)] focus-visible:ring-2 focus-visible:ring-ring hover:[--search-trigger-stroke:var(--color-border-strong)]\",\n iconOnly ? \"cursor-pointer justify-center\" : \"cursor-text px-3.5\",\n )}\n />\n ) : null}\n <motion.div\n aria-hidden=\"true\"\n initial={false}\n animate={{ opacity: open ? 0 : 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n duration: 0.1,\n delay: open ? 0.1 : 0.12,\n ease: EASE_OUT,\n }\n }\n className={cn(\n \"pointer-events-none absolute inset-0 flex items-center\",\n backgroundScrollLocked && \"z-60\",\n iconOnly ? \"justify-center\" : \"gap-2.5 px-3.5\",\n )}\n >\n <Search className=\"size-4 shrink-0 text-muted-foreground\" />\n {iconOnly ? null : (\n <>\n <span className=\"min-w-0 flex-1 truncate text-muted-foreground text-sm\">\n {placeholder}\n </span>\n {shortcut ? (\n <kbd className=\"flex h-7 min-w-7 shrink-0 items-center justify-center rounded-md border border-border px-2 text-muted-foreground text-xs\">\n {shortcut.toUpperCase()}\n </kbd>\n ) : null}\n </>\n )}\n </motion.div>\n </div>\n {overlay}\n </LayoutGroup>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,MAAM,eAA2B;CAC/B,MAAM;CACN,UAAU;CACV,QA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,SAAS;IACT,YAAY;IACZ,OAAO,EACL,WAAW,+CACb;IACA,WAAW,GACT,yPACA,WAAW,kCAAkC,oBAC/C;GACD,GAfK,yBAeL,IACC,MACJ,qBAAC,OAAO,KAAR;IACE,eAAY;IACZ,SAAS;IACT,SAAS,EAAE,SAAS,OAAO,IAAI,EAAE;IACjC,YACE,SACI,EAAE,UAAU,EAAE,IACd;KACE,UAAU;KACV,OAAO,OAAO,KAAM;KACpB,MAAM;IACR;IAEN,WAAW,GACT,0DACA,0BAA0B,QAC1B,WAAW,mBAAmB,gBAChC;IAjBF,UAAA,CAmBE,oBAAC,QAAD,EAAQ,WAAU,wCAAyC,CAAA,GAC1D,WAAW,OACV,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA,GACL,WACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,SAAS,YAAY;IACnB,CAAA,IACH,IACJ,EAAA,CAAA,CAEM;GACT,CAAA,CAAA;EACJ,CAAA,GAAA,OACU;;AAEjB"}
|
|
@@ -3,9 +3,9 @@ import { TOUCH_GESTURE_CLASS, capturePointer } from "../../lib/touch.js";
|
|
|
3
3
|
import { EASE_OUT, SPRING_GLIDE, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
-
import { X } from "lucide-react";
|
|
7
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/morphing-tabs.tsx
|
|
11
11
|
const DRAG_THRESHOLD = 5;
|
|
@@ -3,9 +3,9 @@ import { EASE_OUT, SPRING_LAYOUT } from "../../../lib/ease.js";
|
|
|
3
3
|
import { MultiSelectGroupContext, useMultiSelectContext } from "./context.js";
|
|
4
4
|
import { useContext, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
-
import { Check } from "lucide-react";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { motion } from "motion/react";
|
|
8
|
+
import { Check } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/multi-select/list.tsx
|
|
10
10
|
function MultiSelectList({ children, ariaLabel = "Options", className }) {
|
|
11
11
|
const context = useMultiSelectContext("MultiSelectList");
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../../lib/ease.js";
|
|
3
3
|
import { mergeRefs, useMultiSelectContext } from "./context.js";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
-
import { ChevronsUpDown, Search, X } from "lucide-react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
+
import { ChevronsUpDown, Search, X } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/multi-select/trigger.tsx
|
|
9
9
|
function MultiSelectTrigger({ children, className }) {
|
|
10
10
|
const context = useMultiSelectContext("MultiSelectTrigger");
|
|
@@ -6,9 +6,9 @@ import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
|
|
|
6
6
|
import { ActionSwapText } from "./action-swap.js";
|
|
7
7
|
import { useCallback, useRef, useState } from "react";
|
|
8
8
|
import { cn } from "@kumix/utils";
|
|
9
|
-
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
10
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { motion, useReducedMotion } from "motion/react";
|
|
11
|
+
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
12
12
|
//#region src/components/motion/notification-stack.tsx
|
|
13
13
|
const STACK_PEEK = 8;
|
|
14
14
|
const STACK_INSET = 12;
|
|
@@ -3,9 +3,9 @@ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
|
3
3
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
-
import { MoreHorizontal, X } from "lucide-react";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { MoreHorizontal, X } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/overflow-actions.tsx
|
|
10
10
|
const SHELL_TRANSITION = {
|
|
11
11
|
type: "spring",
|
|
@@ -30,8 +30,12 @@ export interface MorphPopoverContentProps {
|
|
|
30
30
|
sideOffset?: number;
|
|
31
31
|
/** Panel corner radius, in px. Default 16. */
|
|
32
32
|
radius?: number;
|
|
33
|
+
/** Draw the surface shadow. Default true. */
|
|
34
|
+
shadow?: boolean;
|
|
35
|
+
/** Runs after the portalled surface is positioned and visible. */
|
|
36
|
+
onOpenAutoFocus?: (content: HTMLDivElement) => void;
|
|
33
37
|
className?: string;
|
|
34
38
|
}
|
|
35
|
-
export declare function MorphPopoverContent(
|
|
39
|
+
export declare function MorphPopoverContent(props: MorphPopoverContentProps): import("react").ReactPortal | null;
|
|
36
40
|
//#endregion
|
|
37
41
|
//# sourceMappingURL=popover-morph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-morph.d.ts","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"popover-morph.d.ts","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"mappings":";;KA+BK;KACA;iBAsBY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;EAChB;;;;;;;wBAQc,eACd,UACA,MAAM,gBACN,aACA,cACA,aACC,oCAAiB,IAAA;iBAoFH;EACf,UAAU;;;wBAcI,sBAAsB,YAAY,2BAAwB,aAAA,kDAAA;iBA0CzD;EACf,UAAU;EACV,OAAO;EACP,QAAQ;;EAER;;EAEA;;EAEA;;EAEA,mBAAmB,SAAS;EAC5B;;wBAGc,oBAAoB,OAAO,2CAAwB"}
|
|
@@ -4,7 +4,7 @@ import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.j
|
|
|
4
4
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
|
+
import { AnimatePresence, animate, motion, useMotionValue, usePresence, useReducedMotion } from "motion/react";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
//#region src/components/motion/popover-morph.tsx
|
|
10
10
|
const MorphContext = createContext(null);
|
|
@@ -94,13 +94,14 @@ function mergeRefs(...refs) {
|
|
|
94
94
|
/** Wraps a single element, toggling the popover on click. */
|
|
95
95
|
function MorphPopoverTrigger({ children }) {
|
|
96
96
|
const ctx = useMorphContext("MorphPopoverTrigger");
|
|
97
|
-
if (!isValidElement(children)) return children;
|
|
98
97
|
const child = children;
|
|
99
|
-
const childOnClick = child
|
|
100
|
-
const childRef = child
|
|
98
|
+
const childOnClick = child?.props?.onClick;
|
|
99
|
+
const childRef = (child?.props)?.ref;
|
|
100
|
+
const mergedRef = useMemo(() => mergeRefs(childRef, ctx.registerTrigger), [childRef, ctx.registerTrigger]);
|
|
101
|
+
if (!isValidElement(children)) return children;
|
|
101
102
|
return cloneElement(child, {
|
|
102
103
|
id: ctx.triggerId,
|
|
103
|
-
ref:
|
|
104
|
+
ref: mergedRef,
|
|
104
105
|
onClick: (e) => {
|
|
105
106
|
childOnClick?.(e);
|
|
106
107
|
ctx.toggle();
|
|
@@ -111,70 +112,120 @@ function MorphPopoverTrigger({ children }) {
|
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
const originFor = (side, align) => `${side === "bottom" ? "top" : "bottom"} ${align === "end" ? "right" : "left"}`;
|
|
114
|
-
function
|
|
115
|
-
|
|
115
|
+
function clipAt(side, align, radius, inset) {
|
|
116
|
+
const top = side === "bottom" ? "0%" : `${inset}%`;
|
|
117
|
+
const bottom = side === "bottom" ? `${inset}%` : "0%";
|
|
118
|
+
return `inset(${top} ${align === "end" ? "0%" : `${inset}%`} ${bottom} ${align === "end" ? `${inset}%` : "0%"} round ${radius}px)`;
|
|
116
119
|
}
|
|
117
|
-
const clipShown = (radius) => `inset(0% 0% 0% 0% round ${radius}px)`;
|
|
118
120
|
const MORPH_CLIP_TRANSITION = {
|
|
119
121
|
duration: .32,
|
|
120
122
|
ease: EASE_OUT
|
|
121
123
|
};
|
|
122
|
-
function MorphPopoverContent(
|
|
124
|
+
function MorphPopoverContent(props) {
|
|
123
125
|
const ctx = useMorphContext("MorphPopoverContent");
|
|
124
|
-
const reduce = useReducedMotion() ?? false;
|
|
125
126
|
const [portalReady, setPortalReady] = useState(false);
|
|
126
|
-
const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, portalReady && ctx.open);
|
|
127
127
|
useEffect(() => setPortalReady(true), []);
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
if (!portalReady) return null;
|
|
129
|
+
return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: ctx.open && /* @__PURE__ */ jsx(MorphPopoverSurface, { ...props }) }), document.body);
|
|
130
|
+
}
|
|
131
|
+
function MorphPopoverSurface({ children, side = "bottom", align = "end", sideOffset = 8, radius = 16, shadow = true, onOpenAutoFocus, className }) {
|
|
132
|
+
const ctx = useMorphContext("MorphPopoverContent");
|
|
133
|
+
const reduce = useReducedMotion() ?? false;
|
|
134
|
+
const [isPresent, safeToRemove] = usePresence();
|
|
135
|
+
const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, isPresent);
|
|
136
|
+
const preferredLeft = layout ? align === "end" ? layout.trigger.left + layout.trigger.width - layout.content.width : layout.trigger.left : 0;
|
|
137
|
+
const gutter = 12;
|
|
138
|
+
const below = layout ? Math.max(0, window.innerHeight - layout.trigger.top - layout.trigger.height - sideOffset - gutter) : 0;
|
|
139
|
+
const above = layout ? Math.max(0, layout.trigger.top - sideOffset - gutter) : 0;
|
|
140
|
+
const requestedSpace = side === "bottom" ? below : above;
|
|
141
|
+
const otherSpace = side === "bottom" ? above : below;
|
|
142
|
+
const resolvedSide = layout && layout.content.height > requestedSpace && otherSpace > requestedSpace ? side === "bottom" ? "top" : "bottom" : side;
|
|
143
|
+
const availableHeight = resolvedSide === "bottom" ? below : above;
|
|
144
|
+
const left = layout ? Math.max(gutter, Math.min(preferredLeft, window.innerWidth - layout.content.width - gutter)) : 0;
|
|
145
|
+
const top = layout ? resolvedSide === "bottom" ? layout.trigger.top + layout.trigger.height + sideOffset : Math.max(gutter, layout.trigger.top - layout.content.height - sideOffset) : 0;
|
|
130
146
|
const wrap = reduce ? void 0 : {
|
|
131
147
|
hidden: {
|
|
132
|
-
opacity: 0,
|
|
133
148
|
scale: .96,
|
|
134
149
|
transition: SPRING_PANEL
|
|
135
150
|
},
|
|
136
151
|
show: {
|
|
137
|
-
opacity: 1,
|
|
138
152
|
scale: 1,
|
|
139
153
|
transition: SPRING_PANEL
|
|
140
154
|
}
|
|
141
155
|
};
|
|
142
156
|
const clip = reduce ? void 0 : {
|
|
143
157
|
hidden: {
|
|
144
|
-
clipPath:
|
|
158
|
+
clipPath: clipAt(resolvedSide, align, radius, 92),
|
|
145
159
|
transition: MORPH_CLIP_TRANSITION
|
|
146
160
|
},
|
|
147
161
|
show: {
|
|
148
|
-
clipPath:
|
|
162
|
+
clipPath: clipAt(resolvedSide, align, radius, 0),
|
|
149
163
|
transition: MORPH_CLIP_TRANSITION
|
|
150
164
|
}
|
|
151
165
|
};
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
const opacity = useMotionValue(0);
|
|
167
|
+
const ready = layout !== null;
|
|
168
|
+
const focusedOnOpen = useRef(false);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!ready || !isPresent || focusedOnOpen.current || !ctx.contentRef.current) return;
|
|
171
|
+
focusedOnOpen.current = true;
|
|
172
|
+
onOpenAutoFocus?.(ctx.contentRef.current);
|
|
173
|
+
}, [
|
|
174
|
+
ready,
|
|
175
|
+
isPresent,
|
|
176
|
+
ctx.contentRef,
|
|
177
|
+
onOpenAutoFocus
|
|
178
|
+
]);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (!ready) {
|
|
181
|
+
if (!isPresent) safeToRemove?.();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const animation = animate(opacity, isPresent ? 1 : 0, {
|
|
185
|
+
...reduce ? { duration: .12 } : SPRING_PANEL,
|
|
186
|
+
onComplete: () => {
|
|
187
|
+
if (!isPresent) safeToRemove?.();
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return () => animation.stop();
|
|
191
|
+
}, [
|
|
192
|
+
opacity,
|
|
193
|
+
ready,
|
|
194
|
+
isPresent,
|
|
195
|
+
reduce,
|
|
196
|
+
safeToRemove
|
|
197
|
+
]);
|
|
198
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
154
199
|
"data-morph-popover-portal": "",
|
|
200
|
+
inert: !isPresent,
|
|
155
201
|
variants: wrap,
|
|
156
|
-
initial:
|
|
157
|
-
animate:
|
|
158
|
-
exit:
|
|
159
|
-
transition: reduce ? { duration: .12 } : void 0,
|
|
202
|
+
initial: "hidden",
|
|
203
|
+
animate: layout ? "show" : "hidden",
|
|
204
|
+
exit: "hidden",
|
|
160
205
|
style: {
|
|
161
206
|
left,
|
|
162
207
|
top,
|
|
208
|
+
opacity,
|
|
209
|
+
pointerEvents: isPresent ? "auto" : "none",
|
|
163
210
|
visibility: layout ? "visible" : "hidden",
|
|
164
|
-
transformOrigin: originFor(
|
|
211
|
+
transformOrigin: originFor(resolvedSide, align)
|
|
165
212
|
},
|
|
166
|
-
className: "filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]
|
|
213
|
+
className: cn("fixed z-9999", shadow && "filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]"),
|
|
167
214
|
children: /* @__PURE__ */ jsx(motion.div, {
|
|
168
215
|
ref: ctx.contentRef,
|
|
169
216
|
id: ctx.contentId,
|
|
170
217
|
role: "dialog",
|
|
171
218
|
"aria-labelledby": ctx.triggerId,
|
|
172
219
|
variants: clip,
|
|
173
|
-
style: {
|
|
220
|
+
style: {
|
|
221
|
+
borderRadius: radius,
|
|
222
|
+
maxHeight: layout ? availableHeight : void 0,
|
|
223
|
+
overflowY: "auto"
|
|
224
|
+
},
|
|
174
225
|
className: cn("overflow-hidden border border-border bg-background", className),
|
|
175
226
|
children
|
|
176
227
|
})
|
|
177
|
-
})
|
|
228
|
+
});
|
|
178
229
|
}
|
|
179
230
|
//#endregion
|
|
180
231
|
export { MorphPopover, MorphPopoverContent, MorphPopoverTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-morph.js","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"end\";\n\ntype MorphContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n triggerId: string;\n contentId: string;\n /** The element the panel measures against — see `registerTrigger`. */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n registerTrigger: (node: HTMLElement | null) => void;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n};\n\nconst MorphContext = createContext<MorphContextValue | null>(null);\n\nfunction useMorphContext(component: string) {\n const ctx = useContext(MorphContext);\n if (!ctx) throw new Error(`${component} must be used within <MorphPopover>`);\n return ctx;\n}\n\nexport interface MorphPopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\n/**\n * A popover whose panel morphs open from the trigger corner: it's laid out at\n * full size but clipped to the corner nearest the trigger, then unclips as one\n * piece. Closes on outside pointer / Escape. Controlled or uncontrolled.\n */\nexport function MorphPopover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: MorphPopoverProps) {\n const baseId = useId();\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const [trigger, setTrigger] = useState<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n // A trigger normally registers itself through MorphPopoverTrigger. It can't\n // when something else already clones the element — a Tooltip wrapping the\n // button, say — and an unregistered trigger leaves the panel with nothing to\n // measure against, so it renders permanently invisible. The root boxes the\n // trigger exactly (the content portals out of it), so it stands in until a\n // real trigger registers, and stands in again if that one unmounts. Both are\n // state, so a trigger arriving while the panel is open re-anchors it.\n const anchorRef = useMemo<React.MutableRefObject<HTMLElement | null>>(\n () => ({ current: trigger ?? root }),\n [root, trigger],\n );\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: a dismissal hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded. When no trigger has\n // registered, the root anchor stands in only if it can actually hold focus;\n // there is nowhere better than where the keyboard already is, so leave it.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (!inPanel) return;\n const restore = trigger ?? (root && root.tabIndex >= 0 ? root : null);\n restore?.focus();\n }, [root, setOpen, trigger]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (root && !root.contains(target) && !contentRef.current?.contains(target)) close();\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, root, close]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n triggerId: `${baseId}-trigger`,\n contentId: `${baseId}-content`,\n triggerRef: anchorRef,\n registerTrigger: setTrigger,\n contentRef,\n }),\n [open, setOpen, toggle, baseId, anchorRef],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={setRoot} className={cn(\"relative inline-flex\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphPopoverTriggerProps {\n children: ReactElement;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\n/** Wraps a single element, toggling the popover on click. */\nexport function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps) {\n const ctx = useMorphContext(\"MorphPopoverTrigger\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as ((e: unknown) => void) | undefined;\n const childRef = (child.props as { ref?: Ref<HTMLElement> }).ref;\n\n return cloneElement(child, {\n id: ctx.triggerId,\n ref: mergeRefs(childRef, ctx.registerTrigger),\n onClick: (e: unknown) => {\n childOnClick?.(e);\n ctx.toggle();\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n });\n}\n\nconst originFor = (side: Side, align: Align) =>\n `${side === \"bottom\" ? \"top\" : \"bottom\"} ${align === \"end\" ? \"right\" : \"left\"}`;\n\n// A clip that hides everything but the corner nearest the trigger, so the\n// panel appears to grow out of it. inset(top right bottom left).\nfunction clipHidden(side: Side, align: Align, radius: number) {\n const top = side === \"bottom\" ? \"0%\" : \"92%\";\n const bottom = side === \"bottom\" ? \"92%\" : \"0%\";\n const right = align === \"end\" ? \"0%\" : \"92%\";\n const left = align === \"end\" ? \"92%\" : \"0%\";\n return `inset(${top} ${right} ${bottom} ${left} round ${radius}px)`;\n}\nconst clipShown = (radius: number) => `inset(0% 0% 0% 0% round ${radius}px)`;\n\n// Preserve the original spring character on the wrapper, but tween the complex\n// clip-path so it cannot snap when the spring resolves its final distance.\nconst MORPH_CLIP_TRANSITION = { duration: 0.32, ease: EASE_OUT } as const;\n\nexport interface MorphPopoverContentProps {\n children: ReactNode;\n side?: Side;\n align?: Align;\n /** Gap between trigger and panel, in px. Default 8. */\n sideOffset?: number;\n /** Panel corner radius, in px. Default 16. */\n radius?: number;\n className?: string;\n}\n\nexport function MorphPopoverContent({\n children,\n side = \"bottom\",\n align = \"end\",\n sideOffset = 8,\n radius = 16,\n className,\n}: MorphPopoverContentProps) {\n const ctx = useMorphContext(\"MorphPopoverContent\");\n const reduce = useReducedMotion() ?? false;\n const [portalReady, setPortalReady] = useState(false);\n const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, portalReady && ctx.open);\n\n useEffect(() => setPortalReady(true), []);\n const left = layout\n ? align === \"end\"\n ? layout.trigger.left + layout.trigger.width - layout.content.width\n : layout.trigger.left\n : 0;\n const top = layout\n ? side === \"bottom\"\n ? layout.trigger.top + layout.trigger.height + sideOffset\n : layout.trigger.top - layout.content.height - sideOffset\n : 0;\n\n // Both directions travel between the exact same hidden/show states. Exit\n // targets \"hidden\" directly instead of introducing separate choreography.\n const wrap = reduce\n ? undefined\n : {\n hidden: { opacity: 0, scale: 0.96, transition: SPRING_PANEL },\n show: { opacity: 1, scale: 1, transition: SPRING_PANEL },\n };\n const clip = reduce\n ? undefined\n : {\n hidden: {\n clipPath: clipHidden(side, align, radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n show: {\n clipPath: clipShown(radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n };\n\n // Keep the server and first client render identical, then mount the portal.\n if (!portalReady) return null;\n\n return createPortal(\n <AnimatePresence>\n {ctx.open ? (\n <motion.div\n data-morph-popover-portal=\"\"\n // Wrapper carries the shadow as a drop-shadow filter, which hugs the\n // clipped shape below (box-shadow would just get clipped away).\n variants={wrap}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"show\"}\n exit={reduce ? { opacity: 0 } : \"hidden\"}\n transition={reduce ? { duration: 0.12 } : undefined}\n style={{\n left,\n top,\n visibility: layout ? \"visible\" : \"hidden\",\n transformOrigin: originFor(side, align),\n }}\n className=\"filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))] fixed z-9999\"\n >\n <motion.div\n ref={ctx.contentRef}\n id={ctx.contentId}\n role=\"dialog\"\n aria-labelledby={ctx.triggerId}\n variants={clip}\n style={{ borderRadius: radius }}\n className={cn(\"overflow-hidden border border-border bg-background\", className)}\n >\n {children}\n </motion.div>\n </motion.div>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;AAuCA,MAAM,eAAe,cAAwC,IAAI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;EAG1B,UAAU;EACV,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;EACnC,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;EACnC,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI;EAChC,YAAY,SAAS,EAAE,UAAU,IAAK,IAAI,KAAA;EAC1C,OAAO;GACL;GACA;GACA,YAAY,SAAS,YAAY;GACjC,iBAAiB,UAAU,MAAM,KAAK;EACxC;EACA,WAAU;EAEV,UAAA,oBAAC,OAAO,KAAR;GACE,KAAK,IAAI;GACT,IAAI,IAAI;GACR,MAAK;GACL,mBAAiB,IAAI;GACrB,UAAU;GACV,OAAO,EAAE,cAAc,OAAO;GAC9B,WAAW,GAAG,sDAAsD,SAAS;GAE5E;EACS,CAAA;CACF,CAAA,IACV,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
|
|
1
|
+
{"version":3,"file":"popover-morph.js","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n animate,\n motion,\n useMotionValue,\n usePresence,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"end\";\n\ntype MorphContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n triggerId: string;\n contentId: string;\n /** The element the panel measures against — see `registerTrigger`. */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n registerTrigger: (node: HTMLElement | null) => void;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n};\n\nconst MorphContext = createContext<MorphContextValue | null>(null);\n\nfunction useMorphContext(component: string) {\n const ctx = useContext(MorphContext);\n if (!ctx) throw new Error(`${component} must be used within <MorphPopover>`);\n return ctx;\n}\n\nexport interface MorphPopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\n/**\n * A popover whose panel morphs open from the trigger corner: it's laid out at\n * full size but clipped to the corner nearest the trigger, then unclips as one\n * piece. Closes on outside pointer / Escape. Controlled or uncontrolled.\n */\nexport function MorphPopover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: MorphPopoverProps) {\n const baseId = useId();\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const [trigger, setTrigger] = useState<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n // A trigger normally registers itself through MorphPopoverTrigger. It can't\n // when something else already clones the element — a Tooltip wrapping the\n // button, say — and an unregistered trigger leaves the panel with nothing to\n // measure against, so it renders permanently invisible. The root boxes the\n // trigger exactly (the content portals out of it), so it stands in until a\n // real trigger registers, and stands in again if that one unmounts. Both are\n // state, so a trigger arriving while the panel is open re-anchors it.\n const anchorRef = useMemo<React.MutableRefObject<HTMLElement | null>>(\n () => ({ current: trigger ?? root }),\n [root, trigger],\n );\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: a dismissal hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded. When no trigger has\n // registered, the root anchor stands in only if it can actually hold focus;\n // there is nowhere better than where the keyboard already is, so leave it.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (!inPanel) return;\n const restore = trigger ?? (root && root.tabIndex >= 0 ? root : null);\n restore?.focus();\n }, [root, setOpen, trigger]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (root && !root.contains(target) && !contentRef.current?.contains(target)) close();\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, root, close]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n triggerId: `${baseId}-trigger`,\n contentId: `${baseId}-content`,\n triggerRef: anchorRef,\n registerTrigger: setTrigger,\n contentRef,\n }),\n [open, setOpen, toggle, baseId, anchorRef],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={setRoot} className={cn(\"relative inline-flex\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphPopoverTriggerProps {\n children: ReactElement;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\n/** Wraps a single element, toggling the popover on click. */\nexport function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps) {\n const ctx = useMorphContext(\"MorphPopoverTrigger\");\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child?.props?.onClick as ((e: unknown) => void) | undefined;\n const childRef = (child?.props as { ref?: Ref<HTMLElement> } | undefined)?.ref;\n // Register once per actual ref change, not once per open-state render.\n const mergedRef = useMemo(\n () => mergeRefs(childRef, ctx.registerTrigger),\n [childRef, ctx.registerTrigger],\n );\n if (!isValidElement(children)) return children;\n\n return cloneElement(child, {\n id: ctx.triggerId,\n ref: mergedRef,\n onClick: (e: unknown) => {\n childOnClick?.(e);\n ctx.toggle();\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n });\n}\n\nconst originFor = (side: Side, align: Align) =>\n `${side === \"bottom\" ? \"top\" : \"bottom\"} ${align === \"end\" ? \"right\" : \"left\"}`;\n\n// A clip that hides everything but the corner nearest the trigger, so the\n// panel appears to grow out of it. inset(top right bottom left).\nfunction clipAt(side: Side, align: Align, radius: number, inset: number) {\n const top = side === \"bottom\" ? \"0%\" : `${inset}%`;\n const bottom = side === \"bottom\" ? `${inset}%` : \"0%\";\n const right = align === \"end\" ? \"0%\" : `${inset}%`;\n const left = align === \"end\" ? `${inset}%` : \"0%\";\n return `inset(${top} ${right} ${bottom} ${left} round ${radius}px)`;\n}\n\n// Preserve the original spring character on the wrapper, but tween the complex\n// clip-path so it cannot snap when the spring resolves its final distance.\nconst MORPH_CLIP_TRANSITION = { duration: 0.32, ease: EASE_OUT } as const;\n\nexport interface MorphPopoverContentProps {\n children: ReactNode;\n side?: Side;\n align?: Align;\n /** Gap between trigger and panel, in px. Default 8. */\n sideOffset?: number;\n /** Panel corner radius, in px. Default 16. */\n radius?: number;\n /** Draw the surface shadow. Default true. */\n shadow?: boolean;\n /** Runs after the portalled surface is positioned and visible. */\n onOpenAutoFocus?: (content: HTMLDivElement) => void;\n className?: string;\n}\n\nexport function MorphPopoverContent(props: MorphPopoverContentProps) {\n const ctx = useMorphContext(\"MorphPopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n useEffect(() => setPortalReady(true), []);\n if (!portalReady) return null;\n return createPortal(\n <AnimatePresence>{ctx.open && <MorphPopoverSurface {...props} />}</AnimatePresence>,\n document.body,\n );\n}\n\n// Measurement belongs to the mounted portal session: reopening must not start\n// an entrance at the previous session's coordinates before measuring this one.\nfunction MorphPopoverSurface({\n children,\n side = \"bottom\",\n align = \"end\",\n sideOffset = 8,\n radius = 16,\n shadow = true,\n onOpenAutoFocus,\n className,\n}: MorphPopoverContentProps) {\n const ctx = useMorphContext(\"MorphPopoverContent\");\n const reduce = useReducedMotion() ?? false;\n const [isPresent, safeToRemove] = usePresence();\n const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, isPresent);\n\n const preferredLeft = layout\n ? align === \"end\"\n ? layout.trigger.left + layout.trigger.width - layout.content.width\n : layout.trigger.left\n : 0;\n // Keep larger compositions, such as calendars, inside the viewport. Prefer\n // the requested side, then use the roomier side when it cannot fit there.\n const gutter = 12;\n const below = layout\n ? Math.max(\n 0,\n window.innerHeight - layout.trigger.top - layout.trigger.height - sideOffset - gutter,\n )\n : 0;\n const above = layout ? Math.max(0, layout.trigger.top - sideOffset - gutter) : 0;\n const requestedSpace = side === \"bottom\" ? below : above;\n const otherSpace = side === \"bottom\" ? above : below;\n const resolvedSide =\n layout && layout.content.height > requestedSpace && otherSpace > requestedSpace\n ? side === \"bottom\"\n ? \"top\"\n : \"bottom\"\n : side;\n const availableHeight = resolvedSide === \"bottom\" ? below : above;\n const left = layout\n ? Math.max(gutter, Math.min(preferredLeft, window.innerWidth - layout.content.width - gutter))\n : 0;\n const top = layout\n ? resolvedSide === \"bottom\"\n ? layout.trigger.top + layout.trigger.height + sideOffset\n : Math.max(gutter, layout.trigger.top - layout.content.height - sideOffset)\n : 0;\n\n // Both directions travel between the exact same hidden/show states. Exit\n // targets \"hidden\" directly instead of introducing separate choreography.\n const wrap = reduce\n ? undefined\n : {\n hidden: { scale: 0.96, transition: SPRING_PANEL },\n show: { scale: 1, transition: SPRING_PANEL },\n };\n const clip = reduce\n ? undefined\n : {\n hidden: {\n clipPath: clipAt(resolvedSide, align, radius, 92),\n transition: MORPH_CLIP_TRANSITION,\n },\n show: {\n clipPath: clipAt(resolvedSide, align, radius, 0),\n transition: MORPH_CLIP_TRANSITION,\n },\n };\n // Animate the value directly so opacity stays in the inline style throughout\n // the entrance. A native opacity animation can expose the initial inline 0\n // for a frame when it finishes, before Motion writes the final value.\n const opacity = useMotionValue(0);\n const ready = layout !== null;\n const focusedOnOpen = useRef(false);\n useEffect(() => {\n if (!ready || !isPresent || focusedOnOpen.current || !ctx.contentRef.current) return;\n focusedOnOpen.current = true;\n onOpenAutoFocus?.(ctx.contentRef.current);\n }, [ready, isPresent, ctx.contentRef, onOpenAutoFocus]);\n useEffect(() => {\n if (!ready) {\n if (!isPresent) safeToRemove?.();\n return;\n }\n const animation = animate(opacity, isPresent ? 1 : 0, {\n ...(reduce ? { duration: 0.12 } : SPRING_PANEL),\n onComplete: () => {\n if (!isPresent) safeToRemove?.();\n },\n });\n return () => animation.stop();\n }, [opacity, ready, isPresent, reduce, safeToRemove]);\n\n return (\n <motion.div\n data-morph-popover-portal=\"\"\n inert={!isPresent}\n // Wrapper carries the shadow as a drop-shadow filter, which hugs the\n // clipped shape below (box-shadow would just get clipped away).\n variants={wrap}\n initial=\"hidden\"\n animate={layout ? \"show\" : \"hidden\"}\n exit=\"hidden\"\n style={{\n left,\n top,\n opacity,\n pointerEvents: isPresent ? \"auto\" : \"none\",\n visibility: layout ? \"visible\" : \"hidden\",\n transformOrigin: originFor(resolvedSide, align),\n }}\n className={cn(\"fixed z-9999\", shadow && \"filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]\")}\n >\n <motion.div\n ref={ctx.contentRef}\n id={ctx.contentId}\n role=\"dialog\"\n aria-labelledby={ctx.triggerId}\n variants={clip}\n style={{\n borderRadius: radius,\n maxHeight: layout ? availableHeight : undefined,\n overflowY: \"auto\",\n }}\n className={cn(\"overflow-hidden border border-border bg-background\", className)}\n >\n {children}\n </motion.div>\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;;;AA8CA,MAAM,eAAe,cAAwC,IAAI;AAEjE,SAAS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SAAS,EAAE,UAAU,IAAK,IAAI;GAClC,kBAAkB;IAChB,IAAI,CAAC,WAAW,eAAe;GACjC;EACF,CAAC;EACD,aAAa,UAAU,KAAK;CAC9B,GAAG;EAAC;EAAS;EAAO;EAAW;EAAQ;CAAY,CAAC;CAEpD,OACE,oBAAC,OAAO,KAAR;EACE,6BAA0B;EAC1B,OAAO,CAAC;EAGR,UAAU;EACV,SAAQ;EACR,SAAS,SAAS,SAAS;EAC3B,MAAK;EACL,OAAO;GACL;GACA;GACA;GACA,eAAe,YAAY,SAAS;GACpC,YAAY,SAAS,YAAY;GACjC,iBAAiB,UAAU,cAAc,KAAK;EAChD;EACA,WAAW,GAAG,gBAAgB,UAAU,oDAAoD;EAE5F,UAAA,oBAAC,OAAO,KAAR;GACE,KAAK,IAAI;GACT,IAAI,IAAI;GACR,MAAK;GACL,mBAAiB,IAAI;GACrB,UAAU;GACV,OAAO;IACL,cAAc;IACd,WAAW,SAAS,kBAAkB,KAAA;IACtC,WAAW;GACb;GACA,WAAW,GAAG,sDAAsD,SAAS;GAE5E;EACS,CAAA;CACF,CAAA;AAEhB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/prediction-market-card.d.ts
|
|
3
|
+
export interface PredictionMarketCardOutcome {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Probability between 0 and 1. */
|
|
7
|
+
probability: number;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Optional team color for the compact probability line. */
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PredictionMarketCardSelection {
|
|
13
|
+
outcomeId: string;
|
|
14
|
+
side: "yes" | "no";
|
|
15
|
+
}
|
|
16
|
+
export interface PredictionMarketCardProps {
|
|
17
|
+
title: string;
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
category?: string;
|
|
20
|
+
volume: string;
|
|
21
|
+
/** Chronological volume samples for the optional footer sparkline. */
|
|
22
|
+
volumeHistory?: number[];
|
|
23
|
+
/** A scheduled time or live match status. */
|
|
24
|
+
status?: string;
|
|
25
|
+
live?: boolean;
|
|
26
|
+
outcomes: PredictionMarketCardOutcome[];
|
|
27
|
+
/** Called on each outcome CTA click; the card keeps no selected state. */
|
|
28
|
+
onOutcomeClick?: (value: PredictionMarketCardSelection) => void;
|
|
29
|
+
bookmarked?: boolean;
|
|
30
|
+
defaultBookmarked?: boolean;
|
|
31
|
+
onBookmarkChange?: (bookmarked: boolean) => void;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
/** A listing surface with outcome CTAs and an independent bookmark toggle. */
|
|
35
|
+
export declare function PredictionMarketCard({ title, icon, category, volume, volumeHistory, status, live, outcomes, onOutcomeClick, bookmarked, defaultBookmarked, onBookmarkChange, className }: PredictionMarketCardProps): import("react").JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=prediction-market-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction-market-card.d.ts","names":[],"sources":["../../../src/components/motion/prediction-market-card.tsx"],"mappings":";;iBAYiB;EACf;EACA;;EAEA;EACA,OAAO;;EAEP;;iBAGe;EACf;EACA;;iBAGe;EACf;EACA,OAAO;EACP;EACA;;EAEA;;EAEA;EACA;EACA,UAAU;;EAEV,kBAAkB,OAAO;EACzB;EACA;EACA,oBAAoB;EACpB;;;wBAQc,uBACd,OACA,MACA,UACA,QACA,eACA,QACA,MACA,UACA,gBACA,YACA,mBACA,kBACA,aACC,4CAAyB,IAAA"}
|