@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,302 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Children, cloneElement, createContext, useContext, useState, } from "react";
|
|
4
|
+
import { Check, ChevronRight } from "lucide-react";
|
|
5
|
+
import { useIsMobile } from "../hooks/use-is-mobile.js";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
8
|
+
import { DRAWER_SWIPE_DIRECTIONS, Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "./drawer.js";
|
|
9
|
+
import { DROPDOWN_MENU_ITEM_CLASSES, DROPDOWN_MENU_LABEL_CLASSES, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "./dropdown-menu.js";
|
|
10
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
11
|
+
import { Separator } from "./separator.js";
|
|
12
|
+
/** What it opens as from 768px up. Below that it is always a sheet from the bottom. */
|
|
13
|
+
export const RESPONSIVE_OVERLAY_DESKTOP_VARIANTS = {
|
|
14
|
+
DIALOG: "dialog",
|
|
15
|
+
POPOVER: "popover",
|
|
16
|
+
DROPDOWN: "dropdown",
|
|
17
|
+
};
|
|
18
|
+
const HOSTS = { ...RESPONSIVE_OVERLAY_DESKTOP_VARIANTS, DRAWER: "drawer" };
|
|
19
|
+
const HostContext = createContext(HOSTS.DIALOG);
|
|
20
|
+
const OverlayRootContext = createContext({ close: () => { }, isMenu: false });
|
|
21
|
+
/** Whether the sheet around a part is a list of rows: a dropdown's, or a submenu's. */
|
|
22
|
+
const MenuSheetContext = createContext(false);
|
|
23
|
+
/** Whether a part sits in a submenu's rows. */
|
|
24
|
+
const SubmenuContext = createContext(false);
|
|
25
|
+
const RadioGroupContext = createContext(null);
|
|
26
|
+
/**
|
|
27
|
+
* A menu's sheet pads like the dropdown it replaces: its rows carry their own inset. The bottom keeps the iPhone
|
|
28
|
+
* home indicator's inset on top.
|
|
29
|
+
*/
|
|
30
|
+
const MENU_SHEET_CLASSES = "px-space-8 pt-space-8 pb-[calc(var(--spacing-space-16)+env(safe-area-inset-bottom))]";
|
|
31
|
+
/** A menu's title, in line with its rows' text as the dropdown's label is. */
|
|
32
|
+
const MENU_SHEET_TITLE_CLASSES = "px-space-8 pb-space-8";
|
|
33
|
+
/**
|
|
34
|
+
* A row outside the dropdown: the menu's row with the states a plain button gets. In a sheet it is 40px, tall enough
|
|
35
|
+
* for a thumb and close enough to read as one menu.
|
|
36
|
+
*/
|
|
37
|
+
function getRowClassName(host, className) {
|
|
38
|
+
return cn(DROPDOWN_MENU_ITEM_CLASSES, "hover:bg-hover focus-visible:bg-hover disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50", "data-[variant=destructive]:text-danger data-[variant=destructive]:[&>svg]:text-danger", host === HOSTS.DRAWER && "min-h-10", className);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The sheet pads its content once and scrolls it past its height cap. It is always full width, so a desktop width
|
|
42
|
+
* the caller set (`w-60`, `sm:max-w-lg`) gives way, and so does a menu's desktop padding (`p-0` around a searchable
|
|
43
|
+
* list). The strip the drawer keeps past its bottom edge is dropped: in a sheet that scrolls it would add empty space
|
|
44
|
+
* under the content.
|
|
45
|
+
*/
|
|
46
|
+
function getSheetClassName(isMenu, className) {
|
|
47
|
+
return cn("overflow-y-auto px-5 after:hidden", className, isMenu && MENU_SHEET_CLASSES, "w-full max-w-none sm:max-w-none");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One overlay for both widths: a Dialog, Popover or DropdownMenu from 768px up, a Drawer from the bottom below it.
|
|
51
|
+
* The parts render the matching parts of whichever it is, so a screen writes its overlay once. Open state is held
|
|
52
|
+
* here, so the overlay stays open when the window crosses 768px, and a row can close it in every form.
|
|
53
|
+
*/
|
|
54
|
+
export function ResponsiveOverlay({ open, defaultOpen = false, onOpenChange, desktopVariant = RESPONSIVE_OVERLAY_DESKTOP_VARIANTS.DIALOG, modal, children, }) {
|
|
55
|
+
const isMobile = useIsMobile();
|
|
56
|
+
const host = isMobile ? HOSTS.DRAWER : desktopVariant;
|
|
57
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
58
|
+
const isOpen = open ?? uncontrolledOpen;
|
|
59
|
+
const handleOpenChange = (next) => {
|
|
60
|
+
if (open === undefined) {
|
|
61
|
+
setUncontrolledOpen(next);
|
|
62
|
+
}
|
|
63
|
+
onOpenChange?.(next);
|
|
64
|
+
};
|
|
65
|
+
const root = { close: () => handleOpenChange(false), isMenu: desktopVariant === RESPONSIVE_OVERLAY_DESKTOP_VARIANTS.DROPDOWN };
|
|
66
|
+
return (_jsx(OverlayRootContext.Provider, { value: root, children: _jsx(HostContext.Provider, { value: host, children: _jsx(HostRoot, { host: host, open: isOpen, onOpenChange: handleOpenChange, modal: modal, children: children }) }) }));
|
|
67
|
+
}
|
|
68
|
+
/** The root of whichever the overlay is at this width. */
|
|
69
|
+
function HostRoot({ host, ...props }) {
|
|
70
|
+
if (host === HOSTS.DRAWER) {
|
|
71
|
+
return _jsx(Drawer, { swipeDirection: DRAWER_SWIPE_DIRECTIONS.DOWN, ...props });
|
|
72
|
+
}
|
|
73
|
+
if (host === HOSTS.POPOVER) {
|
|
74
|
+
return _jsx(Popover, { ...props });
|
|
75
|
+
}
|
|
76
|
+
if (host === HOSTS.DROPDOWN) {
|
|
77
|
+
return _jsx(DropdownMenu, { ...props });
|
|
78
|
+
}
|
|
79
|
+
return _jsx(Dialog, { ...props });
|
|
80
|
+
}
|
|
81
|
+
/** Closes the whole overlay from inside it, for a pick that isn't one of its rows (a searchable list's item). */
|
|
82
|
+
export function useResponsiveOverlayClose() {
|
|
83
|
+
return useContext(OverlayRootContext).close;
|
|
84
|
+
}
|
|
85
|
+
/** Whether this part sits in the phone's sheet: the overlay's own answer, not a second viewport check. */
|
|
86
|
+
export function useIsInResponsiveOverlayDrawer() {
|
|
87
|
+
return useContext(HostContext) === HOSTS.DRAWER;
|
|
88
|
+
}
|
|
89
|
+
/** The control that opens it. Props a wrapping trigger adds (a Tooltip's) pass through to it. */
|
|
90
|
+
export function ResponsiveOverlayTrigger({ render, children, ...props }) {
|
|
91
|
+
const host = useContext(HostContext);
|
|
92
|
+
if (host === HOSTS.DROPDOWN) {
|
|
93
|
+
return (_jsx(DropdownMenuTrigger, { render: render, ...props, children: children }));
|
|
94
|
+
}
|
|
95
|
+
if (host === HOSTS.DRAWER) {
|
|
96
|
+
return (_jsx(DrawerTrigger, { render: render, ...props, children: children }));
|
|
97
|
+
}
|
|
98
|
+
if (host === HOSTS.POPOVER) {
|
|
99
|
+
return (_jsx(PopoverTrigger, { render: render, ...props, children: children }));
|
|
100
|
+
}
|
|
101
|
+
return (_jsx(DialogTrigger, { render: render, ...props, children: children }));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The surface. A dialog fills the width up to 512px; size it with a `w-*` (up to 512px) or an `sm:max-w-*` class. A
|
|
105
|
+
* popover pads 16px unless the className sets its own. `align`, `side` and `sideOffset` place a popover or a
|
|
106
|
+
* dropdown; the sheet ignores them and every width.
|
|
107
|
+
*/
|
|
108
|
+
export function ResponsiveOverlayContent({ className, children, align, side, sideOffset, showCloseButton, showHandle = true, }) {
|
|
109
|
+
const host = useContext(HostContext);
|
|
110
|
+
const { isMenu } = useContext(OverlayRootContext);
|
|
111
|
+
if (host === HOSTS.DRAWER) {
|
|
112
|
+
return (_jsx(DrawerContent, { className: getSheetClassName(isMenu, className), showSwipeHandle: showHandle, children: _jsx(MenuSheetContext.Provider, { value: isMenu, children: children }) }));
|
|
113
|
+
}
|
|
114
|
+
if (host === HOSTS.POPOVER) {
|
|
115
|
+
return (_jsx(PopoverContent, { className: cn("p-space-16", className), align: align, side: side, sideOffset: sideOffset, children: children }));
|
|
116
|
+
}
|
|
117
|
+
if (host === HOSTS.DROPDOWN) {
|
|
118
|
+
return (_jsx(DropdownMenuContent, { className: className, align: align, side: side, sideOffset: sideOffset, children: children }));
|
|
119
|
+
}
|
|
120
|
+
return (_jsx(DialogContent, { className: cn("w-full sm:max-w-lg", className), showCloseButton: showCloseButton, children: children }));
|
|
121
|
+
}
|
|
122
|
+
/** The title and description. The sheet has no ×: a swipe, the dimmed page or a pick closes it. */
|
|
123
|
+
export function ResponsiveOverlayHeader({ className, children }) {
|
|
124
|
+
const host = useContext(HostContext);
|
|
125
|
+
if (host === HOSTS.DRAWER) {
|
|
126
|
+
return (_jsx(DrawerHeader, { showCloseButton: false, className: cn("px-0", className), children: children }));
|
|
127
|
+
}
|
|
128
|
+
if (host === HOSTS.POPOVER || host === HOSTS.DROPDOWN) {
|
|
129
|
+
return _jsx("div", { className: cn("flex flex-col gap-space-4 px-space-4 pt-space-4", className), children: children });
|
|
130
|
+
}
|
|
131
|
+
return _jsx(DialogHeader, { className: className, children: children });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Names the overlay, and a submenu's sheet on a phone. In a dropdown it is the menu's label (hide it with `sr-only`
|
|
135
|
+
* where the trigger already says it); in a dropdown's submenu it is read by screen readers only, since the row
|
|
136
|
+
* beside it names it.
|
|
137
|
+
*/
|
|
138
|
+
export function ResponsiveOverlayTitle({ className, children }) {
|
|
139
|
+
const host = useContext(HostContext);
|
|
140
|
+
const isMenuSheet = useContext(MenuSheetContext);
|
|
141
|
+
const isInSubmenu = useContext(SubmenuContext);
|
|
142
|
+
if (host === HOSTS.DRAWER) {
|
|
143
|
+
return _jsx(DrawerTitle, { className: cn(isMenuSheet && MENU_SHEET_TITLE_CLASSES, className), children: children });
|
|
144
|
+
}
|
|
145
|
+
if (host === HOSTS.POPOVER) {
|
|
146
|
+
return _jsx("p", { className: cn("m-0 text-card-title text-ink", className), children: children });
|
|
147
|
+
}
|
|
148
|
+
if (host === HOSTS.DROPDOWN) {
|
|
149
|
+
return _jsx("div", { className: cn(DROPDOWN_MENU_LABEL_CLASSES, isInSubmenu && "sr-only", className), children: children });
|
|
150
|
+
}
|
|
151
|
+
return _jsx(DialogTitle, { className: className, children: children });
|
|
152
|
+
}
|
|
153
|
+
export function ResponsiveOverlayDescription({ className, children }) {
|
|
154
|
+
const host = useContext(HostContext);
|
|
155
|
+
if (host === HOSTS.DRAWER) {
|
|
156
|
+
return _jsx(DrawerDescription, { className: className, children: children });
|
|
157
|
+
}
|
|
158
|
+
if (host === HOSTS.POPOVER || host === HOSTS.DROPDOWN) {
|
|
159
|
+
return _jsx("p", { className: cn("m-0 text-ui text-muted", className), children: children });
|
|
160
|
+
}
|
|
161
|
+
return _jsx(DialogDescription, { className: className, children: children });
|
|
162
|
+
}
|
|
163
|
+
/** The actions. In the sheet they stack full width. */
|
|
164
|
+
export function ResponsiveOverlayFooter({ className, children }) {
|
|
165
|
+
const host = useContext(HostContext);
|
|
166
|
+
if (host === HOSTS.DRAWER) {
|
|
167
|
+
return _jsx(DrawerFooter, { className: cn("px-0", className), children: children });
|
|
168
|
+
}
|
|
169
|
+
return _jsx(DialogFooter, { className: className, children: children });
|
|
170
|
+
}
|
|
171
|
+
/** A row drawn as the element it is given (a Link), its own click kept, the way `render` works in the system. */
|
|
172
|
+
function RenderedRow({ render, children, className, onClick, ...rest }) {
|
|
173
|
+
const handleClick = (event) => {
|
|
174
|
+
render.props.onClick?.(event);
|
|
175
|
+
onClick();
|
|
176
|
+
};
|
|
177
|
+
return cloneElement(render, { ...rest, className: cn(className, render.props.className), onClick: handleClick }, children);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A row that closes the whole overlay on a pick: a menu item in the dropdown (arrow keys, typeahead), a button
|
|
181
|
+
* elsewhere. A 16px icon, then the label, as children.
|
|
182
|
+
*/
|
|
183
|
+
export function ResponsiveOverlayItem({ className, children, onSelect, render, disabled, variant }) {
|
|
184
|
+
const host = useContext(HostContext);
|
|
185
|
+
const { close } = useContext(OverlayRootContext);
|
|
186
|
+
const handleClick = () => {
|
|
187
|
+
onSelect?.();
|
|
188
|
+
close();
|
|
189
|
+
};
|
|
190
|
+
if (host === HOSTS.DROPDOWN) {
|
|
191
|
+
return (_jsx(DropdownMenuItem, { render: render, disabled: disabled, variant: variant, className: className, onClick: onSelect, children: children }));
|
|
192
|
+
}
|
|
193
|
+
if (render) {
|
|
194
|
+
return (_jsx(RenderedRow, { render: render, "aria-disabled": disabled || undefined, "data-variant": variant, onClick: handleClick, className: getRowClassName(host, className), children: children }));
|
|
195
|
+
}
|
|
196
|
+
return (_jsx("button", { type: "button", disabled: disabled, "data-variant": variant, onClick: handleClick, className: getRowClassName(host, className), children: children }));
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A section header over the rows that follow it, in every form. DropdownMenuLabel must sit inside a group; this one
|
|
200
|
+
* doesn't, so it draws the label's look itself.
|
|
201
|
+
*/
|
|
202
|
+
export function ResponsiveOverlayLabel({ className, children }) {
|
|
203
|
+
return _jsx("div", { className: cn(DROPDOWN_MENU_LABEL_CLASSES, className), children: children });
|
|
204
|
+
}
|
|
205
|
+
export function ResponsiveOverlaySeparator() {
|
|
206
|
+
const host = useContext(HostContext);
|
|
207
|
+
if (host === HOSTS.DROPDOWN) {
|
|
208
|
+
return _jsx(DropdownMenuSeparator, {});
|
|
209
|
+
}
|
|
210
|
+
return _jsx(Separator, { className: "mx-space-8 my-1.25 data-[orientation=horizontal]:w-auto" });
|
|
211
|
+
}
|
|
212
|
+
/** One pick among options: the dropdown's radio items, rows with a check elsewhere. */
|
|
213
|
+
export function ResponsiveOverlayRadioGroup({ value, onChange, children }) {
|
|
214
|
+
const host = useContext(HostContext);
|
|
215
|
+
if (host === HOSTS.DROPDOWN) {
|
|
216
|
+
return (_jsx(DropdownMenuRadioGroup, { value: value, onValueChange: onChange, children: children }));
|
|
217
|
+
}
|
|
218
|
+
return (_jsx(RadioGroupContext.Provider, { value: { value, onChange }, children: _jsx("div", { role: "radiogroup", children: children }) }));
|
|
219
|
+
}
|
|
220
|
+
/** One option; the current one shows a `link` check on the right. A pick closes the whole overlay. */
|
|
221
|
+
export function ResponsiveOverlayRadioItem({ value, description, disabled, className, children }) {
|
|
222
|
+
const host = useContext(HostContext);
|
|
223
|
+
const group = useContext(RadioGroupContext);
|
|
224
|
+
const { close } = useContext(OverlayRootContext);
|
|
225
|
+
if (host === HOSTS.DROPDOWN) {
|
|
226
|
+
return (_jsx(DropdownMenuRadioItem, { value: value, disabled: disabled, description: description, closeOnClick: true, className: className, children: children }));
|
|
227
|
+
}
|
|
228
|
+
if (!group) {
|
|
229
|
+
throw new Error("ResponsiveOverlayRadioItem must be inside ResponsiveOverlayRadioGroup");
|
|
230
|
+
}
|
|
231
|
+
const isChecked = group.value === value;
|
|
232
|
+
const handleClick = () => {
|
|
233
|
+
group.onChange(value);
|
|
234
|
+
close();
|
|
235
|
+
};
|
|
236
|
+
return (_jsx("button", { type: "button", role: "radio", "aria-checked": isChecked, disabled: disabled, onClick: handleClick, className: getRowClassName(host, className), children: _jsx(CheckedRowBody, { isChecked: isChecked, description: description, children: children }) }));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* One of several options that can be on together (a filter's values): a `link` check on the right while it is on. A
|
|
240
|
+
* pick keeps the overlay open, so several can be ticked in one go.
|
|
241
|
+
*/
|
|
242
|
+
export function ResponsiveOverlayCheckboxItem({ checked, onCheckedChange, description, disabled, className, children, }) {
|
|
243
|
+
const host = useContext(HostContext);
|
|
244
|
+
if (host === HOSTS.DROPDOWN) {
|
|
245
|
+
return (_jsx(DropdownMenuCheckboxItem, { checked: checked, onCheckedChange: (isChecked) => onCheckedChange(isChecked), disabled: disabled, description: description, className: className, children: children }));
|
|
246
|
+
}
|
|
247
|
+
return (_jsx("button", { type: "button", role: "checkbox", "aria-checked": checked, disabled: disabled, onClick: () => onCheckedChange(!checked), className: getRowClassName(host, className), children: _jsx(CheckedRowBody, { isChecked: checked, description: description, children: children }) }));
|
|
248
|
+
}
|
|
249
|
+
/** A radio or checkbox row outside the dropdown: the label and its second line, then the check while it is on. */
|
|
250
|
+
function CheckedRowBody({ isChecked, description, children }) {
|
|
251
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex min-w-0 flex-1 flex-col py-space-4", children: [_jsx(RowLabel, { children: children }), description && _jsx("span", { className: "text-small text-muted", children: description })] }), _jsx("span", { className: cn("flex", !isChecked && "invisible"), children: _jsx(Check, { className: "text-link" }) })] }));
|
|
252
|
+
}
|
|
253
|
+
/** A leading icon stays beside the label, and the label truncates, as in the dropdown. */
|
|
254
|
+
function RowLabel({ children }) {
|
|
255
|
+
const nodes = Children.toArray(children);
|
|
256
|
+
const firstTextIndex = nodes.findIndex((node) => typeof node === "string" || typeof node === "number");
|
|
257
|
+
const lead = firstTextIndex > 0 ? nodes.slice(0, firstTextIndex) : [];
|
|
258
|
+
const label = firstTextIndex > 0 ? nodes.slice(firstTextIndex) : nodes;
|
|
259
|
+
return (_jsxs("span", { className: "flex min-w-0 items-center gap-space-8 [&>svg]:text-ink-2", children: [lead, _jsx("span", { className: "min-w-0 truncate", children: label })] }));
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* A submenu: a flyout in the dropdown, a second sheet over the first on a phone (the first steps back), a popover
|
|
263
|
+
* beside its row in a dialog or a popover.
|
|
264
|
+
*/
|
|
265
|
+
export function ResponsiveOverlaySub({ children }) {
|
|
266
|
+
const host = useContext(HostContext);
|
|
267
|
+
if (host === HOSTS.DROPDOWN) {
|
|
268
|
+
return _jsx(DropdownMenuSub, { children: children });
|
|
269
|
+
}
|
|
270
|
+
if (host === HOSTS.DRAWER) {
|
|
271
|
+
return _jsx(Drawer, { swipeDirection: DRAWER_SWIPE_DIRECTIONS.DOWN, children: children });
|
|
272
|
+
}
|
|
273
|
+
return _jsx(Popover, { children: children });
|
|
274
|
+
}
|
|
275
|
+
/** The row that opens the submenu, with a `muted` chevron on the right. */
|
|
276
|
+
export function ResponsiveOverlaySubTrigger({ className, children }) {
|
|
277
|
+
const host = useContext(HostContext);
|
|
278
|
+
if (host === HOSTS.DROPDOWN) {
|
|
279
|
+
return _jsx(DropdownMenuSubTrigger, { className: className, children: children });
|
|
280
|
+
}
|
|
281
|
+
const row = (_jsxs("button", { type: "button", className: getRowClassName(host, className), children: [children, _jsx(ChevronRight, { className: "ml-auto text-muted" })] }));
|
|
282
|
+
if (host === HOSTS.DRAWER) {
|
|
283
|
+
return _jsx(DrawerTrigger, { render: row });
|
|
284
|
+
}
|
|
285
|
+
return _jsx(PopoverTrigger, { render: row });
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The submenu's rows, under a ResponsiveOverlayTitle that names its sheet on a phone. A submenu's sheet is always a
|
|
289
|
+
* list of rows, padded like a menu's.
|
|
290
|
+
*/
|
|
291
|
+
export function ResponsiveOverlaySubContent({ className, children, sideOffset }) {
|
|
292
|
+
const host = useContext(HostContext);
|
|
293
|
+
const rows = _jsx(SubmenuContext.Provider, { value: true, children: children });
|
|
294
|
+
if (host === HOSTS.DROPDOWN) {
|
|
295
|
+
return (_jsx(DropdownMenuSubContent, { className: className, sideOffset: sideOffset, children: rows }));
|
|
296
|
+
}
|
|
297
|
+
if (host === HOSTS.DRAWER) {
|
|
298
|
+
return (_jsx(DrawerContent, { className: getSheetClassName(true, className), children: _jsx(MenuSheetContext.Provider, { value: true, children: rows }) }));
|
|
299
|
+
}
|
|
300
|
+
return (_jsx(PopoverContent, { side: "right", align: "start", sideOffset: sideOffset, className: cn("p-space-16", className), children: rows }));
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=responsive-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-overlay.js","sourceRoot":"","sources":["../../src/components/responsive-overlay.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,GAMT,MA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UAAU,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,kBAAE,QAAQ,GAA2B,CAAC;IAEjF,IAAI,IAAI,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5B,OAAO,CACL,KAAC,sBAAsB,IAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,YACjE,IAAI,GACkB,CAC1B,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,CACL,KAAC,aAAa,IAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,YAC1D,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,kBAAE,IAAI,GAA6B,GACrD,CACjB,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,YACtG,IAAI,GACU,CAClB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport {\n Children,\n cloneElement,\n createContext,\n useContext,\n useState,\n type ComponentProps,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Check, ChevronRight } from \"lucide-react\";\nimport { useIsMobile } from \"../hooks/use-is-mobile.ts\";\nimport { cn } from \"../lib/cn.ts\";\nimport { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from \"./dialog.tsx\";\nimport {\n DRAWER_SWIPE_DIRECTIONS,\n Drawer,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"./drawer.tsx\";\nimport {\n DROPDOWN_MENU_ITEM_CLASSES,\n DROPDOWN_MENU_ITEM_VARIANTS,\n DROPDOWN_MENU_LABEL_CLASSES,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from \"./dropdown-menu.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover.tsx\";\nimport { Separator } from \"./separator.tsx\";\n\n/** What it opens as from 768px up. Below that it is always a sheet from the bottom. */\nexport const RESPONSIVE_OVERLAY_DESKTOP_VARIANTS = {\n DIALOG: \"dialog\",\n POPOVER: \"popover\",\n DROPDOWN: \"dropdown\",\n} as const;\n\ntype DesktopVariant = (typeof RESPONSIVE_OVERLAY_DESKTOP_VARIANTS)[keyof typeof RESPONSIVE_OVERLAY_DESKTOP_VARIANTS];\n\nconst HOSTS = { ...RESPONSIVE_OVERLAY_DESKTOP_VARIANTS, DRAWER: \"drawer\" } as const;\n\ntype Host = (typeof HOSTS)[keyof typeof HOSTS];\n\ntype ItemVariant = (typeof DROPDOWN_MENU_ITEM_VARIANTS)[keyof typeof DROPDOWN_MENU_ITEM_VARIANTS];\n\nconst HostContext = createContext<Host>(HOSTS.DIALOG);\n\ninterface OverlayRoot {\n /** Closes the whole overlay, a submenu's sheet with it. */\n close: () => void;\n /** A dropdown on desktop: its sheet on a phone is a menu too. */\n isMenu: boolean;\n}\n\nconst OverlayRootContext = createContext<OverlayRoot>({ close: () => {}, isMenu: false });\n\n/** Whether the sheet around a part is a list of rows: a dropdown's, or a submenu's. */\nconst MenuSheetContext = createContext(false);\n/** Whether a part sits in a submenu's rows. */\nconst SubmenuContext = createContext(false);\n\ninterface RadioGroupValue {\n value: string;\n onChange: (value: string) => void;\n}\n\nconst RadioGroupContext = createContext<RadioGroupValue | null>(null);\n\n/**\n * A menu's sheet pads like the dropdown it replaces: its rows carry their own inset. The bottom keeps the iPhone\n * home indicator's inset on top.\n */\nconst MENU_SHEET_CLASSES = \"px-space-8 pt-space-8 pb-[calc(var(--spacing-space-16)+env(safe-area-inset-bottom))]\";\n/** A menu's title, in line with its rows' text as the dropdown's label is. */\nconst MENU_SHEET_TITLE_CLASSES = \"px-space-8 pb-space-8\";\n\n/**\n * A row outside the dropdown: the menu's row with the states a plain button gets. In a sheet it is 40px, tall enough\n * for a thumb and close enough to read as one menu.\n */\nfunction getRowClassName(host: Host, className?: string) {\n return cn(\n DROPDOWN_MENU_ITEM_CLASSES,\n \"hover:bg-hover focus-visible:bg-hover disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50\",\n \"data-[variant=destructive]:text-danger data-[variant=destructive]:[&>svg]:text-danger\",\n host === HOSTS.DRAWER && \"min-h-10\",\n className\n );\n}\n\n/**\n * The sheet pads its content once and scrolls it past its height cap. It is always full width, so a desktop width\n * the caller set (`w-60`, `sm:max-w-lg`) gives way, and so does a menu's desktop padding (`p-0` around a searchable\n * list). The strip the drawer keeps past its bottom edge is dropped: in a sheet that scrolls it would add empty space\n * under the content.\n */\nfunction getSheetClassName(isMenu: boolean, className?: string) {\n return cn(\"overflow-y-auto px-5 after:hidden\", className, isMenu && MENU_SHEET_CLASSES, \"w-full max-w-none sm:max-w-none\");\n}\n\nexport interface ResponsiveOverlayProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** What it opens as from 768px up: a dialog (default), a popover or a dropdown menu. */\n desktopVariant?: DesktopVariant;\n modal?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One overlay for both widths: a Dialog, Popover or DropdownMenu from 768px up, a Drawer from the bottom below it.\n * The parts render the matching parts of whichever it is, so a screen writes its overlay once. Open state is held\n * here, so the overlay stays open when the window crosses 768px, and a row can close it in every form.\n */\nexport function ResponsiveOverlay({\n open,\n defaultOpen = false,\n onOpenChange,\n desktopVariant = RESPONSIVE_OVERLAY_DESKTOP_VARIANTS.DIALOG,\n modal,\n children,\n}: ResponsiveOverlayProps) {\n const isMobile = useIsMobile();\n const host: Host = isMobile ? HOSTS.DRAWER : desktopVariant;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n\n const handleOpenChange = (next: boolean) => {\n if (open === undefined) {\n setUncontrolledOpen(next);\n }\n\n onOpenChange?.(next);\n };\n\n const root = { close: () => handleOpenChange(false), isMenu: desktopVariant === RESPONSIVE_OVERLAY_DESKTOP_VARIANTS.DROPDOWN };\n\n return (\n <OverlayRootContext.Provider value={root}>\n <HostContext.Provider value={host}>\n <HostRoot host={host} open={isOpen} onOpenChange={handleOpenChange} modal={modal}>\n {children}\n </HostRoot>\n </HostContext.Provider>\n </OverlayRootContext.Provider>\n );\n}\n\ninterface HostRootProps {\n host: Host;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n modal?: boolean;\n children?: ReactNode;\n}\n\n/** The root of whichever the overlay is at this width. */\nfunction HostRoot({ host, ...props }: HostRootProps) {\n if (host === HOSTS.DRAWER) {\n return <Drawer swipeDirection={DRAWER_SWIPE_DIRECTIONS.DOWN} {...props} />;\n }\n\n if (host === HOSTS.POPOVER) {\n return <Popover {...props} />;\n }\n\n if (host === HOSTS.DROPDOWN) {\n return <DropdownMenu {...props} />;\n }\n\n return <Dialog {...props} />;\n}\n\n/** Closes the whole overlay from inside it, for a pick that isn't one of its rows (a searchable list's item). */\nexport function useResponsiveOverlayClose(): () => void {\n return useContext(OverlayRootContext).close;\n}\n\n/** Whether this part sits in the phone's sheet: the overlay's own answer, not a second viewport check. */\nexport function useIsInResponsiveOverlayDrawer(): boolean {\n return useContext(HostContext) === HOSTS.DRAWER;\n}\n\ntype ResponsiveOverlayTriggerProps = Omit<HTMLAttributes<HTMLElement>, \"children\"> & {\n /** The control, as the system's triggers take it (`render={<Button />}`); its label goes in children. */\n render: ReactElement;\n children?: ReactNode;\n};\n\n/** The control that opens it. Props a wrapping trigger adds (a Tooltip's) pass through to it. */\nexport function ResponsiveOverlayTrigger({ render, children, ...props }: ResponsiveOverlayTriggerProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuTrigger render={render} {...props}>\n {children}\n </DropdownMenuTrigger>\n );\n }\n\n if (host === HOSTS.DRAWER) {\n return (\n <DrawerTrigger render={render} {...props}>\n {children}\n </DrawerTrigger>\n );\n }\n\n if (host === HOSTS.POPOVER) {\n return (\n <PopoverTrigger render={render} {...props}>\n {children}\n </PopoverTrigger>\n );\n }\n\n return (\n <DialogTrigger render={render} {...props}>\n {children}\n </DialogTrigger>\n );\n}\n\ntype ContentPosition = Pick<ComponentProps<typeof DropdownMenuContent>, \"align\" | \"side\" | \"sideOffset\">;\n\nexport interface ResponsiveOverlayContentProps extends ContentPosition {\n className?: string;\n children?: ReactNode;\n /** The dialog's ×. */\n showCloseButton?: boolean;\n /** The sheet's grab handle. */\n showHandle?: boolean;\n}\n\n/**\n * The surface. A dialog fills the width up to 512px; size it with a `w-*` (up to 512px) or an `sm:max-w-*` class. A\n * popover pads 16px unless the className sets its own. `align`, `side` and `sideOffset` place a popover or a\n * dropdown; the sheet ignores them and every width.\n */\nexport function ResponsiveOverlayContent({\n className,\n children,\n align,\n side,\n sideOffset,\n showCloseButton,\n showHandle = true,\n}: ResponsiveOverlayContentProps) {\n const host = useContext(HostContext);\n const { isMenu } = useContext(OverlayRootContext);\n\n if (host === HOSTS.DRAWER) {\n return (\n <DrawerContent className={getSheetClassName(isMenu, className)} showSwipeHandle={showHandle}>\n <MenuSheetContext.Provider value={isMenu}>{children}</MenuSheetContext.Provider>\n </DrawerContent>\n );\n }\n\n if (host === HOSTS.POPOVER) {\n return (\n <PopoverContent className={cn(\"p-space-16\", className)} align={align} side={side} sideOffset={sideOffset}>\n {children}\n </PopoverContent>\n );\n }\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuContent className={className} align={align} side={side} sideOffset={sideOffset}>\n {children}\n </DropdownMenuContent>\n );\n }\n\n return (\n <DialogContent className={cn(\"w-full sm:max-w-lg\", className)} showCloseButton={showCloseButton}>\n {children}\n </DialogContent>\n );\n}\n\ninterface SlotProps {\n className?: string;\n children?: ReactNode;\n}\n\n/** The title and description. The sheet has no ×: a swipe, the dimmed page or a pick closes it. */\nexport function ResponsiveOverlayHeader({ className, children }: SlotProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DRAWER) {\n return (\n <DrawerHeader showCloseButton={false} className={cn(\"px-0\", className)}>\n {children}\n </DrawerHeader>\n );\n }\n\n if (host === HOSTS.POPOVER || host === HOSTS.DROPDOWN) {\n return <div className={cn(\"flex flex-col gap-space-4 px-space-4 pt-space-4\", className)}>{children}</div>;\n }\n\n return <DialogHeader className={className}>{children}</DialogHeader>;\n}\n\n/**\n * Names the overlay, and a submenu's sheet on a phone. In a dropdown it is the menu's label (hide it with `sr-only`\n * where the trigger already says it); in a dropdown's submenu it is read by screen readers only, since the row\n * beside it names it.\n */\nexport function ResponsiveOverlayTitle({ className, children }: SlotProps) {\n const host = useContext(HostContext);\n const isMenuSheet = useContext(MenuSheetContext);\n const isInSubmenu = useContext(SubmenuContext);\n\n if (host === HOSTS.DRAWER) {\n return <DrawerTitle className={cn(isMenuSheet && MENU_SHEET_TITLE_CLASSES, className)}>{children}</DrawerTitle>;\n }\n\n if (host === HOSTS.POPOVER) {\n return <p className={cn(\"m-0 text-card-title text-ink\", className)}>{children}</p>;\n }\n\n if (host === HOSTS.DROPDOWN) {\n return <div className={cn(DROPDOWN_MENU_LABEL_CLASSES, isInSubmenu && \"sr-only\", className)}>{children}</div>;\n }\n\n return <DialogTitle className={className}>{children}</DialogTitle>;\n}\n\nexport function ResponsiveOverlayDescription({ className, children }: SlotProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DRAWER) {\n return <DrawerDescription className={className}>{children}</DrawerDescription>;\n }\n\n if (host === HOSTS.POPOVER || host === HOSTS.DROPDOWN) {\n return <p className={cn(\"m-0 text-ui text-muted\", className)}>{children}</p>;\n }\n\n return <DialogDescription className={className}>{children}</DialogDescription>;\n}\n\n/** The actions. In the sheet they stack full width. */\nexport function ResponsiveOverlayFooter({ className, children }: SlotProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DRAWER) {\n return <DrawerFooter className={cn(\"px-0\", className)}>{children}</DrawerFooter>;\n }\n\n return <DialogFooter className={className}>{children}</DialogFooter>;\n}\n\ninterface RowElementProps {\n className?: string;\n onClick?: (event: MouseEvent) => void;\n}\n\ninterface RenderedRowProps {\n render: ReactElement<RowElementProps>;\n className: string;\n onClick: () => void;\n children?: ReactNode;\n \"aria-disabled\"?: boolean;\n \"data-variant\"?: string;\n}\n\n/** A row drawn as the element it is given (a Link), its own click kept, the way `render` works in the system. */\nfunction RenderedRow({ render, children, className, onClick, ...rest }: RenderedRowProps) {\n const handleClick = (event: MouseEvent) => {\n render.props.onClick?.(event);\n onClick();\n };\n\n return cloneElement(\n render as ReactElement<RowElementProps & Record<string, unknown>>,\n { ...rest, className: cn(className, render.props.className), onClick: handleClick },\n children\n );\n}\n\nexport interface ResponsiveOverlayItemProps extends SlotProps {\n /** Runs on a pick; then the whole overlay closes. Optional for a link row, which navigates on its own. */\n onSelect?: () => void;\n /** The element the row is drawn as (a Link), as the system's menu items take it. */\n render?: ReactElement<RowElementProps>;\n disabled?: boolean;\n /** `destructive` (Delete): danger text and icon, last, after a separator. */\n variant?: ItemVariant;\n}\n\n/**\n * A row that closes the whole overlay on a pick: a menu item in the dropdown (arrow keys, typeahead), a button\n * elsewhere. A 16px icon, then the label, as children.\n */\nexport function ResponsiveOverlayItem({ className, children, onSelect, render, disabled, variant }: ResponsiveOverlayItemProps) {\n const host = useContext(HostContext);\n const { close } = useContext(OverlayRootContext);\n\n const handleClick = () => {\n onSelect?.();\n close();\n };\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuItem render={render} disabled={disabled} variant={variant} className={className} onClick={onSelect}>\n {children}\n </DropdownMenuItem>\n );\n }\n\n if (render) {\n return (\n <RenderedRow\n render={render}\n aria-disabled={disabled || undefined}\n data-variant={variant}\n onClick={handleClick}\n className={getRowClassName(host, className)}\n >\n {children}\n </RenderedRow>\n );\n }\n\n return (\n <button type=\"button\" disabled={disabled} data-variant={variant} onClick={handleClick} className={getRowClassName(host, className)}>\n {children}\n </button>\n );\n}\n\n/**\n * A section header over the rows that follow it, in every form. DropdownMenuLabel must sit inside a group; this one\n * doesn't, so it draws the label's look itself.\n */\nexport function ResponsiveOverlayLabel({ className, children }: SlotProps) {\n return <div className={cn(DROPDOWN_MENU_LABEL_CLASSES, className)}>{children}</div>;\n}\n\nexport function ResponsiveOverlaySeparator() {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return <DropdownMenuSeparator />;\n }\n\n return <Separator className=\"mx-space-8 my-1.25 data-[orientation=horizontal]:w-auto\" />;\n}\n\nexport interface ResponsiveOverlayRadioGroupProps {\n value: string;\n onChange: (value: string) => void;\n children?: ReactNode;\n}\n\n/** One pick among options: the dropdown's radio items, rows with a check elsewhere. */\nexport function ResponsiveOverlayRadioGroup({ value, onChange, children }: ResponsiveOverlayRadioGroupProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuRadioGroup value={value} onValueChange={onChange}>\n {children}\n </DropdownMenuRadioGroup>\n );\n }\n\n return (\n <RadioGroupContext.Provider value={{ value, onChange }}>\n <div role=\"radiogroup\">{children}</div>\n </RadioGroupContext.Provider>\n );\n}\n\nexport interface ResponsiveOverlayRadioItemProps extends SlotProps {\n value: string;\n /** A second line in 12px `muted`, such as why the option is off. */\n description?: ReactNode;\n disabled?: boolean;\n}\n\n/** One option; the current one shows a `link` check on the right. A pick closes the whole overlay. */\nexport function ResponsiveOverlayRadioItem({ value, description, disabled, className, children }: ResponsiveOverlayRadioItemProps) {\n const host = useContext(HostContext);\n const group = useContext(RadioGroupContext);\n const { close } = useContext(OverlayRootContext);\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuRadioItem value={value} disabled={disabled} description={description} closeOnClick className={className}>\n {children}\n </DropdownMenuRadioItem>\n );\n }\n\n if (!group) {\n throw new Error(\"ResponsiveOverlayRadioItem must be inside ResponsiveOverlayRadioGroup\");\n }\n\n const isChecked = group.value === value;\n\n const handleClick = () => {\n group.onChange(value);\n close();\n };\n\n return (\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked={isChecked}\n disabled={disabled}\n onClick={handleClick}\n className={getRowClassName(host, className)}\n >\n <CheckedRowBody isChecked={isChecked} description={description}>\n {children}\n </CheckedRowBody>\n </button>\n );\n}\n\nexport interface ResponsiveOverlayCheckboxItemProps extends SlotProps {\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n /** A second line in 12px `muted`, such as why the option is off. */\n description?: ReactNode;\n disabled?: boolean;\n}\n\n/**\n * One of several options that can be on together (a filter's values): a `link` check on the right while it is on. A\n * pick keeps the overlay open, so several can be ticked in one go.\n */\nexport function ResponsiveOverlayCheckboxItem({\n checked,\n onCheckedChange,\n description,\n disabled,\n className,\n children,\n}: ResponsiveOverlayCheckboxItemProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuCheckboxItem\n checked={checked}\n onCheckedChange={(isChecked) => onCheckedChange(isChecked)}\n disabled={disabled}\n description={description}\n className={className}\n >\n {children}\n </DropdownMenuCheckboxItem>\n );\n }\n\n return (\n <button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={checked}\n disabled={disabled}\n onClick={() => onCheckedChange(!checked)}\n className={getRowClassName(host, className)}\n >\n <CheckedRowBody isChecked={checked} description={description}>\n {children}\n </CheckedRowBody>\n </button>\n );\n}\n\n/** A radio or checkbox row outside the dropdown: the label and its second line, then the check while it is on. */\nfunction CheckedRowBody({ isChecked, description, children }: { isChecked: boolean; description?: ReactNode; children?: ReactNode }) {\n return (\n <>\n <span className=\"flex min-w-0 flex-1 flex-col py-space-4\">\n <RowLabel>{children}</RowLabel>\n {description && <span className=\"text-small text-muted\">{description}</span>}\n </span>\n {/* Wrapped, as in the dropdown's items: the row's icon colour is for its direct svg children. */}\n <span className={cn(\"flex\", !isChecked && \"invisible\")}>\n <Check className=\"text-link\" />\n </span>\n </>\n );\n}\n\n/** A leading icon stays beside the label, and the label truncates, as in the dropdown. */\nfunction RowLabel({ children }: { children?: ReactNode }) {\n const nodes = Children.toArray(children);\n const firstTextIndex = nodes.findIndex((node) => typeof node === \"string\" || typeof node === \"number\");\n const lead = firstTextIndex > 0 ? nodes.slice(0, firstTextIndex) : [];\n const label = firstTextIndex > 0 ? nodes.slice(firstTextIndex) : nodes;\n\n return (\n <span className=\"flex min-w-0 items-center gap-space-8 [&>svg]:text-ink-2\">\n {lead}\n <span className=\"min-w-0 truncate\">{label}</span>\n </span>\n );\n}\n\n/**\n * A submenu: a flyout in the dropdown, a second sheet over the first on a phone (the first steps back), a popover\n * beside its row in a dialog or a popover.\n */\nexport function ResponsiveOverlaySub({ children }: { children?: ReactNode }) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return <DropdownMenuSub>{children}</DropdownMenuSub>;\n }\n\n if (host === HOSTS.DRAWER) {\n return <Drawer swipeDirection={DRAWER_SWIPE_DIRECTIONS.DOWN}>{children}</Drawer>;\n }\n\n return <Popover>{children}</Popover>;\n}\n\n/** The row that opens the submenu, with a `muted` chevron on the right. */\nexport function ResponsiveOverlaySubTrigger({ className, children }: SlotProps) {\n const host = useContext(HostContext);\n\n if (host === HOSTS.DROPDOWN) {\n return <DropdownMenuSubTrigger className={className}>{children}</DropdownMenuSubTrigger>;\n }\n\n const row = (\n <button type=\"button\" className={getRowClassName(host, className)}>\n {children}\n <ChevronRight className=\"ml-auto text-muted\" />\n </button>\n );\n\n if (host === HOSTS.DRAWER) {\n return <DrawerTrigger render={row} />;\n }\n\n return <PopoverTrigger render={row} />;\n}\n\nexport interface ResponsiveOverlaySubContentProps extends SlotProps {\n sideOffset?: number;\n}\n\n/**\n * The submenu's rows, under a ResponsiveOverlayTitle that names its sheet on a phone. A submenu's sheet is always a\n * list of rows, padded like a menu's.\n */\nexport function ResponsiveOverlaySubContent({ className, children, sideOffset }: ResponsiveOverlaySubContentProps) {\n const host = useContext(HostContext);\n const rows = <SubmenuContext.Provider value>{children}</SubmenuContext.Provider>;\n\n if (host === HOSTS.DROPDOWN) {\n return (\n <DropdownMenuSubContent className={className} sideOffset={sideOffset}>\n {rows}\n </DropdownMenuSubContent>\n );\n }\n\n if (host === HOSTS.DRAWER) {\n return (\n <DrawerContent className={getSheetClassName(true, className)}>\n <MenuSheetContext.Provider value>{rows}</MenuSheetContext.Provider>\n </DrawerContent>\n );\n }\n\n return (\n <PopoverContent side=\"right\" align=\"start\" sideOffset={sideOffset} className={cn(\"p-space-16\", className)}>\n {rows}\n </PopoverContent>\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
export type ScrollShadowsProps = useRender.ComponentProps<"div">;
|
|
3
|
+
/**
|
|
4
|
+
* A scroll container that fades its content out on the edges that have more to scroll to, and nowhere else, so an
|
|
5
|
+
* unscrolled list reads as plain content and a cut-off row never looks clipped. Vertical, horizontal or both: the
|
|
6
|
+
* fades follow whichever way it overflows, and update as content arrives or resizes. The fades are a mask on the
|
|
7
|
+
* content, so they work on any surface. It renders one element, the scroller: a `<div>`, or the list itself with
|
|
8
|
+
* `render={<ul />}`. Its props, `className` (a `max-h-*`, the list's own layout) and `ref` go on it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ScrollShadows({ render, className, style, children, ref, onScroll, ...props }: ScrollShadowsProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
+
//# sourceMappingURL=scroll-shadows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-shadows.d.ts","sourceRoot":"","sources":["../../src/components/scroll-shadows.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAUtD,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,8FAgDhH"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { NO_SCROLL_FADE_EDGES, buildScrollFadeStyle, checkIfSameScrollFadeEdges, readScrollFadeEdges, } from "../lib/scroll-fade.js";
|
|
7
|
+
/**
|
|
8
|
+
* A scroll container that fades its content out on the edges that have more to scroll to, and nowhere else, so an
|
|
9
|
+
* unscrolled list reads as plain content and a cut-off row never looks clipped. Vertical, horizontal or both: the
|
|
10
|
+
* fades follow whichever way it overflows, and update as content arrives or resizes. The fades are a mask on the
|
|
11
|
+
* content, so they work on any surface. It renders one element, the scroller: a `<div>`, or the list itself with
|
|
12
|
+
* `render={<ul />}`. Its props, `className` (a `max-h-*`, the list's own layout) and `ref` go on it.
|
|
13
|
+
*/
|
|
14
|
+
export function ScrollShadows({ render, className, style, children, ref, onScroll, ...props }) {
|
|
15
|
+
const scrollerRef = useRef(null);
|
|
16
|
+
const [edges, setEdges] = useState(NO_SCROLL_FADE_EDGES);
|
|
17
|
+
// Stores the edges only when one changed, so a resize that changes nothing doesn't re-render.
|
|
18
|
+
const syncEdges = (scroller) => {
|
|
19
|
+
const next = readScrollFadeEdges(scroller);
|
|
20
|
+
setEdges((current) => (checkIfSameScrollFadeEdges(current, next) ? current : next));
|
|
21
|
+
};
|
|
22
|
+
// Content that arrives or resizes after mount changes which edges overflow without a scroll event.
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const scroller = scrollerRef.current;
|
|
25
|
+
if (!scroller) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const observer = new ResizeObserver(() => syncEdges(scroller));
|
|
29
|
+
observer.observe(scroller);
|
|
30
|
+
for (const child of scroller.children) {
|
|
31
|
+
observer.observe(child);
|
|
32
|
+
}
|
|
33
|
+
return () => observer.disconnect();
|
|
34
|
+
// syncEdges reads only its argument and the state setter, so the first one stays right.
|
|
35
|
+
}, [children]);
|
|
36
|
+
const handleScroll = (event) => {
|
|
37
|
+
onScroll?.(event);
|
|
38
|
+
syncEdges(event.currentTarget);
|
|
39
|
+
};
|
|
40
|
+
return useRender({
|
|
41
|
+
defaultTagName: "div",
|
|
42
|
+
render,
|
|
43
|
+
ref: ref ? [ref, scrollerRef] : scrollerRef,
|
|
44
|
+
state: { slot: "scroll-shadows" },
|
|
45
|
+
props: mergeProps(props, {
|
|
46
|
+
onScroll: handleScroll,
|
|
47
|
+
className: cn("min-h-0 overflow-auto", className),
|
|
48
|
+
style: { ...style, ...buildScrollFadeStyle(edges) },
|
|
49
|
+
children,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=scroll-shadows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-shadows.js","sourceRoot":"","sources":["../../src/components/scroll-shadows.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAgB,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,oB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AM,YAAY,GAAG,CAAC,KAA8B,EAAE,EAAE;QACtD,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;QAClB,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;QACf,cAAc,EAAE,KAAK;QACrB,MAAM;QACN,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW;QAC3C,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACjC,KAAK,EAAE,UAAU,CAAQ,KAAK,EAAE;YAC9B,QAAQ,EAAE,YAAY;YACtB,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC;YACjD,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,EAAE;YACnD,QAAQ;SACT,CAAC;KACH,CAAC,CAAC;AACL,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type UIEvent } from \"react\";\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cn } from \"../lib/cn.ts\";\nimport {\n NO_SCROLL_FADE_EDGES,\n buildScrollFadeStyle,\n checkIfSameScrollFadeEdges,\n readScrollFadeEdges,\n type ScrollFadeEdges,\n} from \"../lib/scroll-fade.ts\";\n\nexport type ScrollShadowsProps = useRender.ComponentProps<\"div\">;\n\n/**\n * A scroll container that fades its content out on the edges that have more to scroll to, and nowhere else, so an\n * unscrolled list reads as plain content and a cut-off row never looks clipped. Vertical, horizontal or both: the\n * fades follow whichever way it overflows, and update as content arrives or resizes. The fades are a mask on the\n * content, so they work on any surface. It renders one element, the scroller: a `<div>`, or the list itself with\n * `render={<ul />}`. Its props, `className` (a `max-h-*`, the list's own layout) and `ref` go on it.\n */\nexport function ScrollShadows({ render, className, style, children, ref, onScroll, ...props }: ScrollShadowsProps) {\n const scrollerRef = useRef<HTMLDivElement | null>(null);\n const [edges, setEdges] = useState<ScrollFadeEdges>(NO_SCROLL_FADE_EDGES);\n\n // Stores the edges only when one changed, so a resize that changes nothing doesn't re-render.\n const syncEdges = (scroller: HTMLElement) => {\n const next = readScrollFadeEdges(scroller);\n\n setEdges((current) => (checkIfSameScrollFadeEdges(current, next) ? current : next));\n };\n\n // Content that arrives or resizes after mount changes which edges overflow without a scroll event.\n useEffect(() => {\n const scroller = scrollerRef.current;\n\n if (!scroller) {\n return;\n }\n\n const observer = new ResizeObserver(() => syncEdges(scroller));\n\n observer.observe(scroller);\n\n for (const child of scroller.children) {\n observer.observe(child);\n }\n\n return () => observer.disconnect();\n // syncEdges reads only its argument and the state setter, so the first one stays right.\n }, [children]);\n\n const handleScroll = (event: UIEvent<HTMLDivElement>) => {\n onScroll?.(event);\n syncEdges(event.currentTarget);\n };\n\n return useRender({\n defaultTagName: \"div\",\n render,\n ref: ref ? [ref, scrollerRef] : scrollerRef,\n state: { slot: \"scroll-shadows\" },\n props: mergeProps<\"div\">(props, {\n onScroll: handleScroll,\n className: cn(\"min-h-0 overflow-auto\", className),\n style: { ...style, ...buildScrollFadeStyle(edges) },\n children,\n }),\n });\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
type SearchFieldProps = Omit<ComponentProps<"input">, "value" | "defaultValue" | "onChange"> & {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onValueChange?: (value: string) => void;
|
|
6
|
+
/** One key ("/") that focuses the field from anywhere on the page. Shown as a Kbd while the field is empty. */
|
|
7
|
+
hotkey?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Filters a list: 34px, 280px wide, a search icon, a clear × once there's text. A form field, never the
|
|
11
|
+
* chat composer. With a `hotkey` it shows the key while empty and focuses itself when the key is pressed
|
|
12
|
+
* anywhere outside another field.
|
|
13
|
+
*/
|
|
14
|
+
declare function SearchField({ className, placeholder, value, defaultValue, onValueChange, hotkey, "aria-label": ariaLabel, ...props }: SearchFieldProps): import("react").JSX.Element;
|
|
15
|
+
export { SearchField };
|
|
16
|
+
//# sourceMappingURL=search-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-field.d.ts","sourceRoot":"","sources":["../../src/components/search-field.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAYzE,KAAK,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,CAAC,GAAG;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAUF;;;;GAIG;AACH,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,WAAsB,EACtB,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,MAAM,EACN,YAAY,EAAE,SAAS,EACvB,GAAG,KAAK,EACT,EAAE,gBAAgB,+BA+DlB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Search, X } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { INPUT_GROUP_ADDON_ALIGNS, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, } from "./input-group.js";
|
|
7
|
+
import { Kbd } from "./kbd.js";
|
|
8
|
+
function checkIfEditableTarget(target) {
|
|
9
|
+
if (!(target instanceof HTMLElement)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Filters a list: 34px, 280px wide, a search icon, a clear × once there's text. A form field, never the
|
|
16
|
+
* chat composer. With a `hotkey` it shows the key while empty and focuses itself when the key is pressed
|
|
17
|
+
* anywhere outside another field.
|
|
18
|
+
*/
|
|
19
|
+
function SearchField({ className, placeholder = "Search", value, defaultValue = "", onValueChange, hotkey, "aria-label": ariaLabel, ...props }) {
|
|
20
|
+
const inputRef = useRef(null);
|
|
21
|
+
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
22
|
+
const currentValue = value ?? innerValue;
|
|
23
|
+
const setValue = (next) => {
|
|
24
|
+
setInnerValue(next);
|
|
25
|
+
onValueChange?.(next);
|
|
26
|
+
};
|
|
27
|
+
const handleClear = () => {
|
|
28
|
+
setValue("");
|
|
29
|
+
inputRef.current?.focus();
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!hotkey) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const handleKeyDown = (event) => {
|
|
36
|
+
const hasModifier = event.metaKey || event.ctrlKey || event.altKey;
|
|
37
|
+
if (event.key !== hotkey || hasModifier || event.defaultPrevented || checkIfEditableTarget(event.target)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
inputRef.current?.focus();
|
|
42
|
+
};
|
|
43
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
44
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
45
|
+
}, [hotkey]);
|
|
46
|
+
const isHotkeyVisible = Boolean(hotkey) && currentValue === "";
|
|
47
|
+
return (_jsxs(InputGroup, { "data-slot": "search-field", className: cn("w-70", className), children: [_jsx(InputGroupAddon, { children: _jsx(Search, {}) }), _jsx(InputGroupInput, { ref: inputRef, type: "search", placeholder: placeholder, "aria-label": ariaLabel ?? placeholder, value: currentValue, onChange: (event) => setValue(event.target.value), className: "[&::-webkit-search-cancel-button]:hidden", ...props }), _jsxs(InputGroupAddon, { align: INPUT_GROUP_ADDON_ALIGNS.INLINE_END, children: [currentValue !== "" && (_jsx(InputGroupButton, { "aria-label": "Clear search", onClick: handleClear, children: _jsx(X, {}) })), isHotkeyVisible && _jsx(Kbd, { className: "mr-space-2 max-md:hidden", children: hotkey })] })] }));
|
|
48
|
+
}
|
|
49
|
+
export { SearchField };
|
|
50
|
+
//# sourceMappingURL=search-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-field.js","sourceRoot":"","sources":["../../src/components/search-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAmB,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAW,CAAC;AAUhC,SAAS,qBAAqB,CAAC,MAA0B;IACvD,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,iBAAiB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9F,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,WAAW,GAAG,QAAQ,EACtB,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,aAAa,EACb,M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AM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,YAAY,KAAK,EAAE,CAAC;IAE/D,OAAO,CACL,MAAC,UAAU,iBAAW,cAAc,EAAC,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,aACnE,KAAC,eAAe,cACd,KAAC,MAAM,KAAG,GACM,EAClB,KAAC,eAAe,IACd,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,QAAQ,EACb,WAAW,EAAE,WAAW,gBACZ,SAAS,IAAI,WAAW,EACpC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,SAAS,EAAC,0CAA0C,KAChD,KAAK,GACT,EACF,MAAC,eAAe,IAAC,KAAK,EAAE,wBAAwB,CAAC,UAAU,aACxD,YAAY,KAAK,EAAE,IAAI,CACtB,KAAC,gBAAgB,kBAAY,cAAc,EAAC,OAAO,EAAE,WAAW,YAC9D,KAAC,CAAC,KAAG,GACY,CACpB,EACA,eAAe,IAAI,KAAC,GAAG,IAAC,SAAS,EAAC,0BAA0B,YAAE,MAAM,GAAO,IAC5D,IACP,CACd,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type ComponentProps } from \"react\";\nimport { Search, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn.ts\";\nimport {\n INPUT_GROUP_ADDON_ALIGNS,\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n} from \"./input-group.tsx\";\nimport { Kbd } from \"./kbd.tsx\";\n\ntype SearchFieldProps = Omit<ComponentProps<\"input\">, \"value\" | \"defaultValue\" | \"onChange\"> & {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** One key (\"/\") that focuses the field from anywhere on the page. Shown as a Kbd while the field is empty. */\n hotkey?: string;\n};\n\nfunction checkIfEditableTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n return target.isContentEditable || [\"INPUT\", \"TEXTAREA\", \"SELECT\"].includes(target.tagName);\n}\n\n/**\n * Filters a list: 34px, 280px wide, a search icon, a clear × once there's text. A form field, never the\n * chat composer. With a `hotkey` it shows the key while empty and focuses itself when the key is pressed\n * anywhere outside another field.\n */\nfunction SearchField({\n className,\n placeholder = \"Search\",\n value,\n defaultValue = \"\",\n onValueChange,\n hotkey,\n \"aria-label\": ariaLabel,\n ...props\n}: SearchFieldProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const currentValue = value ?? innerValue;\n\n const setValue = (next: string) => {\n setInnerValue(next);\n onValueChange?.(next);\n };\n\n const handleClear = () => {\n setValue(\"\");\n inputRef.current?.focus();\n };\n\n useEffect(() => {\n if (!hotkey) {\n return;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const hasModifier = event.metaKey || event.ctrlKey || event.altKey;\n\n if (event.key !== hotkey || hasModifier || event.defaultPrevented || checkIfEditableTarget(event.target)) {\n return;\n }\n\n event.preventDefault();\n inputRef.current?.focus();\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [hotkey]);\n\n const isHotkeyVisible = Boolean(hotkey) && currentValue === \"\";\n\n return (\n <InputGroup data-slot=\"search-field\" className={cn(\"w-70\", className)}>\n <InputGroupAddon>\n <Search />\n </InputGroupAddon>\n <InputGroupInput\n ref={inputRef}\n type=\"search\"\n placeholder={placeholder}\n aria-label={ariaLabel ?? placeholder}\n value={currentValue}\n onChange={(event) => setValue(event.target.value)}\n className=\"[&::-webkit-search-cancel-button]:hidden\"\n {...props}\n />\n <InputGroupAddon align={INPUT_GROUP_ADDON_ALIGNS.INLINE_END}>\n {currentValue !== \"\" && (\n <InputGroupButton aria-label=\"Clear search\" onClick={handleClear}>\n <X />\n </InputGroupButton>\n )}\n {isHotkeyVisible && <Kbd className=\"mr-space-2 max-md:hidden\">{hotkey}</Kbd>}\n </InputGroupAddon>\n </InputGroup>\n );\n}\n\nexport { SearchField };\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { SELECT_TRIGGER_SIZES } from "./select.tsx";
|
|
3
|
+
/**
|
|
4
|
+
* Past this many options a plain list stops being scannable and people scroll for a name they already know: the
|
|
5
|
+
* select grows a search line. The default for `threshold`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SEARCHABLE_SELECT_THRESHOLD = 10;
|
|
8
|
+
export interface SearchableSelectOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** After the label: a lock on a private channel. The search reads the label only. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
type SelectTriggerSize = (typeof SELECT_TRIGGER_SIZES)[keyof typeof SELECT_TRIGGER_SIZES];
|
|
15
|
+
export interface SearchableSelectProps {
|
|
16
|
+
options: SearchableSelectOption[];
|
|
17
|
+
/** The chosen option's value; null while nothing is chosen. */
|
|
18
|
+
value: string | null;
|
|
19
|
+
onValueChange: (value: string) => void;
|
|
20
|
+
/** On the trigger while nothing is chosen, and in the search line unless `searchPlaceholder` is set. */
|
|
21
|
+
placeholder: string;
|
|
22
|
+
searchPlaceholder?: string;
|
|
23
|
+
/** Shown in the search list when nothing matches. */
|
|
24
|
+
emptyText?: string;
|
|
25
|
+
/** Past this many options the field grows a search line. Default: `SEARCHABLE_SELECT_THRESHOLD` (10). */
|
|
26
|
+
threshold?: number;
|
|
27
|
+
size?: SelectTriggerSize;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** For a `<Label htmlFor>`. */
|
|
30
|
+
id?: string;
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
/** On the trigger: its width. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** On either list: its height cap, `max-h-*`. Default: 300px. */
|
|
35
|
+
listClassName?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A Select that grows a search line once its list is too long to scan: up to `threshold` options (ten by default) it
|
|
39
|
+
* is a Select; past that the same field opens a Popover with a Command. Either way it looks like the Select, and its list stops at 300px.
|
|
40
|
+
*/
|
|
41
|
+
export declare function SearchableSelect({ options, value, onValueChange, placeholder, searchPlaceholder, emptyText, threshold, size, disabled, id, "aria-label": ariaLabel, className, listClassName, }: SearchableSelectProps): import("react").JSX.Element;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=searchable-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchable-select.d.ts","sourceRoot":"","sources":["../../src/components/searchable-select.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKjD,OAAO,EACL,oBAAoB,EAOrB,MAAM,cAAc,CAAC;AAEtB;;;GAGG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,KAAK,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAE1F,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC,+DAA+D;IAC/D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yGAAyG;I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