@kumix/ui 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/agents/agent-activity/activity-row.js +2 -2
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
- package/dist/components/agents/agent-activity/index.js +2 -2
- package/dist/components/agents/agent-activity/index.js.map +1 -1
- package/dist/components/agents/agent-code.d.ts.map +1 -1
- package/dist/components/agents/agent-code.js +2 -2
- package/dist/components/agents/agent-code.js.map +1 -1
- package/dist/components/agents/agent-disclosure.js +1 -1
- package/dist/components/agents/agent-disclosure.js.map +1 -1
- package/dist/components/agents/ai-sidebar.js +2 -2
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +2 -2
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/chat-app.js +1 -1
- package/dist/components/agents/chat-app.js.map +1 -1
- package/dist/components/agents/citations.js +2 -2
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/code-block.js +2 -2
- package/dist/components/agents/code-block.js.map +1 -1
- package/dist/components/agents/file-diff.js +2 -2
- package/dist/components/agents/file-diff.js.map +1 -1
- package/dist/components/agents/image-generation.js +2 -2
- package/dist/components/agents/image-generation.js.map +1 -1
- package/dist/components/agents/loading-states/agent-progress.js +1 -1
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -1
- package/dist/components/agents/message-bubble.js +2 -2
- package/dist/components/agents/message-bubble.js.map +1 -1
- package/dist/components/agents/message-scroller.js +1 -1
- package/dist/components/agents/message-scroller.js.map +1 -1
- package/dist/components/agents/message.js +1 -1
- package/dist/components/agents/message.js.map +1 -1
- package/dist/components/agents/prompt-input.js +2 -2
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/agents/streaming-response.js +2 -2
- package/dist/components/agents/streaming-response.js.map +1 -1
- package/dist/components/agents/todo-list.js +2 -2
- package/dist/components/agents/todo-list.js.map +1 -1
- package/dist/components/agents/tool-approval.js +2 -2
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/agents/tool-result.js +2 -2
- package/dist/components/agents/tool-result.js.map +1 -1
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/adaptive-stepper.js +2 -2
- package/dist/components/motion/adaptive-stepper.js.map +1 -1
- package/dist/components/motion/animated-badge.js +2 -2
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-number.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +2 -2
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +2 -2
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +2 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/bloom-menu.js +2 -2
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +2 -2
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/metallic.js +1 -1
- package/dist/components/motion/button/metallic.js.map +1 -1
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/card-folder.d.ts +30 -0
- package/dist/components/motion/card-folder.d.ts.map +1 -0
- package/dist/components/motion/card-folder.js +254 -0
- package/dist/components/motion/card-folder.js.map +1 -0
- package/dist/components/motion/center-morph-modal.js +2 -2
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/content.js.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -1
- package/dist/components/motion/combobox/context.js.map +1 -1
- package/dist/components/motion/combobox/list.js +2 -2
- package/dist/components/motion/combobox/list.js.map +1 -1
- package/dist/components/motion/combobox/trigger.js +2 -2
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/command-palette.js +2 -2
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +2 -2
- package/dist/components/motion/context-menu.js.map +1 -1
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/cylinder-carousel.js.map +1 -1
- package/dist/components/motion/digit-swap.d.ts +23 -0
- package/dist/components/motion/digit-swap.d.ts.map +1 -0
- package/dist/components/motion/digit-swap.js +77 -0
- package/dist/components/motion/digit-swap.js.map +1 -0
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/dock.js.map +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/dynamic-island.js +1 -1
- package/dist/components/motion/dynamic-island.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +1 -1
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts.map +1 -1
- package/dist/components/motion/expandable-control.js +1 -1
- package/dist/components/motion/expandable-control.js.map +1 -1
- package/dist/components/motion/expandable-tabs.js +1 -1
- package/dist/components/motion/expandable-tabs.js.map +1 -1
- package/dist/components/motion/expanding-arrow-button.js +1 -1
- package/dist/components/motion/expanding-arrow-button.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +2 -2
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/file-tree.js +2 -2
- package/dist/components/motion/file-tree.js.map +1 -1
- package/dist/components/motion/file-upload.js +2 -2
- package/dist/components/motion/file-upload.js.map +1 -1
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/hold-action-button.js.map +1 -1
- package/dist/components/motion/infinite-masonry.js +2 -2
- package/dist/components/motion/infinite-masonry.js.map +1 -1
- package/dist/components/motion/input.d.ts.map +1 -1
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/input.js.map +1 -1
- package/dist/components/motion/liquid.js +1 -1
- package/dist/components/motion/liquid.js.map +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/magnetic.js.map +1 -1
- package/dist/components/motion/marquee.d.ts.map +1 -1
- package/dist/components/motion/marquee.js +1 -1
- package/dist/components/motion/marquee.js.map +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +2 -2
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +2 -2
- package/dist/components/motion/morphing-tabs.js.map +1 -1
- package/dist/components/motion/multi-select/content.js +1 -1
- package/dist/components/motion/multi-select/content.js.map +1 -1
- package/dist/components/motion/multi-select/context.js +1 -1
- package/dist/components/motion/multi-select/context.js.map +1 -1
- package/dist/components/motion/multi-select/list.js +2 -2
- package/dist/components/motion/multi-select/list.js.map +1 -1
- package/dist/components/motion/multi-select/trigger.js +2 -2
- package/dist/components/motion/multi-select/trigger.js.map +1 -1
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
- package/dist/components/motion/not-found/magnetic.js +1 -1
- package/dist/components/motion/not-found/magnetic.js.map +1 -1
- package/dist/components/motion/not-found/shared.js +1 -1
- package/dist/components/motion/not-found/shared.js.map +1 -1
- package/dist/components/motion/not-found/spotlight.js +1 -1
- package/dist/components/motion/not-found/spotlight.js.map +1 -1
- package/dist/components/motion/notification-stack.js +2 -2
- package/dist/components/motion/notification-stack.js.map +1 -1
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/otp-input.js +1 -1
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/overflow-actions.js +2 -2
- package/dist/components/motion/overflow-actions.js.map +1 -1
- package/dist/components/motion/parallax.d.ts.map +1 -1
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.js +1 -1
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/preview-rail.js +1 -1
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/project-folder.js +2 -2
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +1 -1
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-bubble.js.map +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-fluid.js.map +1 -1
- package/dist/components/motion/range-slider-ruler.js +1 -1
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.js +1 -1
- package/dist/components/motion/range-slider-wave.js.map +1 -1
- package/dist/components/motion/range-slider.js +1 -1
- package/dist/components/motion/range-slider.js.map +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-progress.js.map +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/scroll-reveal.js.map +1 -1
- package/dist/components/motion/scroll-to.js +1 -1
- package/dist/components/motion/scroll-to.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +2 -2
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.js +2 -2
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +1 -1
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/signup-form.js +2 -2
- package/dist/components/motion/signup-form.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/swipeable-list.js +1 -1
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/switch.d.ts.map +1 -1
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/switch.js.map +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
- package/dist/components/motion/table/skeleton-rows.js +1 -1
- package/dist/components/motion/table/skeleton-rows.js.map +1 -1
- package/dist/components/motion/table/table-header.js +2 -2
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/table/table-menu.js.map +1 -1
- package/dist/components/motion/tabs.js +1 -1
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-reveal.js.map +1 -1
- package/dist/components/motion/text-scramble.d.ts.map +1 -1
- package/dist/components/motion/text-scramble.js +1 -1
- package/dist/components/motion/text-scramble.js.map +1 -1
- package/dist/components/motion/text-shimmer.js +1 -1
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +2 -2
- package/dist/components/motion/theme-toggle.js.map +1 -1
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tilt-card.js.map +1 -1
- package/dist/components/motion/tooltip.js +1 -1
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/motion/wheel-picker.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.d.ts.map +1 -1
- package/dist/components/reui/alert.js +2 -2
- package/dist/components/reui/alert.js.map +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.js +2 -2
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/badge.d.ts.map +1 -1
- package/dist/components/reui/badge.js +1 -1
- package/dist/components/reui/badge.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +2 -2
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +2 -2
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +2 -2
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +2 -2
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader.js +2 -2
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.js +1 -1
- package/dist/components/reui/code-block/code-block.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +2 -2
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -2
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +2 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +2 -2
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +1 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +2 -2
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters/filters-advanced.js +2 -2
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +3 -3
- package/dist/components/reui/filters/filters-builder.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +2 -2
- package/dist/components/reui/filters/filters-chip.js.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +3 -3
- package/dist/components/reui/filters/filters-editors.js.map +1 -1
- package/dist/components/reui/filters/filters.js +2 -2
- package/dist/components/reui/filters/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +2 -2
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +2 -2
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +2 -2
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +2 -2
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.js +1 -1
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-stack.js +1 -1
- package/dist/components/reui/icon-stack.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +1 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.js +2 -2
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +2 -2
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/rating.d.ts.map +1 -1
- package/dist/components/reui/rating.js +2 -2
- package/dist/components/reui/rating.js.map +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/sortable.js +1 -1
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/stepper.d.ts.map +1 -1
- package/dist/components/reui/stepper.js +1 -1
- package/dist/components/reui/stepper.js.map +1 -1
- package/dist/components/reui/timeline.d.ts.map +1 -1
- package/dist/components/reui/timeline.js +1 -1
- package/dist/components/reui/timeline.js.map +1 -1
- package/dist/components/reui/tree.d.ts.map +1 -1
- package/dist/components/reui/tree.js +2 -2
- package/dist/components/reui/tree.js.map +1 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +2 -2
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +2 -2
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -1
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +2 -2
- package/dist/components/ui/attachment.js.map +1 -1
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +2 -2
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble.js +2 -2
- package/dist/components/ui/bubble.js.map +1 -1
- package/dist/components/ui/button-group.js +2 -2
- package/dist/components/ui/button-group.js.map +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +2 -2
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +2 -2
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.js +2 -2
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.js +2 -2
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +2 -2
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/dialog.js +2 -2
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +2 -2
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/empty.js +2 -2
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +3 -3
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +1 -1
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +2 -2
- package/dist/components/ui/input-group.js.map +1 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +2 -2
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.js +2 -2
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/kbd.js.map +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/marker.d.ts.map +1 -1
- package/dist/components/ui/marker.js +2 -2
- package/dist/components/ui/marker.js.map +1 -1
- package/dist/components/ui/menubar.js +2 -2
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/message-scroller.js +2 -2
- package/dist/components/ui/message-scroller.js.map +1 -1
- package/dist/components/ui/message.d.ts.map +1 -1
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/message.js.map +1 -1
- package/dist/components/ui/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select.js +2 -2
- package/dist/components/ui/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +2 -2
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.js +2 -2
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/questionnaire.js +4 -4
- package/dist/components/ui/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +2 -2
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +1 -1
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +2 -2
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +2 -2
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +2 -2
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +2 -2
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toast.js +3 -3
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toggle-group.js +1 -1
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +2 -2
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/{copy-menu-TIKvPaAZ.js → copy-menu-C5GaT4Z-.js} +2 -2
- package/dist/{copy-menu-TIKvPaAZ.js.map → copy-menu-C5GaT4Z-.js.map} +1 -1
- package/package.json +5 -3
|
@@ -5,10 +5,10 @@ import { useTapGesture } from "../../hooks/use-tap-gesture.js";
|
|
|
5
5
|
import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
|
|
6
6
|
import { ActionSwapText } from "./action-swap.js";
|
|
7
7
|
import { useCallback, useRef, useState } from "react";
|
|
8
|
-
import { cn } from "
|
|
9
|
-
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
8
|
+
import { cn } from "cn";
|
|
10
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { motion, useReducedMotion } from "motion/react";
|
|
11
|
+
import { ArrowUpRight, BellOff } from "lucide-react";
|
|
12
12
|
//#region src/components/motion/notification-stack.tsx
|
|
13
13
|
const STACK_PEEK = 8;
|
|
14
14
|
const STACK_INSET = 12;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-stack.js","names":[],"sources":["../../../src/components/motion/notification-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { ArrowUpRight, BellOff } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { ActionSwapText } from \"./action-swap\";\n\nexport type NotificationStackItem = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n trailing?: ReactNode;\n};\n\nexport type NotificationStackClassNames = {\n stack?: string;\n card?: string;\n content?: string;\n title?: string;\n description?: string;\n trailing?: string;\n footer?: string;\n count?: string;\n};\n\nexport interface NotificationStackProps {\n items: NotificationStackItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onViewAll?: () => void;\n maxVisible?: number;\n collapsedLabel?: string;\n expandedLabel?: string;\n emptyLabel?: string;\n className?: string;\n classNames?: NotificationStackClassNames;\n}\n\nconst STACK_PEEK = 8;\nconst STACK_INSET = 12;\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nfunction NotificationCardContent({\n item,\n classNames,\n}: {\n item: NotificationStackItem;\n classNames?: NotificationStackClassNames;\n}) {\n return (\n <span className={cn(\"flex min-w-0 flex-col gap-1.5 py-4\", classNames?.content)}>\n <span className=\"flex min-w-0 items-start justify-between gap-3\">\n <span className={cn(\"min-w-0 font-medium text-sm leading-snug\", classNames?.title)}>\n {item.title}\n </span>\n {item.trailing ? (\n <span className={cn(\"shrink-0 text-xs\", classNames?.trailing)}>{item.trailing}</span>\n ) : null}\n </span>\n {item.description ? (\n <span\n className={cn(\"text-muted-foreground text-xs leading-relaxed\", classNames?.description)}\n >\n {item.description}\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function NotificationStack({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onViewAll,\n maxVisible = 3,\n collapsedLabel = \"Notifications\",\n expandedLabel = \"View all\",\n emptyLabel = \"All caught up\",\n className,\n classNames,\n}: NotificationStackProps) {\n const reduce = useReducedMotion();\n const hasFocus = useRef(false);\n const rootRef = useRef<HTMLButtonElement>(null);\n const hover = useHoverGesture();\n // What the last gesture on the stack was, and whether it was already\n // expanded when that gesture started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n // Set by the tap that expands the stack, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n\n const collapse = useCallback(() => {\n setTapExpanded(false);\n setIsExpanded(false);\n }, [setIsExpanded]);\n\n // A pointer leaving the stack is what collapses it, and a finger never\n // leaves: without this the stack stays open for good once tapped, and when\n // `onViewAll` is set the next tap follows the link instead of closing. The\n // tap that lands somewhere else stands in for the pointer leaving, and it is\n // consumed rather than passed through — the expanded stack covers the page,\n // so the tap that dismisses it is aimed at nothing else.\n useDismiss(tapExpanded && isExpanded, collapse, rootRef, {\n behavior: \"consume\",\n });\n\n const visibleItems = items.slice(0, Math.max(1, maxVisible));\n const primaryItem = visibleItems[0];\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const cardTransition: Transition = reduce ? { duration: 0 } : { duration: 0.32, ease: EASE_OUT };\n const backgroundTransition: Transition = reduce\n ? { duration: 0 }\n : { duration: 0.26, ease: EASE_OUT };\n\n if (!primaryItem) {\n return (\n <div\n className={cn(\n \"flex w-full max-w-[22rem] items-center justify-center gap-2 rounded-3xl bg-muted/70 px-5 py-8 font-medium text-muted-foreground text-sm\",\n className,\n )}\n >\n <BellOff className=\"h-4 w-4\" aria-hidden=\"true\" />\n {emptyLabel}\n </div>\n );\n }\n\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n if (event.currentTarget.contains(event.relatedTarget)) return;\n hasFocus.current = false;\n collapse();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n // A key press is the start of a keyboard activation, never part of a tap:\n // whatever a taken-away gesture left behind must not be read as one.\n tap.drop();\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n collapse();\n // Focus stays where the keyboard put it. Blurring here collapsed the stack\n // *and* threw the user back to the top of the document.\n };\n\n const handleClick = () => {\n const gesture = tap.take();\n // Read from where the gesture started, not from now: a browser that\n // focuses the stack on contact expands it mid-tap, and the first tap would\n // then follow `onViewAll` instead of opening the list it was meant to.\n const wasExpanded = gesture ? gesture.state : isExpanded;\n\n if (!wasExpanded) {\n setIsExpanded(true);\n if (gesture && gesture.pointerType !== \"mouse\") setTapExpanded(true);\n return;\n }\n\n if (onViewAll) {\n onViewAll();\n return;\n }\n\n collapse();\n };\n\n return (\n <motion.button\n ref={rootRef}\n type=\"button\"\n initial={false}\n aria-expanded={isExpanded}\n aria-label={\n isExpanded\n ? `${items.length} notifications. ${expandedLabel}.`\n : `${items.length} notifications. Expand notifications.`\n }\n // A tap reports as a hover on its way past — enter, leave, then click —\n // so an unfiltered hover path expands, collapses and expands again in\n // the space of one tap, springs and all. The tap has its own route\n // through `handleClick`.\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (hover.enter(event)) setIsExpanded(true);\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n if (hover.leave(event) && !hasFocus.current) collapse();\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // The platform can take the gesture away mid-press — a scroll, a system\n // swipe — and no click follows it.\n onPointerCancel={tap.drop}\n onFocus={() => {\n hasFocus.current = true;\n setIsExpanded(true);\n }}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n className={cn(\n \"relative z-10 block w-full max-w-[22rem] cursor-pointer rounded-3xl text-left text-foreground outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n className,\n )}\n >\n {/* This invisible first card gives the button its compact intrinsic footprint. */}\n <span aria-hidden=\"true\" className=\"invisible block p-3\">\n <span className=\"block\">\n <span\n className={cn(\"block rounded-2xl border border-transparent px-4\", classNames?.card)}\n >\n <NotificationCardContent item={primaryItem} classNames={classNames} />\n </span>\n </span>\n <span className=\"mt-2 block h-9\" />\n </span>\n\n <span className=\"absolute inset-x-0 bottom-0 block p-3\">\n <motion.span\n aria-hidden=\"true\"\n layout\n initial={false}\n transition={backgroundTransition}\n className=\"absolute inset-0 rounded-3xl bg-muted\"\n />\n <span className={cn(\"relative z-10 grid gap-1\", !isExpanded && \"pb-2\", classNames?.stack)}>\n {visibleItems.map((item, index) => {\n const isPrimary = index === 0;\n\n return (\n <motion.span\n key={item.id}\n layout=\"position\"\n initial={false}\n animate={{\n y: isExpanded ? 0 : index * STACK_PEEK,\n clipPath: isExpanded\n ? \"inset(0px 0px round 16px)\"\n : `inset(0px ${index * STACK_INSET}px round 16px)`,\n }}\n transition={cardTransition}\n className={cn(\n \"block rounded-2xl border border-border/60 bg-background px-4\",\n classNames?.card,\n )}\n style={{\n zIndex: visibleItems.length - index,\n gridColumn: 1,\n gridRow: isExpanded ? index + 1 : 1,\n }}\n >\n <span className={cn(\"block\", !isPrimary && !isExpanded && \"invisible\")}>\n <NotificationCardContent item={item} classNames={classNames} />\n </span>\n </motion.span>\n );\n })}\n </span>\n\n <motion.span\n layout=\"position\"\n transition={transition}\n className={cn(\n \"relative z-10 mt-2 flex min-h-9 items-center gap-2 px-1\",\n classNames?.footer,\n )}\n >\n <span\n className={cn(\n \"grid size-7 shrink-0 place-items-center rounded-full bg-orange-600 font-medium text-white text-xs shadow-[inset_0_1px_2px_rgb(0_0_0/0.2),inset_0_-1px_0_rgb(255_255_255/0.16)] dark:bg-orange-500\",\n classNames?.count,\n )}\n >\n {items.length}\n </span>\n <span className=\"flex items-center font-medium text-sm\">\n <ActionSwapText value={isExpanded ? \"expanded\" : \"collapsed\"} animation=\"roll\">\n {isExpanded ? (\n <span className=\"inline-flex items-center gap-1\">\n {expandedLabel}\n <ArrowUpRight className=\"size-4\" aria-hidden=\"true\" />\n </span>\n ) : (\n collapsedLabel\n )}\n </ActionSwapText>\n </span>\n </motion.span>\n </span>\n </motion.button>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqDA,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe;CACxE,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAS,wBAAwB,EAC/B,MACA,cAIC;CACD,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,sCAAsC,YAAY,OAAO;EAA7E,UAAA,CACE,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,oBAAC,QAAD;IAAM,WAAW,GAAG,4CAA4C,YAAY,KAAK;IAC9E,UAAA,KAAK;GACF,CAAA,GACL,KAAK,WACJ,oBAAC,QAAD;IAAM,WAAW,GAAG,oBAAoB,YAAY,QAAQ;IAAI,UAAA,KAAK;GAAe,CAAA,IAClF,IACA;EACL,CAAA,GAAA,KAAK,cACJ,oBAAC,QAAD;GACE,WAAW,GAAG,iDAAi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,oBAAC,QAAD;KAAM,WAAW,GAAG,4BAA4B,CAAC,cAAc,QAAQ,YAAY,KAAK;KACrF,UAAA,aAAa,KAAK,MAAM,UAAU;MACjC,MAAM,YAAY,UAAU;MAE5B,OACE,oBAAC,OAAO,MAAR;OAEE,QAAO;OACP,SAAS;OACT,SAAS;QACP,GAAG,aAAa,IAAI,QAAQ;QAC5B,UAAU,aACN,8BACA,aAAa,QAAQ,YAAY;OACvC;OACA,YAAY;OACZ,WAAW,GACT,gEACA,YAAY,IACd;OACA,OAAO;QACL,QAAQ,aAAa,SAAS;QAC9B,YAAY;QACZ,SAAS,aAAa,QAAQ,IAAI;OACpC;OAEA,UAAA,oBAAC,QAAD;QAAM,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC,cAAc,WAAW;QACnE,UAAA,oBAAC,yBAAD;SAA+B;SAAkB;QAAa,CAAA;OAC1D,CAAA;MACK,GAvBN,KAAK,EAuBC;KAEjB,CAAC;IACG,CAAA;IAEN,qBAAC,OAAO,MAAR;KACE,QAAO;KACK;KACZ,WAAW,GACT,2DACA,YAAY,MACd;KANF,UAAA,CAQE,oBAAC,QAAD;MACE,WAAW,GACT,qMACA,YAAY,KACd;MAEC,UAAA,MAAM;KACH,CAAA,GACN,oBAAC,QAAD;MAAM,WAAU;MACd,UAAA,oBAAC,gBAAD;OAAgB,OAAO,aAAa,aAAa;OAAa,WAAU;OACrE,UAAA,aACC,qBAAC,QAAD;QAAM,WAAU;QAAhB,UAAA,CACG,eACD,oBAAC,cAAD;SAAc,WAAU;SAAS,eAAY;QAAQ,CAAA,CACjD;OAEN,CAAA,IAAA;MAEY,CAAA;KACZ,CAAA,CACK;;GACT;EACO,CAAA,CAAA;;AAEnB"}
|
|
1
|
+
{"version":3,"file":"notification-stack.js","names":[],"sources":["../../../src/components/motion/notification-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { ArrowUpRight, BellOff } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { ActionSwapText } from \"./action-swap\";\n\nexport type NotificationStackItem = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n trailing?: ReactNode;\n};\n\nexport type NotificationStackClassNames = {\n stack?: string;\n card?: string;\n content?: string;\n title?: string;\n description?: string;\n trailing?: string;\n footer?: string;\n count?: string;\n};\n\nexport interface NotificationStackProps {\n items: NotificationStackItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onViewAll?: () => void;\n maxVisible?: number;\n collapsedLabel?: string;\n expandedLabel?: string;\n emptyLabel?: string;\n className?: string;\n classNames?: NotificationStackClassNames;\n}\n\nconst STACK_PEEK = 8;\nconst STACK_INSET = 12;\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nfunction NotificationCardContent({\n item,\n classNames,\n}: {\n item: NotificationStackItem;\n classNames?: NotificationStackClassNames;\n}) {\n return (\n <span className={cn(\"flex min-w-0 flex-col gap-1.5 py-4\", classNames?.content)}>\n <span className=\"flex min-w-0 items-start justify-between gap-3\">\n <span className={cn(\"min-w-0 font-medium text-sm leading-snug\", classNames?.title)}>\n {item.title}\n </span>\n {item.trailing ? (\n <span className={cn(\"shrink-0 text-xs\", classNames?.trailing)}>{item.trailing}</span>\n ) : null}\n </span>\n {item.description ? (\n <span\n className={cn(\"text-muted-foreground text-xs leading-relaxed\", classNames?.description)}\n >\n {item.description}\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function NotificationStack({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onViewAll,\n maxVisible = 3,\n collapsedLabel = \"Notifications\",\n expandedLabel = \"View all\",\n emptyLabel = \"All caught up\",\n className,\n classNames,\n}: NotificationStackProps) {\n const reduce = useReducedMotion();\n const hasFocus = useRef(false);\n const rootRef = useRef<HTMLButtonElement>(null);\n const hover = useHoverGesture();\n // What the last gesture on the stack was, and whether it was already\n // expanded when that gesture started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n // Set by the tap that expands the stack, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n\n const collapse = useCallback(() => {\n setTapExpanded(false);\n setIsExpanded(false);\n }, [setIsExpanded]);\n\n // A pointer leaving the stack is what collapses it, and a finger never\n // leaves: without this the stack stays open for good once tapped, and when\n // `onViewAll` is set the next tap follows the link instead of closing. The\n // tap that lands somewhere else stands in for the pointer leaving, and it is\n // consumed rather than passed through — the expanded stack covers the page,\n // so the tap that dismisses it is aimed at nothing else.\n useDismiss(tapExpanded && isExpanded, collapse, rootRef, {\n behavior: \"consume\",\n });\n\n const visibleItems = items.slice(0, Math.max(1, maxVisible));\n const primaryItem = visibleItems[0];\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const cardTransition: Transition = reduce ? { duration: 0 } : { duration: 0.32, ease: EASE_OUT };\n const backgroundTransition: Transition = reduce\n ? { duration: 0 }\n : { duration: 0.26, ease: EASE_OUT };\n\n if (!primaryItem) {\n return (\n <div\n className={cn(\n \"flex w-full max-w-[22rem] items-center justify-center gap-2 rounded-3xl bg-muted/70 px-5 py-8 font-medium text-muted-foreground text-sm\",\n className,\n )}\n >\n <BellOff className=\"h-4 w-4\" aria-hidden=\"true\" />\n {emptyLabel}\n </div>\n );\n }\n\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n if (event.currentTarget.contains(event.relatedTarget)) return;\n hasFocus.current = false;\n collapse();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n // A key press is the start of a keyboard activation, never part of a tap:\n // whatever a taken-away gesture left behind must not be read as one.\n tap.drop();\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n collapse();\n // Focus stays where the keyboard put it. Blurring here collapsed the stack\n // *and* threw the user back to the top of the document.\n };\n\n const handleClick = () => {\n const gesture = tap.take();\n // Read from where the gesture started, not from now: a browser that\n // focuses the stack on contact expands it mid-tap, and the first tap would\n // then follow `onViewAll` instead of opening the list it was meant to.\n const wasExpanded = gesture ? gesture.state : isExpanded;\n\n if (!wasExpanded) {\n setIsExpanded(true);\n if (gesture && gesture.pointerType !== \"mouse\") setTapExpanded(true);\n return;\n }\n\n if (onViewAll) {\n onViewAll();\n return;\n }\n\n collapse();\n };\n\n return (\n <motion.button\n ref={rootRef}\n type=\"button\"\n initial={false}\n aria-expanded={isExpanded}\n aria-label={\n isExpanded\n ? `${items.length} notifications. ${expandedLabel}.`\n : `${items.length} notifications. Expand notifications.`\n }\n // A tap reports as a hover on its way past — enter, leave, then click —\n // so an unfiltered hover path expands, collapses and expands again in\n // the space of one tap, springs and all. The tap has its own route\n // through `handleClick`.\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (hover.enter(event)) setIsExpanded(true);\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n if (hover.leave(event) && !hasFocus.current) collapse();\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // The platform can take the gesture away mid-press — a scroll, a system\n // swipe — and no click follows it.\n onPointerCancel={tap.drop}\n onFocus={() => {\n hasFocus.current = true;\n setIsExpanded(true);\n }}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n className={cn(\n \"relative z-10 block w-full max-w-[22rem] cursor-pointer rounded-3xl text-left text-foreground outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n className,\n )}\n >\n {/* This invisible first card gives the button its compact intrinsic footprint. */}\n <span aria-hidden=\"true\" className=\"invisible block p-3\">\n <span className=\"block\">\n <span\n className={cn(\"block rounded-2xl border border-transparent px-4\", classNames?.card)}\n >\n <NotificationCardContent item={primaryItem} classNames={classNames} />\n </span>\n </span>\n <span className=\"mt-2 block h-9\" />\n </span>\n\n <span className=\"absolute inset-x-0 bottom-0 block p-3\">\n <motion.span\n aria-hidden=\"true\"\n layout\n initial={false}\n transition={backgroundTransition}\n className=\"absolute inset-0 rounded-3xl bg-muted\"\n />\n <span className={cn(\"relative z-10 grid gap-1\", !isExpanded && \"pb-2\", classNames?.stack)}>\n {visibleItems.map((item, index) => {\n const isPrimary = index === 0;\n\n return (\n <motion.span\n key={item.id}\n layout=\"position\"\n initial={false}\n animate={{\n y: isExpanded ? 0 : index * STACK_PEEK,\n clipPath: isExpanded\n ? \"inset(0px 0px round 16px)\"\n : `inset(0px ${index * STACK_INSET}px round 16px)`,\n }}\n transition={cardTransition}\n className={cn(\n \"block rounded-2xl border border-border/60 bg-background px-4\",\n classNames?.card,\n )}\n style={{\n zIndex: visibleItems.length - index,\n gridColumn: 1,\n gridRow: isExpanded ? index + 1 : 1,\n }}\n >\n <span className={cn(\"block\", !isPrimary && !isExpanded && \"invisible\")}>\n <NotificationCardContent item={item} classNames={classNames} />\n </span>\n </motion.span>\n );\n })}\n </span>\n\n <motion.span\n layout=\"position\"\n transition={transition}\n className={cn(\n \"relative z-10 mt-2 flex min-h-9 items-center gap-2 px-1\",\n classNames?.footer,\n )}\n >\n <span\n className={cn(\n \"grid size-7 shrink-0 place-items-center rounded-full bg-orange-600 font-medium text-white text-xs shadow-[inset_0_1px_2px_rgb(0_0_0/0.2),inset_0_-1px_0_rgb(255_255_255/0.16)] dark:bg-orange-500\",\n classNames?.count,\n )}\n >\n {items.length}\n </span>\n <span className=\"flex items-center font-medium text-sm\">\n <ActionSwapText value={isExpanded ? \"expanded\" : \"collapsed\"} animation=\"roll\">\n {isExpanded ? (\n <span className=\"inline-flex items-center gap-1\">\n {expandedLabel}\n <ArrowUpRight className=\"size-4\" aria-hidden=\"true\" />\n </span>\n ) : (\n collapsedLabel\n )}\n </ActionSwapText>\n </span>\n </motion.span>\n </span>\n </motion.button>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqDA,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe;CACxE,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAS,wBAAwB,EAC/B,MACA,cAIC;CACD,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,sCAAsC,YAAY,OAAO;EAA7E,UAAA,CACE,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,oBAAC,QAAD;IAAM,WAAW,GAAG,4CAA4C,YAAY,KAAK;IAC9E,UAAA,KAAK;GACF,CAAA,GACL,KAAK,WACJ,oBAAC,QAAD;IAAM,WAAW,GAAG,oBAAoB,YAAY,QAAQ;IAAI,UAAA,KAAK;GAAe,CAAA,IAClF,IACA;EACL,CAAA,GAAA,KAAK,cACJ,oBAAC,QAAD;GACE,WAAW,GAAG,iDAAiD,YAAY,WAA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D;KAAM,WAAW,GAAG,4BAA4B,CAAC,cAAc,QAAQ,YAAY,KAAK;KACrF,UAAA,aAAa,KAAK,MAAM,UAAU;MACjC,MAAM,YAAY,UAAU;MAE5B,OACE,oBAAC,OAAO,MAAR;OAEE,QAAO;OACP,SAAS;OACT,SAAS;QACP,GAAG,aAAa,IAAI,QAAQ;QAC5B,UAAU,aACN,8BACA,aAAa,QAAQ,YAAY;OACvC;OACA,YAAY;OACZ,WAAW,GACT,gEACA,YAAY,IACd;OACA,OAAO;QACL,QAAQ,aAAa,SAAS;QAC9B,YAAY;QACZ,SAAS,aAAa,QAAQ,IAAI;OACpC;OAEA,UAAA,oBAAC,QAAD;QAAM,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC,cAAc,WAAW;QACnE,UAAA,oBAAC,yBAAD;SAA+B;SAAkB;QAAa,CAAA;OAC1D,CAAA;MACK,GAvBN,KAAK,EAuBC;KAEjB,CAAC;IACG,CAAA;IAEN,qBAAC,OAAO,MAAR;KACE,QAAO;KACK;KACZ,WAAW,GACT,2DACA,YAAY,MACd;KANF,UAAA,CAQE,oBAAC,QAAD;MACE,WAAW,GACT,qMACA,YAAY,KACd;MAEC,UAAA,MAAM;KACH,CAAA,GACN,oBAAC,QAAD;MAAM,WAAU;MACd,UAAA,oBAAC,gBAAD;OAAgB,OAAO,aAAa,aAAa;OAAa,WAAU;OACrE,UAAA,aACC,qBAAC,QAAD;QAAM,WAAU;QAAhB,UAAA,CACG,eACD,oBAAC,cAAD;SAAc,WAAU;SAAS,eAAY;QAAQ,CAAA,CACjD;OAEN,CAAA,IAAA;MAEY,CAAA;KACZ,CAAA,CACK;;GACT;EACO,CAAA,CAAA;;AAEnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "cn";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { animate, motion, useInView, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/number-ticker.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-ticker.js","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { animate, motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"number-ticker.js","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { animate, motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport interface NumberTickerProps {\n value: number;\n /** Digits to pad to (left). */\n pad?: number;\n /** Per-digit roll duration in seconds. */\n duration?: number;\n /** Stagger between digits. */\n stagger?: number;\n /** Render only after the element enters the viewport. */\n startOnView?: boolean;\n prefix?: string;\n suffix?: string;\n /** Add a small blur during digit rolls. */\n blur?: boolean;\n className?: string;\n digitClassName?: string;\n /** Insert locale group separators (commas). Server-component safe. */\n locale?: boolean;\n /** Custom formatter. Client-only — server components must use `locale` instead. */\n format?: (value: number) => string;\n}\n\nconst DIGIT_HEIGHT_EM = 1.1;\nconst DIGITS = Array.from({ length: 10 }, (_, n) => n);\n\nexport function NumberTicker({\n value,\n pad,\n duration = 0.9,\n stagger = 0.04,\n startOnView = true,\n prefix,\n suffix,\n blur = false,\n className,\n digitClassName,\n locale,\n format,\n}: NumberTickerProps) {\n const containerRef = useRef<HTMLSpanElement>(null);\n const inView = useInView(containerRef, { once: true, amount: 0.6 });\n const [armed, setArmed] = useState(!startOnView);\n\n useEffect(() => {\n if (startOnView && inView) setArmed(true);\n }, [startOnView, inView]);\n\n const text = useMemo(() => {\n const rounded = Math.round(value);\n const formatted = format\n ? format(rounded)\n : locale\n ? rounded.toLocaleString()\n : rounded.toString();\n return pad ? formatted.padStart(pad, \"0\") : formatted;\n }, [value, pad, format, locale]);\n const glyphs = useMemo(() => {\n const chars = text.split(\"\");\n // Key by place value (position from the right): a changing digit keeps its\n // identity and rolls to the new value instead of remounting and replaying\n // from 0. Growing numbers add glyphs on the left without re-keying the\n // ones, tens, hundreds already on screen.\n return chars.map((char, i) => ({ char, id: `g-${chars.length - 1 - i}` }));\n }, [text]);\n const readableText = `${prefix ?? \"\"}${text}${suffix ?? \"\"}`;\n\n // Stagger is an entrance flourish. Once the reveal has played, value\n // changes roll every digit immediately — a per-digit delay on live updates\n // reads as lag.\n const [entered, setEntered] = useState(false);\n useEffect(() => {\n if (!armed || entered) return;\n const total = (duration + glyphs.length * stagger) * 1000;\n const t = window.setTimeout(() => setEntered(true), total);\n return () => window.clearTimeout(t);\n }, [armed, entered, duration, stagger, glyphs.length]);\n\n return (\n <span ref={containerRef} className={cn(\"inline-flex items-center tabular-nums\", className)}>\n <span className=\"sr-only\">{readableText}</span>\n <span aria-hidden=\"true\" className=\"inline-flex items-center\">\n {prefix ? <span>{prefix}</span> : null}\n {glyphs.map(({ char, id }, i) => {\n const isDigit = /\\d/.test(char);\n if (!isDigit) {\n return (\n <span key={id} className=\"inline-block\">\n {char}\n </span>\n );\n }\n const digit = Number(char);\n return (\n <Digit\n key={id}\n digit={armed ? digit : 0}\n delay={entered ? 0 : i * stagger}\n duration={duration}\n blur={blur}\n className={digitClassName}\n />\n );\n })}\n {suffix ? <span>{suffix}</span> : null}\n </span>\n </span>\n );\n}\n\nfunction Digit({\n digit,\n delay,\n duration,\n blur,\n className,\n}: {\n digit: number;\n delay: number;\n duration: number;\n blur: boolean;\n className?: string;\n}) {\n const reduce = useReducedMotion();\n const columnRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n if (reduce || !blur || !columnRef.current || !Number.isFinite(digit)) {\n return;\n }\n\n const node = columnRef.current;\n const controls = animate(\n node,\n { filter: [\"blur(10px)\", \"blur(0px)\"] },\n {\n duration: Math.min(duration * 0.75, 0.32),\n delay,\n ease: EASE_OUT,\n },\n );\n\n return () => {\n controls.stop();\n node.style.filter = \"blur(0px)\";\n };\n }, [blur, delay, digit, duration, reduce]);\n\n return (\n <span\n className={cn(\"relative inline-block overflow-hidden\", className)}\n style={{ height: `${DIGIT_HEIGHT_EM}em`, width: \"1ch\" }}\n >\n <motion.span\n ref={columnRef}\n initial={{ y: 0 }}\n animate={{ y: `-${digit * DIGIT_HEIGHT_EM}em` }}\n transition={reduce ? { duration: 0 } : { duration, delay, ease: EASE_OUT }}\n className=\"absolute inset-x-0 top-0 flex flex-col items-center will-change-[transform,filter]\"\n >\n {DIGITS.map((n) => (\n <span key={n} className=\"flex h-[1.1em] items-center justify-center leading-none\">\n {n}\n </span>\n ))}\n </motion.span>\n </span>\n );\n}\n"],"mappings":";;;;;;;AA8BA,MAAM,kBAAkB;AACxB,MAAM,SAAS,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAErD,SAAgB,aAAa,EAC3B,OACA,KACA,WAAW,IACX,UAAU,KACV,cAAc,MACd,QACA,QACA,OAAO,OACP,WACA,gBACA,QACA,UACoB;CACpB,MAAM,eAAe,OAAwB,IAAI;CACjD,MAAM,SAAS,UAAU,cAAc;EAAE,MAAM;EAAM,QAAQ;CAAI,CAAC;CAClE,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC,WAAW;CAE/C,gBAAgB;EACd,IAAI,eAAe,QAAQ,SAAS,IAAI;CAC1C,GAAG,CAAC,aAAa,MAAM,CAAC;CAExB,MAAM,OAAO,cAAc;EACzB,MAAM,UAAU,KAAK,MAAM,KAAK;EAChC,MAAM,YAAY,SACd,OAAO,OAAO,IACd,SACE,QAAQ,eAAe,IACvB,QAAQ,SAAS;EACvB,OAAO,MAAM,UAAU,SAAS,KAAK,GAAG,IAAI;CAC9C,GAAG;EAAC;EAAO;EAAK;EAAQ;CAA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ChC,MAAM,YAAY,OAAwB,IAAI;CAE9C,gBAAgB;EACd,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,WAAW,CAAC,OAAO,SAAS,KAAK,GACjE;EAGF,MAAM,OAAO,UAAU;EACvB,MAAM,WAAW,QACf,MACA,EAAE,QAAQ,CAAC,cAAc,WAAW,EAAE,GACtC;GACE,UAAU,KAAK,IAAI,WAAW,KAAM,GAAI;GACxC;GACA,MAAM;EACR,CACF;EAEA,aAAa;GACX,SAAS,KAAK;GACd,KAAK,MAAM,SAAS;EACtB;CACF,GAAG;EAAC;EAAM;EAAO;EAAO;EAAU;CAAM,CAAC;CAEzC,OACE,oBAAC,QAAD;EACE,WAAW,GAAG,yCAAyC,SAAS;EAChE,OAAO;GAAE,QAAQ,GAAG,gBAAgB;GAAK,OAAO;EAAM;EAEtD,UAAA,oBAAC,OAAO,MAAR;GACE,KAAK;GACL,SAAS,EAAE,GAAG,EAAE;GAChB,SAAS,EAAE,GAAG,IAAI,QAAQ,gBAAgB,IAAI;GAC9C,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IAAE;IAAU;IAAO,MAAM;GAAS;GACzE,WAAU;GAET,UAAA,OAAO,KAAK,MACX,oBAAC,QAAD;IAAc,WAAU;IACrB,UAAA;GACG,GAFK,CAEL,CACP;EACU,CAAA;CACT,CAAA;AAEV"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "cn";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { AnimatePresence, animate, motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/otp-input.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-input.js","names":[],"sources":["../../../src/components/motion/otp-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OTPStatus = \"idle\" | \"error\" | \"success\";\n\nexport interface OTPInputProps {\n /** Number of slots. Default 6. */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Fires once every slot is filled. */\n onComplete?: (value: string) => void;\n /** Optional label rendered above the slots. */\n label?: string;\n /** Helper text shown below the slots while idle. */\n hint?: string;\n /** Message shown below the slots when status is \"success\". */\n successMessage?: string;\n /** Message shown below the slots when status is \"error\". */\n errorMessage?: string;\n /** External validation feedback. \"error\" shakes, \"success\" draws a check. */\n status?: OTPStatus;\n /** Render dots instead of the typed digits. */\n mask?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Accessible label for the underlying input. */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function OTPInput({\n length = 6,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onComplete,\n label,\n hint,\n successMessage,\n errorMessage,\n status = \"idle\",\n mask = false,\n disabled = false,\n autoFocus = false,\n \"aria-label\": ariaLabel = \"One-time passcode\",\n className,\n}: OTPInputProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const inputRef = useRef<HTMLInputElement>(null);\n const slotsRef = useRef<HTMLDivElement>(null);\n\n const controlled = controlledValue !== undefined;\n\n // Source of truth is a fixed-length array, so a cleared middle slot stays an\n // in-place hole instead of collapsing the digits after it to the left.\n const [slots, setSlots] = useState<string[]>(() =>\n toSlots(controlled ? controlledValue : defaultValue, length),\n );\n const [focused, setFocused] = useState(false);\n const [active, setActive] = useState(0);\n\n const joined = slots.join(\"\");\n const joinedRef = useRef(joined);\n\n useEffect(() => {\n joinedRef.current = joined;\n }, [joined]);\n\n // Pull in external value changes; skip when the parent is just echoing our own\n // onChange, so internal holes survive the controlled round-trip.\n useEffect(() => {\n if (!controlled) return;\n const incoming = sanitize(controlledValue, length);\n if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));\n }, [controlled, controlledValue, length]);\n\n const commit = (next: string[]) => {\n const wasComplete = slots.every((c) => c !== \"\");\n setSlots(next);\n const str = next.join(\"\");\n onChange?.(str);\n // Fire only on the empty→full transition, not on every edit of a full code.\n if (!wasComplete && next.every((c) => c !== \"\")) onComplete?.(str);\n };\n\n const clearSlot = (idx: number) => {\n const next = [...slots];\n next[idx] = \"\";\n commit(next);\n };\n\n const slotFromClientX = (clientX: number) => {\n const els = slotsRef.current?.children;\n if (!els) return 0;\n for (let i = 0; i < els.length; i++) {\n if (clientX < els[i].getBoundingClientRect().right) return i;\n }\n return length - 1;\n };\n\n // Single insertion path: one digit overwrites the active slot and advances; a\n // multi-digit chunk (paste / SMS autofill) fills forward from the active slot.\n const insert = (raw: string, from = active) => {\n const digits = raw.replace(/\\D/g, \"\");\n if (!digits) return;\n const next = [...slots];\n let i = from;\n for (const ch of digits) {\n if (i >= length) break;\n next[i] = ch;\n i++;\n }\n commit(next);\n setActive(Math.min(i, length - 1));\n };\n\n // The keyboard is the single source of truth: preventDefault on keydown\n // reliably blocks native insertion (unlike beforeinput in React), so the hidden\n // input never accumulates a competing string and slot holes survive.\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;\n const k = e.key;\n if (/^[0-9]$/.test(k)) {\n e.preventDefault();\n insert(k);\n } else if (k === \"Backspace\") {\n e.preventDefault();\n // A filled slot clears in place; an empty slot steps back and clears there.\n if (slots[active]) {\n clearSlot(active);\n } else if (active > 0) {\n clearSlot(active - 1);\n setActive((current) => Math.max(current - 1, 0));\n }\n } else if (k === \"Delete\") {\n e.preventDefault();\n clearSlot(active);\n } else if (k === \"ArrowLeft\") {\n e.preventDefault();\n setActive((a) => Math.max(a - 1, 0));\n } else if (k === \"ArrowRight\") {\n e.preventDefault();\n setActive((a) => Math.min(a + 1, length - 1));\n } else if (k === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (k === \"End\") {\n e.preventDefault();\n setActive(length - 1);\n }\n };\n\n const onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n if (disabled) return;\n // preventDefault suppresses the duplicate onChange, keeping that path autofill-only.\n e.preventDefault();\n insert(e.clipboardData.getData(\"text\"), active);\n };\n\n // Autofill path: SMS one-time-code arrives as a whole value in one shot.\n // Keystrokes go through onKeyDown and paste through onPaste, so only autofill\n // reaches here — spread it across the slots from the start.\n const onChangeNative = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = sanitize(e.target.value, length);\n if (!digits) return;\n commit(toSlots(digits, length));\n setActive(Math.min(digits.length, length - 1));\n };\n\n // Error shake — imperative so it replays on every transition into \"error\".\n useEffect(() => {\n if (status !== \"error\" || reduce || !slotsRef.current) return;\n animate(slotsRef.current, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.45, ease: EASE_OUT });\n }, [status, reduce]);\n\n const showSuccess = status === \"success\";\n const activeIndex = focused ? active : -1;\n const message = showSuccess ? successMessage : status === \"error\" ? errorMessage : hint;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n {label ? (\n <label htmlFor={`${uid}-input`} className=\"font-medium text-foreground text-sm\">\n {label}\n </label>\n ) : null}\n <fieldset\n className=\"relative m-0 inline-flex w-max border-0 p-0\"\n onMouseDown={(e) => {\n if (disabled) return;\n // Suppress the native click-caret; we drive the active slot ourselves.\n e.preventDefault();\n // Clamp to the first empty slot so a click can't jump ahead of progress.\n const firstEmpty = slots.indexOf(\"\");\n const cap = firstEmpty === -1 ? length - 1 : firstEmpty;\n setActive(Math.min(slotFromClientX(e.clientX), cap));\n inputRef.current?.focus();\n }}\n >\n <input\n ref={inputRef}\n id={`${uid}-input`}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-invalid={status === \"error\"}\n // Kept empty on purpose — our state owns the digits, native holds none.\n value=\"\"\n maxLength={length}\n onKeyDown={onKeyDown}\n onChange={onChangeNative}\n onPaste={onPaste}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n // Transparent overlay owns focus, the soft keyboard, paste and autofill;\n // the slots below are purely presentational.\n className=\"absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed\"\n />\n\n <div ref={slotsRef} className=\"flex items-center gap-2\">\n {Array.from({ length }, (_, i) => {\n const char = slots[i] ?? \"\";\n const isActive = i === activeIndex;\n return (\n <div\n key={`${uid}-${i}`}\n data-active={isActive}\n data-filled={char !== \"\"}\n className={cn(\n \"relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200\",\n showSuccess\n ? \"border-emerald-500/60 text-foreground\"\n : status === \"error\"\n ? \"border-destructive/60 text-foreground\"\n : char\n ? \"border-border-strong text-foreground\"\n : \"border-border text-muted-foreground\",\n // Active slot reads stronger; twMerge lets this win the border.\n isActive && !showSuccess && status !== \"error\" && \"border-foreground\",\n disabled && \"opacity-50\",\n )}\n >\n {/* Blinking caret marks the active slot — centered when empty,\n trailing the digit when the slot is already filled. */}\n {isActive && !showSuccess ? (\n <motion.span\n aria-hidden\n animate={reduce ? undefined : { opacity: [1, 1, 0, 0] }}\n transition={\n reduce\n ? undefined\n : { duration: 1, repeat: Number.POSITIVE_INFINITY, ease: \"linear\" }\n }\n className={cn(\n \"pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground\",\n char ? \"right-3\" : \"left-1/2 -translate-x-1/2\",\n )}\n />\n ) : null}\n\n {/* Digits roll vertically. Each is absolutely centered so enter and\n exit overlap in place — no in-flow reflow, no sideways drift. */}\n <AnimatePresence initial={false}>\n {char ? (\n <motion.span\n key={char}\n initial={reduce ? { opacity: 0 } : { y: 14, opacity: 0, filter: \"blur(4px)\" }}\n animate={reduce ? { opacity: 1 } : { y: 0, opacity: 1, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { y: -14, opacity: 0, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.22, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center leading-none\"\n >\n {mask ? \"•\" : char}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </div>\n );\n })}\n </div>\n\n <AnimatePresence>\n {showSuccess ? (\n <motion.span\n initial={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n animate={reduce ? { opacity: 1 } : { scale: 1, opacity: 1 }}\n exit={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n transition={\n reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 28 }\n }\n className=\"pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500\"\n aria-hidden\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <title>Verified</title>\n <motion.path\n d=\"M5 13l4 4L19 7\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce ? { duration: 0 } : { duration: 0.35, ease: EASE_OUT, delay: 0.1 }\n }\n />\n </svg>\n </motion.span>\n ) : null}\n </AnimatePresence>\n </fieldset>\n\n {message ? (\n <p\n aria-live=\"polite\"\n className={cn(\n \"text-sm\",\n showSuccess\n ? \"text-emerald-500\"\n : status === \"error\"\n ? \"text-destructive\"\n : \"text-muted-foreground\",\n )}\n >\n {message}\n </p>\n ) : null}\n </div>\n );\n}\n\nfunction sanitize(raw: string, length: number) {\n return raw.replace(/\\D/g, \"\").slice(0, length);\n}\n\nfunction toSlots(raw: string, length: number) {\n const digits = sanitize(raw, length);\n return Array.from({ length }, (_, i) => digits[i] ?? \"\");\n}\n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"sources":["../../../src/components/motion/otp-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OTPStatus = \"idle\" | \"error\" | \"success\";\n\nexport interface OTPInputProps {\n /** Number of slots. Default 6. */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Fires once every slot is filled. */\n onComplete?: (value: string) => void;\n /** Optional label rendered above the slots. */\n label?: string;\n /** Helper text shown below the slots while idle. */\n hint?: string;\n /** Message shown below the slots when status is \"success\". */\n successMessage?: string;\n /** Message shown below the slots when status is \"error\". */\n errorMessage?: string;\n /** External validation feedback. \"error\" shakes, \"success\" draws a check. */\n status?: OTPStatus;\n /** Render dots instead of the typed digits. */\n mask?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Accessible label for the underlying input. */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function OTPInput({\n length = 6,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onComplete,\n label,\n hint,\n successMessage,\n errorMessage,\n status = \"idle\",\n mask = false,\n disabled = false,\n autoFocus = false,\n \"aria-label\": ariaLabel = \"One-time passcode\",\n className,\n}: OTPInputProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const inputRef = useRef<HTMLInputElement>(null);\n const slotsRef = useRef<HTMLDivElement>(null);\n\n const controlled = controlledValue !== undefined;\n\n // Source of truth is a fixed-length array, so a cleared middle slot stays an\n // in-place hole instead of collapsing the digits after it to the left.\n const [slots, setSlots] = useState<string[]>(() =>\n toSlots(controlled ? controlledValue : defaultValue, length),\n );\n const [focused, setFocused] = useState(false);\n const [active, setActive] = useState(0);\n\n const joined = slots.join(\"\");\n const joinedRef = useRef(joined);\n\n useEffect(() => {\n joinedRef.current = joined;\n }, [joined]);\n\n // Pull in external value changes; skip when the parent is just echoing our own\n // onChange, so internal holes survive the controlled round-trip.\n useEffect(() => {\n if (!controlled) return;\n const incoming = sanitize(controlledValue, length);\n if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));\n }, [controlled, controlledValue, length]);\n\n const commit = (next: string[]) => {\n const wasComplete = slots.every((c) => c !== \"\");\n setSlots(next);\n const str = next.join(\"\");\n onChange?.(str);\n // Fire only on the empty→full transition, not on every edit of a full code.\n if (!wasComplete && next.every((c) => c !== \"\")) onComplete?.(str);\n };\n\n const clearSlot = (idx: number) => {\n const next = [...slots];\n next[idx] = \"\";\n commit(next);\n };\n\n const slotFromClientX = (clientX: number) => {\n const els = slotsRef.current?.children;\n if (!els) return 0;\n for (let i = 0; i < els.length; i++) {\n if (clientX < els[i].getBoundingClientRect().right) return i;\n }\n return length - 1;\n };\n\n // Single insertion path: one digit overwrites the active slot and advances; a\n // multi-digit chunk (paste / SMS autofill) fills forward from the active slot.\n const insert = (raw: string, from = active) => {\n const digits = raw.replace(/\\D/g, \"\");\n if (!digits) return;\n const next = [...slots];\n let i = from;\n for (const ch of digits) {\n if (i >= length) break;\n next[i] = ch;\n i++;\n }\n commit(next);\n setActive(Math.min(i, length - 1));\n };\n\n // The keyboard is the single source of truth: preventDefault on keydown\n // reliably blocks native insertion (unlike beforeinput in React), so the hidden\n // input never accumulates a competing string and slot holes survive.\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;\n const k = e.key;\n if (/^[0-9]$/.test(k)) {\n e.preventDefault();\n insert(k);\n } else if (k === \"Backspace\") {\n e.preventDefault();\n // A filled slot clears in place; an empty slot steps back and clears there.\n if (slots[active]) {\n clearSlot(active);\n } else if (active > 0) {\n clearSlot(active - 1);\n setActive((current) => Math.max(current - 1, 0));\n }\n } else if (k === \"Delete\") {\n e.preventDefault();\n clearSlot(active);\n } else if (k === \"ArrowLeft\") {\n e.preventDefault();\n setActive((a) => Math.max(a - 1, 0));\n } else if (k === \"ArrowRight\") {\n e.preventDefault();\n setActive((a) => Math.min(a + 1, length - 1));\n } else if (k === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (k === \"End\") {\n e.preventDefault();\n setActive(length - 1);\n }\n };\n\n const onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n if (disabled) return;\n // preventDefault suppresses the duplicate onChange, keeping that path autofill-only.\n e.preventDefault();\n insert(e.clipboardData.getData(\"text\"), active);\n };\n\n // Autofill path: SMS one-time-code arrives as a whole value in one shot.\n // Keystrokes go through onKeyDown and paste through onPaste, so only autofill\n // reaches here — spread it across the slots from the start.\n const onChangeNative = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = sanitize(e.target.value, length);\n if (!digits) return;\n commit(toSlots(digits, length));\n setActive(Math.min(digits.length, length - 1));\n };\n\n // Error shake — imperative so it replays on every transition into \"error\".\n useEffect(() => {\n if (status !== \"error\" || reduce || !slotsRef.current) return;\n animate(slotsRef.current, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.45, ease: EASE_OUT });\n }, [status, reduce]);\n\n const showSuccess = status === \"success\";\n const activeIndex = focused ? active : -1;\n const message = showSuccess ? successMessage : status === \"error\" ? errorMessage : hint;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n {label ? (\n <label htmlFor={`${uid}-input`} className=\"font-medium text-foreground text-sm\">\n {label}\n </label>\n ) : null}\n <fieldset\n className=\"relative m-0 inline-flex w-max border-0 p-0\"\n onMouseDown={(e) => {\n if (disabled) return;\n // Suppress the native click-caret; we drive the active slot ourselves.\n e.preventDefault();\n // Clamp to the first empty slot so a click can't jump ahead of progress.\n const firstEmpty = slots.indexOf(\"\");\n const cap = firstEmpty === -1 ? length - 1 : firstEmpty;\n setActive(Math.min(slotFromClientX(e.clientX), cap));\n inputRef.current?.focus();\n }}\n >\n <input\n ref={inputRef}\n id={`${uid}-input`}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-invalid={status === \"error\"}\n // Kept empty on purpose — our state owns the digits, native holds none.\n value=\"\"\n maxLength={length}\n onKeyDown={onKeyDown}\n onChange={onChangeNative}\n onPaste={onPaste}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n // Transparent overlay owns focus, the soft keyboard, paste and autofill;\n // the slots below are purely presentational.\n className=\"absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed\"\n />\n\n <div ref={slotsRef} className=\"flex items-center gap-2\">\n {Array.from({ length }, (_, i) => {\n const char = slots[i] ?? \"\";\n const isActive = i === activeIndex;\n return (\n <div\n key={`${uid}-${i}`}\n data-active={isActive}\n data-filled={char !== \"\"}\n className={cn(\n \"relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200\",\n showSuccess\n ? \"border-emerald-500/60 text-foreground\"\n : status === \"error\"\n ? \"border-destructive/60 text-foreground\"\n : char\n ? \"border-border-strong text-foreground\"\n : \"border-border text-muted-foreground\",\n // Active slot reads stronger; twMerge lets this win the border.\n isActive && !showSuccess && status !== \"error\" && \"border-foreground\",\n disabled && \"opacity-50\",\n )}\n >\n {/* Blinking caret marks the active slot — centered when empty,\n trailing the digit when the slot is already filled. */}\n {isActive && !showSuccess ? (\n <motion.span\n aria-hidden\n animate={reduce ? undefined : { opacity: [1, 1, 0, 0] }}\n transition={\n reduce\n ? undefined\n : { duration: 1, repeat: Number.POSITIVE_INFINITY, ease: \"linear\" }\n }\n className={cn(\n \"pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground\",\n char ? \"right-3\" : \"left-1/2 -translate-x-1/2\",\n )}\n />\n ) : null}\n\n {/* Digits roll vertically. Each is absolutely centered so enter and\n exit overlap in place — no in-flow reflow, no sideways drift. */}\n <AnimatePresence initial={false}>\n {char ? (\n <motion.span\n key={char}\n initial={reduce ? { opacity: 0 } : { y: 14, opacity: 0, filter: \"blur(4px)\" }}\n animate={reduce ? { opacity: 1 } : { y: 0, opacity: 1, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { y: -14, opacity: 0, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.22, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center leading-none\"\n >\n {mask ? \"•\" : char}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </div>\n );\n })}\n </div>\n\n <AnimatePresence>\n {showSuccess ? (\n <motion.span\n initial={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n animate={reduce ? { opacity: 1 } : { scale: 1, opacity: 1 }}\n exit={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n transition={\n reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 28 }\n }\n className=\"pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500\"\n aria-hidden\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <title>Verified</title>\n <motion.path\n d=\"M5 13l4 4L19 7\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce ? { duration: 0 } : { duration: 0.35, ease: EASE_OUT, delay: 0.1 }\n }\n />\n </svg>\n </motion.span>\n ) : null}\n </AnimatePresence>\n </fieldset>\n\n {message ? (\n <p\n aria-live=\"polite\"\n className={cn(\n \"text-sm\",\n showSuccess\n ? \"text-emerald-500\"\n : status === \"error\"\n ? \"text-destructive\"\n : \"text-muted-foreground\",\n )}\n >\n {message}\n </p>\n ) : null}\n </div>\n );\n}\n\nfunction sanitize(raw: string, length: number) {\n return raw.replace(/\\D/g, \"\").slice(0, length);\n}\n\nfunction toSlots(raw: string, length: number) {\n const digits = sanitize(raw, length);\n return Array.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|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
3
3
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
4
4
|
import { useCallback, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
-
import { cn } from "
|
|
6
|
-
import { MoreHorizontal, X } from "lucide-react";
|
|
5
|
+
import { cn } from "cn";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { MoreHorizontal, X } from "lucide-react";
|
|
9
9
|
//#region src/components/motion/overflow-actions.tsx
|
|
10
10
|
const SHELL_TRANSITION = {
|
|
11
11
|
type: "spring",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflow-actions.js","names":[],"sources":["../../../src/components/motion/overflow-actions.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { MoreHorizontal, X } 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\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OverflowActionsSize = \"sm\" | \"md\";\n\nexport type OverflowActionItem = {\n id: string;\n label: ReactNode;\n icon?: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n};\n\nexport type OverflowActionsClassNames = {\n root?: string;\n track?: string;\n action?: string;\n primaryAction?: string;\n overflowAction?: string;\n toggle?: string;\n icon?: string;\n label?: string;\n};\n\nexport interface OverflowActionsProps {\n primaryActions: OverflowActionItem[];\n overflowActions: OverflowActionItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onAction?: (item: OverflowActionItem) => void;\n collapseOnAction?: boolean;\n size?: OverflowActionsSize;\n openLabel?: string;\n closeLabel?: string;\n className?: string;\n classNames?: OverflowActionsClassNames;\n}\n\n// This needs a softer layout spring than the app defaults so the overflow group\n// stays visually attached to the toggle while entering and leaving.\nconst SHELL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 220,\n damping: 17,\n mass: 0.85,\n};\n\nconst ICON_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(3px)\" },\n visible: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n exit: {\n opacity: 0,\n filter: \"blur(3px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n};\n\nconst OVERFLOW_ACTION_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(4px)\" },\n visible: { opacity: 1, filter: \"blur(0px)\" },\n exit: { opacity: 0, filter: \"blur(4px)\" },\n};\n\nconst TRACK_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1 p-1 text-xs\",\n md: \"gap-1.5 p-1.5 text-sm\",\n};\n\nconst GROUP_GAP_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1\",\n md: \"gap-1.5\",\n};\n\nconst ACTION_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 min-w-8 gap-1.5 px-3\",\n md: \"h-9 min-w-9 gap-2 px-3.5\",\n};\n\nconst TOGGLE_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 w-8\",\n md: \"h-9 w-9\",\n};\n\nconst ICON_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function OverflowActions({\n primaryActions,\n overflowActions,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onAction,\n collapseOnAction = false,\n size = \"md\",\n openLabel = \"Show extra actions\",\n closeLabel = \"Hide extra actions\",\n className,\n classNames,\n}: OverflowActionsProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const overflowId = useId();\n const overflowWrapperRef = useRef<HTMLDivElement>(null);\n const overflowWrapperLeftRef = useRef(0);\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n\n const transition = reduce ? { duration: 0 } : SHELL_TRANSITION;\n\n useLayoutEffect(() => {\n const overflowNode = overflowWrapperRef.current;\n if (!overflowNode) return;\n\n if (!isExpanded) {\n overflowNode.style.left = `${\n overflowWrapperLeftRef.current - overflowNode.getBoundingClientRect().left\n }px`;\n return;\n }\n\n overflowNode.style.left = \"\";\n overflowWrapperLeftRef.current = overflowNode.getBoundingClientRect().left;\n }, [isExpanded]);\n\n const handleAction = (item: OverflowActionItem) => {\n item.onClick?.();\n onAction?.(item);\n if (collapseOnAction) setIsExpanded(false);\n };\n\n return (\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex\", classNames?.root, className)}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\n \"relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card\",\n TRACK_SIZE_CLASS[size],\n classNames?.track,\n )}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex items-center\", GROUP_GAP_CLASS[size])}\n >\n {primaryActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.primaryAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"overflow-actions\"\n ref={overflowWrapperRef}\n id={overflowId}\n layout\n aria-hidden={!isExpanded}\n transition={transition}\n className={cn(\"relative inline-flex w-max items-center\", GROUP_GAP_CLASS[size])}\n >\n {overflowActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n overflow\n visible={isExpanded}\n variants={OVERFLOW_ACTION_VARIANTS}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.overflowAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <motion.button\n type=\"button\"\n layout\n aria-expanded={isExpanded}\n aria-controls={isExpanded ? overflowId : undefined}\n aria-label={isExpanded ? closeLabel : openLabel}\n title={isExpanded ? closeLabel : openLabel}\n onClick={() => setIsExpanded(!isExpanded)}\n whileTap={reduce ? undefined : { scale: 0.96 }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.03 }}\n transition={transition}\n className={cn(\n \"relative inline-grid shrink-0 place-items-center rounded-full bg-primary text-primary-foreground outline-none disabled:pointer-events-none disabled:opacity-50\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n TOGGLE_SIZE_CLASS[size],\n classNames?.toggle,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={isExpanded ? \"close\" : \"open\"}\n variants={ICON_VARIANTS}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"visible\"}\n exit={reduce ? { opacity: 0 } : \"exit\"}\n className=\"inline-grid place-items-center\"\n >\n {isExpanded ? (\n <X className={ICON_SIZE_CLASS[size]} />\n ) : (\n <MoreHorizontal className={ICON_SIZE_CLASS[size]} />\n )}\n </motion.span>\n </AnimatePresence>\n </motion.button>\n </motion.div>\n </motion.div>\n );\n}\n\nfunction ActionButton({\n item,\n size,\n reduce,\n canHover,\n overflow,\n visible = true,\n variants,\n onAction,\n layoutTransition,\n className,\n iconClassName,\n labelClassName,\n}: {\n item: OverflowActionItem;\n size: OverflowActionsSize;\n reduce: boolean | null;\n canHover: boolean;\n overflow?: boolean;\n visible?: boolean;\n variants?: Variants;\n onAction: (item: OverflowActionItem) => void;\n layoutTransition: Transition;\n className?: string;\n iconClassName?: string;\n labelClassName?: string;\n}) {\n const label = typeof item.label === \"string\" ? item.label : undefined;\n\n return (\n <motion.span\n layout=\"position\"\n variants={variants}\n initial={variants ? (reduce ? { opacity: 0 } : \"hidden\") : undefined}\n animate={variants ? (reduce ? { opacity: 1 } : \"visible\") : undefined}\n exit={variants ? (reduce ? { opacity: 0 } : \"exit\") : undefined}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.97 }}\n whileHover={reduce || !canHover || item.disabled ? undefined : { scale: 1.008 }}\n transition={layoutTransition}\n className=\"inline-flex shrink-0\"\n >\n <button\n type=\"button\"\n disabled={item.disabled}\n aria-label={item.ariaLabel}\n tabIndex={overflow && !visible ? -1 : undefined}\n title={label}\n onClick={() => onAction(item)}\n className={cn(\n \"inline-flex shrink-0 items-center justify-center rounded-full bg-background font-medium text-foreground outline-none\",\n \"disabled:pointer-events-none disabled:opacity-45\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n ACTION_SIZE_CLASS[size],\n className,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n iconClassName,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span className={cn(\"whitespace-nowrap\", labelClassName)}>{item.label}</span>\n </button>\n </motion.span>\n );\n}\n"],"mappings":";;;;;;;;;AAuDA,MAAM,mBAA+B;CACnC,MAAM;CACN,W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AI,WAAY,KAAA;EAC3D,SAAS,WAAY,SAAS,EAAE,SAAS,EAAE,IAAI,YAAa,KAAA;EAC5D,MAAM,WAAY,SAAS,EAAE,SAAS,EAAE,IAAI,SAAU,KAAA;EACtD,UAAU,UAAU,KAAK,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;EAC9D,YAAY,UAAU,CAAC,YAAY,KAAK,WAAW,KAAA,IAAY,EAAE,OAAO,MAAM;EAC9E,YAAY;EACZ,WAAU;EAEV,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,UAAU,KAAK;GACf,cAAY,KAAK;GACjB,UAAU,YAAY,CAAC,UAAU,KAAK,KAAA;GACtC,OAAO;GACP,eAAe,SAAS,IAAI;GAC5B,WAAW,GACT,wHACA,oDACA,iHACA,kBAAkB,OAClB,SACF;GAbF,UAAA,CAeG,KAAK,OACJ,oBAAC,QAAD;IACE,WAAW,GACT,oDACA,gBAAgB,OAChB,aACF;IAEC,UAAA,KAAK;GACF,CAAA,IACJ,MACJ,oBAAC,QAAD;IAAM,WAAW,GAAG,qBAAqB,cAAc;IAAI,UAAA,KAAK;GAAY,CAAA,CACtE;;CACG,CAAA;AAEjB"}
|
|
1
|
+
{"version":3,"file":"overflow-actions.js","names":[],"sources":["../../../src/components/motion/overflow-actions.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { MoreHorizontal, X } from \"lucide-react\";\nimport {\n AnimatePresence,\n motion,\n type Transition,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OverflowActionsSize = \"sm\" | \"md\";\n\nexport type OverflowActionItem = {\n id: string;\n label: ReactNode;\n icon?: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n};\n\nexport type OverflowActionsClassNames = {\n root?: string;\n track?: string;\n action?: string;\n primaryAction?: string;\n overflowAction?: string;\n toggle?: string;\n icon?: string;\n label?: string;\n};\n\nexport interface OverflowActionsProps {\n primaryActions: OverflowActionItem[];\n overflowActions: OverflowActionItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onAction?: (item: OverflowActionItem) => void;\n collapseOnAction?: boolean;\n size?: OverflowActionsSize;\n openLabel?: string;\n closeLabel?: string;\n className?: string;\n classNames?: OverflowActionsClassNames;\n}\n\n// This needs a softer layout spring than the app defaults so the overflow group\n// stays visually attached to the toggle while entering and leaving.\nconst SHELL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 220,\n damping: 17,\n mass: 0.85,\n};\n\nconst ICON_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(3px)\" },\n visible: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n exit: {\n opacity: 0,\n filter: \"blur(3px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n },\n};\n\nconst OVERFLOW_ACTION_VARIANTS: Variants = {\n hidden: { opacity: 0, filter: \"blur(4px)\" },\n visible: { opacity: 1, filter: \"blur(0px)\" },\n exit: { opacity: 0, filter: \"blur(4px)\" },\n};\n\nconst TRACK_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1 p-1 text-xs\",\n md: \"gap-1.5 p-1.5 text-sm\",\n};\n\nconst GROUP_GAP_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"gap-1\",\n md: \"gap-1.5\",\n};\n\nconst ACTION_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 min-w-8 gap-1.5 px-3\",\n md: \"h-9 min-w-9 gap-2 px-3.5\",\n};\n\nconst TOGGLE_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-8 w-8\",\n md: \"h-9 w-9\",\n};\n\nconst ICON_SIZE_CLASS: Record<OverflowActionsSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function OverflowActions({\n primaryActions,\n overflowActions,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onAction,\n collapseOnAction = false,\n size = \"md\",\n openLabel = \"Show extra actions\",\n closeLabel = \"Hide extra actions\",\n className,\n classNames,\n}: OverflowActionsProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const overflowId = useId();\n const overflowWrapperRef = useRef<HTMLDivElement>(null);\n const overflowWrapperLeftRef = useRef(0);\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n\n const transition = reduce ? { duration: 0 } : SHELL_TRANSITION;\n\n useLayoutEffect(() => {\n const overflowNode = overflowWrapperRef.current;\n if (!overflowNode) return;\n\n if (!isExpanded) {\n overflowNode.style.left = `${\n overflowWrapperLeftRef.current - overflowNode.getBoundingClientRect().left\n }px`;\n return;\n }\n\n overflowNode.style.left = \"\";\n overflowWrapperLeftRef.current = overflowNode.getBoundingClientRect().left;\n }, [isExpanded]);\n\n const handleAction = (item: OverflowActionItem) => {\n item.onClick?.();\n onAction?.(item);\n if (collapseOnAction) setIsExpanded(false);\n };\n\n return (\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex\", classNames?.root, className)}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\n \"relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card\",\n TRACK_SIZE_CLASS[size],\n classNames?.track,\n )}\n >\n <motion.div\n layout\n transition={transition}\n className={cn(\"inline-flex items-center\", GROUP_GAP_CLASS[size])}\n >\n {primaryActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.primaryAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"overflow-actions\"\n ref={overflowWrapperRef}\n id={overflowId}\n layout\n aria-hidden={!isExpanded}\n transition={transition}\n className={cn(\"relative inline-flex w-max items-center\", GROUP_GAP_CLASS[size])}\n >\n {overflowActions.map((item) => (\n <ActionButton\n key={item.id}\n item={item}\n size={size}\n reduce={reduce}\n canHover={canHover}\n overflow\n visible={isExpanded}\n variants={OVERFLOW_ACTION_VARIANTS}\n onAction={handleAction}\n layoutTransition={transition}\n className={cn(classNames?.action, classNames?.overflowAction)}\n iconClassName={classNames?.icon}\n labelClassName={classNames?.label}\n />\n ))}\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <motion.button\n type=\"button\"\n layout\n aria-expanded={isExpanded}\n aria-controls={isExpanded ? overflowId : undefined}\n aria-label={isExpanded ? closeLabel : openLabel}\n title={isExpanded ? closeLabel : openLabel}\n onClick={() => setIsExpanded(!isExpanded)}\n whileTap={reduce ? undefined : { scale: 0.96 }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.03 }}\n transition={transition}\n className={cn(\n \"relative inline-grid shrink-0 place-items-center rounded-full bg-primary text-primary-foreground outline-none disabled:pointer-events-none disabled:opacity-50\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n TOGGLE_SIZE_CLASS[size],\n classNames?.toggle,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={isExpanded ? \"close\" : \"open\"}\n variants={ICON_VARIANTS}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"visible\"}\n exit={reduce ? { opacity: 0 } : \"exit\"}\n className=\"inline-grid place-items-center\"\n >\n {isExpanded ? (\n <X className={ICON_SIZE_CLASS[size]} />\n ) : (\n <MoreHorizontal className={ICON_SIZE_CLASS[size]} />\n )}\n </motion.span>\n </AnimatePresence>\n </motion.button>\n </motion.div>\n </motion.div>\n );\n}\n\nfunction ActionButton({\n item,\n size,\n reduce,\n canHover,\n overflow,\n visible = true,\n variants,\n onAction,\n layoutTransition,\n className,\n iconClassName,\n labelClassName,\n}: {\n item: OverflowActionItem;\n size: OverflowActionsSize;\n reduce: boolean | null;\n canHover: boolean;\n overflow?: boolean;\n visible?: boolean;\n variants?: Variants;\n onAction: (item: OverflowActionItem) => void;\n layoutTransition: Transition;\n className?: string;\n iconClassName?: string;\n labelClassName?: string;\n}) {\n const label = typeof item.label === \"string\" ? item.label : undefined;\n\n return (\n <motion.span\n layout=\"position\"\n variants={variants}\n initial={variants ? (reduce ? { opacity: 0 } : \"hidden\") : undefined}\n animate={variants ? (reduce ? { opacity: 1 } : \"visible\") : undefined}\n exit={variants ? (reduce ? { opacity: 0 } : \"exit\") : undefined}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.97 }}\n whileHover={reduce || !canHover || item.disabled ? undefined : { scale: 1.008 }}\n transition={layoutTransition}\n className=\"inline-flex shrink-0\"\n >\n <button\n type=\"button\"\n disabled={item.disabled}\n aria-label={item.ariaLabel}\n tabIndex={overflow && !visible ? -1 : undefined}\n title={label}\n onClick={() => onAction(item)}\n className={cn(\n \"inline-flex shrink-0 items-center justify-center rounded-full bg-background font-medium text-foreground outline-none\",\n \"disabled:pointer-events-none disabled:opacity-45\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n ACTION_SIZE_CLASS[size],\n className,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n iconClassName,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span className={cn(\"whitespace-nowrap\", labelClassName)}>{item.label}</span>\n </button>\n </motion.span>\n );\n}\n"],"mappings":";;;;;;;;;AAuDA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,gBAA0B;CAC9B,QAAQ;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC1C,SAAS;EACP,SAAS;EACT,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;CAC/C;CACA,MAAM;EACJ,SAAS;EACT,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;CAC/C;AACF;AAEA,MAAM,2BAAqC;CACzC,QAAQ;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC1C,SAAS;EAAE,SAAS;EAAG,QAAQ;CAAY;CAC3C,MAAM;EAAE,SAAS;EAAG,QAAQ;CAAY;AAC1C;AAEA,MAAM,mBAAwD;CAC5D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAAuD;CAC3D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,oBAAyD;CAC7D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,oBAAyD;CAC7D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAAuD;CAC3D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,KAAK;CACjF,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAgB,gBAAgB,EAC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EA,SAAS,aAAa,EACpB,MACA,MACA,QACA,UACA,UACA,UAAU,MACV,UACA,UACA,kBACA,WACA,eACA,kBAcC;CACD,MAAM,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,KAAA;CAE5D,OACE,oBAAC,OAAO,MAAR;EACE,QAAO;EACG;EACV,SAAS,WAAY,SAAS,EAAE,SAAS,EAAE,IAAI,WAAY,KAAA;EAC3D,SAAS,WAAY,SAAS,EAAE,SAAS,EAAE,IAAI,YAAa,KAAA;EAC5D,MAAM,WAAY,SAAS,EAAE,SAAS,EAAE,IAAI,SAAU,KAAA;EACtD,UAAU,UAAU,KAAK,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;EAC9D,YAAY,UAAU,CAAC,YAAY,KAAK,WAAW,KAAA,IAAY,EAAE,OAAO,MAAM;EAC9E,YAAY;EACZ,WAAU;EAEV,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,UAAU,KAAK;GACf,cAAY,KAAK;GACjB,UAAU,YAAY,CAAC,UAAU,KAAK,KAAA;GACtC,OAAO;GACP,eAAe,SAAS,IAAI;GAC5B,WAAW,GACT,wHACA,oDACA,iHACA,kBAAkB,OAClB,SACF;GAbF,UAAA,CAeG,KAAK,OACJ,oBAAC,QAAD;IACE,WAAW,GACT,oDACA,gBAAgB,OAChB,aACF;IAEC,UAAA,KAAK;GACF,CAAA,IACJ,MACJ,oBAAC,QAAD;IAAM,WAAW,GAAG,qBAAqB,cAAc;IAAI,UAAA,KAAK;GAAY,CAAA,CACtE;;CACG,CAAA;AAEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallax.d.ts","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"parallax.d.ts","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"mappings":";;iBAiBiB;EACf,UAAU;;;;;;EAMV;EACA;;EAEA,YAAY,UAAU;;EAEtB;EACA;;wBAGc,WACd,UACA,OACA,MACA,WACA,QACA,aACC,gCAAa,IAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "cn";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { motion, useReducedMotion, useScroll, useSpring, useTransform } from "motion/react";
|
|
6
6
|
//#region src/components/motion/parallax.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallax.js","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport {\n type MotionStyle,\n motion,\n useReducedMotion,\n useScroll,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\
|
|
1
|
+
{"version":3,"file":"parallax.js","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport { cn } from \"cn\";\nimport {\n type MotionStyle,\n motion,\n useReducedMotion,\n useScroll,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\n// Soft follow so the drift trails the scroll smoothly; looser than the UI\n// springs in lib/ease.ts on purpose.\nconst PARALLAX_SPRING = { stiffness: 120, damping: 30, mass: 0.6 };\n\nexport interface ParallaxProps {\n children: ReactNode;\n /**\n * Drift as a fraction of the element's travel through the viewport.\n * Positive moves with the scroll (foreground), negative against it\n * (background). ~0.1–0.5 reads best.\n */\n speed?: number;\n axis?: \"x\" | \"y\";\n /** Scroll container for contained scroll areas. Defaults to the viewport. */\n container?: RefObject<HTMLElement | null>;\n /** Spring-smooth the drift. Disabled automatically under reduced motion. */\n spring?: boolean;\n className?: string;\n}\n\nexport function Parallax({\n children,\n speed = 0.3,\n axis = \"y\",\n container,\n spring = true,\n className,\n}: ParallaxProps) {\n const reduce = useReducedMotion();\n const ref = useRef<HTMLDivElement>(null);\n const { scrollYProgress } = useScroll({\n target: ref,\n container,\n offset: [\"start end\", \"end start\"],\n // Run after paint so a container ref defined higher in the tree is hydrated;\n // otherwise framer falls back to the document and only the page scroll works.\n // layoutEffect: false,\n });\n\n // progress 0→1 as the element crosses the viewport; map to a symmetric drift.\n const travel = speed * 100;\n const drift = useTransform(scrollYProgress, [0, 1], [travel, -travel]);\n const smoothed = useSpring(drift, PARALLAX_SPRING);\n const value = spring && !reduce ? smoothed : drift;\n\n const style: MotionStyle = reduce ? {} : axis === \"x\" ? { x: value } : { y: value };\n\n return (\n <motion.div ref={ref} style={style} className={cn(className)}>\n {children}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;AAeA,MAAM,kBAAkB;CAAE,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;AAkBjE,SAAgB,SAAS,EACvB,UACA,QAAQ,IACR,OAAO,KACP,WACA,SAAS,MACT,aACgB;CAChB,MAAM,SAAS,iBAAiB;CAChC,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,EAAE,oBAAoB,UAAU;EACpC,QAAQ;EACR;EACA,QAAQ,CAAC,aAAa,WAAW;CAInC,CAAC;CAGD,MAAM,SAAS,QAAQ;CACvB,MAAM,QAAQ,aAAa,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;CACrE,MAAM,WAAW,UAAU,OAAO,eAAe;CACjD,MAAM,QAAQ,UAAU,CAAC,SAAS,WAAW;CAE7C,MAAM,QAAqB,SAAS,CAAC,IAAI,SAAS,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,GAAG,MAAM;CAElF,OACE,oBAAC,OAAO,KAAR;EAAiB;EAAY;EAAO,WAAW,GAAG,SAAS;EACxD;CACS,CAAA;AAEhB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_PANEL } from "../../lib/ease.js";
|
|
3
3
|
import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.js";
|
|
4
4
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "cn";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-morph.js","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"end\";\n\ntype MorphContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n triggerId: string;\n contentId: string;\n /** The element the panel measures against — see `registerTrigger`. */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n registerTrigger: (node: HTMLElement | null) => void;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\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 <MorphPopover>`);\n return ctx;\n}\n\nexport interface MorphPopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\n/**\n * A popover whose panel morphs open from the trigger corner: it's laid out at\n * full size but clipped to the corner nearest the trigger, then unclips as one\n * piece. Closes on outside pointer / Escape. Controlled or uncontrolled.\n */\nexport function MorphPopover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: MorphPopoverProps) {\n const baseId = useId();\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const [trigger, setTrigger] = useState<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n // A trigger normally registers itself through MorphPopoverTrigger. It can't\n // when something else already clones the element — a Tooltip wrapping the\n // button, say — and an unregistered trigger leaves the panel with nothing to\n // measure against, so it renders permanently invisible. The root boxes the\n // trigger exactly (the content portals out of it), so it stands in until a\n // real trigger registers, and stands in again if that one unmounts. Both are\n // state, so a trigger arriving while the panel is open re-anchors it.\n const anchorRef = useMemo<React.MutableRefObject<HTMLElement | null>>(\n () => ({ current: trigger ?? root }),\n [root, trigger],\n );\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: a dismissal hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded. When no trigger has\n // registered, the root anchor stands in only if it can actually hold focus;\n // there is nowhere better than where the keyboard already is, so leave it.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (!inPanel) return;\n const restore = trigger ?? (root && root.tabIndex >= 0 ? root : null);\n restore?.focus();\n }, [root, setOpen, trigger]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (root && !root.contains(target) && !contentRef.current?.contains(target)) close();\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, root, close]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n triggerId: `${baseId}-trigger`,\n contentId: `${baseId}-content`,\n triggerRef: anchorRef,\n registerTrigger: setTrigger,\n contentRef,\n }),\n [open, setOpen, toggle, baseId, anchorRef],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={setRoot} className={cn(\"relative inline-flex\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphPopoverTriggerProps {\n children: ReactElement;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\n/** Wraps a single element, toggling the popover on click. */\nexport function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps) {\n const ctx = useMorphContext(\"MorphPopoverTrigger\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as ((e: unknown) => void) | undefined;\n const childRef = (child.props as { ref?: Ref<HTMLElement> }).ref;\n\n return cloneElement(child, {\n id: ctx.triggerId,\n ref: mergeRefs(childRef, ctx.registerTrigger),\n onClick: (e: unknown) => {\n childOnClick?.(e);\n ctx.toggle();\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n });\n}\n\nconst originFor = (side: Side, align: Align) =>\n `${side === \"bottom\" ? \"top\" : \"bottom\"} ${align === \"end\" ? \"right\" : \"left\"}`;\n\n// A clip that hides everything but the corner nearest the trigger, so the\n// panel appears to grow out of it. inset(top right bottom left).\nfunction clipHidden(side: Side, align: Align, radius: number) {\n const top = side === \"bottom\" ? \"0%\" : \"92%\";\n const bottom = side === \"bottom\" ? \"92%\" : \"0%\";\n const right = align === \"end\" ? \"0%\" : \"92%\";\n const left = align === \"end\" ? \"92%\" : \"0%\";\n return `inset(${top} ${right} ${bottom} ${left} round ${radius}px)`;\n}\nconst clipShown = (radius: number) => `inset(0% 0% 0% 0% round ${radius}px)`;\n\n// Preserve the original spring character on the wrapper, but tween the complex\n// clip-path so it cannot snap when the spring resolves its final distance.\nconst MORPH_CLIP_TRANSITION = { duration: 0.32, ease: EASE_OUT } as const;\n\nexport interface MorphPopoverContentProps {\n children: ReactNode;\n side?: Side;\n align?: Align;\n /** Gap between trigger and panel, in px. Default 8. */\n sideOffset?: number;\n /** Panel corner radius, in px. Default 16. */\n radius?: number;\n className?: string;\n}\n\nexport function MorphPopoverContent({\n children,\n side = \"bottom\",\n align = \"end\",\n sideOffset = 8,\n radius = 16,\n className,\n}: MorphPopoverContentProps) {\n const ctx = useMorphContext(\"MorphPopoverContent\");\n const reduce = useReducedMotion() ?? false;\n const [portalReady, setPortalReady] = useState(false);\n const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, portalReady && ctx.open);\n\n useEffect(() => setPortalReady(true), []);\n const left = layout\n ? align === \"end\"\n ? layout.trigger.left + layout.trigger.width - layout.content.width\n : layout.trigger.left\n : 0;\n const top = layout\n ? side === \"bottom\"\n ? layout.trigger.top + layout.trigger.height + sideOffset\n : layout.trigger.top - layout.content.height - sideOffset\n : 0;\n\n // Both directions travel between the exact same hidden/show states. Exit\n // targets \"hidden\" directly instead of introducing separate choreography.\n const wrap = reduce\n ? undefined\n : {\n hidden: { opacity: 0, scale: 0.96, transition: SPRING_PANEL },\n show: { opacity: 1, scale: 1, transition: SPRING_PANEL },\n };\n const clip = reduce\n ? undefined\n : {\n hidden: {\n clipPath: clipHidden(side, align, radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n show: {\n clipPath: clipShown(radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n };\n\n // Keep the server and first client render identical, then mount the portal.\n if (!portalReady) return null;\n\n return createPortal(\n <AnimatePresence>\n {ctx.open ? (\n <motion.div\n data-morph-popover-portal=\"\"\n // Wrapper carries the shadow as a drop-shadow filter, which hugs the\n // clipped shape below (box-shadow would just get clipped away).\n variants={wrap}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"show\"}\n exit={reduce ? { opacity: 0 } : \"hidden\"}\n transition={reduce ? { duration: 0.12 } : undefined}\n style={{\n left,\n top,\n visibility: layout ? \"visible\" : \"hidden\",\n transformOrigin: originFor(side, align),\n }}\n className=\"filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))] fixed z-9999\"\n >\n <motion.div\n ref={ctx.contentRef}\n id={ctx.contentId}\n role=\"dialog\"\n aria-labelledby={ctx.triggerId}\n variants={clip}\n style={{ borderRadius: radius }}\n className={cn(\"overflow-hidden border border-border bg-background\", className)}\n >\n {children}\n </motion.div>\n </motion.div>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;AAuCA,MAAM,eAAe,cAAwC,IAAI;AAEjE,SAAS,gBAAgB,WAAmB;CAC1C,MAAM,MAAM,WAAW,YAAY;CACnC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,GAAG,UAAU,oCAAoC;CAC3E,OAAO;AACT;;;;;;AAiBA,SAAgB,aAAa,EAC3B,UACA,MAAM,gBACN,cAAc,OACd,cACA,aACoB;CACpB,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,MAAM,WAAW,SAAgC,IAAI;CAC5D,MAAM,CAAC,SAAS,cAAc,SAA6B,IAAI;CAC/D,MAAM,aAAa,OAA8B,IAAI;CACrD,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iB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,CAAA;CACF,CAAA,IACV,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
|
|
1
|
+
{"version":3,"file":"popover-morph.js","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"end\";\n\ntype MorphContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n triggerId: string;\n contentId: string;\n /** The element the panel measures against — see `registerTrigger`. */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n registerTrigger: (node: HTMLElement | null) => void;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\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 <MorphPopover>`);\n return ctx;\n}\n\nexport interface MorphPopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\n/**\n * A popover whose panel morphs open from the trigger corner: it's laid out at\n * full size but clipped to the corner nearest the trigger, then unclips as one\n * piece. Closes on outside pointer / Escape. Controlled or uncontrolled.\n */\nexport function MorphPopover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: MorphPopoverProps) {\n const baseId = useId();\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const [trigger, setTrigger] = useState<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n // A trigger normally registers itself through MorphPopoverTrigger. It can't\n // when something else already clones the element — a Tooltip wrapping the\n // button, say — and an unregistered trigger leaves the panel with nothing to\n // measure against, so it renders permanently invisible. The root boxes the\n // trigger exactly (the content portals out of it), so it stands in until a\n // real trigger registers, and stands in again if that one unmounts. Both are\n // state, so a trigger arriving while the panel is open re-anchors it.\n const anchorRef = useMemo<React.MutableRefObject<HTMLElement | null>>(\n () => ({ current: trigger ?? root }),\n [root, trigger],\n );\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: a dismissal hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded. When no trigger has\n // registered, the root anchor stands in only if it can actually hold focus;\n // there is nowhere better than where the keyboard already is, so leave it.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (!inPanel) return;\n const restore = trigger ?? (root && root.tabIndex >= 0 ? root : null);\n restore?.focus();\n }, [root, setOpen, trigger]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (root && !root.contains(target) && !contentRef.current?.contains(target)) close();\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, root, close]);\n\n const ctx = useMemo<MorphContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n triggerId: `${baseId}-trigger`,\n contentId: `${baseId}-content`,\n triggerRef: anchorRef,\n registerTrigger: setTrigger,\n contentRef,\n }),\n [open, setOpen, toggle, baseId, anchorRef],\n );\n\n return (\n <MorphContext.Provider value={ctx}>\n <div ref={setRoot} className={cn(\"relative inline-flex\", className)}>\n {children}\n </div>\n </MorphContext.Provider>\n );\n}\n\nexport interface MorphPopoverTriggerProps {\n children: ReactElement;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\n/** Wraps a single element, toggling the popover on click. */\nexport function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps) {\n const ctx = useMorphContext(\"MorphPopoverTrigger\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as ((e: unknown) => void) | undefined;\n const childRef = (child.props as { ref?: Ref<HTMLElement> }).ref;\n\n return cloneElement(child, {\n id: ctx.triggerId,\n ref: mergeRefs(childRef, ctx.registerTrigger),\n onClick: (e: unknown) => {\n childOnClick?.(e);\n ctx.toggle();\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n });\n}\n\nconst originFor = (side: Side, align: Align) =>\n `${side === \"bottom\" ? \"top\" : \"bottom\"} ${align === \"end\" ? \"right\" : \"left\"}`;\n\n// A clip that hides everything but the corner nearest the trigger, so the\n// panel appears to grow out of it. inset(top right bottom left).\nfunction clipHidden(side: Side, align: Align, radius: number) {\n const top = side === \"bottom\" ? \"0%\" : \"92%\";\n const bottom = side === \"bottom\" ? \"92%\" : \"0%\";\n const right = align === \"end\" ? \"0%\" : \"92%\";\n const left = align === \"end\" ? \"92%\" : \"0%\";\n return `inset(${top} ${right} ${bottom} ${left} round ${radius}px)`;\n}\nconst clipShown = (radius: number) => `inset(0% 0% 0% 0% round ${radius}px)`;\n\n// Preserve the original spring character on the wrapper, but tween the complex\n// clip-path so it cannot snap when the spring resolves its final distance.\nconst MORPH_CLIP_TRANSITION = { duration: 0.32, ease: EASE_OUT } as const;\n\nexport interface MorphPopoverContentProps {\n children: ReactNode;\n side?: Side;\n align?: Align;\n /** Gap between trigger and panel, in px. Default 8. */\n sideOffset?: number;\n /** Panel corner radius, in px. Default 16. */\n radius?: number;\n className?: string;\n}\n\nexport function MorphPopoverContent({\n children,\n side = \"bottom\",\n align = \"end\",\n sideOffset = 8,\n radius = 16,\n className,\n}: MorphPopoverContentProps) {\n const ctx = useMorphContext(\"MorphPopoverContent\");\n const reduce = useReducedMotion() ?? false;\n const [portalReady, setPortalReady] = useState(false);\n const layout = usePopoverPortalPosition(ctx.triggerRef, ctx.contentRef, portalReady && ctx.open);\n\n useEffect(() => setPortalReady(true), []);\n const left = layout\n ? align === \"end\"\n ? layout.trigger.left + layout.trigger.width - layout.content.width\n : layout.trigger.left\n : 0;\n const top = layout\n ? side === \"bottom\"\n ? layout.trigger.top + layout.trigger.height + sideOffset\n : layout.trigger.top - layout.content.height - sideOffset\n : 0;\n\n // Both directions travel between the exact same hidden/show states. Exit\n // targets \"hidden\" directly instead of introducing separate choreography.\n const wrap = reduce\n ? undefined\n : {\n hidden: { opacity: 0, scale: 0.96, transition: SPRING_PANEL },\n show: { opacity: 1, scale: 1, transition: SPRING_PANEL },\n };\n const clip = reduce\n ? undefined\n : {\n hidden: {\n clipPath: clipHidden(side, align, radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n show: {\n clipPath: clipShown(radius),\n transition: MORPH_CLIP_TRANSITION,\n },\n };\n\n // Keep the server and first client render identical, then mount the portal.\n if (!portalReady) return null;\n\n return createPortal(\n <AnimatePresence>\n {ctx.open ? (\n <motion.div\n data-morph-popover-portal=\"\"\n // Wrapper carries the shadow as a drop-shadow filter, which hugs the\n // clipped shape below (box-shadow would just get clipped away).\n variants={wrap}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"show\"}\n exit={reduce ? { opacity: 0 } : \"hidden\"}\n transition={reduce ? { duration: 0.12 } : undefined}\n style={{\n left,\n top,\n visibility: layout ? \"visible\" : \"hidden\",\n transformOrigin: originFor(side, align),\n }}\n className=\"filter-[drop-shadow(0_10px_18px_rgba(0,0,0,0.14))] fixed z-9999\"\n >\n <motion.div\n ref={ctx.contentRef}\n id={ctx.contentId}\n role=\"dialog\"\n aria-labelledby={ctx.triggerId}\n variants={clip}\n style={{ borderRadius: radius }}\n className={cn(\"overflow-hidden border border-border bg-background\", className)}\n >\n {children}\n </motion.div>\n </motion.div>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;AAuCA,MAAM,eAAe,cAAwC,IAAI;AAEjE,SAAS,gBAAgB,WAAmB;CAC1C,MAAM,MAAM,WAAW,YAAY;CACnC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,GAAG,UAAU,oCAAoC;CAC3E,OAAO;AACT;;;;;;AAiBA,SAAgB,aAAa,EAC3B,UACA,MAAM,gBACN,cAAc,OACd,cACA,aACoB;CACpB,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,MAAM,WAAW,SAAgC,IAAI;CAC5D,MAAM,CAAC,SAAS,cAAc,SAA6B,IAAI;CAC/D,MAAM,aAAa,OAA8B,IAAI;CACrD,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAE3C,MAAM,UAAU,aACb,SAAkB;EACjB,IAAI,CAAC,YAAY,gBAAgB,IAAI;EACrC,eAAe,IAAI;CACrB,GACA,CAAC,YAAY,YAAY,CAC3B;CACA,MAAM,SAAS,kBAAkB,QAAQ,CAAC,IAAI,GAAG,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,OAAO,QAAQ,QAC5D,OAAO,QAAQ,OACjB;CACJ,MAAM,MAAM,SACR,SAAS,WACP,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS,aAC7C,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS,aAC/C;CAIJ,MAAM,OAAO,SACT,KAAA,IACA;EACE,QAAQ;GAAE,SAAS;GAAG,OAAO;GAAM,YAAY;EAAa;EAC5D,MAAM;GAAE,SAAS;GAAG,OAAO;GAAG,YAAY;EAAa;CACzD;CACJ,MAAM,OAAO,SACT,KAAA,IACA;EACE,QAAQ;GACN,UAAU,WAAW,MAAM,OAAO,MAAM;GACxC,YAAY;EACd;EACA,MAAM;GACJ,UAAU,UAAU,MAAM;GAC1B,YAAY;EACd;CACF;CAGJ,IAAI,CAAC,aAAa,OAAO;CAEzB,OAAO,aACL,oBAAC,iBAAD,EAAA,UACG,IAAI,OACH,oBAAC,OAAO,KAAR;EACE,6BAA0B;EAG1B,UAAU;EACV,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;EACnC,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;EACnC,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI;EAChC,YAAY,SAAS,EAAE,UAAU,IAAK,IAAI,KAAA;EAC1C,OAAO;GACL;GACA;GACA,YAAY,SAAS,YAAY;GACjC,iBAAiB,UAAU,MAAM,KAAK;EACxC;EACA,WAAU;EAEV,UAAA,oBAAC,OAAO,KAAR;GACE,KAAK,IAAI;GACT,IAAI,IAAI;GACR,MAAK;GACL,mBAAiB,IAAI;GACrB,UAAU;GACV,OAAO,EAAE,cAAc,OAAO;GAC9B,WAAW,GAAG,sDAAsD,SAAS;GAE5E;EACS,CAAA;CACF,CAAA,IACV,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
|
|
@@ -4,7 +4,7 @@ import { useHoverGesture } from "../../hooks/use-hover-gesture.js";
|
|
|
4
4
|
import { useTapGesture } from "../../hooks/use-tap-gesture.js";
|
|
5
5
|
import { t as usePopoverPortalPosition } from "../../popover-position-BUqYCq8X.js";
|
|
6
6
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { cn } from "
|
|
7
|
+
import { cn } from "cn";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { animate, useMotionValue, useMotionValueEvent, useReducedMotion } from "motion/react";
|
|
10
10
|
import { createPortal } from "react-dom";
|