@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,272 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Field
|
|
3
|
+
slug: field
|
|
4
|
+
description: "A labelled control: label above, the control, then a hint or an error; or a check with its label beside it."
|
|
5
|
+
group: Inputs
|
|
6
|
+
layer: primitive
|
|
7
|
+
status: stable
|
|
8
|
+
since: 0.3.0
|
|
9
|
+
import: import { Field, FieldLabel, FieldContent, FieldDescription, FieldError, FieldGroup, FIELD_ORIENTATIONS } from "@major-tech/ui/field";
|
|
10
|
+
source: packages/ui/src/components/field.tsx
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Field
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Anatomy
|
|
18
|
+
|
|
19
|
+
FieldLabel above (12px medium ink-2), the control, then a FieldDescription or a FieldError, 6px apart. Every typed value in forms, dialogs and settings sits in a Field: an Input, a Textarea, an InputGroup, a Select.
|
|
20
|
+
|
|
21
|
+
Example: `anatomy`
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Field, FieldDescription, FieldLabel } from "@major-tech/ui/field";
|
|
25
|
+
import { Input } from "@major-tech/ui/input";
|
|
26
|
+
import { Textarea } from "@major-tech/ui/textarea";
|
|
27
|
+
|
|
28
|
+
export default function FieldAnatomy() {
|
|
29
|
+
return (
|
|
30
|
+
<div className="flex w-80 max-w-full flex-col gap-space-24">
|
|
31
|
+
<Field>
|
|
32
|
+
<FieldLabel htmlFor="app-name" required>
|
|
33
|
+
Name
|
|
34
|
+
</FieldLabel>
|
|
35
|
+
<Input id="app-name" placeholder="Lead tracker" required aria-describedby="app-name-hint" />
|
|
36
|
+
<FieldDescription id="app-name-hint">Shown in the sidebar and on the app’s card.</FieldDescription>
|
|
37
|
+
</Field>
|
|
38
|
+
<Field>
|
|
39
|
+
<FieldLabel htmlFor="app-description">Description</FieldLabel>
|
|
40
|
+
<Textarea
|
|
41
|
+
id="app-description"
|
|
42
|
+
placeholder="Tracks new leads from the website form."
|
|
43
|
+
aria-describedby="app-description-hint"
|
|
44
|
+
/>
|
|
45
|
+
<FieldDescription id="app-description-hint">Shown to builders and to Major AI.</FieldDescription>
|
|
46
|
+
</Field>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Form grid
|
|
53
|
+
|
|
54
|
+
FieldGroup is the two-column form: short fields pair up (Host + Port, Username + Password), a long one spans both with `col-span-full`. Hosts, URLs and keys are mono. Validate on blur or on the action.
|
|
55
|
+
|
|
56
|
+
Example: `connection-form` (Connect PostgreSQL). Leave Username empty and tab out to see the error.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
"use client";
|
|
60
|
+
|
|
61
|
+
import { useState, type ChangeEvent } from "react";
|
|
62
|
+
import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@major-tech/ui/field";
|
|
63
|
+
import { Input } from "@major-tech/ui/input";
|
|
64
|
+
import { PasswordInput } from "@major-tech/ui/password-input";
|
|
65
|
+
|
|
66
|
+
export default function ConnectionForm() {
|
|
67
|
+
const [username, setUsername] = useState("");
|
|
68
|
+
const [isUsernameTouched, setIsUsernameTouched] = useState(false);
|
|
69
|
+
const isUsernameErrorVisible = isUsernameTouched && username === "";
|
|
70
|
+
|
|
71
|
+
const handleUsernameChange = (event: ChangeEvent<HTMLInputElement>) => setUsername(event.target.value);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<FieldGroup className="w-135 max-w-full max-sm:grid-cols-1">
|
|
75
|
+
<Field>
|
|
76
|
+
<FieldLabel htmlFor="pg-host" required>
|
|
77
|
+
Host
|
|
78
|
+
</FieldLabel>
|
|
79
|
+
<Input
|
|
80
|
+
id="pg-host"
|
|
81
|
+
required
|
|
82
|
+
className="font-mono text-small"
|
|
83
|
+
defaultValue="ep-quiet-sound-a4f3.eu-central-1.aws.neon.tech"
|
|
84
|
+
/>
|
|
85
|
+
</Field>
|
|
86
|
+
<Field>
|
|
87
|
+
<FieldLabel htmlFor="pg-port" required>
|
|
88
|
+
Port
|
|
89
|
+
</FieldLabel>
|
|
90
|
+
<Input id="pg-port" required className="font-mono text-small" defaultValue="5432" inputMode="numeric" />
|
|
91
|
+
</Field>
|
|
92
|
+
<Field>
|
|
93
|
+
<FieldLabel htmlFor="pg-username" required>
|
|
94
|
+
Username
|
|
95
|
+
</FieldLabel>
|
|
96
|
+
<Input
|
|
97
|
+
id="pg-username"
|
|
98
|
+
required
|
|
99
|
+
value={username}
|
|
100
|
+
onChange={handleUsernameChange}
|
|
101
|
+
onBlur={() => setIsUsernameTouched(true)}
|
|
102
|
+
aria-invalid={isUsernameErrorVisible}
|
|
103
|
+
aria-describedby="pg-username-error"
|
|
104
|
+
/>
|
|
105
|
+
<FieldError id="pg-username-error">{isUsernameErrorVisible && "Fill in username first."}</FieldError>
|
|
106
|
+
</Field>
|
|
107
|
+
<Field>
|
|
108
|
+
<FieldLabel htmlFor="pg-password" required>
|
|
109
|
+
Password
|
|
110
|
+
</FieldLabel>
|
|
111
|
+
<PasswordInput id="pg-password" required defaultValue="n30n-s3cret" autoComplete="new-password" />
|
|
112
|
+
</Field>
|
|
113
|
+
<Field className="col-span-full">
|
|
114
|
+
<FieldLabel htmlFor="pg-database">Database</FieldLabel>
|
|
115
|
+
<Input id="pg-database" placeholder="analytics" aria-describedby="pg-database-hint" />
|
|
116
|
+
<FieldDescription id="pg-database-hint">Leave empty to use the default database.</FieldDescription>
|
|
117
|
+
</Field>
|
|
118
|
+
</FieldGroup>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Live validation
|
|
124
|
+
|
|
125
|
+
Validate as people type only when it helps them choose, like subdomain availability. A success hint is a FieldDescription in `text-success` with a CircleCheck.
|
|
126
|
+
|
|
127
|
+
Example: `subdomain`. Try “sales”.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
"use client";
|
|
131
|
+
|
|
132
|
+
import { useState, type ChangeEvent } from "react";
|
|
133
|
+
import { CircleCheck } from "lucide-react";
|
|
134
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "@major-tech/ui/field";
|
|
135
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from "@major-tech/ui/input-group";
|
|
136
|
+
|
|
137
|
+
const TAKEN_SUBDOMAINS = ["sales", "office", "admin"];
|
|
138
|
+
|
|
139
|
+
export default function SubdomainField() {
|
|
140
|
+
const [subdomain, setSubdomain] = useState("my-office");
|
|
141
|
+
const isTaken = TAKEN_SUBDOMAINS.includes(subdomain);
|
|
142
|
+
const isAvailable = !isTaken && subdomain !== "";
|
|
143
|
+
|
|
144
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) =>
|
|
145
|
+
setSubdomain(event.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""));
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<Field className="w-105 max-w-full">
|
|
149
|
+
<FieldLabel htmlFor="subdomain">Subdomain</FieldLabel>
|
|
150
|
+
<InputGroup>
|
|
151
|
+
<InputGroupInput
|
|
152
|
+
id="subdomain"
|
|
153
|
+
className="font-mono text-small"
|
|
154
|
+
value={subdomain}
|
|
155
|
+
onChange={handleChange}
|
|
156
|
+
aria-invalid={isTaken}
|
|
157
|
+
aria-describedby="subdomain-status"
|
|
158
|
+
/>
|
|
159
|
+
<InputGroupAddon align="inline-end" variant="affix">
|
|
160
|
+
.major.app
|
|
161
|
+
</InputGroupAddon>
|
|
162
|
+
</InputGroup>
|
|
163
|
+
<FieldError id="subdomain-status">{isTaken && "This subdomain is already taken."}</FieldError>
|
|
164
|
+
{isAvailable && (
|
|
165
|
+
<FieldDescription id="subdomain-status" className="text-success">
|
|
166
|
+
<CircleCheck aria-hidden />
|
|
167
|
+
This subdomain is available.
|
|
168
|
+
</FieldDescription>
|
|
169
|
+
)}
|
|
170
|
+
</Field>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Beside a check
|
|
176
|
+
|
|
177
|
+
`orientation="horizontal"` puts a Checkbox, Switch or RadioGroupItem first and its 13px ink label 8px to the right. With a second line, wrap the label and the FieldDescription in FieldContent.
|
|
178
|
+
|
|
179
|
+
Example: `horizontal`
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { Checkbox } from "@major-tech/ui/checkbox";
|
|
183
|
+
import { Field, FieldContent, FieldDescription, FieldLabel } from "@major-tech/ui/field";
|
|
184
|
+
import { Switch } from "@major-tech/ui/switch";
|
|
185
|
+
|
|
186
|
+
export default function FieldHorizontal() {
|
|
187
|
+
return (
|
|
188
|
+
<div className="flex flex-col gap-space-14">
|
|
189
|
+
<Field orientation="horizontal">
|
|
190
|
+
<Checkbox id="daily-summary" defaultChecked />
|
|
191
|
+
<FieldLabel htmlFor="daily-summary">Send a daily summary</FieldLabel>
|
|
192
|
+
</Field>
|
|
193
|
+
<Field orientation="horizontal">
|
|
194
|
+
<Switch id="separate-credentials" aria-describedby="separate-credentials-hint" />
|
|
195
|
+
<FieldContent>
|
|
196
|
+
<FieldLabel htmlFor="separate-credentials">Different credentials per environment</FieldLabel>
|
|
197
|
+
<FieldDescription id="separate-credentials-hint">
|
|
198
|
+
Recommended when the service has a separate staging setup.
|
|
199
|
+
</FieldDescription>
|
|
200
|
+
</FieldContent>
|
|
201
|
+
</Field>
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Guidelines
|
|
208
|
+
|
|
209
|
+
Do:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<Field className="w-60">
|
|
213
|
+
<FieldLabel htmlFor="do-username" required>
|
|
214
|
+
Username
|
|
215
|
+
</FieldLabel>
|
|
216
|
+
<Input id="do-username" required aria-invalid aria-describedby="do-username-error" />
|
|
217
|
+
<FieldError id="do-username-error">Fill in username first.</FieldError>
|
|
218
|
+
</Field>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- Errors say what to do: “Fill in username first.”
|
|
222
|
+
- Mark required fields with the asterisk; optional fields say nothing (or “Optional” as the placeholder).
|
|
223
|
+
- Save settings fields when they lose focus, confirmed with a “Saved” toast.
|
|
224
|
+
|
|
225
|
+
Don't:
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
<Input className="w-60" placeholder="Username *" aria-invalid />
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
- Placeholder text as the label: it disappears as soon as people type.
|
|
232
|
+
- Abstract errors: “Invalid”, “Error 422”.
|
|
233
|
+
- Fixed parts of a value (“.major.app”) in the placeholder: they are an InputGroup affix.
|
|
234
|
+
|
|
235
|
+
## API
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
import { Field, FieldLabel, FieldContent, FieldDescription, FieldError, FieldGroup, FIELD_ORIENTATIONS } from "@major-tech/ui/field";
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### `<Field />`
|
|
242
|
+
|
|
243
|
+
Also accepts every `<div>` attribute. Renders `role="group"`. `FIELD_ORIENTATIONS` holds the values below as constants.
|
|
244
|
+
|
|
245
|
+
| Prop | Type | Default | Description |
|
|
246
|
+
| --- | --- | --- | --- |
|
|
247
|
+
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Label above the control, or a check with its label to the right. |
|
|
248
|
+
|
|
249
|
+
### `<FieldLabel />`
|
|
250
|
+
|
|
251
|
+
Also accepts every `<label>` attribute.
|
|
252
|
+
|
|
253
|
+
| Prop | Type | Default | Description |
|
|
254
|
+
| --- | --- | --- | --- |
|
|
255
|
+
| `htmlFor` | `string` | — | The control's id. |
|
|
256
|
+
| `required` | `boolean` | `false` | Adds the danger asterisk (`aria-hidden`). Set `required` on the control too. |
|
|
257
|
+
|
|
258
|
+
### `<FieldContent /> · <FieldDescription /> · <FieldError /> · <FieldGroup />`
|
|
259
|
+
|
|
260
|
+
| Prop | Type | Default | Description |
|
|
261
|
+
| --- | --- | --- | --- |
|
|
262
|
+
| `FieldContent` | `<div>` | — | In a horizontal Field: the label and its description, stacked. Dims with a disabled control. |
|
|
263
|
+
| `FieldDescription` | `<p>` | — | 12px muted hint. `text-success` and a CircleCheck for a success hint. |
|
|
264
|
+
| `FieldError` | `<p>` | — | Danger line with an alert icon and `role="alert"`. Renders nothing without children. |
|
|
265
|
+
| `FieldGroup` | `<div>` | — | Two-column grid, 16px between columns and 14px between rows. |
|
|
266
|
+
|
|
267
|
+
### Accessibility
|
|
268
|
+
|
|
269
|
+
- FieldLabel is a real `<label>`: point `htmlFor` at the control's id.
|
|
270
|
+
- Link hints and errors with `aria-describedby`; FieldError is announced.
|
|
271
|
+
- Set `aria-invalid` on the control: Input, Textarea and InputGroup take the danger ring from it.
|
|
272
|
+
- The asterisk is hidden from assistive tech, so set `required` on the control.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: FileUpload
|
|
3
|
+
slug: file-upload
|
|
4
|
+
description: "Adding files: one logo, favicon or brief, or attachments dropped on the composer and AskUserQuestion, with one drop field and the same checks everywhere."
|
|
5
|
+
group: Inputs
|
|
6
|
+
layer: composed
|
|
7
|
+
status: stable
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
import: import { FileUpload, FILE_UPLOAD_VARIANTS, FILE_UPLOAD_PREVIEWS, FileDropArea, checkIfFileDragClaimed, validateFiles, matchesAccept, FILE_REJECTIONS, formatFileSize } from "@major-tech/ui/file-upload";
|
|
10
|
+
source: packages/ui/src/components/file-upload.tsx
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# FileUpload
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Button
|
|
18
|
+
|
|
19
|
+
The default empty state: an outline Button with the upload icon (“Upload logo”), the accepted types beside it. A FieldLabel can point at its id: the label opens the file picker.
|
|
20
|
+
|
|
21
|
+
Example: `button`
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Field, FieldLabel } from "@major-tech/ui/field";
|
|
25
|
+
import { FileUpload } from "@major-tech/ui/file-upload";
|
|
26
|
+
|
|
27
|
+
const MAX_LOGO_BYTES = 5 * 1024 * 1024;
|
|
28
|
+
|
|
29
|
+
export default function FileUploadButton() {
|
|
30
|
+
return (
|
|
31
|
+
<Field>
|
|
32
|
+
<FieldLabel htmlFor="logo-upload">Logo</FieldLabel>
|
|
33
|
+
<FileUpload
|
|
34
|
+
id="logo-upload"
|
|
35
|
+
label="Upload logo"
|
|
36
|
+
accept="image/png,image/jpeg,image/webp"
|
|
37
|
+
maxSize={MAX_LOGO_BYTES}
|
|
38
|
+
hint="PNG, JPG or WebP, up to 5 MB"
|
|
39
|
+
/>
|
|
40
|
+
</Field>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Drop zone
|
|
46
|
+
|
|
47
|
+
For larger areas: a dashed line drop zone with an icon, “Drop a file or browse” and the accepted types in muted. It turns link green while a file is dragged over it.
|
|
48
|
+
|
|
49
|
+
Example: `dropzone`
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { FileUpload } from "@major-tech/ui/file-upload";
|
|
53
|
+
|
|
54
|
+
const MAX_SKILL_BYTES = 5 * 1024 * 1024;
|
|
55
|
+
|
|
56
|
+
export default function FileUploadDropzone() {
|
|
57
|
+
return (
|
|
58
|
+
<div className="w-140 max-w-full">
|
|
59
|
+
<FileUpload
|
|
60
|
+
variant="dropzone"
|
|
61
|
+
preview="file"
|
|
62
|
+
accept=".zip,.skill"
|
|
63
|
+
hint="A .zip or .skill file, up to 5 MB"
|
|
64
|
+
maxSize={MAX_SKILL_BYTES}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Uploaded
|
|
72
|
+
|
|
73
|
+
A preview, then Replace (outline) and Remove (ghost). Logos sit in a 34px secondary box, favicons in a little browser-tab mock, other files show their name.
|
|
74
|
+
|
|
75
|
+
Example: `uploaded`
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { FileUpload } from "@major-tech/ui/file-upload";
|
|
79
|
+
|
|
80
|
+
const MARK_URL = "/major-mark.svg";
|
|
81
|
+
|
|
82
|
+
export default function FileUploadUploaded() {
|
|
83
|
+
return (
|
|
84
|
+
<div className="flex flex-col gap-space-14">
|
|
85
|
+
<FileUpload defaultValue={MARK_URL} accept="image/png,image/jpeg,image/webp" />
|
|
86
|
+
<FileUpload
|
|
87
|
+
preview="favicon"
|
|
88
|
+
tabTitle="Lead tracker"
|
|
89
|
+
defaultValue={MARK_URL}
|
|
90
|
+
accept="image/png,image/svg+xml,image/x-icon"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Several files
|
|
98
|
+
|
|
99
|
+
FileUpload is for one file in a form: a logo, a favicon, a brief. Where people attach several files to a message, wrap the area in FileDropArea and show the files in an AttachmentGallery. While files are dragged over it, a dashed field covers the area and says where they go. The chat panel, the Composer and AskUserQuestion use the same field.
|
|
100
|
+
|
|
101
|
+
Example: `drop-area`
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
"use client";
|
|
105
|
+
|
|
106
|
+
import { useEffect, useRef, useState } from "react";
|
|
107
|
+
import { ATTACHMENT_STATUSES, AttachmentGallery, type AttachmentItem } from "@major-tech/ui/attachment-gallery";
|
|
108
|
+
import { FileDropArea, validateFiles } from "@major-tech/ui/file-upload";
|
|
109
|
+
|
|
110
|
+
/** A connector's context documents: these types, up to 25 MB each and 5 per resource. */
|
|
111
|
+
const ACCEPT = ".md,.pdf,.json,.yaml,.yml";
|
|
112
|
+
const MAX_FILE_BYTES = 25 * 1024 * 1024;
|
|
113
|
+
const MAX_FILES = 5;
|
|
114
|
+
const DROP_HINT = "Markdown, PDF, JSON or YAML, up to 5 files, 25 MB each";
|
|
115
|
+
|
|
116
|
+
/** Stands in for the product's upload: a second of "uploading", then the file is ready at its url. */
|
|
117
|
+
const UPLOAD_MS = 1000;
|
|
118
|
+
|
|
119
|
+
export default function FileUploadDropArea() {
|
|
120
|
+
const [files, setFiles] = useState<AttachmentItem[]>([]);
|
|
121
|
+
const urls = useRef(new Set<string>());
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const created = urls.current;
|
|
125
|
+
|
|
126
|
+
return () => created.forEach((url) => URL.revokeObjectURL(url));
|
|
127
|
+
}, []);
|
|
128
|
+
|
|
129
|
+
const toAttachment = (file: File, status: AttachmentItem["status"], error?: string): AttachmentItem => {
|
|
130
|
+
const url = URL.createObjectURL(file);
|
|
131
|
+
urls.current.add(url);
|
|
132
|
+
|
|
133
|
+
return { id: url, name: file.name, type: file.type, size: file.size, url, status, error };
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const addFiles = (picked: File[]) => {
|
|
137
|
+
const { accepted, rejected } = validateFiles(picked, {
|
|
138
|
+
accept: ACCEPT,
|
|
139
|
+
maxSize: MAX_FILE_BYTES,
|
|
140
|
+
maxFiles: MAX_FILES,
|
|
141
|
+
attachedCount: files.length,
|
|
142
|
+
});
|
|
143
|
+
const added = accepted.map((file) => toAttachment(file, ATTACHMENT_STATUSES.UPLOADING));
|
|
144
|
+
const failed = rejected.map(({ file, message }) => toAttachment(file, ATTACHMENT_STATUSES.ERROR, message));
|
|
145
|
+
const ids = new Set(added.map(({ id }) => id));
|
|
146
|
+
|
|
147
|
+
setFiles((current) => [...current, ...added, ...failed]);
|
|
148
|
+
setTimeout(() => {
|
|
149
|
+
setFiles((current) =>
|
|
150
|
+
current.map((item) => (ids.has(item.id) ? { ...item, status: ATTACHMENT_STATUSES.DONE } : item))
|
|
151
|
+
);
|
|
152
|
+
}, UPLOAD_MS);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<FileDropArea
|
|
157
|
+
onFiles={addFiles}
|
|
158
|
+
hint={DROP_HINT}
|
|
159
|
+
className="flex min-h-60 w-full flex-col gap-space-12 rounded-xl border border-line bg-surface p-space-16"
|
|
160
|
+
>
|
|
161
|
+
<p className="m-0 text-body text-muted">Context documents: drag files from your computer onto this panel.</p>
|
|
162
|
+
<AttachmentGallery
|
|
163
|
+
items={files}
|
|
164
|
+
onRemove={(id) => setFiles((current) => current.filter((item) => item.id !== id))}
|
|
165
|
+
/>
|
|
166
|
+
</FileDropArea>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
- The field: surface over the whole area, a dashed 1.5px link border on success-soft, the upload icon, “Drop files to attach” in 13px, and a second line in muted: where they go, or the limits.
|
|
172
|
+
- Nested areas work: the innermost one under the pointer takes the drop. A drop on the AskUserQuestion card goes to its question, not the composer under it.
|
|
173
|
+
- Dragging is never the only way: keep a button or a menu item that opens the file picker.
|
|
174
|
+
|
|
175
|
+
### Checks
|
|
176
|
+
|
|
177
|
+
validateFiles checks dropped or picked files against the limits before anything uploads, with the same words everywhere: “Larger than 100 MB”, “This file type isn’t supported”, “Up to 30 files”.
|
|
178
|
+
|
|
179
|
+
- Upload the accepted files at once and show them as uploading; show a rejected file as a failed tile with its reason, so the person sees which one and why.
|
|
180
|
+
- Too many files: attach up to the limit and say the rest in a toast.
|
|
181
|
+
- A single FileUpload checks accept and maxSize itself and shows the reason under it.
|
|
182
|
+
|
|
183
|
+
### Limits in Major
|
|
184
|
+
|
|
185
|
+
What each place in Major accepts. Say the limits in the hint, in these words, and set the same accept, maxSize and maxFiles, so a file is refused before it uploads. Some limits are checked again after upload: a file refused there shows as a failed tile, “Upload failed”.
|
|
186
|
+
|
|
187
|
+
- **Chat attachments** (the Composer and AskUserQuestion answers): any type, up to 100 MB a file and 30 files a message.
|
|
188
|
+
- **Avatar and organisation logo**: PNG, JPG or WebP, up to 5 MB.
|
|
189
|
+
- **Connector logo** (Custom API, MCP): PNG, JPG, WebP, GIF, SVG or ICO, up to 1 MB.
|
|
190
|
+
- **Connector context documents**: .md, .pdf, .json, .yaml or .yml, up to 25 MB each and 5 per resource.
|
|
191
|
+
- **Skill**: a SKILL.md with its files, or a .zip or .skill archive up to 5 MB (25 MB unpacked, 5 MB a file, 200 files).
|
|
192
|
+
- **Postgres SSL certificate**: .pem, .crt, .cer or .txt.
|
|
193
|
+
- **Managed blob storage**: any file, no limit.
|
|
194
|
+
|
|
195
|
+
### Guidelines
|
|
196
|
+
|
|
197
|
+
- Accepted types and sizes live in the hint or the row's description: “Square PNG, SVG or ICO, 32×32 or larger”.
|
|
198
|
+
- Confirm with a toast: “Favicon saved”, “Logo removed”.
|
|
199
|
+
- Reject oversized files before uploading, with a FieldError that says what to do.
|
|
200
|
+
|
|
201
|
+
## API
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { FileUpload, FILE_UPLOAD_VARIANTS, FILE_UPLOAD_PREVIEWS, FileDropArea, checkIfFileDragClaimed, validateFiles, matchesAccept, FILE_REJECTIONS, formatFileSize } from "@major-tech/ui/file-upload";
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### `<FileUpload />`
|
|
208
|
+
|
|
209
|
+
`FILE_UPLOAD_VARIANTS` and `FILE_UPLOAD_PREVIEWS` hold the values below as constants.
|
|
210
|
+
|
|
211
|
+
| Prop | Type | Default | Description |
|
|
212
|
+
| --- | --- | --- | --- |
|
|
213
|
+
| `variant` | `"button" \| "dropzone"` | `"button"` | Empty state. |
|
|
214
|
+
| `preview` | `"image" \| "favicon" \| "file"` | `"image"` | How an uploaded file is shown. |
|
|
215
|
+
| `label` | `string` | `"Upload file"` | Button label (button variant). |
|
|
216
|
+
| `hint` | `ReactNode` | — | Accepted types and sizes. |
|
|
217
|
+
| `accept` | `string` | — | Native accept string; a dropped file of another type is refused. |
|
|
218
|
+
| `maxSize` | `number` | — | Bytes; a larger file shows an error instead of being picked. |
|
|
219
|
+
| `value / defaultValue` | `File \| string \| null` | — | A File, an existing URL, or null. |
|
|
220
|
+
| `onValueChange` | `(file: File \| null) => void` | — | Picked file, or null on Remove. |
|
|
221
|
+
| `tabTitle` | `string` | `"Untitled"` | Page name in the favicon tab mock. |
|
|
222
|
+
| `disabled` | `boolean` | — | Disables picking, Replace and Remove. |
|
|
223
|
+
| `id` | `string` | — | Id of the hidden file input, for a FieldLabel. |
|
|
224
|
+
| `className` | `string` | — | Goes on the wrapper. |
|
|
225
|
+
|
|
226
|
+
### `<FileDropArea />`
|
|
227
|
+
|
|
228
|
+
Renders a `<div>` around its children; every other `<div>` attribute goes on it.
|
|
229
|
+
|
|
230
|
+
| Prop | Type | Default | Description |
|
|
231
|
+
| --- | --- | --- | --- |
|
|
232
|
+
| `onFiles`* | `(files: File[]) => void` | — | The dropped files. Check them with validateFiles, then upload. |
|
|
233
|
+
| `label` | `ReactNode` | `"Drop files to attach"` | The field’s first line. |
|
|
234
|
+
| `hint` | `ReactNode` | — | The second line: where they go, or the limits. |
|
|
235
|
+
| `disabled` | `boolean` | — | Takes no drops and shows no field. |
|
|
236
|
+
|
|
237
|
+
`*` marks a required prop.
|
|
238
|
+
|
|
239
|
+
### `validateFiles · matchesAccept · FILE_REJECTIONS · formatFileSize · checkIfFileDragClaimed`
|
|
240
|
+
|
|
241
|
+
| Prop | Type | Default | Description |
|
|
242
|
+
| --- | --- | --- | --- |
|
|
243
|
+
| `validateFiles(files, limits)` | `{ accepted: File[]; rejected: FileRejection[] }` | — | limits: accept, maxSize (bytes), maxFiles and attachedCount (files already there). |
|
|
244
|
+
| `FileRejection` | `{ file: File; code: FileRejectionCode; message: string }` | — | A refused file, with the reason in words. |
|
|
245
|
+
| `matchesAccept(file, accept)` | `boolean` | — | Whether a file matches a native accept string: .pdf, image/*, image/png. |
|
|
246
|
+
| `FILE_REJECTIONS.TOO_LARGE · TYPE · TOO_MANY` | `"too-large" \| "type" \| "too-many"` | — | Why a file was refused: larger than `maxSize`, not in `accept`, past `maxFiles`. |
|
|
247
|
+
| `formatFileSize(bytes)` | `string` | — | A size as the messages write it: “820 KB”, “100 MB”. |
|
|
248
|
+
| `checkIfFileDragClaimed(event)` | `boolean` | — | Whether a FileDropArea took this drag event (the innermost one under the pointer does). A drop zone of the product's own around one checks it and lets the drop go: from a React handler, or a native listener on `document` or `window` (one inside the React root runs before the claim). |
|
|
249
|
+
|
|
250
|
+
### Accessibility
|
|
251
|
+
|
|
252
|
+
- The drop zone is a real button, so it works by keyboard as well as by drag and drop.
|
|
253
|
+
- Errors are announced (`role="alert"`).
|
|
254
|
+
- The native file input stays in the DOM (visually hidden) for form submission and testing.
|
|
255
|
+
- FileDropArea adds nothing to the keyboard order: pair it with a control that opens the file picker.
|