@bspk/ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion.d.ts +20 -0
- package/Accordion.js +18 -0
- package/Accordion.js.map +1 -0
- package/Badge.d.ts +33 -0
- package/Badge.js +43 -0
- package/Badge.js.map +1 -0
- package/BannerAlert.d.ts +53 -0
- package/BannerAlert.js +133 -0
- package/BannerAlert.js.map +1 -0
- package/BottomNavigation.d.ts +20 -0
- package/BottomNavigation.js +18 -0
- package/BottomNavigation.js.map +1 -0
- package/BottomSheet.d.ts +20 -0
- package/BottomSheet.js +18 -0
- package/BottomSheet.js.map +1 -0
- package/Breadcrumb.d.ts +20 -0
- package/Breadcrumb.js +18 -0
- package/Breadcrumb.js.map +1 -0
- package/Button.d.ts +66 -0
- package/Button.js +254 -0
- package/Button.js.map +1 -0
- package/ButtonDock.d.ts +20 -0
- package/ButtonDock.js +18 -0
- package/ButtonDock.js.map +1 -0
- package/CODE_OF_CONDUCT.md +137 -0
- package/CONTRIBUTING.md +42 -0
- package/Card.d.ts +37 -0
- package/Card.js +38 -0
- package/Card.js.map +1 -0
- package/Chart.d.ts +20 -0
- package/Chart.js +18 -0
- package/Chart.js.map +1 -0
- package/Checkbox.d.ts +26 -0
- package/Checkbox.js +123 -0
- package/Checkbox.js.map +1 -0
- package/CheckboxGroup.d.ts +49 -0
- package/CheckboxGroup.js +18 -0
- package/CheckboxGroup.js.map +1 -0
- package/CheckboxOption.d.ts +14 -0
- package/CheckboxOption.js +16 -0
- package/CheckboxOption.js.map +1 -0
- package/Chip.d.ts +50 -0
- package/Chip.js +87 -0
- package/Chip.js.map +1 -0
- package/DatePicker.d.ts +20 -0
- package/DatePicker.js +18 -0
- package/DatePicker.js.map +1 -0
- package/Dialog.d.ts +46 -0
- package/Dialog.js +221 -0
- package/Dialog.js.map +1 -0
- package/Divider.d.ts +44 -0
- package/Divider.js +76 -0
- package/Divider.js.map +1 -0
- package/Drawer.d.ts +20 -0
- package/Drawer.js +18 -0
- package/Drawer.js.map +1 -0
- package/Dropdown.d.ts +50 -0
- package/Dropdown.js +153 -0
- package/Dropdown.js.map +1 -0
- package/DropdownField.d.ts +16 -0
- package/DropdownField.js +19 -0
- package/DropdownField.js.map +1 -0
- package/EmptyState.d.ts +35 -0
- package/EmptyState.js +20 -0
- package/EmptyState.js.map +1 -0
- package/Fab.d.ts +43 -0
- package/Fab.js +146 -0
- package/Fab.js.map +1 -0
- package/FileUpload.d.ts +20 -0
- package/FileUpload.js +18 -0
- package/FileUpload.js.map +1 -0
- package/FormField.d.ts +48 -0
- package/FormField.js +39 -0
- package/FormField.js.map +1 -0
- package/GUIDELINES.md +41 -0
- package/Image.d.ts +20 -0
- package/Image.js +18 -0
- package/Image.js.map +1 -0
- package/Img.d.ts +26 -0
- package/Img.js +20 -0
- package/Img.js.map +1 -0
- package/InlineAlert.d.ts +31 -0
- package/InlineAlert.js +73 -0
- package/InlineAlert.js.map +1 -0
- package/LICENSE +395 -0
- package/Layout.d.ts +48 -0
- package/Layout.js +24 -0
- package/Layout.js.map +1 -0
- package/Link.d.ts +38 -0
- package/Link.js +37 -0
- package/Link.js.map +1 -0
- package/ListItem.d.ts +68 -0
- package/ListItem.js +207 -0
- package/ListItem.js.map +1 -0
- package/Menu.d.ts +86 -0
- package/Menu.js +98 -0
- package/Menu.js.map +1 -0
- package/MenuButton.d.ts +16 -0
- package/MenuButton.js +30 -0
- package/MenuButton.js.map +1 -0
- package/Modal.d.ts +31 -0
- package/Modal.js +53 -0
- package/Modal.js.map +1 -0
- package/MultiSelection.d.ts +20 -0
- package/MultiSelection.js +18 -0
- package/MultiSelection.js.map +1 -0
- package/NavigationRail.d.ts +20 -0
- package/NavigationRail.js +18 -0
- package/NavigationRail.js.map +1 -0
- package/NumberField.d.ts +17 -0
- package/NumberField.js +20 -0
- package/NumberField.js.map +1 -0
- package/NumberInput.d.ts +34 -0
- package/NumberInput.js +188 -0
- package/NumberInput.js.map +1 -0
- package/OTPInput.d.ts +20 -0
- package/OTPInput.js +18 -0
- package/OTPInput.js.map +1 -0
- package/PageControl.d.ts +20 -0
- package/PageControl.js +18 -0
- package/PageControl.js.map +1 -0
- package/PasswordInput.d.ts +20 -0
- package/PasswordInput.js +18 -0
- package/PasswordInput.js.map +1 -0
- package/PhoneNumberInput.d.ts +20 -0
- package/PhoneNumberInput.js +18 -0
- package/PhoneNumberInput.js.map +1 -0
- package/Popover.d.ts +44 -0
- package/Popover.js +152 -0
- package/Popover.js.map +1 -0
- package/Portal.d.ts +24 -0
- package/Portal.js +23 -0
- package/Portal.js.map +1 -0
- package/Profile.d.ts +41 -0
- package/Profile.js +83 -0
- package/Profile.js.map +1 -0
- package/ProgressBar.d.ts +38 -0
- package/ProgressBar.js +64 -0
- package/ProgressBar.js.map +1 -0
- package/ProgressCircle.d.ts +31 -0
- package/ProgressCircle.js +82 -0
- package/ProgressCircle.js.map +1 -0
- package/ProgressionStepper.d.ts +66 -0
- package/ProgressionStepper.js +197 -0
- package/ProgressionStepper.js.map +1 -0
- package/ProgressionStepperBar.d.ts +31 -0
- package/ProgressionStepperBar.js +51 -0
- package/ProgressionStepperBar.js.map +1 -0
- package/README.md +13 -0
- package/Radio.d.ts +17 -0
- package/Radio.js +97 -0
- package/Radio.js.map +1 -0
- package/RadioGroup.d.ts +31 -0
- package/RadioGroup.js +18 -0
- package/RadioGroup.js.map +1 -0
- package/RadioOption.d.ts +14 -0
- package/RadioOption.js +16 -0
- package/RadioOption.js.map +1 -0
- package/Rating.d.ts +16 -0
- package/Rating.js +18 -0
- package/Rating.js.map +1 -0
- package/SearchBar.d.ts +26 -0
- package/SearchBar.js +49 -0
- package/SearchBar.js.map +1 -0
- package/SegmentedControl.d.ts +69 -0
- package/SegmentedControl.js +136 -0
- package/SegmentedControl.js.map +1 -0
- package/Skeleton.d.ts +28 -0
- package/Skeleton.js +57 -0
- package/Skeleton.js.map +1 -0
- package/SliderInput.d.ts +16 -0
- package/SliderInput.js +18 -0
- package/SliderInput.js.map +1 -0
- package/Snackbar.d.ts +16 -0
- package/Snackbar.js +18 -0
- package/Snackbar.js.map +1 -0
- package/StylesProviderAnywhere.d.ts +10 -0
- package/StylesProviderAnywhere.js +29 -0
- package/StylesProviderAnywhere.js.map +1 -0
- package/StylesProviderBetterHomesGardens.d.ts +10 -0
- package/StylesProviderBetterHomesGardens.js +29 -0
- package/StylesProviderBetterHomesGardens.js.map +1 -0
- package/StylesProviderCartus.d.ts +10 -0
- package/StylesProviderCartus.js +29 -0
- package/StylesProviderCartus.js.map +1 -0
- package/StylesProviderCentury21.d.ts +10 -0
- package/StylesProviderCentury21.js +29 -0
- package/StylesProviderCentury21.js.map +1 -0
- package/StylesProviderColdwellBanker.d.ts +10 -0
- package/StylesProviderColdwellBanker.js +29 -0
- package/StylesProviderColdwellBanker.js.map +1 -0
- package/StylesProviderCorcoran.d.ts +10 -0
- package/StylesProviderCorcoran.js +29 -0
- package/StylesProviderCorcoran.js.map +1 -0
- package/StylesProviderDenaliBoss.d.ts +10 -0
- package/StylesProviderDenaliBoss.js +29 -0
- package/StylesProviderDenaliBoss.js.map +1 -0
- package/StylesProviderEra.d.ts +10 -0
- package/StylesProviderEra.js +29 -0
- package/StylesProviderEra.js.map +1 -0
- package/StylesProviderSothebys.d.ts +10 -0
- package/StylesProviderSothebys.js +29 -0
- package/StylesProviderSothebys.js.map +1 -0
- package/Switch.d.ts +33 -0
- package/Switch.js +85 -0
- package/Switch.js.map +1 -0
- package/SwitchGroup.d.ts +35 -0
- package/SwitchGroup.js +18 -0
- package/SwitchGroup.js.map +1 -0
- package/SwitchOption.d.ts +14 -0
- package/SwitchOption.js +16 -0
- package/SwitchOption.js.map +1 -0
- package/TabGroup.d.ts +73 -0
- package/TabGroup.js +119 -0
- package/TabGroup.js.map +1 -0
- package/Table.d.ts +45 -0
- package/Table.js +66 -0
- package/Table.js.map +1 -0
- package/Tag.d.ts +56 -0
- package/Tag.js +77 -0
- package/Tag.js.map +1 -0
- package/TextField.d.ts +16 -0
- package/TextField.js +19 -0
- package/TextField.js.map +1 -0
- package/TextInput.d.ts +45 -0
- package/TextInput.js +172 -0
- package/TextInput.js.map +1 -0
- package/Textarea.d.ts +63 -0
- package/Textarea.js +113 -0
- package/Textarea.js.map +1 -0
- package/TextareaField.d.ts +16 -0
- package/TextareaField.js +26 -0
- package/TextareaField.js.map +1 -0
- package/TimePicker.d.ts +16 -0
- package/TimePicker.js +18 -0
- package/TimePicker.js.map +1 -0
- package/ToggleOption.d.ts +27 -0
- package/ToggleOption.js +91 -0
- package/ToggleOption.js.map +1 -0
- package/Tooltip.d.ts +39 -0
- package/Tooltip.js +104 -0
- package/Tooltip.js.map +1 -0
- package/TopNavigation.d.ts +16 -0
- package/TopNavigation.js +18 -0
- package/TopNavigation.js.map +1 -0
- package/Txt.d.ts +38 -0
- package/Txt.js +21 -0
- package/Txt.js.map +1 -0
- package/hooks/useCheckboxGroupState.d.ts +37 -0
- package/hooks/useCheckboxGroupState.js +61 -0
- package/hooks/useCheckboxGroupState.js.map +1 -0
- package/hooks/useCheckboxState.d.ts +23 -0
- package/hooks/useCheckboxState.js +40 -0
- package/hooks/useCheckboxState.js.map +1 -0
- package/hooks/useFloating.d.ts +38 -0
- package/hooks/useFloating.js +156 -0
- package/hooks/useFloating.js.map +1 -0
- package/hooks/useFloatingMenu.d.ts +35 -0
- package/hooks/useFloatingMenu.js +71 -0
- package/hooks/useFloatingMenu.js.map +1 -0
- package/hooks/useId.d.ts +8 -0
- package/hooks/useId.js +16 -0
- package/hooks/useId.js.map +1 -0
- package/hooks/useKeyboardNavigation.d.ts +35 -0
- package/hooks/useKeyboardNavigation.js +79 -0
- package/hooks/useKeyboardNavigation.js.map +1 -0
- package/hooks/useLongPress.d.ts +11 -0
- package/hooks/useLongPress.js +49 -0
- package/hooks/useLongPress.js.map +1 -0
- package/hooks/useModalState.d.ts +22 -0
- package/hooks/useModalState.js +37 -0
- package/hooks/useModalState.js.map +1 -0
- package/hooks/useNavOptions.d.ts +28 -0
- package/hooks/useNavOptions.js +46 -0
- package/hooks/useNavOptions.js.map +1 -0
- package/hooks/useOutsideClick.d.ts +31 -0
- package/hooks/useOutsideClick.js +50 -0
- package/hooks/useOutsideClick.js.map +1 -0
- package/hooks/useRadioState.d.ts +23 -0
- package/hooks/useRadioState.js +38 -0
- package/hooks/useRadioState.js.map +1 -0
- package/hooks/useSwitchGroupState.d.ts +37 -0
- package/hooks/useSwitchGroupState.js +60 -0
- package/hooks/useSwitchGroupState.js.map +1 -0
- package/hooks/useTimeout.d.ts +26 -0
- package/hooks/useTimeout.js +45 -0
- package/hooks/useTimeout.js.map +1 -0
- package/hooks/useValidChildren.d.ts +6 -0
- package/hooks/useValidChildren.js +33 -0
- package/hooks/useValidChildren.js.map +1 -0
- package/index.d.ts +125 -0
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/meta.d.ts +44 -0
- package/meta.js +5789 -0
- package/meta.js.map +1 -0
- package/package.json +73 -0
- package/src/Accordion.tsx +33 -0
- package/src/Badge.tsx +75 -0
- package/src/BannerAlert.tsx +211 -0
- package/src/BottomNavigation.tsx +33 -0
- package/src/BottomSheet.tsx +33 -0
- package/src/Breadcrumb.tsx +33 -0
- package/src/Button.tsx +358 -0
- package/src/ButtonDock.tsx +33 -0
- package/src/Card.tsx +66 -0
- package/src/Chart.tsx +33 -0
- package/src/Checkbox.tsx +174 -0
- package/src/CheckboxGroup.tsx +95 -0
- package/src/CheckboxOption.tsx +27 -0
- package/src/Chip.tsx +155 -0
- package/src/DatePicker.tsx +33 -0
- package/src/Dialog.tsx +304 -0
- package/src/Divider.tsx +129 -0
- package/src/Drawer.tsx +33 -0
- package/src/Dropdown.tsx +251 -0
- package/src/DropdownField.tsx +57 -0
- package/src/EmptyState.tsx +73 -0
- package/src/Fab.tsx +222 -0
- package/src/FileUpload.tsx +33 -0
- package/src/FormField.tsx +107 -0
- package/src/Image.tsx +33 -0
- package/src/Img.tsx +39 -0
- package/src/InlineAlert.tsx +119 -0
- package/src/Layout.tsx +82 -0
- package/src/Link.tsx +82 -0
- package/src/ListItem.tsx +316 -0
- package/src/Menu.tsx +263 -0
- package/src/MenuButton.tsx +45 -0
- package/src/Modal.tsx +104 -0
- package/src/MultiSelection.tsx +33 -0
- package/src/NavigationRail.tsx +33 -0
- package/src/NumberField.tsx +47 -0
- package/src/NumberInput.tsx +282 -0
- package/src/OTPInput.tsx +33 -0
- package/src/PageControl.tsx +33 -0
- package/src/PasswordInput.tsx +33 -0
- package/src/PhoneNumberInput.tsx +33 -0
- package/src/Popover.tsx +237 -0
- package/src/Portal.tsx +36 -0
- package/src/Profile.tsx +140 -0
- package/src/ProgressBar.tsx +110 -0
- package/src/ProgressCircle.tsx +153 -0
- package/src/ProgressionStepper.tsx +294 -0
- package/src/ProgressionStepperBar.tsx +95 -0
- package/src/Radio.tsx +119 -0
- package/src/RadioGroup.tsx +62 -0
- package/src/RadioOption.tsx +24 -0
- package/src/Rating.tsx +29 -0
- package/src/SearchBar.tsx +121 -0
- package/src/SegmentedControl.tsx +233 -0
- package/src/Skeleton.tsx +90 -0
- package/src/SliderInput.tsx +29 -0
- package/src/Snackbar.tsx +29 -0
- package/src/StylesProviderAnywhere.tsx +31 -0
- package/src/StylesProviderBetterHomesGardens.tsx +31 -0
- package/src/StylesProviderCartus.tsx +31 -0
- package/src/StylesProviderCentury21.tsx +31 -0
- package/src/StylesProviderColdwellBanker.tsx +31 -0
- package/src/StylesProviderCorcoran.tsx +31 -0
- package/src/StylesProviderDenaliBoss.tsx +31 -0
- package/src/StylesProviderEra.tsx +31 -0
- package/src/StylesProviderSothebys.tsx +31 -0
- package/src/Switch.tsx +122 -0
- package/src/SwitchGroup.tsx +60 -0
- package/src/SwitchOption.tsx +24 -0
- package/src/TabGroup.tsx +219 -0
- package/src/Table.tsx +126 -0
- package/src/Tag.tsx +149 -0
- package/src/TextField.tsx +61 -0
- package/src/TextInput.tsx +265 -0
- package/src/Textarea.tsx +205 -0
- package/src/TextareaField.tsx +67 -0
- package/src/TimePicker.tsx +29 -0
- package/src/ToggleOption.tsx +117 -0
- package/src/Tooltip.tsx +170 -0
- package/src/TopNavigation.tsx +29 -0
- package/src/Txt.tsx +69 -0
- package/src/hooks/useCheckboxGroupState.ts +79 -0
- package/src/hooks/useCheckboxState.ts +48 -0
- package/src/hooks/useFloating.ts +202 -0
- package/src/hooks/useFloatingMenu.ts +110 -0
- package/src/hooks/useId.ts +14 -0
- package/src/hooks/useKeyboardNavigation.ts +98 -0
- package/src/hooks/useLongPress.ts +53 -0
- package/src/hooks/useModalState.ts +37 -0
- package/src/hooks/useNavOptions.ts +76 -0
- package/src/hooks/useOutsideClick.ts +51 -0
- package/src/hooks/useRadioState.ts +42 -0
- package/src/hooks/useSwitchGroupState.ts +75 -0
- package/src/hooks/useTimeout.ts +45 -0
- package/src/hooks/useValidChildren.ts +54 -0
- package/src/index.ts +160 -0
- package/src/meta.ts +6238 -0
- package/src/package.json +3 -0
- package/src/styles/anywhere.css +1693 -0
- package/src/styles/anywhere.ts +1694 -0
- package/src/styles/base.css +160 -0
- package/src/styles/base.ts +161 -0
- package/src/styles/better-homes-gardens.css +1693 -0
- package/src/styles/better-homes-gardens.ts +1694 -0
- package/src/styles/cartus.css +1691 -0
- package/src/styles/cartus.ts +1692 -0
- package/src/styles/century-21.css +1689 -0
- package/src/styles/century-21.ts +1690 -0
- package/src/styles/coldwell-banker.css +1691 -0
- package/src/styles/coldwell-banker.ts +1692 -0
- package/src/styles/corcoran.css +1685 -0
- package/src/styles/corcoran.ts +1686 -0
- package/src/styles/denali-boss.css +1681 -0
- package/src/styles/denali-boss.ts +1682 -0
- package/src/styles/era.css +1685 -0
- package/src/styles/era.ts +1686 -0
- package/src/styles/sothebys.css +1677 -0
- package/src/styles/sothebys.ts +1678 -0
- package/src/utils/children.ts +80 -0
- package/src/utils/colorVariants.ts +74 -0
- package/src/utils/errors.tsx +104 -0
- package/src/utils/getValidNode.ts +7 -0
- package/src/utils/keyboard.ts +382 -0
- package/src/utils/placeholder.test.ts +7 -0
- package/src/utils/ref.ts +11 -0
- package/src/utils/scrollElementIntoView.ts +29 -0
- package/src/utils/srOnly.ts +14 -0
- package/src/utils/tryIntPsrse.ts +7 -0
- package/src/utils/txtVariants.ts +53 -0
- package/styles/anywhere.css +1693 -0
- package/styles/anywhere.d.ts +2 -0
- package/styles/anywhere.js +1697 -0
- package/styles/anywhere.js.map +1 -0
- package/styles/anywhere.ts +1694 -0
- package/styles/base.css +160 -0
- package/styles/base.d.ts +2 -0
- package/styles/base.js +164 -0
- package/styles/base.js.map +1 -0
- package/styles/base.ts +161 -0
- package/styles/better-homes-gardens.css +1693 -0
- package/styles/better-homes-gardens.d.ts +2 -0
- package/styles/better-homes-gardens.js +1697 -0
- package/styles/better-homes-gardens.js.map +1 -0
- package/styles/better-homes-gardens.ts +1694 -0
- package/styles/cartus.css +1691 -0
- package/styles/cartus.d.ts +2 -0
- package/styles/cartus.js +1695 -0
- package/styles/cartus.js.map +1 -0
- package/styles/cartus.ts +1692 -0
- package/styles/century-21.css +1689 -0
- package/styles/century-21.d.ts +2 -0
- package/styles/century-21.js +1693 -0
- package/styles/century-21.js.map +1 -0
- package/styles/century-21.ts +1690 -0
- package/styles/coldwell-banker.css +1691 -0
- package/styles/coldwell-banker.d.ts +2 -0
- package/styles/coldwell-banker.js +1695 -0
- package/styles/coldwell-banker.js.map +1 -0
- package/styles/coldwell-banker.ts +1692 -0
- package/styles/corcoran.css +1685 -0
- package/styles/corcoran.d.ts +2 -0
- package/styles/corcoran.js +1689 -0
- package/styles/corcoran.js.map +1 -0
- package/styles/corcoran.ts +1686 -0
- package/styles/denali-boss.css +1681 -0
- package/styles/denali-boss.d.ts +2 -0
- package/styles/denali-boss.js +1685 -0
- package/styles/denali-boss.js.map +1 -0
- package/styles/denali-boss.ts +1682 -0
- package/styles/era.css +1685 -0
- package/styles/era.d.ts +2 -0
- package/styles/era.js +1689 -0
- package/styles/era.js.map +1 -0
- package/styles/era.ts +1686 -0
- package/styles/sothebys.css +1677 -0
- package/styles/sothebys.d.ts +2 -0
- package/styles/sothebys.js +1681 -0
- package/styles/sothebys.js.map +1 -0
- package/styles/sothebys.ts +1678 -0
- package/utils/children.d.ts +29 -0
- package/utils/children.js +70 -0
- package/utils/children.js.map +1 -0
- package/utils/colorVariants.d.ts +5 -0
- package/utils/colorVariants.js +61 -0
- package/utils/colorVariants.js.map +1 -0
- package/utils/errors.d.ts +36 -0
- package/utils/errors.js +65 -0
- package/utils/errors.js.map +1 -0
- package/utils/getValidNode.d.ts +2 -0
- package/utils/getValidNode.js +9 -0
- package/utils/getValidNode.js.map +1 -0
- package/utils/keyboard.d.ts +4 -0
- package/utils/keyboard.js +140 -0
- package/utils/keyboard.js.map +1 -0
- package/utils/ref.d.ts +5 -0
- package/utils/ref.js +10 -0
- package/utils/ref.js.map +1 -0
- package/utils/scrollElementIntoView.d.ts +8 -0
- package/utils/scrollElementIntoView.js +30 -0
- package/utils/scrollElementIntoView.js.map +1 -0
- package/utils/srOnly.d.ts +14 -0
- package/utils/srOnly.js +15 -0
- package/utils/srOnly.js.map +1 -0
- package/utils/tryIntPsrse.d.ts +2 -0
- package/utils/tryIntPsrse.js +10 -0
- package/utils/tryIntPsrse.js.map +1 -0
- package/utils/txtVariants.d.ts +2 -0
- package/utils/txtVariants.js +30 -0
- package/utils/txtVariants.js.map +1 -0
package/src/Tooltip.tsx
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { cloneElement, ReactElement, useId, useMemo, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Portal } from './Portal';
|
|
5
|
+
import { Placement, useFloating } from './hooks/useFloating';
|
|
6
|
+
|
|
7
|
+
export type TooltipProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The placement of the tooltip.
|
|
10
|
+
*
|
|
11
|
+
* @default top
|
|
12
|
+
*/
|
|
13
|
+
placement?: Placement;
|
|
14
|
+
/** The tooltip content. */
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* A single element that will trigger the tooltip when hovered over.
|
|
18
|
+
*
|
|
19
|
+
* @type ReactElement
|
|
20
|
+
* @required
|
|
21
|
+
*/
|
|
22
|
+
children: ReactElement;
|
|
23
|
+
/** Determines if the tooltip is disabled. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Determines if the tooltip should hide the tail.
|
|
27
|
+
*
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
tail?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Brief message that provide additional guidance and helps users perform an action if needed.
|
|
35
|
+
*
|
|
36
|
+
* @name Tooltip
|
|
37
|
+
*/
|
|
38
|
+
function Tooltip({ placement = 'top', label, children, disabled = false, tail = true }: TooltipProps) {
|
|
39
|
+
const id = useId();
|
|
40
|
+
const [show, setShow] = useState(false);
|
|
41
|
+
|
|
42
|
+
const child = useMemo(
|
|
43
|
+
() =>
|
|
44
|
+
!disabled &&
|
|
45
|
+
children &&
|
|
46
|
+
cloneElement(children, {
|
|
47
|
+
onMouseOver: () => setShow(true),
|
|
48
|
+
onMouseLeave: () => setShow(false),
|
|
49
|
+
'aria-describedby': id,
|
|
50
|
+
}),
|
|
51
|
+
[children, disabled, id],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const arrowRef = useRef<HTMLElement | null>(null);
|
|
55
|
+
|
|
56
|
+
const { floatingStyles, middlewareData, elements } = useFloating({
|
|
57
|
+
placement: placement,
|
|
58
|
+
strategy: 'fixed',
|
|
59
|
+
offsetOptions: 8,
|
|
60
|
+
arrowRef,
|
|
61
|
+
hide: !show,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return disabled ? (
|
|
65
|
+
children
|
|
66
|
+
) : (
|
|
67
|
+
<>
|
|
68
|
+
{child}
|
|
69
|
+
{label && (
|
|
70
|
+
<Portal>
|
|
71
|
+
<div
|
|
72
|
+
css={style}
|
|
73
|
+
data-placement={middlewareData?.offset?.placement}
|
|
74
|
+
data-tooltip=""
|
|
75
|
+
id={id}
|
|
76
|
+
ref={(node) => {
|
|
77
|
+
elements.setFloating(node);
|
|
78
|
+
elements.setTrigger(document.querySelector<HTMLElement>(`[aria-describedby="${id}"]`));
|
|
79
|
+
}}
|
|
80
|
+
role="tooltip"
|
|
81
|
+
style={floatingStyles}
|
|
82
|
+
>
|
|
83
|
+
<span data-text>{label}</span>
|
|
84
|
+
{tail !== false && (
|
|
85
|
+
<span
|
|
86
|
+
aria-hidden
|
|
87
|
+
data-arrow
|
|
88
|
+
ref={(node) => {
|
|
89
|
+
arrowRef.current = node;
|
|
90
|
+
}}
|
|
91
|
+
style={{
|
|
92
|
+
left: `${middlewareData?.arrow?.x}px`,
|
|
93
|
+
top: `${middlewareData?.arrow?.y}px`,
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</Portal>
|
|
99
|
+
)}
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Tooltip.bspkName = 'Tooltip';
|
|
105
|
+
|
|
106
|
+
export { Tooltip };
|
|
107
|
+
|
|
108
|
+
export const style = css`
|
|
109
|
+
position: fixed;
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
z-index: var(--z-index-tooltip-popover);
|
|
112
|
+
|
|
113
|
+
[data-text] {
|
|
114
|
+
display: block;
|
|
115
|
+
z-index: 2;
|
|
116
|
+
position: relative;
|
|
117
|
+
background-color: var(--surface-neutral-inverse);
|
|
118
|
+
border-radius: var(--radius-small);
|
|
119
|
+
color: var(--foreground-neutral-on-inverse-surface);
|
|
120
|
+
box-shadow: var(--drop-shadow-float);
|
|
121
|
+
font: var(--labels-small);
|
|
122
|
+
padding: var(--spacing-sizing-01) var(--spacing-sizing-02);
|
|
123
|
+
border: none;
|
|
124
|
+
transition: opacity 0.2s ease-in-out;
|
|
125
|
+
width: max-content;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
--arrow-size: var(--spacing-sizing-01);
|
|
129
|
+
--arrow-offset: calc(var(--arrow-size) * -2);
|
|
130
|
+
|
|
131
|
+
[data-arrow] {
|
|
132
|
+
display: block;
|
|
133
|
+
z-index: 1;
|
|
134
|
+
position: absolute;
|
|
135
|
+
width: 0;
|
|
136
|
+
height: 0;
|
|
137
|
+
border-style: solid;
|
|
138
|
+
border-width: var(--arrow-size) var(--arrow-size) var(--arrow-size) var(--arrow-size);
|
|
139
|
+
border-color: transparent transparent transparent transparent;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&[data-placement^='bottom'] {
|
|
143
|
+
[data-arrow] {
|
|
144
|
+
top: var(--arrow-offset);
|
|
145
|
+
border-bottom-color: var(--surface-neutral-inverse);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&[data-placement^='top'] {
|
|
150
|
+
[data-arrow] {
|
|
151
|
+
border-top-color: var(--surface-neutral-inverse);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&[data-placement^='right'] {
|
|
156
|
+
[data-arrow] {
|
|
157
|
+
margin-left: var(--arrow-offset);
|
|
158
|
+
border-right-color: var(--surface-neutral-inverse);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&[data-placement^='left'] {
|
|
163
|
+
[data-arrow] {
|
|
164
|
+
right: var(--arrow-offset);
|
|
165
|
+
border-left-color: var(--surface-neutral-inverse);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
export type TopNavigationProps = {
|
|
4
|
+
/** The content of the top navigation. */
|
|
5
|
+
children: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Component description coming soon.
|
|
10
|
+
*
|
|
11
|
+
* @name TopNavigation
|
|
12
|
+
*/
|
|
13
|
+
function TopNavigation({ children }: TopNavigationProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div css={style} data-top-navigation>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
TopNavigation.bspkName = 'TopNavigation';
|
|
22
|
+
|
|
23
|
+
export { TopNavigation };
|
|
24
|
+
|
|
25
|
+
export const style = css`
|
|
26
|
+
display: flex;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Txt.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { ElementType } from 'react';
|
|
3
|
+
|
|
4
|
+
import { TxtVariant } from './utils/txtVariants';
|
|
5
|
+
|
|
6
|
+
import { ElementProps } from './';
|
|
7
|
+
|
|
8
|
+
export type TxtProps<As extends ElementType = 'span'> = {
|
|
9
|
+
/**
|
|
10
|
+
* The element type to render as.
|
|
11
|
+
*
|
|
12
|
+
* @default span
|
|
13
|
+
* @type ElementType
|
|
14
|
+
*/
|
|
15
|
+
as?: As;
|
|
16
|
+
/**
|
|
17
|
+
* The content to render.
|
|
18
|
+
*
|
|
19
|
+
* @type string
|
|
20
|
+
* @required
|
|
21
|
+
*/
|
|
22
|
+
children: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* The variant to use.
|
|
25
|
+
*
|
|
26
|
+
* @default body-base
|
|
27
|
+
*/
|
|
28
|
+
variant?: TxtVariant;
|
|
29
|
+
/** The id of the element. */
|
|
30
|
+
id?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A text component that applies the correct font styles based on the variant and size. variant
|
|
35
|
+
*
|
|
36
|
+
* @name Txt
|
|
37
|
+
*/
|
|
38
|
+
function Txt<As extends ElementType = 'span'>({
|
|
39
|
+
children,
|
|
40
|
+
as,
|
|
41
|
+
variant = 'body-base',
|
|
42
|
+
style: styleProp,
|
|
43
|
+
...containerProps
|
|
44
|
+
}: ElementProps<TxtProps<As>, As>) {
|
|
45
|
+
const content = children?.toString();
|
|
46
|
+
|
|
47
|
+
if (!content) return null;
|
|
48
|
+
|
|
49
|
+
const As: ElementType = as || 'span';
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<As
|
|
53
|
+
{...containerProps}
|
|
54
|
+
css={css`
|
|
55
|
+
font: var(--${variant});
|
|
56
|
+
`}
|
|
57
|
+
data-txt
|
|
58
|
+
style={styleProp}
|
|
59
|
+
>
|
|
60
|
+
{content}
|
|
61
|
+
</As>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Txt.bspkName = 'Txt';
|
|
66
|
+
|
|
67
|
+
export { Txt };
|
|
68
|
+
|
|
69
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CheckboxProps } from '../Checkbox';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A hook to manage the state of a group of checkboxes. Used alongside the CheckboxGroup component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { Checkbox } from "@bspk/ui/Checkbox";
|
|
10
|
+
* import { useCheckboxGroupState } from "@bspk/ui/hooks/useCheckboxGroupState";
|
|
11
|
+
*
|
|
12
|
+
* export function Example() {
|
|
13
|
+
* const allValues = ["Red", "Orange", "Yellow", "Green"];
|
|
14
|
+
*
|
|
15
|
+
* const { allCheckboxProps, checkboxProps, values } = useCheckboxGroupState(allValues, "fruits");
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <>
|
|
19
|
+
* <pre>Selected Values: {values.join(", ")}</pre>
|
|
20
|
+
* <Checkbox aria-label="All" {...allCheckboxProps} />
|
|
21
|
+
* {allValues.map((value) => (
|
|
22
|
+
* <Checkbox key={value} aria-label={value} {...checkboxProps(value)} />
|
|
23
|
+
* ))}
|
|
24
|
+
* </>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @param allValues - The values of the checkboxes.
|
|
29
|
+
* @param name - The name of the checkboxes.
|
|
30
|
+
* @param externalState - The externally managed state of the checkboxes.
|
|
31
|
+
* @returns Properties to pass to the checkbox, other helper functions, and the state of the checkbox.
|
|
32
|
+
*/
|
|
33
|
+
export function useCheckboxGroupState(
|
|
34
|
+
allValues: string[],
|
|
35
|
+
name: string,
|
|
36
|
+
externalState?: [values: string[], setValues: (next: string[]) => void],
|
|
37
|
+
) {
|
|
38
|
+
const localState = useState<string[]>([]);
|
|
39
|
+
const [values, setValues] = externalState || localState;
|
|
40
|
+
|
|
41
|
+
const toggleValue = useCallback(
|
|
42
|
+
(itemValue: string, checked: boolean) => {
|
|
43
|
+
setValues(
|
|
44
|
+
allValues.flatMap((value) => {
|
|
45
|
+
if (value === itemValue) return checked ? value : [];
|
|
46
|
+
return values.includes(value) ? value : [];
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
[allValues, setValues, values],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const checkboxProps = useCallback(
|
|
54
|
+
(value: string): Pick<CheckboxProps, 'checked' | 'name' | 'onChange' | 'value'> => ({
|
|
55
|
+
checked: values.includes(value),
|
|
56
|
+
name,
|
|
57
|
+
onChange: (checked) => toggleValue(value, checked),
|
|
58
|
+
value,
|
|
59
|
+
}),
|
|
60
|
+
[values, name, toggleValue],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const allCheckboxProps = useMemo((): Pick<
|
|
64
|
+
CheckboxProps,
|
|
65
|
+
'checked' | 'indeterminate' | 'name' | 'onChange' | 'value'
|
|
66
|
+
> => {
|
|
67
|
+
return {
|
|
68
|
+
checked: allValues.length === values.length,
|
|
69
|
+
indeterminate: values.length > 0 && values.length < allValues.length,
|
|
70
|
+
name,
|
|
71
|
+
onChange: () => setValues(allValues.length === values.length ? [] : allValues),
|
|
72
|
+
value: 'all',
|
|
73
|
+
};
|
|
74
|
+
}, [allValues, values.length, name, setValues]);
|
|
75
|
+
|
|
76
|
+
return { toggleValue, allCheckboxProps, checkboxProps, values, setValues };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CheckboxProps } from '../Checkbox';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A hook to manage the state of a single checkbox. Used alongside the Checkbox component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { Checkbox } from '@bspk/ui/Checkbox';
|
|
10
|
+
* import { useCheckboxState } from '@bspk/ui/hooks/useCheckboxState';
|
|
11
|
+
*
|
|
12
|
+
* export function Example() {
|
|
13
|
+
* const { checkboxProps } = useCheckboxState('fruits');
|
|
14
|
+
* return <Checkbox aria-label="cherry" {...checkboxProps('cherry')} />;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @param name - The name of the checkbox.
|
|
18
|
+
* @param externalState - The externally managed state of the checkbox.
|
|
19
|
+
* @returns Properties to pass to the checkbox and the state of the checkbox.
|
|
20
|
+
*/
|
|
21
|
+
export function useCheckboxState(
|
|
22
|
+
name: string,
|
|
23
|
+
externalState?: [value: string[] | undefined, onChange: (next: string[]) => void],
|
|
24
|
+
): {
|
|
25
|
+
checkboxProps: (value: string) => Pick<CheckboxProps, 'checked' | 'name' | 'onChange' | 'value'>;
|
|
26
|
+
value: string[] | undefined;
|
|
27
|
+
setValue: (next: string[]) => void;
|
|
28
|
+
} {
|
|
29
|
+
const localState = useState<string[]>();
|
|
30
|
+
const [value, setValue] = externalState || localState;
|
|
31
|
+
|
|
32
|
+
const checkboxProps = (checkboxValue: string): Pick<CheckboxProps, 'checked' | 'name' | 'onChange' | 'value'> => {
|
|
33
|
+
return {
|
|
34
|
+
name,
|
|
35
|
+
checked: value?.includes(checkboxValue),
|
|
36
|
+
value: checkboxValue,
|
|
37
|
+
onChange: (checked) => {
|
|
38
|
+
const next = (value || []).filter((v) => v !== checkboxValue);
|
|
39
|
+
if (checked) next.push(checkboxValue);
|
|
40
|
+
setValue(next);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return { checkboxProps, value, setValue };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to manage the positioning of a floating element relative to a reference element.
|
|
3
|
+
*
|
|
4
|
+
* @template ReferenceType - The type of the reference element, extending HTMLElement.
|
|
5
|
+
* @param {Object} params - The parameters for the hook.
|
|
6
|
+
* @param {Placement} params.placement - The preferred placement of the floating element.
|
|
7
|
+
* @param {React.MutableRefObject<HTMLElement | null>} [params.arrowRef] - A ref object for the arrow element.
|
|
8
|
+
* @param {Strategy} [params.strategy] - The positioning strategy ('absolute' or 'fixed').
|
|
9
|
+
* @param {OffsetOptions} [params.offsetOptions=0] - The offset options for the floating element. Default is `0`
|
|
10
|
+
* @param {boolean} [params.refWidth] - Whether to match the width of the floating element to the reference element.
|
|
11
|
+
* @param {boolean} [params.hide=false] - Whether to hide the floating element. Default is `false`
|
|
12
|
+
*/
|
|
13
|
+
import {
|
|
14
|
+
computePosition,
|
|
15
|
+
ComputePositionReturn,
|
|
16
|
+
Placement,
|
|
17
|
+
arrow,
|
|
18
|
+
Strategy,
|
|
19
|
+
offset,
|
|
20
|
+
flip,
|
|
21
|
+
autoUpdate,
|
|
22
|
+
MiddlewareData,
|
|
23
|
+
OffsetOptions,
|
|
24
|
+
size,
|
|
25
|
+
MiddlewareState,
|
|
26
|
+
} from '@floating-ui/dom';
|
|
27
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
28
|
+
|
|
29
|
+
import { useTimeout } from './useTimeout';
|
|
30
|
+
|
|
31
|
+
export type { Placement, Strategy };
|
|
32
|
+
|
|
33
|
+
const TRANSITION_DELAY = 250;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* @param param0
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export function useFloating<TriggerElementType extends HTMLElement>({
|
|
42
|
+
placement,
|
|
43
|
+
arrowRef,
|
|
44
|
+
strategy,
|
|
45
|
+
offsetOptions = 0,
|
|
46
|
+
refWidth,
|
|
47
|
+
hide = false,
|
|
48
|
+
}: {
|
|
49
|
+
placement: Placement;
|
|
50
|
+
arrowRef?: React.MutableRefObject<HTMLElement | null>;
|
|
51
|
+
strategy?: Strategy;
|
|
52
|
+
offsetOptions?: OffsetOptions;
|
|
53
|
+
refWidth?: boolean;
|
|
54
|
+
hide?: boolean;
|
|
55
|
+
}) {
|
|
56
|
+
const [floatingStyles, setFloatingStylesState] = useState<React.CSSProperties>({
|
|
57
|
+
opacity: 0,
|
|
58
|
+
pointerEvents: 'none',
|
|
59
|
+
display: 'none',
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const setFloatingStyles = (next: (prev: React.CSSProperties) => React.CSSProperties) => {
|
|
63
|
+
setFloatingStylesState((prev) => ({
|
|
64
|
+
transition: `opacity ${TRANSITION_DELAY}ms`,
|
|
65
|
+
...next(prev),
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const [middlewareData, setMiddlewareData] = useState<MiddlewareData>({});
|
|
70
|
+
|
|
71
|
+
const [triggerElement, setTriggerElement] = useState<TriggerElementType | null>(null);
|
|
72
|
+
|
|
73
|
+
const [floatingElement, setFloatingElement] = useState<HTMLElement | null>(null);
|
|
74
|
+
|
|
75
|
+
// const elements: {
|
|
76
|
+
// trigger: HTMLElement | null;
|
|
77
|
+
// floating: HTMLElement | null;
|
|
78
|
+
// setReference: (node: TriggerElementType | null) => void;
|
|
79
|
+
// setFloating: (node: HTMLElement | null) => void;
|
|
80
|
+
// } = {
|
|
81
|
+
// trigger: triggerElement,
|
|
82
|
+
// floating: floatingElement,
|
|
83
|
+
// setReference: setTriggerElement,
|
|
84
|
+
// setFloating: setFloatingElement,
|
|
85
|
+
// };
|
|
86
|
+
|
|
87
|
+
const computeDebounce = useTimeout();
|
|
88
|
+
const transitionDelay = useTimeout();
|
|
89
|
+
|
|
90
|
+
const compute = useCallback(() => {
|
|
91
|
+
computeDebounce.clear();
|
|
92
|
+
transitionDelay.clear();
|
|
93
|
+
|
|
94
|
+
// check if the reference or floating element is null
|
|
95
|
+
if (triggerElement === null || floatingElement === null) return;
|
|
96
|
+
|
|
97
|
+
if (hide) {
|
|
98
|
+
if (floatingElement?.style.top)
|
|
99
|
+
setFloatingStyles((prev) => ({
|
|
100
|
+
...prev,
|
|
101
|
+
display: undefined,
|
|
102
|
+
opacity: 0,
|
|
103
|
+
pointerEvents: 'none',
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
transitionDelay.set(() => {
|
|
107
|
+
setFloatingStyles((prev) => ({
|
|
108
|
+
...prev,
|
|
109
|
+
display: 'none',
|
|
110
|
+
}));
|
|
111
|
+
}, TRANSITION_DELAY);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// debounce the computePosition call
|
|
116
|
+
|
|
117
|
+
computeDebounce.set(() => {
|
|
118
|
+
// check again if the reference or floating element is null
|
|
119
|
+
if (hide || triggerElement === null || floatingElement === null) return;
|
|
120
|
+
|
|
121
|
+
computePosition(triggerElement, floatingElement, {
|
|
122
|
+
placement: placement,
|
|
123
|
+
strategy,
|
|
124
|
+
middleware: [
|
|
125
|
+
arrowRef?.current && arrow({ element: arrowRef.current, padding: 8 }),
|
|
126
|
+
offset(offsetOptions),
|
|
127
|
+
flip(),
|
|
128
|
+
refWidth &&
|
|
129
|
+
size({
|
|
130
|
+
apply({ rects, elements }: MiddlewareState) {
|
|
131
|
+
Object.assign(elements.floating.style, {
|
|
132
|
+
width: `${rects.reference.width}px`,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
],
|
|
137
|
+
}).then((value: ComputePositionReturn) => {
|
|
138
|
+
setFloatingStyles(() => ({
|
|
139
|
+
top: value.y,
|
|
140
|
+
left: value.x,
|
|
141
|
+
position: value.strategy,
|
|
142
|
+
opacity: 0,
|
|
143
|
+
pointerEvents: 'none',
|
|
144
|
+
display: undefined,
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
transitionDelay.set(() => {
|
|
148
|
+
setFloatingStyles((prev) => ({
|
|
149
|
+
...prev,
|
|
150
|
+
opacity: 1,
|
|
151
|
+
pointerEvents: 'auto',
|
|
152
|
+
display: undefined,
|
|
153
|
+
}));
|
|
154
|
+
}, 10);
|
|
155
|
+
|
|
156
|
+
setMiddlewareData(value.middlewareData);
|
|
157
|
+
});
|
|
158
|
+
}, 10);
|
|
159
|
+
}, [
|
|
160
|
+
computeDebounce,
|
|
161
|
+
transitionDelay,
|
|
162
|
+
triggerElement,
|
|
163
|
+
floatingElement,
|
|
164
|
+
hide,
|
|
165
|
+
placement,
|
|
166
|
+
strategy,
|
|
167
|
+
arrowRef,
|
|
168
|
+
offsetOptions,
|
|
169
|
+
refWidth,
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
compute();
|
|
174
|
+
return () => {
|
|
175
|
+
computeDebounce.clear();
|
|
176
|
+
transitionDelay.clear();
|
|
177
|
+
};
|
|
178
|
+
}, [compute, computeDebounce, hide, transitionDelay]);
|
|
179
|
+
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (hide || triggerElement === null || floatingElement === null) return;
|
|
182
|
+
|
|
183
|
+
const cleanup = autoUpdate(triggerElement, floatingElement, compute);
|
|
184
|
+
|
|
185
|
+
return () => {
|
|
186
|
+
cleanup();
|
|
187
|
+
};
|
|
188
|
+
}, [compute, hide, floatingElement, triggerElement]);
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
elements: {
|
|
192
|
+
trigger: triggerElement,
|
|
193
|
+
floating: floatingElement,
|
|
194
|
+
setTrigger: setTriggerElement,
|
|
195
|
+
setFloating: setFloatingElement,
|
|
196
|
+
},
|
|
197
|
+
floatingStyles,
|
|
198
|
+
middlewareData,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|