@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,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CodeBlock
|
|
3
|
+
slug: code-block
|
|
4
|
+
description: "Code on the code surface with syntax colours: a header with the file's name and a copy button, numbered or added and removed lines, wrapping or scrolling."
|
|
5
|
+
group: Data
|
|
6
|
+
layer: composed
|
|
7
|
+
status: beta
|
|
8
|
+
since: 0.4.0
|
|
9
|
+
import: import { CodeBlock, CodeBlockHeader, CodeBlockTitle, CodeBlockActions, CodeBlockCopyButton, CodeBlockContent, CodeBlockLine, CodeBlockFooter, CodeBlockHighlightedLines, HighlightedCodeBlock, SYNTAX_THEME, CODE_BLOCK_VARIANTS, CODE_BLOCK_SIZES, CODE_BLOCK_LINE_VARIANTS } from "@major-tech/ui/code-block";
|
|
10
|
+
source: packages/ui/src/components/code-block.tsx
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# CodeBlock
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### A file
|
|
18
|
+
|
|
19
|
+
Code on code-surface: a header with the file's name and a copy button, then the code in its language's colours. Numbered lines can start where the part of the file starts.
|
|
20
|
+
|
|
21
|
+
Example: `file`
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import {
|
|
25
|
+
CodeBlock,
|
|
26
|
+
CodeBlockActions,
|
|
27
|
+
CodeBlockContent,
|
|
28
|
+
CodeBlockCopyButton,
|
|
29
|
+
CodeBlockHeader,
|
|
30
|
+
CodeBlockHighlightedLines,
|
|
31
|
+
CodeBlockTitle,
|
|
32
|
+
} from "@major-tech/ui/code-block";
|
|
33
|
+
import { findCodeLanguage } from "@major-tech/ui/lib/code-language";
|
|
34
|
+
import { FileText } from "lucide-react";
|
|
35
|
+
|
|
36
|
+
const PATH = "src/lib/format-joke.ts";
|
|
37
|
+
const FIRST_LINE = 40;
|
|
38
|
+
|
|
39
|
+
const CODE = `export function formatJoke(joke: Joke): string {
|
|
40
|
+
// One line, no hashtags.
|
|
41
|
+
const text = joke.setup.trim();
|
|
42
|
+
|
|
43
|
+
return \`\${text} \${joke.punchline}\`;
|
|
44
|
+
}`;
|
|
45
|
+
|
|
46
|
+
export default function CodeBlockFile() {
|
|
47
|
+
return (
|
|
48
|
+
<CodeBlock className="max-w-136">
|
|
49
|
+
<CodeBlockHeader>
|
|
50
|
+
<CodeBlockTitle>
|
|
51
|
+
<FileText />
|
|
52
|
+
{PATH}
|
|
53
|
+
</CodeBlockTitle>
|
|
54
|
+
<CodeBlockActions>
|
|
55
|
+
<CodeBlockCopyButton value={CODE} />
|
|
56
|
+
</CodeBlockActions>
|
|
57
|
+
</CodeBlockHeader>
|
|
58
|
+
<CodeBlockContent lineNumbers startLine={FIRST_LINE}>
|
|
59
|
+
<CodeBlockHighlightedLines code={CODE} language={findCodeLanguage(PATH)} />
|
|
60
|
+
</CodeBlockContent>
|
|
61
|
+
</CodeBlock>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- The header is at least 32px, under a line rule; its title takes a 14px icon, and a long name truncates in a span with `truncate` (as ToolResult's file header has it).
|
|
67
|
+
- The header's buttons stay hidden until the block is hovered or focused, and always show on touch.
|
|
68
|
+
- `startLine` numbers a part of a file from where it starts (a Read from line 40).
|
|
69
|
+
- **CodeBlockHighlightedLines** colours the code with prism-react-renderer and `SYNTAX_THEME` (One Light and One Dark, darkened where needed to reach 4.5:1 contrast) on the `syntax-*` tokens; `findCodeLanguage` from `@major-tech/ui/lib/code-language` reads the language off a path.
|
|
70
|
+
- Plain CodeBlockLines are for text that isn't code in a language: terminal output, an error.
|
|
71
|
+
|
|
72
|
+
### Highlighted code
|
|
73
|
+
|
|
74
|
+
`HighlightedCodeBlock` is the block with no header: code in its language, for what a request will run or a snippet in a page.
|
|
75
|
+
|
|
76
|
+
Example: `highlighted`
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
"use client";
|
|
80
|
+
|
|
81
|
+
import { CODE_BLOCK_SIZES, HighlightedCodeBlock } from "@major-tech/ui/code-block";
|
|
82
|
+
|
|
83
|
+
const QUERY = `-- Open deals over $10k, newest first
|
|
84
|
+
SELECT name, amount, stage
|
|
85
|
+
FROM deals
|
|
86
|
+
WHERE stage = 'open' AND amount > 10000
|
|
87
|
+
ORDER BY created_at DESC
|
|
88
|
+
LIMIT 20;`;
|
|
89
|
+
|
|
90
|
+
export default function CodeBlockHighlighted() {
|
|
91
|
+
return (
|
|
92
|
+
<HighlightedCodeBlock size={CODE_BLOCK_SIZES.SM} wrap code={QUERY} language="sql" className="max-h-48 max-w-120" />
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- Its language is TypeScript unless you say otherwise, as in the web.
|
|
98
|
+
- Prism's bundled languages take colours: TypeScript, TSX, JavaScript, JSON, YAML, Markdown, Python, SQL, GraphQL, CSS, Go, Rust, Swift, Kotlin and a few more. Any other (bash, Ruby) reads as plain text.
|
|
99
|
+
- A diff in colour is `CodeBlockHighlightedLines` with the removed or added variant, one part after the other.
|
|
100
|
+
|
|
101
|
+
### Sizes
|
|
102
|
+
|
|
103
|
+
default (13px `text-code`) on pages: an agent's code, a config file. sm (12.5px `text-code-small`) in the chat: tool calls, diffs, terminal output.
|
|
104
|
+
|
|
105
|
+
Example: `sizes`
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { CodeBlock, CodeBlockContent, CodeBlockLine } from "@major-tech/ui/code-block";
|
|
109
|
+
|
|
110
|
+
const CODE = `{
|
|
111
|
+
"name": "Daily Joke",
|
|
112
|
+
"model": "sonnet"
|
|
113
|
+
}`;
|
|
114
|
+
|
|
115
|
+
const SIZES = [
|
|
116
|
+
{ size: "default", label: "default · 13px, pages" },
|
|
117
|
+
{ size: "sm", label: "sm · 12.5px, the chat" },
|
|
118
|
+
] as const;
|
|
119
|
+
|
|
120
|
+
export default function CodeBlockSizes() {
|
|
121
|
+
return (
|
|
122
|
+
<div className="flex w-full max-w-136 flex-col gap-space-12">
|
|
123
|
+
{SIZES.map(({ size, label }) => (
|
|
124
|
+
<div key={size} className="flex flex-col gap-space-6">
|
|
125
|
+
<span className="text-small text-muted">{label}</span>
|
|
126
|
+
<CodeBlock size={size}>
|
|
127
|
+
<CodeBlockContent>
|
|
128
|
+
{CODE.split("\n").map((line, index) => (
|
|
129
|
+
<CodeBlockLine key={index}>{line}</CodeBlockLine>
|
|
130
|
+
))}
|
|
131
|
+
</CodeBlockContent>
|
|
132
|
+
</CodeBlock>
|
|
133
|
+
</div>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Diff and highlighted lines
|
|
141
|
+
|
|
142
|
+
A line's variant: added in `success-soft` with a + in the gutter, removed in `danger-soft` with a −, highlighted in `hover` for a line to find (a search match, the line an error points at).
|
|
143
|
+
|
|
144
|
+
Example: `lines`
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
"use client";
|
|
148
|
+
|
|
149
|
+
import {
|
|
150
|
+
CODE_BLOCK_LINE_VARIANTS,
|
|
151
|
+
CODE_BLOCK_SIZES,
|
|
152
|
+
CodeBlock,
|
|
153
|
+
CodeBlockContent,
|
|
154
|
+
CodeBlockLine,
|
|
155
|
+
} from "@major-tech/ui/code-block";
|
|
156
|
+
|
|
157
|
+
export default function CodeBlockLines() {
|
|
158
|
+
return (
|
|
159
|
+
<div className="flex w-full max-w-136 flex-col gap-space-12">
|
|
160
|
+
<CodeBlock size={CODE_BLOCK_SIZES.SM}>
|
|
161
|
+
<CodeBlockContent>
|
|
162
|
+
<CodeBlockLine>{"{"}</CodeBlockLine>
|
|
163
|
+
<CodeBlockLine>{' "name": "Daily Joke",'}</CodeBlockLine>
|
|
164
|
+
<CodeBlockLine variant={CODE_BLOCK_LINE_VARIANTS.REMOVED}>{' "model": "haiku"'}</CodeBlockLine>
|
|
165
|
+
<CodeBlockLine variant={CODE_BLOCK_LINE_VARIANTS.ADDED}>{' "model": "sonnet"'}</CodeBlockLine>
|
|
166
|
+
<CodeBlockLine>{"}"}</CodeBlockLine>
|
|
167
|
+
</CodeBlockContent>
|
|
168
|
+
</CodeBlock>
|
|
169
|
+
<CodeBlock size={CODE_BLOCK_SIZES.SM}>
|
|
170
|
+
<CodeBlockContent lineNumbers startLine={12}>
|
|
171
|
+
<CodeBlockLine>{"const joke = await fetchJoke();"}</CodeBlockLine>
|
|
172
|
+
<CodeBlockLine variant={CODE_BLOCK_LINE_VARIANTS.HIGHLIGHTED}>{"await slack.post(joke.text);"}</CodeBlockLine>
|
|
173
|
+
<CodeBlockLine>{"return joke;"}</CodeBlockLine>
|
|
174
|
+
</CodeBlockContent>
|
|
175
|
+
</CodeBlock>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- Every line spans the block's full width, so a diff's tint reaches both edges.
|
|
182
|
+
- The + and − sit in the gutter and aren't copied with the text.
|
|
183
|
+
|
|
184
|
+
### A failed call
|
|
185
|
+
|
|
186
|
+
destructive turns the border and text danger. A `CodeBlockFooter` under the code says how it ended: an exit code, a note.
|
|
187
|
+
|
|
188
|
+
Example: `failed`
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
"use client";
|
|
192
|
+
|
|
193
|
+
import {
|
|
194
|
+
CODE_BLOCK_SIZES,
|
|
195
|
+
CODE_BLOCK_VARIANTS,
|
|
196
|
+
CodeBlock,
|
|
197
|
+
CodeBlockContent,
|
|
198
|
+
CodeBlockFooter,
|
|
199
|
+
CodeBlockHeader,
|
|
200
|
+
CodeBlockLine,
|
|
201
|
+
CodeBlockTitle,
|
|
202
|
+
} from "@major-tech/ui/code-block";
|
|
203
|
+
import { SquareTerminal } from "lucide-react";
|
|
204
|
+
|
|
205
|
+
export default function CodeBlockFailed() {
|
|
206
|
+
return (
|
|
207
|
+
<CodeBlock size={CODE_BLOCK_SIZES.SM} variant={CODE_BLOCK_VARIANTS.DESTRUCTIVE} className="max-w-136">
|
|
208
|
+
<CodeBlockHeader>
|
|
209
|
+
<CodeBlockTitle>
|
|
210
|
+
<SquareTerminal />
|
|
211
|
+
Terminal
|
|
212
|
+
</CodeBlockTitle>
|
|
213
|
+
</CodeBlockHeader>
|
|
214
|
+
<CodeBlockContent wrap>
|
|
215
|
+
<CodeBlockLine>$ pnpm test</CodeBlockLine>
|
|
216
|
+
<CodeBlockLine>FAIL src/lib/format-joke.test.ts</CodeBlockLine>
|
|
217
|
+
<CodeBlockLine>Expected one line, received two.</CodeBlockLine>
|
|
218
|
+
</CodeBlockContent>
|
|
219
|
+
<CodeBlockFooter className="text-danger">exit code 1</CodeBlockFooter>
|
|
220
|
+
</CodeBlock>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Wrap or scroll
|
|
226
|
+
|
|
227
|
+
Long lines scroll sideways by default; wrap breaks them instead. Cap the height with `max-h-*` and the code scrolls inside the block.
|
|
228
|
+
|
|
229
|
+
Example: `wrap`
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
"use client";
|
|
233
|
+
|
|
234
|
+
import { CODE_BLOCK_SIZES, CodeBlock, CodeBlockContent, CodeBlockLine } from "@major-tech/ui/code-block";
|
|
235
|
+
|
|
236
|
+
const LINES = [
|
|
237
|
+
"curl -s https://api.example.com/v1/jokes?category=programming&safe=true&limit=1 -H 'Accept: application/json'",
|
|
238
|
+
'{"id":"j_8121","setup":"Why do programmers prefer dark mode?","punchline":"Because light attracts bugs."}',
|
|
239
|
+
"Fetched 1 joke in 182ms",
|
|
240
|
+
"Posting to #random",
|
|
241
|
+
"Posted",
|
|
242
|
+
"Done",
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
const MODES = [
|
|
246
|
+
{ isWrapped: false, label: "Scrolls sideways (the default)" },
|
|
247
|
+
{ isWrapped: true, label: "wrap" },
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
export default function CodeBlockWrap() {
|
|
251
|
+
return (
|
|
252
|
+
<div className="flex w-full max-w-105 flex-col gap-space-12">
|
|
253
|
+
{MODES.map(({ isWrapped, label }) => (
|
|
254
|
+
<div key={label} className="flex flex-col gap-space-6">
|
|
255
|
+
<span className="text-small text-muted">{label}</span>
|
|
256
|
+
<CodeBlock size={CODE_BLOCK_SIZES.SM}>
|
|
257
|
+
<CodeBlockContent wrap={isWrapped} className="max-h-28">
|
|
258
|
+
{LINES.map((line, index) => (
|
|
259
|
+
<CodeBlockLine key={index}>{line}</CodeBlockLine>
|
|
260
|
+
))}
|
|
261
|
+
</CodeBlockContent>
|
|
262
|
+
</CodeBlock>
|
|
263
|
+
</div>
|
|
264
|
+
))}
|
|
265
|
+
</div>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
- Terminal output and errors wrap: they're prose more than code.
|
|
271
|
+
- Files and diffs scroll, with a wrap toggle in the header (ToolResult has one).
|
|
272
|
+
|
|
273
|
+
### Guidelines
|
|
274
|
+
|
|
275
|
+
Do:
|
|
276
|
+
|
|
277
|
+
- Use sm in the chat and default on pages.
|
|
278
|
+
- Name the file in the header when the code comes from one.
|
|
279
|
+
- Cap long code with `max-h-*` so it never pushes the conversation away.
|
|
280
|
+
- Highlight code in its language; leave output and errors plain.
|
|
281
|
+
|
|
282
|
+
Don't:
|
|
283
|
+
|
|
284
|
+
- Colour code with status or object tokens: syntax colours are the `syntax-*` tokens, through `SYNTAX_THEME`.
|
|
285
|
+
- Put prose in a CodeBlock: a reply's text is a ChatMessage.
|
|
286
|
+
- Confuse it with the docs site's own code block, which shows example sources and is highlighted at build time.
|
|
287
|
+
|
|
288
|
+
## API
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { CodeBlock, CodeBlockHeader, CodeBlockTitle, CodeBlockActions, CodeBlockCopyButton, CodeBlockContent, CodeBlockLine, CodeBlockFooter, CodeBlockHighlightedLines, HighlightedCodeBlock, SYNTAX_THEME, CODE_BLOCK_VARIANTS, CODE_BLOCK_SIZES, CODE_BLOCK_LINE_VARIANTS } from "@major-tech/ui/code-block";
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### `<CodeBlock />`
|
|
295
|
+
|
|
296
|
+
Renders a `<div>`.
|
|
297
|
+
|
|
298
|
+
| Prop | Type | Default | Description |
|
|
299
|
+
| --- | --- | --- | --- |
|
|
300
|
+
| `variant` | `"default" \| "destructive"` | `"default"` | destructive: a failed call. |
|
|
301
|
+
| `size` | `"default" \| "sm"` | `"default"` | 13px on pages; 12.5px in the chat. |
|
|
302
|
+
|
|
303
|
+
### `<CodeBlockHeader /> · <CodeBlockTitle /> · <CodeBlockActions /> · <CodeBlockFooter />`
|
|
304
|
+
|
|
305
|
+
Each renders a `<div>`.
|
|
306
|
+
|
|
307
|
+
| Prop | Type | Default | Description |
|
|
308
|
+
| --- | --- | --- | --- |
|
|
309
|
+
| `CodeBlockHeader` | `ReactNode` | — | The row above the code: a title and actions. |
|
|
310
|
+
| `CodeBlockTitle` | `ReactNode` | — | The file's name after an optional 14px icon; truncates. |
|
|
311
|
+
| `CodeBlockActions` | `ReactNode` | — | The header's buttons, at its right edge; shown on hover and focus. |
|
|
312
|
+
| `CodeBlockFooter` | `ReactNode` | — | 12px muted line under the code: “exit code 1”. |
|
|
313
|
+
|
|
314
|
+
### `<CodeBlockCopyButton />`
|
|
315
|
+
|
|
316
|
+
A 24px ghost icon Button.
|
|
317
|
+
|
|
318
|
+
| Prop | Type | Default | Description |
|
|
319
|
+
| --- | --- | --- | --- |
|
|
320
|
+
| `value`* | `string` | — | The text it copies. It shows a check for 2s. |
|
|
321
|
+
|
|
322
|
+
`*` marks a required prop.
|
|
323
|
+
|
|
324
|
+
### `<CodeBlockContent />`
|
|
325
|
+
|
|
326
|
+
Renders a focusable `<pre>`; its children are CodeBlockLines.
|
|
327
|
+
|
|
328
|
+
| Prop | Type | Default | Description |
|
|
329
|
+
| --- | --- | --- | --- |
|
|
330
|
+
| `wrap` | `boolean` | `false` | Wrap long lines instead of scrolling sideways. |
|
|
331
|
+
| `lineNumbers` | `boolean` | `false` | Number the lines in a faint gutter. |
|
|
332
|
+
| `startLine` | `number` | `1` | The first line's number. |
|
|
333
|
+
|
|
334
|
+
### `<CodeBlockLine />`
|
|
335
|
+
|
|
336
|
+
Renders a `<span>`.
|
|
337
|
+
|
|
338
|
+
| Prop | Type | Default | Description |
|
|
339
|
+
| --- | --- | --- | --- |
|
|
340
|
+
| `variant` | `"default" \| "added" \| "removed" \| "highlighted"` | `"default"` | A diff's added or removed line, or a line to find. |
|
|
341
|
+
|
|
342
|
+
### `<CodeBlockHighlightedLines />`
|
|
343
|
+
|
|
344
|
+
Renders CodeBlockLines, inside a `CodeBlockContent`.
|
|
345
|
+
|
|
346
|
+
| Prop | Type | Default | Description |
|
|
347
|
+
| --- | --- | --- | --- |
|
|
348
|
+
| `code`* | `string` | — | The code; a trailing newline adds no line. |
|
|
349
|
+
| `language` | `string` | `"text"` | A Prism language: “typescript”, “sql”, “json”. Plain text by default. |
|
|
350
|
+
| `variant` | `"default" \| "added" \| "removed" \| "highlighted"` | — | Every line's variant: a diff's removed or added side. |
|
|
351
|
+
|
|
352
|
+
`*` marks a required prop.
|
|
353
|
+
|
|
354
|
+
### `<HighlightedCodeBlock />`
|
|
355
|
+
|
|
356
|
+
A CodeBlock (`size`, `className`…) with no header.
|
|
357
|
+
|
|
358
|
+
| Prop | Type | Default | Description |
|
|
359
|
+
| --- | --- | --- | --- |
|
|
360
|
+
| `code`* | `string` | — | The code; the blank lines around it are dropped, its indentation kept. |
|
|
361
|
+
| `language` | `string` | `"typescript"` | A Prism language. |
|
|
362
|
+
| `wrap` | `boolean` | `false` | Wrap long lines instead of scrolling sideways. |
|
|
363
|
+
| `lineNumbers` | `boolean` | `false` | Number the lines. |
|
|
364
|
+
| `startLine` | `number` | `1` | The first line's number. |
|
|
365
|
+
|
|
366
|
+
`*` marks a required prop.
|
|
367
|
+
|
|
368
|
+
### `SYNTAX_THEME · findCodeLanguage`
|
|
369
|
+
|
|
370
|
+
| Prop | Type | Default | Description |
|
|
371
|
+
| --- | --- | --- | --- |
|
|
372
|
+
| `SYNTAX_THEME` | `PrismTheme` | — | The `syntax-*` tokens as a prism-react-renderer theme, for a Highlight of your own. |
|
|
373
|
+
| `findCodeLanguage(path)` | `string` | — | From `@major-tech/ui/lib/code-language`: the language of a file by its extension (“src/post.ts” → “typescript”), or “text”. |
|
|
374
|
+
|
|
375
|
+
### `CODE_BLOCK_VARIANTS · CODE_BLOCK_SIZES · CODE_BLOCK_LINE_VARIANTS`
|
|
376
|
+
|
|
377
|
+
| Prop | Type | Default | Description |
|
|
378
|
+
| --- | --- | --- | --- |
|
|
379
|
+
| `CODE_BLOCK_VARIANTS` | `DEFAULT · DESTRUCTIVE` | — | The block's variants. |
|
|
380
|
+
| `CODE_BLOCK_SIZES` | `DEFAULT · SM` | — | The block's sizes. |
|
|
381
|
+
| `CODE_BLOCK_LINE_VARIANTS` | `DEFAULT · ADDED · REMOVED · HIGHLIGHTED` | — | The line variants. |
|
|
382
|
+
|
|
383
|
+
### Accessibility
|
|
384
|
+
|
|
385
|
+
- The code is focusable, so it scrolls from the keyboard, with a faint focus ring.
|
|
386
|
+
- The copy button is named Copy and announces Copied in a polite live region. Outside a secure context, where the browser has no clipboard, it does nothing.
|
|
387
|
+
- Line numbers and the + and − are not selected with the code.
|
|
388
|
+
- An empty line keeps a newline, so a copied selection keeps blank lines.
|
|
389
|
+
- Syntax colours never carry meaning on their own; comments are also set in italics.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Collapsible
|
|
3
|
+
slug: collapsible
|
|
4
|
+
description: "A single region that shows and hides. Unstyled: the caller draws the trigger and the region."
|
|
5
|
+
group: Layout
|
|
6
|
+
layer: primitive
|
|
7
|
+
status: stable
|
|
8
|
+
since: 0.3.0
|
|
9
|
+
primitive: Collapsible
|
|
10
|
+
import: import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@major-tech/ui/collapsible";
|
|
11
|
+
source: packages/ui/src/components/collapsible.tsx
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Collapsible
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### A region that shows and hides
|
|
19
|
+
|
|
20
|
+
Unstyled: the trigger and the region are yours. It is the base of a diff's file blocks and of the agent's collapsible trace lines.
|
|
21
|
+
|
|
22
|
+
Example: `files`
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@major-tech/ui/collapsible";
|
|
26
|
+
import { ChevronRight } from "lucide-react";
|
|
27
|
+
|
|
28
|
+
const CHANGED_FILES = ["src/app/page.tsx", "src/lib/leads.ts", "src/components/lead-table.tsx"];
|
|
29
|
+
|
|
30
|
+
export default function CollapsibleFiles() {
|
|
31
|
+
return (
|
|
32
|
+
<Collapsible className="w-90 max-w-full overflow-hidden rounded-xl border border-panel-edge bg-surface shadow-card">
|
|
33
|
+
<CollapsibleTrigger
|
|
34
|
+
render={
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
className="group flex w-full cursor-pointer items-center gap-space-8 px-space-14 py-space-10 text-left font-sans text-ui-strong text-ink outline-none hover:bg-hover focus-visible:ring-2 focus-visible:ring-faint focus-visible:ring-inset"
|
|
38
|
+
/>
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
<ChevronRight className="size-3.5 text-muted transition-transform duration-150 group-data-panel-open:rotate-90" />
|
|
42
|
+
{CHANGED_FILES.length} files changed
|
|
43
|
+
<span className="ml-auto text-small font-normal text-muted">+24 −6</span>
|
|
44
|
+
</CollapsibleTrigger>
|
|
45
|
+
<CollapsibleContent className="overflow-hidden data-open:animate-collapsible-open data-closed:animate-collapsible-close">
|
|
46
|
+
<ul className="m-0 flex list-none flex-col border-t border-line p-0">
|
|
47
|
+
{CHANGED_FILES.map((file) => (
|
|
48
|
+
<li key={file} className="px-space-14 py-space-8 font-mono text-code-small text-ink-2">
|
|
49
|
+
{file}
|
|
50
|
+
</li>
|
|
51
|
+
))}
|
|
52
|
+
</ul>
|
|
53
|
+
</CollapsibleContent>
|
|
54
|
+
</Collapsible>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Guidelines
|
|
60
|
+
|
|
61
|
+
- Animate the height with `animate-collapsible-open` and `animate-collapsible-close` (200 / 150ms) on CollapsibleContent, keyed on `data-open` and `data-closed`, with `overflow-hidden`.
|
|
62
|
+
- Turn a chevron off the trigger's `data-panel-open`: `group-data-panel-open:rotate-90`, in 150ms.
|
|
63
|
+
|
|
64
|
+
Do:
|
|
65
|
+
|
|
66
|
+
- One region that shows and hides: a file's diff, a step's details.
|
|
67
|
+
- A real button as the trigger.
|
|
68
|
+
|
|
69
|
+
Don't:
|
|
70
|
+
|
|
71
|
+
- Stacked sections, or an Advanced settings toggle: use Accordion, which brings the styles.
|
|
72
|
+
- Hiding content the person needs to finish a task.
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@major-tech/ui/collapsible";
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Parts
|
|
81
|
+
|
|
82
|
+
Each part takes the props of its Base UI Collapsible counterpart.
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `Collapsible` | `Root` | — | `open` / `defaultOpen` / `onOpenChange` / `disabled`. |
|
|
87
|
+
| `CollapsibleTrigger` | `—` | — | A `<button>`; pass another element as `render`. Carries `data-panel-open` while open. |
|
|
88
|
+
| `CollapsibleContent` | `—` | — | The region. `keepMounted` keeps it in the DOM while closed. |
|
|
89
|
+
|
|
90
|
+
### Accessibility
|
|
91
|
+
|
|
92
|
+
- The trigger carries `aria-expanded` and `aria-controls` (Base UI).
|
|
93
|
+
- Enter and Space toggle the region.
|