@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,22 @@
|
|
|
1
|
+
import { MutableRefObject, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type FloatingElementAlignment = 'beforeStart' | 'afterStart' | 'center' | 'beforeEnd' | 'afterEnd';
|
|
4
|
+
type CalculatePositionOptions = {
|
|
5
|
+
verticalAlignment?: FloatingElementAlignment;
|
|
6
|
+
horizontalAlignment?: FloatingElementAlignment;
|
|
7
|
+
screenPadding?: number;
|
|
8
|
+
gap?: number;
|
|
9
|
+
};
|
|
10
|
+
type UseFloatingElementOptions = CalculatePositionOptions & {
|
|
11
|
+
isPolling?: boolean;
|
|
12
|
+
pollingInterval?: number;
|
|
13
|
+
};
|
|
14
|
+
type UseFloatingElementProps = UseFloatingElementOptions & {
|
|
15
|
+
containerRef: MutableRefObject<HTMLElement>;
|
|
16
|
+
anchorRef: MutableRefObject<HTMLElement>;
|
|
17
|
+
windowRef?: MutableRefObject<HTMLElement>;
|
|
18
|
+
active?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare function useFloatingElement({ active, windowRef, anchorRef, containerRef, isPolling, pollingInterval, verticalAlignment, horizontalAlignment, screenPadding, gap, }: UseFloatingElementProps): CSSProperties;
|
|
21
|
+
|
|
22
|
+
export { type FloatingElementAlignment, type UseFloatingElementOptions, type UseFloatingElementProps, useFloatingElement };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MutableRefObject, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type FloatingElementAlignment = 'beforeStart' | 'afterStart' | 'center' | 'beforeEnd' | 'afterEnd';
|
|
4
|
+
type CalculatePositionOptions = {
|
|
5
|
+
verticalAlignment?: FloatingElementAlignment;
|
|
6
|
+
horizontalAlignment?: FloatingElementAlignment;
|
|
7
|
+
screenPadding?: number;
|
|
8
|
+
gap?: number;
|
|
9
|
+
};
|
|
10
|
+
type UseFloatingElementOptions = CalculatePositionOptions & {
|
|
11
|
+
isPolling?: boolean;
|
|
12
|
+
pollingInterval?: number;
|
|
13
|
+
};
|
|
14
|
+
type UseFloatingElementProps = UseFloatingElementOptions & {
|
|
15
|
+
containerRef: MutableRefObject<HTMLElement>;
|
|
16
|
+
anchorRef: MutableRefObject<HTMLElement>;
|
|
17
|
+
windowRef?: MutableRefObject<HTMLElement>;
|
|
18
|
+
active?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare function useFloatingElement({ active, windowRef, anchorRef, containerRef, isPolling, pollingInterval, verticalAlignment, horizontalAlignment, screenPadding, gap, }: UseFloatingElementProps): CSSProperties;
|
|
21
|
+
|
|
22
|
+
export { type FloatingElementAlignment, type UseFloatingElementOptions, type UseFloatingElementProps, useFloatingElement };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useFloatingElement.ts
|
|
21
|
+
var useFloatingElement_exports = {};
|
|
22
|
+
__export(useFloatingElement_exports, {
|
|
23
|
+
useFloatingElement: () => useFloatingElement
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useFloatingElement_exports);
|
|
26
|
+
var import_react2 = require("react");
|
|
27
|
+
|
|
28
|
+
// src/utils/math.ts
|
|
29
|
+
var clamp = (value, range = [0, 1]) => {
|
|
30
|
+
const [min, max] = range;
|
|
31
|
+
return Math.min(Math.max(value, min), max);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/hooks/focus/useIsMounted.ts
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
37
|
+
var useIsomorphicEffect = isClient ? import_react.useLayoutEffect : import_react.useEffect;
|
|
38
|
+
var useIsMounted = () => {
|
|
39
|
+
const [isMounted, setIsMounted] = (0, import_react.useState)(false);
|
|
40
|
+
useIsomorphicEffect(() => {
|
|
41
|
+
setIsMounted(true);
|
|
42
|
+
return () => {
|
|
43
|
+
setIsMounted(false);
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
return isMounted;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/hooks/useFloatingElement.ts
|
|
50
|
+
function calculatePosition({
|
|
51
|
+
windowRect,
|
|
52
|
+
containerRect,
|
|
53
|
+
anchorRect,
|
|
54
|
+
options
|
|
55
|
+
}) {
|
|
56
|
+
const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
|
|
57
|
+
const windowWidth = windowRect.width;
|
|
58
|
+
const windowHeight = windowRect.height;
|
|
59
|
+
const maxWidth = windowWidth - 2 * screenPadding;
|
|
60
|
+
const maxHeight = windowHeight - 2 * screenPadding;
|
|
61
|
+
const width = Math.min(containerRect.width, maxWidth);
|
|
62
|
+
const height = Math.min(containerRect.height, maxHeight);
|
|
63
|
+
const leftSuggestion = {
|
|
64
|
+
beforeStart: anchorRect.left - width - gap,
|
|
65
|
+
afterStart: anchorRect.left,
|
|
66
|
+
center: anchorRect.left + anchorRect.width / 2 - width / 2,
|
|
67
|
+
beforeEnd: anchorRect.right - width,
|
|
68
|
+
afterEnd: anchorRect.right + gap
|
|
69
|
+
}[horizontalAlignment];
|
|
70
|
+
const topSuggestion = {
|
|
71
|
+
beforeStart: anchorRect.top - height - gap,
|
|
72
|
+
afterStart: anchorRect.top,
|
|
73
|
+
center: anchorRect.top + anchorRect.height / 2 - height / 2,
|
|
74
|
+
beforeEnd: anchorRect.bottom - height,
|
|
75
|
+
afterEnd: anchorRect.bottom + gap
|
|
76
|
+
}[verticalAlignment];
|
|
77
|
+
const left = clamp(leftSuggestion, [
|
|
78
|
+
screenPadding,
|
|
79
|
+
windowWidth - screenPadding - width
|
|
80
|
+
]);
|
|
81
|
+
const top = clamp(topSuggestion, [
|
|
82
|
+
screenPadding,
|
|
83
|
+
windowHeight - screenPadding - height
|
|
84
|
+
]);
|
|
85
|
+
return {
|
|
86
|
+
left,
|
|
87
|
+
top,
|
|
88
|
+
maxWidth,
|
|
89
|
+
maxHeight
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function useFloatingElement({
|
|
93
|
+
active = true,
|
|
94
|
+
windowRef,
|
|
95
|
+
anchorRef,
|
|
96
|
+
containerRef,
|
|
97
|
+
isPolling = false,
|
|
98
|
+
pollingInterval = 100,
|
|
99
|
+
verticalAlignment = "afterEnd",
|
|
100
|
+
horizontalAlignment = "afterStart",
|
|
101
|
+
screenPadding = 16,
|
|
102
|
+
gap = 4
|
|
103
|
+
}) {
|
|
104
|
+
const [style, setStyle] = (0, import_react2.useState)();
|
|
105
|
+
const isMounted = useIsMounted();
|
|
106
|
+
const calculate = (0, import_react2.useCallback)(() => {
|
|
107
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
108
|
+
const windowRect = windowRef?.current.getBoundingClientRect() ?? {
|
|
109
|
+
top: 0,
|
|
110
|
+
bottom: window.innerHeight,
|
|
111
|
+
left: 0,
|
|
112
|
+
right: window.innerWidth,
|
|
113
|
+
width: window.innerWidth,
|
|
114
|
+
height: window.innerHeight
|
|
115
|
+
};
|
|
116
|
+
const anchorElement = anchorRef?.current;
|
|
117
|
+
if (anchorRef && !anchorElement) {
|
|
118
|
+
console.warn("FloatingContainer anchor provided, but its value is undefined");
|
|
119
|
+
}
|
|
120
|
+
const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
|
|
121
|
+
const calculateProps = {
|
|
122
|
+
windowRect,
|
|
123
|
+
anchorRect,
|
|
124
|
+
containerRect,
|
|
125
|
+
options: {
|
|
126
|
+
horizontalAlignment,
|
|
127
|
+
verticalAlignment,
|
|
128
|
+
screenPadding,
|
|
129
|
+
gap
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
setStyle(calculatePosition(calculateProps));
|
|
133
|
+
}, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
|
|
134
|
+
const height = containerRef.current?.getBoundingClientRect().height;
|
|
135
|
+
const width = containerRef.current?.getBoundingClientRect().width;
|
|
136
|
+
(0, import_react2.useEffect)(() => {
|
|
137
|
+
if (active && isMounted) {
|
|
138
|
+
calculate();
|
|
139
|
+
} else {
|
|
140
|
+
setStyle(void 0);
|
|
141
|
+
}
|
|
142
|
+
}, [calculate, active, isMounted, height, width]);
|
|
143
|
+
(0, import_react2.useEffect)(() => {
|
|
144
|
+
window.addEventListener("resize", calculate);
|
|
145
|
+
let timeout;
|
|
146
|
+
if (isPolling) {
|
|
147
|
+
timeout = setInterval(calculate, pollingInterval);
|
|
148
|
+
}
|
|
149
|
+
return () => {
|
|
150
|
+
window.removeEventListener("resize", calculate);
|
|
151
|
+
if (timeout) {
|
|
152
|
+
clearInterval(timeout);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}, [calculate, isPolling, pollingInterval]);
|
|
156
|
+
return style;
|
|
157
|
+
}
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
useFloatingElement
|
|
161
|
+
});
|
|
162
|
+
//# sourceMappingURL=useFloatingElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useFloatingElement.ts","../../src/utils/math.ts","../../src/hooks/focus/useIsMounted.ts"],"sourcesContent":["'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;AAGA,IAAAA,gBAAiD;;;ACH1C,IAAM,QAAQ,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C7D,QAAM,QAAQ,aAAa,SAAS,sBAAsB,EAAE;AAC5D,+BAAU,MAAM;AACd,QAAI,UAAU,WAAW;AACvB,gBAAU;AAAA,IACZ,OAAO;AACL,eAAS,MAAS;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEhD,+BAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,SAAS;AAC3C,QAAI;AACJ,QAAI,WAAW;AACb,gBAAU,YAAY,WAAW,eAAe;AAAA,IAClD;AACA,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;","names":["import_react"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/hooks/useFloatingElement.ts
|
|
4
|
+
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
5
|
+
|
|
6
|
+
// src/utils/math.ts
|
|
7
|
+
var clamp = (value, range = [0, 1]) => {
|
|
8
|
+
const [min, max] = range;
|
|
9
|
+
return Math.min(Math.max(value, min), max);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/hooks/focus/useIsMounted.ts
|
|
13
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
14
|
+
var isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
15
|
+
var useIsomorphicEffect = isClient ? useLayoutEffect : useEffect;
|
|
16
|
+
var useIsMounted = () => {
|
|
17
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
18
|
+
useIsomorphicEffect(() => {
|
|
19
|
+
setIsMounted(true);
|
|
20
|
+
return () => {
|
|
21
|
+
setIsMounted(false);
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
return isMounted;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/hooks/useFloatingElement.ts
|
|
28
|
+
function calculatePosition({
|
|
29
|
+
windowRect,
|
|
30
|
+
containerRect,
|
|
31
|
+
anchorRect,
|
|
32
|
+
options
|
|
33
|
+
}) {
|
|
34
|
+
const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
|
|
35
|
+
const windowWidth = windowRect.width;
|
|
36
|
+
const windowHeight = windowRect.height;
|
|
37
|
+
const maxWidth = windowWidth - 2 * screenPadding;
|
|
38
|
+
const maxHeight = windowHeight - 2 * screenPadding;
|
|
39
|
+
const width = Math.min(containerRect.width, maxWidth);
|
|
40
|
+
const height = Math.min(containerRect.height, maxHeight);
|
|
41
|
+
const leftSuggestion = {
|
|
42
|
+
beforeStart: anchorRect.left - width - gap,
|
|
43
|
+
afterStart: anchorRect.left,
|
|
44
|
+
center: anchorRect.left + anchorRect.width / 2 - width / 2,
|
|
45
|
+
beforeEnd: anchorRect.right - width,
|
|
46
|
+
afterEnd: anchorRect.right + gap
|
|
47
|
+
}[horizontalAlignment];
|
|
48
|
+
const topSuggestion = {
|
|
49
|
+
beforeStart: anchorRect.top - height - gap,
|
|
50
|
+
afterStart: anchorRect.top,
|
|
51
|
+
center: anchorRect.top + anchorRect.height / 2 - height / 2,
|
|
52
|
+
beforeEnd: anchorRect.bottom - height,
|
|
53
|
+
afterEnd: anchorRect.bottom + gap
|
|
54
|
+
}[verticalAlignment];
|
|
55
|
+
const left = clamp(leftSuggestion, [
|
|
56
|
+
screenPadding,
|
|
57
|
+
windowWidth - screenPadding - width
|
|
58
|
+
]);
|
|
59
|
+
const top = clamp(topSuggestion, [
|
|
60
|
+
screenPadding,
|
|
61
|
+
windowHeight - screenPadding - height
|
|
62
|
+
]);
|
|
63
|
+
return {
|
|
64
|
+
left,
|
|
65
|
+
top,
|
|
66
|
+
maxWidth,
|
|
67
|
+
maxHeight
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function useFloatingElement({
|
|
71
|
+
active = true,
|
|
72
|
+
windowRef,
|
|
73
|
+
anchorRef,
|
|
74
|
+
containerRef,
|
|
75
|
+
isPolling = false,
|
|
76
|
+
pollingInterval = 100,
|
|
77
|
+
verticalAlignment = "afterEnd",
|
|
78
|
+
horizontalAlignment = "afterStart",
|
|
79
|
+
screenPadding = 16,
|
|
80
|
+
gap = 4
|
|
81
|
+
}) {
|
|
82
|
+
const [style, setStyle] = useState2();
|
|
83
|
+
const isMounted = useIsMounted();
|
|
84
|
+
const calculate = useCallback(() => {
|
|
85
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
86
|
+
const windowRect = windowRef?.current.getBoundingClientRect() ?? {
|
|
87
|
+
top: 0,
|
|
88
|
+
bottom: window.innerHeight,
|
|
89
|
+
left: 0,
|
|
90
|
+
right: window.innerWidth,
|
|
91
|
+
width: window.innerWidth,
|
|
92
|
+
height: window.innerHeight
|
|
93
|
+
};
|
|
94
|
+
const anchorElement = anchorRef?.current;
|
|
95
|
+
if (anchorRef && !anchorElement) {
|
|
96
|
+
console.warn("FloatingContainer anchor provided, but its value is undefined");
|
|
97
|
+
}
|
|
98
|
+
const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
|
|
99
|
+
const calculateProps = {
|
|
100
|
+
windowRect,
|
|
101
|
+
anchorRect,
|
|
102
|
+
containerRect,
|
|
103
|
+
options: {
|
|
104
|
+
horizontalAlignment,
|
|
105
|
+
verticalAlignment,
|
|
106
|
+
screenPadding,
|
|
107
|
+
gap
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
setStyle(calculatePosition(calculateProps));
|
|
111
|
+
}, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
|
|
112
|
+
const height = containerRef.current?.getBoundingClientRect().height;
|
|
113
|
+
const width = containerRef.current?.getBoundingClientRect().width;
|
|
114
|
+
useEffect2(() => {
|
|
115
|
+
if (active && isMounted) {
|
|
116
|
+
calculate();
|
|
117
|
+
} else {
|
|
118
|
+
setStyle(void 0);
|
|
119
|
+
}
|
|
120
|
+
}, [calculate, active, isMounted, height, width]);
|
|
121
|
+
useEffect2(() => {
|
|
122
|
+
window.addEventListener("resize", calculate);
|
|
123
|
+
let timeout;
|
|
124
|
+
if (isPolling) {
|
|
125
|
+
timeout = setInterval(calculate, pollingInterval);
|
|
126
|
+
}
|
|
127
|
+
return () => {
|
|
128
|
+
window.removeEventListener("resize", calculate);
|
|
129
|
+
if (timeout) {
|
|
130
|
+
clearInterval(timeout);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, [calculate, isPolling, pollingInterval]);
|
|
134
|
+
return style;
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
useFloatingElement
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=useFloatingElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useFloatingElement.ts","../../src/utils/math.ts","../../src/hooks/focus/useIsMounted.ts"],"sourcesContent":["'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":";;;AAGA,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;;;ACD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MAAS;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEhD,EAAAA,WAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,SAAS;AAC3C,QAAI;AACJ,QAAI,WAAW;AACb,gBAAU,YAAY,WAAW,eAAe;AAAA,IAClD;AACA,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;","names":["useEffect","useState","useState","useEffect"]}
|
|
@@ -25,7 +25,7 @@ __export(useLocalStorage_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(useLocalStorage_exports);
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
|
|
28
|
-
// src/
|
|
28
|
+
// src/utils/storage.ts
|
|
29
29
|
var StorageService = class {
|
|
30
30
|
// this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
|
|
31
31
|
constructor(storage) {
|
|
@@ -54,7 +54,7 @@ var LocalStorageService = class extends StorageService {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
// src/
|
|
57
|
+
// src/utils/resolveSetState.ts
|
|
58
58
|
function resolveSetState(action, prev) {
|
|
59
59
|
return typeof action === "function" ? action(prev) : action;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts","../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsC;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IAAI,IAAI;AAC3E;;;AFIO,IAAM,kBAAkB,CAAI,KAAa,cAAmC;AACjF,QAAM,UAAM,0BAAY,MAAS;AAC/B,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,IAAI,oBAAoB;AAC/C,UAAM,QAAQ,eAAe,IAAO,GAAG;AACvC,WAAO,SAAS;AAAA,EAClB,GAAG,CAAC,WAAW,GAAG,CAAC;AAEnB,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAY,GAAG;AAErD,QAAM,eAAwB,0BAAY,YAAU;AAClD,UAAM,WAAW,gBAAgB,QAAQ,WAAW;AACpD,UAAM,iBAAiB,IAAI,oBAAoB;AAC/C,mBAAe,IAAI,KAAK,QAAQ;AAEhC,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,aAAa,gBAAgB,GAAG,CAAC;AAErC,SAAO,CAAC,aAAa,QAAQ;AAC/B;","names":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/hooks/useLocalStorage.ts
|
|
4
4
|
import { useCallback, useState } from "react";
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/utils/storage.ts
|
|
7
7
|
var StorageService = class {
|
|
8
8
|
// this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
|
|
9
9
|
constructor(storage) {
|
|
@@ -32,7 +32,7 @@ var LocalStorageService = class extends StorageService {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
// src/
|
|
35
|
+
// src/utils/resolveSetState.ts
|
|
36
36
|
function resolveSetState(action, prev) {
|
|
37
37
|
return typeof action === "function" ? action(prev) : action;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts","../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>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AA,EACzB,GAAG,CAAC,aAAa,gBAAgB,GAAG,CAAC;AAErC,SAAO,CAAC,aAAa,QAAQ;AAC/B;","names":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
type
|
|
2
|
-
message: string;
|
|
3
|
-
condition: boolean;
|
|
1
|
+
type OptionsResolved = {
|
|
4
2
|
type?: 'info' | 'error' | 'warning';
|
|
5
3
|
};
|
|
6
|
-
|
|
4
|
+
type Options = Partial<OptionsResolved>;
|
|
5
|
+
declare const useLogOnce: (message: string, condition: boolean, options?: Options) => void;
|
|
7
6
|
|
|
8
7
|
export { useLogOnce };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
type
|
|
2
|
-
message: string;
|
|
3
|
-
condition: boolean;
|
|
1
|
+
type OptionsResolved = {
|
|
4
2
|
type?: 'info' | 'error' | 'warning';
|
|
5
3
|
};
|
|
6
|
-
|
|
4
|
+
type Options = Partial<OptionsResolved>;
|
|
5
|
+
declare const useLogOnce: (message: string, condition: boolean, options?: Options) => void;
|
|
7
6
|
|
|
8
7
|
export { useLogOnce };
|
package/dist/hooks/useLogOnce.js
CHANGED
|
@@ -23,12 +23,12 @@ __export(useLogOnce_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useLogOnce_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}) => {
|
|
26
|
+
var defaultOptions = {
|
|
27
|
+
type: "warning"
|
|
28
|
+
};
|
|
29
|
+
var useLogOnce = (message, condition, options) => {
|
|
31
30
|
const [hasLogged, setHasLogged] = (0, import_react.useState)(false);
|
|
31
|
+
const { type } = { ...defaultOptions, ...options };
|
|
32
32
|
(0, import_react.useEffect)(() => {
|
|
33
33
|
if (!hasLogged && condition) {
|
|
34
34
|
switch (type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useLogOnce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\ntype
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLogOnce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\ntype OptionsResolved = {\n type?: 'info' | 'error' | 'warning',\n}\n\nconst defaultOptions: OptionsResolved = {\n type: 'warning',\n}\n\ntype Options = Partial<OptionsResolved>\n\nexport const useLogOnce = (\n message: string,\n condition: boolean,\n options?: Options\n) => {\n const [hasLogged, setHasLogged] = useState<boolean>(false)\n const { type } = { ...defaultOptions, ...options }\n\n useEffect(() => {\n if (!hasLogged && condition) {\n switch (type) {\n case 'info':\n console.info(message)\n break\n case 'error':\n console.error(message)\n break\n case 'warning':\n console.warn(message)\n break\n }\n setHasLogged(true)\n }\n }, [condition]) // eslint-disable-line react-hooks/exhaustive-deps\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAMpC,IAAM,iBAAkC;AAAA,EACtC,MAAM;AACR;AAIO,IAAM,aAAa,CACxB,SACA,WACA,YACG;AACH,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAkB,KAAK;AACzD,QAAM,EAAE,KAAK,IAAI,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEjD,8BAAU,MAAM;AACd,QAAI,CAAC,aAAa,WAAW;AAC3B,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,kBAAQ,KAAK,OAAO;AACpB;AAAA,QACF,KAAK;AACH,kBAAQ,MAAM,OAAO;AACrB;AAAA,QACF,KAAK;AACH,kBAAQ,KAAK,OAAO;AACpB;AAAA,MACJ;AACA,mBAAa,IAAI;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAChB;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/hooks/useLogOnce.ts
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) => {
|
|
3
|
+
var defaultOptions = {
|
|
4
|
+
type: "warning"
|
|
5
|
+
};
|
|
6
|
+
var useLogOnce = (message, condition, options) => {
|
|
8
7
|
const [hasLogged, setHasLogged] = useState(false);
|
|
8
|
+
const { type } = { ...defaultOptions, ...options };
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
if (!hasLogged && condition) {
|
|
11
11
|
switch (type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useLogOnce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\ntype
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLogOnce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\ntype OptionsResolved = {\n type?: 'info' | 'error' | 'warning',\n}\n\nconst defaultOptions: OptionsResolved = {\n type: 'warning',\n}\n\ntype Options = Partial<OptionsResolved>\n\nexport const useLogOnce = (\n message: string,\n condition: boolean,\n options?: Options\n) => {\n const [hasLogged, setHasLogged] = useState<boolean>(false)\n const { type } = { ...defaultOptions, ...options }\n\n useEffect(() => {\n if (!hasLogged && condition) {\n switch (type) {\n case 'info':\n console.info(message)\n break\n case 'error':\n console.error(message)\n break\n case 'warning':\n console.warn(message)\n break\n }\n setHasLogged(true)\n }\n }, [condition]) // eslint-disable-line react-hooks/exhaustive-deps\n}"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AAMpC,IAAM,iBAAkC;AAAA,EACtC,MAAM;AACR;AAIO,IAAM,aAAa,CACxB,SACA,WACA,YACG;AACH,QAAM,CAAC,WAAW,YAAY,IAAI,SAAkB,KAAK;AACzD,QAAM,EAAE,KAAK,IAAI,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEjD,YAAU,MAAM;AACd,QAAI,CAAC,aAAa,WAAW;AAC3B,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,kBAAQ,KAAK,OAAO;AACpB;AAAA,QACF,KAAK;AACH,kBAAQ,MAAM,OAAO;AACrB;AAAA,QACF,KAAK;AACH,kBAAQ,KAAK,OAAO;AACpB;AAAA,MACJ;AACA,mBAAa,IAAI;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAChB;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
type UseSearchProps<T> = {
|
|
4
4
|
list: T[];
|
|
@@ -16,7 +16,7 @@ declare const useSearch: <T>({ list, initialSearch, searchMapping, additionalSea
|
|
|
16
16
|
allItems: T[];
|
|
17
17
|
updateSearch: (newSearch?: string) => void;
|
|
18
18
|
search: string;
|
|
19
|
-
setSearch:
|
|
19
|
+
setSearch: React.Dispatch<React.SetStateAction<string>>;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { type UseSearchProps, useSearch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
type UseSearchProps<T> = {
|
|
4
4
|
list: T[];
|
|
@@ -16,7 +16,7 @@ declare const useSearch: <T>({ list, initialSearch, searchMapping, additionalSea
|
|
|
16
16
|
allItems: T[];
|
|
17
17
|
updateSearch: (newSearch?: string) => void;
|
|
18
18
|
search: string;
|
|
19
|
-
setSearch:
|
|
19
|
+
setSearch: React.Dispatch<React.SetStateAction<string>>;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { type UseSearchProps, useSearch };
|
package/dist/hooks/useSearch.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(useSearch_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(useSearch_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/utils/simpleSearch.ts
|
|
28
28
|
var MultiSubjectSearchWithMapping = (search, objects, mapping) => {
|
|
29
29
|
return objects.filter((object) => {
|
|
30
30
|
const mappedSearchKeywords = mapping(object)?.map((value) => value.toLowerCase().trim());
|