@true-engineering/true-react-common-ui-kit 1.0.1
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/LICENSE +201 -0
- package/README.md +13 -0
- package/dist/components/AccountInfo/AccountInfo.d.ts +11 -0
- package/dist/components/AccountInfo/AccountInfo.styles.d.ts +64 -0
- package/dist/components/AccountInfo/index.d.ts +2 -0
- package/dist/components/AddButton/AddButton.d.ts +12 -0
- package/dist/components/AddButton/AddButton.styles.d.ts +28 -0
- package/dist/components/AddButton/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +28 -0
- package/dist/components/Button/Button.styles.d.ts +150 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.styles.d.ts +47 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/CloseButton/CloseButton.d.ts +10 -0
- package/dist/components/CloseButton/CloseButton.styles.d.ts +27 -0
- package/dist/components/CloseButton/index.d.ts +2 -0
- package/dist/components/Colors/Colors.d.ts +2 -0
- package/dist/components/Colors/Colors.styles.d.ts +32 -0
- package/dist/components/Colors/index.d.ts +2 -0
- package/dist/components/CssBaseline/CssBaseline.d.ts +7 -0
- package/dist/components/CssBaseline/CssBaseline.styles.d.ts +11 -0
- package/dist/components/CssBaseline/index.d.ts +2 -0
- package/dist/components/DateInput/DateInput.d.ts +14 -0
- package/dist/components/DateInput/DateInput.styles.d.ts +11 -0
- package/dist/components/DateInput/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.d.ts +34 -0
- package/dist/components/DatePicker/DatePicker.styles.d.ts +46 -0
- package/dist/components/DatePicker/DatePickerHeader/DatePickerHeader.d.ts +14 -0
- package/dist/components/DatePicker/DatePickerHeader/DatePickerHeader.styles.d.ts +69 -0
- package/dist/components/DatePicker/DatePickerHeader/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePickerInput/DatePickerInput.d.ts +11 -0
- package/dist/components/DatePicker/DatePickerInput/DatePickerInput.styles.d.ts +20 -0
- package/dist/components/DatePicker/DatePickerInput/index.d.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +4 -0
- package/dist/components/Description/Description.d.ts +12 -0
- package/dist/components/Description/Description.styles.d.ts +24 -0
- package/dist/components/Description/index.d.ts +2 -0
- package/dist/components/FiltersPane/FilterInterval/FilterInterval.d.ts +26 -0
- package/dist/components/FiltersPane/FilterInterval/FilterInterval.styles.d.ts +52 -0
- package/dist/components/FiltersPane/FilterInterval/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterMultiSelect/FilterMultiSelect.d.ts +5 -0
- package/dist/components/FiltersPane/FilterMultiSelect/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterSelect/FilterSelect.d.ts +25 -0
- package/dist/components/FiltersPane/FilterSelect/FilterSelect.styles.d.ts +124 -0
- package/dist/components/FiltersPane/FilterSelect/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterSelect/locales.d.ts +11 -0
- package/dist/components/FiltersPane/FilterValueView/FilterValueView.d.ts +3 -0
- package/dist/components/FiltersPane/FilterValueView/FilterValueView.styles.d.ts +12 -0
- package/dist/components/FiltersPane/FilterValueView/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterWithDates/FilterWithDates.d.ts +23 -0
- package/dist/components/FiltersPane/FilterWithDates/FilterWithDates.styles.d.ts +47 -0
- package/dist/components/FiltersPane/FilterWithDates/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.d.ts +16 -0
- package/dist/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.styles.d.ts +12 -0
- package/dist/components/FiltersPane/FilterWithPeriod/index.d.ts +1 -0
- package/dist/components/FiltersPane/FilterWrapper/FilterWrapper.d.ts +27 -0
- package/dist/components/FiltersPane/FilterWrapper/FilterWrapper.styles.d.ts +96 -0
- package/dist/components/FiltersPane/FilterWrapper/index.d.ts +1 -0
- package/dist/components/FiltersPane/FiltersPane.d.ts +22 -0
- package/dist/components/FiltersPane/FiltersPane.styles.d.ts +57 -0
- package/dist/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.d.ts +26 -0
- package/dist/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +91 -0
- package/dist/components/FiltersPane/FiltersPaneSearch/index.d.ts +1 -0
- package/dist/components/FiltersPane/index.d.ts +16 -0
- package/dist/components/FiltersPane/locales.d.ts +28 -0
- package/dist/components/FiltersPane/types.d.ts +77 -0
- package/dist/components/Flag/Flag.d.ts +8 -0
- package/dist/components/Flag/Flag.styles.d.ts +12 -0
- package/dist/components/Flag/augment.d.ts +1 -0
- package/dist/components/Flag/index.d.ts +2 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +25 -0
- package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +101 -0
- package/dist/components/FlexibleTable/TableRow.d.ts +28 -0
- package/dist/components/FlexibleTable/TableValue.d.ts +21 -0
- package/dist/components/FlexibleTable/index.d.ts +3 -0
- package/dist/components/FlexibleTable/types.d.ts +44 -0
- package/dist/components/Icon/ComplexIconBoilerplate.d.ts +7 -0
- package/dist/components/Icon/Icon.d.ts +11 -0
- package/dist/components/Icon/Icon.styles.d.ts +8 -0
- package/dist/components/Icon/IconBoilerplate.d.ts +6 -0
- package/dist/components/Icon/complexIcons/augment.d.ts +1 -0
- package/dist/components/Icon/complexIcons/icons.d.ts +4 -0
- package/dist/components/Icon/complexIcons/index.d.ts +1 -0
- package/dist/components/Icon/icons/icons.d.ts +9 -0
- package/dist/components/Icon/icons/index.d.ts +1 -0
- package/dist/components/Icon/index.d.ts +4 -0
- package/dist/components/IncrementInput/ChangeButton.d.ts +11 -0
- package/dist/components/IncrementInput/IncrementInput.d.ts +8 -0
- package/dist/components/IncrementInput/IncrementInput.styles.d.ts +63 -0
- package/dist/components/IncrementInput/index.d.ts +2 -0
- package/dist/components/Input/Input.d.ts +45 -0
- package/dist/components/Input/Input.styles.d.ts +247 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/List/List.d.ts +21 -0
- package/dist/components/List/List.styles.d.ts +39 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/Modal/Modal.d.ts +26 -0
- package/dist/components/Modal/Modal.styles.d.ts +239 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/MoreMenu/MoreMenu.d.ts +14 -0
- package/dist/components/MoreMenu/MoreMenu.styles.d.ts +53 -0
- package/dist/components/MoreMenu/index.d.ts +2 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +19 -0
- package/dist/components/MultiSelect/MultiSelect.styles.d.ts +44 -0
- package/dist/components/MultiSelect/MultiSelectInput/MultiSelectInput.d.ts +11 -0
- package/dist/components/MultiSelect/MultiSelectInput/MultiSelectInput.styles.d.ts +62 -0
- package/dist/components/MultiSelect/MultiSelectInput/index.d.ts +1 -0
- package/dist/components/MultiSelect/index.d.ts +3 -0
- package/dist/components/MultiSelectList/MultiSelectList.d.ts +28 -0
- package/dist/components/MultiSelectList/MultiSelectList.styles.d.ts +105 -0
- package/dist/components/MultiSelectList/index.d.ts +2 -0
- package/dist/components/MultiSelectList/locales.d.ts +11 -0
- package/dist/components/Notification/Notification.d.ts +16 -0
- package/dist/components/Notification/Notification.styles.d.ts +37 -0
- package/dist/components/Notification/index.d.ts +2 -0
- package/dist/components/NumberInput/NumberInput.d.ts +13 -0
- package/dist/components/NumberInput/helpers.d.ts +2 -0
- package/dist/components/NumberInput/index.d.ts +1 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +13 -0
- package/dist/components/PhoneInput/PhoneInput.styles.d.ts +66 -0
- package/dist/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.d.ts +15 -0
- package/dist/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.styles.d.ts +83 -0
- package/dist/components/PhoneInput/PhoneInputCountryList/index.d.ts +2 -0
- package/dist/components/PhoneInput/index.d.ts +5 -0
- package/dist/components/PhoneInput/phone-info.d.ts +2 -0
- package/dist/components/PhoneInput/types.d.ts +15 -0
- package/dist/components/RadioButton/RadioButton.d.ts +13 -0
- package/dist/components/RadioButton/RadioButton.styles.d.ts +30 -0
- package/dist/components/RadioButton/index.d.ts +2 -0
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +382 -0
- package/dist/components/ScrollIntoViewIfNeeded/index.d.ts +1 -0
- package/dist/components/SearchInput/SearchInput.d.ts +7 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts +39 -0
- package/dist/components/SearchInput/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +27 -0
- package/dist/components/Select/Select.styles.d.ts +61 -0
- package/dist/components/Select/SelectList/SelectList.d.ts +21 -0
- package/dist/components/Select/SelectList/SelectList.styles.d.ts +46 -0
- package/dist/components/Select/SelectList/index.d.ts +1 -0
- package/dist/components/Select/helpers.d.ts +3 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/SmartInput/SmartInput.d.ts +22 -0
- package/dist/components/SmartInput/helpers.d.ts +10 -0
- package/dist/components/SmartInput/index.d.ts +1 -0
- package/dist/components/Switch/Switch.d.ts +20 -0
- package/dist/components/Switch/Switch.styles.d.ts +62 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/TextArea/TextArea.d.ts +29 -0
- package/dist/components/TextArea/TextArea.styles.d.ts +128 -0
- package/dist/components/TextArea/index.d.ts +2 -0
- package/dist/components/TextWithInfo/TextWithInfo.d.ts +15 -0
- package/dist/components/TextWithInfo/TextWithInfo.styles.d.ts +48 -0
- package/dist/components/TextWithInfo/index.d.ts +2 -0
- package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +20 -0
- package/dist/components/TextWithTooltip/TextWithTooltip.styles.d.ts +14 -0
- package/dist/components/TextWithTooltip/index.d.ts +2 -0
- package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +12 -0
- package/dist/components/ThemedPreloader/ThemedPreloader.styles.d.ts +14 -0
- package/dist/components/ThemedPreloader/components/DefaultPreloader/DefaultPreloader.d.ts +2 -0
- package/dist/components/ThemedPreloader/components/DefaultPreloader/index.d.ts +1 -0
- package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.d.ts +7 -0
- package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.d.ts +43 -0
- package/dist/components/ThemedPreloader/components/DotsPreloader/index.d.ts +2 -0
- package/dist/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.d.ts +9 -0
- package/dist/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.d.ts +9 -0
- package/dist/components/ThemedPreloader/components/SvgPreloader/index.d.ts +2 -0
- package/dist/components/ThemedPreloader/components/index.d.ts +2 -0
- package/dist/components/ThemedPreloader/index.d.ts +2 -0
- package/dist/components/Toaster/Toaster.d.ts +17 -0
- package/dist/components/Toaster/Toaster.styles.d.ts +45 -0
- package/dist/components/Toaster/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/components/Tooltip/Tooltip.styles.d.ts +35 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/types.d.ts +1 -0
- package/dist/components/index.d.ts +36 -0
- package/dist/helpers/colors.d.ts +2 -0
- package/dist/helpers/data-attributes.d.ts +5 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/phone.d.ts +11 -0
- package/dist/helpers/popper-helpers.d.ts +2 -0
- package/dist/helpers/utils.d.ts +17 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/use-did-mount-effect.d.ts +2 -0
- package/dist/hooks/use-dropdown.d.ts +11 -0
- package/dist/hooks/use-is-mounted.d.ts +1 -0
- package/dist/hooks/use-on-click-outside.d.ts +5 -0
- package/dist/hooks/use-theme.d.ts +9 -0
- package/dist/hooks/use-tweak-styles.d.ts +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/style.css +745 -0
- package/dist/theme.d.ts +67 -0
- package/dist/true-react-common-ui-kit.js +26961 -0
- package/dist/true-react-common-ui-kit.js.map +1 -0
- package/dist/true-react-common-ui-kit.umd.cjs +26951 -0
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/vite-env.d.ts +1 -0
- package/package.json +90 -0
- package/src/components/AccountInfo/AccountInfo.stories.tsx +35 -0
- package/src/components/AccountInfo/AccountInfo.styles.ts +55 -0
- package/src/components/AccountInfo/AccountInfo.tsx +106 -0
- package/src/components/AccountInfo/index.ts +2 -0
- package/src/components/AddButton/AddButton.stories.tsx +21 -0
- package/src/components/AddButton/AddButton.styles.ts +34 -0
- package/src/components/AddButton/AddButton.tsx +49 -0
- package/src/components/AddButton/index.ts +2 -0
- package/src/components/Button/Button.stories.tsx +61 -0
- package/src/components/Button/Button.styles.ts +196 -0
- package/src/components/Button/Button.tsx +195 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +35 -0
- package/src/components/Checkbox/Checkbox.styles.ts +59 -0
- package/src/components/Checkbox/Checkbox.tsx +93 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/CloseButton/CloseButton.styles.ts +34 -0
- package/src/components/CloseButton/CloseButton.tsx +37 -0
- package/src/components/CloseButton/index.ts +2 -0
- package/src/components/Colors/Colors.stories.tsx +7 -0
- package/src/components/Colors/Colors.styles.ts +38 -0
- package/src/components/Colors/Colors.tsx +34 -0
- package/src/components/Colors/index.ts +2 -0
- package/src/components/CssBaseline/CssBaseline.styles.ts +15 -0
- package/src/components/CssBaseline/CssBaseline.tsx +17 -0
- package/src/components/CssBaseline/index.ts +2 -0
- package/src/components/DateInput/DateInput.stories.tsx +63 -0
- package/src/components/DateInput/DateInput.styles.ts +14 -0
- package/src/components/DateInput/DateInput.tsx +60 -0
- package/src/components/DateInput/index.ts +2 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +96 -0
- package/src/components/DatePicker/DatePicker.styles.ts +54 -0
- package/src/components/DatePicker/DatePicker.tsx +358 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.styles.ts +84 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.tsx +94 -0
- package/src/components/DatePicker/DatePickerHeader/index.ts +1 -0
- package/src/components/DatePicker/DatePickerInput/DatePickerInput.styles.ts +25 -0
- package/src/components/DatePicker/DatePickerInput/DatePickerInput.tsx +31 -0
- package/src/components/DatePicker/DatePickerInput/index.ts +1 -0
- package/src/components/DatePicker/index.ts +4 -0
- package/src/components/Description/Description.stories.tsx +29 -0
- package/src/components/Description/Description.styles.ts +31 -0
- package/src/components/Description/Description.tsx +69 -0
- package/src/components/Description/index.ts +2 -0
- package/src/components/FiltersPane/FilterInterval/FilterInterval.styles.ts +64 -0
- package/src/components/FiltersPane/FilterInterval/FilterInterval.tsx +162 -0
- package/src/components/FiltersPane/FilterInterval/index.ts +1 -0
- package/src/components/FiltersPane/FilterMultiSelect/FilterMultiSelect.tsx +14 -0
- package/src/components/FiltersPane/FilterMultiSelect/index.ts +1 -0
- package/src/components/FiltersPane/FilterSelect/FilterSelect.styles.ts +144 -0
- package/src/components/FiltersPane/FilterSelect/FilterSelect.tsx +397 -0
- package/src/components/FiltersPane/FilterSelect/index.ts +1 -0
- package/src/components/FiltersPane/FilterSelect/locales.ts +37 -0
- package/src/components/FiltersPane/FilterValueView/FilterValueView.styles.tsx +15 -0
- package/src/components/FiltersPane/FilterValueView/FilterValueView.tsx +186 -0
- package/src/components/FiltersPane/FilterValueView/index.tsx +1 -0
- package/src/components/FiltersPane/FilterWithDates/FilterWithDates.styles.ts +60 -0
- package/src/components/FiltersPane/FilterWithDates/FilterWithDates.tsx +222 -0
- package/src/components/FiltersPane/FilterWithDates/index.ts +1 -0
- package/src/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.styles.ts +17 -0
- package/src/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.tsx +231 -0
- package/src/components/FiltersPane/FilterWithPeriod/index.ts +1 -0
- package/src/components/FiltersPane/FilterWrapper/FilterWrapper.styles.ts +110 -0
- package/src/components/FiltersPane/FilterWrapper/FilterWrapper.tsx +360 -0
- package/src/components/FiltersPane/FilterWrapper/index.ts +1 -0
- package/src/components/FiltersPane/FiltersPane.stories.tsx +307 -0
- package/src/components/FiltersPane/FiltersPane.styles.ts +71 -0
- package/src/components/FiltersPane/FiltersPane.tsx +193 -0
- package/src/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.styles.ts +109 -0
- package/src/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.tsx +175 -0
- package/src/components/FiltersPane/FiltersPaneSearch/index.ts +1 -0
- package/src/components/FiltersPane/index.ts +20 -0
- package/src/components/FiltersPane/locales.ts +107 -0
- package/src/components/FiltersPane/types.ts +126 -0
- package/src/components/Flag/Flag.stories.tsx +29 -0
- package/src/components/Flag/Flag.styles.ts +18 -0
- package/src/components/Flag/Flag.tsx +28 -0
- package/src/components/Flag/augment.d.ts +1 -0
- package/src/components/Flag/index.ts +2 -0
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +80 -0
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +131 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +241 -0
- package/src/components/FlexibleTable/TableRow.tsx +164 -0
- package/src/components/FlexibleTable/TableValue.tsx +86 -0
- package/src/components/FlexibleTable/fixture-test.ts +254 -0
- package/src/components/FlexibleTable/index.ts +3 -0
- package/src/components/FlexibleTable/types.ts +58 -0
- package/src/components/Icon/ComplexIconBoilerplate.tsx +17 -0
- package/src/components/Icon/Icon.stories.tsx +88 -0
- package/src/components/Icon/Icon.styles.ts +10 -0
- package/src/components/Icon/Icon.tsx +34 -0
- package/src/components/Icon/IconBoilerplate.tsx +42 -0
- package/src/components/Icon/complexIcons/augment.d.ts +1 -0
- package/src/components/Icon/complexIcons/avatarGreen.svg +58 -0
- package/src/components/Icon/complexIcons/icons.ts +7 -0
- package/src/components/Icon/complexIcons/index.ts +1 -0
- package/src/components/Icon/icons/icons.ts +838 -0
- package/src/components/Icon/icons/index.ts +1 -0
- package/src/components/Icon/index.ts +4 -0
- package/src/components/IncrementInput/ChangeButton.tsx +34 -0
- package/src/components/IncrementInput/IncrementInput.stories.tsx +34 -0
- package/src/components/IncrementInput/IncrementInput.styles.ts +77 -0
- package/src/components/IncrementInput/IncrementInput.tsx +95 -0
- package/src/components/IncrementInput/index.ts +2 -0
- package/src/components/Input/Input.stories.tsx +92 -0
- package/src/components/Input/Input.styles.ts +305 -0
- package/src/components/Input/Input.tsx +308 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/List/List.stories.tsx +62 -0
- package/src/components/List/List.styles.ts +52 -0
- package/src/components/List/List.tsx +75 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/Modal/Modal.stories.tsx +113 -0
- package/src/components/Modal/Modal.styles.ts +308 -0
- package/src/components/Modal/Modal.tsx +210 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/MoreMenu/MoreMenu.stories.tsx +46 -0
- package/src/components/MoreMenu/MoreMenu.styles.ts +68 -0
- package/src/components/MoreMenu/MoreMenu.tsx +91 -0
- package/src/components/MoreMenu/index.ts +2 -0
- package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -0
- package/src/components/MultiSelect/MultiSelect.styles.ts +55 -0
- package/src/components/MultiSelect/MultiSelect.tsx +98 -0
- package/src/components/MultiSelect/MultiSelectInput/MultiSelectInput.styles.ts +73 -0
- package/src/components/MultiSelect/MultiSelectInput/MultiSelectInput.tsx +62 -0
- package/src/components/MultiSelect/MultiSelectInput/index.ts +1 -0
- package/src/components/MultiSelect/index.ts +3 -0
- package/src/components/MultiSelectList/MultiSelectList.styles.ts +125 -0
- package/src/components/MultiSelectList/MultiSelectList.tsx +519 -0
- package/src/components/MultiSelectList/index.ts +2 -0
- package/src/components/MultiSelectList/locales.ts +37 -0
- package/src/components/Notification/Notification.stories.tsx +51 -0
- package/src/components/Notification/Notification.styles.ts +50 -0
- package/src/components/Notification/Notification.tsx +84 -0
- package/src/components/Notification/index.ts +2 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +35 -0
- package/src/components/NumberInput/NumberInput.tsx +142 -0
- package/src/components/NumberInput/helpers.ts +68 -0
- package/src/components/NumberInput/index.ts +1 -0
- package/src/components/PhoneInput/PhoneInput.stories.tsx +71 -0
- package/src/components/PhoneInput/PhoneInput.styles.ts +84 -0
- package/src/components/PhoneInput/PhoneInput.tsx +223 -0
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.stories.tsx +21 -0
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.styles.ts +100 -0
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.tsx +171 -0
- package/src/components/PhoneInput/PhoneInputCountryList/index.ts +2 -0
- package/src/components/PhoneInput/index.ts +6 -0
- package/src/components/PhoneInput/phone-info.ts +2167 -0
- package/src/components/PhoneInput/types.ts +16 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +46 -0
- package/src/components/RadioButton/RadioButton.styles.ts +37 -0
- package/src/components/RadioButton/RadioButton.tsx +56 -0
- package/src/components/RadioButton/index.ts +2 -0
- package/src/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.ts +66 -0
- package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -0
- package/src/components/SearchInput/SearchInput.stories.tsx +24 -0
- package/src/components/SearchInput/SearchInput.styles.ts +50 -0
- package/src/components/SearchInput/SearchInput.tsx +63 -0
- package/src/components/SearchInput/index.ts +2 -0
- package/src/components/Select/Select.stories.tsx +230 -0
- package/src/components/Select/Select.styles.ts +74 -0
- package/src/components/Select/Select.tsx +440 -0
- package/src/components/Select/SelectList/SelectList.styles.ts +57 -0
- package/src/components/Select/SelectList/SelectList.tsx +135 -0
- package/src/components/Select/SelectList/index.ts +1 -0
- package/src/components/Select/helpers.ts +13 -0
- package/src/components/Select/index.ts +3 -0
- package/src/components/SmartInput/SmartInput.stories.tsx +63 -0
- package/src/components/SmartInput/SmartInput.tsx +177 -0
- package/src/components/SmartInput/helpers.ts +85 -0
- package/src/components/SmartInput/index.ts +1 -0
- package/src/components/Switch/Switch.stories.tsx +40 -0
- package/src/components/Switch/Switch.styles.ts +75 -0
- package/src/components/Switch/Switch.tsx +89 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/TextArea/TextArea.stories.tsx +35 -0
- package/src/components/TextArea/TextArea.styles.ts +153 -0
- package/src/components/TextArea/TextArea.tsx +178 -0
- package/src/components/TextArea/index.ts +2 -0
- package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -0
- package/src/components/TextWithInfo/TextWithInfo.styles.ts +60 -0
- package/src/components/TextWithInfo/TextWithInfo.tsx +67 -0
- package/src/components/TextWithInfo/index.ts +2 -0
- package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -0
- package/src/components/TextWithTooltip/TextWithTooltip.styles.ts +19 -0
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +163 -0
- package/src/components/TextWithTooltip/index.ts +2 -0
- package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -0
- package/src/components/ThemedPreloader/ThemedPreloader.styles.ts +21 -0
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +56 -0
- package/src/components/ThemedPreloader/components/DefaultPreloader/DefaultPreloader.tsx +34 -0
- package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -0
- package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.ts +54 -0
- package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.tsx +18 -0
- package/src/components/ThemedPreloader/components/DotsPreloader/index.ts +2 -0
- package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.ts +11 -0
- package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.tsx +32 -0
- package/src/components/ThemedPreloader/components/SvgPreloader/index.ts +2 -0
- package/src/components/ThemedPreloader/components/index.ts +2 -0
- package/src/components/ThemedPreloader/index.ts +2 -0
- package/src/components/Toaster/Toaster.stories.tsx +34 -0
- package/src/components/Toaster/Toaster.styles.ts +59 -0
- package/src/components/Toaster/Toaster.tsx +113 -0
- package/src/components/Toaster/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +21 -0
- package/src/components/Tooltip/Tooltip.styles.ts +45 -0
- package/src/components/Tooltip/Tooltip.tsx +40 -0
- package/src/components/Tooltip/index.ts +3 -0
- package/src/components/Tooltip/types.ts +1 -0
- package/src/components/index.ts +36 -0
- package/src/helpers/colors.ts +2 -0
- package/src/helpers/data-attributes.ts +18 -0
- package/src/helpers/dateHelpers/date-helpers.ts +9 -0
- package/src/helpers/index.ts +5 -0
- package/src/helpers/phone.ts +106 -0
- package/src/helpers/popper-helpers.ts +17 -0
- package/src/helpers/utils.ts +164 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-did-mount-effect.ts +21 -0
- package/src/hooks/use-dropdown.ts +85 -0
- package/src/hooks/use-is-mounted.ts +15 -0
- package/src/hooks/use-on-click-outside.ts +92 -0
- package/src/hooks/use-theme.ts +36 -0
- package/src/hooks/use-tweak-styles.ts +14 -0
- package/src/index.ts +5 -0
- package/src/theme.ts +155 -0
- package/src/types.ts +106 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { FC, useState, useRef, useMemo } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../Icon';
|
|
5
|
+
import { Flag } from '../Flag';
|
|
6
|
+
import {
|
|
7
|
+
useOnClickOutsideWithRef,
|
|
8
|
+
useTheme,
|
|
9
|
+
useTweakStyles,
|
|
10
|
+
} from '../../hooks';
|
|
11
|
+
import { IInputProps, Input } from '../Input';
|
|
12
|
+
import {
|
|
13
|
+
getCountryCodeFromPhone,
|
|
14
|
+
getFullPhone,
|
|
15
|
+
getPhoneMask,
|
|
16
|
+
getPhoneObjFromString,
|
|
17
|
+
findCountryByCode,
|
|
18
|
+
} from '../../helpers';
|
|
19
|
+
import { PhoneInputCountryList } from './PhoneInputCountryList';
|
|
20
|
+
import { IPhoneInfo, IPhoneValue } from './types';
|
|
21
|
+
|
|
22
|
+
import { PhoneInputStyles, styles } from './PhoneInput.styles';
|
|
23
|
+
|
|
24
|
+
export interface IPhoneInputProps
|
|
25
|
+
extends Omit<
|
|
26
|
+
IInputProps,
|
|
27
|
+
'value' | 'onChange' | 'type' | 'mask' | 'units' | 'placeholder'
|
|
28
|
+
> {
|
|
29
|
+
tweakStyles?: PhoneInputStyles;
|
|
30
|
+
locale?: string;
|
|
31
|
+
codeSearchPlaceholder?: string;
|
|
32
|
+
noMatchesLabel?: string;
|
|
33
|
+
value?: IPhoneValue;
|
|
34
|
+
onChange: (
|
|
35
|
+
phone: IPhoneValue,
|
|
36
|
+
event: React.MouseEvent | KeyboardEvent | React.FormEvent<HTMLInputElement>,
|
|
37
|
+
) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const DEFAULT_VALUE: IPhoneValue = { phoneNumber: '', dialCode: '' };
|
|
41
|
+
|
|
42
|
+
export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
43
|
+
locale = 'ru',
|
|
44
|
+
value = DEFAULT_VALUE,
|
|
45
|
+
onChange,
|
|
46
|
+
testId,
|
|
47
|
+
isDisabled,
|
|
48
|
+
isInvalid,
|
|
49
|
+
isActive,
|
|
50
|
+
tweakStyles,
|
|
51
|
+
codeSearchPlaceholder = 'Поиск',
|
|
52
|
+
noMatchesLabel = 'Ничего не найдено',
|
|
53
|
+
...inputProps
|
|
54
|
+
}) => {
|
|
55
|
+
const { classes, componentStyles } = useTheme(
|
|
56
|
+
'PhoneInput',
|
|
57
|
+
styles,
|
|
58
|
+
tweakStyles,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const list = useRef<HTMLDivElement>(null);
|
|
62
|
+
const inputWrapper = useRef<HTMLDivElement>(null);
|
|
63
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
64
|
+
const [isListOpen, setIsListOpen] = useState(false);
|
|
65
|
+
const [isFocused, setFocused] = useState(false);
|
|
66
|
+
|
|
67
|
+
const phoneWithCode = getFullPhone(value);
|
|
68
|
+
|
|
69
|
+
const countryCode = useMemo(
|
|
70
|
+
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
71
|
+
[value.dialCode, value.phoneNumber],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const handleClose = () => {
|
|
75
|
+
setIsListOpen(false);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const handleChange = (
|
|
79
|
+
inputValue: string,
|
|
80
|
+
event: React.FormEvent<HTMLInputElement>,
|
|
81
|
+
) => {
|
|
82
|
+
// if (event.type === 'change') - нужно из-за InputMask
|
|
83
|
+
// Помимо change, еще могут приходить focus и blur, когда input пустой и тогда происходят неприятные сайд-эффекты
|
|
84
|
+
if (event.type === 'change') {
|
|
85
|
+
const newValue = inputValue.replace(/[^0-9]/g, '');
|
|
86
|
+
let selectedCountryCode = countryCode;
|
|
87
|
+
|
|
88
|
+
const selectedCountry = findCountryByCode(countryCode);
|
|
89
|
+
|
|
90
|
+
// Проверяем введенный номер на соответствие с selectedCountry
|
|
91
|
+
// Если не соответствует, то пытаемся найти countryCode, для которой
|
|
92
|
+
// данный номер будет валидным (функция getPhoneObjFromString)
|
|
93
|
+
if (selectedCountry !== undefined) {
|
|
94
|
+
// Сначала проверяем, что введенный телефон удовлетворяет одному
|
|
95
|
+
// из fullCode для выбранной страны
|
|
96
|
+
const isSomeFullCodeValid = selectedCountry.fullCodes.some(
|
|
97
|
+
(fullCode) => {
|
|
98
|
+
if (newValue.length >= fullCode.length) {
|
|
99
|
+
return newValue.startsWith(fullCode);
|
|
100
|
+
} else {
|
|
101
|
+
return fullCode.startsWith(newValue);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// После проверяем, что введенный телефон удовлетворяет dialCode для выбранной страны
|
|
107
|
+
const isDialCodeValid = newValue.startsWith(selectedCountry.dialCode);
|
|
108
|
+
|
|
109
|
+
if (!isSomeFullCodeValid || !isDialCodeValid) {
|
|
110
|
+
selectedCountryCode = undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
onChange(getPhoneObjFromString(newValue, selectedCountryCode), event);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleSelect = (
|
|
119
|
+
newPhoneInfo: IPhoneInfo,
|
|
120
|
+
event: React.MouseEvent | KeyboardEvent,
|
|
121
|
+
) => {
|
|
122
|
+
if (newPhoneInfo.countryCode !== countryCode) {
|
|
123
|
+
onChange(
|
|
124
|
+
{
|
|
125
|
+
phoneNumber: '',
|
|
126
|
+
dialCode: newPhoneInfo.dialCode,
|
|
127
|
+
countryCode: newPhoneInfo.countryCode,
|
|
128
|
+
},
|
|
129
|
+
event,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
handleClose();
|
|
133
|
+
|
|
134
|
+
const input = inputRef?.current;
|
|
135
|
+
if (input !== null) {
|
|
136
|
+
input.focus();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
141
|
+
setFocused(true);
|
|
142
|
+
if (inputProps.onFocus !== undefined) {
|
|
143
|
+
inputProps?.onFocus(event);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
148
|
+
setFocused(false);
|
|
149
|
+
if (inputProps.onBlur !== undefined) {
|
|
150
|
+
inputProps?.onBlur(event);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
useOnClickOutsideWithRef(list, handleClose, inputWrapper);
|
|
155
|
+
|
|
156
|
+
const tweakInputStyles = useTweakStyles(
|
|
157
|
+
componentStyles,
|
|
158
|
+
tweakStyles,
|
|
159
|
+
'tweakInput',
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const tweakCountryListStyles = useTweakStyles(
|
|
163
|
+
componentStyles,
|
|
164
|
+
tweakStyles,
|
|
165
|
+
'tweakCountryList',
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div className={classes.root} data-testid={testId}>
|
|
170
|
+
<div
|
|
171
|
+
className={clsx(classes.countrySelectContainer, {
|
|
172
|
+
[classes.disabledCountrySelect]: isDisabled,
|
|
173
|
+
[classes.invalidBorder]: isInvalid,
|
|
174
|
+
[classes.focusedBorder]: isActive || isListOpen || isFocused,
|
|
175
|
+
})}
|
|
176
|
+
ref={inputWrapper}
|
|
177
|
+
onClick={!isDisabled ? () => setIsListOpen(!isListOpen) : undefined}
|
|
178
|
+
>
|
|
179
|
+
<div className={classes.flag}>
|
|
180
|
+
<Flag countryCode={countryCode} />
|
|
181
|
+
</div>
|
|
182
|
+
<div
|
|
183
|
+
className={clsx(classes.arrow, {
|
|
184
|
+
[classes.up]: isListOpen,
|
|
185
|
+
[classes.invalidArrow]: isInvalid,
|
|
186
|
+
})}
|
|
187
|
+
>
|
|
188
|
+
<Icon type="chevron-down" />
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<Input
|
|
193
|
+
onChange={handleChange}
|
|
194
|
+
value={phoneWithCode}
|
|
195
|
+
mask={getPhoneMask(countryCode)}
|
|
196
|
+
// alwaysShowMask={false}
|
|
197
|
+
ref={inputRef}
|
|
198
|
+
isDisabled={isDisabled}
|
|
199
|
+
isInvalid={isInvalid}
|
|
200
|
+
isActive={isListOpen || isActive}
|
|
201
|
+
testId={testId !== undefined ? `${testId}-input` : undefined}
|
|
202
|
+
onFocus={handleFocus}
|
|
203
|
+
onBlur={handleBlur}
|
|
204
|
+
tweakStyles={tweakInputStyles}
|
|
205
|
+
{...inputProps}
|
|
206
|
+
/>
|
|
207
|
+
|
|
208
|
+
{isListOpen && (
|
|
209
|
+
<div className={classes.flagListContainer} ref={list}>
|
|
210
|
+
<PhoneInputCountryList
|
|
211
|
+
selectedCountryCode={countryCode}
|
|
212
|
+
placeholder={codeSearchPlaceholder}
|
|
213
|
+
onChange={handleSelect}
|
|
214
|
+
closeList={handleClose}
|
|
215
|
+
locale={locale}
|
|
216
|
+
tweakStyles={tweakCountryListStyles}
|
|
217
|
+
noMatchesLabel={noMatchesLabel}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import PhoneInputCountryList from './PhoneInputCountryList';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Inputs/PhoneInput/PhoneInputCountryList',
|
|
6
|
+
component: PhoneInputCountryList,
|
|
7
|
+
args: {
|
|
8
|
+
locale: 'ru',
|
|
9
|
+
placeholder: 'Поиск',
|
|
10
|
+
noMatchesLabel: 'Ничего не найдено',
|
|
11
|
+
},
|
|
12
|
+
parameters: {
|
|
13
|
+
controls: {
|
|
14
|
+
exclude: ['data', 'tweakStyles', 'testId'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} as ComponentMeta<typeof PhoneInputCountryList>;
|
|
18
|
+
|
|
19
|
+
export const Default: ComponentStory<typeof PhoneInputCountryList> = (args) => (
|
|
20
|
+
<PhoneInputCountryList {...args} />
|
|
21
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { colors, dimensions, helpers } from '../../../theme';
|
|
2
|
+
import { ComponentStyles } from '../../../types';
|
|
3
|
+
|
|
4
|
+
const ROW_HEIGHT = 40;
|
|
5
|
+
const LIST_PADDING = 10;
|
|
6
|
+
|
|
7
|
+
export const styles = {
|
|
8
|
+
root: {
|
|
9
|
+
borderRadius: dimensions.BORDER_RADIUS_SMALL,
|
|
10
|
+
backgroundColor: colors.CLASSIC_WHITE,
|
|
11
|
+
border: [1, 'solid', colors.BORDER_MAIN],
|
|
12
|
+
boxShadow: '1px 2px 10px rgba(0, 0, 0, 0.25)',
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
searchContainer: {
|
|
17
|
+
width: '100%',
|
|
18
|
+
height: dimensions.CONTROL_HEIGHT,
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
boxSizing: 'border-box',
|
|
22
|
+
padding: [0, 8, 0, 16],
|
|
23
|
+
borderBottom: [1, 'solid', colors.BORDER_MAIN],
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
icon: {
|
|
27
|
+
width: 20,
|
|
28
|
+
height: 20,
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
searchIcon: {
|
|
32
|
+
extend: 'icon',
|
|
33
|
+
color: colors.FONT_LABEL,
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
flagList: {
|
|
38
|
+
maxHeight: ROW_HEIGHT * 6 + 2 * LIST_PADDING,
|
|
39
|
+
padding: [LIST_PADDING, 0],
|
|
40
|
+
...helpers.withScrollBar,
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
listItem: {
|
|
44
|
+
height: ROW_HEIGHT,
|
|
45
|
+
padding: [12, 16],
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
fontSize: 14,
|
|
50
|
+
lineHeight: '20px',
|
|
51
|
+
letterSpacing: 0.15,
|
|
52
|
+
whiteSpace: 'nowrap',
|
|
53
|
+
boxSizing: 'border-box',
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
selectedCountry: {
|
|
57
|
+
backgroundColor: colors.GREY_BACKGROUND,
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
activeCountry: {
|
|
61
|
+
backgroundColor: colors.GREY_FOCUS,
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
flag: {
|
|
65
|
+
width: 22,
|
|
66
|
+
height: 16,
|
|
67
|
+
flexShrink: 0,
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
countryName: {
|
|
71
|
+
color: colors.FONT_MAIN,
|
|
72
|
+
overflowX: 'hidden',
|
|
73
|
+
textOverflow: 'ellipsis',
|
|
74
|
+
margin: [0, 8, 0, 12],
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
dialCode: {
|
|
78
|
+
color: colors.GREY_ACTIVE,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
emptyResult: {
|
|
82
|
+
color: colors.FONT_LABEL,
|
|
83
|
+
padding: [6, 16],
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
tweakInput: {
|
|
87
|
+
inputWrapper: {
|
|
88
|
+
border: 'none',
|
|
89
|
+
height: 'calc(var(--control-height) - 2px)',
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
input: {
|
|
93
|
+
fontSize: 14,
|
|
94
|
+
lineHeight: '20px',
|
|
95
|
+
letterSpacing: 0.15,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type PhoneInputCountryListStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { FC, MouseEvent, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { ScrollIntoViewIfNeeded } from '../../ScrollIntoViewIfNeeded';
|
|
4
|
+
import { Flag } from '../../Flag';
|
|
5
|
+
import { Icon } from '../../Icon';
|
|
6
|
+
import { Input } from '../../Input';
|
|
7
|
+
import { phoneInfo } from '../phone-info';
|
|
8
|
+
import { useTheme, useTweakStyles } from '../../../hooks';
|
|
9
|
+
import {
|
|
10
|
+
checkSearchStringInCountry,
|
|
11
|
+
getCountryTextByLocale,
|
|
12
|
+
findCountryIndexByCode,
|
|
13
|
+
sortCountriesByLocale,
|
|
14
|
+
} from '../../../helpers';
|
|
15
|
+
import { ICommonProps } from '../../../types';
|
|
16
|
+
import { IPhoneInfo } from '../types';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
PhoneInputCountryListStyles,
|
|
20
|
+
styles,
|
|
21
|
+
} from './PhoneInputCountryList.styles';
|
|
22
|
+
|
|
23
|
+
export interface IPhoneInputCountryListProps extends ICommonProps {
|
|
24
|
+
tweakStyles?: PhoneInputCountryListStyles;
|
|
25
|
+
selectedCountryCode?: string;
|
|
26
|
+
locale: string;
|
|
27
|
+
placeholder: string;
|
|
28
|
+
noMatchesLabel: string;
|
|
29
|
+
closeList(): void;
|
|
30
|
+
onChange(country: IPhoneInfo, event: MouseEvent | KeyboardEvent): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const PhoneInputCountryList: FC<IPhoneInputCountryListProps> = ({
|
|
34
|
+
locale,
|
|
35
|
+
placeholder,
|
|
36
|
+
selectedCountryCode,
|
|
37
|
+
closeList,
|
|
38
|
+
noMatchesLabel,
|
|
39
|
+
onChange,
|
|
40
|
+
tweakStyles,
|
|
41
|
+
}) => {
|
|
42
|
+
const { classes, componentStyles } = useTheme(
|
|
43
|
+
'PhoneInputCountryList',
|
|
44
|
+
styles,
|
|
45
|
+
tweakStyles,
|
|
46
|
+
);
|
|
47
|
+
const tweakInputStyles = useTweakStyles(
|
|
48
|
+
componentStyles,
|
|
49
|
+
tweakStyles,
|
|
50
|
+
'tweakInput',
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const sortedCountries = useMemo(
|
|
54
|
+
() => sortCountriesByLocale(phoneInfo, locale),
|
|
55
|
+
[phoneInfo, locale],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const selectedCountryIdx = findCountryIndexByCode(
|
|
59
|
+
selectedCountryCode,
|
|
60
|
+
sortedCountries,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const [searchValue, setSearchValue] = useState('');
|
|
64
|
+
const [countriesList, setCountriesList] = useState(sortedCountries);
|
|
65
|
+
const [keyCursorOn, setKeyCursorOn] = useState(
|
|
66
|
+
selectedCountryIdx !== -1 ? selectedCountryIdx : 0,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const handleSearchChange = (newSearchValue: string) => {
|
|
70
|
+
const newCountriesList = sortedCountries.filter((country) =>
|
|
71
|
+
checkSearchStringInCountry(country, newSearchValue),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const defaultKeyCursorOn = newCountriesList.length > 0 ? 0 : -1;
|
|
75
|
+
const newSelectedCountryIdx = findCountryIndexByCode(
|
|
76
|
+
selectedCountryCode,
|
|
77
|
+
newCountriesList,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
setCountriesList(newCountriesList);
|
|
81
|
+
setSearchValue(newSearchValue);
|
|
82
|
+
setKeyCursorOn(
|
|
83
|
+
newSelectedCountryIdx !== -1 ? newSelectedCountryIdx : defaultKeyCursorOn,
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
88
|
+
const lastListItemIdx = countriesList.length - 1;
|
|
89
|
+
|
|
90
|
+
if (event.code === 'Escape' || event.code === 'Tab') {
|
|
91
|
+
closeList();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (event.code === 'ArrowDown' && lastListItemIdx !== -1) {
|
|
95
|
+
// чтобы убрать перемещение курсора в инпуте
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
setKeyCursorOn(keyCursorOn < lastListItemIdx ? keyCursorOn + 1 : 0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (event.code === 'ArrowUp' && lastListItemIdx !== -1) {
|
|
101
|
+
// чтобы убрать перемещение курсора в инпуте
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
setKeyCursorOn(keyCursorOn > 0 ? keyCursorOn - 1 : lastListItemIdx);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
|
|
107
|
+
if (countriesList.length === 0) {
|
|
108
|
+
closeList();
|
|
109
|
+
} else if (keyCursorOn >= 0) {
|
|
110
|
+
onChange(countriesList[keyCursorOn], event);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
document.addEventListener('keydown', handleKeyDown, false);
|
|
117
|
+
|
|
118
|
+
return () => {
|
|
119
|
+
document.removeEventListener('keydown', handleKeyDown, false);
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className={classes.root}>
|
|
125
|
+
<div className={classes.searchContainer}>
|
|
126
|
+
<div className={classes.searchIcon}>
|
|
127
|
+
<Icon type="search" />
|
|
128
|
+
</div>
|
|
129
|
+
<Input
|
|
130
|
+
value={searchValue}
|
|
131
|
+
placeholder={placeholder}
|
|
132
|
+
onChange={handleSearchChange}
|
|
133
|
+
tweakStyles={tweakInputStyles}
|
|
134
|
+
isClearable
|
|
135
|
+
shouldFocusOnMount
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
<div className={classes.flagList}>
|
|
139
|
+
{countriesList.map((country, index) => (
|
|
140
|
+
<ScrollIntoViewIfNeeded
|
|
141
|
+
key={country.countryCode}
|
|
142
|
+
active={keyCursorOn === index}
|
|
143
|
+
options={{ block: 'nearest' }}
|
|
144
|
+
>
|
|
145
|
+
<div
|
|
146
|
+
className={clsx(classes.listItem, {
|
|
147
|
+
[classes.activeCountry]: selectedCountryIdx === index,
|
|
148
|
+
[classes.selectedCountry]: keyCursorOn === index,
|
|
149
|
+
})}
|
|
150
|
+
onMouseEnter={() => setKeyCursorOn(index)}
|
|
151
|
+
onClick={(e) => onChange(country, e)}
|
|
152
|
+
>
|
|
153
|
+
<div className={classes.flag}>
|
|
154
|
+
<Flag countryCode={country.countryCode} />
|
|
155
|
+
</div>
|
|
156
|
+
<div className={classes.countryName}>
|
|
157
|
+
{getCountryTextByLocale(country, locale)}
|
|
158
|
+
</div>
|
|
159
|
+
<div className={classes.dialCode}>{`+${country.dialCode}`}</div>
|
|
160
|
+
</div>
|
|
161
|
+
</ScrollIntoViewIfNeeded>
|
|
162
|
+
))}
|
|
163
|
+
{countriesList.length === 0 && (
|
|
164
|
+
<div className={classes.emptyResult}>{noMatchesLabel}</div>
|
|
165
|
+
)}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default PhoneInputCountryList;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './PhoneInput';
|
|
2
|
+
export type { PhoneInputStyles } from './PhoneInput.styles';
|
|
3
|
+
export type { PhoneInputCountryListStyles } from './PhoneInputCountryList/PhoneInputCountryList.styles';
|
|
4
|
+
|
|
5
|
+
export { phoneInfo } from './phone-info';
|
|
6
|
+
export * from './types';
|