@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,63 @@
|
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { IInputProps } from '../Input';
|
|
4
|
+
import { SmartInput, TSmartType } from './SmartInput';
|
|
5
|
+
|
|
6
|
+
const types: Array<IInputProps['type']> = [
|
|
7
|
+
'text',
|
|
8
|
+
'password',
|
|
9
|
+
'email',
|
|
10
|
+
'number',
|
|
11
|
+
];
|
|
12
|
+
const smartTypes: TSmartType[] = [
|
|
13
|
+
'default',
|
|
14
|
+
'agencyName',
|
|
15
|
+
'surname',
|
|
16
|
+
'name',
|
|
17
|
+
'email',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: 'Inputs/SmartInput',
|
|
22
|
+
component: SmartInput,
|
|
23
|
+
argTypes: {
|
|
24
|
+
type: { control: 'inline-radio', options: types },
|
|
25
|
+
smartType: { control: 'inline-radio', options: smartTypes },
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const Template: ComponentStory<typeof SmartInput> = (args) => {
|
|
30
|
+
const [value, setValue] = useState('');
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
<div>Фичи умного инпута:</div>
|
|
35
|
+
<ul>
|
|
36
|
+
<li>Переключение раскладки при вводе</li>
|
|
37
|
+
<li>Транслитерация при копировании текста на русском</li>
|
|
38
|
+
<li>
|
|
39
|
+
Запрет ввода определённых символов для разных видов полей, например,
|
|
40
|
+
только буквы, пробелы и дефис для фамилий и т.д.
|
|
41
|
+
</li>
|
|
42
|
+
<li>
|
|
43
|
+
Фильтрация скопированного значения на предмет запрещённых символов
|
|
44
|
+
</li>
|
|
45
|
+
<li>Трансформация значения в UPPERCASE</li>
|
|
46
|
+
</ul>
|
|
47
|
+
|
|
48
|
+
<SmartInput {...args} value={value} onChange={(v) => setValue(v)} />
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Default = Template.bind({});
|
|
54
|
+
|
|
55
|
+
Default.args = {
|
|
56
|
+
label: 'Label',
|
|
57
|
+
placeholder: 'Placeholder',
|
|
58
|
+
type: 'text',
|
|
59
|
+
smartType: 'default',
|
|
60
|
+
isUpperCase: false,
|
|
61
|
+
isDisabled: false,
|
|
62
|
+
hasFloatingLabel: true,
|
|
63
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, {useState, useEffect, forwardRef} from 'react';
|
|
2
|
+
import { Input, IInputProps } from '../Input';
|
|
3
|
+
import {
|
|
4
|
+
CharactersMap,
|
|
5
|
+
transformCaseSensitive,
|
|
6
|
+
TransliterationMap,
|
|
7
|
+
} from './helpers';
|
|
8
|
+
|
|
9
|
+
export type TSmartType =
|
|
10
|
+
| 'name'
|
|
11
|
+
| 'nameRuEn'
|
|
12
|
+
| 'surname'
|
|
13
|
+
| 'surnameRuEn'
|
|
14
|
+
| 'email'
|
|
15
|
+
| 'agencyName'
|
|
16
|
+
| 'default'
|
|
17
|
+
| 'digits'
|
|
18
|
+
| 'docNumber'
|
|
19
|
+
| 'benefitCert';
|
|
20
|
+
|
|
21
|
+
export interface ISmartInputProps extends IInputProps {
|
|
22
|
+
isUpperCase?: boolean;
|
|
23
|
+
smartType?: TSmartType;
|
|
24
|
+
regExp?: RegExp;
|
|
25
|
+
onChange: (value: string) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SMART_INPUT_REGEX_MAP = {
|
|
29
|
+
default: /./i,
|
|
30
|
+
agencyName: /^[a-zA-Z\s0-9-]*$/i,
|
|
31
|
+
surname: /^[a-zA-Z\s-]*$/i,
|
|
32
|
+
name: /^[a-zA-Z\s-.`']*$/i,
|
|
33
|
+
surnameRuEn: /^[a-zA-Zа-яА-Я\s-]*$/i,
|
|
34
|
+
nameRuEn: /^[a-zA-Zа-яА-Я\s-.`']*$/i,
|
|
35
|
+
email: /^[a-zA-Z0-9@_\-.+']*$/i,
|
|
36
|
+
digits: /^[0-9]*$/i,
|
|
37
|
+
docNumber: /^[a-zA-Z0-9]*$/i,
|
|
38
|
+
benefitCert: /^[a-zA-Z0-9/]*$/i,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const SmartInput = forwardRef<HTMLInputElement, ISmartInputProps>(({
|
|
42
|
+
onChange,
|
|
43
|
+
isUpperCase,
|
|
44
|
+
smartType = 'default',
|
|
45
|
+
regExp,
|
|
46
|
+
value = '',
|
|
47
|
+
maxLength,
|
|
48
|
+
...rest
|
|
49
|
+
}, ref) => {
|
|
50
|
+
const [currentValue, setCurrentValue] = useState<string>(
|
|
51
|
+
getUpperCaseIfNeeded(value),
|
|
52
|
+
);
|
|
53
|
+
const [caretPosition, setCaretPosition] = useState<number | null>(null);
|
|
54
|
+
const [input, setInput] = useState<HTMLInputElement | null>(null);
|
|
55
|
+
const regex = regExp || SMART_INPUT_REGEX_MAP[smartType];
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (
|
|
59
|
+
input &&
|
|
60
|
+
input.type !== 'email' &&
|
|
61
|
+
input.selectionStart !== caretPosition
|
|
62
|
+
) {
|
|
63
|
+
input.selectionStart = caretPosition;
|
|
64
|
+
input.selectionEnd = caretPosition;
|
|
65
|
+
}
|
|
66
|
+
}, [caretPosition]);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setCurrentValue(getUpperCaseIfNeeded(value));
|
|
70
|
+
}, [value]);
|
|
71
|
+
|
|
72
|
+
function getUpperCaseIfNeeded(str: string) {
|
|
73
|
+
return isUpperCase ? str.toUpperCase() : str;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const handleChange = (
|
|
77
|
+
str: string,
|
|
78
|
+
event?: React.FormEvent<HTMLInputElement>,
|
|
79
|
+
) => {
|
|
80
|
+
const mappedValue = str
|
|
81
|
+
.split('')
|
|
82
|
+
.map((symbol) =>
|
|
83
|
+
regex.test(symbol)
|
|
84
|
+
? symbol
|
|
85
|
+
: transformCaseSensitive(
|
|
86
|
+
smartType,
|
|
87
|
+
smartType !== 'email'
|
|
88
|
+
? CharactersMap
|
|
89
|
+
: { ...CharactersMap, '"': '@' },
|
|
90
|
+
symbol,
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
.filter((symbol) => regex.test(symbol))
|
|
94
|
+
.join('');
|
|
95
|
+
const domElement = event?.currentTarget;
|
|
96
|
+
|
|
97
|
+
if (domElement) {
|
|
98
|
+
if (!input) {
|
|
99
|
+
setInput(domElement);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setCurrentValue(getUpperCaseIfNeeded(mappedValue));
|
|
103
|
+
onChange(getUpperCaseIfNeeded(mappedValue));
|
|
104
|
+
|
|
105
|
+
if (mappedValue !== currentValue) {
|
|
106
|
+
setCaretPosition(domElement.selectionStart);
|
|
107
|
+
} else {
|
|
108
|
+
setCaretPosition(
|
|
109
|
+
domElement.selectionStart ? domElement.selectionStart - 1 : null,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {
|
|
116
|
+
const str = event.clipboardData.getData('text/plain').split('').join('');
|
|
117
|
+
const domElement = event.currentTarget;
|
|
118
|
+
|
|
119
|
+
if (!input) {
|
|
120
|
+
setInput(domElement);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
const selectionStart = domElement.selectionStart ?? 0;
|
|
125
|
+
const selectionEnd = domElement.selectionEnd ?? 0;
|
|
126
|
+
|
|
127
|
+
let mappedValue = str
|
|
128
|
+
.split('')
|
|
129
|
+
.map((symbol) =>
|
|
130
|
+
regex.test(symbol)
|
|
131
|
+
? symbol
|
|
132
|
+
: transformCaseSensitive(smartType, TransliterationMap, symbol),
|
|
133
|
+
)
|
|
134
|
+
.filter((letter) => regex.test(letter))
|
|
135
|
+
.join('');
|
|
136
|
+
|
|
137
|
+
const newValueLength =
|
|
138
|
+
mappedValue.length +
|
|
139
|
+
currentValue.length -
|
|
140
|
+
(selectionEnd - selectionStart);
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
maxLength !== undefined &&
|
|
144
|
+
maxLength >= 0 &&
|
|
145
|
+
newValueLength > maxLength
|
|
146
|
+
) {
|
|
147
|
+
const validMappedValueLength =
|
|
148
|
+
mappedValue.length - (newValueLength - maxLength);
|
|
149
|
+
|
|
150
|
+
mappedValue = mappedValue.substring(0, validMappedValueLength);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const newValue = getUpperCaseIfNeeded(
|
|
154
|
+
`${currentValue?.substring(
|
|
155
|
+
0,
|
|
156
|
+
selectionStart,
|
|
157
|
+
)}${mappedValue}${currentValue?.substring(
|
|
158
|
+
selectionEnd,
|
|
159
|
+
)}`,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
setCaretPosition(selectionStart + mappedValue.length);
|
|
163
|
+
setCurrentValue(newValue);
|
|
164
|
+
onChange(newValue);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Input
|
|
169
|
+
{...rest}
|
|
170
|
+
ref={ref}
|
|
171
|
+
maxLength={maxLength}
|
|
172
|
+
onChange={handleChange}
|
|
173
|
+
onPaste={handlePaste}
|
|
174
|
+
value={currentValue}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { TSmartType } from './SmartInput';
|
|
2
|
+
|
|
3
|
+
export const transformCaseSensitive = (
|
|
4
|
+
smartType: TSmartType,
|
|
5
|
+
map: { [key: string]: string },
|
|
6
|
+
symbol: string,
|
|
7
|
+
): string => {
|
|
8
|
+
const isUpperCase = symbol.toUpperCase() === symbol;
|
|
9
|
+
const result = smartType.endsWith('RuEn')
|
|
10
|
+
? symbol.toLowerCase()
|
|
11
|
+
: map[symbol.toLowerCase()] ?? symbol;
|
|
12
|
+
return isUpperCase ? result.toUpperCase() : result;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const CharactersMap: { [key: string]: string } = {
|
|
16
|
+
й: 'q',
|
|
17
|
+
ц: 'w',
|
|
18
|
+
у: 'e',
|
|
19
|
+
к: 'r',
|
|
20
|
+
е: 't',
|
|
21
|
+
н: 'y',
|
|
22
|
+
г: 'u',
|
|
23
|
+
ш: 'i',
|
|
24
|
+
щ: 'o',
|
|
25
|
+
з: 'p',
|
|
26
|
+
х: '[',
|
|
27
|
+
ъ: ']',
|
|
28
|
+
ф: 'a',
|
|
29
|
+
ы: 's',
|
|
30
|
+
в: 'd',
|
|
31
|
+
а: 'f',
|
|
32
|
+
п: 'g',
|
|
33
|
+
р: 'h',
|
|
34
|
+
о: 'j',
|
|
35
|
+
л: 'k',
|
|
36
|
+
д: 'l',
|
|
37
|
+
ж: ';',
|
|
38
|
+
э: "'",
|
|
39
|
+
я: 'z',
|
|
40
|
+
ч: 'x',
|
|
41
|
+
с: 'c',
|
|
42
|
+
м: 'v',
|
|
43
|
+
и: 'b',
|
|
44
|
+
т: 'n',
|
|
45
|
+
ь: 'm',
|
|
46
|
+
б: ',',
|
|
47
|
+
ю: '.',
|
|
48
|
+
ё: '`',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const TransliterationMap: { [key: string]: string } = {
|
|
52
|
+
й: 'i',
|
|
53
|
+
ц: 'ts',
|
|
54
|
+
у: 'u',
|
|
55
|
+
к: 'k',
|
|
56
|
+
е: 'e',
|
|
57
|
+
н: 'n',
|
|
58
|
+
г: 'g',
|
|
59
|
+
ш: 'sh',
|
|
60
|
+
щ: 'shch',
|
|
61
|
+
з: 'z',
|
|
62
|
+
х: 'h',
|
|
63
|
+
ъ: 'ie',
|
|
64
|
+
ф: 'f',
|
|
65
|
+
ы: 'y',
|
|
66
|
+
в: 'v',
|
|
67
|
+
а: 'a',
|
|
68
|
+
п: 'p',
|
|
69
|
+
р: 'r',
|
|
70
|
+
о: 'o',
|
|
71
|
+
л: 'l',
|
|
72
|
+
д: 'd',
|
|
73
|
+
ж: 'zh',
|
|
74
|
+
э: 'e',
|
|
75
|
+
я: 'ia',
|
|
76
|
+
ч: 'ch',
|
|
77
|
+
с: 's',
|
|
78
|
+
м: 'm',
|
|
79
|
+
и: 'i',
|
|
80
|
+
т: 't',
|
|
81
|
+
ь: '',
|
|
82
|
+
б: 'b',
|
|
83
|
+
ю: 'iu',
|
|
84
|
+
ё: 'e',
|
|
85
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SmartInput';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Switch } from './Switch';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Switch',
|
|
7
|
+
component: Switch,
|
|
8
|
+
argTypes: {
|
|
9
|
+
labelPosition: { control: 'inline-radio', options: ['left', 'right'] },
|
|
10
|
+
color: { control: 'inline-radio', options: ['primary', 'secondary'] },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template: ComponentStory<typeof Switch> = (args) => {
|
|
15
|
+
const [isChecked, setIsChecked] = useState(true);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Switch
|
|
19
|
+
{...args}
|
|
20
|
+
isChecked={isChecked}
|
|
21
|
+
onChange={(value) => setIsChecked(value.isEnabled)}
|
|
22
|
+
value="check"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
|
|
29
|
+
Default.args = {
|
|
30
|
+
children: 'Label',
|
|
31
|
+
labelPosition: 'right',
|
|
32
|
+
isDisabled: false,
|
|
33
|
+
color: 'primary',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Default.parameters = {
|
|
37
|
+
controls: {
|
|
38
|
+
exclude: ['data', 'testId', 'onChange'],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ComponentStyles } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
cursor: 'pointer',
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
primary: {},
|
|
11
|
+
|
|
12
|
+
secondary: {},
|
|
13
|
+
|
|
14
|
+
invalid: {},
|
|
15
|
+
|
|
16
|
+
disabled: {
|
|
17
|
+
pointerEvents: 'none',
|
|
18
|
+
cursor: 'default',
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
checked: {
|
|
22
|
+
'& $switch::before': {
|
|
23
|
+
left: 18,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
switch: {
|
|
28
|
+
position: 'relative',
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
display: 'block',
|
|
31
|
+
width: 36,
|
|
32
|
+
height: 20,
|
|
33
|
+
backgroundColor: '#333',
|
|
34
|
+
borderRadius: 10,
|
|
35
|
+
boxSizing: 'border-box',
|
|
36
|
+
transitionProperty: 'opacity, background-color',
|
|
37
|
+
transition: '0.25s ease-in-out',
|
|
38
|
+
|
|
39
|
+
'&::before': {
|
|
40
|
+
content: '""',
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 2,
|
|
43
|
+
left: 2,
|
|
44
|
+
right: 'auto',
|
|
45
|
+
display: 'block',
|
|
46
|
+
width: 16,
|
|
47
|
+
height: 16,
|
|
48
|
+
backgroundColor: '#fff',
|
|
49
|
+
borderRadius: '50%',
|
|
50
|
+
zIndex: 1,
|
|
51
|
+
transitionProperty: 'left, background-color',
|
|
52
|
+
transition: '0.25s ease-in-out',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
input: {
|
|
57
|
+
display: 'none',
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
label: {
|
|
61
|
+
transitionProperty: 'opacity, color',
|
|
62
|
+
transition: '0.25s ease-in-out',
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
labelLeft: {
|
|
66
|
+
order: -1,
|
|
67
|
+
marginRight: 12,
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
labelRight: {
|
|
71
|
+
marginLeft: 12,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type SwitchStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { styles, SwitchStyles } from './Switch.styles';
|
|
8
|
+
|
|
9
|
+
export interface ISwitchState<V = string> {
|
|
10
|
+
name: V;
|
|
11
|
+
isEnabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ISwitchProps<V extends string> extends ICommonProps {
|
|
15
|
+
tweakStyles?: SwitchStyles;
|
|
16
|
+
value: V;
|
|
17
|
+
isChecked: boolean;
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
isInvalid?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `children` instead
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @default `right`
|
|
26
|
+
*/
|
|
27
|
+
labelPosition?: 'left' | 'right';
|
|
28
|
+
/**
|
|
29
|
+
* @default `primary`
|
|
30
|
+
*/
|
|
31
|
+
color?: 'primary' | 'secondary';
|
|
32
|
+
onChange: (state: ISwitchState<V>) => void;
|
|
33
|
+
testId?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Switch = <V extends string>({
|
|
37
|
+
isDisabled,
|
|
38
|
+
isChecked,
|
|
39
|
+
isInvalid,
|
|
40
|
+
onChange,
|
|
41
|
+
value,
|
|
42
|
+
label,
|
|
43
|
+
children,
|
|
44
|
+
labelPosition = 'right',
|
|
45
|
+
color = 'primary',
|
|
46
|
+
data,
|
|
47
|
+
tweakStyles,
|
|
48
|
+
testId,
|
|
49
|
+
}: PropsWithChildren<ISwitchProps<V>>): JSX.Element => {
|
|
50
|
+
const { classes } = useTheme('Switch', styles, tweakStyles);
|
|
51
|
+
|
|
52
|
+
const hasLabel = isNotEmpty(label);
|
|
53
|
+
const hasChild = isNotEmpty(children);
|
|
54
|
+
const handleChange = () => onChange({ name: value, isEnabled: !isChecked });
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<label
|
|
58
|
+
className={clsx(classes.root, classes[color], {
|
|
59
|
+
[classes.disabled]: isDisabled,
|
|
60
|
+
[classes.checked]: isChecked,
|
|
61
|
+
[classes.invalid]: isInvalid,
|
|
62
|
+
})}
|
|
63
|
+
{...addDataAttributes(data)}
|
|
64
|
+
data-testid={testId}
|
|
65
|
+
>
|
|
66
|
+
<span className={classes.switch}>
|
|
67
|
+
<input
|
|
68
|
+
type="checkbox"
|
|
69
|
+
name={value}
|
|
70
|
+
className={classes.input}
|
|
71
|
+
onChange={isDisabled ? undefined : handleChange}
|
|
72
|
+
checked={isChecked}
|
|
73
|
+
disabled={isDisabled}
|
|
74
|
+
data-testid={testId !== undefined ? `${testId}-input` : undefined}
|
|
75
|
+
/>
|
|
76
|
+
</span>
|
|
77
|
+
{(hasLabel || hasChild) && (
|
|
78
|
+
<span
|
|
79
|
+
className={clsx(
|
|
80
|
+
classes.label,
|
|
81
|
+
classes[labelPosition === 'left' ? 'labelLeft' : 'labelRight'],
|
|
82
|
+
)}
|
|
83
|
+
>
|
|
84
|
+
{hasLabel ? label : children}
|
|
85
|
+
</span>
|
|
86
|
+
)}
|
|
87
|
+
</label>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentStory } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { TextArea } from './TextArea';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Inputs/TextArea',
|
|
7
|
+
component: TextArea,
|
|
8
|
+
argTypes: {
|
|
9
|
+
maxLength: {
|
|
10
|
+
control: { type: 'range', min: 10, max: 500, step: 10 },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Template: ComponentStory<typeof TextArea> = (args) => {
|
|
16
|
+
const [value, setValue] = useState('');
|
|
17
|
+
return <TextArea {...args} value={value} onChange={(v) => setValue(v)} />;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Default = Template.bind({});
|
|
21
|
+
|
|
22
|
+
Default.args = {
|
|
23
|
+
label: 'Label',
|
|
24
|
+
placeholder: 'Placeholder',
|
|
25
|
+
infoMessage: 'Message Info',
|
|
26
|
+
rows: 5,
|
|
27
|
+
maxLength: 500,
|
|
28
|
+
hasFloatingLabel: true,
|
|
29
|
+
hasRequiredLabel: true,
|
|
30
|
+
isInvalid: false,
|
|
31
|
+
errorMessage: 'Error Text',
|
|
32
|
+
isActive: false,
|
|
33
|
+
isDisabled: false,
|
|
34
|
+
isRequired: false,
|
|
35
|
+
};
|