@exsto/ds 0.0.1-rc.2 → 0.0.1-rc.21
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/README.md +163 -28
- package/dist/date-picker.js +2 -0
- package/dist/ds/src/date-picker.d.ts +9 -0
- package/dist/ds/src/file-input.d.ts +9 -0
- package/dist/ds/src/index.d.ts +2 -3
- package/dist/ds/src/rich-text-editor.d.ts +8 -0
- package/dist/ds/src/time-field.d.ts +9 -0
- package/dist/file-input.js +2 -0
- package/dist/index.js +79 -2
- package/dist/rich-text-editor.js +4 -0
- package/dist/source-hash.txt +1 -0
- package/dist/styles.css +1185 -403
- package/dist/theme.css +122 -7
- package/dist/time-field.js +2 -0
- package/dist/ui/src/components/edyn/animated-number/animated-number.d.ts +30 -0
- package/dist/ui/src/components/edyn/animated-number/animated-number.js +108 -0
- package/dist/ui/src/components/edyn/animated-number/animated-number.js.map +1 -0
- package/dist/ui/src/components/edyn/animated-number/animated-number.test.d.ts +9 -0
- package/dist/ui/src/components/edyn/animated-number/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/audio-player/audio-player.d.ts +3 -2
- package/dist/ui/src/components/edyn/audio-player/audio-player.js +86 -0
- package/dist/ui/src/components/edyn/audio-player/audio-player.js.map +1 -0
- package/dist/ui/src/components/edyn/date-picker/date-picker.d.ts +86 -0
- package/dist/ui/src/components/edyn/date-picker/date-picker.js +302 -0
- package/dist/ui/src/components/edyn/date-picker/date-picker.js.map +1 -0
- package/dist/ui/src/components/edyn/date-picker/date-picker.state.test.d.ts +9 -0
- package/dist/ui/src/components/edyn/date-picker/date-text.d.ts +40 -0
- package/dist/ui/src/components/edyn/date-picker/date-text.js +105 -0
- package/dist/ui/src/components/edyn/date-picker/date-text.js.map +1 -0
- package/dist/ui/src/components/edyn/date-picker/index.d.ts +2 -0
- package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.d.ts +28 -0
- package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.js +70 -0
- package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.js.map +1 -0
- package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.test.d.ts +9 -0
- package/dist/ui/src/components/edyn/date-range-picker/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/file-input/file-input.d.ts +90 -0
- package/dist/ui/src/components/edyn/file-input/file-input.js +261 -0
- package/dist/ui/src/components/edyn/file-input/file-input.js.map +1 -0
- package/dist/ui/src/components/edyn/file-input/file-input.test.d.ts +8 -0
- package/dist/ui/src/components/edyn/file-input/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/initials-avatar/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.d.ts +54 -0
- package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.js +86 -0
- package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.js.map +1 -0
- package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.test.d.ts +10 -0
- package/dist/ui/src/components/edyn/multi-select/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/multi-select/multi-select.d.ts +117 -0
- package/dist/ui/src/components/edyn/multi-select/multi-select.js +342 -0
- package/dist/ui/src/components/edyn/multi-select/multi-select.js.map +1 -0
- package/dist/ui/src/components/edyn/multi-select/multi-select.test.d.ts +9 -0
- package/dist/ui/src/components/edyn/presence/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/presence/presence.d.ts +15 -0
- package/dist/ui/src/components/edyn/presence/presence.js +58 -0
- package/dist/ui/src/components/edyn/presence/presence.js.map +1 -0
- package/dist/ui/src/components/edyn/presence/presence.test.d.ts +8 -0
- package/dist/ui/src/components/edyn/progress-line/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/progress-line/progress-line.d.ts +23 -0
- package/dist/ui/src/components/edyn/progress-line/progress-line.js +100 -0
- package/dist/ui/src/components/edyn/progress-line/progress-line.js.map +1 -0
- package/dist/ui/src/components/edyn/progress-line/progress-line.test.d.ts +9 -0
- package/dist/ui/src/components/edyn/rich-text-content/allow-list.d.ts +11 -0
- package/dist/ui/src/components/edyn/rich-text-content/allow-list.js +37 -0
- package/dist/ui/src/components/edyn/rich-text-content/allow-list.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-content/index.d.ts +2 -0
- package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.d.ts +22 -0
- package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.js +124 -0
- package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.test.d.ts +8 -0
- package/dist/ui/src/components/edyn/rich-text-editor/extensions.d.ts +18 -0
- package/dist/ui/src/components/edyn/rich-text-editor/extensions.js +124 -0
- package/dist/ui/src/components/edyn/rich-text-editor/extensions.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/index.d.ts +3 -0
- package/dist/ui/src/components/edyn/rich-text-editor/mention-list.d.ts +17 -0
- package/dist/ui/src/components/edyn/rich-text-editor/mention-list.js +232 -0
- package/dist/ui/src/components/edyn/rich-text-editor/mention-list.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.d.ts +53 -0
- package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.js +244 -0
- package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.test.d.ts +6 -0
- package/dist/ui/src/components/edyn/rich-text-editor/serialize.d.ts +13 -0
- package/dist/ui/src/components/edyn/rich-text-editor/serialize.js +55 -0
- package/dist/ui/src/components/edyn/rich-text-editor/serialize.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/sync.d.ts +19 -0
- package/dist/ui/src/components/edyn/rich-text-editor/sync.js +34 -0
- package/dist/ui/src/components/edyn/rich-text-editor/sync.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/sync.test.d.ts +11 -0
- package/dist/ui/src/components/edyn/rich-text-editor/toolbar.d.ts +20 -0
- package/dist/ui/src/components/edyn/rich-text-editor/toolbar.js +235 -0
- package/dist/ui/src/components/edyn/rich-text-editor/toolbar.js.map +1 -0
- package/dist/ui/src/components/edyn/rich-text-editor/types.d.ts +68 -0
- package/dist/ui/src/components/edyn/rich-text-editor/types.js +26 -0
- package/dist/ui/src/components/edyn/rich-text-editor/types.js.map +1 -0
- package/dist/ui/src/components/edyn/time-field/index.d.ts +1 -0
- package/dist/ui/src/components/edyn/time-field/time-field.d.ts +85 -0
- package/dist/ui/src/components/edyn/time-field/time-field.js +337 -0
- package/dist/ui/src/components/edyn/time-field/time-field.js.map +1 -0
- package/dist/ui/src/components/edyn/time-field/time-field.test.d.ts +8 -0
- package/dist/ui/src/components/edyn/video-player/video-player.d.ts +2 -2
- package/dist/ui/src/components/edyn/video-player/video-player.js +132 -0
- package/dist/ui/src/components/edyn/video-player/video-player.js.map +1 -0
- package/dist/ui/src/components/forwarded-props.test.d.ts +8 -0
- package/dist/ui/src/components/ui/accordion/accordion.d.ts +9 -8
- package/dist/ui/src/components/ui/accordion/accordion.js +83 -0
- package/dist/ui/src/components/ui/accordion/accordion.js.map +1 -0
- package/dist/ui/src/components/ui/alert/alert.js +47 -0
- package/dist/ui/src/components/ui/alert/alert.js.map +1 -0
- package/dist/ui/src/components/ui/alert-dialog/alert-dialog.js +97 -0
- package/dist/ui/src/components/ui/alert-dialog/alert-dialog.js.map +1 -0
- package/dist/ui/src/components/ui/aspect-ratio/aspect-ratio.js +15 -0
- package/dist/ui/src/components/ui/aspect-ratio/aspect-ratio.js.map +1 -0
- package/dist/ui/src/components/ui/attachment/attachment.d.ts +1 -1
- package/dist/ui/src/components/ui/attachment/attachment.js +105 -0
- package/dist/ui/src/components/ui/attachment/attachment.js.map +1 -0
- package/dist/ui/src/components/ui/avatar/avatar.js +51 -0
- package/dist/ui/src/components/ui/avatar/avatar.js.map +1 -0
- package/dist/ui/src/components/ui/badge/badge.d.ts +1 -1
- package/dist/ui/src/components/ui/badge/badge.js +47 -0
- package/dist/ui/src/components/ui/badge/badge.js.map +1 -0
- package/dist/ui/src/components/ui/breadcrumb/breadcrumb.js +73 -0
- package/dist/ui/src/components/ui/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/ui/src/components/ui/bubble/bubble.js +74 -0
- package/dist/ui/src/components/ui/bubble/bubble.js.map +1 -0
- package/dist/ui/src/components/ui/button/button.behavior.test.d.ts +8 -0
- package/dist/ui/src/components/ui/button/button.d.ts +1 -1
- package/dist/ui/src/components/ui/button/button.js +93 -0
- package/dist/ui/src/components/ui/button/button.js.map +1 -0
- package/dist/ui/src/components/ui/button-group/button-group.js +37 -0
- package/dist/ui/src/components/ui/button-group/button-group.js.map +1 -0
- package/dist/ui/src/components/ui/calendar/calendar.behavior.test.d.ts +9 -0
- package/dist/ui/src/components/ui/calendar/calendar.d.ts +1 -1
- package/dist/ui/src/components/ui/calendar/calendar.js +141 -0
- package/dist/ui/src/components/ui/calendar/calendar.js.map +1 -0
- package/dist/ui/src/components/ui/card/card.js +57 -0
- package/dist/ui/src/components/ui/card/card.js.map +1 -0
- package/dist/ui/src/components/ui/carousel/carousel.js +136 -0
- package/dist/ui/src/components/ui/carousel/carousel.js.map +1 -0
- package/dist/ui/src/components/ui/chart/chart.js +168 -0
- package/dist/ui/src/components/ui/chart/chart.js.map +1 -0
- package/dist/ui/src/components/ui/checkbox/checkbox.js +21 -0
- package/dist/ui/src/components/ui/checkbox/checkbox.js.map +1 -0
- package/dist/ui/src/components/ui/collapsible/collapsible.js +26 -0
- package/dist/ui/src/components/ui/collapsible/collapsible.js.map +1 -0
- package/dist/ui/src/components/ui/combobox/combobox.d.ts +15 -1
- package/dist/ui/src/components/ui/combobox/combobox.js +111 -0
- package/dist/ui/src/components/ui/combobox/combobox.js.map +1 -0
- package/dist/ui/src/components/ui/command/command.d.ts +17 -1
- package/dist/ui/src/components/ui/command/command.js +118 -0
- package/dist/ui/src/components/ui/command/command.js.map +1 -0
- package/dist/ui/src/components/ui/context-menu/context-menu.d.ts +1 -1
- package/dist/ui/src/components/ui/context-menu/context-menu.js +145 -0
- package/dist/ui/src/components/ui/context-menu/context-menu.js.map +1 -0
- package/dist/ui/src/components/ui/dialog/dialog.js +94 -0
- package/dist/ui/src/components/ui/dialog/dialog.js.map +1 -0
- package/dist/ui/src/components/ui/direction/direction.js +2 -0
- package/dist/ui/src/components/ui/drawer/drawer.js +88 -0
- package/dist/ui/src/components/ui/drawer/drawer.js.map +1 -0
- package/dist/ui/src/components/ui/dropdown-menu/dropdown-menu.d.ts +12 -1
- package/dist/ui/src/components/ui/dropdown-menu/dropdown-menu.js +159 -0
- package/dist/ui/src/components/ui/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/ui/src/components/ui/empty/empty.js +61 -0
- package/dist/ui/src/components/ui/empty/empty.js.map +1 -0
- package/dist/ui/src/components/ui/field/field.js +36 -0
- package/dist/ui/src/components/ui/field/field.js.map +1 -0
- package/dist/ui/src/components/ui/hover-card/hover-card.js +39 -0
- package/dist/ui/src/components/ui/hover-card/hover-card.js.map +1 -0
- package/dist/ui/src/components/ui/indicator/indicator.js +79 -0
- package/dist/ui/src/components/ui/indicator/indicator.js.map +1 -0
- package/dist/ui/src/components/ui/input/input.js +16 -0
- package/dist/ui/src/components/ui/input/input.js.map +1 -0
- package/dist/ui/src/components/ui/input-group/input-group.d.ts +1 -1
- package/dist/ui/src/components/ui/input-group/input-group.js +77 -0
- package/dist/ui/src/components/ui/input-group/input-group.js.map +1 -0
- package/dist/ui/src/components/ui/input-otp/input-otp.js +48 -0
- package/dist/ui/src/components/ui/input-otp/input-otp.js.map +1 -0
- package/dist/ui/src/components/ui/item/item.d.ts +1 -1
- package/dist/ui/src/components/ui/item/item.js +122 -0
- package/dist/ui/src/components/ui/item/item.js.map +1 -0
- package/dist/ui/src/components/ui/kbd/kbd.js +21 -0
- package/dist/ui/src/components/ui/kbd/kbd.js.map +1 -0
- package/dist/ui/src/components/ui/label/label.js +14 -0
- package/dist/ui/src/components/ui/label/label.js.map +1 -0
- package/dist/ui/src/components/ui/marker/marker.js +44 -0
- package/dist/ui/src/components/ui/marker/marker.js.map +1 -0
- package/dist/ui/src/components/ui/menubar/menubar.js +140 -0
- package/dist/ui/src/components/ui/menubar/menubar.js.map +1 -0
- package/dist/ui/src/components/ui/message/message.js +50 -0
- package/dist/ui/src/components/ui/message/message.js.map +1 -0
- package/dist/ui/src/components/ui/message-scroller/message-scroller.js +61 -0
- package/dist/ui/src/components/ui/message-scroller/message-scroller.js.map +1 -0
- package/dist/ui/src/components/ui/native-select/native-select.js +39 -0
- package/dist/ui/src/components/ui/native-select/native-select.js.map +1 -0
- package/dist/ui/src/components/ui/navigation-menu/navigation-menu.js +87 -0
- package/dist/ui/src/components/ui/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/ui/src/components/ui/pagination/pagination.d.ts +3 -2
- package/dist/ui/src/components/ui/pagination/pagination.js +104 -0
- package/dist/ui/src/components/ui/pagination/pagination.js.map +1 -0
- package/dist/ui/src/components/ui/popover/popover.d.ts +1 -1
- package/dist/ui/src/components/ui/popover/popover.js +59 -0
- package/dist/ui/src/components/ui/popover/popover.js.map +1 -0
- package/dist/ui/src/components/ui/progress/progress.behavior.test.d.ts +8 -0
- package/dist/ui/src/components/ui/progress/progress.d.ts +43 -1
- package/dist/ui/src/components/ui/progress/progress.js +70 -0
- package/dist/ui/src/components/ui/progress/progress.js.map +1 -0
- package/dist/ui/src/components/ui/questionnaire/questionnaire.js +171 -0
- package/dist/ui/src/components/ui/questionnaire/questionnaire.js.map +1 -0
- package/dist/ui/src/components/ui/radio-group/radio-group.js +29 -0
- package/dist/ui/src/components/ui/radio-group/radio-group.js.map +1 -0
- package/dist/ui/src/components/ui/resizable/resizable.js +29 -0
- package/dist/ui/src/components/ui/resizable/resizable.js.map +1 -0
- package/dist/ui/src/components/ui/scroll-area/index.d.ts +1 -0
- package/dist/ui/src/components/ui/scroll-area/popup-list-scroll.d.ts +13 -0
- package/dist/ui/src/components/ui/scroll-area/popup-list-scroll.js +69 -0
- package/dist/ui/src/components/ui/scroll-area/popup-list-scroll.js.map +1 -0
- package/dist/ui/src/components/ui/scroll-area/scroll-area.behavior.test.d.ts +12 -0
- package/dist/ui/src/components/ui/scroll-area/scroll-area.d.ts +57 -6
- package/dist/ui/src/components/ui/scroll-area/scroll-area.js +155 -0
- package/dist/ui/src/components/ui/scroll-area/scroll-area.js.map +1 -0
- package/dist/ui/src/components/ui/select/select.js +97 -0
- package/dist/ui/src/components/ui/select/select.js.map +1 -0
- package/dist/ui/src/components/ui/separator/separator.behavior.test.d.ts +14 -0
- package/dist/ui/src/components/ui/separator/separator.d.ts +14 -0
- package/dist/ui/src/components/ui/separator/separator.js +30 -0
- package/dist/ui/src/components/ui/separator/separator.js.map +1 -0
- package/dist/ui/src/components/ui/sheet/sheet.d.ts +8 -0
- package/dist/ui/src/components/ui/sheet/sheet.js +99 -0
- package/dist/ui/src/components/ui/sheet/sheet.js.map +1 -0
- package/dist/ui/src/components/ui/sidebar/sidebar.js +383 -0
- package/dist/ui/src/components/ui/sidebar/sidebar.js.map +1 -0
- package/dist/ui/src/components/ui/skeleton/skeleton.js +14 -0
- package/dist/ui/src/components/ui/skeleton/skeleton.js.map +1 -0
- package/dist/ui/src/components/ui/slider/slider.js +49 -0
- package/dist/ui/src/components/ui/slider/slider.js.map +1 -0
- package/dist/ui/src/components/ui/spinner/spinner.js +28 -0
- package/dist/ui/src/components/ui/spinner/spinner.js.map +1 -0
- package/dist/ui/src/components/ui/switch/switch.js +20 -0
- package/dist/ui/src/components/ui/switch/switch.js.map +1 -0
- package/dist/ui/src/components/ui/table/table.behavior.test.d.ts +4 -5
- package/dist/ui/src/components/ui/table/table.d.ts +15 -1
- package/dist/ui/src/components/ui/table/table.js +81 -0
- package/dist/ui/src/components/ui/table/table.js.map +1 -0
- package/dist/ui/src/components/ui/tabs/tabs.d.ts +9 -8
- package/dist/ui/src/components/ui/tabs/tabs.js +50 -0
- package/dist/ui/src/components/ui/tabs/tabs.js.map +1 -0
- package/dist/ui/src/components/ui/textarea/textarea.js +14 -0
- package/dist/ui/src/components/ui/textarea/textarea.js.map +1 -0
- package/dist/ui/src/components/ui/toast/toast.js +124 -0
- package/dist/ui/src/components/ui/toast/toast.js.map +1 -0
- package/dist/ui/src/components/ui/toggle/toggle.js +37 -0
- package/dist/ui/src/components/ui/toggle/toggle.js.map +1 -0
- package/dist/ui/src/components/ui/toggle-group/toggle-group.js +56 -0
- package/dist/ui/src/components/ui/toggle-group/toggle-group.js.map +1 -0
- package/dist/ui/src/components/ui/tooltip/tooltip.js +43 -0
- package/dist/ui/src/components/ui/tooltip/tooltip.js.map +1 -0
- package/dist/ui/src/hooks/use-media-player.js +140 -0
- package/dist/ui/src/hooks/use-media-player.js.map +1 -0
- package/dist/ui/src/hooks/use-merged-refs.js +18 -0
- package/dist/ui/src/hooks/use-merged-refs.js.map +1 -0
- package/dist/ui/src/hooks/use-mobile.js +20 -0
- package/dist/ui/src/hooks/use-mobile.js.map +1 -0
- package/dist/ui/src/index.d.ts +8 -0
- package/dist/ui/src/lib/first-weekday.d.ts +6 -0
- package/dist/ui/src/lib/first-weekday.js +34 -0
- package/dist/ui/src/lib/first-weekday.js.map +1 -0
- package/dist/ui/src/lib/focus-guards.d.ts +2 -0
- package/dist/ui/src/lib/focus-guards.js +52 -0
- package/dist/ui/src/lib/focus-guards.js.map +1 -0
- package/dist/ui/src/lib/focus-ring.test.d.ts +8 -0
- package/dist/ui/src/lib/popup-list.d.ts +75 -0
- package/dist/ui/src/lib/popup-list.js +48 -0
- package/dist/ui/src/lib/popup-list.js.map +1 -0
- package/dist/ui/src/lib/popup-list.test.d.ts +10 -0
- package/dist/ui/src/lib/utils.js +21 -0
- package/dist/ui/src/lib/utils.js.map +1 -0
- package/package.json +36 -8
- package/dist/chunks/toggle-group-ByNq8g7H.js +0 -4263
- package/dist/chunks/toggle-group-ByNq8g7H.js.map +0 -1
- package/dist/dom/src/context.d.ts +0 -34
- package/dist/dom/src/define-element.d.ts +0 -11
- package/dist/dom/src/field-control.d.ts +0 -5
- package/dist/dom/src/index.d.ts +0 -6
- package/dist/dom/src/mode.d.ts +0 -8
- package/dist/dom/src/styles.d.ts +0 -6
- package/dist/dom/src/theme-state.d.ts +0 -1
- package/dist/dom/src/types.d.ts +0 -65
- package/dist/ds/src/elements.d.ts +0 -12
- package/dist/elements/src/edx-accordion.d.ts +0 -14
- package/dist/elements/src/edx-accordion.test.d.ts +0 -1
- package/dist/elements/src/edx-alert.d.ts +0 -14
- package/dist/elements/src/edx-audio-player.d.ts +0 -11
- package/dist/elements/src/edx-avatar.d.ts +0 -10
- package/dist/elements/src/edx-badge.d.ts +0 -12
- package/dist/elements/src/edx-breadcrumb.d.ts +0 -11
- package/dist/elements/src/edx-button-group.d.ts +0 -7
- package/dist/elements/src/edx-button.d.ts +0 -20
- package/dist/elements/src/edx-calendar.d.ts +0 -21
- package/dist/elements/src/edx-card.d.ts +0 -8
- package/dist/elements/src/edx-checkbox.d.ts +0 -18
- package/dist/elements/src/edx-combobox.d.ts +0 -28
- package/dist/elements/src/edx-content-components.d.ts +0 -2
- package/dist/elements/src/edx-dialog.d.ts +0 -20
- package/dist/elements/src/edx-drawer.d.ts +0 -21
- package/dist/elements/src/edx-dropdown-menu.d.ts +0 -29
- package/dist/elements/src/edx-field.d.ts +0 -9
- package/dist/elements/src/edx-field.test.d.ts +0 -1
- package/dist/elements/src/edx-indicator.d.ts +0 -14
- package/dist/elements/src/edx-input-group.d.ts +0 -32
- package/dist/elements/src/edx-input-otp.d.ts +0 -19
- package/dist/elements/src/edx-input.d.ts +0 -31
- package/dist/elements/src/edx-interactive-components.d.ts +0 -2
- package/dist/elements/src/edx-label.d.ts +0 -6
- package/dist/elements/src/edx-pagination.d.ts +0 -8
- package/dist/elements/src/edx-popover.d.ts +0 -24
- package/dist/elements/src/edx-progress.d.ts +0 -10
- package/dist/elements/src/edx-radio-group.d.ts +0 -22
- package/dist/elements/src/edx-radio-group.test.d.ts +0 -1
- package/dist/elements/src/edx-scroll-area.d.ts +0 -15
- package/dist/elements/src/edx-scroll-area.test.d.ts +0 -1
- package/dist/elements/src/edx-select.d.ts +0 -34
- package/dist/elements/src/edx-separator.d.ts +0 -10
- package/dist/elements/src/edx-skeleton.d.ts +0 -8
- package/dist/elements/src/edx-slider.d.ts +0 -17
- package/dist/elements/src/edx-slider.test.d.ts +0 -1
- package/dist/elements/src/edx-switch.d.ts +0 -18
- package/dist/elements/src/edx-table.d.ts +0 -13
- package/dist/elements/src/edx-table.test.d.ts +0 -1
- package/dist/elements/src/edx-tabs.d.ts +0 -15
- package/dist/elements/src/edx-tabs.test.d.ts +0 -1
- package/dist/elements/src/edx-textarea.d.ts +0 -25
- package/dist/elements/src/edx-toggle-group.d.ts +0 -27
- package/dist/elements/src/edx-toggle-group.test.d.ts +0 -1
- package/dist/elements/src/edx-toggle.d.ts +0 -18
- package/dist/elements/src/edx-tooltip.d.ts +0 -28
- package/dist/elements/src/edx-video-player.d.ts +0 -16
- package/dist/elements/src/field-control-bridge.d.ts +0 -7
- package/dist/elements/src/index.d.ts +0 -14
- package/dist/elements/src/projected-content.test.d.ts +0 -1
- package/dist/elements/src/registry.d.ts +0 -39
- package/dist/elements/src/registry.test.d.ts +0 -1
- package/dist/elements.js +0 -4020
- package/dist/elements.js.map +0 -1
- /package/dist/{dom/src/define-element.test.d.ts → ui/src/components/edyn/date-picker/date-text.test.d.ts} +0 -0
- /package/dist/{dom/src/native-slot.test.d.ts → ui/src/lib/first-weekday.test.d.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
/** An option: `leading` goes before its label (an avatar, a status dot), `count` after it (how many it would show). */
|
|
3
|
+
export type TMultiSelectOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
count?: number;
|
|
7
|
+
leading?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/** Every word the component prints, so a product can translate it. */
|
|
10
|
+
export interface IMultiSelectLabels {
|
|
11
|
+
noMatches: string;
|
|
12
|
+
loading: string;
|
|
13
|
+
/** Shown when `error` is `true`; a string `error` replaces it. */
|
|
14
|
+
error: string;
|
|
15
|
+
retry: string;
|
|
16
|
+
loadMore: string;
|
|
17
|
+
loadingMore: string;
|
|
18
|
+
clear: string;
|
|
19
|
+
selectedCount: (count: number) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_MULTI_SELECT_LABELS: IMultiSelectLabels;
|
|
22
|
+
/** Above this many options a list draws only the rows on screen. */
|
|
23
|
+
export declare const VIRTUALIZE_FROM = 100;
|
|
24
|
+
/** The number of options up to which a MultiSelect does not show its search field (see `searchFrom`). */
|
|
25
|
+
export declare const SEARCH_FROM = 8;
|
|
26
|
+
/** Anything else a button takes (data-*, aria-*, title) goes to the trigger. */
|
|
27
|
+
export interface IMultiSelectProps extends Omit<ComponentPropsWithoutRef<'button'>, 'placeholder' | 'value' | 'defaultValue' | 'id' | 'disabled' | 'className' | 'children' | 'onChange'> {
|
|
28
|
+
/** The trigger's text with nothing picked, which means no filter ("All dealer groups"). */
|
|
29
|
+
placeholder: string;
|
|
30
|
+
/** The search field's prompt ("Search dealer groups…"). */
|
|
31
|
+
searchPlaceholder: string;
|
|
32
|
+
/**
|
|
33
|
+
* How many options a list must have before it shows its search field: it is there for a list too long to scan, and over a short
|
|
34
|
+
* one it is a box in the way. Above this many (default 8, the rows a popup shows at once) the field shows; at or under, it
|
|
35
|
+
* does not. In async mode it always shows, because the field is how the caller is told what to fetch. `0` always shows it.
|
|
36
|
+
*
|
|
37
|
+
* Hidden, the field is still in the popup, out of sight and not typable, because it is what Base UI moves the highlight
|
|
38
|
+
* from: the arrow keys, Home, End and Enter work as ever, and a screen reader still finds it by its label.
|
|
39
|
+
*/
|
|
40
|
+
searchFrom?: number;
|
|
41
|
+
/** The options to show now: all of a short fixed list, or in async mode the ones for the typed text. */
|
|
42
|
+
options: readonly TMultiSelectOption[];
|
|
43
|
+
value: readonly string[];
|
|
44
|
+
onValueChange: (value: string[]) => void;
|
|
45
|
+
/**
|
|
46
|
+
* What the trigger says once something is chosen. `selection` (default) names the one chosen or counts several;
|
|
47
|
+
* `label` keeps the label and only counts, so a value the page shows elsewhere (as a removable chip, say) is
|
|
48
|
+
* not repeated here: nothing chosen reads `placeholder`, anything chosen reads `labels.selectedCount(n)`.
|
|
49
|
+
*/
|
|
50
|
+
summary?: 'selection' | 'label';
|
|
51
|
+
/** For a Label's htmlFor. */
|
|
52
|
+
id?: string;
|
|
53
|
+
'aria-label'?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Marks the trigger invalid: the kit's destructive border, and a screen reader says so. For a form that does not use
|
|
56
|
+
* Field; inside one, its invalid state already does this.
|
|
57
|
+
*/
|
|
58
|
+
'aria-invalid'?: boolean | 'true' | 'false';
|
|
59
|
+
/**
|
|
60
|
+
* The id of the text that explains it (the error). Added to what a Field names already, never replacing it.
|
|
61
|
+
*/
|
|
62
|
+
'aria-describedby'?: string;
|
|
63
|
+
/** Shown but not changeable (a read-only form). */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Layout only (a width); the look is the kit's. */
|
|
66
|
+
className?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Passing this turns on ASYNC MODE, for lists that grow (people, dealer groups) and must
|
|
69
|
+
* be searched by the API rather than loaded whole and filtered in the browser. The
|
|
70
|
+
* component then never filters: it reports the typed text (after `searchDelay`) and shows
|
|
71
|
+
* whatever `options` the caller supplies for it. It is also called with '' each time the
|
|
72
|
+
* list opens, so the first page is fetched on demand, not at page load.
|
|
73
|
+
*/
|
|
74
|
+
onSearchChange?: (text: string) => void;
|
|
75
|
+
/** How long typing must pause before `onSearchChange` is called. Async mode only. */
|
|
76
|
+
searchDelay?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The options behind the chosen values, for the ones not in the current `options`. A
|
|
79
|
+
* search that no longer returns a chosen value must not make it vanish from the trigger
|
|
80
|
+
* or the count, so the caller says what it is called. Without a label a value shows as
|
|
81
|
+
* itself.
|
|
82
|
+
*/
|
|
83
|
+
selectedOptions?: readonly TMultiSelectOption[];
|
|
84
|
+
/** The options for the typed text are on their way. The old ones stay until they arrive. */
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
/** The request failed: `true` for the default message, or the message itself. */
|
|
87
|
+
error?: boolean | string;
|
|
88
|
+
onRetry?: () => void;
|
|
89
|
+
/** There is another page after `options`. */
|
|
90
|
+
hasMore?: boolean;
|
|
91
|
+
onLoadMore?: () => void;
|
|
92
|
+
/** The next page is on its way. */
|
|
93
|
+
loadingMore?: boolean;
|
|
94
|
+
labels?: Partial<IMultiSelectLabels>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The options behind the chosen values, in the order they were chosen. A value with no
|
|
98
|
+
* known option is kept and shown as itself rather than dropped: a selection must never
|
|
99
|
+
* change just because a list did.
|
|
100
|
+
*/
|
|
101
|
+
export declare const resolveChosen: (value: readonly string[], options: readonly TMultiSelectOption[], selectedOptions?: readonly TMultiSelectOption[]) => TMultiSelectOption[];
|
|
102
|
+
/** What the trigger says: the placeholder, the one picked, or a count. */
|
|
103
|
+
export declare const summarize: (chosen: readonly TMultiSelectOption[], placeholder: string, labels: IMultiSelectLabels, summary?: "selection" | "label") => string;
|
|
104
|
+
/** Every chosen name, for a tooltip on a trigger whose text is cut. With `label` the names are not shown, so it is the text itself. */
|
|
105
|
+
export declare const fullSelection: (chosen: readonly TMultiSelectOption[], placeholder: string, labels: IMultiSelectLabels, summary?: "selection" | "label") => string;
|
|
106
|
+
/**
|
|
107
|
+
* A choice of several from a list: a trigger shaped like a Select that says what is picked
|
|
108
|
+
* (the placeholder, the one picked, or a count), and a popup with a search field and checkbox
|
|
109
|
+
* options, with the shared popup list style, the ScrollArea's bar and fades, and virtualization
|
|
110
|
+
* past VIRTUALIZE_FROM options. Nothing chosen means no filter.
|
|
111
|
+
*
|
|
112
|
+
* For a short fixed list pass `options` and nothing else: the component filters them as the
|
|
113
|
+
* user types. For a list that grows, pass `onSearchChange` and it becomes a window onto a
|
|
114
|
+
* server: the caller fetches the options for the typed text, and says when they are loading,
|
|
115
|
+
* failed, or have another page.
|
|
116
|
+
*/
|
|
117
|
+
export declare const MultiSelect: ({ placeholder, searchPlaceholder, searchFrom, options, value, onValueChange, id, disabled, className, onSearchChange, searchDelay, selectedOptions, loading, error, onRetry, hasMore, onLoadMore, loadingMore, labels: labelOverrides, summary, ...rest }: IMultiSelectProps) => import('react').JSX.Element;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { useExposedFocusGuards } from "../../../lib/focus-guards.js";
|
|
3
|
+
import { POPUP_FRAME_CLASS, POPUP_LAYER_CLASS, POPUP_LIST_HEIGHT_CLASS, POPUP_LIST_WIDTH_CLASS, popupItemClass } from "../../../lib/popup-list.js";
|
|
4
|
+
import { ScrollArea } from "../../ui/scroll-area/scroll-area.js";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../../ui/tooltip/tooltip.js";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { IconCheck, IconChevronDown, IconSearch } from "@tabler/icons-react";
|
|
9
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
10
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
11
|
+
//#region ../ui/src/components/edyn/multi-select/multi-select.tsx
|
|
12
|
+
var DEFAULT_MULTI_SELECT_LABELS = {
|
|
13
|
+
noMatches: "No matches.",
|
|
14
|
+
loading: "Loading…",
|
|
15
|
+
error: "Could not load the options.",
|
|
16
|
+
retry: "Try again",
|
|
17
|
+
loadMore: "Load more",
|
|
18
|
+
loadingMore: "Loading…",
|
|
19
|
+
clear: "Clear",
|
|
20
|
+
selectedCount: (count) => `${count} selected`
|
|
21
|
+
};
|
|
22
|
+
/** Above this many options a list draws only the rows on screen. */
|
|
23
|
+
var VIRTUALIZE_FROM = 100;
|
|
24
|
+
/** The number of options up to which a MultiSelect does not show its search field (see `searchFrom`). */
|
|
25
|
+
var SEARCH_FROM = 8;
|
|
26
|
+
var ITEM_HEIGHT = 32;
|
|
27
|
+
/**
|
|
28
|
+
* The options behind the chosen values, in the order they were chosen. A value with no
|
|
29
|
+
* known option is kept and shown as itself rather than dropped: a selection must never
|
|
30
|
+
* change just because a list did.
|
|
31
|
+
*/
|
|
32
|
+
var resolveChosen = (value, options, selectedOptions = []) => {
|
|
33
|
+
const known = /* @__PURE__ */ new Map();
|
|
34
|
+
for (const option of [...selectedOptions, ...options]) known.set(option.value, option);
|
|
35
|
+
return value.map((entry) => known.get(entry) ?? {
|
|
36
|
+
value: entry,
|
|
37
|
+
label: entry
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
/** What the trigger says: the placeholder, the one picked, or a count. */
|
|
41
|
+
var summarize = (chosen, placeholder, labels, summary = "selection") => {
|
|
42
|
+
if (chosen.length === 0) return placeholder;
|
|
43
|
+
if (summary === "label") return labels.selectedCount(chosen.length);
|
|
44
|
+
return chosen.length === 1 ? chosen[0]?.label ?? "" : labels.selectedCount(chosen.length);
|
|
45
|
+
};
|
|
46
|
+
/** Every chosen name, for a tooltip on a trigger whose text is cut. With `label` the names are not shown, so it is the text itself. */
|
|
47
|
+
var fullSelection = (chosen, placeholder, labels, summary = "selection") => summary === "selection" && chosen.length > 0 ? chosen.map((option) => option.label).join(", ") : summarize(chosen, placeholder, labels, summary);
|
|
48
|
+
var POPUP = cn("flex max-h-(--available-height) origin-(--transform-origin) flex-col overflow-hidden duration-100", POPUP_FRAME_CLASS, POPUP_LIST_WIDTH_CLASS, "motion-reduce:animate-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95");
|
|
49
|
+
var TRIGGER = "flex h-8 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-lg border border-control bg-transparent px-2.5 text-sm text-foreground transition-colors outline-none disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive data-popup-open:outline-solid dark:bg-input/30";
|
|
50
|
+
var Option = ({ option, index, style, measure, highlighted }) => {
|
|
51
|
+
const [cut, setCut] = useState(false);
|
|
52
|
+
const measureLabel = useCallback((element) => {
|
|
53
|
+
if (!element) return;
|
|
54
|
+
const measureCut = () => setCut(element.scrollWidth > element.clientWidth);
|
|
55
|
+
measureCut();
|
|
56
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
57
|
+
const observer = new ResizeObserver(measureCut);
|
|
58
|
+
observer.observe(element);
|
|
59
|
+
return () => observer.disconnect();
|
|
60
|
+
}, []);
|
|
61
|
+
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
62
|
+
value: option,
|
|
63
|
+
index,
|
|
64
|
+
ref: measure,
|
|
65
|
+
"data-index": index,
|
|
66
|
+
style,
|
|
67
|
+
"data-slot": "multi-select-item",
|
|
68
|
+
className: cn(popupItemClass("base-ui"), "group"),
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx("span", {
|
|
71
|
+
"data-slot": "multi-select-item-indicator",
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
className: "flex size-4 shrink-0 items-center justify-center rounded-sm border border-control text-primary-foreground transition-colors group-data-[selected]:border-primary group-data-[selected]:bg-primary",
|
|
74
|
+
children: /* @__PURE__ */ jsx(IconCheck, {
|
|
75
|
+
className: "size-3 opacity-0 group-data-[selected]:opacity-100",
|
|
76
|
+
stroke: 3
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
option.leading,
|
|
80
|
+
/* @__PURE__ */ jsxs(Tooltip, {
|
|
81
|
+
open: highlighted && cut,
|
|
82
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
83
|
+
"data-slot": "multi-select-item-label",
|
|
84
|
+
"data-overflowing": cut ? "" : void 0,
|
|
85
|
+
render: /* @__PURE__ */ jsx("span", {
|
|
86
|
+
ref: measureLabel,
|
|
87
|
+
className: "min-w-0 flex-1 truncate"
|
|
88
|
+
}),
|
|
89
|
+
children: option.label
|
|
90
|
+
}, option.label), /* @__PURE__ */ jsx(TooltipContent, {
|
|
91
|
+
side: "right",
|
|
92
|
+
children: option.label
|
|
93
|
+
})]
|
|
94
|
+
}),
|
|
95
|
+
option.count !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
96
|
+
className: "text-xs text-muted-foreground tabular-nums group-data-highlighted:text-foreground",
|
|
97
|
+
children: option.count
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
var Options = ({ scroller, scrollTo, busy, highlightedValue }) => {
|
|
103
|
+
const items = Combobox.useFilteredItems();
|
|
104
|
+
const virtual = items.length > 100;
|
|
105
|
+
const [mounted, setMounted] = useState(false);
|
|
106
|
+
useEffect(() => setMounted(true), []);
|
|
107
|
+
const virtualizer = useVirtualizer({
|
|
108
|
+
count: items.length,
|
|
109
|
+
getScrollElement: () => scroller.current,
|
|
110
|
+
estimateSize: () => ITEM_HEIGHT,
|
|
111
|
+
overscan: 12,
|
|
112
|
+
enabled: virtual && mounted
|
|
113
|
+
});
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
scrollTo.current = virtual ? (index) => virtualizer.scrollToIndex(index, { align: "auto" }) : () => void 0;
|
|
116
|
+
}, [
|
|
117
|
+
scrollTo,
|
|
118
|
+
virtual,
|
|
119
|
+
virtualizer
|
|
120
|
+
]);
|
|
121
|
+
if (!virtual) return /* @__PURE__ */ jsx(Combobox.List, {
|
|
122
|
+
"aria-busy": busy || void 0,
|
|
123
|
+
className: "px-1 outline-none",
|
|
124
|
+
children: items.map((option, index) => /* @__PURE__ */ jsx(Option, {
|
|
125
|
+
option,
|
|
126
|
+
index,
|
|
127
|
+
highlighted: highlightedValue === option.value
|
|
128
|
+
}, option.value))
|
|
129
|
+
});
|
|
130
|
+
return /* @__PURE__ */ jsx(Combobox.List, {
|
|
131
|
+
"data-virtualized": "",
|
|
132
|
+
"aria-busy": busy || void 0,
|
|
133
|
+
className: "relative mx-1 outline-none",
|
|
134
|
+
style: { height: virtualizer.getTotalSize() },
|
|
135
|
+
children: virtualizer.getVirtualItems().map((row) => {
|
|
136
|
+
const option = items[row.index];
|
|
137
|
+
return option === void 0 ? null : /* @__PURE__ */ jsx(Option, {
|
|
138
|
+
option,
|
|
139
|
+
index: row.index,
|
|
140
|
+
highlighted: highlightedValue === option.value,
|
|
141
|
+
measure: virtualizer.measureElement,
|
|
142
|
+
style: {
|
|
143
|
+
position: "absolute",
|
|
144
|
+
top: 0,
|
|
145
|
+
left: 0,
|
|
146
|
+
right: 0,
|
|
147
|
+
transform: `translateY(${row.start}px)`
|
|
148
|
+
}
|
|
149
|
+
}, option.value);
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
/** Rendered inside the portal, so it exists only while the list is open: the focus guards around the list are not aria-hidden. */
|
|
154
|
+
var ExposedFocusGuards = () => {
|
|
155
|
+
useExposedFocusGuards();
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A choice of several from a list: a trigger shaped like a Select that says what is picked
|
|
160
|
+
* (the placeholder, the one picked, or a count), and a popup with a search field and checkbox
|
|
161
|
+
* options, with the shared popup list style, the ScrollArea's bar and fades, and virtualization
|
|
162
|
+
* past VIRTUALIZE_FROM options. Nothing chosen means no filter.
|
|
163
|
+
*
|
|
164
|
+
* For a short fixed list pass `options` and nothing else: the component filters them as the
|
|
165
|
+
* user types. For a list that grows, pass `onSearchChange` and it becomes a window onto a
|
|
166
|
+
* server: the caller fetches the options for the typed text, and says when they are loading,
|
|
167
|
+
* failed, or have another page.
|
|
168
|
+
*/
|
|
169
|
+
var MultiSelect = ({ placeholder, searchPlaceholder, searchFrom = 8, options, value, onValueChange, id, disabled = false, className, onSearchChange, searchDelay = 250, selectedOptions, loading = false, error = false, onRetry, hasMore = false, onLoadMore, loadingMore = false, labels: labelOverrides, summary = "selection", ...rest }) => {
|
|
170
|
+
const labels = useMemo(() => ({
|
|
171
|
+
...DEFAULT_MULTI_SELECT_LABELS,
|
|
172
|
+
...labelOverrides
|
|
173
|
+
}), [labelOverrides]);
|
|
174
|
+
const isAsync = onSearchChange !== void 0;
|
|
175
|
+
const chosen = useMemo(() => resolveChosen(value, options, selectedOptions), [
|
|
176
|
+
value,
|
|
177
|
+
options,
|
|
178
|
+
selectedOptions
|
|
179
|
+
]);
|
|
180
|
+
const items = useMemo(() => {
|
|
181
|
+
const offered = new Set(options.map((option) => option.value));
|
|
182
|
+
return [...chosen.filter((option) => !offered.has(option.value)), ...options];
|
|
183
|
+
}, [chosen, options]);
|
|
184
|
+
const refScroller = useRef(null);
|
|
185
|
+
const refScrollTo = useRef(() => void 0);
|
|
186
|
+
const refTimer = useRef(void 0);
|
|
187
|
+
const refTriggerText = useRef(null);
|
|
188
|
+
const refSearch = useRef(null);
|
|
189
|
+
const [popupOpen, setPopupOpen] = useState(false);
|
|
190
|
+
const [highlightedValue, setHighlightedValue] = useState(null);
|
|
191
|
+
const refReported = useRef(void 0);
|
|
192
|
+
const refOpen = useRef(false);
|
|
193
|
+
const searchable = isAsync || items.length > searchFrom;
|
|
194
|
+
const errorMessage = typeof error === "string" ? error : labels.error;
|
|
195
|
+
const failed = error !== false;
|
|
196
|
+
useEffect(() => () => window.clearTimeout(refTimer.current), []);
|
|
197
|
+
const closeFromTrigger = (event) => {
|
|
198
|
+
if (event.key !== "Escape" || !popupOpen || refSearch.current === null) return;
|
|
199
|
+
event.stopPropagation();
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
refSearch.current.dispatchEvent(new KeyboardEvent("keydown", {
|
|
202
|
+
key: "Escape",
|
|
203
|
+
bubbles: true,
|
|
204
|
+
cancelable: true
|
|
205
|
+
}));
|
|
206
|
+
};
|
|
207
|
+
return /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
208
|
+
multiple: true,
|
|
209
|
+
disabled,
|
|
210
|
+
items,
|
|
211
|
+
filter: isAsync ? null : void 0,
|
|
212
|
+
value: chosen,
|
|
213
|
+
onValueChange: (next) => onValueChange(next.map((option) => option.value)),
|
|
214
|
+
onInputValueChange: (text) => {
|
|
215
|
+
if (onSearchChange === void 0 || !refOpen.current) return;
|
|
216
|
+
window.clearTimeout(refTimer.current);
|
|
217
|
+
if (text === refReported.current) return;
|
|
218
|
+
refTimer.current = window.setTimeout(() => {
|
|
219
|
+
refReported.current = text;
|
|
220
|
+
onSearchChange(text);
|
|
221
|
+
}, searchDelay);
|
|
222
|
+
},
|
|
223
|
+
onOpenChange: (open) => {
|
|
224
|
+
window.clearTimeout(refTimer.current);
|
|
225
|
+
setPopupOpen(open);
|
|
226
|
+
if (!open) setHighlightedValue(null);
|
|
227
|
+
refOpen.current = open;
|
|
228
|
+
refReported.current = open ? "" : void 0;
|
|
229
|
+
if (open && onSearchChange !== void 0) onSearchChange("");
|
|
230
|
+
},
|
|
231
|
+
itemToStringLabel: (option) => option.label,
|
|
232
|
+
isItemEqualToValue: (a, b) => a.value === b.value,
|
|
233
|
+
virtualized: items.length > 100,
|
|
234
|
+
onItemHighlighted: (item, details) => {
|
|
235
|
+
setHighlightedValue(item?.value ?? null);
|
|
236
|
+
if (details.reason === "keyboard" && details.index >= 0) refScrollTo.current(details.index);
|
|
237
|
+
},
|
|
238
|
+
children: [/* @__PURE__ */ jsxs(Tooltip, {
|
|
239
|
+
disabled: popupOpen,
|
|
240
|
+
onOpenChange: (open, details) => {
|
|
241
|
+
const element = refTriggerText.current;
|
|
242
|
+
if (open && !(element && element.scrollWidth > element.clientWidth)) details.cancel();
|
|
243
|
+
},
|
|
244
|
+
children: [/* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
245
|
+
"data-slot": "multi-select-trigger",
|
|
246
|
+
render: /* @__PURE__ */ jsx(Combobox.Trigger, {
|
|
247
|
+
...rest,
|
|
248
|
+
id,
|
|
249
|
+
"data-set": chosen.length > 0 ? "" : void 0,
|
|
250
|
+
onKeyDown: closeFromTrigger,
|
|
251
|
+
className: cn(TRIGGER, className)
|
|
252
|
+
}),
|
|
253
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
254
|
+
ref: refTriggerText,
|
|
255
|
+
className: cn("min-w-0 flex-1 truncate text-left", chosen.length === 0 && "text-muted-foreground"),
|
|
256
|
+
children: summarize(chosen, placeholder, labels, summary)
|
|
257
|
+
}), /* @__PURE__ */ jsx(IconChevronDown, {
|
|
258
|
+
"aria-hidden": "true",
|
|
259
|
+
className: "size-4 shrink-0 text-muted-foreground"
|
|
260
|
+
})]
|
|
261
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: fullSelection(chosen, placeholder, labels, summary) })]
|
|
262
|
+
}), /* @__PURE__ */ jsxs(Combobox.Portal, { children: [/* @__PURE__ */ jsx(ExposedFocusGuards, {}), /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
263
|
+
sideOffset: 4,
|
|
264
|
+
align: "start",
|
|
265
|
+
className: POPUP_LAYER_CLASS,
|
|
266
|
+
children: /* @__PURE__ */ jsxs(Combobox.Popup, {
|
|
267
|
+
"data-slot": "multi-select-content",
|
|
268
|
+
className: POPUP,
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ jsxs("div", {
|
|
271
|
+
className: searchable ? "flex shrink-0 items-center gap-2 border-b border-border px-3" : "sr-only",
|
|
272
|
+
children: [/* @__PURE__ */ jsx(IconSearch, {
|
|
273
|
+
"aria-hidden": "true",
|
|
274
|
+
className: "size-4 shrink-0 text-muted-foreground"
|
|
275
|
+
}), /* @__PURE__ */ jsx(Combobox.Input, {
|
|
276
|
+
ref: refSearch,
|
|
277
|
+
readOnly: !searchable,
|
|
278
|
+
placeholder: searchPlaceholder,
|
|
279
|
+
"aria-label": searchPlaceholder.replace(/…$/, ""),
|
|
280
|
+
className: "h-10 w-full min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
281
|
+
})]
|
|
282
|
+
}),
|
|
283
|
+
/* @__PURE__ */ jsx(Combobox.Status, {
|
|
284
|
+
"data-slot": "multi-select-status",
|
|
285
|
+
className: "px-3 py-2 text-sm text-muted-foreground empty:p-0",
|
|
286
|
+
children: failed ? /* @__PURE__ */ jsxs("span", {
|
|
287
|
+
className: "flex items-center justify-between gap-2 text-destructive",
|
|
288
|
+
children: [errorMessage, onRetry !== void 0 && /* @__PURE__ */ jsx("button", {
|
|
289
|
+
type: "button",
|
|
290
|
+
onClick: onRetry,
|
|
291
|
+
className: "rounded-md px-2 py-1 font-medium text-foreground hover:bg-foreground/6",
|
|
292
|
+
children: labels.retry
|
|
293
|
+
})]
|
|
294
|
+
}) : loading ? labels.loading : null
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ jsx(Combobox.Empty, {
|
|
297
|
+
className: "px-3 py-6 text-center text-sm text-muted-foreground empty:p-0",
|
|
298
|
+
children: loading || failed ? null : labels.noMatches
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx(ScrollArea, {
|
|
301
|
+
type: "always",
|
|
302
|
+
fade: true,
|
|
303
|
+
viewportRef: refScroller,
|
|
304
|
+
className: POPUP_LIST_HEIGHT_CLASS,
|
|
305
|
+
children: /* @__PURE__ */ jsx(Options, {
|
|
306
|
+
scroller: refScroller,
|
|
307
|
+
scrollTo: refScrollTo,
|
|
308
|
+
busy: loading,
|
|
309
|
+
highlightedValue
|
|
310
|
+
})
|
|
311
|
+
}),
|
|
312
|
+
hasMore && onLoadMore !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
313
|
+
className: "shrink-0 border-t border-border p-1",
|
|
314
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
315
|
+
type: "button",
|
|
316
|
+
disabled: loadingMore,
|
|
317
|
+
onClick: onLoadMore,
|
|
318
|
+
className: "h-8 w-full rounded-md px-2 text-sm font-medium text-foreground hover:bg-foreground/6 disabled:pointer-events-none disabled:opacity-50",
|
|
319
|
+
children: loadingMore ? labels.loadingMore : labels.loadMore
|
|
320
|
+
})
|
|
321
|
+
}),
|
|
322
|
+
chosen.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
323
|
+
className: "flex shrink-0 items-center justify-between gap-2 border-t border-border py-1 pr-1 pl-3 text-xs text-muted-foreground",
|
|
324
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
325
|
+
className: "tabular-nums",
|
|
326
|
+
children: labels.selectedCount(chosen.length)
|
|
327
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
328
|
+
type: "button",
|
|
329
|
+
onClick: () => onValueChange([]),
|
|
330
|
+
className: "rounded-md px-2 py-1 font-medium text-foreground hover:bg-foreground/6",
|
|
331
|
+
children: labels.clear
|
|
332
|
+
})]
|
|
333
|
+
})
|
|
334
|
+
]
|
|
335
|
+
})
|
|
336
|
+
})] })]
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
//#endregion
|
|
340
|
+
export { DEFAULT_MULTI_SELECT_LABELS, MultiSelect, SEARCH_FROM, VIRTUALIZE_FROM, fullSelection, resolveChosen, summarize };
|
|
341
|
+
|
|
342
|
+
//# sourceMappingURL=multi-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select.js","names":[],"sources":["../../../../../../../ui/src/components/edyn/multi-select/multi-select.tsx"],"sourcesContent":["import { Combobox } from '@base-ui/react/combobox';\nimport { ScrollArea } from '@edyn/ui/components/ui/scroll-area';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@edyn/ui/components/ui/tooltip';\nimport { useExposedFocusGuards } from '@edyn/ui/lib/focus-guards';\nimport { POPUP_FRAME_CLASS, POPUP_LAYER_CLASS, POPUP_LIST_HEIGHT_CLASS, POPUP_LIST_WIDTH_CLASS, popupItemClass } from '@edyn/ui/lib/popup-list';\nimport { cn } from '@edyn/ui/lib/utils';\nimport { IconCheck, IconChevronDown, IconSearch } from '@tabler/icons-react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n type RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\n/** An option: `leading` goes before its label (an avatar, a status dot), `count` after it (how many it would show). */\nexport type TMultiSelectOption = { value: string; label: string; count?: number; leading?: ReactNode };\n\n/** Every word the component prints, so a product can translate it. */\nexport interface IMultiSelectLabels {\n noMatches: string;\n loading: string;\n /** Shown when `error` is `true`; a string `error` replaces it. */\n error: string;\n retry: string;\n loadMore: string;\n loadingMore: string;\n clear: string;\n selectedCount: (count: number) => string;\n}\n\nexport const DEFAULT_MULTI_SELECT_LABELS: IMultiSelectLabels = {\n noMatches: 'No matches.',\n loading: 'Loading…',\n error: 'Could not load the options.',\n retry: 'Try again',\n loadMore: 'Load more',\n loadingMore: 'Loading…',\n clear: 'Clear',\n selectedCount: (count) => `${count} selected`,\n};\n\n/** Above this many options a list draws only the rows on screen. */\nexport const VIRTUALIZE_FROM = 100;\n\n/** The number of options up to which a MultiSelect does not show its search field (see `searchFrom`). */\nexport const SEARCH_FROM = 8;\n\nconst ITEM_HEIGHT = 32;\n\n/** Anything else a button takes (data-*, aria-*, title) goes to the trigger. */\nexport interface IMultiSelectProps\n extends Omit<\n ComponentPropsWithoutRef<'button'>,\n 'placeholder' | 'value' | 'defaultValue' | 'id' | 'disabled' | 'className' | 'children' | 'onChange'\n > {\n /** The trigger's text with nothing picked, which means no filter (\"All dealer groups\"). */\n placeholder: string;\n /** The search field's prompt (\"Search dealer groups…\"). */\n searchPlaceholder: string;\n /**\n * How many options a list must have before it shows its search field: it is there for a list too long to scan, and over a short\n * one it is a box in the way. Above this many (default 8, the rows a popup shows at once) the field shows; at or under, it\n * does not. In async mode it always shows, because the field is how the caller is told what to fetch. `0` always shows it.\n *\n * Hidden, the field is still in the popup, out of sight and not typable, because it is what Base UI moves the highlight\n * from: the arrow keys, Home, End and Enter work as ever, and a screen reader still finds it by its label.\n */\n searchFrom?: number;\n /** The options to show now: all of a short fixed list, or in async mode the ones for the typed text. */\n options: readonly TMultiSelectOption[];\n value: readonly string[];\n onValueChange: (value: string[]) => void;\n /**\n * What the trigger says once something is chosen. `selection` (default) names the one chosen or counts several;\n * `label` keeps the label and only counts, so a value the page shows elsewhere (as a removable chip, say) is\n * not repeated here: nothing chosen reads `placeholder`, anything chosen reads `labels.selectedCount(n)`.\n */\n summary?: 'selection' | 'label';\n /** For a Label's htmlFor. */\n id?: string;\n 'aria-label'?: string;\n /**\n * Marks the trigger invalid: the kit's destructive border, and a screen reader says so. For a form that does not use\n * Field; inside one, its invalid state already does this.\n */\n 'aria-invalid'?: boolean | 'true' | 'false';\n /**\n * The id of the text that explains it (the error). Added to what a Field names already, never replacing it.\n */\n 'aria-describedby'?: string;\n /** Shown but not changeable (a read-only form). */\n disabled?: boolean;\n /** Layout only (a width); the look is the kit's. */\n className?: string;\n /**\n * Passing this turns on ASYNC MODE, for lists that grow (people, dealer groups) and must\n * be searched by the API rather than loaded whole and filtered in the browser. The\n * component then never filters: it reports the typed text (after `searchDelay`) and shows\n * whatever `options` the caller supplies for it. It is also called with '' each time the\n * list opens, so the first page is fetched on demand, not at page load.\n */\n onSearchChange?: (text: string) => void;\n /** How long typing must pause before `onSearchChange` is called. Async mode only. */\n searchDelay?: number;\n /**\n * The options behind the chosen values, for the ones not in the current `options`. A\n * search that no longer returns a chosen value must not make it vanish from the trigger\n * or the count, so the caller says what it is called. Without a label a value shows as\n * itself.\n */\n selectedOptions?: readonly TMultiSelectOption[];\n /** The options for the typed text are on their way. The old ones stay until they arrive. */\n loading?: boolean;\n /** The request failed: `true` for the default message, or the message itself. */\n error?: boolean | string;\n onRetry?: () => void;\n /** There is another page after `options`. */\n hasMore?: boolean;\n onLoadMore?: () => void;\n /** The next page is on its way. */\n loadingMore?: boolean;\n labels?: Partial<IMultiSelectLabels>;\n}\n\n/**\n * The options behind the chosen values, in the order they were chosen. A value with no\n * known option is kept and shown as itself rather than dropped: a selection must never\n * change just because a list did.\n */\nexport const resolveChosen = (\n value: readonly string[],\n options: readonly TMultiSelectOption[],\n selectedOptions: readonly TMultiSelectOption[] = [],\n): TMultiSelectOption[] => {\n const known = new Map<string, TMultiSelectOption>();\n for (const option of [...selectedOptions, ...options]) {\n known.set(option.value, option);\n }\n return value.map((entry) => known.get(entry) ?? { value: entry, label: entry });\n};\n\n/** What the trigger says: the placeholder, the one picked, or a count. */\nexport const summarize = (\n chosen: readonly TMultiSelectOption[],\n placeholder: string,\n labels: IMultiSelectLabels,\n summary: 'selection' | 'label' = 'selection',\n): string => {\n if (chosen.length === 0) {\n return placeholder;\n }\n if (summary === 'label') {\n return labels.selectedCount(chosen.length);\n }\n return chosen.length === 1 ? (chosen[0]?.label ?? '') : labels.selectedCount(chosen.length);\n};\n\n/** Every chosen name, for a tooltip on a trigger whose text is cut. With `label` the names are not shown, so it is the text itself. */\nexport const fullSelection = (\n chosen: readonly TMultiSelectOption[],\n placeholder: string,\n labels: IMultiSelectLabels,\n summary: 'selection' | 'label' = 'selection',\n): string =>\n summary === 'selection' && chosen.length > 0 ? chosen.map((option) => option.label).join(', ') : summarize(chosen, placeholder, labels, summary);\n\nconst POPUP = cn(\n 'flex max-h-(--available-height) origin-(--transform-origin) flex-col overflow-hidden duration-100',\n POPUP_FRAME_CLASS,\n POPUP_LIST_WIDTH_CLASS,\n 'motion-reduce:animate-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n);\n\nconst TRIGGER =\n 'flex h-8 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-lg border border-control bg-transparent px-2.5 text-sm text-foreground transition-colors outline-none disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive data-popup-open:outline-solid dark:bg-input/30';\n\nconst Option = ({\n option,\n index,\n style,\n measure,\n highlighted,\n}: {\n option: TMultiSelectOption;\n index: number;\n style?: CSSProperties;\n measure?: (node: Element | null) => void;\n highlighted: boolean;\n}) => {\n const [cut, setCut] = useState(false);\n // A callback ref, so measuring starts when the label mounts and stops when it goes; the key on the label below mounts a fresh one\n // when the text changes, which a resize observer alone would miss at an unchanged width.\n const measureLabel = useCallback((element: HTMLSpanElement | null) => {\n if (!element) {\n return;\n }\n const measureCut = (): void => setCut(element.scrollWidth > element.clientWidth);\n measureCut();\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n const observer = new ResizeObserver(measureCut);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n\n return (\n <Combobox.Item\n value={option}\n index={index}\n ref={measure}\n data-index={index}\n style={style}\n data-slot=\"multi-select-item\"\n className={cn(popupItemClass('base-ui'), 'group')}\n >\n {/* A checkbox, filled when chosen: a set of toggles reads as one. */}\n <span\n data-slot=\"multi-select-item-indicator\"\n aria-hidden=\"true\"\n className=\"flex size-4 shrink-0 items-center justify-center rounded-sm border border-control text-primary-foreground transition-colors group-data-[selected]:border-primary group-data-[selected]:bg-primary\"\n >\n <IconCheck className=\"size-3 opacity-0 group-data-[selected]:opacity-100\" stroke={3} />\n </span>\n {option.leading}\n {/* The option is the highlighted one under the pointer and under the keyboard alike, so one controlled tooltip serves both: the full label while the text is cut. */}\n <Tooltip open={highlighted && cut}>\n <TooltipTrigger\n key={option.label}\n data-slot=\"multi-select-item-label\"\n data-overflowing={cut ? '' : undefined}\n render={<span ref={measureLabel} className=\"min-w-0 flex-1 truncate\" />}\n >\n {option.label}\n </TooltipTrigger>\n <TooltipContent side=\"right\">{option.label}</TooltipContent>\n </Tooltip>\n {/* Muted grey is 4.2:1 on the highlighted row (6% of the foreground), under the 4.5:1 small text needs, so the count turns to the foreground with its row, as a CommandShortcut does. */}\n {option.count !== undefined && (\n <span className=\"text-xs text-muted-foreground tabular-nums group-data-highlighted:text-foreground\">{option.count}</span>\n )}\n </Combobox.Item>\n );\n};\n\n// The options on offer, every one drawn, or past VIRTUALIZE_FROM only those on screen. The\n// list is the listbox itself (the options its direct children), sized to the whole list\n// when virtualized; the ScrollArea wraps it.\nconst Options = ({\n scroller,\n scrollTo,\n busy,\n highlightedValue,\n}: {\n scroller: RefObject<HTMLDivElement | null>;\n scrollTo: RefObject<(index: number) => void>;\n busy: boolean;\n highlightedValue: string | null;\n}) => {\n const items = Combobox.useFilteredItems<TMultiSelectOption>();\n const virtual = items.length > VIRTUALIZE_FROM;\n // The scroller is an ancestor, so its ref is set only after this list's own effects:\n // one more render once mounted gives the virtualizer its element.\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const virtualizer = useVirtualizer({\n count: items.length,\n getScrollElement: () => scroller.current,\n estimateSize: () => ITEM_HEIGHT,\n overscan: 12,\n enabled: virtual && mounted,\n });\n useEffect(() => {\n scrollTo.current = virtual ? (index) => virtualizer.scrollToIndex(index, { align: 'auto' }) : () => undefined;\n }, [scrollTo, virtual, virtualizer]);\n if (!virtual) {\n return (\n <Combobox.List aria-busy={busy || undefined} className=\"px-1 outline-none\">\n {items.map((option, index) => (\n <Option key={option.value} option={option} index={index} highlighted={highlightedValue === option.value} />\n ))}\n </Combobox.List>\n );\n }\n return (\n <Combobox.List\n data-virtualized=\"\"\n aria-busy={busy || undefined}\n className=\"relative mx-1 outline-none\"\n style={{ height: virtualizer.getTotalSize() }}\n >\n {virtualizer.getVirtualItems().map((row) => {\n const option = items[row.index];\n return option === undefined ? null : (\n <Option\n key={option.value}\n option={option}\n index={row.index}\n highlighted={highlightedValue === option.value}\n measure={virtualizer.measureElement}\n style={{ position: 'absolute', top: 0, left: 0, right: 0, transform: `translateY(${row.start}px)` }}\n />\n );\n })}\n </Combobox.List>\n );\n};\n\n/** Rendered inside the portal, so it exists only while the list is open: the focus guards around the list are not aria-hidden. */\nconst ExposedFocusGuards = () => {\n useExposedFocusGuards();\n return null;\n};\n\n/**\n * A choice of several from a list: a trigger shaped like a Select that says what is picked\n * (the placeholder, the one picked, or a count), and a popup with a search field and checkbox\n * options, with the shared popup list style, the ScrollArea's bar and fades, and virtualization\n * past VIRTUALIZE_FROM options. Nothing chosen means no filter.\n *\n * For a short fixed list pass `options` and nothing else: the component filters them as the\n * user types. For a list that grows, pass `onSearchChange` and it becomes a window onto a\n * server: the caller fetches the options for the typed text, and says when they are loading,\n * failed, or have another page.\n */\nexport const MultiSelect = ({\n placeholder,\n searchPlaceholder,\n searchFrom = SEARCH_FROM,\n options,\n value,\n onValueChange,\n id,\n disabled = false,\n className,\n onSearchChange,\n searchDelay = 250,\n selectedOptions,\n loading = false,\n error = false,\n onRetry,\n hasMore = false,\n onLoadMore,\n loadingMore = false,\n labels: labelOverrides,\n summary = 'selection',\n ...rest\n}: IMultiSelectProps) => {\n const labels = useMemo(() => ({ ...DEFAULT_MULTI_SELECT_LABELS, ...labelOverrides }), [labelOverrides]);\n const isAsync = onSearchChange !== undefined;\n const chosen = useMemo(() => resolveChosen(value, options, selectedOptions), [value, options, selectedOptions]);\n // Chosen options the current page does not contain stay on offer at the top, so they can\n // still be unchecked after a search has moved on.\n const items = useMemo(() => {\n const offered = new Set(options.map((option) => option.value));\n return [...chosen.filter((option) => !offered.has(option.value)), ...options];\n }, [chosen, options]);\n const refScroller = useRef<HTMLDivElement | null>(null);\n const refScrollTo = useRef<(index: number) => void>(() => undefined);\n const refTimer = useRef<number | undefined>(undefined);\n const refTriggerText = useRef<HTMLSpanElement | null>(null);\n const refSearch = useRef<HTMLInputElement | null>(null);\n // The popup and the trigger's tooltip are two hover surfaces on one element, so the tooltip stands down while the popup is open.\n const [popupOpen, setPopupOpen] = useState(false);\n // The option under the pointer or the keyboard, whichever moved last, for the tooltip that shows a cut label in full.\n const [highlightedValue, setHighlightedValue] = useState<string | null>(null);\n // The text last reported through onSearchChange, and whether the popup is open. Base UI\n // reports the input as empty when the popup opens and again when it closes; reporting\n // those would fetch the first page twice on every open, and again while closed.\n const refReported = useRef<string | undefined>(undefined);\n const refOpen = useRef(false);\n // Over a short list the search is a box in the way; the list still counts what was offered, so a chosen option the page lacks\n // does not hide the field.\n const searchable = isAsync || items.length > searchFrom;\n const errorMessage = typeof error === 'string' ? error : labels.error;\n const failed = error !== false;\n\n useEffect(() => () => window.clearTimeout(refTimer.current), []);\n\n // Base UI gives the search field a key handler that closes the popup on Escape and keeps the key from the page, but not\n // the trigger: with focus back on the trigger and the popup still open (a click that landed while a Sheet slid in,\n // `focus()`, Shift+Tab) Escape reached the document, where an enclosing Sheet or Dialog closed along with the popup.\n // So the trigger hands Escape to the search field, the path that already works, and the key goes no further.\n const closeFromTrigger = (event: ReactKeyboardEvent<HTMLElement>) => {\n if (event.key !== 'Escape' || !popupOpen || refSearch.current === null) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n refSearch.current.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }));\n };\n\n return (\n <Combobox.Root\n multiple\n disabled={disabled}\n items={items}\n filter={isAsync ? null : undefined}\n value={chosen}\n onValueChange={(next: TMultiSelectOption[]) => onValueChange(next.map((option) => option.value))}\n onInputValueChange={(text) => {\n if (onSearchChange === undefined || !refOpen.current) {\n return;\n }\n window.clearTimeout(refTimer.current);\n if (text === refReported.current) {\n return;\n }\n refTimer.current = window.setTimeout(() => {\n refReported.current = text;\n onSearchChange(text);\n }, searchDelay);\n }}\n onOpenChange={(open) => {\n window.clearTimeout(refTimer.current);\n setPopupOpen(open);\n if (!open) {\n setHighlightedValue(null);\n }\n refOpen.current = open;\n refReported.current = open ? '' : undefined;\n if (open && onSearchChange !== undefined) {\n onSearchChange('');\n }\n }}\n itemToStringLabel={(option: TMultiSelectOption) => option.label}\n isItemEqualToValue={(a: TMultiSelectOption, b: TMultiSelectOption) => a.value === b.value}\n virtualized={items.length > VIRTUALIZE_FROM}\n onItemHighlighted={(item, details) => {\n setHighlightedValue(item?.value ?? null);\n if (details.reason === 'keyboard' && details.index >= 0) {\n refScrollTo.current(details.index);\n }\n }}\n >\n {/* A tooltip only when the text is really cut, which is known when it is about to open. */}\n <Tooltip\n disabled={popupOpen}\n onOpenChange={(open, details) => {\n const element = refTriggerText.current;\n if (open && !(element && element.scrollWidth > element.clientWidth)) {\n details.cancel();\n }\n }}\n >\n <TooltipTrigger\n data-slot=\"multi-select-trigger\"\n render={\n <Combobox.Trigger\n {...rest}\n id={id}\n data-set={chosen.length > 0 ? '' : undefined}\n onKeyDown={closeFromTrigger}\n className={cn(TRIGGER, className)}\n />\n }\n >\n <span ref={refTriggerText} className={cn('min-w-0 flex-1 truncate text-left', chosen.length === 0 && 'text-muted-foreground')}>\n {summarize(chosen, placeholder, labels, summary)}\n </span>\n <IconChevronDown aria-hidden=\"true\" className=\"size-4 shrink-0 text-muted-foreground\" />\n </TooltipTrigger>\n <TooltipContent>{fullSelection(chosen, placeholder, labels, summary)}</TooltipContent>\n </Tooltip>\n <Combobox.Portal>\n <ExposedFocusGuards />\n <Combobox.Positioner sideOffset={4} align=\"start\" className={POPUP_LAYER_CLASS}>\n <Combobox.Popup data-slot=\"multi-select-content\" className={POPUP}>\n <div className={searchable ? 'flex shrink-0 items-center gap-2 border-b border-border px-3' : 'sr-only'}>\n <IconSearch aria-hidden=\"true\" className=\"size-4 shrink-0 text-muted-foreground\" />\n <Combobox.Input\n ref={refSearch}\n readOnly={!searchable}\n placeholder={searchPlaceholder}\n aria-label={searchPlaceholder.replace(/…$/, '')}\n className=\"h-10 w-full min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n {/* The live region stays mounted and only its words change, which is what makes a\n screen reader announce them. */}\n <Combobox.Status data-slot=\"multi-select-status\" className=\"px-3 py-2 text-sm text-muted-foreground empty:p-0\">\n {failed ? (\n <span className=\"flex items-center justify-between gap-2 text-destructive\">\n {errorMessage}\n {onRetry !== undefined && (\n <button type=\"button\" onClick={onRetry} className=\"rounded-md px-2 py-1 font-medium text-foreground hover:bg-foreground/6\">\n {labels.retry}\n </button>\n )}\n </span>\n ) : loading ? (\n labels.loading\n ) : null}\n </Combobox.Status>\n <Combobox.Empty className=\"px-3 py-6 text-center text-sm text-muted-foreground empty:p-0\">\n {loading || failed ? null : labels.noMatches}\n </Combobox.Empty>\n <ScrollArea type=\"always\" fade viewportRef={refScroller} className={POPUP_LIST_HEIGHT_CLASS}>\n <Options scroller={refScroller} scrollTo={refScrollTo} busy={loading} highlightedValue={highlightedValue} />\n </ScrollArea>\n {hasMore && onLoadMore !== undefined && (\n <div className=\"shrink-0 border-t border-border p-1\">\n <button\n type=\"button\"\n disabled={loadingMore}\n onClick={onLoadMore}\n className=\"h-8 w-full rounded-md px-2 text-sm font-medium text-foreground hover:bg-foreground/6 disabled:pointer-events-none disabled:opacity-50\"\n >\n {loadingMore ? labels.loadingMore : labels.loadMore}\n </button>\n </div>\n )}\n {chosen.length > 0 && (\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-t border-border py-1 pr-1 pl-3 text-xs text-muted-foreground\">\n <span className=\"tabular-nums\">{labels.selectedCount(chosen.length)}</span>\n <button\n type=\"button\"\n onClick={() => onValueChange([])}\n className=\"rounded-md px-2 py-1 font-medium text-foreground hover:bg-foreground/6\"\n >\n {labels.clear}\n </button>\n </div>\n )}\n </Combobox.Popup>\n </Combobox.Positioner>\n </Combobox.Portal>\n </Combobox.Root>\n );\n};\n"],"mappings":";;;;;;;;;;;AAqCA,IAAa,8BAAkD;CAC7D,WAAW;CACX,SAAS;CACT,OAAO;CACP,OAAO;CACP,UAAU;CACV,aAAa;CACb,OAAO;CACP,gBAAgB,UAAU,GAAG,MAAM;AACrC;;AAGA,IAAa,kBAAkB;;AAG/B,IAAa,cAAc;AAE3B,IAAM,cAAc;;;;;;AAkFpB,IAAa,iBACX,OACA,SACA,kBAAiD,CAAC,MACzB;CACzB,MAAM,wBAAQ,IAAI,IAAgC;CAClD,KAAK,MAAM,UAAU,CAAC,GAAG,iBAAiB,GAAG,OAAO,GAClD,MAAM,IAAI,OAAO,OAAO,MAAM;CAEhC,OAAO,MAAM,KAAK,UAAU,MAAM,IAAI,KAAK,K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AC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACG,cACA,YAAY,KAAA,KACX,oBAAC,UAAD;QAAQ,MAAK;QAAS,SAAS;QAAS,WAAU;QAC/C,UAAA,OAAO;OACF,CAAA,CAEN;MACJ,CAAA,IAAA,UACF,OAAO,UACL;KACW,CAAA;KACjB,oBAAC,SAAS,OAAV;MAAgB,WAAU;MACvB,UAAA,WAAW,SAAS,OAAO,OAAO;KACrB,CAAA;KAChB,oBAAC,YAAD;MAAY,MAAK;MAAS,MAAA;MAAK,aAAa;MAAa,WAAW;MAClE,UAAA,oBAAC,SAAD;OAAS,UAAU;OAAa,UAAU;OAAa,MAAM;OAA2B;MAAmB,CAAA;KACjG,CAAA;KACX,WAAW,eAAe,KAAA,KACzB,oBAAC,OAAD;MAAK,WAAU;MACb,UAAA,oBAAC,UAAD;OACE,MAAK;OACL,UAAU;OACV,SAAS;OACT,WAAU;OAET,UAAA,cAAc,OAAO,cAAc,OAAO;MACrC,CAAA;KACL,CAAA;KAEN,OAAO,SAAS,KACf,qBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAgB,UAAA,OAAO,cAAc,OAAO,MAAM;MAAQ,CAAA,GAC1E,oBAAC,UAAD;OACE,MAAK;OACL,eAAe,cAAc,CAAC,CAAC;OAC/B,WAAU;OAET,UAAA,OAAO;MACF,CAAA,CACL;;IAEO;;EACG,CAAA,CACN,EAAA,CAAA,CACJ;;AAEnB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MultiSelect: what stays chosen, what the trigger says, and what words it prints.
|
|
3
|
+
*
|
|
4
|
+
* PATH TAKEN: the rules that keep a selection stable while the list under it changes
|
|
5
|
+
* are plain functions, and the closed trigger renders in happy-dom. Opening the popup,
|
|
6
|
+
* typing, the server round trips and virtualization need a real browser, so
|
|
7
|
+
* e2e/multi-select.spec.ts drives those against a fake server.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './presence';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
/** Where a person is, as a chat or a directory shows it. */
|
|
3
|
+
export declare const PRESENCE_STATES: readonly ["available", "busy", "away", "out-of-office", "offline", "unknown"];
|
|
4
|
+
export type TPresenceState = (typeof PRESENCE_STATES)[number];
|
|
5
|
+
/** The words for each state, for assistive technology and for the visible label. A product that is not in English passes its own. */
|
|
6
|
+
export declare const DEFAULT_PRESENCE_LABELS: Readonly<Record<TPresenceState, string>>;
|
|
7
|
+
export interface IPresenceProps extends Omit<ComponentPropsWithoutRef<'span'>, 'children'> {
|
|
8
|
+
state: TPresenceState;
|
|
9
|
+
/** Show the state's word beside the dot. Off, the dot stands alone and the word is there for assistive technology only. */
|
|
10
|
+
showLabel?: boolean;
|
|
11
|
+
/** Other words for the state (a translation, or "In a meeting"); the default words are in `DEFAULT_PRESENCE_LABELS`. */
|
|
12
|
+
label?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A person's presence: a small dot, and optionally its word. Always has the word as text, so it is never a picture alone. */
|
|
15
|
+
export declare const Presence: ({ state, showLabel, label, className, ...props }: IPresenceProps) => import('react').JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region ../ui/src/components/edyn/presence/presence.tsx
|
|
4
|
+
/** Where a person is, as a chat or a directory shows it. */
|
|
5
|
+
var PRESENCE_STATES = [
|
|
6
|
+
"available",
|
|
7
|
+
"busy",
|
|
8
|
+
"away",
|
|
9
|
+
"out-of-office",
|
|
10
|
+
"offline",
|
|
11
|
+
"unknown"
|
|
12
|
+
];
|
|
13
|
+
/** The words for each state, for assistive technology and for the visible label. A product that is not in English passes its own. */
|
|
14
|
+
var DEFAULT_PRESENCE_LABELS = {
|
|
15
|
+
available: "Available",
|
|
16
|
+
busy: "Busy",
|
|
17
|
+
away: "Away",
|
|
18
|
+
"out-of-office": "Out of office",
|
|
19
|
+
offline: "Offline",
|
|
20
|
+
unknown: "Unknown"
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Each state has its own colour and its own shape, because colour alone is not a signal (WCAG 1.4.1): available is a solid dot,
|
|
24
|
+
* busy a solid dot with a bar across it, away a solid dot with a bite out of it, out of office a solid dot with an arrow pointing out
|
|
25
|
+
* (the info colour, the one hue the other states leave free), offline a hollow ring and unknown a dashed ring.
|
|
26
|
+
* The colours are the theme's tokens, so they follow light and dark, and each clears 3:1 against the page, a card and a muted
|
|
27
|
+
* surface in both (e2e/presence.spec.ts measures it).
|
|
28
|
+
*/
|
|
29
|
+
var DOT = {
|
|
30
|
+
available: "bg-success",
|
|
31
|
+
busy: "bg-destructive after:absolute after:inset-x-0.5 after:top-1/2 after:h-0.5 after:-translate-y-1/2 after:bg-background",
|
|
32
|
+
away: "bg-warning after:absolute after:-top-px after:-right-px after:size-1.5 after:rounded-full after:bg-background",
|
|
33
|
+
"out-of-office": "bg-info after:absolute after:top-1/2 after:left-1/2 after:-translate-x-1/3 after:-translate-y-1/2 after:border-y-3 after:border-l-5 after:border-y-transparent after:border-l-background",
|
|
34
|
+
offline: "border-2 border-muted-foreground",
|
|
35
|
+
unknown: "border-2 border-dashed border-muted-foreground"
|
|
36
|
+
};
|
|
37
|
+
/** A person's presence: a small dot, and optionally its word. Always has the word as text, so it is never a picture alone. */
|
|
38
|
+
var Presence = ({ state, showLabel = false, label, className, ...props }) => {
|
|
39
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
40
|
+
"data-slot": "presence",
|
|
41
|
+
"data-state": state,
|
|
42
|
+
className: cn("inline-flex items-center gap-1.5 text-sm", className),
|
|
43
|
+
...props,
|
|
44
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
"data-slot": "presence-dot",
|
|
47
|
+
className: cn("relative size-2.5 shrink-0 rounded-full", DOT[state])
|
|
48
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
49
|
+
"data-slot": "presence-label",
|
|
50
|
+
className: cn(!showLabel && "sr-only"),
|
|
51
|
+
children: label ?? DEFAULT_PRESENCE_LABELS[state]
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { DEFAULT_PRESENCE_LABELS, PRESENCE_STATES, Presence };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=presence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.js","names":[],"sources":["../../../../../../../ui/src/components/edyn/presence/presence.tsx"],"sourcesContent":["import { cn } from '@edyn/ui/lib/utils';\nimport type { ComponentPropsWithoutRef } from 'react';\n\n/** Where a person is, as a chat or a directory shows it. */\nexport const PRESENCE_STATES = ['available', 'busy', 'away', 'out-of-office', 'offline', 'unknown'] as const;\n\nexport type TPresenceState = (typeof PRESENCE_STATES)[number];\n\n/** The words for each state, for assistive technology and for the visible label. A product that is not in English passes its own. */\nexport const DEFAULT_PRESENCE_LABELS: Readonly<Record<TPresenceState, string>> = {\n available: 'Available',\n busy: 'Busy',\n away: 'Away',\n 'out-of-office': 'Out of office',\n offline: 'Offline',\n unknown: 'Unknown',\n};\n\n/**\n * Each state has its own colour and its own shape, because colour alone is not a signal (WCAG 1.4.1): available is a solid dot,\n * busy a solid dot with a bar across it, away a solid dot with a bite out of it, out of office a solid dot with an arrow pointing out\n * (the info colour, the one hue the other states leave free), offline a hollow ring and unknown a dashed ring.\n * The colours are the theme's tokens, so they follow light and dark, and each clears 3:1 against the page, a card and a muted\n * surface in both (e2e/presence.spec.ts measures it).\n */\nconst DOT: Readonly<Record<TPresenceState, string>> = {\n available: 'bg-success',\n busy: 'bg-destructive after:absolute after:inset-x-0.5 after:top-1/2 after:h-0.5 after:-translate-y-1/2 after:bg-background',\n away: 'bg-warning after:absolute after:-top-px after:-right-px after:size-1.5 after:rounded-full after:bg-background',\n 'out-of-office':\n 'bg-info after:absolute after:top-1/2 after:left-1/2 after:-translate-x-1/3 after:-translate-y-1/2 after:border-y-3 after:border-l-5 after:border-y-transparent after:border-l-background',\n offline: 'border-2 border-muted-foreground',\n unknown: 'border-2 border-dashed border-muted-foreground',\n};\n\nexport interface IPresenceProps extends Omit<ComponentPropsWithoutRef<'span'>, 'children'> {\n state: TPresenceState;\n /** Show the state's word beside the dot. Off, the dot stands alone and the word is there for assistive technology only. */\n showLabel?: boolean;\n /** Other words for the state (a translation, or \"In a meeting\"); the default words are in `DEFAULT_PRESENCE_LABELS`. */\n label?: string;\n}\n\n/** A person's presence: a small dot, and optionally its word. Always has the word as text, so it is never a picture alone. */\nexport const Presence = ({ state, showLabel = false, label, className, ...props }: IPresenceProps) => {\n return (\n <span data-slot=\"presence\" data-state={state} className={cn('inline-flex items-center gap-1.5 text-sm', className)} {...props}>\n <span aria-hidden=\"true\" data-slot=\"presence-dot\" className={cn('relative size-2.5 shrink-0 rounded-full', DOT[state])} />\n <span data-slot=\"presence-label\" className={cn(!showLabel && 'sr-only')}>\n {label ?? DEFAULT_PRESENCE_LABELS[state]}\n </span>\n </span>\n );\n};\n"],"mappings":";;;;AAIA,IAAa,kBAAkB;CAAC;CAAa;CAAQ;CAAQ;CAAiB;CAAW;AAAS;;AAKlG,IAAa,0BAAoE;CAC/E,WAAW;CACX,MAAM;CACN,MAAM;CACN,iBAAiB;CACjB,SAAS;CACT,SAAS;AACX;;;;;;;;AASA,IAAM,MAAgD;CACpD,WAAW;CACX,MAAM;CACN,MAAM;CACN,iBACE;CACF,SAAS;CACT,SAAS;AACX;;AAWA,IAAa,YAAY,EAAE,OAAO,YAAY,OAAO,OAAO,WAAW,GAAG,YAA4B;CACpG,OACE,qBAAC,QAAD;EAAM,aAAU;EAAW,cAAY;EAAO,WAAW,GAAG,4CAA4C,SAAS;EAAG,GAAI;EAAxH,UAAA,CACE,oBAAC,QAAD;GAAM,eAAY;GAAO,aAAU;GAAe,WAAW,GAAG,2CAA2C,IAAI,MAAM;EAAI,CAAA,GACzH,oBAAC,QAAD;GAAM,aAAU;GAAiB,WAAW,GAAG,CAAC,aAAa,SAAS;GACnE,UAAA,SAAS,wBAAwB;EAC9B,CAAA,CACF;;AAEV"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presence: a dot and the word for a person's state.
|
|
3
|
+
*
|
|
4
|
+
* PATH TAKEN: what the component renders (the word, what is hidden, what is decorative, how each state differs) does not depend
|
|
5
|
+
* on layout, so happy-dom is enough. That the colours clear 3:1 in both themes and the label contrast needs a real browser:
|
|
6
|
+
* e2e/presence.spec.ts measures it.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progress-line';
|