@kumix/ui 0.2.3 → 0.3.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 +32 -10
- package/dist/components/motion/action-swap-blur.d.ts +11 -0
- package/dist/components/motion/action-swap-blur.d.ts.map +1 -0
- package/dist/components/motion/action-swap-blur.js +26 -0
- package/dist/components/motion/action-swap-blur.js.map +1 -0
- package/dist/components/motion/action-swap-cascade.d.ts +11 -0
- package/dist/components/motion/action-swap-cascade.d.ts.map +1 -0
- package/dist/components/motion/action-swap-cascade.js +26 -0
- package/dist/components/motion/action-swap-cascade.js.map +1 -0
- package/dist/components/motion/action-swap-roll.d.ts +11 -0
- package/dist/components/motion/action-swap-roll.d.ts.map +1 -0
- package/dist/components/motion/action-swap-roll.js +26 -0
- package/dist/components/motion/action-swap-roll.js.map +1 -0
- package/dist/components/motion/action-swap.d.ts +41 -0
- package/dist/components/motion/action-swap.d.ts.map +1 -0
- package/dist/components/motion/action-swap.js +261 -0
- package/dist/components/motion/action-swap.js.map +1 -0
- package/dist/components/motion/animated-badge.d.ts +18 -0
- package/dist/components/motion/animated-badge.d.ts.map +1 -0
- package/dist/components/motion/animated-badge.js +206 -0
- package/dist/components/motion/animated-badge.js.map +1 -0
- package/dist/components/motion/animated-number.d.ts +12 -0
- package/dist/components/motion/animated-number.d.ts.map +1 -0
- package/dist/components/motion/animated-number.js +47 -0
- package/dist/components/motion/animated-number.js.map +1 -0
- package/dist/components/motion/animated-sidebar.d.ts +97 -0
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -0
- package/dist/components/motion/animated-sidebar.js +611 -0
- package/dist/components/motion/animated-sidebar.js.map +1 -0
- package/dist/components/motion/animated-toast-stack.d.ts +65 -0
- package/dist/components/motion/animated-toast-stack.d.ts.map +1 -0
- package/dist/components/motion/animated-toast-stack.js +303 -0
- package/dist/components/motion/animated-toast-stack.js.map +1 -0
- package/dist/components/motion/bottom-sheet.d.ts +19 -0
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -0
- package/dist/components/motion/bottom-sheet.js +146 -0
- package/dist/components/motion/bottom-sheet.js.map +1 -0
- package/dist/components/motion/bounce-sidebar.d.ts +26 -0
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -0
- package/dist/components/motion/bounce-sidebar.js +164 -0
- package/dist/components/motion/bounce-sidebar.js.map +1 -0
- package/dist/components/motion/bouncy-accordion.d.ts +32 -0
- package/dist/components/motion/bouncy-accordion.d.ts.map +1 -0
- package/dist/components/motion/bouncy-accordion.js +172 -0
- package/dist/components/motion/bouncy-accordion.js.map +1 -0
- package/dist/components/motion/button/base.d.ts +17 -0
- package/dist/components/motion/button/base.d.ts.map +1 -0
- package/dist/components/motion/button/base.js +86 -0
- package/dist/components/motion/button/base.js.map +1 -0
- package/dist/components/motion/button/magnetic.d.ts +12 -0
- package/dist/components/motion/button/magnetic.d.ts.map +1 -0
- package/dist/components/motion/button/magnetic.js +21 -0
- package/dist/components/motion/button/magnetic.js.map +1 -0
- package/dist/components/motion/button/stateful.d.ts +16 -0
- package/dist/components/motion/button/stateful.d.ts.map +1 -0
- package/dist/components/motion/button/stateful.js +190 -0
- package/dist/components/motion/button/stateful.js.map +1 -0
- package/dist/components/motion/center-morph-modal.d.ts +43 -0
- package/dist/components/motion/center-morph-modal.d.ts.map +1 -0
- package/dist/components/motion/center-morph-modal.js +238 -0
- package/dist/components/motion/center-morph-modal.js.map +1 -0
- package/dist/components/motion/checkbox.d.ts +15 -0
- package/dist/components/motion/checkbox.d.ts.map +1 -0
- package/dist/components/motion/checkbox.js +81 -0
- package/dist/components/motion/checkbox.js.map +1 -0
- package/dist/components/motion/chromatic-text-reveal.d.ts +31 -0
- package/dist/components/motion/chromatic-text-reveal.d.ts.map +1 -0
- package/dist/components/motion/chromatic-text-reveal.js +132 -0
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -0
- package/dist/components/motion/context-menu.d.ts +71 -0
- package/dist/components/motion/context-menu.d.ts.map +1 -0
- package/dist/components/motion/context-menu.js +454 -0
- package/dist/components/motion/context-menu.js.map +1 -0
- package/dist/components/motion/cylinder-carousel.d.ts +40 -0
- package/dist/components/motion/cylinder-carousel.d.ts.map +1 -0
- package/dist/components/motion/cylinder-carousel.js +274 -0
- package/dist/components/motion/cylinder-carousel.js.map +1 -0
- package/dist/components/motion/dock.d.ts +24 -0
- package/dist/components/motion/dock.d.ts.map +1 -0
- package/dist/components/motion/dock.js +62 -0
- package/dist/components/motion/dock.js.map +1 -0
- package/dist/components/motion/drawer.d.ts +19 -0
- package/dist/components/motion/drawer.d.ts.map +1 -0
- package/dist/components/motion/drawer.js +58 -0
- package/dist/components/motion/drawer.js.map +1 -0
- package/dist/components/motion/hold-action-button.d.ts +17 -0
- package/dist/components/motion/hold-action-button.d.ts.map +1 -0
- package/dist/components/motion/hold-action-button.js +158 -0
- package/dist/components/motion/hold-action-button.js.map +1 -0
- package/dist/components/motion/input.d.ts +29 -0
- package/dist/components/motion/input.d.ts.map +1 -0
- package/dist/components/motion/input.js +126 -0
- package/dist/components/motion/input.js.map +1 -0
- package/dist/components/motion/loader.d.ts +17 -0
- package/dist/components/motion/loader.d.ts.map +1 -0
- package/dist/components/motion/loader.js +791 -0
- package/dist/components/motion/loader.js.map +1 -0
- package/dist/components/motion/magnetic.d.ts +11 -0
- package/dist/components/motion/magnetic.d.ts.map +1 -0
- package/dist/components/motion/magnetic.js +44 -0
- package/dist/components/motion/magnetic.js.map +1 -0
- package/dist/components/motion/marquee.d.ts +15 -0
- package/dist/components/motion/marquee.d.ts.map +1 -0
- package/dist/components/motion/marquee.js +35 -0
- package/dist/components/motion/marquee.js.map +1 -0
- package/dist/components/motion/morphing-modal.d.ts +15 -0
- package/dist/components/motion/morphing-modal.d.ts.map +1 -0
- package/dist/components/motion/morphing-modal.js +117 -0
- package/dist/components/motion/morphing-modal.js.map +1 -0
- package/dist/components/motion/number-ticker.d.ts +26 -0
- package/dist/components/motion/number-ticker.d.ts.map +1 -0
- package/dist/components/motion/number-ticker.js +129 -0
- package/dist/components/motion/number-ticker.js.map +1 -0
- package/dist/components/motion/parallax.d.ts +21 -0
- package/dist/components/motion/parallax.d.ts.map +1 -0
- package/dist/components/motion/parallax.js +35 -0
- package/dist/components/motion/parallax.js.map +1 -0
- package/dist/components/motion/popover-morph.d.ts +38 -0
- package/dist/components/motion/popover-morph.d.ts.map +1 -0
- package/dist/components/motion/popover-morph.js +167 -0
- package/dist/components/motion/popover-morph.js.map +1 -0
- package/dist/components/motion/popover.d.ts +40 -0
- package/dist/components/motion/popover.d.ts.map +1 -0
- package/dist/components/motion/popover.js +393 -0
- package/dist/components/motion/popover.js.map +1 -0
- package/dist/components/motion/preview-rail.d.ts +26 -0
- package/dist/components/motion/preview-rail.d.ts.map +1 -0
- package/dist/components/motion/preview-rail.js +134 -0
- package/dist/components/motion/preview-rail.js.map +1 -0
- package/dist/components/motion/pull-to-refresh.d.ts +28 -0
- package/dist/components/motion/pull-to-refresh.d.ts.map +1 -0
- package/dist/components/motion/pull-to-refresh.js +389 -0
- package/dist/components/motion/pull-to-refresh.js.map +1 -0
- package/dist/components/motion/radio.d.ts +22 -0
- package/dist/components/motion/radio.d.ts.map +1 -0
- package/dist/components/motion/radio.js +79 -0
- package/dist/components/motion/radio.js.map +1 -0
- package/dist/components/motion/range-slider-bubble.d.ts +16 -0
- package/dist/components/motion/range-slider-bubble.d.ts.map +1 -0
- package/dist/components/motion/range-slider-bubble.js +117 -0
- package/dist/components/motion/range-slider-bubble.js.map +1 -0
- package/dist/components/motion/range-slider-fluid.d.ts +18 -0
- package/dist/components/motion/range-slider-fluid.d.ts.map +1 -0
- package/dist/components/motion/range-slider-fluid.js +63 -0
- package/dist/components/motion/range-slider-fluid.js.map +1 -0
- package/dist/components/motion/range-slider-ruler.d.ts +19 -0
- package/dist/components/motion/range-slider-ruler.d.ts.map +1 -0
- package/dist/components/motion/range-slider-ruler.js +142 -0
- package/dist/components/motion/range-slider-ruler.js.map +1 -0
- package/dist/components/motion/range-slider-wave.d.ts +16 -0
- package/dist/components/motion/range-slider-wave.d.ts.map +1 -0
- package/dist/components/motion/range-slider-wave.js +57 -0
- package/dist/components/motion/range-slider-wave.js.map +1 -0
- package/dist/components/motion/range-slider.d.ts +11 -0
- package/dist/components/motion/range-slider.d.ts.map +1 -0
- package/dist/components/motion/range-slider.js +63 -0
- package/dist/components/motion/range-slider.js.map +1 -0
- package/dist/components/motion/scroll-progress.d.ts +29 -0
- package/dist/components/motion/scroll-progress.d.ts.map +1 -0
- package/dist/components/motion/scroll-progress.js +71 -0
- package/dist/components/motion/scroll-progress.js.map +1 -0
- package/dist/components/motion/scroll-reveal.d.ts +23 -0
- package/dist/components/motion/scroll-reveal.d.ts.map +1 -0
- package/dist/components/motion/scroll-reveal.js +42 -0
- package/dist/components/motion/scroll-reveal.js.map +1 -0
- package/dist/components/motion/scroll-to.d.ts +21 -0
- package/dist/components/motion/scroll-to.d.ts.map +1 -0
- package/dist/components/motion/scroll-to.js +27 -0
- package/dist/components/motion/scroll-to.js.map +1 -0
- package/dist/components/motion/select-morph.d.ts +41 -0
- package/dist/components/motion/select-morph.d.ts.map +1 -0
- package/dist/components/motion/select-morph.js +251 -0
- package/dist/components/motion/select-morph.js.map +1 -0
- package/dist/components/motion/select.d.ts +36 -0
- package/dist/components/motion/select.d.ts.map +1 -0
- package/dist/components/motion/select.js +319 -0
- package/dist/components/motion/select.js.map +1 -0
- package/dist/components/motion/shader-background.d.ts +38 -0
- package/dist/components/motion/shader-background.d.ts.map +1 -0
- package/dist/components/motion/shader-background.js +49 -0
- package/dist/components/motion/shader-background.js.map +1 -0
- package/dist/components/motion/shared-layout-bg.d.ts +17 -0
- package/dist/components/motion/shared-layout-bg.d.ts.map +1 -0
- package/dist/components/motion/shared-layout-bg.js +88 -0
- package/dist/components/motion/shared-layout-bg.js.map +1 -0
- package/dist/components/motion/slide-action-button.d.ts +15 -0
- package/dist/components/motion/slide-action-button.d.ts.map +1 -0
- package/dist/components/motion/slide-action-button.js +146 -0
- package/dist/components/motion/slide-action-button.js.map +1 -0
- package/dist/components/motion/smooth-scroll.d.ts +47 -0
- package/dist/components/motion/smooth-scroll.d.ts.map +1 -0
- package/dist/components/motion/smooth-scroll.js +182 -0
- package/dist/components/motion/smooth-scroll.js.map +1 -0
- package/dist/components/motion/switch.d.ts +13 -0
- package/dist/components/motion/switch.d.ts.map +1 -0
- package/dist/components/motion/switch.js +76 -0
- package/dist/components/motion/switch.js.map +1 -0
- package/dist/components/motion/table/editable-cell.d.ts +9 -0
- package/dist/components/motion/table/editable-cell.d.ts.map +1 -0
- package/dist/components/motion/table/editable-cell.js +17 -0
- package/dist/components/motion/table/editable-cell.js.map +1 -0
- package/dist/components/motion/table/index.d.ts +6 -0
- package/dist/components/motion/table/index.d.ts.map +1 -0
- package/dist/components/motion/table/index.js +420 -0
- package/dist/components/motion/table/index.js.map +1 -0
- package/dist/components/motion/table/row-handle.d.ts +15 -0
- package/dist/components/motion/table/row-handle.d.ts.map +1 -0
- package/dist/components/motion/table/row-handle.js +51 -0
- package/dist/components/motion/table/row-handle.js.map +1 -0
- package/dist/components/motion/table/skeleton-rows.d.ts +11 -0
- package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -0
- package/dist/components/motion/table/skeleton-rows.js +23 -0
- package/dist/components/motion/table/skeleton-rows.js.map +1 -0
- package/dist/components/motion/table/table-header.d.ts +35 -0
- package/dist/components/motion/table/table-header.d.ts.map +1 -0
- package/dist/components/motion/table/table-header.js +167 -0
- package/dist/components/motion/table/table-header.js.map +1 -0
- package/dist/components/motion/table/table-menu.d.ts +17 -0
- package/dist/components/motion/table/table-menu.d.ts.map +1 -0
- package/dist/components/motion/table/table-menu.js +92 -0
- package/dist/components/motion/table/table-menu.js.map +1 -0
- package/dist/components/motion/tabs.d.ts +29 -0
- package/dist/components/motion/tabs.d.ts.map +1 -0
- package/dist/components/motion/tabs.js +125 -0
- package/dist/components/motion/tabs.js.map +1 -0
- package/dist/components/motion/text-cascade.d.ts +15 -0
- package/dist/components/motion/text-cascade.d.ts.map +1 -0
- package/dist/components/motion/text-cascade.js +21 -0
- package/dist/components/motion/text-cascade.js.map +1 -0
- package/dist/components/motion/text-reveal.d.ts +25 -0
- package/dist/components/motion/text-reveal.d.ts.map +1 -0
- package/dist/components/motion/text-reveal.js +94 -0
- package/dist/components/motion/text-reveal.js.map +1 -0
- package/dist/components/motion/text-shimmer.d.ts +12 -0
- package/dist/components/motion/text-shimmer.d.ts.map +1 -0
- package/dist/components/motion/text-shimmer.js +15 -0
- package/dist/components/motion/text-shimmer.js.map +1 -0
- package/dist/components/motion/theme-toggle.d.ts +23 -0
- package/dist/components/motion/theme-toggle.d.ts.map +1 -0
- package/dist/components/motion/theme-toggle.js +160 -0
- package/dist/components/motion/theme-toggle.js.map +1 -0
- package/dist/components/motion/tilt-card.d.ts +12 -0
- package/dist/components/motion/tilt-card.d.ts.map +1 -0
- package/dist/components/motion/tilt-card.js +56 -0
- package/dist/components/motion/tilt-card.js.map +1 -0
- package/dist/components/motion/tooltip.d.ts +17 -0
- package/dist/components/motion/tooltip.d.ts.map +1 -0
- package/dist/components/motion/tooltip.js +194 -0
- package/dist/components/motion/tooltip.js.map +1 -0
- package/dist/components/motion/wheel-picker.d.ts +24 -0
- package/dist/components/motion/wheel-picker.d.ts.map +1 -0
- package/dist/components/motion/wheel-picker.js +442 -0
- package/dist/components/motion/wheel-picker.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 +2 -2
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/badge.js +10 -9
- package/dist/components/reui/badge.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +21 -19
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +4 -2
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +2 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js +8 -7
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +7 -4
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +49 -47
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-lib.js +3 -2
- package/dist/components/reui/event-calendar/event-calendar-lib.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +37 -31
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +2 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +2 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters.js +5 -3
- package/dist/components/reui/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +52 -51
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-lib.js +3 -2
- package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +34 -30
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-recurrence.js +2 -2
- package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +175 -171
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/icon-tile.js +12 -11
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.js +42 -37
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/sortable.js +10 -9
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/stepper.js +16 -16
- package/dist/components/reui/stepper.js.map +1 -1
- package/dist/components/reui/timeline.js +45 -38
- package/dist/components/reui/timeline.js.map +1 -1
- package/dist/components/reui/tree.js +2 -1
- package/dist/components/reui/tree.js.map +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +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 +2 -2
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/empty.js +2 -2
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/hooks/use-hover-capable.d.ts +10 -0
- package/dist/hooks/use-hover-capable.d.ts.map +1 -0
- package/dist/hooks/use-hover-capable.js +24 -0
- package/dist/hooks/use-hover-capable.js.map +1 -0
- package/dist/hooks/use-mobile.js +1 -1
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/hooks/use-slider.d.ts +58 -0
- package/dist/hooks/use-slider.d.ts.map +1 -0
- package/dist/hooks/use-slider.js +133 -0
- package/dist/hooks/use-slider.js.map +1 -0
- package/dist/lib/ease.d.ts +50 -0
- package/dist/lib/ease.d.ts.map +1 -0
- package/dist/lib/ease.js +66 -0
- package/dist/lib/ease.js.map +1 -0
- package/dist/lib/tick-sound.d.ts +17 -0
- package/dist/lib/tick-sound.d.ts.map +1 -0
- package/dist/lib/tick-sound.js +120 -0
- package/dist/lib/tick-sound.js.map +1 -0
- package/dist/popover-position-BUqYCq8X.js +54 -0
- package/dist/popover-position-BUqYCq8X.js.map +1 -0
- package/dist/theme.css +18 -58
- package/dist/types-Bah5NY44.d.ts +81 -0
- package/dist/types-Bah5NY44.d.ts.map +1 -0
- package/dist/utils-DQ7OpbYQ.js +25 -0
- package/dist/utils-DQ7OpbYQ.js.map +1 -0
- package/package.json +17 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/popover-morph.d.ts
|
|
3
|
+
type Side = "top" | "bottom";
|
|
4
|
+
type Align = "start" | "end";
|
|
5
|
+
interface MorphPopoverProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Controlled open state. */
|
|
8
|
+
open?: boolean;
|
|
9
|
+
/** Uncontrolled initial open state. */
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A popover whose panel morphs open from the trigger corner: it's laid out at
|
|
16
|
+
* full size but clipped to the corner nearest the trigger, then unclips as one
|
|
17
|
+
* piece. Closes on outside pointer / Escape. Controlled or uncontrolled.
|
|
18
|
+
*/
|
|
19
|
+
declare function MorphPopover({ children, open: controlledOpen, defaultOpen, onOpenChange, className }: MorphPopoverProps): import("react").JSX.Element;
|
|
20
|
+
interface MorphPopoverTriggerProps {
|
|
21
|
+
children: ReactElement;
|
|
22
|
+
}
|
|
23
|
+
/** Wraps a single element, toggling the popover on click. */
|
|
24
|
+
declare function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps): ReactElement<Record<string, unknown>, string | import("react").JSXElementConstructor<any>>;
|
|
25
|
+
interface MorphPopoverContentProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
side?: Side;
|
|
28
|
+
align?: Align;
|
|
29
|
+
/** Gap between trigger and panel, in px. Default 8. */
|
|
30
|
+
sideOffset?: number;
|
|
31
|
+
/** Panel corner radius, in px. Default 16. */
|
|
32
|
+
radius?: number;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
declare function MorphPopoverContent({ children, side, align, sideOffset, radius, className }: MorphPopoverContentProps): import("react").ReactPortal | null;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { MorphPopover, MorphPopoverContent, MorphPopoverContentProps, MorphPopoverProps, MorphPopoverTrigger, MorphPopoverTriggerProps };
|
|
38
|
+
//# sourceMappingURL=popover-morph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-morph.d.ts","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"mappings":";;KAwBK;KACA;UAoBY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;EAChB;;;;;;;iBAQc,eACd,UACA,MAAM,gBACN,aACA,cACA,aACC,oCAAiB,IAAA;UA4DH;EACf,UAAU;;;iBAcI,sBAAsB,YAAY,2BAAwB,aAAA,kDAAA;UAyCzD;EACf,UAAU;EACV,OAAO;EACP,QAAQ;;EAER;;EAEA;EACA;;iBAGc,sBACd,UACA,MACA,OACA,YACA,QACA,aACC,2CAAwB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
|
|
3
|
+
import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.js";
|
|
4
|
+
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
//#region src/components/motion/popover-morph.tsx
|
|
10
|
+
const MorphContext = createContext(null);
|
|
11
|
+
function useMorphContext(component) {
|
|
12
|
+
const ctx = useContext(MorphContext);
|
|
13
|
+
if (!ctx) throw new Error(`${component} must be used within <MorphPopover>`);
|
|
14
|
+
return ctx;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A popover whose panel morphs open from the trigger corner: it's laid out at
|
|
18
|
+
* full size but clipped to the corner nearest the trigger, then unclips as one
|
|
19
|
+
* piece. Closes on outside pointer / Escape. Controlled or uncontrolled.
|
|
20
|
+
*/
|
|
21
|
+
function MorphPopover({ children, open: controlledOpen, defaultOpen = false, onOpenChange, className }) {
|
|
22
|
+
const baseId = useId();
|
|
23
|
+
const rootRef = useRef(null);
|
|
24
|
+
const triggerRef = useRef(null);
|
|
25
|
+
const contentRef = useRef(null);
|
|
26
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
27
|
+
const controlled = controlledOpen !== void 0;
|
|
28
|
+
const open = controlled ? controlledOpen : internalOpen;
|
|
29
|
+
const setOpen = useCallback((next) => {
|
|
30
|
+
if (!controlled) setInternalOpen(next);
|
|
31
|
+
onOpenChange?.(next);
|
|
32
|
+
}, [controlled, onOpenChange]);
|
|
33
|
+
const toggle = useCallback(() => setOpen(!open), [setOpen, open]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!open) return;
|
|
36
|
+
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
37
|
+
const onPointer = (e) => {
|
|
38
|
+
const target = e.target;
|
|
39
|
+
if (rootRef.current && !rootRef.current.contains(target) && !contentRef.current?.contains(target)) setOpen(false);
|
|
40
|
+
};
|
|
41
|
+
window.addEventListener("keydown", onKey);
|
|
42
|
+
window.addEventListener("pointerdown", onPointer);
|
|
43
|
+
return () => {
|
|
44
|
+
window.removeEventListener("keydown", onKey);
|
|
45
|
+
window.removeEventListener("pointerdown", onPointer);
|
|
46
|
+
};
|
|
47
|
+
}, [open, setOpen]);
|
|
48
|
+
const ctx = useMemo(() => ({
|
|
49
|
+
open,
|
|
50
|
+
setOpen,
|
|
51
|
+
toggle,
|
|
52
|
+
triggerId: `${baseId}-trigger`,
|
|
53
|
+
contentId: `${baseId}-content`,
|
|
54
|
+
triggerRef,
|
|
55
|
+
contentRef
|
|
56
|
+
}), [
|
|
57
|
+
open,
|
|
58
|
+
setOpen,
|
|
59
|
+
toggle,
|
|
60
|
+
baseId
|
|
61
|
+
]);
|
|
62
|
+
return /* @__PURE__ */ jsx(MorphContext.Provider, {
|
|
63
|
+
value: ctx,
|
|
64
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
65
|
+
ref: rootRef,
|
|
66
|
+
className: cn("relative inline-flex", className),
|
|
67
|
+
children
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function mergeRefs(...refs) {
|
|
72
|
+
return (node) => {
|
|
73
|
+
for (const ref of refs) if (typeof ref === "function") ref(node);
|
|
74
|
+
else if (ref && typeof ref === "object") ref.current = node;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Wraps a single element, toggling the popover on click. */
|
|
78
|
+
function MorphPopoverTrigger({ children }) {
|
|
79
|
+
const ctx = useMorphContext("MorphPopoverTrigger");
|
|
80
|
+
if (!isValidElement(children)) return children;
|
|
81
|
+
const child = children;
|
|
82
|
+
const childOnClick = child.props.onClick;
|
|
83
|
+
const childRef = child.props.ref;
|
|
84
|
+
return cloneElement(child, {
|
|
85
|
+
id: ctx.triggerId,
|
|
86
|
+
ref: mergeRefs(childRef, (node) => {
|
|
87
|
+
ctx.triggerRef.current = node;
|
|
88
|
+
}),
|
|
89
|
+
onClick: (e) => {
|
|
90
|
+
childOnClick?.(e);
|
|
91
|
+
ctx.toggle();
|
|
92
|
+
},
|
|
93
|
+
"aria-haspopup": "dialog",
|
|
94
|
+
"aria-expanded": ctx.open,
|
|
95
|
+
"aria-controls": ctx.open ? ctx.contentId : void 0
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const originFor = (side, align) => `${side === "bottom" ? "top" : "bottom"} ${align === "end" ? "right" : "left"}`;
|
|
99
|
+
function clipHidden(side, align, radius) {
|
|
100
|
+
return `inset(${side === "bottom" ? "0%" : "92%"} ${align === "end" ? "0%" : "92%"} ${side === "bottom" ? "92%" : "0%"} ${align === "end" ? "92%" : "0%"} round ${radius}px)`;
|
|
101
|
+
}
|
|
102
|
+
const clipShown = (radius) => `inset(0% 0% 0% 0% round ${radius}px)`;
|
|
103
|
+
const MORPH_CLIP_TRANSITION = {
|
|
104
|
+
duration: .32,
|
|
105
|
+
ease: EASE_OUT
|
|
106
|
+
};
|
|
107
|
+
function MorphPopoverContent({ children, side = "bottom", align = "end", sideOffset = 8, radius = 16, className }) {
|
|
108
|
+
const ctx = useMorphContext("MorphPopoverContent");
|
|
109
|
+
const reduce = useReducedMotion() ?? false;
|
|
110
|
+
const [portalReady, setPortalReady] = useState(false);
|
|
111
|
+
const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, portalReady && ctx.open);
|
|
112
|
+
useEffect(() => setPortalReady(true), []);
|
|
113
|
+
const left = layout ? align === "end" ? layout.trigger.left + layout.trigger.width - layout.content.width : layout.trigger.left : 0;
|
|
114
|
+
const top = layout ? side === "bottom" ? layout.trigger.top + layout.trigger.height + sideOffset : layout.trigger.top - layout.content.height - sideOffset : 0;
|
|
115
|
+
const wrap = reduce ? void 0 : {
|
|
116
|
+
hidden: {
|
|
117
|
+
opacity: 0,
|
|
118
|
+
scale: .96,
|
|
119
|
+
transition: SPRING_PANEL
|
|
120
|
+
},
|
|
121
|
+
show: {
|
|
122
|
+
opacity: 1,
|
|
123
|
+
scale: 1,
|
|
124
|
+
transition: SPRING_PANEL
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const clip = reduce ? void 0 : {
|
|
128
|
+
hidden: {
|
|
129
|
+
clipPath: clipHidden(side, align, radius),
|
|
130
|
+
transition: MORPH_CLIP_TRANSITION
|
|
131
|
+
},
|
|
132
|
+
show: {
|
|
133
|
+
clipPath: clipShown(radius),
|
|
134
|
+
transition: MORPH_CLIP_TRANSITION
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (!portalReady) return null;
|
|
138
|
+
return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: ctx.open ? /* @__PURE__ */ jsx(motion.div, {
|
|
139
|
+
"data-morph-popover-portal": "",
|
|
140
|
+
variants: wrap,
|
|
141
|
+
initial: reduce ? { opacity: 0 } : "hidden",
|
|
142
|
+
animate: reduce ? { opacity: 1 } : "show",
|
|
143
|
+
exit: reduce ? { opacity: 0 } : "hidden",
|
|
144
|
+
transition: reduce ? { duration: .12 } : void 0,
|
|
145
|
+
style: {
|
|
146
|
+
left,
|
|
147
|
+
top,
|
|
148
|
+
visibility: layout ? "visible" : "hidden",
|
|
149
|
+
transformOrigin: originFor(side, align)
|
|
150
|
+
},
|
|
151
|
+
className: "fixed z-[9999] [filter:drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]",
|
|
152
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
153
|
+
ref: ctx.contentRef,
|
|
154
|
+
id: ctx.contentId,
|
|
155
|
+
role: "dialog",
|
|
156
|
+
"aria-labelledby": ctx.triggerId,
|
|
157
|
+
variants: clip,
|
|
158
|
+
style: { borderRadius: radius },
|
|
159
|
+
className: cn("overflow-hidden border border-border bg-background", className),
|
|
160
|
+
children
|
|
161
|
+
})
|
|
162
|
+
}) : null }), document.body);
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { MorphPopover, MorphPopoverContent, MorphPopoverTrigger };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=popover-morph.js.map
|
|
@@ -0,0 +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 triggerRef: React.MutableRefObject<HTMLElement | null>;\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 rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<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 useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (\n rootRef.current &&\n !rootRef.current.contains(target) &&\n !contentRef.current?.contains(target)\n )\n setOpen(false);\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, setOpen]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n triggerId: `${baseId}-trigger`,\n contentId: `${baseId}-content`,\n triggerRef,\n contentRef,\n }),\n [open, setOpen, toggle, baseId],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={rootRef} 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, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\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=\"fixed z-[9999] [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={{ 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":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/popover.d.ts
|
|
3
|
+
type Side = "top" | "bottom";
|
|
4
|
+
type Align = "start" | "center" | "end";
|
|
5
|
+
type TriggerMode = "click" | "hover";
|
|
6
|
+
interface PopoverProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Controlled open state. */
|
|
9
|
+
open?: boolean;
|
|
10
|
+
/** Uncontrolled initial open state. */
|
|
11
|
+
defaultOpen?: boolean;
|
|
12
|
+
onOpenChange?: (open: boolean) => void;
|
|
13
|
+
/** How the popover is summoned. Default "click". */
|
|
14
|
+
trigger?: TriggerMode;
|
|
15
|
+
/** Which side of the trigger the panel oozes out of. Default "bottom". */
|
|
16
|
+
side?: Side;
|
|
17
|
+
/** Alignment along the trigger's edge. Default "center". */
|
|
18
|
+
align?: Align;
|
|
19
|
+
/** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */
|
|
20
|
+
sideOffset?: number;
|
|
21
|
+
/** Corner radius of the open panel, in px. Default 16. */
|
|
22
|
+
panelRadius?: number;
|
|
23
|
+
/** Blur radius feeding the goo filter — higher melts more. Default 8. */
|
|
24
|
+
gooStrength?: number;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function Popover({ children, open: controlledOpen, defaultOpen, onOpenChange, trigger, side, align, sideOffset, panelRadius, gooStrength, className }: PopoverProps): import("react").JSX.Element;
|
|
28
|
+
interface PopoverTriggerProps {
|
|
29
|
+
/** A single focusable element (e.g. a Button) that opens the popover. */
|
|
30
|
+
children: ReactElement;
|
|
31
|
+
}
|
|
32
|
+
declare function PopoverTrigger({ children }: PopoverTriggerProps): ReactElement<Record<string, unknown>, string | import("react").JSXElementConstructor<any>>;
|
|
33
|
+
interface PopoverContentProps {
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
declare function PopoverContent({ children, className }: PopoverContentProps): import("react").ReactPortal | null;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Popover, PopoverContent, PopoverContentProps, PopoverProps, PopoverTrigger, PopoverTriggerProps };
|
|
40
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","names":[],"sources":["../../../src/components/motion/popover.tsx"],"mappings":";;KA8BK;KACA;KACA;UA+IY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;;EAEhB,UAAU;;EAEV,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;EAEA;EACA;;iBAGc,UACd,UACA,MAAM,gBACN,aACA,cACA,SACA,MACA,OACA,YACA,aACA,aACA,aACC,+BAAY,IAAA;UA0IE;;EAEf,UAAU;;iBAGI,iBAAiB,YAAY,sBAAmB,aAAA,kDAAA;UA2C/C;EACf,UAAU;EACV;;iBAGc,iBAAiB,UAAU,aAAa,sCAAmB"}
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.js";
|
|
3
|
+
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { animate, useMotionValue, useMotionValueEvent, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
//#region src/components/motion/popover.tsx
|
|
9
|
+
const GOO_OPEN_SPRING = {
|
|
10
|
+
type: "spring",
|
|
11
|
+
visualDuration: .3,
|
|
12
|
+
bounce: .15
|
|
13
|
+
};
|
|
14
|
+
const GOO_CLOSE_SPRING = {
|
|
15
|
+
type: "spring",
|
|
16
|
+
visualDuration: .21,
|
|
17
|
+
bounce: .15
|
|
18
|
+
};
|
|
19
|
+
const HOVER_CLOSE_DELAY = 120;
|
|
20
|
+
const CIRCLE_KAPPA = .5523;
|
|
21
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
22
|
+
function buildGeo(tW, tH, cW, cH, side, align, gap, panelRadius) {
|
|
23
|
+
const py = side === "bottom" ? tH + gap : -(gap + cH);
|
|
24
|
+
const px = align === "start" ? 0 : align === "end" ? tW - cW : (tW - cW) / 2;
|
|
25
|
+
const left = Math.min(0, px);
|
|
26
|
+
const top = Math.min(0, py);
|
|
27
|
+
const layerW = Math.max(tW, px + cW) - left;
|
|
28
|
+
const layerH = Math.max(tH, py + cH) - top;
|
|
29
|
+
const triggerRadius = Math.min(tH / 2, panelRadius);
|
|
30
|
+
return {
|
|
31
|
+
layerW,
|
|
32
|
+
layerH,
|
|
33
|
+
left,
|
|
34
|
+
top,
|
|
35
|
+
trigger: {
|
|
36
|
+
x: -left,
|
|
37
|
+
y: -top,
|
|
38
|
+
w: tW,
|
|
39
|
+
h: tH,
|
|
40
|
+
r: triggerRadius
|
|
41
|
+
},
|
|
42
|
+
panel: {
|
|
43
|
+
x: px - left,
|
|
44
|
+
y: py - top,
|
|
45
|
+
w: cW,
|
|
46
|
+
h: cH,
|
|
47
|
+
r: panelRadius
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function rectAtProgress(geo, progress) {
|
|
52
|
+
const trigger = geo.trigger;
|
|
53
|
+
const panel = geo.panel;
|
|
54
|
+
return {
|
|
55
|
+
x: lerp(trigger.x, panel.x, progress),
|
|
56
|
+
y: lerp(trigger.y, panel.y, progress),
|
|
57
|
+
w: lerp(trigger.w, panel.w, progress),
|
|
58
|
+
h: lerp(trigger.h, panel.h, progress),
|
|
59
|
+
r: lerp(trigger.r, panel.r, progress)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function insetFor(rect, layerW, layerH) {
|
|
63
|
+
return `inset(${rect.y}px ${layerW - (rect.x + rect.w)}px ${layerH - (rect.y + rect.h)}px ${rect.x}px round ${rect.r}px)`;
|
|
64
|
+
}
|
|
65
|
+
function roundedRectShape(rect) {
|
|
66
|
+
const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));
|
|
67
|
+
const control = radius * CIRCLE_KAPPA;
|
|
68
|
+
const x1 = rect.x;
|
|
69
|
+
const y1 = rect.y;
|
|
70
|
+
const x2 = rect.x + rect.w;
|
|
71
|
+
const y2 = rect.y + rect.h;
|
|
72
|
+
const px = (value) => `${value.toFixed(3)}px`;
|
|
73
|
+
return `shape(from ${px(x1 + radius)} ${px(y1)}, line to ${px(x2 - radius)} ${px(y1)}, curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, line to ${px(x2)} ${px(y2 - radius)}, curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, line to ${px(x1 + radius)} ${px(y2)}, curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, line to ${px(x1)} ${px(y1 + radius)}, curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, close)`;
|
|
74
|
+
}
|
|
75
|
+
function clipForProgress(geo, progress, supportsShape) {
|
|
76
|
+
const rect = rectAtProgress(geo, progress);
|
|
77
|
+
return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);
|
|
78
|
+
}
|
|
79
|
+
const PopoverContext = createContext(null);
|
|
80
|
+
function usePopoverContext(component) {
|
|
81
|
+
const ctx = useContext(PopoverContext);
|
|
82
|
+
if (!ctx) throw new Error(`${component} must be used within <Popover>`);
|
|
83
|
+
return ctx;
|
|
84
|
+
}
|
|
85
|
+
function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenChange, trigger = "click", side = "bottom", align = "center", sideOffset = 14, panelRadius = 16, gooStrength = 8, className }) {
|
|
86
|
+
const reduce = useReducedMotion() ?? false;
|
|
87
|
+
const gooId = useId().replace(/:/g, "");
|
|
88
|
+
const contentId = useId();
|
|
89
|
+
const rootRef = useRef(null);
|
|
90
|
+
const triggerRef = useRef(null);
|
|
91
|
+
const contentRef = useRef(null);
|
|
92
|
+
const closeTimer = useRef(null);
|
|
93
|
+
const progress = useMotionValue(defaultOpen ? 1 : 0);
|
|
94
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
95
|
+
const controlled = controlledOpen !== void 0;
|
|
96
|
+
const open = controlled ? controlledOpen : internalOpen;
|
|
97
|
+
const setOpen = useCallback((next) => {
|
|
98
|
+
if (!controlled) setInternalOpen(next);
|
|
99
|
+
onOpenChange?.(next);
|
|
100
|
+
}, [controlled, onOpenChange]);
|
|
101
|
+
const cancelClose = useCallback(() => {
|
|
102
|
+
if (closeTimer.current) {
|
|
103
|
+
clearTimeout(closeTimer.current);
|
|
104
|
+
closeTimer.current = null;
|
|
105
|
+
}
|
|
106
|
+
}, []);
|
|
107
|
+
const openHover = useCallback(() => {
|
|
108
|
+
cancelClose();
|
|
109
|
+
setOpen(true);
|
|
110
|
+
}, [cancelClose, setOpen]);
|
|
111
|
+
const scheduleClose = useCallback(() => {
|
|
112
|
+
cancelClose();
|
|
113
|
+
closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);
|
|
114
|
+
}, [cancelClose, setOpen]);
|
|
115
|
+
const toggle = useCallback(() => setOpen(!open), [setOpen, open]);
|
|
116
|
+
useEffect(() => () => cancelClose(), [cancelClose]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const animation = animate(progress, open ? 1 : 0, reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING);
|
|
119
|
+
return () => animation.stop();
|
|
120
|
+
}, [
|
|
121
|
+
open,
|
|
122
|
+
progress,
|
|
123
|
+
reduce
|
|
124
|
+
]);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!open) return;
|
|
127
|
+
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
128
|
+
const onPointer = (e) => {
|
|
129
|
+
const target = e.target;
|
|
130
|
+
if (rootRef.current && !rootRef.current.contains(target) && !contentRef.current?.contains(target)) setOpen(false);
|
|
131
|
+
};
|
|
132
|
+
window.addEventListener("keydown", onKey);
|
|
133
|
+
if (trigger === "click") window.addEventListener("pointerdown", onPointer);
|
|
134
|
+
return () => {
|
|
135
|
+
window.removeEventListener("keydown", onKey);
|
|
136
|
+
window.removeEventListener("pointerdown", onPointer);
|
|
137
|
+
};
|
|
138
|
+
}, [
|
|
139
|
+
open,
|
|
140
|
+
setOpen,
|
|
141
|
+
trigger
|
|
142
|
+
]);
|
|
143
|
+
const ctx = useMemo(() => ({
|
|
144
|
+
open,
|
|
145
|
+
setOpen,
|
|
146
|
+
toggle,
|
|
147
|
+
openHover,
|
|
148
|
+
scheduleClose,
|
|
149
|
+
triggerMode: trigger,
|
|
150
|
+
side,
|
|
151
|
+
align,
|
|
152
|
+
gap: sideOffset,
|
|
153
|
+
panelRadius,
|
|
154
|
+
gooStrength,
|
|
155
|
+
reduce,
|
|
156
|
+
gooId,
|
|
157
|
+
contentId,
|
|
158
|
+
progress,
|
|
159
|
+
triggerRef,
|
|
160
|
+
contentRef
|
|
161
|
+
}), [
|
|
162
|
+
open,
|
|
163
|
+
setOpen,
|
|
164
|
+
toggle,
|
|
165
|
+
openHover,
|
|
166
|
+
scheduleClose,
|
|
167
|
+
trigger,
|
|
168
|
+
side,
|
|
169
|
+
align,
|
|
170
|
+
sideOffset,
|
|
171
|
+
panelRadius,
|
|
172
|
+
gooStrength,
|
|
173
|
+
reduce,
|
|
174
|
+
gooId,
|
|
175
|
+
contentId,
|
|
176
|
+
progress
|
|
177
|
+
]);
|
|
178
|
+
const hoverHandlers = trigger === "hover" ? {
|
|
179
|
+
onMouseEnter: openHover,
|
|
180
|
+
onMouseLeave: scheduleClose
|
|
181
|
+
} : {};
|
|
182
|
+
return /* @__PURE__ */ jsx(PopoverContext.Provider, {
|
|
183
|
+
value: ctx,
|
|
184
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
185
|
+
ref: rootRef,
|
|
186
|
+
className: cn("relative isolate inline-flex", className),
|
|
187
|
+
...hoverHandlers,
|
|
188
|
+
children
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function mergeRefs(...refs) {
|
|
193
|
+
return (node) => {
|
|
194
|
+
for (const ref of refs) if (typeof ref === "function") ref(node);
|
|
195
|
+
else if (ref && typeof ref === "object") ref.current = node;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function PopoverTrigger({ children }) {
|
|
199
|
+
const ctx = usePopoverContext("PopoverTrigger");
|
|
200
|
+
if (!isValidElement(children)) return children;
|
|
201
|
+
const child = children;
|
|
202
|
+
const childProps = child.props;
|
|
203
|
+
const childRef = childProps.ref;
|
|
204
|
+
const compose = (name, handler) => (event) => {
|
|
205
|
+
childProps[name]?.(event);
|
|
206
|
+
if (!event.defaultPrevented) handler();
|
|
207
|
+
};
|
|
208
|
+
const handlers = ctx.triggerMode === "hover" ? {
|
|
209
|
+
onFocus: compose("onFocus", ctx.openHover),
|
|
210
|
+
onBlur: compose("onBlur", ctx.scheduleClose)
|
|
211
|
+
} : { onClick: compose("onClick", ctx.toggle) };
|
|
212
|
+
return cloneElement(child, {
|
|
213
|
+
...handlers,
|
|
214
|
+
ref: mergeRefs(childRef, (node) => {
|
|
215
|
+
ctx.triggerRef.current = node;
|
|
216
|
+
}),
|
|
217
|
+
className: cn("relative z-0", childProps.className),
|
|
218
|
+
"aria-haspopup": "dialog",
|
|
219
|
+
"aria-expanded": ctx.open,
|
|
220
|
+
"aria-controls": ctx.open ? ctx.contentId : void 0,
|
|
221
|
+
"data-state": ctx.open ? "open" : "closed"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
const ALIGN_ORIGIN = {
|
|
225
|
+
start: "left",
|
|
226
|
+
center: "center",
|
|
227
|
+
end: "right"
|
|
228
|
+
};
|
|
229
|
+
function PopoverContent({ children, className }) {
|
|
230
|
+
const ctx = usePopoverContext("PopoverContent");
|
|
231
|
+
const [portalReady, setPortalReady] = useState(false);
|
|
232
|
+
const { side, align, gap, panelRadius, gooStrength, reduce, gooId, contentId, progress, triggerRef, contentRef, open, triggerMode, openHover, scheduleClose } = ctx;
|
|
233
|
+
const measureRef = contentRef;
|
|
234
|
+
const blobRef = useRef(null);
|
|
235
|
+
const clipRef = useRef(null);
|
|
236
|
+
const geoRef = useRef(null);
|
|
237
|
+
const supportsShapeRef = useRef(false);
|
|
238
|
+
const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);
|
|
239
|
+
useEffect(() => setPortalReady(true), []);
|
|
240
|
+
const geo = useMemo(() => buildGeo(layout?.trigger.width ?? 0, layout?.trigger.height ?? 0, layout?.content.width ?? 0, layout?.content.height ?? 0, side, align, gap, panelRadius), [
|
|
241
|
+
layout,
|
|
242
|
+
side,
|
|
243
|
+
align,
|
|
244
|
+
gap,
|
|
245
|
+
panelRadius
|
|
246
|
+
]);
|
|
247
|
+
const render = useCallback((g, p) => {
|
|
248
|
+
if (!g || g.layerW === 0) return;
|
|
249
|
+
const clip = clipForProgress(g, p, supportsShapeRef.current);
|
|
250
|
+
if (blobRef.current) blobRef.current.style.clipPath = clip;
|
|
251
|
+
if (clipRef.current) clipRef.current.style.clipPath = clip;
|
|
252
|
+
}, []);
|
|
253
|
+
useLayoutEffect(() => {
|
|
254
|
+
supportsShapeRef.current = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("clip-path", "shape(from 0px 0px, line to 1px 1px, close)");
|
|
255
|
+
geoRef.current = geo;
|
|
256
|
+
render(geo, progress.get());
|
|
257
|
+
}, [
|
|
258
|
+
geo,
|
|
259
|
+
progress,
|
|
260
|
+
render
|
|
261
|
+
]);
|
|
262
|
+
useMotionValueEvent(progress, "change", (p) => render(geoRef.current, p));
|
|
263
|
+
const hoverHandlers = triggerMode === "hover" ? {
|
|
264
|
+
onMouseEnter: openHover,
|
|
265
|
+
onMouseLeave: scheduleClose
|
|
266
|
+
} : {};
|
|
267
|
+
const maskId = `${gooId}-trigger-cutout`;
|
|
268
|
+
if (!portalReady) return null;
|
|
269
|
+
return createPortal(/* @__PURE__ */ jsxs("div", {
|
|
270
|
+
"data-popover-portal": "",
|
|
271
|
+
className: "pointer-events-none fixed top-0 left-0 isolate z-9999 size-0",
|
|
272
|
+
style: {
|
|
273
|
+
visibility: layout ? "visible" : "hidden",
|
|
274
|
+
transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`
|
|
275
|
+
},
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
278
|
+
"aria-hidden": true,
|
|
279
|
+
width: "0",
|
|
280
|
+
height: "0",
|
|
281
|
+
className: "absolute",
|
|
282
|
+
children: [/* @__PURE__ */ jsx("title", { children: "Popover visual effects" }), /* @__PURE__ */ jsxs("defs", { children: [/* @__PURE__ */ jsxs("filter", {
|
|
283
|
+
id: gooId,
|
|
284
|
+
x: "-50%",
|
|
285
|
+
y: "-50%",
|
|
286
|
+
width: "200%",
|
|
287
|
+
height: "200%",
|
|
288
|
+
children: [
|
|
289
|
+
/* @__PURE__ */ jsx("feGaussianBlur", {
|
|
290
|
+
in: "SourceGraphic",
|
|
291
|
+
stdDeviation: gooStrength,
|
|
292
|
+
result: "blur"
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ jsx("feColorMatrix", {
|
|
295
|
+
in: "blur",
|
|
296
|
+
mode: "matrix",
|
|
297
|
+
values: "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10",
|
|
298
|
+
result: "goo"
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx("feComposite", {
|
|
301
|
+
in: "SourceGraphic",
|
|
302
|
+
in2: "goo",
|
|
303
|
+
operator: "atop"
|
|
304
|
+
})
|
|
305
|
+
]
|
|
306
|
+
}), /* @__PURE__ */ jsxs("mask", {
|
|
307
|
+
id: maskId,
|
|
308
|
+
maskUnits: "userSpaceOnUse",
|
|
309
|
+
maskContentUnits: "userSpaceOnUse",
|
|
310
|
+
x: 0,
|
|
311
|
+
y: 0,
|
|
312
|
+
width: geo.layerW,
|
|
313
|
+
height: geo.layerH,
|
|
314
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
315
|
+
width: geo.layerW,
|
|
316
|
+
height: geo.layerH,
|
|
317
|
+
fill: "white"
|
|
318
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
319
|
+
x: geo.trigger.x,
|
|
320
|
+
y: geo.trigger.y,
|
|
321
|
+
width: geo.trigger.w,
|
|
322
|
+
height: geo.trigger.h,
|
|
323
|
+
rx: geo.trigger.r,
|
|
324
|
+
fill: "black"
|
|
325
|
+
})]
|
|
326
|
+
})] })]
|
|
327
|
+
}),
|
|
328
|
+
/* @__PURE__ */ jsxs("div", {
|
|
329
|
+
"aria-hidden": true,
|
|
330
|
+
className: "pointer-events-none absolute z-[-1]",
|
|
331
|
+
style: {
|
|
332
|
+
left: geo.left,
|
|
333
|
+
top: geo.top,
|
|
334
|
+
width: geo.layerW,
|
|
335
|
+
height: geo.layerH,
|
|
336
|
+
filter: reduce ? void 0 : `url(#${gooId})`,
|
|
337
|
+
mask: `url(#${maskId})`,
|
|
338
|
+
WebkitMask: `url(#${maskId})`
|
|
339
|
+
},
|
|
340
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
341
|
+
className: "absolute bg-popover",
|
|
342
|
+
style: {
|
|
343
|
+
left: geo.trigger.x,
|
|
344
|
+
top: geo.trigger.y,
|
|
345
|
+
width: geo.trigger.w,
|
|
346
|
+
height: geo.trigger.h,
|
|
347
|
+
borderRadius: geo.trigger.r
|
|
348
|
+
}
|
|
349
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
350
|
+
ref: blobRef,
|
|
351
|
+
className: "absolute inset-0 bg-popover",
|
|
352
|
+
style: { clipPath: clipForProgress(geo, progress.get(), false) }
|
|
353
|
+
})]
|
|
354
|
+
}),
|
|
355
|
+
/* @__PURE__ */ jsx("div", {
|
|
356
|
+
className: "pointer-events-none absolute z-10",
|
|
357
|
+
style: {
|
|
358
|
+
left: geo.left,
|
|
359
|
+
top: geo.top,
|
|
360
|
+
width: geo.layerW,
|
|
361
|
+
height: geo.layerH
|
|
362
|
+
},
|
|
363
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
364
|
+
ref: clipRef,
|
|
365
|
+
inert: !open,
|
|
366
|
+
className: "absolute inset-0",
|
|
367
|
+
style: {
|
|
368
|
+
clipPath: clipForProgress(geo, progress.get(), false),
|
|
369
|
+
pointerEvents: open ? "auto" : "none"
|
|
370
|
+
},
|
|
371
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
372
|
+
ref: measureRef,
|
|
373
|
+
id: contentId,
|
|
374
|
+
role: "dialog",
|
|
375
|
+
...hoverHandlers,
|
|
376
|
+
style: {
|
|
377
|
+
position: "absolute",
|
|
378
|
+
left: geo.panel.x,
|
|
379
|
+
top: geo.panel.y,
|
|
380
|
+
transformOrigin: `${ALIGN_ORIGIN[align]} ${side === "bottom" ? "top" : "bottom"}`
|
|
381
|
+
},
|
|
382
|
+
className: cn("w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none", className),
|
|
383
|
+
children
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
}), document.body);
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
export { Popover, PopoverContent, PopoverTrigger };
|
|
392
|
+
|
|
393
|
+
//# sourceMappingURL=popover.js.map
|