@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,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Plus, X } from "lucide-react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
6
|
+
/** What a chip stands for, which fixes its colours. Without a kind it is neutral: a file, an attachment. */
|
|
7
|
+
export const CHIP_KINDS = {
|
|
8
|
+
/** What uses a skill: neutral, with its icon. */
|
|
9
|
+
AGENT: "agent",
|
|
10
|
+
CONNECTOR: "connector",
|
|
11
|
+
APPLICATION: "application",
|
|
12
|
+
/** A workflow an agent can start: neutral, with its icon. */
|
|
13
|
+
WORKFLOW: "workflow",
|
|
14
|
+
SKILL: "skill",
|
|
15
|
+
VARIABLE: "variable",
|
|
16
|
+
/** What the person points at for the agent: an element picked with Click and ask, or a node on a workflow canvas. */
|
|
17
|
+
ELEMENT: "element",
|
|
18
|
+
};
|
|
19
|
+
/** Whether what the chip stands for can work. What makes it `warn` is the product's call: not attached, not connected. */
|
|
20
|
+
export const CHIP_STATES = {
|
|
21
|
+
OK: "ok",
|
|
22
|
+
/** Can't work yet: `warn` on `warn-soft`. */
|
|
23
|
+
WARN: "warn",
|
|
24
|
+
/** No longer in the organization: faint and struck through. */
|
|
25
|
+
MISSING: "missing",
|
|
26
|
+
};
|
|
27
|
+
// Neutral chips keep their icon muted, so the name leads.
|
|
28
|
+
const NEUTRAL_CLASSES = "bg-chip text-ink [&_svg]:text-ink-2";
|
|
29
|
+
// On its own, an icon's chip starts closer to it.
|
|
30
|
+
const KIND_CLASSES = {
|
|
31
|
+
[CHIP_KINDS.AGENT]: cn(NEUTRAL_CLASSES, "pl-space-4"),
|
|
32
|
+
[CHIP_KINDS.CONNECTOR]: "bg-chip text-ink pl-space-4",
|
|
33
|
+
[CHIP_KINDS.APPLICATION]: "bg-object-green-soft text-object-green",
|
|
34
|
+
[CHIP_KINDS.WORKFLOW]: cn(NEUTRAL_CLASSES, "pl-space-4"),
|
|
35
|
+
[CHIP_KINDS.SKILL]: "bg-object-purple-soft text-object-purple",
|
|
36
|
+
[CHIP_KINDS.VARIABLE]: "bg-object-blue-soft text-object-blue font-mono",
|
|
37
|
+
[CHIP_KINDS.ELEMENT]: "bg-selection-soft text-selection",
|
|
38
|
+
};
|
|
39
|
+
const INLINE_KIND_CLASSES = {
|
|
40
|
+
[CHIP_KINDS.AGENT]: NEUTRAL_CLASSES,
|
|
41
|
+
[CHIP_KINDS.CONNECTOR]: "bg-chip text-ink",
|
|
42
|
+
[CHIP_KINDS.APPLICATION]: "bg-object-green-soft text-object-green",
|
|
43
|
+
[CHIP_KINDS.WORKFLOW]: NEUTRAL_CLASSES,
|
|
44
|
+
[CHIP_KINDS.SKILL]: "bg-object-purple-soft text-object-purple",
|
|
45
|
+
[CHIP_KINDS.VARIABLE]: "bg-object-blue-soft pl-1.25 font-mono text-[0.84em] text-object-blue",
|
|
46
|
+
[CHIP_KINDS.ELEMENT]: "bg-selection-soft text-selection",
|
|
47
|
+
};
|
|
48
|
+
// `warn` and `missing` replace the kind's colours.
|
|
49
|
+
const STATE_CLASSES = {
|
|
50
|
+
[CHIP_STATES.OK]: "",
|
|
51
|
+
[CHIP_STATES.WARN]: "bg-warn-soft text-warn [&_svg]:text-warn",
|
|
52
|
+
[CHIP_STATES.MISSING]: "bg-transparent text-faint line-through",
|
|
53
|
+
};
|
|
54
|
+
/** A chip nothing opens: no pointer and no hover, like a label. */
|
|
55
|
+
const STATIC_CHIP_CLASSES = "cursor-default hover:brightness-100";
|
|
56
|
+
// The chip's ✕: quiet until hovered, with a 24px hit area around its 14px square. Its mousedown is kept from an
|
|
57
|
+
// editor around the chip, which would otherwise select the chip before the click lands.
|
|
58
|
+
function ChipRemoveButton({ onRemove, isRemoveDisabled, removeLabel = "Remove", className }) {
|
|
59
|
+
const handleMouseDown = (event) => event.preventDefault();
|
|
60
|
+
return (_jsx("button", { type: "button", "aria-label": removeLabel, disabled: isRemoveDisabled, onMouseDown: handleMouseDown, onClick: onRemove, className: cn("relative inline-grid size-3.5 shrink-0 cursor-pointer place-items-center rounded-[0.1875rem] opacity-50 outline-none transition-[opacity,background-color] duration-120 after:absolute after:-inset-1.25 after:content-['']", "hover:bg-current/12 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-current disabled:pointer-events-none disabled:opacity-25", className), children: _jsx(X, { className: "size-2.5!", strokeWidth: 2 }) }));
|
|
61
|
+
}
|
|
62
|
+
// The 6px dot in the chip's colour, in a 12px hover target: its text is the tooltip, and is read after the name.
|
|
63
|
+
function ChipDot({ label, className }) {
|
|
64
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx("span", { "aria-hidden": "true", "data-slot": "chip-dot", className: cn("inline-grid size-3 shrink-0 place-items-center no-underline", className) }), children: _jsx("span", { className: "size-1.5 rounded-full bg-current" }) }), _jsx(TooltipContent, { className: "max-w-xs whitespace-pre-wrap", children: label })] }), _jsxs("span", { className: "sr-only", children: [", ", label] })] }));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Something a person or an agent works with, as a chip: a connector, app, agent, workflow, skill or variable, a file, a
|
|
68
|
+
* picked element. The same chip in the Details panel, the Composer, a sent message and an agent's instructions. A
|
|
69
|
+
* button when something handles its click (its details popover's trigger, or `onClick`); otherwise a static chip, so
|
|
70
|
+
* it isn't a tab stop that does nothing.
|
|
71
|
+
*/
|
|
72
|
+
export function Chip({ kind, inline = false, icon, note, state = CHIP_STATES.OK, dot, onRemove, isRemoveDisabled, removeLabel, disabled, className, children, ...props }) {
|
|
73
|
+
// A trigger passes its onClick in through `render`; with none, nothing would happen on a click.
|
|
74
|
+
const isStatic = props.onClick === undefined;
|
|
75
|
+
const staticProps = props;
|
|
76
|
+
const kindClasses = inline ? INLINE_KIND_CLASSES : KIND_CLASSES;
|
|
77
|
+
const chipClassName = cn(
|
|
78
|
+
// Positioned, so the dot's screen-reader text stays inside the chip rather than stretching a scrolling ancestor.
|
|
79
|
+
"relative cursor-pointer border-0 font-sans font-medium outline-none transition-[filter] duration-120", "hover:brightness-96 focus-visible:ring-2 focus-visible:ring-faint disabled:cursor-default disabled:hover:brightness-100", inline
|
|
80
|
+
? // Shorter than the line it sits in, so chips on wrapped lines keep a gap between them.
|
|
81
|
+
"mx-px inline-block rounded-sm py-px pr-1.25 pl-0.75 text-[0.9em] leading-4 whitespace-nowrap"
|
|
82
|
+
: "inline-flex h-5.5 max-w-full items-center gap-1.25 rounded-segment px-1.75 text-small [&_img]:size-3.5 [&_img]:shrink-0 [&_img]:rounded-[0.1875rem] [&_svg]:size-3.5 [&_svg]:shrink-0", kind === undefined ? NEUTRAL_CLASSES : kindClasses[kind], STATE_CLASSES[state], isStatic && STATIC_CHIP_CLASSES, className);
|
|
83
|
+
const content = inline ? (_jsxs(_Fragment, { children: [icon && (_jsx("span", { className: "relative -top-px mr-1 inline-block size-3.5 overflow-hidden rounded-[0.1875rem] align-middle [&_svg]:size-full", children: icon })), children, note && _jsx("span", { className: "ml-1 font-normal", children: note }), dot && _jsx(ChipDot, { label: dot, className: "ml-0.75 align-[-0.125rem]" })] })) : (_jsxs(_Fragment, { children: [icon, _jsx("span", { className: "truncate", children: children }), note && (
|
|
84
|
+
// The way out keeps its width; where a picked element is gives way before its name.
|
|
85
|
+
_jsx("span", { className: cn("font-normal", kind === CHIP_KINDS.ELEMENT ? "min-w-0 truncate" : "shrink-0"), children: note })), dot && _jsx(ChipDot, { label: dot, className: "-mx-0.5" })] }));
|
|
86
|
+
if (!onRemove) {
|
|
87
|
+
return isStatic ? (_jsx("span", { "data-slot": "chip", className: chipClassName, ...staticProps, children: content })) : (_jsx("button", { type: "button", "data-slot": "chip", disabled: disabled, className: chipClassName, ...props, children: content }));
|
|
88
|
+
}
|
|
89
|
+
const partClassName = inline ? undefined : "inline-flex min-w-0 items-center gap-1.25";
|
|
90
|
+
return (_jsxs("span", { "data-slot": "chip", className: cn(chipClassName, inline ? "pr-0.5" : "gap-0.5 pr-0.75", "has-focus-visible:ring-2 has-focus-visible:ring-faint"), children: [isStatic ? (_jsx("span", { className: partClassName, ...staticProps, children: content })) : (_jsx("button", { type: "button", disabled: disabled, className: cn("cursor-pointer outline-none disabled:cursor-default", partClassName), ...props, children: content })), _jsx(ChipRemoveButton, { onRemove: onRemove, isRemoveDisabled: isRemoveDisabled, removeLabel: removeLabel, className: inline ? "relative -top-px ml-0.5 align-middle" : undefined })] }));
|
|
91
|
+
}
|
|
92
|
+
/** The "+" after a group's chips. Usually the trigger of a picker (a DropdownMenu or Popover). */
|
|
93
|
+
export function ChipAdd({ isLabelVisible = false, className, ...props }) {
|
|
94
|
+
return (_jsxs("button", { type: "button", "data-slot": "chip-add", className: cn("inline-flex h-5.5 cursor-pointer items-center gap-1 rounded-segment px-1.25 font-sans text-small text-faint outline-none transition-colors duration-120", "hover:bg-hover hover:text-muted focus-visible:ring-2 focus-visible:ring-faint disabled:pointer-events-none disabled:opacity-50", "aria-expanded:bg-hover aria-expanded:text-muted [&_svg]:size-3.5", className), ...props, children: [_jsx(Plus, {}), isLabelVisible && "Add"] }));
|
|
95
|
+
}
|
|
96
|
+
/** A label + values pair in the Details panel: 12px faint label over a wrapping row of chips. */
|
|
97
|
+
export function DetailsGroup({ label, actions, children }) {
|
|
98
|
+
return (_jsxs("div", { "data-slot": "details-group", className: "flex flex-col", children: [_jsxs("div", { className: "flex min-h-3.5 items-center justify-between gap-space-8 text-small leading-3.5 text-faint", children: [_jsx("span", { children: label }), actions] }), _jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-space-4 pt-0.75 pb-space-12 text-ui text-ink", children: children })] }));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../src/components/chip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,O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,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,SAAS,GACtE,IACG,CACR,CAAC;AACJ,CAAC;AAOD,kGAAkG;AAClG,MAAM,UAAU,OAAO,CAAC,EAAE,cAAc,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgB;IACnF,OAAO,CACL,kBACE,IAAI,EAAC,QAAQ,eACH,UAAU,EACpB,SAAS,EAAE,EAAE,CACX,yJAAyJ,EACzJ,gIAAgI,EAChI,kEAAkE,EAClE,SAAS,CACV,KACG,KAAK,aAET,KAAC,IAAI,KAAG,EACP,cAAc,IAAI,KAAK,IACjB,CACV,CAAC;AACJ,CAAC;AASD,iGAAiG;AACjG,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAqB;IAC1E,OAAO,CACL,4BAAe,eAAe,EAAC,SAAS,EAAC,eAAe,aACtD,eAAK,SAAS,EAAC,2FAA2F,aACxG,yBAAO,KAAK,GAAQ,EACnB,OAAO,IACJ,EACN,cAAK,SAAS,EAAC,sFAAsF,YAClG,QAAQ,GACL,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport type { ComponentProps, MouseEvent, ReactNode } from \"react\";\nimport { Plus, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./tooltip.tsx\";\n\n/** What a chip stands for, which fixes its colours. Without a kind it is neutral: a file, an attachment. */\nexport const CHIP_KINDS = {\n /** What uses a skill: neutral, with its icon. */\n AGENT: \"agent\",\n CONNECTOR: \"connector\",\n APPLICATION: \"application\",\n /** A workflow an agent can start: neutral, with its icon. */\n WORKFLOW: \"workflow\",\n SKILL: \"skill\",\n VARIABLE: \"variable\",\n /** What the person points at for the agent: an element picked with Click and ask, or a node on a workflow canvas. */\n ELEMENT: \"element\",\n} as const;\n\nexport type ChipKind = (typeof CHIP_KINDS)[keyof typeof CHIP_KINDS];\n\n/** Whether what the chip stands for can work. What makes it `warn` is the product's call: not attached, not connected. */\nexport const CHIP_STATES = {\n OK: \"ok\",\n /** Can't work yet: `warn` on `warn-soft`. */\n WARN: \"warn\",\n /** No longer in the organization: faint and struck through. */\n MISSING: \"missing\",\n} as const;\n\nexport type ChipState = (typeof CHIP_STATES)[keyof typeof CHIP_STATES];\n\n// Neutral chips keep their icon muted, so the name leads.\nconst NEUTRAL_CLASSES = \"bg-chip text-ink [&_svg]:text-ink-2\";\n\n// On its own, an icon's chip starts closer to it.\nconst KIND_CLASSES = {\n [CHIP_KINDS.AGENT]: cn(NEUTRAL_CLASSES, \"pl-space-4\"),\n [CHIP_KINDS.CONNECTOR]: \"bg-chip text-ink pl-space-4\",\n [CHIP_KINDS.APPLICATION]: \"bg-object-green-soft text-object-green\",\n [CHIP_KINDS.WORKFLOW]: cn(NEUTRAL_CLASSES, \"pl-space-4\"),\n [CHIP_KINDS.SKILL]: \"bg-object-purple-soft text-object-purple\",\n [CHIP_KINDS.VARIABLE]: \"bg-object-blue-soft text-object-blue font-mono\",\n [CHIP_KINDS.ELEMENT]: \"bg-selection-soft text-selection\",\n} satisfies Record<ChipKind, string>;\n\nconst INLINE_KIND_CLASSES = {\n [CHIP_KINDS.AGENT]: NEUTRAL_CLASSES,\n [CHIP_KINDS.CONNECTOR]: \"bg-chip text-ink\",\n [CHIP_KINDS.APPLICATION]: \"bg-object-green-soft text-object-green\",\n [CHIP_KINDS.WORKFLOW]: NEUTRAL_CLASSES,\n [CHIP_KINDS.SKILL]: \"bg-object-purple-soft text-object-purple\",\n [CHIP_KINDS.VARIABLE]: \"bg-object-blue-soft pl-1.25 font-mono text-[0.84em] text-object-blue\",\n [CHIP_KINDS.ELEMENT]: \"bg-selection-soft text-selection\",\n} satisfies Record<ChipKind, string>;\n\n// `warn` and `missing` replace the kind's colours.\nconst STATE_CLASSES = {\n [CHIP_STATES.OK]: \"\",\n [CHIP_STATES.WARN]: \"bg-warn-soft text-warn [&_svg]:text-warn\",\n [CHIP_STATES.MISSING]: \"bg-transparent text-faint line-through\",\n} satisfies Record<ChipState, string>;\n\n/** A chip nothing opens: no pointer and no hover, like a label. */\nconst STATIC_CHIP_CLASSES = \"cursor-default hover:brightness-100\";\n\ninterface ChipRemoveButtonProps {\n onRemove: () => void;\n isRemoveDisabled?: boolean;\n removeLabel?: string;\n className?: string;\n}\n\n// The chip's ✕: quiet until hovered, with a 24px hit area around its 14px square. Its mousedown is kept from an\n// editor around the chip, which would otherwise select the chip before the click lands.\nfunction ChipRemoveButton({ onRemove, isRemoveDisabled, removeLabel = \"Remove\", className }: ChipRemoveButtonProps) {\n const handleMouseDown = (event: MouseEvent) => event.preventDefault();\n\n return (\n <button\n type=\"button\"\n aria-label={removeLabel}\n disabled={isRemoveDisabled}\n onMouseDown={handleMouseDown}\n onClick={onRemove}\n className={cn(\n \"relative inline-grid size-3.5 shrink-0 cursor-pointer place-items-center rounded-[0.1875rem] opacity-50 outline-none transition-[opacity,background-color] duration-120 after:absolute after:-inset-1.25 after:content-['']\",\n \"hover:bg-current/12 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-current disabled:pointer-events-none disabled:opacity-25\",\n className\n )}\n >\n <X className=\"size-2.5!\" strokeWidth={2} />\n </button>\n );\n}\n\n// The 6px dot in the chip's colour, in a 12px hover target: its text is the tooltip, and is read after the name.\nfunction ChipDot({ label, className }: { label: string; className?: string }) {\n return (\n <>\n <Tooltip>\n <TooltipTrigger\n render={\n <span\n aria-hidden=\"true\"\n data-slot=\"chip-dot\"\n className={cn(\"inline-grid size-3 shrink-0 place-items-center no-underline\", className)}\n />\n }\n >\n <span className=\"size-1.5 rounded-full bg-current\" />\n </TooltipTrigger>\n <TooltipContent className=\"max-w-xs whitespace-pre-wrap\">{label}</TooltipContent>\n </Tooltip>\n <span className=\"sr-only\">, {label}</span>\n </>\n );\n}\n\nexport interface ChipProps extends ComponentProps<\"button\"> {\n /** Omitted for what isn't one of an agent's objects (a file, an attachment): neutral. */\n kind?: ChipKind;\n /** Set in a line of text (a mention in instructions, a composer or a message): sized to the text, it wraps with it. */\n inline?: boolean;\n /** A 14px mark before the name: a connector's logo or BrandTile, an app's tiles, a skill's BookOpenText. */\n icon?: ReactNode;\n /** Regular-weight text after the name: the way out (\"Connect\"), or where a picked element is (its text and page). */\n note?: ReactNode;\n /** Default `ok`. `warn` and `missing` replace the kind's colours. */\n state?: ChipState;\n /**\n * A 6px dot after the name for what the colours don't tell: why it can't work (\"Not connected\"), the comment written\n * on a picked element. The text is its tooltip and is read with the name.\n */\n dot?: string;\n /** Adds a small ✕ after the name that calls this: detach the object, delete the mention, drop the pick. */\n onRemove?: () => void;\n isRemoveDisabled?: boolean;\n /** The ✕'s accessible name. Default: \"Remove\". */\n removeLabel?: string;\n}\n\n/**\n * Something a person or an agent works with, as a chip: a connector, app, agent, workflow, skill or variable, a file, a\n * picked element. The same chip in the Details panel, the Composer, a sent message and an agent's instructions. A\n * button when something handles its click (its details popover's trigger, or `onClick`); otherwise a static chip, so\n * it isn't a tab stop that does nothing.\n */\nexport function Chip({\n kind,\n inline = false,\n icon,\n note,\n state = CHIP_STATES.OK,\n dot,\n onRemove,\n isRemoveDisabled,\n removeLabel,\n disabled,\n className,\n children,\n ...props\n}: ChipProps) {\n // A trigger passes its onClick in through `render`; with none, nothing would happen on a click.\n const isStatic = props.onClick === undefined;\n const staticProps = props as ComponentProps<\"span\">;\n const kindClasses = inline ? INLINE_KIND_CLASSES : KIND_CLASSES;\n\n const chipClassName = cn(\n // Positioned, so the dot's screen-reader text stays inside the chip rather than stretching a scrolling ancestor.\n \"relative cursor-pointer border-0 font-sans font-medium outline-none transition-[filter] duration-120\",\n \"hover:brightness-96 focus-visible:ring-2 focus-visible:ring-faint disabled:cursor-default disabled:hover:brightness-100\",\n inline\n ? // Shorter than the line it sits in, so chips on wrapped lines keep a gap between them.\n \"mx-px inline-block rounded-sm py-px pr-1.25 pl-0.75 text-[0.9em] leading-4 whitespace-nowrap\"\n : \"inline-flex h-5.5 max-w-full items-center gap-1.25 rounded-segment px-1.75 text-small [&_img]:size-3.5 [&_img]:shrink-0 [&_img]:rounded-[0.1875rem] [&_svg]:size-3.5 [&_svg]:shrink-0\",\n kind === undefined ? NEUTRAL_CLASSES : kindClasses[kind],\n STATE_CLASSES[state],\n isStatic && STATIC_CHIP_CLASSES,\n className\n );\n\n const content = inline ? (\n <>\n {icon && (\n <span className=\"relative -top-px mr-1 inline-block size-3.5 overflow-hidden rounded-[0.1875rem] align-middle [&_svg]:size-full\">\n {icon}\n </span>\n )}\n {children}\n {note && <span className=\"ml-1 font-normal\">{note}</span>}\n {dot && <ChipDot label={dot} className=\"ml-0.75 align-[-0.125rem]\" />}\n </>\n ) : (\n <>\n {icon}\n <span className=\"truncate\">{children}</span>\n {note && (\n // The way out keeps its width; where a picked element is gives way before its name.\n <span className={cn(\"font-normal\", kind === CHIP_KINDS.ELEMENT ? \"min-w-0 truncate\" : \"shrink-0\")}>{note}</span>\n )}\n {dot && <ChipDot label={dot} className=\"-mx-0.5\" />}\n </>\n );\n\n if (!onRemove) {\n return isStatic ? (\n <span data-slot=\"chip\" className={chipClassName} {...staticProps}>\n {content}\n </span>\n ) : (\n <button type=\"button\" data-slot=\"chip\" disabled={disabled} className={chipClassName} {...props}>\n {content}\n </button>\n );\n }\n\n const partClassName = inline ? undefined : \"inline-flex min-w-0 items-center gap-1.25\";\n\n return (\n <span\n data-slot=\"chip\"\n className={cn(\n chipClassName,\n inline ? \"pr-0.5\" : \"gap-0.5 pr-0.75\",\n \"has-focus-visible:ring-2 has-focus-visible:ring-faint\"\n )}\n >\n {isStatic ? (\n <span className={partClassName} {...staticProps}>\n {content}\n </span>\n ) : (\n <button\n type=\"button\"\n disabled={disabled}\n className={cn(\"cursor-pointer outline-none disabled:cursor-default\", partClassName)}\n {...props}\n >\n {content}\n </button>\n )}\n <ChipRemoveButton\n onRemove={onRemove}\n isRemoveDisabled={isRemoveDisabled}\n removeLabel={removeLabel}\n className={inline ? \"relative -top-px ml-0.5 align-middle\" : undefined}\n />\n </span>\n );\n}\n\nexport interface ChipAddProps extends ComponentProps<\"button\"> {\n /** Also says \"Add\", for a group with nothing in it yet: a lone \"+\" reads as decoration. */\n isLabelVisible?: boolean;\n}\n\n/** The \"+\" after a group's chips. Usually the trigger of a picker (a DropdownMenu or Popover). */\nexport function ChipAdd({ isLabelVisible = false, className, ...props }: ChipAddProps) {\n return (\n <button\n type=\"button\"\n data-slot=\"chip-add\"\n className={cn(\n \"inline-flex h-5.5 cursor-pointer items-center gap-1 rounded-segment px-1.25 font-sans text-small text-faint outline-none transition-colors duration-120\",\n \"hover:bg-hover hover:text-muted focus-visible:ring-2 focus-visible:ring-faint disabled:pointer-events-none disabled:opacity-50\",\n \"aria-expanded:bg-hover aria-expanded:text-muted [&_svg]:size-3.5\",\n className\n )}\n {...props}\n >\n <Plus />\n {isLabelVisible && \"Add\"}\n </button>\n );\n}\n\nexport interface DetailsGroupProps {\n label: ReactNode;\n /** Label row extras on the right (a suggestions chip). */\n actions?: ReactNode;\n children?: ReactNode;\n}\n\n/** A label + values pair in the Details panel: 12px faint label over a wrapping row of chips. */\nexport function DetailsGroup({ label, actions, children }: DetailsGroupProps) {\n return (\n <div data-slot=\"details-group\" className=\"flex flex-col\">\n <div className=\"flex min-h-3.5 items-center justify-between gap-space-8 text-small leading-3.5 text-faint\">\n <span>{label}</span>\n {actions}\n </div>\n <div className=\"flex min-w-0 flex-wrap items-center gap-space-4 pt-0.75 pb-space-12 text-ui text-ink\">\n {children}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
import { type PrismTheme } from "prism-react-renderer";
|
|
3
|
+
import { Button } from "./button.tsx";
|
|
4
|
+
export declare const CODE_BLOCK_VARIANTS: {
|
|
5
|
+
readonly DEFAULT: "default";
|
|
6
|
+
/** A failed call's output: the border and text in danger. */
|
|
7
|
+
readonly DESTRUCTIVE: "destructive";
|
|
8
|
+
};
|
|
9
|
+
export type CodeBlockVariant = (typeof CODE_BLOCK_VARIANTS)[keyof typeof CODE_BLOCK_VARIANTS];
|
|
10
|
+
export declare const CODE_BLOCK_SIZES: {
|
|
11
|
+
/** 13px `text-code`, for pages: an agent's code, a config file. */
|
|
12
|
+
readonly DEFAULT: "default";
|
|
13
|
+
/** 12.5px `text-code-small`, for the chat: tool calls, diffs, terminal output. */
|
|
14
|
+
readonly SM: "sm";
|
|
15
|
+
};
|
|
16
|
+
export type CodeBlockSize = (typeof CODE_BLOCK_SIZES)[keyof typeof CODE_BLOCK_SIZES];
|
|
17
|
+
export declare const CODE_BLOCK_LINE_VARIANTS: {
|
|
18
|
+
readonly DEFAULT: "default";
|
|
19
|
+
/** A diff's added line: `success-soft`, with a + in the gutter. */
|
|
20
|
+
readonly ADDED: "added";
|
|
21
|
+
/** A diff's removed line: `danger-soft`, with a − in the gutter. */
|
|
22
|
+
readonly REMOVED: "removed";
|
|
23
|
+
/** A line to find: a search match, the line an error points at. */
|
|
24
|
+
readonly HIGHLIGHTED: "highlighted";
|
|
25
|
+
};
|
|
26
|
+
export type CodeBlockLineVariant = (typeof CODE_BLOCK_LINE_VARIANTS)[keyof typeof CODE_BLOCK_LINE_VARIANTS];
|
|
27
|
+
/**
|
|
28
|
+
* Prism's colours as the `syntax-*` tokens (One Light / One Dark, darkened where needed to reach 4.5:1 contrast), so highlighting follows the theme
|
|
29
|
+
* wherever code renders. The surface stays the block's.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SYNTAX_THEME: PrismTheme;
|
|
32
|
+
export type CodeBlockProps = ComponentProps<"div"> & {
|
|
33
|
+
variant?: CodeBlockVariant;
|
|
34
|
+
size?: CodeBlockSize;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Code on `code-surface`: an optional CodeBlockHeader (the file's name, actions), the CodeBlockContent with one
|
|
38
|
+
* CodeBlockLine per line (CodeBlockHighlightedLines for syntax colours), and an optional CodeBlockFooter.
|
|
39
|
+
*/
|
|
40
|
+
export declare function CodeBlock({ className, variant, size, ...props }: CodeBlockProps): import("react").JSX.Element;
|
|
41
|
+
/** The row above the code, at least 32px, under a `line` rule: a CodeBlockTitle and CodeBlockActions. */
|
|
42
|
+
export declare function CodeBlockHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
43
|
+
/** The file's name or the block's label in 12px `ink-2`, after an optional 14px icon; it truncates. */
|
|
44
|
+
export declare function CodeBlockTitle({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
45
|
+
/** The header's buttons, at its right edge: hidden until the block is hovered or focused, always shown on touch. */
|
|
46
|
+
export declare function CodeBlockActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
47
|
+
export type CodeBlockCopyButtonProps = Omit<ComponentProps<typeof Button>, "value" | "children"> & {
|
|
48
|
+
/** The text the button copies. */
|
|
49
|
+
value: string;
|
|
50
|
+
};
|
|
51
|
+
/** A 24px ghost icon button named Copy that copies `value`; it shows a check for 2s and announces “Copied”. */
|
|
52
|
+
export declare function CodeBlockCopyButton({ value, className, onClick, ...props }: CodeBlockCopyButtonProps): import("react").JSX.Element;
|
|
53
|
+
export type CodeBlockContentProps = ComponentProps<"pre"> & {
|
|
54
|
+
/** Wrap long lines instead of scrolling sideways. */
|
|
55
|
+
wrap?: boolean;
|
|
56
|
+
/** Number the lines in a `faint` gutter. */
|
|
57
|
+
lineNumbers?: boolean;
|
|
58
|
+
/** The first line's number, for a part of a file. */
|
|
59
|
+
startLine?: number;
|
|
60
|
+
};
|
|
61
|
+
/** The code: a focusable `<pre>` that scrolls (set its height with `max-h-*`). Its children are CodeBlockLines. */
|
|
62
|
+
export declare function CodeBlockContent({ className, children, style, wrap, lineNumbers, startLine, ...props }: CodeBlockContentProps): import("react").JSX.Element;
|
|
63
|
+
export type CodeBlockLineProps = ComponentProps<"span"> & {
|
|
64
|
+
variant?: CodeBlockLineVariant;
|
|
65
|
+
};
|
|
66
|
+
/** One line of code, across the block's full width so a diff's tint reaches both edges. */
|
|
67
|
+
export declare function CodeBlockLine({ className, variant, children, ...props }: CodeBlockLineProps): import("react").JSX.Element;
|
|
68
|
+
export type CodeBlockHighlightedLinesProps = {
|
|
69
|
+
/** The code; a trailing newline adds no empty line. */
|
|
70
|
+
code: string;
|
|
71
|
+
/** A Prism language (“typescript”, “sql”, “json”); findCodeLanguage from `@major-tech/ui/lib/code-language` reads it off a path. Plain text by default. */
|
|
72
|
+
language?: string;
|
|
73
|
+
/** Every line's variant: the removed or added side of a diff. */
|
|
74
|
+
variant?: CodeBlockLineVariant;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* `code` as one CodeBlockLine per line with syntax colours (SYNTAX_THEME), inside a CodeBlockContent. It renders
|
|
78
|
+
* lines only, so a diff puts its removed and added parts one after another, each in its variant.
|
|
79
|
+
*/
|
|
80
|
+
export declare function CodeBlockHighlightedLines({ code, language, variant }: CodeBlockHighlightedLinesProps): import("react").JSX.Element;
|
|
81
|
+
export type HighlightedCodeBlockProps = Omit<CodeBlockProps, "children" | "variant"> & {
|
|
82
|
+
/** The code; the blank lines around it are dropped, its indentation kept. */
|
|
83
|
+
code: string;
|
|
84
|
+
/** A Prism language. TypeScript by default, as in the web. */
|
|
85
|
+
language?: string;
|
|
86
|
+
/** Wrap long lines instead of scrolling sideways. */
|
|
87
|
+
wrap?: boolean;
|
|
88
|
+
/** Number the lines. */
|
|
89
|
+
lineNumbers?: boolean;
|
|
90
|
+
startLine?: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The web's HighlightedCodeBlock: a CodeBlock with no header whose code takes syntax colours. Set its height with
|
|
94
|
+
* `max-h-*`. For a header, a diff or lines of your own, compose CodeBlock with CodeBlockHighlightedLines.
|
|
95
|
+
*/
|
|
96
|
+
export declare function HighlightedCodeBlock({ code, language, wrap, lineNumbers, startLine, ...props }: HighlightedCodeBlockProps): import("react").JSX.Element;
|
|
97
|
+
/** A 12px `muted` line under the code: an exit code, “12 more lines”. */
|
|
98
|
+
export declare function CodeBlockFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
99
|
+
//# sourceMappingURL=code-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EAAiC,MAAM,EAAE,MAAM,cAAc,CAAC;AAErE,eAAO,MAAM,mBAAmB;;IAE9B,6DAA6D;;CAErD,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAE9F,eAAO,MAAM,gBAAgB;IAC3B,mEAAmE;;IAEnE,kFAAkF;;CAE1E,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAErF,eAAO,MAAM,wBAAwB;;IAEnC,mEAAmE;;IAEnE,oEAAoE;;IAEpE,mEAAmE;;CAE3D,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAiB5G;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,UAqB1B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IACnD,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,C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2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,OAA0C,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BAiB9H;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,2JAA2J;IAC3J,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,IAAI,EAAE,QAA8B,EAAE,OAAO,EAAE,EAAE,8BAA8B,+BAc1H;AAOD,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IACrF,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,QAAuB,EACvB,IAAY,EACZ,WAAmB,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,yBAAyB,+BAQ3B;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,+BAQ7E"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Check, Copy } from "lucide-react";
|
|
5
|
+
import { Highlight } from "prism-react-renderer";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { PLAIN_TEXT_LANGUAGE } from "../lib/code-language.js";
|
|
8
|
+
import { BUTTON_SIZES, BUTTON_VARIANTS, Button } from "./button.js";
|
|
9
|
+
export const CODE_BLOCK_VARIANTS = {
|
|
10
|
+
DEFAULT: "default",
|
|
11
|
+
/** A failed call's output: the border and text in danger. */
|
|
12
|
+
DESTRUCTIVE: "destructive",
|
|
13
|
+
};
|
|
14
|
+
export const CODE_BLOCK_SIZES = {
|
|
15
|
+
/** 13px `text-code`, for pages: an agent's code, a config file. */
|
|
16
|
+
DEFAULT: "default",
|
|
17
|
+
/** 12.5px `text-code-small`, for the chat: tool calls, diffs, terminal output. */
|
|
18
|
+
SM: "sm",
|
|
19
|
+
};
|
|
20
|
+
export const CODE_BLOCK_LINE_VARIANTS = {
|
|
21
|
+
DEFAULT: "default",
|
|
22
|
+
/** A diff's added line: `success-soft`, with a + in the gutter. */
|
|
23
|
+
ADDED: "added",
|
|
24
|
+
/** A diff's removed line: `danger-soft`, with a − in the gutter. */
|
|
25
|
+
REMOVED: "removed",
|
|
26
|
+
/** A line to find: a search match, the line an error points at. */
|
|
27
|
+
HIGHLIGHTED: "highlighted",
|
|
28
|
+
};
|
|
29
|
+
const VARIANT_CLASSES = {
|
|
30
|
+
[CODE_BLOCK_VARIANTS.DEFAULT]: "border-line text-ink",
|
|
31
|
+
[CODE_BLOCK_VARIANTS.DESTRUCTIVE]: "border-danger/30 text-danger",
|
|
32
|
+
};
|
|
33
|
+
const LINE_VARIANT_CLASSES = {
|
|
34
|
+
[CODE_BLOCK_LINE_VARIANTS.DEFAULT]: "",
|
|
35
|
+
[CODE_BLOCK_LINE_VARIANTS.ADDED]: "bg-success-soft after:text-success after:content-['+']",
|
|
36
|
+
[CODE_BLOCK_LINE_VARIANTS.REMOVED]: "bg-danger-soft after:text-danger after:content-['−']",
|
|
37
|
+
[CODE_BLOCK_LINE_VARIANTS.HIGHLIGHTED]: "bg-hover",
|
|
38
|
+
};
|
|
39
|
+
/** How long the copy button shows its check. */
|
|
40
|
+
const COPIED_RESET_MS = 2000;
|
|
41
|
+
/**
|
|
42
|
+
* Prism's colours as the `syntax-*` tokens (One Light / One Dark, darkened where needed to reach 4.5:1 contrast), so highlighting follows the theme
|
|
43
|
+
* wherever code renders. The surface stays the block's.
|
|
44
|
+
*/
|
|
45
|
+
export const SYNTAX_THEME = {
|
|
46
|
+
plain: { color: "var(--color-syntax-plain)", backgroundColor: "transparent" },
|
|
47
|
+
styles: [
|
|
48
|
+
{ types: ["comment", "prolog", "doctype", "cdata"], style: { color: "var(--color-syntax-comment)", fontStyle: "italic" } },
|
|
49
|
+
{ types: ["punctuation", "entity"], style: { color: "var(--color-syntax-plain)" } },
|
|
50
|
+
{ types: ["keyword"], style: { color: "var(--color-syntax-keyword)" } },
|
|
51
|
+
{
|
|
52
|
+
types: ["attr-name", "class-name", "maybe-class-name", "boolean", "constant", "number", "atrule"],
|
|
53
|
+
style: { color: "var(--color-syntax-constant)" },
|
|
54
|
+
},
|
|
55
|
+
{ types: ["property", "tag", "symbol", "deleted", "important"], style: { color: "var(--color-syntax-tag)" } },
|
|
56
|
+
{
|
|
57
|
+
types: ["selector", "string", "char", "builtin", "inserted", "regex", "attr-value"],
|
|
58
|
+
style: { color: "var(--color-syntax-string)" },
|
|
59
|
+
},
|
|
60
|
+
{ types: ["variable", "operator", "function"], style: { color: "var(--color-syntax-function)" } },
|
|
61
|
+
{ types: ["url"], style: { color: "var(--color-syntax-url)" } },
|
|
62
|
+
{ types: ["namespace"], style: { opacity: 0.7 } },
|
|
63
|
+
{ types: ["italic"], style: { fontStyle: "italic" } },
|
|
64
|
+
{ types: ["important", "bold"], style: { fontWeight: "bold" } },
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Code on `code-surface`: an optional CodeBlockHeader (the file's name, actions), the CodeBlockContent with one
|
|
69
|
+
* CodeBlockLine per line (CodeBlockHighlightedLines for syntax colours), and an optional CodeBlockFooter.
|
|
70
|
+
*/
|
|
71
|
+
export function CodeBlock({ className, variant = CODE_BLOCK_VARIANTS.DEFAULT, size = CODE_BLOCK_SIZES.DEFAULT, ...props }) {
|
|
72
|
+
return (_jsx("div", { "data-slot": "code-block", "data-variant": variant, "data-size": size, className: cn("group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg border bg-code-surface font-mono text-code data-[size=sm]:text-code-small", VARIANT_CLASSES[variant], className), ...props }));
|
|
73
|
+
}
|
|
74
|
+
/** The row above the code, at least 32px, under a `line` rule: a CodeBlockTitle and CodeBlockActions. */
|
|
75
|
+
export function CodeBlockHeader({ className, ...props }) {
|
|
76
|
+
return (_jsx("div", { "data-slot": "code-block-header", className: cn("flex min-h-8 min-w-0 shrink-0 items-center gap-space-8 border-b border-line px-space-16 font-sans text-muted", className), ...props }));
|
|
77
|
+
}
|
|
78
|
+
/** The file's name or the block's label in 12px `ink-2`, after an optional 14px icon; it truncates. */
|
|
79
|
+
export function CodeBlockTitle({ className, ...props }) {
|
|
80
|
+
return (_jsx("div", { "data-slot": "code-block-title", className: cn("flex min-w-0 items-center gap-1.5 truncate text-small font-medium text-ink-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5", className), ...props }));
|
|
81
|
+
}
|
|
82
|
+
/** The header's buttons, at its right edge: hidden until the block is hovered or focused, always shown on touch. */
|
|
83
|
+
export function CodeBlockActions({ className, ...props }) {
|
|
84
|
+
return (_jsx("div", { "data-slot": "code-block-actions", className: cn("ms-auto -me-1 flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within/code-block:opacity-100 group-hover/code-block:opacity-100 pointer-coarse:opacity-100", className), ...props }));
|
|
85
|
+
}
|
|
86
|
+
/** A 24px ghost icon button named Copy that copies `value`; it shows a check for 2s and announces “Copied”. */
|
|
87
|
+
export function CodeBlockCopyButton({ value, className, onClick, ...props }) {
|
|
88
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!isCopied) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const timeout = setTimeout(() => setIsCopied(false), COPIED_RESET_MS);
|
|
94
|
+
return () => clearTimeout(timeout);
|
|
95
|
+
}, [isCopied]);
|
|
96
|
+
const handleClick = (event) => {
|
|
97
|
+
onClick?.(event);
|
|
98
|
+
// Missing outside a secure context (an http preview); copying then does nothing.
|
|
99
|
+
navigator.clipboard
|
|
100
|
+
?.writeText(value)
|
|
101
|
+
.then(() => setIsCopied(true))
|
|
102
|
+
.catch(() => { });
|
|
103
|
+
};
|
|
104
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { "data-slot": "code-block-copy-button", variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.ICON_SM, "aria-label": "Copy", className: className, onClick: handleClick, ...props, children: isCopied ? _jsx(Check, { className: "text-success" }) : _jsx(Copy, {}) }), _jsx("span", { "aria-live": "polite", className: "sr-only", children: isCopied ? "Copied" : "" })] }));
|
|
105
|
+
}
|
|
106
|
+
/** The code: a focusable `<pre>` that scrolls (set its height with `max-h-*`). Its children are CodeBlockLines. */
|
|
107
|
+
export function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }) {
|
|
108
|
+
return (_jsx("pre", { "data-slot": "code-block-content", "data-wrap": wrap || undefined, "data-numbered": lineNumbers || undefined, dir: "ltr", tabIndex: 0, style: { counterReset: `line ${startLine - 1}`, ...style }, className: cn("m-0 min-h-0 min-w-0 overflow-auto px-space-16 py-space-8 text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-faint data-wrap:whitespace-pre-wrap data-wrap:wrap-anywhere", className), ...props, children: _jsx("code", { "data-slot": "code-block-code", className: "grid min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0", children: children }) }));
|
|
109
|
+
}
|
|
110
|
+
const LINE_CLASSES = [
|
|
111
|
+
"relative -mx-space-16 block min-h-lh px-space-16",
|
|
112
|
+
"before:min-w-6 before:text-end before:text-faint after:absolute after:start-1 after:top-0 after:select-none",
|
|
113
|
+
"in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3",
|
|
114
|
+
"in-data-numbered:[counter-increment:line] in-data-numbered:before:select-none in-data-numbered:before:content-[counter(line)]",
|
|
115
|
+
].join(" ");
|
|
116
|
+
/** One line of code, across the block's full width so a diff's tint reaches both edges. */
|
|
117
|
+
export function CodeBlockLine({ className, variant = CODE_BLOCK_LINE_VARIANTS.DEFAULT, children, ...props }) {
|
|
118
|
+
// An empty line holds a newline, so copying a selection keeps blank lines.
|
|
119
|
+
const isEmpty = children === undefined || children === null || children === "" || (Array.isArray(children) && children.length === 0);
|
|
120
|
+
return (_jsx("span", { "data-slot": "code-block-line", "data-variant": variant, className: cn(LINE_CLASSES, LINE_VARIANT_CLASSES[variant], className), ...props, children: _jsx("span", { "data-slot": "code-block-line-content", className: "min-w-0", children: isEmpty ? "\n" : children }) }));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* `code` as one CodeBlockLine per line with syntax colours (SYNTAX_THEME), inside a CodeBlockContent. It renders
|
|
124
|
+
* lines only, so a diff puts its removed and added parts one after another, each in its variant.
|
|
125
|
+
*/
|
|
126
|
+
export function CodeBlockHighlightedLines({ code, language = PLAIN_TEXT_LANGUAGE, variant }) {
|
|
127
|
+
return (_jsx(Highlight, { theme: SYNTAX_THEME, code: code.replace(/\n$/, ""), language: language, children: ({ tokens, getTokenProps }) => tokens.map((line, lineIndex) => (_jsx(CodeBlockLine, { variant: variant, children: line.map((token, tokenIndex) => (_jsx("span", { ...getTokenProps({ token }) }, tokenIndex))) }, lineIndex))) }));
|
|
128
|
+
}
|
|
129
|
+
/** Drops the blank lines around code and keeps its first line's indentation. */
|
|
130
|
+
function trimBlankLines(code) {
|
|
131
|
+
return code.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The web's HighlightedCodeBlock: a CodeBlock with no header whose code takes syntax colours. Set its height with
|
|
135
|
+
* `max-h-*`. For a header, a diff or lines of your own, compose CodeBlock with CodeBlockHighlightedLines.
|
|
136
|
+
*/
|
|
137
|
+
export function HighlightedCodeBlock({ code, language = "typescript", wrap = false, lineNumbers = false, startLine, ...props }) {
|
|
138
|
+
return (_jsx(CodeBlock, { ...props, children: _jsx(CodeBlockContent, { wrap: wrap, lineNumbers: lineNumbers, startLine: startLine, children: _jsx(CodeBlockHighlightedLines, { code: trimBlankLines(code), language: language }) }) }));
|
|
139
|
+
}
|
|
140
|
+
/** A 12px `muted` line under the code: an exit code, “12 more lines”. */
|
|
141
|
+
export function CodeBlockFooter({ className, ...props }) {
|
|
142
|
+
return (_jsx("div", { "data-slot": "code-block-footer", className: cn("flex min-w-0 shrink-0 items-center gap-space-8 px-space-16 pb-space-8 font-sans text-small text-muted", className), ...props }));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=code-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.js","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAmB,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAc,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO,EAAE,SAAS;IAClB,6DAA6D;IAC7D,WAA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C7B,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC9B,KAAC,aAAa,IAAiB,OAAO,EAAE,OAAO,YAC5C,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAC/B,kBAA2B,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,IAAxC,UAAU,CAAkC,CACxD,CAAC,IAHgB,SAAS,CAIb,CACjB,CAAC,GAEM,CACb,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;AAcD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EACnC,IAAI,EACJ,QAAQ,GAAG,YAAY,EACvB,IAAI,GAAG,KAAK,EACZ,WAAW,GAAG,KAAK,EACnB,SAAS,EACT,GAAG,KAAK,EACkB;IAC1B,OAAO,CACL,KAAC,SAAS,OAAK,KAAK,YAClB,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,YAC1E,KAAC,yBAAyB,IAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAI,GAC5D,GACT,CACb,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAyB;IAC5E,OAAO,CACL,2BACY,mBAAmB,EAC7B,SAAS,EAAE,EAAE,CAAC,uGAAuG,EAAE,SAAS,CAAC,KAC7H,KAAK,GACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useState, type ComponentProps } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { Highlight, type PrismTheme } from \"prism-react-renderer\";\nimport { cn } from \"../lib/cn.ts\";\nimport { PLAIN_TEXT_LANGUAGE } from \"../lib/code-language.ts\";\nimport { BUTTON_SIZES, BUTTON_VARIANTS, Button } from \"./button.tsx\";\n\nexport const CODE_BLOCK_VARIANTS = {\n DEFAULT: \"default\",\n /** A failed call's output: the border and text in danger. */\n DESTRUCTIVE: \"destructive\",\n} as const;\n\nexport type CodeBlockVariant = (typeof CODE_BLOCK_VARIANTS)[keyof typeof CODE_BLOCK_VARIANTS];\n\nexport const CODE_BLOCK_SIZES = {\n /** 13px `text-code`, for pages: an agent's code, a config file. */\n DEFAULT: \"default\",\n /** 12.5px `text-code-small`, for the chat: tool calls, diffs, terminal output. */\n SM: \"sm\",\n} as const;\n\nexport type CodeBlockSize = (typeof CODE_BLOCK_SIZES)[keyof typeof CODE_BLOCK_SIZES];\n\nexport const CODE_BLOCK_LINE_VARIANTS = {\n DEFAULT: \"default\",\n /** A diff's added line: `success-soft`, with a + in the gutter. */\n ADDED: \"added\",\n /** A diff's removed line: `danger-soft`, with a − in the gutter. */\n REMOVED: \"removed\",\n /** A line to find: a search match, the line an error points at. */\n HIGHLIGHTED: \"highlighted\",\n} as const;\n\nexport type CodeBlockLineVariant = (typeof CODE_BLOCK_LINE_VARIANTS)[keyof typeof CODE_BLOCK_LINE_VARIANTS];\n\nconst VARIANT_CLASSES = {\n [CODE_BLOCK_VARIANTS.DEFAULT]: \"border-line text-ink\",\n [CODE_BLOCK_VARIANTS.DESTRUCTIVE]: \"border-danger/30 text-danger\",\n} satisfies Record<CodeBlockVariant, string>;\n\nconst LINE_VARIANT_CLASSES = {\n [CODE_BLOCK_LINE_VARIANTS.DEFAULT]: \"\",\n [CODE_BLOCK_LINE_VARIANTS.ADDED]: \"bg-success-soft after:text-success after:content-['+']\",\n [CODE_BLOCK_LINE_VARIANTS.REMOVED]: \"bg-danger-soft after:text-danger after:content-['−']\",\n [CODE_BLOCK_LINE_VARIANTS.HIGHLIGHTED]: \"bg-hover\",\n} satisfies Record<CodeBlockLineVariant, string>;\n\n/** How long the copy button shows its check. */\nconst COPIED_RESET_MS = 2000;\n\n/**\n * Prism's colours as the `syntax-*` tokens (One Light / One Dark, darkened where needed to reach 4.5:1 contrast), so highlighting follows the theme\n * wherever code renders. The surface stays the block's.\n */\nexport const SYNTAX_THEME: PrismTheme = {\n plain: { color: \"var(--color-syntax-plain)\", backgroundColor: \"transparent\" },\n styles: [\n { types: [\"comment\", \"prolog\", \"doctype\", \"cdata\"], style: { color: \"var(--color-syntax-comment)\", fontStyle: \"italic\" } },\n { types: [\"punctuation\", \"entity\"], style: { color: \"var(--color-syntax-plain)\" } },\n { types: [\"keyword\"], style: { color: \"var(--color-syntax-keyword)\" } },\n {\n types: [\"attr-name\", \"class-name\", \"maybe-class-name\", \"boolean\", \"constant\", \"number\", \"atrule\"],\n style: { color: \"var(--color-syntax-constant)\" },\n },\n { types: [\"property\", \"tag\", \"symbol\", \"deleted\", \"important\"], style: { color: \"var(--color-syntax-tag)\" } },\n {\n types: [\"selector\", \"string\", \"char\", \"builtin\", \"inserted\", \"regex\", \"attr-value\"],\n style: { color: \"var(--color-syntax-string)\" },\n },\n { types: [\"variable\", \"operator\", \"function\"], style: { color: \"var(--color-syntax-function)\" } },\n { types: [\"url\"], style: { color: \"var(--color-syntax-url)\" } },\n { types: [\"namespace\"], style: { opacity: 0.7 } },\n { types: [\"italic\"], style: { fontStyle: \"italic\" } },\n { types: [\"important\", \"bold\"], style: { fontWeight: \"bold\" } },\n ],\n};\n\nexport type CodeBlockProps = ComponentProps<\"div\"> & {\n variant?: CodeBlockVariant;\n size?: CodeBlockSize;\n};\n\n/**\n * Code on `code-surface`: an optional CodeBlockHeader (the file's name, actions), the CodeBlockContent with one\n * CodeBlockLine per line (CodeBlockHighlightedLines for syntax colours), and an optional CodeBlockFooter.\n */\nexport function CodeBlock({ className, variant = CODE_BLOCK_VARIANTS.DEFAULT, size = CODE_BLOCK_SIZES.DEFAULT, ...props }: CodeBlockProps) {\n return (\n <div\n data-slot=\"code-block\"\n data-variant={variant}\n data-size={size}\n className={cn(\n \"group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg border bg-code-surface font-mono text-code data-[size=sm]:text-code-small\",\n VARIANT_CLASSES[variant],\n className\n )}\n {...props}\n />\n );\n}\n\n/** The row above the code, at least 32px, under a `line` rule: a CodeBlockTitle and CodeBlockActions. */\nexport function CodeBlockHeader({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-header\"\n className={cn(\n \"flex min-h-8 min-w-0 shrink-0 items-center gap-space-8 border-b border-line px-space-16 font-sans text-muted\",\n className\n )}\n {...props}\n />\n );\n}\n\n/** The file's name or the block's label in 12px `ink-2`, after an optional 14px icon; it truncates. */\nexport function CodeBlockTitle({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-title\"\n className={cn(\n \"flex min-w-0 items-center gap-1.5 truncate text-small font-medium text-ink-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5\",\n className\n )}\n {...props}\n />\n );\n}\n\n/** The header's buttons, at its right edge: hidden until the block is hovered or focused, always shown on touch. */\nexport function CodeBlockActions({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n \"ms-auto -me-1 flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within/code-block:opacity-100 group-hover/code-block:opacity-100 pointer-coarse:opacity-100\",\n className\n )}\n {...props}\n />\n );\n}\n\nexport type CodeBlockCopyButtonProps = Omit<ComponentProps<typeof Button>, \"value\" | \"children\"> & {\n /** The text the button copies. */\n value: string;\n};\n\n/** A 24px ghost icon button named Copy that copies `value`; it shows a check for 2s and announces “Copied”. */\nexport function CodeBlockCopyButton({ value, className, onClick, ...props }: CodeBlockCopyButtonProps) {\n const [isCopied, setIsCopied] = useState(false);\n\n useEffect(() => {\n if (!isCopied) {\n return;\n }\n\n const timeout = setTimeout(() => setIsCopied(false), COPIED_RESET_MS);\n\n return () => clearTimeout(timeout);\n }, [isCopied]);\n\n const handleClick: ComponentProps<typeof Button>[\"onClick\"] = (event) => {\n onClick?.(event);\n // Missing outside a secure context (an http preview); copying then does nothing.\n navigator.clipboard\n ?.writeText(value)\n .then(() => setIsCopied(true))\n .catch(() => {});\n };\n\n return (\n <>\n <Button\n data-slot=\"code-block-copy-button\"\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Copy\"\n className={className}\n onClick={handleClick}\n {...props}\n >\n {isCopied ? <Check className=\"text-success\" /> : <Copy />}\n </Button>\n <span aria-live=\"polite\" className=\"sr-only\">\n {isCopied ? \"Copied\" : \"\"}\n </span>\n </>\n );\n}\n\nexport type CodeBlockContentProps = ComponentProps<\"pre\"> & {\n /** Wrap long lines instead of scrolling sideways. */\n wrap?: boolean;\n /** Number the lines in a `faint` gutter. */\n lineNumbers?: boolean;\n /** The first line's number, for a part of a file. */\n startLine?: number;\n};\n\n/** The code: a focusable `<pre>` that scrolls (set its height with `max-h-*`). Its children are CodeBlockLines. */\nexport function CodeBlockContent({\n className,\n children,\n style,\n wrap = false,\n lineNumbers = false,\n startLine = 1,\n ...props\n}: CodeBlockContentProps) {\n return (\n <pre\n data-slot=\"code-block-content\"\n data-wrap={wrap || undefined}\n data-numbered={lineNumbers || undefined}\n dir=\"ltr\"\n tabIndex={0}\n style={{ counterReset: `line ${startLine - 1}`, ...style }}\n className={cn(\n \"m-0 min-h-0 min-w-0 overflow-auto px-space-16 py-space-8 text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-faint data-wrap:whitespace-pre-wrap data-wrap:wrap-anywhere\",\n className\n )}\n {...props}\n >\n <code\n data-slot=\"code-block-code\"\n className=\"grid min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0\"\n >\n {children}\n </code>\n </pre>\n );\n}\n\nconst LINE_CLASSES = [\n \"relative -mx-space-16 block min-h-lh px-space-16\",\n \"before:min-w-6 before:text-end before:text-faint after:absolute after:start-1 after:top-0 after:select-none\",\n \"in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3\",\n \"in-data-numbered:[counter-increment:line] in-data-numbered:before:select-none in-data-numbered:before:content-[counter(line)]\",\n].join(\" \");\n\nexport type CodeBlockLineProps = ComponentProps<\"span\"> & {\n variant?: CodeBlockLineVariant;\n};\n\n/** One line of code, across the block's full width so a diff's tint reaches both edges. */\nexport function CodeBlockLine({ className, variant = CODE_BLOCK_LINE_VARIANTS.DEFAULT, children, ...props }: CodeBlockLineProps) {\n // An empty line holds a newline, so copying a selection keeps blank lines.\n const isEmpty =\n children === undefined || children === null || children === \"\" || (Array.isArray(children) && children.length === 0);\n\n return (\n <span\n data-slot=\"code-block-line\"\n data-variant={variant}\n className={cn(LINE_CLASSES, LINE_VARIANT_CLASSES[variant], className)}\n {...props}\n >\n <span data-slot=\"code-block-line-content\" className=\"min-w-0\">\n {isEmpty ? \"\\n\" : children}\n </span>\n </span>\n );\n}\n\nexport type CodeBlockHighlightedLinesProps = {\n /** The code; a trailing newline adds no empty line. */\n code: string;\n /** A Prism language (“typescript”, “sql”, “json”); findCodeLanguage from `@major-tech/ui/lib/code-language` reads it off a path. Plain text by default. */\n language?: string;\n /** Every line's variant: the removed or added side of a diff. */\n variant?: CodeBlockLineVariant;\n};\n\n/**\n * `code` as one CodeBlockLine per line with syntax colours (SYNTAX_THEME), inside a CodeBlockContent. It renders\n * lines only, so a diff puts its removed and added parts one after another, each in its variant.\n */\nexport function CodeBlockHighlightedLines({ code, language = PLAIN_TEXT_LANGUAGE, variant }: CodeBlockHighlightedLinesProps) {\n return (\n <Highlight theme={SYNTAX_THEME} code={code.replace(/\\n$/, \"\")} language={language}>\n {({ tokens, getTokenProps }) =>\n tokens.map((line, lineIndex) => (\n <CodeBlockLine key={lineIndex} variant={variant}>\n {line.map((token, tokenIndex) => (\n <span key={tokenIndex} {...getTokenProps({ token })} />\n ))}\n </CodeBlockLine>\n ))\n }\n </Highlight>\n );\n}\n\n/** Drops the blank lines around code and keeps its first line's indentation. */\nfunction trimBlankLines(code: string): string {\n return code.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\nexport type HighlightedCodeBlockProps = Omit<CodeBlockProps, \"children\" | \"variant\"> & {\n /** The code; the blank lines around it are dropped, its indentation kept. */\n code: string;\n /** A Prism language. TypeScript by default, as in the web. */\n language?: string;\n /** Wrap long lines instead of scrolling sideways. */\n wrap?: boolean;\n /** Number the lines. */\n lineNumbers?: boolean;\n startLine?: number;\n};\n\n/**\n * The web's HighlightedCodeBlock: a CodeBlock with no header whose code takes syntax colours. Set its height with\n * `max-h-*`. For a header, a diff or lines of your own, compose CodeBlock with CodeBlockHighlightedLines.\n */\nexport function HighlightedCodeBlock({\n code,\n language = \"typescript\",\n wrap = false,\n lineNumbers = false,\n startLine,\n ...props\n}: HighlightedCodeBlockProps) {\n return (\n <CodeBlock {...props}>\n <CodeBlockContent wrap={wrap} lineNumbers={lineNumbers} startLine={startLine}>\n <CodeBlockHighlightedLines code={trimBlankLines(code)} language={language} />\n </CodeBlockContent>\n </CodeBlock>\n );\n}\n\n/** A 12px `muted` line under the code: an exit code, “12 more lines”. */\nexport function CodeBlockFooter({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"code-block-footer\"\n className={cn(\"flex min-w-0 shrink-0 items-center gap-space-8 px-space-16 pb-space-8 font-sans text-small text-muted\", className)}\n {...props}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
2
|
+
/**
|
|
3
|
+
* A single region that shows and hides: Base UI's primitive with data-slots, unstyled; the caller styles it.
|
|
4
|
+
* For stacked sections or an "Advanced settings" toggle, use Accordion.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Collapsible(props: CollapsiblePrimitive.Root.Props): import("react").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* The toggle, a `<button>`; pass another element as `render`. While open it carries `data-panel-open`, for turning
|
|
9
|
+
* the chevron.
|
|
10
|
+
*/
|
|
11
|
+
export declare function CollapsibleTrigger(props: CollapsiblePrimitive.Trigger.Props): import("react").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* The region. To animate its height, add
|
|
14
|
+
* `overflow-hidden data-open:animate-collapsible-open data-closed:animate-collapsible-close`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function CollapsibleContent(props: CollapsiblePrimitive.Panel.Props): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=collapsible.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../src/components/collapsible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEjF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC,KAAK,+BAEjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,+BAE3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,+BAEzE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
4
|
+
/**
|
|
5
|
+
* A single region that shows and hides: Base UI's primitive with data-slots, unstyled; the caller styles it.
|
|
6
|
+
* For stacked sections or an "Advanced settings" toggle, use Accordion.
|
|
7
|
+
*/
|
|
8
|
+
export function Collapsible(props) {
|
|
9
|
+
return _jsx(CollapsiblePrimitive.Root, { "data-slot": "collapsible", ...props });
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The toggle, a `<button>`; pass another element as `render`. While open it carries `data-panel-open`, for turning
|
|
13
|
+
* the chevron.
|
|
14
|
+
*/
|
|
15
|
+
export function CollapsibleTrigger(props) {
|
|
16
|
+
return _jsx(CollapsiblePrimitive.Trigger, { "data-slot": "collapsible-trigger", ...props });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The region. To animate its height, add
|
|
20
|
+
* `overflow-hidden data-open:animate-collapsible-open data-closed:animate-collapsible-close`.
|
|
21
|
+
*/
|
|
22
|
+
export function CollapsibleContent(props) {
|
|
23
|
+
return _jsx(CollapsiblePrimitive.Panel, { "data-slot": "collapsible-content", ...props });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible.js","sourceRoot":"","sources":["../../src/components/collapsible.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEjF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAsC;IAChE,OAAO,KAAC,oBAAoB,CAAC,IAAI,iBAAW,aAAa,KAAK,KAAK,GAAI,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAyC;IAC1E,OAAO,KAAC,oBAAoB,CAAC,OAAO,iBAAW,qBAAqB,KAAK,KAAK,GAAI,CAAC;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAuC;IACxE,OAAO,KAAC,oBAAoB,CAAC,KAAK,iBAAW,qBAAqB,KAAK,KAAK,GAAI,CAAC;AACnF,CAAC","sourcesContent":["\"use client\";\n\nimport { Collapsible as CollapsiblePrimitive } from \"@base-ui/react/collapsible\";\n\n/**\n * A single region that shows and hides: Base UI's primitive with data-slots, unstyled; the caller styles it.\n * For stacked sections or an \"Advanced settings\" toggle, use Accordion.\n */\nexport function Collapsible(props: CollapsiblePrimitive.Root.Props) {\n return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />;\n}\n\n/**\n * The toggle, a `<button>`; pass another element as `render`. While open it carries `data-panel-open`, for turning\n * the chevron.\n */\nexport function CollapsibleTrigger(props: CollapsiblePrimitive.Trigger.Props) {\n return <CollapsiblePrimitive.Trigger data-slot=\"collapsible-trigger\" {...props} />;\n}\n\n/**\n * The region. To animate its height, add\n * `overflow-hidden data-open:animate-collapsible-open data-closed:animate-collapsible-close`.\n */\nexport function CollapsibleContent(props: CollapsiblePrimitive.Panel.Props) {\n return <CollapsiblePrimitive.Panel data-slot=\"collapsible-content\" {...props} />;\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
3
|
+
/** What a filter reads of an item: its value and the words it is found by. */
|
|
4
|
+
export interface CommandFilterItem {
|
|
5
|
+
value: string;
|
|
6
|
+
keywords: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** Whether an item matches the search. */
|
|
9
|
+
export type CommandFilter = (search: string, item: CommandFilterItem) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The default filter: an item matches when its keywords (or its value, when it has none) contain every word of the
|
|
12
|
+
* search, in any case and order.
|
|
13
|
+
*/
|
|
14
|
+
export declare const filterCommandItem: CommandFilter;
|
|
15
|
+
export interface CommandProps extends Omit<ComponentProps<"div">, "defaultValue"> {
|
|
16
|
+
/** The search text, controlled. */
|
|
17
|
+
search?: string;
|
|
18
|
+
defaultSearch?: string;
|
|
19
|
+
onSearchChange?: (search: string) => void;
|
|
20
|
+
/** Which items show for the search. `false` shows them all: the product filters (a server search). */
|
|
21
|
+
filter?: CommandFilter | false;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A searchable list worked from the keyboard: type to narrow it, arrows to move, Enter to pick. It has no surface
|
|
25
|
+
* of its own: a Dialog (the ⌘K palette) or a Popover (a picker) holds it. Base UI Autocomplete, inline.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Command({ search: searchProp, defaultSearch, onSearchChange, filter, className, children, ...props }: CommandProps): import("react").JSX.Element;
|
|
28
|
+
export type CommandInputProps = Omit<ComponentProps<typeof Autocomplete.Input>, "value" | "defaultValue">;
|
|
29
|
+
/** The search line: a 40px row with a search icon over a rule. The search text is set on Command. */
|
|
30
|
+
export declare function CommandInput({ className, ...props }: CommandInputProps): import("react").JSX.Element;
|
|
31
|
+
/** The rows, scrolling past their height (set it with `max-h-*`), 6px inside like the menu sheet. */
|
|
32
|
+
export declare function CommandList({ className, ...props }: ComponentProps<typeof Autocomplete.List>): import("react").JSX.Element;
|
|
33
|
+
/** Shown while nothing matches: "No results." */
|
|
34
|
+
export declare function CommandEmpty({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element | null;
|
|
35
|
+
export interface CommandGroupProps extends Omit<ComponentProps<typeof Autocomplete.Group>, "items"> {
|
|
36
|
+
/** The group's name, in the menu's section style. */
|
|
37
|
+
heading?: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
/** Rows under a heading. A group with no matching row hides, heading and all. */
|
|
40
|
+
export declare function CommandGroup({ heading, className, children, ...props }: CommandGroupProps): import("react").JSX.Element;
|
|
41
|
+
export interface CommandItemProps extends Omit<ComponentProps<typeof Autocomplete.Item>, "value"> {
|
|
42
|
+
/** The item's id: unique in the list. */
|
|
43
|
+
value: string;
|
|
44
|
+
/** The words it is found by: its name, then any synonyms. Default: its value. */
|
|
45
|
+
keywords?: readonly string[];
|
|
46
|
+
/** Picked by a click or by Enter while highlighted. */
|
|
47
|
+
onSelect?: () => void;
|
|
48
|
+
}
|
|
49
|
+
/** A row in the menu's row style: an icon, the label, anything on the right. Hidden while it doesn't match. */
|
|
50
|
+
export declare function CommandItem({ value, keywords, onSelect, onClick, className, ...props }: CommandItemProps): import("react").JSX.Element | null;
|
|
51
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/components/command.tsx"],"names":[],"mappings":"AAEA,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAK3D,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,0CAA0C;AAC1C,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAU/B,CAAC;AA0CF,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC/E,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,sGAAsG;IACtG,MAAM,CAAC,EAAE,aAAa,GAAG,KAAK,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,MAAM,EAAE,UAAU,EAClB,aAAkB,EAClB,cAAc,EACd,MAA0B,EAC1B,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,YAAY,+BAwDd;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC;AAE1G,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,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