@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,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_DRAWER } from "../../lib/ease.js";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { AnimatePresence, motion, useDragControls, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
//#region src/components/motion/bottom-sheet.tsx
|
|
9
|
+
const DRAWER = {
|
|
10
|
+
duration: .5,
|
|
11
|
+
ease: EASE_DRAWER
|
|
12
|
+
};
|
|
13
|
+
function BottomSheet({ open, onOpenChange, snapPoints = [.5, .92], defaultSnap = 0, title, description, children, className, dismissThreshold = 120 }) {
|
|
14
|
+
const [snap, setSnap] = useState(defaultSnap);
|
|
15
|
+
const [mounted, setMounted] = useState(false);
|
|
16
|
+
const dragControls = useDragControls();
|
|
17
|
+
const sheetRef = useRef(null);
|
|
18
|
+
const reduce = useReducedMotion();
|
|
19
|
+
const heightRef = useRef(0);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setMounted(true);
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (open) setSnap(defaultSnap);
|
|
25
|
+
}, [open, defaultSnap]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!open) return;
|
|
28
|
+
const body = document.body;
|
|
29
|
+
const scrollY = window.scrollY;
|
|
30
|
+
const prev = {
|
|
31
|
+
position: body.style.position,
|
|
32
|
+
top: body.style.top,
|
|
33
|
+
left: body.style.left,
|
|
34
|
+
right: body.style.right,
|
|
35
|
+
overflow: body.style.overflow
|
|
36
|
+
};
|
|
37
|
+
body.style.position = "fixed";
|
|
38
|
+
body.style.top = `-${scrollY}px`;
|
|
39
|
+
body.style.left = "0";
|
|
40
|
+
body.style.right = "0";
|
|
41
|
+
body.style.overflow = "hidden";
|
|
42
|
+
return () => {
|
|
43
|
+
body.style.position = prev.position;
|
|
44
|
+
body.style.top = prev.top;
|
|
45
|
+
body.style.left = prev.left;
|
|
46
|
+
body.style.right = prev.right;
|
|
47
|
+
body.style.overflow = prev.overflow;
|
|
48
|
+
window.scrollTo(0, scrollY);
|
|
49
|
+
};
|
|
50
|
+
}, [open]);
|
|
51
|
+
const onDragEnd = (_, info) => {
|
|
52
|
+
const velocity = info.velocity.y;
|
|
53
|
+
const offset = info.offset.y;
|
|
54
|
+
if (velocity > 600 || offset > dismissThreshold) {
|
|
55
|
+
const smaller = snapPoints.map((_, i) => i).filter((i) => i < snap);
|
|
56
|
+
if (smaller.length && velocity < 800 && offset < dismissThreshold * 1.6) setSnap(smaller[smaller.length - 1]);
|
|
57
|
+
else onOpenChange(false);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (velocity < -500) {
|
|
61
|
+
setSnap((current) => Math.min(snapPoints.length - 1, current + 1));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setSnap((current) => {
|
|
65
|
+
if (offset > 80 && current > 0) return current - 1;
|
|
66
|
+
if (offset < -80 && current < snapPoints.length - 1) return current + 1;
|
|
67
|
+
return current;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const snapValue = snapPoints[snap];
|
|
71
|
+
const heightStyle = snapValue === "auto" ? { maxHeight: "92vh" } : { height: `${snapValue * 100}vh` };
|
|
72
|
+
if (!mounted) return null;
|
|
73
|
+
return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: "pointer-events-none fixed inset-0 z-50",
|
|
75
|
+
children: [/* @__PURE__ */ jsx(motion.button, {
|
|
76
|
+
type: "button",
|
|
77
|
+
"aria-label": "Close bottom sheet",
|
|
78
|
+
initial: { opacity: 0 },
|
|
79
|
+
animate: { opacity: 1 },
|
|
80
|
+
exit: { opacity: 0 },
|
|
81
|
+
transition: DRAWER,
|
|
82
|
+
onClick: () => onOpenChange(false),
|
|
83
|
+
className: "pointer-events-auto absolute inset-0 bg-background/40 backdrop-blur-sm"
|
|
84
|
+
}), /* @__PURE__ */ jsxs(motion.div, {
|
|
85
|
+
ref: sheetRef,
|
|
86
|
+
drag: "y",
|
|
87
|
+
dragControls,
|
|
88
|
+
dragListener: false,
|
|
89
|
+
dragConstraints: {
|
|
90
|
+
top: 0,
|
|
91
|
+
bottom: 0
|
|
92
|
+
},
|
|
93
|
+
dragElastic: {
|
|
94
|
+
top: .02,
|
|
95
|
+
bottom: .4
|
|
96
|
+
},
|
|
97
|
+
dragMomentum: false,
|
|
98
|
+
onDragEnd,
|
|
99
|
+
initial: reduce ? {
|
|
100
|
+
y: 0,
|
|
101
|
+
opacity: 0
|
|
102
|
+
} : { y: "100%" },
|
|
103
|
+
animate: reduce ? {
|
|
104
|
+
y: 0,
|
|
105
|
+
opacity: 1
|
|
106
|
+
} : { y: 0 },
|
|
107
|
+
exit: reduce ? {
|
|
108
|
+
y: 0,
|
|
109
|
+
opacity: 0
|
|
110
|
+
} : { y: "100%" },
|
|
111
|
+
transition: reduce ? {
|
|
112
|
+
duration: .18,
|
|
113
|
+
ease: EASE_DRAWER
|
|
114
|
+
} : DRAWER,
|
|
115
|
+
onAnimationComplete: () => {
|
|
116
|
+
if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;
|
|
117
|
+
},
|
|
118
|
+
style: heightStyle,
|
|
119
|
+
className: cn("pointer-events-auto absolute right-0 bottom-0 left-0 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform", "border border-border bg-background shadow-xl", className),
|
|
120
|
+
role: "dialog",
|
|
121
|
+
"aria-modal": "true",
|
|
122
|
+
"aria-label": title,
|
|
123
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
124
|
+
onPointerDown: (e) => dragControls.start(e),
|
|
125
|
+
className: "flex cursor-grab touch-none flex-col items-center px-4 pt-3 pb-2 active:cursor-grabbing",
|
|
126
|
+
children: [/* @__PURE__ */ jsx("div", { className: "h-1.5 w-10 rounded-full bg-muted-foreground/40" }), title || description ? /* @__PURE__ */ jsxs("div", {
|
|
127
|
+
className: "mt-3 w-full",
|
|
128
|
+
children: [title ? /* @__PURE__ */ jsx("h2", {
|
|
129
|
+
className: "font-semibold text-base text-foreground",
|
|
130
|
+
children: title
|
|
131
|
+
}) : null, description ? /* @__PURE__ */ jsx("p", {
|
|
132
|
+
className: "mt-0.5 text-muted-foreground text-sm",
|
|
133
|
+
children: description
|
|
134
|
+
}) : null]
|
|
135
|
+
}) : null]
|
|
136
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "flex-1 overflow-y-auto overscroll-contain px-4 pb-6",
|
|
138
|
+
children
|
|
139
|
+
})]
|
|
140
|
+
})]
|
|
141
|
+
}) : null }), document.body);
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { BottomSheet };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=bottom-sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.js","names":[],"sources":["../../../src/components/motion/bottom-sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport {\n AnimatePresence,\n motion,\n type PanInfo,\n useDragControls,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_DRAWER } from \"../../lib/ease\";\n\n// Vaul-style glide: a long, fully-damped tween reads smoother than a spring on\n// open — no settle/overshoot, just one clean decel. Same curve drives the\n// backdrop fade so the surface and scrim move as one.\nconst DRAWER = { duration: 0.5, ease: EASE_DRAWER } as const;\n\nexport interface BottomSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Heights (0-1 = fraction of viewport, or \"auto\"). First entry is default. */\n snapPoints?: (number | \"auto\")[];\n defaultSnap?: number;\n title?: string;\n description?: string;\n children?: ReactNode;\n className?: string;\n /** Min drag distance (px) past current snap to dismiss. */\n dismissThreshold?: number;\n}\n\nexport function BottomSheet({\n open,\n onOpenChange,\n snapPoints = [0.5, 0.92],\n defaultSnap = 0,\n title,\n description,\n children,\n className,\n dismissThreshold = 120,\n}: BottomSheetProps) {\n const [snap, setSnap] = useState(defaultSnap);\n const [mounted, setMounted] = useState(false);\n const dragControls = useDragControls();\n const sheetRef = useRef<HTMLDivElement>(null);\n const reduce = useReducedMotion();\n const heightRef = useRef(0);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (open) setSnap(defaultSnap);\n }, [open, defaultSnap]);\n\n // Lock background scroll while open. overflow:hidden alone is ignored by\n // iOS Safari — boundary scrolls inside the sheet chain to the page, which\n // scrolls underneath and ends up somewhere else on close. position:fixed\n // is the lock that actually holds; restore the scroll position after.\n useEffect(() => {\n if (!open) return;\n const body = document.body;\n const scrollY = window.scrollY;\n const prev = {\n position: body.style.position,\n top: body.style.top,\n left: body.style.left,\n right: body.style.right,\n overflow: body.style.overflow,\n };\n body.style.position = \"fixed\";\n body.style.top = `-${scrollY}px`;\n body.style.left = \"0\";\n body.style.right = \"0\";\n body.style.overflow = \"hidden\";\n return () => {\n body.style.position = prev.position;\n body.style.top = prev.top;\n body.style.left = prev.left;\n body.style.right = prev.right;\n body.style.overflow = prev.overflow;\n window.scrollTo(0, scrollY);\n };\n }, [open]);\n\n const onDragEnd = (_: unknown, info: PanInfo) => {\n const velocity = info.velocity.y;\n const offset = info.offset.y;\n\n // Strong downward fling or large drag → dismiss.\n if (velocity > 600 || offset > dismissThreshold) {\n const smaller = snapPoints.map((_, i) => i).filter((i) => i < snap);\n if (smaller.length && velocity < 800 && offset < dismissThreshold * 1.6) {\n setSnap(smaller[smaller.length - 1]);\n } else {\n onOpenChange(false);\n }\n return;\n }\n\n // Strong upward fling → next snap.\n if (velocity < -500) {\n setSnap((current) => Math.min(snapPoints.length - 1, current + 1));\n return;\n }\n\n // Otherwise snap to nearest by current offset.\n setSnap((current) => {\n if (offset > 80 && current > 0) return current - 1;\n if (offset < -80 && current < snapPoints.length - 1) return current + 1;\n return current;\n });\n };\n\n const snapValue = snapPoints[snap];\n const heightStyle =\n snapValue === \"auto\" ? { maxHeight: \"92vh\" } : { height: `${snapValue * 100}vh` };\n\n // Portal to <body>: an ancestor with backdrop-filter or transform becomes\n // the containing block for fixed descendants, which would position the\n // sheet against that ancestor instead of the viewport.\n if (!mounted) return null;\n\n return createPortal(\n <AnimatePresence>\n {open ? (\n <div className=\"pointer-events-none fixed inset-0 z-50\">\n <motion.button\n type=\"button\"\n aria-label=\"Close bottom sheet\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={DRAWER}\n onClick={() => onOpenChange(false)}\n // A dim scrim with a light blur. backdrop-blur is GPU-expensive and\n // re-rasterizes every frame the sheet drags over it; a small radius\n // plus more opacity keeps the glass look without the jank.\n className=\"pointer-events-auto absolute inset-0 bg-background/40 backdrop-blur-sm\"\n />\n <motion.div\n ref={sheetRef}\n drag=\"y\"\n dragControls={dragControls}\n dragListener={false}\n dragConstraints={{ top: 0, bottom: 0 }}\n dragElastic={{ top: 0.02, bottom: 0.4 }}\n dragMomentum={false}\n onDragEnd={onDragEnd}\n initial={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n animate={reduce ? { y: 0, opacity: 1 } : { y: 0 }}\n exit={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n transition={reduce ? { duration: 0.18, ease: EASE_DRAWER } : DRAWER}\n onAnimationComplete={() => {\n if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;\n }}\n style={heightStyle}\n className={cn(\n \"pointer-events-auto absolute right-0 bottom-0 left-0 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform\",\n \"border border-border bg-background shadow-xl\",\n className,\n )}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={title}\n >\n <div\n onPointerDown={(e) => dragControls.start(e)}\n className=\"flex cursor-grab touch-none flex-col items-center px-4 pt-3 pb-2 active:cursor-grabbing\"\n >\n <div className=\"h-1.5 w-10 rounded-full bg-muted-foreground/40\" />\n {title || description ? (\n <div className=\"mt-3 w-full\">\n {title ? (\n <h2 className=\"font-semibold text-base text-foreground\">{title}</h2>\n ) : null}\n {description ? (\n <p className=\"mt-0.5 text-muted-foreground text-sm\">{description}</p>\n ) : null}\n </div>\n ) : null}\n </div>\n {/* overscroll-contain stops boundary scrolls from chaining to the page. */}\n <div className=\"flex-1 overflow-y-auto overscroll-contain px-4 pb-6\">{children}</div>\n </motion.div>\n </div>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"m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E,GAAG;IAAG,SAAS;GAAE,IAAI,EAAE,GAAG,OAAO;GAClD,YAAY,SAAS;IAAE,UAAU;IAAM,MAAM;GAAY,IAAI;GAC7D,2BAA2B;IACzB,IAAI,SAAS,SAAS,UAAU,UAAU,SAAS,QAAQ;GAC7D;GACA,OAAO;GACP,WAAW,GACT,4IACA,gDACA,SACF;GACA,MAAK;GACL,cAAW;GACX,cAAY;GAxBd,UAAA,CA0BE,qBAAC,OAAD;IACE,gBAAgB,MAAM,aAAa,MAAM,CAAC;IAC1C,WAAU;IAFZ,UAAA,CAIE,oBAAC,OAAD,EAAK,WAAU,iDAAkD,CAAA,GAChE,SAAS,cACR,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,QACC,oBAAC,MAAD;MAAI,WAAU;MAA2C,UAAA;KAAU,CAAA,IACjE,MACH,cACC,oBAAC,KAAD;MAAG,WAAU;MAAwC,UAAA;KAAe,CAAA,IAClE,IACD;IACH,CAAA,IAAA,IACD;GAEL,CAAA,GAAA,oBAAC,OAAD;IAAK,WAAU;IAAuD;GAAc,CAAA,CAC1E;EACT,CAAA,CAAA;CACH,CAAA,IAAA,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/bounce-sidebar.d.ts
|
|
3
|
+
interface BounceSidebarItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
href?: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
10
|
+
rel?: string;
|
|
11
|
+
}
|
|
12
|
+
interface BounceSidebarProps {
|
|
13
|
+
items: BounceSidebarItem[];
|
|
14
|
+
value?: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
onValueChange?: (value: string) => void;
|
|
17
|
+
ariaLabel?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
listClassName?: string;
|
|
20
|
+
itemClassName?: string;
|
|
21
|
+
indicatorClassName?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function BounceSidebar({ items, value, defaultValue, onValueChange, ariaLabel, className, listClassName, itemClassName, indicatorClassName }: BounceSidebarProps): import("react").JSX.Element;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BounceSidebar, BounceSidebarItem, BounceSidebarProps };
|
|
26
|
+
//# sourceMappingURL=bounce-sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounce-sidebar.d.ts","names":[],"sources":["../../../src/components/motion/bounce-sidebar.tsx"],"mappings":";;UAOiB;EACf;EACA,OAAO;EACP;EACA,OAAO;EACP;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;;iBAqBc,gBACd,OACA,OACA,cACA,eACA,WACA,WACA,eACA,eACA,sBACC,qCAAkB,IAAA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
|
+
import { animate, motion, useMotionValue, useReducedMotion } from "motion/react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/motion/bounce-sidebar.tsx
|
|
7
|
+
const DOT_SIZE = 6;
|
|
8
|
+
const BOUNCE_SPRING = {
|
|
9
|
+
type: "spring",
|
|
10
|
+
stiffness: 280,
|
|
11
|
+
damping: 18,
|
|
12
|
+
mass: .3
|
|
13
|
+
};
|
|
14
|
+
function quadraticBezier(start, control, end, progress) {
|
|
15
|
+
const remaining = 1 - progress;
|
|
16
|
+
return remaining * remaining * start + 2 * remaining * progress * control + progress * progress * end;
|
|
17
|
+
}
|
|
18
|
+
function BounceSidebar({ items, value, defaultValue, onValueChange, ariaLabel = "Sidebar navigation", className, listClassName, itemClassName, indicatorClassName }) {
|
|
19
|
+
const reduce = useReducedMotion();
|
|
20
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id ?? "");
|
|
21
|
+
const requestedValue = value ?? internalValue;
|
|
22
|
+
const selectedValue = items.some((item) => item.id === requestedValue) ? requestedValue : items[0]?.id ?? "";
|
|
23
|
+
const selectedIndex = items.findIndex((item) => item.id === selectedValue);
|
|
24
|
+
const listRef = useRef(null);
|
|
25
|
+
const itemRefs = useRef(/* @__PURE__ */ new Map());
|
|
26
|
+
const selectedValueRef = useRef(selectedValue);
|
|
27
|
+
const previousIndexRef = useRef(selectedIndex);
|
|
28
|
+
const hasPositionRef = useRef(false);
|
|
29
|
+
const animationRef = useRef(null);
|
|
30
|
+
const x = useMotionValue(0);
|
|
31
|
+
const y = useMotionValue(0);
|
|
32
|
+
selectedValueRef.current = selectedValue;
|
|
33
|
+
const snapIndicator = useCallback(() => {
|
|
34
|
+
const selectedItem = itemRefs.current.get(selectedValueRef.current);
|
|
35
|
+
if (!selectedItem) return;
|
|
36
|
+
animationRef.current?.stop();
|
|
37
|
+
x.set(0);
|
|
38
|
+
y.set(selectedItem.offsetTop + (selectedItem.offsetHeight - DOT_SIZE) / 2);
|
|
39
|
+
hasPositionRef.current = true;
|
|
40
|
+
}, [x, y]);
|
|
41
|
+
const positionIndicator = useCallback((shouldAnimate) => {
|
|
42
|
+
const selectedItem = itemRefs.current.get(selectedValue);
|
|
43
|
+
if (!selectedItem) return;
|
|
44
|
+
const destinationY = selectedItem.offsetTop + (selectedItem.offsetHeight - DOT_SIZE) / 2;
|
|
45
|
+
animationRef.current?.stop();
|
|
46
|
+
if (!hasPositionRef.current || reduce || !shouldAnimate) {
|
|
47
|
+
x.set(0);
|
|
48
|
+
y.set(destinationY);
|
|
49
|
+
hasPositionRef.current = true;
|
|
50
|
+
previousIndexRef.current = selectedIndex;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const startY = y.get();
|
|
54
|
+
const distance = destinationY - startY;
|
|
55
|
+
const travel = Math.abs(distance);
|
|
56
|
+
const longJumpProgress = Math.min(1, Math.max(0, (travel - 48) / 120));
|
|
57
|
+
const controlX = -Math.min(40, Math.max(8, travel * .25));
|
|
58
|
+
const controlY = destinationY + ((startY + destinationY) / 2 - destinationY) * longJumpProgress;
|
|
59
|
+
animationRef.current = animate(0, 1, {
|
|
60
|
+
...BOUNCE_SPRING,
|
|
61
|
+
stiffness: BOUNCE_SPRING.stiffness - 60 * longJumpProgress,
|
|
62
|
+
damping: BOUNCE_SPRING.damping + longJumpProgress,
|
|
63
|
+
mass: BOUNCE_SPRING.mass + .15 * longJumpProgress,
|
|
64
|
+
onUpdate: (progress) => {
|
|
65
|
+
x.set(quadraticBezier(0, controlX, 0, progress));
|
|
66
|
+
y.set(quadraticBezier(startY, controlY, destinationY, progress));
|
|
67
|
+
},
|
|
68
|
+
onComplete: () => {
|
|
69
|
+
x.set(0);
|
|
70
|
+
y.set(destinationY);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
previousIndexRef.current = selectedIndex;
|
|
74
|
+
}, [
|
|
75
|
+
reduce,
|
|
76
|
+
selectedIndex,
|
|
77
|
+
selectedValue,
|
|
78
|
+
x,
|
|
79
|
+
y
|
|
80
|
+
]);
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
const shouldAnimate = hasPositionRef.current && previousIndexRef.current !== selectedIndex;
|
|
83
|
+
positionIndicator(shouldAnimate);
|
|
84
|
+
}, [positionIndicator, selectedIndex]);
|
|
85
|
+
useLayoutEffect(() => {
|
|
86
|
+
const list = listRef.current;
|
|
87
|
+
if (!list || typeof ResizeObserver === "undefined") return;
|
|
88
|
+
const observer = new ResizeObserver(snapIndicator);
|
|
89
|
+
observer.observe(list);
|
|
90
|
+
return () => observer.disconnect();
|
|
91
|
+
}, [snapIndicator]);
|
|
92
|
+
useLayoutEffect(() => () => {
|
|
93
|
+
animationRef.current?.stop();
|
|
94
|
+
}, []);
|
|
95
|
+
const selectItem = (id) => {
|
|
96
|
+
if (value === void 0) setInternalValue(id);
|
|
97
|
+
onValueChange?.(id);
|
|
98
|
+
};
|
|
99
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
100
|
+
"aria-label": ariaLabel,
|
|
101
|
+
className: cn("relative", className),
|
|
102
|
+
children: /* @__PURE__ */ jsxs("ul", {
|
|
103
|
+
ref: listRef,
|
|
104
|
+
className: cn("relative flex list-none flex-col gap-1.5 pl-6", listClassName),
|
|
105
|
+
children: [selectedIndex >= 0 ? /* @__PURE__ */ jsx("li", {
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
role: "presentation",
|
|
108
|
+
className: "pointer-events-none absolute inset-0",
|
|
109
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
110
|
+
style: {
|
|
111
|
+
x,
|
|
112
|
+
y
|
|
113
|
+
},
|
|
114
|
+
className: cn("absolute top-0 left-3 h-1.5 w-1.5 rounded-full bg-primary", indicatorClassName)
|
|
115
|
+
})
|
|
116
|
+
}) : null, items.map((item) => {
|
|
117
|
+
const active = item.id === selectedValue;
|
|
118
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [item.icon ? /* @__PURE__ */ jsx("span", {
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
className: "shrink-0",
|
|
121
|
+
children: item.icon
|
|
122
|
+
}) : null, /* @__PURE__ */ jsx("span", { children: item.label })] });
|
|
123
|
+
const interactiveClasses = cn("flex min-h-9 w-full items-center gap-2 rounded-lg px-2 text-left font-medium text-sm outline-none transition-colors", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", active ? "text-foreground" : "text-muted-foreground hover:text-foreground", item.disabled ? "cursor-not-allowed opacity-40" : void 0, itemClassName);
|
|
124
|
+
return /* @__PURE__ */ jsx("li", {
|
|
125
|
+
ref: (node) => {
|
|
126
|
+
if (node) itemRefs.current.set(item.id, node);
|
|
127
|
+
else itemRefs.current.delete(item.id);
|
|
128
|
+
},
|
|
129
|
+
className: "relative",
|
|
130
|
+
children: item.href ? /* @__PURE__ */ jsx("a", {
|
|
131
|
+
href: item.href,
|
|
132
|
+
target: item.target,
|
|
133
|
+
rel: item.rel ?? (item.target === "_blank" ? "noreferrer noopener" : void 0),
|
|
134
|
+
"aria-current": active ? "page" : void 0,
|
|
135
|
+
"aria-disabled": item.disabled || void 0,
|
|
136
|
+
"data-active": active || void 0,
|
|
137
|
+
tabIndex: item.disabled ? -1 : void 0,
|
|
138
|
+
onClick: (event) => {
|
|
139
|
+
if (item.disabled) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
selectItem(item.id);
|
|
144
|
+
},
|
|
145
|
+
className: interactiveClasses,
|
|
146
|
+
children: content
|
|
147
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
148
|
+
type: "button",
|
|
149
|
+
disabled: item.disabled,
|
|
150
|
+
"aria-current": active ? "page" : void 0,
|
|
151
|
+
"data-active": active || void 0,
|
|
152
|
+
onClick: () => selectItem(item.id),
|
|
153
|
+
className: interactiveClasses,
|
|
154
|
+
children: content
|
|
155
|
+
})
|
|
156
|
+
}, item.id);
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { BounceSidebar };
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=bounce-sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounce-sidebar.js","names":[],"sources":["../../../src/components/motion/bounce-sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { animate, motion, useMotionValue, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nexport interface BounceSidebarItem {\n id: string;\n label: ReactNode;\n href?: string;\n icon?: ReactNode;\n disabled?: boolean;\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n rel?: string;\n}\n\nexport interface BounceSidebarProps {\n items: BounceSidebarItem[];\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n ariaLabel?: string;\n className?: string;\n listClassName?: string;\n itemClassName?: string;\n indicatorClassName?: string;\n}\n\nconst DOT_SIZE = 6;\n\n// A compact, lightly underdamped spring gives the dot a quick landing without\n// turning the sidebar into a playful toy. The sideways arc carries the bounce.\nconst BOUNCE_SPRING = {\n type: \"spring\",\n stiffness: 280,\n damping: 18,\n mass: 0.3,\n} as const;\n\nfunction quadraticBezier(start: number, control: number, end: number, progress: number) {\n const remaining = 1 - progress;\n return (\n remaining * remaining * start + 2 * remaining * progress * control + progress * progress * end\n );\n}\n\nexport function BounceSidebar({\n items,\n value,\n defaultValue,\n onValueChange,\n ariaLabel = \"Sidebar navigation\",\n className,\n listClassName,\n itemClassName,\n indicatorClassName,\n}: BounceSidebarProps) {\n const reduce = useReducedMotion();\n const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id ?? \"\");\n const requestedValue = value ?? internalValue;\n const selectedValue = items.some((item) => item.id === requestedValue)\n ? requestedValue\n : (items[0]?.id ?? \"\");\n const selectedIndex = items.findIndex((item) => item.id === selectedValue);\n const listRef = useRef<HTMLUListElement>(null);\n const itemRefs = useRef(new Map<string, HTMLLIElement>());\n const selectedValueRef = useRef(selectedValue);\n const previousIndexRef = useRef(selectedIndex);\n const hasPositionRef = useRef(false);\n const animationRef = useRef<ReturnType<typeof animate> | null>(null);\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n selectedValueRef.current = selectedValue;\n\n const snapIndicator = useCallback(() => {\n const selectedItem = itemRefs.current.get(selectedValueRef.current);\n if (!selectedItem) return;\n\n animationRef.current?.stop();\n x.set(0);\n y.set(selectedItem.offsetTop + (selectedItem.offsetHeight - DOT_SIZE) / 2);\n hasPositionRef.current = true;\n }, [x, y]);\n\n const positionIndicator = useCallback(\n (shouldAnimate: boolean) => {\n const selectedItem = itemRefs.current.get(selectedValue);\n if (!selectedItem) return;\n\n const destinationY = selectedItem.offsetTop + (selectedItem.offsetHeight - DOT_SIZE) / 2;\n\n animationRef.current?.stop();\n\n if (!hasPositionRef.current || reduce || !shouldAnimate) {\n x.set(0);\n y.set(destinationY);\n hasPositionRef.current = true;\n previousIndexRef.current = selectedIndex;\n return;\n }\n\n const startY = y.get();\n const distance = destinationY - startY;\n const travel = Math.abs(distance);\n const longJumpProgress = Math.min(1, Math.max(0, (travel - 48) / 120));\n const controlX = -Math.min(40, Math.max(8, travel * 0.25));\n const midpointY = (startY + destinationY) / 2;\n const controlY = destinationY + (midpointY - destinationY) * longJumpProgress;\n\n animationRef.current = animate(0, 1, {\n ...BOUNCE_SPRING,\n stiffness: BOUNCE_SPRING.stiffness - 60 * longJumpProgress,\n damping: BOUNCE_SPRING.damping + longJumpProgress,\n mass: BOUNCE_SPRING.mass + 0.15 * longJumpProgress,\n onUpdate: (progress) => {\n x.set(quadraticBezier(0, controlX, 0, progress));\n y.set(quadraticBezier(startY, controlY, destinationY, progress));\n },\n onComplete: () => {\n x.set(0);\n y.set(destinationY);\n },\n });\n\n previousIndexRef.current = selectedIndex;\n },\n [reduce, selectedIndex, selectedValue, x, y],\n );\n\n useLayoutEffect(() => {\n const shouldAnimate = hasPositionRef.current && previousIndexRef.current !== selectedIndex;\n positionIndicator(shouldAnimate);\n }, [positionIndicator, selectedIndex]);\n\n useLayoutEffect(() => {\n const list = listRef.current;\n if (!list || typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(snapIndicator);\n observer.observe(list);\n return () => observer.disconnect();\n }, [snapIndicator]);\n\n useLayoutEffect(\n () => () => {\n animationRef.current?.stop();\n },\n [],\n );\n\n const selectItem = (id: string) => {\n if (value === undefined) setInternalValue(id);\n onValueChange?.(id);\n };\n\n return (\n <nav aria-label={ariaLabel} className={cn(\"relative\", className)}>\n <ul\n ref={listRef}\n className={cn(\"relative flex list-none flex-col gap-1.5 pl-6\", listClassName)}\n >\n {selectedIndex >= 0 ? (\n <li\n aria-hidden=\"true\"\n role=\"presentation\"\n className=\"pointer-events-none absolute inset-0\"\n >\n <motion.span\n style={{ x, y }}\n className={cn(\n \"absolute top-0 left-3 h-1.5 w-1.5 rounded-full bg-primary\",\n indicatorClassName,\n )}\n />\n </li>\n ) : null}\n\n {items.map((item) => {\n const active = item.id === selectedValue;\n const content = (\n <>\n {item.icon ? (\n <span aria-hidden=\"true\" className=\"shrink-0\">\n {item.icon}\n </span>\n ) : null}\n <span>{item.label}</span>\n </>\n );\n const interactiveClasses = cn(\n \"flex min-h-9 w-full items-center gap-2 rounded-lg px-2 text-left font-medium text-sm outline-none transition-colors\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n active ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n item.disabled ? \"cursor-not-allowed opacity-40\" : undefined,\n itemClassName,\n );\n\n return (\n <li\n key={item.id}\n ref={(node) => {\n if (node) itemRefs.current.set(item.id, node);\n else itemRefs.current.delete(item.id);\n }}\n className=\"relative\"\n >\n {item.href ? (\n <a\n href={item.href}\n target={item.target}\n rel={item.rel ?? (item.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n aria-current={active ? \"page\" : undefined}\n aria-disabled={item.disabled || undefined}\n data-active={active || undefined}\n tabIndex={item.disabled ? -1 : undefined}\n onClick={(event) => {\n if (item.disabled) {\n event.preventDefault();\n return;\n }\n selectItem(item.id);\n }}\n className={interactiveClasses}\n >\n {content}\n </a>\n ) : (\n <button\n type=\"button\"\n disabled={item.disabled}\n aria-current={active ? \"page\" : undefined}\n data-active={active || undefined}\n onClick={() => selectItem(item.id)}\n className={interactiveClasses}\n >\n {content}\n </button>\n )}\n </li>\n );\n })}\n </ul>\n </nav>\n );\n}\n"],"mappings":";;;;;;AA6BA,MAAM,WAAW;AAIjB,MAAM,gBAAgB;CACpB,MAAM;CACN,WAAW;CACX,S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AA;MAC/B,UAAU,UAAU;OAClB,IAAI,KAAK,UAAU;QACjB,MAAM,eAAe;QACrB;OACF;OACA,WAAW,KAAK,EAAE;MACpB;MACA,WAAW;MAEV,UAAA;KACA,CAAA,IAEH,oBAAC,UAAD;MACE,MAAK;MACL,UAAU,KAAK;MACf,gBAAc,SAAS,SAAS,KAAA;MAChC,eAAa,UAAU,KAAA;MACvB,eAAe,WAAW,KAAK,EAAE;MACjC,WAAW;MAEV,UAAA;KACK,CAAA;IAER,GAvCG,KAAK,EAuCR;GAER,CAAC,CACC;;CACD,CAAA;AAET"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/bouncy-accordion.d.ts
|
|
3
|
+
type BouncyAccordionItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BouncyAccordionClassNames = {
|
|
11
|
+
root?: string;
|
|
12
|
+
item?: string;
|
|
13
|
+
trigger?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
chevron?: string;
|
|
17
|
+
content?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
};
|
|
20
|
+
interface BouncyAccordionProps {
|
|
21
|
+
items: BouncyAccordionItem[];
|
|
22
|
+
value?: string | null;
|
|
23
|
+
defaultValue?: string | null;
|
|
24
|
+
onValueChange?: (value: string | null) => void;
|
|
25
|
+
collapsible?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
classNames?: BouncyAccordionClassNames;
|
|
28
|
+
}
|
|
29
|
+
declare function BouncyAccordion({ items, value, defaultValue, onValueChange, collapsible, className, classNames }: BouncyAccordionProps): import("react").JSX.Element;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { BouncyAccordion, BouncyAccordionClassNames, BouncyAccordionItem, BouncyAccordionProps };
|
|
32
|
+
//# sourceMappingURL=bouncy-accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bouncy-accordion.d.ts","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"mappings":";;KASY;EACV;EACA,OAAO;EACP,cAAc;EACd,OAAO;EACP;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,iBAAiB;EACjB;EACA;EACA,aAAa;;iBAiNC,kBACd,OACA,OACA,cACA,eACA,aACA,WACA,cACC,uCAAoB,IAAA"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
|
+
import { useCallback, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { motion, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDown } from "lucide-react";
|
|
8
|
+
//#region src/components/motion/bouncy-accordion.tsx
|
|
9
|
+
const ROW_TRANSITION = {
|
|
10
|
+
type: "spring",
|
|
11
|
+
duration: .55,
|
|
12
|
+
bounce: .38
|
|
13
|
+
};
|
|
14
|
+
const CONTENT_OPEN_TRANSITION = {
|
|
15
|
+
type: "spring",
|
|
16
|
+
duration: .58,
|
|
17
|
+
bounce: .32
|
|
18
|
+
};
|
|
19
|
+
const CONTENT_CLOSE_TRANSITION = {
|
|
20
|
+
type: "spring",
|
|
21
|
+
duration: .46,
|
|
22
|
+
bounce: .26
|
|
23
|
+
};
|
|
24
|
+
const DESCRIPTION_TRANSITION = {
|
|
25
|
+
duration: .18,
|
|
26
|
+
ease: EASE_OUT
|
|
27
|
+
};
|
|
28
|
+
const CHEVRON_TRANSITION = {
|
|
29
|
+
type: "spring",
|
|
30
|
+
duration: .42,
|
|
31
|
+
bounce: .28
|
|
32
|
+
};
|
|
33
|
+
function useControllableAccordionValue({ value, defaultValue, onValueChange }) {
|
|
34
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? null);
|
|
35
|
+
const isControlled = value !== void 0;
|
|
36
|
+
return [value ?? internalValue, useCallback((next) => {
|
|
37
|
+
if (!isControlled) setInternalValue(next);
|
|
38
|
+
onValueChange?.(next);
|
|
39
|
+
}, [isControlled, onValueChange])];
|
|
40
|
+
}
|
|
41
|
+
function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromPrevious, contentId, triggerId, reduce, classNames, onToggle }) {
|
|
42
|
+
const contentRef = useRef(null);
|
|
43
|
+
const [contentHeight, setContentHeight] = useState(0);
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
const node = contentRef.current;
|
|
46
|
+
if (!node) return;
|
|
47
|
+
const updateHeight = () => {
|
|
48
|
+
setContentHeight(node.offsetHeight);
|
|
49
|
+
};
|
|
50
|
+
updateHeight();
|
|
51
|
+
const observer = new ResizeObserver(updateHeight);
|
|
52
|
+
observer.observe(node);
|
|
53
|
+
return () => {
|
|
54
|
+
observer.disconnect();
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
58
|
+
layout: "position",
|
|
59
|
+
initial: false,
|
|
60
|
+
style: { marginTop: separatedFromPrevious ? 12 : 0 },
|
|
61
|
+
transition: reduce ? { duration: 0 } : ROW_TRANSITION,
|
|
62
|
+
children: /* @__PURE__ */ jsxs(motion.div, {
|
|
63
|
+
"data-state": open ? "open" : "closed",
|
|
64
|
+
initial: false,
|
|
65
|
+
animate: {
|
|
66
|
+
borderTopLeftRadius: startsGroup ? 28 : 0,
|
|
67
|
+
borderTopRightRadius: startsGroup ? 28 : 0,
|
|
68
|
+
borderBottomLeftRadius: endsGroup ? 28 : 0,
|
|
69
|
+
borderBottomRightRadius: endsGroup ? 28 : 0
|
|
70
|
+
},
|
|
71
|
+
transition: reduce ? { duration: 0 } : ROW_TRANSITION,
|
|
72
|
+
className: cn("overflow-hidden bg-card text-card-foreground", item.disabled && "opacity-50", classNames?.item),
|
|
73
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
74
|
+
id: triggerId,
|
|
75
|
+
type: "button",
|
|
76
|
+
disabled: item.disabled,
|
|
77
|
+
"aria-expanded": open,
|
|
78
|
+
"aria-controls": contentId,
|
|
79
|
+
onClick: onToggle,
|
|
80
|
+
className: cn("flex min-h-[54px] w-full items-center gap-4 px-5 text-left outline-none transition-colors", "focus-visible:bg-muted/25", "disabled:pointer-events-none", classNames?.trigger),
|
|
81
|
+
children: [
|
|
82
|
+
item.icon ? /* @__PURE__ */ jsx("span", {
|
|
83
|
+
className: cn("grid h-7 w-7 shrink-0 place-items-center text-muted-foreground", classNames?.icon),
|
|
84
|
+
children: item.icon
|
|
85
|
+
}) : null,
|
|
86
|
+
/* @__PURE__ */ jsx("span", {
|
|
87
|
+
className: cn("min-w-0 flex-1 truncate font-medium text-[15px] text-foreground", classNames?.title),
|
|
88
|
+
children: item.title
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
91
|
+
"aria-hidden": true,
|
|
92
|
+
animate: { rotate: open ? 180 : 0 },
|
|
93
|
+
transition: reduce ? { duration: 0 } : CHEVRON_TRANSITION,
|
|
94
|
+
className: cn("grid h-6 w-6 shrink-0 place-items-center text-muted-foreground", classNames?.chevron),
|
|
95
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}), /* @__PURE__ */ jsx(motion.div, {
|
|
99
|
+
layout: "size",
|
|
100
|
+
id: contentId,
|
|
101
|
+
role: "region",
|
|
102
|
+
"aria-labelledby": triggerId,
|
|
103
|
+
"aria-hidden": !open,
|
|
104
|
+
inert: !open,
|
|
105
|
+
initial: false,
|
|
106
|
+
style: { height: open && item.description ? contentHeight : 0 },
|
|
107
|
+
transition: reduce ? { duration: 0 } : open ? CONTENT_OPEN_TRANSITION : CONTENT_CLOSE_TRANSITION,
|
|
108
|
+
className: cn("overflow-hidden", classNames?.content),
|
|
109
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
110
|
+
ref: contentRef,
|
|
111
|
+
animate: { opacity: open ? 1 : 0 },
|
|
112
|
+
transition: reduce ? { duration: 0 } : DESCRIPTION_TRANSITION,
|
|
113
|
+
className: "px-5 pb-5",
|
|
114
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
115
|
+
className: cn("text-[15px] text-muted-foreground leading-6", classNames?.description),
|
|
116
|
+
children: item.description
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
})]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function BouncyAccordion({ items, value, defaultValue = null, onValueChange, collapsible = true, className, classNames }) {
|
|
124
|
+
const reduce = useReducedMotion();
|
|
125
|
+
const baseId = useId();
|
|
126
|
+
const [activeValue, setActiveValue] = useControllableAccordionValue({
|
|
127
|
+
value,
|
|
128
|
+
defaultValue,
|
|
129
|
+
onValueChange
|
|
130
|
+
});
|
|
131
|
+
const activeIndex = items.findIndex((item) => item.id === activeValue);
|
|
132
|
+
const toggleItem = useCallback((id) => {
|
|
133
|
+
if (activeValue === id) {
|
|
134
|
+
if (collapsible) setActiveValue(null);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
setActiveValue(id);
|
|
138
|
+
}, [
|
|
139
|
+
activeValue,
|
|
140
|
+
collapsible,
|
|
141
|
+
setActiveValue
|
|
142
|
+
]);
|
|
143
|
+
return /* @__PURE__ */ jsx("div", {
|
|
144
|
+
className: cn("w-full", className, classNames?.root),
|
|
145
|
+
children: items.map((item, index) => {
|
|
146
|
+
const open = activeValue === item.id;
|
|
147
|
+
const previousIsOpen = activeIndex === index - 1;
|
|
148
|
+
const nextIsOpen = activeIndex === index + 1;
|
|
149
|
+
const startsGroup = open || index === 0 || previousIsOpen;
|
|
150
|
+
const endsGroup = open || index === items.length - 1 || nextIsOpen;
|
|
151
|
+
const separatedFromPrevious = index > 0 && (open || previousIsOpen);
|
|
152
|
+
const contentId = `${baseId}-${item.id}-content`;
|
|
153
|
+
const triggerId = `${baseId}-${item.id}-trigger`;
|
|
154
|
+
return /* @__PURE__ */ jsx(BouncyAccordionRow, {
|
|
155
|
+
item,
|
|
156
|
+
open,
|
|
157
|
+
startsGroup,
|
|
158
|
+
endsGroup,
|
|
159
|
+
separatedFromPrevious,
|
|
160
|
+
contentId,
|
|
161
|
+
triggerId,
|
|
162
|
+
reduce,
|
|
163
|
+
classNames,
|
|
164
|
+
onToggle: () => toggleItem(item.id)
|
|
165
|
+
}, item.id);
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { BouncyAccordion };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=bouncy-accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bouncy-accordion.js","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type BouncyAccordionItem = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n};\n\nexport type BouncyAccordionClassNames = {\n root?: string;\n item?: string;\n trigger?: string;\n icon?: string;\n title?: string;\n chevron?: string;\n content?: string;\n description?: string;\n};\n\nexport interface BouncyAccordionProps {\n items: BouncyAccordionItem[];\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n collapsible?: boolean;\n className?: string;\n classNames?: BouncyAccordionClassNames;\n}\n\n// Local springs keep the accordion's connected groups moving together while\n// avoiding scale projection on text-heavy row contents.\n// Gap spring: must not overshoot y — positive y overshoot drifts items below\n// their mt-3 resting point and briefly overlaps the next item.\nconst ROW_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.55,\n bounce: 0.38,\n};\n\nconst CONTENT_OPEN_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.58,\n bounce: 0.32,\n};\n\nconst CONTENT_CLOSE_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.46,\n bounce: 0.26,\n};\n\nconst DESCRIPTION_TRANSITION: Transition = {\n duration: 0.18,\n ease: EASE_OUT,\n};\n\nconst CHEVRON_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.42,\n bounce: 0.28,\n};\n\nfunction useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? null);\n const isControlled = value !== undefined;\n const currentValue = value ?? internalValue;\n\n const setValue = useCallback(\n (next: string | null) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction BouncyAccordionRow({\n item,\n open,\n startsGroup,\n endsGroup,\n separatedFromPrevious,\n contentId,\n triggerId,\n reduce,\n classNames,\n onToggle,\n}: {\n item: BouncyAccordionItem;\n open: boolean;\n startsGroup: boolean;\n endsGroup: boolean;\n separatedFromPrevious: boolean;\n contentId: string;\n triggerId: string;\n reduce: boolean | null;\n classNames?: BouncyAccordionClassNames;\n onToggle: () => void;\n}) {\n const contentRef = useRef<HTMLDivElement>(null);\n const [contentHeight, setContentHeight] = useState(0);\n\n useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node) return;\n\n const updateHeight = () => {\n setContentHeight(node.offsetHeight);\n };\n\n updateHeight();\n\n const observer = new ResizeObserver(updateHeight);\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return (\n <motion.div\n layout=\"position\"\n initial={false}\n style={{ marginTop: separatedFromPrevious ? 12 : 0 }}\n transition={reduce ? { duration: 0 } : ROW_TRANSITION}\n >\n <motion.div\n data-state={open ? \"open\" : \"closed\"}\n initial={false}\n animate={{\n borderTopLeftRadius: startsGroup ? 28 : 0,\n borderTopRightRadius: startsGroup ? 28 : 0,\n borderBottomLeftRadius: endsGroup ? 28 : 0,\n borderBottomRightRadius: endsGroup ? 28 : 0,\n }}\n transition={reduce ? { duration: 0 } : ROW_TRANSITION}\n className={cn(\n \"overflow-hidden bg-card text-card-foreground\",\n item.disabled && \"opacity-50\",\n classNames?.item,\n )}\n >\n <button\n id={triggerId}\n type=\"button\"\n disabled={item.disabled}\n aria-expanded={open}\n aria-controls={contentId}\n onClick={onToggle}\n className={cn(\n \"flex min-h-[54px] w-full items-center gap-4 px-5 text-left outline-none transition-colors\",\n \"focus-visible:bg-muted/25\",\n \"disabled:pointer-events-none\",\n classNames?.trigger,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"grid h-7 w-7 shrink-0 place-items-center text-muted-foreground\",\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span\n className={cn(\n \"min-w-0 flex-1 truncate font-medium text-[15px] text-foreground\",\n classNames?.title,\n )}\n >\n {item.title}\n </span>\n <motion.span\n aria-hidden\n animate={{ rotate: open ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n className={cn(\n \"grid h-6 w-6 shrink-0 place-items-center text-muted-foreground\",\n classNames?.chevron,\n )}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </button>\n\n <motion.div\n layout=\"size\"\n id={contentId}\n role=\"region\"\n aria-labelledby={triggerId}\n aria-hidden={!open}\n inert={!open}\n initial={false}\n style={{ height: open && item.description ? contentHeight : 0 }}\n transition={\n reduce ? { duration: 0 } : open ? CONTENT_OPEN_TRANSITION : CONTENT_CLOSE_TRANSITION\n }\n className={cn(\"overflow-hidden\", classNames?.content)}\n >\n <motion.div\n ref={contentRef}\n animate={{\n opacity: open ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : DESCRIPTION_TRANSITION}\n className=\"px-5 pb-5\"\n >\n <div\n className={cn(\"text-[15px] text-muted-foreground leading-6\", classNames?.description)}\n >\n {item.description}\n </div>\n </motion.div>\n </motion.div>\n </motion.div>\n </motion.div>\n );\n}\n\nexport function BouncyAccordion({\n items,\n value,\n defaultValue = null,\n onValueChange,\n collapsible = true,\n className,\n classNames,\n}: BouncyAccordionProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n const [activeValue, setActiveValue] = useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n });\n const activeIndex = items.findIndex((item) => item.id === activeValue);\n\n const toggleItem = useCallback(\n (id: string) => {\n if (activeValue === id) {\n if (collapsible) {\n setActiveValue(null);\n }\n return;\n }\n\n setActiveValue(id);\n },\n [activeValue, collapsible, setActiveValue],\n );\n\n return (\n <div className={cn(\"w-full\", className, classNames?.root)}>\n {items.map((item, index) => {\n const open = activeValue === item.id;\n const previousIsOpen = activeIndex === index - 1;\n const nextIsOpen = activeIndex === index + 1;\n const startsGroup = open || index === 0 || previousIsOpen;\n const endsGroup = open || index === items.length - 1 || nextIsOpen;\n const separatedFromPrevious = index > 0 && (open || previousIsOpen);\n const contentId = `${baseId}-${item.id}-content`;\n const triggerId = `${baseId}-${item.id}-trigger`;\n\n return (\n <BouncyAccordionRow\n key={item.id}\n item={item}\n open={open}\n startsGroup={startsGroup}\n endsGroup={endsGroup}\n separatedFromPrevious={separatedFromPrevious}\n contentId={contentId}\n triggerId={triggerId}\n reduce={reduce}\n classNames={classNames}\n onToggle={() => toggleItem(item.id)}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA0CA,MAAM,iBAA6B;CACjC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,0BAAsC;CAC1C,MAAM;CACN,UAAU;CACV,QAAQ;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B;CACvB,MAAM,SAAS,iBAAiB;CAChC,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,aAAa,kBAAkB,8BAA8B;EAClE;EACA;EACA;CACF,CAAC;CACD,MAAM,cAAc,MAAM,WAAW,SAAS,KAAK,OAAO,WAAW;CAErE,MAAM,aAAa,aAChB,OAAe;EACd,IAAI,gBAAgB,IAAI;GACtB,IAAI,aACF,eAAe,IAAI;GAErB;EACF;EAEA,eAAe,EAAE;CACnB,GACA;EAAC;EAAa;EAAa;CAAc,CAC3C;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,UAAU,WAAW,YAAY,IAAI;EACrD,UAAA,MAAM,KAAK,MAAM,UAAU;GAC1B,MAAM,OAAO,gBAAgB,KAAK;GAClC,MAAM,iBAAiB,gBAAgB,QAAQ;GAC/C,MAAM,aAAa,gBAAgB,QAAQ;GAC3C,MAAM,cAAc,QAAQ,UAAU,KAAK;GAC3C,MAAM,YAAY,QAAQ,UAAU,MAAM,SAAS,KAAK;GACxD,MAAM,wBAAwB,QAAQ,MAAM,QAAQ;GACpD,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG;GACvC,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG;GAEvC,OACE,oBAAC,oBAAD;IAEQ;IACA;IACO;IACF;IACY;IACZ;IACA;IACH;IACI;IACZ,gBAAgB,WAAW,KAAK,EAAE;GACnC,GAXM,KAAK,EAWX;EAEL,CAAC;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { HTMLMotionProps } from "motion/react";
|
|
3
|
+
//#region src/components/motion/button/base.d.ts
|
|
4
|
+
type ButtonVariant = "primary" | "secondary" | "ghost" | "outline";
|
|
5
|
+
type ButtonSize = "sm" | "md" | "lg" | "icon";
|
|
6
|
+
interface ButtonProps extends Omit<HTMLMotionProps<"button">, "children"> {
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
size?: ButtonSize;
|
|
9
|
+
pressScale?: number;
|
|
10
|
+
/** Spawn a Material-style ripple from the press point. Off by default. */
|
|
11
|
+
ripple?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const Button: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Button, ButtonProps, ButtonSize, ButtonVariant };
|
|
17
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"mappings":";;;KAgBY;KACA;UAEK,oBAAoB,KAAK;EACxC,UAAU;EACV,OAAO;EACP;;EAEA;EACA,WAAW;;cAmBA,wBAAM,0BAAA,KAAA,sCAAA,cAAA"}
|