@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,440 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ReactNode,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { Styles } from 'jss';
|
|
10
|
+
import clsx from 'clsx';
|
|
11
|
+
import { merge } from 'lodash';
|
|
12
|
+
import { debounce } from 'ts-debounce';
|
|
13
|
+
import { Portal } from 'react-overlays';
|
|
14
|
+
|
|
15
|
+
import { SelectList, isOptionDisabled } from './SelectList';
|
|
16
|
+
import { IInputProps, Input } from '../Input';
|
|
17
|
+
import { IIconType, Icon } from '../Icon';
|
|
18
|
+
import {
|
|
19
|
+
useIsMounted,
|
|
20
|
+
useTheme,
|
|
21
|
+
useOnClickOutsideWithRef,
|
|
22
|
+
useDropdown,
|
|
23
|
+
} from '../../hooks';
|
|
24
|
+
import { IDropdownWithPopperOptions } from '../../types';
|
|
25
|
+
|
|
26
|
+
import { SelectStyles, styles } from './Select.styles';
|
|
27
|
+
import {
|
|
28
|
+
defaultConvertFunction,
|
|
29
|
+
defaultCompareFunction,
|
|
30
|
+
getActiveValueIndex,
|
|
31
|
+
} from './helpers';
|
|
32
|
+
|
|
33
|
+
export interface ISelectProps<Value>
|
|
34
|
+
extends Omit<IInputProps, 'value' | 'onChange' | 'type'> {
|
|
35
|
+
tweakStyles?: SelectStyles;
|
|
36
|
+
defaultOptionLabel?: string;
|
|
37
|
+
noMatchesLabel?: string;
|
|
38
|
+
loadingLabel?: React.ReactNode;
|
|
39
|
+
optionsMode?: 'search' | 'dynamic' | 'normal';
|
|
40
|
+
onType?: (value: string) => Promise<void>;
|
|
41
|
+
debounceTime?: number;
|
|
42
|
+
minSymbolsCountToOpenList?: number;
|
|
43
|
+
dropdownOptions?: IDropdownWithPopperOptions;
|
|
44
|
+
dropdownIcon?: IIconType;
|
|
45
|
+
onOpen?: () => void;
|
|
46
|
+
|
|
47
|
+
optionsFilter?: (options: Value[], query: string) => Value[];
|
|
48
|
+
options: Value[];
|
|
49
|
+
value?: Value;
|
|
50
|
+
onChange: (value?: Value) => void; // подумать как возвращать индекс
|
|
51
|
+
compareValuesOnChange?: (
|
|
52
|
+
v1: Value | undefined,
|
|
53
|
+
v2: Value | undefined,
|
|
54
|
+
) => boolean;
|
|
55
|
+
// возможно делать какую-то индексацию опций
|
|
56
|
+
|
|
57
|
+
// Для избежания проблем юзайте useCallback на эти функции
|
|
58
|
+
// или выносите их из компонента (чтобы не было сайдэфектов от перерендеринга их)
|
|
59
|
+
convertValueToString?: (value?: Value) => string | undefined;
|
|
60
|
+
convertValueToReactNode?: (value?: Value) => ReactNode | undefined;
|
|
61
|
+
convertValueToId?: (value?: Value) => string | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function Select<Value>({
|
|
65
|
+
options,
|
|
66
|
+
value,
|
|
67
|
+
onChange,
|
|
68
|
+
compareValuesOnChange = defaultCompareFunction,
|
|
69
|
+
convertValueToString = defaultConvertFunction,
|
|
70
|
+
convertValueToId,
|
|
71
|
+
convertValueToReactNode,
|
|
72
|
+
defaultOptionLabel,
|
|
73
|
+
onFocus,
|
|
74
|
+
onBlur,
|
|
75
|
+
onType,
|
|
76
|
+
onOpen,
|
|
77
|
+
debounceTime = 400,
|
|
78
|
+
optionsMode = 'normal',
|
|
79
|
+
optionsFilter,
|
|
80
|
+
noMatchesLabel,
|
|
81
|
+
loadingLabel,
|
|
82
|
+
tweakStyles,
|
|
83
|
+
testId,
|
|
84
|
+
isDisabled,
|
|
85
|
+
dropdownOptions,
|
|
86
|
+
minSymbolsCountToOpenList = 0,
|
|
87
|
+
dropdownIcon = 'chevron-down',
|
|
88
|
+
...inputProps
|
|
89
|
+
}: ISelectProps<Value>): JSX.Element {
|
|
90
|
+
const { classes, componentStyles } = useTheme('Select', styles, tweakStyles);
|
|
91
|
+
const isMounted = useIsMounted();
|
|
92
|
+
const [isListOpen, setIsListOpen] = useState(false);
|
|
93
|
+
const [areOptionsLoading, setAreOptionsLoading] = useState(false);
|
|
94
|
+
const hasDefaultOption = defaultOptionLabel !== undefined;
|
|
95
|
+
|
|
96
|
+
const [focusedListCellIndex, setFocusedListCellIndex] = useState(-1);
|
|
97
|
+
const [searchValue, setSearchValue] = useState('');
|
|
98
|
+
|
|
99
|
+
// если мы ввели что то в строку поиска - то этот булеан будет отключаться
|
|
100
|
+
// вынесен отдельно, из-за проблем с дебаунсом при динамич. опциях
|
|
101
|
+
const [shouldShowDefaultOption, setShouldShowDefaultOption] = useState(true);
|
|
102
|
+
|
|
103
|
+
const inputWrapper = useRef<HTMLDivElement>(null);
|
|
104
|
+
const list = useRef<HTMLDivElement>(null);
|
|
105
|
+
const input = useRef<HTMLInputElement>(null); // TODO ref снаружи?
|
|
106
|
+
|
|
107
|
+
const filteredOptions = useMemo(() => {
|
|
108
|
+
if (optionsMode !== 'search') {
|
|
109
|
+
return options;
|
|
110
|
+
}
|
|
111
|
+
if (optionsFilter) {
|
|
112
|
+
return optionsFilter(options, searchValue);
|
|
113
|
+
}
|
|
114
|
+
const lowerCaseValue = searchValue?.toLowerCase();
|
|
115
|
+
return options.filter((option) => {
|
|
116
|
+
const convertedOption = convertValueToString(option);
|
|
117
|
+
return (
|
|
118
|
+
convertedOption !== undefined &&
|
|
119
|
+
convertedOption.toLowerCase().includes(lowerCaseValue)
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
}, [optionsMode, optionsFilter, options, convertValueToString, searchValue]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
setFocusedListCellIndex(
|
|
126
|
+
getActiveValueIndex(filteredOptions, value, convertValueToString),
|
|
127
|
+
);
|
|
128
|
+
}, [filteredOptions, value, convertValueToString]);
|
|
129
|
+
|
|
130
|
+
const handleListClose = () => {
|
|
131
|
+
setIsListOpen(false);
|
|
132
|
+
setSearchValue('');
|
|
133
|
+
setShouldShowDefaultOption(true);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleListOpen = async () => {
|
|
137
|
+
if (isListOpen) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
setIsListOpen(true);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
144
|
+
if (onFocus !== undefined) {
|
|
145
|
+
onFocus(event);
|
|
146
|
+
}
|
|
147
|
+
handleListOpen();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const handleOnClick = () => {
|
|
151
|
+
handleListOpen();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
155
|
+
if (onBlur !== undefined) {
|
|
156
|
+
onBlur(event);
|
|
157
|
+
}
|
|
158
|
+
handleListClose();
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const handleOnChange = useCallback(
|
|
162
|
+
(newValue: Value | undefined) => {
|
|
163
|
+
const areValuesEqual = compareValuesOnChange(value, newValue);
|
|
164
|
+
if (areValuesEqual) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
onChange(newValue);
|
|
168
|
+
},
|
|
169
|
+
[value, onChange],
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const handleOptionClick = useCallback(
|
|
173
|
+
(index: number) => {
|
|
174
|
+
handleOnChange(index === -1 ? undefined : filteredOptions[index]);
|
|
175
|
+
handleListClose();
|
|
176
|
+
input.current?.blur();
|
|
177
|
+
},
|
|
178
|
+
[handleOnChange, filteredOptions],
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const handleOnType = useCallback(
|
|
182
|
+
async (v: string) => {
|
|
183
|
+
if (onType === undefined) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (isMounted()) {
|
|
187
|
+
setAreOptionsLoading(true);
|
|
188
|
+
}
|
|
189
|
+
await onType(v);
|
|
190
|
+
if (isMounted()) {
|
|
191
|
+
setAreOptionsLoading(false);
|
|
192
|
+
}
|
|
193
|
+
if (optionsMode === 'dynamic') {
|
|
194
|
+
setShouldShowDefaultOption(v === '');
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
[onType, optionsMode],
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const debounceHandleOnType = useCallback(
|
|
201
|
+
debounce(handleOnType, debounceTime),
|
|
202
|
+
[handleOnType, debounceTime],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const handleInputChange = (v: string) => {
|
|
206
|
+
if (onType !== undefined) {
|
|
207
|
+
debounceHandleOnType(v);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (optionsMode !== 'dynamic') {
|
|
211
|
+
setShouldShowDefaultOption(v === '');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (v === '') {
|
|
215
|
+
handleOnChange(undefined);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
setSearchValue(v);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
222
|
+
if (!isListOpen) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
event.stopPropagation();
|
|
227
|
+
|
|
228
|
+
switch (event.code) {
|
|
229
|
+
case 'Enter':
|
|
230
|
+
case 'NumpadEnter': {
|
|
231
|
+
let indexToClick = focusedListCellIndex;
|
|
232
|
+
|
|
233
|
+
// если осталось одна опция в списке,
|
|
234
|
+
// то выбираем ее нажатием на enter
|
|
235
|
+
if (indexToClick === -1 && filteredOptions.length === 1) {
|
|
236
|
+
indexToClick = 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
handleOptionClick(indexToClick);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
case 'ArrowDown': {
|
|
244
|
+
// чтобы убрать перемещение курсора в инпуте
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
let newIndex: number = focusedListCellIndex ?? -1;
|
|
247
|
+
// ищем первый незадизейбленный вариант, либо дефолтную опцию
|
|
248
|
+
for (let i = newIndex; i < newIndex + filteredOptions.length; i++) {
|
|
249
|
+
const targetIndex = (i + 1) % filteredOptions.length;
|
|
250
|
+
if (
|
|
251
|
+
shouldShowDefaultOption &&
|
|
252
|
+
hasDefaultOption &&
|
|
253
|
+
newIndex > -1 &&
|
|
254
|
+
targetIndex === 0
|
|
255
|
+
) {
|
|
256
|
+
newIndex = -1;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
if (!isOptionDisabled(filteredOptions[targetIndex])) {
|
|
260
|
+
newIndex = targetIndex;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
setFocusedListCellIndex(newIndex);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case 'ArrowUp': {
|
|
269
|
+
// чтобы убрать перемещение курсора в инпуте
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
const newIndex: number =
|
|
272
|
+
(focusedListCellIndex ?? -1) === -1 ? 0 : focusedListCellIndex;
|
|
273
|
+
// ищем первый незадизейбленный вариант, либо дефолтную опцию
|
|
274
|
+
for (let i = newIndex; i > newIndex - filteredOptions.length; i--) {
|
|
275
|
+
const targetIndex = (i > 0 ? i : filteredOptions.length + i) - 1;
|
|
276
|
+
if (
|
|
277
|
+
shouldShowDefaultOption &&
|
|
278
|
+
hasDefaultOption &&
|
|
279
|
+
focusedListCellIndex !== -1 &&
|
|
280
|
+
targetIndex === filteredOptions.length - 1
|
|
281
|
+
) {
|
|
282
|
+
// не выносить сет наружу (приведет к багу)
|
|
283
|
+
setFocusedListCellIndex(-1);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
if (!isOptionDisabled(filteredOptions[targetIndex])) {
|
|
287
|
+
// не выносить сет наружу (приведет к багу)
|
|
288
|
+
setFocusedListCellIndex(targetIndex);
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const onArrowClick = () => {
|
|
298
|
+
if (isListOpen) {
|
|
299
|
+
input.current?.blur();
|
|
300
|
+
} else {
|
|
301
|
+
input.current?.focus();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
useOnClickOutsideWithRef(
|
|
306
|
+
list,
|
|
307
|
+
() => {
|
|
308
|
+
handleListClose();
|
|
309
|
+
},
|
|
310
|
+
inputWrapper,
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
const isOpen =
|
|
314
|
+
isListOpen &&
|
|
315
|
+
(inputProps.isLoading ||
|
|
316
|
+
filteredOptions.length > 0 ||
|
|
317
|
+
(defaultOptionLabel !== undefined && searchValue === '') ||
|
|
318
|
+
noMatchesLabel !== undefined) &&
|
|
319
|
+
searchValue.trim().length >= minSymbolsCountToOpenList;
|
|
320
|
+
|
|
321
|
+
const { isReadonly = true } = inputProps;
|
|
322
|
+
const shouldUsePointerCursor = optionsMode === 'normal' && isReadonly;
|
|
323
|
+
|
|
324
|
+
const tweakInputStyles = useMemo(
|
|
325
|
+
() =>
|
|
326
|
+
merge(
|
|
327
|
+
{},
|
|
328
|
+
componentStyles.tweakInput,
|
|
329
|
+
{
|
|
330
|
+
...(shouldUsePointerCursor
|
|
331
|
+
? { input: { cursor: 'pointer' } }
|
|
332
|
+
: undefined),
|
|
333
|
+
},
|
|
334
|
+
tweakStyles?.tweakInput,
|
|
335
|
+
) as Styles,
|
|
336
|
+
[tweakStyles?.tweakInput, shouldUsePointerCursor],
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
// Эти значения ставятся в false по дефолту также в useDropdown
|
|
340
|
+
const {
|
|
341
|
+
shouldUsePopper = false,
|
|
342
|
+
shouldRenderInBody = false,
|
|
343
|
+
shouldHideOnScroll = false,
|
|
344
|
+
} = dropdownOptions ?? {};
|
|
345
|
+
|
|
346
|
+
const popperData = useDropdown({
|
|
347
|
+
isOpen,
|
|
348
|
+
onDropdownClose: handleListClose,
|
|
349
|
+
referenceElement: inputWrapper.current,
|
|
350
|
+
dropdownElement: list.current,
|
|
351
|
+
options: dropdownOptions,
|
|
352
|
+
dependenciesForPositionUpdating: [
|
|
353
|
+
inputProps.isLoading,
|
|
354
|
+
filteredOptions.length,
|
|
355
|
+
],
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
if (isOpen && onOpen !== undefined) {
|
|
360
|
+
onOpen();
|
|
361
|
+
}
|
|
362
|
+
}, [isOpen, onOpen]);
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<div className={classes.root} onKeyDown={handleKeyDown}>
|
|
366
|
+
<div
|
|
367
|
+
className={clsx(classes.inputWrapper, isDisabled && classes.disabled)}
|
|
368
|
+
onClick={isDisabled ? undefined : handleOnClick}
|
|
369
|
+
ref={inputWrapper}
|
|
370
|
+
>
|
|
371
|
+
<Input
|
|
372
|
+
value={searchValue !== '' ? searchValue : convertValueToString(value)}
|
|
373
|
+
onChange={handleInputChange}
|
|
374
|
+
isActive={isListOpen}
|
|
375
|
+
isReadonly={optionsMode === 'normal'}
|
|
376
|
+
onFocus={handleFocus}
|
|
377
|
+
onBlur={handleBlur}
|
|
378
|
+
isDisabled={isDisabled}
|
|
379
|
+
ref={input}
|
|
380
|
+
isLoading={areOptionsLoading}
|
|
381
|
+
tweakStyles={tweakInputStyles}
|
|
382
|
+
testId={testId}
|
|
383
|
+
{...inputProps}
|
|
384
|
+
/>
|
|
385
|
+
<div
|
|
386
|
+
onMouseDown={(event: React.MouseEvent) => {
|
|
387
|
+
event.preventDefault();
|
|
388
|
+
}}
|
|
389
|
+
onClick={onArrowClick}
|
|
390
|
+
className={clsx(classes.arrow, isListOpen && classes.activeArrow)}
|
|
391
|
+
>
|
|
392
|
+
<Icon type={dropdownIcon} />
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
<Portal
|
|
396
|
+
container={shouldRenderInBody ? document.body : inputWrapper.current}
|
|
397
|
+
>
|
|
398
|
+
<>
|
|
399
|
+
{(shouldUsePopper || isOpen) && (
|
|
400
|
+
<div
|
|
401
|
+
className={clsx(classes.listWrapper, {
|
|
402
|
+
[classes.withoutPopper]: !shouldUsePopper,
|
|
403
|
+
[classes.listWrapperInBody]: shouldRenderInBody,
|
|
404
|
+
})}
|
|
405
|
+
ref={list}
|
|
406
|
+
// чтобы предотвратить onBlur на инпуте
|
|
407
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
408
|
+
style={popperData?.styles.popper as Styles}
|
|
409
|
+
{...popperData?.attributes.popper}
|
|
410
|
+
>
|
|
411
|
+
{isOpen && (
|
|
412
|
+
<SelectList
|
|
413
|
+
options={filteredOptions}
|
|
414
|
+
convertValueToString={convertValueToString}
|
|
415
|
+
convertValueToReactNode={convertValueToReactNode}
|
|
416
|
+
convertValueToId={convertValueToId}
|
|
417
|
+
onOptionClick={handleOptionClick}
|
|
418
|
+
defaultOptionLabel={
|
|
419
|
+
hasDefaultOption && shouldShowDefaultOption
|
|
420
|
+
? defaultOptionLabel
|
|
421
|
+
: undefined
|
|
422
|
+
}
|
|
423
|
+
noMatchesLabel={noMatchesLabel}
|
|
424
|
+
focusedIndex={focusedListCellIndex}
|
|
425
|
+
activeValue={value}
|
|
426
|
+
isLoading={inputProps.isLoading}
|
|
427
|
+
loadingLabel={loadingLabel}
|
|
428
|
+
tweakStyles={tweakStyles?.tweakSelectList as Styles}
|
|
429
|
+
testId={testId !== undefined ? `${testId}-list` : undefined}
|
|
430
|
+
// скролл не работает с включеным поппером
|
|
431
|
+
shouldScrollToList={!shouldUsePopper && !shouldHideOnScroll}
|
|
432
|
+
/>
|
|
433
|
+
)}
|
|
434
|
+
</div>
|
|
435
|
+
)}
|
|
436
|
+
</>
|
|
437
|
+
</Portal>
|
|
438
|
+
</div>
|
|
439
|
+
);
|
|
440
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { colors, dimensions, helpers } from '../../../theme';
|
|
2
|
+
import { ComponentStyles } from '../../../types';
|
|
3
|
+
|
|
4
|
+
export const ROW_HEIGHT = 40;
|
|
5
|
+
const CONTAINER_PADDING = 10;
|
|
6
|
+
const CELL_PADDING = [10, 20];
|
|
7
|
+
|
|
8
|
+
export const styles = {
|
|
9
|
+
root: {
|
|
10
|
+
borderRadius: dimensions.BORDER_RADIUS_SMALL,
|
|
11
|
+
boxShadow: '0 13px 74px -27px rgba(0, 0, 0, 0.11)',
|
|
12
|
+
boxSizing: 'border-box',
|
|
13
|
+
padding: [CONTAINER_PADDING, 0],
|
|
14
|
+
fontSize: 16,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
list: {
|
|
18
|
+
height: '100%',
|
|
19
|
+
maxHeight: ROW_HEIGHT * 6,
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
backgroundColor: colors.CLASSIC_WHITE,
|
|
22
|
+
|
|
23
|
+
...helpers.withScrollBar,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
cell: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
minHeight: ROW_HEIGHT,
|
|
30
|
+
width: 'auto',
|
|
31
|
+
padding: CELL_PADDING,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
boxSizing: 'border-box',
|
|
34
|
+
fontSize: 14,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
noMatchesLabel: {
|
|
38
|
+
pointerEvents: 'none',
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
focused: {},
|
|
42
|
+
|
|
43
|
+
active: {},
|
|
44
|
+
|
|
45
|
+
disabled: {
|
|
46
|
+
cursor: 'default',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
loading: {
|
|
50
|
+
cursor: 'default',
|
|
51
|
+
pointerEvents: 'none',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
defaultCell: {},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SelectListStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React, { ReactNode, useMemo } from 'react';
|
|
2
|
+
import { ScrollIntoViewIfNeeded } from '../../ScrollIntoViewIfNeeded';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../../../hooks';
|
|
6
|
+
import { ICommonProps } from '../../../types';
|
|
7
|
+
|
|
8
|
+
import { SelectListStyles, styles } from './SelectList.styles';
|
|
9
|
+
|
|
10
|
+
export interface ISelectListProps<Value> extends ICommonProps {
|
|
11
|
+
tweakStyles?: SelectListStyles;
|
|
12
|
+
options: Value[];
|
|
13
|
+
focusedIndex?: number;
|
|
14
|
+
activeValue?: Value;
|
|
15
|
+
noMatchesLabel?: string;
|
|
16
|
+
isLoading?: boolean;
|
|
17
|
+
loadingLabel?: React.ReactNode;
|
|
18
|
+
defaultOptionLabel?: string;
|
|
19
|
+
onOptionClick: (index: number) => void;
|
|
20
|
+
testId?: string;
|
|
21
|
+
shouldScrollToList?: boolean;
|
|
22
|
+
convertValueToString: (value?: Value) => string | undefined;
|
|
23
|
+
convertValueToReactNode?: (value?: Value) => ReactNode | undefined;
|
|
24
|
+
convertValueToId?: (value?: Value) => string | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isOptionDisabled<Value>(option: Value): boolean {
|
|
28
|
+
return (
|
|
29
|
+
typeof option === 'object' &&
|
|
30
|
+
option !== null &&
|
|
31
|
+
((option as { isDisabled?: boolean })?.isDisabled ?? false)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const DEFAULT_OPTION_INDEX = -1;
|
|
36
|
+
|
|
37
|
+
export function SelectList<Value>({
|
|
38
|
+
options,
|
|
39
|
+
onOptionClick,
|
|
40
|
+
focusedIndex,
|
|
41
|
+
activeValue,
|
|
42
|
+
defaultOptionLabel,
|
|
43
|
+
noMatchesLabel = 'Совпадений не найдено',
|
|
44
|
+
isLoading,
|
|
45
|
+
loadingLabel = 'Загрузка...',
|
|
46
|
+
convertValueToString,
|
|
47
|
+
convertValueToReactNode,
|
|
48
|
+
convertValueToId = convertValueToString,
|
|
49
|
+
tweakStyles,
|
|
50
|
+
testId,
|
|
51
|
+
shouldScrollToList = true,
|
|
52
|
+
}: ISelectListProps<Value>): JSX.Element {
|
|
53
|
+
const { classes } = useTheme('SelectList', styles, tweakStyles);
|
|
54
|
+
const activeValueId = convertValueToId(activeValue);
|
|
55
|
+
|
|
56
|
+
const convertedToStringOptions = useMemo(
|
|
57
|
+
() => options.map(convertValueToString),
|
|
58
|
+
[options, convertValueToString],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const isActiveOption = (item: Value): boolean =>
|
|
62
|
+
convertValueToId(item) === activeValueId;
|
|
63
|
+
|
|
64
|
+
const convertedToReactNodesOptions = useMemo(
|
|
65
|
+
() =>
|
|
66
|
+
convertValueToReactNode !== undefined
|
|
67
|
+
? options.map(convertValueToReactNode)
|
|
68
|
+
: [],
|
|
69
|
+
[options, convertValueToReactNode],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const listOptions =
|
|
73
|
+
convertValueToReactNode !== undefined
|
|
74
|
+
? convertedToReactNodesOptions
|
|
75
|
+
: convertedToStringOptions;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<ScrollIntoViewIfNeeded
|
|
79
|
+
active={shouldScrollToList}
|
|
80
|
+
className={classes.root}
|
|
81
|
+
>
|
|
82
|
+
<div className={classes.list} data-testid={testId}>
|
|
83
|
+
{isLoading ? (
|
|
84
|
+
<div className={clsx(classes.cell, classes.loading)}>
|
|
85
|
+
{loadingLabel}
|
|
86
|
+
</div>
|
|
87
|
+
) : (
|
|
88
|
+
<>
|
|
89
|
+
{defaultOptionLabel !== undefined && (
|
|
90
|
+
<ScrollIntoViewIfNeeded
|
|
91
|
+
active={focusedIndex === DEFAULT_OPTION_INDEX}
|
|
92
|
+
options={{ block: 'nearest' }}
|
|
93
|
+
className={clsx(
|
|
94
|
+
classes.cell,
|
|
95
|
+
classes.defaultCell,
|
|
96
|
+
focusedIndex === DEFAULT_OPTION_INDEX && classes.focused,
|
|
97
|
+
)}
|
|
98
|
+
onClick={() => onOptionClick(DEFAULT_OPTION_INDEX)}
|
|
99
|
+
>
|
|
100
|
+
{defaultOptionLabel}
|
|
101
|
+
</ScrollIntoViewIfNeeded>
|
|
102
|
+
)}
|
|
103
|
+
{listOptions.map((opt, index) => {
|
|
104
|
+
const optionValue = options[index];
|
|
105
|
+
const isActive = isActiveOption(optionValue);
|
|
106
|
+
// проверяем, что опция задизейблена
|
|
107
|
+
const isDisabled = isOptionDisabled(optionValue);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<ScrollIntoViewIfNeeded
|
|
111
|
+
active={index === focusedIndex}
|
|
112
|
+
options={{ block: 'nearest' }}
|
|
113
|
+
key={index}
|
|
114
|
+
className={clsx(classes.cell, {
|
|
115
|
+
[classes.focused]: index === focusedIndex,
|
|
116
|
+
[classes.active]: isActive,
|
|
117
|
+
[classes.disabled]: isDisabled,
|
|
118
|
+
})}
|
|
119
|
+
onClick={!isDisabled ? () => onOptionClick(index) : undefined}
|
|
120
|
+
>
|
|
121
|
+
{opt}
|
|
122
|
+
</ScrollIntoViewIfNeeded>
|
|
123
|
+
);
|
|
124
|
+
})}
|
|
125
|
+
{listOptions.length === 0 && (
|
|
126
|
+
<div className={clsx(classes.cell, classes.noMatchesLabel)}>
|
|
127
|
+
{noMatchesLabel}
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</div>
|
|
133
|
+
</ScrollIntoViewIfNeeded>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectList';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const defaultConvertFunction = (v: unknown) =>
|
|
2
|
+
v === undefined ? undefined : String(v);
|
|
3
|
+
|
|
4
|
+
export const defaultCompareFunction = <Value>(
|
|
5
|
+
v1: Value | undefined,
|
|
6
|
+
v2: Value | undefined,
|
|
7
|
+
) => v1 === v2;
|
|
8
|
+
|
|
9
|
+
export const getActiveValueIndex = <Value>(
|
|
10
|
+
options: Value[],
|
|
11
|
+
value: Value | undefined,
|
|
12
|
+
convertFunc: (v?: Value) => string | undefined,
|
|
13
|
+
): number => options.findIndex((o) => convertFunc(o) === convertFunc(value));
|