@kumix/ui 0.2.4 → 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 +2 -2
- 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 +2 -2
- 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.d.ts +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.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/empty.d.ts +1 -1
- package/dist/components/ui/empty.js +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/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/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,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSlider } from "../../hooks/use-slider.js";
|
|
3
|
+
import { SPRING_GLIDE, SPRING_PANEL, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { AnimatePresence, motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform, useVelocity } from "motion/react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/motion/range-slider-bubble.tsx
|
|
9
|
+
const SPRING_TILT = {
|
|
10
|
+
stiffness: 260,
|
|
11
|
+
damping: 22,
|
|
12
|
+
mass: .4
|
|
13
|
+
};
|
|
14
|
+
/** Drag speed (px/s of track percent) that maxes out lean and squash. */
|
|
15
|
+
const FULL_TILT = 320;
|
|
16
|
+
/**
|
|
17
|
+
* Slider with a value bubble that pops out of the thumb on grab and reacts to
|
|
18
|
+
* how fast you drag: it leans into the direction of travel and squashes along
|
|
19
|
+
* the way, then settles upright when you let go.
|
|
20
|
+
*/
|
|
21
|
+
function BubbleSlider({ format, className, ...options }) {
|
|
22
|
+
const reduce = useReducedMotion();
|
|
23
|
+
const { percent, current, dragging, trackProps, sliderProps } = useSlider({
|
|
24
|
+
...options,
|
|
25
|
+
formatValueText: options.formatValueText ?? format
|
|
26
|
+
});
|
|
27
|
+
const readout = format ? format(current) : current;
|
|
28
|
+
const target = useMotionValue(percent);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
target.set(percent);
|
|
31
|
+
}, [percent, target]);
|
|
32
|
+
const smooth = useSpring(target, SPRING_GLIDE);
|
|
33
|
+
const pos = reduce ? target : smooth;
|
|
34
|
+
const left = useMotionTemplate`${pos}%`;
|
|
35
|
+
const velocity = useVelocity(pos);
|
|
36
|
+
const lean = useSpring(useTransform(velocity, [
|
|
37
|
+
-320,
|
|
38
|
+
0,
|
|
39
|
+
FULL_TILT
|
|
40
|
+
], [
|
|
41
|
+
1,
|
|
42
|
+
0,
|
|
43
|
+
-1
|
|
44
|
+
], { clamp: true }), SPRING_TILT);
|
|
45
|
+
const tilt = useTransform(lean, (v) => v * 16);
|
|
46
|
+
const squash = useTransform(lean, (v) => 1 + Math.abs(v) * .18);
|
|
47
|
+
const stretch = useTransform(lean, (v) => 1 - Math.abs(v) * .12);
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: cn("relative flex h-20 w-full items-end px-5 pb-5", options.disabled ? "pointer-events-none opacity-50" : void 0, className),
|
|
50
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
51
|
+
...trackProps,
|
|
52
|
+
className: cn("relative h-2 w-full touch-none select-none rounded-full bg-muted", options.disabled ? void 0 : "cursor-grab active:cursor-grabbing"),
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
55
|
+
className: "absolute inset-y-0 left-0 rounded-full bg-foreground",
|
|
56
|
+
style: { width: left }
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
59
|
+
className: "absolute top-1/2 size-5 rounded-full border-2 border-foreground bg-background shadow-sm",
|
|
60
|
+
style: {
|
|
61
|
+
left,
|
|
62
|
+
x: "-50%",
|
|
63
|
+
y: "-50%"
|
|
64
|
+
},
|
|
65
|
+
animate: reduce ? void 0 : { scale: dragging ? 1.25 : 1 },
|
|
66
|
+
transition: SPRING_PRESS
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
69
|
+
className: "pointer-events-none absolute bottom-6",
|
|
70
|
+
style: {
|
|
71
|
+
left,
|
|
72
|
+
x: "-50%"
|
|
73
|
+
},
|
|
74
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { children: dragging ? /* @__PURE__ */ jsxs(motion.div, {
|
|
75
|
+
initial: reduce ? { opacity: 0 } : {
|
|
76
|
+
opacity: 0,
|
|
77
|
+
scale: .4,
|
|
78
|
+
y: 10
|
|
79
|
+
},
|
|
80
|
+
animate: reduce ? { opacity: 1 } : {
|
|
81
|
+
opacity: 1,
|
|
82
|
+
scale: 1,
|
|
83
|
+
y: 0
|
|
84
|
+
},
|
|
85
|
+
exit: reduce ? {
|
|
86
|
+
opacity: 0,
|
|
87
|
+
transition: { duration: .12 }
|
|
88
|
+
} : {
|
|
89
|
+
opacity: 0,
|
|
90
|
+
scale: .5,
|
|
91
|
+
y: 8,
|
|
92
|
+
transition: { duration: .12 }
|
|
93
|
+
},
|
|
94
|
+
transition: reduce ? { duration: .12 } : SPRING_PANEL,
|
|
95
|
+
style: reduce ? void 0 : {
|
|
96
|
+
rotate: tilt,
|
|
97
|
+
scaleX: squash,
|
|
98
|
+
scaleY: stretch,
|
|
99
|
+
originY: 1
|
|
100
|
+
},
|
|
101
|
+
className: "relative rounded-xl bg-foreground px-2.5 py-1 font-medium text-background text-sm tabular-nums shadow-md",
|
|
102
|
+
children: [readout, /* @__PURE__ */ jsx("span", { className: "absolute -bottom-1 left-1/2 size-2.5 -translate-x-1/2 rotate-45 rounded-[3px] bg-foreground" })]
|
|
103
|
+
}) : null })
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("button", {
|
|
106
|
+
type: "button",
|
|
107
|
+
...sliderProps,
|
|
108
|
+
className: "absolute inset-x-0 -inset-y-5 touch-none rounded-full outline-none ring-foreground/30 focus-visible:ring-4"
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { BubbleSlider };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=range-slider-bubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-bubble.js","names":[],"sources":["../../../src/components/motion/range-slider-bubble.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n AnimatePresence,\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n useVelocity,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, useSlider } from \"../../hooks/use-slider\";\nimport { SPRING_GLIDE, SPRING_PANEL, SPRING_PRESS } from \"../../lib/ease\";\n\n// Loose enough that the bubble keeps leaning a beat after the pointer stops.\nconst SPRING_TILT = { stiffness: 260, damping: 22, mass: 0.4 } as const;\n/** Drag speed (px/s of track percent) that maxes out lean and squash. */\nconst FULL_TILT = 320;\n\nexport interface BubbleSliderProps extends SliderOptions {\n /** Formats the value shown in the bubble. */\n format?: (value: number) => string;\n className?: string;\n}\n\n/**\n * Slider with a value bubble that pops out of the thumb on grab and reacts to\n * how fast you drag: it leans into the direction of travel and squashes along\n * the way, then settles upright when you let go.\n */\nexport function BubbleSlider({ format, className, ...options }: BubbleSliderProps) {\n const reduce = useReducedMotion();\n // A bare number needs no valueText — it would only repeat aria-valuenow.\n const { percent, current, dragging, trackProps, sliderProps } = useSlider({\n ...options,\n formatValueText: options.formatValueText ?? format,\n });\n // The value is already snapped to the step — rounding here would only make\n // the bubble disagree with aria-valuenow on a fractional scale.\n const readout = format ? format(current) : current;\n\n const target = useMotionValue(percent);\n useEffect(() => {\n target.set(percent);\n }, [percent, target]);\n const smooth = useSpring(target, SPRING_GLIDE);\n const pos = reduce ? target : smooth;\n const left = useMotionTemplate`${pos}%`;\n\n // One spring drives the whole reaction: lean is signed, squash reads its\n // magnitude. Two springs off the same velocity would just run twice.\n const velocity = useVelocity(pos);\n const lean = useSpring(\n useTransform(velocity, [-FULL_TILT, 0, FULL_TILT], [1, 0, -1], { clamp: true }),\n SPRING_TILT,\n );\n const tilt = useTransform(lean, (v) => v * 16);\n const squash = useTransform(lean, (v) => 1 + Math.abs(v) * 0.18);\n const stretch = useTransform(lean, (v) => 1 - Math.abs(v) * 0.12);\n\n return (\n <div\n className={cn(\n // px/pb leave room for the thumb, the bubble and the 48px hit area to\n // overhang the 8px track without escaping the component's own box\n \"relative flex h-20 w-full items-end px-5 pb-5\",\n options.disabled ? \"pointer-events-none opacity-50\" : undefined,\n className,\n )}\n >\n <div\n {...trackProps}\n className={cn(\n \"relative h-2 w-full touch-none select-none rounded-full bg-muted\",\n options.disabled ? undefined : \"cursor-grab active:cursor-grabbing\",\n )}\n >\n <motion.div\n className=\"absolute inset-y-0 left-0 rounded-full bg-foreground\"\n style={{ width: left }}\n />\n\n {/* thumb — overhangs the track by half its width at both ends, which the\n wrapper's padding leaves room for */}\n <motion.div\n className=\"absolute top-1/2 size-5 rounded-full border-2 border-foreground bg-background shadow-sm\"\n style={{ left, x: \"-50%\", y: \"-50%\" }}\n animate={reduce ? undefined : { scale: dragging ? 1.25 : 1 }}\n transition={SPRING_PRESS}\n />\n\n {/* bubble — anchored to the thumb, leaning with drag velocity */}\n <motion.div className=\"pointer-events-none absolute bottom-6\" style={{ left, x: \"-50%\" }}>\n <AnimatePresence>\n {dragging ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.4, y: 10 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1, y: 0 }}\n exit={\n reduce\n ? { opacity: 0, transition: { duration: 0.12 } }\n : { opacity: 0, scale: 0.5, y: 8, transition: { duration: 0.12 } }\n }\n transition={reduce ? { duration: 0.12 } : SPRING_PANEL}\n style={\n reduce ? undefined : { rotate: tilt, scaleX: squash, scaleY: stretch, originY: 1 }\n }\n className=\"relative rounded-xl bg-foreground px-2.5 py-1 font-medium text-background text-sm tabular-nums shadow-md\"\n >\n {readout}\n <span className=\"absolute -bottom-1 left-1/2 size-2.5 -translate-x-1/2 rotate-45 rounded-[3px] bg-foreground\" />\n </motion.div>\n ) : null}\n </AnimatePresence>\n </motion.div>\n\n {/* 8px of track is not a touch target — pad the hit area out to 48px */}\n <button\n type=\"button\"\n {...sliderProps}\n className=\"absolute inset-x-0 -inset-y-5 touch-none rounded-full outline-none ring-foreground/30 focus-visible:ring-4\"\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAmBA,MAAM,cAAc;CAAE,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;;AAE7D,MAAM,YAAY;;;;;;AAalB,SAAgB,aAAa,EAAE,QAAQ,WAAW,GAAG,WAA8B;CACjF,MAAM,SAAS,iBAAiB;CAEhC,MAAM,EAAE,SAAS,SAAS,UAAU,YAAY,gBAAgB,UAAU;EACxE,GAAG;EACH,iBAAiB,QAAQ,mBAAmB;CAC9C,CAAC;CAGD,MAAM,UAAU,SAAS,OAAO,OAAO,IAAI;CAE3C,MAAM,SAAS,eAAe,OAAO;CACrC,gBAAgB;EACd,OAAO,IAAI,OAAO;CACpB,GAAG,CAAC,SAAS,MAAM,CAAC;CACpB,MAAM,SAAS,UAAU,QAAQ,YAAY;CAC7C,MAAM,MAAM,SAAS,SAAS;CAC9B,MAAM,OAAO,iBAAiB,GAAG,IAAI;CAIrC,MAAM,WAAW,YAAY,GAAG;CAChC,MAAM,OAAO,UACX,aAAa,UAAU;EAAC;EAAY;EAAG;CAAS,GAAG;EAAC;EAAG;EAAG;CAAE,GAAG,EAAE,OAAO,KAAK,CAAC,GAC9E,WACF;CACA,MAAM,OAAO,aAAa,OAAO,MAAM,IAAI,EAAE;CAC7C,MAAM,SAAS,aAAa,OAAO,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,GAAI;CAC/D,MAAM,UAAU,aAAa,OAAO,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,GAAI;CAEhE,OACE,oBAAC,OAAD;EACE,WAAW,GAGT,iDACA,QAAQ,WAAW,mCAAmC,KAAA,GACtD,SACF;EAEA,UAAA,qBAAC,OAAD;GACE,GAAI;GACJ,WAAW,GACT,oEACA,QAAQ,WAAW,KAAA,IAAY,oCACjC;GALF,UAAA;IAOE,oBAAC,OAAO,KAAR;KACE,WAAU;KACV,OAAO,EAAE,OAAO,KAAK;IACtB,CAAA;IAID,oBAAC,OAAO,KAAR;KACE,WAAU;KACV,OAAO;MAAE;MAAM,GAAG;MAAQ,GAAG;KAAO;KACpC,SAAS,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW,OAAO,EAAE;KAC3D,YAAY;IACb,CAAA;IAGD,oBAAC,OAAO,KAAR;KAAY,WAAU;KAAwC,OAAO;MAAE;MAAM,GAAG;KAAO;KACrF,UAAA,oBAAC,iBAAD,EAAA,UACG,WACC,qBAAC,OAAO,KAAR;MACE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,OAAO;OAAK,GAAG;MAAG;MACnE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,OAAO;OAAG,GAAG;MAAE;MAChE,MACE,SACI;OAAE,SAAS;OAAG,YAAY,EAAE,UAAU,IAAK;MAAE,IAC7C;OAAE,SAAS;OAAG,OAAO;OAAK,GAAG;OAAG,YAAY,EAAE,UAAU,IAAK;MAAE;MAErE,YAAY,SAAS,EAAE,UAAU,IAAK,IAAI;MAC1C,OACE,SAAS,KAAA,IAAY;OAAE,QAAQ;OAAM,QAAQ;OAAQ,QAAQ;OAAS,SAAS;MAAE;MAEnF,WAAU;MAZZ,UAAA,CAcG,SACD,oBAAC,QAAD,EAAM,WAAU,8FAA+F,CAAA,CACrG;KACV,CAAA,IAAA,KACW,CAAA;IACP,CAAA;IAGZ,oBAAC,UAAD;KACE,MAAK;KACL,GAAI;KACJ,WAAU;IACX,CAAA;GACE;;CACF,CAAA;AAET"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider-fluid.d.ts
|
|
3
|
+
interface FluidSliderProps extends SliderOptions {
|
|
4
|
+
/** Text shown on the left of the track. */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Formats the value shown on the right. */
|
|
7
|
+
format?: (value: number) => string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Thumbless slider: the whole pill is the control. The fill glides to the new
|
|
12
|
+
* value behind a rounded liquid cap, and the label reads inverted wherever the
|
|
13
|
+
* fill has covered it.
|
|
14
|
+
*/
|
|
15
|
+
declare function FluidSlider({ label, format, className, ...options }: FluidSliderProps): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { FluidSlider, FluidSliderProps };
|
|
18
|
+
//# sourceMappingURL=range-slider-fluid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-fluid.d.ts","names":[],"sources":["../../../src/components/motion/range-slider-fluid.tsx"],"mappings":";;UAgBiB,yBAAyB;;EAExC;;EAEA,UAAU;EACV;;;;;;;iBAQc,cACd,OAGA,QACA,cACG,WACF,mCAAgB,IAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSlider } from "../../hooks/use-slider.js";
|
|
3
|
+
import { SPRING_GLIDE, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/motion/range-slider-fluid.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Thumbless slider: the whole pill is the control. The fill glides to the new
|
|
11
|
+
* value behind a rounded liquid cap, and the label reads inverted wherever the
|
|
12
|
+
* fill has covered it.
|
|
13
|
+
*/
|
|
14
|
+
function FluidSlider({ label, format = (v) => `${v}%`, className, ...options }) {
|
|
15
|
+
const reduce = useReducedMotion();
|
|
16
|
+
const { percent, current, dragging, trackProps, sliderProps } = useSlider({
|
|
17
|
+
...options,
|
|
18
|
+
formatValueText: options.formatValueText ?? format
|
|
19
|
+
});
|
|
20
|
+
const target = useMotionValue(percent);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
target.set(percent);
|
|
23
|
+
}, [percent, target]);
|
|
24
|
+
const smooth = useSpring(target, SPRING_GLIDE);
|
|
25
|
+
const uncovered = useTransform(reduce ? target : smooth, (v) => 100 - v);
|
|
26
|
+
const clipPath = useMotionTemplate`inset(0 ${uncovered}% 0 0 round 9999px)`;
|
|
27
|
+
const row = /* @__PURE__ */ jsxs(Fragment$1, { children: [label ? /* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "truncate",
|
|
29
|
+
children: label
|
|
30
|
+
}) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */ jsx("span", {
|
|
31
|
+
className: "tabular-nums",
|
|
32
|
+
children: format(current)
|
|
33
|
+
})] });
|
|
34
|
+
return /* @__PURE__ */ jsxs(motion.div, {
|
|
35
|
+
...trackProps,
|
|
36
|
+
animate: reduce ? void 0 : { scale: dragging ? 1.03 : 1 },
|
|
37
|
+
transition: SPRING_PRESS,
|
|
38
|
+
className: cn("relative flex h-12 w-full touch-none select-none overflow-hidden rounded-full bg-muted", options.disabled ? "pointer-events-none opacity-50" : "cursor-grab active:cursor-grabbing", className),
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx("div", {
|
|
41
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-between px-5 font-medium text-foreground text-sm",
|
|
42
|
+
children: row
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsxs(motion.div, {
|
|
45
|
+
className: "absolute inset-0",
|
|
46
|
+
style: { clipPath },
|
|
47
|
+
children: [/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-foreground" }), /* @__PURE__ */ jsx("div", {
|
|
48
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-between px-5 font-medium text-background text-sm",
|
|
49
|
+
children: row
|
|
50
|
+
})]
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
...sliderProps,
|
|
55
|
+
className: "absolute inset-0 touch-none rounded-full outline-none ring-foreground/40 ring-inset focus-visible:ring-4"
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { FluidSlider };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=range-slider-fluid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-fluid.js","names":[],"sources":["../../../src/components/motion/range-slider-fluid.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, useSlider } from \"../../hooks/use-slider\";\nimport { SPRING_GLIDE, SPRING_PRESS } from \"../../lib/ease\";\n\nexport interface FluidSliderProps extends SliderOptions {\n /** Text shown on the left of the track. */\n label?: string;\n /** Formats the value shown on the right. */\n format?: (value: number) => string;\n className?: string;\n}\n\n/**\n * Thumbless slider: the whole pill is the control. The fill glides to the new\n * value behind a rounded liquid cap, and the label reads inverted wherever the\n * fill has covered it.\n */\nexport function FluidSlider({\n label,\n // The value arrives already snapped to the step. Rounding it again would\n // only make the label and the announcement disagree with aria-valuenow.\n format = (v) => `${v}%`,\n className,\n ...options\n}: FluidSliderProps) {\n const reduce = useReducedMotion();\n const { percent, current, dragging, trackProps, sliderProps } = useSlider({\n ...options,\n formatValueText: options.formatValueText ?? format,\n });\n\n const target = useMotionValue(percent);\n useEffect(() => {\n target.set(percent);\n }, [percent, target]);\n const smooth = useSpring(target, SPRING_GLIDE);\n const pos = reduce ? target : smooth;\n // Reveal the fill by clipping a full-width layer rather than animating its\n // width: at 0% the clip is empty, so no hairline of a sub-pixel-wide box is\n // left behind, and the label inside is never scaled or re-laid out.\n const uncovered = useTransform(pos, (v) => 100 - v);\n const clipPath = useMotionTemplate`inset(0 ${uncovered}% 0 0 round 9999px)`;\n\n const row = (\n <>\n {label ? <span className=\"truncate\">{label}</span> : <span />}\n <span className=\"tabular-nums\">{format(current)}</span>\n </>\n );\n\n return (\n <motion.div\n {...trackProps}\n animate={reduce ? undefined : { scale: dragging ? 1.03 : 1 }}\n transition={SPRING_PRESS}\n className={cn(\n \"relative flex h-12 w-full touch-none select-none overflow-hidden rounded-full bg-muted\",\n options.disabled ? \"pointer-events-none opacity-50\" : \"cursor-grab active:cursor-grabbing\",\n className,\n )}\n >\n {/* uncovered label — sits on the muted track */}\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-between px-5 font-medium text-foreground text-sm\">\n {row}\n </div>\n\n {/* fill + the same label, both clipped to the value, so the text inverts\n as the fill covers it and lines up glyph for glyph with the copy\n underneath. The clip's rounded right edge is the liquid cap. */}\n <motion.div className=\"absolute inset-0\" style={{ clipPath }}>\n <div className=\"absolute inset-0 bg-foreground\" />\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-between px-5 font-medium text-background text-sm\">\n {row}\n </div>\n </motion.div>\n\n {/* focusable, keyboard-controlled handle surface. The ring is inset — an\n outset one is clipped away by the track's overflow-hidden. */}\n <button\n type=\"button\"\n {...sliderProps}\n className=\"absolute inset-0 touch-none rounded-full outline-none ring-foreground/40 ring-inset focus-visible:ring-4\"\n />\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAgB,YAAY,EAC1B,OAGA,UAAU,MAAM,GAAG,EAAE,IACrB,WACA,GAAG,WACgB;CACnB,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,SAAS,SAAS,UAAU,YAAY,gBAAgB,UAAU;EACxE,GAAG;EACH,iBAAiB,QAAQ,mBAAmB;CAC9C,CAAC;CAED,MAAM,SAAS,eAAe,OAAO;CACrC,gBAAgB;EACd,OAAO,IAAI,OAAO;CACpB,GAAG,CAAC,SAAS,MAAM,CAAC;CACpB,MAAM,SAAS,UAAU,QAAQ,YAAY;CAK7C,MAAM,YAAY,aAJN,SAAS,SAAS,SAIO,MAAM,MAAM,CAAC;CAClD,MAAM,WAAW,iBAAiB,WAAW,UAAU;CAEvD,MAAM,MACJ,qBAAA,YAAA,EAAA,UAAA,CACG,QAAQ,oBAAC,QAAD;EAAM,WAAU;EAAY,UAAA;CAAY,CAAA,IAAI,oBAAC,QAAD,CAAO,CAAA,GAC5D,oBAAC,QAAD;EAAM,WAAU;EAAgB,UAAA,OAAO,OAAO;CAAQ,CAAA,CACtD,EAAA,CAAA;CAGJ,OACE,qBAAC,OAAO,KAAR;EACE,GAAI;EACJ,SAAS,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW,OAAO,EAAE;EAC3D,YAAY;EACZ,WAAW,GACT,0FACA,QAAQ,WAAW,mCAAmC,sCACtD,SACF;EARF,UAAA;GAWE,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA;GAKL,qBAAC,OAAO,KAAR;IAAY,WAAU;IAAmB,OAAO,EAAE,SAAS;IAA3D,UAAA,CACE,oBAAC,OAAD,EAAK,WAAU,iCAAkC,CAAA,GACjD,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,CACK;;GAIZ,oBAAC,UAAD;IACE,MAAK;IACL,GAAI;IACJ,WAAU;GACX,CAAA;EACS;;AAEhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider-ruler.d.ts
|
|
3
|
+
interface RulerSliderProps extends SliderOptions {
|
|
4
|
+
/** Pixels between two steps. */
|
|
5
|
+
gap?: number;
|
|
6
|
+
/** Label every Nth step; those ticks are drawn tall. */
|
|
7
|
+
majorEvery?: number;
|
|
8
|
+
/** Unit shown next to the value. */
|
|
9
|
+
unit?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ruler slider: the scale scrolls under a fixed needle instead of a handle
|
|
14
|
+
* moving along a track. Flicks carry momentum and settle onto the nearest tick.
|
|
15
|
+
*/
|
|
16
|
+
declare function RulerSlider({ gap, majorEvery, unit, className, ...options }: RulerSliderProps): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { RulerSlider, RulerSliderProps };
|
|
19
|
+
//# sourceMappingURL=range-slider-ruler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-ruler.d.ts","names":[],"sources":["../../../src/components/motion/range-slider-ruler.tsx"],"mappings":";;UAiBiB,yBAAyB;;EAExC;;EAEA;;EAEA;EACA;;;;;;iBAOc,cACd,KACA,YACA,MACA,cACG,WACF,mCAAgB,IAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { snapSliderValue, useSlider } from "../../hooks/use-slider.js";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { animate, motion, useMotionValue, useMotionValueEvent, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/motion/range-slider-ruler.tsx
|
|
8
|
+
const SPRING_SNAP = {
|
|
9
|
+
type: "spring",
|
|
10
|
+
stiffness: 500,
|
|
11
|
+
damping: 40,
|
|
12
|
+
mass: .6
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Ruler slider: the scale scrolls under a fixed needle instead of a handle
|
|
16
|
+
* moving along a track. Flicks carry momentum and settle onto the nearest tick.
|
|
17
|
+
*/
|
|
18
|
+
function RulerSlider({ gap = 14, majorEvery = 5, unit, className, ...options }) {
|
|
19
|
+
const reduce = useReducedMotion();
|
|
20
|
+
const decimals = String(options.step ?? 1).split(".")[1]?.length ?? 0;
|
|
21
|
+
const readout = (value) => value.toFixed(decimals);
|
|
22
|
+
const { current, min, max, step, commit, sliderProps } = useSlider({
|
|
23
|
+
...options,
|
|
24
|
+
formatValueText: options.formatValueText ?? (unit ? (v) => `${readout(v)} ${unit}` : void 0)
|
|
25
|
+
});
|
|
26
|
+
const span = Number(((max - min) / step).toFixed(6));
|
|
27
|
+
const wholeSteps = Math.floor(span);
|
|
28
|
+
const remainder = span - wholeSteps;
|
|
29
|
+
const maxOffset = span * gap;
|
|
30
|
+
const x = useMotionValue(-((current - min) / step) * gap);
|
|
31
|
+
const interacting = useRef(false);
|
|
32
|
+
const holding = useRef(false);
|
|
33
|
+
const gesture = useRef(0);
|
|
34
|
+
const ticks = Array.from({ length: wholeSteps + 1 }, (_, i) => ({
|
|
35
|
+
value: Number((min + i * step).toFixed(6)),
|
|
36
|
+
major: i % majorEvery === 0,
|
|
37
|
+
offset: i * gap
|
|
38
|
+
}));
|
|
39
|
+
if (remainder > 0) ticks.push({
|
|
40
|
+
value: max,
|
|
41
|
+
major: true,
|
|
42
|
+
offset: maxOffset
|
|
43
|
+
});
|
|
44
|
+
const snapToTick = () => {
|
|
45
|
+
const snapped = -((snapSliderValue(min + -x.get() / gap * step, min, max, step) - min) / step) * gap;
|
|
46
|
+
const id = ++gesture.current;
|
|
47
|
+
if (reduce) {
|
|
48
|
+
x.set(snapped);
|
|
49
|
+
interacting.current = false;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
animate(x, snapped, SPRING_SNAP).then(() => {
|
|
53
|
+
if (gesture.current === id) interacting.current = false;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const rootProps = {
|
|
57
|
+
...sliderProps,
|
|
58
|
+
onKeyDown: (event) => {
|
|
59
|
+
x.stop();
|
|
60
|
+
gesture.current++;
|
|
61
|
+
interacting.current = false;
|
|
62
|
+
holding.current = false;
|
|
63
|
+
sliderProps.onKeyDown(event);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (interacting.current) return;
|
|
68
|
+
x.set(-((current - min) / step) * gap);
|
|
69
|
+
}, [
|
|
70
|
+
current,
|
|
71
|
+
min,
|
|
72
|
+
step,
|
|
73
|
+
gap,
|
|
74
|
+
x
|
|
75
|
+
]);
|
|
76
|
+
useMotionValueEvent(x, "change", (v) => {
|
|
77
|
+
if (!interacting.current) return;
|
|
78
|
+
commit(min + -v / gap * step);
|
|
79
|
+
});
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
...rootProps,
|
|
82
|
+
className: cn("relative w-full touch-none select-none overflow-hidden", options.disabled ? "pointer-events-none opacity-50" : "cursor-grab active:cursor-grabbing", "rounded-2xl outline-none ring-foreground/30 focus-visible:ring-4", className),
|
|
83
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
84
|
+
className: "pointer-events-none flex items-baseline justify-center gap-1 pt-1 pb-3",
|
|
85
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
86
|
+
className: "font-semibold text-3xl text-foreground tabular-nums",
|
|
87
|
+
children: readout(current)
|
|
88
|
+
}), unit ? /* @__PURE__ */ jsx("span", {
|
|
89
|
+
className: "text-muted-foreground text-sm",
|
|
90
|
+
children: unit
|
|
91
|
+
}) : null]
|
|
92
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
93
|
+
className: "relative h-12 [mask-image:linear-gradient(to_right,transparent,black_18%,black_82%,transparent)]",
|
|
94
|
+
children: [/* @__PURE__ */ jsx(motion.div, {
|
|
95
|
+
drag: options.disabled ? false : "x",
|
|
96
|
+
dragConstraints: {
|
|
97
|
+
left: -maxOffset,
|
|
98
|
+
right: 0
|
|
99
|
+
},
|
|
100
|
+
dragElastic: .03,
|
|
101
|
+
dragMomentum: !reduce,
|
|
102
|
+
dragTransition: {
|
|
103
|
+
power: .22,
|
|
104
|
+
timeConstant: 320
|
|
105
|
+
},
|
|
106
|
+
onDragStart: () => {
|
|
107
|
+
gesture.current++;
|
|
108
|
+
interacting.current = true;
|
|
109
|
+
holding.current = true;
|
|
110
|
+
},
|
|
111
|
+
onDragTransitionEnd: () => {
|
|
112
|
+
if (!holding.current) snapToTick();
|
|
113
|
+
},
|
|
114
|
+
onDragEnd: () => {
|
|
115
|
+
holding.current = false;
|
|
116
|
+
if (reduce) snapToTick();
|
|
117
|
+
},
|
|
118
|
+
style: {
|
|
119
|
+
x,
|
|
120
|
+
marginLeft: -gap / 2,
|
|
121
|
+
width: maxOffset + gap
|
|
122
|
+
},
|
|
123
|
+
className: "absolute inset-y-0 left-1/2",
|
|
124
|
+
children: ticks.map((tick) => /* @__PURE__ */ jsxs("span", {
|
|
125
|
+
className: "absolute bottom-0 flex -translate-x-1/2 flex-col items-center pb-[18px]",
|
|
126
|
+
style: { left: tick.offset + gap / 2 },
|
|
127
|
+
children: [/* @__PURE__ */ jsx("span", { className: cn("w-px rounded-full", tick.major ? "h-7 bg-foreground/70" : "h-3.5 bg-foreground/45") }), tick.major ? /* @__PURE__ */ jsx("span", {
|
|
128
|
+
className: "absolute bottom-0 text-[10px] text-muted-foreground tabular-nums",
|
|
129
|
+
children: tick.value
|
|
130
|
+
}) : null]
|
|
131
|
+
}, tick.value))
|
|
132
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
133
|
+
className: "pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2",
|
|
134
|
+
children: /* @__PURE__ */ jsx("span", { className: "block h-9 w-[3px] rounded-full bg-foreground" })
|
|
135
|
+
})]
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
export { RulerSlider };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=range-slider-ruler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-ruler.js","names":[],"sources":["../../../src/components/motion/range-slider-ruler.tsx"],"sourcesContent":["\"use client\";\n\nimport { type KeyboardEvent, useEffect, useRef } from \"react\";\nimport {\n animate,\n motion,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, snapSliderValue, useSlider } from \"../../hooks/use-slider\";\n\n// Settle spring for the snap after a flick — quick, no overshoot past the tick.\nconst SPRING_SNAP = { type: \"spring\", stiffness: 500, damping: 40, mass: 0.6 } as const;\n\nexport interface RulerSliderProps extends SliderOptions {\n /** Pixels between two steps. */\n gap?: number;\n /** Label every Nth step; those ticks are drawn tall. */\n majorEvery?: number;\n /** Unit shown next to the value. */\n unit?: string;\n className?: string;\n}\n\n/**\n * Ruler slider: the scale scrolls under a fixed needle instead of a handle\n * moving along a track. Flicks carry momentum and settle onto the nearest tick.\n */\nexport function RulerSlider({\n gap = 14,\n majorEvery = 5,\n unit,\n className,\n ...options\n}: RulerSliderProps) {\n const reduce = useReducedMotion();\n // Decimal places the step implies, so 0.5 reads \"72.5\" and 1 reads \"72\".\n // Fixed width keeps the readout from jittering as the value rolls; tick\n // labels stay trimmed so a whole-number scale is not littered with \".0\".\n // ponytail: reads 0 decimals for an exponential step (1e-7) — no such scale\n // is legible on a ruler anyway, so no parsing beyond this.\n const decimals = String(options.step ?? 1).split(\".\")[1]?.length ?? 0;\n const readout = (value: number) => value.toFixed(decimals);\n\n const { current, min, max, step, commit, sliderProps } = useSlider({\n ...options,\n // \"72.5 kg\" beats a bare \"72.5\" for a screen reader — but a caller who\n // formats the announcement itself outranks the unit.\n formatValueText: options.formatValueText ?? (unit ? (v) => `${readout(v)} ${unit}` : undefined),\n });\n\n // The range need not divide by the step (0–10 by 4). Full ticks stop at the\n // last whole one and max gets a tick of its own, so the scale never runs past\n // the value the slider can actually report.\n const span = Number(((max - min) / step).toFixed(6));\n const wholeSteps = Math.floor(span);\n const remainder = span - wholeSteps;\n const maxOffset = span * gap;\n const x = useMotionValue(-((current - min) / step) * gap);\n // While the pointer drives the strip (or its momentum still runs), x owns the\n // value; outside of that the value owns x.\n const interacting = useRef(false);\n // True only while the pointer is down. It keeps a cancelled momentum's\n // transition end from snapping underneath a fresh grab.\n const holding = useRef(false);\n // A new gesture or key press bumps this, so a snap that resolves late cannot\n // clear interacting underneath an active drag.\n const gesture = useRef(0);\n\n // ponytail: every tick is in the DOM — fine to a few hundred (80 units at\n // step 0.5 is 161). Window to the visible span if a finer step is ever needed.\n // Each tick carries an offset because max sits `remainder` of a step past the\n // last whole tick. Whenever remainder is under 0.5 that point falls inside\n // the previous box, so an appended flex box can never centre on it.\n const ticks = Array.from({ length: wholeSteps + 1 }, (_, i) => ({\n // toFixed trims float dust from fractional steps (0.1 + 0.2 …).\n value: Number((min + i * step).toFixed(6)),\n major: i % majorEvery === 0,\n offset: i * gap,\n }));\n // A tiny remainder puts this label close to the one before it. That is what\n // a scale ending a hair past a step looks like.\n if (remainder > 0) ticks.push({ value: max, major: true, offset: maxOffset });\n\n const snapToTick = () => {\n // The same nearest-tick rule useSlider applies. max counts as a candidate\n // when the step does not divide the range, so a flick near the end does\n // not settle on the last whole step.\n const target = snapSliderValue(min + (-x.get() / gap) * step, min, max, step);\n const snapped = -((target - min) / step) * gap;\n const id = ++gesture.current;\n if (reduce) {\n x.set(snapped);\n interacting.current = false;\n return;\n }\n animate(x, snapped, SPRING_SNAP).then(() => {\n if (gesture.current === id) interacting.current = false;\n });\n };\n\n // A key press takes the scale back from momentum: without this the coasting\n // strip keeps committing its own value and swallows the keyboard input.\n const rootProps = {\n ...sliderProps,\n onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => {\n x.stop();\n gesture.current++;\n interacting.current = false;\n holding.current = false;\n sliderProps.onKeyDown(event);\n },\n };\n\n useEffect(() => {\n if (interacting.current) return;\n x.set(-((current - min) / step) * gap);\n }, [current, min, step, gap, x]);\n\n useMotionValueEvent(x, \"change\", (v) => {\n if (!interacting.current) return;\n commit(min + (-v / gap) * step);\n });\n\n return (\n <div\n {...rootProps}\n className={cn(\n \"relative w-full touch-none select-none overflow-hidden\",\n options.disabled ? \"pointer-events-none opacity-50\" : \"cursor-grab active:cursor-grabbing\",\n \"rounded-2xl outline-none ring-foreground/30 focus-visible:ring-4\",\n className,\n )}\n >\n <div className=\"pointer-events-none flex items-baseline justify-center gap-1 pt-1 pb-3\">\n <span className=\"font-semibold text-3xl text-foreground tabular-nums\">\n {readout(current)}\n </span>\n {unit ? <span className=\"text-muted-foreground text-sm\">{unit}</span> : null}\n </div>\n\n {/* masked, not overlaid with background-coloured gradients — the fade has\n to work on any surface the slider is dropped onto */}\n <div className=\"relative h-12 [mask-image:linear-gradient(to_right,transparent,black_18%,black_82%,transparent)]\">\n {/* strip — dragged directly, so momentum comes from the drag gesture */}\n <motion.div\n drag={options.disabled ? false : \"x\"}\n dragConstraints={{ left: -maxOffset, right: 0 }}\n dragElastic={0.03}\n dragMomentum={!reduce}\n dragTransition={{ power: 0.22, timeConstant: 320 }}\n onDragStart={() => {\n gesture.current++;\n interacting.current = true;\n holding.current = true;\n }}\n // Momentum end when there is momentum, drag end when there is not.\n onDragTransitionEnd={() => {\n if (!holding.current) snapToTick();\n }}\n onDragEnd={() => {\n holding.current = false;\n if (reduce) snapToTick();\n }}\n // The ticks are positioned rather than laid out, so the row needs an\n // explicit width plus half a gap of slop each side to cover the\n // whole drag surface.\n style={{ x, marginLeft: -gap / 2, width: maxOffset + gap }}\n className=\"absolute inset-y-0 left-1/2\"\n >\n {ticks.map((tick) => (\n // pb reserves the label row, so minor ticks need no spacer node\n <span\n key={tick.value}\n className=\"absolute bottom-0 flex -translate-x-1/2 flex-col items-center pb-[18px]\"\n style={{ left: tick.offset + gap / 2 }}\n >\n <span\n className={cn(\n \"w-px rounded-full\",\n // minor ticks at /45 clear the 3:1 non-text floor in both themes\n tick.major ? \"h-7 bg-foreground/70\" : \"h-3.5 bg-foreground/45\",\n )}\n />\n {tick.major ? (\n <span className=\"absolute bottom-0 text-[10px] text-muted-foreground tabular-nums\">\n {tick.value}\n </span>\n ) : null}\n </span>\n ))}\n </motion.div>\n\n {/* needle — the read head the scale moves under */}\n <div className=\"pointer-events-none absolute bottom-5 left-1/2 -translate-x-1/2\">\n <span className=\"block h-9 w-[3px] rounded-full bg-foreground\" />\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAeA,MAAM,cAAc;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;;;;;AAgB7E,SAAgB,YAAY,EAC1B,MAAM,IACN,aAAa,GACb,MACA,WACA,GAAG,WACgB;CACnB,MAAM,SAAS,iBAAiB;CAMhC,MAAM,WAAW,OAAO,QAAQ,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,UAAU;CACpE,MAAM,WAAW,UAAkB,MAAM,QAAQ,QAAQ;CAEzD,MAAM,EAAE,SAAS,KAAK,KAAK,MAAM,QAAQ,gBAAgB,UAAU;EACjE,GAAG;EAGH,iBAAiB,QAAQ,oBAAoB,QAAQ,MAAM,GAAG,QAAQ,CAAC,EAAE,GAAG,SAAS,KAAA;CACvF,CAAC;CAKD,MAAM,OAAO,SAAS,MAAM,OAAO,KAAA,CAAM,QAAQ,CAAC,CAAC;CACnD,MAAM,aAAa,KAAK,MAAM,IAAI;CAClC,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,OAAO;CACzB,MAAM,IAAI,eAAe,GAAG,UAAU,OAAO,QAAQ,GAAG;CAGxD,MAAM,cAAc,OAAO,KAAK;CAGhC,MAAM,UAAU,OAAO,KAAK;CAG5B,MAAM,UAAU,OAAO,CAAC;CAOxB,MAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,aAAa,EAAE,IAAI,GAAG,OAAO;EAE9D,OAAO,QAAQ,MAAM,IAAI,KAAA,CAAM,QAAQ,CAAC,CAAC;EACzC,OAAO,IAAI,eAAe;EAC1B,QAAQ,IAAI;CACd,EAAE;CAGF,IAAI,YAAY,GAAG,MAAM,KAAK;EAAE,OAAO;EAAK,OAAO;EAAM,QAAQ;CAAU,CAAC;CAE5E,MAAM,mBAAmB;EAKvB,MAAM,UAAU,GADD,gBAAgB,MAAO,CAAC,EAAE,IAAI,IAAI,MAAO,MAAM,KAAK,KAAK,IAChD,IAAI,OAAO,QAAQ;EAC3C,MAAM,KAAK,EAAE,QAAQ;EACrB,IAAI,QAAQ;GACV,EAAE,IAAI,OAAO;GACb,YAAY,UAAU;GACtB;EACF;EACA,QAAQ,GAAG,SAAS,WAAW,CAAC,CAAC,WAAW;GAC1C,IAAI,QAAQ,YAAY,IAAI,YAAY,UAAU;EACpD,CAAC;CACH;CAIA,MAAM,YAAY;EAChB,GAAG;EACH,YAAY,UAAyC;GACnD,EAAE,KAAK;GACP,QAAQ;GACR,YAAY,UAAU;GACtB,QAAQ,UAAU;GAClB,YAAY,UAAU,KAAK;EAC7B;CACF;CAEA,gBAAgB;EACd,IAAI,YAAY,SAAS;EACzB,EAAE,IAAI,GAAG,UAAU,OAAO,QAAQ,GAAG;CACvC,GAAG;EAAC;EAAS;EAAK;EAAM;EAAK;CAAC,CAAC;CAE/B,oBAAoB,GAAG,WAAW,MAAM;EACtC,IAAI,CAAC,YAAY,SAAS;EAC1B,OAAO,MAAO,CAAC,IAAI,MAAO,IAAI;CAChC,CAAC;CAED,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GACT,0DACA,QAAQ,WAAW,mCAAmC,sCACtD,oEACA,SACF;EAPF,UAAA,CASE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,QAAQ,OAAO;GACZ,CAAA,GACL,OAAO,oBAAC,QAAD;IAAM,WAAU;IAAiC,UAAA;GAAW,CAAA,IAAI,IACrE;EAIL,CAAA,GAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CAEE,oBAAC,OAAO,KAAR;IACE,MAAM,QAAQ,WAAW,QAAQ;IACjC,iBAAiB;KAAE,MAAM,CAAC;KAAW,OAAO;IAAE;IAC9C,aAAa;IACb,cAAc,CAAC;IACf,gBAAgB;KAAE,OAAO;KAAM,cAAc;IAAI;IACjD,mBAAmB;KACjB,QAAQ;KACR,YAAY,UAAU;KACtB,QAAQ,UAAU;IACpB;IAEA,2BAA2B;KACzB,IAAI,CAAC,QAAQ,SAAS,WAAW;IACnC;IACA,iBAAiB;KACf,QAAQ,UAAU;KAClB,IAAI,QAAQ,WAAW;IACzB;IAIA,OAAO;KAAE;KAAG,YAAY,CAAC,MAAM;KAAG,OAAO,YAAY;IAAI;IACzD,WAAU;IAET,UAAA,MAAM,KAAK,SAEV,qBAAC,QAAD;KAEE,WAAU;KACV,OAAO,EAAE,MAAM,KAAK,SAAS,MAAM,EAAE;KAHvC,UAAA,CAKE,oBAAC,QAAD,EACE,WAAW,GACT,qBAEA,KAAK,QAAQ,yBAAyB,wBACxC,EACD,CAAA,GACA,KAAK,QACJ,oBAAC,QAAD;MAAM,WAAU;MACb,UAAA,KAAK;KACF,CAAA,IACJ,IACA;IAhBC,GAAA,KAAK,KAgBN,CACP;GACS,CAAA,GAGZ,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,QAAD,EAAM,WAAU,+CAAgD,CAAA;GAC7D,CAAA,CACF;EACF,CAAA,CAAA;;AAET"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider-wave.d.ts
|
|
3
|
+
interface WaveSliderProps extends SliderOptions {
|
|
4
|
+
/** Number of bars drawn across the track. */
|
|
5
|
+
bars?: number;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Equalizer slider: bars rise into a crest around the handle position and fall
|
|
10
|
+
* back as it passes, so the value reads as a travelling wave. Bars up to the
|
|
11
|
+
* value are filled, the rest stay muted.
|
|
12
|
+
*/
|
|
13
|
+
declare function WaveSlider({ bars, className, ...options }: WaveSliderProps): import("react").JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { WaveSlider, WaveSliderProps };
|
|
16
|
+
//# sourceMappingURL=range-slider-wave.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-wave.d.ts","names":[],"sources":["../../../src/components/motion/range-slider-wave.tsx"],"mappings":";;UAeiB,wBAAwB;;EAEvC;EACA;;;;;;;iBAQc,aAAa,MAAa,cAAc,WAAW,kCAAe,IAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSlider } from "../../hooks/use-slider.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { motion, useReducedMotion } from "motion/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/motion/range-slider-wave.tsx
|
|
8
|
+
const SPRING_BAR = {
|
|
9
|
+
type: "spring",
|
|
10
|
+
stiffness: 420,
|
|
11
|
+
damping: 20,
|
|
12
|
+
mass: .5
|
|
13
|
+
};
|
|
14
|
+
/** Bar count that reads as a wave without turning into a stripe pattern. */
|
|
15
|
+
const BARS = 32;
|
|
16
|
+
/** Width of the crest in bars — bigger spreads the bell wider. */
|
|
17
|
+
const SPREAD = 2.6;
|
|
18
|
+
/**
|
|
19
|
+
* Equalizer slider: bars rise into a crest around the handle position and fall
|
|
20
|
+
* back as it passes, so the value reads as a travelling wave. Bars up to the
|
|
21
|
+
* value are filled, the rest stay muted.
|
|
22
|
+
*/
|
|
23
|
+
function WaveSlider({ bars = BARS, className, ...options }) {
|
|
24
|
+
const reduce = useReducedMotion();
|
|
25
|
+
const { percent, dragging, trackProps, sliderProps } = useSlider(options);
|
|
26
|
+
const keys = useMemo(() => Array.from({ length: bars }, (_, i) => `bar-${i}`), [bars]);
|
|
27
|
+
const head = percent / 100 * (bars - 1);
|
|
28
|
+
const lanes = keys.map((key, i) => {
|
|
29
|
+
const distance = Math.abs(i - head);
|
|
30
|
+
return {
|
|
31
|
+
key,
|
|
32
|
+
distance,
|
|
33
|
+
crest: Math.exp(-(distance ** 2) / (2 * SPREAD ** 2)),
|
|
34
|
+
filled: i <= Math.round(head)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
...trackProps,
|
|
39
|
+
className: cn("relative flex h-20 w-full touch-none select-none items-center justify-between gap-1", options.disabled ? "pointer-events-none opacity-50" : "cursor-grab active:cursor-grabbing", className),
|
|
40
|
+
children: [lanes.map((lane) => /* @__PURE__ */ jsx(motion.span, {
|
|
41
|
+
className: cn("h-14 flex-1 origin-center rounded-full", lane.filled ? "bg-foreground" : "bg-foreground/45"),
|
|
42
|
+
animate: { scaleY: reduce ? .4 : .22 + lane.crest * (dragging ? .78 : .6) },
|
|
43
|
+
transition: reduce ? { duration: 0 } : {
|
|
44
|
+
...SPRING_BAR,
|
|
45
|
+
delay: Math.min(lane.distance * .012, .12)
|
|
46
|
+
}
|
|
47
|
+
}, lane.key)), /* @__PURE__ */ jsx("button", {
|
|
48
|
+
type: "button",
|
|
49
|
+
...sliderProps,
|
|
50
|
+
className: "absolute inset-0 touch-none rounded-xl outline-none ring-foreground/30 focus-visible:ring-4"
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { WaveSlider };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=range-slider-wave.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-wave.js","names":[],"sources":["../../../src/components/motion/range-slider-wave.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, useSlider } from \"../../hooks/use-slider\";\n\n// Per-bar spring: soft enough that the crest wobbles as it travels.\nconst SPRING_BAR = { type: \"spring\", stiffness: 420, damping: 20, mass: 0.5 } as const;\n/** Bar count that reads as a wave without turning into a stripe pattern. */\nconst BARS = 32;\n/** Width of the crest in bars — bigger spreads the bell wider. */\nconst SPREAD = 2.6;\n\nexport interface WaveSliderProps extends SliderOptions {\n /** Number of bars drawn across the track. */\n bars?: number;\n className?: string;\n}\n\n/**\n * Equalizer slider: bars rise into a crest around the handle position and fall\n * back as it passes, so the value reads as a travelling wave. Bars up to the\n * value are filled, the rest stay muted.\n */\nexport function WaveSlider({ bars = BARS, className, ...options }: WaveSliderProps) {\n const reduce = useReducedMotion();\n const { percent, dragging, trackProps, sliderProps } = useSlider(options);\n\n // Keys only change when the bar count does — the list never reorders.\n const keys = useMemo(() => Array.from({ length: bars }, (_, i) => `bar-${i}`), [bars]);\n\n const head = (percent / 100) * (bars - 1);\n const lanes = keys.map((key, i) => {\n const distance = Math.abs(i - head);\n return {\n key,\n distance,\n // Gaussian crest centred on the handle.\n crest: Math.exp(-(distance ** 2) / (2 * SPREAD ** 2)),\n filled: i <= Math.round(head),\n };\n });\n\n return (\n <div\n {...trackProps}\n className={cn(\n \"relative flex h-20 w-full touch-none select-none items-center justify-between gap-1\",\n options.disabled ? \"pointer-events-none opacity-50\" : \"cursor-grab active:cursor-grabbing\",\n className,\n )}\n >\n {lanes.map((lane) => (\n <motion.span\n key={lane.key}\n className={cn(\n \"h-14 flex-1 origin-center rounded-full\",\n // /45 keeps the unfilled track above the 3:1 non-text contrast\n // floor in both themes (measured 4.16 dark / 3.13 light)\n lane.filled ? \"bg-foreground\" : \"bg-foreground/45\",\n )}\n animate={{\n scaleY: reduce ? 0.4 : 0.22 + lane.crest * (dragging ? 0.78 : 0.6),\n }}\n transition={\n reduce\n ? { duration: 0 }\n : { ...SPRING_BAR, delay: Math.min(lane.distance * 0.012, 0.12) }\n }\n />\n ))}\n\n <button\n type=\"button\"\n {...sliderProps}\n className=\"absolute inset-0 touch-none rounded-xl outline-none ring-foreground/30 focus-visible:ring-4\"\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AASA,MAAM,aAAa;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;;AAE5E,MAAM,OAAO;;AAEb,MAAM,SAAS;;;;;;AAaf,SAAgB,WAAW,EAAE,OAAO,MAAM,WAAW,GAAG,WAA4B;CAClF,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,SAAS,UAAU,YAAY,gBAAgB,UAAU,OAAO;CAGxE,MAAM,OAAO,cAAc,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC;CAErF,MAAM,OAAQ,UAAU,OAAQ,OAAO;CACvC,MAAM,QAAQ,KAAK,KAAK,KAAK,MAAM;EACjC,MAAM,WAAW,KAAK,IAAI,IAAI,IAAI;EAClC,OAAO;GACL;GACA;GAEA,OAAO,KAAK,IAAI,EAAE,YAAY,MAAM,IAAI,UAAU,EAAE;GACpD,QAAQ,KAAK,KAAK,MAAM,IAAI;EAC9B;CACF,CAAC;CAED,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GACT,uFACA,QAAQ,WAAW,mCAAmC,sCACtD,SACF;EANF,UAAA,CAQG,MAAM,KAAK,SACV,oBAAC,OAAO,MAAR;GAEE,WAAW,GACT,0CAGA,KAAK,SAAS,kBAAkB,kBAClC;GACA,SAAS,EACP,QAAQ,SAAS,KAAM,MAAO,KAAK,SAAS,WAAW,MAAO,IAChE;GACA,YACE,SACI,EAAE,UAAU,EAAE,IACd;IAAE,GAAG;IAAY,OAAO,KAAK,IAAI,KAAK,WAAW,MAAO,GAAI;GAAE;EAErE,GAfM,KAAK,GAeX,CACF,GAED,oBAAC,UAAD;GACE,MAAK;GACL,GAAI;GACJ,WAAU;EACX,CAAA,CACE;;AAET"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider.d.ts
|
|
3
|
+
interface RangeSliderProps extends SliderOptions {
|
|
4
|
+
/** Render a tick dot at each step. */
|
|
5
|
+
showTicks?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function RangeSlider({ showTicks, className, ...options }: RangeSliderProps): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RangeSlider, RangeSliderProps };
|
|
11
|
+
//# sourceMappingURL=range-slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider.d.ts","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"mappings":";;UAmBiB,yBAAyB;;EAExC;EACA;;iBAGc,cAAc,WAAkB,cAAc,WAAW,mCAAgB,IAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSlider } from "../../hooks/use-slider.js";
|
|
3
|
+
import { SPRING_GLIDE } from "../../lib/ease.js";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/motion/range-slider.tsx
|
|
9
|
+
const SPRING_BOUNCY = {
|
|
10
|
+
type: "spring",
|
|
11
|
+
stiffness: 500,
|
|
12
|
+
damping: 14,
|
|
13
|
+
mass: .7
|
|
14
|
+
};
|
|
15
|
+
function RangeSlider({ showTicks = true, className, ...options }) {
|
|
16
|
+
const reduce = useReducedMotion();
|
|
17
|
+
const { percent, dragging, min, max, step, trackProps, sliderProps } = useSlider(options);
|
|
18
|
+
const target = useMotionValue(percent);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
target.set(percent);
|
|
21
|
+
}, [percent, target]);
|
|
22
|
+
const smooth = useSpring(target, SPRING_GLIDE);
|
|
23
|
+
const pos = reduce ? target : smooth;
|
|
24
|
+
const left = useMotionTemplate`${pos}%`;
|
|
25
|
+
const thumbX = useTransform(pos, (p) => `${-p}%`);
|
|
26
|
+
const steps = Math.floor(Number(((max - min) / step).toFixed(6)));
|
|
27
|
+
const ticks = showTicks && steps > 0 && steps <= 50 ? Array.from({ length: steps + 1 }, (_, i) => Number((min + i * step).toFixed(6))) : [];
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
...trackProps,
|
|
30
|
+
className: cn("relative flex h-10 w-full touch-none select-none items-center overflow-hidden rounded-lg bg-muted", options.disabled ? "pointer-events-none opacity-50" : "cursor-grab active:cursor-grabbing", className),
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
33
|
+
className: "absolute inset-y-0 left-0 bg-foreground/15",
|
|
34
|
+
style: { width: left }
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "pointer-events-none absolute inset-x-[3px] inset-y-0",
|
|
38
|
+
children: ticks.map((t) => {
|
|
39
|
+
const tp = (t - min) / (max - min) * 100;
|
|
40
|
+
return /* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground/25",
|
|
42
|
+
style: { left: `${tp}%` }
|
|
43
|
+
}, t);
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
47
|
+
...sliderProps,
|
|
48
|
+
animate: reduce ? void 0 : { scaleY: dragging ? 1.35 : 1 },
|
|
49
|
+
transition: SPRING_BOUNCY,
|
|
50
|
+
className: "absolute top-1/2 h-5 w-1.5 rounded-sm bg-foreground shadow-sm outline-none ring-foreground/30 ring-inset focus-visible:ring-4",
|
|
51
|
+
style: {
|
|
52
|
+
left,
|
|
53
|
+
x: thumbX,
|
|
54
|
+
y: "-50%"
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { RangeSlider };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=range-slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider.js","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, useSlider } from \"../../hooks/use-slider\";\nimport { SPRING_GLIDE } from \"../../lib/ease\";\n\n// Bouncy grab feedback for the thumb scale only.\nconst SPRING_BOUNCY = { type: \"spring\", stiffness: 500, damping: 14, mass: 0.7 } as const;\n\nexport interface RangeSliderProps extends SliderOptions {\n /** Render a tick dot at each step. */\n showTicks?: boolean;\n className?: string;\n}\n\nexport function RangeSlider({ showTicks = true, className, ...options }: RangeSliderProps) {\n const reduce = useReducedMotion();\n const { percent, dragging, min, max, step, trackProps, sliderProps } = useSlider(options);\n\n // Spring-smoothed position drives both the thumb and the fill.\n const target = useMotionValue(percent);\n useEffect(() => {\n target.set(percent);\n }, [percent, target]);\n const smooth = useSpring(target, SPRING_GLIDE);\n const pos = reduce ? target : smooth;\n const left = useMotionTemplate`${pos}%`;\n // Self-offset the thumb from 0% (flush left) to -100% (flush right) of its\n // own width so it stays fully inside the track at both ends — no clip, no gap.\n const thumbX = useTransform(pos, (p) => `${-p}%`);\n\n // Floor rather than round, so a range the step does not divide (0 to 10 by 4)\n // stops its dots at the last whole step instead of drawing one past max.\n // toFixed comes first because 0.3/0.1 is 2.9999999999999996, which would\n // floor to 2 and drop the last dot.\n const steps = Math.floor(Number(((max - min) / step).toFixed(6)));\n const ticks =\n showTicks && steps > 0 && steps <= 50\n ? Array.from({ length: steps + 1 }, (_, i) => Number((min + i * step).toFixed(6)))\n : [];\n\n return (\n <div\n {...trackProps}\n className={cn(\n \"relative flex h-10 w-full touch-none select-none items-center overflow-hidden rounded-lg bg-muted\",\n options.disabled ? \"pointer-events-none opacity-50\" : \"cursor-grab active:cursor-grabbing\",\n className,\n )}\n >\n {/* fill — runs from the left edge to the thumb, consistent tone */}\n <motion.div className=\"absolute inset-y-0 left-0 bg-foreground/15\" style={{ width: left }} />\n\n {/* Ticks, inset by half the thumb's width. That inset is the span the\n thumb's own centre travels, so a dot sits where the thumb lands. */}\n <div className=\"pointer-events-none absolute inset-x-[3px] inset-y-0\">\n {ticks.map((t) => {\n const tp = ((t - min) / (max - min)) * 100;\n return (\n <span\n key={t}\n className=\"absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground/25\"\n style={{ left: `${tp}%` }}\n />\n );\n })}\n </div>\n\n {/* vertical bar thumb — contained at both ends via thumbX */}\n <motion.div\n {...sliderProps}\n animate={reduce ? undefined : { scaleY: dragging ? 1.35 : 1 }}\n transition={SPRING_BOUNCY}\n className=\"absolute top-1/2 h-5 w-1.5 rounded-sm bg-foreground shadow-sm outline-none ring-foreground/30 ring-inset focus-visible:ring-4\"\n style={{ left, x: thumbX, y: \"-50%\" }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAiBA,MAAM,gBAAgB;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;AAQ/E,SAAgB,YAAY,EAAE,YAAY,MAAM,WAAW,GAAG,WAA6B;CACzF,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,SAAS,UAAU,KAAK,KAAK,MAAM,YAAY,gBAAgB,UAAU,OAAO;CAGxF,MAAM,SAAS,eAAe,OAAO;CACrC,gBAAgB;EACd,OAAO,IAAI,OAAO;CACpB,GAAG,CAAC,SAAS,MAAM,CAAC;CACpB,MAAM,SAAS,UAAU,QAAQ,YAAY;CAC7C,MAAM,MAAM,SAAS,SAAS;CAC9B,MAAM,OAAO,iBAAiB,GAAG,IAAI;CAGrC,MAAM,SAAS,aAAa,MAAM,MAAM,GAAG,CAAC,EAAE,EAAE;CAMhD,MAAM,QAAQ,KAAK,MAAM,SAAS,MAAM,OAAO,KAAA,CAAM,QAAQ,CAAC,CAAC,CAAC;CAChE,MAAM,QACJ,aAAa,QAAQ,KAAK,SAAS,KAC/B,MAAM,KAAK,EAAE,QAAQ,QAAQ,EAAE,IAAI,GAAG,MAAM,QAAQ,MAAM,IAAI,KAAA,CAAM,QAAQ,CAAC,CAAC,CAAC,IAC/E,CAAC;CAEP,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GACT,qGACA,QAAQ,WAAW,mCAAmC,sCACtD,SACF;EANF,UAAA;GASE,oBAAC,OAAO,KAAR;IAAY,WAAU;IAA6C,OAAO,EAAE,OAAO,KAAK;GAAI,CAAA;GAI5F,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,MAAM,KAAK,MAAM;KAChB,MAAM,MAAO,IAAI,QAAQ,MAAM,OAAQ;KACvC,OACE,oBAAC,QAAD;MAEE,WAAU;MACV,OAAO,EAAE,MAAM,GAAG,GAAG,GAAG;KACzB,GAHM,CAGN;IAEL,CAAC;GACE,CAAA;GAGL,oBAAC,OAAO,KAAR;IACE,GAAI;IACJ,SAAS,SAAS,KAAA,IAAY,EAAE,QAAQ,WAAW,OAAO,EAAE;IAC5D,YAAY;IACZ,WAAU;IACV,OAAO;KAAE;KAAM,GAAG;KAAQ,GAAG;IAAO;GACrC,CAAA;EACE;;AAET"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MotionValue } from "motion/react";
|
|
2
|
+
//#region src/components/motion/scroll-progress.d.ts
|
|
3
|
+
type CommonProps = {
|
|
4
|
+
/** Override the scroll source. Defaults to the page via useSmoothScroll. */
|
|
5
|
+
progress?: MotionValue<number>;
|
|
6
|
+
/** Spring-smooth the value. Disabled automatically under reduced motion. */
|
|
7
|
+
spring?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
interface ScrollProgressBarProps extends CommonProps {
|
|
11
|
+
variant?: "bar";
|
|
12
|
+
position?: "top" | "bottom";
|
|
13
|
+
/** Bar thickness in px. */
|
|
14
|
+
height?: number;
|
|
15
|
+
/** Position the bar with `fixed` (page) or `absolute` (embedded). */
|
|
16
|
+
fixed?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface ScrollProgressCircleProps extends CommonProps {
|
|
19
|
+
variant: "circle";
|
|
20
|
+
/** Diameter in px. */
|
|
21
|
+
size?: number;
|
|
22
|
+
/** Stroke width in px. */
|
|
23
|
+
thickness?: number;
|
|
24
|
+
}
|
|
25
|
+
type ScrollProgressProps = ScrollProgressBarProps | ScrollProgressCircleProps;
|
|
26
|
+
declare function ScrollProgress(props: ScrollProgressProps): import("react").JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ScrollProgress, ScrollProgressBarProps, ScrollProgressCircleProps, ScrollProgressProps };
|
|
29
|
+
//# sourceMappingURL=scroll-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-progress.d.ts","names":[],"sources":["../../../src/components/motion/scroll-progress.tsx"],"mappings":";;KAWK;;EAEH,WAAW;;EAEX;EACA;;UAGe,+BAA+B;EAC9C;EACA;;EAEA;;EAEA;;UAGe,kCAAkC;EACjD;;EAEA;;EAEA;;KAGU,sBAAsB,yBAAyB;iBAU3C,eAAe,OAAO,sCAAmB,IAAA"}
|