@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
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { SvgCancel } from '@bspk/icons/Cancel';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { ChangeEvent, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useId } from './hooks/useId';
|
|
6
|
+
|
|
7
|
+
import { ElementProps, CommonProps } from '.';
|
|
8
|
+
|
|
9
|
+
export type TextInputProps = CommonProps<
|
|
10
|
+
'aria-label' | 'disabled' | 'id' | 'invalid' | 'name' | 'readOnly' | 'required' | 'size' | 'value'
|
|
11
|
+
> & {
|
|
12
|
+
/**
|
|
13
|
+
* Callback when the value of the field changes.
|
|
14
|
+
*
|
|
15
|
+
* @type (next: String, Event) => void
|
|
16
|
+
* @required
|
|
17
|
+
*/
|
|
18
|
+
onChange: (next: string, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
/** The ref of the container. */
|
|
20
|
+
containerRef?: (node: HTMLElement | null) => void;
|
|
21
|
+
/** The ref of the input. */
|
|
22
|
+
inputRef?: (node: HTMLElement | null) => void;
|
|
23
|
+
/** The trailing element to display in the field. */
|
|
24
|
+
trailing?: ReactNode;
|
|
25
|
+
/** The leading element to display in the field. */
|
|
26
|
+
leading?: ReactNode;
|
|
27
|
+
/** The placeholder of the field. */
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
/** The type of the input. */
|
|
30
|
+
type?: Extract<HTMLInputTypeAttribute, 'number' | 'text'>;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies if user agent has any permission to provide automated assistance in filling out form field values.
|
|
33
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
34
|
+
*
|
|
35
|
+
* @default off
|
|
36
|
+
*/
|
|
37
|
+
autoComplete?: HTMLInputAutoCompleteAttribute;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A text input that allows users to enter text, numbers or symbols in a singular line. This is the base element and is
|
|
42
|
+
* not intended to be used directly. Use the TextField component.
|
|
43
|
+
*
|
|
44
|
+
* @element
|
|
45
|
+
*
|
|
46
|
+
* @name TextInput
|
|
47
|
+
*/
|
|
48
|
+
function TextInput({
|
|
49
|
+
invalid: invalidProp,
|
|
50
|
+
onChange,
|
|
51
|
+
size = 'medium',
|
|
52
|
+
value = '',
|
|
53
|
+
name,
|
|
54
|
+
'aria-label': ariaLabel,
|
|
55
|
+
inputRef,
|
|
56
|
+
required,
|
|
57
|
+
placeholder,
|
|
58
|
+
id: idProp,
|
|
59
|
+
leading,
|
|
60
|
+
trailing,
|
|
61
|
+
type,
|
|
62
|
+
readOnly,
|
|
63
|
+
disabled,
|
|
64
|
+
autoComplete = 'off',
|
|
65
|
+
containerRef,
|
|
66
|
+
...otherProps
|
|
67
|
+
}: ElementProps<TextInputProps, 'div'>) {
|
|
68
|
+
const id = useId(idProp);
|
|
69
|
+
|
|
70
|
+
const invalid = !readOnly && !disabled && invalidProp;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
css={style}
|
|
75
|
+
data-disabled={disabled || undefined}
|
|
76
|
+
data-invalid={invalid || undefined}
|
|
77
|
+
data-readonly={readOnly || undefined}
|
|
78
|
+
data-required={required || undefined}
|
|
79
|
+
data-size={size}
|
|
80
|
+
data-text-input
|
|
81
|
+
ref={containerRef}
|
|
82
|
+
{...otherProps}
|
|
83
|
+
>
|
|
84
|
+
{leading && <span data-leading>{leading}</span>}
|
|
85
|
+
<input
|
|
86
|
+
aria-invalid={invalid || undefined}
|
|
87
|
+
aria-label={ariaLabel}
|
|
88
|
+
autoComplete={autoComplete}
|
|
89
|
+
disabled={disabled || undefined}
|
|
90
|
+
id={id}
|
|
91
|
+
name={name}
|
|
92
|
+
onChange={(event) => {
|
|
93
|
+
onChange(event.target.value, event);
|
|
94
|
+
}}
|
|
95
|
+
placeholder={placeholder || ' '}
|
|
96
|
+
readOnly={readOnly || undefined}
|
|
97
|
+
ref={inputRef}
|
|
98
|
+
required={required || undefined}
|
|
99
|
+
type={type}
|
|
100
|
+
value={value}
|
|
101
|
+
/>
|
|
102
|
+
{trailing && <span data-trailing>{trailing}</span>}
|
|
103
|
+
{value?.toString().length > 0 && !readOnly && !disabled && (
|
|
104
|
+
<button aria-label="clear" data-clear onClick={() => onChange('')}>
|
|
105
|
+
<SvgCancel />
|
|
106
|
+
</button>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
TextInput.bspkName = 'TextInput';
|
|
113
|
+
|
|
114
|
+
export { TextInput };
|
|
115
|
+
|
|
116
|
+
export const style = css`
|
|
117
|
+
--border-color: var(--stroke-neutral-base);
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-direction: row;
|
|
120
|
+
background-color: var(--surface-neutral-t1-base);
|
|
121
|
+
border: solid 1px var(--border-color);
|
|
122
|
+
height: var(--field-height);
|
|
123
|
+
border-radius: var(--radius-small);
|
|
124
|
+
padding: 0 var(--field-padding);
|
|
125
|
+
gap: var(--spacing-sizing-01);
|
|
126
|
+
flex-wrap: nowrap;
|
|
127
|
+
width: 100%;
|
|
128
|
+
|
|
129
|
+
&:focus-within {
|
|
130
|
+
--border-color: var(--stroke-brand-primary);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
& > * {
|
|
134
|
+
display: flex;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
align-items: center;
|
|
137
|
+
height: var(--field-height);
|
|
138
|
+
font: var(--field-font);
|
|
139
|
+
color: var(--foreground-neutral-on-surface);
|
|
140
|
+
min-width: 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&:hover:not(:focus-within) {
|
|
144
|
+
background:
|
|
145
|
+
// multiple colors
|
|
146
|
+
|
|
147
|
+
linear-gradient(var(--interactions-hover-opacity), var(--interactions-hover-opacity)),
|
|
148
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:active:not(:focus-within) {
|
|
152
|
+
background:
|
|
153
|
+
// multiple colors
|
|
154
|
+
|
|
155
|
+
linear-gradient(var(--interactions-press-opacity), var(--interactions-press-opacity)),
|
|
156
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&[data-readonly] {
|
|
160
|
+
--border-color: var(--stroke-neutral-disabled-light);
|
|
161
|
+
|
|
162
|
+
background:
|
|
163
|
+
// multiple colors
|
|
164
|
+
|
|
165
|
+
linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
|
|
166
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&[data-disabled] {
|
|
170
|
+
--border-color: var(--stroke-neutral-disabled-light);
|
|
171
|
+
|
|
172
|
+
background:
|
|
173
|
+
// multiple colors
|
|
174
|
+
|
|
175
|
+
linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
|
|
176
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
177
|
+
|
|
178
|
+
& > * {
|
|
179
|
+
color: var(--foreground-neutral-disabled-on-surface);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&[data-invalid] {
|
|
184
|
+
--border-color: var(--status-error);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
&[data-size='small'] {
|
|
188
|
+
--field-padding: var(--spacing-sizing-02);
|
|
189
|
+
--field-height: var(--spacing-sizing-08);
|
|
190
|
+
--field-font: var(--body-small);
|
|
191
|
+
--field-icon-width: var(--spacing-sizing-04);
|
|
192
|
+
--field-clear-width: var(--spacing-sizing-05);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&[data-size='medium'] {
|
|
196
|
+
--field-padding: var(--spacing-sizing-03);
|
|
197
|
+
--field-height: var(--spacing-sizing-10);
|
|
198
|
+
--field-font: var(--body-base);
|
|
199
|
+
--field-icon-width: var(--spacing-sizing-05);
|
|
200
|
+
--field-clear-width: var(--spacing-sizing-05);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&[data-size='large'] {
|
|
204
|
+
--field-padding: var(--spacing-sizing-03);
|
|
205
|
+
--field-height: var(--spacing-sizing-12);
|
|
206
|
+
--field-font: var(--body-large);
|
|
207
|
+
--field-icon-width: var(--spacing-sizing-06);
|
|
208
|
+
--field-clear-width: var(--spacing-sizing-06);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[data-leading],
|
|
212
|
+
[data-trailing] {
|
|
213
|
+
svg {
|
|
214
|
+
width: var(--field-icon-width);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
label {
|
|
219
|
+
font: var(--labels-small);
|
|
220
|
+
color: var(--foreground-neutral-on-surface-variant-01);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
input {
|
|
224
|
+
flex: 1;
|
|
225
|
+
background-color: transparent !important;
|
|
226
|
+
border: none;
|
|
227
|
+
outline: none;
|
|
228
|
+
padding: 0;
|
|
229
|
+
pointer-events: all;
|
|
230
|
+
text-overflow: ellipsis;
|
|
231
|
+
|
|
232
|
+
&[type='number']::-webkit-inner-spin-button,
|
|
233
|
+
&[type='number']::-webkit-outer-spin-button {
|
|
234
|
+
display: none;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
button[data-clear] {
|
|
239
|
+
display: none;
|
|
240
|
+
border: none;
|
|
241
|
+
background: none;
|
|
242
|
+
padding: 0;
|
|
243
|
+
cursor: pointer;
|
|
244
|
+
pointer-events: all;
|
|
245
|
+
margin-left: var(--spacing-sizing-02);
|
|
246
|
+
padding-right: var(--field-padding);
|
|
247
|
+
|
|
248
|
+
svg {
|
|
249
|
+
pointer-events: none;
|
|
250
|
+
width: var(--field-clear-width);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&:focus-within {
|
|
255
|
+
button[data-clear] {
|
|
256
|
+
display: flex;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&:has(button[data-clear]) {
|
|
261
|
+
padding-right: 0;
|
|
262
|
+
}
|
|
263
|
+
`;
|
|
264
|
+
|
|
265
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/Textarea.tsx
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { ChangeEvent, CSSProperties, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useId } from './hooks/useId';
|
|
5
|
+
|
|
6
|
+
import { CommonProps } from './';
|
|
7
|
+
|
|
8
|
+
export type TextareaProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'invalid' | 'readOnly' | 'required'> & {
|
|
9
|
+
/**
|
|
10
|
+
* Callback when the value of the field changes.
|
|
11
|
+
*
|
|
12
|
+
* @type (next: String, Event) => void
|
|
13
|
+
* @required
|
|
14
|
+
*/
|
|
15
|
+
onChange: (next: string, event?: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The size of the field.
|
|
18
|
+
*
|
|
19
|
+
* @default medium
|
|
20
|
+
*/
|
|
21
|
+
size?: 'large' | 'medium' | 'small';
|
|
22
|
+
/** The value of the field. */
|
|
23
|
+
value?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The textarea control name of the field.
|
|
26
|
+
*
|
|
27
|
+
* @required
|
|
28
|
+
*/
|
|
29
|
+
name: string;
|
|
30
|
+
/** The ref of the field. */
|
|
31
|
+
innerRef?: Ref<HTMLTextAreaElement>;
|
|
32
|
+
/** The placeholder of the field. */
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The maximum number of characters that the field will accept.
|
|
36
|
+
*
|
|
37
|
+
* @minimum 1
|
|
38
|
+
*/
|
|
39
|
+
maxLength?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The minimum number of rows that the textarea should have. If set the textarea will automatically grow and shrink
|
|
42
|
+
* to fit the content.
|
|
43
|
+
*
|
|
44
|
+
* @minimum 3
|
|
45
|
+
*/
|
|
46
|
+
minRows?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of rows that the textarea should have. If set the textarea will automatically grow and shrink
|
|
49
|
+
* to fit the content.
|
|
50
|
+
*
|
|
51
|
+
* @maximum 10
|
|
52
|
+
*/
|
|
53
|
+
maxRows?: number;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const MIN_ROWS = 3;
|
|
57
|
+
const MAX_ROWS = 10;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A component that allows users to input large amounts of text that could span multiple lines.
|
|
61
|
+
*
|
|
62
|
+
* @element
|
|
63
|
+
*
|
|
64
|
+
* @name Textarea
|
|
65
|
+
*/
|
|
66
|
+
function Textarea({
|
|
67
|
+
invalid: invalidProp,
|
|
68
|
+
onChange,
|
|
69
|
+
size = 'medium',
|
|
70
|
+
value = '',
|
|
71
|
+
name,
|
|
72
|
+
'aria-label': ariaLabel,
|
|
73
|
+
innerRef,
|
|
74
|
+
placeholder,
|
|
75
|
+
id: idProp,
|
|
76
|
+
minRows: minRowsProp = MIN_ROWS,
|
|
77
|
+
maxRows: maxRowsProp = MAX_ROWS,
|
|
78
|
+
...otherProps
|
|
79
|
+
}: TextareaProps) {
|
|
80
|
+
const id = useId(idProp);
|
|
81
|
+
const invalid = !otherProps.readOnly && !otherProps.disabled && invalidProp;
|
|
82
|
+
// ensure minRows and maxRows are within bounds
|
|
83
|
+
const minRows = Math.min(MAX_ROWS, Math.max(minRowsProp, MIN_ROWS));
|
|
84
|
+
const maxRows = Math.max(MIN_ROWS, Math.min(maxRowsProp, MAX_ROWS));
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
css={style}
|
|
89
|
+
data-size={size}
|
|
90
|
+
data-textarea
|
|
91
|
+
style={
|
|
92
|
+
{
|
|
93
|
+
'--min-rows': minRows,
|
|
94
|
+
'--max-rows': maxRows,
|
|
95
|
+
} as CSSProperties
|
|
96
|
+
}
|
|
97
|
+
>
|
|
98
|
+
<textarea
|
|
99
|
+
{...otherProps}
|
|
100
|
+
aria-invalid={invalid || undefined}
|
|
101
|
+
aria-label={ariaLabel}
|
|
102
|
+
id={id}
|
|
103
|
+
name={name}
|
|
104
|
+
onBlur={(event) => {
|
|
105
|
+
const target = event.target as HTMLTextAreaElement;
|
|
106
|
+
target.scrollTop = 0;
|
|
107
|
+
}}
|
|
108
|
+
onChange={(event) => onChange(event.target.value, event)}
|
|
109
|
+
onInput={(event) => {
|
|
110
|
+
const target = event.target as HTMLTextAreaElement;
|
|
111
|
+
// we know the textarea was resized, so we don't want to auto-size it
|
|
112
|
+
if (target.style.height) return;
|
|
113
|
+
(target.nextSibling as HTMLElement).innerText = `${target.value}\n`;
|
|
114
|
+
}}
|
|
115
|
+
placeholder={placeholder}
|
|
116
|
+
ref={innerRef}
|
|
117
|
+
value={value}
|
|
118
|
+
/>
|
|
119
|
+
<div aria-hidden data-replicated-value />
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Textarea.bspkName = 'Textarea';
|
|
125
|
+
|
|
126
|
+
export { Textarea };
|
|
127
|
+
|
|
128
|
+
export const style = css`
|
|
129
|
+
display: grid;
|
|
130
|
+
width: 100%;
|
|
131
|
+
|
|
132
|
+
// &[data-size='medium']
|
|
133
|
+
--font: var(--body-base);
|
|
134
|
+
--line-height: 20px;
|
|
135
|
+
--padding: var(--spacing-sizing-03);
|
|
136
|
+
|
|
137
|
+
&[data-size='small'] {
|
|
138
|
+
--font: var(--body-small);
|
|
139
|
+
--line-height: 20px;
|
|
140
|
+
--padding: var(--spacing-sizing-02);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&[data-size='large'] {
|
|
144
|
+
--font: var(--body-large);
|
|
145
|
+
--line-height: 24px;
|
|
146
|
+
--padding: var(--spacing-sizing-03);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
[data-replicated-value] {
|
|
150
|
+
white-space: pre-wrap;
|
|
151
|
+
visibility: hidden;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
textarea,
|
|
155
|
+
[data-replicated-value] {
|
|
156
|
+
width: 100%;
|
|
157
|
+
font: var(--font);
|
|
158
|
+
border: 1px solid var(--border-color);
|
|
159
|
+
padding: var(--padding);
|
|
160
|
+
grid-area: 1 / 1 / 2 / 2;
|
|
161
|
+
min-height: calc((var(--line-height) * var(--min-rows)) + (var(--padding) * 2));
|
|
162
|
+
max-height: calc((var(--line-height) * var(--max-rows)) + (var(--padding) * 2));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
textarea {
|
|
166
|
+
--border-color: var(--stroke-neutral-base);
|
|
167
|
+
|
|
168
|
+
resize: vertical;
|
|
169
|
+
color: var(--foreground-neutral-on-surface);
|
|
170
|
+
background-color: var(--surface-neutral-t1-base);
|
|
171
|
+
border-radius: var(--radius-small);
|
|
172
|
+
|
|
173
|
+
&:focus-within {
|
|
174
|
+
--border-color: var(--stroke-neutral-focus);
|
|
175
|
+
outline: none;
|
|
176
|
+
color: var(--foreground-neutral-on-surface);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&:disabled {
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
background:
|
|
182
|
+
// multiple colors
|
|
183
|
+
|
|
184
|
+
linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
|
|
185
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
186
|
+
color: var(--foreground-neutral-disabled-on-surface);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&:read-only {
|
|
190
|
+
background:
|
|
191
|
+
// multiple colors
|
|
192
|
+
|
|
193
|
+
linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
|
|
194
|
+
linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
|
|
195
|
+
color: var(--foreground-neutral-on-surface-variant-02);
|
|
196
|
+
cursor: not-allowed;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&[aria-invalid] {
|
|
200
|
+
--border-color: var(--status-error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FormField, FormFieldProps } from './FormField';
|
|
2
|
+
import { Textarea, TextareaProps } from './Textarea';
|
|
3
|
+
import { Txt } from './Txt';
|
|
4
|
+
import { tryIntParse } from './utils/tryIntPsrse';
|
|
5
|
+
|
|
6
|
+
export type TextareaFieldProps = Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label'> &
|
|
7
|
+
TextareaProps;
|
|
8
|
+
/**
|
|
9
|
+
* A component that allows users to input large amounts of text that could span multiple lines.
|
|
10
|
+
*
|
|
11
|
+
* This component takes properties from the FormField and Textarea components.
|
|
12
|
+
*
|
|
13
|
+
* @name TextareaField
|
|
14
|
+
*/
|
|
15
|
+
function TextareaField({
|
|
16
|
+
label,
|
|
17
|
+
errorMessage: errorMessageProp,
|
|
18
|
+
helperText,
|
|
19
|
+
controlId: id,
|
|
20
|
+
onChange,
|
|
21
|
+
maxLength: maxLengthProp,
|
|
22
|
+
invalid,
|
|
23
|
+
readOnly,
|
|
24
|
+
disabled,
|
|
25
|
+
required,
|
|
26
|
+
...textareaProps
|
|
27
|
+
}: TextareaFieldProps) {
|
|
28
|
+
const maxLength = tryIntParse(maxLengthProp) || -1;
|
|
29
|
+
const errorMessage = (!readOnly && !disabled && errorMessageProp) || undefined;
|
|
30
|
+
|
|
31
|
+
if (typeof onChange !== 'function') return null;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<FormField
|
|
35
|
+
controlId={id}
|
|
36
|
+
errorMessage={errorMessage}
|
|
37
|
+
helperText={helperText}
|
|
38
|
+
label={label}
|
|
39
|
+
labelTrailing={
|
|
40
|
+
<Txt style={{ color: 'var(--foreground-neutral-on-surface-variant-02)' }} variant="body-small">
|
|
41
|
+
{`${textareaProps?.value?.length || 0}${maxLength > 0 ? `/${maxLength}` : ''}`}
|
|
42
|
+
</Txt>
|
|
43
|
+
}
|
|
44
|
+
required={required}
|
|
45
|
+
>
|
|
46
|
+
{(fieldProps) => (
|
|
47
|
+
<Textarea
|
|
48
|
+
{...textareaProps}
|
|
49
|
+
{...fieldProps}
|
|
50
|
+
aria-label={textareaProps['aria-label'] || label}
|
|
51
|
+
id={id}
|
|
52
|
+
invalid={invalid}
|
|
53
|
+
onChange={(next, event) => {
|
|
54
|
+
onChange(next, event);
|
|
55
|
+
}}
|
|
56
|
+
required={required}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
</FormField>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
TextareaField.bspkName = 'TextareaField';
|
|
64
|
+
|
|
65
|
+
export { TextareaField };
|
|
66
|
+
|
|
67
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
export type TimePickerProps = {
|
|
4
|
+
/** The content of the timepicker. */
|
|
5
|
+
children: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Component description coming soon.
|
|
10
|
+
*
|
|
11
|
+
* @name TimePicker
|
|
12
|
+
*/
|
|
13
|
+
function TimePicker({ children }: TimePickerProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div css={style} data-time-picker>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
TimePicker.bspkName = 'TimePicker';
|
|
22
|
+
|
|
23
|
+
export { TimePicker };
|
|
24
|
+
|
|
25
|
+
export const style = css`
|
|
26
|
+
display: flex;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
export type ToggleOptionProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The label of the field. Also used as the aria-label of the checkbox.
|
|
7
|
+
*
|
|
8
|
+
* @required
|
|
9
|
+
*/
|
|
10
|
+
label: string;
|
|
11
|
+
/** The description of the field. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** The control element to use. */
|
|
14
|
+
children?: ReactElement;
|
|
15
|
+
/** The size of the control option label. */
|
|
16
|
+
size?: 'base' | 'large' | 'small';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A utility component that wraps a checkbox, radio, and switch.
|
|
21
|
+
*
|
|
22
|
+
* @name ToggleOption
|
|
23
|
+
*/
|
|
24
|
+
function ToggleOption({ label, description, children, size }: ToggleOptionProps) {
|
|
25
|
+
return (
|
|
26
|
+
<label css={style} data-size={size} data-toggle-option="">
|
|
27
|
+
<span data-control>{children}</span>
|
|
28
|
+
<span data-content>
|
|
29
|
+
<span data-label>{label}</span>
|
|
30
|
+
{description && <span data-description>{description}</span>}
|
|
31
|
+
</span>
|
|
32
|
+
</label>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ToggleOption.bspkName = 'ToggleOption';
|
|
37
|
+
|
|
38
|
+
export { ToggleOption };
|
|
39
|
+
|
|
40
|
+
export const style = css`
|
|
41
|
+
display: flex;
|
|
42
|
+
width: 100%;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
padding: 0 var(--spacing-sizing-01) 0 0;
|
|
46
|
+
gap: var(--spacing-sizing-02);
|
|
47
|
+
user-select: none;
|
|
48
|
+
background: unset;
|
|
49
|
+
border: unset;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
min-height: var(--spacing-sizing-08);
|
|
52
|
+
align-items: center;
|
|
53
|
+
|
|
54
|
+
&:has([data-description]) {
|
|
55
|
+
align-items: unset;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (any-pointer: coarse) {
|
|
59
|
+
min-height: var(--spacing-sizing-12);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[data-content] {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
padding: 2px 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[data-label] {
|
|
69
|
+
color: var(--foreground-neutral-on-surface);
|
|
70
|
+
font: var(--labels-base);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[data-description] {
|
|
74
|
+
font: var(--body-small);
|
|
75
|
+
color: var(--foreground-neutral-on-surface-variant-01);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&[data-size='small'] {
|
|
79
|
+
[data-label] {
|
|
80
|
+
font: var(--labels-small);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[data-description] {
|
|
84
|
+
font: var(--body-x-small);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&[data-size='large'] {
|
|
89
|
+
[data-label] {
|
|
90
|
+
font: var(--labels-large);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-description] {
|
|
94
|
+
font: var(--body-base);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:not(:has(:disabled)) {
|
|
99
|
+
[data-pseudo='focus'] &,
|
|
100
|
+
&:focus-visible,
|
|
101
|
+
&:has(*:focus-visible) {
|
|
102
|
+
outline: var(--stroke-neutral-focus) 2px solid;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&:has(:disabled) {
|
|
107
|
+
[data-label] {
|
|
108
|
+
color: var(--foreground-neutral-disabled-on-surface);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-description] {
|
|
112
|
+
color: var(--foreground-neutral-disabled-on-surface);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|