@true-engineering/true-react-common-ui-kit 3.13.0 → 3.13.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.
Files changed (643) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +6 -0
  3. package/dist/components/AccountInfo/AccountInfo.d.ts +11 -11
  4. package/dist/components/AccountInfo/AccountInfo.stories.d.ts +6 -6
  5. package/dist/components/AccountInfo/AccountInfo.styles.d.ts +6 -6
  6. package/dist/components/AccountInfo/constants.d.ts +1 -1
  7. package/dist/components/AccountInfo/index.d.ts +2 -2
  8. package/dist/components/AddButton/AddButton.d.ts +14 -14
  9. package/dist/components/AddButton/AddButton.stories.d.ts +6 -6
  10. package/dist/components/AddButton/AddButton.styles.d.ts +3 -3
  11. package/dist/components/AddButton/index.d.ts +2 -2
  12. package/dist/components/Button/Button.d.ts +41 -41
  13. package/dist/components/Button/Button.stories.d.ts +6 -6
  14. package/dist/components/Button/Button.styles.d.ts +8 -8
  15. package/dist/components/Button/constants.d.ts +2 -2
  16. package/dist/components/Button/index.d.ts +3 -3
  17. package/dist/components/Button/types.d.ts +3 -3
  18. package/dist/components/Checkbox/Checkbox.d.ts +24 -24
  19. package/dist/components/Checkbox/Checkbox.stories.d.ts +8 -8
  20. package/dist/components/Checkbox/Checkbox.styles.d.ts +3 -3
  21. package/dist/components/Checkbox/index.d.ts +2 -2
  22. package/dist/components/CloseButton/CloseButton.d.ts +10 -10
  23. package/dist/components/CloseButton/CloseButton.stories.d.ts +5 -5
  24. package/dist/components/CloseButton/CloseButton.styles.d.ts +3 -3
  25. package/dist/components/CloseButton/index.d.ts +2 -2
  26. package/dist/components/Colors/Colors.d.ts +2 -2
  27. package/dist/components/Colors/Colors.stories.d.ts +5 -5
  28. package/dist/components/Colors/Colors.styles.d.ts +1 -1
  29. package/dist/components/Colors/index.d.ts +1 -1
  30. package/dist/components/CssBaseline/CssBaseline.d.ts +5 -5
  31. package/dist/components/CssBaseline/CssBaseline.styles.d.ts +3 -3
  32. package/dist/components/CssBaseline/index.d.ts +2 -2
  33. package/dist/components/DateInput/DateInput.d.ts +17 -17
  34. package/dist/components/DateInput/DateInput.stories.d.ts +7 -7
  35. package/dist/components/DateInput/DateInput.styles.d.ts +6 -6
  36. package/dist/components/DateInput/constants.d.ts +2 -2
  37. package/dist/components/DateInput/index.d.ts +3 -3
  38. package/dist/components/DatePicker/DatePicker.d.ts +26 -26
  39. package/dist/components/DatePicker/DatePicker.stories.d.ts +7 -7
  40. package/dist/components/DatePicker/DatePicker.styles.d.ts +6 -6
  41. package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.d.ts +8 -8
  42. package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.d.ts +7 -7
  43. package/dist/components/DatePicker/components/DatePickerHeader/index.d.ts +2 -2
  44. package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +4 -4
  45. package/dist/components/DatePicker/components/PopperContainer/index.d.ts +1 -1
  46. package/dist/components/DatePicker/components/index.d.ts +2 -2
  47. package/dist/components/DatePicker/constants.d.ts +3 -3
  48. package/dist/components/DatePicker/helpers.d.ts +3 -3
  49. package/dist/components/DatePicker/index.d.ts +4 -4
  50. package/dist/components/DatePicker/types.d.ts +4 -4
  51. package/dist/components/Description/Description.d.ts +13 -13
  52. package/dist/components/Description/Description.stories.d.ts +16 -16
  53. package/dist/components/Description/Description.styles.d.ts +3 -3
  54. package/dist/components/Description/constants.d.ts +1 -1
  55. package/dist/components/Description/index.d.ts +2 -2
  56. package/dist/components/FiltersPane/FiltersPane.d.ts +22 -22
  57. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +31 -31
  58. package/dist/components/FiltersPane/FiltersPane.styles.d.ts +9 -9
  59. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +12 -12
  60. package/dist/components/FiltersPane/components/Filter/index.d.ts +1 -1
  61. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.d.ts +24 -24
  62. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +15 -15
  63. package/dist/components/FiltersPane/components/FilterInterval/index.d.ts +2 -2
  64. package/dist/components/FiltersPane/components/FilterMultiSelect/FilterMultiSelect.d.ts +5 -5
  65. package/dist/components/FiltersPane/components/FilterMultiSelect/index.d.ts +1 -1
  66. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.d.ts +29 -29
  67. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +15 -15
  68. package/dist/components/FiltersPane/components/FilterSelect/index.d.ts +2 -2
  69. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +5 -5
  70. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.styles.d.ts +3 -3
  71. package/dist/components/FiltersPane/components/FilterValueView/index.d.ts +2 -2
  72. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.d.ts +16 -16
  73. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +26 -26
  74. package/dist/components/FiltersPane/components/FilterWithDates/index.d.ts +2 -2
  75. package/dist/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.d.ts +13 -13
  76. package/dist/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.styles.d.ts +7 -7
  77. package/dist/components/FiltersPane/components/FilterWithPeriod/index.d.ts +2 -2
  78. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +14 -14
  79. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +6 -6
  80. package/dist/components/FiltersPane/components/FilterWrapper/index.d.ts +2 -2
  81. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.d.ts +21 -21
  82. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +10 -10
  83. package/dist/components/FiltersPane/components/FiltersPaneSearch/index.d.ts +2 -2
  84. package/dist/components/FiltersPane/components/index.d.ts +9 -9
  85. package/dist/components/FiltersPane/constants.d.ts +9 -9
  86. package/dist/components/FiltersPane/helpers.d.ts +5 -5
  87. package/dist/components/FiltersPane/index.d.ts +4 -4
  88. package/dist/components/FiltersPane/types.d.ts +107 -107
  89. package/dist/components/Flag/Flag.d.ts +8 -8
  90. package/dist/components/Flag/Flag.stories.d.ts +12 -12
  91. package/dist/components/Flag/Flag.styles.d.ts +3 -3
  92. package/dist/components/Flag/index.d.ts +2 -2
  93. package/dist/components/FlexibleTable/FlexibleTable.d.ts +22 -22
  94. package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +15 -15
  95. package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +7 -7
  96. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +14 -14
  97. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +3 -3
  98. package/dist/components/FlexibleTable/components/FlexibleTableCell/index.d.ts +2 -2
  99. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +28 -28
  100. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +6 -6
  101. package/dist/components/FlexibleTable/components/FlexibleTableRow/index.d.ts +2 -2
  102. package/dist/components/FlexibleTable/components/index.d.ts +2 -2
  103. package/dist/components/FlexibleTable/constants.d.ts +1 -1
  104. package/dist/components/FlexibleTable/helpers.d.ts +3 -3
  105. package/dist/components/FlexibleTable/index.d.ts +4 -4
  106. package/dist/components/FlexibleTable/types.d.ts +44 -44
  107. package/dist/components/Icon/Icon.d.ts +8 -8
  108. package/dist/components/Icon/Icon.stories.d.ts +6 -6
  109. package/dist/components/Icon/Icon.styles.d.ts +3 -3
  110. package/dist/components/Icon/complexIcons/icons.d.ts +3 -3
  111. package/dist/components/Icon/complexIcons/index.d.ts +1 -1
  112. package/dist/components/Icon/components/ComplexIconBoilerplate/ComplexIconBoilerplate.d.ts +6 -6
  113. package/dist/components/Icon/components/ComplexIconBoilerplate/index.d.ts +1 -1
  114. package/dist/components/Icon/components/IconBolerplate/IconBoilerplate.d.ts +6 -6
  115. package/dist/components/Icon/components/IconBolerplate/index.d.ts +1 -1
  116. package/dist/components/Icon/components/index.d.ts +2 -2
  117. package/dist/components/Icon/helpers.d.ts +6 -6
  118. package/dist/components/Icon/icons-list.d.ts +1 -1
  119. package/dist/components/Icon/index.d.ts +5 -5
  120. package/dist/components/Icon/snippet.d.ts +3 -3
  121. package/dist/components/Icon/types.d.ts +13 -13
  122. package/dist/components/IconButton/IconButton.d.ts +19 -19
  123. package/dist/components/IconButton/IconButton.stories.d.ts +6 -6
  124. package/dist/components/IconButton/IconButton.styles.d.ts +3 -3
  125. package/dist/components/IconButton/constants.d.ts +2 -2
  126. package/dist/components/IconButton/index.d.ts +3 -3
  127. package/dist/components/IconButton/types.d.ts +5 -5
  128. package/dist/components/IncrementInput/IncrementInput.d.ts +9 -9
  129. package/dist/components/IncrementInput/IncrementInput.stories.d.ts +6 -6
  130. package/dist/components/IncrementInput/IncrementInput.styles.d.ts +9 -9
  131. package/dist/components/IncrementInput/index.d.ts +2 -2
  132. package/dist/components/Input/Input.d.ts +52 -52
  133. package/dist/components/Input/Input.stories.d.ts +34 -34
  134. package/dist/components/Input/Input.styles.d.ts +7 -7
  135. package/dist/components/Input/constants.d.ts +1 -1
  136. package/dist/components/Input/index.d.ts +3 -3
  137. package/dist/components/Input/types.d.ts +4 -4
  138. package/dist/components/List/List.d.ts +9 -9
  139. package/dist/components/List/List.stories.d.ts +5 -5
  140. package/dist/components/List/List.styles.d.ts +3 -3
  141. package/dist/components/List/components/ListItem/ListItem.d.ts +15 -15
  142. package/dist/components/List/components/ListItem/ListItem.styles.d.ts +3 -3
  143. package/dist/components/List/components/ListItem/index.d.ts +2 -2
  144. package/dist/components/List/components/index.d.ts +1 -1
  145. package/dist/components/List/index.d.ts +3 -3
  146. package/dist/components/Modal/Modal.d.ts +34 -34
  147. package/dist/components/Modal/Modal.stories.d.ts +29 -29
  148. package/dist/components/Modal/Modal.styles.d.ts +7 -7
  149. package/dist/components/Modal/index.d.ts +3 -3
  150. package/dist/components/Modal/types.d.ts +3 -3
  151. package/dist/components/MoreMenu/MoreMenu.d.ts +15 -15
  152. package/dist/components/MoreMenu/MoreMenu.stories.d.ts +6 -6
  153. package/dist/components/MoreMenu/MoreMenu.styles.d.ts +6 -6
  154. package/dist/components/MoreMenu/index.d.ts +2 -2
  155. package/dist/components/MultiSelect/MultiSelect.d.ts +23 -23
  156. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +13 -13
  157. package/dist/components/MultiSelect/MultiSelect.styles.d.ts +7 -7
  158. package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.d.ts +12 -12
  159. package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.styles.d.ts +3 -3
  160. package/dist/components/MultiSelect/components/MultiSelectInput/index.d.ts +2 -2
  161. package/dist/components/MultiSelect/components/index.d.ts +1 -1
  162. package/dist/components/MultiSelect/index.d.ts +4 -4
  163. package/dist/components/MultiSelect/types.d.ts +1 -1
  164. package/dist/components/MultiSelectList/MultiSelectList.d.ts +25 -25
  165. package/dist/components/MultiSelectList/MultiSelectList.styles.d.ts +13 -13
  166. package/dist/components/MultiSelectList/constants.d.ts +3 -3
  167. package/dist/components/MultiSelectList/helpers.d.ts +3 -3
  168. package/dist/components/MultiSelectList/index.d.ts +3 -3
  169. package/dist/components/MultiSelectList/types.d.ts +12 -12
  170. package/dist/components/NewMoreMenu/NewMoreMenu.d.ts +15 -15
  171. package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +12 -12
  172. package/dist/components/NewMoreMenu/NewMoreMenu.styles.d.ts +8 -8
  173. package/dist/components/NewMoreMenu/index.d.ts +2 -2
  174. package/dist/components/Notification/Notification.d.ts +15 -15
  175. package/dist/components/Notification/Notification.stories.d.ts +8 -8
  176. package/dist/components/Notification/Notification.styles.d.ts +3 -3
  177. package/dist/components/Notification/index.d.ts +3 -3
  178. package/dist/components/Notification/types.d.ts +1 -1
  179. package/dist/components/NumberInput/NumberInput.d.ts +18 -18
  180. package/dist/components/NumberInput/NumberInput.stories.d.ts +7 -7
  181. package/dist/components/NumberInput/helpers.d.ts +4 -4
  182. package/dist/components/NumberInput/index.d.ts +1 -1
  183. package/dist/components/PhoneInput/PhoneInput.d.ts +17 -17
  184. package/dist/components/PhoneInput/PhoneInput.stories.d.ts +28 -28
  185. package/dist/components/PhoneInput/PhoneInput.styles.d.ts +9 -9
  186. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.d.ts +13 -13
  187. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +5 -5
  188. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.d.ts +7 -7
  189. package/dist/components/PhoneInput/components/PhoneInputCountryList/index.d.ts +2 -2
  190. package/dist/components/PhoneInput/components/index.d.ts +1 -1
  191. package/dist/components/PhoneInput/constants.d.ts +2 -2
  192. package/dist/components/PhoneInput/index.d.ts +4 -4
  193. package/dist/components/PhoneInput/types.d.ts +15 -15
  194. package/dist/components/RadioButton/RadioButton.d.ts +15 -15
  195. package/dist/components/RadioButton/RadioButton.stories.d.ts +7 -7
  196. package/dist/components/RadioButton/RadioButton.styles.d.ts +3 -3
  197. package/dist/components/RadioButton/index.d.ts +2 -2
  198. package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +386 -386
  199. package/dist/components/ScrollIntoViewIfNeeded/constants.d.ts +3 -3
  200. package/dist/components/ScrollIntoViewIfNeeded/index.d.ts +1 -1
  201. package/dist/components/SearchInput/SearchInput.d.ts +6 -6
  202. package/dist/components/SearchInput/SearchInput.stories.d.ts +13 -13
  203. package/dist/components/SearchInput/SearchInput.styles.d.ts +7 -7
  204. package/dist/components/SearchInput/index.d.ts +2 -2
  205. package/dist/components/Select/CustomSelect.stories.d.ts +11 -11
  206. package/dist/components/Select/MultiSelect.stories.d.ts +15 -15
  207. package/dist/components/Select/Select.d.ts +47 -47
  208. package/dist/components/Select/Select.stories.d.ts +15 -15
  209. package/dist/components/Select/Select.styles.d.ts +33 -33
  210. package/dist/components/Select/components/SelectList/SelectList.d.ts +22 -22
  211. package/dist/components/Select/components/SelectList/SelectList.styles.d.ts +6 -6
  212. package/dist/components/Select/components/SelectList/index.d.ts +2 -2
  213. package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +14 -14
  214. package/dist/components/Select/components/SelectListItem/SelectListItem.styles.d.ts +2 -2
  215. package/dist/components/Select/components/SelectListItem/index.d.ts +1 -1
  216. package/dist/components/Select/components/index.d.ts +2 -2
  217. package/dist/components/Select/constants.d.ts +2 -2
  218. package/dist/components/Select/helpers.d.ts +7 -7
  219. package/dist/components/Select/index.d.ts +4 -4
  220. package/dist/components/Select/types.d.ts +1 -1
  221. package/dist/components/Selector/Selector.d.ts +22 -22
  222. package/dist/components/Selector/Selector.stories.d.ts +7 -7
  223. package/dist/components/Selector/Selector.styles.d.ts +9 -9
  224. package/dist/components/Selector/index.d.ts +2 -2
  225. package/dist/components/Selector/types.d.ts +10 -10
  226. package/dist/components/Skeleton/Skeleton.d.ts +7 -7
  227. package/dist/components/Skeleton/Skeleton.stories.d.ts +6 -6
  228. package/dist/components/Skeleton/Skeleton.styles.d.ts +3 -3
  229. package/dist/components/Skeleton/index.d.ts +2 -2
  230. package/dist/components/SmartInput/SmartInput.d.ts +12 -12
  231. package/dist/components/SmartInput/SmartInput.stories.d.ts +18 -18
  232. package/dist/components/SmartInput/constants.d.ts +18 -18
  233. package/dist/components/SmartInput/helpers.d.ts +4 -4
  234. package/dist/components/SmartInput/index.d.ts +2 -2
  235. package/dist/components/SmartInput/types.d.ts +1 -1
  236. package/dist/components/Status/Status.d.ts +16 -16
  237. package/dist/components/Status/Status.stories.d.ts +6 -6
  238. package/dist/components/Status/Status.styles.d.ts +3 -3
  239. package/dist/components/Status/constants.d.ts +2 -2
  240. package/dist/components/Status/index.d.ts +2 -2
  241. package/dist/components/Status/types.d.ts +3 -3
  242. package/dist/components/Switch/Switch.d.ts +20 -20
  243. package/dist/components/Switch/Switch.stories.d.ts +16 -16
  244. package/dist/components/Switch/Switch.styles.d.ts +3 -3
  245. package/dist/components/Switch/index.d.ts +3 -3
  246. package/dist/components/Switch/types.d.ts +4 -4
  247. package/dist/components/TextArea/TextArea.d.ts +36 -36
  248. package/dist/components/TextArea/TextArea.stories.d.ts +16 -16
  249. package/dist/components/TextArea/TextArea.styles.d.ts +3 -3
  250. package/dist/components/TextArea/index.d.ts +2 -2
  251. package/dist/components/TextButton/TextButton.d.ts +31 -31
  252. package/dist/components/TextButton/TextButton.stories.d.ts +6 -6
  253. package/dist/components/TextButton/TextButton.styles.d.ts +7 -7
  254. package/dist/components/TextButton/constants.d.ts +2 -2
  255. package/dist/components/TextButton/index.d.ts +3 -3
  256. package/dist/components/TextButton/types.d.ts +5 -5
  257. package/dist/components/TextWithInfo/TextWithInfo.d.ts +15 -15
  258. package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +12 -12
  259. package/dist/components/TextWithInfo/TextWithInfo.styles.d.ts +3 -3
  260. package/dist/components/TextWithInfo/index.d.ts +2 -2
  261. package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +26 -26
  262. package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +24 -24
  263. package/dist/components/TextWithTooltip/TextWithTooltip.styles.d.ts +6 -6
  264. package/dist/components/TextWithTooltip/index.d.ts +2 -2
  265. package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +11 -11
  266. package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +17 -17
  267. package/dist/components/ThemedPreloader/ThemedPreloader.styles.d.ts +7 -7
  268. package/dist/components/ThemedPreloader/components/DefaultPreloader/DefaultPreloader.d.ts +2 -2
  269. package/dist/components/ThemedPreloader/components/DefaultPreloader/index.d.ts +1 -1
  270. package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.d.ts +5 -5
  271. package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.d.ts +3 -3
  272. package/dist/components/ThemedPreloader/components/DotsPreloader/index.d.ts +2 -2
  273. package/dist/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.d.ts +8 -8
  274. package/dist/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.d.ts +3 -3
  275. package/dist/components/ThemedPreloader/components/SvgPreloader/index.d.ts +2 -2
  276. package/dist/components/ThemedPreloader/components/index.d.ts +3 -3
  277. package/dist/components/ThemedPreloader/constants.d.ts +1 -1
  278. package/dist/components/ThemedPreloader/index.d.ts +4 -4
  279. package/dist/components/ThemedPreloader/types.d.ts +2 -2
  280. package/dist/components/Toaster/Toaster.d.ts +23 -23
  281. package/dist/components/Toaster/Toaster.stories.d.ts +5 -5
  282. package/dist/components/Toaster/Toaster.styles.d.ts +6 -6
  283. package/dist/components/Toaster/constants.d.ts +1 -1
  284. package/dist/components/Toaster/index.d.ts +3 -3
  285. package/dist/components/Toaster/types.d.ts +1 -1
  286. package/dist/components/Tooltip/Tooltip.d.ts +11 -11
  287. package/dist/components/Tooltip/Tooltip.stories.d.ts +5 -5
  288. package/dist/components/Tooltip/Tooltip.styles.d.ts +3 -3
  289. package/dist/components/Tooltip/index.d.ts +3 -3
  290. package/dist/components/Tooltip/types.d.ts +1 -1
  291. package/dist/components/WithPopup/WithPopup.d.ts +30 -30
  292. package/dist/components/WithPopup/WithPopup.stories.d.ts +16 -16
  293. package/dist/components/WithPopup/WithPopup.styles.d.ts +3 -3
  294. package/dist/components/WithPopup/constants.d.ts +2 -2
  295. package/dist/components/WithPopup/index.d.ts +2 -2
  296. package/dist/components/WithPopup/types.d.ts +2 -2
  297. package/dist/components/index.d.ts +43 -43
  298. package/dist/constants/index.d.ts +1 -1
  299. package/dist/constants/phone-info.d.ts +2 -2
  300. package/dist/helpers/index.d.ts +3 -3
  301. package/dist/helpers/misc.d.ts +19 -19
  302. package/dist/helpers/phone.d.ts +14 -14
  303. package/dist/helpers/popper-helpers.d.ts +2 -2
  304. package/dist/hooks/index.d.ts +7 -7
  305. package/dist/hooks/use-did-mount-effect.d.ts +2 -2
  306. package/dist/hooks/use-dropdown.d.ts +11 -11
  307. package/dist/hooks/use-is-mounted.d.ts +1 -1
  308. package/dist/hooks/use-merged-refs.d.ts +2 -2
  309. package/dist/hooks/use-mixed-styles.d.ts +1 -1
  310. package/dist/hooks/use-on-click-outside.d.ts +5 -5
  311. package/dist/hooks/use-tweak-styles.d.ts +21 -21
  312. package/dist/index.d.ts +6 -6
  313. package/dist/theme/Provider.d.ts +11 -11
  314. package/dist/theme/common.d.ts +100 -100
  315. package/dist/theme/helpers.d.ts +10 -10
  316. package/dist/theme/index.d.ts +4 -4
  317. package/dist/theme/types.d.ts +80 -80
  318. package/dist/true-react-common-ui-kit.js +57 -60
  319. package/dist/true-react-common-ui-kit.js.map +1 -1
  320. package/dist/true-react-common-ui-kit.umd.cjs +57 -60
  321. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  322. package/dist/types.d.ts +19 -19
  323. package/package.json +97 -97
  324. package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
  325. package/src/components/AccountInfo/AccountInfo.styles.ts +52 -52
  326. package/src/components/AccountInfo/AccountInfo.tsx +80 -80
  327. package/src/components/AccountInfo/constants.ts +1 -1
  328. package/src/components/AccountInfo/index.ts +2 -2
  329. package/src/components/AddButton/AddButton.stories.tsx +21 -21
  330. package/src/components/AddButton/AddButton.styles.ts +34 -34
  331. package/src/components/AddButton/AddButton.tsx +52 -52
  332. package/src/components/AddButton/index.ts +2 -2
  333. package/src/components/Button/Button.stories.tsx +54 -54
  334. package/src/components/Button/Button.styles.ts +200 -200
  335. package/src/components/Button/Button.tsx +129 -129
  336. package/src/components/Button/constants.ts +11 -11
  337. package/src/components/Button/index.ts +3 -3
  338. package/src/components/Button/types.ts +5 -5
  339. package/src/components/Checkbox/Checkbox.stories.tsx +54 -54
  340. package/src/components/Checkbox/Checkbox.styles.ts +49 -49
  341. package/src/components/Checkbox/Checkbox.tsx +84 -84
  342. package/src/components/Checkbox/index.ts +2 -2
  343. package/src/components/CloseButton/CloseButton.stories.tsx +11 -11
  344. package/src/components/CloseButton/CloseButton.styles.ts +34 -34
  345. package/src/components/CloseButton/CloseButton.tsx +35 -35
  346. package/src/components/CloseButton/index.ts +2 -2
  347. package/src/components/Colors/Colors.stories.tsx +7 -7
  348. package/src/components/Colors/Colors.styles.ts +36 -36
  349. package/src/components/Colors/Colors.tsx +26 -26
  350. package/src/components/Colors/index.ts +1 -1
  351. package/src/components/CssBaseline/CssBaseline.styles.ts +14 -14
  352. package/src/components/CssBaseline/CssBaseline.tsx +13 -13
  353. package/src/components/CssBaseline/index.ts +2 -2
  354. package/src/components/DateInput/DateInput.stories.tsx +61 -61
  355. package/src/components/DateInput/DateInput.styles.ts +18 -18
  356. package/src/components/DateInput/DateInput.tsx +90 -90
  357. package/src/components/DateInput/constants.ts +2 -2
  358. package/src/components/DateInput/index.ts +3 -3
  359. package/src/components/DatePicker/DatePicker.stories.tsx +88 -88
  360. package/src/components/DatePicker/DatePicker.styles.ts +38 -38
  361. package/src/components/DatePicker/DatePicker.tsx +308 -308
  362. package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.ts +88 -88
  363. package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.tsx +89 -89
  364. package/src/components/DatePicker/components/DatePickerHeader/index.ts +2 -2
  365. package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +6 -6
  366. package/src/components/DatePicker/components/PopperContainer/index.ts +1 -1
  367. package/src/components/DatePicker/components/index.ts +2 -2
  368. package/src/components/DatePicker/constants.ts +6 -6
  369. package/src/components/DatePicker/helpers.ts +23 -23
  370. package/src/components/DatePicker/index.ts +4 -4
  371. package/src/components/DatePicker/types.ts +45 -45
  372. package/src/components/Description/Description.stories.tsx +27 -27
  373. package/src/components/Description/Description.styles.ts +30 -30
  374. package/src/components/Description/Description.tsx +61 -61
  375. package/src/components/Description/constants.ts +1 -1
  376. package/src/components/Description/index.ts +2 -2
  377. package/src/components/FiltersPane/FiltersPane.stories.tsx +287 -287
  378. package/src/components/FiltersPane/FiltersPane.styles.ts +88 -88
  379. package/src/components/FiltersPane/FiltersPane.tsx +158 -158
  380. package/src/components/FiltersPane/components/Filter/Filter.tsx +203 -203
  381. package/src/components/FiltersPane/components/Filter/index.ts +1 -1
  382. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +61 -61
  383. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +154 -154
  384. package/src/components/FiltersPane/components/FilterInterval/index.ts +2 -2
  385. package/src/components/FiltersPane/components/FilterMultiSelect/FilterMultiSelect.tsx +10 -10
  386. package/src/components/FiltersPane/components/FilterMultiSelect/index.ts +1 -1
  387. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.styles.ts +141 -141
  388. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.tsx +354 -354
  389. package/src/components/FiltersPane/components/FilterSelect/index.ts +2 -2
  390. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.styles.tsx +15 -15
  391. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
  392. package/src/components/FiltersPane/components/FilterValueView/index.tsx +2 -2
  393. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +68 -68
  394. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
  395. package/src/components/FiltersPane/components/FilterWithDates/index.ts +2 -2
  396. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.styles.ts +21 -21
  397. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
  398. package/src/components/FiltersPane/components/FilterWithPeriod/index.ts +2 -2
  399. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.ts +115 -115
  400. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +167 -167
  401. package/src/components/FiltersPane/components/FilterWrapper/index.ts +2 -2
  402. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +123 -123
  403. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.tsx +165 -165
  404. package/src/components/FiltersPane/components/FiltersPaneSearch/index.ts +2 -2
  405. package/src/components/FiltersPane/components/index.ts +9 -9
  406. package/src/components/FiltersPane/constants.ts +137 -137
  407. package/src/components/FiltersPane/helpers.ts +26 -26
  408. package/src/components/FiltersPane/index.ts +5 -5
  409. package/src/components/FiltersPane/types.ts +156 -156
  410. package/src/components/Flag/Flag.stories.tsx +29 -29
  411. package/src/components/Flag/Flag.styles.ts +17 -17
  412. package/src/components/Flag/Flag.tsx +26 -26
  413. package/src/components/Flag/augment.d.ts +1 -1
  414. package/src/components/Flag/index.ts +2 -2
  415. package/src/components/FlexibleTable/FlexibleTable.stories.tsx +267 -267
  416. package/src/components/FlexibleTable/FlexibleTable.styles.ts +111 -111
  417. package/src/components/FlexibleTable/FlexibleTable.tsx +271 -271
  418. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +38 -38
  419. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +83 -83
  420. package/src/components/FlexibleTable/components/FlexibleTableCell/index.ts +2 -2
  421. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
  422. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +196 -196
  423. package/src/components/FlexibleTable/components/FlexibleTableRow/index.ts +2 -2
  424. package/src/components/FlexibleTable/components/index.ts +2 -2
  425. package/src/components/FlexibleTable/constants.ts +1 -1
  426. package/src/components/FlexibleTable/helpers.ts +13 -13
  427. package/src/components/FlexibleTable/index.ts +4 -4
  428. package/src/components/FlexibleTable/types.ts +52 -52
  429. package/src/components/Icon/Icon.stories.tsx +86 -86
  430. package/src/components/Icon/Icon.styles.ts +10 -10
  431. package/src/components/Icon/Icon.tsx +26 -26
  432. package/src/components/Icon/complexIcons/augment.d.ts +1 -1
  433. package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
  434. package/src/components/Icon/complexIcons/icons.ts +5 -5
  435. package/src/components/Icon/complexIcons/index.ts +1 -1
  436. package/src/components/Icon/components/ComplexIconBoilerplate/ComplexIconBoilerplate.tsx +16 -16
  437. package/src/components/Icon/components/ComplexIconBoilerplate/index.ts +1 -1
  438. package/src/components/Icon/components/IconBolerplate/IconBoilerplate.tsx +43 -43
  439. package/src/components/Icon/components/IconBolerplate/index.ts +1 -1
  440. package/src/components/Icon/components/index.ts +2 -2
  441. package/src/components/Icon/helpers.tsx +9 -9
  442. package/src/components/Icon/icons-list.ts +848 -848
  443. package/src/components/Icon/index.ts +5 -5
  444. package/src/components/Icon/snippet.tsx +6 -6
  445. package/src/components/Icon/types.ts +18 -18
  446. package/src/components/IconButton/IconButton.stories.tsx +32 -32
  447. package/src/components/IconButton/IconButton.styles.ts +84 -88
  448. package/src/components/IconButton/IconButton.tsx +74 -74
  449. package/src/components/IconButton/constants.ts +3 -3
  450. package/src/components/IconButton/index.ts +3 -3
  451. package/src/components/IconButton/types.ts +11 -11
  452. package/src/components/IncrementInput/IncrementInput.stories.tsx +31 -31
  453. package/src/components/IncrementInput/IncrementInput.styles.ts +78 -78
  454. package/src/components/IncrementInput/IncrementInput.tsx +105 -105
  455. package/src/components/IncrementInput/index.ts +2 -2
  456. package/src/components/Input/Input.stories.tsx +86 -86
  457. package/src/components/Input/Input.styles.ts +308 -308
  458. package/src/components/Input/Input.tsx +297 -297
  459. package/src/components/Input/constants.ts +1 -1
  460. package/src/components/Input/index.ts +3 -3
  461. package/src/components/Input/types.ts +32 -32
  462. package/src/components/List/List.stories.tsx +70 -70
  463. package/src/components/List/List.styles.ts +52 -52
  464. package/src/components/List/List.tsx +33 -33
  465. package/src/components/List/components/ListItem/ListItem.styles.ts +48 -48
  466. package/src/components/List/components/ListItem/ListItem.tsx +57 -57
  467. package/src/components/List/components/ListItem/index.ts +2 -2
  468. package/src/components/List/components/index.ts +1 -1
  469. package/src/components/List/index.ts +3 -3
  470. package/src/components/Modal/Modal.stories.tsx +105 -105
  471. package/src/components/Modal/Modal.styles.ts +318 -318
  472. package/src/components/Modal/Modal.tsx +203 -203
  473. package/src/components/Modal/index.ts +3 -3
  474. package/src/components/Modal/types.ts +17 -17
  475. package/src/components/MoreMenu/MoreMenu.stories.tsx +46 -46
  476. package/src/components/MoreMenu/MoreMenu.styles.ts +69 -69
  477. package/src/components/MoreMenu/MoreMenu.tsx +93 -93
  478. package/src/components/MoreMenu/index.ts +2 -2
  479. package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
  480. package/src/components/MultiSelect/MultiSelect.styles.ts +59 -59
  481. package/src/components/MultiSelect/MultiSelect.tsx +106 -106
  482. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.styles.ts +73 -73
  483. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
  484. package/src/components/MultiSelect/components/MultiSelectInput/index.ts +2 -2
  485. package/src/components/MultiSelect/components/index.ts +1 -1
  486. package/src/components/MultiSelect/index.ts +4 -4
  487. package/src/components/MultiSelect/types.ts +1 -1
  488. package/src/components/MultiSelectList/MultiSelectList.styles.ts +136 -136
  489. package/src/components/MultiSelectList/MultiSelectList.tsx +464 -464
  490. package/src/components/MultiSelectList/constants.ts +21 -21
  491. package/src/components/MultiSelectList/helpers.ts +11 -11
  492. package/src/components/MultiSelectList/index.ts +3 -3
  493. package/src/components/MultiSelectList/types.ts +15 -15
  494. package/src/components/NewMoreMenu/NewMoreMenu.stories.tsx +73 -73
  495. package/src/components/NewMoreMenu/NewMoreMenu.styles.ts +39 -39
  496. package/src/components/NewMoreMenu/NewMoreMenu.tsx +80 -80
  497. package/src/components/NewMoreMenu/index.ts +2 -2
  498. package/src/components/Notification/Notification.stories.tsx +46 -46
  499. package/src/components/Notification/Notification.styles.ts +55 -55
  500. package/src/components/Notification/Notification.tsx +69 -69
  501. package/src/components/Notification/index.ts +3 -3
  502. package/src/components/Notification/types.ts +1 -1
  503. package/src/components/NumberInput/NumberInput.stories.tsx +35 -35
  504. package/src/components/NumberInput/NumberInput.tsx +137 -137
  505. package/src/components/NumberInput/helpers.ts +86 -86
  506. package/src/components/NumberInput/index.ts +1 -1
  507. package/src/components/PhoneInput/PhoneInput.stories.tsx +70 -70
  508. package/src/components/PhoneInput/PhoneInput.styles.ts +89 -89
  509. package/src/components/PhoneInput/PhoneInput.tsx +214 -214
  510. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.tsx +21 -21
  511. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.ts +103 -103
  512. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
  513. package/src/components/PhoneInput/components/PhoneInputCountryList/index.ts +2 -2
  514. package/src/components/PhoneInput/components/index.ts +1 -1
  515. package/src/components/PhoneInput/constants.ts +3 -3
  516. package/src/components/PhoneInput/index.ts +4 -4
  517. package/src/components/PhoneInput/types.ts +16 -16
  518. package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
  519. package/src/components/RadioButton/RadioButton.styles.ts +37 -37
  520. package/src/components/RadioButton/RadioButton.tsx +57 -57
  521. package/src/components/RadioButton/index.ts +2 -2
  522. package/src/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.ts +54 -54
  523. package/src/components/ScrollIntoViewIfNeeded/constants.ts +12 -12
  524. package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
  525. package/src/components/SearchInput/SearchInput.stories.tsx +23 -23
  526. package/src/components/SearchInput/SearchInput.styles.ts +50 -50
  527. package/src/components/SearchInput/SearchInput.tsx +56 -56
  528. package/src/components/SearchInput/index.ts +2 -2
  529. package/src/components/Select/CustomSelect.stories.tsx +217 -217
  530. package/src/components/Select/MultiSelect.stories.tsx +240 -240
  531. package/src/components/Select/Select.stories.tsx +235 -235
  532. package/src/components/Select/Select.styles.ts +146 -146
  533. package/src/components/Select/Select.tsx +609 -609
  534. package/src/components/Select/components/SelectList/SelectList.styles.ts +71 -71
  535. package/src/components/Select/components/SelectList/SelectList.tsx +156 -156
  536. package/src/components/Select/components/SelectList/index.ts +2 -2
  537. package/src/components/Select/components/SelectListItem/SelectListItem.styles.ts +14 -14
  538. package/src/components/Select/components/SelectListItem/SelectListItem.tsx +72 -72
  539. package/src/components/Select/components/SelectListItem/index.ts +1 -1
  540. package/src/components/Select/components/index.ts +2 -2
  541. package/src/components/Select/constants.ts +2 -2
  542. package/src/components/Select/helpers.ts +27 -27
  543. package/src/components/Select/index.ts +4 -4
  544. package/src/components/Select/types.ts +1 -1
  545. package/src/components/Selector/Selector.stories.tsx +62 -62
  546. package/src/components/Selector/Selector.styles.ts +165 -165
  547. package/src/components/Selector/Selector.tsx +115 -115
  548. package/src/components/Selector/index.ts +2 -2
  549. package/src/components/Selector/types.ts +12 -12
  550. package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
  551. package/src/components/Skeleton/Skeleton.styles.ts +46 -46
  552. package/src/components/Skeleton/Skeleton.tsx +12 -12
  553. package/src/components/Skeleton/index.ts +2 -2
  554. package/src/components/SmartInput/SmartInput.stories.tsx +51 -51
  555. package/src/components/SmartInput/SmartInput.tsx +134 -134
  556. package/src/components/SmartInput/constants.ts +84 -84
  557. package/src/components/SmartInput/helpers.ts +13 -13
  558. package/src/components/SmartInput/index.ts +2 -2
  559. package/src/components/SmartInput/types.ts +11 -11
  560. package/src/components/Status/Status.stories.tsx +73 -73
  561. package/src/components/Status/Status.styles.ts +143 -143
  562. package/src/components/Status/Status.tsx +49 -49
  563. package/src/components/Status/constants.ts +11 -11
  564. package/src/components/Status/index.ts +3 -3
  565. package/src/components/Status/types.ts +5 -5
  566. package/src/components/Switch/Switch.stories.tsx +40 -40
  567. package/src/components/Switch/Switch.styles.ts +75 -75
  568. package/src/components/Switch/Switch.tsx +75 -75
  569. package/src/components/Switch/index.ts +3 -3
  570. package/src/components/Switch/types.ts +4 -4
  571. package/src/components/TextArea/TextArea.stories.tsx +35 -35
  572. package/src/components/TextArea/TextArea.styles.ts +157 -157
  573. package/src/components/TextArea/TextArea.tsx +180 -180
  574. package/src/components/TextArea/index.ts +2 -2
  575. package/src/components/TextButton/TextButton.stories.tsx +47 -47
  576. package/src/components/TextButton/TextButton.styles.ts +130 -130
  577. package/src/components/TextButton/TextButton.tsx +110 -110
  578. package/src/components/TextButton/constants.ts +3 -3
  579. package/src/components/TextButton/index.ts +3 -3
  580. package/src/components/TextButton/types.ts +11 -11
  581. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
  582. package/src/components/TextWithInfo/TextWithInfo.styles.ts +59 -59
  583. package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
  584. package/src/components/TextWithInfo/index.ts +2 -2
  585. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
  586. package/src/components/TextWithTooltip/TextWithTooltip.styles.ts +21 -21
  587. package/src/components/TextWithTooltip/TextWithTooltip.tsx +156 -156
  588. package/src/components/TextWithTooltip/index.ts +2 -2
  589. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
  590. package/src/components/ThemedPreloader/ThemedPreloader.styles.ts +26 -26
  591. package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
  592. package/src/components/ThemedPreloader/components/DefaultPreloader/DefaultPreloader.tsx +29 -29
  593. package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
  594. package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.ts +54 -54
  595. package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.tsx +15 -15
  596. package/src/components/ThemedPreloader/components/DotsPreloader/index.ts +2 -2
  597. package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.ts +11 -11
  598. package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.tsx +24 -24
  599. package/src/components/ThemedPreloader/components/SvgPreloader/index.ts +2 -2
  600. package/src/components/ThemedPreloader/components/index.ts +3 -3
  601. package/src/components/ThemedPreloader/constants.ts +1 -1
  602. package/src/components/ThemedPreloader/index.ts +4 -4
  603. package/src/components/ThemedPreloader/types.ts +3 -3
  604. package/src/components/Toaster/Toaster.stories.tsx +30 -30
  605. package/src/components/Toaster/Toaster.styles.ts +60 -60
  606. package/src/components/Toaster/Toaster.tsx +109 -109
  607. package/src/components/Toaster/constants.ts +1 -1
  608. package/src/components/Toaster/index.ts +3 -3
  609. package/src/components/Toaster/types.ts +1 -1
  610. package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
  611. package/src/components/Tooltip/Tooltip.styles.ts +49 -49
  612. package/src/components/Tooltip/Tooltip.tsx +35 -35
  613. package/src/components/Tooltip/index.ts +3 -3
  614. package/src/components/Tooltip/types.ts +1 -1
  615. package/src/components/WithPopup/WithPopup.stories.tsx +77 -77
  616. package/src/components/WithPopup/WithPopup.styles.ts +21 -21
  617. package/src/components/WithPopup/WithPopup.tsx +130 -130
  618. package/src/components/WithPopup/constants.ts +3 -3
  619. package/src/components/WithPopup/index.ts +2 -2
  620. package/src/components/WithPopup/types.ts +3 -3
  621. package/src/components/index.ts +43 -43
  622. package/src/constants/index.ts +1 -1
  623. package/src/constants/phone-info.ts +2147 -2147
  624. package/src/helpers/index.ts +3 -3
  625. package/src/helpers/misc.ts +158 -158
  626. package/src/helpers/phone.ts +91 -91
  627. package/src/helpers/popper-helpers.ts +17 -17
  628. package/src/hooks/index.ts +7 -7
  629. package/src/hooks/use-did-mount-effect.ts +18 -18
  630. package/src/hooks/use-dropdown.ts +84 -84
  631. package/src/hooks/use-is-mounted.ts +15 -15
  632. package/src/hooks/use-merged-refs.ts +4 -4
  633. package/src/hooks/use-mixed-styles.ts +14 -14
  634. package/src/hooks/use-on-click-outside.ts +77 -77
  635. package/src/hooks/use-tweak-styles.ts +57 -57
  636. package/src/index.ts +6 -6
  637. package/src/theme/Provider.tsx +21 -21
  638. package/src/theme/common.ts +163 -163
  639. package/src/theme/helpers.ts +76 -76
  640. package/src/theme/index.ts +4 -4
  641. package/src/theme/types.ts +153 -153
  642. package/src/types.ts +26 -26
  643. package/src/vite-env.d.ts +1 -1
@@ -1,609 +1,609 @@
1
- import {
2
- ReactNode,
3
- FocusEvent,
4
- KeyboardEvent,
5
- MouseEvent,
6
- useCallback,
7
- useEffect,
8
- useMemo,
9
- useRef,
10
- useState,
11
- SyntheticEvent,
12
- ChangeEvent,
13
- FormEvent,
14
- } from 'react';
15
- import { Portal } from 'react-overlays';
16
- import clsx from 'clsx';
17
- import { Styles } from 'jss';
18
- import { debounce } from 'ts-debounce';
19
- import {
20
- getTestId,
21
- isNotEmpty,
22
- isReactNodeNotEmpty,
23
- isStringNotEmpty,
24
- createFilter,
25
- } from '@true-engineering/true-react-platform-helpers';
26
- import { hasExactParent } from '../../helpers';
27
- import { useIsMounted, useOnClickOutsideWithRef, useDropdown, useTweakStyles } from '../../hooks';
28
- import { ICommonProps, IDropdownWithPopperOptions } from '../../types';
29
- import { renderIcon, IIcon } from '../Icon';
30
- import { IInputProps, Input } from '../Input';
31
- import { ISearchInputProps, SearchInput } from '../SearchInput';
32
- import { SelectList } from './components';
33
- import { ALL_OPTION_INDEX, DEFAULT_OPTION_INDEX } from './constants';
34
- import {
35
- defaultConvertFunction,
36
- defaultCompareFunction,
37
- defaultIsOptionDisabled,
38
- getDefaultConvertToIdFunction,
39
- isMultiSelectValue,
40
- } from './helpers';
41
- import { IMultipleSelectValue } from './types';
42
- import { useStyles, ISelectStyles, searchInputStyles, getInputStyles } from './Select.styles';
43
-
44
- export interface ISelectProps<Value>
45
- extends Omit<IInputProps, 'value' | 'onChange' | 'onBlur' | 'type' | 'tweakStyles'>,
46
- ICommonProps<ISelectStyles> {
47
- defaultOptionLabel?: ReactNode;
48
- allOptionsLabel?: string;
49
- noMatchesLabel?: string;
50
- loadingLabel?: ReactNode;
51
- /** @default 'normal' */
52
- optionsMode?: 'search' | 'dynamic' | 'normal';
53
- /** @default 400 */
54
- debounceTime?: number;
55
- /** @default 0 */
56
- minSymbolsCountToOpenList?: number;
57
- dropdownOptions?: IDropdownWithPopperOptions;
58
- /** @default 'chevron-down' */
59
- dropdownIcon?: IIcon;
60
- options: Value[] | Readonly<Value[]>;
61
- value: Value | undefined;
62
- /** @default true */
63
- shouldScrollToList?: boolean;
64
- isMultiSelect?: boolean;
65
- searchInput?: { shouldRenderInList: true } & Pick<ISearchInputProps, 'placeholder'>;
66
- isOptionDisabled?: (option: Value) => boolean;
67
- onChange: (
68
- value: Value | undefined,
69
- event:
70
- | MouseEvent<HTMLElement>
71
- | KeyboardEvent
72
- | ChangeEvent<HTMLElement>
73
- | FormEvent<HTMLElement>,
74
- ) => void; // подумать как возвращать индекс
75
- onBlur?: (event: Event | SyntheticEvent) => void;
76
- onType?: (value: string) => Promise<void>;
77
- optionsFilter?: (options: Value[], query: string) => Value[];
78
- onOpen?: () => void;
79
- compareValuesOnChange?: (v1?: Value, v2?: Value) => boolean;
80
- // Для избежания проблем юзайте useCallback на эти функции
81
- // или выносите их из компонента (чтобы не было сайдэфектов от перерендеринга их)
82
- convertValueToString?: (value: Value) => string | undefined;
83
- convertValueToReactNode?: (value: Value, isDisabled: boolean) => ReactNode;
84
- convertValueToId?: (value: Value) => string | undefined;
85
- }
86
-
87
- export interface IMultipleSelectProps<Value>
88
- extends Omit<ISelectProps<Value>, 'value' | 'onChange' | 'compareValuesOnChange'> {
89
- isMultiSelect: true;
90
- value: IMultipleSelectValue<Value> | undefined;
91
- onChange: (
92
- value: IMultipleSelectValue<Value> | undefined,
93
- event:
94
- | MouseEvent<HTMLElement>
95
- | KeyboardEvent
96
- | ChangeEvent<HTMLElement>
97
- | FormEvent<HTMLElement>,
98
- ) => void;
99
- compareValuesOnChange?: (
100
- v1?: IMultipleSelectValue<Value>,
101
- v2?: IMultipleSelectValue<Value>,
102
- ) => boolean;
103
- }
104
-
105
- export function Select<Value>(
106
- props: ISelectProps<Value> | IMultipleSelectProps<Value>,
107
- ): JSX.Element {
108
- const {
109
- options,
110
- value,
111
- defaultOptionLabel,
112
- allOptionsLabel,
113
- debounceTime = 400,
114
- optionsMode = 'normal',
115
- noMatchesLabel,
116
- loadingLabel,
117
- tweakStyles,
118
- testId,
119
- isReadonly,
120
- isDisabled,
121
- dropdownOptions,
122
- minSymbolsCountToOpenList = 0,
123
- dropdownIcon = 'chevron-down',
124
- shouldScrollToList = true,
125
- searchInput,
126
- iconType,
127
- onChange,
128
- onFocus,
129
- onBlur,
130
- onType,
131
- onOpen,
132
- isOptionDisabled = defaultIsOptionDisabled,
133
- compareValuesOnChange = defaultCompareFunction,
134
- convertValueToString = defaultConvertFunction,
135
- convertValueToId,
136
- convertValueToReactNode,
137
- optionsFilter,
138
- ...inputProps
139
- } = props;
140
- const classes = useStyles({ theme: tweakStyles });
141
-
142
- const { shouldRenderInList: shouldRenderSearchInputInList = false, ...searchInputProps } =
143
- searchInput ?? {};
144
- const hasSearchInputInList = optionsMode !== 'normal' && shouldRenderSearchInputInList;
145
- const isMultiSelect = isMultiSelectValue(props, value);
146
- const hasReadonlyInput = isReadonly || optionsMode === 'normal' || shouldRenderSearchInputInList;
147
-
148
- const tweakInputStyles = useTweakStyles({
149
- innerStyles: getInputStyles({ hasReadonlyInput, isMultiSelect }),
150
- tweakStyles,
151
- className: 'tweakInput',
152
- currentComponentName: 'Select',
153
- });
154
-
155
- const tweakSearchInputStyles = useTweakStyles({
156
- innerStyles: searchInputStyles,
157
- tweakStyles,
158
- className: 'tweakSearchInput',
159
- currentComponentName: 'Select',
160
- });
161
-
162
- const tweakSelectListStyles = useTweakStyles({
163
- tweakStyles,
164
- className: 'tweakSelectList',
165
- currentComponentName: 'Select',
166
- });
167
-
168
- const isMounted = useIsMounted();
169
- const [isListOpen, setIsListOpen] = useState(false);
170
- const [areOptionsLoading, setAreOptionsLoading] = useState(false);
171
- const hasDefaultOption = isReactNodeNotEmpty(defaultOptionLabel);
172
-
173
- const [focusedListCellIndex, setFocusedListCellIndex] = useState(DEFAULT_OPTION_INDEX);
174
- const [searchValue, setSearchValue] = useState('');
175
- // если мы ввели что то в строку поиска - то этот булеан будет отключаться
176
- // вынесен отдельно, из-за проблем с дебаунсом при динамич. опциях
177
- const [shouldShowDefaultOption, setShouldShowDefaultOption] = useState(true);
178
-
179
- const inputWrapper = useRef<HTMLDivElement>(null);
180
- const list = useRef<HTMLDivElement>(null);
181
- const input = useRef<HTMLInputElement>(null); // TODO ref снаружи?
182
-
183
- const strValue = isMultiSelect ? value?.[0] : value;
184
- const shouldShowAllOption =
185
- isMultiSelect && isStringNotEmpty(allOptionsLabel) && searchValue === '';
186
-
187
- const filteredOptions = useMemo(() => {
188
- if (optionsMode !== 'search') {
189
- return options;
190
- }
191
-
192
- const filter =
193
- optionsFilter ?? createFilter<Value>((option) => [convertValueToString(option) ?? '']);
194
-
195
- return filter(options as Value[], searchValue);
196
- }, [optionsFilter, options, convertValueToString, searchValue, optionsMode]);
197
-
198
- const availableOptions = useMemo(
199
- () => options.filter((o) => !isOptionDisabled(o)),
200
- [options, isOptionDisabled],
201
- );
202
-
203
- const areAllOptionsSelected = isMultiSelect && value?.length === availableOptions.length;
204
- const shouldShowMultiSelectCounter =
205
- isMultiSelect && isNotEmpty(value) && value.length > 1 && !areAllOptionsSelected;
206
-
207
- const optionsIndexesForNavigation = useMemo(() => {
208
- const result: number[] = [];
209
- if (shouldShowDefaultOption && hasDefaultOption) {
210
- result.push(DEFAULT_OPTION_INDEX);
211
- }
212
- if (shouldShowAllOption) {
213
- result.push(ALL_OPTION_INDEX);
214
- }
215
- return result.concat(
216
- filteredOptions.reduce((acc, cur, i) => {
217
- if (!isOptionDisabled(cur)) {
218
- acc.push(i);
219
- }
220
- return acc;
221
- }, [] as number[]),
222
- );
223
- }, [
224
- filteredOptions,
225
- hasDefaultOption,
226
- isOptionDisabled,
227
- shouldShowAllOption,
228
- shouldShowDefaultOption,
229
- ]);
230
-
231
- const stringValue = isNotEmpty(strValue) ? convertValueToString(strValue) : undefined;
232
- // Для мультиселекта пытаемся показать "Все опции" если выбраны все опции
233
- const showedStringValue =
234
- areAllOptionsSelected && isNotEmpty(allOptionsLabel) ? allOptionsLabel : stringValue;
235
-
236
- const convertToId = useCallback(
237
- (v: Value) => (convertValueToId ?? getDefaultConvertToIdFunction(convertValueToString))(v),
238
- [convertValueToId, convertValueToString],
239
- );
240
-
241
- const handleListClose = useCallback(
242
- (event: Event | SyntheticEvent) => {
243
- setIsListOpen(false);
244
- setSearchValue('');
245
- setShouldShowDefaultOption(true);
246
- onBlur?.(event);
247
- },
248
- [onBlur],
249
- );
250
-
251
- const handleListOpen = () => {
252
- if (!isListOpen) {
253
- setIsListOpen(true);
254
- }
255
- };
256
-
257
- const handleFocus = (event: FocusEvent<HTMLInputElement>) => {
258
- onFocus?.(event);
259
- handleListOpen();
260
- };
261
-
262
- const handleOnClick = () => {
263
- handleListOpen();
264
- };
265
-
266
- const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
267
- // Когда что-то блокирует открытие листа, но блур все равно должен сработать
268
- // например minSymbolsCount
269
- if (isListOpen && !isOpen) {
270
- handleListClose(event);
271
- return;
272
- }
273
-
274
- if (
275
- !isNotEmpty(event.relatedTarget) ||
276
- !isNotEmpty(list.current) ||
277
- !isNotEmpty(inputWrapper.current)
278
- ) {
279
- return;
280
- }
281
-
282
- const isActionInsideSelect =
283
- hasExactParent(event.relatedTarget, list.current) ||
284
- hasExactParent(event.relatedTarget, inputWrapper.current);
285
-
286
- // Ниче не делаем если клик был внутри селекта
287
- if (!isActionInsideSelect) {
288
- handleListClose(event);
289
- }
290
- };
291
-
292
- const handleOnChange = useCallback(
293
- (
294
- newValue: Value | IMultipleSelectValue<Value> | undefined,
295
- event:
296
- | MouseEvent<HTMLElement>
297
- | KeyboardEvent
298
- | ChangeEvent<HTMLElement>
299
- | FormEvent<HTMLElement>,
300
- ) => {
301
- // Тут беда с типами, сорри
302
- if (!compareValuesOnChange(value as never, newValue as never)) {
303
- onChange(newValue as (Value & IMultipleSelectValue<Value>) | undefined, event);
304
- }
305
- },
306
- [value, compareValuesOnChange, onChange],
307
- );
308
-
309
- const handleOptionSelect = useCallback(
310
- (index: number, event: MouseEvent<HTMLElement> | KeyboardEvent) => {
311
- handleOnChange(index === DEFAULT_OPTION_INDEX ? undefined : filteredOptions[index], event);
312
- handleListClose(event);
313
- input.current?.blur();
314
- },
315
- [handleOnChange, handleListClose, filteredOptions],
316
- );
317
-
318
- // MultiSelect
319
- const handleToggleOptionCheckbox = useCallback(
320
- (index: number, isSelected: boolean, event: ChangeEvent<HTMLElement> | KeyboardEvent) => {
321
- if (!isMultiSelect) {
322
- return;
323
- }
324
-
325
- // Если выбрана не дефолтная опция, которая сетит андеф
326
- if (index === DEFAULT_OPTION_INDEX || (index === ALL_OPTION_INDEX && !isSelected)) {
327
- handleOnChange(undefined, event);
328
- return;
329
- }
330
- if (index === ALL_OPTION_INDEX && isSelected) {
331
- handleOnChange(availableOptions as IMultipleSelectValue<Value>, event);
332
- return;
333
- }
334
- const option = filteredOptions[index];
335
- handleOnChange(
336
- isSelected
337
- ? // Добавляем
338
- ([...(value ?? []), option] as IMultipleSelectValue<Value>)
339
- : // Убираем
340
- value?.filter((o) => convertToId(o) !== convertToId(option)),
341
- event,
342
- );
343
- },
344
- [isMultiSelect, filteredOptions, handleOnChange, value, availableOptions, convertToId],
345
- );
346
-
347
- const handleOnType = useCallback(
348
- async (v: string) => {
349
- if (onType === undefined) {
350
- return;
351
- }
352
- if (isMounted()) {
353
- setAreOptionsLoading(true);
354
- }
355
- await onType(v);
356
- if (isMounted()) {
357
- setAreOptionsLoading(false);
358
- }
359
- if (optionsMode === 'dynamic') {
360
- setShouldShowDefaultOption(v === '');
361
- }
362
- },
363
- [isMounted, onType, optionsMode],
364
- );
365
-
366
- const debounceHandleOnType = useMemo(
367
- () => debounce(handleOnType, debounceTime),
368
- [handleOnType, debounceTime],
369
- );
370
-
371
- const handleInputChange = (v: string, event: FormEvent<HTMLElement>) => {
372
- if (onType !== undefined) {
373
- debounceHandleOnType(v);
374
- }
375
-
376
- if (optionsMode !== 'dynamic') {
377
- setShouldShowDefaultOption(v === '');
378
- }
379
-
380
- if (v === '' && !hasSearchInputInList) {
381
- handleOnChange(undefined, event);
382
- }
383
-
384
- setSearchValue(v);
385
- };
386
-
387
- const handleKeyDown = (event: KeyboardEvent) => {
388
- if (!isListOpen) {
389
- return;
390
- }
391
-
392
- event.stopPropagation();
393
- const curIndexInNavigation = optionsIndexesForNavigation.findIndex(
394
- (index) => index === focusedListCellIndex,
395
- );
396
-
397
- switch (event.code) {
398
- case 'Enter':
399
- case 'NumpadEnter': {
400
- let indexToSelect = focusedListCellIndex;
401
-
402
- // если осталась одна опция в списке,
403
- // то выбираем ее нажатием на enter
404
- if (indexToSelect === DEFAULT_OPTION_INDEX && filteredOptions.length === 1) {
405
- indexToSelect = 0;
406
- }
407
-
408
- if (isMultiSelect) {
409
- let isThisValueAlreadySelected: boolean;
410
- if (indexToSelect === ALL_OPTION_INDEX) {
411
- isThisValueAlreadySelected = areAllOptionsSelected;
412
- } else {
413
- // подумать над концептом реального фокуса на опциях, а не вот эти вот focusedCell
414
- const valueIdToSelect = convertToId(filteredOptions[indexToSelect]);
415
- isThisValueAlreadySelected =
416
- value?.some((opt) => convertToId(opt) === valueIdToSelect) ?? false;
417
- }
418
- handleToggleOptionCheckbox(indexToSelect, !isThisValueAlreadySelected, event);
419
- } else {
420
- handleOptionSelect(indexToSelect, event);
421
- }
422
- break;
423
- }
424
-
425
- case 'ArrowDown': {
426
- // чтобы убрать перемещение курсора в инпуте
427
- event.preventDefault();
428
- const targetIndexInNavigation =
429
- (curIndexInNavigation + 1) % optionsIndexesForNavigation.length;
430
- setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation]);
431
- break;
432
- }
433
-
434
- case 'ArrowUp': {
435
- // чтобы убрать перемещение курсора в инпуте
436
- event.preventDefault();
437
- const targetIndexInNavigation =
438
- (curIndexInNavigation - 1 + optionsIndexesForNavigation.length) %
439
- optionsIndexesForNavigation.length;
440
- setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation]);
441
- break;
442
- }
443
- }
444
- };
445
-
446
- const onArrowClick = () => {
447
- if (isListOpen) {
448
- input.current?.blur();
449
- } else {
450
- input.current?.focus();
451
- }
452
- };
453
-
454
- useOnClickOutsideWithRef(list, handleListClose, inputWrapper);
455
-
456
- const hasEnoughSymbolsToSearch = searchValue.trim().length >= minSymbolsCountToOpenList;
457
-
458
- const isOpen =
459
- // Пользователь пытается открыть лист
460
- isListOpen &&
461
- // Нам есть что показать:
462
- // Есть опции
463
- (filteredOptions.length > 0 ||
464
- // Дефолтная опция
465
- (defaultOptionLabel !== undefined && !hasEnoughSymbolsToSearch) ||
466
- // Текст "Загрузка..."
467
- inputProps.isLoading ||
468
- // Текст "Совпадений не найдено"
469
- noMatchesLabel !== undefined ||
470
- // У нас есть инпут с поиском внутри листа
471
- hasSearchInputInList) &&
472
- // Последняя проверка на случай, если мы че то ищем в опциях
473
- (optionsMode === 'normal' || hasEnoughSymbolsToSearch);
474
-
475
- // Эти значения ставятся в false по дефолту также в useDropdown
476
- const {
477
- shouldUsePopper = false,
478
- shouldRenderInBody = false,
479
- shouldHideOnScroll = false,
480
- } = dropdownOptions ?? {};
481
-
482
- const popperData = useDropdown({
483
- isOpen,
484
- onDropdownClose: handleListClose,
485
- referenceElement: inputWrapper.current,
486
- dropdownElement: list.current,
487
- options: dropdownOptions,
488
- dependenciesForPositionUpdating: [inputProps.isLoading, filteredOptions.length],
489
- });
490
-
491
- useEffect(() => {
492
- setFocusedListCellIndex(
493
- optionsIndexesForNavigation.find(
494
- (index) =>
495
- isNotEmpty(strValue) &&
496
- isNotEmpty(filteredOptions[index]) &&
497
- convertToId(filteredOptions[index]) === convertToId(strValue),
498
- ) ?? optionsIndexesForNavigation[0],
499
- );
500
- }, [strValue, filteredOptions, optionsIndexesForNavigation, convertToId]);
501
-
502
- useEffect(() => {
503
- if (isOpen) {
504
- onOpen?.();
505
- }
506
- }, [isOpen]);
507
-
508
- const listEl = (
509
- <div
510
- className={clsx(classes.listWrapper, {
511
- [classes.withoutPopper]: !shouldUsePopper,
512
- [classes.listWrapperInBody]: shouldRenderInBody,
513
- })}
514
- ref={list}
515
- style={popperData?.styles.popper as Styles}
516
- onBlur={handleBlur} // обработка для Tab из списка
517
- {...popperData?.attributes.popper}
518
- >
519
- {isOpen && (
520
- <SelectList
521
- options={filteredOptions}
522
- defaultOptionLabel={hasDefaultOption && shouldShowDefaultOption && defaultOptionLabel}
523
- allOptionsLabel={shouldShowAllOption && allOptionsLabel}
524
- areAllOptionsSelected={areAllOptionsSelected}
525
- customListHeader={
526
- hasSearchInputInList && (
527
- <SearchInput
528
- value={searchValue}
529
- onChange={handleInputChange}
530
- tweakStyles={tweakSearchInputStyles}
531
- placeholder="Поиск"
532
- {...searchInputProps}
533
- />
534
- )
535
- }
536
- noMatchesLabel={noMatchesLabel}
537
- focusedIndex={focusedListCellIndex}
538
- activeValue={value}
539
- isLoading={inputProps.isLoading}
540
- loadingLabel={loadingLabel}
541
- tweakStyles={tweakSelectListStyles}
542
- testId={getTestId(testId, 'list')}
543
- // скролл не работает с включеным поппером
544
- shouldScrollToList={shouldScrollToList && !shouldUsePopper && !shouldHideOnScroll}
545
- isOptionDisabled={isOptionDisabled}
546
- convertValueToString={convertValueToString}
547
- convertValueToReactNode={convertValueToReactNode}
548
- convertValueToId={convertToId}
549
- onOptionSelect={handleOptionSelect}
550
- onToggleCheckbox={isMultiSelect ? handleToggleOptionCheckbox : undefined}
551
- />
552
- )}
553
- </div>
554
- );
555
-
556
- const multiSelectCounterWithIcon =
557
- shouldShowMultiSelectCounter || isNotEmpty(iconType) ? (
558
- <>
559
- {shouldShowMultiSelectCounter && (
560
- <div className={classes.counter}>(+{value.length - 1})</div>
561
- )}
562
- {isNotEmpty(iconType) && <div className={classes.icon}>{renderIcon(iconType)}</div>}
563
- </>
564
- ) : undefined;
565
-
566
- return (
567
- <div className={classes.root} onKeyDown={handleKeyDown}>
568
- <div
569
- className={clsx(classes.inputWrapper, isDisabled && classes.disabled)}
570
- onClick={isDisabled ? undefined : handleOnClick}
571
- ref={inputWrapper}
572
- >
573
- <Input
574
- value={
575
- searchValue !== '' && !shouldRenderSearchInputInList ? searchValue : showedStringValue
576
- }
577
- onChange={handleInputChange}
578
- isActive={isListOpen}
579
- isReadonly={hasReadonlyInput}
580
- onFocus={handleFocus}
581
- onBlur={handleBlur}
582
- isDisabled={isDisabled}
583
- ref={input}
584
- isLoading={areOptionsLoading}
585
- tweakStyles={tweakInputStyles}
586
- testId={testId}
587
- iconType={isMultiSelect ? multiSelectCounterWithIcon : iconType}
588
- {...inputProps}
589
- />
590
- <div
591
- onMouseDown={(event: MouseEvent) => {
592
- event.preventDefault();
593
- }}
594
- onClick={onArrowClick}
595
- className={clsx(classes.arrow, isOpen && classes.activeArrow)}
596
- >
597
- {renderIcon(dropdownIcon)}
598
- </div>
599
- </div>
600
- {shouldUsePopper ? (
601
- <Portal container={shouldRenderInBody ? document.body : inputWrapper.current}>
602
- <>{listEl}</>
603
- </Portal>
604
- ) : (
605
- <>{isOpen && listEl}</>
606
- )}
607
- </div>
608
- );
609
- }
1
+ import {
2
+ ReactNode,
3
+ FocusEvent,
4
+ KeyboardEvent,
5
+ MouseEvent,
6
+ useCallback,
7
+ useEffect,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ SyntheticEvent,
12
+ ChangeEvent,
13
+ FormEvent,
14
+ } from 'react';
15
+ import { Portal } from 'react-overlays';
16
+ import clsx from 'clsx';
17
+ import { Styles } from 'jss';
18
+ import { debounce } from 'ts-debounce';
19
+ import {
20
+ getTestId,
21
+ isNotEmpty,
22
+ isReactNodeNotEmpty,
23
+ isStringNotEmpty,
24
+ createFilter,
25
+ } from '@true-engineering/true-react-platform-helpers';
26
+ import { hasExactParent } from '../../helpers';
27
+ import { useIsMounted, useOnClickOutsideWithRef, useDropdown, useTweakStyles } from '../../hooks';
28
+ import { ICommonProps, IDropdownWithPopperOptions } from '../../types';
29
+ import { renderIcon, IIcon } from '../Icon';
30
+ import { IInputProps, Input } from '../Input';
31
+ import { ISearchInputProps, SearchInput } from '../SearchInput';
32
+ import { SelectList } from './components';
33
+ import { ALL_OPTION_INDEX, DEFAULT_OPTION_INDEX } from './constants';
34
+ import {
35
+ defaultConvertFunction,
36
+ defaultCompareFunction,
37
+ defaultIsOptionDisabled,
38
+ getDefaultConvertToIdFunction,
39
+ isMultiSelectValue,
40
+ } from './helpers';
41
+ import { IMultipleSelectValue } from './types';
42
+ import { useStyles, ISelectStyles, searchInputStyles, getInputStyles } from './Select.styles';
43
+
44
+ export interface ISelectProps<Value>
45
+ extends Omit<IInputProps, 'value' | 'onChange' | 'onBlur' | 'type' | 'tweakStyles'>,
46
+ ICommonProps<ISelectStyles> {
47
+ defaultOptionLabel?: ReactNode;
48
+ allOptionsLabel?: string;
49
+ noMatchesLabel?: string;
50
+ loadingLabel?: ReactNode;
51
+ /** @default 'normal' */
52
+ optionsMode?: 'search' | 'dynamic' | 'normal';
53
+ /** @default 400 */
54
+ debounceTime?: number;
55
+ /** @default 0 */
56
+ minSymbolsCountToOpenList?: number;
57
+ dropdownOptions?: IDropdownWithPopperOptions;
58
+ /** @default 'chevron-down' */
59
+ dropdownIcon?: IIcon;
60
+ options: Value[] | Readonly<Value[]>;
61
+ value: Value | undefined;
62
+ /** @default true */
63
+ shouldScrollToList?: boolean;
64
+ isMultiSelect?: boolean;
65
+ searchInput?: { shouldRenderInList: true } & Pick<ISearchInputProps, 'placeholder'>;
66
+ isOptionDisabled?: (option: Value) => boolean;
67
+ onChange: (
68
+ value: Value | undefined,
69
+ event:
70
+ | MouseEvent<HTMLElement>
71
+ | KeyboardEvent
72
+ | ChangeEvent<HTMLElement>
73
+ | FormEvent<HTMLElement>,
74
+ ) => void; // подумать как возвращать индекс
75
+ onBlur?: (event: Event | SyntheticEvent) => void;
76
+ onType?: (value: string) => Promise<void>;
77
+ optionsFilter?: (options: Value[], query: string) => Value[];
78
+ onOpen?: () => void;
79
+ compareValuesOnChange?: (v1?: Value, v2?: Value) => boolean;
80
+ // Для избежания проблем юзайте useCallback на эти функции
81
+ // или выносите их из компонента (чтобы не было сайдэфектов от перерендеринга их)
82
+ convertValueToString?: (value: Value) => string | undefined;
83
+ convertValueToReactNode?: (value: Value, isDisabled: boolean) => ReactNode;
84
+ convertValueToId?: (value: Value) => string | undefined;
85
+ }
86
+
87
+ export interface IMultipleSelectProps<Value>
88
+ extends Omit<ISelectProps<Value>, 'value' | 'onChange' | 'compareValuesOnChange'> {
89
+ isMultiSelect: true;
90
+ value: IMultipleSelectValue<Value> | undefined;
91
+ onChange: (
92
+ value: IMultipleSelectValue<Value> | undefined,
93
+ event:
94
+ | MouseEvent<HTMLElement>
95
+ | KeyboardEvent
96
+ | ChangeEvent<HTMLElement>
97
+ | FormEvent<HTMLElement>,
98
+ ) => void;
99
+ compareValuesOnChange?: (
100
+ v1?: IMultipleSelectValue<Value>,
101
+ v2?: IMultipleSelectValue<Value>,
102
+ ) => boolean;
103
+ }
104
+
105
+ export function Select<Value>(
106
+ props: ISelectProps<Value> | IMultipleSelectProps<Value>,
107
+ ): JSX.Element {
108
+ const {
109
+ options,
110
+ value,
111
+ defaultOptionLabel,
112
+ allOptionsLabel,
113
+ debounceTime = 400,
114
+ optionsMode = 'normal',
115
+ noMatchesLabel,
116
+ loadingLabel,
117
+ tweakStyles,
118
+ testId,
119
+ isReadonly,
120
+ isDisabled,
121
+ dropdownOptions,
122
+ minSymbolsCountToOpenList = 0,
123
+ dropdownIcon = 'chevron-down',
124
+ shouldScrollToList = true,
125
+ searchInput,
126
+ iconType,
127
+ onChange,
128
+ onFocus,
129
+ onBlur,
130
+ onType,
131
+ onOpen,
132
+ isOptionDisabled = defaultIsOptionDisabled,
133
+ compareValuesOnChange = defaultCompareFunction,
134
+ convertValueToString = defaultConvertFunction,
135
+ convertValueToId,
136
+ convertValueToReactNode,
137
+ optionsFilter,
138
+ ...inputProps
139
+ } = props;
140
+ const classes = useStyles({ theme: tweakStyles });
141
+
142
+ const { shouldRenderInList: shouldRenderSearchInputInList = false, ...searchInputProps } =
143
+ searchInput ?? {};
144
+ const hasSearchInputInList = optionsMode !== 'normal' && shouldRenderSearchInputInList;
145
+ const isMultiSelect = isMultiSelectValue(props, value);
146
+ const hasReadonlyInput = isReadonly || optionsMode === 'normal' || shouldRenderSearchInputInList;
147
+
148
+ const tweakInputStyles = useTweakStyles({
149
+ innerStyles: getInputStyles({ hasReadonlyInput, isMultiSelect }),
150
+ tweakStyles,
151
+ className: 'tweakInput',
152
+ currentComponentName: 'Select',
153
+ });
154
+
155
+ const tweakSearchInputStyles = useTweakStyles({
156
+ innerStyles: searchInputStyles,
157
+ tweakStyles,
158
+ className: 'tweakSearchInput',
159
+ currentComponentName: 'Select',
160
+ });
161
+
162
+ const tweakSelectListStyles = useTweakStyles({
163
+ tweakStyles,
164
+ className: 'tweakSelectList',
165
+ currentComponentName: 'Select',
166
+ });
167
+
168
+ const isMounted = useIsMounted();
169
+ const [isListOpen, setIsListOpen] = useState(false);
170
+ const [areOptionsLoading, setAreOptionsLoading] = useState(false);
171
+ const hasDefaultOption = isReactNodeNotEmpty(defaultOptionLabel);
172
+
173
+ const [focusedListCellIndex, setFocusedListCellIndex] = useState(DEFAULT_OPTION_INDEX);
174
+ const [searchValue, setSearchValue] = useState('');
175
+ // если мы ввели что то в строку поиска - то этот булеан будет отключаться
176
+ // вынесен отдельно, из-за проблем с дебаунсом при динамич. опциях
177
+ const [shouldShowDefaultOption, setShouldShowDefaultOption] = useState(true);
178
+
179
+ const inputWrapper = useRef<HTMLDivElement>(null);
180
+ const list = useRef<HTMLDivElement>(null);
181
+ const input = useRef<HTMLInputElement>(null); // TODO ref снаружи?
182
+
183
+ const strValue = isMultiSelect ? value?.[0] : value;
184
+ const shouldShowAllOption =
185
+ isMultiSelect && isStringNotEmpty(allOptionsLabel) && searchValue === '';
186
+
187
+ const filteredOptions = useMemo(() => {
188
+ if (optionsMode !== 'search') {
189
+ return options;
190
+ }
191
+
192
+ const filter =
193
+ optionsFilter ?? createFilter<Value>((option) => [convertValueToString(option) ?? '']);
194
+
195
+ return filter(options as Value[], searchValue);
196
+ }, [optionsFilter, options, convertValueToString, searchValue, optionsMode]);
197
+
198
+ const availableOptions = useMemo(
199
+ () => options.filter((o) => !isOptionDisabled(o)),
200
+ [options, isOptionDisabled],
201
+ );
202
+
203
+ const areAllOptionsSelected = isMultiSelect && value?.length === availableOptions.length;
204
+ const shouldShowMultiSelectCounter =
205
+ isMultiSelect && isNotEmpty(value) && value.length > 1 && !areAllOptionsSelected;
206
+
207
+ const optionsIndexesForNavigation = useMemo(() => {
208
+ const result: number[] = [];
209
+ if (shouldShowDefaultOption && hasDefaultOption) {
210
+ result.push(DEFAULT_OPTION_INDEX);
211
+ }
212
+ if (shouldShowAllOption) {
213
+ result.push(ALL_OPTION_INDEX);
214
+ }
215
+ return result.concat(
216
+ filteredOptions.reduce((acc, cur, i) => {
217
+ if (!isOptionDisabled(cur)) {
218
+ acc.push(i);
219
+ }
220
+ return acc;
221
+ }, [] as number[]),
222
+ );
223
+ }, [
224
+ filteredOptions,
225
+ hasDefaultOption,
226
+ isOptionDisabled,
227
+ shouldShowAllOption,
228
+ shouldShowDefaultOption,
229
+ ]);
230
+
231
+ const stringValue = isNotEmpty(strValue) ? convertValueToString(strValue) : undefined;
232
+ // Для мультиселекта пытаемся показать "Все опции" если выбраны все опции
233
+ const showedStringValue =
234
+ areAllOptionsSelected && isNotEmpty(allOptionsLabel) ? allOptionsLabel : stringValue;
235
+
236
+ const convertToId = useCallback(
237
+ (v: Value) => (convertValueToId ?? getDefaultConvertToIdFunction(convertValueToString))(v),
238
+ [convertValueToId, convertValueToString],
239
+ );
240
+
241
+ const handleListClose = useCallback(
242
+ (event: Event | SyntheticEvent) => {
243
+ setIsListOpen(false);
244
+ setSearchValue('');
245
+ setShouldShowDefaultOption(true);
246
+ onBlur?.(event);
247
+ },
248
+ [onBlur],
249
+ );
250
+
251
+ const handleListOpen = () => {
252
+ if (!isListOpen) {
253
+ setIsListOpen(true);
254
+ }
255
+ };
256
+
257
+ const handleFocus = (event: FocusEvent<HTMLInputElement>) => {
258
+ onFocus?.(event);
259
+ handleListOpen();
260
+ };
261
+
262
+ const handleOnClick = () => {
263
+ handleListOpen();
264
+ };
265
+
266
+ const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
267
+ // Когда что-то блокирует открытие листа, но блур все равно должен сработать
268
+ // например minSymbolsCount
269
+ if (isListOpen && !isOpen) {
270
+ handleListClose(event);
271
+ return;
272
+ }
273
+
274
+ if (
275
+ !isNotEmpty(event.relatedTarget) ||
276
+ !isNotEmpty(list.current) ||
277
+ !isNotEmpty(inputWrapper.current)
278
+ ) {
279
+ return;
280
+ }
281
+
282
+ const isActionInsideSelect =
283
+ hasExactParent(event.relatedTarget, list.current) ||
284
+ hasExactParent(event.relatedTarget, inputWrapper.current);
285
+
286
+ // Ниче не делаем если клик был внутри селекта
287
+ if (!isActionInsideSelect) {
288
+ handleListClose(event);
289
+ }
290
+ };
291
+
292
+ const handleOnChange = useCallback(
293
+ (
294
+ newValue: Value | IMultipleSelectValue<Value> | undefined,
295
+ event:
296
+ | MouseEvent<HTMLElement>
297
+ | KeyboardEvent
298
+ | ChangeEvent<HTMLElement>
299
+ | FormEvent<HTMLElement>,
300
+ ) => {
301
+ // Тут беда с типами, сорри
302
+ if (!compareValuesOnChange(value as never, newValue as never)) {
303
+ onChange(newValue as (Value & IMultipleSelectValue<Value>) | undefined, event);
304
+ }
305
+ },
306
+ [value, compareValuesOnChange, onChange],
307
+ );
308
+
309
+ const handleOptionSelect = useCallback(
310
+ (index: number, event: MouseEvent<HTMLElement> | KeyboardEvent) => {
311
+ handleOnChange(index === DEFAULT_OPTION_INDEX ? undefined : filteredOptions[index], event);
312
+ handleListClose(event);
313
+ input.current?.blur();
314
+ },
315
+ [handleOnChange, handleListClose, filteredOptions],
316
+ );
317
+
318
+ // MultiSelect
319
+ const handleToggleOptionCheckbox = useCallback(
320
+ (index: number, isSelected: boolean, event: ChangeEvent<HTMLElement> | KeyboardEvent) => {
321
+ if (!isMultiSelect) {
322
+ return;
323
+ }
324
+
325
+ // Если выбрана не дефолтная опция, которая сетит андеф
326
+ if (index === DEFAULT_OPTION_INDEX || (index === ALL_OPTION_INDEX && !isSelected)) {
327
+ handleOnChange(undefined, event);
328
+ return;
329
+ }
330
+ if (index === ALL_OPTION_INDEX && isSelected) {
331
+ handleOnChange(availableOptions as IMultipleSelectValue<Value>, event);
332
+ return;
333
+ }
334
+ const option = filteredOptions[index];
335
+ handleOnChange(
336
+ isSelected
337
+ ? // Добавляем
338
+ ([...(value ?? []), option] as IMultipleSelectValue<Value>)
339
+ : // Убираем
340
+ value?.filter((o) => convertToId(o) !== convertToId(option)),
341
+ event,
342
+ );
343
+ },
344
+ [isMultiSelect, filteredOptions, handleOnChange, value, availableOptions, convertToId],
345
+ );
346
+
347
+ const handleOnType = useCallback(
348
+ async (v: string) => {
349
+ if (onType === undefined) {
350
+ return;
351
+ }
352
+ if (isMounted()) {
353
+ setAreOptionsLoading(true);
354
+ }
355
+ await onType(v);
356
+ if (isMounted()) {
357
+ setAreOptionsLoading(false);
358
+ }
359
+ if (optionsMode === 'dynamic') {
360
+ setShouldShowDefaultOption(v === '');
361
+ }
362
+ },
363
+ [isMounted, onType, optionsMode],
364
+ );
365
+
366
+ const debounceHandleOnType = useMemo(
367
+ () => debounce(handleOnType, debounceTime),
368
+ [handleOnType, debounceTime],
369
+ );
370
+
371
+ const handleInputChange = (v: string, event: FormEvent<HTMLElement>) => {
372
+ if (onType !== undefined) {
373
+ debounceHandleOnType(v);
374
+ }
375
+
376
+ if (optionsMode !== 'dynamic') {
377
+ setShouldShowDefaultOption(v === '');
378
+ }
379
+
380
+ if (v === '' && !hasSearchInputInList) {
381
+ handleOnChange(undefined, event);
382
+ }
383
+
384
+ setSearchValue(v);
385
+ };
386
+
387
+ const handleKeyDown = (event: KeyboardEvent) => {
388
+ if (!isListOpen) {
389
+ return;
390
+ }
391
+
392
+ event.stopPropagation();
393
+ const curIndexInNavigation = optionsIndexesForNavigation.findIndex(
394
+ (index) => index === focusedListCellIndex,
395
+ );
396
+
397
+ switch (event.code) {
398
+ case 'Enter':
399
+ case 'NumpadEnter': {
400
+ let indexToSelect = focusedListCellIndex;
401
+
402
+ // если осталась одна опция в списке,
403
+ // то выбираем ее нажатием на enter
404
+ if (indexToSelect === DEFAULT_OPTION_INDEX && filteredOptions.length === 1) {
405
+ indexToSelect = 0;
406
+ }
407
+
408
+ if (isMultiSelect) {
409
+ let isThisValueAlreadySelected: boolean;
410
+ if (indexToSelect === ALL_OPTION_INDEX) {
411
+ isThisValueAlreadySelected = areAllOptionsSelected;
412
+ } else {
413
+ // подумать над концептом реального фокуса на опциях, а не вот эти вот focusedCell
414
+ const valueIdToSelect = convertToId(filteredOptions[indexToSelect]);
415
+ isThisValueAlreadySelected =
416
+ value?.some((opt) => convertToId(opt) === valueIdToSelect) ?? false;
417
+ }
418
+ handleToggleOptionCheckbox(indexToSelect, !isThisValueAlreadySelected, event);
419
+ } else {
420
+ handleOptionSelect(indexToSelect, event);
421
+ }
422
+ break;
423
+ }
424
+
425
+ case 'ArrowDown': {
426
+ // чтобы убрать перемещение курсора в инпуте
427
+ event.preventDefault();
428
+ const targetIndexInNavigation =
429
+ (curIndexInNavigation + 1) % optionsIndexesForNavigation.length;
430
+ setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation]);
431
+ break;
432
+ }
433
+
434
+ case 'ArrowUp': {
435
+ // чтобы убрать перемещение курсора в инпуте
436
+ event.preventDefault();
437
+ const targetIndexInNavigation =
438
+ (curIndexInNavigation - 1 + optionsIndexesForNavigation.length) %
439
+ optionsIndexesForNavigation.length;
440
+ setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation]);
441
+ break;
442
+ }
443
+ }
444
+ };
445
+
446
+ const onArrowClick = () => {
447
+ if (isListOpen) {
448
+ input.current?.blur();
449
+ } else {
450
+ input.current?.focus();
451
+ }
452
+ };
453
+
454
+ useOnClickOutsideWithRef(list, handleListClose, inputWrapper);
455
+
456
+ const hasEnoughSymbolsToSearch = searchValue.trim().length >= minSymbolsCountToOpenList;
457
+
458
+ const isOpen =
459
+ // Пользователь пытается открыть лист
460
+ isListOpen &&
461
+ // Нам есть что показать:
462
+ // Есть опции
463
+ (filteredOptions.length > 0 ||
464
+ // Дефолтная опция
465
+ (defaultOptionLabel !== undefined && !hasEnoughSymbolsToSearch) ||
466
+ // Текст "Загрузка..."
467
+ inputProps.isLoading ||
468
+ // Текст "Совпадений не найдено"
469
+ noMatchesLabel !== undefined ||
470
+ // У нас есть инпут с поиском внутри листа
471
+ hasSearchInputInList) &&
472
+ // Последняя проверка на случай, если мы че то ищем в опциях
473
+ (optionsMode === 'normal' || hasEnoughSymbolsToSearch);
474
+
475
+ // Эти значения ставятся в false по дефолту также в useDropdown
476
+ const {
477
+ shouldUsePopper = false,
478
+ shouldRenderInBody = false,
479
+ shouldHideOnScroll = false,
480
+ } = dropdownOptions ?? {};
481
+
482
+ const popperData = useDropdown({
483
+ isOpen,
484
+ onDropdownClose: handleListClose,
485
+ referenceElement: inputWrapper.current,
486
+ dropdownElement: list.current,
487
+ options: dropdownOptions,
488
+ dependenciesForPositionUpdating: [inputProps.isLoading, filteredOptions.length],
489
+ });
490
+
491
+ useEffect(() => {
492
+ setFocusedListCellIndex(
493
+ optionsIndexesForNavigation.find(
494
+ (index) =>
495
+ isNotEmpty(strValue) &&
496
+ isNotEmpty(filteredOptions[index]) &&
497
+ convertToId(filteredOptions[index]) === convertToId(strValue),
498
+ ) ?? optionsIndexesForNavigation[0],
499
+ );
500
+ }, [strValue, filteredOptions, optionsIndexesForNavigation, convertToId]);
501
+
502
+ useEffect(() => {
503
+ if (isOpen) {
504
+ onOpen?.();
505
+ }
506
+ }, [isOpen]);
507
+
508
+ const listEl = (
509
+ <div
510
+ className={clsx(classes.listWrapper, {
511
+ [classes.withoutPopper]: !shouldUsePopper,
512
+ [classes.listWrapperInBody]: shouldRenderInBody,
513
+ })}
514
+ ref={list}
515
+ style={popperData?.styles.popper as Styles}
516
+ onBlur={handleBlur} // обработка для Tab из списка
517
+ {...popperData?.attributes.popper}
518
+ >
519
+ {isOpen && (
520
+ <SelectList
521
+ options={filteredOptions}
522
+ defaultOptionLabel={hasDefaultOption && shouldShowDefaultOption && defaultOptionLabel}
523
+ allOptionsLabel={shouldShowAllOption && allOptionsLabel}
524
+ areAllOptionsSelected={areAllOptionsSelected}
525
+ customListHeader={
526
+ hasSearchInputInList && (
527
+ <SearchInput
528
+ value={searchValue}
529
+ onChange={handleInputChange}
530
+ tweakStyles={tweakSearchInputStyles}
531
+ placeholder="Поиск"
532
+ {...searchInputProps}
533
+ />
534
+ )
535
+ }
536
+ noMatchesLabel={noMatchesLabel}
537
+ focusedIndex={focusedListCellIndex}
538
+ activeValue={value}
539
+ isLoading={inputProps.isLoading}
540
+ loadingLabel={loadingLabel}
541
+ tweakStyles={tweakSelectListStyles}
542
+ testId={getTestId(testId, 'list')}
543
+ // скролл не работает с включеным поппером
544
+ shouldScrollToList={shouldScrollToList && !shouldUsePopper && !shouldHideOnScroll}
545
+ isOptionDisabled={isOptionDisabled}
546
+ convertValueToString={convertValueToString}
547
+ convertValueToReactNode={convertValueToReactNode}
548
+ convertValueToId={convertToId}
549
+ onOptionSelect={handleOptionSelect}
550
+ onToggleCheckbox={isMultiSelect ? handleToggleOptionCheckbox : undefined}
551
+ />
552
+ )}
553
+ </div>
554
+ );
555
+
556
+ const multiSelectCounterWithIcon =
557
+ shouldShowMultiSelectCounter || isNotEmpty(iconType) ? (
558
+ <>
559
+ {shouldShowMultiSelectCounter && (
560
+ <div className={classes.counter}>(+{value.length - 1})</div>
561
+ )}
562
+ {isNotEmpty(iconType) && <div className={classes.icon}>{renderIcon(iconType)}</div>}
563
+ </>
564
+ ) : undefined;
565
+
566
+ return (
567
+ <div className={classes.root} onKeyDown={handleKeyDown}>
568
+ <div
569
+ className={clsx(classes.inputWrapper, isDisabled && classes.disabled)}
570
+ onClick={isDisabled ? undefined : handleOnClick}
571
+ ref={inputWrapper}
572
+ >
573
+ <Input
574
+ value={
575
+ searchValue !== '' && !shouldRenderSearchInputInList ? searchValue : showedStringValue
576
+ }
577
+ onChange={handleInputChange}
578
+ isActive={isListOpen}
579
+ isReadonly={hasReadonlyInput}
580
+ onFocus={handleFocus}
581
+ onBlur={handleBlur}
582
+ isDisabled={isDisabled}
583
+ ref={input}
584
+ isLoading={areOptionsLoading}
585
+ tweakStyles={tweakInputStyles}
586
+ testId={testId}
587
+ iconType={isMultiSelect ? multiSelectCounterWithIcon : iconType}
588
+ {...inputProps}
589
+ />
590
+ <div
591
+ onMouseDown={(event: MouseEvent) => {
592
+ event.preventDefault();
593
+ }}
594
+ onClick={onArrowClick}
595
+ className={clsx(classes.arrow, isOpen && classes.activeArrow)}
596
+ >
597
+ {renderIcon(dropdownIcon)}
598
+ </div>
599
+ </div>
600
+ {shouldUsePopper ? (
601
+ <Portal container={shouldRenderInBody ? document.body : inputWrapper.current}>
602
+ <>{listEl}</>
603
+ </Portal>
604
+ ) : (
605
+ <>{isOpen && listEl}</>
606
+ )}
607
+ </div>
608
+ );
609
+ }