@true-engineering/true-react-common-ui-kit 3.50.0 → 3.51.0

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