@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,16 @@
|
|
|
1
|
+
export interface IPhoneInfo {
|
|
2
|
+
countryEn: string;
|
|
3
|
+
countryRu: string;
|
|
4
|
+
countryCode: string;
|
|
5
|
+
dialCode: string;
|
|
6
|
+
phoneMask?: string;
|
|
7
|
+
dialCodePriority?: number;
|
|
8
|
+
areaCodes?: string[];
|
|
9
|
+
fullCodes: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IPhoneValue {
|
|
13
|
+
phoneNumber?: string;
|
|
14
|
+
dialCode?: string;
|
|
15
|
+
countryCode?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { RadioButton } from './RadioButton';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'RadioButton',
|
|
7
|
+
component: RadioButton,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const options = ['one', 'two', 'three'];
|
|
11
|
+
|
|
12
|
+
const Template: ComponentStory<typeof RadioButton> = (args) => {
|
|
13
|
+
const [activeIdx, setActiveIdx] = useState(0);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ display: 'flex', gap: 20 }}>
|
|
17
|
+
{options.map((opt) => (
|
|
18
|
+
<RadioButton
|
|
19
|
+
{...args}
|
|
20
|
+
key={opt}
|
|
21
|
+
isChecked={opt === options[activeIdx]}
|
|
22
|
+
value={opt}
|
|
23
|
+
groupName="groupName"
|
|
24
|
+
onChange={(v) => {
|
|
25
|
+
setActiveIdx(options.findIndex((i) => i === v));
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Default = Template.bind({});
|
|
34
|
+
|
|
35
|
+
Default.args = {
|
|
36
|
+
children: 'Label',
|
|
37
|
+
// isChecked: false,
|
|
38
|
+
isInvalid: false,
|
|
39
|
+
isDisabled: false,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Default.parameters = {
|
|
43
|
+
controls: {
|
|
44
|
+
exclude: ['data', 'value', 'groupName', 'isChecked', 'onChange'],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComponentStyles } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
input: {
|
|
5
|
+
appearance: 'none',
|
|
6
|
+
cursor: 'pointer',
|
|
7
|
+
borderRadius: '50%',
|
|
8
|
+
width: 18,
|
|
9
|
+
height: 18,
|
|
10
|
+
outline: 'none',
|
|
11
|
+
transition: '0.1s all ease-in-out',
|
|
12
|
+
margin: 0,
|
|
13
|
+
border: [1, 'solid', '#000'],
|
|
14
|
+
|
|
15
|
+
'&:checked': {
|
|
16
|
+
border: [5, 'solid', '#000'],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
label: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
cursor: 'pointer',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
content: {
|
|
27
|
+
marginLeft: 8,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
isDisabled: {
|
|
31
|
+
cursor: 'default',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
isInvalid: {},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type RadioButtonStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useTheme } from '../../hooks';
|
|
4
|
+
import { addDataAttributes, isNotEmpty } from '../../helpers';
|
|
5
|
+
import { ICommonProps } from '../../types';
|
|
6
|
+
|
|
7
|
+
import { RadioButtonStyles, styles } from './RadioButton.styles';
|
|
8
|
+
|
|
9
|
+
export interface IRadioButtonProps<Value extends string> extends ICommonProps {
|
|
10
|
+
tweakStyles?: RadioButtonStyles;
|
|
11
|
+
value: Value;
|
|
12
|
+
groupName: string;
|
|
13
|
+
isChecked?: boolean;
|
|
14
|
+
isDisabled?: boolean;
|
|
15
|
+
isInvalid?: boolean;
|
|
16
|
+
onChange: (value: Value) => void | Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function RadioButton<Value extends string>({
|
|
20
|
+
children,
|
|
21
|
+
value,
|
|
22
|
+
groupName,
|
|
23
|
+
isChecked,
|
|
24
|
+
isDisabled,
|
|
25
|
+
isInvalid,
|
|
26
|
+
onChange,
|
|
27
|
+
data,
|
|
28
|
+
tweakStyles,
|
|
29
|
+
}: PropsWithChildren<IRadioButtonProps<Value>>): JSX.Element {
|
|
30
|
+
const { classes } = useTheme('RadioButton', styles, tweakStyles);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<label
|
|
34
|
+
className={clsx(classes.label, isDisabled && classes.isDisabled)}
|
|
35
|
+
htmlFor={`${groupName}--${value}`}
|
|
36
|
+
{...addDataAttributes(data)}
|
|
37
|
+
>
|
|
38
|
+
<input
|
|
39
|
+
id={`${groupName}--${value}`}
|
|
40
|
+
type="radio"
|
|
41
|
+
value={value}
|
|
42
|
+
name={groupName}
|
|
43
|
+
checked={isChecked}
|
|
44
|
+
disabled={isDisabled}
|
|
45
|
+
onChange={(event) => onChange(event.target.value as Value)}
|
|
46
|
+
className={clsx(classes.input, {
|
|
47
|
+
[classes.isDisabled]: isDisabled,
|
|
48
|
+
[classes.isInvalid]: isInvalid,
|
|
49
|
+
})}
|
|
50
|
+
/>
|
|
51
|
+
{isNotEmpty(children) && (
|
|
52
|
+
<span className={classes.content}>{children}</span>
|
|
53
|
+
)}
|
|
54
|
+
</label>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createElement, createRef, PureComponent } from 'react';
|
|
2
|
+
|
|
3
|
+
import scrollIntoViewIfNeeded, {
|
|
4
|
+
StandardBehaviorOptions,
|
|
5
|
+
} from 'scroll-into-view-if-needed';
|
|
6
|
+
|
|
7
|
+
interface IScrollIntoViewIfNeededProps extends React.HTMLProps<HTMLElement> {
|
|
8
|
+
active?: boolean;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
elementType?: string;
|
|
11
|
+
options?: StandardBehaviorOptions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ScrollIntoViewIfNeededDefaultElementType = 'div';
|
|
15
|
+
|
|
16
|
+
const ScrollIntoViewIfNeededDefaultProps: IScrollIntoViewIfNeededProps = {
|
|
17
|
+
active: true,
|
|
18
|
+
elementType: ScrollIntoViewIfNeededDefaultElementType,
|
|
19
|
+
options: {
|
|
20
|
+
behavior: 'smooth',
|
|
21
|
+
scrollMode: 'if-needed',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoViewIfNeededProps> {
|
|
26
|
+
node: React.RefObject<HTMLElement> = createRef();
|
|
27
|
+
|
|
28
|
+
public static defaultProps: IScrollIntoViewIfNeededProps =
|
|
29
|
+
ScrollIntoViewIfNeededDefaultProps;
|
|
30
|
+
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
const { active } = this.props;
|
|
33
|
+
if (active) {
|
|
34
|
+
this.handleScrollIntoViewIfNeeded();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
componentDidUpdate({ active }: IScrollIntoViewIfNeededProps) {
|
|
39
|
+
const { active: isNowActive } = this.props;
|
|
40
|
+
if (!active && isNowActive) {
|
|
41
|
+
this.handleScrollIntoViewIfNeeded();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
handleScrollIntoViewIfNeeded = () => {
|
|
46
|
+
const { options } = this.props;
|
|
47
|
+
const { current: node } = this.node;
|
|
48
|
+
|
|
49
|
+
if (node) {
|
|
50
|
+
scrollIntoViewIfNeeded(node, options);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
render() {
|
|
55
|
+
const { active, elementType, children, options, ...wrapperProps } =
|
|
56
|
+
this.props;
|
|
57
|
+
|
|
58
|
+
return createElement(
|
|
59
|
+
elementType ?? ScrollIntoViewIfNeededDefaultElementType,
|
|
60
|
+
{ ref: this.node, ...wrapperProps },
|
|
61
|
+
children,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default ScrollIntoViewIfNeeded;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ScrollIntoViewIfNeeded';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { SearchInput } from './SearchInput';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Inputs/SearchInput',
|
|
8
|
+
component: SearchInput,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const Template: ComponentStory<typeof SearchInput> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('');
|
|
13
|
+
return (
|
|
14
|
+
<div style={{ width: 320 }}>
|
|
15
|
+
<SearchInput {...args} value={value} onChange={setValue} />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Default = Template.bind({});
|
|
21
|
+
|
|
22
|
+
Default.args = {
|
|
23
|
+
placeholder: 'Поиск',
|
|
24
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { colors } from '../../theme';
|
|
2
|
+
import { rgba } from '../../helpers';
|
|
3
|
+
import { ComponentStyles } from '../../types';
|
|
4
|
+
|
|
5
|
+
const LEFT_PADDING = 44;
|
|
6
|
+
|
|
7
|
+
export const styles = {
|
|
8
|
+
root: {
|
|
9
|
+
position: 'relative',
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
icon: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
left: 12,
|
|
17
|
+
height: '100%',
|
|
18
|
+
width: 20,
|
|
19
|
+
zIndex: 2,
|
|
20
|
+
color: colors.GREY_ACTIVE,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
tweakInput: {
|
|
24
|
+
inputWrapper: {
|
|
25
|
+
height: 35,
|
|
26
|
+
borderColor: 'transparent',
|
|
27
|
+
backgroundColor: rgba(colors.BORDER_MAIN, 0.3),
|
|
28
|
+
borderRadius: 18,
|
|
29
|
+
paddingLeft: LEFT_PADDING,
|
|
30
|
+
transitionProperty: 'background-color, border-color',
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
focused: {
|
|
34
|
+
backgroundColor: colors.CLASSIC_WHITE,
|
|
35
|
+
borderColor: colors.BORDER_MAIN,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
input: {
|
|
39
|
+
fontSize: 14,
|
|
40
|
+
paddingLeft: 0,
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
label: {
|
|
44
|
+
left: LEFT_PADDING,
|
|
45
|
+
fontSize: 14,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type SearchInputStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useTheme, useTweakStyles } from '../../hooks';
|
|
4
|
+
import { getTestId, addDataAttributes, addDataTestId } from '../../helpers';
|
|
5
|
+
import { Icon } from '../Icon';
|
|
6
|
+
import { IInputProps, Input } from '../Input';
|
|
7
|
+
|
|
8
|
+
import { SearchInputStyles, styles } from './SearchInput.styles';
|
|
9
|
+
|
|
10
|
+
export type ISearchInputProps = Omit<
|
|
11
|
+
IInputProps,
|
|
12
|
+
| 'type'
|
|
13
|
+
| 'isInvalid'
|
|
14
|
+
| 'errorMessage'
|
|
15
|
+
| 'label'
|
|
16
|
+
| 'isActive'
|
|
17
|
+
| 'errorPosition'
|
|
18
|
+
| 'hasFloatingLabel'
|
|
19
|
+
| 'border'
|
|
20
|
+
> & {
|
|
21
|
+
tweakStyles?: SearchInputStyles;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const SearchInput: FC<ISearchInputProps> = ({
|
|
25
|
+
isClearable = true,
|
|
26
|
+
tweakStyles,
|
|
27
|
+
testId,
|
|
28
|
+
data,
|
|
29
|
+
...props
|
|
30
|
+
}) => {
|
|
31
|
+
const { classes, componentStyles } = useTheme(
|
|
32
|
+
'SearchInput',
|
|
33
|
+
styles,
|
|
34
|
+
tweakStyles,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const tweakInputStyles = useTweakStyles(
|
|
38
|
+
componentStyles,
|
|
39
|
+
tweakStyles,
|
|
40
|
+
'tweakInput',
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
className={classes.root}
|
|
46
|
+
{...addDataTestId(testId)}
|
|
47
|
+
{...addDataAttributes(data)}
|
|
48
|
+
>
|
|
49
|
+
<div className={classes.icon}>
|
|
50
|
+
<Icon type="search" />
|
|
51
|
+
</div>
|
|
52
|
+
<Input
|
|
53
|
+
isClearable={isClearable}
|
|
54
|
+
isActive={props.value !== '' && props.value !== undefined}
|
|
55
|
+
testId={getTestId(testId, 'input')}
|
|
56
|
+
tweakStyles={tweakInputStyles}
|
|
57
|
+
hasFloatingLabel={false}
|
|
58
|
+
label={props.placeholder}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ReactNode, useEffect, useState } from 'react';
|
|
2
|
+
import { Select, ISelectProps } from './Select';
|
|
3
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
interface ObjectValue {
|
|
6
|
+
name: string;
|
|
7
|
+
age: number;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const inlineStyles = [undefined, 'left', 'right', 'middle'];
|
|
12
|
+
const borders: Array<ISelectProps<any>['border']> = [
|
|
13
|
+
undefined,
|
|
14
|
+
'left',
|
|
15
|
+
'top',
|
|
16
|
+
'right',
|
|
17
|
+
'bottom',
|
|
18
|
+
];
|
|
19
|
+
const errorPositions: Array<ISelectProps<any>['errorPosition']> = [
|
|
20
|
+
'bottom',
|
|
21
|
+
'top',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const genLetters = (qnt = 1): string =>
|
|
25
|
+
Math.random()
|
|
26
|
+
.toString(36)
|
|
27
|
+
.replace(/[^a-z]+/g, '')
|
|
28
|
+
.substr(0, qnt);
|
|
29
|
+
|
|
30
|
+
const convertObjectToString = (v?: ObjectValue): string | undefined =>
|
|
31
|
+
v !== undefined ? `${v.name}` : undefined;
|
|
32
|
+
|
|
33
|
+
const convertObjectToId = (v?: ObjectValue): string | undefined =>
|
|
34
|
+
v !== undefined ? `${v.name}${v.age}` : undefined;
|
|
35
|
+
|
|
36
|
+
const convertObjectToReactNode = (v?: ObjectValue): ReactNode | undefined =>
|
|
37
|
+
v !== undefined ? (
|
|
38
|
+
<span>
|
|
39
|
+
<i>{v.name}</i>, {v.age}
|
|
40
|
+
</span>
|
|
41
|
+
) : undefined;
|
|
42
|
+
|
|
43
|
+
const convertStringToReactNode = (v?: string): ReactNode | undefined =>
|
|
44
|
+
v !== undefined ? <i>{v}</i> : undefined;
|
|
45
|
+
|
|
46
|
+
const stringOptions = [
|
|
47
|
+
'Опция 1',
|
|
48
|
+
'Опция 11',
|
|
49
|
+
'Еще одна опция',
|
|
50
|
+
'Еще выбор',
|
|
51
|
+
'Очень длинная опция вот такой текст',
|
|
52
|
+
'1',
|
|
53
|
+
'2',
|
|
54
|
+
'3',
|
|
55
|
+
'4',
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const objectOptions: ObjectValue[] = [
|
|
59
|
+
{ name: 'Ivan', age: 34 },
|
|
60
|
+
{ name: 'Ivan', age: 42 },
|
|
61
|
+
{ name: 'Konstantin', age: 11 },
|
|
62
|
+
{ name: 'Mikhail', age: 24 },
|
|
63
|
+
{ name: 'Maria', age: 45, isDisabled: true },
|
|
64
|
+
{ name: 'Elena', age: 14 },
|
|
65
|
+
{ name: 'Artem', age: 23 },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
// Максимум не включается, минимум включается
|
|
69
|
+
const getRandomInt = (min: number, max: number) =>
|
|
70
|
+
Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) +
|
|
71
|
+
Math.ceil(min);
|
|
72
|
+
|
|
73
|
+
interface ISelectWithCustomProps<T> extends ISelectProps<T> {
|
|
74
|
+
valuesType: 'strings' | 'objects';
|
|
75
|
+
shouldUseReactNodes?: boolean;
|
|
76
|
+
shouldUsePopper?: boolean;
|
|
77
|
+
shouldRenderInBody?: boolean;
|
|
78
|
+
shouldHideOnScroll?: boolean;
|
|
79
|
+
canBeFlipped?: boolean;
|
|
80
|
+
scrollParent?: 'document' | 'auto';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function SelectWithCustomProps<T>({
|
|
84
|
+
valuesType,
|
|
85
|
+
optionsMode,
|
|
86
|
+
shouldUseReactNodes,
|
|
87
|
+
shouldUsePopper,
|
|
88
|
+
shouldRenderInBody,
|
|
89
|
+
shouldHideOnScroll,
|
|
90
|
+
canBeFlipped,
|
|
91
|
+
scrollParent,
|
|
92
|
+
...rest
|
|
93
|
+
}: ISelectWithCustomProps<T>) {
|
|
94
|
+
const [stringValue, setStringValue] = useState<string | undefined>();
|
|
95
|
+
const stringHandler = (newValue?: string) => {
|
|
96
|
+
setStringValue(newValue);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const [objectValue, setObjectValue] = useState<ObjectValue | undefined>();
|
|
100
|
+
const objectHandler = (newValue?: ObjectValue) => {
|
|
101
|
+
setObjectValue(newValue);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const selectValuesType = valuesType;
|
|
105
|
+
const shouldRenderAsReactNodes = shouldUseReactNodes;
|
|
106
|
+
|
|
107
|
+
const getOptions = async (): Promise<Array<string | ObjectValue>> =>
|
|
108
|
+
new Promise((resolve) =>
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
resolve(
|
|
111
|
+
[...Array(10)].map((_) => {
|
|
112
|
+
if (selectValuesType === 'strings') {
|
|
113
|
+
return genLetters(getRandomInt(3, 10));
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
name: genLetters(getRandomInt(3, 10)),
|
|
117
|
+
age: getRandomInt(10, 70),
|
|
118
|
+
} as ObjectValue;
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}, 1000),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const [dynamicOptions, setDynamicOptions] = useState<
|
|
125
|
+
Array<string | ObjectValue>
|
|
126
|
+
>([]);
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
const api = async () => {
|
|
130
|
+
setDynamicOptions(await getOptions());
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
api();
|
|
134
|
+
}, [selectValuesType]);
|
|
135
|
+
|
|
136
|
+
const handleOpen = () => {
|
|
137
|
+
console.log('isOpen');
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const props =
|
|
141
|
+
selectValuesType === 'strings'
|
|
142
|
+
? {
|
|
143
|
+
onChange: stringHandler,
|
|
144
|
+
value: stringValue,
|
|
145
|
+
options: optionsMode === 'dynamic' ? dynamicOptions : stringOptions,
|
|
146
|
+
convertValueToReactNode: shouldRenderAsReactNodes
|
|
147
|
+
? convertStringToReactNode
|
|
148
|
+
: undefined,
|
|
149
|
+
}
|
|
150
|
+
: {
|
|
151
|
+
onChange: objectHandler,
|
|
152
|
+
value: objectValue,
|
|
153
|
+
options: optionsMode === 'dynamic' ? dynamicOptions : objectOptions,
|
|
154
|
+
convertValueToString: convertObjectToString,
|
|
155
|
+
convertValueToId: convertObjectToId,
|
|
156
|
+
convertValueToReactNode: shouldRenderAsReactNodes
|
|
157
|
+
? convertObjectToReactNode
|
|
158
|
+
: undefined,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<Select
|
|
163
|
+
{...rest}
|
|
164
|
+
{...(props as unknown as ISelectProps<any>)}
|
|
165
|
+
optionsMode={optionsMode}
|
|
166
|
+
onType={async () => setDynamicOptions(await getOptions())}
|
|
167
|
+
onOpen={handleOpen}
|
|
168
|
+
dropdownOptions={{
|
|
169
|
+
shouldUsePopper,
|
|
170
|
+
shouldRenderInBody,
|
|
171
|
+
shouldHideOnScroll,
|
|
172
|
+
canBeFlipped,
|
|
173
|
+
scrollParent,
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default {
|
|
180
|
+
title: 'Select',
|
|
181
|
+
component: SelectWithCustomProps,
|
|
182
|
+
argTypes: {
|
|
183
|
+
debounceTime: {
|
|
184
|
+
control: { type: 'range', min: 0, max: 1000, step: 100 },
|
|
185
|
+
},
|
|
186
|
+
errorPosition: { control: 'inline-radio', options: errorPositions },
|
|
187
|
+
border: { control: 'inline-radio', options: borders },
|
|
188
|
+
inlineStyle: { control: 'select', options: inlineStyles },
|
|
189
|
+
optionsMode: {
|
|
190
|
+
control: 'inline-radio',
|
|
191
|
+
options: ['normal', 'search', 'dynamic'],
|
|
192
|
+
},
|
|
193
|
+
valuesType: {
|
|
194
|
+
control: 'inline-radio',
|
|
195
|
+
options: ['strings', 'objects'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
} as ComponentMeta<typeof SelectWithCustomProps>;
|
|
199
|
+
|
|
200
|
+
const Template: ComponentStory<typeof SelectWithCustomProps> = (args) => (
|
|
201
|
+
<SelectWithCustomProps {...args} />
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
export const Default = Template.bind({});
|
|
205
|
+
|
|
206
|
+
Default.args = {
|
|
207
|
+
label: 'Dropdown',
|
|
208
|
+
defaultOptionLabel: 'Default Option',
|
|
209
|
+
noMatchesLabel: 'No matches',
|
|
210
|
+
border: undefined,
|
|
211
|
+
isInvalid: false,
|
|
212
|
+
errorMessage: 'Error Text',
|
|
213
|
+
errorPosition: 'bottom',
|
|
214
|
+
hasFloatingLabel: true,
|
|
215
|
+
hasRequiredLabel: true,
|
|
216
|
+
isDisabled: false,
|
|
217
|
+
isRequired: false,
|
|
218
|
+
isClearable: false,
|
|
219
|
+
isLoading: false,
|
|
220
|
+
debounceTime: 400,
|
|
221
|
+
// custom options
|
|
222
|
+
shouldUseReactNodes: false,
|
|
223
|
+
valuesType: 'strings',
|
|
224
|
+
optionsMode: 'normal',
|
|
225
|
+
shouldUsePopper: false,
|
|
226
|
+
shouldRenderInBody: false,
|
|
227
|
+
shouldHideOnScroll: false,
|
|
228
|
+
canBeFlipped: false,
|
|
229
|
+
scrollParent: 'document',
|
|
230
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ComponentStyles } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
root: {
|
|
5
|
+
width: '100%',
|
|
6
|
+
position: 'relative',
|
|
7
|
+
boxSizing: 'border-box',
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
inputWrapper: {
|
|
11
|
+
width: '100%',
|
|
12
|
+
cursor: 'text',
|
|
13
|
+
position: 'relative',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
listWrapper: {
|
|
17
|
+
left: -1,
|
|
18
|
+
zIndex: 3,
|
|
19
|
+
width: 'fit-content',
|
|
20
|
+
minWidth: 'calc(100% + 1px)',
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
withoutPopper: {
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
top: 'calc(100% + 6px)',
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
listWrapperInBody: {
|
|
29
|
+
minWidth: 'auto',
|
|
30
|
+
width: 'auto',
|
|
31
|
+
maxWidth: 'min-content',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
arrow: {
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
right: 12,
|
|
37
|
+
top: 14,
|
|
38
|
+
width: 20,
|
|
39
|
+
height: 20,
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
zIndex: 1,
|
|
42
|
+
transition: 'transform 0.1s ease',
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
activeArrow: {
|
|
46
|
+
transform: 'rotate(180deg)',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
disabled: {
|
|
50
|
+
'& $arrow': {
|
|
51
|
+
cursor: 'default',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
tweakInput: {
|
|
56
|
+
input: {
|
|
57
|
+
paddingRight: 32,
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
disabled: {
|
|
61
|
+
'& $input': {
|
|
62
|
+
cursor: 'default',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
controls: {
|
|
67
|
+
paddingRight: 32,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
tweakSelectList: {},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type SelectStyles = ComponentStyles<typeof styles>;
|