@helpwave/hightide 0.1.24 → 0.1.26
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 +1 -1
- package/dist/components/branding/HelpwaveBadge.d.mts +4 -5
- package/dist/components/branding/HelpwaveBadge.d.ts +4 -5
- package/dist/components/branding/HelpwaveBadge.js +46 -87
- package/dist/components/branding/HelpwaveBadge.js.map +1 -1
- package/dist/components/branding/HelpwaveBadge.mjs +46 -89
- package/dist/components/branding/HelpwaveBadge.mjs.map +1 -1
- package/dist/components/date/DatePicker.d.mts +1 -1
- package/dist/components/date/DatePicker.d.ts +1 -1
- package/dist/components/date/DatePicker.js +106 -60
- package/dist/components/date/DatePicker.js.map +1 -1
- package/dist/components/date/DatePicker.mjs +107 -61
- package/dist/components/date/DatePicker.mjs.map +1 -1
- package/dist/components/date/DayPicker.d.mts +1 -1
- package/dist/components/date/DayPicker.d.ts +1 -1
- package/dist/components/date/DayPicker.js +3 -3
- package/dist/components/date/DayPicker.js.map +1 -1
- package/dist/components/date/DayPicker.mjs +3 -3
- package/dist/components/date/DayPicker.mjs.map +1 -1
- package/dist/components/date/TimeDisplay.js.map +1 -1
- package/dist/components/date/TimeDisplay.mjs.map +1 -1
- package/dist/components/date/TimePicker.js +2 -2
- package/dist/components/date/TimePicker.js.map +1 -1
- package/dist/components/date/TimePicker.mjs +2 -2
- package/dist/components/date/TimePicker.mjs.map +1 -1
- package/dist/components/date/YearMonthPicker.js +84 -36
- package/dist/components/date/YearMonthPicker.js.map +1 -1
- package/dist/components/date/YearMonthPicker.mjs +85 -37
- package/dist/components/date/YearMonthPicker.mjs.map +1 -1
- package/dist/components/{dialogs → dialog}/ConfirmDialog.d.mts +9 -8
- package/dist/components/{dialogs → dialog}/ConfirmDialog.d.ts +9 -8
- package/dist/components/dialog/ConfirmDialog.js +938 -0
- package/dist/components/dialog/ConfirmDialog.js.map +1 -0
- package/dist/components/dialog/ConfirmDialog.mjs +902 -0
- package/dist/components/dialog/ConfirmDialog.mjs.map +1 -0
- package/dist/components/dialog/Dialog.d.mts +27 -0
- package/dist/components/dialog/Dialog.d.ts +27 -0
- package/dist/components/dialog/Dialog.js +879 -0
- package/dist/components/dialog/Dialog.js.map +1 -0
- package/dist/components/dialog/Dialog.mjs +845 -0
- package/dist/components/dialog/Dialog.mjs.map +1 -0
- package/dist/components/dialog/DiscardChangesDialog.d.mts +24 -0
- package/dist/components/dialog/DiscardChangesDialog.d.ts +24 -0
- package/dist/components/dialog/DiscardChangesDialog.js +966 -0
- package/dist/components/dialog/DiscardChangesDialog.js.map +1 -0
- package/dist/components/dialog/DiscardChangesDialog.mjs +930 -0
- package/dist/components/dialog/DiscardChangesDialog.mjs.map +1 -0
- package/dist/components/dialog/InputDialog.d.mts +22 -0
- package/dist/components/dialog/InputDialog.d.ts +22 -0
- package/dist/components/dialog/InputDialog.js +1139 -0
- package/dist/components/dialog/InputDialog.js.map +1 -0
- package/dist/components/dialog/InputDialog.mjs +1103 -0
- package/dist/components/dialog/InputDialog.mjs.map +1 -0
- package/dist/components/dialog/LanguageDialog.d.mts +25 -0
- package/dist/components/dialog/LanguageDialog.d.ts +25 -0
- package/dist/components/dialog/LanguageDialog.js +1684 -0
- package/dist/components/dialog/LanguageDialog.js.map +1 -0
- package/dist/components/dialog/LanguageDialog.mjs +1658 -0
- package/dist/components/dialog/LanguageDialog.mjs.map +1 -0
- package/dist/components/dialog/ThemeDialog.d.mts +26 -0
- package/dist/components/dialog/ThemeDialog.d.ts +26 -0
- package/dist/components/dialog/ThemeDialog.js +1715 -0
- package/dist/components/dialog/ThemeDialog.js.map +1 -0
- package/dist/components/dialog/ThemeDialog.mjs +1689 -0
- package/dist/components/dialog/ThemeDialog.mjs.map +1 -0
- package/dist/components/dialog/index.d.mts +17 -0
- package/dist/components/dialog/index.d.ts +17 -0
- package/dist/components/dialog/index.js +2062 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/dialog/index.mjs +2031 -0
- package/dist/components/dialog/index.mjs.map +1 -0
- package/dist/components/form/FormElementWrapper.d.mts +29 -0
- package/dist/components/form/FormElementWrapper.d.ts +29 -0
- package/dist/components/form/FormElementWrapper.js +98 -0
- package/dist/components/form/FormElementWrapper.js.map +1 -0
- package/dist/components/form/FormElementWrapper.mjs +64 -0
- package/dist/components/form/FormElementWrapper.mjs.map +1 -0
- package/dist/components/icons-and-geometry/Avatar.js +498 -2886
- package/dist/components/icons-and-geometry/Avatar.js.map +1 -1
- package/dist/components/icons-and-geometry/Avatar.mjs +490 -2878
- package/dist/components/icons-and-geometry/Avatar.mjs.map +1 -1
- package/dist/components/icons-and-geometry/{Helpwave.d.mts → HelpwaveLogo.d.mts} +3 -3
- package/dist/components/icons-and-geometry/{Helpwave.d.ts → HelpwaveLogo.d.ts} +3 -3
- package/dist/components/icons-and-geometry/{Helpwave.js → HelpwaveLogo.js} +21 -22
- package/dist/components/icons-and-geometry/HelpwaveLogo.js.map +1 -0
- package/dist/components/icons-and-geometry/{Helpwave.mjs → HelpwaveLogo.mjs} +17 -18
- package/dist/components/icons-and-geometry/HelpwaveLogo.mjs.map +1 -0
- package/dist/components/icons-and-geometry/Ring.js +1 -1
- package/dist/components/icons-and-geometry/Ring.js.map +1 -1
- package/dist/components/icons-and-geometry/Ring.mjs +1 -1
- package/dist/components/icons-and-geometry/Ring.mjs.map +1 -1
- package/dist/components/icons-and-geometry/Tag.js +8 -20
- package/dist/components/icons-and-geometry/Tag.js.map +1 -1
- package/dist/components/icons-and-geometry/Tag.mjs +8 -20
- package/dist/components/icons-and-geometry/Tag.mjs.map +1 -1
- package/dist/components/layout-and-navigation/BreadCrumb.js +667 -22
- package/dist/components/layout-and-navigation/BreadCrumb.js.map +1 -1
- package/dist/components/layout-and-navigation/BreadCrumb.mjs +667 -22
- package/dist/components/layout-and-navigation/BreadCrumb.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Carousel.js +52 -53
- package/dist/components/layout-and-navigation/Carousel.js.map +1 -1
- package/dist/components/layout-and-navigation/Carousel.mjs +52 -53
- package/dist/components/layout-and-navigation/Carousel.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Chip.d.mts +8 -5
- package/dist/components/layout-and-navigation/Chip.d.ts +8 -5
- package/dist/components/layout-and-navigation/Chip.js +17 -4
- package/dist/components/layout-and-navigation/Chip.js.map +1 -1
- package/dist/components/layout-and-navigation/Chip.mjs +17 -4
- package/dist/components/layout-and-navigation/Chip.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Expandable.d.mts +13 -10
- package/dist/components/layout-and-navigation/Expandable.d.ts +13 -10
- package/dist/components/layout-and-navigation/Expandable.js +18 -5
- package/dist/components/layout-and-navigation/Expandable.js.map +1 -1
- package/dist/components/layout-and-navigation/Expandable.mjs +19 -6
- package/dist/components/layout-and-navigation/Expandable.mjs.map +1 -1
- package/dist/components/layout-and-navigation/FAQSection.js +21 -8
- package/dist/components/layout-and-navigation/FAQSection.js.map +1 -1
- package/dist/components/layout-and-navigation/FAQSection.mjs +22 -9
- package/dist/components/layout-and-navigation/FAQSection.mjs.map +1 -1
- package/dist/components/layout-and-navigation/FloatingContainer.d.mts +38 -0
- package/dist/components/layout-and-navigation/FloatingContainer.d.ts +38 -0
- package/dist/components/layout-and-navigation/FloatingContainer.js +219 -0
- package/dist/components/layout-and-navigation/FloatingContainer.js.map +1 -0
- package/dist/components/layout-and-navigation/FloatingContainer.mjs +195 -0
- package/dist/components/layout-and-navigation/FloatingContainer.mjs.map +1 -0
- package/dist/components/layout-and-navigation/ListBox.d.mts +44 -0
- package/dist/components/layout-and-navigation/ListBox.d.ts +44 -0
- package/dist/components/layout-and-navigation/ListBox.js +329 -0
- package/dist/components/layout-and-navigation/ListBox.js.map +1 -0
- package/dist/components/layout-and-navigation/ListBox.mjs +290 -0
- package/dist/components/layout-and-navigation/ListBox.mjs.map +1 -0
- package/dist/components/layout-and-navigation/Pagination.js +142 -230
- package/dist/components/layout-and-navigation/Pagination.js.map +1 -1
- package/dist/components/layout-and-navigation/Pagination.mjs +137 -225
- package/dist/components/layout-and-navigation/Pagination.mjs.map +1 -1
- package/dist/components/layout-and-navigation/ScrollArea.d.mts +15 -0
- package/dist/components/layout-and-navigation/ScrollArea.d.ts +15 -0
- package/dist/components/layout-and-navigation/ScrollArea.js +1252 -0
- package/dist/components/layout-and-navigation/ScrollArea.js.map +1 -0
- package/dist/components/layout-and-navigation/ScrollArea.mjs +1216 -0
- package/dist/components/layout-and-navigation/ScrollArea.mjs.map +1 -0
- package/dist/components/layout-and-navigation/StepperBar.js +67 -30
- package/dist/components/layout-and-navigation/StepperBar.js.map +1 -1
- package/dist/components/layout-and-navigation/StepperBar.mjs +67 -30
- package/dist/components/layout-and-navigation/StepperBar.mjs.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.js +3 -1
- package/dist/components/layout-and-navigation/TextImage.js.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.mjs +3 -1
- package/dist/components/layout-and-navigation/TextImage.mjs.map +1 -1
- package/dist/components/loading-states/ErrorComponent.js.map +1 -1
- package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.d.mts +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.d.ts +1 -1
- package/dist/components/loading-states/LoadingAnimation.js +18 -17
- package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
- package/dist/components/loading-states/LoadingAnimation.mjs +18 -17
- package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
- package/dist/components/loading-states/LoadingButton.js +81 -47
- package/dist/components/loading-states/LoadingButton.js.map +1 -1
- package/dist/components/loading-states/LoadingButton.mjs +81 -47
- package/dist/components/loading-states/LoadingButton.mjs.map +1 -1
- package/dist/components/properties/CheckboxProperty.js +929 -153
- package/dist/components/properties/CheckboxProperty.js.map +1 -1
- package/dist/components/properties/CheckboxProperty.mjs +936 -160
- package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
- package/dist/components/properties/DateProperty.js +191 -241
- package/dist/components/properties/DateProperty.js.map +1 -1
- package/dist/components/properties/DateProperty.mjs +184 -234
- package/dist/components/properties/DateProperty.mjs.map +1 -1
- package/dist/components/properties/MultiSelectProperty.d.mts +5 -10
- package/dist/components/properties/MultiSelectProperty.d.ts +5 -10
- package/dist/components/properties/MultiSelectProperty.js +1193 -1189
- package/dist/components/properties/MultiSelectProperty.js.map +1 -1
- package/dist/components/properties/MultiSelectProperty.mjs +1207 -1193
- package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
- package/dist/components/properties/NumberProperty.js +193 -244
- package/dist/components/properties/NumberProperty.js.map +1 -1
- package/dist/components/properties/NumberProperty.mjs +186 -237
- package/dist/components/properties/NumberProperty.mjs.map +1 -1
- package/dist/components/properties/PropertyBase.js +91 -56
- package/dist/components/properties/PropertyBase.js.map +1 -1
- package/dist/components/properties/PropertyBase.mjs +91 -56
- package/dist/components/properties/PropertyBase.mjs.map +1 -1
- package/dist/components/properties/SelectProperty.d.mts +5 -8
- package/dist/components/properties/SelectProperty.d.ts +5 -8
- package/dist/components/properties/SelectProperty.js +1102 -897
- package/dist/components/properties/SelectProperty.js.map +1 -1
- package/dist/components/properties/SelectProperty.mjs +1107 -892
- package/dist/components/properties/SelectProperty.mjs.map +1 -1
- package/dist/components/properties/TextProperty.js +139 -147
- package/dist/components/properties/TextProperty.js.map +1 -1
- package/dist/components/properties/TextProperty.mjs +142 -150
- package/dist/components/properties/TextProperty.mjs.map +1 -1
- package/dist/components/table/Table.js +1639 -991
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/table/Table.mjs +1645 -997
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/TableFilterButton.js +156 -244
- package/dist/components/table/TableFilterButton.js.map +1 -1
- package/dist/components/table/TableFilterButton.mjs +145 -233
- package/dist/components/table/TableFilterButton.mjs.map +1 -1
- package/dist/components/table/TableSortButton.js +44 -46
- package/dist/components/table/TableSortButton.js.map +1 -1
- package/dist/components/table/TableSortButton.mjs +44 -46
- package/dist/components/table/TableSortButton.mjs.map +1 -1
- package/dist/components/user-action/Button.d.mts +17 -13
- package/dist/components/user-action/Button.d.ts +17 -13
- package/dist/components/user-action/Button.js +80 -87
- package/dist/components/user-action/Button.js.map +1 -1
- package/dist/components/user-action/Button.mjs +80 -87
- package/dist/components/user-action/Button.mjs.map +1 -1
- package/dist/components/user-action/Checkbox.d.mts +9 -25
- package/dist/components/user-action/Checkbox.d.ts +9 -25
- package/dist/components/user-action/Checkbox.js +794 -78
- package/dist/components/user-action/Checkbox.js.map +1 -1
- package/dist/components/user-action/Checkbox.mjs +795 -79
- package/dist/components/user-action/Checkbox.mjs.map +1 -1
- package/dist/components/user-action/CopyToClipboardWrapper.js +3 -1
- package/dist/components/user-action/CopyToClipboardWrapper.js.map +1 -1
- package/dist/components/user-action/CopyToClipboardWrapper.mjs +3 -1
- package/dist/components/user-action/CopyToClipboardWrapper.mjs.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.d.mts +1 -1
- package/dist/components/user-action/DateAndTimePicker.d.ts +1 -1
- package/dist/components/user-action/DateAndTimePicker.js +108 -60
- package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.mjs +109 -61
- package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
- package/dist/components/user-action/Label.d.mts +6 -8
- package/dist/components/user-action/Label.d.ts +6 -8
- package/dist/components/user-action/Label.js +4 -6
- package/dist/components/user-action/Label.js.map +1 -1
- package/dist/components/user-action/Label.mjs +4 -6
- package/dist/components/user-action/Label.mjs.map +1 -1
- package/dist/components/user-action/Menu.d.mts +2 -2
- package/dist/components/user-action/Menu.d.ts +2 -2
- package/dist/components/user-action/Menu.js +1 -1
- package/dist/components/user-action/Menu.js.map +1 -1
- package/dist/components/user-action/Menu.mjs +1 -1
- package/dist/components/user-action/Menu.mjs.map +1 -1
- package/dist/components/user-action/ScrollPicker.js +8 -6
- package/dist/components/user-action/ScrollPicker.js.map +1 -1
- package/dist/components/user-action/ScrollPicker.mjs +8 -6
- package/dist/components/user-action/ScrollPicker.mjs.map +1 -1
- package/dist/components/user-action/SearchBar.d.mts +1 -2
- package/dist/components/user-action/SearchBar.d.ts +1 -2
- package/dist/components/user-action/SearchBar.js +131 -219
- package/dist/components/user-action/SearchBar.js.map +1 -1
- package/dist/components/user-action/SearchBar.mjs +124 -212
- package/dist/components/user-action/SearchBar.mjs.map +1 -1
- package/dist/components/user-action/Textarea.d.mts +22 -11
- package/dist/components/user-action/Textarea.d.ts +22 -11
- package/dist/components/user-action/Textarea.js +101 -92
- package/dist/components/user-action/Textarea.js.map +1 -1
- package/dist/components/user-action/Textarea.mjs +100 -92
- package/dist/components/user-action/Textarea.mjs.map +1 -1
- package/dist/components/user-action/input/Input.d.mts +37 -0
- package/dist/components/user-action/input/Input.d.ts +37 -0
- package/dist/components/user-action/input/Input.js +244 -0
- package/dist/components/user-action/input/Input.js.map +1 -0
- package/dist/components/user-action/input/Input.mjs +209 -0
- package/dist/components/user-action/input/Input.mjs.map +1 -0
- package/dist/components/user-action/input/InsideLabelInput.d.mts +20 -0
- package/dist/components/user-action/input/InsideLabelInput.d.ts +20 -0
- package/dist/components/user-action/input/InsideLabelInput.js +295 -0
- package/dist/components/user-action/input/InsideLabelInput.js.map +1 -0
- package/dist/components/user-action/input/InsideLabelInput.mjs +260 -0
- package/dist/components/user-action/input/InsideLabelInput.mjs.map +1 -0
- package/dist/components/user-action/input/ToggleableInput.d.mts +22 -0
- package/dist/components/user-action/input/ToggleableInput.d.ts +22 -0
- package/dist/components/user-action/{Input.js → input/ToggleableInput.js} +136 -171
- package/dist/components/user-action/input/ToggleableInput.js.map +1 -0
- package/dist/components/user-action/input/ToggleableInput.mjs +264 -0
- package/dist/components/user-action/input/ToggleableInput.mjs.map +1 -0
- package/dist/components/user-action/select/Select.d.mts +98 -0
- package/dist/components/user-action/select/Select.d.ts +98 -0
- package/dist/components/user-action/select/Select.js +1354 -0
- package/dist/components/user-action/select/Select.js.map +1 -0
- package/dist/components/user-action/select/Select.mjs +1320 -0
- package/dist/components/user-action/select/Select.mjs.map +1 -0
- package/dist/components/utils/FocusTrap.d.mts +28 -0
- package/dist/components/utils/FocusTrap.d.ts +28 -0
- package/dist/components/utils/FocusTrap.js +252 -0
- package/dist/components/utils/FocusTrap.js.map +1 -0
- package/dist/components/utils/FocusTrap.mjs +229 -0
- package/dist/components/utils/FocusTrap.mjs.map +1 -0
- package/dist/components/utils/Transition.d.mts +26 -0
- package/dist/components/utils/Transition.d.ts +26 -0
- package/dist/components/utils/Transition.js +74 -0
- package/dist/components/utils/Transition.js.map +1 -0
- package/dist/components/utils/Transition.mjs +50 -0
- package/dist/components/utils/Transition.mjs.map +1 -0
- package/dist/hooks/focus/useFocusGuards.d.mts +3 -0
- package/dist/hooks/focus/useFocusGuards.d.ts +3 -0
- package/dist/hooks/focus/useFocusGuards.js +74 -0
- package/dist/hooks/focus/useFocusGuards.js.map +1 -0
- package/dist/hooks/focus/useFocusGuards.mjs +50 -0
- package/dist/hooks/focus/useFocusGuards.mjs.map +1 -0
- package/dist/hooks/{useFocusManagement.js → focus/useFocusManagement.js} +1 -1
- package/dist/hooks/focus/useFocusManagement.js.map +1 -0
- package/dist/hooks/{useFocusManagement.mjs → focus/useFocusManagement.mjs} +1 -1
- package/dist/hooks/focus/useFocusManagement.mjs.map +1 -0
- package/dist/hooks/{useFocusOnceVisible.js → focus/useFocusOnceVisible.js} +1 -1
- package/dist/hooks/focus/useFocusOnceVisible.js.map +1 -0
- package/dist/hooks/{useFocusOnceVisible.mjs → focus/useFocusOnceVisible.mjs} +1 -1
- package/dist/hooks/focus/useFocusOnceVisible.mjs.map +1 -0
- package/dist/hooks/focus/useFocusTrap.d.mts +16 -0
- package/dist/hooks/focus/useFocusTrap.d.ts +16 -0
- package/dist/hooks/focus/useFocusTrap.js +233 -0
- package/dist/hooks/focus/useFocusTrap.js.map +1 -0
- package/dist/hooks/focus/useFocusTrap.mjs +210 -0
- package/dist/hooks/focus/useFocusTrap.mjs.map +1 -0
- package/dist/hooks/focus/useIsMounted.d.mts +3 -0
- package/dist/hooks/focus/useIsMounted.d.ts +3 -0
- package/dist/hooks/focus/useIsMounted.js +43 -0
- package/dist/hooks/focus/useIsMounted.js.map +1 -0
- package/dist/hooks/focus/useIsMounted.mjs +20 -0
- package/dist/hooks/focus/useIsMounted.mjs.map +1 -0
- package/dist/hooks/useFloatingElement.d.mts +22 -0
- package/dist/hooks/useFloatingElement.d.ts +22 -0
- package/dist/hooks/useFloatingElement.js +162 -0
- package/dist/hooks/useFloatingElement.js.map +1 -0
- package/dist/hooks/useFloatingElement.mjs +139 -0
- package/dist/hooks/useFloatingElement.mjs.map +1 -0
- package/dist/hooks/useLocalStorage.js +2 -2
- package/dist/hooks/useLocalStorage.js.map +1 -1
- package/dist/hooks/useLocalStorage.mjs +2 -2
- package/dist/hooks/useLocalStorage.mjs.map +1 -1
- package/dist/hooks/useLogOnce.d.mts +3 -4
- package/dist/hooks/useLogOnce.d.ts +3 -4
- package/dist/hooks/useLogOnce.js +5 -5
- package/dist/hooks/useLogOnce.js.map +1 -1
- package/dist/hooks/useLogOnce.mjs +5 -5
- package/dist/hooks/useLogOnce.mjs.map +1 -1
- package/dist/hooks/useRerender.d.mts +2 -2
- package/dist/hooks/useRerender.d.ts +2 -2
- package/dist/hooks/useSearch.d.mts +2 -2
- package/dist/hooks/useSearch.d.ts +2 -2
- package/dist/hooks/useSearch.js +1 -1
- package/dist/hooks/useSearch.js.map +1 -1
- package/dist/hooks/useSearch.mjs +1 -1
- package/dist/hooks/useSearch.mjs.map +1 -1
- package/dist/localization/LanguageProvider.d.mts +2 -2
- package/dist/localization/LanguageProvider.d.ts +2 -2
- package/dist/localization/LanguageProvider.js +2 -2
- package/dist/localization/LanguageProvider.js.map +1 -1
- package/dist/localization/LanguageProvider.mjs +2 -2
- package/dist/localization/LanguageProvider.mjs.map +1 -1
- package/dist/localization/defaults/form.d.mts +1 -0
- package/dist/localization/defaults/form.d.ts +1 -0
- package/dist/localization/defaults/form.js +2 -0
- package/dist/localization/defaults/form.js.map +1 -1
- package/dist/localization/defaults/form.mjs +2 -0
- package/dist/localization/defaults/form.mjs.map +1 -1
- package/dist/localization/useTranslation.js.map +1 -1
- package/dist/localization/useTranslation.mjs.map +1 -1
- package/dist/storybook/helper.d.mts +17 -0
- package/dist/storybook/helper.d.ts +17 -0
- package/dist/storybook/helper.js +61 -0
- package/dist/storybook/helper.js.map +1 -0
- package/dist/storybook/helper.mjs +37 -0
- package/dist/storybook/helper.mjs.map +1 -0
- package/dist/{css → style}/globals.css +994 -456
- package/dist/{css → style}/uncompiled/globals.css +75 -13
- package/dist/{css → style}/uncompiled/theme/colors-component.css +18 -4
- package/dist/{css → style}/uncompiled/theme/colors-semantic.css +2 -9
- package/dist/style/uncompiled/typography.css +171 -0
- package/dist/{css → style}/uncompiled/utitlity/animation.css +54 -42
- package/dist/{css → style}/uncompiled/utitlity/index.css +2 -1
- package/dist/{css → style}/uncompiled/utitlity/shadow.css +5 -1
- package/dist/style/uncompiled/utitlity/sizing.css +29 -0
- package/dist/theming/useTheme.d.mts +2 -2
- package/dist/theming/useTheme.d.ts +2 -2
- package/dist/theming/useTheme.js +4 -4
- package/dist/theming/useTheme.js.map +1 -1
- package/dist/theming/useTheme.mjs +4 -4
- package/dist/theming/useTheme.mjs.map +1 -1
- package/dist/{util → utils}/array.d.mts +1 -0
- package/dist/{util → utils}/array.d.ts +1 -0
- package/dist/{util → utils}/array.js +15 -2
- package/dist/utils/array.js.map +1 -0
- package/dist/{util → utils}/array.mjs +15 -2
- package/dist/utils/array.mjs.map +1 -0
- package/dist/utils/bagFunctions.d.mts +15 -0
- package/dist/utils/bagFunctions.d.ts +15 -0
- package/dist/{util/PropsWithFunctionChildren.js → utils/bagFunctions.js} +5 -5
- package/dist/utils/bagFunctions.js.map +1 -0
- package/dist/{util/PropsWithFunctionChildren.mjs → utils/bagFunctions.mjs} +2 -2
- package/dist/utils/bagFunctions.mjs.map +1 -0
- package/dist/{util → utils}/builder.js +1 -1
- package/dist/utils/builder.js.map +1 -0
- package/dist/{util → utils}/builder.mjs +1 -1
- package/dist/utils/builder.mjs.map +1 -0
- package/dist/{util → utils}/date.js +3 -3
- package/dist/utils/date.js.map +1 -0
- package/dist/{util → utils}/date.mjs +2 -2
- package/dist/utils/date.mjs.map +1 -0
- package/dist/{util → utils}/easeFunctions.js +5 -4
- package/dist/utils/easeFunctions.js.map +1 -0
- package/dist/{util → utils}/easeFunctions.mjs +4 -3
- package/dist/utils/easeFunctions.mjs.map +1 -0
- package/dist/{util → utils}/emailValidation.js +1 -1
- package/dist/utils/emailValidation.js.map +1 -0
- package/dist/{util → utils}/emailValidation.mjs +1 -1
- package/dist/utils/emailValidation.mjs.map +1 -0
- package/dist/{util → utils}/loopingArray.js +1 -1
- package/dist/utils/loopingArray.js.map +1 -0
- package/dist/{util → utils}/loopingArray.mjs +1 -1
- package/dist/utils/loopingArray.mjs.map +1 -0
- package/dist/utils/match.d.mts +3 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +32 -0
- package/dist/utils/match.js.map +1 -0
- package/dist/utils/match.mjs +8 -0
- package/dist/utils/match.mjs.map +1 -0
- package/dist/utils/math.d.mts +3 -0
- package/dist/utils/math.d.ts +3 -0
- package/dist/{util → utils}/math.js +3 -2
- package/dist/utils/math.js.map +1 -0
- package/dist/utils/math.mjs +9 -0
- package/dist/utils/math.mjs.map +1 -0
- package/dist/{util → utils}/noop.js +1 -1
- package/dist/utils/noop.js.map +1 -0
- package/dist/utils/noop.mjs +6 -0
- package/dist/utils/noop.mjs.map +1 -0
- package/dist/{util → utils}/resolveSetState.js +1 -1
- package/dist/utils/resolveSetState.js.map +1 -0
- package/dist/{util → utils}/resolveSetState.mjs +1 -1
- package/dist/utils/resolveSetState.mjs.map +1 -0
- package/dist/{util → utils}/simpleSearch.js +1 -1
- package/dist/utils/simpleSearch.js.map +1 -0
- package/dist/{util → utils}/simpleSearch.mjs +1 -1
- package/dist/utils/simpleSearch.mjs.map +1 -0
- package/dist/{util → utils}/storage.js +1 -1
- package/dist/utils/storage.js.map +1 -0
- package/dist/{util → utils}/storage.mjs +1 -1
- package/dist/utils/storage.mjs.map +1 -0
- package/dist/{util → utils}/writeToClipboard.js +2 -1
- package/dist/utils/writeToClipboard.js.map +1 -0
- package/dist/{util → utils}/writeToClipboard.mjs +3 -1
- package/dist/utils/writeToClipboard.mjs.map +1 -0
- package/package.json +8 -8
- package/dist/components/dialogs/ConfirmDialog.js +0 -677
- package/dist/components/dialogs/ConfirmDialog.js.map +0 -1
- package/dist/components/dialogs/ConfirmDialog.mjs +0 -641
- package/dist/components/dialogs/ConfirmDialog.mjs.map +0 -1
- package/dist/components/icons-and-geometry/Helpwave.js.map +0 -1
- package/dist/components/icons-and-geometry/Helpwave.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Overlay.d.mts +0 -67
- package/dist/components/layout-and-navigation/Overlay.d.ts +0 -67
- package/dist/components/layout-and-navigation/Overlay.js +0 -705
- package/dist/components/layout-and-navigation/Overlay.js.map +0 -1
- package/dist/components/layout-and-navigation/Overlay.mjs +0 -668
- package/dist/components/layout-and-navigation/Overlay.mjs.map +0 -1
- package/dist/components/layout-and-navigation/SearchableList.d.mts +0 -24
- package/dist/components/layout-and-navigation/SearchableList.d.ts +0 -24
- package/dist/components/layout-and-navigation/SearchableList.js +0 -761
- package/dist/components/layout-and-navigation/SearchableList.js.map +0 -1
- package/dist/components/layout-and-navigation/SearchableList.mjs +0 -727
- package/dist/components/layout-and-navigation/SearchableList.mjs.map +0 -1
- package/dist/components/layout-and-navigation/Tile.d.mts +0 -27
- package/dist/components/layout-and-navigation/Tile.d.ts +0 -27
- package/dist/components/layout-and-navigation/Tile.js +0 -96
- package/dist/components/layout-and-navigation/Tile.js.map +0 -1
- package/dist/components/layout-and-navigation/Tile.mjs +0 -61
- package/dist/components/layout-and-navigation/Tile.mjs.map +0 -1
- package/dist/components/modals/ConfirmModal.d.mts +0 -33
- package/dist/components/modals/ConfirmModal.d.ts +0 -33
- package/dist/components/modals/ConfirmModal.js +0 -690
- package/dist/components/modals/ConfirmModal.js.map +0 -1
- package/dist/components/modals/ConfirmModal.mjs +0 -654
- package/dist/components/modals/ConfirmModal.mjs.map +0 -1
- package/dist/components/modals/DiscardChangesModal.d.mts +0 -20
- package/dist/components/modals/DiscardChangesModal.d.ts +0 -20
- package/dist/components/modals/DiscardChangesModal.js +0 -720
- package/dist/components/modals/DiscardChangesModal.js.map +0 -1
- package/dist/components/modals/DiscardChangesModal.mjs +0 -684
- package/dist/components/modals/DiscardChangesModal.mjs.map +0 -1
- package/dist/components/modals/InputModal.d.mts +0 -21
- package/dist/components/modals/InputModal.d.ts +0 -21
- package/dist/components/modals/InputModal.js +0 -979
- package/dist/components/modals/InputModal.js.map +0 -1
- package/dist/components/modals/InputModal.mjs +0 -943
- package/dist/components/modals/InputModal.mjs.map +0 -1
- package/dist/components/modals/LanguageModal.d.mts +0 -21
- package/dist/components/modals/LanguageModal.d.ts +0 -21
- package/dist/components/modals/LanguageModal.js +0 -1474
- package/dist/components/modals/LanguageModal.js.map +0 -1
- package/dist/components/modals/LanguageModal.mjs +0 -1438
- package/dist/components/modals/LanguageModal.mjs.map +0 -1
- package/dist/components/modals/ThemeModal.d.mts +0 -21
- package/dist/components/modals/ThemeModal.d.ts +0 -21
- package/dist/components/modals/ThemeModal.js +0 -1503
- package/dist/components/modals/ThemeModal.js.map +0 -1
- package/dist/components/modals/ThemeModal.mjs +0 -1467
- package/dist/components/modals/ThemeModal.mjs.map +0 -1
- package/dist/components/user-action/Input.d.mts +0 -77
- package/dist/components/user-action/Input.d.ts +0 -77
- package/dist/components/user-action/Input.js.map +0 -1
- package/dist/components/user-action/Input.mjs +0 -298
- package/dist/components/user-action/Input.mjs.map +0 -1
- package/dist/components/user-action/MultiSelect.d.mts +0 -42
- package/dist/components/user-action/MultiSelect.d.ts +0 -42
- package/dist/components/user-action/MultiSelect.js +0 -1445
- package/dist/components/user-action/MultiSelect.js.map +0 -1
- package/dist/components/user-action/MultiSelect.mjs +0 -1410
- package/dist/components/user-action/MultiSelect.mjs.map +0 -1
- package/dist/components/user-action/Select.d.mts +0 -41
- package/dist/components/user-action/Select.d.ts +0 -41
- package/dist/components/user-action/Select.js +0 -1242
- package/dist/components/user-action/Select.js.map +0 -1
- package/dist/components/user-action/Select.mjs +0 -1207
- package/dist/components/user-action/Select.mjs.map +0 -1
- package/dist/components/user-action/ToggleableInput.d.mts +0 -37
- package/dist/components/user-action/ToggleableInput.d.ts +0 -37
- package/dist/components/user-action/ToggleableInput.js +0 -192
- package/dist/components/user-action/ToggleableInput.js.map +0 -1
- package/dist/components/user-action/ToggleableInput.mjs +0 -157
- package/dist/components/user-action/ToggleableInput.mjs.map +0 -1
- package/dist/css/uncompiled/textstyles.css +0 -69
- package/dist/hooks/useFocusManagement.js.map +0 -1
- package/dist/hooks/useFocusManagement.mjs.map +0 -1
- package/dist/hooks/useFocusOnceVisible.js.map +0 -1
- package/dist/hooks/useFocusOnceVisible.mjs.map +0 -1
- package/dist/index.d.mts +0 -103
- package/dist/index.d.ts +0 -103
- package/dist/index.js +0 -12595
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -12432
- package/dist/index.mjs.map +0 -1
- package/dist/util/PropsWithFunctionChildren.d.mts +0 -14
- package/dist/util/PropsWithFunctionChildren.d.ts +0 -14
- package/dist/util/PropsWithFunctionChildren.js.map +0 -1
- package/dist/util/PropsWithFunctionChildren.mjs.map +0 -1
- package/dist/util/array.js.map +0 -1
- package/dist/util/array.mjs.map +0 -1
- package/dist/util/builder.js.map +0 -1
- package/dist/util/builder.mjs.map +0 -1
- package/dist/util/date.js.map +0 -1
- package/dist/util/date.mjs.map +0 -1
- package/dist/util/easeFunctions.js.map +0 -1
- package/dist/util/easeFunctions.mjs.map +0 -1
- package/dist/util/emailValidation.js.map +0 -1
- package/dist/util/emailValidation.mjs.map +0 -1
- package/dist/util/loopingArray.js.map +0 -1
- package/dist/util/loopingArray.mjs.map +0 -1
- package/dist/util/math.d.mts +0 -3
- package/dist/util/math.d.ts +0 -3
- package/dist/util/math.js.map +0 -1
- package/dist/util/math.mjs +0 -8
- package/dist/util/math.mjs.map +0 -1
- package/dist/util/news.d.mts +0 -101
- package/dist/util/news.d.ts +0 -101
- package/dist/util/news.js +0 -76
- package/dist/util/news.js.map +0 -1
- package/dist/util/news.mjs +0 -49
- package/dist/util/news.mjs.map +0 -1
- package/dist/util/noop.js.map +0 -1
- package/dist/util/noop.mjs +0 -6
- package/dist/util/noop.mjs.map +0 -1
- package/dist/util/resolveSetState.js.map +0 -1
- package/dist/util/resolveSetState.mjs.map +0 -1
- package/dist/util/simpleSearch.js.map +0 -1
- package/dist/util/simpleSearch.mjs.map +0 -1
- package/dist/util/storage.js.map +0 -1
- package/dist/util/storage.mjs.map +0 -1
- package/dist/util/types.d.mts +0 -3
- package/dist/util/types.d.ts +0 -3
- package/dist/util/types.js +0 -18
- package/dist/util/types.js.map +0 -1
- package/dist/util/types.mjs +0 -1
- package/dist/util/types.mjs.map +0 -1
- package/dist/util/writeToClipboard.js.map +0 -1
- package/dist/util/writeToClipboard.mjs.map +0 -1
- /package/dist/hooks/{useFocusManagement.d.mts → focus/useFocusManagement.d.mts} +0 -0
- /package/dist/hooks/{useFocusManagement.d.ts → focus/useFocusManagement.d.ts} +0 -0
- /package/dist/hooks/{useFocusOnceVisible.d.mts → focus/useFocusOnceVisible.d.mts} +0 -0
- /package/dist/hooks/{useFocusOnceVisible.d.ts → focus/useFocusOnceVisible.d.ts} +0 -0
- /package/dist/{css → style}/uncompiled/theme/colors-basic.css +0 -0
- /package/dist/{css → style}/uncompiled/theme/index.css +0 -0
- /package/dist/{css → style}/uncompiled/theme/variants.css +0 -0
- /package/dist/{css → style}/uncompiled/utitlity/borderradius.css +0 -0
- /package/dist/{css → style}/uncompiled/utitlity/general.css +0 -0
- /package/dist/{util → utils}/builder.d.mts +0 -0
- /package/dist/{util → utils}/builder.d.ts +0 -0
- /package/dist/{util → utils}/date.d.mts +0 -0
- /package/dist/{util → utils}/date.d.ts +0 -0
- /package/dist/{util → utils}/easeFunctions.d.mts +0 -0
- /package/dist/{util → utils}/easeFunctions.d.ts +0 -0
- /package/dist/{util → utils}/emailValidation.d.mts +0 -0
- /package/dist/{util → utils}/emailValidation.d.ts +0 -0
- /package/dist/{util → utils}/loopingArray.d.mts +0 -0
- /package/dist/{util → utils}/loopingArray.d.ts +0 -0
- /package/dist/{util → utils}/noop.d.mts +0 -0
- /package/dist/{util → utils}/noop.d.ts +0 -0
- /package/dist/{util → utils}/resolveSetState.d.mts +0 -0
- /package/dist/{util → utils}/resolveSetState.d.ts +0 -0
- /package/dist/{util → utils}/simpleSearch.d.mts +0 -0
- /package/dist/{util → utils}/simpleSearch.d.ts +0 -0
- /package/dist/{util → utils}/storage.d.mts +0 -0
- /package/dist/{util → utils}/storage.d.ts +0 -0
- /package/dist/{util → utils}/writeToClipboard.d.mts +0 -0
- /package/dist/{util → utils}/writeToClipboard.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/layout-and-navigation/FloatingContainer.tsx","../../../src/hooks/useFloatingElement.ts","../../../src/utils/math.ts","../../../src/hooks/focus/useIsMounted.ts"],"sourcesContent":["import type { HTMLAttributes, MutableRefObject, ReactNode } from 'react'\nimport { forwardRef, useImperativeHandle, useRef } from 'react'\nimport { createPortal } from 'react-dom'\nimport { clsx } from 'clsx'\nimport type { UseFloatingElementOptions } from '@/src/hooks/useFloatingElement'\nimport { useFloatingElement } from '@/src/hooks/useFloatingElement'\n\nexport type FloatingContainerProps = HTMLAttributes<HTMLDivElement> & UseFloatingElementOptions & {\n anchor?: MutableRefObject<HTMLElement>,\n /**\n * Polls the position of the anchor every 100ms\n *\n * Use sparingly\n */\n backgroundOverlay?: ReactNode,\n}\n\n/**\n * A floating container that aligns to its anchor\n *\n * Notes:\n * - to hide it use the hidden attribute as other means break the functionality\n */\nexport const FloatingContainer = forwardRef<HTMLDivElement, FloatingContainerProps>(function FloatingContainer({\n children,\n backgroundOverlay,\n anchor,\n isPolling = false,\n pollingInterval = 100,\n verticalAlignment = 'afterEnd',\n horizontalAlignment = 'afterStart',\n screenPadding = 16,\n gap = 4,\n ...props\n }, forwardRef) {\n const innerRef = useRef<HTMLDivElement>(null)\n useImperativeHandle(forwardRef, () => innerRef.current)\n\n const position = useFloatingElement({\n active: !props.hidden,\n containerRef: innerRef,\n anchorRef: anchor,\n isPolling,\n pollingInterval,\n verticalAlignment,\n horizontalAlignment,\n gap,\n screenPadding,\n })\n\n return createPortal(\n <>\n {backgroundOverlay}\n <div\n {...props}\n ref={innerRef}\n style={{\n position: 'fixed',\n overflow: 'hidden',\n opacity: position ? undefined : 0, // hide when position calculation isn't done yet\n transition: position ? `top ${pollingInterval}ms linear, left ${pollingInterval}ms linear` : undefined,\n ...position,\n ...props.style\n }}\n className={clsx('motion-safe:duration-100 motion-reduce:duration-0', props.className)}\n >\n {children}\n </div>\n </>,\n document.body\n )\n})","'use client'\n\nimport type { CSSProperties, MutableRefObject } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { clamp } from '@/src/utils/math'\nimport { useIsMounted } from '@/src/hooks/focus/useIsMounted'\n\nexport type FloatingElementAlignment = 'beforeStart' | 'afterStart' | 'center' | 'beforeEnd' | 'afterEnd'\n\ntype RectangleBounds = {\n top: number,\n right: number,\n bottom: number,\n left: number,\n width: number,\n height: number,\n}\n\ntype CalculatePositionOptions = {\n verticalAlignment?: FloatingElementAlignment,\n horizontalAlignment?: FloatingElementAlignment,\n screenPadding?: number,\n gap?: number,\n}\n\ntype CalculatePositionProps = {\n windowRect: RectangleBounds,\n containerRect: RectangleBounds,\n anchorRect: RectangleBounds,\n options: CalculatePositionOptions,\n}\n\ntype UseFloatingElementStyle = {\n left: number,\n top: number,\n maxWidth: number,\n maxHeight: number,\n}\n\nfunction calculatePosition({\n windowRect,\n containerRect,\n anchorRect,\n options,\n }: CalculatePositionProps): UseFloatingElementStyle {\n const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options\n const windowWidth = windowRect.width\n const windowHeight = windowRect.height\n\n const maxWidth = windowWidth - 2 * screenPadding\n const maxHeight = windowHeight - 2 * screenPadding\n\n const width = Math.min(containerRect.width, maxWidth)\n const height = Math.min(containerRect.height, maxHeight)\n\n const leftSuggestion = {\n beforeStart: anchorRect.left - width - gap,\n afterStart: anchorRect.left,\n center: anchorRect.left + anchorRect.width / 2 - width / 2,\n beforeEnd: anchorRect.right - width,\n afterEnd: anchorRect.right + gap,\n }[horizontalAlignment]\n\n const topSuggestion = {\n beforeStart: anchorRect.top - height - gap,\n afterStart: anchorRect.top,\n center: anchorRect.top + anchorRect.height / 2 - height / 2,\n beforeEnd: anchorRect.bottom - height,\n afterEnd: anchorRect.bottom + gap,\n }[verticalAlignment]\n\n const left = clamp(leftSuggestion, [\n screenPadding,\n windowWidth - screenPadding - width,\n ])\n\n const top = clamp(topSuggestion, [\n screenPadding,\n windowHeight - screenPadding - height,\n ])\n\n return {\n left,\n top,\n maxWidth,\n maxHeight,\n }\n}\n\nexport type UseFloatingElementOptions = CalculatePositionOptions & {\n isPolling?: boolean,\n pollingInterval?: number,\n}\n\nexport type UseFloatingElementProps = UseFloatingElementOptions & {\n containerRef: MutableRefObject<HTMLElement>,\n anchorRef: MutableRefObject<HTMLElement>,\n windowRef?: MutableRefObject<HTMLElement>,\n active?: boolean,\n}\n\nexport function useFloatingElement({\n active = true,\n windowRef,\n anchorRef,\n containerRef,\n isPolling = false,\n pollingInterval = 100,\n verticalAlignment = 'afterEnd',\n horizontalAlignment = 'afterStart',\n screenPadding = 16,\n gap = 4,\n }: UseFloatingElementProps) {\n const [style, setStyle] = useState<CSSProperties>()\n const isMounted = useIsMounted()\n\n const calculate = useCallback(() => {\n const containerRect = containerRef.current.getBoundingClientRect()\n const windowRect: RectangleBounds = windowRef?.current.getBoundingClientRect() ?? {\n top: 0,\n bottom: window.innerHeight,\n left: 0,\n right: window.innerWidth,\n width: window.innerWidth,\n height: window.innerHeight,\n }\n const anchorElement = anchorRef?.current\n if (anchorRef && !anchorElement) {\n console.warn('FloatingContainer anchor provided, but its value is undefined')\n }\n const anchorRect: RectangleBounds = anchorElement?.getBoundingClientRect() ?? windowRect\n\n const calculateProps: CalculatePositionProps = {\n windowRect,\n anchorRect,\n containerRect,\n options: {\n horizontalAlignment,\n verticalAlignment,\n screenPadding,\n gap,\n }\n }\n setStyle(calculatePosition(calculateProps))\n }, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef])\n\n\n const height = containerRef.current?.getBoundingClientRect().height\n const width = containerRef.current?.getBoundingClientRect().width\n useEffect(() => {\n if (active && isMounted) {\n calculate()\n } else {\n setStyle(undefined)\n }\n }, [calculate, active, isMounted, height, width])\n\n useEffect(() => {\n window.addEventListener('resize', calculate)\n let timeout: NodeJS.Timeout\n if (isPolling) {\n timeout = setInterval(calculate, pollingInterval)\n }\n return () => {\n window.removeEventListener('resize', calculate)\n if (timeout) {\n clearInterval(timeout)\n }\n }\n }, [calculate, isPolling, pollingInterval])\n\n return style\n}","export const clamp = (value: number, range: [number, number] = [0, 1]): number => {\n const [min, max] = range\n return Math.min(Math.max(value, min), max)\n}\n","'use client'\n\nimport { useEffect, useLayoutEffect, useState } from 'react'\n\nconst isClient = typeof window !== 'undefined' && typeof document !== 'undefined'\nconst useIsomorphicEffect = isClient ? useLayoutEffect : useEffect\n\nexport const useIsMounted = () => {\n const [isMounted, setIsMounted] = useState(false)\n\n useIsomorphicEffect(() => {\n setIsMounted(true)\n return () => {\n setIsMounted(false)\n }\n }, [])\n return isMounted\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAAwD;AACxD,uBAA6B;AAC7B,kBAAqB;;;ACArB,IAAAC,gBAAiD;;;ACH1C,IAAM,QAAQ,CAAC,OAAe,QAA0B,CAAC,GAAG,CAAC,MAAc;AACh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AA,UACX;AAAA,UACA,eAAW,kBAAK,qDAAqD,MAAM,SAAS;AAAA,UAEnF;AAAA;AAAA,MACH;AAAA,OACF;AAAA,IACA,SAAS;AAAA,EACX;AACF,CAAC;","names":["import_react","import_react","FloatingContainer","forwardRef"]}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// src/components/layout-and-navigation/FloatingContainer.tsx
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { clsx } from "clsx";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useFloatingElement.ts
|
|
7
|
+
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
8
|
+
|
|
9
|
+
// src/utils/math.ts
|
|
10
|
+
var clamp = (value, range = [0, 1]) => {
|
|
11
|
+
const [min, max] = range;
|
|
12
|
+
return Math.min(Math.max(value, min), max);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/hooks/focus/useIsMounted.ts
|
|
16
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
17
|
+
var isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
18
|
+
var useIsomorphicEffect = isClient ? useLayoutEffect : useEffect;
|
|
19
|
+
var useIsMounted = () => {
|
|
20
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
21
|
+
useIsomorphicEffect(() => {
|
|
22
|
+
setIsMounted(true);
|
|
23
|
+
return () => {
|
|
24
|
+
setIsMounted(false);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return isMounted;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/hooks/useFloatingElement.ts
|
|
31
|
+
function calculatePosition({
|
|
32
|
+
windowRect,
|
|
33
|
+
containerRect,
|
|
34
|
+
anchorRect,
|
|
35
|
+
options
|
|
36
|
+
}) {
|
|
37
|
+
const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
|
|
38
|
+
const windowWidth = windowRect.width;
|
|
39
|
+
const windowHeight = windowRect.height;
|
|
40
|
+
const maxWidth = windowWidth - 2 * screenPadding;
|
|
41
|
+
const maxHeight = windowHeight - 2 * screenPadding;
|
|
42
|
+
const width = Math.min(containerRect.width, maxWidth);
|
|
43
|
+
const height = Math.min(containerRect.height, maxHeight);
|
|
44
|
+
const leftSuggestion = {
|
|
45
|
+
beforeStart: anchorRect.left - width - gap,
|
|
46
|
+
afterStart: anchorRect.left,
|
|
47
|
+
center: anchorRect.left + anchorRect.width / 2 - width / 2,
|
|
48
|
+
beforeEnd: anchorRect.right - width,
|
|
49
|
+
afterEnd: anchorRect.right + gap
|
|
50
|
+
}[horizontalAlignment];
|
|
51
|
+
const topSuggestion = {
|
|
52
|
+
beforeStart: anchorRect.top - height - gap,
|
|
53
|
+
afterStart: anchorRect.top,
|
|
54
|
+
center: anchorRect.top + anchorRect.height / 2 - height / 2,
|
|
55
|
+
beforeEnd: anchorRect.bottom - height,
|
|
56
|
+
afterEnd: anchorRect.bottom + gap
|
|
57
|
+
}[verticalAlignment];
|
|
58
|
+
const left = clamp(leftSuggestion, [
|
|
59
|
+
screenPadding,
|
|
60
|
+
windowWidth - screenPadding - width
|
|
61
|
+
]);
|
|
62
|
+
const top = clamp(topSuggestion, [
|
|
63
|
+
screenPadding,
|
|
64
|
+
windowHeight - screenPadding - height
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
left,
|
|
68
|
+
top,
|
|
69
|
+
maxWidth,
|
|
70
|
+
maxHeight
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function useFloatingElement({
|
|
74
|
+
active = true,
|
|
75
|
+
windowRef,
|
|
76
|
+
anchorRef,
|
|
77
|
+
containerRef,
|
|
78
|
+
isPolling = false,
|
|
79
|
+
pollingInterval = 100,
|
|
80
|
+
verticalAlignment = "afterEnd",
|
|
81
|
+
horizontalAlignment = "afterStart",
|
|
82
|
+
screenPadding = 16,
|
|
83
|
+
gap = 4
|
|
84
|
+
}) {
|
|
85
|
+
const [style, setStyle] = useState2();
|
|
86
|
+
const isMounted = useIsMounted();
|
|
87
|
+
const calculate = useCallback(() => {
|
|
88
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
89
|
+
const windowRect = windowRef?.current.getBoundingClientRect() ?? {
|
|
90
|
+
top: 0,
|
|
91
|
+
bottom: window.innerHeight,
|
|
92
|
+
left: 0,
|
|
93
|
+
right: window.innerWidth,
|
|
94
|
+
width: window.innerWidth,
|
|
95
|
+
height: window.innerHeight
|
|
96
|
+
};
|
|
97
|
+
const anchorElement = anchorRef?.current;
|
|
98
|
+
if (anchorRef && !anchorElement) {
|
|
99
|
+
console.warn("FloatingContainer anchor provided, but its value is undefined");
|
|
100
|
+
}
|
|
101
|
+
const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
|
|
102
|
+
const calculateProps = {
|
|
103
|
+
windowRect,
|
|
104
|
+
anchorRect,
|
|
105
|
+
containerRect,
|
|
106
|
+
options: {
|
|
107
|
+
horizontalAlignment,
|
|
108
|
+
verticalAlignment,
|
|
109
|
+
screenPadding,
|
|
110
|
+
gap
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
setStyle(calculatePosition(calculateProps));
|
|
114
|
+
}, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
|
|
115
|
+
const height = containerRef.current?.getBoundingClientRect().height;
|
|
116
|
+
const width = containerRef.current?.getBoundingClientRect().width;
|
|
117
|
+
useEffect2(() => {
|
|
118
|
+
if (active && isMounted) {
|
|
119
|
+
calculate();
|
|
120
|
+
} else {
|
|
121
|
+
setStyle(void 0);
|
|
122
|
+
}
|
|
123
|
+
}, [calculate, active, isMounted, height, width]);
|
|
124
|
+
useEffect2(() => {
|
|
125
|
+
window.addEventListener("resize", calculate);
|
|
126
|
+
let timeout;
|
|
127
|
+
if (isPolling) {
|
|
128
|
+
timeout = setInterval(calculate, pollingInterval);
|
|
129
|
+
}
|
|
130
|
+
return () => {
|
|
131
|
+
window.removeEventListener("resize", calculate);
|
|
132
|
+
if (timeout) {
|
|
133
|
+
clearInterval(timeout);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}, [calculate, isPolling, pollingInterval]);
|
|
137
|
+
return style;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/components/layout-and-navigation/FloatingContainer.tsx
|
|
141
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
142
|
+
var FloatingContainer = forwardRef(function FloatingContainer2({
|
|
143
|
+
children,
|
|
144
|
+
backgroundOverlay,
|
|
145
|
+
anchor,
|
|
146
|
+
isPolling = false,
|
|
147
|
+
pollingInterval = 100,
|
|
148
|
+
verticalAlignment = "afterEnd",
|
|
149
|
+
horizontalAlignment = "afterStart",
|
|
150
|
+
screenPadding = 16,
|
|
151
|
+
gap = 4,
|
|
152
|
+
...props
|
|
153
|
+
}, forwardRef2) {
|
|
154
|
+
const innerRef = useRef(null);
|
|
155
|
+
useImperativeHandle(forwardRef2, () => innerRef.current);
|
|
156
|
+
const position = useFloatingElement({
|
|
157
|
+
active: !props.hidden,
|
|
158
|
+
containerRef: innerRef,
|
|
159
|
+
anchorRef: anchor,
|
|
160
|
+
isPolling,
|
|
161
|
+
pollingInterval,
|
|
162
|
+
verticalAlignment,
|
|
163
|
+
horizontalAlignment,
|
|
164
|
+
gap,
|
|
165
|
+
screenPadding
|
|
166
|
+
});
|
|
167
|
+
return createPortal(
|
|
168
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
|
+
backgroundOverlay,
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
...props,
|
|
174
|
+
ref: innerRef,
|
|
175
|
+
style: {
|
|
176
|
+
position: "fixed",
|
|
177
|
+
overflow: "hidden",
|
|
178
|
+
opacity: position ? void 0 : 0,
|
|
179
|
+
// hide when position calculation isn't done yet
|
|
180
|
+
transition: position ? `top ${pollingInterval}ms linear, left ${pollingInterval}ms linear` : void 0,
|
|
181
|
+
...position,
|
|
182
|
+
...props.style
|
|
183
|
+
},
|
|
184
|
+
className: clsx("motion-safe:duration-100 motion-reduce:duration-0", props.className),
|
|
185
|
+
children
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
] }),
|
|
189
|
+
document.body
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
export {
|
|
193
|
+
FloatingContainer
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=FloatingContainer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/layout-and-navigation/FloatingContainer.tsx","../../../src/hooks/useFloatingElement.ts","../../../src/utils/math.ts","../../../src/hooks/focus/useIsMounted.ts"],"sourcesContent":["import type { HTMLAttributes, MutableRefObject, ReactNode } from 'react'\nimport { forwardRef, useImperativeHandle, useRef } from 'react'\nimport { createPortal } from 'react-dom'\nimport { clsx } from 'clsx'\nimport type { UseFloatingElementOptions } from '@/src/hooks/useFloatingElement'\nimport { useFloatingElement } from '@/src/hooks/useFloatingElement'\n\nexport type FloatingContainerProps = HTMLAttributes<HTMLDivElement> & UseFloatingElementOptions & {\n anchor?: MutableRefObject<HTMLElement>,\n /**\n * Polls the position of the anchor every 100ms\n *\n * Use sparingly\n */\n backgroundOverlay?: ReactNode,\n}\n\n/**\n * A floating container that aligns to its anchor\n *\n * Notes:\n * - to hide it use the hidden attribute as other means break the functionality\n */\nexport const FloatingContainer = forwardRef<HTMLDivElement, FloatingContainerProps>(function FloatingContainer({\n children,\n backgroundOverlay,\n anchor,\n isPolling = false,\n pollingInterval = 100,\n verticalAlignment = 'afterEnd',\n horizontalAlignment = 'afterStart',\n screenPadding = 16,\n gap = 4,\n ...props\n }, forwardRef) {\n const innerRef = useRef<HTMLDivElement>(null)\n useImperativeHandle(forwardRef, () => innerRef.current)\n\n const position = useFloatingElement({\n active: !props.hidden,\n containerRef: innerRef,\n anchorRef: anchor,\n isPolling,\n pollingInterval,\n verticalAlignment,\n horizontalAlignment,\n gap,\n screenPadding,\n })\n\n return createPortal(\n <>\n {backgroundOverlay}\n <div\n {...props}\n ref={innerRef}\n style={{\n position: 'fixed',\n overflow: 'hidden',\n opacity: position ? undefined : 0, // hide when position calculation isn't done yet\n transition: position ? `top ${pollingInterval}ms linear, left ${pollingInterval}ms linear` : undefined,\n ...position,\n ...props.style\n }}\n className={clsx('motion-safe:duration-100 motion-reduce:duration-0', props.className)}\n >\n {children}\n </div>\n </>,\n document.body\n )\n})","'use client'\n\nimport type { CSSProperties, MutableRefObject } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { clamp } from '@/src/utils/math'\nimport { useIsMounted } from '@/src/hooks/focus/useIsMounted'\n\nexport type FloatingElementAlignment = 'beforeStart' | 'afterStart' | 'center' | 'beforeEnd' | 'afterEnd'\n\ntype RectangleBounds = {\n top: number,\n right: number,\n bottom: number,\n left: number,\n width: number,\n height: number,\n}\n\ntype CalculatePositionOptions = {\n verticalAlignment?: FloatingElementAlignment,\n horizontalAlignment?: FloatingElementAlignment,\n screenPadding?: number,\n gap?: number,\n}\n\ntype CalculatePositionProps = {\n windowRect: RectangleBounds,\n containerRect: RectangleBounds,\n anchorRect: RectangleBounds,\n options: CalculatePositionOptions,\n}\n\ntype UseFloatingElementStyle = {\n left: number,\n top: number,\n maxWidth: number,\n maxHeight: number,\n}\n\nfunction calculatePosition({\n windowRect,\n containerRect,\n anchorRect,\n options,\n }: CalculatePositionProps): UseFloatingElementStyle {\n const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options\n const windowWidth = windowRect.width\n const windowHeight = windowRect.height\n\n const maxWidth = windowWidth - 2 * screenPadding\n const maxHeight = windowHeight - 2 * screenPadding\n\n const width = Math.min(containerRect.width, maxWidth)\n const height = Math.min(containerRect.height, maxHeight)\n\n const leftSuggestion = {\n beforeStart: anchorRect.left - width - gap,\n afterStart: anchorRect.left,\n center: anchorRect.left + anchorRect.width / 2 - width / 2,\n beforeEnd: anchorRect.right - width,\n afterEnd: anchorRect.right + gap,\n }[horizontalAlignment]\n\n const topSuggestion = {\n beforeStart: anchorRect.top - height - gap,\n afterStart: anchorRect.top,\n center: anchorRect.top + anchorRect.height / 2 - height / 2,\n beforeEnd: anchorRect.bottom - height,\n afterEnd: anchorRect.bottom + gap,\n }[verticalAlignment]\n\n const left = clamp(leftSuggestion, [\n screenPadding,\n windowWidth - screenPadding - width,\n ])\n\n const top = clamp(topSuggestion, [\n screenPadding,\n windowHeight - screenPadding - height,\n ])\n\n return {\n left,\n top,\n maxWidth,\n maxHeight,\n }\n}\n\nexport type UseFloatingElementOptions = CalculatePositionOptions & {\n isPolling?: boolean,\n pollingInterval?: number,\n}\n\nexport type UseFloatingElementProps = UseFloatingElementOptions & {\n containerRef: MutableRefObject<HTMLElement>,\n anchorRef: MutableRefObject<HTMLElement>,\n windowRef?: MutableRefObject<HTMLElement>,\n active?: boolean,\n}\n\nexport function useFloatingElement({\n active = true,\n windowRef,\n anchorRef,\n containerRef,\n isPolling = false,\n pollingInterval = 100,\n verticalAlignment = 'afterEnd',\n horizontalAlignment = 'afterStart',\n screenPadding = 16,\n gap = 4,\n }: UseFloatingElementProps) {\n const [style, setStyle] = useState<CSSProperties>()\n const isMounted = useIsMounted()\n\n const calculate = useCallback(() => {\n const containerRect = containerRef.current.getBoundingClientRect()\n const windowRect: RectangleBounds = windowRef?.current.getBoundingClientRect() ?? {\n top: 0,\n bottom: window.innerHeight,\n left: 0,\n right: window.innerWidth,\n width: window.innerWidth,\n height: window.innerHeight,\n }\n const anchorElement = anchorRef?.current\n if (anchorRef && !anchorElement) {\n console.warn('FloatingContainer anchor provided, but its value is undefined')\n }\n const anchorRect: RectangleBounds = anchorElement?.getBoundingClientRect() ?? windowRect\n\n const calculateProps: CalculatePositionProps = {\n windowRect,\n anchorRect,\n containerRect,\n options: {\n horizontalAlignment,\n verticalAlignment,\n screenPadding,\n gap,\n }\n }\n setStyle(calculatePosition(calculateProps))\n }, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef])\n\n\n const height = containerRef.current?.getBoundingClientRect().height\n const width = containerRef.current?.getBoundingClientRect().width\n useEffect(() => {\n if (active && isMounted) {\n calculate()\n } else {\n setStyle(undefined)\n }\n }, [calculate, active, isMounted, height, width])\n\n useEffect(() => {\n window.addEventListener('resize', calculate)\n let timeout: NodeJS.Timeout\n if (isPolling) {\n timeout = setInterval(calculate, pollingInterval)\n }\n return () => {\n window.removeEventListener('resize', calculate)\n if (timeout) {\n clearInterval(timeout)\n }\n }\n }, [calculate, isPolling, pollingInterval])\n\n return style\n}","export const clamp = (value: number, range: [number, number] = [0, 1]): number => {\n const [min, max] = range\n return Math.min(Math.max(value, min), max)\n}\n","'use client'\n\nimport { useEffect, useLayoutEffect, useState } from 'react'\n\nconst isClient = typeof window !== 'undefined' && typeof document !== 'undefined'\nconst useIsomorphicEffect = isClient ? useLayoutEffect : useEffect\n\nexport const useIsMounted = () => {\n const [isMounted, setIsMounted] = useState(false)\n\n useIsomorphicEffect(() => {\n setIsMounted(true)\n return () => {\n setIsMounted(false)\n }\n }, [])\n return isMounted\n}"],"mappings":";AACA,SAAS,YAAY,qBAAqB,cAAc;AACxD,SAAS,oBAAoB;AAC7B,SAAS,YAAY;;;ACArB,SAAS,aAAa,aAAAA,YAAW,YAAAC,iBAAgB;;;ACH1C,IAAM,QAAQ,CAAC,OAAe,QAA0B,CAAC,GAAG,CAAC,MAAc;AAChF,QAAM,CAAC,KAAK,GAAG,IAAI;AACnB,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;;;ACDA,SAAS,WAAW,iBAAiB,gBAAgB;AAErD,IAAM,WAAW,OAAO,WAAW,eAAe,OAAO,aAAa;AACtE,IAAM,sBAAsB,WAAW,kBAAkB;AAElD,IAAM,eAAe,MAAM;AAChC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,sBAAoB,MAAM;AACxB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A,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,SAAS;AAC9C,UAAI,SAAS;AACX,sBAAc,OAAO;AAAA,MACvB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,WAAW,eAAe,CAAC;AAE1C,SAAO;AACT;;;ADzHI,mBAEE,KAFF;AA5BG,IAAM,oBAAoB,WAAmD,SAASC,mBAAkB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,GAAG;AACL,GAAGC,aAAY;AAC5H,QAAM,WAAW,OAAuB,IAAI;AAC5C,sBAAoBA,aAAY,MAAM,SAAS,OAAO;AAEtD,QAAM,WAAW,mBAAmB;AAAA,IAClC,QAAQ,CAAC,MAAM;AAAA,IACf,cAAc;AAAA,IACd,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,iCACG;AAAA;AAAA,MACD;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ,KAAK;AAAA,UACL,OAAO;AAAA,YACL,UAAU;AAAA,YACV,UAAU;AAAA,YACV,SAAS,WAAW,SAAY;AAAA;AAAA,YAChC,YAAY,WAAW,OAAO,eAAe,mBAAmB,eAAe,cAAc;AAAA,YAC7F,GAAG;AAAA,YACH,GAAG,MAAM;AAAA,UACX;AAAA,UACA,WAAW,KAAK,qDAAqD,MAAM,SAAS;AAAA,UAEnF;AAAA;AAAA,MACH;AAAA,OACF;AAAA,IACA,SAAS;AAAA,EACX;AACF,CAAC;","names":["useEffect","useState","useState","useEffect","FloatingContainer","forwardRef"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ListBoxItemProps = HTMLAttributes<HTMLLIElement> & {
|
|
5
|
+
value: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const ListBoxItem: React__default.ForwardRefExoticComponent<HTMLAttributes<HTMLLIElement> & {
|
|
9
|
+
value: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
} & React__default.RefAttributes<HTMLLIElement>>;
|
|
12
|
+
type ListBoxOrientation = 'vertical' | 'horizontal';
|
|
13
|
+
type ListBoxPrimitiveProps = HTMLAttributes<HTMLUListElement> & {
|
|
14
|
+
value?: string[];
|
|
15
|
+
onItemClicked?: (value: string) => void;
|
|
16
|
+
onSelectionChanged?: (value: string[]) => void;
|
|
17
|
+
isSelection?: boolean;
|
|
18
|
+
isMultiple?: boolean;
|
|
19
|
+
orientation?: ListBoxOrientation;
|
|
20
|
+
};
|
|
21
|
+
declare const ListBoxPrimitive: React__default.ForwardRefExoticComponent<HTMLAttributes<HTMLUListElement> & {
|
|
22
|
+
value?: string[];
|
|
23
|
+
onItemClicked?: (value: string) => void;
|
|
24
|
+
onSelectionChanged?: (value: string[]) => void;
|
|
25
|
+
isSelection?: boolean;
|
|
26
|
+
isMultiple?: boolean;
|
|
27
|
+
orientation?: ListBoxOrientation;
|
|
28
|
+
} & React__default.RefAttributes<HTMLUListElement>>;
|
|
29
|
+
type ListBoxMultipleProps = Omit<ListBoxPrimitiveProps, 'isMultiple'>;
|
|
30
|
+
declare const ListBoxMultiple: ({ ...props }: ListBoxMultipleProps) => react_jsx_runtime.JSX.Element;
|
|
31
|
+
type ListBoxMultipleUncontrolledProps = ListBoxMultipleProps;
|
|
32
|
+
declare const ListBoxMultipleUncontrolled: ({ value: initialValue, onSelectionChanged, ...props }: ListBoxMultipleUncontrolledProps) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
type ListBoxProps = Omit<ListBoxPrimitiveProps, 'isMultiple' | 'value' | 'onSelectionChanged'> & {
|
|
34
|
+
value?: string;
|
|
35
|
+
onSelectionChanged?: (value: string) => void;
|
|
36
|
+
};
|
|
37
|
+
declare const ListBox: React__default.ForwardRefExoticComponent<Omit<ListBoxPrimitiveProps, "value" | "onSelectionChanged" | "isMultiple"> & {
|
|
38
|
+
value?: string;
|
|
39
|
+
onSelectionChanged?: (value: string) => void;
|
|
40
|
+
} & React__default.RefAttributes<HTMLUListElement>>;
|
|
41
|
+
type ListBoxUncontrolledProps = ListBoxProps;
|
|
42
|
+
declare const ListBoxUncontrolled: ({ value: initialValue, onSelectionChanged, ...props }: ListBoxUncontrolledProps) => react_jsx_runtime.JSX.Element;
|
|
43
|
+
|
|
44
|
+
export { ListBox, ListBoxItem, type ListBoxItemProps, ListBoxMultiple, type ListBoxMultipleProps, ListBoxMultipleUncontrolled, type ListBoxMultipleUncontrolledProps, ListBoxPrimitive, type ListBoxPrimitiveProps, type ListBoxProps, ListBoxUncontrolled, type ListBoxUncontrolledProps };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ListBoxItemProps = HTMLAttributes<HTMLLIElement> & {
|
|
5
|
+
value: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const ListBoxItem: React__default.ForwardRefExoticComponent<HTMLAttributes<HTMLLIElement> & {
|
|
9
|
+
value: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
} & React__default.RefAttributes<HTMLLIElement>>;
|
|
12
|
+
type ListBoxOrientation = 'vertical' | 'horizontal';
|
|
13
|
+
type ListBoxPrimitiveProps = HTMLAttributes<HTMLUListElement> & {
|
|
14
|
+
value?: string[];
|
|
15
|
+
onItemClicked?: (value: string) => void;
|
|
16
|
+
onSelectionChanged?: (value: string[]) => void;
|
|
17
|
+
isSelection?: boolean;
|
|
18
|
+
isMultiple?: boolean;
|
|
19
|
+
orientation?: ListBoxOrientation;
|
|
20
|
+
};
|
|
21
|
+
declare const ListBoxPrimitive: React__default.ForwardRefExoticComponent<HTMLAttributes<HTMLUListElement> & {
|
|
22
|
+
value?: string[];
|
|
23
|
+
onItemClicked?: (value: string) => void;
|
|
24
|
+
onSelectionChanged?: (value: string[]) => void;
|
|
25
|
+
isSelection?: boolean;
|
|
26
|
+
isMultiple?: boolean;
|
|
27
|
+
orientation?: ListBoxOrientation;
|
|
28
|
+
} & React__default.RefAttributes<HTMLUListElement>>;
|
|
29
|
+
type ListBoxMultipleProps = Omit<ListBoxPrimitiveProps, 'isMultiple'>;
|
|
30
|
+
declare const ListBoxMultiple: ({ ...props }: ListBoxMultipleProps) => react_jsx_runtime.JSX.Element;
|
|
31
|
+
type ListBoxMultipleUncontrolledProps = ListBoxMultipleProps;
|
|
32
|
+
declare const ListBoxMultipleUncontrolled: ({ value: initialValue, onSelectionChanged, ...props }: ListBoxMultipleUncontrolledProps) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
type ListBoxProps = Omit<ListBoxPrimitiveProps, 'isMultiple' | 'value' | 'onSelectionChanged'> & {
|
|
34
|
+
value?: string;
|
|
35
|
+
onSelectionChanged?: (value: string) => void;
|
|
36
|
+
};
|
|
37
|
+
declare const ListBox: React__default.ForwardRefExoticComponent<Omit<ListBoxPrimitiveProps, "value" | "onSelectionChanged" | "isMultiple"> & {
|
|
38
|
+
value?: string;
|
|
39
|
+
onSelectionChanged?: (value: string) => void;
|
|
40
|
+
} & React__default.RefAttributes<HTMLUListElement>>;
|
|
41
|
+
type ListBoxUncontrolledProps = ListBoxProps;
|
|
42
|
+
declare const ListBoxUncontrolled: ({ value: initialValue, onSelectionChanged, ...props }: ListBoxUncontrolledProps) => react_jsx_runtime.JSX.Element;
|
|
43
|
+
|
|
44
|
+
export { ListBox, ListBoxItem, type ListBoxItemProps, ListBoxMultiple, type ListBoxMultipleProps, ListBoxMultipleUncontrolled, type ListBoxMultipleUncontrolledProps, ListBoxPrimitive, type ListBoxPrimitiveProps, type ListBoxProps, ListBoxUncontrolled, type ListBoxUncontrolledProps };
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/layout-and-navigation/ListBox.tsx
|
|
30
|
+
var ListBox_exports = {};
|
|
31
|
+
__export(ListBox_exports, {
|
|
32
|
+
ListBox: () => ListBox,
|
|
33
|
+
ListBoxItem: () => ListBoxItem,
|
|
34
|
+
ListBoxMultiple: () => ListBoxMultiple,
|
|
35
|
+
ListBoxMultipleUncontrolled: () => ListBoxMultipleUncontrolled,
|
|
36
|
+
ListBoxPrimitive: () => ListBoxPrimitive,
|
|
37
|
+
ListBoxUncontrolled: () => ListBoxUncontrolled
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(ListBox_exports);
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var import_clsx = require("clsx");
|
|
42
|
+
|
|
43
|
+
// src/utils/match.ts
|
|
44
|
+
var match = (key, values) => {
|
|
45
|
+
return values[key];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/components/layout-and-navigation/ListBox.tsx
|
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
var ListBoxContext = (0, import_react.createContext)(null);
|
|
51
|
+
function useListBoxContext() {
|
|
52
|
+
const ctx = (0, import_react.useContext)(ListBoxContext);
|
|
53
|
+
if (!ctx) {
|
|
54
|
+
throw new Error("ListBoxItem must be used within a ListBoxPrimitive");
|
|
55
|
+
}
|
|
56
|
+
return ctx;
|
|
57
|
+
}
|
|
58
|
+
var ListBoxItem = (0, import_react.forwardRef)(
|
|
59
|
+
function ListBoxItem2({ value, disabled = false, children, className, ...rest }, ref) {
|
|
60
|
+
const {
|
|
61
|
+
registerItem,
|
|
62
|
+
unregisterItem,
|
|
63
|
+
highlightedId,
|
|
64
|
+
setHighlightedId,
|
|
65
|
+
onItemClick,
|
|
66
|
+
isSelected
|
|
67
|
+
} = useListBoxContext();
|
|
68
|
+
const itemRef = (0, import_react.useRef)(null);
|
|
69
|
+
const id = import_react.default.useId();
|
|
70
|
+
(0, import_react.useEffect)(() => {
|
|
71
|
+
registerItem({ id, value, disabled, ref: itemRef });
|
|
72
|
+
return () => unregisterItem(id);
|
|
73
|
+
}, [id, value, disabled, registerItem, unregisterItem]);
|
|
74
|
+
const isHighlighted = highlightedId === id;
|
|
75
|
+
const selected = isSelected(value);
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
+
"li",
|
|
78
|
+
{
|
|
79
|
+
ref: (node) => {
|
|
80
|
+
itemRef.current = node;
|
|
81
|
+
if (typeof ref === "function") ref(node);
|
|
82
|
+
else if (ref) ref.current = node;
|
|
83
|
+
},
|
|
84
|
+
id,
|
|
85
|
+
role: "option",
|
|
86
|
+
"aria-disabled": disabled,
|
|
87
|
+
"aria-selected": selected,
|
|
88
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
89
|
+
"data-selected": selected ? "" : void 0,
|
|
90
|
+
"data-disabled": disabled ? "" : void 0,
|
|
91
|
+
className: (0, import_clsx.clsx)(
|
|
92
|
+
"flex-row-1 items-center px-2 py-1 rounded-md",
|
|
93
|
+
"data-highlighted:bg-primary/20",
|
|
94
|
+
"data-disabled:text-disabled data-disabled:cursor-not-allowed",
|
|
95
|
+
"not-data-disabled:cursor-pointer",
|
|
96
|
+
className
|
|
97
|
+
),
|
|
98
|
+
onClick: () => {
|
|
99
|
+
if (!disabled) onItemClick(id);
|
|
100
|
+
},
|
|
101
|
+
onMouseEnter: () => {
|
|
102
|
+
if (!disabled) {
|
|
103
|
+
setHighlightedId(id);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
...rest,
|
|
107
|
+
children: children ?? value
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
var ListBoxPrimitive = (0, import_react.forwardRef)(
|
|
113
|
+
function ListBoxPrimitive2({
|
|
114
|
+
value,
|
|
115
|
+
onSelectionChanged,
|
|
116
|
+
onItemClicked,
|
|
117
|
+
isSelection = false,
|
|
118
|
+
isMultiple = false,
|
|
119
|
+
orientation = "vertical",
|
|
120
|
+
...props
|
|
121
|
+
}, ref) {
|
|
122
|
+
const itemsRef = (0, import_react.useRef)([]);
|
|
123
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react.useState)(void 0);
|
|
124
|
+
const registerItem = (0, import_react.useCallback)((item) => {
|
|
125
|
+
itemsRef.current.push(item);
|
|
126
|
+
itemsRef.current.sort((a, b) => {
|
|
127
|
+
const aEl = a.ref.current;
|
|
128
|
+
const bEl = b.ref.current;
|
|
129
|
+
if (!aEl || !bEl) return 0;
|
|
130
|
+
return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
131
|
+
});
|
|
132
|
+
}, []);
|
|
133
|
+
const unregisterItem = (0, import_react.useCallback)((id) => {
|
|
134
|
+
itemsRef.current = itemsRef.current.filter((i) => i.id !== id);
|
|
135
|
+
}, []);
|
|
136
|
+
const isSelected = (0, import_react.useCallback)(
|
|
137
|
+
(val) => (value ?? []).includes(val),
|
|
138
|
+
[value]
|
|
139
|
+
);
|
|
140
|
+
const onItemClickedHandler = (0, import_react.useCallback)(
|
|
141
|
+
(id) => {
|
|
142
|
+
const index = itemsRef.current.findIndex((i) => i.id === id);
|
|
143
|
+
if (index === -1) {
|
|
144
|
+
console.error("ListBoxItem provided an invalid id");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const item = itemsRef.current[index];
|
|
148
|
+
const val = item.value;
|
|
149
|
+
onItemClicked?.(val);
|
|
150
|
+
setHighlightedIndex(index);
|
|
151
|
+
if (!isSelection) return;
|
|
152
|
+
if (!isMultiple) {
|
|
153
|
+
onSelectionChanged?.([val]);
|
|
154
|
+
} else {
|
|
155
|
+
if (isSelected(val)) {
|
|
156
|
+
onSelectionChanged?.((value ?? []).filter((v) => v !== val));
|
|
157
|
+
} else {
|
|
158
|
+
onSelectionChanged?.([...value ?? [], val]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
[onItemClicked, isSelection, isMultiple, onSelectionChanged, isSelected, value]
|
|
163
|
+
);
|
|
164
|
+
const setHighlightedId = (0, import_react.useCallback)((id) => {
|
|
165
|
+
const index = itemsRef.current.findIndex((i) => i.id === id);
|
|
166
|
+
if (index !== -1) {
|
|
167
|
+
setHighlightedIndex(index);
|
|
168
|
+
}
|
|
169
|
+
}, []);
|
|
170
|
+
(0, import_react.useEffect)(() => {
|
|
171
|
+
if (highlightedIndex !== void 0) {
|
|
172
|
+
itemsRef.current[highlightedIndex]?.ref.current?.scrollIntoView({ block: "nearest", behavior: "auto" });
|
|
173
|
+
}
|
|
174
|
+
}, [highlightedIndex]);
|
|
175
|
+
const highlightedItem = itemsRef.current[highlightedIndex];
|
|
176
|
+
const ctxValue = {
|
|
177
|
+
registerItem,
|
|
178
|
+
unregisterItem,
|
|
179
|
+
highlightedId: highlightedItem?.id,
|
|
180
|
+
setHighlightedId,
|
|
181
|
+
onItemClick: onItemClickedHandler,
|
|
182
|
+
isSelected
|
|
183
|
+
};
|
|
184
|
+
const moveHighlight = (delta) => {
|
|
185
|
+
if (itemsRef.current.length === 0) return;
|
|
186
|
+
let nextIndex = highlightedIndex ?? -1;
|
|
187
|
+
for (let i = 0; i < itemsRef.current.length; i++) {
|
|
188
|
+
nextIndex = (nextIndex + delta + itemsRef.current.length) % itemsRef.current.length;
|
|
189
|
+
if (!itemsRef.current[nextIndex].disabled) break;
|
|
190
|
+
}
|
|
191
|
+
setHighlightedIndex(nextIndex);
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBoxContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
194
|
+
"ul",
|
|
195
|
+
{
|
|
196
|
+
ref,
|
|
197
|
+
...props,
|
|
198
|
+
onFocus: (event) => {
|
|
199
|
+
if (highlightedIndex === void 0) {
|
|
200
|
+
const firstEnabled = itemsRef.current.findIndex((i) => !i.disabled);
|
|
201
|
+
setHighlightedIndex(firstEnabled !== -1 ? firstEnabled : void 0);
|
|
202
|
+
}
|
|
203
|
+
props.onFocus?.(event);
|
|
204
|
+
},
|
|
205
|
+
onBlur: (event) => {
|
|
206
|
+
setHighlightedIndex(void 0);
|
|
207
|
+
props.onBlur?.(event);
|
|
208
|
+
},
|
|
209
|
+
onKeyDown: (event) => {
|
|
210
|
+
switch (event.key) {
|
|
211
|
+
case match(orientation, {
|
|
212
|
+
vertical: "ArrowDown",
|
|
213
|
+
horizontal: "ArrowUp"
|
|
214
|
+
}):
|
|
215
|
+
moveHighlight(1);
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
break;
|
|
218
|
+
case match(orientation, {
|
|
219
|
+
vertical: "ArrowUp",
|
|
220
|
+
horizontal: "ArrowDown"
|
|
221
|
+
}):
|
|
222
|
+
moveHighlight(-1);
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
break;
|
|
225
|
+
case "Home":
|
|
226
|
+
setHighlightedIndex(itemsRef.current.findIndex((i) => !i.disabled));
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
break;
|
|
229
|
+
case "End":
|
|
230
|
+
for (let i = itemsRef.current.length - 1; i >= 0; i--) {
|
|
231
|
+
if (!itemsRef.current[i].disabled) {
|
|
232
|
+
setHighlightedIndex(i);
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
break;
|
|
238
|
+
case "Enter":
|
|
239
|
+
case " ":
|
|
240
|
+
if (highlightedIndex !== void 0) {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
onItemClickedHandler(itemsRef.current[highlightedIndex].id);
|
|
243
|
+
}
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
props.onKeyDown?.(event);
|
|
247
|
+
},
|
|
248
|
+
role: "listbox",
|
|
249
|
+
"aria-multiselectable": isSelection ? isMultiple : void 0,
|
|
250
|
+
"aria-orientation": orientation,
|
|
251
|
+
tabIndex: 0,
|
|
252
|
+
children: props.children
|
|
253
|
+
}
|
|
254
|
+
) });
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
var ListBoxMultiple = ({ ...props }) => {
|
|
258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBoxPrimitive, { ...props });
|
|
259
|
+
};
|
|
260
|
+
var ListBoxMultipleUncontrolled = ({
|
|
261
|
+
value: initialValue,
|
|
262
|
+
onSelectionChanged,
|
|
263
|
+
...props
|
|
264
|
+
}) => {
|
|
265
|
+
const [value, setValue] = (0, import_react.useState)(initialValue);
|
|
266
|
+
(0, import_react.useEffect)(() => {
|
|
267
|
+
setValue(initialValue);
|
|
268
|
+
}, [initialValue]);
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
270
|
+
ListBoxMultiple,
|
|
271
|
+
{
|
|
272
|
+
...props,
|
|
273
|
+
value,
|
|
274
|
+
onSelectionChanged: (newValue) => {
|
|
275
|
+
setValue(newValue);
|
|
276
|
+
onSelectionChanged?.(newValue);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
var ListBox = (0, import_react.forwardRef)(function ListBox2({
|
|
282
|
+
value,
|
|
283
|
+
onSelectionChanged,
|
|
284
|
+
...props
|
|
285
|
+
}, ref) {
|
|
286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
|
+
ListBoxPrimitive,
|
|
288
|
+
{
|
|
289
|
+
ref,
|
|
290
|
+
value: value !== void 0 ? [value] : void 0,
|
|
291
|
+
onSelectionChanged: (newValue) => {
|
|
292
|
+
onSelectionChanged(newValue[0] ?? value);
|
|
293
|
+
},
|
|
294
|
+
isMultiple: false,
|
|
295
|
+
...props
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
var ListBoxUncontrolled = ({
|
|
300
|
+
value: initialValue,
|
|
301
|
+
onSelectionChanged,
|
|
302
|
+
...props
|
|
303
|
+
}) => {
|
|
304
|
+
const [value, setValue] = (0, import_react.useState)(initialValue);
|
|
305
|
+
(0, import_react.useEffect)(() => {
|
|
306
|
+
setValue(initialValue);
|
|
307
|
+
}, [initialValue]);
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
309
|
+
ListBox,
|
|
310
|
+
{
|
|
311
|
+
...props,
|
|
312
|
+
value,
|
|
313
|
+
onSelectionChanged: (newValue) => {
|
|
314
|
+
setValue(newValue);
|
|
315
|
+
onSelectionChanged?.(newValue);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
321
|
+
0 && (module.exports = {
|
|
322
|
+
ListBox,
|
|
323
|
+
ListBoxItem,
|
|
324
|
+
ListBoxMultiple,
|
|
325
|
+
ListBoxMultipleUncontrolled,
|
|
326
|
+
ListBoxPrimitive,
|
|
327
|
+
ListBoxUncontrolled
|
|
328
|
+
});
|
|
329
|
+
//# sourceMappingURL=ListBox.js.map
|