@kumix/ui 0.3.13 → 0.3.14
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 +2 -2
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-activity/index.js.map +1 -1
- package/dist/components/agents/agent-code.d.ts.map +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/agent-code.js.map +1 -1
- package/dist/components/agents/agent-disclosure.js +1 -1
- package/dist/components/agents/agent-disclosure.js.map +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +1 -1
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/chat-app.js +1 -1
- package/dist/components/agents/chat-app.js.map +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/code-block.js.map +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/file-diff.js.map +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/image-generation.js.map +1 -1
- package/dist/components/agents/loading-states/agent-progress.js +1 -1
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -1
- package/dist/components/agents/message-bubble.js +1 -1
- package/dist/components/agents/message-bubble.js.map +1 -1
- package/dist/components/agents/message-scroller.js +1 -1
- package/dist/components/agents/message-scroller.js.map +1 -1
- package/dist/components/agents/message.js +1 -1
- package/dist/components/agents/message.js.map +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/streaming-response.js.map +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/todo-list.js.map +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/tool-result.js.map +1 -1
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/adaptive-stepper.js.map +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-number.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/metallic.js +1 -1
- package/dist/components/motion/button/metallic.js.map +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/card-folder.js.map +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/content.js.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -1
- package/dist/components/motion/combobox/context.js.map +1 -1
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/list.js.map +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/command-palette.js +1 -1
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/context-menu.js.map +1 -1
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/cylinder-carousel.js.map +1 -1
- package/dist/components/motion/digit-swap.js +1 -1
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/dock.js.map +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/dynamic-island.js +1 -1
- package/dist/components/motion/dynamic-island.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +1 -1
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts.map +1 -1
- package/dist/components/motion/expandable-control.js +1 -1
- package/dist/components/motion/expandable-control.js.map +1 -1
- package/dist/components/motion/expandable-tabs.js +1 -1
- package/dist/components/motion/expandable-tabs.js.map +1 -1
- package/dist/components/motion/expanding-arrow-button.js +1 -1
- package/dist/components/motion/expanding-arrow-button.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-tree.js.map +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/file-upload.js.map +1 -1
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/hold-action-button.js.map +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/infinite-masonry.js.map +1 -1
- package/dist/components/motion/input.d.ts.map +1 -1
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/input.js.map +1 -1
- package/dist/components/motion/liquid.js +1 -1
- package/dist/components/motion/liquid.js.map +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/magnetic.js.map +1 -1
- package/dist/components/motion/marquee.d.ts.map +1 -1
- package/dist/components/motion/marquee.js +1 -1
- package/dist/components/motion/marquee.js.map +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/morphing-tabs.js.map +1 -1
- package/dist/components/motion/multi-select/content.js +1 -1
- package/dist/components/motion/multi-select/content.js.map +1 -1
- package/dist/components/motion/multi-select/context.js +1 -1
- package/dist/components/motion/multi-select/context.js.map +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/list.js.map +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/multi-select/trigger.js.map +1 -1
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
- package/dist/components/motion/not-found/magnetic.js +1 -1
- package/dist/components/motion/not-found/magnetic.js.map +1 -1
- package/dist/components/motion/not-found/shared.js +1 -1
- package/dist/components/motion/not-found/shared.js.map +1 -1
- package/dist/components/motion/not-found/spotlight.js +1 -1
- package/dist/components/motion/not-found/spotlight.js.map +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/notification-stack.js.map +1 -1
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/otp-input.js +1 -1
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/overflow-actions.js.map +1 -1
- package/dist/components/motion/parallax.d.ts.map +1 -1
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.js +1 -1
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/preview-rail.js +1 -1
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +1 -1
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-bubble.js.map +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-fluid.js.map +1 -1
- package/dist/components/motion/range-slider-inline.d.ts +18 -0
- package/dist/components/motion/range-slider-inline.d.ts.map +1 -0
- package/dist/components/motion/range-slider-inline.js +267 -0
- package/dist/components/motion/range-slider-inline.js.map +1 -0
- package/dist/components/motion/range-slider-ruler.js +1 -1
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.js +1 -1
- package/dist/components/motion/range-slider-wave.js.map +1 -1
- package/dist/components/motion/range-slider.d.ts.map +1 -1
- package/dist/components/motion/range-slider.js +27 -11
- package/dist/components/motion/range-slider.js.map +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-progress.js.map +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/scroll-reveal.js.map +1 -1
- package/dist/components/motion/scroll-to.js +1 -1
- package/dist/components/motion/scroll-to.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +1 -1
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/signup-form.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/swipeable-list.js +1 -1
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/switch.d.ts.map +1 -1
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/switch.js.map +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
- package/dist/components/motion/table/skeleton-rows.js +1 -1
- package/dist/components/motion/table/skeleton-rows.js.map +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/table/table-menu.js.map +1 -1
- package/dist/components/motion/tabs.js +1 -1
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-reveal.js.map +1 -1
- package/dist/components/motion/text-scramble.d.ts.map +1 -1
- package/dist/components/motion/text-scramble.js +1 -1
- package/dist/components/motion/text-scramble.js.map +1 -1
- package/dist/components/motion/text-shimmer.js +1 -1
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/theme-toggle.js.map +1 -1
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tilt-card.js.map +1 -1
- package/dist/components/motion/tooltip.js +1 -1
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/motion/wheel-picker.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.d.ts.map +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/alert.js.map +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/badge.d.ts.map +1 -1
- package/dist/components/reui/badge.js +1 -1
- package/dist/components/reui/badge.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +1 -1
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +1 -1
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +1 -1
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader.js +1 -1
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.js +1 -1
- package/dist/components/reui/code-block/code-block.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +1 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -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 +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +2 -2
- package/dist/components/reui/filters/filters-builder.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-chip.js.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +2 -2
- package/dist/components/reui/filters/filters-editors.js.map +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/filters/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +2 -2
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.js +1 -1
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-stack.js +1 -1
- package/dist/components/reui/icon-stack.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +1 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/rating.d.ts.map +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/rating.js.map +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/sortable.js +1 -1
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/stepper.d.ts.map +1 -1
- package/dist/components/reui/stepper.js +1 -1
- package/dist/components/reui/stepper.js.map +1 -1
- package/dist/components/reui/timeline.d.ts.map +1 -1
- package/dist/components/reui/timeline.js +1 -1
- package/dist/components/reui/timeline.js.map +1 -1
- package/dist/components/reui/tree.d.ts.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/reui/tree.js.map +1 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/accordion.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.d.ts.map +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -1
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/attachment.js.map +1 -1
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/bubble.js.map +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button-group.js.map +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/context-menu.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.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +1 -1
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-group.js.map +1 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/kbd.js.map +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/marker.d.ts.map +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/marker.js.map +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/message-scroller.js.map +1 -1
- package/dist/components/ui/message.d.ts.map +1 -1
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/message.js.map +1 -1
- package/dist/components/ui/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +1 -1
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/separator.js.map +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 +2 -2
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toggle-group.js +1 -1
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/package.json +8 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
3
3
|
import { createContext, useCallback, useContext, useId, useMemo, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { MotionConfig, motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/radio.tsx
|
|
@@ -1 +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 {
|
|
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,eAAe,IACf,eACA,UACA,WACA,cAAc,cACI;CAClB,MAAM,CAAC,UAAU,eAAe,SAAS,YAAY;CACrD,MAAM,WAAW,MAAM;CACvB,MAAM,SAAS,iBAAiB;CAChC,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,UAAU,aAAa,QAAQ;CACrC,MAAM,WAAW,aACd,SAAiB;EAChB,IAAI,CAAC,YAAY,YAAY,IAAI;EACjC,gBAAgB,IAAI;CACtB,GACA,CAAC,YAAY,aAAa,CAC5B;CACA,MAAM,eAAe,eACZ;EAAE,OAAO;EAAS;EAAU;CAAS,IAC5C;EAAC;EAAS;EAAU;CAAQ,CAC9B;CAEA,OACE,oBAAC,cAAD;EAAc,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACnD,UAAA,oBAAC,SAAS,UAAV;GAAmB,OAAO;GACxB,UAAA,oBAAC,OAAD;IACE,MAAK;IACL,WAAW,GACT,cACA,gBAAgB,aAAa,aAAa,sBAC1C,SACF;IAEC;GACE,CAAA;EACY,CAAA;CACP,CAAA;AAElB;AAUA,SAAgB,eAAe,EAC7B,OACA,OACA,UACA,WACA,IAAI,UACkB;CACtB,MAAM,EAAE,OAAO,YAAY,UAAU,aAAa,cAAc;CAChE,MAAM,SAAS,MAAM;CACrB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,eAAe;CAEhC,OACE,qBAAC,SAAD;EACE,SAAS;EACT,WAAW,GACT,kCACA,WAAW,uBAAuB,kBAClC,SACF;EANF,UAAA,CAQE,oBAAC,OAAO,QAAR;GACM;GACJ,MAAK;GACL,MAAK;GACL,gBAAc;GACJ;GACV,eAAe,CAAC,YAAY,SAAS,KAAK;GAC1C,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;GACzD,YAAY;GACZ,cAAY,WAAW,YAAY;GACnC,WAAW,GACT,uIACA,iHACA,mDACA,WAAW,mBAAmB,0DAChC;GAEC,UAAA,WACC,oBAAC,OAAO,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"}
|
|
@@ -3,7 +3,7 @@ import { TOUCH_GESTURE_CLASS } from "../../lib/touch.js";
|
|
|
3
3
|
import { useSlider } from "../../hooks/use-slider.js";
|
|
4
4
|
import { SPRING_GLIDE, SPRING_PANEL, SPRING_PRESS } from "../../lib/ease.js";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform, useVelocity } from "motion/react";
|
|
9
9
|
//#region src/components/motion/range-slider-bubble.tsx
|
|
@@ -1 +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 {
|
|
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\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\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 rounded-full bg-muted\",\n TOUCH_GESTURE_CLASS,\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":";;;;;;;;;AAoBA,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,IA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ACF,CAAA;AAET"}
|
|
@@ -3,7 +3,7 @@ import { TOUCH_GESTURE_CLASS } from "../../lib/touch.js";
|
|
|
3
3
|
import { useSlider } from "../../hooks/use-slider.js";
|
|
4
4
|
import { SPRING_GLIDE, SPRING_PRESS } from "../../lib/ease.js";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
9
9
|
//#region src/components/motion/range-slider-fluid.tsx
|
|
@@ -1 +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 {
|
|
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\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\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 overflow-hidden rounded-full bg-muted\",\n TOUCH_GESTURE_CLASS,\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":";;;;;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|
+
import { SliderOptions } from "../../hooks/use-slider.js";
|
|
2
|
+
//#region src/components/motion/range-slider-inline.d.ts
|
|
3
|
+
export interface InlineSliderProps extends SliderOptions {
|
|
4
|
+
/** Rounds snap-stop values. While dragging, the readout keeps this step's decimal precision. */
|
|
5
|
+
step?: number;
|
|
6
|
+
/** Compact label inside the left edge of the track. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Formats the inline value without changing its precision. */
|
|
9
|
+
format?: (value: number) => string;
|
|
10
|
+
/** Show markers for the ten evenly spaced snap stops, except where they overlap inline text. */
|
|
11
|
+
showTicks?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** An always-visible inline slider with an inset fill and a thumb that parts
|
|
15
|
+
* around its labels, keeping their text readable as the handle passes them. */
|
|
16
|
+
export declare function InlineSlider({ label, format, showTicks, className, ...options }: InlineSliderProps): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=range-slider-inline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-inline.d.ts","names":[],"sources":["../../../src/components/motion/range-slider-inline.tsx"],"mappings":";;iBA2CiB,0BAA0B;;EAEzC;;EAEA;;EAEA,UAAU;;EAEV;EACA;;;;wBAKc,eACd,OACA,QACA,WACA,cACG,WACF,oCAAiB,IAAA"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { TOUCH_GESTURE_CLASS, capturePointer, releasePointer } from "../../lib/touch.js";
|
|
3
|
+
import { snapSliderValue, useSlider } from "../../hooks/use-slider.js";
|
|
4
|
+
import { SPRING_GLIDE } from "../../lib/ease.js";
|
|
5
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
|
|
9
|
+
//#region src/components/motion/range-slider-inline.tsx
|
|
10
|
+
const STOP_COUNT = 10;
|
|
11
|
+
const HANDLE_START = 8;
|
|
12
|
+
const HANDLE_END_INSET = 12;
|
|
13
|
+
const TEXT_INSET = 20;
|
|
14
|
+
const SPRING_BOUNCY = {
|
|
15
|
+
type: "spring",
|
|
16
|
+
stiffness: 500,
|
|
17
|
+
damping: 14,
|
|
18
|
+
mass: .7
|
|
19
|
+
};
|
|
20
|
+
function mapBetweenStops(stops, point, from, to) {
|
|
21
|
+
const upperIndex = stops.findIndex((stop) => stop[from] >= point);
|
|
22
|
+
const upper = stops[upperIndex < 0 ? stops.length - 1 : upperIndex];
|
|
23
|
+
const lower = stops[Math.max(0, upperIndex - 1)];
|
|
24
|
+
if (lower[from] === upper[from]) return upper[to];
|
|
25
|
+
return lower[to] + (point - lower[from]) / (upper[from] - lower[from]) * (upper[to] - lower[to]);
|
|
26
|
+
}
|
|
27
|
+
function nearestStop(stops, x) {
|
|
28
|
+
return stops.reduce((nearest, stop) => Math.abs(stop.x - x) < Math.abs(nearest.x - x) ? stop : nearest);
|
|
29
|
+
}
|
|
30
|
+
/** An always-visible inline slider with an inset fill and a thumb that parts
|
|
31
|
+
* around its labels, keeping their text readable as the handle passes them. */
|
|
32
|
+
function InlineSlider({ label, format = String, showTicks = true, className, ...options }) {
|
|
33
|
+
const reduce = useReducedMotion();
|
|
34
|
+
const step = options.step && options.step > 0 ? options.step : 1;
|
|
35
|
+
const precision = step.toFixed(6).replace(/0+$/, "").split(".")[1]?.length ?? 0;
|
|
36
|
+
const { current, min, max, commit, trackProps, sliderProps } = useSlider({
|
|
37
|
+
...options,
|
|
38
|
+
step: 10 ** -precision,
|
|
39
|
+
"aria-label": options["aria-label"] ?? label,
|
|
40
|
+
formatValueText: options.formatValueText ?? format
|
|
41
|
+
});
|
|
42
|
+
const labelRef = useRef(null);
|
|
43
|
+
const readoutRef = useRef(null);
|
|
44
|
+
const [geometry, setGeometry] = useState({
|
|
45
|
+
width: 292,
|
|
46
|
+
labelWidth: 22,
|
|
47
|
+
readoutWidth: 24
|
|
48
|
+
});
|
|
49
|
+
const [dragging, setDragging] = useState(false);
|
|
50
|
+
const dragFrame = useRef(null);
|
|
51
|
+
const pendingDragValue = useRef(null);
|
|
52
|
+
const gesture = useRef(null);
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
const track = trackProps.ref.current;
|
|
55
|
+
const labelElement = labelRef.current;
|
|
56
|
+
const readout = readoutRef.current;
|
|
57
|
+
if (!track || !labelElement || !readout) return;
|
|
58
|
+
const measure = () => {
|
|
59
|
+
const width = track.getBoundingClientRect().width;
|
|
60
|
+
if (!width) return;
|
|
61
|
+
const next = {
|
|
62
|
+
width,
|
|
63
|
+
labelWidth: labelElement.getBoundingClientRect().width,
|
|
64
|
+
readoutWidth: readout.getBoundingClientRect().width
|
|
65
|
+
};
|
|
66
|
+
setGeometry((previous) => previous.width === next.width && previous.labelWidth === next.labelWidth && previous.readoutWidth === next.readoutWidth ? previous : next);
|
|
67
|
+
};
|
|
68
|
+
measure();
|
|
69
|
+
const observer = new ResizeObserver(measure);
|
|
70
|
+
observer.observe(track);
|
|
71
|
+
observer.observe(labelElement);
|
|
72
|
+
observer.observe(readout);
|
|
73
|
+
return () => observer.disconnect();
|
|
74
|
+
}, [trackProps.ref]);
|
|
75
|
+
const endX = Math.max(HANDLE_START, geometry.width - HANDLE_END_INSET);
|
|
76
|
+
const stops = useMemo(() => {
|
|
77
|
+
const values = [...new Set(Array.from({ length: STOP_COUNT }, (_, index) => snapSliderValue(min + index / 9 * (max - min), min, max, step)))];
|
|
78
|
+
return values.map((value, index) => ({
|
|
79
|
+
value,
|
|
80
|
+
x: values.length === 1 ? HANDLE_START : HANDLE_START + index / (values.length - 1) * (endX - HANDLE_START)
|
|
81
|
+
}));
|
|
82
|
+
}, [
|
|
83
|
+
min,
|
|
84
|
+
max,
|
|
85
|
+
step,
|
|
86
|
+
endX
|
|
87
|
+
]);
|
|
88
|
+
const restingX = mapBetweenStops(stops, current, "value", "x");
|
|
89
|
+
const handleX = useMotionValue(restingX);
|
|
90
|
+
const restingTarget = useRef(restingX);
|
|
91
|
+
const settleTo = useCallback((x) => {
|
|
92
|
+
restingTarget.current = x;
|
|
93
|
+
handleX.jump(handleX.get());
|
|
94
|
+
if (reduce) handleX.jump(x);
|
|
95
|
+
else animate(handleX, x, {
|
|
96
|
+
type: "spring",
|
|
97
|
+
...SPRING_GLIDE
|
|
98
|
+
});
|
|
99
|
+
}, [handleX, reduce]);
|
|
100
|
+
useLayoutEffect(() => {
|
|
101
|
+
if (gesture.current || restingTarget.current === restingX) return;
|
|
102
|
+
settleTo(restingX);
|
|
103
|
+
}, [restingX, settleTo]);
|
|
104
|
+
useEffect(() => () => {
|
|
105
|
+
handleX.stop();
|
|
106
|
+
if (dragFrame.current !== null) cancelAnimationFrame(dragFrame.current);
|
|
107
|
+
}, [handleX]);
|
|
108
|
+
const fillRight = useTransform(handleX, (x) => x >= endX ? geometry.width - 2 : x + 8);
|
|
109
|
+
const fillX = useTransform(fillRight, (right) => right - geometry.width + 2);
|
|
110
|
+
const split = useTransform(handleX, (x) => {
|
|
111
|
+
const overlap = (start, end) => Math.max(0, Math.min(1, (x + 4 - start) / 6, (end - x) / 6));
|
|
112
|
+
return Math.max(overlap(TEXT_INSET, TEXT_INSET + geometry.labelWidth), overlap(geometry.width - TEXT_INSET - geometry.readoutWidth, geometry.width - TEXT_INSET));
|
|
113
|
+
});
|
|
114
|
+
const stemOpacity = useTransform(split, (amount) => 1 - amount);
|
|
115
|
+
const capTop = useTransform(split, (amount) => -amount);
|
|
116
|
+
const capBottom = useTransform(split, (amount) => amount);
|
|
117
|
+
const labelBounds = {
|
|
118
|
+
start: TEXT_INSET,
|
|
119
|
+
end: TEXT_INSET + geometry.labelWidth
|
|
120
|
+
};
|
|
121
|
+
const readoutBounds = {
|
|
122
|
+
start: geometry.width - TEXT_INSET - geometry.readoutWidth,
|
|
123
|
+
end: geometry.width - TEXT_INSET
|
|
124
|
+
};
|
|
125
|
+
const overlapsText = (x, bounds) => x + 2 >= bounds.start && x - 2 <= bounds.end;
|
|
126
|
+
const ticks = showTicks ? stops.map((stop) => stop.x).filter((x) => !overlapsText(x, labelBounds) && !overlapsText(x, readoutBounds)) : [];
|
|
127
|
+
const queueDragCommit = (value) => {
|
|
128
|
+
pendingDragValue.current = value;
|
|
129
|
+
if (dragFrame.current !== null) return;
|
|
130
|
+
dragFrame.current = requestAnimationFrame(() => {
|
|
131
|
+
dragFrame.current = null;
|
|
132
|
+
if (pendingDragValue.current !== null) commit(pendingDragValue.current);
|
|
133
|
+
pendingDragValue.current = null;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const cancelDragCommit = () => {
|
|
137
|
+
if (dragFrame.current !== null) cancelAnimationFrame(dragFrame.current);
|
|
138
|
+
dragFrame.current = null;
|
|
139
|
+
pendingDragValue.current = null;
|
|
140
|
+
};
|
|
141
|
+
const endGesture = (event) => {
|
|
142
|
+
const active = gesture.current;
|
|
143
|
+
if (!active || active.id !== event.pointerId) return;
|
|
144
|
+
gesture.current = null;
|
|
145
|
+
cancelDragCommit();
|
|
146
|
+
setDragging(false);
|
|
147
|
+
if (!options.disabled && geometry.width > 0) {
|
|
148
|
+
const x = event.type === "pointerup" ? event.clientX - active.left - active.offset : active.x;
|
|
149
|
+
const stop = nearestStop(stops, x);
|
|
150
|
+
commit(stop.value);
|
|
151
|
+
settleTo(options.value === void 0 ? stop.x : restingX);
|
|
152
|
+
} else settleTo(restingX);
|
|
153
|
+
releasePointer(event.currentTarget, event.pointerId);
|
|
154
|
+
};
|
|
155
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
156
|
+
...trackProps,
|
|
157
|
+
onPointerDown: (event) => {
|
|
158
|
+
if (options.disabled || event.button !== 0 || gesture.current) return;
|
|
159
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
160
|
+
if (!rect.width) return;
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
const pointerX = event.clientX - rect.left;
|
|
163
|
+
const thumbX = handleX.get();
|
|
164
|
+
const offset = Math.abs(pointerX - thumbX - 2) <= 12 ? pointerX - thumbX : 2;
|
|
165
|
+
gesture.current = {
|
|
166
|
+
id: event.pointerId,
|
|
167
|
+
left: rect.left,
|
|
168
|
+
offset,
|
|
169
|
+
x: thumbX
|
|
170
|
+
};
|
|
171
|
+
setDragging(true);
|
|
172
|
+
handleX.stop();
|
|
173
|
+
cancelDragCommit();
|
|
174
|
+
capturePointer(event.currentTarget, event.pointerId);
|
|
175
|
+
event.currentTarget.querySelector("[role=slider]")?.focus({ preventScroll: true });
|
|
176
|
+
},
|
|
177
|
+
onPointerMove: (event) => {
|
|
178
|
+
const active = gesture.current;
|
|
179
|
+
if (!active || active.id !== event.pointerId || options.disabled) return;
|
|
180
|
+
const x = Math.min(endX, Math.max(HANDLE_START, event.clientX - active.left - active.offset));
|
|
181
|
+
active.x = x;
|
|
182
|
+
handleX.set(x);
|
|
183
|
+
queueDragCommit(mapBetweenStops(stops, x, "x", "value"));
|
|
184
|
+
},
|
|
185
|
+
onPointerUp: endGesture,
|
|
186
|
+
onPointerCancel: endGesture,
|
|
187
|
+
onLostPointerCapture: endGesture,
|
|
188
|
+
className: cn("relative h-10 w-full touch-none select-none overflow-hidden rounded-lg bg-muted", TOUCH_GESTURE_CLASS, options.disabled ? "pointer-events-none opacity-50" : "cursor-grab active:cursor-grabbing", className),
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx("div", {
|
|
191
|
+
"aria-hidden": "true",
|
|
192
|
+
className: "pointer-events-none absolute inset-x-[2px] inset-y-0 overflow-hidden rounded-lg",
|
|
193
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
194
|
+
className: "absolute inset-0 rounded-lg bg-foreground/15",
|
|
195
|
+
style: { x: fillX }
|
|
196
|
+
})
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsxs("div", {
|
|
199
|
+
"aria-hidden": "true",
|
|
200
|
+
className: "pointer-events-none absolute inset-0 text-foreground",
|
|
201
|
+
children: [
|
|
202
|
+
/* @__PURE__ */ jsx("span", {
|
|
203
|
+
ref: labelRef,
|
|
204
|
+
className: "absolute top-1/2 left-5 max-w-[40%] -translate-y-1/2 truncate font-medium text-sm leading-5",
|
|
205
|
+
children: label
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ jsx("span", {
|
|
208
|
+
ref: readoutRef,
|
|
209
|
+
className: "absolute top-1/2 right-5 max-w-[40%] -translate-y-1/2 truncate font-semibold text-[13px] tabular-nums leading-[18px] tracking-tight",
|
|
210
|
+
children: format(current)
|
|
211
|
+
}),
|
|
212
|
+
ticks.map((left) => /* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: "absolute top-1/2 size-1 -translate-y-1/2 rounded-full bg-foreground/25",
|
|
214
|
+
style: { left }
|
|
215
|
+
}, left))
|
|
216
|
+
]
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ jsxs(motion.div, {
|
|
219
|
+
"aria-hidden": "true",
|
|
220
|
+
animate: reduce ? void 0 : { scaleY: dragging ? 1.35 : 1 },
|
|
221
|
+
transition: SPRING_BOUNCY,
|
|
222
|
+
className: "pointer-events-none absolute top-2 left-0 h-6 w-1 text-foreground",
|
|
223
|
+
style: { x: handleX },
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
226
|
+
className: "absolute top-0 size-1 rounded-full bg-current",
|
|
227
|
+
style: { y: reduce ? 0 : capTop }
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
230
|
+
className: "absolute inset-y-0 w-1 rounded-full bg-current",
|
|
231
|
+
style: { opacity: stemOpacity }
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
234
|
+
className: "absolute bottom-0 size-1 rounded-full bg-current",
|
|
235
|
+
style: { y: reduce ? 0 : capBottom }
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx("button", {
|
|
240
|
+
type: "button",
|
|
241
|
+
...sliderProps,
|
|
242
|
+
onKeyDown: (event) => {
|
|
243
|
+
if (options.disabled) return;
|
|
244
|
+
const next = {
|
|
245
|
+
ArrowRight: stops.find((stop) => stop.value > current)?.value ?? max,
|
|
246
|
+
ArrowUp: stops.find((stop) => stop.value > current)?.value ?? max,
|
|
247
|
+
ArrowLeft: stops.findLast((stop) => stop.value < current)?.value ?? min,
|
|
248
|
+
ArrowDown: stops.findLast((stop) => stop.value < current)?.value ?? min,
|
|
249
|
+
Home: min,
|
|
250
|
+
End: max,
|
|
251
|
+
PageUp: max,
|
|
252
|
+
PageDown: min
|
|
253
|
+
}[event.key];
|
|
254
|
+
if (next !== void 0) {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
commit(next);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
className: "absolute inset-0 cursor-inherit touch-none rounded-lg border-0 outline-none"
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
export { InlineSlider };
|
|
266
|
+
|
|
267
|
+
//# sourceMappingURL=range-slider-inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider-inline.js","names":[],"sources":["../../../src/components/motion/range-slider-inline.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type PointerEvent,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { animate, motion, useMotionValue, useReducedMotion, useTransform } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SliderOptions, snapSliderValue, useSlider } from \"../../hooks/use-slider\";\nimport { SPRING_GLIDE } from \"../../lib/ease\";\nimport { capturePointer, releasePointer, TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\n\nconst STOP_COUNT = 10;\nconst HANDLE_START = 8;\nconst HANDLE_END_INSET = 12;\nconst TEXT_INSET = 20;\n// Matches RangeSlider's bouncy grab and release feedback.\nconst SPRING_BOUNCY = { type: \"spring\", stiffness: 500, damping: 14, mass: 0.7 } as const;\n\ntype Stop = { value: number; x: number };\n\nfunction mapBetweenStops(stops: Stop[], point: number, from: keyof Stop, to: keyof Stop) {\n const upperIndex = stops.findIndex((stop) => stop[from] >= point);\n const upper = stops[upperIndex < 0 ? stops.length - 1 : upperIndex];\n const lower = stops[Math.max(0, upperIndex - 1)];\n if (lower[from] === upper[from]) return upper[to];\n return (\n lower[to] + ((point - lower[from]) / (upper[from] - lower[from])) * (upper[to] - lower[to])\n );\n}\n\nfunction nearestStop(stops: Stop[], x: number) {\n return stops.reduce((nearest, stop) =>\n Math.abs(stop.x - x) < Math.abs(nearest.x - x) ? stop : nearest,\n );\n}\n\nexport interface InlineSliderProps extends SliderOptions {\n /** Rounds snap-stop values. While dragging, the readout keeps this step's decimal precision. */\n step?: number;\n /** Compact label inside the left edge of the track. */\n label: string;\n /** Formats the inline value without changing its precision. */\n format?: (value: number) => string;\n /** Show markers for the ten evenly spaced snap stops, except where they overlap inline text. */\n showTicks?: boolean;\n className?: string;\n}\n\n/** An always-visible inline slider with an inset fill and a thumb that parts\n * around its labels, keeping their text readable as the handle passes them. */\nexport function InlineSlider({\n label,\n format = String,\n showTicks = true,\n className,\n ...options\n}: InlineSliderProps) {\n const reduce = useReducedMotion();\n const step = options.step && options.step > 0 ? options.step : 1;\n const precision = step.toFixed(6).replace(/0+$/, \"\").split(\".\")[1]?.length ?? 0;\n const { current, min, max, commit, trackProps, sliderProps } = useSlider({\n ...options,\n step: 10 ** -precision,\n \"aria-label\": options[\"aria-label\"] ?? label,\n formatValueText: options.formatValueText ?? format,\n });\n const labelRef = useRef<HTMLSpanElement>(null);\n const readoutRef = useRef<HTMLSpanElement>(null);\n const [geometry, setGeometry] = useState({\n width: 292,\n labelWidth: 22,\n readoutWidth: 24,\n });\n const [dragging, setDragging] = useState(false);\n const dragFrame = useRef<number | null>(null);\n const pendingDragValue = useRef<number | null>(null);\n const gesture = useRef<{\n id: number;\n left: number;\n offset: number;\n x: number;\n } | null>(null);\n\n useLayoutEffect(() => {\n const track = trackProps.ref.current;\n const labelElement = labelRef.current;\n const readout = readoutRef.current;\n if (!track || !labelElement || !readout) return;\n const measure = () => {\n const width = track.getBoundingClientRect().width;\n if (!width) return;\n const next = {\n width,\n labelWidth: labelElement.getBoundingClientRect().width,\n readoutWidth: readout.getBoundingClientRect().width,\n };\n setGeometry((previous) =>\n previous.width === next.width &&\n previous.labelWidth === next.labelWidth &&\n previous.readoutWidth === next.readoutWidth\n ? previous\n : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(track);\n observer.observe(labelElement);\n observer.observe(readout);\n return () => observer.disconnect();\n }, [trackProps.ref]);\n\n // Each stop owns both a value and a physical position. As in RangeSlider,\n // the stops span the entire track at even intervals; text only affects\n // whether a marker is painted, never whether its stop remains interactive.\n const endX = Math.max(HANDLE_START, geometry.width - HANDLE_END_INSET);\n const stops = useMemo(() => {\n const values = [\n ...new Set(\n Array.from({ length: STOP_COUNT }, (_, index) =>\n snapSliderValue(min + (index / (STOP_COUNT - 1)) * (max - min), min, max, step),\n ),\n ),\n ];\n return values.map((value, index) => ({\n value,\n x:\n values.length === 1\n ? HANDLE_START\n : HANDLE_START + (index / (values.length - 1)) * (endX - HANDLE_START),\n }));\n }, [min, max, step, endX]);\n const restingX = mapBetweenStops(stops, current, \"value\", \"x\");\n // One motion value owns the thumb for the entire gesture. Pointer movement\n // writes pixels directly; only release/click/keyboard changes use a spring.\n // Never derive dragging pixels from a rounded value or swap to a lagging spring.\n const handleX = useMotionValue(restingX);\n const restingTarget = useRef(restingX);\n const settleTo = useCallback(\n (x: number) => {\n restingTarget.current = x;\n handleX.jump(handleX.get());\n if (reduce) handleX.jump(x);\n else animate(handleX, x, { type: \"spring\", ...SPRING_GLIDE });\n },\n [handleX, reduce],\n );\n useLayoutEffect(() => {\n if (gesture.current || restingTarget.current === restingX) return;\n settleTo(restingX);\n }, [restingX, settleTo]);\n useEffect(\n () => () => {\n handleX.stop();\n if (dragFrame.current !== null) cancelAnimationFrame(dragFrame.current);\n },\n [handleX],\n );\n const fillRight = useTransform(handleX, (x) => (x >= endX ? geometry.width - 2 : x + 8));\n // Slide a fixed-size fill inside the inset clipping window. The labels and\n // dots stay above it, and only transforms animate.\n const fillX = useTransform(fillRight, (right) => right - geometry.width + 2);\n // Part progressively over six pixels at each text edge instead of\n // toggling the stem on/off in a single pointer frame. The thumb uses the\n // same two-dot treatment across both the label and numeric readout.\n const split = useTransform(handleX, (x) => {\n const overlap = (start: number, end: number) =>\n Math.max(0, Math.min(1, (x + 4 - start) / 6, (end - x) / 6));\n return Math.max(\n overlap(TEXT_INSET, TEXT_INSET + geometry.labelWidth),\n overlap(geometry.width - TEXT_INSET - geometry.readoutWidth, geometry.width - TEXT_INSET),\n );\n });\n const stemOpacity = useTransform(split, (amount) => 1 - amount);\n const capTop = useTransform(split, (amount) => -amount);\n const capBottom = useTransform(split, (amount) => amount);\n const labelBounds = { start: TEXT_INSET, end: TEXT_INSET + geometry.labelWidth };\n const readoutBounds = {\n start: geometry.width - TEXT_INSET - geometry.readoutWidth,\n end: geometry.width - TEXT_INSET,\n };\n const overlapsText = (x: number, bounds: { start: number; end: number }) =>\n x + 2 >= bounds.start && x - 2 <= bounds.end;\n const ticks = showTicks\n ? stops\n .map((stop) => stop.x)\n .filter((x) => !overlapsText(x, labelBounds) && !overlapsText(x, readoutBounds))\n : [];\n\n const queueDragCommit = (value: number) => {\n pendingDragValue.current = value;\n if (dragFrame.current !== null) return;\n dragFrame.current = requestAnimationFrame(() => {\n dragFrame.current = null;\n if (pendingDragValue.current !== null) commit(pendingDragValue.current);\n pendingDragValue.current = null;\n });\n };\n\n const cancelDragCommit = () => {\n if (dragFrame.current !== null) cancelAnimationFrame(dragFrame.current);\n dragFrame.current = null;\n pendingDragValue.current = null;\n };\n\n const endGesture = (event: PointerEvent<HTMLDivElement>) => {\n const active = gesture.current;\n if (!active || active.id !== event.pointerId) return;\n // Clear before releasing capture: its lost-capture event must not commit twice.\n gesture.current = null;\n cancelDragCommit();\n setDragging(false);\n if (!options.disabled && geometry.width > 0) {\n const x = event.type === \"pointerup\" ? event.clientX - active.left - active.offset : active.x;\n const stop = nearestStop(stops, x);\n commit(stop.value);\n settleTo(options.value === undefined ? stop.x : restingX);\n } else {\n settleTo(restingX);\n }\n releasePointer(event.currentTarget, event.pointerId);\n };\n\n return (\n <div\n {...trackProps}\n onPointerDown={(event) => {\n if (options.disabled || event.button !== 0 || gesture.current) return;\n const rect = event.currentTarget.getBoundingClientRect();\n if (!rect.width) return;\n event.preventDefault();\n const pointerX = event.clientX - rect.left;\n const thumbX = handleX.get();\n // Grabbing the thumb preserves the exact grab point. A track click\n // waits for release, so it glides to a dot without an intermediate jump.\n const offset = Math.abs(pointerX - thumbX - 2) <= 12 ? pointerX - thumbX : 2;\n gesture.current = { id: event.pointerId, left: rect.left, offset, x: thumbX };\n setDragging(true);\n handleX.stop();\n cancelDragCommit();\n capturePointer(event.currentTarget, event.pointerId);\n event.currentTarget\n .querySelector<HTMLButtonElement>(\"[role=slider]\")\n ?.focus({ preventScroll: true });\n }}\n onPointerMove={(event) => {\n const active = gesture.current;\n if (!active || active.id !== event.pointerId || options.disabled) return;\n const x = Math.min(\n endX,\n Math.max(HANDLE_START, event.clientX - active.left - active.offset),\n );\n active.x = x;\n handleX.set(x);\n // Use the same piecewise map as the resting stops, so value and\n // position agree throughout the drag.\n queueDragCommit(mapBetweenStops(stops, x, \"x\", \"value\"));\n }}\n onPointerUp={endGesture}\n onPointerCancel={endGesture}\n onLostPointerCapture={endGesture}\n className={cn(\n \"relative h-10 w-full touch-none select-none overflow-hidden rounded-lg bg-muted\",\n TOUCH_GESTURE_CLASS,\n options.disabled ? \"pointer-events-none opacity-50\" : \"cursor-grab active:cursor-grabbing\",\n className,\n )}\n >\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-[2px] inset-y-0 overflow-hidden rounded-lg\"\n >\n <motion.div className=\"absolute inset-0 rounded-lg bg-foreground/15\" style={{ x: fillX }} />\n </div>\n <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 text-foreground\">\n <span\n ref={labelRef}\n className=\"absolute top-1/2 left-5 max-w-[40%] -translate-y-1/2 truncate font-medium text-sm leading-5\"\n >\n {label}\n </span>\n <span\n ref={readoutRef}\n className=\"absolute top-1/2 right-5 max-w-[40%] -translate-y-1/2 truncate font-semibold text-[13px] tabular-nums leading-[18px] tracking-tight\"\n >\n {format(current)}\n </span>\n {ticks.map((left) => (\n <span\n key={left}\n className=\"absolute top-1/2 size-1 -translate-y-1/2 rounded-full bg-foreground/25\"\n style={{ left }}\n />\n ))}\n </div>\n <motion.div\n aria-hidden=\"true\"\n animate={reduce ? undefined : { scaleY: dragging ? 1.35 : 1 }}\n transition={SPRING_BOUNCY}\n className=\"pointer-events-none absolute top-2 left-0 h-6 w-1 text-foreground\"\n style={{ x: handleX }}\n >\n <motion.span\n className=\"absolute top-0 size-1 rounded-full bg-current\"\n style={{ y: reduce ? 0 : capTop }}\n />\n <motion.span\n className=\"absolute inset-y-0 w-1 rounded-full bg-current\"\n style={{ opacity: stemOpacity }}\n />\n <motion.span\n className=\"absolute bottom-0 size-1 rounded-full bg-current\"\n style={{ y: reduce ? 0 : capBottom }}\n />\n </motion.div>\n <button\n type=\"button\"\n {...sliderProps}\n onKeyDown={(event) => {\n if (options.disabled) return;\n const next = {\n ArrowRight: stops.find((stop) => stop.value > current)?.value ?? max,\n ArrowUp: stops.find((stop) => stop.value > current)?.value ?? max,\n ArrowLeft: stops.findLast((stop) => stop.value < current)?.value ?? min,\n ArrowDown: stops.findLast((stop) => stop.value < current)?.value ?? min,\n Home: min,\n End: max,\n PageUp: max,\n PageDown: min,\n }[event.key];\n if (next !== undefined) {\n event.preventDefault();\n commit(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ider } from "../../hooks/use-slider.js";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { animate, motion, useMotionValue, useMotionValueEvent, useReducedMotion } from "motion/react";
|
|
8
8
|
//#region src/components/motion/range-slider-ruler.tsx
|
|
@@ -1 +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 { cn } from \"cn\";\nimport {\n animate,\n motion,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\n\nimport { type SliderOptions, snapSliderValue, useSlider } from \"../../hooks/use-slider\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\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 overflow-hidden\",\n TOUCH_GESTURE_CLASS,\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=\"mask-[linear-gradient(to_right,transparent,black_18%,black_82%,transparent)] relative h-12\">\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":";;;;;;;;AAgBA,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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
+
{"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\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\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 overflow-hidden\",\n TOUCH_GESTURE_CLASS,\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=\"mask-[linear-gradient(to_right,transparent,black_18%,black_82%,transparent)] relative h-12\">\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":";;;;;;;;AAgBA,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,M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E;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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { TOUCH_GESTURE_CLASS } from "../../lib/touch.js";
|
|
3
3
|
import { useSlider } from "../../hooks/use-slider.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
8
8
|
//#region src/components/motion/range-slider-wave.tsx
|
|
@@ -1 +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 {
|
|
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\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\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 items-center justify-between gap-1\",\n TOUCH_GESTURE_CLASS,\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":";;;;;;;;AAUA,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,2EACA,qBACA,QAAQ,WAAW,mCAAmC,sCACtD,SACF;EAPF,UAAA,CASG,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-slider.d.ts","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"range-slider.d.ts","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"mappings":";;iBAaiB,yBAAyB;;EAExC;EACA;;wBAGc,cAAc,WAAkB,cAAc,WAAW,mCAAgB,IAAA"}
|