@kumix/ui 0.3.0 → 0.3.2
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 +46 -17
- package/dist/components/agents/agent-activity/activity-row.d.ts +8 -0
- package/dist/components/agents/agent-activity/activity-row.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/activity-row.js +228 -0
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -0
- package/dist/components/agents/agent-activity/index.d.ts +6 -0
- package/dist/components/agents/agent-activity/index.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/index.js +182 -0
- package/dist/components/agents/agent-activity/index.js.map +1 -0
- package/dist/components/agents/agent-code.d.ts +25 -0
- package/dist/components/agents/agent-code.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +117 -0
- package/dist/components/agents/agent-code.js.map +1 -0
- package/dist/components/agents/agent-disclosure.d.ts +12 -0
- package/dist/components/agents/agent-disclosure.d.ts.map +1 -0
- package/dist/components/agents/agent-disclosure.js +36 -0
- package/dist/components/agents/agent-disclosure.js.map +1 -0
- package/dist/components/agents/ai-sidebar.d.ts +41 -0
- package/dist/components/agents/ai-sidebar.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.js +576 -0
- package/dist/components/agents/ai-sidebar.js.map +1 -0
- package/dist/components/agents/approval-card/index.d.ts +51 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -0
- package/dist/components/agents/approval-card/index.js +317 -0
- package/dist/components/agents/approval-card/index.js.map +1 -0
- package/dist/components/agents/chat-app.d.ts +10 -0
- package/dist/components/agents/chat-app.d.ts.map +1 -0
- package/dist/components/agents/chat-app.js +20 -0
- package/dist/components/agents/chat-app.js.map +1 -0
- package/dist/components/agents/citations.d.ts +45 -0
- package/dist/components/agents/citations.d.ts.map +1 -0
- package/dist/components/agents/citations.js +175 -0
- package/dist/components/agents/citations.js.map +1 -0
- package/dist/components/agents/code-block.d.ts +21 -0
- package/dist/components/agents/code-block.d.ts.map +1 -0
- package/dist/components/agents/code-block.js +113 -0
- package/dist/components/agents/code-block.js.map +1 -0
- package/dist/components/agents/file-diff.d.ts +30 -0
- package/dist/components/agents/file-diff.d.ts.map +1 -0
- package/dist/components/agents/file-diff.js +186 -0
- package/dist/components/agents/file-diff.js.map +1 -0
- package/dist/components/agents/image-generation.d.ts +27 -0
- package/dist/components/agents/image-generation.d.ts.map +1 -0
- package/dist/components/agents/image-generation.js +308 -0
- package/dist/components/agents/image-generation.js.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts +16 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.js +117 -0
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts +20 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.js +184 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts +13 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js +17 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -0
- package/dist/components/agents/message-bubble.d.ts +38 -0
- package/dist/components/agents/message-bubble.d.ts.map +1 -0
- package/dist/components/agents/message-bubble.js +182 -0
- package/dist/components/agents/message-bubble.js.map +1 -0
- package/dist/components/agents/message-context.d.ts +6 -0
- package/dist/components/agents/message-context.d.ts.map +1 -0
- package/dist/components/agents/message-context.js +8 -0
- package/dist/components/agents/message-context.js.map +1 -0
- package/dist/components/agents/message-scroller.d.ts +30 -0
- package/dist/components/agents/message-scroller.d.ts.map +1 -0
- package/dist/components/agents/message-scroller.js +314 -0
- package/dist/components/agents/message-scroller.js.map +1 -0
- package/dist/components/agents/message.d.ts +37 -0
- package/dist/components/agents/message.d.ts.map +1 -0
- package/dist/components/agents/message.js +139 -0
- package/dist/components/agents/message.js.map +1 -0
- package/dist/components/agents/prompt-input.d.ts +37 -0
- package/dist/components/agents/prompt-input.d.ts.map +1 -0
- package/dist/components/agents/prompt-input.js +216 -0
- package/dist/components/agents/prompt-input.js.map +1 -0
- package/dist/components/agents/streaming-response.d.ts +35 -0
- package/dist/components/agents/streaming-response.d.ts.map +1 -0
- package/dist/components/agents/streaming-response.js +151 -0
- package/dist/components/agents/streaming-response.js.map +1 -0
- package/dist/components/agents/todo-list.d.ts +24 -0
- package/dist/components/agents/todo-list.d.ts.map +1 -0
- package/dist/components/agents/todo-list.js +334 -0
- package/dist/components/agents/todo-list.js.map +1 -0
- package/dist/components/agents/tool-approval.d.ts +33 -0
- package/dist/components/agents/tool-approval.d.ts.map +1 -0
- package/dist/components/agents/tool-approval.js +166 -0
- package/dist/components/agents/tool-approval.js.map +1 -0
- package/dist/components/agents/tool-result.d.ts +34 -0
- package/dist/components/agents/tool-result.d.ts.map +1 -0
- package/dist/components/agents/tool-result.js +220 -0
- package/dist/components/agents/tool-result.js.map +1 -0
- package/dist/components/custom/confirm-dialog.d.ts +16 -0
- package/dist/components/custom/confirm-dialog.d.ts.map +1 -0
- package/dist/components/custom/confirm-dialog.js +93 -0
- package/dist/components/custom/confirm-dialog.js.map +1 -0
- package/dist/components/custom/toast.d.ts +20 -0
- package/dist/components/custom/toast.d.ts.map +1 -0
- package/dist/components/custom/toast.js +73 -0
- package/dist/components/custom/toast.js.map +1 -0
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +3 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/attachment-upload.d.ts +47 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -0
- package/dist/components/motion/attachment-upload.js +737 -0
- package/dist/components/motion/attachment-upload.js.map +1 -0
- package/dist/components/motion/availability-scheduler/copy-menu.d.ts +10 -0
- package/dist/components/motion/availability-scheduler/copy-menu.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/copy-menu.js +3 -0
- package/dist/components/motion/availability-scheduler/day-row.d.ts +15 -0
- package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/day-row.js +181 -0
- package/dist/components/motion/availability-scheduler/day-row.js.map +1 -0
- package/dist/components/motion/availability-scheduler/icon-button.d.ts +15 -0
- package/dist/components/motion/availability-scheduler/icon-button.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/icon-button.js +24 -0
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -0
- package/dist/components/motion/availability-scheduler/index.d.ts +14 -0
- package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/index.js +59 -0
- package/dist/components/motion/availability-scheduler/index.js.map +1 -0
- package/dist/components/motion/availability-scheduler/time-select.d.ts +10 -0
- package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/time-select.js +26 -0
- package/dist/components/motion/availability-scheduler/time-select.js.map +1 -0
- package/dist/components/motion/bloom-menu.d.ts +17 -0
- package/dist/components/motion/bloom-menu.d.ts.map +1 -0
- package/dist/components/motion/bloom-menu.js +170 -0
- package/dist/components/motion/bloom-menu.js.map +1 -0
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/index.d.ts +4 -0
- package/dist/components/motion/button/index.js +5 -0
- package/dist/components/motion/button/magnetic.js +1 -1
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/center-morph-modal.js +3 -3
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +2 -2
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/command-palette.d.ts +26 -0
- package/dist/components/motion/command-palette.d.ts.map +1 -0
- package/dist/components/motion/command-palette.js +250 -0
- package/dist/components/motion/command-palette.js.map +1 -0
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/dynamic-island.d.ts +22 -0
- package/dist/components/motion/dynamic-island.d.ts.map +1 -0
- package/dist/components/motion/dynamic-island.js +143 -0
- package/dist/components/motion/dynamic-island.js.map +1 -0
- package/dist/components/motion/expandable-action-bar.d.ts +52 -0
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -0
- package/dist/components/motion/expandable-action-bar.js +191 -0
- package/dist/components/motion/expandable-action-bar.js.map +1 -0
- package/dist/components/motion/expandable-tabs.d.ts +33 -0
- package/dist/components/motion/expandable-tabs.d.ts.map +1 -0
- package/dist/components/motion/expandable-tabs.js +291 -0
- package/dist/components/motion/expandable-tabs.js.map +1 -0
- package/dist/components/motion/feedback-widget.d.ts +18 -0
- package/dist/components/motion/feedback-widget.d.ts.map +1 -0
- package/dist/components/motion/feedback-widget.js +413 -0
- package/dist/components/motion/feedback-widget.js.map +1 -0
- package/dist/components/motion/file-upload.d.ts +48 -0
- package/dist/components/motion/file-upload.d.ts.map +1 -0
- package/dist/components/motion/file-upload.js +382 -0
- package/dist/components/motion/file-upload.js.map +1 -0
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/infinite-masonry.d.ts +31 -0
- package/dist/components/motion/infinite-masonry.d.ts.map +1 -0
- package/dist/components/motion/infinite-masonry.js +223 -0
- package/dist/components/motion/infinite-masonry.js.map +1 -0
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/not-found/glitch.d.ts +6 -0
- package/dist/components/motion/not-found/glitch.d.ts.map +1 -0
- package/dist/components/motion/not-found/glitch.js +90 -0
- package/dist/components/motion/not-found/glitch.js.map +1 -0
- package/dist/components/motion/not-found/magnetic.d.ts +6 -0
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -0
- package/dist/components/motion/not-found/magnetic.js +47 -0
- package/dist/components/motion/not-found/magnetic.js.map +1 -0
- package/dist/components/motion/not-found/shared.d.ts +32 -0
- package/dist/components/motion/not-found/shared.d.ts.map +1 -0
- package/dist/components/motion/not-found/shared.js +52 -0
- package/dist/components/motion/not-found/shared.js.map +1 -0
- package/dist/components/motion/not-found/spotlight.d.ts +6 -0
- package/dist/components/motion/not-found/spotlight.d.ts.map +1 -0
- package/dist/components/motion/not-found/spotlight.js +70 -0
- package/dist/components/motion/not-found/spotlight.js.map +1 -0
- package/dist/components/motion/not-found/stacked.d.ts +6 -0
- package/dist/components/motion/not-found/stacked.d.ts.map +1 -0
- package/dist/components/motion/not-found/stacked.js +95 -0
- package/dist/components/motion/not-found/stacked.js.map +1 -0
- package/dist/components/motion/not-found/terminal.d.ts +6 -0
- package/dist/components/motion/not-found/terminal.d.ts.map +1 -0
- package/dist/components/motion/not-found/terminal.js +90 -0
- package/dist/components/motion/not-found/terminal.js.map +1 -0
- package/dist/components/motion/notification-stack.d.ts +35 -0
- package/dist/components/motion/notification-stack.d.ts.map +1 -0
- package/dist/components/motion/notification-stack.js +187 -0
- package/dist/components/motion/notification-stack.js.map +1 -0
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/otp-input.d.ts +32 -0
- package/dist/components/motion/otp-input.d.ts.map +1 -0
- package/dist/components/motion/otp-input.js +272 -0
- package/dist/components/motion/otp-input.js.map +1 -0
- package/dist/components/motion/overflow-actions.d.ts +39 -0
- package/dist/components/motion/overflow-actions.d.ts.map +1 -0
- package/dist/components/motion/overflow-actions.js +220 -0
- package/dist/components/motion/overflow-actions.js.map +1 -0
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/popover-morph.js +2 -2
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/preview-rail.d.ts +10 -2
- package/dist/components/motion/preview-rail.d.ts.map +1 -1
- package/dist/components/motion/preview-rail.js +58 -27
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +2 -2
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-ruler.js +2 -2
- 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.js +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shared-layout-bg.js +2 -2
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/smooth-scroll.js +1 -1
- package/dist/components/motion/swipeable-list.d.ts +60 -0
- package/dist/components/motion/swipeable-list.d.ts.map +1 -0
- package/dist/components/motion/swipeable-list.js +254 -0
- package/dist/components/motion/swipeable-list.js.map +1 -0
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/tabs.js +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-shimmer.d.ts.map +1 -1
- package/dist/components/motion/text-shimmer.js +4 -3
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tooltip.js +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +4 -3
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -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.d.ts +15 -4
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +35 -7
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +3 -2
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +0 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -3
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +12 -7
- 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.d.ts +71 -4
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +146 -39
- 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.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +4 -5
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +6 -5
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +9 -10
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +60 -33
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +153 -69
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +105 -20
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +83 -10
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +47 -44
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +20 -2
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +7 -5
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -1
- package/dist/components/reui/filters.js +26 -21
- package/dist/components/reui/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +8 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/sortable.js +13 -11
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/questionnaire.d.ts +21 -0
- package/dist/components/ui/questionnaire.d.ts.map +1 -0
- package/dist/components/ui/questionnaire.js +164 -0
- package/dist/components/ui/questionnaire.js.map +1 -0
- package/dist/copy-menu-Bk5GP9Gp.js +201 -0
- package/dist/copy-menu-Bk5GP9Gp.js.map +1 -0
- package/dist/hooks/use-body-classes.d.ts +0 -3
- package/dist/hooks/use-body-classes.d.ts.map +1 -1
- package/dist/hooks/use-body-classes.js +0 -3
- package/dist/hooks/use-body-classes.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +0 -3
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +0 -3
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-file-upload.js +6 -4
- package/dist/hooks/use-file-upload.js.map +1 -1
- package/dist/hooks/use-hydrated.d.ts +0 -10
- package/dist/hooks/use-hydrated.d.ts.map +1 -1
- package/dist/hooks/use-hydrated.js +0 -10
- package/dist/hooks/use-hydrated.js.map +1 -1
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -1
- package/dist/hooks/use-intersection-observer.js +0 -5
- package/dist/hooks/use-intersection-observer.js.map +1 -1
- package/dist/hooks/use-is-mac.d.ts +0 -5
- package/dist/hooks/use-is-mac.d.ts.map +1 -1
- package/dist/hooks/use-is-mac.js +0 -5
- package/dist/hooks/use-is-mac.js.map +1 -1
- package/dist/hooks/use-media-query.d.ts +0 -5
- package/dist/hooks/use-media-query.d.ts.map +1 -1
- package/dist/hooks/use-media-query.js +0 -5
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-meta-color.d.ts.map +1 -1
- package/dist/hooks/use-meta-color.js +0 -3
- package/dist/hooks/use-meta-color.js.map +1 -1
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -1
- package/dist/hooks/use-mutation-observer.js +0 -5
- package/dist/hooks/use-mutation-observer.js.map +1 -1
- package/dist/hooks/use-scroll-position.d.ts.map +1 -1
- package/dist/hooks/use-scroll-position.js +0 -5
- package/dist/hooks/use-scroll-position.js.map +1 -1
- package/dist/hooks/use-slider-input.d.ts.map +1 -1
- package/dist/hooks/use-slider-input.js +0 -5
- package/dist/hooks/use-slider-input.js.map +1 -1
- package/dist/hooks/use-viewport.d.ts +0 -5
- package/dist/hooks/use-viewport.d.ts.map +1 -1
- package/dist/hooks/use-viewport.js +0 -5
- package/dist/hooks/use-viewport.js.map +1 -1
- package/dist/lib/favicon.d.ts +5 -0
- package/dist/lib/favicon.d.ts.map +1 -0
- package/dist/lib/favicon.js +12 -0
- package/dist/lib/favicon.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +8 -0
- package/dist/lib/text-shimmer.d.ts.map +1 -0
- package/dist/lib/text-shimmer.js +10 -0
- package/dist/lib/text-shimmer.js.map +1 -0
- package/dist/types-j36vVGtZ.d.ts +78 -0
- package/dist/types-j36vVGtZ.d.ts.map +1 -0
- package/dist/types-smkWN_7x.d.ts +20 -0
- package/dist/types-smkWN_7x.d.ts.map +1 -0
- package/package.json +18 -13
- package/dist/components/ui/sonner.d.ts +0 -7
- package/dist/components/ui/sonner.d.ts.map +0 -1
- package/dist/components/ui/sonner.js +0 -32
- package/dist/components/ui/sonner.js.map +0 -1
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
3
|
+
import { Tooltip } from "./tooltip.js";
|
|
4
|
+
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { AlertCircle, Check, ExternalLink, FileImage, Link, LoaderCircle, Mic, Paperclip, Pause, Play, RotateCcw, Upload, X } from "lucide-react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
//#region src/components/motion/attachment-upload.tsx
|
|
11
|
+
const ITEM_TRANSITION = {
|
|
12
|
+
duration: .2,
|
|
13
|
+
ease: EASE_OUT
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_MAX_FILE_SIZE = 524288e3;
|
|
16
|
+
const UPLOAD_PROGRESS_MS = 900;
|
|
17
|
+
const UPLOAD_COMPLETE_HOLD_MS = 1e3;
|
|
18
|
+
const REMOVE_PENDING_MS = 420;
|
|
19
|
+
const WAVEFORM_BARS = [
|
|
20
|
+
18,
|
|
21
|
+
31,
|
|
22
|
+
24,
|
|
23
|
+
39,
|
|
24
|
+
30,
|
|
25
|
+
43,
|
|
26
|
+
27,
|
|
27
|
+
18,
|
|
28
|
+
9,
|
|
29
|
+
29,
|
|
30
|
+
38,
|
|
31
|
+
24,
|
|
32
|
+
34,
|
|
33
|
+
18,
|
|
34
|
+
26,
|
|
35
|
+
37,
|
|
36
|
+
21,
|
|
37
|
+
14,
|
|
38
|
+
7,
|
|
39
|
+
11,
|
|
40
|
+
22,
|
|
41
|
+
35,
|
|
42
|
+
18,
|
|
43
|
+
26,
|
|
44
|
+
41,
|
|
45
|
+
29,
|
|
46
|
+
17,
|
|
47
|
+
33
|
|
48
|
+
].map((height, index) => ({
|
|
49
|
+
id: `wave-${index}-${height}`,
|
|
50
|
+
height
|
|
51
|
+
}));
|
|
52
|
+
function useControllableList({ value, defaultValue, onValueChange }) {
|
|
53
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? []);
|
|
54
|
+
const controlled = value !== void 0;
|
|
55
|
+
return [value ?? internalValue, useCallback((next) => {
|
|
56
|
+
if (!controlled) setInternalValue(next);
|
|
57
|
+
onValueChange?.(next);
|
|
58
|
+
}, [controlled, onValueChange])];
|
|
59
|
+
}
|
|
60
|
+
function formatBytes(bytes) {
|
|
61
|
+
if (bytes === void 0 || !Number.isFinite(bytes) || bytes <= 0) return null;
|
|
62
|
+
const units = [
|
|
63
|
+
"B",
|
|
64
|
+
"KB",
|
|
65
|
+
"MB",
|
|
66
|
+
"GB"
|
|
67
|
+
];
|
|
68
|
+
const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
|
|
69
|
+
const value = bytes / 1024 ** exponent;
|
|
70
|
+
return `${value >= 10 || exponent === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[exponent]}`;
|
|
71
|
+
}
|
|
72
|
+
function formatDuration(seconds) {
|
|
73
|
+
const safeSeconds = Math.max(0, Math.round(seconds ?? 0));
|
|
74
|
+
return `${Math.floor(safeSeconds / 60)}:${String(safeSeconds % 60).padStart(2, "0")}`;
|
|
75
|
+
}
|
|
76
|
+
function formatMaxSize(bytes) {
|
|
77
|
+
const megabytes = bytes / 1048576;
|
|
78
|
+
return `${Number.isInteger(megabytes) ? megabytes : megabytes.toFixed(1)} MB`;
|
|
79
|
+
}
|
|
80
|
+
function inferKind(file) {
|
|
81
|
+
if (file.type.startsWith("image/")) return "image";
|
|
82
|
+
if (file.type.startsWith("audio/")) return "audio";
|
|
83
|
+
return "file";
|
|
84
|
+
}
|
|
85
|
+
function AttachmentIcon({ kind }) {
|
|
86
|
+
if (kind === "link") return /* @__PURE__ */ jsx(Link, { className: "size-4" });
|
|
87
|
+
if (kind === "image") return /* @__PURE__ */ jsx(FileImage, { className: "size-4" });
|
|
88
|
+
if (kind === "audio") return /* @__PURE__ */ jsx(Mic, { className: "size-4" });
|
|
89
|
+
return /* @__PURE__ */ jsx(Paperclip, { className: "size-4" });
|
|
90
|
+
}
|
|
91
|
+
function imageSource(item) {
|
|
92
|
+
if (item.kind !== "image") return void 0;
|
|
93
|
+
return item.previewUrl ?? item.href;
|
|
94
|
+
}
|
|
95
|
+
function RowAction({ label, onClick, state, retryable = false, reduce = false }) {
|
|
96
|
+
if (state === "uploading") return /* @__PURE__ */ jsx("span", {
|
|
97
|
+
"aria-hidden": "true",
|
|
98
|
+
className: "size-9 shrink-0"
|
|
99
|
+
});
|
|
100
|
+
if (state === "complete") return /* @__PURE__ */ jsx(Tooltip, {
|
|
101
|
+
content: "Upload complete",
|
|
102
|
+
side: "top",
|
|
103
|
+
delay: 100,
|
|
104
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
105
|
+
role: "status",
|
|
106
|
+
"aria-label": `Upload complete for ${label}`,
|
|
107
|
+
initial: reduce ? { opacity: 0 } : {
|
|
108
|
+
opacity: 0,
|
|
109
|
+
scale: .75
|
|
110
|
+
},
|
|
111
|
+
animate: {
|
|
112
|
+
opacity: 1,
|
|
113
|
+
scale: 1
|
|
114
|
+
},
|
|
115
|
+
transition: ITEM_TRANSITION,
|
|
116
|
+
className: "grid size-9 shrink-0 place-items-center rounded-xl text-emerald-600 dark:text-emerald-400",
|
|
117
|
+
children: /* @__PURE__ */ jsx(Check, { className: "size-4" })
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
if (state === "removing") return /* @__PURE__ */ jsx(Tooltip, {
|
|
121
|
+
content: "Removing attachment",
|
|
122
|
+
side: "top",
|
|
123
|
+
delay: 100,
|
|
124
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
125
|
+
role: "status",
|
|
126
|
+
"aria-label": `Removing ${label}`,
|
|
127
|
+
className: "grid size-9 shrink-0 place-items-center rounded-xl text-muted-foreground",
|
|
128
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
129
|
+
animate: reduce ? void 0 : { rotate: 360 },
|
|
130
|
+
transition: {
|
|
131
|
+
duration: .7,
|
|
132
|
+
ease: "linear",
|
|
133
|
+
repeat: Infinity
|
|
134
|
+
},
|
|
135
|
+
className: "grid place-items-center",
|
|
136
|
+
children: /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4" })
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
if (state === "failed") {
|
|
141
|
+
if (!retryable) return /* @__PURE__ */ jsx(Tooltip, {
|
|
142
|
+
content: "Upload failed",
|
|
143
|
+
side: "top",
|
|
144
|
+
delay: 100,
|
|
145
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
146
|
+
role: "status",
|
|
147
|
+
"aria-label": `Upload failed for ${label}`,
|
|
148
|
+
className: "grid size-9 shrink-0 place-items-center rounded-xl text-destructive",
|
|
149
|
+
children: /* @__PURE__ */ jsx(AlertCircle, { className: "size-4" })
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
153
|
+
content: "Retry upload",
|
|
154
|
+
side: "top",
|
|
155
|
+
delay: 100,
|
|
156
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
157
|
+
type: "button",
|
|
158
|
+
"aria-label": `Retry ${label}`,
|
|
159
|
+
onClick,
|
|
160
|
+
whileTap: reduce ? void 0 : { scale: .92 },
|
|
161
|
+
transition: SPRING_PRESS,
|
|
162
|
+
className: "grid size-9 shrink-0 place-items-center rounded-xl text-destructive outline-none transition-colors hover:bg-destructive/10 focus-visible:ring-2 focus-visible:ring-ring",
|
|
163
|
+
children: /* @__PURE__ */ jsx(RotateCcw, { className: "size-4" })
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
168
|
+
content: "Remove attachment",
|
|
169
|
+
side: "top",
|
|
170
|
+
delay: 100,
|
|
171
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
172
|
+
type: "button",
|
|
173
|
+
"aria-label": `Remove ${label}`,
|
|
174
|
+
onClick,
|
|
175
|
+
whileTap: reduce ? void 0 : { scale: .92 },
|
|
176
|
+
transition: SPRING_PRESS,
|
|
177
|
+
className: "grid size-9 shrink-0 place-items-center rounded-xl text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
178
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function ImageThumbnail({ item, layoutId, onPreview, reduce }) {
|
|
183
|
+
const src = imageSource(item);
|
|
184
|
+
if (!src) return /* @__PURE__ */ jsx("span", {
|
|
185
|
+
"aria-hidden": "true",
|
|
186
|
+
className: "grid size-8 shrink-0 place-items-center rounded-lg bg-muted text-muted-foreground",
|
|
187
|
+
children: /* @__PURE__ */ jsx(FileImage, { className: "size-4" })
|
|
188
|
+
});
|
|
189
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
190
|
+
side: "top",
|
|
191
|
+
delay: 160,
|
|
192
|
+
wrapperClassName: "shrink-0",
|
|
193
|
+
className: "rounded-xl p-1 shadow-xl",
|
|
194
|
+
content: /* @__PURE__ */ jsxs("span", {
|
|
195
|
+
className: "block w-32",
|
|
196
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
197
|
+
src,
|
|
198
|
+
alt: "",
|
|
199
|
+
className: "h-20 w-full rounded-lg object-cover"
|
|
200
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
201
|
+
className: "block px-1 pt-1 pb-0.5 text-center font-medium text-[10px] text-muted-foreground",
|
|
202
|
+
children: "Click to preview"
|
|
203
|
+
})]
|
|
204
|
+
}),
|
|
205
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
206
|
+
type: "button",
|
|
207
|
+
"aria-label": `Preview ${item.name}`,
|
|
208
|
+
onClick: (event) => {
|
|
209
|
+
event.currentTarget.blur();
|
|
210
|
+
onPreview(item);
|
|
211
|
+
},
|
|
212
|
+
whileTap: reduce ? void 0 : { scale: .94 },
|
|
213
|
+
transition: SPRING_PRESS,
|
|
214
|
+
className: "group/image relative size-9 shrink-0 overflow-hidden rounded-[10px] bg-muted outline-none ring-1 ring-border/70 focus-visible:ring-2 focus-visible:ring-ring",
|
|
215
|
+
children: /* @__PURE__ */ jsx(motion.img, {
|
|
216
|
+
layoutId,
|
|
217
|
+
src,
|
|
218
|
+
alt: "",
|
|
219
|
+
className: "size-full object-cover",
|
|
220
|
+
transition: { layout: SPRING_LAYOUT }
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function ImagePreviewDialog({ item, layoutId, onClose, reduce }) {
|
|
226
|
+
const closeRef = useRef(null);
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (!item) return;
|
|
229
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
230
|
+
const previousOverflow = document.body.style.overflow;
|
|
231
|
+
document.body.style.overflow = "hidden";
|
|
232
|
+
closeRef.current?.focus();
|
|
233
|
+
const handleKeyDown = (event) => {
|
|
234
|
+
if (event.key === "Escape") onClose();
|
|
235
|
+
if (event.key === "Tab") {
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
closeRef.current?.focus();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
241
|
+
return () => {
|
|
242
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
243
|
+
document.body.style.overflow = previousOverflow;
|
|
244
|
+
previousFocus?.focus();
|
|
245
|
+
};
|
|
246
|
+
}, [item, onClose]);
|
|
247
|
+
if (typeof document === "undefined") return null;
|
|
248
|
+
const src = item ? imageSource(item) : void 0;
|
|
249
|
+
const content = item && src ? /* @__PURE__ */ jsxs("div", {
|
|
250
|
+
className: "pointer-events-none fixed inset-0 z-10000",
|
|
251
|
+
children: [/* @__PURE__ */ jsx(motion.button, {
|
|
252
|
+
type: "button",
|
|
253
|
+
"aria-label": "Close image preview",
|
|
254
|
+
tabIndex: -1,
|
|
255
|
+
className: "pointer-events-auto absolute inset-0 size-full cursor-default bg-black/45 backdrop-blur-xl",
|
|
256
|
+
initial: { opacity: 0 },
|
|
257
|
+
animate: { opacity: 1 },
|
|
258
|
+
exit: reduce ? void 0 : { opacity: 0 },
|
|
259
|
+
transition: {
|
|
260
|
+
duration: reduce ? .1 : .2,
|
|
261
|
+
ease: EASE_OUT
|
|
262
|
+
},
|
|
263
|
+
onClick: onClose
|
|
264
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
265
|
+
className: "absolute inset-0 flex items-center justify-center p-4 sm:p-8",
|
|
266
|
+
children: /* @__PURE__ */ jsxs(motion.div, {
|
|
267
|
+
role: "dialog",
|
|
268
|
+
"aria-modal": "true",
|
|
269
|
+
"aria-label": `Preview of ${item.name}`,
|
|
270
|
+
initial: { opacity: 0 },
|
|
271
|
+
animate: { opacity: 1 },
|
|
272
|
+
exit: reduce ? void 0 : { opacity: 0 },
|
|
273
|
+
transition: ITEM_TRANSITION,
|
|
274
|
+
className: "pointer-events-auto relative",
|
|
275
|
+
children: [/* @__PURE__ */ jsx(motion.img, {
|
|
276
|
+
layoutId: reduce ? void 0 : layoutId,
|
|
277
|
+
src,
|
|
278
|
+
alt: item.name,
|
|
279
|
+
className: "max-h-[90vh] max-w-[90vw] rounded-2xl object-contain shadow-2xl",
|
|
280
|
+
transition: { layout: SPRING_LAYOUT }
|
|
281
|
+
}), /* @__PURE__ */ jsx(motion.button, {
|
|
282
|
+
ref: closeRef,
|
|
283
|
+
type: "button",
|
|
284
|
+
"aria-label": "Close image preview",
|
|
285
|
+
onClick: onClose,
|
|
286
|
+
initial: reduce ? { opacity: 0 } : {
|
|
287
|
+
opacity: 0,
|
|
288
|
+
scale: .8
|
|
289
|
+
},
|
|
290
|
+
animate: {
|
|
291
|
+
opacity: 1,
|
|
292
|
+
scale: 1
|
|
293
|
+
},
|
|
294
|
+
exit: reduce ? void 0 : {
|
|
295
|
+
opacity: 0,
|
|
296
|
+
scale: .8
|
|
297
|
+
},
|
|
298
|
+
whileTap: reduce ? void 0 : { scale: .92 },
|
|
299
|
+
transition: SPRING_PRESS,
|
|
300
|
+
className: "absolute -top-3 -right-3 grid size-9 place-items-center rounded-full bg-background text-foreground shadow-xl outline-none ring-1 ring-border/70 transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",
|
|
301
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
302
|
+
})]
|
|
303
|
+
})
|
|
304
|
+
})]
|
|
305
|
+
}) : null;
|
|
306
|
+
return createPortal(reduce ? content : /* @__PURE__ */ jsx(AnimatePresence, { children: content }), document.body);
|
|
307
|
+
}
|
|
308
|
+
function AttachmentRow({ item, playing, uploading, uploadComplete, failed, removing, arrivalIndex, imageLayoutId, onAudioToggle, onImagePreview, onRemove, onRetry, reduce, className }) {
|
|
309
|
+
const size = formatBytes(item.size);
|
|
310
|
+
const progress = item.duration && item.duration > 0 ? Math.min(1, Math.max(0, (item.currentTime ?? 0) / item.duration)) : 0;
|
|
311
|
+
const actionState = removing ? "removing" : uploading ? "uploading" : uploadComplete ? "complete" : failed ? "failed" : "idle";
|
|
312
|
+
const arrivalDelay = Math.min(Math.max(arrivalIndex, 0), 5) * .055;
|
|
313
|
+
const rowTransition = !reduce && arrivalIndex >= 0 ? {
|
|
314
|
+
...SPRING_LAYOUT,
|
|
315
|
+
delay: arrivalDelay,
|
|
316
|
+
opacity: {
|
|
317
|
+
duration: .16,
|
|
318
|
+
ease: EASE_OUT,
|
|
319
|
+
delay: arrivalDelay
|
|
320
|
+
}
|
|
321
|
+
} : ITEM_TRANSITION;
|
|
322
|
+
const showUploadProgress = uploading || uploadComplete;
|
|
323
|
+
const uploadProgress = /* @__PURE__ */ jsx(motion.span, {
|
|
324
|
+
role: "progressbar",
|
|
325
|
+
"aria-label": `Uploading ${item.name}`,
|
|
326
|
+
className: "pointer-events-none absolute inset-0 -z-10 origin-left bg-emerald-400/25 dark:bg-emerald-500/20",
|
|
327
|
+
initial: {
|
|
328
|
+
opacity: 1,
|
|
329
|
+
scaleX: 0
|
|
330
|
+
},
|
|
331
|
+
animate: {
|
|
332
|
+
opacity: 1,
|
|
333
|
+
scaleX: 1
|
|
334
|
+
},
|
|
335
|
+
exit: reduce ? void 0 : { opacity: 0 },
|
|
336
|
+
transition: {
|
|
337
|
+
duration: reduce ? .1 : UPLOAD_PROGRESS_MS / 1e3,
|
|
338
|
+
ease: EASE_OUT
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
return /* @__PURE__ */ jsxs(motion.li, {
|
|
342
|
+
layout: !reduce,
|
|
343
|
+
initial: reduce ? { opacity: 0 } : arrivalIndex >= 0 ? {
|
|
344
|
+
opacity: 0,
|
|
345
|
+
y: -16,
|
|
346
|
+
scale: .985
|
|
347
|
+
} : {
|
|
348
|
+
opacity: 0,
|
|
349
|
+
y: 6
|
|
350
|
+
},
|
|
351
|
+
animate: {
|
|
352
|
+
opacity: 1,
|
|
353
|
+
y: 0,
|
|
354
|
+
scale: 1
|
|
355
|
+
},
|
|
356
|
+
exit: reduce ? void 0 : {
|
|
357
|
+
opacity: 0,
|
|
358
|
+
y: -4
|
|
359
|
+
},
|
|
360
|
+
transition: rowTransition,
|
|
361
|
+
className: cn("flex min-h-14 items-center gap-1 rounded-2xl bg-muted/70 p-1", className),
|
|
362
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
363
|
+
className: "relative isolate flex min-w-0 flex-1 items-center gap-3 self-stretch overflow-hidden rounded-xl bg-background px-2 py-1",
|
|
364
|
+
children: [
|
|
365
|
+
failed ? /* @__PURE__ */ jsx("span", {
|
|
366
|
+
"aria-hidden": "true",
|
|
367
|
+
className: "pointer-events-none absolute inset-0 -z-10 bg-destructive/10"
|
|
368
|
+
}) : null,
|
|
369
|
+
item.kind === "image" ? /* @__PURE__ */ jsx(ImageThumbnail, {
|
|
370
|
+
item,
|
|
371
|
+
layoutId: imageLayoutId,
|
|
372
|
+
onPreview: onImagePreview,
|
|
373
|
+
reduce
|
|
374
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
375
|
+
"aria-hidden": "true",
|
|
376
|
+
className: "grid size-7 shrink-0 place-items-center text-muted-foreground",
|
|
377
|
+
children: /* @__PURE__ */ jsx(AttachmentIcon, { kind: item.kind })
|
|
378
|
+
}),
|
|
379
|
+
item.kind === "audio" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
380
|
+
/* @__PURE__ */ jsx("span", {
|
|
381
|
+
className: "w-9 shrink-0 text-muted-foreground text-xs tabular-nums",
|
|
382
|
+
children: formatDuration(item.currentTime)
|
|
383
|
+
}),
|
|
384
|
+
/* @__PURE__ */ jsx("span", {
|
|
385
|
+
"aria-hidden": "true",
|
|
386
|
+
className: "flex h-11 min-w-0 flex-1 items-center gap-[3px] overflow-hidden",
|
|
387
|
+
children: WAVEFORM_BARS.map((bar, index) => /* @__PURE__ */ jsx(motion.span, {
|
|
388
|
+
className: cn("w-[3px] shrink-0 rounded-full", index / WAVEFORM_BARS.length <= progress ? "bg-foreground" : "bg-muted-foreground/35"),
|
|
389
|
+
style: { height: bar.height },
|
|
390
|
+
animate: reduce || !playing ? void 0 : { scaleY: [
|
|
391
|
+
.72,
|
|
392
|
+
1,
|
|
393
|
+
.78
|
|
394
|
+
] },
|
|
395
|
+
transition: {
|
|
396
|
+
duration: .55,
|
|
397
|
+
ease: EASE_OUT,
|
|
398
|
+
repeat: Infinity,
|
|
399
|
+
delay: index * .018
|
|
400
|
+
}
|
|
401
|
+
}, bar.id))
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ jsx("span", {
|
|
404
|
+
className: "w-9 shrink-0 text-right text-muted-foreground text-xs tabular-nums",
|
|
405
|
+
children: formatDuration(item.duration)
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ jsx(motion.button, {
|
|
408
|
+
type: "button",
|
|
409
|
+
"aria-label": `${playing ? "Pause" : "Play"} ${item.name}`,
|
|
410
|
+
onClick: () => onAudioToggle?.(item),
|
|
411
|
+
whileTap: { scale: .94 },
|
|
412
|
+
transition: SPRING_PRESS,
|
|
413
|
+
className: "grid size-9 shrink-0 place-items-center rounded-full bg-foreground text-background outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
414
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
415
|
+
mode: "wait",
|
|
416
|
+
initial: false,
|
|
417
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
418
|
+
initial: reduce ? { opacity: 0 } : {
|
|
419
|
+
opacity: 0,
|
|
420
|
+
scale: .8
|
|
421
|
+
},
|
|
422
|
+
animate: {
|
|
423
|
+
opacity: 1,
|
|
424
|
+
scale: 1
|
|
425
|
+
},
|
|
426
|
+
exit: reduce ? { opacity: 0 } : {
|
|
427
|
+
opacity: 0,
|
|
428
|
+
scale: .8
|
|
429
|
+
},
|
|
430
|
+
transition: ITEM_TRANSITION,
|
|
431
|
+
children: playing ? /* @__PURE__ */ jsx(Pause, { className: "size-4 fill-current" }) : /* @__PURE__ */ jsx(Play, { className: "size-4 translate-x-px fill-current" })
|
|
432
|
+
}, playing ? "pause" : "play")
|
|
433
|
+
})
|
|
434
|
+
})
|
|
435
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
436
|
+
/* @__PURE__ */ jsxs("span", {
|
|
437
|
+
className: "min-w-0 flex-1",
|
|
438
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
439
|
+
className: "block truncate font-medium text-foreground text-sm",
|
|
440
|
+
children: item.name
|
|
441
|
+
}), failed ? /* @__PURE__ */ jsx("span", {
|
|
442
|
+
className: "block truncate text-[11px] text-destructive",
|
|
443
|
+
children: item.error ?? "Upload failed"
|
|
444
|
+
}) : null]
|
|
445
|
+
}),
|
|
446
|
+
/* @__PURE__ */ jsx("span", {
|
|
447
|
+
className: "shrink-0 text-muted-foreground text-xs",
|
|
448
|
+
children: item.kind === "link" ? "Web" : size
|
|
449
|
+
}),
|
|
450
|
+
item.kind === "link" && item.href ? /* @__PURE__ */ jsx("a", {
|
|
451
|
+
href: item.href,
|
|
452
|
+
target: "_blank",
|
|
453
|
+
rel: "noreferrer noopener",
|
|
454
|
+
"aria-label": `Open ${item.name}`,
|
|
455
|
+
className: "grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
456
|
+
children: /* @__PURE__ */ jsx(ExternalLink, { className: "size-4" })
|
|
457
|
+
}) : null
|
|
458
|
+
] }),
|
|
459
|
+
reduce ? showUploadProgress ? uploadProgress : null : /* @__PURE__ */ jsx(AnimatePresence, { children: showUploadProgress ? uploadProgress : null })
|
|
460
|
+
]
|
|
461
|
+
}), /* @__PURE__ */ jsx(RowAction, {
|
|
462
|
+
label: item.name,
|
|
463
|
+
onClick: () => {
|
|
464
|
+
if (actionState === "failed") {
|
|
465
|
+
onRetry?.(item);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
onRemove(item);
|
|
469
|
+
},
|
|
470
|
+
state: actionState,
|
|
471
|
+
retryable: onRetry !== void 0,
|
|
472
|
+
reduce
|
|
473
|
+
})]
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
function AttachmentUpload({ value, defaultValue, onValueChange, onFilesAdded, onFilesRejected, onRemove, onRetry, playingId, onAudioToggle, accept, multiple = true, maxFiles = 12, maxFileSize = DEFAULT_MAX_FILE_SIZE, disabled = false, title = "Drag and drop or browse files", description, attachmentsLabel = "Attachments", className, classNames }) {
|
|
477
|
+
const inputId = useId();
|
|
478
|
+
const inputRef = useRef(null);
|
|
479
|
+
const dragDepthRef = useRef(0);
|
|
480
|
+
const ownedUrlsRef = useRef(/* @__PURE__ */ new Set());
|
|
481
|
+
const lifecycleTimersRef = useRef(/* @__PURE__ */ new Set());
|
|
482
|
+
const reduce = useReducedMotion() ?? false;
|
|
483
|
+
const [dragging, setDragging] = useState(false);
|
|
484
|
+
const [previewItem, setPreviewItem] = useState(null);
|
|
485
|
+
const [uploadingIds, setUploadingIds] = useState(() => /* @__PURE__ */ new Set());
|
|
486
|
+
const [uploadCompleteIds, setUploadCompleteIds] = useState(() => /* @__PURE__ */ new Set());
|
|
487
|
+
const [removingIds, setRemovingIds] = useState(() => /* @__PURE__ */ new Set());
|
|
488
|
+
const [items, setItems] = useControllableList({
|
|
489
|
+
value,
|
|
490
|
+
defaultValue,
|
|
491
|
+
onValueChange
|
|
492
|
+
});
|
|
493
|
+
const itemsRef = useRef(items);
|
|
494
|
+
itemsRef.current = items;
|
|
495
|
+
useEffect(() => () => {
|
|
496
|
+
for (const url of ownedUrlsRef.current) URL.revokeObjectURL(url);
|
|
497
|
+
ownedUrlsRef.current.clear();
|
|
498
|
+
for (const timer of lifecycleTimersRef.current) clearTimeout(timer);
|
|
499
|
+
lifecycleTimersRef.current.clear();
|
|
500
|
+
}, []);
|
|
501
|
+
const maxReached = items.length >= maxFiles;
|
|
502
|
+
const scheduleLifecycle = useCallback((callback, delay) => {
|
|
503
|
+
const timer = setTimeout(() => {
|
|
504
|
+
lifecycleTimersRef.current.delete(timer);
|
|
505
|
+
callback();
|
|
506
|
+
}, delay);
|
|
507
|
+
lifecycleTimersRef.current.add(timer);
|
|
508
|
+
}, []);
|
|
509
|
+
const addFiles = useCallback((incomingFiles) => {
|
|
510
|
+
if (disabled || incomingFiles.length === 0) return;
|
|
511
|
+
const availableSlots = Math.max(0, maxFiles - items.length);
|
|
512
|
+
if (availableSlots === 0) {
|
|
513
|
+
onFilesRejected?.(incomingFiles, "max-files");
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const selectedFiles = incomingFiles.slice(0, multiple ? availableSlots : Math.min(1, availableSlots));
|
|
517
|
+
const oversized = selectedFiles.filter((file) => file.size > maxFileSize);
|
|
518
|
+
const accepted = selectedFiles.filter((file) => file.size <= maxFileSize);
|
|
519
|
+
if (oversized.length > 0) onFilesRejected?.(oversized, "too-large");
|
|
520
|
+
if (incomingFiles.length > selectedFiles.length) onFilesRejected?.(incomingFiles.slice(selectedFiles.length), "max-files");
|
|
521
|
+
const added = accepted.map((file, index) => {
|
|
522
|
+
const kind = inferKind(file);
|
|
523
|
+
const objectUrl = URL.createObjectURL(file);
|
|
524
|
+
ownedUrlsRef.current.add(objectUrl);
|
|
525
|
+
return {
|
|
526
|
+
id: `${Date.now()}-${index}-${file.name}`,
|
|
527
|
+
name: file.name,
|
|
528
|
+
kind,
|
|
529
|
+
size: file.size,
|
|
530
|
+
previewUrl: kind === "image" ? objectUrl : void 0,
|
|
531
|
+
href: objectUrl,
|
|
532
|
+
currentTime: kind === "audio" ? 0 : void 0,
|
|
533
|
+
duration: kind === "audio" ? 0 : void 0,
|
|
534
|
+
file
|
|
535
|
+
};
|
|
536
|
+
});
|
|
537
|
+
if (added.length === 0) return;
|
|
538
|
+
setItems([...items, ...added]);
|
|
539
|
+
const addedIds = added.map((item) => item.id);
|
|
540
|
+
setUploadingIds((current) => /* @__PURE__ */ new Set([...current, ...addedIds]));
|
|
541
|
+
scheduleLifecycle(() => {
|
|
542
|
+
setUploadingIds((current) => {
|
|
543
|
+
const next = new Set(current);
|
|
544
|
+
for (const id of addedIds) next.delete(id);
|
|
545
|
+
return next;
|
|
546
|
+
});
|
|
547
|
+
setUploadCompleteIds((current) => /* @__PURE__ */ new Set([...current, ...addedIds]));
|
|
548
|
+
scheduleLifecycle(() => {
|
|
549
|
+
setUploadCompleteIds((current) => {
|
|
550
|
+
const next = new Set(current);
|
|
551
|
+
for (const id of addedIds) next.delete(id);
|
|
552
|
+
return next;
|
|
553
|
+
});
|
|
554
|
+
}, UPLOAD_COMPLETE_HOLD_MS);
|
|
555
|
+
}, reduce ? 140 : UPLOAD_PROGRESS_MS);
|
|
556
|
+
onFilesAdded?.(added, accepted);
|
|
557
|
+
}, [
|
|
558
|
+
disabled,
|
|
559
|
+
items,
|
|
560
|
+
maxFileSize,
|
|
561
|
+
maxFiles,
|
|
562
|
+
multiple,
|
|
563
|
+
onFilesAdded,
|
|
564
|
+
onFilesRejected,
|
|
565
|
+
reduce,
|
|
566
|
+
scheduleLifecycle,
|
|
567
|
+
setItems
|
|
568
|
+
]);
|
|
569
|
+
const finalizeRemove = useCallback((item) => {
|
|
570
|
+
const ownedUrl = [item.previewUrl, item.href].find((url) => url !== void 0 && ownedUrlsRef.current.has(url));
|
|
571
|
+
if (ownedUrl) {
|
|
572
|
+
URL.revokeObjectURL(ownedUrl);
|
|
573
|
+
ownedUrlsRef.current.delete(ownedUrl);
|
|
574
|
+
}
|
|
575
|
+
setPreviewItem((current) => current?.id === item.id ? null : current);
|
|
576
|
+
setUploadingIds((current) => {
|
|
577
|
+
const next = new Set(current);
|
|
578
|
+
next.delete(item.id);
|
|
579
|
+
return next;
|
|
580
|
+
});
|
|
581
|
+
setUploadCompleteIds((current) => {
|
|
582
|
+
const next = new Set(current);
|
|
583
|
+
next.delete(item.id);
|
|
584
|
+
return next;
|
|
585
|
+
});
|
|
586
|
+
setItems(itemsRef.current.filter((entry) => entry.id !== item.id));
|
|
587
|
+
onRemove?.(item);
|
|
588
|
+
}, [onRemove, setItems]);
|
|
589
|
+
const requestRemove = useCallback((item) => {
|
|
590
|
+
if (removingIds.has(item.id)) return;
|
|
591
|
+
setRemovingIds((current) => new Set(current).add(item.id));
|
|
592
|
+
scheduleLifecycle(() => {
|
|
593
|
+
finalizeRemove(item);
|
|
594
|
+
setRemovingIds((current) => {
|
|
595
|
+
const next = new Set(current);
|
|
596
|
+
next.delete(item.id);
|
|
597
|
+
return next;
|
|
598
|
+
});
|
|
599
|
+
}, reduce ? 140 : REMOVE_PENDING_MS);
|
|
600
|
+
}, [
|
|
601
|
+
finalizeRemove,
|
|
602
|
+
reduce,
|
|
603
|
+
removingIds,
|
|
604
|
+
scheduleLifecycle
|
|
605
|
+
]);
|
|
606
|
+
const resetDrag = useCallback(() => {
|
|
607
|
+
dragDepthRef.current = 0;
|
|
608
|
+
setDragging(false);
|
|
609
|
+
}, []);
|
|
610
|
+
const closePreview = useCallback(() => setPreviewItem(null), []);
|
|
611
|
+
useEffect(() => {
|
|
612
|
+
if (previewItem && !items.some((item) => item.id === previewItem.id)) setPreviewItem(null);
|
|
613
|
+
}, [items, previewItem]);
|
|
614
|
+
const uploadOrder = Array.from(uploadingIds);
|
|
615
|
+
const previewLayoutId = previewItem ? `attachment-image-${previewItem.id}` : void 0;
|
|
616
|
+
return /* @__PURE__ */ jsx(LayoutGroup, {
|
|
617
|
+
id: inputId,
|
|
618
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
619
|
+
className: cn("w-full", className),
|
|
620
|
+
children: [
|
|
621
|
+
/* @__PURE__ */ jsx("input", {
|
|
622
|
+
ref: inputRef,
|
|
623
|
+
id: inputId,
|
|
624
|
+
type: "file",
|
|
625
|
+
"aria-label": "Upload attachments",
|
|
626
|
+
accept,
|
|
627
|
+
multiple,
|
|
628
|
+
disabled: disabled || maxReached,
|
|
629
|
+
tabIndex: -1,
|
|
630
|
+
className: "sr-only",
|
|
631
|
+
onChange: (event) => {
|
|
632
|
+
addFiles(Array.from(event.currentTarget.files ?? []));
|
|
633
|
+
event.currentTarget.value = "";
|
|
634
|
+
}
|
|
635
|
+
}),
|
|
636
|
+
/* @__PURE__ */ jsxs(motion.button, {
|
|
637
|
+
type: "button",
|
|
638
|
+
disabled: disabled || maxReached,
|
|
639
|
+
"data-dragging": dragging,
|
|
640
|
+
animate: reduce ? void 0 : { scale: dragging ? 1.006 : 1 },
|
|
641
|
+
whileTap: reduce ? void 0 : { scale: .995 },
|
|
642
|
+
transition: SPRING_PRESS,
|
|
643
|
+
onClick: () => inputRef.current?.click(),
|
|
644
|
+
onDragEnter: (event) => {
|
|
645
|
+
if (disabled || maxReached) return;
|
|
646
|
+
event.preventDefault();
|
|
647
|
+
dragDepthRef.current += 1;
|
|
648
|
+
setDragging(true);
|
|
649
|
+
},
|
|
650
|
+
onDragOver: (event) => {
|
|
651
|
+
if (disabled || maxReached) return;
|
|
652
|
+
event.preventDefault();
|
|
653
|
+
event.dataTransfer.dropEffect = "copy";
|
|
654
|
+
setDragging(true);
|
|
655
|
+
},
|
|
656
|
+
onDragLeave: (event) => {
|
|
657
|
+
if (disabled || maxReached) return;
|
|
658
|
+
event.preventDefault();
|
|
659
|
+
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
|
|
660
|
+
if (dragDepthRef.current === 0) setDragging(false);
|
|
661
|
+
},
|
|
662
|
+
onDrop: (event) => {
|
|
663
|
+
if (disabled || maxReached) return;
|
|
664
|
+
event.preventDefault();
|
|
665
|
+
resetDrag();
|
|
666
|
+
addFiles(Array.from(event.dataTransfer.files));
|
|
667
|
+
},
|
|
668
|
+
className: cn("group relative isolate flex min-h-52 w-full flex-col items-center justify-center overflow-hidden rounded-[2rem] bg-muted/65 p-2 text-center outline-none", "transition-colors duration-200 hover:bg-muted/85", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "data-[dragging=true]:bg-muted", "disabled:pointer-events-none disabled:opacity-55", classNames?.dropzone),
|
|
669
|
+
children: [
|
|
670
|
+
/* @__PURE__ */ jsx("span", {
|
|
671
|
+
"aria-hidden": "true",
|
|
672
|
+
className: "absolute inset-2 -z-10 rounded-[1.5rem] border border-muted-foreground/25 border-dashed bg-background transition-[border-color,background-color] duration-200 group-hover:border-muted-foreground/45 group-data-[dragging=true]:border-foreground/65 group-data-[dragging=true]:bg-muted/20"
|
|
673
|
+
}),
|
|
674
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
675
|
+
"aria-hidden": "true",
|
|
676
|
+
animate: reduce ? void 0 : {
|
|
677
|
+
y: dragging ? -4 : 0,
|
|
678
|
+
scale: dragging ? 1.08 : 1
|
|
679
|
+
},
|
|
680
|
+
transition: ITEM_TRANSITION,
|
|
681
|
+
className: "mb-3 grid size-11 place-items-center rounded-2xl bg-muted text-foreground transition-colors duration-200 group-hover:bg-muted/80 group-data-[dragging=true]:bg-foreground group-data-[dragging=true]:text-background",
|
|
682
|
+
children: /* @__PURE__ */ jsx(Upload, { className: "size-[18px]" })
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ jsx("span", {
|
|
685
|
+
className: "font-semibold text-foreground text-sm tracking-[-0.01em]",
|
|
686
|
+
children: maxReached ? "Attachment limit reached" : title
|
|
687
|
+
}),
|
|
688
|
+
/* @__PURE__ */ jsx("span", {
|
|
689
|
+
className: "mt-1 text-muted-foreground text-xs leading-5",
|
|
690
|
+
children: maxReached ? `${items.length} of ${maxFiles} attachments added` : description ?? `Maximum ${formatMaxSize(maxFileSize)} file size`
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
}),
|
|
694
|
+
items.length > 0 ? /* @__PURE__ */ jsxs("section", {
|
|
695
|
+
className: "mt-8",
|
|
696
|
+
"aria-labelledby": `${inputId}-attachments`,
|
|
697
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
698
|
+
id: `${inputId}-attachments`,
|
|
699
|
+
className: "font-semibold text-foreground text-sm",
|
|
700
|
+
children: attachmentsLabel
|
|
701
|
+
}), items.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
702
|
+
className: cn("mt-3 space-y-2", classNames?.list),
|
|
703
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
704
|
+
initial: uploadOrder.length > 0,
|
|
705
|
+
children: items.map((item) => /* @__PURE__ */ jsx(AttachmentRow, {
|
|
706
|
+
item,
|
|
707
|
+
playing: playingId === item.id,
|
|
708
|
+
uploading: uploadingIds.has(item.id) || item.status === "uploading",
|
|
709
|
+
uploadComplete: uploadCompleteIds.has(item.id) || item.status === "complete",
|
|
710
|
+
failed: item.status === "failed",
|
|
711
|
+
removing: removingIds.has(item.id),
|
|
712
|
+
arrivalIndex: uploadOrder.indexOf(item.id),
|
|
713
|
+
imageLayoutId: reduce ? void 0 : `attachment-image-${item.id}`,
|
|
714
|
+
onAudioToggle,
|
|
715
|
+
onImagePreview: setPreviewItem,
|
|
716
|
+
onRemove: requestRemove,
|
|
717
|
+
onRetry,
|
|
718
|
+
reduce,
|
|
719
|
+
className: classNames?.row
|
|
720
|
+
}, item.id))
|
|
721
|
+
})
|
|
722
|
+
}) : null]
|
|
723
|
+
}) : null,
|
|
724
|
+
/* @__PURE__ */ jsx(ImagePreviewDialog, {
|
|
725
|
+
item: previewItem,
|
|
726
|
+
layoutId: reduce ? void 0 : previewLayoutId,
|
|
727
|
+
onClose: closePreview,
|
|
728
|
+
reduce
|
|
729
|
+
})
|
|
730
|
+
]
|
|
731
|
+
})
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
//#endregion
|
|
735
|
+
export { AttachmentUpload };
|
|
736
|
+
|
|
737
|
+
//# sourceMappingURL=attachment-upload.js.map
|