@major-tech/ui 0.0.0-stage → 1.0.1
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 +107 -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 +159 -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 +284 -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":"alert.js","sourceRoot":"","sources":["../../src/components/alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,GAAG,EAA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ance-authority\";\nimport { CircleAlert, CircleCheck, Info, TriangleAlert, type LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn.ts\";\n\nexport const ALERT_VARIANTS = {\n /** Something to know. */\n INFO: \"info\",\n /** Something that worked and is still true. */\n SUCCESS: \"success\",\n /** Something to look at before it breaks: an expired sign-in, a missing connection. */\n WARNING: \"warning\",\n /** Something to fix. */\n DESTRUCTIVE: \"destructive\",\n} as const;\n\ntype AlertVariant = (typeof ALERT_VARIANTS)[keyof typeof ALERT_VARIANTS];\n\nconst alertVariants = cva(\n \"relative flex w-full items-start gap-space-10 rounded-lg px-space-14 py-space-12 font-sans text-ui leading-[1.1875rem] [&>svg]:mt-px [&>svg]:size-4 [&>svg]:shrink-0\",\n {\n variants: {\n variant: {\n [ALERT_VARIANTS.INFO]: \"bg-secondary text-ink-2 [&_[data-slot=alert-title]]:text-ink\",\n [ALERT_VARIANTS.SUCCESS]: \"bg-success-soft text-success\",\n [ALERT_VARIANTS.WARNING]: \"bg-warn-soft text-warn\",\n [ALERT_VARIANTS.DESTRUCTIVE]: \"bg-danger-soft text-danger\",\n },\n },\n defaultVariants: { variant: ALERT_VARIANTS.INFO },\n }\n);\n\nconst ALERT_ICONS = {\n [ALERT_VARIANTS.INFO]: Info,\n [ALERT_VARIANTS.SUCCESS]: CircleCheck,\n [ALERT_VARIANTS.WARNING]: TriangleAlert,\n [ALERT_VARIANTS.DESTRUCTIVE]: CircleAlert,\n} satisfies Record<AlertVariant, LucideIcon>;\n\nexport type AlertProps = ComponentProps<\"div\"> &\n VariantProps<typeof alertVariants> & {\n /** Replaces the tone's icon; `false` drops it. */\n icon?: ReactNode;\n };\n\n/**\n * An inline message about what is true now, with the tone's 16px icon added for you. Children: `AlertContent`\n * (holding `AlertTitle` and `AlertDescription`), then at most one `AlertAction`.\n */\nexport function Alert({ className, variant, icon, children, ...props }: AlertProps) {\n const tone = variant ?? ALERT_VARIANTS.INFO;\n const Icon = ALERT_ICONS[tone];\n const isUrgent = tone === ALERT_VARIANTS.WARNING || tone === ALERT_VARIANTS.DESTRUCTIVE;\n return (\n <div data-slot=\"alert\" role={isUrgent ? \"alert\" : \"status\"} className={cn(alertVariants({ variant }), className)} {...props}>\n {icon ?? <Icon aria-hidden />}\n {children}\n </div>\n );\n}\n\n/** The text column: an optional `AlertTitle`, then an `AlertDescription`. */\nexport function AlertContent({ className, ...props }: ComponentProps<\"div\">) {\n return <div data-slot=\"alert-content\" className={cn(\"min-w-0 flex-1\", className)} {...props} />;\n}\n\n/** An optional bold first line. */\nexport function AlertTitle({ className, ...props }: ComponentProps<\"div\">) {\n return <div data-slot=\"alert-title\" className={cn(\"font-semibold\", className)} {...props} />;\n}\n\n/** One or two sentences: the problem and the way out. */\nexport function AlertDescription({ className, ...props }: ComponentProps<\"div\">) {\n return <div data-slot=\"alert-description\" className={cn(\"[&_p]:m-0\", className)} {...props} />;\n}\n\n/** An outline Button, or a ghost × when the alert is safe to ignore. */\nexport function AlertAction({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div data-slot=\"alert-action\" className={cn(\"-my-space-4 -mr-space-4 flex shrink-0 items-center\", className)} {...props} />\n );\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
import { type AttachmentItem } from "./attachment-gallery.tsx";
|
|
3
|
+
export declare const QUESTION_KINDS: {
|
|
4
|
+
/** Pick one: radios; picking an answer moves on by itself. */
|
|
5
|
+
readonly ONE: "one";
|
|
6
|
+
/** Pick any: checkboxes, confirmed with Next. */
|
|
7
|
+
readonly ANY: "any";
|
|
8
|
+
};
|
|
9
|
+
export type QuestionKind = (typeof QUESTION_KINDS)[keyof typeof QUESTION_KINDS];
|
|
10
|
+
export interface QuestionOption {
|
|
11
|
+
id: string;
|
|
12
|
+
/** Two to four words, sentence case: "Trend over time". */
|
|
13
|
+
label: string;
|
|
14
|
+
/** What it means, one line: "Only you can open it". Give one to every answer of a question, or to none. */
|
|
15
|
+
description?: string;
|
|
16
|
+
/**
|
|
17
|
+
* What this answer would look like, shown under the answers once it's picked: an HTML mockup, or plain text (Markdown,
|
|
18
|
+
* 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
|
|
19
|
+
* content up to 320px.
|
|
20
|
+
*/
|
|
21
|
+
preview?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Question {
|
|
24
|
+
id: string;
|
|
25
|
+
/** Short and about the outcome: "Who will look at it?" */
|
|
26
|
+
title: string;
|
|
27
|
+
/** Default: one. */
|
|
28
|
+
kind?: QuestionKind;
|
|
29
|
+
/** Two to four answers; Something else is added after them. */
|
|
30
|
+
options: QuestionOption[];
|
|
31
|
+
}
|
|
32
|
+
export interface QuestionAnswer {
|
|
33
|
+
questionId: string;
|
|
34
|
+
/** Ids of the picked answers. */
|
|
35
|
+
optionIds: string[];
|
|
36
|
+
/** The typed Something else answer. */
|
|
37
|
+
other?: string;
|
|
38
|
+
/** The files attached to this question, as the product passed them in `attachments`. */
|
|
39
|
+
attachments: AttachmentItem[];
|
|
40
|
+
/** Skipped or left unanswered: Major decides. */
|
|
41
|
+
skipped: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** A file sent with an answer, as history keeps it. Without a url (not signed yet, no local preview) it can't be opened. */
|
|
44
|
+
export interface AskUserQuestionSummaryFile {
|
|
45
|
+
name: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
}
|
|
48
|
+
/** One answered question as the summary shows it: what history stores, with no File objects. */
|
|
49
|
+
export interface AskUserQuestionSummaryItem {
|
|
50
|
+
question: string;
|
|
51
|
+
/** The answer as text: a Pick any question's labels joined by ", ". Leave it out for a skipped question. */
|
|
52
|
+
answer?: string;
|
|
53
|
+
files?: AskUserQuestionSummaryFile[];
|
|
54
|
+
}
|
|
55
|
+
/** The summary's items from the questions and what onSubmit received. */
|
|
56
|
+
export declare function summarizeAnswers(questions: Question[], answers: QuestionAnswer[]): AskUserQuestionSummaryItem[];
|
|
57
|
+
export interface AskUserQuestionProps extends Omit<ComponentProps<"div">, "onSubmit" | "children"> {
|
|
58
|
+
/** Two or three questions, never more than three. */
|
|
59
|
+
questions: Question[];
|
|
60
|
+
/** Called once with every answer, when the last question is answered or skipped. The card then folds into its summary. */
|
|
61
|
+
onSubmit?: (answers: QuestionAnswer[]) => void;
|
|
62
|
+
/** 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. */
|
|
63
|
+
onDraftChange?: (answers: QuestionAnswer[]) => void;
|
|
64
|
+
/** Files attached to each question, by question id. The product uploads them and passes their status. */
|
|
65
|
+
attachments?: Record<string, AttachmentItem[]>;
|
|
66
|
+
/** Shows Attach files and takes files dropped on the card: they go to the question on screen. Upload them, then pass them in `attachments`. */
|
|
67
|
+
onAttachFiles?: (questionId: string, files: File[]) => void;
|
|
68
|
+
onRemoveAttachment?: (questionId: string, attachmentId: string) => void;
|
|
69
|
+
onRetryAttachment?: (questionId: string, attachmentId: string) => void;
|
|
70
|
+
/** Native accept string for Attach files: "image/*,.pdf". */
|
|
71
|
+
accept?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The AskUserQuestion tool: Major's questions before it builds, one at a time inside its reply, each answered with a
|
|
75
|
+
* tap, a typed answer or attached files. After sending it folds into AskUserQuestionSummary.
|
|
76
|
+
*/
|
|
77
|
+
export declare function AskUserQuestion({ questions, onSubmit, onDraftChange, attachments, onAttachFiles, onRemoveAttachment, onRetryAttachment, accept, className, onKeyDown, ref, ...props }: AskUserQuestionProps): import("react").JSX.Element | null;
|
|
78
|
+
export declare const ASK_USER_QUESTION_SUMMARY_STATUSES: {
|
|
79
|
+
/** The answers were sent: each question with its answer. */
|
|
80
|
+
readonly SENT: "sent";
|
|
81
|
+
/** The person wrote a new message instead of answering. */
|
|
82
|
+
readonly SKIPPED: "skipped";
|
|
83
|
+
/** The person answered in the composer instead of on the card. */
|
|
84
|
+
readonly IN_CHAT: "in-chat";
|
|
85
|
+
};
|
|
86
|
+
export type AskUserQuestionSummaryStatus = (typeof ASK_USER_QUESTION_SUMMARY_STATUSES)[keyof typeof ASK_USER_QUESTION_SUMMARY_STATUSES];
|
|
87
|
+
export interface AskUserQuestionSummaryProps extends Omit<ComponentProps<"div">, "children"> {
|
|
88
|
+
/** Default: sent. */
|
|
89
|
+
status?: AskUserQuestionSummaryStatus;
|
|
90
|
+
/** The questions and their answers, for a sent card. `summarizeAnswers` makes them from what onSubmit received. */
|
|
91
|
+
items?: AskUserQuestionSummaryItem[];
|
|
92
|
+
/**
|
|
93
|
+
* 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
|
|
94
|
+
* out, a picture opens in a larger preview and any other file in a new tab.
|
|
95
|
+
*/
|
|
96
|
+
onOpenFile?: (file: AskUserQuestionSummaryFile) => void;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The questions after they're done: Your answers, each question with its answer (“I’ll decide” for a skipped one),
|
|
100
|
+
* or one line when the person skipped them or answered in chat. Rendered on its own from history.
|
|
101
|
+
*/
|
|
102
|
+
export declare function AskUserQuestionSummary({ status, items, onOpenFile, className, ...props }: AskUserQuestionSummaryProps): import("react").JSX.Element;
|
|
103
|
+
//# sourceMappingURL=ask-user-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-question.d.ts","sourceRoot":"","sources":["../../src/components/ask-user-question.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAsF,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAInJ,eAAO,MAAM,cAAc;IACzB,8DAA8D;;IAE9D,iDAAiD;;CAEzC,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEhF,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC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AC;CACzD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,MAAgD,EAChD,KAAU,EACV,UAAU,EACV,SAAS,EACT,GAAG,KAAK,EACT,EAAE,2BAA2B,+BA4D7B"}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
|
+
import { Check, ChevronLeft, ChevronRight, CornerDownRight, MessageCircleQuestion, Paperclip } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { tokens } from "../lib/major-tokens.js";
|
|
7
|
+
import { ATTACHMENT_GALLERY_SIZES, ATTACHMENT_STATUSES, AttachmentGallery, isAttachmentBusy } from "./attachment-gallery.js";
|
|
8
|
+
import { BUTTON_SIZES, BUTTON_VARIANTS, Button } from "./button.js";
|
|
9
|
+
import { FileDropArea } from "./file-upload.js";
|
|
10
|
+
export const QUESTION_KINDS = {
|
|
11
|
+
/** Pick one: radios; picking an answer moves on by itself. */
|
|
12
|
+
ONE: "one",
|
|
13
|
+
/** Pick any: checkboxes, confirmed with Next. */
|
|
14
|
+
ANY: "any",
|
|
15
|
+
};
|
|
16
|
+
/** The summary's items from the questions and what onSubmit received. */
|
|
17
|
+
export function summarizeAnswers(questions, answers) {
|
|
18
|
+
return questions.map((question) => {
|
|
19
|
+
const answer = answers.find(({ questionId }) => questionId === question.id);
|
|
20
|
+
const words = [
|
|
21
|
+
...question.options.filter(({ id }) => answer?.optionIds.includes(id)).map(({ label }) => label),
|
|
22
|
+
...(answer?.other ? [answer.other] : []),
|
|
23
|
+
];
|
|
24
|
+
const files = (answer?.attachments ?? []).map(({ name, url }) => ({ name, url }));
|
|
25
|
+
return {
|
|
26
|
+
question: question.title,
|
|
27
|
+
...(words.length > 0 && { answer: words.join(", ") }),
|
|
28
|
+
...(files.length > 0 && { files }),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const EMPTY_DRAFT = { picked: [], other: "", otherOpen: false, skipped: false };
|
|
33
|
+
const NO_ATTACHMENTS = [];
|
|
34
|
+
/** A preview taller than this scrolls inside its frame. */
|
|
35
|
+
const PREVIEW_MAX_HEIGHT_PX = 320;
|
|
36
|
+
/** The frame's height until its document has reported its own. */
|
|
37
|
+
const PREVIEW_DEFAULT_HEIGHT_PX = 200;
|
|
38
|
+
/** The frame's top and bottom border, on top of its document's height. */
|
|
39
|
+
const PREVIEW_BORDER_PX = 2;
|
|
40
|
+
/** What the frame's own script sends the page: its document's height. */
|
|
41
|
+
const PREVIEW_HEIGHT_MESSAGE = "ask-user-question-preview-height";
|
|
42
|
+
const DOCTYPE_PATTERN = /^\s*<!doctype[^>]*>/i;
|
|
43
|
+
const HTML_DOCUMENT_PATTERN = /^\s*<(!doctype|html)[\s>]/i;
|
|
44
|
+
/** HTML starts with a tag. Anything else (Markdown, ASCII, a line with `Array<string>` in it) is set as written. */
|
|
45
|
+
const HTML_PATTERN = /^\s*<[a-z!]/i;
|
|
46
|
+
/**
|
|
47
|
+
* The preview frame's page, in the system's light values: the frame can't read the page's CSS variables, and a mockup
|
|
48
|
+
* is drawn for a light page.
|
|
49
|
+
*/
|
|
50
|
+
const PREVIEW_PAGE_STYLE = [
|
|
51
|
+
"html,body{margin:0}body{box-sizing:border-box}",
|
|
52
|
+
`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}}`,
|
|
53
|
+
`pre{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font:${tokens.textStyles["code-small"].fontSize}/${tokens.textStyles["code-small"].lineHeight} ${tokens.fontFamily.mono}}`,
|
|
54
|
+
].join("");
|
|
55
|
+
/** Runs in the frame: sends its document's height to the page on load and whenever it changes (an image, a font). */
|
|
56
|
+
const 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);})();`;
|
|
57
|
+
/**
|
|
58
|
+
* The frame's policy: only the script carrying this frame's nonce runs, so a mockup's own scripts and handlers don't.
|
|
59
|
+
* It loads styles, images, fonts and media, and nothing else (no frames, no requests from code).
|
|
60
|
+
*/
|
|
61
|
+
const buildPreviewPolicy = (nonce) => [
|
|
62
|
+
"default-src 'none'",
|
|
63
|
+
`script-src 'nonce-${nonce}'`,
|
|
64
|
+
"style-src 'unsafe-inline' https:",
|
|
65
|
+
"img-src https: data: blob:",
|
|
66
|
+
"font-src https: data:",
|
|
67
|
+
"media-src https: data:",
|
|
68
|
+
].join("; ");
|
|
69
|
+
const escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
70
|
+
/** A random nonce per frame, so a mockup can't carry one that runs its script. */
|
|
71
|
+
function createNonce() {
|
|
72
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 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
|
|
76
|
+
* policy and the height script come first, before anything of the mockup's own.
|
|
77
|
+
*/
|
|
78
|
+
function buildPreviewDocument(preview, nonce) {
|
|
79
|
+
const head = `<meta http-equiv="Content-Security-Policy" content="${buildPreviewPolicy(nonce)}"><script nonce="${nonce}">${PREVIEW_HEIGHT_SCRIPT}</script>`;
|
|
80
|
+
if (HTML_DOCUMENT_PATTERN.test(preview)) {
|
|
81
|
+
const doctype = preview.match(DOCTYPE_PATTERN)?.[0] ?? "";
|
|
82
|
+
return `${doctype}${head}${preview.slice(doctype.length)}`;
|
|
83
|
+
}
|
|
84
|
+
const body = HTML_PATTERN.test(preview) ? preview : `<pre>${escapeHtml(preview)}</pre>`;
|
|
85
|
+
return `<!doctype html><html><head><meta charset="utf-8">${head}<style>${PREVIEW_PAGE_STYLE}</style></head><body>${body}</body></html>`;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A picked answer's preview. The frame is sandboxed on an opaque origin: the mockup can't reach the page, and what it
|
|
89
|
+
* loads goes without the product's cookies. Its one script reports the document's height, up to 320px, past which
|
|
90
|
+
* it scrolls.
|
|
91
|
+
*/
|
|
92
|
+
function AnswerPreview({ label, preview }) {
|
|
93
|
+
const frameRef = useRef(null);
|
|
94
|
+
const [nonce] = useState(createNonce);
|
|
95
|
+
const [height, setHeight] = useState(PREVIEW_DEFAULT_HEIGHT_PX);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const handleMessage = (event) => {
|
|
98
|
+
if (event.source !== frameRef.current?.contentWindow || typeof event.data !== "object" || event.data === null) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const { type, height: documentHeight } = event.data;
|
|
102
|
+
if (type === PREVIEW_HEIGHT_MESSAGE && typeof documentHeight === "number" && Number.isFinite(documentHeight)) {
|
|
103
|
+
setHeight(Math.min(Math.max(Math.ceil(documentHeight), 0) + PREVIEW_BORDER_PX, PREVIEW_MAX_HEIGHT_PX));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener("message", handleMessage);
|
|
107
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
108
|
+
}, []);
|
|
109
|
+
return (_jsx("iframe", { ref: frameRef, "data-slot": "ask-user-question-preview", title: `Preview: ${label}`, sandbox: "allow-scripts", srcDoc: buildPreviewDocument(preview, nonce), style: { height },
|
|
110
|
+
// A mockup is drawn for a light page: it keeps a white canvas in the dark theme too.
|
|
111
|
+
className: "block w-full rounded-lg border border-line bg-white [color-scheme:light]" }));
|
|
112
|
+
}
|
|
113
|
+
/** The short beat before a Pick one answer moves to the next question. */
|
|
114
|
+
const PICK_DELAY_MS = 200;
|
|
115
|
+
const KIND_HINTS = {
|
|
116
|
+
[QUESTION_KINDS.ONE]: "Pick one",
|
|
117
|
+
[QUESTION_KINDS.ANY]: "Pick any",
|
|
118
|
+
};
|
|
119
|
+
/** Only uploaded files count as an answer and are sent: failed, idle and busy ones are left out. */
|
|
120
|
+
const listDoneFiles = (files) => files.filter(({ status }) => (status ?? ATTACHMENT_STATUSES.DONE) === ATTACHMENT_STATUSES.DONE);
|
|
121
|
+
const hasAnswer = (draft, files) => draft.picked.length > 0 || draft.other.trim() !== "" || listDoneFiles(files).length > 0;
|
|
122
|
+
const isUploading = (files) => files.some(isAttachmentBusy);
|
|
123
|
+
const hasPreviews = (question) => question.options.some(({ preview }) => preview);
|
|
124
|
+
/**
|
|
125
|
+
* Pick any, a typed answer, attached files and a question with previews are confirmed with Next; any other Pick one
|
|
126
|
+
* tap moves on by itself.
|
|
127
|
+
*/
|
|
128
|
+
const needsNext = (question, draft, files) => (question.kind ?? QUESTION_KINDS.ONE) === QUESTION_KINDS.ANY ||
|
|
129
|
+
draft.other.trim() !== "" ||
|
|
130
|
+
files.length > 0 ||
|
|
131
|
+
hasPreviews(question);
|
|
132
|
+
function toAnswer(question, draft, files) {
|
|
133
|
+
const other = draft.other.trim();
|
|
134
|
+
const skipped = draft.skipped || !hasAnswer(draft, files);
|
|
135
|
+
return {
|
|
136
|
+
questionId: question.id,
|
|
137
|
+
optionIds: skipped ? [] : draft.picked,
|
|
138
|
+
...(!skipped && other && { other }),
|
|
139
|
+
attachments: skipped ? [] : listDoneFiles(files),
|
|
140
|
+
skipped,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const ANSWER_SLOT = "ask-user-question-answer";
|
|
144
|
+
/** The 16px radio or checkbox drawn inside an answer row (the row itself is the control). */
|
|
145
|
+
function AnswerMark({ kind, checked }) {
|
|
146
|
+
if (kind === QUESTION_KINDS.ANY) {
|
|
147
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("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", checked && "border-link bg-link group-hover/answer:border-link"), children: checked && _jsx(Check, { className: "size-3 stroke-2" }) }));
|
|
148
|
+
}
|
|
149
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("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", checked && "border-link group-hover/answer:border-link"), children: checked && _jsx("span", { className: "block size-1.75 rounded-full bg-link" }) }));
|
|
150
|
+
}
|
|
151
|
+
const ROW_CLASS = "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";
|
|
152
|
+
/** Keys that act on the focused control themselves: Enter there isn't Next. */
|
|
153
|
+
const OWN_ENTER = "button, a, input, textarea, select, iframe";
|
|
154
|
+
/**
|
|
155
|
+
* The AskUserQuestion tool: Major's questions before it builds, one at a time inside its reply, each answered with a
|
|
156
|
+
* tap, a typed answer or attached files. After sending it folds into AskUserQuestionSummary.
|
|
157
|
+
*/
|
|
158
|
+
export function AskUserQuestion({ questions, onSubmit, onDraftChange, attachments, onAttachFiles, onRemoveAttachment, onRetryAttachment, accept, className, onKeyDown, ref, ...props }) {
|
|
159
|
+
const [index, setIndex] = useState(0);
|
|
160
|
+
const [drafts, setDrafts] = useState({});
|
|
161
|
+
const [sent, setSent] = useState(null);
|
|
162
|
+
const pickTimer = useRef(undefined);
|
|
163
|
+
const sentRef = useRef(false);
|
|
164
|
+
const rootRef = useRef(null);
|
|
165
|
+
// The card keeps its own handle on the node for focus and arrow keys; a caller's ref gets the node too.
|
|
166
|
+
const setRootNode = (node) => {
|
|
167
|
+
rootRef.current = node;
|
|
168
|
+
if (typeof ref === "function")
|
|
169
|
+
ref(node);
|
|
170
|
+
else if (ref)
|
|
171
|
+
ref.current = node;
|
|
172
|
+
};
|
|
173
|
+
const fileInputRef = useRef(null);
|
|
174
|
+
const otherInputRef = useRef(null);
|
|
175
|
+
const otherButtonRef = useRef(null);
|
|
176
|
+
const movedByPerson = useRef(false);
|
|
177
|
+
const isSummaryFocused = useRef(false);
|
|
178
|
+
const refocusOther = useRef(false);
|
|
179
|
+
const lastDraftKey = useRef("[]");
|
|
180
|
+
const onDraftChangeRef = useRef(onDraftChange);
|
|
181
|
+
onDraftChangeRef.current = onDraftChange;
|
|
182
|
+
const baseId = useId();
|
|
183
|
+
const question = questions[index];
|
|
184
|
+
const kind = question?.kind ?? QUESTION_KINDS.ONE;
|
|
185
|
+
const draft = (question && drafts[question.id]) ?? EMPTY_DRAFT;
|
|
186
|
+
const filesOf = (questionId) => attachments?.[questionId] ?? NO_ATTACHMENTS;
|
|
187
|
+
const files = question ? filesOf(question.id) : NO_ATTACHMENTS;
|
|
188
|
+
const isLast = index === questions.length - 1;
|
|
189
|
+
const titleId = `${baseId}-title`;
|
|
190
|
+
const summaryId = props.id ?? `${baseId}-summary`;
|
|
191
|
+
useEffect(() => () => clearTimeout(pickTimer.current), []);
|
|
192
|
+
// Sending from the keyboard unmounts the focused control: focus goes to the summary instead of <body>.
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (!sent || !isSummaryFocused.current)
|
|
195
|
+
return;
|
|
196
|
+
isSummaryFocused.current = false;
|
|
197
|
+
document.getElementById(summaryId)?.focus();
|
|
198
|
+
}, [sent, summaryId]);
|
|
199
|
+
// After moving to another question, keep keyboard focus in the card: on its first answer.
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (!movedByPerson.current)
|
|
202
|
+
return;
|
|
203
|
+
movedByPerson.current = false;
|
|
204
|
+
rootRef.current?.querySelector(`[data-slot=${ANSWER_SLOT}]`)?.focus();
|
|
205
|
+
}, [index]);
|
|
206
|
+
// Opening Something else focuses its field; closing an empty one hands focus back to its row.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (draft.otherOpen)
|
|
209
|
+
otherInputRef.current?.focus();
|
|
210
|
+
else if (refocusOther.current) {
|
|
211
|
+
refocusOther.current = false;
|
|
212
|
+
otherButtonRef.current?.focus({ preventScroll: true });
|
|
213
|
+
}
|
|
214
|
+
}, [draft.otherOpen, index]);
|
|
215
|
+
// Report the answers so far whenever they change.
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (sentRef.current)
|
|
218
|
+
return;
|
|
219
|
+
const answers = questions
|
|
220
|
+
.map((each) => toAnswer(each, drafts[each.id] ?? EMPTY_DRAFT, attachments?.[each.id] ?? NO_ATTACHMENTS))
|
|
221
|
+
.filter(({ skipped }) => !skipped);
|
|
222
|
+
const key = JSON.stringify(answers);
|
|
223
|
+
if (key === lastDraftKey.current)
|
|
224
|
+
return;
|
|
225
|
+
lastDraftKey.current = key;
|
|
226
|
+
onDraftChangeRef.current?.(answers);
|
|
227
|
+
}, [questions, drafts, attachments]);
|
|
228
|
+
if (sent) {
|
|
229
|
+
return (_jsx(AskUserQuestionSummary, { id: summaryId, ref: ref, tabIndex: -1, items: summarizeAnswers(questions, sent), className: className, ...props }));
|
|
230
|
+
}
|
|
231
|
+
if (!question)
|
|
232
|
+
return null;
|
|
233
|
+
const uploading = isUploading(files);
|
|
234
|
+
// Sending takes every question's files, so the last question waits for uploads anywhere in the card.
|
|
235
|
+
const isAnyUploading = questions.some((each) => isUploading(filesOf(each.id)));
|
|
236
|
+
const isSendBlocked = isLast && isAnyUploading;
|
|
237
|
+
// So with a file attached anywhere, the last question confirms with Send answers instead of sending on a tap: a pick
|
|
238
|
+
// made while a file uploads waits on the button, not on a timer that can't fire.
|
|
239
|
+
const isSendConfirmed = isLast && questions.some((each) => filesOf(each.id).length > 0);
|
|
240
|
+
const canGoOn = hasAnswer(draft, files) && !uploading && !isSendBlocked;
|
|
241
|
+
const setDraft = (questionId, update) => setDrafts((current) => ({ ...current, [questionId]: update(current[questionId] ?? EMPTY_DRAFT) }));
|
|
242
|
+
const send = (from) => {
|
|
243
|
+
clearTimeout(pickTimer.current);
|
|
244
|
+
if (sentRef.current)
|
|
245
|
+
return;
|
|
246
|
+
sentRef.current = true;
|
|
247
|
+
isSummaryFocused.current = Boolean(rootRef.current?.contains(document.activeElement));
|
|
248
|
+
const answers = questions.map((each) => toAnswer(each, from[each.id] ?? EMPTY_DRAFT, filesOf(each.id)));
|
|
249
|
+
setSent(answers);
|
|
250
|
+
onSubmit?.(answers);
|
|
251
|
+
};
|
|
252
|
+
const goTo = (next) => {
|
|
253
|
+
clearTimeout(pickTimer.current);
|
|
254
|
+
movedByPerson.current = true;
|
|
255
|
+
setIndex(next);
|
|
256
|
+
};
|
|
257
|
+
const goOn = (from) => {
|
|
258
|
+
if (isLast)
|
|
259
|
+
send(from);
|
|
260
|
+
else
|
|
261
|
+
goTo(index + 1);
|
|
262
|
+
};
|
|
263
|
+
const pick = (optionId) => {
|
|
264
|
+
clearTimeout(pickTimer.current);
|
|
265
|
+
if (kind === QUESTION_KINDS.ANY) {
|
|
266
|
+
setDraft(question.id, (current) => ({
|
|
267
|
+
...current,
|
|
268
|
+
skipped: false,
|
|
269
|
+
picked: current.picked.includes(optionId)
|
|
270
|
+
? current.picked.filter((id) => id !== optionId)
|
|
271
|
+
: [...current.picked, optionId],
|
|
272
|
+
}));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
// Pick one: a tap replaces a typed answer, then moves on after a short beat (unless something waits for Next).
|
|
276
|
+
const nextDraft = { ...draft, picked: [optionId], other: "", otherOpen: false, skipped: false };
|
|
277
|
+
const next = { ...drafts, [question.id]: nextDraft };
|
|
278
|
+
setDrafts(next);
|
|
279
|
+
if (!needsNext(question, nextDraft, files) && !isSendConfirmed) {
|
|
280
|
+
pickTimer.current = setTimeout(() => goOn(next), PICK_DELAY_MS);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const type = (value) => setDraft(question.id, (current) => ({
|
|
284
|
+
...current,
|
|
285
|
+
other: value,
|
|
286
|
+
skipped: false,
|
|
287
|
+
// Pick one: typing replaces the pick. Pick any: it adds to the picks.
|
|
288
|
+
picked: kind === QUESTION_KINDS.ONE && value.trim() ? [] : current.picked,
|
|
289
|
+
}));
|
|
290
|
+
const closeOther = (refocus) => {
|
|
291
|
+
refocusOther.current = refocus;
|
|
292
|
+
setDraft(question.id, (current) => ({ ...current, other: "", otherOpen: false }));
|
|
293
|
+
};
|
|
294
|
+
const skip = () => {
|
|
295
|
+
const next = { ...drafts, [question.id]: { ...EMPTY_DRAFT, skipped: true } };
|
|
296
|
+
setDrafts(next);
|
|
297
|
+
goOn(next);
|
|
298
|
+
};
|
|
299
|
+
const attach = (picked) => {
|
|
300
|
+
if (!picked.length || !onAttachFiles)
|
|
301
|
+
return;
|
|
302
|
+
clearTimeout(pickTimer.current);
|
|
303
|
+
setDraft(question.id, (current) => ({ ...current, skipped: false }));
|
|
304
|
+
onAttachFiles(question.id, picked);
|
|
305
|
+
};
|
|
306
|
+
const handleFileInput = (event) => {
|
|
307
|
+
const picked = Array.from(event.target.files ?? []);
|
|
308
|
+
event.target.value = "";
|
|
309
|
+
attach(picked);
|
|
310
|
+
};
|
|
311
|
+
const handleKeyDown = (event) => {
|
|
312
|
+
onKeyDown?.(event);
|
|
313
|
+
if (event.defaultPrevented)
|
|
314
|
+
return;
|
|
315
|
+
const target = event.target;
|
|
316
|
+
const inField = target instanceof HTMLInputElement;
|
|
317
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
318
|
+
const rows = Array.from(rootRef.current?.querySelectorAll(`[data-slot=${ANSWER_SLOT}], [data-slot=${ANSWER_SLOT}-other] input`) ??
|
|
319
|
+
[]);
|
|
320
|
+
const at = rows.indexOf(target);
|
|
321
|
+
if (at === -1)
|
|
322
|
+
return;
|
|
323
|
+
event.preventDefault();
|
|
324
|
+
rows[(at + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length]?.focus();
|
|
325
|
+
}
|
|
326
|
+
else if (inField) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
else if (event.key === "ArrowLeft" && index > 0) {
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
goTo(index - 1);
|
|
332
|
+
}
|
|
333
|
+
else if (event.key === "ArrowRight" && !isLast) {
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
goTo(index + 1);
|
|
336
|
+
}
|
|
337
|
+
else if (event.key === "Enter" && !target.closest(OWN_ENTER) && canGoOn) {
|
|
338
|
+
// Enter anywhere on the card but on a control does what Next does.
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
goOn(drafts);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const otherFilled = draft.other.trim() !== "";
|
|
344
|
+
const selectedCount = draft.picked.length + (otherFilled ? 1 : 0);
|
|
345
|
+
const showNext = needsNext(question, draft, files) || isSendConfirmed;
|
|
346
|
+
const role = kind === QUESTION_KINDS.ANY ? "checkbox" : "radio";
|
|
347
|
+
const previewOption = [...draft.picked]
|
|
348
|
+
.reverse()
|
|
349
|
+
.map((id) => question.options.find((option) => option.id === id))
|
|
350
|
+
.find((option) => option?.preview);
|
|
351
|
+
return (_jsxs(FileDropArea, { ref: setRootNode, "data-slot": "ask-user-question", "data-state": "asking", role: "group", "aria-label": `Question ${index + 1} of ${questions.length}`, onKeyDown: handleKeyDown, onFiles: attach, disabled: !onAttachFiles, hint: `to “${question.title}”`, className: cn("rounded-xl border border-line bg-surface font-sans shadow-card", className), ...props, children: [_jsxs("div", { className: "transition-[opacity,translate] duration-160 ease-out starting:translate-x-1.5 starting:opacity-0", children: [_jsxs("div", { className: "flex items-start gap-2.5 pt-space-14 pr-space-10 pl-space-14", children: [_jsx("p", { id: titleId, className: "m-0 min-w-0 flex-1 text-body leading-5 font-semibold text-ink", children: question.title }), questions.length > 1 && (_jsxs("div", { className: "-mt-0.5 flex shrink-0 items-center text-small text-muted", children: [_jsx(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.ICON_SM, "aria-label": "Previous question", disabled: index === 0, onClick: () => goTo(index - 1), children: _jsx(ChevronLeft, {}) }), _jsxs("span", { className: "min-w-10 text-center", children: [index + 1, " of ", questions.length] }), _jsx(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.ICON_SM, "aria-label": "Next question", disabled: isLast, onClick: () => goTo(index + 1), children: _jsx(ChevronRight, {}) })] }))] }), _jsx("p", { className: "m-0 mt-0.5 px-space-14 text-small text-muted", children: KIND_HINTS[kind] }), _jsxs("div", { className: "flex flex-col gap-space-6 px-space-14 pt-space-12", children: [_jsxs("div", { role: kind === QUESTION_KINDS.ANY ? "group" : "radiogroup", "aria-labelledby": titleId, className: "flex flex-col gap-space-6", children: [question.options.map((option) => (_jsxs("button", { type: "button", "data-slot": ANSWER_SLOT, role: role, "aria-checked": draft.picked.includes(option.id), onClick: () => pick(option.id), className: ROW_CLASS, children: [_jsx(AnswerMark, { kind: kind, checked: draft.picked.includes(option.id) }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-px", children: [_jsx("span", { className: "text-ui text-ink", children: option.label }), option.description && _jsx("span", { className: "text-small text-muted", children: option.description })] })] }, option.id))), !draft.otherOpen && (_jsxs("button", { ref: otherButtonRef, type: "button", "data-slot": ANSWER_SLOT, role: role, "aria-checked": false, onClick: () => {
|
|
352
|
+
clearTimeout(pickTimer.current);
|
|
353
|
+
setDraft(question.id, (current) => ({ ...current, otherOpen: true }));
|
|
354
|
+
}, className: ROW_CLASS, children: [_jsx(AnswerMark, { kind: kind, checked: false }), _jsx("span", { className: "flex-1 text-ui text-muted", children: "Something else" })] }))] }), draft.otherOpen && (_jsxs("div", { "data-slot": `${ANSWER_SLOT}-other`, className: cn(ROW_CLASS, "cursor-text hover:border-line focus-within:border-faint"), onMouseDown: (event) => {
|
|
355
|
+
// Clicks on the row keep the field focused instead of closing an empty one.
|
|
356
|
+
if (event.target === otherInputRef.current)
|
|
357
|
+
return;
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
otherInputRef.current?.focus();
|
|
360
|
+
}, children: [_jsx(AnswerMark, { kind: kind, checked: otherFilled }), _jsx("input", { ref: otherInputRef, value: draft.other, onChange: (event) => type(event.target.value), onKeyDown: (event) => {
|
|
361
|
+
if (event.key === "Enter" && canGoOn) {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
goOn(drafts);
|
|
364
|
+
}
|
|
365
|
+
else if (event.key === "Escape" && !otherFilled) {
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
event.stopPropagation();
|
|
368
|
+
closeOther(true);
|
|
369
|
+
}
|
|
370
|
+
}, onBlur: (event) => {
|
|
371
|
+
// Focus moving nowhere (a click on the page) comes back to the row instead of dropping to <body>.
|
|
372
|
+
if (!otherFilled)
|
|
373
|
+
closeOther(event.relatedTarget === null);
|
|
374
|
+
}, placeholder: "Type your answer, then Enter", "aria-label": "Something else", className: "h-4.75 min-w-0 flex-1 border-0 bg-transparent p-0 text-ui text-ink outline-none placeholder:text-faint" })] }))] }), previewOption?.preview && (_jsx("div", { className: "px-space-14 pt-space-12", children: _jsx(AnswerPreview, { label: previewOption.label, preview: previewOption.preview }, previewOption.id) })), _jsx(AttachmentGallery, { items: files, size: ATTACHMENT_GALLERY_SIZES.SM, onRemove: onRemoveAttachment && ((id) => onRemoveAttachment(question.id, id)), onRetry: onRetryAttachment && ((id) => onRetryAttachment(question.id, id)), className: "px-space-14 pt-space-12" })] }, question.id), _jsxs("div", { className: "mt-space-12 flex items-center gap-space-8 border-t border-line px-space-14 py-space-10", children: [_jsx(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.SM, disabled: isSendBlocked, onClick: skip, children: "Skip" }), onAttachFiles && (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.SM, onClick: () => fileInputRef.current?.click(), children: [_jsx(Paperclip, {}), "Attach files"] }), _jsx("input", { ref: fileInputRef, type: "file", multiple: true, accept: accept, tabIndex: -1, hidden: true, onChange: handleFileInput })] })), _jsx("span", { className: "flex-1" }), kind === QUESTION_KINDS.ANY && selectedCount > 0 && (_jsxs("span", { className: "text-small text-muted", children: [selectedCount, " selected"] })), showNext && (_jsx(Button, { size: BUTTON_SIZES.SM, disabled: !canGoOn, onClick: () => goOn(drafts), children: isLast ? "Send answers" : "Next" }))] })] }));
|
|
375
|
+
}
|
|
376
|
+
export const ASK_USER_QUESTION_SUMMARY_STATUSES = {
|
|
377
|
+
/** The answers were sent: each question with its answer. */
|
|
378
|
+
SENT: "sent",
|
|
379
|
+
/** The person wrote a new message instead of answering. */
|
|
380
|
+
SKIPPED: "skipped",
|
|
381
|
+
/** The person answered in the composer instead of on the card. */
|
|
382
|
+
IN_CHAT: "in-chat",
|
|
383
|
+
};
|
|
384
|
+
const SUMMARY_LINES = {
|
|
385
|
+
[ASK_USER_QUESTION_SUMMARY_STATUSES.SKIPPED]: "Skipped. You sent a new message instead.",
|
|
386
|
+
[ASK_USER_QUESTION_SUMMARY_STATUSES.IN_CHAT]: "Answered in chat",
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* The questions after they're done: Your answers, each question with its answer (“I’ll decide” for a skipped one),
|
|
390
|
+
* or one line when the person skipped them or answered in chat. Rendered on its own from history.
|
|
391
|
+
*/
|
|
392
|
+
export function AskUserQuestionSummary({ status = ASK_USER_QUESTION_SUMMARY_STATUSES.SENT, items = [], onOpenFile, className, ...props }) {
|
|
393
|
+
if (status !== ASK_USER_QUESTION_SUMMARY_STATUSES.SENT) {
|
|
394
|
+
return (_jsxs("div", { "data-slot": "ask-user-question-summary", "data-state": status, className: cn("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", className), ...props, children: [_jsx(MessageCircleQuestion, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-faint" }), SUMMARY_LINES[status]] }));
|
|
395
|
+
}
|
|
396
|
+
return (_jsxs("div", { "data-slot": "ask-user-question-summary", "data-state": status, role: "group", "aria-label": "Answers sent", className: cn("rounded-xl border border-line bg-surface pb-space-12 font-sans shadow-card outline-none", className), ...props, children: [_jsxs("div", { className: "flex items-center gap-space-6 px-space-14 pt-space-12 text-small font-medium text-muted", children: [_jsx(MessageCircleQuestion, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-faint" }), "Your answers"] }), _jsx("ul", { className: "m-0 list-none p-0", children: items.map((item, i) => (_jsxs("li", { className: "px-space-14 pt-space-10 [&+&]:mt-space-10 [&+&]:border-t [&+&]:border-line", children: [_jsx("p", { className: "m-0 mb-space-4 text-ui leading-4.75 font-semibold text-ink", children: item.question }), _jsxs("p", { className: cn("m-0 flex items-center gap-space-6 text-ui leading-4.75 text-ink-2", !item.answer && !item.files?.length && "text-muted"), children: [_jsx(CornerDownRight, { "aria-hidden": "true", className: "size-3.25 shrink-0 text-muted" }), item.answer ??
|
|
397
|
+
(item.files?.length
|
|
398
|
+
? `${item.files.length} ${item.files.length === 1 ? "file" : "files"}`
|
|
399
|
+
: "I’ll decide")] }), item.files && item.files.length > 0 && (_jsx(AttachmentGallery, { items: item.files.map(({ name, url }, index) => ({ id: `${index}-${name}`, name, url })), size: ATTACHMENT_GALLERY_SIZES.SM, onOpen: onOpenFile && (({ name, url }) => onOpenFile({ name, url })), className: "mt-space-6 ml-4.75" }))] }, i))) })] }));
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=ask-user-question.js.map
|