@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,389 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_IN_OUT, EASE_OUT, SPRING_PANEL, SPRING_SWAP } from "../../lib/ease.js";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/motion/pull-to-refresh.tsx
|
|
8
|
+
const EMPTY_GESTURE = {
|
|
9
|
+
active: false,
|
|
10
|
+
startX: 0,
|
|
11
|
+
startY: 0,
|
|
12
|
+
pointerId: null
|
|
13
|
+
};
|
|
14
|
+
const CHARACTER_LOOP = {
|
|
15
|
+
duration: .9,
|
|
16
|
+
ease: EASE_IN_OUT,
|
|
17
|
+
repeat: Number.POSITIVE_INFINITY
|
|
18
|
+
};
|
|
19
|
+
const CALM_PULSE = {
|
|
20
|
+
duration: 1.2,
|
|
21
|
+
ease: EASE_IN_OUT,
|
|
22
|
+
repeat: Number.POSITIVE_INFINITY
|
|
23
|
+
};
|
|
24
|
+
const LABEL_SWAP = {
|
|
25
|
+
duration: .16,
|
|
26
|
+
ease: EASE_OUT
|
|
27
|
+
};
|
|
28
|
+
function resistedDistance(distance, maxPull) {
|
|
29
|
+
return maxPull * (1 - Math.exp(-Math.max(0, distance) / maxPull));
|
|
30
|
+
}
|
|
31
|
+
function RefreshBuddy({ progress, status, reduce }) {
|
|
32
|
+
const lift = useTransform(progress, [0, 1], [-7, 0]);
|
|
33
|
+
const tilt = useTransform(progress, [0, 1], [-10, 0]);
|
|
34
|
+
const stretch = useTransform(progress, [
|
|
35
|
+
0,
|
|
36
|
+
.55,
|
|
37
|
+
1
|
|
38
|
+
], [
|
|
39
|
+
.68,
|
|
40
|
+
1.1,
|
|
41
|
+
.92
|
|
42
|
+
]);
|
|
43
|
+
const ready = status === "ready";
|
|
44
|
+
const refreshing = status === "refreshing";
|
|
45
|
+
return /* @__PURE__ */ jsx(motion.span, {
|
|
46
|
+
style: reduce ? void 0 : {
|
|
47
|
+
y: lift,
|
|
48
|
+
rotate: tilt,
|
|
49
|
+
scaleY: stretch
|
|
50
|
+
},
|
|
51
|
+
className: "block h-9 w-9 origin-bottom",
|
|
52
|
+
children: /* @__PURE__ */ jsxs(motion.svg, {
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
viewBox: "0 0 36 36",
|
|
55
|
+
style: { opacity: 1 },
|
|
56
|
+
className: "h-full w-full overflow-visible",
|
|
57
|
+
animate: refreshing ? reduce ? { opacity: [
|
|
58
|
+
.55,
|
|
59
|
+
1,
|
|
60
|
+
.55
|
|
61
|
+
] } : {
|
|
62
|
+
y: [
|
|
63
|
+
0,
|
|
64
|
+
-2,
|
|
65
|
+
0
|
|
66
|
+
],
|
|
67
|
+
rotate: [
|
|
68
|
+
-3,
|
|
69
|
+
3,
|
|
70
|
+
-3
|
|
71
|
+
]
|
|
72
|
+
} : reduce ? { opacity: 1 } : {
|
|
73
|
+
y: 0,
|
|
74
|
+
rotate: 0,
|
|
75
|
+
scale: ready ? 1.08 : 1
|
|
76
|
+
},
|
|
77
|
+
transition: refreshing ? reduce ? CALM_PULSE : CHARACTER_LOOP : SPRING_SWAP,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsxs(motion.g, {
|
|
80
|
+
style: { transformOrigin: "18px 18px" },
|
|
81
|
+
animate: refreshing && !reduce ? { rotate: [0, 360] } : reduce ? void 0 : { rotate: ready ? 0 : -35 },
|
|
82
|
+
transition: refreshing ? reduce ? CALM_PULSE : CHARACTER_LOOP : SPRING_SWAP,
|
|
83
|
+
className: cn("transition-opacity duration-150", ready || refreshing ? "opacity-100" : "opacity-0"),
|
|
84
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
85
|
+
d: "M18 2.5a15.5 15.5 0 0 1 12.7 6.6",
|
|
86
|
+
fill: "none",
|
|
87
|
+
stroke: "currentColor",
|
|
88
|
+
strokeWidth: "1.5",
|
|
89
|
+
strokeLinecap: "round",
|
|
90
|
+
className: "text-muted-foreground"
|
|
91
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
92
|
+
cx: "31.3",
|
|
93
|
+
cy: "10.2",
|
|
94
|
+
r: "2.2",
|
|
95
|
+
className: "fill-foreground"
|
|
96
|
+
})]
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("rect", {
|
|
99
|
+
x: "7",
|
|
100
|
+
y: "7",
|
|
101
|
+
width: "22",
|
|
102
|
+
height: "22",
|
|
103
|
+
rx: "9",
|
|
104
|
+
className: "fill-foreground"
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs(motion.g, {
|
|
107
|
+
style: {
|
|
108
|
+
opacity: 1,
|
|
109
|
+
transformOrigin: "18px 16px"
|
|
110
|
+
},
|
|
111
|
+
animate: refreshing && !reduce ? { scaleY: [
|
|
112
|
+
1,
|
|
113
|
+
1,
|
|
114
|
+
.15,
|
|
115
|
+
1,
|
|
116
|
+
1
|
|
117
|
+
] } : reduce ? { opacity: 1 } : { scaleY: ready ? 1.18 : 1 },
|
|
118
|
+
transition: refreshing && !reduce ? CHARACTER_LOOP : SPRING_SWAP,
|
|
119
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
120
|
+
cx: "14.2",
|
|
121
|
+
cy: "16",
|
|
122
|
+
r: "1.45",
|
|
123
|
+
className: "fill-background"
|
|
124
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
125
|
+
cx: "21.8",
|
|
126
|
+
cy: "16",
|
|
127
|
+
r: "1.45",
|
|
128
|
+
className: "fill-background"
|
|
129
|
+
})]
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ jsx("path", {
|
|
132
|
+
d: "M14.5 21h7",
|
|
133
|
+
fill: "none",
|
|
134
|
+
stroke: "currentColor",
|
|
135
|
+
strokeWidth: "1.5",
|
|
136
|
+
strokeLinecap: "round",
|
|
137
|
+
className: cn("text-background transition-opacity duration-150", ready || refreshing ? "opacity-0" : "opacity-100")
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ jsx("path", {
|
|
140
|
+
d: "M14 20.5c1 2.4 7 2.4 8 0",
|
|
141
|
+
fill: "none",
|
|
142
|
+
stroke: "currentColor",
|
|
143
|
+
strokeWidth: "1.5",
|
|
144
|
+
strokeLinecap: "round",
|
|
145
|
+
className: cn("text-background transition-opacity duration-150", ready ? "opacity-100" : "opacity-0")
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ jsx("circle", {
|
|
148
|
+
cx: "18",
|
|
149
|
+
cy: "21",
|
|
150
|
+
r: "1.6",
|
|
151
|
+
className: cn("fill-background transition-opacity duration-150", refreshing ? "opacity-100" : "opacity-0")
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function PullToRefresh({ onRefresh, children, refreshing = false, disabled = false, threshold = 76, maxPull = 132, holdDistance = 68, pullingLabel = "Pull to refresh", releaseLabel = "Release to refresh", refreshingLabel = "Refreshing", ariaLabel = "Refreshable content", className, contentClassName, indicatorClassName }) {
|
|
158
|
+
const rootRef = useRef(null);
|
|
159
|
+
const gestureRef = useRef({ ...EMPTY_GESTURE });
|
|
160
|
+
const animationRef = useRef(null);
|
|
161
|
+
const statusRef = useRef("idle");
|
|
162
|
+
const disabledRef = useRef(disabled);
|
|
163
|
+
const externalRefreshingRef = useRef(refreshing);
|
|
164
|
+
const refreshingRef = useRef(refreshing);
|
|
165
|
+
const [status, setStatusState] = useState("idle");
|
|
166
|
+
const [internalRefreshing, setInternalRefreshing] = useState(false);
|
|
167
|
+
const reduce = useReducedMotion();
|
|
168
|
+
const pullThreshold = Math.max(24, threshold);
|
|
169
|
+
const pullLimit = Math.max(maxPull, pullThreshold + 24);
|
|
170
|
+
const restingDistance = Math.min(Math.max(0, holdDistance), pullThreshold);
|
|
171
|
+
const y = useMotionValue(0);
|
|
172
|
+
const progress = useTransform(y, [0, pullThreshold], [0, 1]);
|
|
173
|
+
const indicatorOpacity = useTransform(y, [
|
|
174
|
+
0,
|
|
175
|
+
10,
|
|
176
|
+
pullThreshold
|
|
177
|
+
], [
|
|
178
|
+
0,
|
|
179
|
+
.45,
|
|
180
|
+
1
|
|
181
|
+
]);
|
|
182
|
+
const indicatorScale = useTransform(y, [0, pullThreshold], [.86, 1]);
|
|
183
|
+
const isRefreshing = refreshing || internalRefreshing;
|
|
184
|
+
disabledRef.current = disabled;
|
|
185
|
+
externalRefreshingRef.current = refreshing;
|
|
186
|
+
refreshingRef.current = isRefreshing;
|
|
187
|
+
const setStatus = useCallback((next) => {
|
|
188
|
+
if (statusRef.current === next) return;
|
|
189
|
+
statusRef.current = next;
|
|
190
|
+
setStatusState(next);
|
|
191
|
+
}, []);
|
|
192
|
+
const settle = useCallback((target) => {
|
|
193
|
+
animationRef.current?.stop();
|
|
194
|
+
if (reduce) {
|
|
195
|
+
y.set(target);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
animationRef.current = animate(y, target, SPRING_PANEL);
|
|
199
|
+
}, [reduce, y]);
|
|
200
|
+
const updatePull = useCallback((distance) => {
|
|
201
|
+
if (disabledRef.current || refreshingRef.current) return;
|
|
202
|
+
animationRef.current?.stop();
|
|
203
|
+
const next = resistedDistance(distance, pullLimit);
|
|
204
|
+
y.set(next);
|
|
205
|
+
setStatus(next >= pullThreshold ? "ready" : "pulling");
|
|
206
|
+
}, [
|
|
207
|
+
pullLimit,
|
|
208
|
+
pullThreshold,
|
|
209
|
+
setStatus,
|
|
210
|
+
y
|
|
211
|
+
]);
|
|
212
|
+
const runRefresh = useCallback(async () => {
|
|
213
|
+
if (disabledRef.current || refreshingRef.current) return;
|
|
214
|
+
setInternalRefreshing(true);
|
|
215
|
+
setStatus("refreshing");
|
|
216
|
+
settle(restingDistance);
|
|
217
|
+
try {
|
|
218
|
+
await onRefresh();
|
|
219
|
+
} finally {
|
|
220
|
+
setInternalRefreshing(false);
|
|
221
|
+
if (!externalRefreshingRef.current) {
|
|
222
|
+
setStatus("idle");
|
|
223
|
+
settle(0);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}, [
|
|
227
|
+
onRefresh,
|
|
228
|
+
restingDistance,
|
|
229
|
+
setStatus,
|
|
230
|
+
settle
|
|
231
|
+
]);
|
|
232
|
+
const finishPull = useCallback(() => {
|
|
233
|
+
const shouldRefresh = y.get() >= pullThreshold && !disabledRef.current && !refreshingRef.current;
|
|
234
|
+
gestureRef.current = { ...EMPTY_GESTURE };
|
|
235
|
+
if (shouldRefresh) {
|
|
236
|
+
runRefresh();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
setStatus("idle");
|
|
240
|
+
settle(0);
|
|
241
|
+
}, [
|
|
242
|
+
pullThreshold,
|
|
243
|
+
runRefresh,
|
|
244
|
+
setStatus,
|
|
245
|
+
settle,
|
|
246
|
+
y
|
|
247
|
+
]);
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (isRefreshing) {
|
|
250
|
+
setStatus("refreshing");
|
|
251
|
+
settle(restingDistance);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (statusRef.current === "refreshing") {
|
|
255
|
+
setStatus("idle");
|
|
256
|
+
settle(0);
|
|
257
|
+
}
|
|
258
|
+
}, [
|
|
259
|
+
isRefreshing,
|
|
260
|
+
restingDistance,
|
|
261
|
+
setStatus,
|
|
262
|
+
settle
|
|
263
|
+
]);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
const root = rootRef.current;
|
|
266
|
+
if (!root) return;
|
|
267
|
+
const onTouchStart = (event) => {
|
|
268
|
+
if (event.touches.length !== 1 || root.scrollTop > 0 || disabledRef.current || refreshingRef.current) return;
|
|
269
|
+
const touch = event.touches[0];
|
|
270
|
+
gestureRef.current = {
|
|
271
|
+
active: true,
|
|
272
|
+
startX: touch.clientX,
|
|
273
|
+
startY: touch.clientY,
|
|
274
|
+
pointerId: null
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
const onTouchMove = (event) => {
|
|
278
|
+
const gesture = gestureRef.current;
|
|
279
|
+
const touch = event.touches[0];
|
|
280
|
+
if (!gesture.active || !touch) return;
|
|
281
|
+
const deltaX = touch.clientX - gesture.startX;
|
|
282
|
+
const deltaY = touch.clientY - gesture.startY;
|
|
283
|
+
if (root.scrollTop > 0 || deltaY < 0) {
|
|
284
|
+
gestureRef.current = { ...EMPTY_GESTURE };
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (Math.abs(deltaX) > deltaY) return;
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
updatePull(deltaY);
|
|
290
|
+
};
|
|
291
|
+
const onTouchEnd = () => {
|
|
292
|
+
if (gestureRef.current.active) finishPull();
|
|
293
|
+
};
|
|
294
|
+
root.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
295
|
+
root.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
296
|
+
root.addEventListener("touchend", onTouchEnd);
|
|
297
|
+
root.addEventListener("touchcancel", onTouchEnd);
|
|
298
|
+
return () => {
|
|
299
|
+
root.removeEventListener("touchstart", onTouchStart);
|
|
300
|
+
root.removeEventListener("touchmove", onTouchMove);
|
|
301
|
+
root.removeEventListener("touchend", onTouchEnd);
|
|
302
|
+
root.removeEventListener("touchcancel", onTouchEnd);
|
|
303
|
+
};
|
|
304
|
+
}, [finishPull, updatePull]);
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
return () => animationRef.current?.stop();
|
|
307
|
+
}, []);
|
|
308
|
+
const startMousePull = (event) => {
|
|
309
|
+
if (event.pointerType !== "mouse" || event.button !== 0 || event.currentTarget.scrollTop > 0 || disabled || isRefreshing) return;
|
|
310
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
311
|
+
gestureRef.current = {
|
|
312
|
+
active: true,
|
|
313
|
+
startX: event.clientX,
|
|
314
|
+
startY: event.clientY,
|
|
315
|
+
pointerId: event.pointerId
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
const moveMousePull = (event) => {
|
|
319
|
+
const gesture = gestureRef.current;
|
|
320
|
+
if (!gesture.active || gesture.pointerId !== event.pointerId) return;
|
|
321
|
+
const deltaX = event.clientX - gesture.startX;
|
|
322
|
+
const deltaY = event.clientY - gesture.startY;
|
|
323
|
+
if (deltaY < 0 || Math.abs(deltaX) > deltaY) return;
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
updatePull(deltaY);
|
|
326
|
+
};
|
|
327
|
+
const label = status === "refreshing" ? refreshingLabel : status === "ready" ? releaseLabel : pullingLabel;
|
|
328
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
329
|
+
ref: rootRef,
|
|
330
|
+
"aria-label": ariaLabel,
|
|
331
|
+
"aria-busy": isRefreshing,
|
|
332
|
+
"data-state": status,
|
|
333
|
+
"data-disabled": disabled || void 0,
|
|
334
|
+
onPointerDown: startMousePull,
|
|
335
|
+
onPointerMove: moveMousePull,
|
|
336
|
+
onPointerUp: (event) => {
|
|
337
|
+
if (gestureRef.current.pointerId === event.pointerId) finishPull();
|
|
338
|
+
},
|
|
339
|
+
onPointerCancel: (event) => {
|
|
340
|
+
if (gestureRef.current.pointerId === event.pointerId) finishPull();
|
|
341
|
+
},
|
|
342
|
+
className: cn("relative w-full overflow-y-auto overscroll-contain bg-background", status === "pulling" || status === "ready" ? "cursor-grabbing select-none" : "cursor-grab", (disabled || isRefreshing) && "cursor-default", className),
|
|
343
|
+
children: [/* @__PURE__ */ jsxs(motion.div, {
|
|
344
|
+
"aria-live": "polite",
|
|
345
|
+
"aria-atomic": "true",
|
|
346
|
+
style: reduce ? { opacity: indicatorOpacity } : {
|
|
347
|
+
opacity: indicatorOpacity,
|
|
348
|
+
scale: indicatorScale
|
|
349
|
+
},
|
|
350
|
+
className: cn("pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-gradient-to-b from-background via-background/95 to-transparent font-medium text-[11px] text-muted-foreground", indicatorClassName),
|
|
351
|
+
children: [/* @__PURE__ */ jsx(RefreshBuddy, {
|
|
352
|
+
progress,
|
|
353
|
+
status,
|
|
354
|
+
reduce: Boolean(reduce)
|
|
355
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
356
|
+
className: "relative h-4 min-w-24 text-center",
|
|
357
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
358
|
+
initial: false,
|
|
359
|
+
mode: "wait",
|
|
360
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
361
|
+
initial: reduce ? { opacity: 0 } : {
|
|
362
|
+
opacity: 0,
|
|
363
|
+
y: 3
|
|
364
|
+
},
|
|
365
|
+
animate: reduce ? { opacity: 1 } : {
|
|
366
|
+
opacity: 1,
|
|
367
|
+
y: 0
|
|
368
|
+
},
|
|
369
|
+
exit: reduce ? { opacity: 0 } : {
|
|
370
|
+
opacity: 0,
|
|
371
|
+
y: -3
|
|
372
|
+
},
|
|
373
|
+
transition: LABEL_SWAP,
|
|
374
|
+
className: "absolute inset-x-0 whitespace-nowrap",
|
|
375
|
+
children: label
|
|
376
|
+
}, status)
|
|
377
|
+
})
|
|
378
|
+
})]
|
|
379
|
+
}), /* @__PURE__ */ jsx(motion.div, {
|
|
380
|
+
style: reduce ? void 0 : { y },
|
|
381
|
+
className: cn("relative z-10 min-h-full bg-inherit will-change-transform", contentClassName),
|
|
382
|
+
children
|
|
383
|
+
})]
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
387
|
+
export { PullToRefresh };
|
|
388
|
+
|
|
389
|
+
//# sourceMappingURL=pull-to-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull-to-refresh.js","names":[],"sources":["../../../src/components/motion/pull-to-refresh.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN_OUT, EASE_OUT, SPRING_PANEL, SPRING_SWAP } from \"../../lib/ease\";\n\nexport type PullToRefreshStatus = \"idle\" | \"pulling\" | \"ready\" | \"refreshing\";\n\nexport interface PullToRefreshProps {\n /** Runs after the user pulls beyond the threshold and releases. */\n onRefresh: () => void | Promise<void>;\n children: ReactNode;\n /** Keeps the indicator active while an externally managed refresh runs. */\n refreshing?: boolean;\n disabled?: boolean;\n /** Resisted pull distance in pixels required to refresh. */\n threshold?: number;\n /** Maximum resisted pull distance in pixels. */\n maxPull?: number;\n /** Content offset in pixels while refreshing. */\n holdDistance?: number;\n pullingLabel?: ReactNode;\n releaseLabel?: ReactNode;\n refreshingLabel?: ReactNode;\n ariaLabel?: string;\n className?: string;\n contentClassName?: string;\n indicatorClassName?: string;\n}\n\ntype Gesture = {\n active: boolean;\n startX: number;\n startY: number;\n pointerId: number | null;\n};\n\nconst EMPTY_GESTURE: Gesture = {\n active: false,\n startX: 0,\n startY: 0,\n pointerId: null,\n};\n\n// This character needs a compact repeating rhythm rather than a settling\n// spring: a small orbit and blink that read as activity without feeling busy.\nconst CHARACTER_LOOP = {\n duration: 0.9,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst CALM_PULSE = {\n duration: 1.2,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n} as const;\nconst LABEL_SWAP = { duration: 0.16, ease: EASE_OUT } as const;\n\nfunction resistedDistance(distance: number, maxPull: number) {\n return maxPull * (1 - Math.exp(-Math.max(0, distance) / maxPull));\n}\n\nfunction RefreshBuddy({\n progress,\n status,\n reduce,\n}: {\n progress: MotionValue<number>;\n status: PullToRefreshStatus;\n reduce: boolean;\n}) {\n const lift = useTransform(progress, [0, 1], [-7, 0]);\n const tilt = useTransform(progress, [0, 1], [-10, 0]);\n const stretch = useTransform(progress, [0, 0.55, 1], [0.68, 1.1, 0.92]);\n const ready = status === \"ready\";\n const refreshing = status === \"refreshing\";\n\n return (\n <motion.span\n style={reduce ? undefined : { y: lift, rotate: tilt, scaleY: stretch }}\n className=\"block h-9 w-9 origin-bottom\"\n >\n <motion.svg\n aria-hidden=\"true\"\n viewBox=\"0 0 36 36\"\n style={{ opacity: 1 }}\n className=\"h-full w-full overflow-visible\"\n animate={\n refreshing\n ? reduce\n ? { opacity: [0.55, 1, 0.55] }\n : { y: [0, -2, 0], rotate: [-3, 3, -3] }\n : reduce\n ? { opacity: 1 }\n : { y: 0, rotate: 0, scale: ready ? 1.08 : 1 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n >\n <motion.g\n style={{ transformOrigin: \"18px 18px\" }}\n animate={\n refreshing && !reduce\n ? { rotate: [0, 360] }\n : reduce\n ? undefined\n : { rotate: ready ? 0 : -35 }\n }\n transition={refreshing ? (reduce ? CALM_PULSE : CHARACTER_LOOP) : SPRING_SWAP}\n className={cn(\n \"transition-opacity duration-150\",\n ready || refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n <path\n d=\"M18 2.5a15.5 15.5 0 0 1 12.7 6.6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className=\"text-muted-foreground\"\n />\n <circle cx=\"31.3\" cy=\"10.2\" r=\"2.2\" className=\"fill-foreground\" />\n </motion.g>\n\n <rect x=\"7\" y=\"7\" width=\"22\" height=\"22\" rx=\"9\" className=\"fill-foreground\" />\n\n <motion.g\n style={{ opacity: 1, transformOrigin: \"18px 16px\" }}\n animate={\n refreshing && !reduce\n ? { scaleY: [1, 1, 0.15, 1, 1] }\n : reduce\n ? { opacity: 1 }\n : { scaleY: ready ? 1.18 : 1 }\n }\n transition={refreshing && !reduce ? CHARACTER_LOOP : SPRING_SWAP}\n >\n <circle cx=\"14.2\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n <circle cx=\"21.8\" cy=\"16\" r=\"1.45\" className=\"fill-background\" />\n </motion.g>\n\n <path\n d=\"M14.5 21h7\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready || refreshing ? \"opacity-0\" : \"opacity-100\",\n )}\n />\n <path\n d=\"M14 20.5c1 2.4 7 2.4 8 0\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n className={cn(\n \"text-background transition-opacity duration-150\",\n ready ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n <circle\n cx=\"18\"\n cy=\"21\"\n r=\"1.6\"\n className={cn(\n \"fill-background transition-opacity duration-150\",\n refreshing ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </motion.svg>\n </motion.span>\n );\n}\n\nexport function PullToRefresh({\n onRefresh,\n children,\n refreshing = false,\n disabled = false,\n threshold = 76,\n maxPull = 132,\n holdDistance = 68,\n pullingLabel = \"Pull to refresh\",\n releaseLabel = \"Release to refresh\",\n refreshingLabel = \"Refreshing\",\n ariaLabel = \"Refreshable content\",\n className,\n contentClassName,\n indicatorClassName,\n}: PullToRefreshProps) {\n const rootRef = useRef<HTMLElement>(null);\n const gestureRef = useRef<Gesture>({ ...EMPTY_GESTURE });\n const animationRef = useRef<{ stop: () => void } | null>(null);\n const statusRef = useRef<PullToRefreshStatus>(\"idle\");\n const disabledRef = useRef(disabled);\n const externalRefreshingRef = useRef(refreshing);\n const refreshingRef = useRef(refreshing);\n const [status, setStatusState] = useState<PullToRefreshStatus>(\"idle\");\n const [internalRefreshing, setInternalRefreshing] = useState(false);\n const reduce = useReducedMotion();\n const pullThreshold = Math.max(24, threshold);\n const pullLimit = Math.max(maxPull, pullThreshold + 24);\n const restingDistance = Math.min(Math.max(0, holdDistance), pullThreshold);\n const y = useMotionValue(0);\n const progress = useTransform(y, [0, pullThreshold], [0, 1]);\n const indicatorOpacity = useTransform(y, [0, 10, pullThreshold], [0, 0.45, 1]);\n const indicatorScale = useTransform(y, [0, pullThreshold], [0.86, 1]);\n const isRefreshing = refreshing || internalRefreshing;\n\n disabledRef.current = disabled;\n externalRefreshingRef.current = refreshing;\n refreshingRef.current = isRefreshing;\n\n const setStatus = useCallback((next: PullToRefreshStatus) => {\n if (statusRef.current === next) return;\n statusRef.current = next;\n setStatusState(next);\n }, []);\n\n const settle = useCallback(\n (target: number) => {\n animationRef.current?.stop();\n\n if (reduce) {\n y.set(target);\n return;\n }\n\n animationRef.current = animate(y, target, SPRING_PANEL);\n },\n [reduce, y],\n );\n\n const updatePull = useCallback(\n (distance: number) => {\n if (disabledRef.current || refreshingRef.current) return;\n animationRef.current?.stop();\n\n const next = resistedDistance(distance, pullLimit);\n y.set(next);\n setStatus(next >= pullThreshold ? \"ready\" : \"pulling\");\n },\n [pullLimit, pullThreshold, setStatus, y],\n );\n\n const runRefresh = useCallback(async () => {\n if (disabledRef.current || refreshingRef.current) return;\n\n setInternalRefreshing(true);\n setStatus(\"refreshing\");\n settle(restingDistance);\n\n try {\n await onRefresh();\n } finally {\n setInternalRefreshing(false);\n\n // A synchronous refresh can resolve before React commits the temporary\n // internal state, so release here instead of relying only on the effect.\n if (!externalRefreshingRef.current) {\n setStatus(\"idle\");\n settle(0);\n }\n }\n }, [onRefresh, restingDistance, setStatus, settle]);\n\n const finishPull = useCallback(() => {\n const shouldRefresh =\n y.get() >= pullThreshold && !disabledRef.current && !refreshingRef.current;\n\n gestureRef.current = { ...EMPTY_GESTURE };\n\n if (shouldRefresh) {\n void runRefresh();\n return;\n }\n\n setStatus(\"idle\");\n settle(0);\n }, [pullThreshold, runRefresh, setStatus, settle, y]);\n\n useEffect(() => {\n if (isRefreshing) {\n setStatus(\"refreshing\");\n settle(restingDistance);\n return;\n }\n\n if (statusRef.current === \"refreshing\") {\n setStatus(\"idle\");\n settle(0);\n }\n }, [isRefreshing, restingDistance, setStatus, settle]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const onTouchStart = (event: TouchEvent) => {\n if (\n event.touches.length !== 1 ||\n root.scrollTop > 0 ||\n disabledRef.current ||\n refreshingRef.current\n ) {\n return;\n }\n\n const touch = event.touches[0];\n gestureRef.current = {\n active: true,\n startX: touch.clientX,\n startY: touch.clientY,\n pointerId: null,\n };\n };\n\n const onTouchMove = (event: TouchEvent) => {\n const gesture = gestureRef.current;\n const touch = event.touches[0];\n if (!gesture.active || !touch) return;\n\n const deltaX = touch.clientX - gesture.startX;\n const deltaY = touch.clientY - gesture.startY;\n\n if (root.scrollTop > 0 || deltaY < 0) {\n gestureRef.current = { ...EMPTY_GESTURE };\n return;\n }\n\n if (Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const onTouchEnd = () => {\n if (gestureRef.current.active) finishPull();\n };\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n root.addEventListener(\"touchend\", onTouchEnd);\n root.addEventListener(\"touchcancel\", onTouchEnd);\n\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart);\n root.removeEventListener(\"touchmove\", onTouchMove);\n root.removeEventListener(\"touchend\", onTouchEnd);\n root.removeEventListener(\"touchcancel\", onTouchEnd);\n };\n }, [finishPull, updatePull]);\n\n useEffect(() => {\n return () => animationRef.current?.stop();\n }, []);\n\n const startMousePull = (event: ReactPointerEvent<HTMLElement>) => {\n if (\n event.pointerType !== \"mouse\" ||\n event.button !== 0 ||\n event.currentTarget.scrollTop > 0 ||\n disabled ||\n isRefreshing\n ) {\n return;\n }\n\n event.currentTarget.setPointerCapture(event.pointerId);\n gestureRef.current = {\n active: true,\n startX: event.clientX,\n startY: event.clientY,\n pointerId: event.pointerId,\n };\n };\n\n const moveMousePull = (event: ReactPointerEvent<HTMLElement>) => {\n const gesture = gestureRef.current;\n if (!gesture.active || gesture.pointerId !== event.pointerId) return;\n\n const deltaX = event.clientX - gesture.startX;\n const deltaY = event.clientY - gesture.startY;\n if (deltaY < 0 || Math.abs(deltaX) > deltaY) return;\n\n event.preventDefault();\n updatePull(deltaY);\n };\n\n const label =\n status === \"refreshing\" ? refreshingLabel : status === \"ready\" ? releaseLabel : pullingLabel;\n\n return (\n <section\n ref={rootRef}\n aria-label={ariaLabel}\n aria-busy={isRefreshing}\n data-state={status}\n data-disabled={disabled || undefined}\n onPointerDown={startMousePull}\n onPointerMove={moveMousePull}\n onPointerUp={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n onPointerCancel={(event) => {\n if (gestureRef.current.pointerId === event.pointerId) finishPull();\n }}\n className={cn(\n \"relative w-full overflow-y-auto overscroll-contain bg-background\",\n status === \"pulling\" || status === \"ready\" ? \"cursor-grabbing select-none\" : \"cursor-grab\",\n (disabled || isRefreshing) && \"cursor-default\",\n className,\n )}\n >\n <motion.div\n aria-live=\"polite\"\n aria-atomic=\"true\"\n style={\n reduce\n ? { opacity: indicatorOpacity }\n : { opacity: indicatorOpacity, scale: indicatorScale }\n }\n className={cn(\n \"pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-gradient-to-b from-background via-background/95 to-transparent font-medium text-[11px] text-muted-foreground\",\n indicatorClassName,\n )}\n >\n <RefreshBuddy progress={progress} status={status} reduce={Boolean(reduce)} />\n <span className=\"relative h-4 min-w-24 text-center\">\n <AnimatePresence initial={false} mode=\"wait\">\n <motion.span\n key={status}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 3 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={LABEL_SWAP}\n className=\"absolute inset-x-0 whitespace-nowrap\"\n >\n {label}\n </motion.span>\n </AnimatePresence>\n </span>\n </motion.div>\n\n <motion.div\n style={reduce ? undefined : { y }}\n className={cn(\n \"relative z-10 min-h-full bg-inherit will-change-transform\",\n contentClassName,\n )}\n >\n {children}\n </motion.div>\n </section>\n );\n}\n"],"mappings":";;;;;;;AAsDA,MAAM,gBAAyB;CAC7B,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;AACb;AAIA,MAAM,iBAAiB;CACrB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CACjB,UAAU;CACV,MAAM;CACN,QAAQ,OAAO;AACjB;AACA,MAAM,aAAa;CAAE,UAAU;CAAM,MAAM;AAAS;AAEpD,SAAS,iB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E,IAAI;OAAE,SAAS;OAAG,GAAG;MAAG;MACpD,YAAY;MACZ,WAAU;MAET,UAAA;KACU,GARN,MAQM;IACE,CAAA;GACb,CAAA,CACI;EAEZ,CAAA,GAAA,oBAAC,OAAO,KAAR;GACE,OAAO,SAAS,KAAA,IAAY,EAAE,EAAE;GAChC,WAAW,GACT,6DACA,gBACF;GAEC;EACS,CAAA,CACL;;AAEb"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/motion/radio.d.ts
|
|
3
|
+
interface RadioGroupProps {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
orientation?: "vertical" | "horizontal";
|
|
10
|
+
}
|
|
11
|
+
declare function RadioGroup({ value, defaultValue, onValueChange, children, className, orientation }: RadioGroupProps): import("react").JSX.Element;
|
|
12
|
+
interface RadioGroupItemProps {
|
|
13
|
+
value: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function RadioGroupItem({ value, label, disabled, className, id: idProp }: RadioGroupItemProps): import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { RadioGroup, RadioGroupItem, RadioGroupItemProps, RadioGroupProps };
|
|
22
|
+
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.d.ts","names":[],"sources":["../../../src/components/motion/radio.tsx"],"mappings":";;UAgCiB;EACf;EACA;EACA,iBAAiB;EACjB,UAAU;EACV;EACA;;iBAGc,aACd,OACA,cACA,eACA,UACA,WACA,eACC,kCAAe,IAAA;UAoCD;EACf;EACA;EACA;EACA;EACA;;iBAGc,iBACd,OACA,OACA,UACA,WACA,IAAI,UACH,sCAAmB,IAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
3
|
+
import { createContext, useCallback, useContext, useId, useMemo, useState } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { MotionConfig, motion, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/motion/radio.tsx
|
|
8
|
+
const RadioCtx = createContext(null);
|
|
9
|
+
function useRadioGroup() {
|
|
10
|
+
const ctx = useContext(RadioCtx);
|
|
11
|
+
if (!ctx) throw new Error("RadioGroupItem must be used inside <RadioGroup>");
|
|
12
|
+
return ctx;
|
|
13
|
+
}
|
|
14
|
+
function RadioGroup({ value, defaultValue = "", onValueChange, children, className, orientation = "vertical" }) {
|
|
15
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
16
|
+
const layoutId = useId();
|
|
17
|
+
const reduce = useReducedMotion();
|
|
18
|
+
const controlled = value !== void 0;
|
|
19
|
+
const current = controlled ? value : internal;
|
|
20
|
+
const setValue = useCallback((next) => {
|
|
21
|
+
if (!controlled) setInternal(next);
|
|
22
|
+
onValueChange?.(next);
|
|
23
|
+
}, [controlled, onValueChange]);
|
|
24
|
+
const contextValue = useMemo(() => ({
|
|
25
|
+
value: current,
|
|
26
|
+
setValue,
|
|
27
|
+
layoutId
|
|
28
|
+
}), [
|
|
29
|
+
current,
|
|
30
|
+
layoutId,
|
|
31
|
+
setValue
|
|
32
|
+
]);
|
|
33
|
+
return /* @__PURE__ */ jsx(MotionConfig, {
|
|
34
|
+
transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
|
|
35
|
+
children: /* @__PURE__ */ jsx(RadioCtx.Provider, {
|
|
36
|
+
value: contextValue,
|
|
37
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
38
|
+
role: "radiogroup",
|
|
39
|
+
className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap", className),
|
|
40
|
+
children
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function RadioGroupItem({ value, label, disabled, className, id: idProp }) {
|
|
46
|
+
const { value: groupValue, setValue, layoutId } = useRadioGroup();
|
|
47
|
+
const autoId = useId();
|
|
48
|
+
const id = idProp ?? autoId;
|
|
49
|
+
const reduce = useReducedMotion();
|
|
50
|
+
const selected = groupValue === value;
|
|
51
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
52
|
+
htmlFor: id,
|
|
53
|
+
className: cn("inline-flex items-center gap-3", disabled ? "cursor-not-allowed" : "cursor-pointer", className),
|
|
54
|
+
children: [/* @__PURE__ */ jsx(motion.button, {
|
|
55
|
+
id,
|
|
56
|
+
type: "button",
|
|
57
|
+
role: "radio",
|
|
58
|
+
"aria-checked": selected,
|
|
59
|
+
disabled,
|
|
60
|
+
onClick: () => !disabled && setValue(value),
|
|
61
|
+
whileTap: reduce || disabled ? void 0 : { scale: .92 },
|
|
62
|
+
transition: SPRING_PRESS,
|
|
63
|
+
"data-state": selected ? "checked" : "unchecked",
|
|
64
|
+
className: cn("relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "disabled:cursor-not-allowed disabled:opacity-60", selected ? "border-primary" : "border-muted-foreground/50 hover:border-muted-foreground"),
|
|
65
|
+
children: selected ? /* @__PURE__ */ jsx(motion.span, {
|
|
66
|
+
layoutId,
|
|
67
|
+
className: "absolute inset-1 rounded-full bg-primary",
|
|
68
|
+
transition: reduce ? { duration: 0 } : SPRING_LAYOUT
|
|
69
|
+
}) : null
|
|
70
|
+
}), label ? /* @__PURE__ */ jsx("span", {
|
|
71
|
+
className: cn("select-none text-foreground text-sm", disabled && "opacity-60"),
|
|
72
|
+
children: label
|
|
73
|
+
}) : null]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { RadioGroup, RadioGroupItem };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=radio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/motion/radio.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype RadioCtx = {\n value: string;\n setValue: (value: string) => void;\n layoutId: string;\n};\n\nconst RadioCtx = createContext<RadioCtx | null>(null);\n\nfunction useRadioGroup() {\n const ctx = useContext(RadioCtx);\n if (!ctx) {\n throw new Error(\"RadioGroupItem must be used inside <RadioGroup>\");\n }\n return ctx;\n}\n\nexport interface RadioGroupProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n orientation?: \"vertical\" | \"horizontal\";\n}\n\nexport function RadioGroup({\n value,\n defaultValue = \"\",\n onValueChange,\n children,\n className,\n orientation = \"vertical\",\n}: RadioGroupProps) {\n const [internal, setInternal] = useState(defaultValue);\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId }),\n [current, layoutId, setValue],\n );\n\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : SPRING_LAYOUT}>\n <RadioCtx.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n className={cn(\n \"flex gap-3\",\n orientation === \"vertical\" ? \"flex-col\" : \"flex-row flex-wrap\",\n className,\n )}\n >\n {children}\n </div>\n </RadioCtx.Provider>\n </MotionConfig>\n );\n}\n\nexport interface RadioGroupItemProps {\n value: string;\n label?: string;\n disabled?: boolean;\n className?: string;\n id?: string;\n}\n\nexport function RadioGroupItem({\n value,\n label,\n disabled,\n className,\n id: idProp,\n}: RadioGroupItemProps) {\n const { value: groupValue, setValue, layoutId } = useRadioGroup();\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const selected = groupValue === value;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex items-center gap-3\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n disabled={disabled}\n onClick={() => !disabled && setValue(value)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={selected ? \"checked\" : \"unchecked\"}\n className={cn(\n \"relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n selected ? \"border-primary\" : \"border-muted-foreground/50 hover:border-muted-foreground\",\n )}\n >\n {selected ? (\n <motion.span\n layoutId={layoutId}\n className=\"absolute inset-1 rounded-full bg-primary\"\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </motion.button>\n {label ? (\n <span className={cn(\"select-none text-foreground text-sm\", disabled && \"opacity-60\")}>\n {label}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAsBA,MAAM,WAAW,cAA+B,IAAI;AAEpD,SAAS,gBAAgB;CACvB,MAAM,MAAM,WAAW,QAAQ;CAC/B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,iDAAiD;CAEnE,OAAO;AACT;AAWA,SAAgB,WAAW,EACzB,OACA,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AO,MAAR;IACY;IACV,WAAU;IACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACxC,CAAA,IACC;EACS,CAAA,GACd,QACC,oBAAC,QAAD;GAAM,WAAW,GAAG,uCAAuC,YAAY,YAAY;GAChF,UAAA;EACG,CAAA,IACJ,IACC;;AAEX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider-bubble.d.ts
|
|
3
|
+
interface BubbleSliderProps extends SliderOptions {
|
|
4
|
+
/** Formats the value shown in the bubble. */
|
|
5
|
+
format?: (value: number) => string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Slider with a value bubble that pops out of the thumb on grab and reacts to
|
|
10
|
+
* how fast you drag: it leans into the direction of travel and squashes along
|
|
11
|
+
* the way, then settles upright when you let go.
|
|
12
|
+
*/
|
|
13
|
+
declare function BubbleSlider({ format, className, ...options }: BubbleSliderProps): import("react").JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BubbleSlider, BubbleSliderProps };
|
|
16
|
+
//# sourceMappingURL=range-slider-bubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-bubble.d.ts","names":[],"sources":["../../../src/components/motion/range-slider-bubble.tsx"],"mappings":";;UAuBiB,0BAA0B;;EAEzC,UAAU;EACV;;;;;;;iBAQc,eAAe,QAAQ,cAAc,WAAW,oCAAiB,IAAA"}
|