@kumix/ui 0.3.12 → 0.3.13
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 +1 -1
- package/dist/components/agents/agent-activity/activity-row.js +2 -2
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
- package/dist/components/agents/agent-activity/index.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +2 -2
- 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 +2 -2
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/code-block.js +2 -2
- package/dist/components/agents/code-block.js.map +1 -1
- package/dist/components/agents/file-diff.js +2 -2
- package/dist/components/agents/file-diff.js.map +1 -1
- package/dist/components/agents/image-generation.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/agents/streaming-response.js +2 -2
- package/dist/components/agents/streaming-response.js.map +1 -1
- package/dist/components/agents/todo-list.js +2 -2
- package/dist/components/agents/todo-list.js.map +1 -1
- package/dist/components/agents/tool-approval.js +2 -2
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/agents/tool-result.js +2 -2
- package/dist/components/agents/tool-result.js.map +1 -1
- package/dist/components/custom/confirm-dialog.js +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 +2 -2
- package/dist/components/motion/adaptive-stepper.js.map +1 -1
- package/dist/components/motion/animated-badge.js +2 -2
- 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 +2 -2
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +2 -2
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +2 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- 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 +2 -2
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/bloom-menu.js +2 -2
- 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 +2 -2
- 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/button/stateful.js +1 -1
- package/dist/components/motion/card-folder.d.ts +30 -0
- package/dist/components/motion/card-folder.d.ts.map +1 -0
- package/dist/components/motion/card-folder.js +254 -0
- package/dist/components/motion/card-folder.js.map +1 -0
- package/dist/components/motion/center-morph-modal.js +2 -2
- 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 +2 -2
- package/dist/components/motion/combobox/list.js.map +1 -1
- package/dist/components/motion/combobox/trigger.js +2 -2
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/command-palette.js +2 -2
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +2 -2
- 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.d.ts +23 -0
- package/dist/components/motion/digit-swap.d.ts.map +1 -0
- package/dist/components/motion/digit-swap.js +77 -0
- package/dist/components/motion/digit-swap.js.map +1 -0
- 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 +2 -2
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/file-tree.js +2 -2
- package/dist/components/motion/file-tree.js.map +1 -1
- package/dist/components/motion/file-upload.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +2 -2
- 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 +2 -2
- package/dist/components/motion/multi-select/list.js.map +1 -1
- package/dist/components/motion/multi-select/trigger.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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-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.js +1 -1
- 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 +2 -2
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.js +2 -2
- 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 +2 -2
- 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/row-handle.js +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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/reui/alert.js.map +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.js +2 -2
- 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 +2 -2
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +2 -2
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +2 -2
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +2 -2
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -2
- 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 +2 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +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 +2 -2
- 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 +2 -2
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +2 -2
- 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 +2 -2
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- 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 +2 -2
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +3 -3
- package/dist/components/reui/filters/filters-builder.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +2 -2
- package/dist/components/reui/filters/filters-chip.js.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +3 -3
- package/dist/components/reui/filters/filters-editors.js.map +1 -1
- package/dist/components/reui/filters/filters.js +2 -2
- 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 +2 -2
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +2 -2
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +2 -2
- 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 +2 -2
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/ui/bubble.js.map +1 -1
- package/dist/components/ui/button-group.js +2 -2
- 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 +2 -2
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +2 -2
- 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 +2 -2
- 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 +3 -3
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.js +2 -2
- 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 +2 -2
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/dialog.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +3 -3
- 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.d.ts +1 -1
- package/dist/components/ui/input-group.js +2 -2
- 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 +2 -2
- 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 +1 -1
- package/dist/components/ui/item.js +2 -2
- 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 +2 -2
- package/dist/components/ui/marker.js.map +1 -1
- package/dist/components/ui/menubar.js +2 -2
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/message-scroller.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.js +2 -2
- 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 +4 -4
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +3 -3
- 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 +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +2 -2
- 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/dist/{copy-menu-TIKvPaAZ.js → copy-menu-C5GaT4Z-.js} +2 -2
- package/dist/{copy-menu-TIKvPaAZ.js.map → copy-menu-C5GaT4Z-.js.map} +1 -1
- package/package.json +5 -3
|
@@ -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 {\n AnimatePresence,\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n useVelocity,\n} from \"motion/react\";\n\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 { cn } from \"cn\";\nimport {\n AnimatePresence,\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n useVelocity,\n} from \"motion/react\";\n\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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AAA,oBAAC,iBAAD,EAAA,UACG,WACC,qBAAC,OAAO,KAAR;MACE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,OAAO;OAAK,GAAG;MAAG;MACnE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,OAAO;OAAG,GAAG;MAAE;MAChE,MACE,SACI;OAAE,SAAS;OAAG,YAAY,EAAE,UAAU,IAAK;MAAE,IAC7C;OAAE,SAAS;OAAG,OAAO;OAAK,GAAG;OAAG,YAAY,EAAE,UAAU,IAAK;MAAE;MAErE,YAAY,SAAS,EAAE,UAAU,IAAK,IAAI;MAC1C,OACE,SAAS,KAAA,IAAY;OAAE,QAAQ;OAAM,QAAQ;OAAQ,QAAQ;OAAS,SAAS;MAAE;MAEnF,WAAU;MAZZ,UAAA,CAcG,SACD,oBAAC,QAAD,EAAM,WAAU,8FAA+F,CAAA,CACrG;KACV,CAAA,IAAA,KACW,CAAA;IACP,CAAA;IAGZ,oBAAC,UAAD;KACE,MAAK;KACL,GAAI;KACJ,WAAU;IACX,CAAA;GACE;;CACF,CAAA;AAET"}
|
|
@@ -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 "cn";
|
|
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 {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\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 { cn } from \"cn\";\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\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":";;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,EAC1B,OAGA,UAAU,MAAM,GAAG,EAAE,IACrB,WACA,GAAG,WACgB;CACnB,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,SAAS,SAAS,UAAU,YAAY,gBAAgB,UAAU;EACxE,GAAG;EACH,iBAAiB,QAAQ,mBAAmB;CAC9C,CAAC;CAED,MAAM,SAAS,eAAe,OAAO;CACrC,gBAAgB;EACd,OAAO,IAAI,OAAO;CACpB,GAAG,CAAC,SAAS,MAAM,CAAC;CACpB,MAAM,SAAS,UAAU,QAAQ,YAAY;CAK7C,MAAM,YAAY,aAJN,SAAS,SAAS,SAIO,MAAM,MAAM,CAAC;CAClD,MAAM,WAAW,iBAAiB,WAAW,UAAU;CAEvD,MAAM,MACJ,qBAAA,YAAA,EAAA,UAAA,CACG,QAAQ,oBAAC,QAAD;EAAM,WAAU;EAAY,UAAA;CAAY,CAAA,IAAI,oBAAC,QAAD,CAAO,CAAA,GAC5D,oBAAC,QAAD;EAAM,WAAU;EAAgB,UAAA,OAAO,OAAO;CAAQ,CAAA,CACtD,EAAA,CAAA;CAGJ,OACE,qBAAC,OAAO,KAAR;EACE,GAAI;EACJ,SAAS,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW,OAAO,EAAE;EAC3D,YAAY;EACZ,WAAW,GACT,8EACA,qBACA,QAAQ,WAAW,mCAAmC,sCACtD,SACF;EATF,UAAA;GAYE,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA;GAKL,qBAAC,OAAO,KAAR;IAAY,WAAU;IAAmB,OAAO,EAAE,SAAS;IAA3D,UAAA,CACE,oBAAC,OAAD,EAAK,WAAU,iCAAkC,CAAA,GACjD,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,CACK;;GAIZ,oBAAC,UAAD;IACE,MAAK;IACL,GAAI;IACJ,WAAU;GACX,CAAA;EACS;;AAEhB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { TOUCH_GESTURE_CLASS } from "../../lib/touch.js";
|
|
3
3
|
import { snapSliderValue, useSlider } from "../../hooks/use-slider.js";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "cn";
|
|
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 {\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,MAAM,IAAI,KAAA,CAAM,QAAQ,CAAC,CAAC;EACzC,OAAO,IAAI,eAAe;EAC1B,QAAQ,IAAI;CACd,EAAE;CAGF,IAAI,YAAY,GAAG,MAAM,KA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AAE,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"}
|
|
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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,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 "cn";
|
|
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 { cn } from \"cn\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\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"}
|
|
@@ -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 } from "../../lib/ease.js";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "cn";
|
|
7
7
|
import { 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.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-slider.js","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"range-slider.js","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { cn } from \"cn\";\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useReducedMotion,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport { type SliderOptions, useSlider } from \"../../hooks/use-slider\";\nimport { SPRING_GLIDE } from \"../../lib/ease\";\nimport { TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\n\n// Bouncy grab feedback for the thumb scale only.\nconst SPRING_BOUNCY = { type: \"spring\", stiffness: 500, damping: 14, mass: 0.7 } as const;\n\nexport interface RangeSliderProps extends SliderOptions {\n /** Render a tick dot at each step. */\n showTicks?: boolean;\n className?: string;\n}\n\nexport function RangeSlider({ showTicks = true, className, ...options }: RangeSliderProps) {\n const reduce = useReducedMotion();\n const { percent, dragging, min, max, step, trackProps, sliderProps } = useSlider(options);\n\n // Spring-smoothed position drives both the thumb and the fill.\n const target = useMotionValue(percent);\n useEffect(() => {\n target.set(percent);\n }, [percent, target]);\n const smooth = useSpring(target, SPRING_GLIDE);\n const pos = reduce ? target : smooth;\n const left = useMotionTemplate`${pos}%`;\n // Self-offset the thumb from 0% (flush left) to -100% (flush right) of its\n // own width so it stays fully inside the track at both ends — no clip, no gap.\n const thumbX = useTransform(pos, (p) => `${-p}%`);\n\n // Floor rather than round, so a range the step does not divide (0 to 10 by 4)\n // stops its dots at the last whole step instead of drawing one past max.\n // toFixed comes first because 0.3/0.1 is 2.9999999999999996, which would\n // floor to 2 and drop the last dot.\n const steps = Math.floor(Number(((max - min) / step).toFixed(6)));\n const ticks =\n showTicks && steps > 0 && steps <= 50\n ? Array.from({ length: steps + 1 }, (_, i) => Number((min + i * step).toFixed(6)))\n : [];\n\n return (\n <div\n {...trackProps}\n className={cn(\n \"relative flex h-10 w-full touch-none items-center 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 {/* fill — runs from the left edge to the thumb, consistent tone */}\n <motion.div className=\"absolute inset-y-0 left-0 bg-foreground/15\" style={{ width: left }} />\n\n {/* Ticks, inset by half the thumb's width. That inset is the span the\n thumb's own centre travels, so a dot sits where the thumb lands. */}\n <div className=\"pointer-events-none absolute inset-x-[3px] inset-y-0\">\n {ticks.map((t) => {\n const tp = ((t - min) / (max - min)) * 100;\n return (\n <span\n key={t}\n className=\"absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground/25\"\n style={{ left: `${tp}%` }}\n />\n );\n })}\n </div>\n\n {/* vertical bar thumb — contained at both ends via thumbX */}\n <motion.div\n {...sliderProps}\n animate={reduce ? undefined : { scaleY: dragging ? 1.35 : 1 }}\n transition={SPRING_BOUNCY}\n className=\"absolute top-1/2 h-5 w-1.5 rounded-sm bg-foreground shadow-sm outline-none ring-foreground/30 ring-inset focus-visible:ring-4\"\n style={{ left, x: thumbX, y: \"-50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A;GAGL,oBAAC,OAAO,KAAR;IACE,GAAI;IACJ,SAAS,SAAS,KAAA,IAAY,EAAE,QAAQ,WAAW,OAAO,EAAE;IAC5D,YAAY;IACZ,WAAU;IACV,OAAO;KAAE;KAAM,GAAG;KAAQ,GAAG;IAAO;GACrC,CAAA;EACE;;AAET"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useSmoothScroll } from "./smooth-scroll.js";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "cn";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { motion, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
6
6
|
//#region src/components/motion/scroll-progress.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-progress.js","names":[],"sources":["../../../src/components/motion/scroll-progress.tsx"],"sourcesContent":["\"use client\";\n\nimport { type MotionValue, motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"scroll-progress.js","names":[],"sources":["../../../src/components/motion/scroll-progress.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"cn\";\nimport { type MotionValue, motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\n\nimport { useSmoothScroll } from \"./smooth-scroll\";\n\n// Soft follow so the indicator trails the scroll smoothly instead of snapping;\n// looser than the UI springs in lib/ease.ts on purpose.\nconst PROGRESS_SPRING = { stiffness: 120, damping: 30, mass: 0.6 };\n\ntype CommonProps = {\n /** Override the scroll source. Defaults to the page via useSmoothScroll. */\n progress?: MotionValue<number>;\n /** Spring-smooth the value. Disabled automatically under reduced motion. */\n spring?: boolean;\n className?: string;\n};\n\nexport interface ScrollProgressBarProps extends CommonProps {\n variant?: \"bar\";\n position?: \"top\" | \"bottom\";\n /** Bar thickness in px. */\n height?: number;\n /** Position the bar with `fixed` (page) or `absolute` (embedded). */\n fixed?: boolean;\n}\n\nexport interface ScrollProgressCircleProps extends CommonProps {\n variant: \"circle\";\n /** Diameter in px. */\n size?: number;\n /** Stroke width in px. */\n thickness?: number;\n}\n\nexport type ScrollProgressProps = ScrollProgressBarProps | ScrollProgressCircleProps;\n\nfunction useProgressValue(source: MotionValue<number> | undefined, spring: boolean) {\n const reduce = useReducedMotion();\n const fallback = useSmoothScroll().progress;\n const raw = source ?? fallback;\n const smoothed = useSpring(raw, PROGRESS_SPRING);\n return spring && !reduce ? smoothed : raw;\n}\n\nexport function ScrollProgress(props: ScrollProgressProps) {\n if (props.variant === \"circle\") return <ScrollProgressCircle {...props} />;\n return <ScrollProgressBar {...props} />;\n}\n\nfunction ScrollProgressBar({\n progress,\n spring = true,\n position = \"top\",\n height = 2,\n fixed = true,\n className,\n}: ScrollProgressBarProps) {\n const value = useProgressValue(progress, spring);\n return (\n <motion.div\n aria-hidden\n style={{ height, scaleX: value }}\n className={cn(\n \"right-0 left-0 z-50 origin-left bg-foreground\",\n fixed ? \"fixed\" : \"absolute\",\n position === \"top\" ? \"top-0\" : \"bottom-0\",\n className,\n )}\n />\n );\n}\n\nfunction ScrollProgressCircle({\n progress,\n spring = true,\n size = 40,\n thickness = 3,\n className,\n}: ScrollProgressCircleProps) {\n const value = useProgressValue(progress, spring);\n const radius = (size - thickness) / 2;\n const circumference = 2 * Math.PI * radius;\n const offset = useTransform(value, (v) => circumference * (1 - v));\n\n return (\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n role=\"presentation\"\n width={size}\n height={size}\n viewBox={`0 0 ${size} ${size}`}\n className={cn(\"text-foreground\", className)}\n >\n <circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n fill=\"none\"\n strokeWidth={thickness}\n className=\"stroke-current opacity-15\"\n />\n <motion.circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n fill=\"none\"\n strokeWidth={thickness}\n strokeLinecap=\"round\"\n className=\"stroke-current\"\n strokeDasharray={circumference}\n style={{ strokeDashoffset: offset }}\n transform={`rotate(-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X,GAAG;GACH,MAAK;GACL,aAAa;GACb,WAAU;EACX,CAAA,GACD,oBAAC,OAAO,QAAR;GACE,IAAI,OAAO;GACX,IAAI,OAAO;GACX,GAAG;GACH,MAAK;GACL,aAAa;GACb,eAAc;GACd,WAAU;GACV,iBAAiB;GACjB,OAAO,EAAE,kBAAkB,OAAO;GAClC,WAAW,cAAc,OAAO,EAAE,GAAG,OAAO,EAAE;EAC/C,CAAA,CACE;;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { useRef } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "cn";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { motion, useInView, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/scroll-reveal.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-reveal.js","names":[],"sources":["../../../src/components/motion/scroll-reveal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"scroll-reveal.js","names":[],"sources":["../../../src/components/motion/scroll-reveal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport { cn } from \"cn\";\nimport { motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport interface ScrollRevealProps {\n children: ReactNode;\n /** Slide distance in px before reveal. */\n y?: number;\n /** Enter blur in px (kept ≤ 10 per motion conventions). */\n blur?: number;\n /** Reveal duration in seconds. */\n duration?: number;\n delay?: number;\n /** Reveal only once (default) or every time it enters view. */\n once?: boolean;\n /** Portion of the element that must be visible to trigger. */\n amount?: \"some\" | \"all\" | number;\n /** Scroll root for contained scroll areas. Defaults to the viewport. */\n root?: RefObject<Element | null>;\n className?: string;\n}\n\nexport function ScrollReveal({\n children,\n y = 16,\n blur = 8,\n duration = 0.6,\n delay = 0,\n once = true,\n amount = 0.3,\n root,\n className,\n}: ScrollRevealProps) {\n const reduce = useReducedMotion();\n const ref = useRef<HTMLDivElement>(null);\n const inView = useInView(ref, { root, once, amount });\n\n const hidden = reduce ? { opacity: 0 } : { opacity: 0, y, filter: `blur(${blur}px)` };\n const shown = reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" };\n\n return (\n <motion.div\n ref={ref}\n initial={hidden}\n animate={inView ? shown : hidden}\n transition={{ duration, ease: EASE_OUT, delay }}\n className={cn(className)}\n >\n {children}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,aAAa,EAC3B,UACA,IAAI,IACJ,OAAO,GACP,WAAW,IACX,QAAQ,GACR,OAAO,MACP,SAAS,IACT,MACA,aACoB;CACpB,MAAM,SAAS,iBAAiB;CAChC,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,SAAS,UAAU,KAAK;EAAE;EAAM;EAAM;CAAO,CAAC;CAEpD,MAAM,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;EAAE,SAAS;EAAG;EAAG,QAAQ,QAAQ,KAAK;CAAK;CACpF,MAAM,QAAQ,SAAS,EAAE,SAAS,EAAE,IAAI;EAAE,SAAS;EAAG,GAAG;EAAG,QAAQ;CAAY;CAEhF,OACE,oBAAC,OAAO,KAAR;EACO;EACL,SAAS;EACT,SAAS,SAAS,QAAQ;EAC1B,YAAY;GAAE;GAAU,MAAM;GAAU;EAAM;EAC9C,WAAW,GAAG,SAAS;EAEtB;CACS,CAAA;AAEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-to.js","names":[],"sources":["../../../src/components/motion/scroll-to.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\
|
|
1
|
+
{"version":3,"file":"scroll-to.js","names":[],"sources":["../../../src/components/motion/scroll-to.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"cn\";\n\nimport { type ScrollTarget, type ScrollToOptions, useSmoothScroll } from \"./smooth-scroll\";\n\nexport interface ScrollToProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\"> {\n /** Where to scroll: px offset, selector string or element. */\n to: ScrollTarget;\n /** Extra px offset from the target (e.g. to clear a sticky header). */\n offset?: number;\n /** Override the ease duration in seconds. */\n duration?: number;\n children: ReactNode;\n className?: string;\n}\n\n/**\n * Button that smooth-scrolls to a target via the active SmoothScroll provider\n * (or native scroll as a fallback). Respects reduced motion — jumps instantly.\n */\nexport function ScrollTo({ to, offset, duration, children, className, ...rest }: ScrollToProps) {\n const { scrollTo } = useSmoothScroll();\n const options: ScrollToOptions = { offset, duration };\n return (\n <button type=\"button\" onClick={() => scrollTo(to, options)} className={cn(className)} {...rest}>\n {children}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,SAAS,EAAE,IAAI,QAAQ,UAAU,UAAU,WAAW,GAAG,QAAuB;CAC9F,MAAM,EAAE,aAAa,gBAAgB;CACrC,MAAM,UAA2B;EAAE;EAAQ;CAAS;CACpD,OACE,oBAAC,UAAD;EAAQ,MAAK;EAAS,eAAe,SAAS,IAAI,OAAO;EAAG,WAAW,GAAG,SAAS;EAAG,GAAI;EACvF;CACK,CAAA;AAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-morph.d.ts","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"select-morph.d.ts","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"mappings":";;iBA+DiB;EACf;EACA;EACA,iBAAiB;EACjB;EACA;EACA,UAAU;;;;;;;wBAQI,cACd,OACA,cACA,eACA,UACA,WACA,YACC,mCAAgB,IAAA;iBAoFF;EACf;EACA;;wBAGc,mBAAmB,aAAa,aAAa,wCAAqB,IAAA;iBAcjE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBA8ClE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBAmElE;EACf;EACA;EACA;EACA,UAAU;;wBAGI,kBACd,OACA,UACA,WACA,YACC,uCAAoB,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { cn } from "
|
|
4
|
-
import { Check, ChevronDown } from "lucide-react";
|
|
3
|
+
import { cn } from "cn";
|
|
5
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
6
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
7
7
|
//#region src/components/motion/select-morph.tsx
|
|
8
8
|
const MORPH = {
|
|
9
9
|
type: "spring",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-morph.js","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport {\n AnimatePresence,\n motion,\n type Transition,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\n// Shared-layout morph: trigger box grows into the panel and back, one surface.\nconst MORPH: Transition = { type: \"spring\", duration: 0.5, bounce: 0.22 };\n// Trigger and panel header share this row so the morph stays seamless.\nconst ROW = \"flex w-full items-center justify-between gap-2 px-3.5 py-2.5 text-sm\";\n\nconst LIST: Variants = {\n hidden: {},\n show: { transition: { staggerChildren: 0.035, delayChildren: 0.08 } },\n};\nconst ITEM: Variants = {\n hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\ninterface MorphContextValue {\n value: string | undefined;\n open: boolean;\n setOpen: (open: boolean) => void;\n select: (value: string) => void;\n register: (value: string, label: string) => void;\n unregister: (value: string) => void;\n labelFor: (value: string | undefined) => string | undefined;\n placeholder: string;\n setPlaceholder: (p: string) => void;\n reduce: boolean;\n layoutId: string;\n triggerId: string;\n listId: string;\n disabled: boolean;\n}\n\nconst MorphContext = createContext<MorphContextValue | null>(null);\n\nfunction useMorphContext(component: string) {\n const ctx = useContext(MorphContext);\n if (!ctx) throw new Error(`${component} must be used within <MorphSelect>`);\n return ctx;\n}\n\nexport interface MorphSelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\n/**\n * Select whose trigger morphs into the panel via a shared layoutId — instead of\n * a separate dropdown opening, the trigger itself grows into the menu and\n * shrinks back, never detaching. Composable like `Select` (the gooey variant).\n */\nexport function MorphSelect({\n value,\n defaultValue,\n onValueChange,\n disabled = false,\n className,\n children,\n}: MorphSelectProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [internal, setInternal] = useState(defaultValue);\n // ref-counted: items render twice (hidden registrar + open panel), so a\n // label is only dropped once every copy with that value has unmounted.\n const [labels, setLabels] = useState<Map<string, { label: string; count: number }>>(new Map());\n const [placeholder, setPlaceholder] = useState(\"Select\");\n\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n\n const select = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n setOpen(false);\n },\n [controlled, onValueChange],\n );\n\n const register = useCallback((v: string, label: string) => {\n setLabels((m) => {\n const next = new Map(m);\n next.set(v, { label, count: (m.get(v)?.count ?? 0) + 1 });\n return next;\n });\n }, []);\n const unregister = useCallback((v: string) => {\n setLabels((m) => {\n const entry = m.get(v);\n if (!entry) return m;\n const next = new Map(m);\n if (entry.count <= 1) next.delete(v);\n else next.set(v, { label: entry.label, count: entry.count - 1 });\n return next;\n });\n }, []);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n const onPointer = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n value: current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labelFor: (v) => (v === undefined ? undefined : labels.get(v)?.label),\n placeholder,\n setPlaceholder,\n reduce,\n layoutId: `${baseId}-surface`,\n triggerId: `${baseId}-trigger`,\n listId: `${baseId}-list`,\n disabled,\n }),\n [current, open, select, register, unregister, labels, placeholder, reduce, baseId, disabled],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={rootRef} className={cn(\"relative\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphSelectValueProps {\n placeholder?: string;\n className?: string;\n}\n\nexport function MorphSelectValue({ placeholder, className }: MorphSelectValueProps) {\n const ctx = useMorphContext(\"MorphSelectValue\");\n // surface the placeholder so the morph header (rendered by content) matches\n useEffect(() => {\n if (placeholder) ctx.setPlaceholder(placeholder);\n }, [placeholder, ctx.setPlaceholder]);\n const label = ctx.labelFor(ctx.value);\n return (\n <span className={cn(label ? \"text-foreground\" : \"text-muted-foreground\", className)}>\n {label ?? placeholder ?? \"Select\"}\n </span>\n );\n}\n\nexport interface MorphSelectTriggerProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectTrigger({ className, children }: MorphSelectTriggerProps) {\n const ctx = useMorphContext(\"MorphSelectTrigger\");\n return (\n <>\n {/* invisible sizer reserves the closed height (the morph surface is\n absolute, so this keeps surrounding layout from shifting) */}\n <div aria-hidden inert className={cn(ROW, \"invisible rounded-xl border border-border\")}>\n {children}\n <ChevronDown className=\"h-4 w-4\" />\n </div>\n\n <AnimatePresence initial={false} mode=\"popLayout\">\n {!ctx.open ? (\n <motion.button\n key=\"trigger\"\n layoutId={ctx.layoutId}\n type=\"button\"\n id={ctx.triggerId}\n disabled={ctx.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={ctx.open}\n aria-controls={ctx.listId}\n onClick={() => ctx.setOpen(true)}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n style={{ borderRadius: 12 }}\n className={cn(\n ROW,\n \"absolute inset-x-0 top-0 z-10 border border-border bg-background text-foreground outline-none transition-colors\",\n \"hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n <motion.span layout=\"position\" className=\"min-w-0 truncate\">\n {children}\n </motion.span>\n <motion.span layout=\"position\" className=\"text-muted-foreground\">\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n ) : null}\n </AnimatePresence>\n </>\n );\n}\n\nexport interface MorphSelectContentProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectContent({ className, children }: MorphSelectContentProps) {\n const ctx = useMorphContext(\"MorphSelectContent\");\n const label = ctx.labelFor(ctx.value);\n return (\n <>\n {/* always-mounted, hidden — keeps item label registrations alive while\n closed so the trigger shows the selected value before first open */}\n <div className=\"hidden\">{children}</div>\n\n <AnimatePresence initial={false} mode=\"popLayout\">\n {ctx.open ? (\n <motion.div\n key=\"panel\"\n layoutId={ctx.layoutId}\n id={ctx.listId}\n role=\"listbox\"\n aria-labelledby={ctx.triggerId}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n style={{ borderRadius: 12 }}\n className={cn(\n \"absolute inset-x-0 top-0 z-30 overflow-hidden border border-border bg-background shadow-lg\",\n className,\n )}\n >\n {/* header mirrors the trigger (continuous morph) and collapses the\n panel back into the trigger when clicked */}\n <motion.button\n type=\"button\"\n layout=\"position\"\n aria-expanded\n onClick={() => ctx.setOpen(false)}\n className={cn(ROW, \"outline-none\")}\n >\n <span\n className={cn(\n \"min-w-0 truncate\",\n label ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {label ?? ctx.placeholder}\n </span>\n <motion.span\n animate={{ rotate: 180 }}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n className=\"text-muted-foreground\"\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n\n <div className=\"h-px bg-border\" />\n\n <motion.ul\n initial=\"hidden\"\n animate=\"show\"\n variants={ctx.reduce ? undefined : LIST}\n className=\"p-1\"\n >\n {children}\n </motion.ul>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </>\n );\n}\n\nexport interface MorphSelectItemProps {\n value: string;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectItem({\n value,\n disabled = false,\n className,\n children,\n}: MorphSelectItemProps) {\n const ctx = useMorphContext(\"MorphSelectItem\");\n const selected = ctx.value === value;\n const label = typeof children === \"string\" ? children : value;\n\n useLayoutEffect(() => {\n ctx.register(value, label);\n return () => ctx.unregister(value);\n }, [ctx.register, ctx.unregister, value, label]);\n\n return (\n <motion.li variants={ctx.reduce ? undefined : ITEM}>\n <button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n disabled={disabled}\n onClick={() => ctx.select(value)}\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors\",\n selected\n ? \"bg-muted text-foreground\"\n : \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n {selected ? <Check className=\"h-3.5 w-3.5 shrink-0\" /> : null}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C,MAAM,WAAW,IAAI,UAAU;CAC/B,MAAM,QAAQ,OAAO,aAAa,WAAW,WAAW;CAExD,sBAAsB;EACpB,IAAI,SAAS,OAAO,KAAK;EACzB,aAAa,IAAI,WAAW,KAAK;CACnC,GAAG;EAAC,IAAI;EAAU,IAAI;EAAY;EAAO;CAAK,CAAC;CAE/C,OACE,oBAAC,OAAO,IAAR;EAAW,UAAU,IAAI,SAAS,KAAA,IAAY;EAC5C,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,MAAK;GACL,iBAAe;GACL;GACV,eAAe,IAAI,OAAO,KAAK;GAC/B,WAAW,GACT,4HACA,WACI,6BACA,qFACJ,oDACA,SACF;GAbF,UAAA,CAeG,UACA,WAAW,oBAAC,OAAD,EAAO,WAAU,uBAAwB,CAAA,IAAI,IACnD;;CACC,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"select-morph.js","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport {\n AnimatePresence,\n motion,\n type Transition,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\n// Shared-layout morph: trigger box grows into the panel and back, one surface.\nconst MORPH: Transition = { type: \"spring\", duration: 0.5, bounce: 0.22 };\n// Trigger and panel header share this row so the morph stays seamless.\nconst ROW = \"flex w-full items-center justify-between gap-2 px-3.5 py-2.5 text-sm\";\n\nconst LIST: Variants = {\n hidden: {},\n show: { transition: { staggerChildren: 0.035, delayChildren: 0.08 } },\n};\nconst ITEM: Variants = {\n hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\ninterface MorphContextValue {\n value: string | undefined;\n open: boolean;\n setOpen: (open: boolean) => void;\n select: (value: string) => void;\n register: (value: string, label: string) => void;\n unregister: (value: string) => void;\n labelFor: (value: string | undefined) => string | undefined;\n placeholder: string;\n setPlaceholder: (p: string) => void;\n reduce: boolean;\n layoutId: string;\n triggerId: string;\n listId: string;\n disabled: boolean;\n}\n\nconst MorphContext = createContext<MorphContextValue | null>(null);\n\nfunction useMorphContext(component: string) {\n const ctx = useContext(MorphContext);\n if (!ctx) throw new Error(`${component} must be used within <MorphSelect>`);\n return ctx;\n}\n\nexport interface MorphSelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\n/**\n * Select whose trigger morphs into the panel via a shared layoutId — instead of\n * a separate dropdown opening, the trigger itself grows into the menu and\n * shrinks back, never detaching. Composable like `Select` (the gooey variant).\n */\nexport function MorphSelect({\n value,\n defaultValue,\n onValueChange,\n disabled = false,\n className,\n children,\n}: MorphSelectProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [internal, setInternal] = useState(defaultValue);\n // ref-counted: items render twice (hidden registrar + open panel), so a\n // label is only dropped once every copy with that value has unmounted.\n const [labels, setLabels] = useState<Map<string, { label: string; count: number }>>(new Map());\n const [placeholder, setPlaceholder] = useState(\"Select\");\n\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n\n const select = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n setOpen(false);\n },\n [controlled, onValueChange],\n );\n\n const register = useCallback((v: string, label: string) => {\n setLabels((m) => {\n const next = new Map(m);\n next.set(v, { label, count: (m.get(v)?.count ?? 0) + 1 });\n return next;\n });\n }, []);\n const unregister = useCallback((v: string) => {\n setLabels((m) => {\n const entry = m.get(v);\n if (!entry) return m;\n const next = new Map(m);\n if (entry.count <= 1) next.delete(v);\n else next.set(v, { label: entry.label, count: entry.count - 1 });\n return next;\n });\n }, []);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n const onPointer = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n value: current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labelFor: (v) => (v === undefined ? undefined : labels.get(v)?.label),\n placeholder,\n setPlaceholder,\n reduce,\n layoutId: `${baseId}-surface`,\n triggerId: `${baseId}-trigger`,\n listId: `${baseId}-list`,\n disabled,\n }),\n [current, open, select, register, unregister, labels, placeholder, reduce, baseId, disabled],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={rootRef} className={cn(\"relative\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphSelectValueProps {\n placeholder?: string;\n className?: string;\n}\n\nexport function MorphSelectValue({ placeholder, className }: MorphSelectValueProps) {\n const ctx = useMorphContext(\"MorphSelectValue\");\n // surface the placeholder so the morph header (rendered by content) matches\n useEffect(() => {\n if (placeholder) ctx.setPlaceholder(placeholder);\n }, [placeholder, ctx.setPlaceholder]);\n const label = ctx.labelFor(ctx.value);\n return (\n <span className={cn(label ? \"text-foreground\" : \"text-muted-foreground\", className)}>\n {label ?? placeholder ?? \"Select\"}\n </span>\n );\n}\n\nexport interface MorphSelectTriggerProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectTrigger({ className, children }: MorphSelectTriggerProps) {\n const ctx = useMorphContext(\"MorphSelectTrigger\");\n return (\n <>\n {/* invisible sizer reserves the closed height (the morph surface is\n absolute, so this keeps surrounding layout from shifting) */}\n <div aria-hidden inert className={cn(ROW, \"invisible rounded-xl border border-border\")}>\n {children}\n <ChevronDown className=\"h-4 w-4\" />\n </div>\n\n <AnimatePresence initial={false} mode=\"popLayout\">\n {!ctx.open ? (\n <motion.button\n key=\"trigger\"\n layoutId={ctx.layoutId}\n type=\"button\"\n id={ctx.triggerId}\n disabled={ctx.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={ctx.open}\n aria-controls={ctx.listId}\n onClick={() => ctx.setOpen(true)}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n style={{ borderRadius: 12 }}\n className={cn(\n ROW,\n \"absolute inset-x-0 top-0 z-10 border border-border bg-background text-foreground outline-none transition-colors\",\n \"hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n <motion.span layout=\"position\" className=\"min-w-0 truncate\">\n {children}\n </motion.span>\n <motion.span layout=\"position\" className=\"text-muted-foreground\">\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n ) : null}\n </AnimatePresence>\n </>\n );\n}\n\nexport interface MorphSelectContentProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectContent({ className, children }: MorphSelectContentProps) {\n const ctx = useMorphContext(\"MorphSelectContent\");\n const label = ctx.labelFor(ctx.value);\n return (\n <>\n {/* always-mounted, hidden — keeps item label registrations alive while\n closed so the trigger shows the selected value before first open */}\n <div className=\"hidden\">{children}</div>\n\n <AnimatePresence initial={false} mode=\"popLayout\">\n {ctx.open ? (\n <motion.div\n key=\"panel\"\n layoutId={ctx.layoutId}\n id={ctx.listId}\n role=\"listbox\"\n aria-labelledby={ctx.triggerId}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n style={{ borderRadius: 12 }}\n className={cn(\n \"absolute inset-x-0 top-0 z-30 overflow-hidden border border-border bg-background shadow-lg\",\n className,\n )}\n >\n {/* header mirrors the trigger (continuous morph) and collapses the\n panel back into the trigger when clicked */}\n <motion.button\n type=\"button\"\n layout=\"position\"\n aria-expanded\n onClick={() => ctx.setOpen(false)}\n className={cn(ROW, \"outline-none\")}\n >\n <span\n className={cn(\n \"min-w-0 truncate\",\n label ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {label ?? ctx.placeholder}\n </span>\n <motion.span\n animate={{ rotate: 180 }}\n transition={ctx.reduce ? { duration: 0 } : MORPH}\n className=\"text-muted-foreground\"\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n\n <div className=\"h-px bg-border\" />\n\n <motion.ul\n initial=\"hidden\"\n animate=\"show\"\n variants={ctx.reduce ? undefined : LIST}\n className=\"p-1\"\n >\n {children}\n </motion.ul>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </>\n );\n}\n\nexport interface MorphSelectItemProps {\n value: string;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function MorphSelectItem({\n value,\n disabled = false,\n className,\n children,\n}: MorphSelectItemProps) {\n const ctx = useMorphContext(\"MorphSelectItem\");\n const selected = ctx.value === value;\n const label = typeof children === \"string\" ? children : value;\n\n useLayoutEffect(() => {\n ctx.register(value, label);\n return () => ctx.unregister(value);\n }, [ctx.register, ctx.unregister, value, label]);\n\n return (\n <motion.li variants={ctx.reduce ? undefined : ITEM}>\n <button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n disabled={disabled}\n onClick={() => ctx.select(value)}\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors\",\n selected\n ? \"bg-muted text-foreground\"\n : \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n {selected ? <Check className=\"h-3.5 w-3.5 shrink-0\" /> : null}\n </button>\n </motion.li>\n );\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,QAAoB;CAAE,MAAM;CAAU,UAAU;CAAK,QAAQ;AAAK;AAExE,MAAM,MAAM;AAEZ,MAAM,OAAiB;CACrB,QAAQ,CAAC;CACT,MA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AAU,IAAI;EAAY;EAAO;CAAK,CAAC;CAE/C,OACE,oBAAC,OAAO,IAAR;EAAW,UAAU,IAAI,SAAS,KAAA,IAAY;EAC5C,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,MAAK;GACL,iBAAe;GACL;GACV,eAAe,IAAI,OAAO,KAAK;GAC/B,WAAW,GACT,4HACA,WACI,6BACA,qFACJ,oDACA,SACF;GAbF,UAAA,CAeG,UACA,WAAW,oBAAC,OAAD,EAAO,WAAU,uBAAwB,CAAA,IAAI,IACnD;;CACC,CAAA;AAEf"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { Check, ChevronDown } from "lucide-react";
|
|
4
|
+
import { cn } from "cn";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
import { motion, useReducedMotion } from "motion/react";
|
|
7
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
8
8
|
//#region src/components/motion/select.tsx
|
|
9
9
|
const INSTANT_TRANSITION = { duration: 0 };
|
|
10
10
|
const CHEVRON_TRANSITION = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/motion/select.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion, type Variants } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nconst INSTANT_TRANSITION: Transition = { duration: 0 };\n\n// Spring with bounce powers the unfold/separation; per-property timings in the\n// content choreograph it (see SelectContent). Mirrors bouncy-accordion's feel.\nconst CHEVRON_TRANSITION: Transition = { type: \"spring\", duration: 0.4, bounce: 0.3 };\n\nconst LIST_VARIANTS: Variants = {\n hidden: {},\n show: { transition: { staggerChildren: 0.035, delayChildren: 0.05 } },\n};\nconst ITEM_VARIANTS: Variants = {\n hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\ntype Placement = \"bottom\" | \"top\";\n\ninterface SelectContextValue {\n value: string | undefined;\n open: boolean;\n setOpen: (open: boolean) => void;\n select: (value: string) => void;\n register: (value: string, label: string) => void;\n unregister: (value: string) => void;\n labelFor: (value: string | undefined) => string | undefined;\n reduce: boolean;\n triggerId: string;\n listId: string;\n disabled: boolean;\n placement: Placement;\n setPlacement: (p: Placement) => void;\n}\n\nconst SelectContext = createContext<SelectContextValue | null>(null);\n\nfunction useSelectContext(component: string) {\n const ctx = useContext(SelectContext);\n if (!ctx) throw new Error(`${component} must be used within <Select>`);\n return ctx;\n}\n\nexport interface SelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /**\n * Controlled open state of the panel. A layout that stacks selects can hold\n * this to keep exactly one panel open — the panel is absolutely positioned\n * inside its field, so two open at once paint over each other's options.\n */\n open?: boolean;\n /** Uncontrolled initial open state. Default false. */\n defaultOpen?: boolean;\n /**\n * Fires whenever the panel opens or closes. The panel is absolutely\n * positioned inside the field, so a layout that stacks selects has to know\n * which one is open to paint it above its neighbours.\n */\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function Select({\n value,\n defaultValue,\n onValueChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disabled = false,\n className,\n children,\n}: SelectProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internal, setInternal] = useState(defaultValue);\n const [labels, setLabels] = useState<Map<string, string>>(new Map());\n const [placement, setPlacement] = useState<Placement>(\"bottom\");\n\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const openControlled = openProp !== undefined;\n const open = openControlled ? openProp : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, openControlled],\n );\n\n const select = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n setOpen(false);\n },\n [controlled, onValueChange, setOpen],\n );\n\n const register = useCallback((v: string, label: string) => {\n setLabels((m) => (m.get(v) === label ? m : new Map(m).set(v, label)));\n }, []);\n const unregister = useCallback((v: string) => {\n setLabels((m) => {\n if (!m.has(v)) return m;\n const next = new Map(m);\n next.delete(v);\n return next;\n });\n }, []);\n\n // close on outside pointer / escape\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n const onPointer = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, setOpen]);\n\n const ctx = useMemo<SelectContextValue>(\n () => ({\n value: current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labelFor: (v) => (v === undefined ? undefined : labels.get(v)),\n reduce,\n triggerId: `${baseId}-trigger`,\n listId: `${baseId}-list`,\n disabled,\n placement,\n setPlacement,\n }),\n [\n current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labels,\n reduce,\n baseId,\n disabled,\n placement,\n ],\n );\n\n return (\n <SelectContext.Provider value={ctx}>\n <div ref={rootRef} className={cn(\"relative\", className)}>\n {children}\n </div>\n </SelectContext.Provider>\n );\n}\n\nexport interface SelectTriggerProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectTrigger({ className, children }: SelectTriggerProps) {\n const ctx = useSelectContext(\"SelectTrigger\");\n const isTop = ctx.placement === \"top\";\n // edge facing the panel flattens then rounds; the far edge stays rounded.\n // All four corners are specified so none gets stranded when placement flips.\n const kf = ctx.open ? [0, 0, 12] : [12, 0, 12];\n const kfT: Transition = ctx.reduce\n ? { duration: 0 }\n : ctx.open\n ? { duration: 0.6, times: [0, 0.4, 1], ease: EASE_OUT }\n : { duration: 0.42, times: [0, 0.5, 1], ease: EASE_OUT };\n return (\n <motion.button\n type=\"button\"\n id={ctx.triggerId}\n disabled={ctx.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={ctx.open}\n aria-controls={ctx.listId}\n onClick={() => ctx.setOpen(!ctx.open)}\n // Gooey: the edge facing the panel snaps flat (panel attached) then rounds\n // back once the panel pulls away — the two pinch apart.\n initial={false}\n animate={{\n borderTopLeftRadius: isTop ? kf : 12,\n borderTopRightRadius: isTop ? kf : 12,\n borderBottomLeftRadius: isTop ? 12 : kf,\n borderBottomRightRadius: isTop ? 12 : kf,\n }}\n transition={{\n borderTopLeftRadius: isTop ? kfT : INSTANT_TRANSITION,\n borderTopRightRadius: isTop ? kfT : INSTANT_TRANSITION,\n borderBottomLeftRadius: isTop ? INSTANT_TRANSITION : kfT,\n borderBottomRightRadius: isTop ? INSTANT_TRANSITION : kfT,\n }}\n className={cn(\n \"relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-foreground text-sm outline-none transition-colors\",\n \"hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n <motion.span\n aria-hidden\n animate={{ rotate: ctx.open ? 180 : 0 }}\n transition={ctx.reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n className=\"text-muted-foreground\"\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n );\n}\n\nexport interface SelectValueProps {\n placeholder?: string;\n className?: string;\n}\n\nexport function SelectValue({ placeholder, className }: SelectValueProps) {\n const ctx = useSelectContext(\"SelectValue\");\n const label = ctx.labelFor(ctx.value);\n return (\n <span className={cn(label ? \"text-foreground\" : \"text-muted-foreground\", className)}>\n {label ?? placeholder ?? \"Select\"}\n </span>\n );\n}\n\nexport interface SelectContentProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectContent({ className, children }: SelectContentProps) {\n const ctx = useSelectContext(\"SelectContent\");\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState(0);\n const open = ctx.open;\n const { setPlacement } = ctx;\n\n useLayoutEffect(() => {\n const node = innerRef.current;\n if (!node) return;\n const measure = () => setHeight(node.offsetHeight);\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n });\n\n // On open, flip upward when there isn't room below and there's more above.\n useLayoutEffect(() => {\n if (!open) return;\n const trigger = document.getElementById(ctx.triggerId);\n const node = innerRef.current;\n if (!trigger || !node) return;\n const rect = trigger.getBoundingClientRect();\n const h = node.offsetHeight;\n const below = window.innerHeight - rect.bottom;\n const above = rect.top;\n setPlacement(below < h + 16 && above > below ? \"top\" : \"bottom\");\n }, [open, ctx.triggerId, setPlacement]);\n\n // Specify EVERY corner + both margins each render. The near edge (facing the\n // trigger) animates flat->round and the gap opens on that side; the far edge\n // stays rounded and its margin pinned to 0. Setting all of them avoids a\n // stranded square corner when the placement flips between opens.\n const isTop = ctx.placement === \"top\";\n const nearGap = open ? 8 : 0;\n const nearRadius = open ? 12 : 0;\n\n const gapT: Transition = open\n ? { type: \"spring\", duration: 0.6, bounce: 0.5, delay: 0.12 }\n : { type: \"spring\", duration: 0.3, bounce: 0.1 };\n const radiusT: Transition = open\n ? { duration: 0.3, ease: EASE_OUT, delay: 0.14 }\n : { duration: 0.16, ease: EASE_OUT };\n\n // Items stay mounted (open just animates the panel) so each item's label\n // registration persists — otherwise the trigger would fall back to the\n // placeholder the moment the panel closes.\n return (\n <motion.div\n id={ctx.listId}\n role=\"listbox\"\n aria-labelledby={ctx.triggerId}\n aria-hidden={!open}\n inert={!open}\n initial={false}\n animate={\n ctx.reduce\n ? { opacity: open ? 1 : 0, height: open ? height : 0 }\n : {\n opacity: open ? 1 : 0,\n height: open ? height : 0,\n // gap opens on the side facing the trigger\n marginTop: isTop ? 0 : nearGap,\n marginBottom: isTop ? nearGap : 0,\n // near corners go flat->round; far corners stay rounded\n borderTopLeftRadius: isTop ? 12 : nearRadius,\n borderTopRightRadius: isTop ? 12 : nearRadius,\n borderBottomLeftRadius: isTop ? nearRadius : 12,\n borderBottomRightRadius: isTop ? nearRadius : 12,\n }\n }\n transition={\n ctx.reduce\n ? { duration: 0.12 }\n : {\n opacity: open ? { duration: 0.18 } : { duration: 0.16, delay: 0.12 },\n height: open\n ? { type: \"spring\", duration: 0.42, bounce: 0.14 }\n : { duration: 0.26, ease: EASE_OUT, delay: 0.14 },\n marginTop: isTop ? INSTANT_TRANSITION : gapT,\n marginBottom: isTop ? gapT : INSTANT_TRANSITION,\n borderTopLeftRadius: isTop ? INSTANT_TRANSITION : radiusT,\n borderTopRightRadius: isTop ? INSTANT_TRANSITION : radiusT,\n borderBottomLeftRadius: isTop ? radiusT : INSTANT_TRANSITION,\n borderBottomRightRadius: isTop ? radiusT : INSTANT_TRANSITION,\n }\n }\n style={{\n transformOrigin: isTop ? \"bottom\" : \"top\",\n overflow: \"hidden\",\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n // flush against the trigger, then separates into its own rounded pill;\n // sits above or below depending on available space\n className={cn(\n \"absolute right-0 left-0 z-20 rounded-xl border border-border bg-background shadow-lg\",\n isTop ? \"bottom-full\" : \"top-full\",\n className,\n )}\n >\n <motion.div\n ref={innerRef}\n variants={ctx.reduce ? undefined : LIST_VARIANTS}\n initial={false}\n animate={open ? \"show\" : \"hidden\"}\n className=\"p-1\"\n >\n {children}\n </motion.div>\n </motion.div>\n );\n}\n\nexport interface SelectItemProps {\n value: string;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectItem({ value, disabled = false, className, children }: SelectItemProps) {\n const ctx = useSelectContext(\"SelectItem\");\n const selected = ctx.value === value;\n const label = typeof children === \"string\" ? children : value;\n\n useLayoutEffect(() => {\n ctx.register(value, label);\n return () => ctx.unregister(value);\n }, [ctx.register, ctx.unregister, value, label]);\n\n return (\n <motion.li variants={ctx.reduce ? undefined : ITEM_VARIANTS}>\n <button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n disabled={disabled}\n onClick={() => ctx.select(value)}\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors\",\n selected\n ? \"bg-muted text-foreground\"\n : \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n {selected ? <Check className=\"h-3.5 w-3.5 shrink-0\" /> : null}\n </button>\n </motion.li>\n );\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,qBAAiC,EAAE,UAAU,EAAE;AAIrD,MAAM,qBAAiC;CAAE,MAAM;CAAU,UAAU;CAAK,QAAQ;AAAI;AAEpF,MAAM,gBAA0B;CAC9B,QAAQ,CAAC;CACT,MAAM,EAAE,YAAY;EAAE,iBAAiB;EAAO,eAAe;CAAK,EAAE;AACtE;AACA,MAAM,gBAA0B;CAC9B,QAAQ;EAAE,SAAS;EAAG,GAAG;EAAI,QAAQ;CAAY;CACjD,MAAM;EAAE,SAAS;EAAG,GAAG;EAAG,QAAQ;CAAY;AAChD;AAoBA,MAAM,gBAAgB,cAAyC,IAAI;AAEnE,SAAS,iBAAiB,WAAmB;CAC3C,MAAM,MAAM,WAAW,aAAa;CACpC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,GAAG,UAAU,8BAA8B;CACrE,OAAO;AACT;AAyBA,SAAgB,OAAO,EACrB,OACA,cACA,eACA,MAAM,UACN,cAAc,OACd,cAC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AAK,IAC/C;IAAE,UAAU;IAAM,MAAM;IAAU,OAAO;GAAK;GAClD,WAAW,QAAQ,qBAAqB;GACxC,cAAc,QAAQ,OAAO;GAC7B,qBAAqB,QAAQ,qBAAqB;GAClD,sBAAsB,QAAQ,qBAAqB;GACnD,wBAAwB,QAAQ,UAAU;GAC1C,yBAAyB,QAAQ,UAAU;EAC7C;EAEN,OAAO;GACL,iBAAiB,QAAQ,WAAW;GACpC,UAAU;GACV,eAAe,OAAO,SAAS;EACjC;EAGA,WAAW,GACT,wFACA,QAAQ,gBAAgB,YACxB,SACF;EAEA,UAAA,oBAAC,OAAO,KAAR;GACE,KAAK;GACL,UAAU,IAAI,SAAS,KAAA,IAAY;GACnC,SAAS;GACT,SAAS,OAAO,SAAS;GACzB,WAAU;GAET;EACS,CAAA;CACF,CAAA;AAEhB;AASA,SAAgB,WAAW,EAAE,OAAO,WAAW,OAAO,WAAW,YAA6B;CAC5F,MAAM,MAAM,iBAAiB,YAAY;CACzC,MAAM,WAAW,IAAI,UAAU;CAC/B,MAAM,QAAQ,OAAO,aAAa,WAAW,WAAW;CAExD,sBAAsB;EACpB,IAAI,SAAS,OAAO,KAAK;EACzB,aAAa,IAAI,WAAW,KAAK;CACnC,GAAG;EAAC,IAAI;EAAU,IAAI;EAAY;EAAO;CAAK,CAAC;CAE/C,OACE,oBAAC,OAAO,IAAR;EAAW,UAAU,IAAI,SAAS,KAAA,IAAY;EAC5C,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,MAAK;GACL,iBAAe;GACL;GACV,eAAe,IAAI,OAAO,KAAK;GAC/B,WAAW,GACT,4HACA,WACI,6BACA,qFACJ,oDACA,SACF;GAbF,UAAA,CAeG,UACA,WAAW,oBAAC,OAAD,EAAO,WAAU,uBAAwB,CAAA,IAAI,IACnD;;CACC,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/motion/select.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion, type Variants } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../lib/ease\";\n\nconst INSTANT_TRANSITION: Transition = { duration: 0 };\n\n// Spring with bounce powers the unfold/separation; per-property timings in the\n// content choreograph it (see SelectContent). Mirrors bouncy-accordion's feel.\nconst CHEVRON_TRANSITION: Transition = { type: \"spring\", duration: 0.4, bounce: 0.3 };\n\nconst LIST_VARIANTS: Variants = {\n hidden: {},\n show: { transition: { staggerChildren: 0.035, delayChildren: 0.05 } },\n};\nconst ITEM_VARIANTS: Variants = {\n hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\ntype Placement = \"bottom\" | \"top\";\n\ninterface SelectContextValue {\n value: string | undefined;\n open: boolean;\n setOpen: (open: boolean) => void;\n select: (value: string) => void;\n register: (value: string, label: string) => void;\n unregister: (value: string) => void;\n labelFor: (value: string | undefined) => string | undefined;\n reduce: boolean;\n triggerId: string;\n listId: string;\n disabled: boolean;\n placement: Placement;\n setPlacement: (p: Placement) => void;\n}\n\nconst SelectContext = createContext<SelectContextValue | null>(null);\n\nfunction useSelectContext(component: string) {\n const ctx = useContext(SelectContext);\n if (!ctx) throw new Error(`${component} must be used within <Select>`);\n return ctx;\n}\n\nexport interface SelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /**\n * Controlled open state of the panel. A layout that stacks selects can hold\n * this to keep exactly one panel open — the panel is absolutely positioned\n * inside its field, so two open at once paint over each other's options.\n */\n open?: boolean;\n /** Uncontrolled initial open state. Default false. */\n defaultOpen?: boolean;\n /**\n * Fires whenever the panel opens or closes. The panel is absolutely\n * positioned inside the field, so a layout that stacks selects has to know\n * which one is open to paint it above its neighbours.\n */\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function Select({\n value,\n defaultValue,\n onValueChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disabled = false,\n className,\n children,\n}: SelectProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internal, setInternal] = useState(defaultValue);\n const [labels, setLabels] = useState<Map<string, string>>(new Map());\n const [placement, setPlacement] = useState<Placement>(\"bottom\");\n\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const openControlled = openProp !== undefined;\n const open = openControlled ? openProp : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, openControlled],\n );\n\n const select = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n setOpen(false);\n },\n [controlled, onValueChange, setOpen],\n );\n\n const register = useCallback((v: string, label: string) => {\n setLabels((m) => (m.get(v) === label ? m : new Map(m).set(v, label)));\n }, []);\n const unregister = useCallback((v: string) => {\n setLabels((m) => {\n if (!m.has(v)) return m;\n const next = new Map(m);\n next.delete(v);\n return next;\n });\n }, []);\n\n // close on outside pointer / escape\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n const onPointer = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, setOpen]);\n\n const ctx = useMemo<SelectContextValue>(\n () => ({\n value: current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labelFor: (v) => (v === undefined ? undefined : labels.get(v)),\n reduce,\n triggerId: `${baseId}-trigger`,\n listId: `${baseId}-list`,\n disabled,\n placement,\n setPlacement,\n }),\n [\n current,\n open,\n setOpen,\n select,\n register,\n unregister,\n labels,\n reduce,\n baseId,\n disabled,\n placement,\n ],\n );\n\n return (\n <SelectContext.Provider value={ctx}>\n <div ref={rootRef} className={cn(\"relative\", className)}>\n {children}\n </div>\n </SelectContext.Provider>\n );\n}\n\nexport interface SelectTriggerProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectTrigger({ className, children }: SelectTriggerProps) {\n const ctx = useSelectContext(\"SelectTrigger\");\n const isTop = ctx.placement === \"top\";\n // edge facing the panel flattens then rounds; the far edge stays rounded.\n // All four corners are specified so none gets stranded when placement flips.\n const kf = ctx.open ? [0, 0, 12] : [12, 0, 12];\n const kfT: Transition = ctx.reduce\n ? { duration: 0 }\n : ctx.open\n ? { duration: 0.6, times: [0, 0.4, 1], ease: EASE_OUT }\n : { duration: 0.42, times: [0, 0.5, 1], ease: EASE_OUT };\n return (\n <motion.button\n type=\"button\"\n id={ctx.triggerId}\n disabled={ctx.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={ctx.open}\n aria-controls={ctx.listId}\n onClick={() => ctx.setOpen(!ctx.open)}\n // Gooey: the edge facing the panel snaps flat (panel attached) then rounds\n // back once the panel pulls away — the two pinch apart.\n initial={false}\n animate={{\n borderTopLeftRadius: isTop ? kf : 12,\n borderTopRightRadius: isTop ? kf : 12,\n borderBottomLeftRadius: isTop ? 12 : kf,\n borderBottomRightRadius: isTop ? 12 : kf,\n }}\n transition={{\n borderTopLeftRadius: isTop ? kfT : INSTANT_TRANSITION,\n borderTopRightRadius: isTop ? kfT : INSTANT_TRANSITION,\n borderBottomLeftRadius: isTop ? INSTANT_TRANSITION : kfT,\n borderBottomRightRadius: isTop ? INSTANT_TRANSITION : kfT,\n }}\n className={cn(\n \"relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-foreground text-sm outline-none transition-colors\",\n \"hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n <motion.span\n aria-hidden\n animate={{ rotate: ctx.open ? 180 : 0 }}\n transition={ctx.reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n className=\"text-muted-foreground\"\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n );\n}\n\nexport interface SelectValueProps {\n placeholder?: string;\n className?: string;\n}\n\nexport function SelectValue({ placeholder, className }: SelectValueProps) {\n const ctx = useSelectContext(\"SelectValue\");\n const label = ctx.labelFor(ctx.value);\n return (\n <span className={cn(label ? \"text-foreground\" : \"text-muted-foreground\", className)}>\n {label ?? placeholder ?? \"Select\"}\n </span>\n );\n}\n\nexport interface SelectContentProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectContent({ className, children }: SelectContentProps) {\n const ctx = useSelectContext(\"SelectContent\");\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState(0);\n const open = ctx.open;\n const { setPlacement } = ctx;\n\n useLayoutEffect(() => {\n const node = innerRef.current;\n if (!node) return;\n const measure = () => setHeight(node.offsetHeight);\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n });\n\n // On open, flip upward when there isn't room below and there's more above.\n useLayoutEffect(() => {\n if (!open) return;\n const trigger = document.getElementById(ctx.triggerId);\n const node = innerRef.current;\n if (!trigger || !node) return;\n const rect = trigger.getBoundingClientRect();\n const h = node.offsetHeight;\n const below = window.innerHeight - rect.bottom;\n const above = rect.top;\n setPlacement(below < h + 16 && above > below ? \"top\" : \"bottom\");\n }, [open, ctx.triggerId, setPlacement]);\n\n // Specify EVERY corner + both margins each render. The near edge (facing the\n // trigger) animates flat->round and the gap opens on that side; the far edge\n // stays rounded and its margin pinned to 0. Setting all of them avoids a\n // stranded square corner when the placement flips between opens.\n const isTop = ctx.placement === \"top\";\n const nearGap = open ? 8 : 0;\n const nearRadius = open ? 12 : 0;\n\n const gapT: Transition = open\n ? { type: \"spring\", duration: 0.6, bounce: 0.5, delay: 0.12 }\n : { type: \"spring\", duration: 0.3, bounce: 0.1 };\n const radiusT: Transition = open\n ? { duration: 0.3, ease: EASE_OUT, delay: 0.14 }\n : { duration: 0.16, ease: EASE_OUT };\n\n // Items stay mounted (open just animates the panel) so each item's label\n // registration persists — otherwise the trigger would fall back to the\n // placeholder the moment the panel closes.\n return (\n <motion.div\n id={ctx.listId}\n role=\"listbox\"\n aria-labelledby={ctx.triggerId}\n aria-hidden={!open}\n inert={!open}\n initial={false}\n animate={\n ctx.reduce\n ? { opacity: open ? 1 : 0, height: open ? height : 0 }\n : {\n opacity: open ? 1 : 0,\n height: open ? height : 0,\n // gap opens on the side facing the trigger\n marginTop: isTop ? 0 : nearGap,\n marginBottom: isTop ? nearGap : 0,\n // near corners go flat->round; far corners stay rounded\n borderTopLeftRadius: isTop ? 12 : nearRadius,\n borderTopRightRadius: isTop ? 12 : nearRadius,\n borderBottomLeftRadius: isTop ? nearRadius : 12,\n borderBottomRightRadius: isTop ? nearRadius : 12,\n }\n }\n transition={\n ctx.reduce\n ? { duration: 0.12 }\n : {\n opacity: open ? { duration: 0.18 } : { duration: 0.16, delay: 0.12 },\n height: open\n ? { type: \"spring\", duration: 0.42, bounce: 0.14 }\n : { duration: 0.26, ease: EASE_OUT, delay: 0.14 },\n marginTop: isTop ? INSTANT_TRANSITION : gapT,\n marginBottom: isTop ? gapT : INSTANT_TRANSITION,\n borderTopLeftRadius: isTop ? INSTANT_TRANSITION : radiusT,\n borderTopRightRadius: isTop ? INSTANT_TRANSITION : radiusT,\n borderBottomLeftRadius: isTop ? radiusT : INSTANT_TRANSITION,\n borderBottomRightRadius: isTop ? radiusT : INSTANT_TRANSITION,\n }\n }\n style={{\n transformOrigin: isTop ? \"bottom\" : \"top\",\n overflow: \"hidden\",\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n // flush against the trigger, then separates into its own rounded pill;\n // sits above or below depending on available space\n className={cn(\n \"absolute right-0 left-0 z-20 rounded-xl border border-border bg-background shadow-lg\",\n isTop ? \"bottom-full\" : \"top-full\",\n className,\n )}\n >\n <motion.div\n ref={innerRef}\n variants={ctx.reduce ? undefined : LIST_VARIANTS}\n initial={false}\n animate={open ? \"show\" : \"hidden\"}\n className=\"p-1\"\n >\n {children}\n </motion.div>\n </motion.div>\n );\n}\n\nexport interface SelectItemProps {\n value: string;\n disabled?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nexport function SelectItem({ value, disabled = false, className, children }: SelectItemProps) {\n const ctx = useSelectContext(\"SelectItem\");\n const selected = ctx.value === value;\n const label = typeof children === \"string\" ? children : value;\n\n useLayoutEffect(() => {\n ctx.register(value, label);\n return () => ctx.unregister(value);\n }, [ctx.register, ctx.unregister, value, label]);\n\n return (\n <motion.li variants={ctx.reduce ? undefined : ITEM_VARIANTS}>\n <button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n disabled={disabled}\n onClick={() => ctx.select(value)}\n className={cn(\n \"flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors\",\n selected\n ? \"bg-muted text-foreground\"\n : \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n >\n {children}\n {selected ? <Check className=\"h-3.5 w-3.5 shrink-0\" /> : null}\n </button>\n </motion.li>\n );\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,qBAAiC,EAAE,UAAU,EAAE;AAIrD,MAAM,qBAAiC;CAAE,MAAM;CAAU,UAAU;CAAK,QAAQ;AAAI;AAEpF,MAAM,gBAA0B;CAC9B,QAAQ,CAAC;CACT,MAAM,EAAE,YAAY;EAAE,iBAAiB;EAAO,eAAe;CAAK,EAAE;AACtE;AACA,MAAM,gBAA0B;CAC9B,QAAQ;EAAE,SAAS;EAAG,GAAG;EAAI,QAAQ;CAAY;CACjD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,iBAAe;GACL;GACV,eAAe,IAAI,OAAO,KAAK;GAC/B,WAAW,GACT,4HACA,WACI,6BACA,qFACJ,oDACA,SACF;GAbF,UAAA,CAeG,UACA,WAAW,oBAAC,OAAD,EAAO,WAAU,uBAAwB,CAAA,IAAI,IACnD;;CACC,CAAA;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-background.d.ts","names":[],"sources":["../../../src/components/motion/shader-background.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"shader-background.d.ts","names":[],"sources":["../../../src/components/motion/shader-background.tsx"],"mappings":";;KAkDK;EACH,iBAAiB;EACjB,kBAAkB;EAClB,YAAY;EACZ,aAAa;EACb,MAAM;EACN,OAAO;EACP,OAAO;EACP,SAAS;EACT,OAAO;EACP,cAAc;EACd,0BAA0B;EAC1B,eAAe;EACf,WAAW;EACX,YAAY;EACZ,QAAQ;EACR,WAAW;EACX,kBAAkB;EAClB,gBAAgB;EAChB,wBAAwB;EACxB,iBAAiB;EACjB,gBAAgB;;YAGN,gCAAgC;YAEhC,2BACT,KAAK;EAA4B,SAAS;IAAM,mBAAmB,MACpE;qBA4BW,4BAER;;;;;wBAMW,mBAAmB,SAAS,cAAc,QAAQ,wCAAqB,IAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "
|
|
2
|
+
import { cn } from "cn";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { useReducedMotion } from "motion/react";
|
|
5
5
|
import { ColorPanels, Dithering, DotGrid, DotOrbit, GodRays, GrainGradient, MeshGradient, Metaballs, NeuroNoise, PerlinNoise, PulsingBorder, SimplexNoise, SmokeRing, Spiral, StaticMeshGradient, StaticRadialGradient, Swirl, Voronoi, Warp, Water, Waves } from "@paper-design/shaders-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-background.js","names":[],"sources":["../../../src/components/motion/shader-background.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentType } from \"react\";\nimport {\n ColorPanels,\n type ColorPanelsProps,\n Dithering,\n type DitheringProps,\n DotGrid,\n type DotGridProps,\n DotOrbit,\n type DotOrbitProps,\n GodRays,\n type GodRaysProps,\n GrainGradient,\n type GrainGradientProps,\n MeshGradient,\n type MeshGradientProps,\n Metaballs,\n type MetaballsProps,\n NeuroNoise,\n type NeuroNoiseProps,\n PerlinNoise,\n type PerlinNoiseProps,\n PulsingBorder,\n type PulsingBorderProps,\n SimplexNoise,\n type SimplexNoiseProps,\n SmokeRing,\n type SmokeRingProps,\n Spiral,\n type SpiralProps,\n StaticMeshGradient,\n type StaticMeshGradientProps,\n StaticRadialGradient,\n type StaticRadialGradientProps,\n Swirl,\n type SwirlProps,\n Voronoi,\n type VoronoiProps,\n Warp,\n type WarpProps,\n Water,\n type WaterProps,\n Waves,\n type WavesProps,\n} from \"@paper-design/shaders-react\";\nimport {
|
|
1
|
+
{"version":3,"file":"shader-background.js","names":[],"sources":["../../../src/components/motion/shader-background.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentType } from \"react\";\nimport {\n ColorPanels,\n type ColorPanelsProps,\n Dithering,\n type DitheringProps,\n DotGrid,\n type DotGridProps,\n DotOrbit,\n type DotOrbitProps,\n GodRays,\n type GodRaysProps,\n GrainGradient,\n type GrainGradientProps,\n MeshGradient,\n type MeshGradientProps,\n Metaballs,\n type MetaballsProps,\n NeuroNoise,\n type NeuroNoiseProps,\n PerlinNoise,\n type PerlinNoiseProps,\n PulsingBorder,\n type PulsingBorderProps,\n SimplexNoise,\n type SimplexNoiseProps,\n SmokeRing,\n type SmokeRingProps,\n Spiral,\n type SpiralProps,\n StaticMeshGradient,\n type StaticMeshGradientProps,\n StaticRadialGradient,\n type StaticRadialGradientProps,\n Swirl,\n type SwirlProps,\n Voronoi,\n type VoronoiProps,\n Warp,\n type WarpProps,\n Water,\n type WaterProps,\n Waves,\n type WavesProps,\n} from \"@paper-design/shaders-react\";\nimport { cn } from \"cn\";\nimport { useReducedMotion } from \"motion/react\";\n\ntype ShaderVariantProps = {\n \"mesh-gradient\": MeshGradientProps;\n \"grain-gradient\": GrainGradientProps;\n \"dot-grid\": DotGridProps;\n \"dot-orbit\": DotOrbitProps;\n warp: WarpProps;\n waves: WavesProps;\n water: WaterProps;\n voronoi: VoronoiProps;\n swirl: SwirlProps;\n \"smoke-ring\": SmokeRingProps;\n \"static-radial-gradient\": StaticRadialGradientProps;\n \"neuro-noise\": NeuroNoiseProps;\n metaballs: MetaballsProps;\n \"god-rays\": GodRaysProps;\n spiral: SpiralProps;\n dithering: DitheringProps;\n \"pulsing-border\": PulsingBorderProps;\n \"color-panels\": ColorPanelsProps;\n \"static-mesh-gradient\": StaticMeshGradientProps;\n \"simplex-noise\": SimplexNoiseProps;\n \"perlin-noise\": PerlinNoiseProps;\n};\n\nexport type ShaderBackgroundVariant = keyof ShaderVariantProps;\n\nexport type ShaderBackgroundProps = {\n [K in ShaderBackgroundVariant]: { variant: K } & ShaderVariantProps[K];\n}[ShaderBackgroundVariant];\n\nconst VARIANT_COMPONENTS: {\n [K in ShaderBackgroundVariant]: ComponentType<ShaderVariantProps[K]>;\n} = {\n \"mesh-gradient\": MeshGradient,\n \"grain-gradient\": GrainGradient,\n \"dot-grid\": DotGrid,\n \"dot-orbit\": DotOrbit,\n warp: Warp,\n waves: Waves,\n water: Water,\n voronoi: Voronoi,\n swirl: Swirl,\n \"smoke-ring\": SmokeRing,\n \"static-radial-gradient\": StaticRadialGradient,\n \"neuro-noise\": NeuroNoise,\n metaballs: Metaballs,\n \"god-rays\": GodRays,\n spiral: Spiral,\n dithering: Dithering,\n \"pulsing-border\": PulsingBorder,\n \"color-panels\": ColorPanels,\n \"static-mesh-gradient\": StaticMeshGradient,\n \"simplex-noise\": SimplexNoise,\n \"perlin-noise\": PerlinNoise,\n};\n\nexport const SHADER_BACKGROUND_VARIANTS = Object.keys(\n VARIANT_COMPONENTS,\n) as ShaderBackgroundVariant[];\n\n/**\n * Not every variant animates (e.g. dot-grid is a static pattern), so `speed`\n * is only frozen for reduced motion when the variant actually exposes it.\n */\nexport function ShaderBackground({ variant, className, ...rest }: ShaderBackgroundProps) {\n const reducedMotion = useReducedMotion();\n const Shader = VARIANT_COMPONENTS[variant] as ComponentType<Record<string, unknown>>;\n const props = rest as Record<string, unknown>;\n const speedProps = reducedMotion && \"speed\" in props ? { speed: 0 } : {};\n\n return <Shader {...props} {...speedProps} className={cn(\"h-full w-full\", className)} />;\n}\n"],"mappings":";;;;;;AAgFA,MAAM,qBAEF;CACF,iBAAiB;CACjB,kBAAkB;CAClB,YAAY;CACZ,aAAa;CACb,MAAM;CACN,OAAO;CACP,OAAO;CACP,SAAS;CACT,OAAO;CACP,cAAc;CACd,0BAA0B;CAC1B,eAAe;CACf,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,kBAAkB;CAClB,gBAAgB;CAChB,wBAAwB;CACxB,iBAAiB;CACjB,gBAAgB;AAClB;AAEA,MAAa,6BAA6B,OAAO,KAC/C,kBACF;;;;;AAMA,SAAgB,iBAAiB,EAAE,SAAS,WAAW,GAAG,QAA+B;CACvF,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,SAAS,mBAAmB;CAClC,MAAM,QAAQ;CACd,MAAM,aAAa,iBAAiB,WAAW,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;CAEvE,OAAO,oBAAC,QAAD;EAAQ,GAAI;EAAO,GAAI;EAAY,WAAW,GAAG,iBAAiB,SAAS;CAAI,CAAA;AACxF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { SPRING_LAYOUT } from "../../lib/ease.js";
|
|
3
3
|
import { Children, cloneElement, forwardRef, isValidElement, useId, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "cn";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/shared-layout-bg.tsx
|