@major-tech/ui 0.0.0-stage → 1.0.0
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/CHANGELOG.md +101 -0
- package/THIRD_PARTY_NOTICES.md +27 -0
- package/dist/components/accordion.d.ts +33 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +51 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/activity-chart.d.ts +26 -0
- package/dist/components/activity-chart.d.ts.map +1 -0
- package/dist/components/activity-chart.js +56 -0
- package/dist/components/activity-chart.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +28 -0
- package/dist/components/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog.js +51 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +34 -0
- package/dist/components/alert.d.ts.map +1 -0
- package/dist/components/alert.js +59 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/ask-user-question.d.ts +103 -0
- package/dist/components/ask-user-question.d.ts.map +1 -0
- package/dist/components/ask-user-question.js +401 -0
- package/dist/components/ask-user-question.js.map +1 -0
- package/dist/components/attachment-gallery.d.ts +137 -0
- package/dist/components/attachment-gallery.d.ts.map +1 -0
- package/dist/components/attachment-gallery.js +317 -0
- package/dist/components/attachment-gallery.js.map +1 -0
- package/dist/components/avatar.d.ts +37 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +62 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +29 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +50 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/brand-tile.d.ts +33 -0
- package/dist/components/brand-tile.d.ts.map +1 -0
- package/dist/components/brand-tile.js +36 -0
- package/dist/components/brand-tile.js.map +1 -0
- package/dist/components/button.d.ts +51 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +90 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +18 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +78 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +18 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +34 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.d.ts +48 -0
- package/dist/components/carousel.d.ts.map +1 -0
- package/dist/components/carousel.js +227 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/catalog-card.d.ts +29 -0
- package/dist/components/catalog-card.d.ts.map +1 -0
- package/dist/components/catalog-card.js +20 -0
- package/dist/components/catalog-card.js.map +1 -0
- package/dist/components/chart.d.ts +118 -0
- package/dist/components/chart.d.ts.map +1 -0
- package/dist/components/chart.js +209 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +14 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +68 -0
- package/dist/components/chip.d.ts.map +1 -0
- package/dist/components/chip.js +100 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/code-block.d.ts +99 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +144 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/collapsible.d.ts +17 -0
- package/dist/components/collapsible.d.ts.map +1 -0
- package/dist/components/collapsible.js +25 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/command.d.ts +51 -0
- package/dist/components/command.d.ts.map +1 -0
- package/dist/components/command.js +120 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/composer.d.ts +211 -0
- package/dist/components/composer.d.ts.map +1 -0
- package/dist/components/composer.js +605 -0
- package/dist/components/composer.js.map +1 -0
- package/dist/components/connector-request.d.ts +63 -0
- package/dist/components/connector-request.d.ts.map +1 -0
- package/dist/components/connector-request.js +57 -0
- package/dist/components/connector-request.js.map +1 -0
- package/dist/components/context-menu.d.ts +26 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +33 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/data-table.d.ts +61 -0
- package/dist/components/data-table.d.ts.map +1 -0
- package/dist/components/data-table.js +79 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/date-range-picker.d.ts +54 -0
- package/dist/components/date-range-picker.d.ts.map +1 -0
- package/dist/components/date-range-picker.js +451 -0
- package/dist/components/date-range-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +46 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +75 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drawer.d.ts +85 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/drawer.js +166 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +77 -0
- package/dist/components/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu.js +112 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/editor-tabs.d.ts +49 -0
- package/dist/components/editor-tabs.d.ts.map +1 -0
- package/dist/components/editor-tabs.js +157 -0
- package/dist/components/editor-tabs.js.map +1 -0
- package/dist/components/empty-state.d.ts +21 -0
- package/dist/components/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state.js +14 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/entity-card.d.ts +301 -0
- package/dist/components/entity-card.d.ts.map +1 -0
- package/dist/components/entity-card.js +392 -0
- package/dist/components/entity-card.js.map +1 -0
- package/dist/components/entity-row.d.ts +37 -0
- package/dist/components/entity-row.d.ts.map +1 -0
- package/dist/components/entity-row.js +65 -0
- package/dist/components/entity-row.js.map +1 -0
- package/dist/components/env-var-request.d.ts +51 -0
- package/dist/components/env-var-request.d.ts.map +1 -0
- package/dist/components/env-var-request.js +50 -0
- package/dist/components/env-var-request.js.map +1 -0
- package/dist/components/field.d.ts +30 -0
- package/dist/components/field.d.ts.map +1 -0
- package/dist/components/field.js +48 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/file-upload.d.ts +108 -0
- package/dist/components/file-upload.d.ts.map +1 -0
- package/dist/components/file-upload.js +217 -0
- package/dist/components/file-upload.js.map +1 -0
- package/dist/components/hover-card.d.ts +18 -0
- package/dist/components/hover-card.d.ts.map +1 -0
- package/dist/components/hover-card.js +84 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-group.d.ts +29 -0
- package/dist/components/input-group.d.ts.map +1 -0
- package/dist/components/input-group.js +61 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +9 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +13 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/island.d.ts +18 -0
- package/dist/components/island.d.ts.map +1 -0
- package/dist/components/island.js +30 -0
- package/dist/components/island.js.map +1 -0
- package/dist/components/kbd.d.ts +7 -0
- package/dist/components/kbd.d.ts.map +1 -0
- package/dist/components/kbd.js +11 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +8 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +12 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +38 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/message.d.ts +38 -0
- package/dist/components/message.d.ts.map +1 -0
- package/dist/components/message.js +25 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/page-header.d.ts +31 -0
- package/dist/components/page-header.d.ts.map +1 -0
- package/dist/components/page-header.js +94 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/pagination.d.ts +22 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +36 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/password-input.d.ts +5 -0
- package/dist/components/password-input.d.ts.map +1 -0
- package/dist/components/password-input.js +12 -0
- package/dist/components/password-input.js.map +1 -0
- package/dist/components/pepper.d.ts +92 -0
- package/dist/components/pepper.d.ts.map +1 -0
- package/dist/components/pepper.js +1279 -0
- package/dist/components/pepper.js.map +1 -0
- package/dist/components/permission-request.d.ts +53 -0
- package/dist/components/permission-request.d.ts.map +1 -0
- package/dist/components/permission-request.js +54 -0
- package/dist/components/permission-request.js.map +1 -0
- package/dist/components/popover.d.ts +42 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +76 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +9 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/progress.js +12 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/progressive-blur.d.ts +31 -0
- package/dist/components/progressive-blur.d.ts.map +1 -0
- package/dist/components/progressive-blur.js +44 -0
- package/dist/components/progressive-blur.js.map +1 -0
- package/dist/components/radio-group.d.ts +8 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +15 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/request-card.d.ts +34 -0
- package/dist/components/request-card.d.ts.map +1 -0
- package/dist/components/request-card.js +50 -0
- package/dist/components/request-card.js.map +1 -0
- package/dist/components/resizable.d.ts +24 -0
- package/dist/components/resizable.d.ts.map +1 -0
- package/dist/components/resizable.js +40 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/responsive-overlay.d.ts +136 -0
- package/dist/components/responsive-overlay.d.ts.map +1 -0
- package/dist/components/responsive-overlay.js +302 -0
- package/dist/components/responsive-overlay.js.map +1 -0
- package/dist/components/scroll-shadows.d.ts +11 -0
- package/dist/components/scroll-shadows.d.ts.map +1 -0
- package/dist/components/scroll-shadows.js +53 -0
- package/dist/components/scroll-shadows.js.map +1 -0
- package/dist/components/search-field.d.ts +16 -0
- package/dist/components/search-field.d.ts.map +1 -0
- package/dist/components/search-field.js +50 -0
- package/dist/components/search-field.js.map +1 -0
- package/dist/components/searchable-select.d.ts +43 -0
- package/dist/components/searchable-select.d.ts.map +1 -0
- package/dist/components/searchable-select.js +39 -0
- package/dist/components/searchable-select.js.map +1 -0
- package/dist/components/select.d.ts +60 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +94 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +7 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +12 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/settings-section.d.ts +41 -0
- package/dist/components/settings-section.d.ts.map +1 -0
- package/dist/components/settings-section.js +50 -0
- package/dist/components/settings-section.js.map +1 -0
- package/dist/components/sidebar-item.d.ts +41 -0
- package/dist/components/sidebar-item.d.ts.map +1 -0
- package/dist/components/sidebar-item.js +59 -0
- package/dist/components/sidebar-item.js.map +1 -0
- package/dist/components/skeleton.d.ts +7 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +11 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +10 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +36 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sonner.d.ts +8 -0
- package/dist/components/sonner.d.ts.map +1 -0
- package/dist/components/sonner.js +21 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/spinner.d.ts +7 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +12 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stat-strip.d.ts +20 -0
- package/dist/components/stat-strip.d.ts.map +1 -0
- package/dist/components/stat-strip.js +11 -0
- package/dist/components/stat-strip.js.map +1 -0
- package/dist/components/status-dot.d.ts +25 -0
- package/dist/components/status-dot.d.ts.map +1 -0
- package/dist/components/status-dot.js +31 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/subagent-run.d.ts +27 -0
- package/dist/components/subagent-run.d.ts.map +1 -0
- package/dist/components/subagent-run.js +38 -0
- package/dist/components/subagent-run.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +13 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/system-notice.d.ts +34 -0
- package/dist/components/system-notice.d.ts.map +1 -0
- package/dist/components/system-notice.js +52 -0
- package/dist/components/system-notice.js.map +1 -0
- package/dist/components/table.d.ts +27 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +37 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +40 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +52 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/thinking-indicator.d.ts +21 -0
- package/dist/components/thinking-indicator.d.ts.map +1 -0
- package/dist/components/thinking-indicator.js +136 -0
- package/dist/components/thinking-indicator.js.map +1 -0
- package/dist/components/thread-status.d.ts +25 -0
- package/dist/components/thread-status.d.ts.map +1 -0
- package/dist/components/thread-status.js +41 -0
- package/dist/components/thread-status.js.map +1 -0
- package/dist/components/todo-list.d.ts +52 -0
- package/dist/components/todo-list.d.ts.map +1 -0
- package/dist/components/todo-list.js +137 -0
- package/dist/components/todo-list.js.map +1 -0
- package/dist/components/toggle-group.d.ts +17 -0
- package/dist/components/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group.js +26 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.d.ts +27 -0
- package/dist/components/toggle.d.ts.map +1 -0
- package/dist/components/toggle.js +44 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/tool-call.d.ts +60 -0
- package/dist/components/tool-call.d.ts.map +1 -0
- package/dist/components/tool-call.js +94 -0
- package/dist/components/tool-call.js.map +1 -0
- package/dist/components/tool-result.d.ts +127 -0
- package/dist/components/tool-result.d.ts.map +1 -0
- package/dist/components/tool-result.js +155 -0
- package/dist/components/tool-result.js.map +1 -0
- package/dist/components/tooltip.d.ts +18 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +38 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/trace.d.ts +38 -0
- package/dist/components/trace.d.ts.map +1 -0
- package/dist/components/trace.js +52 -0
- package/dist/components/trace.js.map +1 -0
- package/dist/components/turn-summary.d.ts +17 -0
- package/dist/components/turn-summary.d.ts.map +1 -0
- package/dist/components/turn-summary.js +19 -0
- package/dist/components/turn-summary.js.map +1 -0
- package/dist/components/usage-meter.d.ts +16 -0
- package/dist/components/usage-meter.d.ts.map +1 -0
- package/dist/components/usage-meter.js +10 -0
- package/dist/components/usage-meter.js.map +1 -0
- package/dist/components/view-switcher.d.ts +25 -0
- package/dist/components/view-switcher.d.ts.map +1 -0
- package/dist/components/view-switcher.js +196 -0
- package/dist/components/view-switcher.js.map +1 -0
- package/dist/docs/components/accordion.md +151 -0
- package/dist/docs/components/activity-chart.md +104 -0
- package/dist/docs/components/alert-dialog.md +216 -0
- package/dist/docs/components/alert.md +203 -0
- package/dist/docs/components/ask-user-question.md +429 -0
- package/dist/docs/components/attachment-gallery.md +377 -0
- package/dist/docs/components/avatar.md +197 -0
- package/dist/docs/components/badge.md +162 -0
- package/dist/docs/components/brand-tile.md +138 -0
- package/dist/docs/components/button.md +392 -0
- package/dist/docs/components/calendar.md +113 -0
- package/dist/docs/components/card.md +157 -0
- package/dist/docs/components/carousel.md +144 -0
- package/dist/docs/components/catalog-card.md +136 -0
- package/dist/docs/components/chart.md +608 -0
- package/dist/docs/components/checkbox.md +164 -0
- package/dist/docs/components/chip.md +411 -0
- package/dist/docs/components/code-block.md +389 -0
- package/dist/docs/components/collapsible.md +93 -0
- package/dist/docs/components/command.md +276 -0
- package/dist/docs/components/composer.md +1092 -0
- package/dist/docs/components/connector-request.md +497 -0
- package/dist/docs/components/context-menu.md +127 -0
- package/dist/docs/components/data-table.md +462 -0
- package/dist/docs/components/date-range-picker.md +425 -0
- package/dist/docs/components/dialog.md +263 -0
- package/dist/docs/components/drawer.md +505 -0
- package/dist/docs/components/dropdown-menu.md +336 -0
- package/dist/docs/components/editor-tabs.md +283 -0
- package/dist/docs/components/empty-state.md +134 -0
- package/dist/docs/components/entity-card.md +640 -0
- package/dist/docs/components/entity-row.md +291 -0
- package/dist/docs/components/env-var-request.md +223 -0
- package/dist/docs/components/field.md +272 -0
- package/dist/docs/components/file-upload.md +255 -0
- package/dist/docs/components/hover-card.md +335 -0
- package/dist/docs/components/input-group.md +134 -0
- package/dist/docs/components/input.md +97 -0
- package/dist/docs/components/island.md +97 -0
- package/dist/docs/components/kbd.md +91 -0
- package/dist/docs/components/markdown.md +180 -0
- package/dist/docs/components/message.md +336 -0
- package/dist/docs/components/page-header.md +203 -0
- package/dist/docs/components/pagination.md +211 -0
- package/dist/docs/components/password-input.md +68 -0
- package/dist/docs/components/pepper.md +238 -0
- package/dist/docs/components/permission-request.md +265 -0
- package/dist/docs/components/popover.md +206 -0
- package/dist/docs/components/progress.md +142 -0
- package/dist/docs/components/progressive-blur.md +195 -0
- package/dist/docs/components/radio-group.md +129 -0
- package/dist/docs/components/request-card.md +305 -0
- package/dist/docs/components/resizable.md +318 -0
- package/dist/docs/components/responsive-overlay.md +449 -0
- package/dist/docs/components/scroll-shadows.md +161 -0
- package/dist/docs/components/search-field.md +86 -0
- package/dist/docs/components/searchable-select.md +144 -0
- package/dist/docs/components/select.md +331 -0
- package/dist/docs/components/separator.md +80 -0
- package/dist/docs/components/settings-section.md +246 -0
- package/dist/docs/components/sidebar-item.md +307 -0
- package/dist/docs/components/skeleton.md +107 -0
- package/dist/docs/components/slider.md +171 -0
- package/dist/docs/components/sonner.md +122 -0
- package/dist/docs/components/spinner.md +112 -0
- package/dist/docs/components/stat-strip.md +85 -0
- package/dist/docs/components/status-dot.md +190 -0
- package/dist/docs/components/subagent-run.md +196 -0
- package/dist/docs/components/switch.md +91 -0
- package/dist/docs/components/system-notice.md +144 -0
- package/dist/docs/components/table.md +201 -0
- package/dist/docs/components/tabs.md +233 -0
- package/dist/docs/components/textarea.md +89 -0
- package/dist/docs/components/thinking-indicator.md +164 -0
- package/dist/docs/components/thread-status.md +143 -0
- package/dist/docs/components/todo-list.md +225 -0
- package/dist/docs/components/toggle-group.md +117 -0
- package/dist/docs/components/toggle.md +132 -0
- package/dist/docs/components/tool-call.md +237 -0
- package/dist/docs/components/tool-result.md +418 -0
- package/dist/docs/components/tooltip.md +136 -0
- package/dist/docs/components/trace.md +319 -0
- package/dist/docs/components/turn-summary.md +218 -0
- package/dist/docs/components/usage-meter.md +69 -0
- package/dist/docs/components/view-switcher.md +193 -0
- package/dist/docs/foundations/colors.md +83 -0
- package/dist/docs/foundations/elevation.md +19 -0
- package/dist/docs/foundations/iconography.md +34 -0
- package/dist/docs/foundations/layout.md +42 -0
- package/dist/docs/foundations/logo.md +111 -0
- package/dist/docs/foundations/motion.md +91 -0
- package/dist/docs/foundations/radius.md +13 -0
- package/dist/docs/foundations/spacing.md +23 -0
- package/dist/docs/foundations/typography.md +42 -0
- package/dist/docs/getting-started/installation.md +116 -0
- package/dist/docs/getting-started/releases.md +59 -0
- package/dist/docs/getting-started/theming.md +58 -0
- package/dist/docs/guidelines/accessibility.md +28 -0
- package/dist/docs/guidelines/content.md +36 -0
- package/dist/docs/guidelines/forms.md +36 -0
- package/dist/docs/guidelines/principles.md +30 -0
- package/dist/docs/hooks/use-is-mobile.md +134 -0
- package/dist/docs/index.md +182 -0
- package/dist/docs/overview.md +35 -0
- package/dist/docs/patterns/chat.md +477 -0
- package/dist/docs/patterns/index.md +13 -0
- package/dist/docs/patterns/login.md +311 -0
- package/dist/docs/patterns/share.md +415 -0
- package/dist/hooks/use-is-mobile.d.ts +9 -0
- package/dist/hooks/use-is-mobile.d.ts.map +1 -0
- package/dist/hooks/use-is-mobile.js +26 -0
- package/dist/hooks/use-is-mobile.js.map +1 -0
- package/dist/lib/cn.d.ts +4 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +31 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/code-language.d.ts +8 -0
- package/dist/lib/code-language.d.ts.map +1 -0
- package/dist/lib/code-language.js +48 -0
- package/dist/lib/code-language.js.map +1 -0
- package/dist/lib/date-range.d.ts +122 -0
- package/dist/lib/date-range.d.ts.map +1 -0
- package/dist/lib/date-range.js +281 -0
- package/dist/lib/date-range.js.map +1 -0
- package/dist/lib/major-tokens.d.ts +40 -0
- package/dist/lib/major-tokens.d.ts.map +1 -0
- package/dist/lib/major-tokens.js +602 -0
- package/dist/lib/major-tokens.js.map +1 -0
- package/dist/lib/markdown.d.ts +25 -0
- package/dist/lib/markdown.d.ts.map +1 -0
- package/dist/lib/markdown.js +87 -0
- package/dist/lib/markdown.js.map +1 -0
- package/dist/lib/overlay-portal-branch.d.ts +6 -0
- package/dist/lib/overlay-portal-branch.d.ts.map +1 -0
- package/dist/lib/overlay-portal-branch.js +15 -0
- package/dist/lib/overlay-portal-branch.js.map +1 -0
- package/dist/lib/pepper-matcap.d.ts +2 -0
- package/dist/lib/pepper-matcap.d.ts.map +1 -0
- package/dist/lib/pepper-matcap.js +4 -0
- package/dist/lib/pepper-matcap.js.map +1 -0
- package/dist/lib/scroll-fade.d.ts +28 -0
- package/dist/lib/scroll-fade.d.ts.map +1 -0
- package/dist/lib/scroll-fade.js +57 -0
- package/dist/lib/scroll-fade.js.map +1 -0
- package/dist/tailwind.css +7 -0
- package/dist/theme.css +428 -0
- package/package.json +145 -3
- package/tokens.json +841 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-question.js","sourceRoot":"","sources":["../../src/components/ask-user-question.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,S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AAM,CAAC,CAAC,CAAC,OAAO,EAAE;wCACtE,CAAC,CAAC,aAAa,CAAC,IAClB,EACH,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACtC,KAAC,iBAAiB,IAChB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EACxF,IAAI,EAAE,wBAAwB,CAAC,EAAE,EACjC,MAAM,EAAE,UAAU,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EACpE,SAAS,EAAC,oBAAoB,GAC9B,CACH,KArBM,CAAC,CAsBL,CACN,CAAC,GACC,IACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useId,\n useRef,\n useState,\n type ChangeEvent,\n type ComponentProps,\n type KeyboardEvent,\n} from \"react\";\nimport { Check, ChevronLeft, ChevronRight, CornerDownRight, MessageCircleQuestion, Paperclip } from \"lucide-react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { tokens } from \"../lib/major-tokens.ts\";\nimport { ATTACHMENT_GALLERY_SIZES, ATTACHMENT_STATUSES, AttachmentGallery, isAttachmentBusy, type AttachmentItem } from \"./attachment-gallery.tsx\";\nimport { BUTTON_SIZES, BUTTON_VARIANTS, Button } from \"./button.tsx\";\nimport { FileDropArea } from \"./file-upload.tsx\";\n\nexport const QUESTION_KINDS = {\n /** Pick one: radios; picking an answer moves on by itself. */\n ONE: \"one\",\n /** Pick any: checkboxes, confirmed with Next. */\n ANY: \"any\",\n} as const;\n\nexport type QuestionKind = (typeof QUESTION_KINDS)[keyof typeof QUESTION_KINDS];\n\nexport interface QuestionOption {\n id: string;\n /** Two to four words, sentence case: \"Trend over time\". */\n label: string;\n /** What it means, one line: \"Only you can open it\". Give one to every answer of a question, or to none. */\n description?: string;\n /**\n * What this answer would look like, shown under the answers once it's picked: an HTML mockup, or plain text (Markdown,\n * ASCII) set as written. A sandboxed frame on an origin of its own where the mockup's scripts don't run, as tall as its\n * content up to 320px.\n */\n preview?: string;\n}\n\nexport interface Question {\n id: string;\n /** Short and about the outcome: \"Who will look at it?\" */\n title: string;\n /** Default: one. */\n kind?: QuestionKind;\n /** Two to four answers; Something else is added after them. */\n options: QuestionOption[];\n}\n\nexport interface QuestionAnswer {\n questionId: string;\n /** Ids of the picked answers. */\n optionIds: string[];\n /** The typed Something else answer. */\n other?: string;\n /** The files attached to this question, as the product passed them in `attachments`. */\n attachments: AttachmentItem[];\n /** Skipped or left unanswered: Major decides. */\n skipped: boolean;\n}\n\n/** A file sent with an answer, as history keeps it. Without a url (not signed yet, no local preview) it can't be opened. */\nexport interface AskUserQuestionSummaryFile {\n name: string;\n url?: string;\n}\n\n/** One answered question as the summary shows it: what history stores, with no File objects. */\nexport interface AskUserQuestionSummaryItem {\n question: string;\n /** The answer as text: a Pick any question's labels joined by \", \". Leave it out for a skipped question. */\n answer?: string;\n files?: AskUserQuestionSummaryFile[];\n}\n\n/** The summary's items from the questions and what onSubmit received. */\nexport function summarizeAnswers(questions: Question[], answers: QuestionAnswer[]): AskUserQuestionSummaryItem[] {\n return questions.map((question) => {\n const answer = answers.find(({ questionId }) => questionId === question.id);\n const words = [\n ...question.options.filter(({ id }) => answer?.optionIds.includes(id)).map(({ label }) => label),\n ...(answer?.other ? [answer.other] : []),\n ];\n const files = (answer?.attachments ?? []).map(({ name, url }) => ({ name, url }));\n\n return {\n question: question.title,\n ...(words.length > 0 && { answer: words.join(\", \") }),\n ...(files.length > 0 && { files }),\n };\n });\n}\n\ninterface Draft {\n picked: string[];\n other: string;\n otherOpen: boolean;\n skipped: boolean;\n}\n\nconst EMPTY_DRAFT: Draft = { picked: [], other: \"\", otherOpen: false, skipped: false };\nconst NO_ATTACHMENTS: AttachmentItem[] = [];\n\n/** A preview taller than this scrolls inside its frame. */\nconst PREVIEW_MAX_HEIGHT_PX = 320;\n/** The frame's height until its document has reported its own. */\nconst PREVIEW_DEFAULT_HEIGHT_PX = 200;\n/** The frame's top and bottom border, on top of its document's height. */\nconst PREVIEW_BORDER_PX = 2;\n/** What the frame's own script sends the page: its document's height. */\nconst PREVIEW_HEIGHT_MESSAGE = \"ask-user-question-preview-height\";\nconst DOCTYPE_PATTERN = /^\\s*<!doctype[^>]*>/i;\nconst HTML_DOCUMENT_PATTERN = /^\\s*<(!doctype|html)[\\s>]/i;\n/** HTML starts with a tag. Anything else (Markdown, ASCII, a line with `Array<string>` in it) is set as written. */\nconst HTML_PATTERN = /^\\s*<[a-z!]/i;\n\n/**\n * The preview frame's page, in the system's light values: the frame can't read the page's CSS variables, and a mockup\n * is drawn for a light page.\n */\nconst PREVIEW_PAGE_STYLE = [\n \"html,body{margin:0}body{box-sizing:border-box}\",\n `body{padding:${tokens.spacing[\"space-8\"].value};background:${tokens.color.surface.light};color:${tokens.color.ink.light};font:${tokens.textStyles.ui.fontSize}/${tokens.textStyles.ui.lineHeight} ${tokens.fontFamily.sans}}`,\n `pre{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font:${tokens.textStyles[\"code-small\"].fontSize}/${tokens.textStyles[\"code-small\"].lineHeight} ${tokens.fontFamily.mono}}`,\n].join(\"\");\n\n/** Runs in the frame: sends its document's height to the page on load and whenever it changes (an image, a font). */\nconst PREVIEW_HEIGHT_SCRIPT = `(()=>{const send=()=>parent.postMessage({type:\"${PREVIEW_HEIGHT_MESSAGE}\",height:document.documentElement.getBoundingClientRect().height},\"*\");addEventListener(\"load\",send);new ResizeObserver(send).observe(document.documentElement);})();`;\n\n/**\n * The frame's policy: only the script carrying this frame's nonce runs, so a mockup's own scripts and handlers don't.\n * It loads styles, images, fonts and media, and nothing else (no frames, no requests from code).\n */\nconst buildPreviewPolicy = (nonce: string) =>\n [\n \"default-src 'none'\",\n `script-src 'nonce-${nonce}'`,\n \"style-src 'unsafe-inline' https:\",\n \"img-src https: data: blob:\",\n \"font-src https: data:\",\n \"media-src https: data:\",\n ].join(\"; \");\n\nconst escapeHtml = (text: string) => text.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\n\n/** A random nonce per frame, so a mockup can't carry one that runs its script. */\nfunction createNonce() {\n return Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * A preview as the frame's document: a whole HTML document as it is, HTML on the system's page, text in a `<pre>`. The\n * policy and the height script come first, before anything of the mockup's own.\n */\nfunction buildPreviewDocument(preview: string, nonce: string) {\n const head = `<meta http-equiv=\"Content-Security-Policy\" content=\"${buildPreviewPolicy(nonce)}\"><script nonce=\"${nonce}\">${PREVIEW_HEIGHT_SCRIPT}</script>`;\n\n if (HTML_DOCUMENT_PATTERN.test(preview)) {\n const doctype = preview.match(DOCTYPE_PATTERN)?.[0] ?? \"\";\n\n return `${doctype}${head}${preview.slice(doctype.length)}`;\n }\n\n const body = HTML_PATTERN.test(preview) ? preview : `<pre>${escapeHtml(preview)}</pre>`;\n\n return `<!doctype html><html><head><meta charset=\"utf-8\">${head}<style>${PREVIEW_PAGE_STYLE}</style></head><body>${body}</body></html>`;\n}\n\n/**\n * A picked answer's preview. The frame is sandboxed on an opaque origin: the mockup can't reach the page, and what it\n * loads goes without the product's cookies. Its one script reports the document's height, up to 320px, past which\n * it scrolls.\n */\nfunction AnswerPreview({ label, preview }: { label: string; preview: string }) {\n const frameRef = useRef<HTMLIFrameElement>(null);\n const [nonce] = useState(createNonce);\n const [height, setHeight] = useState(PREVIEW_DEFAULT_HEIGHT_PX);\n\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (event.source !== frameRef.current?.contentWindow || typeof event.data !== \"object\" || event.data === null) {\n return;\n }\n\n const { type, height: documentHeight } = event.data as { type?: unknown; height?: unknown };\n\n if (type === PREVIEW_HEIGHT_MESSAGE && typeof documentHeight === \"number\" && Number.isFinite(documentHeight)) {\n setHeight(Math.min(Math.max(Math.ceil(documentHeight), 0) + PREVIEW_BORDER_PX, PREVIEW_MAX_HEIGHT_PX));\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n\n return () => window.removeEventListener(\"message\", handleMessage);\n }, []);\n\n return (\n <iframe\n ref={frameRef}\n data-slot=\"ask-user-question-preview\"\n title={`Preview: ${label}`}\n sandbox=\"allow-scripts\"\n srcDoc={buildPreviewDocument(preview, nonce)}\n style={{ height }}\n // A mockup is drawn for a light page: it keeps a white canvas in the dark theme too.\n className=\"block w-full rounded-lg border border-line bg-white [color-scheme:light]\"\n />\n );\n}\n\n/** The short beat before a Pick one answer moves to the next question. */\nconst PICK_DELAY_MS = 200;\n\nconst KIND_HINTS = {\n [QUESTION_KINDS.ONE]: \"Pick one\",\n [QUESTION_KINDS.ANY]: \"Pick any\",\n} satisfies Record<QuestionKind, string>;\n\n/** Only uploaded files count as an answer and are sent: failed, idle and busy ones are left out. */\nconst listDoneFiles = (files: AttachmentItem[]) =>\n files.filter(({ status }) => (status ?? ATTACHMENT_STATUSES.DONE) === ATTACHMENT_STATUSES.DONE);\n\nconst hasAnswer = (draft: Draft, files: AttachmentItem[]) =>\n draft.picked.length > 0 || draft.other.trim() !== \"\" || listDoneFiles(files).length > 0;\n\nconst isUploading = (files: AttachmentItem[]) => files.some(isAttachmentBusy);\n\nconst hasPreviews = (question: Question) => question.options.some(({ preview }) => preview);\n\n/**\n * Pick any, a typed answer, attached files and a question with previews are confirmed with Next; any other Pick one\n * tap moves on by itself.\n */\nconst needsNext = (question: Question, draft: Draft, files: AttachmentItem[]) =>\n (question.kind ?? QUESTION_KINDS.ONE) === QUESTION_KINDS.ANY ||\n draft.other.trim() !== \"\" ||\n files.length > 0 ||\n hasPreviews(question);\n\nfunction toAnswer(question: Question, draft: Draft, files: AttachmentItem[]): QuestionAnswer {\n const other = draft.other.trim();\n const skipped = draft.skipped || !hasAnswer(draft, files);\n\n return {\n questionId: question.id,\n optionIds: skipped ? [] : draft.picked,\n ...(!skipped && other && { other }),\n attachments: skipped ? [] : listDoneFiles(files),\n skipped,\n };\n}\n\nconst ANSWER_SLOT = \"ask-user-question-answer\";\n\n/** The 16px radio or checkbox drawn inside an answer row (the row itself is the control). */\nfunction AnswerMark({ kind, checked }: { kind: QuestionKind; checked: boolean }) {\n if (kind === QUESTION_KINDS.ANY) {\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"mt-px grid size-4 shrink-0 place-items-center rounded-sm border-[1.5px] border-faint bg-surface text-white transition-[background-color,border-color] duration-120 group-hover/answer:border-ink-2\",\n checked && \"border-link bg-link group-hover/answer:border-link\"\n )}\n >\n {checked && <Check className=\"size-3 stroke-2\" />}\n </span>\n );\n }\n\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"mt-px grid size-4 shrink-0 place-items-center rounded-full border-[1.5px] border-faint bg-surface transition-colors duration-120 group-hover/answer:border-ink-2\",\n checked && \"border-link group-hover/answer:border-link\"\n )}\n >\n {checked && <span className=\"block size-1.75 rounded-full bg-link\" />}\n </span>\n );\n}\n\nconst ROW_CLASS =\n \"group/answer flex min-h-9.5 w-full cursor-pointer items-start gap-2.5 rounded-lg border border-line bg-surface px-space-10 py-2.25 text-left outline-none transition-[border-color] duration-120 hover:border-faint focus-visible:border-faint focus-visible:ring-2 focus-visible:ring-secondary\";\n\n/** Keys that act on the focused control themselves: Enter there isn't Next. */\nconst OWN_ENTER = \"button, a, input, textarea, select, iframe\";\n\nexport interface AskUserQuestionProps extends Omit<ComponentProps<\"div\">, \"onSubmit\" | \"children\"> {\n /** Two or three questions, never more than three. */\n questions: Question[];\n /** Called once with every answer, when the last question is answered or skipped. The card then folds into its summary. */\n onSubmit?: (answers: QuestionAnswer[]) => void;\n /** Called on every change with the answers so far (skipped and unanswered questions left out), so a message typed in the composer can carry them. */\n onDraftChange?: (answers: QuestionAnswer[]) => void;\n /** Files attached to each question, by question id. The product uploads them and passes their status. */\n attachments?: Record<string, AttachmentItem[]>;\n /** Shows Attach files and takes files dropped on the card: they go to the question on screen. Upload them, then pass them in `attachments`. */\n onAttachFiles?: (questionId: string, files: File[]) => void;\n onRemoveAttachment?: (questionId: string, attachmentId: string) => void;\n onRetryAttachment?: (questionId: string, attachmentId: string) => void;\n /** Native accept string for Attach files: \"image/*,.pdf\". */\n accept?: string;\n}\n\n/**\n * The AskUserQuestion tool: Major's questions before it builds, one at a time inside its reply, each answered with a\n * tap, a typed answer or attached files. After sending it folds into AskUserQuestionSummary.\n */\nexport function AskUserQuestion({\n questions,\n onSubmit,\n onDraftChange,\n attachments,\n onAttachFiles,\n onRemoveAttachment,\n onRetryAttachment,\n accept,\n className,\n onKeyDown,\n ref,\n ...props\n}: AskUserQuestionProps) {\n const [index, setIndex] = useState(0);\n const [drafts, setDrafts] = useState<Record<string, Draft>>({});\n const [sent, setSent] = useState<QuestionAnswer[] | null>(null);\n const pickTimer = useRef<ReturnType<typeof setTimeout>>(undefined);\n const sentRef = useRef(false);\n const rootRef = useRef<HTMLDivElement>(null);\n // The card keeps its own handle on the node for focus and arrow keys; a caller's ref gets the node too.\n const setRootNode = (node: HTMLDivElement | null) => {\n rootRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n };\n const fileInputRef = useRef<HTMLInputElement>(null);\n const otherInputRef = useRef<HTMLInputElement>(null);\n const otherButtonRef = useRef<HTMLButtonElement>(null);\n const movedByPerson = useRef(false);\n const isSummaryFocused = useRef(false);\n const refocusOther = useRef(false);\n const lastDraftKey = useRef(\"[]\");\n const onDraftChangeRef = useRef(onDraftChange);\n onDraftChangeRef.current = onDraftChange;\n const baseId = useId();\n\n const question = questions[index];\n const kind = question?.kind ?? QUESTION_KINDS.ONE;\n const draft = (question && drafts[question.id]) ?? EMPTY_DRAFT;\n const filesOf = (questionId: string) => attachments?.[questionId] ?? NO_ATTACHMENTS;\n const files = question ? filesOf(question.id) : NO_ATTACHMENTS;\n const isLast = index === questions.length - 1;\n const titleId = `${baseId}-title`;\n const summaryId = props.id ?? `${baseId}-summary`;\n\n useEffect(() => () => clearTimeout(pickTimer.current), []);\n\n // Sending from the keyboard unmounts the focused control: focus goes to the summary instead of <body>.\n useEffect(() => {\n if (!sent || !isSummaryFocused.current) return;\n isSummaryFocused.current = false;\n document.getElementById(summaryId)?.focus();\n }, [sent, summaryId]);\n\n // After moving to another question, keep keyboard focus in the card: on its first answer.\n useEffect(() => {\n if (!movedByPerson.current) return;\n movedByPerson.current = false;\n rootRef.current?.querySelector<HTMLElement>(`[data-slot=${ANSWER_SLOT}]`)?.focus();\n }, [index]);\n\n // Opening Something else focuses its field; closing an empty one hands focus back to its row.\n useEffect(() => {\n if (draft.otherOpen) otherInputRef.current?.focus();\n else if (refocusOther.current) {\n refocusOther.current = false;\n otherButtonRef.current?.focus({ preventScroll: true });\n }\n }, [draft.otherOpen, index]);\n\n // Report the answers so far whenever they change.\n useEffect(() => {\n if (sentRef.current) return;\n const answers = questions\n .map((each) => toAnswer(each, drafts[each.id] ?? EMPTY_DRAFT, attachments?.[each.id] ?? NO_ATTACHMENTS))\n .filter(({ skipped }) => !skipped);\n const key = JSON.stringify(answers);\n if (key === lastDraftKey.current) return;\n lastDraftKey.current = key;\n onDraftChangeRef.current?.(answers);\n }, [questions, drafts, attachments]);\n\n if (sent) {\n return (\n <AskUserQuestionSummary\n id={summaryId}\n ref={ref}\n tabIndex={-1}\n items={summarizeAnswers(questions, sent)}\n className={className}\n {...props}\n />\n );\n }\n if (!question) return null;\n\n const uploading = isUploading(files);\n // Sending takes every question's files, so the last question waits for uploads anywhere in the card.\n const isAnyUploading = questions.some((each) => isUploading(filesOf(each.id)));\n const isSendBlocked = isLast && isAnyUploading;\n // So with a file attached anywhere, the last question confirms with Send answers instead of sending on a tap: a pick\n // made while a file uploads waits on the button, not on a timer that can't fire.\n const isSendConfirmed = isLast && questions.some((each) => filesOf(each.id).length > 0);\n const canGoOn = hasAnswer(draft, files) && !uploading && !isSendBlocked;\n\n const setDraft = (questionId: string, update: (current: Draft) => Draft) =>\n setDrafts((current) => ({ ...current, [questionId]: update(current[questionId] ?? EMPTY_DRAFT) }));\n\n const send = (from: Record<string, Draft>) => {\n clearTimeout(pickTimer.current);\n if (sentRef.current) return;\n sentRef.current = true;\n isSummaryFocused.current = Boolean(rootRef.current?.contains(document.activeElement));\n const answers = questions.map((each) => toAnswer(each, from[each.id] ?? EMPTY_DRAFT, filesOf(each.id)));\n setSent(answers);\n onSubmit?.(answers);\n };\n\n const goTo = (next: number) => {\n clearTimeout(pickTimer.current);\n movedByPerson.current = true;\n setIndex(next);\n };\n\n const goOn = (from: Record<string, Draft>) => {\n if (isLast) send(from);\n else goTo(index + 1);\n };\n\n const pick = (optionId: string) => {\n clearTimeout(pickTimer.current);\n\n if (kind === QUESTION_KINDS.ANY) {\n setDraft(question.id, (current) => ({\n ...current,\n skipped: false,\n picked: current.picked.includes(optionId)\n ? current.picked.filter((id) => id !== optionId)\n : [...current.picked, optionId],\n }));\n return;\n }\n\n // Pick one: a tap replaces a typed answer, then moves on after a short beat (unless something waits for Next).\n const nextDraft: Draft = { ...draft, picked: [optionId], other: \"\", otherOpen: false, skipped: false };\n const next = { ...drafts, [question.id]: nextDraft };\n setDrafts(next);\n if (!needsNext(question, nextDraft, files) && !isSendConfirmed) {\n pickTimer.current = setTimeout(() => goOn(next), PICK_DELAY_MS);\n }\n };\n\n const type = (value: string) =>\n setDraft(question.id, (current) => ({\n ...current,\n other: value,\n skipped: false,\n // Pick one: typing replaces the pick. Pick any: it adds to the picks.\n picked: kind === QUESTION_KINDS.ONE && value.trim() ? [] : current.picked,\n }));\n\n const closeOther = (refocus: boolean) => {\n refocusOther.current = refocus;\n setDraft(question.id, (current) => ({ ...current, other: \"\", otherOpen: false }));\n };\n\n const skip = () => {\n const next = { ...drafts, [question.id]: { ...EMPTY_DRAFT, skipped: true } };\n setDrafts(next);\n goOn(next);\n };\n\n const attach = (picked: File[]) => {\n if (!picked.length || !onAttachFiles) return;\n clearTimeout(pickTimer.current);\n setDraft(question.id, (current) => ({ ...current, skipped: false }));\n onAttachFiles(question.id, picked);\n };\n\n const handleFileInput = (event: ChangeEvent<HTMLInputElement>) => {\n const picked = Array.from(event.target.files ?? []);\n event.target.value = \"\";\n attach(picked);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n const target = event.target as HTMLElement;\n const inField = target instanceof HTMLInputElement;\n\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n const rows = Array.from(\n rootRef.current?.querySelectorAll<HTMLElement>(`[data-slot=${ANSWER_SLOT}], [data-slot=${ANSWER_SLOT}-other] input`) ??\n []\n );\n const at = rows.indexOf(target);\n if (at === -1) return;\n event.preventDefault();\n rows[(at + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length]?.focus();\n } else if (inField) {\n return;\n } else if (event.key === \"ArrowLeft\" && index > 0) {\n event.preventDefault();\n goTo(index - 1);\n } else if (event.key === \"ArrowRight\" && !isLast) {\n event.preventDefault();\n goTo(index + 1);\n } else if (event.key === \"Enter\" && !target.closest(OWN_ENTER) && canGoOn) {\n // Enter anywhere on the card but on a control does what Next does.\n event.preventDefault();\n goOn(drafts);\n }\n };\n\n const otherFilled = draft.other.trim() !== \"\";\n const selectedCount = draft.picked.length + (otherFilled ? 1 : 0);\n const showNext = needsNext(question, draft, files) || isSendConfirmed;\n const role = kind === QUESTION_KINDS.ANY ? \"checkbox\" : \"radio\";\n const previewOption = [...draft.picked]\n .reverse()\n .map((id) => question.options.find((option) => option.id === id))\n .find((option) => option?.preview);\n\n return (\n <FileDropArea\n ref={setRootNode}\n data-slot=\"ask-user-question\"\n data-state=\"asking\"\n role=\"group\"\n aria-label={`Question ${index + 1} of ${questions.length}`}\n onKeyDown={handleKeyDown}\n onFiles={attach}\n disabled={!onAttachFiles}\n hint={`to “${question.title}”`}\n className={cn(\"rounded-xl border border-line bg-surface font-sans shadow-card\", className)}\n {...props}\n >\n <div\n key={question.id}\n className=\"transition-[opacity,translate] duration-160 ease-out starting:translate-x-1.5 starting:opacity-0\"\n >\n <div className=\"flex items-start gap-2.5 pt-space-14 pr-space-10 pl-space-14\">\n <p id={titleId} className=\"m-0 min-w-0 flex-1 text-body leading-5 font-semibold text-ink\">\n {question.title}\n </p>\n {questions.length > 1 && (\n <div className=\"-mt-0.5 flex shrink-0 items-center text-small text-muted\">\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Previous question\"\n disabled={index === 0}\n onClick={() => goTo(index - 1)}\n >\n <ChevronLeft />\n </Button>\n <span className=\"min-w-10 text-center\">\n {index + 1} of {questions.length}\n </span>\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Next question\"\n disabled={isLast}\n onClick={() => goTo(index + 1)}\n >\n <ChevronRight />\n </Button>\n </div>\n )}\n </div>\n <p className=\"m-0 mt-0.5 px-space-14 text-small text-muted\">{KIND_HINTS[kind]}</p>\n\n <div className=\"flex flex-col gap-space-6 px-space-14 pt-space-12\">\n <div\n role={kind === QUESTION_KINDS.ANY ? \"group\" : \"radiogroup\"}\n aria-labelledby={titleId}\n className=\"flex flex-col gap-space-6\"\n >\n {question.options.map((option) => (\n <button\n key={option.id}\n type=\"button\"\n data-slot={ANSWER_SLOT}\n role={role}\n aria-checked={draft.picked.includes(option.id)}\n onClick={() => pick(option.id)}\n className={ROW_CLASS}\n >\n <AnswerMark kind={kind} checked={draft.picked.includes(option.id)} />\n <span className=\"flex min-w-0 flex-1 flex-col gap-px\">\n <span className=\"text-ui text-ink\">{option.label}</span>\n {option.description && <span className=\"text-small text-muted\">{option.description}</span>}\n </span>\n </button>\n ))}\n\n {!draft.otherOpen && (\n <button\n ref={otherButtonRef}\n type=\"button\"\n data-slot={ANSWER_SLOT}\n role={role}\n aria-checked={false}\n onClick={() => {\n clearTimeout(pickTimer.current);\n setDraft(question.id, (current) => ({ ...current, otherOpen: true }));\n }}\n className={ROW_CLASS}\n >\n <AnswerMark kind={kind} checked={false} />\n <span className=\"flex-1 text-ui text-muted\">Something else</span>\n </button>\n )}\n </div>\n\n {/* While it's a field, Something else sits after the answers: a radio can't hold a text field. */}\n {draft.otherOpen && (\n <div\n data-slot={`${ANSWER_SLOT}-other`}\n className={cn(ROW_CLASS, \"cursor-text hover:border-line focus-within:border-faint\")}\n onMouseDown={(event) => {\n // Clicks on the row keep the field focused instead of closing an empty one.\n if (event.target === otherInputRef.current) return;\n event.preventDefault();\n otherInputRef.current?.focus();\n }}\n >\n <AnswerMark kind={kind} checked={otherFilled} />\n <input\n ref={otherInputRef}\n value={draft.other}\n onChange={(event) => type(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && canGoOn) {\n event.preventDefault();\n goOn(drafts);\n } else if (event.key === \"Escape\" && !otherFilled) {\n event.preventDefault();\n event.stopPropagation();\n closeOther(true);\n }\n }}\n onBlur={(event) => {\n // Focus moving nowhere (a click on the page) comes back to the row instead of dropping to <body>.\n if (!otherFilled) closeOther(event.relatedTarget === null);\n }}\n placeholder=\"Type your answer, then Enter\"\n aria-label=\"Something else\"\n className=\"h-4.75 min-w-0 flex-1 border-0 bg-transparent p-0 text-ui text-ink outline-none placeholder:text-faint\"\n />\n </div>\n )}\n </div>\n\n {previewOption?.preview && (\n <div className=\"px-space-14 pt-space-12\">\n <AnswerPreview key={previewOption.id} label={previewOption.label} preview={previewOption.preview} />\n </div>\n )}\n\n <AttachmentGallery\n items={files}\n size={ATTACHMENT_GALLERY_SIZES.SM}\n onRemove={onRemoveAttachment && ((id) => onRemoveAttachment(question.id, id))}\n onRetry={onRetryAttachment && ((id) => onRetryAttachment(question.id, id))}\n className=\"px-space-14 pt-space-12\"\n />\n </div>\n\n <div className=\"mt-space-12 flex items-center gap-space-8 border-t border-line px-space-14 py-space-10\">\n <Button variant={BUTTON_VARIANTS.GHOST} size={BUTTON_SIZES.SM} disabled={isSendBlocked} onClick={skip}>\n Skip\n </Button>\n {onAttachFiles && (\n <>\n <Button variant={BUTTON_VARIANTS.GHOST} size={BUTTON_SIZES.SM} onClick={() => fileInputRef.current?.click()}>\n <Paperclip />\n Attach files\n </Button>\n <input ref={fileInputRef} type=\"file\" multiple accept={accept} tabIndex={-1} hidden onChange={handleFileInput} />\n </>\n )}\n <span className=\"flex-1\" />\n {kind === QUESTION_KINDS.ANY && selectedCount > 0 && (\n <span className=\"text-small text-muted\">{selectedCount} selected</span>\n )}\n {showNext && (\n <Button size={BUTTON_SIZES.SM} disabled={!canGoOn} onClick={() => goOn(drafts)}>\n {isLast ? \"Send answers\" : \"Next\"}\n </Button>\n )}\n </div>\n\n </FileDropArea>\n );\n}\n\nexport const ASK_USER_QUESTION_SUMMARY_STATUSES = {\n /** The answers were sent: each question with its answer. */\n SENT: \"sent\",\n /** The person wrote a new message instead of answering. */\n SKIPPED: \"skipped\",\n /** The person answered in the composer instead of on the card. */\n IN_CHAT: \"in-chat\",\n} as const;\n\nexport type AskUserQuestionSummaryStatus = (typeof ASK_USER_QUESTION_SUMMARY_STATUSES)[keyof typeof ASK_USER_QUESTION_SUMMARY_STATUSES];\n\nconst SUMMARY_LINES = {\n [ASK_USER_QUESTION_SUMMARY_STATUSES.SKIPPED]: \"Skipped. You sent a new message instead.\",\n [ASK_USER_QUESTION_SUMMARY_STATUSES.IN_CHAT]: \"Answered in chat\",\n} satisfies Record<Exclude<AskUserQuestionSummaryStatus, typeof ASK_USER_QUESTION_SUMMARY_STATUSES.SENT>, string>;\n\nexport interface AskUserQuestionSummaryProps extends Omit<ComponentProps<\"div\">, \"children\"> {\n /** Default: sent. */\n status?: AskUserQuestionSummaryStatus;\n /** The questions and their answers, for a sent card. `summarizeAnswers` makes them from what onSubmit received. */\n items?: AskUserQuestionSummaryItem[];\n /**\n * Opens a sent file the product's own way, when its `url` can't be opened as it is (a link signed on demand). Left\n * out, a picture opens in a larger preview and any other file in a new tab.\n */\n onOpenFile?: (file: AskUserQuestionSummaryFile) => void;\n}\n\n/**\n * The questions after they're done: Your answers, each question with its answer (“I’ll decide” for a skipped one),\n * or one line when the person skipped them or answered in chat. Rendered on its own from history.\n */\nexport function AskUserQuestionSummary({\n status = ASK_USER_QUESTION_SUMMARY_STATUSES.SENT,\n items = [],\n onOpenFile,\n className,\n ...props\n}: AskUserQuestionSummaryProps) {\n if (status !== ASK_USER_QUESTION_SUMMARY_STATUSES.SENT) {\n return (\n <div\n data-slot=\"ask-user-question-summary\"\n data-state={status}\n className={cn(\n \"flex items-center gap-space-6 rounded-xl border border-line bg-surface px-space-14 py-space-12 font-sans text-ui text-muted shadow-card outline-none\",\n className\n )}\n {...props}\n >\n <MessageCircleQuestion aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-faint\" />\n {SUMMARY_LINES[status]}\n </div>\n );\n }\n\n return (\n <div\n data-slot=\"ask-user-question-summary\"\n data-state={status}\n role=\"group\"\n aria-label=\"Answers sent\"\n className={cn(\"rounded-xl border border-line bg-surface pb-space-12 font-sans shadow-card outline-none\", className)}\n {...props}\n >\n <div className=\"flex items-center gap-space-6 px-space-14 pt-space-12 text-small font-medium text-muted\">\n <MessageCircleQuestion aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-faint\" />\n Your answers\n </div>\n <ul className=\"m-0 list-none p-0\">\n {items.map((item, i) => (\n <li key={i} className=\"px-space-14 pt-space-10 [&+&]:mt-space-10 [&+&]:border-t [&+&]:border-line\">\n <p className=\"m-0 mb-space-4 text-ui leading-4.75 font-semibold text-ink\">{item.question}</p>\n <p\n className={cn(\n \"m-0 flex items-center gap-space-6 text-ui leading-4.75 text-ink-2\",\n !item.answer && !item.files?.length && \"text-muted\"\n )}\n >\n <CornerDownRight aria-hidden=\"true\" className=\"size-3.25 shrink-0 text-muted\" />\n {item.answer ??\n (item.files?.length\n ? `${item.files.length} ${item.files.length === 1 ? \"file\" : \"files\"}`\n : \"I’ll decide\")}\n </p>\n {item.files && item.files.length > 0 && (\n <AttachmentGallery\n items={item.files.map(({ name, url }, index) => ({ id: `${index}-${name}`, name, url }))}\n size={ATTACHMENT_GALLERY_SIZES.SM}\n onOpen={onOpenFile && (({ name, url }) => onOpenFile({ name, url }))}\n className=\"mt-space-6 ml-4.75\"\n />\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { formatFileSize } from "./file-upload.tsx";
|
|
4
|
+
/** The upload lifecycle, named as in shadcn's Attachment. */
|
|
5
|
+
export declare const ATTACHMENT_STATUSES: {
|
|
6
|
+
/** Picked but not sent yet: "Ready to upload", a clock. */
|
|
7
|
+
readonly IDLE: "idle";
|
|
8
|
+
/** Uploading: "Uploading · 64%", a spinner or a progress bar; the name shimmers. It can't be opened yet. */
|
|
9
|
+
readonly UPLOADING: "uploading";
|
|
10
|
+
/** Uploaded, Major is reading it: "Processing…"; the name shimmers. */
|
|
11
|
+
readonly PROCESSING: "processing";
|
|
12
|
+
/** Rejected or failed: a danger border, the reason, and Retry when it can be retried. */
|
|
13
|
+
readonly ERROR: "error";
|
|
14
|
+
/** Uploaded: the type and size ("PDF · 1.8 MB"); opens on click. */
|
|
15
|
+
readonly DONE: "done";
|
|
16
|
+
};
|
|
17
|
+
export type AttachmentStatus = (typeof ATTACHMENT_STATUSES)[keyof typeof ATTACHMENT_STATUSES];
|
|
18
|
+
export declare const ATTACHMENT_GALLERY_SIZES: {
|
|
19
|
+
/** 64px tiles: in sent messages (the person's and Major's) and under the answers in AskUserQuestion. Text only in the tooltip. */
|
|
20
|
+
readonly SM: "sm";
|
|
21
|
+
/** 120px tiles: the composer, where files are still being added. */
|
|
22
|
+
readonly MD: "md";
|
|
23
|
+
};
|
|
24
|
+
export type AttachmentGallerySize = (typeof ATTACHMENT_GALLERY_SIZES)[keyof typeof ATTACHMENT_GALLERY_SIZES];
|
|
25
|
+
export declare const ATTACHMENT_MEDIA_VARIANTS: {
|
|
26
|
+
/** A file-type or state icon. */
|
|
27
|
+
readonly ICON: "icon";
|
|
28
|
+
/** An <img> that fills the tile. */
|
|
29
|
+
readonly IMAGE: "image";
|
|
30
|
+
};
|
|
31
|
+
export type AttachmentMediaVariant = (typeof ATTACHMENT_MEDIA_VARIANTS)[keyof typeof ATTACHMENT_MEDIA_VARIANTS];
|
|
32
|
+
export interface AttachmentItem {
|
|
33
|
+
id: string;
|
|
34
|
+
/** The file name: "brief.pdf". Shown on file tiles and as the image's alt text. */
|
|
35
|
+
name: string;
|
|
36
|
+
/** Where the file lives: a local preview while it uploads, then the uploaded file. Images show it; files open it. */
|
|
37
|
+
url?: string;
|
|
38
|
+
/** MIME type: "image/png". Without it, the name's extension tells an image from a file. */
|
|
39
|
+
type?: string;
|
|
40
|
+
/** File size in bytes: shown when done, "PDF · 1.8 MB". */
|
|
41
|
+
size?: number;
|
|
42
|
+
/** Default: done. */
|
|
43
|
+
status?: AttachmentStatus;
|
|
44
|
+
/** Upload progress, 0–100. Without it, an uploading tile shows a spinner. */
|
|
45
|
+
progress?: number;
|
|
46
|
+
/** Why it failed, in a few words: "Larger than 100 MB", "Upload failed. Try again.". */
|
|
47
|
+
error?: string;
|
|
48
|
+
/** The upload failed for a reason that can pass (the network): shows Retry. Leave it out for a file that's too large. */
|
|
49
|
+
isRetryable?: boolean;
|
|
50
|
+
/** Replaces the status line: "Reading 12 pages…". */
|
|
51
|
+
description?: string;
|
|
52
|
+
}
|
|
53
|
+
/** An image shows its picture; anything else shows an icon, its name and its status line. */
|
|
54
|
+
export declare const isImageAttachment: ({ type, name }: Pick<AttachmentItem, "type" | "name">) => boolean;
|
|
55
|
+
/** Uploading or processing: send waits for it. */
|
|
56
|
+
export declare const isAttachmentBusy: ({ status }: Pick<AttachmentItem, "status">) => boolean;
|
|
57
|
+
/** 512 → "512 B", 840_000 → "820 KB", 1_887_437 → "1.8 MB". The same sizes FileUpload and validateFiles print. */
|
|
58
|
+
export { formatFileSize };
|
|
59
|
+
/** The line under the name, in shadcn's words: what the file is doing now. */
|
|
60
|
+
export declare function getAttachmentStatusLine(item: AttachmentItem): string;
|
|
61
|
+
export interface AttachmentGroupProps extends ComponentProps<"ul"> {
|
|
62
|
+
/** Default: "Attached files". */
|
|
63
|
+
"aria-label"?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* One row of tiles that scrolls sideways when it doesn't fit: snapping to each tile, with ScrollShadows' fade on the
|
|
67
|
+
* side that has more.
|
|
68
|
+
*/
|
|
69
|
+
export declare function AttachmentGroup({ className, "aria-label": label, ...props }: AttachmentGroupProps): import("react").JSX.Element;
|
|
70
|
+
export interface AttachmentProps extends ComponentProps<"li"> {
|
|
71
|
+
/** Default: done. */
|
|
72
|
+
status?: AttachmentStatus;
|
|
73
|
+
/** Default: md. */
|
|
74
|
+
size?: AttachmentGallerySize;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One tile. Its media, content and trigger sit inside the square; AttachmentActions hang off its top-right corner.
|
|
78
|
+
* Only the picture is clipped to the rounded square, so the trigger's hover border and the actions stay visible.
|
|
79
|
+
*/
|
|
80
|
+
export declare function Attachment({ status, size, className, children, ...props }: AttachmentProps): import("react").JSX.Element;
|
|
81
|
+
export interface AttachmentMediaProps extends ComponentProps<"span"> {
|
|
82
|
+
/** Default: icon. */
|
|
83
|
+
variant?: AttachmentMediaVariant;
|
|
84
|
+
}
|
|
85
|
+
/** The picture (variant image, an <img> inside) or the icon: the file's type, or the state while it isn't done. */
|
|
86
|
+
export declare function AttachmentMedia({ variant, className, ...props }: AttachmentMediaProps): import("react").JSX.Element;
|
|
87
|
+
/** The state's icon centred on a picture, or on a small tile's face. */
|
|
88
|
+
export declare function AttachmentOverlay({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
89
|
+
/** The name and status line. Read by screen readers everywhere; seen only on md file tiles. */
|
|
90
|
+
export declare function AttachmentContent({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
91
|
+
/** The file name. Shimmers while it uploads or processes. */
|
|
92
|
+
export declare function AttachmentTitle({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
93
|
+
/** The status line: "Uploading · 64%", "PDF · 1.8 MB", or why it failed. */
|
|
94
|
+
export declare function AttachmentDescription({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
95
|
+
export interface AttachmentProgressProps extends ComponentProps<"span"> {
|
|
96
|
+
/** 0–100. */
|
|
97
|
+
value: number;
|
|
98
|
+
}
|
|
99
|
+
/** A 4px bar at the bottom of the tile, where the tile has no room for "Uploading · 64%". */
|
|
100
|
+
export declare function AttachmentProgress({ value, className, ...props }: AttachmentProgressProps): import("react").JSX.Element;
|
|
101
|
+
export type AttachmentTriggerProps = useRender.ComponentProps<"button">;
|
|
102
|
+
/**
|
|
103
|
+
* Covers the whole tile and opens it: a button by default, a link with `render`. It sits under the actions, so both
|
|
104
|
+
* stay clickable and focusable. Name it (aria-label): it has no text of its own.
|
|
105
|
+
*/
|
|
106
|
+
export declare function AttachmentTrigger({ render, className, ref, ...props }: AttachmentTriggerProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
107
|
+
/** The buttons on a tile's top-right corner: shown on hover or focus, always on touch and on a failed tile. */
|
|
108
|
+
export declare function AttachmentActions({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
109
|
+
export interface AttachmentActionProps extends ComponentProps<"button"> {
|
|
110
|
+
/** Say the action and the file: "Remove brief.pdf". */
|
|
111
|
+
"aria-label": string;
|
|
112
|
+
}
|
|
113
|
+
/** A 20px round icon button. */
|
|
114
|
+
export declare function AttachmentAction({ className, ...props }: AttachmentActionProps): import("react").JSX.Element;
|
|
115
|
+
export interface AttachmentGalleryProps extends Omit<ComponentProps<"div">, "children"> {
|
|
116
|
+
items: AttachmentItem[];
|
|
117
|
+
/** Default: md. */
|
|
118
|
+
size?: AttachmentGallerySize;
|
|
119
|
+
/** Shows a remove button on each tile. Leave it out for sent files. */
|
|
120
|
+
onRemove?: (id: string) => void;
|
|
121
|
+
/** Shows Retry on failed tiles marked isRetryable. */
|
|
122
|
+
onRetry?: (id: string) => void;
|
|
123
|
+
/** More buttons for a tile, before Retry and Remove: AttachmentAction elements. */
|
|
124
|
+
renderActions?: (item: AttachmentItem) => ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Opens a file that isn't an image the product's own way, in place of the new tab: for a link that is signed on
|
|
127
|
+
* demand, or a download. Such a file opens without a `url`. Images keep the preview.
|
|
128
|
+
*/
|
|
129
|
+
onOpen?: (item: AttachmentItem) => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Attached files as tiles, built from the Attachment parts: an image fills its tile and opens a larger preview, which
|
|
133
|
+
* flips through the gallery's images; any other file shows its icon, name and status line and opens the file. The same
|
|
134
|
+
* gallery in the composer (md), under AskUserQuestion's answers and in sent messages (sm).
|
|
135
|
+
*/
|
|
136
|
+
export declare function AttachmentGallery({ items, size, onRemove, onRetry, renderActions, onOpen, className, ...props }: AttachmentGalleryProps): import("react").JSX.Element | null;
|
|
137
|
+
//# sourceMappingURL=attachment-gallery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-gallery.d.ts","sourceRoot":"","sources":["../../src/components/attachment-gallery.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,cAAc,EAGnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAoBtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,6DAA6D;AAC7D,eAAO,MAAM,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AE,MAAM,KAAK,IAAI,CAAC;IAC/B,mFAAmF;IACnF,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,CAAC;IACpD;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,IAAkC,EAClC,QAAQ,EACR,OAAO,EACP,aAAa,EACb,MAAM,EACN,SAAS,EACT,GAAG,KAAK,EACT,EAAE,sBAAsB,sCA8HxB"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Children, createContext, isValidElement, useContext, useEffect, useRef, useState, } from "react";
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { ChevronLeft, ChevronRight, CircleAlert, Clock, File, FileArchive, FileAudio, FileCode, FileImage, FileSpreadsheet, FileText, FileVideo, RotateCw, X, } from "lucide-react";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { BUTTON_SIZES, BUTTON_VARIANTS, Button } from "./button.js";
|
|
9
|
+
import { Dialog, DialogContent, DialogTitle, DIALOG_SIZES } from "./dialog.js";
|
|
10
|
+
import { formatFileSize } from "./file-upload.js";
|
|
11
|
+
import { ScrollShadows } from "./scroll-shadows.js";
|
|
12
|
+
import { Spinner } from "./spinner.js";
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
14
|
+
/** The upload lifecycle, named as in shadcn's Attachment. */
|
|
15
|
+
export const ATTACHMENT_STATUSES = {
|
|
16
|
+
/** Picked but not sent yet: "Ready to upload", a clock. */
|
|
17
|
+
IDLE: "idle",
|
|
18
|
+
/** Uploading: "Uploading · 64%", a spinner or a progress bar; the name shimmers. It can't be opened yet. */
|
|
19
|
+
UPLOADING: "uploading",
|
|
20
|
+
/** Uploaded, Major is reading it: "Processing…"; the name shimmers. */
|
|
21
|
+
PROCESSING: "processing",
|
|
22
|
+
/** Rejected or failed: a danger border, the reason, and Retry when it can be retried. */
|
|
23
|
+
ERROR: "error",
|
|
24
|
+
/** Uploaded: the type and size ("PDF · 1.8 MB"); opens on click. */
|
|
25
|
+
DONE: "done",
|
|
26
|
+
};
|
|
27
|
+
export const ATTACHMENT_GALLERY_SIZES = {
|
|
28
|
+
/** 64px tiles: in sent messages (the person's and Major's) and under the answers in AskUserQuestion. Text only in the tooltip. */
|
|
29
|
+
SM: "sm",
|
|
30
|
+
/** 120px tiles: the composer, where files are still being added. */
|
|
31
|
+
MD: "md",
|
|
32
|
+
};
|
|
33
|
+
export const ATTACHMENT_MEDIA_VARIANTS = {
|
|
34
|
+
/** A file-type or state icon. */
|
|
35
|
+
ICON: "icon",
|
|
36
|
+
/** An <img> that fills the tile. */
|
|
37
|
+
IMAGE: "image",
|
|
38
|
+
};
|
|
39
|
+
const IMAGE_EXTENSION = /\.(avif|gif|jpe?g|png|svg|webp)$/i;
|
|
40
|
+
/** An image shows its picture; anything else shows an icon, its name and its status line. */
|
|
41
|
+
export const isImageAttachment = ({ type, name }) => type ? type.startsWith("image/") : IMAGE_EXTENSION.test(name);
|
|
42
|
+
/** A done image with a picture to show: it opens in the gallery's preview, and the preview flips through these. */
|
|
43
|
+
const checkIfPreviewable = (item) => (item.status ?? ATTACHMENT_STATUSES.DONE) === ATTACHMENT_STATUSES.DONE && isImageAttachment(item) && Boolean(item.url);
|
|
44
|
+
/** Uploading or processing: send waits for it. */
|
|
45
|
+
export const isAttachmentBusy = ({ status }) => status === ATTACHMENT_STATUSES.UPLOADING || status === ATTACHMENT_STATUSES.PROCESSING;
|
|
46
|
+
/** 512 → "512 B", 840_000 → "820 KB", 1_887_437 → "1.8 MB". The same sizes FileUpload and validateFiles print. */
|
|
47
|
+
export { formatFileSize };
|
|
48
|
+
/** "brief.final.pdf" → "PDF"; no extension → the MIME subtype, or "FILE". */
|
|
49
|
+
const getExtension = ({ name, type }) => {
|
|
50
|
+
const fromName = /\.([a-z0-9]{1,8})$/i.exec(name)?.[1];
|
|
51
|
+
const fromType = type?.split("/")[1]?.split(/[+.;-]/)[0];
|
|
52
|
+
return (fromName ?? fromType ?? "file").toUpperCase();
|
|
53
|
+
};
|
|
54
|
+
const clampProgress = (progress) => Math.round(Math.max(0, Math.min(100, progress)));
|
|
55
|
+
/** The line under the name, in shadcn's words: what the file is doing now. */
|
|
56
|
+
export function getAttachmentStatusLine(item) {
|
|
57
|
+
if (item.description) {
|
|
58
|
+
return item.description;
|
|
59
|
+
}
|
|
60
|
+
switch (item.status ?? ATTACHMENT_STATUSES.DONE) {
|
|
61
|
+
case ATTACHMENT_STATUSES.IDLE:
|
|
62
|
+
return "Ready to upload";
|
|
63
|
+
case ATTACHMENT_STATUSES.UPLOADING:
|
|
64
|
+
return item.progress === undefined ? "Uploading…" : `Uploading · ${clampProgress(item.progress)}%`;
|
|
65
|
+
case ATTACHMENT_STATUSES.PROCESSING:
|
|
66
|
+
return "Processing…";
|
|
67
|
+
case ATTACHMENT_STATUSES.ERROR:
|
|
68
|
+
return item.error ?? "Upload failed. Try again.";
|
|
69
|
+
default:
|
|
70
|
+
return item.size === undefined ? getExtension(item) : `${getExtension(item)} · ${formatFileSize(item.size)}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const ICON_BY_EXTENSION = [
|
|
74
|
+
[/^(pdf|docx?|md|txt|rtf|odt|pages)$/i, _jsx(FileText, {}, "text")],
|
|
75
|
+
[/^(csv|tsv|xlsx?|ods|numbers)$/i, _jsx(FileSpreadsheet, {}, "sheet")],
|
|
76
|
+
[/^(js|jsx|ts|tsx|json|html?|css|py|rb|go|rs|java|sql|ya?ml|xml|sh)$/i, _jsx(FileCode, {}, "code")],
|
|
77
|
+
[/^(zip|rar|7z|tar|gz)$/i, _jsx(FileArchive, {}, "archive")],
|
|
78
|
+
[/^(mp4|mov|webm|avi|mkv)$/i, _jsx(FileVideo, {}, "video")],
|
|
79
|
+
[/^(mp3|wav|m4a|ogg|flac)$/i, _jsx(FileAudio, {}, "audio")],
|
|
80
|
+
[/^(png|jpe?g|gif|webp|avif|svg|heic)$/i, _jsx(FileImage, {}, "image")],
|
|
81
|
+
];
|
|
82
|
+
const getFileIcon = (extension) => ICON_BY_EXTENSION.find(([pattern]) => pattern.test(extension))?.[1] ?? _jsx(File, {});
|
|
83
|
+
const AttachmentContext = createContext({
|
|
84
|
+
status: ATTACHMENT_STATUSES.DONE,
|
|
85
|
+
size: ATTACHMENT_GALLERY_SIZES.MD,
|
|
86
|
+
isImage: false,
|
|
87
|
+
});
|
|
88
|
+
const useAttachment = () => useContext(AttachmentContext);
|
|
89
|
+
const isBusyStatus = (status) => isAttachmentBusy({ status });
|
|
90
|
+
/**
|
|
91
|
+
* One row of tiles that scrolls sideways when it doesn't fit: snapping to each tile, with ScrollShadows' fade on the
|
|
92
|
+
* side that has more.
|
|
93
|
+
*/
|
|
94
|
+
export function AttachmentGroup({ className, "aria-label": label = "Attached files", ...props }) {
|
|
95
|
+
return (_jsx(ScrollShadows
|
|
96
|
+
// The scroller is the list itself (`render`), so its props are the list's.
|
|
97
|
+
, { ...props, render: _jsx("ul", {}), "data-slot": "attachment-group", "aria-label": label,
|
|
98
|
+
// The top and right padding keep the corner buttons visible; the negative margin takes the top padding back,
|
|
99
|
+
// so spacing set from outside stays exact.
|
|
100
|
+
className: cn("m-0 -mt-space-10 flex list-none snap-x snap-proximity gap-space-8 overflow-y-hidden overscroll-x-contain p-0 pt-space-10 pr-space-10 [scrollbar-width:thin]", className) }));
|
|
101
|
+
}
|
|
102
|
+
function assignRef(ref, node) {
|
|
103
|
+
if (typeof ref === "function") {
|
|
104
|
+
ref(node);
|
|
105
|
+
}
|
|
106
|
+
else if (ref) {
|
|
107
|
+
ref.current = node;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const TILE_SIZE_CLASSES = {
|
|
111
|
+
[ATTACHMENT_GALLERY_SIZES.SM]: "size-16 items-center justify-center gap-space-4 p-space-6",
|
|
112
|
+
[ATTACHMENT_GALLERY_SIZES.MD]: "size-30 gap-space-6 p-space-10",
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* One tile. Its media, content and trigger sit inside the square; AttachmentActions hang off its top-right corner.
|
|
116
|
+
* Only the picture is clipped to the rounded square, so the trigger's hover border and the actions stay visible.
|
|
117
|
+
*/
|
|
118
|
+
export function Attachment({ status = ATTACHMENT_STATUSES.DONE, size = ATTACHMENT_GALLERY_SIZES.MD, className, children, ...props }) {
|
|
119
|
+
// A picture hides the text (it stays for screen readers).
|
|
120
|
+
const isImage = Children.toArray(children).some((child) => isValidElement(child) &&
|
|
121
|
+
child.type === AttachmentMedia &&
|
|
122
|
+
child.props.variant === ATTACHMENT_MEDIA_VARIANTS.IMAGE);
|
|
123
|
+
return (_jsx(AttachmentContext.Provider, { value: { status, size, isImage }, children: _jsx("li", { "data-slot": "attachment", "data-status": status, "data-size": size,
|
|
124
|
+
// Its own stacking context: the trigger and the actions stay under a drop field laid over the box.
|
|
125
|
+
className: cn("group/file relative isolate shrink-0 snap-start", className), ...props, children: _jsx("div", { "data-slot": "attachment-tile", className: cn("relative flex flex-col rounded-lg border bg-secondary text-left", TILE_SIZE_CLASSES[size], status === ATTACHMENT_STATUSES.ERROR ? "border-danger" : "border-line"), children: children }) }) }));
|
|
126
|
+
}
|
|
127
|
+
/** The picture (variant image, an <img> inside) or the icon: the file's type, or the state while it isn't done. */
|
|
128
|
+
export function AttachmentMedia({ variant = ATTACHMENT_MEDIA_VARIANTS.ICON, className, ...props }) {
|
|
129
|
+
const { status, size } = useAttachment();
|
|
130
|
+
const isDone = status === ATTACHMENT_STATUSES.DONE;
|
|
131
|
+
const isFailed = status === ATTACHMENT_STATUSES.ERROR;
|
|
132
|
+
if (variant === ATTACHMENT_MEDIA_VARIANTS.IMAGE) {
|
|
133
|
+
return (_jsx("span", { "data-slot": "attachment-media", "data-variant": variant, className: cn(
|
|
134
|
+
// Inherits the tile's radius: the picture is the one thing clipped to the rounded square.
|
|
135
|
+
"absolute inset-0 block overflow-hidden rounded-[inherit] [&_img]:block [&_img]:size-full [&_img]:object-cover", !isDone && "opacity-40", className), ...props }));
|
|
136
|
+
}
|
|
137
|
+
return (_jsx("span", { "data-slot": "attachment-media", "data-variant": variant, className: cn("flex shrink-0 text-muted [&_svg]:shrink-0", size === ATTACHMENT_GALLERY_SIZES.SM ? "[&_svg]:size-5" : "[&_svg]:size-4", isFailed && "text-danger", className), ...props }));
|
|
138
|
+
}
|
|
139
|
+
/** The state's icon centred on a picture, or on a small tile's face. */
|
|
140
|
+
export function AttachmentOverlay({ className, ...props }) {
|
|
141
|
+
const { status } = useAttachment();
|
|
142
|
+
return (_jsx("span", { "data-slot": "attachment-overlay", className: cn("pointer-events-none absolute inset-0 grid place-items-center text-ink-2 [&_svg]:size-5", status === ATTACHMENT_STATUSES.ERROR && "text-danger", className), ...props }));
|
|
143
|
+
}
|
|
144
|
+
/** The name and status line. Read by screen readers everywhere; seen only on md file tiles. */
|
|
145
|
+
export function AttachmentContent({ className, ...props }) {
|
|
146
|
+
const { size, isImage } = useAttachment();
|
|
147
|
+
const isHidden = size === ATTACHMENT_GALLERY_SIZES.SM || isImage;
|
|
148
|
+
return (_jsx("span", { "data-slot": "attachment-content", className: cn(isHidden ? "sr-only" : "flex min-h-0 flex-1 flex-col gap-space-2 overflow-hidden", className), ...props }));
|
|
149
|
+
}
|
|
150
|
+
/** The file name. Shimmers while it uploads or processes. */
|
|
151
|
+
export function AttachmentTitle({ className, ...props }) {
|
|
152
|
+
const { status } = useAttachment();
|
|
153
|
+
return (_jsx("span", { "data-slot": "attachment-title", className: cn("line-clamp-3 min-h-0 text-small break-all text-ink", isBusyStatus(status) && "shimmer-text", className), ...props }));
|
|
154
|
+
}
|
|
155
|
+
/** The status line: "Uploading · 64%", "PDF · 1.8 MB", or why it failed. */
|
|
156
|
+
export function AttachmentDescription({ className, ...props }) {
|
|
157
|
+
const { status } = useAttachment();
|
|
158
|
+
return (_jsx("span", { "data-slot": "attachment-description", className: cn("mt-auto line-clamp-2 text-2xs text-muted", status === ATTACHMENT_STATUSES.ERROR && "text-danger", className), ...props }));
|
|
159
|
+
}
|
|
160
|
+
/** A 4px bar at the bottom of the tile, where the tile has no room for "Uploading · 64%". */
|
|
161
|
+
export function AttachmentProgress({ value, className, ...props }) {
|
|
162
|
+
const percent = clampProgress(value);
|
|
163
|
+
return (_jsx("span", { role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent, "data-slot": "attachment-progress", className: cn("pointer-events-none absolute inset-x-space-6 bottom-space-6 h-1 overflow-hidden rounded-full bg-line", className), ...props, children: _jsx("span", { className: "block h-full rounded-full bg-link transition-[width] duration-160", style: { width: `${percent}%` } }) }));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Covers the whole tile and opens it: a button by default, a link with `render`. It sits under the actions, so both
|
|
167
|
+
* stay clickable and focusable. Name it (aria-label): it has no text of its own.
|
|
168
|
+
*/
|
|
169
|
+
export function AttachmentTrigger({ render, className, ref, ...props }) {
|
|
170
|
+
return useRender({
|
|
171
|
+
defaultTagName: "button",
|
|
172
|
+
render,
|
|
173
|
+
state: { slot: "attachment-trigger" },
|
|
174
|
+
ref,
|
|
175
|
+
props: mergeProps({
|
|
176
|
+
...(render ? {} : { type: "button" }),
|
|
177
|
+
className: cn("absolute -inset-px z-10 cursor-pointer rounded-lg border border-transparent bg-transparent p-0 outline-none transition-[border-color] duration-120 hover:border-faint focus-visible:border-faint focus-visible:ring-1 focus-visible:ring-faint focus-visible:ring-inset", className),
|
|
178
|
+
}, props),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/** The buttons on a tile's top-right corner: shown on hover or focus, always on touch and on a failed tile. */
|
|
182
|
+
export function AttachmentActions({ className, ...props }) {
|
|
183
|
+
return (_jsx("span", { "data-slot": "attachment-actions", className: cn("absolute -top-2 -right-2 z-20 flex gap-space-2 opacity-0 transition-opacity duration-120 group-hover/file:opacity-100 group-data-[status=error]/file:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", className), ...props }));
|
|
184
|
+
}
|
|
185
|
+
/** A 20px round icon button. */
|
|
186
|
+
export function AttachmentAction({ className, ...props }) {
|
|
187
|
+
return (_jsx("button", { type: "button", "data-slot": "attachment-action", className: cn("relative grid size-5 cursor-pointer place-items-center rounded-full border border-line bg-surface p-0 text-muted shadow-card outline-none after:absolute after:-inset-0.5 after:content-[''] hover:text-ink focus-visible:ring-2 focus-visible:ring-faint [&_svg]:size-3", className), ...props }));
|
|
188
|
+
}
|
|
189
|
+
/* ---------------------------------------------------------------------------------------------------------------- */
|
|
190
|
+
/* The gallery */
|
|
191
|
+
/* ---------------------------------------------------------------------------------------------------------------- */
|
|
192
|
+
const EXTENSION_BADGE_CLASS = "rounded-sm bg-surface px-space-4 text-2xs font-medium text-muted";
|
|
193
|
+
/** The icon a tile shows for its state: the clock, a spinner, the alert, or the file's own icon. */
|
|
194
|
+
function getStateIcon(item, status, size, extension) {
|
|
195
|
+
// Where there's no text to shimmer (small tiles), processing spins like an upload of unknown progress.
|
|
196
|
+
const isSpinning = (status === ATTACHMENT_STATUSES.UPLOADING && (size === ATTACHMENT_GALLERY_SIZES.MD || item.progress === undefined)) ||
|
|
197
|
+
(status === ATTACHMENT_STATUSES.PROCESSING && size === ATTACHMENT_GALLERY_SIZES.SM);
|
|
198
|
+
if (isSpinning) {
|
|
199
|
+
return _jsx(Spinner, { "aria-hidden": "true", className: "text-ink-2" });
|
|
200
|
+
}
|
|
201
|
+
if (status === ATTACHMENT_STATUSES.IDLE) {
|
|
202
|
+
return _jsx(Clock, { "aria-hidden": "true" });
|
|
203
|
+
}
|
|
204
|
+
if (status === ATTACHMENT_STATUSES.ERROR) {
|
|
205
|
+
return _jsx(CircleAlert, { "aria-hidden": "true" });
|
|
206
|
+
}
|
|
207
|
+
return getFileIcon(extension);
|
|
208
|
+
}
|
|
209
|
+
/** The icon on a dimmed picture while it isn't done; nothing when it is (or when the bar shows progress). */
|
|
210
|
+
function getImageOverlayIcon(item, status) {
|
|
211
|
+
switch (status) {
|
|
212
|
+
case ATTACHMENT_STATUSES.IDLE:
|
|
213
|
+
return _jsx(Clock, { "aria-hidden": "true" });
|
|
214
|
+
case ATTACHMENT_STATUSES.UPLOADING:
|
|
215
|
+
return item.progress === undefined ? _jsx(Spinner, { "aria-hidden": "true" }) : null;
|
|
216
|
+
case ATTACHMENT_STATUSES.PROCESSING:
|
|
217
|
+
return _jsx(Spinner, { "aria-hidden": "true" });
|
|
218
|
+
case ATTACHMENT_STATUSES.ERROR:
|
|
219
|
+
return _jsx(CircleAlert, { "aria-hidden": "true" });
|
|
220
|
+
default:
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** One file built from the parts: the face for its kind and size, the state on top, the trigger and the actions. */
|
|
225
|
+
function GalleryTile({ item, size, onOpenImage, onOpen, onRemove, onRetry, renderActions }) {
|
|
226
|
+
const status = item.status ?? ATTACHMENT_STATUSES.DONE;
|
|
227
|
+
const isDone = status === ATTACHMENT_STATUSES.DONE;
|
|
228
|
+
const isFailed = status === ATTACHMENT_STATUSES.ERROR;
|
|
229
|
+
const isImage = isImageAttachment(item) && Boolean(item.url);
|
|
230
|
+
const isSmall = size === ATTACHMENT_GALLERY_SIZES.SM;
|
|
231
|
+
const extension = getExtension(item);
|
|
232
|
+
const statusLine = getAttachmentStatusLine(item);
|
|
233
|
+
const hasBar = status === ATTACHMENT_STATUSES.UPLOADING && item.progress !== undefined && (isSmall || isImage);
|
|
234
|
+
// A file the product opens itself needs no url: its link is signed when it's opened.
|
|
235
|
+
const isOpenable = isDone && (Boolean(item.url) || (Boolean(onOpen) && !isImageAttachment(item)));
|
|
236
|
+
// The name and status show on hover wherever the tile doesn't print them: small tiles and pictures.
|
|
237
|
+
const isTooltipVisible = isSmall || isImage;
|
|
238
|
+
const customActions = renderActions?.(item);
|
|
239
|
+
const hasRetry = Boolean(onRetry && isFailed && item.isRetryable);
|
|
240
|
+
const hasActions = Boolean(customActions || hasRetry || onRemove);
|
|
241
|
+
let trigger;
|
|
242
|
+
if (isOpenable && isImage) {
|
|
243
|
+
trigger = (_jsx(AttachmentTrigger, { "aria-label": `Open ${item.name}`, onClick: () => onOpenImage(item), className: "cursor-zoom-in" }));
|
|
244
|
+
}
|
|
245
|
+
else if (isOpenable && onOpen) {
|
|
246
|
+
trigger = _jsx(AttachmentTrigger, { "aria-label": `Open ${item.name}`, onClick: () => onOpen(item) });
|
|
247
|
+
}
|
|
248
|
+
else if (isOpenable) {
|
|
249
|
+
trigger = (_jsx(AttachmentTrigger, { render: _jsx("a", { href: item.url, target: "_blank", rel: "noreferrer" }), "aria-label": `Open ${item.name}` }));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
// Not openable yet (or never): still focusable, so the name and the state are reachable from the keyboard.
|
|
253
|
+
trigger = (_jsx(AttachmentTrigger, { render: _jsx("span", {}), tabIndex: 0, role: "img", "aria-label": `${item.name}: ${statusLine}`, "aria-busy": isBusyStatus(status) || undefined, className: "cursor-default hover:border-transparent" }));
|
|
254
|
+
}
|
|
255
|
+
if (isTooltipVisible) {
|
|
256
|
+
trigger = (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: trigger }), _jsxs(TooltipContent, { side: "top", className: "max-w-60 flex-col items-start gap-0 break-all whitespace-normal", children: [_jsx("span", { className: "block", children: item.name }), _jsx("span", { className: "block opacity-75", children: statusLine })] })] }));
|
|
257
|
+
}
|
|
258
|
+
const overlayIcon = isImage ? getImageOverlayIcon(item, status) : null;
|
|
259
|
+
return (_jsxs(Attachment, { status: status, size: size, children: [isImage ? (_jsx(AttachmentMedia, { variant: ATTACHMENT_MEDIA_VARIANTS.IMAGE, children: _jsx("img", { src: item.url, alt: item.name }) })) : (_jsx(AttachmentMedia, { children: getStateIcon(item, status, size, extension) })), isSmall && !isImage && _jsx("span", { className: EXTENSION_BADGE_CLASS, children: extension }), _jsxs(AttachmentContent, { "aria-hidden": "true", children: [_jsx(AttachmentTitle, { children: item.name }), _jsx(AttachmentDescription, { children: statusLine })] }), overlayIcon && _jsx(AttachmentOverlay, { children: overlayIcon }), hasBar && _jsx(AttachmentProgress, { value: item.progress ?? 0, "aria-label": `Uploading ${item.name}` }), trigger, hasActions && (_jsxs(AttachmentActions, { children: [customActions, hasRetry && (_jsx(AttachmentAction, { "aria-label": `Retry ${item.name}`, onClick: () => onRetry?.(item.id), children: _jsx(RotateCw, {}) })), onRemove && (_jsx(AttachmentAction, { "aria-label": `Remove ${item.name}`, onClick: () => onRemove(item.id), children: _jsx(X, {}) }))] }))] }));
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Attached files as tiles, built from the Attachment parts: an image fills its tile and opens a larger preview, which
|
|
263
|
+
* flips through the gallery's images; any other file shows its icon, name and status line and opens the file. The same
|
|
264
|
+
* gallery in the composer (md), under AskUserQuestion's answers and in sent messages (sm).
|
|
265
|
+
*/
|
|
266
|
+
export function AttachmentGallery({ items, size = ATTACHMENT_GALLERY_SIZES.MD, onRemove, onRetry, renderActions, onOpen, className, ...props }) {
|
|
267
|
+
// By id, not by item: a preview whose image goes away (removed, or failed on a retry) closes.
|
|
268
|
+
const [previewId, setPreviewId] = useState(null);
|
|
269
|
+
const rootRef = useRef(null);
|
|
270
|
+
// The tile that last held focus. A press that takes its button away (Remove, or Retry turning into a spinner)
|
|
271
|
+
// hands focus to the tile now in that place, instead of dropping it to the page.
|
|
272
|
+
const focusedTileIndex = useRef(null);
|
|
273
|
+
const listTiles = () => [...(rootRef.current?.querySelectorAll("[data-slot=attachment]") ?? [])];
|
|
274
|
+
const setRootNode = (node) => {
|
|
275
|
+
rootRef.current = node;
|
|
276
|
+
assignRef(props.ref, node);
|
|
277
|
+
};
|
|
278
|
+
const handleFocus = (event) => {
|
|
279
|
+
props.onFocus?.(event);
|
|
280
|
+
const tile = event.target.closest("[data-slot=attachment]");
|
|
281
|
+
focusedTileIndex.current = tile ? listTiles().indexOf(tile) : null;
|
|
282
|
+
};
|
|
283
|
+
const handleBlur = (event) => {
|
|
284
|
+
props.onBlur?.(event);
|
|
285
|
+
// Focus moved on by the person (a click elsewhere, Tab out): nothing to restore.
|
|
286
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
287
|
+
focusedTileIndex.current = null;
|
|
288
|
+
};
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
const index = focusedTileIndex.current;
|
|
291
|
+
if (index === null || document.activeElement !== document.body)
|
|
292
|
+
return;
|
|
293
|
+
const tiles = listTiles();
|
|
294
|
+
const tile = tiles[Math.min(index, tiles.length - 1)];
|
|
295
|
+
tile?.querySelector("button:not(:disabled), a[href], [tabindex='0']")?.focus();
|
|
296
|
+
}, [items]);
|
|
297
|
+
if (items.length === 0) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const images = items.filter(checkIfPreviewable);
|
|
301
|
+
const previewIndex = images.findIndex((item) => item.id === previewId);
|
|
302
|
+
const preview = images[previewIndex];
|
|
303
|
+
const hasSiblings = images.length > 1;
|
|
304
|
+
const handleOpenImage = (item) => setPreviewId(item.id);
|
|
305
|
+
// Round the set: the last image's next is the first.
|
|
306
|
+
const turnPreview = (step) => {
|
|
307
|
+
setPreviewId(images[(previewIndex + step + images.length) % images.length].id);
|
|
308
|
+
};
|
|
309
|
+
const handlePreviewKeyDown = (event) => {
|
|
310
|
+
if (!hasSiblings || (event.key !== "ArrowLeft" && event.key !== "ArrowRight"))
|
|
311
|
+
return;
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
turnPreview(event.key === "ArrowLeft" ? -1 : 1);
|
|
314
|
+
};
|
|
315
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { "data-slot": "attachment-gallery", "data-size": size, className: cn("min-w-0", className), ...props, ref: setRootNode, onFocus: handleFocus, onBlur: handleBlur, children: _jsx(AttachmentGroup, { children: items.map((item) => (_jsx(GalleryTile, { item: item, size: size, onOpenImage: handleOpenImage, onOpen: onOpen, onRemove: onRemove, onRetry: onRetry, renderActions: renderActions }, item.id))) }) }), _jsx(Dialog, { open: preview !== undefined, onOpenChange: (open) => !open && setPreviewId(null), children: preview && (_jsxs(DialogContent, { size: DIALOG_SIZES.XL, onKeyDown: handlePreviewKeyDown, children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-space-8 pr-8", children: [_jsx(DialogTitle, { className: "truncate", children: preview.name }), hasSiblings && (_jsxs("span", { className: "shrink-0 text-ui text-muted", children: [previewIndex + 1, " of ", images.length] }))] }), _jsxs("div", { className: "relative", children: [_jsx("img", { src: preview.url, alt: preview.name, className: "block max-h-[70vh] w-full rounded-lg object-contain" }), hasSiblings && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: BUTTON_VARIANTS.OUTLINE, size: BUTTON_SIZES.ICON, "aria-label": "Previous image", onClick: () => turnPreview(-1), className: "absolute top-1/2 left-space-8 -translate-y-1/2 rounded-full bg-surface", children: _jsx(ChevronLeft, {}) }), _jsx(Button, { variant: BUTTON_VARIANTS.OUTLINE, size: BUTTON_SIZES.ICON, "aria-label": "Next image", onClick: () => turnPreview(1), className: "absolute top-1/2 right-space-8 -translate-y-1/2 rounded-full bg-surface", children: _jsx(ChevronRight, {}) })] }))] })] })) })] }));
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=attachment-gallery.js.map
|