@kumix/ui 0.3.13 → 0.3.15
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 +12 -12
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-activity/index.js.map +1 -1
- package/dist/components/agents/agent-code.d.ts.map +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/agent-code.js.map +1 -1
- package/dist/components/agents/agent-disclosure.js +1 -1
- package/dist/components/agents/agent-disclosure.js.map +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +1 -1
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/chat-app.js +1 -1
- package/dist/components/agents/chat-app.js.map +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/code-block.js.map +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/file-diff.js.map +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/image-generation.js.map +1 -1
- package/dist/components/agents/loading-states/agent-progress.js +1 -1
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -1
- package/dist/components/agents/message-bubble.js +1 -1
- package/dist/components/agents/message-bubble.js.map +1 -1
- package/dist/components/agents/message-scroller.js +1 -1
- package/dist/components/agents/message-scroller.js.map +1 -1
- package/dist/components/agents/message.js +1 -1
- package/dist/components/agents/message.js.map +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/streaming-response.js.map +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/todo-list.js.map +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/tool-result.js.map +1 -1
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/adaptive-stepper.js.map +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-number.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +5 -4
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/metallic.js +1 -1
- package/dist/components/motion/button/metallic.js.map +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/card-folder.js.map +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/content.js.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -1
- package/dist/components/motion/combobox/context.js.map +1 -1
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/list.js.map +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/command-palette.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +3 -22
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/context-menu.js.map +1 -1
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/cylinder-carousel.js.map +1 -1
- package/dist/components/motion/digit-swap.js +1 -1
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/dock.js.map +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/dynamic-island.js +1 -1
- package/dist/components/motion/dynamic-island.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +1 -1
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts.map +1 -1
- package/dist/components/motion/expandable-control.js +1 -1
- package/dist/components/motion/expandable-control.js.map +1 -1
- package/dist/components/motion/expandable-tabs.js +1 -1
- package/dist/components/motion/expandable-tabs.js.map +1 -1
- package/dist/components/motion/expanding-arrow-button.js +1 -1
- package/dist/components/motion/expanding-arrow-button.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-tree.js.map +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/file-upload.js.map +1 -1
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/hold-action-button.js.map +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/infinite-masonry.js.map +1 -1
- package/dist/components/motion/input.d.ts.map +1 -1
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/input.js.map +1 -1
- package/dist/components/motion/liquid.js +1 -1
- package/dist/components/motion/liquid.js.map +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/magnetic.js.map +1 -1
- package/dist/components/motion/marquee.d.ts.map +1 -1
- package/dist/components/motion/marquee.js +1 -1
- package/dist/components/motion/marquee.js.map +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/morphing-tabs.js.map +1 -1
- package/dist/components/motion/multi-select/content.js +1 -1
- package/dist/components/motion/multi-select/content.js.map +1 -1
- package/dist/components/motion/multi-select/context.js +1 -1
- package/dist/components/motion/multi-select/context.js.map +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/list.js.map +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/multi-select/trigger.js.map +1 -1
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
- package/dist/components/motion/not-found/magnetic.js +1 -1
- package/dist/components/motion/not-found/magnetic.js.map +1 -1
- package/dist/components/motion/not-found/shared.js +1 -1
- package/dist/components/motion/not-found/shared.js.map +1 -1
- package/dist/components/motion/not-found/spotlight.js +1 -1
- package/dist/components/motion/not-found/spotlight.js.map +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/notification-stack.js.map +1 -1
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/otp-input.js +1 -1
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/overflow-actions.js.map +1 -1
- package/dist/components/motion/parallax.d.ts.map +1 -1
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.js +1 -1
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/preview-rail.js +1 -1
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +1 -1
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-bubble.js.map +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-fluid.js.map +1 -1
- package/dist/components/motion/range-slider-inline.d.ts +18 -0
- package/dist/components/motion/range-slider-inline.d.ts.map +1 -0
- package/dist/components/motion/range-slider-inline.js +267 -0
- package/dist/components/motion/range-slider-inline.js.map +1 -0
- package/dist/components/motion/range-slider-ruler.js +1 -1
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.js +1 -1
- package/dist/components/motion/range-slider-wave.js.map +1 -1
- package/dist/components/motion/range-slider.d.ts.map +1 -1
- package/dist/components/motion/range-slider.js +27 -11
- package/dist/components/motion/range-slider.js.map +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-progress.js.map +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/scroll-reveal.js.map +1 -1
- package/dist/components/motion/scroll-to.js +1 -1
- package/dist/components/motion/scroll-to.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +1 -1
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/signup-form.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/swipeable-list.js +1 -1
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/switch.d.ts.map +1 -1
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/switch.js.map +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
- package/dist/components/motion/table/skeleton-rows.js +1 -1
- package/dist/components/motion/table/skeleton-rows.js.map +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/table/table-menu.js.map +1 -1
- package/dist/components/motion/tabs.js +2 -2
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-reveal.js.map +1 -1
- package/dist/components/motion/text-scramble.d.ts.map +1 -1
- package/dist/components/motion/text-scramble.js +1 -1
- package/dist/components/motion/text-scramble.js.map +1 -1
- package/dist/components/motion/text-shimmer.js +1 -1
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/theme-toggle.js.map +1 -1
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tilt-card.js.map +1 -1
- package/dist/components/motion/tooltip-surface.d.ts +12 -0
- package/dist/components/motion/tooltip-surface.d.ts.map +1 -0
- package/dist/components/motion/tooltip-surface.js +97 -0
- package/dist/components/motion/tooltip-surface.js.map +1 -0
- package/dist/components/motion/tooltip.d.ts +13 -3
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +75 -104
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/motion/wheel-picker.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.d.ts.map +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/alert.js.map +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +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 +1 -1
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +1 -1
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +1 -1
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader.js +1 -1
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.js +1 -1
- package/dist/components/reui/code-block/code-block.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +1 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +1 -1
- package/dist/components/reui/filters/filters-builder.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-chip.js.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +1 -1
- package/dist/components/reui/filters/filters-editors.js.map +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/filters/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +6 -12
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +10 -17
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.js +1 -1
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-stack.js +1 -1
- package/dist/components/reui/icon-stack.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +1 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js +4 -4
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/rating.d.ts.map +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/rating.js.map +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/sortable.js +1 -1
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/stepper.d.ts.map +1 -1
- package/dist/components/reui/stepper.js +1 -1
- package/dist/components/reui/stepper.js.map +1 -1
- package/dist/components/reui/timeline.d.ts.map +1 -1
- package/dist/components/reui/timeline.js +1 -1
- package/dist/components/reui/timeline.js.map +1 -1
- package/dist/components/reui/tree.d.ts.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/reui/tree.js.map +1 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -1
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/attachment.js.map +1 -1
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/bubble.js.map +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button-group.js.map +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +1 -1
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-group.js.map +1 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/kbd.js.map +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.d.ts.map +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/marker.js.map +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/message-scroller.js.map +1 -1
- package/dist/components/ui/message.d.ts.map +1 -1
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/message.js.map +1 -1
- package/dist/components/ui/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +1 -1
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toggle-group.js +1 -1
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +1 -1
- package/dist/hooks/use-dismiss.d.ts.map +1 -1
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/lib/command-search.d.ts +10 -0
- package/dist/lib/command-search.d.ts.map +1 -0
- package/dist/lib/command-search.js +52 -0
- package/dist/lib/command-search.js.map +1 -0
- package/package.json +10 -12
|
@@ -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 {
|
|
1
|
+
{"version":3,"file":"range-slider.js","names":[],"sources":["../../../src/components/motion/range-slider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useLayoutEffect, useState } from \"react\";\nimport { motion, useMotionValue, useReducedMotion, useSpring, useTransform } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\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 const [trackWidth, setTrackWidth] = useState(292);\n useLayoutEffect(() => {\n const track = trackProps.ref.current;\n if (!track) return;\n const measure = () => {\n const width = track.getBoundingClientRect().width;\n if (width > 0) setTrackWidth(width);\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(track);\n return () => observer.disconnect();\n }, [trackProps.ref]);\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 thumbX = useTransform(pos, (p) => 8 + (Math.max(0, trackWidth - 20) * p) / 100);\n // Match InlineSlider: the 4px handle starts 8px inside the track, and\n // the rounded fill extends 8px past its left edge. Translate a full-size\n // fill inside the 2px inset clip so its corner never stretches.\n const fillX = useTransform(pos, (p) =>\n p >= 100 ? \"0%\" : `calc(${p - 100}% + ${14 - 0.16 * p}px)`,\n );\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 <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-[2px] inset-y-0 overflow-hidden rounded-lg\"\n >\n <motion.div className=\"absolute inset-0 rounded-lg bg-foreground/15\" style={{ x: fillX }} />\n </div>\n\n {/* Tick centres follow the same inset path as the handle centre. */}\n <div className=\"pointer-events-none absolute inset-x-[10px] 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 {/* Keep the handle inside the rounded progress fill at both ends. */}\n <motion.div\n {...sliderProps}\n animate={reduce ? undefined : { scaleY: dragging ? 1.35 : 1 }}\n transition={SPRING_BOUNCY}\n className=\"absolute top-1/2 left-0 h-6 w-1 rounded-full bg-foreground outline-none ring-foreground/30 ring-inset focus-visible:ring-4\"\n style={{ x: thumbX, y: \"-50%\" }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,gBAAgB;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;AAQ/E,SAAgB,YAAY,EAAE,YAAY,MAAM,WAAW,GAAG,WAA6B;CACzF,MAAM,SAAS,iBAAiB;CAChC,MAAM,EAAE,SAAS,UAAU,KAAK,KAAK,MAAM,YAAY,gBAAgB,UAAU,OAAO;CACxF,MAAM,CAAC,YAAY,iBAAiB,SAAS,GAAG;CAChD,sBAAsB;EACpB,MAAM,QAAQ,WAAW,IAAI;EAC7B,IAAI,CAAC,OAAO;EACZ,MAAM,gBAAgB;GACpB,MAAM,QAAQ,MAAM,sBAAsB,CAAC,CAAC;GAC5C,IAAI,QAAQ,GAAG,cAAc,KAAK;EACpC;EACA,QAAQ;E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L,oBAAC,OAAO,KAAR;IACE,GAAI;IACJ,SAAS,SAAS,KAAA,IAAY,EAAE,QAAQ,WAAW,OAAO,EAAE;IAC5D,YAAY;IACZ,WAAU;IACV,OAAO;KAAE,GAAG;KAAQ,GAAG;IAAO;GAC/B,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 "@kumix/utils";
|
|
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 {
|
|
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 { cn } from \"@kumix/utils\";\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(-90 ${size / 2} ${size / 2})`}\n />\n </svg>\n );\n}\n"],"mappings":";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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 "@kumix/utils";
|
|
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 { motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\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\";\nimport { cn } from \"
|
|
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\";\n\nimport { cn } from \"@kumix/utils\";\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":";;iBAgEiB;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,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
6
6
|
import { Check, ChevronDown } from "lucide-react";
|
|
@@ -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 { 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,O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,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 { 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}\n </button>\n </motion.li>\n );\n}\n"],"mappings":";;;;;;;AA0BA,MAAM,QAAoB;CAAE,MAAM;CAAU,UAAU;CAAK,QAAQ;AAAK;AAExE,MAAM,MAAM;AAEZ,MAAM,OAAiB;CACrB,QAAQ,CAAC;CACT,MAAM,EAAE,YAAY;EAAE,iBAAiB;EAAO,eAAe;CAAK,EAAE;AACtE;AACA,MAAM,OAAiB;CACrB,QAAQ;EAAE,SAAS;EAAG,GAAG;EAAI,QAAQ;C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ACE,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,7 +1,7 @@
|
|
|
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 "
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { motion, useReducedMotion } from "motion/react";
|
|
7
7
|
import { Check, ChevronDown } from "lucide-react";
|
|
@@ -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 { 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,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,cACA,WAAW,OACX,WACA,YACc;CACd,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,SAAS,MAAM;CACrB,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,CAAC,UAAU,eAAe,SAAS,YAAY;CACrD,MAAM,CAAC,QAAQ,aAAa,yBAA8B,IAAI,IAAI,CAAC;CACnE,MAAM,CA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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 { 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,cAC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../../../src/components/motion/shader-background.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"shader-background.d.ts","names":[],"sources":["../../../src/components/motion/shader-background.tsx"],"mappings":";;KAmDK;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 "@kumix/utils";
|
|
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 { useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\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":";;;;;;AAiFA,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 "@kumix/utils";
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useState,\n} from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"shared-layout-bg.js","names":[],"sources":["../../../src/components/motion/shared-layout-bg.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useId,\n useState,\n} from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\nexport interface SharedLayoutBgProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n children: ReactNode;\n /** Semantic container used for the children. */\n as?: \"div\" | \"ul\";\n /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n pillClassName?: string;\n /** Horizontal inset of the pill relative to each row (px). Default 20. */\n inset?: number;\n /** Optional positioning override for the pill wrapper inside each item. */\n pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n initial: { opacity: 0, filter: \"blur(6px)\" },\n animate: { opacity: 1, filter: \"blur(0px)\" },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0, filter: \"blur(6px)\" } : {}),\n};\n\nconst reducedVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(function SharedLayoutBg(\n {\n children,\n as = \"div\",\n className,\n onMouseLeave,\n pillClassName,\n pillContainerClassName,\n inset = 20,\n ...props\n },\n forwardedRef,\n) {\n const [activeId, setActiveId] = useState<string | null>(null);\n const uid = useId();\n const reduce = useReducedMotion();\n\n const renderedChildren = Children.toArray(children)\n .filter(isValidElement)\n .map((child, index) => {\n const el = child as ReactElement<{\n className?: string;\n onMouseEnter?: () => void;\n children?: ReactNode;\n }>;\n const childKey = el.key ? String(el.key) : `item-${index}`;\n return cloneElement(\n el,\n {\n key: childKey,\n className: cn(\"relative\", el.props.className),\n onMouseEnter: () => {\n el.props.onMouseEnter?.();\n setActiveId(childKey);\n },\n },\n <>\n <AnimatePresence custom={activeId !== null}>\n {activeId !== null ? (\n <motion.div\n variants={reduce ? reducedVariants : variants}\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n custom={activeId !== null}\n className={cn(\"pointer-events-none absolute inset-y-0\", pillContainerClassName)}\n style={{ left: -inset, right: -inset }}\n >\n {activeId === childKey ? (\n <motion.div\n layoutId={`shared-bg-${uid}`}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"pointer-events-none h-full w-full rounded-2xl bg-primary/6\",\n pillClassName,\n )}\n />\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n <div className=\"relative z-10\">{el.props.children}</div>\n </>,\n );\n });\n\n const handleMouseLeave = (event: MouseEvent<HTMLElement>) => {\n setActiveId(null);\n onMouseLeave?.(event);\n };\n\n // layoutRoot scopes the pill's layout projection to this list, so fixed or\n // scrolled ancestors can't smear scroll offsets into its movement.\n return as === \"ul\" ? (\n <motion.ul\n {...(props as HTMLMotionProps<\"ul\">)}\n ref={forwardedRef as Ref<HTMLUListElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.ul>\n ) : (\n <motion.div\n {...(props as HTMLMotionProps<\"div\">)}\n ref={forwardedRef as Ref<HTMLDivElement>}\n layoutRoot\n onMouseLeave={handleMouseLeave}\n className={cn(\"flex w-full flex-col\", className)}\n >\n {renderedChildren}\n </motion.div>\n );\n});\n"],"mappings":";;;;;;;AAsCA,MAAM,WAAqB;CACzB,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,OAAO,a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,UAAA,GAAG,MAAM;EAAc,CAAA,CACvD,EAAA,CAAA,CACJ;CACF,CAAC;CAEH,MAAM,oBAAoB,UAAmC;EAC3D,YAAY,IAAI;EAChB,eAAe,KAAK;CACtB;CAIA,OAAO,OAAO,OACZ,oBAAC,OAAO,IAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACQ,CAAA,IAEX,oBAAC,OAAO,KAAR;EACE,GAAK;EACL,KAAK;EACL,YAAA;EACA,cAAc;EACd,WAAW,GAAG,wBAAwB,SAAS;EAE9C,UAAA;CACS,CAAA;AAEhB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import "./button/index.js";
|
|
|
5
5
|
import { Checkbox } from "./checkbox.js";
|
|
6
6
|
import { Input } from "./input.js";
|
|
7
7
|
import { useCallback, useId, useMemo, useState } from "react";
|
|
8
|
-
import { cn } from "
|
|
8
|
+
import { cn } from "@kumix/utils";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
11
11
|
import { Eye, EyeOff, Lock, Mail, User } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signup-form.js","names":[],"sources":["../../../src/components/motion/signup-form.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FormEvent, type ReactNode, useCallback, useId, useMemo, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { Eye, EyeOff, Lock, Mail, User } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { StatefulButton } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { Input } from \"./input\";\n\nexport type SignUpStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\n\nexport type SignUpValues = {\n name: string;\n email: string;\n password: string;\n confirmPassword: string;\n terms: boolean;\n};\n\nexport type SignUpErrors = Partial<Record<keyof SignUpValues, string>>;\n\nexport type SignUpFormClassNames = {\n root?: string;\n header?: string;\n title?: string;\n description?: string;\n fields?: string;\n strength?: string;\n terms?: string;\n submit?: string;\n footer?: string;\n};\n\nexport interface SignUpFormProps {\n /** Controlled values. Omit for uncontrolled. */\n values?: SignUpValues;\n defaultValues?: Partial<SignUpValues>;\n onValuesChange?: (values: SignUpValues) => void;\n /** Called with valid values only. Return a promise to drive the button state. */\n onSubmit?: (values: SignUpValues) => void | Promise<void>;\n /** Replace the built-in rules — return a message per invalid field. */\n validate?: (values: SignUpValues) => SignUpErrors;\n /** Controlled submit state. Omit to let the form track it. */\n status?: SignUpStatus;\n /** Form-level failure message, shown above the submit button. */\n errorMessage?: string;\n title?: ReactNode;\n description?: ReactNode;\n submitLabel?: string;\n footer?: ReactNode;\n /** Show the password strength meter. */\n strengthMeter?: boolean;\n className?: string;\n classNames?: SignUpFormClassNames;\n}\n\nconst EMPTY_VALUES: SignUpValues = {\n name: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\",\n terms: false,\n};\n\n// Deliberately permissive. Full RFC 5322 matching is impractical in a regex and\n// rejects addresses that deliver fine; the only real check is sending mail.\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst MIN_PASSWORD_LENGTH = 8;\n\nconst STRENGTH_LABELS = [\"Too short\", \"Weak\", \"Fair\", \"Good\", \"Strong\"] as const;\n\nconst STRENGTH_COLORS = [\n \"bg-destructive\",\n \"bg-destructive\",\n \"bg-amber-500\",\n \"bg-amber-400\",\n \"bg-(--color-success)\",\n] as const;\n\n/**\n * Length-weighted strength score, 0-4. NIST SP 800-63B advises against\n * composition requirements and treats length as the dominant factor, so extra\n * character classes only nudge the score — they can't rescue a short password.\n * This is a heuristic for feedback, not entropy estimation; pair it with a\n * breach-list check server-side for anything real.\n */\nexport function passwordStrength(password: string): number {\n if (password.length < MIN_PASSWORD_LENGTH) return 0;\n\n let score = 1;\n if (password.length >= 12) score += 1;\n if (password.length >= 16) score += 1;\n\n const classes = [/[a-z]/, /[A-Z]/, /\\d/, /[^A-Za-z0-9]/].filter((pattern) =>\n pattern.test(password),\n ).length;\n if (classes >= 3) score += 1;\n\n return Math.min(score, 4);\n}\n\nfunction defaultValidate(values: SignUpValues): SignUpErrors {\n const errors: SignUpErrors = {};\n\n if (!values.name.trim()) {\n errors.name = \"Enter your name.\";\n }\n\n if (!values.email.trim()) {\n errors.email = \"Enter your email.\";\n } else if (!EMAIL_PATTERN.test(values.email)) {\n errors.email = \"That doesn't look like an email address.\";\n }\n\n if (!values.password) {\n errors.password = \"Choose a password.\";\n } else if (values.password.length < MIN_PASSWORD_LENGTH) {\n errors.password = `Use at least ${MIN_PASSWORD_LENGTH} characters.`;\n }\n\n if (!values.confirmPassword) {\n errors.confirmPassword = \"Confirm your password.\";\n } else if (values.confirmPassword !== values.password) {\n errors.confirmPassword = \"Passwords don't match.\";\n }\n\n if (!values.terms) {\n errors.terms = \"Accept the terms to continue.\";\n }\n\n return errors;\n}\n\nexport function SignUpForm({\n values: valuesProp,\n defaultValues,\n onValuesChange,\n onSubmit,\n validate,\n status: statusProp,\n errorMessage,\n title = \"Create your account\",\n description = \"Start building in under a minute.\",\n submitLabel = \"Create account\",\n footer,\n strengthMeter = true,\n className,\n classNames,\n}: SignUpFormProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n\n const controlled = valuesProp !== undefined;\n const [internalValues, setInternalValues] = useState<SignUpValues>({\n ...EMPTY_VALUES,\n ...defaultValues,\n });\n const values = controlled ? valuesProp : internalValues;\n\n const [internalStatus, setInternalStatus] = useState<SignUpStatus>(\"idle\");\n const status = statusProp ?? internalStatus;\n\n const [revealPassword, setRevealPassword] = useState(false);\n\n // \"Reward early, punish late\": errors are computed on every change, but a\n // field only *shows* its error once it has been blurred (or submit touched\n // everything). So a first entry is never flagged mid-typing, while a field\n // already in error clears the moment it becomes valid.\n const [touched, setTouched] = useState<Partial<Record<keyof SignUpValues, boolean>>>({});\n\n const errors = useMemo(() => (validate ?? defaultValidate)(values), [values, validate]);\n\n const setValue = useCallback(\n <K extends keyof SignUpValues>(key: K, next: SignUpValues[K]) => {\n const nextValues = { ...values, [key]: next };\n if (!controlled) {\n setInternalValues(nextValues);\n if (statusProp === undefined) {\n setInternalStatus((current) =>\n current === \"success\" || current === \"error\" ? \"idle\" : current,\n );\n }\n }\n onValuesChange?.(nextValues);\n },\n [controlled, onValuesChange, statusProp, values],\n );\n\n const touch = useCallback((key: keyof SignUpValues) => {\n setTouched((prev) => (prev[key] ? prev : { ...prev, [key]: true }));\n }, []);\n\n /** Error to render for a field — hidden until the field has been touched. */\n const shownError = (key: keyof SignUpValues) => (touched[key] ? errors[key] : undefined);\n\n /** Success check draws only once a touched field is non-empty and valid. */\n const isValid = (key: keyof SignUpValues) =>\n Boolean(touched[key]) && !errors[key] && Boolean(values[key]);\n\n const strength = passwordStrength(values.password);\n const showStrength = strengthMeter && values.password.length > 0;\n const isSubmitting = status === \"loading\";\n\n const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n\n setTouched({\n name: true,\n email: true,\n password: true,\n confirmPassword: true,\n terms: true,\n });\n\n if (Object.keys(errors).length > 0) return;\n if (!onSubmit) return;\n\n if (statusProp === undefined) setInternalStatus(\"loading\");\n try {\n await onSubmit(values);\n if (statusProp === undefined) setInternalStatus(\"success\");\n } catch {\n if (statusProp === undefined) setInternalStatus(\"error\");\n }\n };\n\n const termsErrorId = `${baseId}-terms-error`;\n const formErrorId = `${baseId}-form-error`;\n\n return (\n <form\n noValidate\n onSubmit={handleSubmit}\n className={cn(\n \"flex w-full max-w-sm flex-col gap-5 rounded-3xl border border-border p-6\",\n className,\n classNames?.root,\n )}\n >\n {title || description ? (\n <div className={cn(\"flex flex-col gap-1\", classNames?.header)}>\n {title ? (\n <h2\n className={cn(\n \"font-semibold text-foreground text-xl tracking-tight\",\n classNames?.title,\n )}\n >\n {title}\n </h2>\n ) : null}\n {description ? (\n <p className={cn(\"text-muted-foreground text-sm\", classNames?.description)}>\n {description}\n </p>\n ) : null}\n </div>\n ) : null}\n\n <div className={cn(\"flex flex-col gap-1\", classNames?.fields)}>\n <Input\n label=\"Name\"\n autoComplete=\"name\"\n placeholder=\"Ada Lovelace\"\n leftIcon={<User />}\n disabled={isSubmitting}\n value={values.name}\n onChange={(next) => setValue(\"name\", next)}\n onBlur={() => touch(\"name\")}\n error={shownError(\"name\")}\n reserveErrorLine\n success={isValid(\"name\")}\n />\n\n <Input\n label=\"Email\"\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n leftIcon={<Mail />}\n disabled={isSubmitting}\n value={values.email}\n onChange={(next) => setValue(\"email\", next)}\n onBlur={() => touch(\"email\")}\n error={shownError(\"email\")}\n reserveErrorLine\n success={isValid(\"email\")}\n />\n\n <div className=\"flex flex-col gap-2\">\n <Input\n label=\"Password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"At least 8 characters\"\n leftIcon={<Lock />}\n rightIcon={\n <button\n type=\"button\"\n disabled={isSubmitting}\n onClick={() => setRevealPassword((prev) => !prev)}\n aria-label={revealPassword ? \"Hide password\" : \"Show password\"}\n className=\"text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground\"\n >\n {revealPassword ? <EyeOff /> : <Eye />}\n </button>\n }\n disabled={isSubmitting}\n value={values.password}\n onChange={(next) => setValue(\"password\", next)}\n onBlur={() => touch(\"password\")}\n error={shownError(\"password\")}\n reserveErrorLine\n />\n\n <AnimatePresence initial={false}>\n {showStrength ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n className={cn(\"flex flex-col gap-1.5 px-1\", classNames?.strength)}\n >\n <div className=\"flex gap-1.5\" aria-hidden>\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"h-1 flex-1 overflow-hidden rounded-full bg-muted-foreground/20\"\n >\n {/* scaleX rather than width — transforms only, per the\n motion conventions, and it keeps the bar off layout. */}\n <motion.span\n initial={false}\n animate={{ scaleX: index < strength ? 1 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"block h-full w-full origin-left rounded-full\",\n STRENGTH_COLORS[strength],\n )}\n />\n </span>\n ))}\n </div>\n <p aria-live=\"polite\" className=\"text-muted-foreground text-xs\">\n Password strength: {STRENGTH_LABELS[strength]}\n </p>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n\n <Input\n label=\"Confirm password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"Re-enter your password\"\n leftIcon={<Lock />}\n disabled={isSubmitting}\n value={values.confirmPassword}\n onChange={(next) => setValue(\"confirmPassword\", next)}\n onBlur={() => touch(\"confirmPassword\")}\n error={shownError(\"confirmPassword\")}\n reserveErrorLine\n success={isValid(\"confirmPassword\")}\n />\n </div>\n\n <div className={cn(\"flex flex-col gap-1.5\", classNames?.terms)}>\n <Checkbox\n checked={values.terms}\n disabled={isSubmitting}\n onCheckedChange={(next) => {\n setValue(\"terms\", next);\n touch(\"terms\");\n }}\n label=\"I agree to the Terms and Privacy Policy\"\n aria-describedby={shownError(\"terms\") ? termsErrorId : undefined}\n />\n <AnimatePresence initial={false}>\n {shownError(\"terms\") ? (\n <motion.p\n id={termsErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n transition={{ duration: 0.2 }}\n className=\"px-1 text-destructive text-xs\"\n >\n {shownError(\"terms\")}\n </motion.p>\n ) : null}\n </AnimatePresence>\n </div>\n\n <AnimatePresence initial={false}>\n {errorMessage ? (\n <motion.p\n id={formErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.2 }}\n className=\"rounded-2xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-xs\"\n >\n {errorMessage}\n </motion.p>\n ) : null}\n </AnimatePresence>\n\n <StatefulButton\n type=\"submit\"\n size=\"lg\"\n state={status}\n loadingText=\"Creating account\"\n successText=\"Account created\"\n errorText=\"Try again\"\n aria-describedby={errorMessage ? formErrorId : undefined}\n className={cn(\"w-full\", classNames?.submit)}\n >\n {submitLabel}\n </StatefulButton>\n\n {footer ? (\n <div className={cn(\"text-center text-muted-foreground text-sm\", classNames?.footer)}>\n {footer}\n </div>\n ) : null}\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,MAAM,eAA6B;CACjC,MAAM;CACN,OAAO;CACP,UAAU;CACV,iBAAiB;CACjB,OAAO;AACT;AAIA,MAAM,gBAAgB;AAEtB,MAAM,sBAAsB;AAE5B,MAAM,kBAAkB;CAAC;CAAa;CAAQ;CAAQ;CAAQ;AAAQ;AAEtE,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,iBAAiB,UAA0B;CACzD,IAAI,SAAS,SAAS,qBAAqB,OAAO;CAElD,IAAI,QAAQ;CACZ,IAAI,SAAS,UAAU,IAAI,SAAS;CACpC,IAAI,SAAS,UAAU,IAAI,SAAS;CAKpC,IAHgB;EAAC;EAAS;EAAS;EAAM;CAAc,CAAC,CAAC,QAAQ,YAC/D,QAAQ,KAAK,QAAQ,CACvB,CAAC,CAAC,UACa,GAAG,SAAS;CAE3B,OAAO,KAAK,IAAI,OAAO,CAAC;AAC1B;AAEA,SAAS,gBAAgB,QAAoC;CAC3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sources":["../../../src/components/motion/signup-form.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FormEvent, type ReactNode, useCallback, useId, useMemo, useState } from \"react\";\nimport { Eye, EyeOff, Lock, Mail, User } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { StatefulButton } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { Input } from \"./input\";\n\nexport type SignUpStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\n\nexport type SignUpValues = {\n name: string;\n email: string;\n password: string;\n confirmPassword: string;\n terms: boolean;\n};\n\nexport type SignUpErrors = Partial<Record<keyof SignUpValues, string>>;\n\nexport type SignUpFormClassNames = {\n root?: string;\n header?: string;\n title?: string;\n description?: string;\n fields?: string;\n strength?: string;\n terms?: string;\n submit?: string;\n footer?: string;\n};\n\nexport interface SignUpFormProps {\n /** Controlled values. Omit for uncontrolled. */\n values?: SignUpValues;\n defaultValues?: Partial<SignUpValues>;\n onValuesChange?: (values: SignUpValues) => void;\n /** Called with valid values only. Return a promise to drive the button state. */\n onSubmit?: (values: SignUpValues) => void | Promise<void>;\n /** Replace the built-in rules — return a message per invalid field. */\n validate?: (values: SignUpValues) => SignUpErrors;\n /** Controlled submit state. Omit to let the form track it. */\n status?: SignUpStatus;\n /** Form-level failure message, shown above the submit button. */\n errorMessage?: string;\n title?: ReactNode;\n description?: ReactNode;\n submitLabel?: string;\n footer?: ReactNode;\n /** Show the password strength meter. */\n strengthMeter?: boolean;\n className?: string;\n classNames?: SignUpFormClassNames;\n}\n\nconst EMPTY_VALUES: SignUpValues = {\n name: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\",\n terms: false,\n};\n\n// Deliberately permissive. Full RFC 5322 matching is impractical in a regex and\n// rejects addresses that deliver fine; the only real check is sending mail.\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst MIN_PASSWORD_LENGTH = 8;\n\nconst STRENGTH_LABELS = [\"Too short\", \"Weak\", \"Fair\", \"Good\", \"Strong\"] as const;\n\nconst STRENGTH_COLORS = [\n \"bg-destructive\",\n \"bg-destructive\",\n \"bg-amber-500\",\n \"bg-amber-400\",\n \"bg-(--color-success)\",\n] as const;\n\n/**\n * Length-weighted strength score, 0-4. NIST SP 800-63B advises against\n * composition requirements and treats length as the dominant factor, so extra\n * character classes only nudge the score — they can't rescue a short password.\n * This is a heuristic for feedback, not entropy estimation; pair it with a\n * breach-list check server-side for anything real.\n */\nexport function passwordStrength(password: string): number {\n if (password.length < MIN_PASSWORD_LENGTH) return 0;\n\n let score = 1;\n if (password.length >= 12) score += 1;\n if (password.length >= 16) score += 1;\n\n const classes = [/[a-z]/, /[A-Z]/, /\\d/, /[^A-Za-z0-9]/].filter((pattern) =>\n pattern.test(password),\n ).length;\n if (classes >= 3) score += 1;\n\n return Math.min(score, 4);\n}\n\nfunction defaultValidate(values: SignUpValues): SignUpErrors {\n const errors: SignUpErrors = {};\n\n if (!values.name.trim()) {\n errors.name = \"Enter your name.\";\n }\n\n if (!values.email.trim()) {\n errors.email = \"Enter your email.\";\n } else if (!EMAIL_PATTERN.test(values.email)) {\n errors.email = \"That doesn't look like an email address.\";\n }\n\n if (!values.password) {\n errors.password = \"Choose a password.\";\n } else if (values.password.length < MIN_PASSWORD_LENGTH) {\n errors.password = `Use at least ${MIN_PASSWORD_LENGTH} characters.`;\n }\n\n if (!values.confirmPassword) {\n errors.confirmPassword = \"Confirm your password.\";\n } else if (values.confirmPassword !== values.password) {\n errors.confirmPassword = \"Passwords don't match.\";\n }\n\n if (!values.terms) {\n errors.terms = \"Accept the terms to continue.\";\n }\n\n return errors;\n}\n\nexport function SignUpForm({\n values: valuesProp,\n defaultValues,\n onValuesChange,\n onSubmit,\n validate,\n status: statusProp,\n errorMessage,\n title = \"Create your account\",\n description = \"Start building in under a minute.\",\n submitLabel = \"Create account\",\n footer,\n strengthMeter = true,\n className,\n classNames,\n}: SignUpFormProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n\n const controlled = valuesProp !== undefined;\n const [internalValues, setInternalValues] = useState<SignUpValues>({\n ...EMPTY_VALUES,\n ...defaultValues,\n });\n const values = controlled ? valuesProp : internalValues;\n\n const [internalStatus, setInternalStatus] = useState<SignUpStatus>(\"idle\");\n const status = statusProp ?? internalStatus;\n\n const [revealPassword, setRevealPassword] = useState(false);\n\n // \"Reward early, punish late\": errors are computed on every change, but a\n // field only *shows* its error once it has been blurred (or submit touched\n // everything). So a first entry is never flagged mid-typing, while a field\n // already in error clears the moment it becomes valid.\n const [touched, setTouched] = useState<Partial<Record<keyof SignUpValues, boolean>>>({});\n\n const errors = useMemo(() => (validate ?? defaultValidate)(values), [values, validate]);\n\n const setValue = useCallback(\n <K extends keyof SignUpValues>(key: K, next: SignUpValues[K]) => {\n const nextValues = { ...values, [key]: next };\n if (!controlled) {\n setInternalValues(nextValues);\n if (statusProp === undefined) {\n setInternalStatus((current) =>\n current === \"success\" || current === \"error\" ? \"idle\" : current,\n );\n }\n }\n onValuesChange?.(nextValues);\n },\n [controlled, onValuesChange, statusProp, values],\n );\n\n const touch = useCallback((key: keyof SignUpValues) => {\n setTouched((prev) => (prev[key] ? prev : { ...prev, [key]: true }));\n }, []);\n\n /** Error to render for a field — hidden until the field has been touched. */\n const shownError = (key: keyof SignUpValues) => (touched[key] ? errors[key] : undefined);\n\n /** Success check draws only once a touched field is non-empty and valid. */\n const isValid = (key: keyof SignUpValues) =>\n Boolean(touched[key]) && !errors[key] && Boolean(values[key]);\n\n const strength = passwordStrength(values.password);\n const showStrength = strengthMeter && values.password.length > 0;\n const isSubmitting = status === \"loading\";\n\n const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n\n setTouched({\n name: true,\n email: true,\n password: true,\n confirmPassword: true,\n terms: true,\n });\n\n if (Object.keys(errors).length > 0) return;\n if (!onSubmit) return;\n\n if (statusProp === undefined) setInternalStatus(\"loading\");\n try {\n await onSubmit(values);\n if (statusProp === undefined) setInternalStatus(\"success\");\n } catch {\n if (statusProp === undefined) setInternalStatus(\"error\");\n }\n };\n\n const termsErrorId = `${baseId}-terms-error`;\n const formErrorId = `${baseId}-form-error`;\n\n return (\n <form\n noValidate\n onSubmit={handleSubmit}\n className={cn(\n \"flex w-full max-w-sm flex-col gap-5 rounded-3xl border border-border p-6\",\n className,\n classNames?.root,\n )}\n >\n {title || description ? (\n <div className={cn(\"flex flex-col gap-1\", classNames?.header)}>\n {title ? (\n <h2\n className={cn(\n \"font-semibold text-foreground text-xl tracking-tight\",\n classNames?.title,\n )}\n >\n {title}\n </h2>\n ) : null}\n {description ? (\n <p className={cn(\"text-muted-foreground text-sm\", classNames?.description)}>\n {description}\n </p>\n ) : null}\n </div>\n ) : null}\n\n <div className={cn(\"flex flex-col gap-1\", classNames?.fields)}>\n <Input\n label=\"Name\"\n autoComplete=\"name\"\n placeholder=\"Ada Lovelace\"\n leftIcon={<User />}\n disabled={isSubmitting}\n value={values.name}\n onChange={(next) => setValue(\"name\", next)}\n onBlur={() => touch(\"name\")}\n error={shownError(\"name\")}\n reserveErrorLine\n success={isValid(\"name\")}\n />\n\n <Input\n label=\"Email\"\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n leftIcon={<Mail />}\n disabled={isSubmitting}\n value={values.email}\n onChange={(next) => setValue(\"email\", next)}\n onBlur={() => touch(\"email\")}\n error={shownError(\"email\")}\n reserveErrorLine\n success={isValid(\"email\")}\n />\n\n <div className=\"flex flex-col gap-2\">\n <Input\n label=\"Password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"At least 8 characters\"\n leftIcon={<Lock />}\n rightIcon={\n <button\n type=\"button\"\n disabled={isSubmitting}\n onClick={() => setRevealPassword((prev) => !prev)}\n aria-label={revealPassword ? \"Hide password\" : \"Show password\"}\n className=\"text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground\"\n >\n {revealPassword ? <EyeOff /> : <Eye />}\n </button>\n }\n disabled={isSubmitting}\n value={values.password}\n onChange={(next) => setValue(\"password\", next)}\n onBlur={() => touch(\"password\")}\n error={shownError(\"password\")}\n reserveErrorLine\n />\n\n <AnimatePresence initial={false}>\n {showStrength ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n className={cn(\"flex flex-col gap-1.5 px-1\", classNames?.strength)}\n >\n <div className=\"flex gap-1.5\" aria-hidden>\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"h-1 flex-1 overflow-hidden rounded-full bg-muted-foreground/20\"\n >\n {/* scaleX rather than width — transforms only, per the\n motion conventions, and it keeps the bar off layout. */}\n <motion.span\n initial={false}\n animate={{ scaleX: index < strength ? 1 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"block h-full w-full origin-left rounded-full\",\n STRENGTH_COLORS[strength],\n )}\n />\n </span>\n ))}\n </div>\n <p aria-live=\"polite\" className=\"text-muted-foreground text-xs\">\n Password strength: {STRENGTH_LABELS[strength]}\n </p>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n\n <Input\n label=\"Confirm password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"Re-enter your password\"\n leftIcon={<Lock />}\n disabled={isSubmitting}\n value={values.confirmPassword}\n onChange={(next) => setValue(\"confirmPassword\", next)}\n onBlur={() => touch(\"confirmPassword\")}\n error={shownError(\"confirmPassword\")}\n reserveErrorLine\n success={isValid(\"confirmPassword\")}\n />\n </div>\n\n <div className={cn(\"flex flex-col gap-1.5\", classNames?.terms)}>\n <Checkbox\n checked={values.terms}\n disabled={isSubmitting}\n onCheckedChange={(next) => {\n setValue(\"terms\", next);\n touch(\"terms\");\n }}\n label=\"I agree to the Terms and Privacy Policy\"\n aria-describedby={shownError(\"terms\") ? termsErrorId : undefined}\n />\n <AnimatePresence initial={false}>\n {shownError(\"terms\") ? (\n <motion.p\n id={termsErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n transition={{ duration: 0.2 }}\n className=\"px-1 text-destructive text-xs\"\n >\n {shownError(\"terms\")}\n </motion.p>\n ) : null}\n </AnimatePresence>\n </div>\n\n <AnimatePresence initial={false}>\n {errorMessage ? (\n <motion.p\n id={formErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.2 }}\n className=\"rounded-2xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-xs\"\n >\n {errorMessage}\n </motion.p>\n ) : null}\n </AnimatePresence>\n\n <StatefulButton\n type=\"submit\"\n size=\"lg\"\n state={status}\n loadingText=\"Creating account\"\n successText=\"Account created\"\n errorText=\"Try again\"\n aria-describedby={errorMessage ? formErrorId : undefined}\n className={cn(\"w-full\", classNames?.submit)}\n >\n {submitLabel}\n </StatefulButton>\n\n {footer ? (\n <div className={cn(\"text-center text-muted-foreground text-sm\", classNames?.footer)}>\n {footer}\n </div>\n ) : null}\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,MAAM,eAA6B;CACjC,MAAM;CACN,OAAO;CACP,UAAU;CACV,iBAAiB;CACjB,OAAO;AACT;AAIA,MAAM,gBAAgB;AAEtB,MAAM,sBAAsB;AAE5B,MAAM,kBAAkB;CAAC;CAAa;CAAQ;CAAQ;CAAQ;A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S;MAAG,GAAG;KAAG;KACpD,YAAY,EAAE,UAAU,GAAI;KAC5B,WAAU;KAET,UAAA;IACO,CAAA,IACR;GACW,CAAA;GAEjB,oBAAC,gBAAD;IACE,MAAK;IACL,MAAK;IACL,OAAO;IACP,aAAY;IACZ,aAAY;IACZ,WAAU;IACV,oBAAkB,eAAe,cAAc,KAAA;IAC/C,WAAW,GAAG,UAAU,YAAY,MAAM;IAEzC,UAAA;GACa,CAAA;GAEf,SACC,oBAAC,OAAD;IAAK,WAAW,GAAG,6CAA6C,YAAY,MAAM;IAC/E,UAAA;GACE,CAAA,IACH;EACA;;AAEV"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { TOUCH_GESTURE_CLASS, TOUCH_GESTURE_CONTENT_CLASS } from "../../lib/touch.js";
|
|
3
3
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
4
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
|
|
8
8
|
//#region src/components/motion/slide-action-button.tsx
|