@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,80 @@
|
|
|
1
|
+
import { Children, Fragment, isValidElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export function isValidIcon(child: unknown) {
|
|
4
|
+
return isChildNamed(child, 'Icon');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getChildName(child: unknown): string {
|
|
8
|
+
if (!child) return '';
|
|
9
|
+
|
|
10
|
+
const typeChild = typeof child;
|
|
11
|
+
if (['string', 'number', 'boolean', 'bigint'].includes(typeChild)) return typeChild;
|
|
12
|
+
return (isValidElement(child) ? (child.type as { bspkName?: string })?.bspkName : '') || '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getChildTypeName(child: unknown): string {
|
|
16
|
+
if (!child) return '';
|
|
17
|
+
const typeChild = typeof child;
|
|
18
|
+
|
|
19
|
+
if (['string', 'number', 'boolean', 'bigint'].includes(typeChild)) return typeChild;
|
|
20
|
+
|
|
21
|
+
if (isValidElement(child)) {
|
|
22
|
+
if (typeof child.type === 'string') return child.type;
|
|
23
|
+
return child.type.name || '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isChildNamed(child: unknown, name: string): boolean {
|
|
30
|
+
return getChildName(child) === name;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isReactFragment(node: unknown): node is ReactNode {
|
|
34
|
+
return isValidElement(node) && node.type === Fragment;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convert children to a flat array of children elements, removing any fragment wrappers in the process.
|
|
39
|
+
*
|
|
40
|
+
* @param children The children to convert to an array.
|
|
41
|
+
* @param ignoreParent If true, ignore parent elements and only return the children
|
|
42
|
+
*/
|
|
43
|
+
export function childrenToArray(children: ReactNode): ReactNode[] {
|
|
44
|
+
return Children.toArray(children).flatMap((child) => {
|
|
45
|
+
if (isValidElement(child)) {
|
|
46
|
+
if (isReactFragment(child) && child.props.children) return childrenToArray(child.props.children);
|
|
47
|
+
return child;
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(child)) return childrenToArray(child);
|
|
50
|
+
if (child !== null && child !== undefined) return child;
|
|
51
|
+
return [];
|
|
52
|
+
}, []);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type ChildElement =
|
|
56
|
+
| {
|
|
57
|
+
child: ReactNode;
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
child: string;
|
|
62
|
+
name: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the children of a component as an array of objects with the child and the name of the child.
|
|
67
|
+
*
|
|
68
|
+
* Filter out unknown empty strings or non-truthy children other than zeros.
|
|
69
|
+
*
|
|
70
|
+
* @param children The children to get the elements from.
|
|
71
|
+
*/
|
|
72
|
+
export function getChildrenElements(children: ReactNode): ChildElement[] {
|
|
73
|
+
return (Array.isArray(children) ? children : childrenToArray(children))
|
|
74
|
+
.filter((child) => {
|
|
75
|
+
return (typeof child === 'string' && child.trim() !== '') || child === 0 || child;
|
|
76
|
+
})
|
|
77
|
+
.map((child) => ({ child, name: getChildName(child) }));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type ColorVariant =
|
|
2
|
+
| 'blue'
|
|
3
|
+
| 'green'
|
|
4
|
+
| 'grey'
|
|
5
|
+
| 'lime'
|
|
6
|
+
| 'magenta'
|
|
7
|
+
| 'orange'
|
|
8
|
+
| 'pink'
|
|
9
|
+
| 'primary'
|
|
10
|
+
| 'purple'
|
|
11
|
+
| 'red'
|
|
12
|
+
| 'secondary'
|
|
13
|
+
| 'teal'
|
|
14
|
+
| 'white'
|
|
15
|
+
| 'yellow';
|
|
16
|
+
|
|
17
|
+
export const COLOR_VARIABLES: Record<ColorVariant, { foreground: string; surface: string }> = {
|
|
18
|
+
grey: {
|
|
19
|
+
foreground: '--foreground-neutral-on-surface-variant-01',
|
|
20
|
+
surface: '--surface-neutral-t2-lowest',
|
|
21
|
+
},
|
|
22
|
+
white: {
|
|
23
|
+
foreground: '--foreground-neutral-on-surface-variant-01',
|
|
24
|
+
surface: '--surface-neutral-t1-base',
|
|
25
|
+
},
|
|
26
|
+
primary: {
|
|
27
|
+
foreground: '--foreground-brand-primary-depth',
|
|
28
|
+
surface: '--surface-brand-primary-highlight',
|
|
29
|
+
},
|
|
30
|
+
secondary: {
|
|
31
|
+
foreground: '--foreground-brand-secondary-depth',
|
|
32
|
+
surface: '--surface-brand-secondary-highlight',
|
|
33
|
+
},
|
|
34
|
+
blue: {
|
|
35
|
+
foreground: '--foreground-spectrum-blue',
|
|
36
|
+
surface: '--surface-spectrum-blue',
|
|
37
|
+
},
|
|
38
|
+
green: {
|
|
39
|
+
foreground: '--foreground-spectrum-green',
|
|
40
|
+
surface: '--surface-spectrum-green',
|
|
41
|
+
},
|
|
42
|
+
lime: {
|
|
43
|
+
foreground: '--foreground-spectrum-lime',
|
|
44
|
+
surface: '--surface-spectrum-lime',
|
|
45
|
+
},
|
|
46
|
+
magenta: {
|
|
47
|
+
foreground: '--foreground-spectrum-magenta',
|
|
48
|
+
surface: '--surface-spectrum-magenta',
|
|
49
|
+
},
|
|
50
|
+
orange: {
|
|
51
|
+
foreground: '--foreground-spectrum-orange',
|
|
52
|
+
surface: '--surface-spectrum-orange',
|
|
53
|
+
},
|
|
54
|
+
pink: {
|
|
55
|
+
foreground: '--foreground-spectrum-pink',
|
|
56
|
+
surface: '--surface-spectrum-pink',
|
|
57
|
+
},
|
|
58
|
+
purple: {
|
|
59
|
+
foreground: '--foreground-spectrum-purple',
|
|
60
|
+
surface: '--surface-spectrum-purple',
|
|
61
|
+
},
|
|
62
|
+
red: {
|
|
63
|
+
foreground: '--foreground-spectrum-red',
|
|
64
|
+
surface: '--surface-spectrum-red',
|
|
65
|
+
},
|
|
66
|
+
teal: {
|
|
67
|
+
foreground: '--foreground-spectrum-teal',
|
|
68
|
+
surface: '--surface-spectrum-teal',
|
|
69
|
+
},
|
|
70
|
+
yellow: {
|
|
71
|
+
foreground: '--foreground-spectrum-yellow',
|
|
72
|
+
surface: '--surface-spectrum-yellow',
|
|
73
|
+
},
|
|
74
|
+
} as const;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERROR LOGGING
|
|
3
|
+
*
|
|
4
|
+
* When an error is logged it is stored in a buffer.
|
|
5
|
+
*
|
|
6
|
+
* After a debounce period all errors are merged and of they no longer exist are cleared.
|
|
7
|
+
*
|
|
8
|
+
* These errors are grouped by contextId and dispatched as a custom event.
|
|
9
|
+
*
|
|
10
|
+
* At this point the buffer is cleared.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
14
|
+
|
|
15
|
+
export type ErrorDetail = {
|
|
16
|
+
message: string;
|
|
17
|
+
data?: unknown;
|
|
18
|
+
contextId?: string;
|
|
19
|
+
location: Location;
|
|
20
|
+
exists: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const bspkErrorType = (contextId: string) => `bspk-error-${contextId}`;
|
|
24
|
+
|
|
25
|
+
export type LogError = (exists: boolean, log: string | { message: string; data: unknown }) => boolean;
|
|
26
|
+
|
|
27
|
+
let logBuffer: Record<string, ErrorDetail[]> = {};
|
|
28
|
+
let logDebounce: ReturnType<typeof setTimeout> | null = null;
|
|
29
|
+
|
|
30
|
+
export function logError(detail: Pick<ErrorDetail, 'contextId' | 'data' | 'exists' | 'message'>): boolean {
|
|
31
|
+
if (!detail.contextId) return detail.exists;
|
|
32
|
+
|
|
33
|
+
const bufferKey = `${detail.contextId}-${detail.message}`;
|
|
34
|
+
|
|
35
|
+
logBuffer[bufferKey] = logBuffer[bufferKey] || [];
|
|
36
|
+
logBuffer[bufferKey].push({ ...detail, location: document.location });
|
|
37
|
+
|
|
38
|
+
if (logDebounce) clearTimeout(logDebounce);
|
|
39
|
+
|
|
40
|
+
logDebounce = setTimeout(() => {
|
|
41
|
+
const contextErrors: Record<string, ErrorDetail[]> = {};
|
|
42
|
+
|
|
43
|
+
Object.values(logBuffer).flatMap((siblingErrors) => {
|
|
44
|
+
const lastSiblingError = siblingErrors[siblingErrors.length - 1];
|
|
45
|
+
|
|
46
|
+
const nextErrors = lastSiblingError.exists ? [lastSiblingError] : [];
|
|
47
|
+
|
|
48
|
+
if (lastSiblingError.contextId) {
|
|
49
|
+
// we send all errors to the contextId even if they are empty so we can clear the errors
|
|
50
|
+
contextErrors[lastSiblingError.contextId] = contextErrors[lastSiblingError.contextId] || [];
|
|
51
|
+
contextErrors[lastSiblingError.contextId].push(...nextErrors);
|
|
52
|
+
} else if (nextErrors.length) {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
nextErrors.forEach((e) => console.error(e));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
logBuffer = {};
|
|
59
|
+
|
|
60
|
+
Object.entries(contextErrors).forEach(([contextId, errors]) => {
|
|
61
|
+
globalThis.dispatchEvent(new CustomEvent(bspkErrorType(contextId), { detail: errors }));
|
|
62
|
+
});
|
|
63
|
+
}, 500);
|
|
64
|
+
|
|
65
|
+
return detail.exists;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const errorContext = createContext(undefined as string | undefined);
|
|
69
|
+
|
|
70
|
+
export function useErrorLogger(): {
|
|
71
|
+
logError: LogError;
|
|
72
|
+
} {
|
|
73
|
+
const contextId = useContext(errorContext);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
logError: (exists: boolean, message: string, data?: unknown) => logError({ exists, contextId, message, data }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function ErrorLogContext({ children, id }: { children: React.ReactNode; id: string }) {
|
|
81
|
+
return <errorContext.Provider value={id}>{children}</errorContext.Provider>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function useErrorLog() {
|
|
85
|
+
const [errors, setErrors] = useState<ErrorDetail[]>([]);
|
|
86
|
+
const contextId = useContext(errorContext);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!contextId) return;
|
|
90
|
+
|
|
91
|
+
const listener = (event: CustomEvent<ErrorDetail[]>) => {
|
|
92
|
+
// eslint-disable-next-line no-console
|
|
93
|
+
event.detail.forEach(console.error);
|
|
94
|
+
setErrors(event.detail);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
globalThis.addEventListener(bspkErrorType(contextId), listener);
|
|
98
|
+
return () => globalThis.removeEventListener(bspkErrorType(contextId), listener);
|
|
99
|
+
}, [contextId]);
|
|
100
|
+
|
|
101
|
+
return { errors, contextId };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
|
|
3
|
+
export function getValidNode<T = unknown>(node: T): T | undefined {
|
|
4
|
+
return isValidElement(node) || typeof node === 'string' || typeof node === 'number' ? node : undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
export type KeyboardEventKey =
|
|
2
|
+
| ' '
|
|
3
|
+
| '_'
|
|
4
|
+
| '-'
|
|
5
|
+
| ';'
|
|
6
|
+
| ':'
|
|
7
|
+
| '!'
|
|
8
|
+
| '?'
|
|
9
|
+
| '.'
|
|
10
|
+
| ''
|
|
11
|
+
| '"'
|
|
12
|
+
| '('
|
|
13
|
+
| ')'
|
|
14
|
+
| '['
|
|
15
|
+
| ']'
|
|
16
|
+
| '{'
|
|
17
|
+
| '}'
|
|
18
|
+
| '@'
|
|
19
|
+
| '*'
|
|
20
|
+
| '/'
|
|
21
|
+
| '\\'
|
|
22
|
+
| '&'
|
|
23
|
+
| '#'
|
|
24
|
+
| '%'
|
|
25
|
+
| '`'
|
|
26
|
+
| '^'
|
|
27
|
+
| '+'
|
|
28
|
+
| '<'
|
|
29
|
+
| '='
|
|
30
|
+
| '>'
|
|
31
|
+
| '|'
|
|
32
|
+
| '~'
|
|
33
|
+
| '$'
|
|
34
|
+
| '0'
|
|
35
|
+
| '1'
|
|
36
|
+
| '2'
|
|
37
|
+
| '3'
|
|
38
|
+
| '4'
|
|
39
|
+
| '5'
|
|
40
|
+
| '6'
|
|
41
|
+
| '7'
|
|
42
|
+
| '8'
|
|
43
|
+
| '9'
|
|
44
|
+
| 'A'
|
|
45
|
+
| 'a'
|
|
46
|
+
| 'Alt'
|
|
47
|
+
| 'ArrowDown'
|
|
48
|
+
| 'ArrowLeft'
|
|
49
|
+
| 'ArrowRight'
|
|
50
|
+
| 'ArrowUp'
|
|
51
|
+
| 'AudioVolumeDown'
|
|
52
|
+
| 'AudioVolumeMute'
|
|
53
|
+
| 'AudioVolumeUp'
|
|
54
|
+
| 'B'
|
|
55
|
+
| 'b'
|
|
56
|
+
| 'Backspace'
|
|
57
|
+
| 'C'
|
|
58
|
+
| 'c'
|
|
59
|
+
| 'CapsLock'
|
|
60
|
+
| 'ContextMenu'
|
|
61
|
+
| 'Control'
|
|
62
|
+
| 'D'
|
|
63
|
+
| 'd'
|
|
64
|
+
| 'Delete'
|
|
65
|
+
| 'E'
|
|
66
|
+
| 'e'
|
|
67
|
+
| 'End'
|
|
68
|
+
| 'Enter'
|
|
69
|
+
| 'Escape'
|
|
70
|
+
| 'F'
|
|
71
|
+
| 'f'
|
|
72
|
+
| 'F1'
|
|
73
|
+
| 'F2'
|
|
74
|
+
| 'F3'
|
|
75
|
+
| 'F4'
|
|
76
|
+
| 'F5'
|
|
77
|
+
| 'F6'
|
|
78
|
+
| 'F7'
|
|
79
|
+
| 'F8'
|
|
80
|
+
| 'F9'
|
|
81
|
+
| 'F10'
|
|
82
|
+
| 'F11'
|
|
83
|
+
| 'F12'
|
|
84
|
+
| 'G'
|
|
85
|
+
| 'g'
|
|
86
|
+
| 'H'
|
|
87
|
+
| 'h'
|
|
88
|
+
| 'Home'
|
|
89
|
+
| 'I'
|
|
90
|
+
| 'i'
|
|
91
|
+
| 'Insert'
|
|
92
|
+
| 'J'
|
|
93
|
+
| 'j'
|
|
94
|
+
| 'K'
|
|
95
|
+
| 'k'
|
|
96
|
+
| 'L'
|
|
97
|
+
| 'l'
|
|
98
|
+
| 'M'
|
|
99
|
+
| 'm'
|
|
100
|
+
| 'Meta'
|
|
101
|
+
| 'N'
|
|
102
|
+
| 'n'
|
|
103
|
+
| 'NumLock'
|
|
104
|
+
| 'O'
|
|
105
|
+
| 'o'
|
|
106
|
+
| 'P'
|
|
107
|
+
| 'p'
|
|
108
|
+
| 'PageDown'
|
|
109
|
+
| 'PageUp'
|
|
110
|
+
| 'Pause'
|
|
111
|
+
| 'PrintScreen'
|
|
112
|
+
| 'Q'
|
|
113
|
+
| 'q'
|
|
114
|
+
| 'R'
|
|
115
|
+
| 'r'
|
|
116
|
+
| 'S'
|
|
117
|
+
| 's'
|
|
118
|
+
| 'ScrollLock'
|
|
119
|
+
| 'Shift'
|
|
120
|
+
| 'T'
|
|
121
|
+
| 't'
|
|
122
|
+
| 'Tab'
|
|
123
|
+
| 'U'
|
|
124
|
+
| 'u'
|
|
125
|
+
| 'V'
|
|
126
|
+
| 'v'
|
|
127
|
+
| 'W'
|
|
128
|
+
| 'w'
|
|
129
|
+
| 'X'
|
|
130
|
+
| 'x'
|
|
131
|
+
| 'Y'
|
|
132
|
+
| 'y'
|
|
133
|
+
| 'Z'
|
|
134
|
+
| 'z'
|
|
135
|
+
| "'";
|
|
136
|
+
|
|
137
|
+
export type KeyboardEventCode =
|
|
138
|
+
| 'AltLeft'
|
|
139
|
+
| 'AltRight'
|
|
140
|
+
| 'ArrowDown'
|
|
141
|
+
| 'ArrowLeft'
|
|
142
|
+
| 'ArrowRight'
|
|
143
|
+
| 'ArrowUp'
|
|
144
|
+
| 'AudioVolumeDown'
|
|
145
|
+
| 'AudioVolumeMute'
|
|
146
|
+
| 'AudioVolumeUp'
|
|
147
|
+
| 'Backquote'
|
|
148
|
+
| 'Backslash'
|
|
149
|
+
| 'Backspace'
|
|
150
|
+
| 'BracketLeft'
|
|
151
|
+
| 'BracketRight'
|
|
152
|
+
| 'CapsLock'
|
|
153
|
+
| 'Comma'
|
|
154
|
+
| 'ContextMenu'
|
|
155
|
+
| 'ControlLeft'
|
|
156
|
+
| 'ControlRight'
|
|
157
|
+
| 'Delete'
|
|
158
|
+
| 'Digit0'
|
|
159
|
+
| 'Digit1'
|
|
160
|
+
| 'Digit2'
|
|
161
|
+
| 'Digit3'
|
|
162
|
+
| 'Digit4'
|
|
163
|
+
| 'Digit5'
|
|
164
|
+
| 'Digit6'
|
|
165
|
+
| 'Digit7'
|
|
166
|
+
| 'Digit8'
|
|
167
|
+
| 'Digit9'
|
|
168
|
+
| 'End'
|
|
169
|
+
| 'Enter'
|
|
170
|
+
| 'Equal'
|
|
171
|
+
| 'Escape'
|
|
172
|
+
| 'F1'
|
|
173
|
+
| 'F2'
|
|
174
|
+
| 'F3'
|
|
175
|
+
| 'F4'
|
|
176
|
+
| 'F5'
|
|
177
|
+
| 'F6'
|
|
178
|
+
| 'F7'
|
|
179
|
+
| 'F8'
|
|
180
|
+
| 'F9'
|
|
181
|
+
| 'F10'
|
|
182
|
+
| 'F11'
|
|
183
|
+
| 'F12'
|
|
184
|
+
| 'Home'
|
|
185
|
+
| 'Insert'
|
|
186
|
+
| 'KeyA'
|
|
187
|
+
| 'KeyB'
|
|
188
|
+
| 'KeyC'
|
|
189
|
+
| 'KeyD'
|
|
190
|
+
| 'KeyE'
|
|
191
|
+
| 'KeyF'
|
|
192
|
+
| 'KeyG'
|
|
193
|
+
| 'KeyH'
|
|
194
|
+
| 'KeyI'
|
|
195
|
+
| 'KeyJ'
|
|
196
|
+
| 'KeyK'
|
|
197
|
+
| 'KeyL'
|
|
198
|
+
| 'KeyM'
|
|
199
|
+
| 'KeyN'
|
|
200
|
+
| 'KeyO'
|
|
201
|
+
| 'KeyP'
|
|
202
|
+
| 'KeyQ'
|
|
203
|
+
| 'KeyR'
|
|
204
|
+
| 'KeyS'
|
|
205
|
+
| 'KeyT'
|
|
206
|
+
| 'KeyU'
|
|
207
|
+
| 'KeyV'
|
|
208
|
+
| 'KeyW'
|
|
209
|
+
| 'KeyX'
|
|
210
|
+
| 'KeyY'
|
|
211
|
+
| 'KeyZ'
|
|
212
|
+
| 'MetaLeft'
|
|
213
|
+
| 'MetaRight'
|
|
214
|
+
| 'Minus'
|
|
215
|
+
| 'NumLock'
|
|
216
|
+
| 'Numpad0'
|
|
217
|
+
| 'Numpad1'
|
|
218
|
+
| 'Numpad2'
|
|
219
|
+
| 'Numpad3'
|
|
220
|
+
| 'Numpad4'
|
|
221
|
+
| 'Numpad5'
|
|
222
|
+
| 'Numpad6'
|
|
223
|
+
| 'Numpad7'
|
|
224
|
+
| 'Numpad8'
|
|
225
|
+
| 'Numpad9'
|
|
226
|
+
| 'NumpadAdd'
|
|
227
|
+
| 'NumpadDecimal'
|
|
228
|
+
| 'NumpadDivide'
|
|
229
|
+
| 'NumpadMultiply'
|
|
230
|
+
| 'NumpadSubtract'
|
|
231
|
+
| 'PageDown'
|
|
232
|
+
| 'PageUp'
|
|
233
|
+
| 'Pause'
|
|
234
|
+
| 'Period'
|
|
235
|
+
| 'PrintScreen'
|
|
236
|
+
| 'Quote'
|
|
237
|
+
| 'ScrollLock'
|
|
238
|
+
| 'Semicolon'
|
|
239
|
+
| 'ShiftLeft'
|
|
240
|
+
| 'ShiftRight'
|
|
241
|
+
| 'Slash'
|
|
242
|
+
| 'Space'
|
|
243
|
+
| 'Tab';
|
|
244
|
+
|
|
245
|
+
export const EVENT_KEY: Record<KeyboardEventKey, KeyboardEventKey> = Object.freeze({
|
|
246
|
+
Backspace: 'Backspace',
|
|
247
|
+
Tab: 'Tab',
|
|
248
|
+
Enter: 'Enter',
|
|
249
|
+
Shift: 'Shift',
|
|
250
|
+
Control: 'Control',
|
|
251
|
+
Alt: 'Alt',
|
|
252
|
+
Pause: 'Pause',
|
|
253
|
+
CapsLock: 'CapsLock',
|
|
254
|
+
Escape: 'Escape',
|
|
255
|
+
' ': ' ',
|
|
256
|
+
PageUp: 'PageUp',
|
|
257
|
+
PageDown: 'PageDown',
|
|
258
|
+
End: 'End',
|
|
259
|
+
Home: 'Home',
|
|
260
|
+
ArrowLeft: 'ArrowLeft',
|
|
261
|
+
ArrowUp: 'ArrowUp',
|
|
262
|
+
ArrowRight: 'ArrowRight',
|
|
263
|
+
ArrowDown: 'ArrowDown',
|
|
264
|
+
PrintScreen: 'PrintScreen',
|
|
265
|
+
Insert: 'Insert',
|
|
266
|
+
Delete: 'Delete',
|
|
267
|
+
'0': '0',
|
|
268
|
+
'1': '1',
|
|
269
|
+
'2': '2',
|
|
270
|
+
'3': '3',
|
|
271
|
+
'4': '4',
|
|
272
|
+
'5': '5',
|
|
273
|
+
'6': '6',
|
|
274
|
+
'7': '7',
|
|
275
|
+
'8': '8',
|
|
276
|
+
'9': '9',
|
|
277
|
+
A: 'A',
|
|
278
|
+
B: 'B',
|
|
279
|
+
C: 'C',
|
|
280
|
+
D: 'D',
|
|
281
|
+
E: 'E',
|
|
282
|
+
F: 'F',
|
|
283
|
+
G: 'G',
|
|
284
|
+
H: 'H',
|
|
285
|
+
I: 'I',
|
|
286
|
+
J: 'J',
|
|
287
|
+
K: 'K',
|
|
288
|
+
L: 'L',
|
|
289
|
+
M: 'M',
|
|
290
|
+
N: 'N',
|
|
291
|
+
O: 'O',
|
|
292
|
+
P: 'P',
|
|
293
|
+
Q: 'Q',
|
|
294
|
+
R: 'R',
|
|
295
|
+
S: 'S',
|
|
296
|
+
T: 'T',
|
|
297
|
+
U: 'U',
|
|
298
|
+
V: 'V',
|
|
299
|
+
W: 'W',
|
|
300
|
+
X: 'X',
|
|
301
|
+
Y: 'Y',
|
|
302
|
+
Z: 'Z',
|
|
303
|
+
a: 'a',
|
|
304
|
+
b: 'b',
|
|
305
|
+
c: 'c',
|
|
306
|
+
d: 'd',
|
|
307
|
+
e: 'e',
|
|
308
|
+
f: 'f',
|
|
309
|
+
g: 'g',
|
|
310
|
+
h: 'h',
|
|
311
|
+
i: 'i',
|
|
312
|
+
j: 'j',
|
|
313
|
+
k: 'k',
|
|
314
|
+
l: 'l',
|
|
315
|
+
m: 'm',
|
|
316
|
+
n: 'n',
|
|
317
|
+
o: 'o',
|
|
318
|
+
p: 'p',
|
|
319
|
+
q: 'q',
|
|
320
|
+
r: 'r',
|
|
321
|
+
s: 's',
|
|
322
|
+
t: 't',
|
|
323
|
+
u: 'u',
|
|
324
|
+
v: 'v',
|
|
325
|
+
w: 'w',
|
|
326
|
+
x: 'x',
|
|
327
|
+
y: 'y',
|
|
328
|
+
z: 'z',
|
|
329
|
+
Meta: 'Meta',
|
|
330
|
+
ContextMenu: 'ContextMenu',
|
|
331
|
+
AudioVolumeMute: 'AudioVolumeMute',
|
|
332
|
+
AudioVolumeDown: 'AudioVolumeDown',
|
|
333
|
+
AudioVolumeUp: 'AudioVolumeUp',
|
|
334
|
+
F1: 'F1',
|
|
335
|
+
F2: 'F2',
|
|
336
|
+
F3: 'F3',
|
|
337
|
+
F4: 'F4',
|
|
338
|
+
F5: 'F5',
|
|
339
|
+
F6: 'F6',
|
|
340
|
+
F7: 'F7',
|
|
341
|
+
F8: 'F8',
|
|
342
|
+
F9: 'F9',
|
|
343
|
+
F10: 'F10',
|
|
344
|
+
F11: 'F11',
|
|
345
|
+
F12: 'F12',
|
|
346
|
+
NumLock: 'NumLock',
|
|
347
|
+
ScrollLock: 'ScrollLock',
|
|
348
|
+
';': ';',
|
|
349
|
+
'=': '=',
|
|
350
|
+
'': '',
|
|
351
|
+
'-': '-',
|
|
352
|
+
'.': '.',
|
|
353
|
+
'/': '/',
|
|
354
|
+
'`': '`',
|
|
355
|
+
'[': '[',
|
|
356
|
+
'\\': '\\',
|
|
357
|
+
']': ']',
|
|
358
|
+
"'": "'",
|
|
359
|
+
'~': '~',
|
|
360
|
+
'!': '!',
|
|
361
|
+
'@': '@',
|
|
362
|
+
'#': '#',
|
|
363
|
+
$: '$',
|
|
364
|
+
'%': '%',
|
|
365
|
+
'^': '^',
|
|
366
|
+
'&': '&',
|
|
367
|
+
'*': '*',
|
|
368
|
+
'(': '(',
|
|
369
|
+
')': ')',
|
|
370
|
+
_: '_',
|
|
371
|
+
'+': '+',
|
|
372
|
+
'{': '{',
|
|
373
|
+
'}': '}',
|
|
374
|
+
'|': '|',
|
|
375
|
+
':': ':',
|
|
376
|
+
'"': '"',
|
|
377
|
+
'<': '<',
|
|
378
|
+
'>': '>',
|
|
379
|
+
'?': '?',
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
package/src/utils/ref.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MutableRefObject, RefCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
export type InnerRef<T extends HTMLElement | null> = MutableRefObject<T> | RefCallback<T>;
|
|
4
|
+
|
|
5
|
+
/** Sets a ref using either a ref callback or a ref object */
|
|
6
|
+
export function setRef<T extends HTMLElement | null>(ref: InnerRef<T>, node: T): void {
|
|
7
|
+
if (typeof ref === 'function') return ref(node);
|
|
8
|
+
ref.current = node;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrolls the container to make the element visible.
|
|
3
|
+
*
|
|
4
|
+
* @param element -- The element to scroll into view.
|
|
5
|
+
* @param container -- The container to scroll.
|
|
6
|
+
*/
|
|
7
|
+
export function scrollElementIntoView(element: HTMLElement, container: HTMLElement): void {
|
|
8
|
+
const elementRect = element.getBoundingClientRect();
|
|
9
|
+
|
|
10
|
+
const containerRect = container.getBoundingClientRect();
|
|
11
|
+
|
|
12
|
+
if (elementRect.top < containerRect.top) {
|
|
13
|
+
// Element is above the visible area
|
|
14
|
+
container.scrollTop -= containerRect.top - elementRect.top;
|
|
15
|
+
} else if (elementRect.bottom > containerRect.bottom) {
|
|
16
|
+
// Element is below the visible area
|
|
17
|
+
container.scrollTop += elementRect.bottom - containerRect.bottom;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (elementRect.left < containerRect.left) {
|
|
21
|
+
// Element is to the left of the visible area
|
|
22
|
+
container.scrollLeft -= containerRect.left - elementRect.left;
|
|
23
|
+
} else if (elementRect.right > containerRect.right) {
|
|
24
|
+
// Element is to the right of the visible area
|
|
25
|
+
container.scrollLeft += elementRect.right - containerRect.right;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|