@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/Menu.tsx
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { ComponentProps, CSSProperties, MouseEvent as ReactMouseEvent, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Checkbox } from './Checkbox';
|
|
5
|
+
import { ListItem } from './ListItem';
|
|
6
|
+
import { Txt } from './Txt';
|
|
7
|
+
import { useId } from './hooks/useId';
|
|
8
|
+
|
|
9
|
+
import { CommonProps, ElementProps } from './';
|
|
10
|
+
|
|
11
|
+
export const MIN_ITEM_COUNT = 3;
|
|
12
|
+
export const MAX_ITEM_COUNT = 10;
|
|
13
|
+
|
|
14
|
+
export function menuItemId(menuId: string, index: number) {
|
|
15
|
+
return `menu-${menuId}-item-${index}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The props for the renderListItem function. Useful for customizing menu list items. */
|
|
19
|
+
export type RenderListItemParams<M extends MenuItem> = Pick<
|
|
20
|
+
MenuProps<M>,
|
|
21
|
+
'activeIndex' | 'isMulti' | 'selectedValues'
|
|
22
|
+
> & {
|
|
23
|
+
index: number;
|
|
24
|
+
item: M;
|
|
25
|
+
menuId: string;
|
|
26
|
+
selected: boolean;
|
|
27
|
+
itemId?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The props for the menu items. */
|
|
31
|
+
export type MenuItem = CommonProps<'disabled'> & {
|
|
32
|
+
/** The content to display in the menu item. */
|
|
33
|
+
label: string;
|
|
34
|
+
/** The value of the menu item. */
|
|
35
|
+
value: string;
|
|
36
|
+
/** The unique id of the menu item. */
|
|
37
|
+
id?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type MenuProps<Item extends MenuItem = MenuItem> = CommonProps<'disabled' | 'id'> & {
|
|
41
|
+
/**
|
|
42
|
+
* The number of items to display in the menu
|
|
43
|
+
*
|
|
44
|
+
* @default 5
|
|
45
|
+
* @minimum 3
|
|
46
|
+
* @maximum 10
|
|
47
|
+
*/
|
|
48
|
+
itemCount?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Content to display in the menu.
|
|
51
|
+
*
|
|
52
|
+
* @type MenuItems
|
|
53
|
+
*/
|
|
54
|
+
items?: Item[];
|
|
55
|
+
/** A ref to the inner div element. */
|
|
56
|
+
innerRef?: (node: HTMLElement | null) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Message to display when no results are found
|
|
59
|
+
*
|
|
60
|
+
* @type multiline
|
|
61
|
+
*/
|
|
62
|
+
noResultsMessage?: string;
|
|
63
|
+
/** The index of the currently highlighted item. */
|
|
64
|
+
activeIndex?: number;
|
|
65
|
+
/** The values of the selected items */
|
|
66
|
+
selectedValues?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* A function which given data about the list item returns additional list item props used to render the list items.
|
|
69
|
+
*
|
|
70
|
+
* @type (props: RenderListItemParams) => ComponentProps<typeof ListItem>;
|
|
71
|
+
* @param {RenderListItemParams} props
|
|
72
|
+
* @returns {ComponentProps<typeof ListItem>}
|
|
73
|
+
*/
|
|
74
|
+
renderListItem?: (props: RenderListItemParams<Item>) => Partial<ComponentProps<typeof ListItem>>;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the menu allows multiple selections.
|
|
77
|
+
*
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
isMulti?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The function to call when the selected values change.
|
|
83
|
+
*
|
|
84
|
+
* @type (selectedValues: String[], event: ChangeEvent) => void
|
|
85
|
+
* @param {string[]} selectedValues
|
|
86
|
+
* @param {ChangeEvent} event
|
|
87
|
+
* @returns {void}
|
|
88
|
+
*/
|
|
89
|
+
onChange?: (selectedValues: string[], event?: ReactMouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A container housing a simple list of options presented to the user to select one option at a time.
|
|
94
|
+
*
|
|
95
|
+
* @name Menu
|
|
96
|
+
*/
|
|
97
|
+
function Menu<Item extends MenuItem = MenuItem>({
|
|
98
|
+
itemCount: itemCountProp = 5,
|
|
99
|
+
items: itemsProp = [],
|
|
100
|
+
noResultsMessage,
|
|
101
|
+
innerRef,
|
|
102
|
+
onChange,
|
|
103
|
+
activeIndex,
|
|
104
|
+
selectedValues = [],
|
|
105
|
+
disabled,
|
|
106
|
+
id: idProp,
|
|
107
|
+
renderListItem,
|
|
108
|
+
isMulti,
|
|
109
|
+
...props
|
|
110
|
+
}: ElementProps<MenuProps<Item>, 'div'>) {
|
|
111
|
+
const menuId = useId(idProp);
|
|
112
|
+
const items = Array.isArray(itemsProp) ? itemsProp : [];
|
|
113
|
+
const itemCount = useMemo(
|
|
114
|
+
() =>
|
|
115
|
+
// Ensure itemCount is within the range of items.length
|
|
116
|
+
Math.min(
|
|
117
|
+
items.length,
|
|
118
|
+
// pin itemCountProp to a range of 3 to 10
|
|
119
|
+
Math.max(MIN_ITEM_COUNT, Math.min(itemCountProp, MAX_ITEM_COUNT)),
|
|
120
|
+
),
|
|
121
|
+
[itemCountProp, items.length],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
|
+
{...props}
|
|
127
|
+
css={style}
|
|
128
|
+
data-disabled={disabled || undefined}
|
|
129
|
+
data-item-count={itemCount || undefined}
|
|
130
|
+
data-menu=""
|
|
131
|
+
data-no-items={!items.length || undefined}
|
|
132
|
+
id={menuId}
|
|
133
|
+
ref={innerRef}
|
|
134
|
+
role="listbox"
|
|
135
|
+
style={{ ...props.style, '--item-count': itemCount } as CSSProperties}
|
|
136
|
+
>
|
|
137
|
+
{items.length ? (
|
|
138
|
+
items.map((item, index) => {
|
|
139
|
+
const itemId = item.id || menuItemId(menuId, index);
|
|
140
|
+
|
|
141
|
+
const selected = Array.isArray(selectedValues) && selectedValues.includes(item.value);
|
|
142
|
+
|
|
143
|
+
const renderProps = renderListItem?.({
|
|
144
|
+
activeIndex,
|
|
145
|
+
index,
|
|
146
|
+
item,
|
|
147
|
+
selectedValues,
|
|
148
|
+
isMulti,
|
|
149
|
+
menuId: menuId || '',
|
|
150
|
+
selected,
|
|
151
|
+
itemId,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<ListItem
|
|
156
|
+
{...renderProps}
|
|
157
|
+
active={activeIndex === index || undefined}
|
|
158
|
+
aria-disabled={item.disabled || undefined}
|
|
159
|
+
aria-posinset={index + 1}
|
|
160
|
+
aria-selected={selected || undefined}
|
|
161
|
+
as="button"
|
|
162
|
+
data-menu-item
|
|
163
|
+
data-selected={selected || undefined}
|
|
164
|
+
disabled={item.disabled || undefined}
|
|
165
|
+
id={itemId}
|
|
166
|
+
key={itemId}
|
|
167
|
+
label={renderProps?.label?.toString() || item.label?.toString()}
|
|
168
|
+
onClick={(event) => {
|
|
169
|
+
if (renderProps) renderProps?.onClick?.(event);
|
|
170
|
+
|
|
171
|
+
if (onChange) {
|
|
172
|
+
if (!isMulti) {
|
|
173
|
+
onChange?.([item.value], event);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
onChange(
|
|
177
|
+
selected
|
|
178
|
+
? selectedValues.filter((value) => value !== item.value)
|
|
179
|
+
: [...selectedValues, item.value],
|
|
180
|
+
event,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}}
|
|
184
|
+
role="option"
|
|
185
|
+
tabIndex={-1}
|
|
186
|
+
trailing={
|
|
187
|
+
isMulti ? (
|
|
188
|
+
<Checkbox
|
|
189
|
+
aria-label={item.label}
|
|
190
|
+
checked={selected}
|
|
191
|
+
name={item.value}
|
|
192
|
+
onChange={(checked) => {
|
|
193
|
+
onChange?.(
|
|
194
|
+
checked
|
|
195
|
+
? selectedValues.filter((value) => value !== item.value)
|
|
196
|
+
: [...selectedValues, item.value],
|
|
197
|
+
);
|
|
198
|
+
}}
|
|
199
|
+
value={item.value}
|
|
200
|
+
/>
|
|
201
|
+
) : (
|
|
202
|
+
renderProps?.trailing
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
206
|
+
);
|
|
207
|
+
})
|
|
208
|
+
) : (
|
|
209
|
+
<>
|
|
210
|
+
<Txt as="div" variant="heading-h5">
|
|
211
|
+
No results found
|
|
212
|
+
</Txt>
|
|
213
|
+
<Txt as="div" variant="body-base">
|
|
214
|
+
{noResultsMessage}
|
|
215
|
+
</Txt>
|
|
216
|
+
</>
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
Menu.bspkName = 'Menu';
|
|
223
|
+
|
|
224
|
+
export { Menu };
|
|
225
|
+
|
|
226
|
+
export const style = css`
|
|
227
|
+
/**
|
|
228
|
+
--item-count is set via inline style. :)
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
width: 332px;
|
|
232
|
+
border: 1px solid var(--stroke-neutral-low);
|
|
233
|
+
background-color: var(--surface-neutral-t1-base);
|
|
234
|
+
box-shadow: var(--drop-shadow-float);
|
|
235
|
+
border-radius: var(--radius-large);
|
|
236
|
+
display: flex;
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
|
|
239
|
+
--item-size: var(--spacing-sizing-12);
|
|
240
|
+
|
|
241
|
+
&[data-floating] {
|
|
242
|
+
z-index: var(--z-index-dropdown);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&[data-item-count] {
|
|
246
|
+
height: calc(var(--item-count) * var(--item-size));
|
|
247
|
+
overflow-y: scroll;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&[data-no-items] {
|
|
251
|
+
padding: var(--spacing-sizing-08) var(--spacing-sizing-04);
|
|
252
|
+
align-items: center;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
gap: var(--spacing-sizing-03);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
[data-list-item] {
|
|
258
|
+
min-height: var(--item-size);
|
|
259
|
+
height: var(--item-size);
|
|
260
|
+
}
|
|
261
|
+
`;
|
|
262
|
+
|
|
263
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SvgMenu } from '@bspk/icons/Menu';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { ElementType } from 'react';
|
|
4
|
+
|
|
5
|
+
import { ButtonProps } from './Button';
|
|
6
|
+
|
|
7
|
+
import { ElementProps } from '.';
|
|
8
|
+
|
|
9
|
+
export type MenuButtonProps<As extends ElementType> = Pick<ButtonProps<As>, 'as' | 'onClick'>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utility component used within top navigation.
|
|
13
|
+
*
|
|
14
|
+
* @name MenuButton
|
|
15
|
+
*/
|
|
16
|
+
function MenuButton<As extends ElementType = 'button'>({ as, ...props }: ElementProps<MenuButtonProps<As>, As>) {
|
|
17
|
+
const As: ElementType = as || 'div';
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<button {...props} css={style}>
|
|
21
|
+
<SvgMenu />
|
|
22
|
+
</button>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
MenuButton.bspkName = 'MenuButton';
|
|
27
|
+
|
|
28
|
+
export { MenuButton };
|
|
29
|
+
|
|
30
|
+
export const style = css`
|
|
31
|
+
background: none;
|
|
32
|
+
border: none;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
padding: 0;
|
|
35
|
+
height: 48px;
|
|
36
|
+
width: auto;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
padding-top: var(--spacing-sizing-01);
|
|
42
|
+
color: var(--foreground-neutral-on-surface-variant-01);
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Modal.tsx
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { SvgClose } from '@bspk/icons/Close';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Button } from './Button';
|
|
6
|
+
import { Dialog, DialogProps } from './Dialog';
|
|
7
|
+
import { Txt } from './Txt';
|
|
8
|
+
import { useId } from './hooks/useId';
|
|
9
|
+
import { srOnly } from './utils/srOnly';
|
|
10
|
+
|
|
11
|
+
export type ModalProps = DialogProps & {
|
|
12
|
+
/**
|
|
13
|
+
* Modal header.
|
|
14
|
+
*
|
|
15
|
+
* @required
|
|
16
|
+
*/
|
|
17
|
+
header: string;
|
|
18
|
+
/**
|
|
19
|
+
* Modal description.
|
|
20
|
+
*
|
|
21
|
+
* @required
|
|
22
|
+
*/
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Modals display important information that users need to acknowledge. They appear over the interface and block further
|
|
28
|
+
* interactions until an action is selected. Modal is a wrapper around the Dialog component that provides a header and
|
|
29
|
+
* footer for the dialog.
|
|
30
|
+
*
|
|
31
|
+
* TODO: Add support for custom header and footer
|
|
32
|
+
*
|
|
33
|
+
* @name Modal
|
|
34
|
+
*/
|
|
35
|
+
function Modal({
|
|
36
|
+
//
|
|
37
|
+
header,
|
|
38
|
+
description,
|
|
39
|
+
children,
|
|
40
|
+
id: idProp,
|
|
41
|
+
...dialogProps
|
|
42
|
+
}: ModalProps) {
|
|
43
|
+
const id = useId(idProp);
|
|
44
|
+
|
|
45
|
+
const ids = useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
description: `dialog-dialog-${id}-description`,
|
|
48
|
+
title: `dialog-dialog-${id}-title`,
|
|
49
|
+
}),
|
|
50
|
+
[id],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Dialog {...dialogProps} aria-describedby={ids.description} aria-labelledby={ids.title}>
|
|
55
|
+
<div css={style} data-modal-body>
|
|
56
|
+
<header>
|
|
57
|
+
<Txt as="div" data-dialog-title id={ids.title} variant="heading-h4">
|
|
58
|
+
{header}
|
|
59
|
+
</Txt>
|
|
60
|
+
<Button
|
|
61
|
+
icon={<SvgClose />}
|
|
62
|
+
label="close"
|
|
63
|
+
onClick={dialogProps.onClose}
|
|
64
|
+
showLabel={false}
|
|
65
|
+
variant="tertiary"
|
|
66
|
+
/>
|
|
67
|
+
</header>
|
|
68
|
+
<main>
|
|
69
|
+
<p {...srOnly(children)} data-dialog-description id={ids.description}>
|
|
70
|
+
{description}
|
|
71
|
+
</p>
|
|
72
|
+
{children}
|
|
73
|
+
</main>
|
|
74
|
+
</div>
|
|
75
|
+
</Dialog>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Modal.bspkName = 'Modal';
|
|
80
|
+
|
|
81
|
+
export { Modal };
|
|
82
|
+
|
|
83
|
+
export const style = css`
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
gap: var(--spacing-sizing-02);
|
|
88
|
+
padding: var(--spacing-sizing-04);
|
|
89
|
+
|
|
90
|
+
> header {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: row;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: var(--spacing-sizing-04);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
main {
|
|
99
|
+
overflow: auto;
|
|
100
|
+
flex: 1;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
export type MultiSelectionProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The content of the multi selection.
|
|
6
|
+
*
|
|
7
|
+
* @required
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Component description coming soon.
|
|
14
|
+
*
|
|
15
|
+
* @name MultiSelection
|
|
16
|
+
*/
|
|
17
|
+
function MultiSelection({ children }: MultiSelectionProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div css={style} data-multi-selection>
|
|
20
|
+
{children}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
MultiSelection.bspkName = 'MultiSelection';
|
|
26
|
+
|
|
27
|
+
export { MultiSelection };
|
|
28
|
+
|
|
29
|
+
export const style = css`
|
|
30
|
+
display: flex;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
export type NavigationRailProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The content of the navigation rail.
|
|
6
|
+
*
|
|
7
|
+
* @required
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Component description coming soon.
|
|
14
|
+
*
|
|
15
|
+
* @name NavigationRail
|
|
16
|
+
*/
|
|
17
|
+
function NavigationRail({ children }: NavigationRailProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div css={style} data-navigation-rail>
|
|
20
|
+
{children}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NavigationRail.bspkName = 'NavigationRail';
|
|
26
|
+
|
|
27
|
+
export { NavigationRail };
|
|
28
|
+
|
|
29
|
+
export const style = css`
|
|
30
|
+
display: flex;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FormField, FormFieldProps } from './FormField';
|
|
2
|
+
import { NumberInput, NumberInputProps } from './NumberInput';
|
|
3
|
+
|
|
4
|
+
export type NumberFieldProps = Pick<
|
|
5
|
+
NumberInputProps,
|
|
6
|
+
'centered' | 'disabled' | 'id' | 'invalid' | 'name' | 'onChange' | 'readOnly' | 'size' | 'value'
|
|
7
|
+
> &
|
|
8
|
+
Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing' | 'required'>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A input element that allows users to either input a numerical value or singularly increase or decrease the values by
|
|
12
|
+
* pressing the (+) or (-).
|
|
13
|
+
*
|
|
14
|
+
* This component takes properties from the FormField and NumberInput components.
|
|
15
|
+
*
|
|
16
|
+
* @name NumberField
|
|
17
|
+
*/
|
|
18
|
+
function NumberField({
|
|
19
|
+
label,
|
|
20
|
+
errorMessage: errorMessageProp,
|
|
21
|
+
helperText,
|
|
22
|
+
controlId,
|
|
23
|
+
labelTrailing,
|
|
24
|
+
required,
|
|
25
|
+
...inputProps
|
|
26
|
+
}: NumberFieldProps) {
|
|
27
|
+
const errorMessage = (!inputProps.readOnly && !inputProps.disabled && errorMessageProp) || undefined;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<FormField
|
|
31
|
+
controlId={controlId}
|
|
32
|
+
errorMessage={errorMessage}
|
|
33
|
+
helperText={helperText}
|
|
34
|
+
label={label}
|
|
35
|
+
labelTrailing={labelTrailing}
|
|
36
|
+
required={required}
|
|
37
|
+
>
|
|
38
|
+
{(fieldProps) => <NumberInput {...inputProps} {...fieldProps} aria-label={label} id={controlId} />}
|
|
39
|
+
</FormField>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
NumberField.bspkName = 'NumberField';
|
|
44
|
+
|
|
45
|
+
export { NumberField };
|
|
46
|
+
|
|
47
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|