@botiverse/raft-ui 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/components/activity-inbox/activity-inbox-shell.d.mts +12 -0
- package/dist/components/activity-inbox/activity-inbox-shell.mjs +39 -0
- package/dist/components/activity-inbox/activity-inbox-shell.recipe.mjs +14 -0
- package/dist/components/activity-inbox/activity-inbox-sidebar.d.mts +6 -0
- package/dist/components/activity-inbox/activity-inbox-sidebar.mjs +22 -0
- package/dist/components/activity-inbox/activity-inbox-sidebar.recipe.mjs +22 -0
- package/dist/components/activity-inbox/activity-inbox-toolbar.d.mts +9 -0
- package/dist/components/activity-inbox/activity-inbox-toolbar.mjs +29 -0
- package/dist/components/activity-inbox/activity-inbox-toolbar.recipe.mjs +14 -0
- package/dist/components/activity-inbox/index.d.mts +4 -0
- package/dist/components/alert-dialog/alert-dialog.d.mts +41 -0
- package/dist/components/alert-dialog/alert-dialog.mjs +163 -0
- package/dist/components/alert-dialog/index.d.mts +2 -0
- package/dist/components/announcement-dialog/announcement-dialog.d.mts +18 -0
- package/dist/components/announcement-dialog/announcement-dialog.mjs +121 -0
- package/dist/components/announcement-dialog/index.d.mts +3 -0
- package/dist/components/app-rail/app-rail.d.mts +31 -0
- package/dist/components/app-rail/app-rail.mjs +126 -0
- package/dist/components/app-rail/app-rail.recipe.mjs +47 -0
- package/dist/components/app-rail/index.d.mts +2 -0
- package/dist/components/app-shell/app-shell.d.mts +27 -0
- package/dist/components/app-shell/app-shell.mjs +217 -0
- package/dist/components/app-shell/index.d.mts +2 -0
- package/dist/components/avatar/avatar.d.mts +169 -0
- package/dist/components/avatar/avatar.mjs +298 -0
- package/dist/components/avatar/index.d.mts +2 -0
- package/dist/components/badge/badge.d.mts +89 -0
- package/dist/components/badge/badge.mjs +203 -0
- package/dist/components/badge/index.d.mts +2 -0
- package/dist/components/banner/banner.d.mts +141 -0
- package/dist/components/banner/banner.mjs +228 -0
- package/dist/components/banner/index.d.mts +2 -0
- package/dist/components/button/button.d.mts +257 -0
- package/dist/components/button/button.mjs +177 -0
- package/dist/components/button/index.d.mts +2 -0
- package/dist/components/card/card.d.mts +21 -0
- package/dist/components/card/card.mjs +114 -0
- package/dist/components/card/card.recipe.d.mts +105 -0
- package/dist/components/card/card.recipe.mjs +67 -0
- package/dist/components/card/index.d.mts +2 -0
- package/dist/components/checkbox/checkbox-indicator.d.mts +92 -0
- package/dist/components/checkbox/checkbox-indicator.mjs +61 -0
- package/dist/components/checkbox/checkbox.d.mts +9 -0
- package/dist/components/checkbox/checkbox.mjs +40 -0
- package/dist/components/checkbox/index.d.mts +3 -0
- package/dist/components/choice-list/choice-list.d.mts +103 -0
- package/dist/components/choice-list/choice-list.mjs +301 -0
- package/dist/components/choice-list/choice-list.recipe.mjs +44 -0
- package/dist/components/choice-list/index.d.mts +2 -0
- package/dist/components/code-block/code-block.d.mts +30 -0
- package/dist/components/code-block/code-block.mjs +151 -0
- package/dist/components/code-block/code-block.recipe.mjs +47 -0
- package/dist/components/code-block/index.d.mts +2 -0
- package/dist/components/combobox/combobox.d.mts +69 -0
- package/dist/components/combobox/combobox.mjs +438 -0
- package/dist/components/combobox/index.d.mts +2 -0
- package/dist/components/combobox-select/combobox-select.d.mts +4 -0
- package/dist/components/combobox-select/combobox-select.list-side.mjs +16 -0
- package/dist/components/combobox-select/combobox-select.mjs +473 -0
- package/dist/components/combobox-select/combobox-select.options.mjs +21 -0
- package/dist/components/combobox-select/combobox-select.types.d.mts +83 -0
- package/dist/components/combobox-select/index.d.mts +3 -0
- package/dist/components/comment/comment-card.d.mts +40 -0
- package/dist/components/comment/comment-card.mjs +83 -0
- package/dist/components/comment/comment-entry.d.mts +24 -0
- package/dist/components/comment/comment-entry.mjs +75 -0
- package/dist/components/comment/comment-highlight.d.mts +18 -0
- package/dist/components/comment/comment-highlight.mjs +33 -0
- package/dist/components/comment/comment-margin-layout.d.mts +32 -0
- package/dist/components/comment/comment-margin-layout.mjs +44 -0
- package/dist/components/comment/comment-margin.d.mts +29 -0
- package/dist/components/comment/comment-margin.mjs +164 -0
- package/dist/components/comment/comment-marker.d.mts +16 -0
- package/dist/components/comment/comment-marker.mjs +24 -0
- package/dist/components/comment/comment.recipe.mjs +58 -0
- package/dist/components/comment/index.d.mts +8 -0
- package/dist/components/comment/use-comment-margin-fits.d.mts +16 -0
- package/dist/components/comment/use-comment-margin-fits.mjs +34 -0
- package/dist/components/composer/composer-attachment.recipe.mjs +85 -0
- package/dist/components/composer/composer-attachments-scroll-area.d.mts +5 -0
- package/dist/components/composer/composer-attachments-scroll-area.mjs +93 -0
- package/dist/components/composer/composer-attachments.d.mts +27 -0
- package/dist/components/composer/composer-attachments.mjs +147 -0
- package/dist/components/composer/composer-drop-overlay.d.mts +9 -0
- package/dist/components/composer/composer-drop-overlay.mjs +60 -0
- package/dist/components/composer/composer-drop-overlay.recipe.mjs +23 -0
- package/dist/components/composer/composer-root.d.mts +5 -0
- package/dist/components/composer/composer-root.mjs +18 -0
- package/dist/components/composer/composer-suggestion-list.d.mts +139 -0
- package/dist/components/composer/composer-suggestion-list.mjs +160 -0
- package/dist/components/composer/composer-toolbar-label.d.mts +5 -0
- package/dist/components/composer/composer-toolbar-label.mjs +24 -0
- package/dist/components/composer/composer.d.mts +20 -0
- package/dist/components/composer/composer.mjs +88 -0
- package/dist/components/composer/composer.recipe.mjs +29 -0
- package/dist/components/composer/index.d.mts +10 -0
- package/dist/components/composer/sortable-composer-attachments.d.mts +37 -0
- package/dist/components/composer/sortable-composer-attachments.mjs +247 -0
- package/dist/components/composer/use-composer-suggestions.d.mts +83 -0
- package/dist/components/composer/use-composer-suggestions.mjs +207 -0
- package/dist/components/context-menu/context-menu.d.mts +53 -0
- package/dist/components/context-menu/context-menu.mjs +275 -0
- package/dist/components/context-menu/index.d.mts +2 -0
- package/dist/components/conversation-panel/conversation-panel-empty-state.d.mts +9 -0
- package/dist/components/conversation-panel/conversation-panel-empty-state.mjs +57 -0
- package/dist/components/conversation-panel/conversation-panel.d.mts +20 -0
- package/dist/components/conversation-panel/conversation-panel.mjs +63 -0
- package/dist/components/conversation-panel/conversation-panel.recipe.mjs +15 -0
- package/dist/components/conversation-panel/index.d.mts +3 -0
- package/dist/components/copyable-code/copyable-code.d.mts +72 -0
- package/dist/components/copyable-code/copyable-code.mjs +153 -0
- package/dist/components/copyable-code/index.d.mts +2 -0
- package/dist/components/description-list/description-list.d.mts +59 -0
- package/dist/components/description-list/description-list.mjs +96 -0
- package/dist/components/description-list/index.d.mts +2 -0
- package/dist/components/dialog/dialog-sheet-context.mjs +58 -0
- package/dist/components/dialog/dialog-sheet.d.mts +31 -0
- package/dist/components/dialog/dialog-sheet.mjs +194 -0
- package/dist/components/dialog/dialog.d.mts +85 -0
- package/dist/components/dialog/dialog.mjs +371 -0
- package/dist/components/dialog/index.d.mts +3 -0
- package/dist/components/drag/drag-announcements.d.mts +72 -0
- package/dist/components/drag/drag-announcements.mjs +115 -0
- package/dist/components/drag/drag-lift.d.mts +100 -0
- package/dist/components/drag/drag-lift.mjs +276 -0
- package/dist/components/drag/drag-lists.d.mts +98 -0
- package/dist/components/drag/drag-lists.mjs +258 -0
- package/dist/components/drag/drag-sensors.d.mts +87 -0
- package/dist/components/drag/drag-sensors.mjs +169 -0
- package/dist/components/drag/drag.recipe.d.mts +7 -0
- package/dist/components/drag/drag.recipe.mjs +30 -0
- package/dist/components/drag/drop-placeholder.d.mts +41 -0
- package/dist/components/drag/drop-placeholder.mjs +161 -0
- package/dist/components/drag/index.d.mts +8 -0
- package/dist/components/drawer/drawer.d.mts +34 -0
- package/dist/components/drawer/drawer.mjs +202 -0
- package/dist/components/drawer/drawer.recipe.mjs +175 -0
- package/dist/components/drawer/index.d.mts +2 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.mts +62 -0
- package/dist/components/dropdown-menu/dropdown-menu.mjs +319 -0
- package/dist/components/dropdown-menu/index.d.mts +2 -0
- package/dist/components/ellipsis/ellipsis.d.mts +55 -0
- package/dist/components/ellipsis/ellipsis.mjs +320 -0
- package/dist/components/ellipsis/index.d.mts +3 -0
- package/dist/components/empty-state/empty-state.d.mts +15 -0
- package/dist/components/empty-state/empty-state.mjs +102 -0
- package/dist/components/empty-state/index.d.mts +2 -0
- package/dist/components/field/field.d.mts +79 -0
- package/dist/components/field/field.mjs +100 -0
- package/dist/components/field/index.d.mts +2 -0
- package/dist/components/file-preview/file-preview.d.mts +17 -0
- package/dist/components/file-preview/file-preview.mjs +210 -0
- package/dist/components/file-preview/file-preview.recipe.d.mts +99 -0
- package/dist/components/file-preview/file-preview.recipe.mjs +39 -0
- package/dist/components/file-preview/index.d.mts +2 -0
- package/dist/components/files/files.d.mts +35 -0
- package/dist/components/files/files.mjs +69 -0
- package/dist/components/files/files.recipe.mjs +40 -0
- package/dist/components/files/index.d.mts +2 -0
- package/dist/components/filter-chip/filter-chip.d.mts +25 -0
- package/dist/components/filter-chip/filter-chip.mjs +59 -0
- package/dist/components/filter-chip/index.d.mts +2 -0
- package/dist/components/float-button/float-button.d.mts +36 -0
- package/dist/components/float-button/float-button.mjs +116 -0
- package/dist/components/float-button/float-button.position.d.mts +6 -0
- package/dist/components/float-button/float-button.position.mjs +41 -0
- package/dist/components/float-button/index.d.mts +3 -0
- package/dist/components/form-section/form-section.d.mts +16 -0
- package/dist/components/form-section/form-section.mjs +53 -0
- package/dist/components/form-section/index.d.mts +2 -0
- package/dist/components/icon-tile/icon-tile.d.mts +97 -0
- package/dist/components/icon-tile/icon-tile.mjs +49 -0
- package/dist/components/icon-tile/index.d.mts +2 -0
- package/dist/components/icons/action-icons.d.mts +34 -0
- package/dist/components/icons/action-icons.mjs +383 -0
- package/dist/components/icons/conversation-icons.d.mts +12 -0
- package/dist/components/icons/conversation-icons.mjs +147 -0
- package/dist/components/icons/index.d.mts +4 -0
- package/dist/components/icons/object-icons.d.mts +6 -0
- package/dist/components/icons/object-icons.mjs +27 -0
- package/dist/components/inbox-item/inbox-item-leading-badge.d.mts +13 -0
- package/dist/components/inbox-item/inbox-item-leading-badge.mjs +27 -0
- package/dist/components/inbox-item/inbox-item-skeleton.d.mts +46 -0
- package/dist/components/inbox-item/inbox-item-skeleton.mjs +89 -0
- package/dist/components/inbox-item/inbox-item-skeleton.recipe.mjs +20 -0
- package/dist/components/inbox-item/inbox-item.d.mts +71 -0
- package/dist/components/inbox-item/inbox-item.mjs +276 -0
- package/dist/components/inbox-item/inbox-item.recipe.mjs +137 -0
- package/dist/components/inbox-item/index.d.mts +2 -0
- package/dist/components/inline-code/index.d.mts +2 -0
- package/dist/components/inline-code/inline-code.d.mts +8 -0
- package/dist/components/inline-code/inline-code.mjs +30 -0
- package/dist/components/input/index.d.mts +2 -0
- package/dist/components/input/input.d.mts +16 -0
- package/dist/components/input/input.mjs +20 -0
- package/dist/components/input/input.recipe.mjs +12 -0
- package/dist/components/input-group/index.d.mts +2 -0
- package/dist/components/input-group/input-group.d.mts +93 -0
- package/dist/components/input-group/input-group.mjs +178 -0
- package/dist/components/kbd/index.d.mts +2 -0
- package/dist/components/kbd/kbd.d.mts +7 -0
- package/dist/components/kbd/kbd.mjs +34 -0
- package/dist/components/label/index.d.mts +2 -0
- package/dist/components/label/label.d.mts +60 -0
- package/dist/components/label/label.mjs +75 -0
- package/dist/components/legacy-task-panel/index.d.mts +2 -0
- package/dist/components/legacy-task-panel/legacy-task-panel.d.mts +57 -0
- package/dist/components/legacy-task-panel/legacy-task-panel.mjs +234 -0
- package/dist/components/legacy-task-panel/legacy-task-panel.recipe.mjs +30 -0
- package/dist/components/lightbox/index.d.mts +2 -0
- package/dist/components/lightbox/lightbox.d.mts +55 -0
- package/dist/components/lightbox/lightbox.mjs +336 -0
- package/dist/components/list-row/index.d.mts +2 -0
- package/dist/components/list-row/list-row-skeleton.d.mts +21 -0
- package/dist/components/list-row/list-row-skeleton.mjs +43 -0
- package/dist/components/list-row/list-row.d.mts +66 -0
- package/dist/components/list-row/list-row.mjs +167 -0
- package/dist/components/list-row/list-row.recipe.d.mts +126 -0
- package/dist/components/list-row/list-row.recipe.mjs +94 -0
- package/dist/components/live-agent-activity-bar/index.d.mts +2 -0
- package/dist/components/live-agent-activity-bar/live-agent-activity-bar.d.mts +25 -0
- package/dist/components/live-agent-activity-bar/live-agent-activity-bar.mjs +107 -0
- package/dist/components/logo/index.d.mts +2 -0
- package/dist/components/logo/raft-logo.d.mts +9 -0
- package/dist/components/logo/raft-logo.mjs +63 -0
- package/dist/components/markdown/index.d.mts +2 -0
- package/dist/components/markdown/markdown-parts.d.mts +54 -0
- package/dist/components/markdown/markdown-parts.mjs +153 -0
- package/dist/components/markdown/markdown.recipe.mjs +77 -0
- package/dist/components/message-action-card/index.d.mts +2 -0
- package/dist/components/message-action-card/message-action-card-content.recipe.mjs +50 -0
- package/dist/components/message-action-card/message-action-card.d.mts +95 -0
- package/dist/components/message-action-card/message-action-card.mjs +298 -0
- package/dist/components/message-action-card/message-action-card.recipe.mjs +47 -0
- package/dist/components/message-attachment/index.d.mts +5 -0
- package/dist/components/message-attachment/message-attachment.d.mts +27 -0
- package/dist/components/message-attachment/message-attachment.mjs +129 -0
- package/dist/components/message-attachment/message-attachment.recipe.mjs +36 -0
- package/dist/components/message-attachment/message-image-gallery-rows.d.mts +47 -0
- package/dist/components/message-attachment/message-image-gallery-rows.mjs +55 -0
- package/dist/components/message-attachment/message-image-gallery.d.mts +32 -0
- package/dist/components/message-attachment/message-image-gallery.mjs +105 -0
- package/dist/components/message-attachment/message-image-gallery.recipe.mjs +61 -0
- package/dist/components/message-attachment/message-video-preview.d.mts +19 -0
- package/dist/components/message-attachment/message-video-preview.mjs +92 -0
- package/dist/components/message-attachment/message-video-preview.recipe.mjs +33 -0
- package/dist/components/message-embed/index.d.mts +2 -0
- package/dist/components/message-embed/message-embed.d.mts +12 -0
- package/dist/components/message-embed/message-embed.mjs +42 -0
- package/dist/components/message-embed/message-embed.recipe.mjs +14 -0
- package/dist/components/message-forwarded-bundle/index.d.mts +2 -0
- package/dist/components/message-forwarded-bundle/message-forwarded-bundle.d.mts +92 -0
- package/dist/components/message-forwarded-bundle/message-forwarded-bundle.mjs +324 -0
- package/dist/components/message-forwarded-bundle/message-forwarded-bundle.recipe.mjs +81 -0
- package/dist/components/message-item/index.d.mts +13 -0
- package/dist/components/message-item/message-footer.d.mts +20 -0
- package/dist/components/message-item/message-footer.mjs +54 -0
- package/dist/components/message-item/message-footer.recipe.mjs +46 -0
- package/dist/components/message-item/message-item-content.d.mts +22 -0
- package/dist/components/message-item/message-item-content.mjs +81 -0
- package/dist/components/message-item/message-item-delegated.d.mts +38 -0
- package/dist/components/message-item/message-item-delegated.mjs +72 -0
- package/dist/components/message-item/message-item-gutter.d.mts +10 -0
- package/dist/components/message-item/message-item-gutter.mjs +41 -0
- package/dist/components/message-item/message-item-header.d.mts +29 -0
- package/dist/components/message-item/message-item-header.mjs +107 -0
- package/dist/components/message-item/message-item-label.mjs +113 -0
- package/dist/components/message-item/message-item-root.d.mts +25 -0
- package/dist/components/message-item/message-item-root.mjs +39 -0
- package/dist/components/message-item/message-item-toolbar.d.mts +9 -0
- package/dist/components/message-item/message-item-toolbar.mjs +131 -0
- package/dist/components/message-item/message-item.recipe.d.mts +101 -0
- package/dist/components/message-item/message-item.recipe.mjs +114 -0
- package/dist/components/message-item/message-multi-select.d.mts +15 -0
- package/dist/components/message-item/message-multi-select.mjs +49 -0
- package/dist/components/message-item/message-multi-select.recipe.mjs +23 -0
- package/dist/components/message-item/message-reaction.d.mts +39 -0
- package/dist/components/message-item/message-reaction.mjs +188 -0
- package/dist/components/message-item/message-reaction.recipe.mjs +76 -0
- package/dist/components/message-item/message-reference.d.mts +50 -0
- package/dist/components/message-item/message-reference.mjs +111 -0
- package/dist/components/message-item/message-reference.recipe.d.mts +6 -0
- package/dist/components/message-item/message-reference.recipe.mjs +63 -0
- package/dist/components/message-item/message-text-selection-toolbar.d.mts +24 -0
- package/dist/components/message-item/message-text-selection-toolbar.mjs +13 -0
- package/dist/components/message-list/index.d.mts +4 -0
- package/dist/components/message-list/message-list-jump.d.mts +21 -0
- package/dist/components/message-list/message-list-jump.mjs +73 -0
- package/dist/components/message-list/message-list-markers.d.mts +13 -0
- package/dist/components/message-list/message-list-markers.mjs +70 -0
- package/dist/components/message-list/message-list.d.mts +7 -0
- package/dist/components/message-list/message-list.mjs +52 -0
- package/dist/components/message-list/message-list.recipe.mjs +54 -0
- package/dist/components/message-quoted-preview/index.d.mts +2 -0
- package/dist/components/message-quoted-preview/message-quoted-preview.d.mts +40 -0
- package/dist/components/message-quoted-preview/message-quoted-preview.mjs +144 -0
- package/dist/components/message-quoted-preview/message-quoted-preview.recipe.mjs +38 -0
- package/dist/components/message-replies/index.d.mts +2 -0
- package/dist/components/message-replies/message-replies.d.mts +17 -0
- package/dist/components/message-replies/message-replies.mjs +79 -0
- package/dist/components/message-replies/message-replies.recipe.mjs +25 -0
- package/dist/components/message-translation/index.d.mts +2 -0
- package/dist/components/message-translation/message-translation.d.mts +20 -0
- package/dist/components/message-translation/message-translation.mjs +64 -0
- package/dist/components/message-translation/message-translation.recipe.mjs +27 -0
- package/dist/components/meter/index.d.mts +2 -0
- package/dist/components/meter/meter.d.mts +107 -0
- package/dist/components/meter/meter.mjs +118 -0
- package/dist/components/mobile-nav/index.d.mts +3 -0
- package/dist/components/mobile-nav/mobile-nav-server.d.mts +71 -0
- package/dist/components/mobile-nav/mobile-nav-server.mjs +287 -0
- package/dist/components/mobile-nav/mobile-nav.d.mts +12 -0
- package/dist/components/mobile-nav/mobile-nav.mjs +73 -0
- package/dist/components/mode-bar/index.d.mts +2 -0
- package/dist/components/mode-bar/mode-bar.d.mts +33 -0
- package/dist/components/mode-bar/mode-bar.mjs +115 -0
- package/dist/components/notification-center/index.d.mts +2 -0
- package/dist/components/notification-center/notification-center.d.mts +225 -0
- package/dist/components/notification-center/notification-center.mjs +340 -0
- package/dist/components/panel/index.d.mts +7 -0
- package/dist/components/panel/panel-action.d.mts +15 -0
- package/dist/components/panel/panel-action.mjs +23 -0
- package/dist/components/panel/panel-action.recipe.mjs +40 -0
- package/dist/components/panel/panel-header.d.mts +34 -0
- package/dist/components/panel/panel-header.mjs +135 -0
- package/dist/components/panel/panel-header.recipe.mjs +78 -0
- package/dist/components/panel/panel-notice.d.mts +16 -0
- package/dist/components/panel/panel-notice.mjs +77 -0
- package/dist/components/panel/panel-split-action.d.mts +34 -0
- package/dist/components/panel/panel-split-action.mjs +69 -0
- package/dist/components/panel/panel-split-action.recipe.mjs +53 -0
- package/dist/components/panel/panel-toggle-action.d.mts +6 -0
- package/dist/components/panel/panel-toggle-action.mjs +15 -0
- package/dist/components/panel/panel.d.mts +25 -0
- package/dist/components/panel/panel.mjs +96 -0
- package/dist/components/panel/panel.recipe.mjs +24 -0
- package/dist/components/picker-trigger-button/index.d.mts +2 -0
- package/dist/components/picker-trigger-button/picker-trigger-button.d.mts +7 -0
- package/dist/components/picker-trigger-button/picker-trigger-button.mjs +36 -0
- package/dist/components/popover/index.d.mts +2 -0
- package/dist/components/popover/popover.d.mts +41 -0
- package/dist/components/popover/popover.mjs +184 -0
- package/dist/components/preview-card/index.d.mts +2 -0
- package/dist/components/preview-card/preview-card.d.mts +43 -0
- package/dist/components/preview-card/preview-card.mjs +197 -0
- package/dist/components/profile-panel/index.d.mts +2 -0
- package/dist/components/profile-panel/profile-panel.d.mts +14 -0
- package/dist/components/profile-panel/profile-panel.mjs +46 -0
- package/dist/components/profile-panel/profile-panel.recipe.mjs +14 -0
- package/dist/components/progress/index.d.mts +2 -0
- package/dist/components/progress/progress.d.mts +119 -0
- package/dist/components/progress/progress.mjs +139 -0
- package/dist/components/pull-to-refresh/index.d.mts +4 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-gesture.d.mts +30 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-gesture.mjs +134 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-indicator.d.mts +21 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-indicator.mjs +153 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-material-progress.mjs +150 -0
- package/dist/components/pull-to-refresh/use-pull-to-refresh.d.mts +55 -0
- package/dist/components/pull-to-refresh/use-pull-to-refresh.mjs +156 -0
- package/dist/components/radio-group/index.d.mts +2 -0
- package/dist/components/radio-group/radio-group.d.mts +14 -0
- package/dist/components/radio-group/radio-group.mjs +59 -0
- package/dist/components/resizable/index.d.mts +2 -0
- package/dist/components/resizable/resizable.d.mts +15 -0
- package/dist/components/resizable/resizable.mjs +39 -0
- package/dist/components/resizable/resizable.recipe.mjs +24 -0
- package/dist/components/scroll-area/index.d.mts +2 -0
- package/dist/components/scroll-area/scroll-area.d.mts +17 -0
- package/dist/components/scroll-area/scroll-area.mjs +55 -0
- package/dist/components/scroll-area/scroll-area.recipe.mjs +23 -0
- package/dist/components/search/index.d.mts +6 -0
- package/dist/components/search/search-entity.d.mts +24 -0
- package/dist/components/search/search-entity.mjs +106 -0
- package/dist/components/search/search-entity.recipe.mjs +41 -0
- package/dist/components/search/search-message.d.mts +25 -0
- package/dist/components/search/search-message.mjs +115 -0
- package/dist/components/search/search-message.recipe.mjs +32 -0
- package/dist/components/search/search-thread.d.mts +17 -0
- package/dist/components/search/search-thread.mjs +79 -0
- package/dist/components/search/search-thread.recipe.mjs +16 -0
- package/dist/components/search/search-trigger.d.mts +15 -0
- package/dist/components/search/search-trigger.mjs +59 -0
- package/dist/components/search/search.d.mts +23 -0
- package/dist/components/search/search.mjs +88 -0
- package/dist/components/search/search.recipe.mjs +22 -0
- package/dist/components/segmented-control/index.d.mts +2 -0
- package/dist/components/segmented-control/segmented-control.d.mts +38 -0
- package/dist/components/segmented-control/segmented-control.mjs +306 -0
- package/dist/components/select/index.d.mts +2 -0
- package/dist/components/select/select.d.mts +95 -0
- package/dist/components/select/select.mjs +483 -0
- package/dist/components/separator/index.d.mts +2 -0
- package/dist/components/separator/separator.d.mts +10 -0
- package/dist/components/separator/separator.mjs +49 -0
- package/dist/components/sidebar/index.d.mts +5 -0
- package/dist/components/sidebar/sidebar-item.d.mts +64 -0
- package/dist/components/sidebar/sidebar-item.mjs +201 -0
- package/dist/components/sidebar/sidebar-item.recipe.mjs +100 -0
- package/dist/components/sidebar/sidebar-menu.d.mts +13 -0
- package/dist/components/sidebar/sidebar-menu.mjs +67 -0
- package/dist/components/sidebar/sidebar-menu.recipe.mjs +22 -0
- package/dist/components/sidebar/sidebar-section.d.mts +41 -0
- package/dist/components/sidebar/sidebar-section.mjs +164 -0
- package/dist/components/sidebar/sidebar-section.recipe.mjs +45 -0
- package/dist/components/sidebar/sidebar.d.mts +17 -0
- package/dist/components/sidebar/sidebar.mjs +149 -0
- package/dist/components/sidebar/sidebar.recipe.mjs +37 -0
- package/dist/components/skeleton/index.d.mts +2 -0
- package/dist/components/skeleton/skeleton.d.mts +50 -0
- package/dist/components/skeleton/skeleton.mjs +29 -0
- package/dist/components/spinner/index.d.mts +2 -0
- package/dist/components/spinner/spinner.d.mts +77 -0
- package/dist/components/spinner/spinner.mjs +118 -0
- package/dist/components/status/index.d.mts +2 -0
- package/dist/components/status/status.d.mts +143 -0
- package/dist/components/status/status.mjs +56 -0
- package/dist/components/steps/index.d.mts +3 -0
- package/dist/components/steps/otter-indicator.d.mts +17 -0
- package/dist/components/steps/otter-indicator.mjs +331 -0
- package/dist/components/steps/steps.d.mts +50 -0
- package/dist/components/steps/steps.mjs +174 -0
- package/dist/components/switch/index.d.mts +2 -0
- package/dist/components/switch/switch.d.mts +9 -0
- package/dist/components/switch/switch.mjs +50 -0
- package/dist/components/system-message/index.d.mts +2 -0
- package/dist/components/system-message/system-message.d.mts +27 -0
- package/dist/components/system-message/system-message.mjs +113 -0
- package/dist/components/system-message/system-message.recipe.mjs +34 -0
- package/dist/components/table/index.d.mts +2 -0
- package/dist/components/table/table.d.mts +35 -0
- package/dist/components/table/table.mjs +102 -0
- package/dist/components/table/table.recipe.mjs +31 -0
- package/dist/components/tabs/index.d.mts +2 -0
- package/dist/components/tabs/tabs.d.mts +185 -0
- package/dist/components/tabs/tabs.mjs +528 -0
- package/dist/components/task-board/index.d.mts +2 -0
- package/dist/components/task-board/task-board-column.recipe.mjs +46 -0
- package/dist/components/task-board/task-board.d.mts +40 -0
- package/dist/components/task-board/task-board.mjs +155 -0
- package/dist/components/task-card/index.d.mts +2 -0
- package/dist/components/task-card/task-card-status.recipe.mjs +17 -0
- package/dist/components/task-card/task-card.d.mts +30 -0
- package/dist/components/task-card/task-card.mjs +141 -0
- package/dist/components/task-card/task-card.recipe.mjs +39 -0
- package/dist/components/task-dnd/index.d.mts +2 -0
- package/dist/components/task-dnd/task-dnd.d.mts +75 -0
- package/dist/components/task-dnd/task-dnd.mjs +341 -0
- package/dist/components/task-dnd/task-dnd.recipe.mjs +20 -0
- package/dist/components/task-list/index.d.mts +2 -0
- package/dist/components/task-list/task-list-section.recipe.mjs +37 -0
- package/dist/components/task-list/task-list.d.mts +34 -0
- package/dist/components/task-list/task-list.mjs +119 -0
- package/dist/components/tasks/index.d.mts +7 -0
- package/dist/components/tasks/task-chip.d.mts +14 -0
- package/dist/components/tasks/task-chip.mjs +81 -0
- package/dist/components/tasks/task-loading.d.mts +7 -0
- package/dist/components/tasks/task-loading.mjs +32 -0
- package/dist/components/tasks/task-loading.recipe.mjs +8 -0
- package/dist/components/tasks/task-status-badge.d.mts +24 -0
- package/dist/components/tasks/task-status-badge.mjs +24 -0
- package/dist/components/tasks/task-status-icon.d.mts +13 -0
- package/dist/components/tasks/task-status-icon.mjs +90 -0
- package/dist/components/tasks/task-status.recipe.d.mts +62 -0
- package/dist/components/tasks/task-status.recipe.mjs +33 -0
- package/dist/components/tasks/tasks-panel.d.mts +22 -0
- package/dist/components/tasks/tasks-panel.mjs +114 -0
- package/dist/components/tasks/tasks-panel.recipe.mjs +36 -0
- package/dist/components/text/index.d.mts +2 -0
- package/dist/components/text/text.d.mts +186 -0
- package/dist/components/text/text.mjs +114 -0
- package/dist/components/text-link/index.d.mts +2 -0
- package/dist/components/text-link/text-link.d.mts +36 -0
- package/dist/components/text-link/text-link.mjs +60 -0
- package/dist/components/text-selection-toolbar/index.d.mts +3 -0
- package/dist/components/text-selection-toolbar/text-selection-anchor.d.mts +22 -0
- package/dist/components/text-selection-toolbar/text-selection-anchor.mjs +106 -0
- package/dist/components/text-selection-toolbar/text-selection-toolbar.d.mts +20 -0
- package/dist/components/text-selection-toolbar/text-selection-toolbar.mjs +41 -0
- package/dist/components/text-selection-toolbar/text-selection-toolbar.recipe.mjs +19 -0
- package/dist/components/textarea/index.d.mts +2 -0
- package/dist/components/textarea/textarea.d.mts +16 -0
- package/dist/components/textarea/textarea.mjs +62 -0
- package/dist/components/thread-panel/index.d.mts +2 -0
- package/dist/components/thread-panel/thread-panel.d.mts +31 -0
- package/dist/components/thread-panel/thread-panel.mjs +162 -0
- package/dist/components/thread-panel/thread-panel.recipe.mjs +36 -0
- package/dist/components/timeline/index.d.mts +2 -0
- package/dist/components/timeline/timeline.d.mts +44 -0
- package/dist/components/timeline/timeline.mjs +81 -0
- package/dist/components/toast/index.d.mts +2 -0
- package/dist/components/toast/toast.d.mts +263 -0
- package/dist/components/toast/toast.mjs +556 -0
- package/dist/components/toggle-group/index.d.mts +2 -0
- package/dist/components/toggle-group/toggle-group.d.mts +15 -0
- package/dist/components/toggle-group/toggle-group.mjs +64 -0
- package/dist/components/tooltip/index.d.mts +2 -0
- package/dist/components/tooltip/tooltip.d.mts +18 -0
- package/dist/components/tooltip/tooltip.mjs +197 -0
- package/dist/components/virtual-list/ItemColumns.mjs +37 -0
- package/dist/components/virtual-list/VirtualList.d.mts +4 -0
- package/dist/components/virtual-list/VirtualList.mjs +1401 -0
- package/dist/components/virtual-list/VirtualListContext.mjs +5 -0
- package/dist/components/virtual-list/hooks/use-event-callback.mjs +10 -0
- package/dist/components/virtual-list/hooks/use-ios-momentum-compensation.mjs +148 -0
- package/dist/components/virtual-list/hooks/use-keyboard-scroll.mjs +42 -0
- package/dist/components/virtual-list/hooks/use-latest-ref.mjs +10 -0
- package/dist/components/virtual-list/hooks/use-layout-effect-with-previous.mjs +16 -0
- package/dist/components/virtual-list/hooks/use-memo-with-previous.mjs +22 -0
- package/dist/components/virtual-list/hooks/use-non-passive-wheel.mjs +23 -0
- package/dist/components/virtual-list/hooks/use-non-virtual-content-resize.mjs +28 -0
- package/dist/components/virtual-list/hooks/use-scroll-anchor.mjs +55 -0
- package/dist/components/virtual-list/index.d.mts +5 -0
- package/dist/components/virtual-list/public-types.d.mts +341 -0
- package/dist/components/virtual-list/resize-observer/ResizeObserverWrapper.d.mts +5 -0
- package/dist/components/virtual-list/resize-observer/ResizeObserverWrapper.mjs +70 -0
- package/dist/components/virtual-list/resize-observer/resize-observer-delegate.d.mts +6 -0
- package/dist/components/virtual-list/resize-observer/resize-observer-delegate.mjs +54 -0
- package/dist/components/virtual-list/utils/align.mjs +19 -0
- package/dist/components/virtual-list/utils/constants.mjs +30 -0
- package/dist/components/virtual-list/utils/fenwick-tree.mjs +66 -0
- package/dist/components/virtual-list/utils/items-anchor.mjs +49 -0
- package/dist/components/virtual-list/utils/measure.mjs +77 -0
- package/dist/components/virtual-list/utils/platform.mjs +39 -0
- package/dist/components/virtual-list/utils/range.mjs +103 -0
- package/dist/components/virtual-list/utils/size-cache.mjs +35 -0
- package/dist/components/workspace-button/index.d.mts +2 -0
- package/dist/components/workspace-button/workspace-button.d.mts +9 -0
- package/dist/components/workspace-button/workspace-button.mjs +28 -0
- package/dist/index.d.mts +239 -4864
- package/dist/index.mjs +142 -17053
- package/dist/lib/chip-remove.mjs +17 -0
- package/dist/lib/data-attributes.d.mts +5 -0
- package/dist/lib/decision-width.mjs +9 -0
- package/dist/lib/default-native-button.mjs +8 -0
- package/dist/lib/desktop-media.mjs +10 -0
- package/dist/lib/drag-escape.mjs +37 -0
- package/dist/lib/frame-insets.mjs +127 -0
- package/dist/lib/head-edges.mjs +44 -0
- package/dist/lib/hud-text-action.mjs +10 -0
- package/dist/lib/inline-chip.mjs +30 -0
- package/dist/lib/input-modality.d.mts +36 -0
- package/dist/lib/input-modality.mjs +186 -0
- package/dist/lib/list-cell.mjs +21 -0
- package/dist/lib/located.d.mts +25 -0
- package/dist/lib/located.mjs +28 -0
- package/dist/lib/overlay-depth.d.mts +42 -0
- package/dist/lib/overlay-depth.mjs +59 -0
- package/dist/lib/phone-media.mjs +24 -0
- package/dist/lib/presence.d.mts +16 -0
- package/dist/lib/presence.mjs +16 -0
- package/dist/lib/row-tone.d.mts +8 -0
- package/dist/lib/search-hit.mjs +18 -0
- package/dist/lib/stacked-actions.mjs +112 -0
- package/dist/lib/styled-props.d.mts +15 -0
- package/dist/lib/tap-activation.mjs +133 -0
- package/dist/lib/theme/theme-context.d.mts +10 -0
- package/dist/lib/theme/theme-context.mjs +9 -0
- package/dist/lib/theme/theme-provider.d.mts +23 -0
- package/dist/lib/theme/theme-provider.mjs +61 -0
- package/dist/lib/theme/theme-scope.mjs +19 -0
- package/dist/lib/theme/use-theme.d.mts +5 -0
- package/dist/lib/theme/use-theme.mjs +9 -0
- package/dist/lib/touch-drag.d.mts +55 -0
- package/dist/lib/touch-drag.mjs +151 -0
- package/dist/lib/truncation.d.mts +26 -0
- package/dist/lib/truncation.mjs +153 -0
- package/dist/lib/tv.d.mts +2 -0
- package/dist/lib/tv.mjs +14 -0
- package/dist/lib/use-copy-to-clipboard.mjs +58 -0
- package/dist/lib/use-merged-ref.mjs +60 -0
- package/dist/lib/use-mobile-viewport.mjs +17 -0
- package/dist/lib/use-overflow-title.mjs +49 -0
- package/dist/lib/use-scrollbar-size.d.mts +16 -0
- package/dist/lib/use-scrollbar-size.mjs +46 -0
- package/dist/lib/use-truncated.d.mts +20 -0
- package/dist/lib/use-truncated.mjs +34 -0
- package/dist/lib/without-children.d.mts +8 -0
- package/dist/wip.d.mts +61 -1222
- package/dist/wip.mjs +43 -3079
- package/package.json +8 -1
- package/dist/inbox-item-B4nNvpp1.d.mts +0 -1784
- package/dist/inbox-item-DHJOrxB8.mjs +0 -7454
- package/dist/style.css +0 -1395
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { tv } from "../../lib/tv.mjs";
|
|
2
|
+
import { CheckboxIndicator } from "./checkbox-indicator.mjs";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
6
|
+
//#region src/components/checkbox/checkbox.tsx
|
|
7
|
+
const checkbox = tv({ slots: {
|
|
8
|
+
root: [
|
|
9
|
+
"relative inline-flex size-5 shrink-0 touch-manipulation items-center justify-center outline-none",
|
|
10
|
+
"rounded-sticker focus-visible:shadow-focus",
|
|
11
|
+
"data-disabled:cursor-not-allowed",
|
|
12
|
+
"after:absolute after:-inset-x-3 after:-inset-y-2 after:content-[''] pointer-coarse:after:-inset-y-3",
|
|
13
|
+
"[label>&]:my-[max(0px,calc((1lh-1.25rem)/2))]",
|
|
14
|
+
"[label>&]:after:-inset-y-[calc(max(0px,(1lh-1.25rem)/2)+4px)]"
|
|
15
|
+
],
|
|
16
|
+
indicator: "pointer-events-none"
|
|
17
|
+
} });
|
|
18
|
+
function Checkbox$1({ shape = "square", className, ...props }) {
|
|
19
|
+
const { root, indicator } = checkbox();
|
|
20
|
+
const renderIndicator = useCallback((indicatorProps, state) => /* @__PURE__ */ jsx(CheckboxIndicator, {
|
|
21
|
+
...indicatorProps,
|
|
22
|
+
checked: state.checked || state.indeterminate,
|
|
23
|
+
disabled: state.disabled,
|
|
24
|
+
mark: state.indeterminate ? "minus" : "check",
|
|
25
|
+
shape
|
|
26
|
+
}), [shape]);
|
|
27
|
+
return /* @__PURE__ */ jsx(Checkbox.Root, {
|
|
28
|
+
"data-slot": "checkbox",
|
|
29
|
+
className: root({ className }),
|
|
30
|
+
...props,
|
|
31
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
|
|
32
|
+
keepMounted: true,
|
|
33
|
+
"data-slot": "checkbox-indicator",
|
|
34
|
+
className: indicator(),
|
|
35
|
+
render: renderIndicator
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { Checkbox$1 as Checkbox };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/choice-list/choice-list.d.ts
|
|
3
|
+
export type ChoiceListItem = {
|
|
4
|
+
value: string;
|
|
5
|
+
/** The row's name. The radio or checkbox is named by this alone. */
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** What the search matches, case-insensitively. Defaults to `label` when it is a string. */
|
|
8
|
+
searchText?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Up to two lines under the name, each cut to one line. An empty line
|
|
11
|
+
* (null, false or "") is not drawn. Colour inside a line is the caller's.
|
|
12
|
+
*/
|
|
13
|
+
description?: ReactNode | readonly ReactNode[];
|
|
14
|
+
/** Drawn before the radio's or checkbox's row text: an avatar, an icon. */
|
|
15
|
+
media?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* A button at the end of the row, such as one that opens details. It sits
|
|
18
|
+
* outside the row's label and the group: clicking it chooses nothing, and
|
|
19
|
+
* it is a Tab stop of its own after the group, in row order.
|
|
20
|
+
*/
|
|
21
|
+
action?: ReactNode;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** The `value` of the group in `groups` this item is listed under. */
|
|
24
|
+
group?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ChoiceListGroup = {
|
|
27
|
+
value: string;
|
|
28
|
+
/** The small heading over the group's rows, such as "Agents". */
|
|
29
|
+
label: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
type ChoiceListCommonProps = {
|
|
32
|
+
items: readonly ChoiceListItem[];
|
|
33
|
+
/**
|
|
34
|
+
* When the search box shows. `"always"` when people look for an item they
|
|
35
|
+
* know by name, such as a person: the box shows at any count, and with a
|
|
36
|
+
* mouse or trackpad focus starts in it. `"auto"` when people choose by
|
|
37
|
+
* comparing the rows: the box shows only above 5 items.
|
|
38
|
+
*/
|
|
39
|
+
search?: "auto" | "always";
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
"aria-labelledby"?: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The search box's accessible name. Required: any list can come to search,
|
|
45
|
+
* since `"auto"` shows the box once the items, usually from data, pass 5.
|
|
46
|
+
*/
|
|
47
|
+
searchLabel: string;
|
|
48
|
+
searchPlaceholder?: string;
|
|
49
|
+
/** The search box's text when the list first draws, such as a search carried over. */
|
|
50
|
+
defaultSearchValue?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The search box's text, for a caller that uses it: a "Create “…”" row
|
|
53
|
+
* named after it, or a no-match line that quotes it. With it, the caller
|
|
54
|
+
* owns the text, and `onSearchValueChange` reports each change.
|
|
55
|
+
*/
|
|
56
|
+
searchValue?: string;
|
|
57
|
+
onSearchValueChange?: (value: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* The values of the items that match the search text, in the order to show
|
|
60
|
+
* them, for a caller with its own search (a ranked people search shared
|
|
61
|
+
* with mentions). With it ChoiceList doesn't match `searchText` itself; it
|
|
62
|
+
* still keeps the chosen rows first and says when nothing matches.
|
|
63
|
+
*/
|
|
64
|
+
matchedValues?: readonly string[];
|
|
65
|
+
/** The clear button's accessible name. */
|
|
66
|
+
clearSearchLabel: string;
|
|
67
|
+
/** The line under the chosen rows when nothing else matches. */
|
|
68
|
+
noMatchLabel?: ReactNode;
|
|
69
|
+
/** The line drawn when there are no items at all. */
|
|
70
|
+
empty?: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Headings that split the rows by kind, in this order, such as Agents then
|
|
73
|
+
* People. Each item names its group; a group with no rows to show, or a
|
|
74
|
+
* search that leaves it empty, draws no heading.
|
|
75
|
+
*/
|
|
76
|
+
groups?: readonly ChoiceListGroup[];
|
|
77
|
+
/**
|
|
78
|
+
* A row of the caller's under the list, inside its frame, that stays in
|
|
79
|
+
* view while the rows scroll: the way out when the item isn't there, such
|
|
80
|
+
* as "Create an agent".
|
|
81
|
+
*/
|
|
82
|
+
footer?: ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* The list takes the height it is given and its rows scroll inside it, for
|
|
85
|
+
* a sheet or panel whose main content is the list. Otherwise a list with a
|
|
86
|
+
* search scrolls past 18rem.
|
|
87
|
+
*/
|
|
88
|
+
fill?: boolean;
|
|
89
|
+
className?: string;
|
|
90
|
+
};
|
|
91
|
+
export type ChoiceListSingleProps = ChoiceListCommonProps & {
|
|
92
|
+
multiple?: false;
|
|
93
|
+
value: string | null;
|
|
94
|
+
onValueChange: (value: string) => void;
|
|
95
|
+
};
|
|
96
|
+
export type ChoiceListMultipleProps = ChoiceListCommonProps & {
|
|
97
|
+
multiple: true;
|
|
98
|
+
value: readonly string[];
|
|
99
|
+
onValueChange: (value: string[]) => void;
|
|
100
|
+
};
|
|
101
|
+
export type ChoiceListProps = ChoiceListSingleProps | ChoiceListMultipleProps;
|
|
102
|
+
export declare function ChoiceList(props: ChoiceListProps): import("react").JSX.Element;
|
|
103
|
+
//#endregion
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Button } from "../button/button.mjs";
|
|
2
|
+
import { Checkbox } from "../checkbox/checkbox.mjs";
|
|
3
|
+
import { useOverflowTitle } from "../../lib/use-overflow-title.mjs";
|
|
4
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from "../input-group/input-group.mjs";
|
|
5
|
+
import { RadioGroup, RadioGroupItem } from "../radio-group/radio-group.mjs";
|
|
6
|
+
import { choiceList } from "./choice-list.recipe.mjs";
|
|
7
|
+
import { Search, X } from "lucide-react";
|
|
8
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { CheckboxGroup } from "@base-ui/react/checkbox-group";
|
|
11
|
+
//#region src/components/choice-list/choice-list.tsx
|
|
12
|
+
const SEARCH_ABOVE = 5;
|
|
13
|
+
const MAX_DESCRIPTION_LINES = 2;
|
|
14
|
+
function isDrawn(line) {
|
|
15
|
+
return line !== null && line !== void 0 && line !== false && line !== "";
|
|
16
|
+
}
|
|
17
|
+
function descriptionLines(description) {
|
|
18
|
+
return (Array.isArray(description) ? description : [description]).filter(isDrawn);
|
|
19
|
+
}
|
|
20
|
+
function CutLine({ id, slot, className, children }) {
|
|
21
|
+
const ref = useOverflowTitle();
|
|
22
|
+
return /* @__PURE__ */ jsx("span", {
|
|
23
|
+
ref,
|
|
24
|
+
id,
|
|
25
|
+
"data-slot": slot,
|
|
26
|
+
className,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const NOT_TEXT_INPUTS = /* @__PURE__ */ new Set([
|
|
31
|
+
"button",
|
|
32
|
+
"checkbox",
|
|
33
|
+
"radio",
|
|
34
|
+
"submit",
|
|
35
|
+
"reset",
|
|
36
|
+
"image",
|
|
37
|
+
"file",
|
|
38
|
+
"range",
|
|
39
|
+
"color"
|
|
40
|
+
]);
|
|
41
|
+
function isTextEntry(element) {
|
|
42
|
+
if (!(element instanceof HTMLElement)) return false;
|
|
43
|
+
if (element.isContentEditable || element instanceof HTMLTextAreaElement) return true;
|
|
44
|
+
if (element instanceof HTMLSelectElement) return true;
|
|
45
|
+
return element instanceof HTMLInputElement && !NOT_TEXT_INPUTS.has(element.type);
|
|
46
|
+
}
|
|
47
|
+
function searchTextOf(item) {
|
|
48
|
+
if (item.searchText !== void 0) return item.searchText;
|
|
49
|
+
return typeof item.label === "string" ? item.label : "";
|
|
50
|
+
}
|
|
51
|
+
function visibleItems(items, needle, pinned, chosen, matchedValues) {
|
|
52
|
+
if (!needle) return {
|
|
53
|
+
rows: items,
|
|
54
|
+
noMatch: false
|
|
55
|
+
};
|
|
56
|
+
const matched = matchedValues ? new Set(matchedValues) : null;
|
|
57
|
+
const matches = (item) => matched ? matched.has(item.value) : searchTextOf(item).toLowerCase().includes(needle);
|
|
58
|
+
const pinnedSet = new Set(pinned);
|
|
59
|
+
const isPinned = (item) => pinnedSet.has(item.value);
|
|
60
|
+
const top = items.filter((item) => isPinned(item) || chosen.includes(item.value) && !matches(item));
|
|
61
|
+
const byValue = matchedValues ? new Map(items.map((item) => [item.value, item])) : null;
|
|
62
|
+
const rest = (byValue && matched ? [...matched].flatMap((value) => byValue.get(value) ?? []) : items).filter((item) => !top.includes(item) && matches(item));
|
|
63
|
+
return {
|
|
64
|
+
rows: [...top, ...rest],
|
|
65
|
+
noMatch: !items.some(matches)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function layoutSections(rows, groups) {
|
|
69
|
+
const known = new Set(groups?.map((group) => group.value));
|
|
70
|
+
const sections = groups ? groups.map((group) => ({
|
|
71
|
+
group,
|
|
72
|
+
rows: rows.filter((item) => item.group === group.value)
|
|
73
|
+
})) : [];
|
|
74
|
+
sections.push({
|
|
75
|
+
group: null,
|
|
76
|
+
rows: rows.filter((item) => !groups || item.group === void 0 || !known.has(item.group))
|
|
77
|
+
});
|
|
78
|
+
const drawn = sections.filter((section) => section.rows.length > 0);
|
|
79
|
+
const gridRowOf = /* @__PURE__ */ new Map();
|
|
80
|
+
let gridRows = 0;
|
|
81
|
+
for (const section of drawn) {
|
|
82
|
+
if (section.group) gridRows += 1;
|
|
83
|
+
for (const item of section.rows) {
|
|
84
|
+
gridRows += 1;
|
|
85
|
+
gridRowOf.set(item.value, gridRows);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
sections: drawn,
|
|
90
|
+
gridRowOf,
|
|
91
|
+
gridRows
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function ChoiceList(props) {
|
|
95
|
+
const { items, search = "auto", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disabled = false, searchLabel, searchPlaceholder, defaultSearchValue = "", searchValue, onSearchValueChange, matchedValues, clearSearchLabel, noMatchLabel, empty, groups, footer, fill = false, className } = props;
|
|
96
|
+
const value = props.value;
|
|
97
|
+
const chosen = useMemo(() => value === null ? [] : typeof value === "string" ? [value] : value, [value]);
|
|
98
|
+
const [ownQuery, setOwnQuery] = useState(defaultSearchValue);
|
|
99
|
+
const query = searchValue ?? ownQuery;
|
|
100
|
+
const setQuery = useCallback((next) => {
|
|
101
|
+
if (searchValue === void 0) setOwnQuery(next);
|
|
102
|
+
onSearchValueChange?.(next);
|
|
103
|
+
}, [searchValue, onSearchValueChange]);
|
|
104
|
+
const [pinned, setPinned] = useState(chosen);
|
|
105
|
+
const inputRef = useRef(null);
|
|
106
|
+
const baseId = useId();
|
|
107
|
+
const searchable = items.length > 0 && (search === "always" || items.length > SEARCH_ABOVE);
|
|
108
|
+
const [wasSearchable, setWasSearchable] = useState(searchable);
|
|
109
|
+
if (wasSearchable !== searchable) {
|
|
110
|
+
setWasSearchable(searchable);
|
|
111
|
+
if (!searchable) setOwnQuery("");
|
|
112
|
+
}
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!searchable && searchValue) onSearchValueChange?.("");
|
|
115
|
+
}, [
|
|
116
|
+
searchable,
|
|
117
|
+
searchValue,
|
|
118
|
+
onSearchValueChange
|
|
119
|
+
]);
|
|
120
|
+
const [pinnedFor, setPinnedFor] = useState(query);
|
|
121
|
+
if (pinnedFor !== query) {
|
|
122
|
+
setPinnedFor(query);
|
|
123
|
+
setPinned(chosen);
|
|
124
|
+
}
|
|
125
|
+
const { rows, noMatch } = visibleItems(items, searchable ? query.trim().toLowerCase() : "", pinned, chosen, matchedValues);
|
|
126
|
+
const hasAction = rows.some((item) => item.action !== void 0 && item.action !== null);
|
|
127
|
+
const slots = choiceList({
|
|
128
|
+
scroll: searchable && !fill,
|
|
129
|
+
fill
|
|
130
|
+
});
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (process.env.NODE_ENV === "production") return;
|
|
133
|
+
if (!ariaLabel && !ariaLabelledBy) console.warn("raft-ui: a ChoiceList has neither aria-label nor aria-labelledby.");
|
|
134
|
+
if (items.some((item) => descriptionLines(item.description).length > MAX_DESCRIPTION_LINES)) console.warn(`raft-ui: a ChoiceList item has more than ${MAX_DESCRIPTION_LINES} description lines; only the first ${MAX_DESCRIPTION_LINES} are drawn.`);
|
|
135
|
+
}, [
|
|
136
|
+
ariaLabel,
|
|
137
|
+
ariaLabelledBy,
|
|
138
|
+
items
|
|
139
|
+
]);
|
|
140
|
+
const focusSearch = search === "always" && searchable;
|
|
141
|
+
const focusedSearch = useRef(false);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!focusSearch || focusedSearch.current) return;
|
|
144
|
+
focusedSearch.current = true;
|
|
145
|
+
const input = inputRef.current;
|
|
146
|
+
if (!input || typeof window.matchMedia !== "function") return;
|
|
147
|
+
if (!window.matchMedia("(pointer: fine)").matches) return;
|
|
148
|
+
if (isTextEntry(document.activeElement)) return;
|
|
149
|
+
input.focus({ preventScroll: true });
|
|
150
|
+
}, [focusSearch]);
|
|
151
|
+
const changeQuery = useCallback((event) => {
|
|
152
|
+
setQuery(event.currentTarget.value);
|
|
153
|
+
}, [setQuery]);
|
|
154
|
+
const clearQuery = useCallback(() => {
|
|
155
|
+
setQuery("");
|
|
156
|
+
inputRef.current?.focus();
|
|
157
|
+
}, [setQuery]);
|
|
158
|
+
const { sections, gridRowOf, gridRows } = layoutSections(rows, groups);
|
|
159
|
+
const groupProps = {
|
|
160
|
+
"aria-label": ariaLabel,
|
|
161
|
+
"aria-labelledby": ariaLabelledBy,
|
|
162
|
+
disabled,
|
|
163
|
+
className: slots.group(),
|
|
164
|
+
style: { gridRow: `1 / span ${gridRows}` }
|
|
165
|
+
};
|
|
166
|
+
const rowElement = (item) => {
|
|
167
|
+
const id = `${baseId}-${items.indexOf(item)}`;
|
|
168
|
+
const lines = descriptionLines(item.description).slice(0, MAX_DESCRIPTION_LINES);
|
|
169
|
+
const rowDisabled = disabled || item.disabled === true;
|
|
170
|
+
const markProps = {
|
|
171
|
+
value: item.value,
|
|
172
|
+
disabled: item.disabled,
|
|
173
|
+
"aria-labelledby": `${id}-label`,
|
|
174
|
+
"aria-describedby": lines.length > 0 ? `${id}-description` : void 0
|
|
175
|
+
};
|
|
176
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
177
|
+
"data-slot": "choice-list-item",
|
|
178
|
+
"data-disabled": rowDisabled ? "" : void 0,
|
|
179
|
+
className: slots.item({ hasAction }),
|
|
180
|
+
children: [
|
|
181
|
+
props.multiple ? /* @__PURE__ */ jsx(Checkbox, { ...markProps }) : /* @__PURE__ */ jsx(RadioGroupItem, { ...markProps }),
|
|
182
|
+
item.media !== void 0 && item.media !== null ? /* @__PURE__ */ jsx("span", {
|
|
183
|
+
"data-slot": "choice-list-media",
|
|
184
|
+
className: slots.media(),
|
|
185
|
+
children: item.media
|
|
186
|
+
}) : null,
|
|
187
|
+
/* @__PURE__ */ jsxs("span", {
|
|
188
|
+
"data-slot": "choice-list-body",
|
|
189
|
+
className: slots.body(),
|
|
190
|
+
children: [/* @__PURE__ */ jsx(CutLine, {
|
|
191
|
+
id: `${id}-label`,
|
|
192
|
+
slot: "choice-list-label",
|
|
193
|
+
className: slots.label(),
|
|
194
|
+
children: item.label
|
|
195
|
+
}), lines.length > 0 ? /* @__PURE__ */ jsx("span", {
|
|
196
|
+
id: `${id}-description`,
|
|
197
|
+
className: "contents",
|
|
198
|
+
children: lines.map((line, index) => /* @__PURE__ */ jsx(CutLine, {
|
|
199
|
+
slot: "choice-list-description",
|
|
200
|
+
className: slots.description(),
|
|
201
|
+
children: line
|
|
202
|
+
}, index))
|
|
203
|
+
}) : null]
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
}, item.value);
|
|
207
|
+
};
|
|
208
|
+
const rowElements = sections.map((section, index) => {
|
|
209
|
+
if (!section.group) return section.rows.map(rowElement);
|
|
210
|
+
const headingId = `${baseId}-group-${index}`;
|
|
211
|
+
const start = (gridRowOf.get(section.rows[0].value) ?? 1) - 1;
|
|
212
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
213
|
+
role: "group",
|
|
214
|
+
"aria-labelledby": headingId,
|
|
215
|
+
"data-slot": "choice-list-section",
|
|
216
|
+
className: slots.section(),
|
|
217
|
+
style: { gridRow: `${start} / span ${section.rows.length + 1}` },
|
|
218
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
219
|
+
id: headingId,
|
|
220
|
+
"data-slot": "choice-list-heading",
|
|
221
|
+
className: slots.heading(),
|
|
222
|
+
children: section.group.label
|
|
223
|
+
}), section.rows.map(rowElement)]
|
|
224
|
+
}, section.group.value);
|
|
225
|
+
});
|
|
226
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
227
|
+
"data-slot": "choice-list",
|
|
228
|
+
className: slots.root({ className }),
|
|
229
|
+
children: [searchable ? /* @__PURE__ */ jsxs(InputGroup, {
|
|
230
|
+
"data-slot": "choice-list-search",
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { "aria-hidden": true }) }),
|
|
233
|
+
/* @__PURE__ */ jsx(InputGroupInput, {
|
|
234
|
+
ref: inputRef,
|
|
235
|
+
type: "search",
|
|
236
|
+
value: query,
|
|
237
|
+
onChange: changeQuery,
|
|
238
|
+
"aria-label": searchLabel,
|
|
239
|
+
placeholder: searchPlaceholder,
|
|
240
|
+
disabled,
|
|
241
|
+
autoComplete: "off",
|
|
242
|
+
className: slots.searchInput()
|
|
243
|
+
}),
|
|
244
|
+
query ? /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
245
|
+
align: "inline-end",
|
|
246
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
247
|
+
variant: "ghost",
|
|
248
|
+
size: "icon-md",
|
|
249
|
+
"aria-label": clearSearchLabel,
|
|
250
|
+
onClick: clearQuery,
|
|
251
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true })
|
|
252
|
+
})
|
|
253
|
+
}) : null
|
|
254
|
+
]
|
|
255
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
256
|
+
"data-slot": "choice-list-frame",
|
|
257
|
+
className: slots.frame(),
|
|
258
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
259
|
+
"data-slot": "choice-list-scroller",
|
|
260
|
+
className: slots.scroller(),
|
|
261
|
+
children: items.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
262
|
+
"data-slot": "choice-list-note",
|
|
263
|
+
className: slots.note(),
|
|
264
|
+
children: empty
|
|
265
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [rows.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
266
|
+
"data-slot": "choice-list-rows",
|
|
267
|
+
className: slots.rows(),
|
|
268
|
+
children: [props.multiple ? /* @__PURE__ */ jsx(CheckboxGroup, {
|
|
269
|
+
"data-slot": "choice-list-group",
|
|
270
|
+
value: props.value,
|
|
271
|
+
onValueChange: props.onValueChange,
|
|
272
|
+
...groupProps,
|
|
273
|
+
children: rowElements
|
|
274
|
+
}) : /* @__PURE__ */ jsx(RadioGroup, {
|
|
275
|
+
"data-slot": "choice-list-group",
|
|
276
|
+
value: props.value,
|
|
277
|
+
onValueChange: props.onValueChange,
|
|
278
|
+
...groupProps,
|
|
279
|
+
children: rowElements
|
|
280
|
+
}), sections.flatMap((section) => section.rows.map((item) => item.action !== void 0 && item.action !== null ? /* @__PURE__ */ jsx("div", {
|
|
281
|
+
"data-slot": "choice-list-action",
|
|
282
|
+
className: slots.action(),
|
|
283
|
+
style: { gridRow: gridRowOf.get(item.value) },
|
|
284
|
+
children: item.action
|
|
285
|
+
}, item.value) : null))]
|
|
286
|
+
}) : null, searchable ? /* @__PURE__ */ jsx("p", {
|
|
287
|
+
role: "status",
|
|
288
|
+
"data-slot": "choice-list-status",
|
|
289
|
+
className: noMatch ? slots.note() : "sr-only",
|
|
290
|
+
children: noMatch ? noMatchLabel : null
|
|
291
|
+
}) : null] })
|
|
292
|
+
}), footer !== void 0 && footer !== null ? /* @__PURE__ */ jsx("div", {
|
|
293
|
+
"data-slot": "choice-list-footer",
|
|
294
|
+
className: slots.footer(),
|
|
295
|
+
children: footer
|
|
296
|
+
}) : null]
|
|
297
|
+
})]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
export { ChoiceList };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tv } from "../../lib/tv.mjs";
|
|
2
|
+
//#region src/components/choice-list/choice-list.recipe.ts
|
|
3
|
+
const choiceList = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
root: ["grid min-w-0 gap-2"],
|
|
6
|
+
searchInput: ["[&::-webkit-search-cancel-button]:appearance-none"],
|
|
7
|
+
frame: ["flex min-w-0 flex-col overflow-hidden", "rounded-container border border-line-hairline bg-layer-card"],
|
|
8
|
+
scroller: ["min-h-0 min-w-0 p-1"],
|
|
9
|
+
rows: ["grid grid-cols-[minmax(0,1fr)_auto] gap-x-0 gap-y-0.5"],
|
|
10
|
+
group: ["col-span-2 col-start-1 grid grid-cols-subgrid grid-rows-subgrid gap-x-0 gap-y-0.5"],
|
|
11
|
+
section: ["col-span-2 col-start-1 grid grid-cols-subgrid grid-rows-subgrid"],
|
|
12
|
+
heading: ["col-span-2 px-2.5 pt-2 pb-1", "font-sans text-caption font-bold text-foreground-hint"],
|
|
13
|
+
item: [
|
|
14
|
+
"col-span-2 flex min-w-0 items-start gap-2.5 rounded-chip px-2.5",
|
|
15
|
+
"min-h-option py-option-inset",
|
|
16
|
+
"pointer-coarse:min-h-11 pointer-coarse:py-[calc((--spacing(11)-1lh)/2)]",
|
|
17
|
+
"text-left font-sans text-subhead",
|
|
18
|
+
"not-data-disabled:hover:bg-brand-soft not-data-disabled:active:overlay-medium",
|
|
19
|
+
"data-disabled:cursor-not-allowed"
|
|
20
|
+
],
|
|
21
|
+
media: ["flex h-lh shrink-0 items-center"],
|
|
22
|
+
body: ["grid min-w-0 flex-1 gap-0.5"],
|
|
23
|
+
label: ["truncate font-semibold text-foreground", "in-data-disabled:text-foreground-disabled"],
|
|
24
|
+
description: ["block truncate font-sans text-footnote font-normal text-foreground-muted", "in-data-disabled:text-foreground-disabled"],
|
|
25
|
+
action: [
|
|
26
|
+
"relative z-10 col-start-2 flex h-lh items-center self-start pr-1",
|
|
27
|
+
"mt-option-inset pointer-coarse:mt-[calc((--spacing(11)-1lh)/2)]",
|
|
28
|
+
"font-sans text-subhead"
|
|
29
|
+
],
|
|
30
|
+
note: ["px-2.5 py-2 font-sans text-callout text-foreground-hint"],
|
|
31
|
+
footer: ["shrink-0 border-t border-line-seam p-1"]
|
|
32
|
+
},
|
|
33
|
+
variants: {
|
|
34
|
+
scroll: { true: { scroller: ["max-h-72 overflow-y-auto overscroll-contain"] } },
|
|
35
|
+
fill: { true: {
|
|
36
|
+
root: ["flex min-h-0 flex-1 flex-col"],
|
|
37
|
+
frame: ["min-h-0 flex-1"],
|
|
38
|
+
scroller: ["flex-1 overflow-y-auto overscroll-contain"]
|
|
39
|
+
} },
|
|
40
|
+
hasAction: { true: { item: ["pr-11"] } }
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { choiceList };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ChoiceList, ChoiceListGroup, ChoiceListItem, ChoiceListMultipleProps, ChoiceListProps, ChoiceListSingleProps } from "./choice-list.mjs";
|
|
2
|
+
export { ChoiceList, type ChoiceListGroup, type ChoiceListItem, type ChoiceListMultipleProps, type ChoiceListProps, type ChoiceListSingleProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
//#region src/components/code-block/code-block.d.ts
|
|
3
|
+
export type CodeBlockProps = useRender.ComponentProps<"div">;
|
|
4
|
+
/** Framed code surface. Compose a header and a body inside it. */
|
|
5
|
+
export declare function CodeBlock({ className, render, ...props }: CodeBlockProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
6
|
+
export type CodeBlockHeaderProps = useRender.ComponentProps<"div">;
|
|
7
|
+
export declare function CodeBlockHeader({ className, render, ...props }: CodeBlockHeaderProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
export type CodeBlockTitleProps = useRender.ComponentProps<"span">;
|
|
9
|
+
export declare function CodeBlockTitle({ className, render, ...props }: CodeBlockTitleProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
|
+
export type CodeBlockActionsProps = useRender.ComponentProps<"div">;
|
|
11
|
+
/** Trailing action region. In the header it ends the header; in the body it takes a column of its own beside the code. */
|
|
12
|
+
export declare function CodeBlockActions({ className, render, ...props }: CodeBlockActionsProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type CodeBlockActionProps = useRender.ComponentProps<"button">;
|
|
14
|
+
/** Styled action shell. The consumer owns the icon and the behavior. */
|
|
15
|
+
export declare function CodeBlockAction({ className, render, ...props }: CodeBlockActionProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
export type CodeBlockBodyProps = useRender.ComponentProps<"div">;
|
|
17
|
+
/**
|
|
18
|
+
* Inner code panel. Render the code in a `CodeBlockPre` (or a complete pre
|
|
19
|
+
* and code) as children.
|
|
20
|
+
*/
|
|
21
|
+
export declare function CodeBlockBody({ children, className, render, ...props }: CodeBlockBodyProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
22
|
+
export type CodeBlockPreProps = useRender.ComponentProps<"pre">;
|
|
23
|
+
/**
|
|
24
|
+
* The code's `pre`. A long line scrolls inside it; while it does, it is a
|
|
25
|
+
* named region the keyboard can reach (`tabindex="0"`, `role="region"`, its
|
|
26
|
+
* `aria-label`, "Code" by default), since Safari doesn't focus a scroller on
|
|
27
|
+
* its own. Code that fits adds no Tab stop.
|
|
28
|
+
*/
|
|
29
|
+
export declare function CodeBlockPre({ render, ref, "aria-label": ariaLabel, ...props }: CodeBlockPreProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
30
|
+
//#endregion
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { codeBlock } from "./code-block.recipe.mjs";
|
|
2
|
+
import { useCallback, useLayoutEffect, useState } from "react";
|
|
3
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
//#region src/components/code-block/code-block.tsx
|
|
7
|
+
const CORNERS = [
|
|
8
|
+
{
|
|
9
|
+
x: "left",
|
|
10
|
+
y: "top"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
x: "right",
|
|
14
|
+
y: "top"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
x: "left",
|
|
18
|
+
y: "bottom"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
x: "right",
|
|
22
|
+
y: "bottom"
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
/** Framed code surface. Compose a header and a body inside it. */
|
|
26
|
+
function CodeBlock({ className, render, ...props }) {
|
|
27
|
+
const { root } = codeBlock();
|
|
28
|
+
const defaultProps = { className: root({ className }) };
|
|
29
|
+
return useRender({
|
|
30
|
+
defaultTagName: "div",
|
|
31
|
+
render,
|
|
32
|
+
props: mergeProps(defaultProps, props),
|
|
33
|
+
state: { slot: "code-block" }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function CodeBlockHeader({ className, render, ...props }) {
|
|
37
|
+
const { header } = codeBlock();
|
|
38
|
+
const defaultProps = { className: header({ className }) };
|
|
39
|
+
return useRender({
|
|
40
|
+
defaultTagName: "div",
|
|
41
|
+
render,
|
|
42
|
+
props: mergeProps(defaultProps, props),
|
|
43
|
+
state: { slot: "code-block-header" }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function CodeBlockTitle({ className, render, ...props }) {
|
|
47
|
+
const { title } = codeBlock();
|
|
48
|
+
const defaultProps = { className: title({ className }) };
|
|
49
|
+
return useRender({
|
|
50
|
+
defaultTagName: "span",
|
|
51
|
+
render,
|
|
52
|
+
props: mergeProps(defaultProps, props),
|
|
53
|
+
state: { slot: "code-block-title" }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Trailing action region. In the header it ends the header; in the body it takes a column of its own beside the code. */
|
|
57
|
+
function CodeBlockActions({ className, render, ...props }) {
|
|
58
|
+
const { actions } = codeBlock();
|
|
59
|
+
const defaultProps = { className: actions({ className }) };
|
|
60
|
+
return useRender({
|
|
61
|
+
defaultTagName: "div",
|
|
62
|
+
render,
|
|
63
|
+
props: mergeProps(defaultProps, props),
|
|
64
|
+
state: { slot: "code-block-actions" }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Styled action shell. The consumer owns the icon and the behavior. */
|
|
68
|
+
function CodeBlockAction({ className, render, ...props }) {
|
|
69
|
+
const { action } = codeBlock();
|
|
70
|
+
const defaultProps = {
|
|
71
|
+
type: "button",
|
|
72
|
+
className: action({ className })
|
|
73
|
+
};
|
|
74
|
+
return useRender({
|
|
75
|
+
defaultTagName: "button",
|
|
76
|
+
render,
|
|
77
|
+
props: mergeProps(defaultProps, props),
|
|
78
|
+
state: { slot: "code-block-action" }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Inner code panel. Render the code in a `CodeBlockPre` (or a complete pre
|
|
83
|
+
* and code) as children.
|
|
84
|
+
*/
|
|
85
|
+
function CodeBlockBody({ children, className, render, ...props }) {
|
|
86
|
+
const { body, corner } = codeBlock();
|
|
87
|
+
const defaultProps = {
|
|
88
|
+
className: body({ className }),
|
|
89
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [CORNERS.map(({ x, y }) => /* @__PURE__ */ jsx("span", {
|
|
90
|
+
"data-slot": "code-block-corner",
|
|
91
|
+
"data-x": x,
|
|
92
|
+
"data-y": y,
|
|
93
|
+
className: corner(),
|
|
94
|
+
"aria-hidden": true
|
|
95
|
+
}, `${y}-${x}`)), children] })
|
|
96
|
+
};
|
|
97
|
+
return useRender({
|
|
98
|
+
defaultTagName: "div",
|
|
99
|
+
render,
|
|
100
|
+
props: mergeProps(defaultProps, props),
|
|
101
|
+
state: { slot: "code-block-body" }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The code's `pre`. A long line scrolls inside it; while it does, it is a
|
|
106
|
+
* named region the keyboard can reach (`tabindex="0"`, `role="region"`, its
|
|
107
|
+
* `aria-label`, "Code" by default), since Safari doesn't focus a scroller on
|
|
108
|
+
* its own. Code that fits adds no Tab stop.
|
|
109
|
+
*/
|
|
110
|
+
function CodeBlockPre({ render, ref, "aria-label": ariaLabel = "Code", ...props }) {
|
|
111
|
+
const [pre, setPre] = useState(null);
|
|
112
|
+
const preRef = useCallback((element) => setPre(element), []);
|
|
113
|
+
const [overflowing, setOverflowing] = useState(false);
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
if (!pre) return;
|
|
116
|
+
const measure = () => setOverflowing(pre.scrollWidth > pre.clientWidth);
|
|
117
|
+
const resize = new ResizeObserver(measure);
|
|
118
|
+
const observe = () => {
|
|
119
|
+
resize.disconnect();
|
|
120
|
+
resize.observe(pre);
|
|
121
|
+
for (const child of pre.children) resize.observe(child);
|
|
122
|
+
};
|
|
123
|
+
observe();
|
|
124
|
+
const mutation = new MutationObserver(() => {
|
|
125
|
+
observe();
|
|
126
|
+
measure();
|
|
127
|
+
});
|
|
128
|
+
mutation.observe(pre, {
|
|
129
|
+
childList: true,
|
|
130
|
+
subtree: true,
|
|
131
|
+
characterData: true
|
|
132
|
+
});
|
|
133
|
+
return () => {
|
|
134
|
+
resize.disconnect();
|
|
135
|
+
mutation.disconnect();
|
|
136
|
+
};
|
|
137
|
+
}, [pre]);
|
|
138
|
+
return useRender({
|
|
139
|
+
defaultTagName: "pre",
|
|
140
|
+
render,
|
|
141
|
+
ref: ref ? [preRef, ref] : preRef,
|
|
142
|
+
props: mergeProps(overflowing ? {
|
|
143
|
+
tabIndex: 0,
|
|
144
|
+
role: "region",
|
|
145
|
+
"aria-label": ariaLabel
|
|
146
|
+
} : {}, props),
|
|
147
|
+
state: { slot: "code-block-pre" }
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { CodeBlock, CodeBlockAction, CodeBlockActions, CodeBlockBody, CodeBlockHeader, CodeBlockPre, CodeBlockTitle };
|