@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/Dialog.tsx
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { FocusTrap } from 'focus-trap-react';
|
|
3
|
+
import { ReactNode, Ref, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Portal } from './Portal';
|
|
6
|
+
import { useId } from './hooks/useId';
|
|
7
|
+
import { useOutsideClick } from './hooks/useOutsideClick';
|
|
8
|
+
|
|
9
|
+
import { CommonProps, ElementProps } from './';
|
|
10
|
+
|
|
11
|
+
export type DialogProps = CommonProps<'id'> & {
|
|
12
|
+
/** The content of the dialog. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** A ref to the dialog element. */
|
|
15
|
+
innerRef?: Ref<HTMLDivElement>;
|
|
16
|
+
/**
|
|
17
|
+
* If the dialog should appear.
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
open?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Function to call when the dialog is closed.
|
|
24
|
+
*
|
|
25
|
+
* @type () => void
|
|
26
|
+
* @required
|
|
27
|
+
*/
|
|
28
|
+
onClose: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* The placement of the dialog on the screen.
|
|
31
|
+
*
|
|
32
|
+
* @default center
|
|
33
|
+
*/
|
|
34
|
+
placement?: 'bottom' | 'center' | 'left' | 'right' | 'top';
|
|
35
|
+
/**
|
|
36
|
+
* Whether the dialog should have a scrim behind it.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
hideScrim?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Dialogs display important information that users need to acknowledge. They appear over the interface and block
|
|
45
|
+
* further interactions until an action is selected.
|
|
46
|
+
*
|
|
47
|
+
* @name Dialog
|
|
48
|
+
*/
|
|
49
|
+
function Dialog({
|
|
50
|
+
//
|
|
51
|
+
children,
|
|
52
|
+
innerRef,
|
|
53
|
+
onClose,
|
|
54
|
+
open,
|
|
55
|
+
placement = 'center',
|
|
56
|
+
hideScrim,
|
|
57
|
+
id: idProp,
|
|
58
|
+
...containerProps
|
|
59
|
+
}: ElementProps<DialogProps, 'div'>) {
|
|
60
|
+
const id = useId(idProp);
|
|
61
|
+
const boxRef = useRef<HTMLDivElement | null>(null);
|
|
62
|
+
const [visibility, setVisibilityState] = useState<'hidden' | 'hiding' | 'show' | 'showing'>(
|
|
63
|
+
open ? 'show' : 'hidden',
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const prevVisibility = useRef(visibility);
|
|
67
|
+
|
|
68
|
+
const setVisibility = useCallback((next: typeof visibility) => {
|
|
69
|
+
setVisibilityState((prev) => {
|
|
70
|
+
prevVisibility.current = prev;
|
|
71
|
+
return next;
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
const handleKeyDown = useCallback((e: KeyboardEvent) => e.key === 'Escape' && onClose(), [onClose]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (open) {
|
|
79
|
+
if (prevVisibility.current.startsWith('show')) return;
|
|
80
|
+
setVisibility('showing');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (prevVisibility.current.startsWith('hid')) return;
|
|
85
|
+
setVisibility('hiding');
|
|
86
|
+
}, [open, setVisibility]);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (prevVisibility.current === visibility) return;
|
|
90
|
+
|
|
91
|
+
if (visibility === 'showing') {
|
|
92
|
+
document.body.style.overflow = 'hidden';
|
|
93
|
+
setTimeout(() => setVisibility('show'), 10);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (visibility === 'hiding') {
|
|
97
|
+
document.body.style.overflow = '';
|
|
98
|
+
setTimeout(() => setVisibility('hidden'), 10);
|
|
99
|
+
}
|
|
100
|
+
}, [setVisibility, visibility]);
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (visibility.startsWith('hid')) return;
|
|
104
|
+
|
|
105
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
106
|
+
return () => {
|
|
107
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
108
|
+
};
|
|
109
|
+
}, [handleKeyDown, visibility]);
|
|
110
|
+
|
|
111
|
+
useOutsideClick([boxRef.current], onClose, !open);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
visibility !== 'hidden' && (
|
|
115
|
+
<Portal>
|
|
116
|
+
<div
|
|
117
|
+
{...containerProps}
|
|
118
|
+
css={style}
|
|
119
|
+
data-dialog-root=""
|
|
120
|
+
data-placement={placement}
|
|
121
|
+
data-visibility={visibility}
|
|
122
|
+
id={id}
|
|
123
|
+
ref={innerRef}
|
|
124
|
+
role="presentation"
|
|
125
|
+
>
|
|
126
|
+
{!hideScrim && <div aria-hidden="true" data-dialog-backdrop />}
|
|
127
|
+
<FocusTrap
|
|
128
|
+
focusTrapOptions={{
|
|
129
|
+
fallbackFocus: () => boxRef.current!,
|
|
130
|
+
clickOutsideDeactivates: true,
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
<div
|
|
134
|
+
data-dialog-box
|
|
135
|
+
ref={(node) => {
|
|
136
|
+
boxRef.current = node;
|
|
137
|
+
}}
|
|
138
|
+
tabIndex={-1}
|
|
139
|
+
>
|
|
140
|
+
{children}
|
|
141
|
+
</div>
|
|
142
|
+
</FocusTrap>
|
|
143
|
+
</div>
|
|
144
|
+
</Portal>
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
Dialog.bspkName = 'Dialog';
|
|
150
|
+
|
|
151
|
+
export { Dialog };
|
|
152
|
+
|
|
153
|
+
export const style = css`
|
|
154
|
+
position: fixed;
|
|
155
|
+
inset: 0;
|
|
156
|
+
z-index: var(--z-index-dialog);
|
|
157
|
+
|
|
158
|
+
[data-dialog-box] {
|
|
159
|
+
text-align: start;
|
|
160
|
+
position: relative;
|
|
161
|
+
border-radius: var(--radius-large);
|
|
162
|
+
box-shadow: var(--drop-shadow-float);
|
|
163
|
+
background: var(--surface-neutral-t1-base);
|
|
164
|
+
color: var(--foreground-neutral-on-surface);
|
|
165
|
+
max-height: calc(100vh - var(--spacing-sizing-24));
|
|
166
|
+
overflow: scroll;
|
|
167
|
+
z-index: 2;
|
|
168
|
+
|
|
169
|
+
> :first-of-type {
|
|
170
|
+
margin-top: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
> :last-child {
|
|
174
|
+
margin-bottom: 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// we make the width responsive to the viewport
|
|
178
|
+
@media (min-width: 640px) {
|
|
179
|
+
width: 90%;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@media (min-width: 768px) {
|
|
183
|
+
width: 80%;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media (min-width: 1024px) {
|
|
187
|
+
width: 60%;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@media (min-width: 1280px) {
|
|
191
|
+
width: 50%;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[data-dialog-backdrop] {
|
|
196
|
+
z-index: 1;
|
|
197
|
+
position: fixed;
|
|
198
|
+
inset: 0;
|
|
199
|
+
background-color: var(--background-scrim);
|
|
200
|
+
opacity: 0;
|
|
201
|
+
transition: opacity 0.3s;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&[data-visibility='show'] {
|
|
205
|
+
[data-dialog-backdrop] {
|
|
206
|
+
opacity: 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&[data-placement='center'] {
|
|
211
|
+
display: flex;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
align-items: center;
|
|
214
|
+
|
|
215
|
+
[data-dialog-box] {
|
|
216
|
+
transition: opacity 1s;
|
|
217
|
+
opacity: 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
&[data-visibility='show'] {
|
|
221
|
+
[data-dialog-box] {
|
|
222
|
+
opacity: 1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
&[data-placement='bottom'] {
|
|
228
|
+
[data-dialog-box] {
|
|
229
|
+
position: absolute;
|
|
230
|
+
border-bottom-left-radius: 0;
|
|
231
|
+
border-bottom-right-radius: 0;
|
|
232
|
+
width: 600px;
|
|
233
|
+
left: 50%;
|
|
234
|
+
transform: translateX(-50%);
|
|
235
|
+
bottom: -100vh;
|
|
236
|
+
transition: bottom 0.3s;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&[data-visibility='show'] {
|
|
240
|
+
[data-dialog-box] {
|
|
241
|
+
bottom: 0;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&[data-placement='top'] {
|
|
247
|
+
[data-dialog-box] {
|
|
248
|
+
position: absolute;
|
|
249
|
+
border-top-left-radius: 0;
|
|
250
|
+
border-top-right-radius: 0;
|
|
251
|
+
width: 600px;
|
|
252
|
+
left: 50%;
|
|
253
|
+
transform: translateX(-50%);
|
|
254
|
+
top: -100vh;
|
|
255
|
+
transition: top 0.3s;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&[data-visibility='show'] {
|
|
259
|
+
[data-dialog-box] {
|
|
260
|
+
top: 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&[data-placement='left'] {
|
|
266
|
+
[data-dialog-box] {
|
|
267
|
+
position: absolute;
|
|
268
|
+
max-height: unset;
|
|
269
|
+
width: 280px;
|
|
270
|
+
height: 100vh;
|
|
271
|
+
border-bottom-left-radius: 0;
|
|
272
|
+
border-top-left-radius: 0;
|
|
273
|
+
left: -100vw;
|
|
274
|
+
transition: left 0.3s;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&[data-visibility='show'] {
|
|
278
|
+
[data-dialog-box] {
|
|
279
|
+
left: 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
&[data-placement='right'] {
|
|
285
|
+
[data-dialog-box] {
|
|
286
|
+
position: absolute;
|
|
287
|
+
max-height: unset;
|
|
288
|
+
width: 280px;
|
|
289
|
+
height: 100vh;
|
|
290
|
+
border-bottom-right-radius: 0;
|
|
291
|
+
border-top-right-radius: 0;
|
|
292
|
+
right: -100vw;
|
|
293
|
+
transition: right 0.3s;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&[data-visibility='show'] {
|
|
297
|
+
[data-dialog-box] {
|
|
298
|
+
right: 0;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
|
|
304
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Divider.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
import { ElementProps } from './';
|
|
4
|
+
|
|
5
|
+
export type DividerProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The orientation of the divider.
|
|
8
|
+
*
|
|
9
|
+
* @default horizontal
|
|
10
|
+
*/
|
|
11
|
+
orientation?: 'horizontal' | 'vertical';
|
|
12
|
+
/**
|
|
13
|
+
* The thickness of the divider.
|
|
14
|
+
*
|
|
15
|
+
* @default light
|
|
16
|
+
*/
|
|
17
|
+
thickness?: 'heavy' | 'light';
|
|
18
|
+
/**
|
|
19
|
+
* If the divider padding is shown.
|
|
20
|
+
*
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
padding?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The inset (margin) of the divider. The value is a number between 0 and 12, which corresponds to the spacing
|
|
26
|
+
* sizing variables defined in the theme. The inset is applied to the left and right sides of the divider when the
|
|
27
|
+
* orientation is horizontal, and to the top and bottom when the orientation is vertical.
|
|
28
|
+
*
|
|
29
|
+
* @default 0
|
|
30
|
+
*/
|
|
31
|
+
inset?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const insetToVariable = (insetProp: number | string) => {
|
|
35
|
+
const inset = Number(insetProp);
|
|
36
|
+
if (inset === undefined || inset === null || inset < 1 || inset > 12) return '0px';
|
|
37
|
+
return `var(--spacing-sizing-${inset.toString().padStart(2, '0')})`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Horizontal thin lines that separates grouped content in a list or other containers with an optional section/group
|
|
42
|
+
* label.
|
|
43
|
+
*
|
|
44
|
+
* Vertical thin lines that separates grouped content or other visual elements within a container.
|
|
45
|
+
*
|
|
46
|
+
* @name Divider
|
|
47
|
+
*/
|
|
48
|
+
function Divider({
|
|
49
|
+
padding = true,
|
|
50
|
+
orientation = 'horizontal',
|
|
51
|
+
thickness = 'light',
|
|
52
|
+
inset = 0,
|
|
53
|
+
...props
|
|
54
|
+
}: ElementProps<DividerProps, 'div'>) {
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
{...props}
|
|
58
|
+
aria-orientation={orientation}
|
|
59
|
+
css={style}
|
|
60
|
+
data-divider
|
|
61
|
+
data-hide-padding={!padding || undefined}
|
|
62
|
+
data-orientation={orientation}
|
|
63
|
+
data-thickness={thickness}
|
|
64
|
+
role="separator"
|
|
65
|
+
style={
|
|
66
|
+
{
|
|
67
|
+
...props.style,
|
|
68
|
+
'--inset': insetToVariable(inset),
|
|
69
|
+
} as React.CSSProperties
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Divider.bspkName = 'Divider';
|
|
76
|
+
|
|
77
|
+
export { Divider };
|
|
78
|
+
|
|
79
|
+
export const style = css`
|
|
80
|
+
display: flex;
|
|
81
|
+
background-color: var(--stroke-neutral-low);
|
|
82
|
+
align-self: stretch;
|
|
83
|
+
justify-content: stretch;
|
|
84
|
+
margin: 0;
|
|
85
|
+
padding: 0;
|
|
86
|
+
align-content: stretch;
|
|
87
|
+
content: 'hello';
|
|
88
|
+
|
|
89
|
+
--length: calc(100% - var(--inset) * 2);
|
|
90
|
+
|
|
91
|
+
&, // default
|
|
92
|
+
&[data-thickness='light'] {
|
|
93
|
+
--line-thickness: 1px;
|
|
94
|
+
--padding: var(--spacing-sizing-02);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&[data-thickness='heavy'] {
|
|
98
|
+
--line-thickness: 2px;
|
|
99
|
+
--padding: var(--spacing-sizing-04);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&, // default
|
|
103
|
+
&[data-orientation='horizontal'] {
|
|
104
|
+
width: unset;
|
|
105
|
+
min-height: unset;
|
|
106
|
+
|
|
107
|
+
height: var(--line-thickness);
|
|
108
|
+
min-width: var(--length);
|
|
109
|
+
|
|
110
|
+
margin: var(--padding) var(--inset);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&[data-orientation='vertical'] {
|
|
114
|
+
height: unset;
|
|
115
|
+
min-width: unset;
|
|
116
|
+
|
|
117
|
+
width: var(--line-thickness);
|
|
118
|
+
min-height: var(--length);
|
|
119
|
+
|
|
120
|
+
margin: var(--inset) var(--padding);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&[data-hide-padding] {
|
|
124
|
+
//
|
|
125
|
+
--padding: 0;
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Drawer.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
export type DrawerProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The content of the drawer.
|
|
6
|
+
*
|
|
7
|
+
* @required
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Component description coming soon.
|
|
14
|
+
*
|
|
15
|
+
* @name Drawer
|
|
16
|
+
*/
|
|
17
|
+
function Drawer({ children }: DrawerProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div css={style} data-drawer>
|
|
20
|
+
{children}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Drawer.bspkName = 'Drawer';
|
|
26
|
+
|
|
27
|
+
export { Drawer };
|
|
28
|
+
|
|
29
|
+
export const style = css`
|
|
30
|
+
display: flex;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Dropdown.tsx
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { SvgChevronRight } from '@bspk/icons/ChevronRight';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
import { ListItem } from './ListItem';
|
|
5
|
+
import { Menu, MenuProps } from './Menu';
|
|
6
|
+
import { Portal } from './Portal';
|
|
7
|
+
import { Placement } from './hooks/useFloating';
|
|
8
|
+
import { useFloatingMenu } from './hooks/useFloatingMenu';
|
|
9
|
+
import { useId } from './hooks/useId';
|
|
10
|
+
|
|
11
|
+
import { CommonProps } from './';
|
|
12
|
+
|
|
13
|
+
export type DropdownOption = {
|
|
14
|
+
/** The value of the option. */
|
|
15
|
+
value: string;
|
|
16
|
+
/** The label of the option. This is the text that will be displayed on the option. */
|
|
17
|
+
label: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type DropdownProps<O extends DropdownOption = DropdownOption> = CommonProps<
|
|
21
|
+
'aria-label' | 'disabled' | 'id' | 'invalid' | 'name' | 'readOnly' | 'size'
|
|
22
|
+
> &
|
|
23
|
+
Pick<MenuProps<O>, 'isMulti' | 'itemCount' | 'onChange' | 'renderListItem'> & {
|
|
24
|
+
/**
|
|
25
|
+
* Array of options to display in the dropdown
|
|
26
|
+
*
|
|
27
|
+
* @type DropdownOption[]
|
|
28
|
+
* @required
|
|
29
|
+
*/
|
|
30
|
+
options: O[];
|
|
31
|
+
/**
|
|
32
|
+
* Array of selected values!
|
|
33
|
+
*
|
|
34
|
+
* @type Array<string>
|
|
35
|
+
*/
|
|
36
|
+
value?: Array<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Placeholder for the dropdown
|
|
39
|
+
*
|
|
40
|
+
* @default Select...
|
|
41
|
+
*/
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The placement of the dropdown menu. Will be ignored if the menu is too close to the edge of the screen.
|
|
45
|
+
*
|
|
46
|
+
* @default bottom
|
|
47
|
+
*/
|
|
48
|
+
placement?: Extract<Placement, 'bottom' | 'top'>;
|
|
49
|
+
/** The style of the dropdown. */
|
|
50
|
+
style?: React.CSSProperties;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A field element that allows users to select one option from a list of available choices. *
|
|
55
|
+
*
|
|
56
|
+
* @name Dropdown
|
|
57
|
+
*/
|
|
58
|
+
function Dropdown<O extends DropdownOption = DropdownOption>({
|
|
59
|
+
options = [],
|
|
60
|
+
value: selected,
|
|
61
|
+
onChange,
|
|
62
|
+
'aria-label': ariaLabel,
|
|
63
|
+
placeholder = 'Select...',
|
|
64
|
+
size = 'medium',
|
|
65
|
+
itemCount = 5,
|
|
66
|
+
disabled,
|
|
67
|
+
id: propId,
|
|
68
|
+
invalid,
|
|
69
|
+
readOnly,
|
|
70
|
+
placement = 'bottom',
|
|
71
|
+
name,
|
|
72
|
+
isMulti,
|
|
73
|
+
renderListItem,
|
|
74
|
+
style: styleProp,
|
|
75
|
+
}: DropdownProps<O>) {
|
|
76
|
+
const id = useId(propId);
|
|
77
|
+
|
|
78
|
+
const { triggerProps, menuProps, closeMenu } = useFloatingMenu({
|
|
79
|
+
placement,
|
|
80
|
+
triggerProps: {
|
|
81
|
+
disabled,
|
|
82
|
+
invalid,
|
|
83
|
+
readOnly,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const dropdownLabel = isMulti
|
|
88
|
+
? `${selected?.length || 0} option${selected?.length !== 1 ? 's' : ''} selected`
|
|
89
|
+
: options.find((o) => o.value === selected?.[0])?.label;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<input defaultValue={selected} name={name} type="hidden" />
|
|
94
|
+
<button
|
|
95
|
+
aria-label={ariaLabel}
|
|
96
|
+
css={style}
|
|
97
|
+
data-dropdown=""
|
|
98
|
+
data-empty={dropdownLabel ? undefined : ''}
|
|
99
|
+
data-invalid={invalid || undefined}
|
|
100
|
+
data-size={size}
|
|
101
|
+
disabled={disabled || readOnly}
|
|
102
|
+
id={id}
|
|
103
|
+
style={styleProp}
|
|
104
|
+
{...triggerProps}
|
|
105
|
+
>
|
|
106
|
+
<ListItem data-placeholder="" label={dropdownLabel || placeholder} readOnly />
|
|
107
|
+
<span data-svg>
|
|
108
|
+
<SvgChevronRight />
|
|
109
|
+
</span>
|
|
110
|
+
</button>
|
|
111
|
+
<Portal>
|
|
112
|
+
<Menu
|
|
113
|
+
data-floating
|
|
114
|
+
isMulti={isMulti}
|
|
115
|
+
itemCount={itemCount}
|
|
116
|
+
items={options}
|
|
117
|
+
onChange={(selectedValues, event) => {
|
|
118
|
+
event?.preventDefault();
|
|
119
|
+
if (!isMulti) closeMenu();
|
|
120
|
+
onChange?.(selectedValues);
|
|
121
|
+
}}
|
|
122
|
+
renderListItem={renderListItem}
|
|
123
|
+
selectedValues={selected}
|
|
124
|
+
{...menuProps}
|
|
125
|
+
/>
|
|
126
|
+
</Portal>
|
|
127
|
+
</>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
Dropdown.bspkName = 'Dropdown';
|
|
132
|
+
|
|
133
|
+
export { Dropdown };
|
|
134
|
+
|
|
135
|
+
export const style = css`
|
|
136
|
+
// default -- size medium not disabled or readonly
|
|
137
|
+
--dropdown-background: var(--surface-neutral-t1-base);
|
|
138
|
+
--dropdown-border-color: var(--stroke-neutral-base);
|
|
139
|
+
--dropdown-text-color: var(--foreground-neutral-on-surface);
|
|
140
|
+
--dropdown-height: var(--spacing-sizing-10);
|
|
141
|
+
--dropdown-font: var(--body-base);
|
|
142
|
+
--dropdown-clear-height: var(--spacing-sizing-05);
|
|
143
|
+
--dropdown-padding: var(--spacing-sizing-03);
|
|
144
|
+
--dropdown-icon-width: var(--spacing-sizing-05);
|
|
145
|
+
|
|
146
|
+
position: relative;
|
|
147
|
+
width: 100%;
|
|
148
|
+
max-width: 280px;
|
|
149
|
+
outline: unset;
|
|
150
|
+
min-height: var(--dropdown-height);
|
|
151
|
+
max-height: var(--dropdown-height);
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: row;
|
|
154
|
+
gap: var(--spacing-sizing-02);
|
|
155
|
+
flex-grow: 0;
|
|
156
|
+
flex-shrink: 0;
|
|
157
|
+
text-align: left;
|
|
158
|
+
font: var(--dropdown-font);
|
|
159
|
+
border: 1px solid var(--dropdown-border-color);
|
|
160
|
+
border-radius: var(--radius-small);
|
|
161
|
+
background: var(--dropdown-background);
|
|
162
|
+
padding: 0 var(--dropdown-padding);
|
|
163
|
+
|
|
164
|
+
[data-placeholder] {
|
|
165
|
+
display: block;
|
|
166
|
+
max-width: 100%;
|
|
167
|
+
text-overflow: ellipsis;
|
|
168
|
+
overflow: hidden;
|
|
169
|
+
padding: 0;
|
|
170
|
+
|
|
171
|
+
[data-inner] {
|
|
172
|
+
min-height: auto;
|
|
173
|
+
padding: 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[data-item-label] [data-text] {
|
|
177
|
+
color: var(--dropdown-text-color);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[data-svg] {
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
justify-content: center;
|
|
185
|
+
svg {
|
|
186
|
+
transform: rotate(90deg);
|
|
187
|
+
width: var(--dropdown-icon-width);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// &[data-size='medium'] {
|
|
192
|
+
& {
|
|
193
|
+
[data-svg] svg {
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&[data-size='small'] {
|
|
198
|
+
--dropdown-height: var(--spacing-sizing-08);
|
|
199
|
+
--dropdown-font: var(--body-small);
|
|
200
|
+
--dropdown-clear-height: var(--spacing-sizing-05);
|
|
201
|
+
--dropdown-padding: var(--spacing-sizing-02);
|
|
202
|
+
--dropdown-icon-width: var(--spacing-sizing-05);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&[data-size='large'] {
|
|
206
|
+
--dropdown-height: var(--spacing-sizing-12);
|
|
207
|
+
--dropdown-font: var(--body-large);
|
|
208
|
+
--dropdown-clear-height: var(--spacing-sizing-06);
|
|
209
|
+
--dropdown-icon-width: var(--spacing-sizing-06);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&:disabled {
|
|
213
|
+
--dropdown-text-color: var(--foreground-neutral-disabled-on-surface);
|
|
214
|
+
--dropdown-border-color: var(--stroke-neutral-disabled-light);
|
|
215
|
+
--dropdown-background:
|
|
216
|
+
linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
|
|
217
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
218
|
+
|
|
219
|
+
&[aria-readonly]:not([data-empty]) {
|
|
220
|
+
--dropdown-text-color: var(--foreground-neutral-on-surface);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&:not(:disabled) {
|
|
225
|
+
&:focus {
|
|
226
|
+
--dropdown-border-color: var(--stroke-brand-primary);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&:hover {
|
|
230
|
+
--dropdown-background:
|
|
231
|
+
linear-gradient(var(--interactions-neutral-hover-opacity), var(--interactions-neutral-hover-opacity)),
|
|
232
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&:active {
|
|
236
|
+
--dropdown-background:
|
|
237
|
+
linear-gradient(var(--interactions-neutral-press-opacity), var(--interactions-neutral-press-opacity)),
|
|
238
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&[data-invalid] {
|
|
243
|
+
--dropdown-border-color: var(--status-error);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&[data-empty] {
|
|
247
|
+
--dropdown-text-color: var(--foreground-neutral-on-surface-variant-03);
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|