@alfalab/core-components-select 17.8.2 → 17.8.4

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 (257) hide show
  1. package/components/arrow/Component.js +1 -1
  2. package/components/arrow/index.css +6 -4
  3. package/components/base-checkmark/Component.js +1 -1
  4. package/components/base-checkmark/index.css +9 -7
  5. package/components/base-option/Component.js +1 -1
  6. package/components/base-option/index.css +21 -19
  7. package/components/base-select/Component.d.ts +8 -14
  8. package/components/base-select/Component.js +48 -75
  9. package/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
  10. package/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +19 -0
  11. package/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
  12. package/components/base-select/components/list-desktop/list-popover-desktop.js +12 -0
  13. package/components/base-select/components/list-desktop/types/types.d.ts +3 -0
  14. package/components/base-select/components/list-desktop/types/types.js +2 -0
  15. package/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
  16. package/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +23 -0
  17. package/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
  18. package/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +22 -0
  19. package/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
  20. package/components/base-select/components/list-mobile/helpers/index.js +11 -0
  21. package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
  22. package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +28 -0
  23. package/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
  24. package/components/base-select/components/list-mobile/list-mobile.js +26 -0
  25. package/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
  26. package/components/base-select/components/list-mobile/list-modal-mobile.js +42 -0
  27. package/components/base-select/components/list-mobile/types/types.d.ts +4 -0
  28. package/components/base-select/components/list-mobile/types/types.js +2 -0
  29. package/components/base-select/index.css +16 -14
  30. package/components/base-select/mobile.css +19 -17
  31. package/components/base-select/types/component-types.d.ts +50 -0
  32. package/components/base-select/types/component-types.js +2 -0
  33. package/components/checkmark/Component.js +1 -1
  34. package/components/checkmark/index.css +15 -13
  35. package/components/checkmark-mobile/Component.js +1 -1
  36. package/components/checkmark-mobile/index.css +9 -7
  37. package/components/field/Component.js +1 -1
  38. package/components/field/index.css +15 -13
  39. package/components/footer/Component.js +1 -1
  40. package/components/footer/index.css +9 -7
  41. package/components/optgroup/Component.js +1 -1
  42. package/components/optgroup/index.css +12 -10
  43. package/components/option/Component.js +1 -1
  44. package/components/option/index.css +24 -22
  45. package/components/options-list/Component.js +1 -1
  46. package/components/options-list/index.css +16 -14
  47. package/components/search/Component.js +1 -1
  48. package/components/search/index.css +5 -3
  49. package/components/virtual-options-list/Component.js +1 -1
  50. package/components/virtual-options-list/index.css +21 -19
  51. package/cssm/components/arrow/index.module.css +3 -1
  52. package/cssm/components/base-checkmark/index.module.css +3 -1
  53. package/cssm/components/base-option/index.module.css +6 -4
  54. package/cssm/components/base-select/Component.d.ts +8 -14
  55. package/cssm/components/base-select/Component.js +38 -60
  56. package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
  57. package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +19 -0
  58. package/cssm/components/base-select/components/list-desktop/list-popover-desktop.d.ts +9 -0
  59. package/cssm/components/base-select/components/list-desktop/list-popover-desktop.js +24 -0
  60. package/cssm/components/base-select/components/list-desktop/types/types.d.ts +3 -0
  61. package/cssm/components/base-select/components/list-desktop/types/types.js +2 -0
  62. package/cssm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
  63. package/cssm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +23 -0
  64. package/cssm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
  65. package/cssm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +22 -0
  66. package/cssm/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
  67. package/cssm/components/base-select/components/list-mobile/helpers/index.js +11 -0
  68. package/cssm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
  69. package/cssm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +29 -0
  70. package/cssm/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
  71. package/cssm/components/base-select/components/list-mobile/list-mobile.js +26 -0
  72. package/cssm/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
  73. package/cssm/components/base-select/components/list-mobile/list-modal-mobile.js +43 -0
  74. package/cssm/components/base-select/components/list-mobile/types/types.d.ts +4 -0
  75. package/cssm/components/base-select/components/list-mobile/types/types.js +2 -0
  76. package/cssm/components/base-select/index.module.css +5 -3
  77. package/cssm/components/base-select/mobile.module.css +7 -5
  78. package/cssm/components/base-select/types/component-types.d.ts +50 -0
  79. package/cssm/components/base-select/types/component-types.js +2 -0
  80. package/cssm/components/checkmark/index.module.css +5 -3
  81. package/cssm/components/checkmark-mobile/index.module.css +3 -1
  82. package/cssm/components/field/index.module.css +3 -1
  83. package/cssm/components/footer/index.module.css +4 -2
  84. package/cssm/components/optgroup/index.module.css +6 -4
  85. package/cssm/components/option/index.module.css +5 -3
  86. package/cssm/components/options-list/index.module.css +6 -4
  87. package/cssm/components/search/index.module.css +3 -1
  88. package/cssm/components/virtual-options-list/index.module.css +6 -4
  89. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +5 -3
  90. package/cssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +5 -3
  91. package/esm/components/arrow/Component.js +1 -1
  92. package/esm/components/arrow/index.css +6 -4
  93. package/esm/components/base-checkmark/Component.js +1 -1
  94. package/esm/components/base-checkmark/index.css +9 -7
  95. package/esm/components/base-option/Component.js +1 -1
  96. package/esm/components/base-option/index.css +21 -19
  97. package/esm/components/base-select/Component.d.ts +8 -14
  98. package/esm/components/base-select/Component.js +39 -66
  99. package/esm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
  100. package/esm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +15 -0
  101. package/esm/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
  102. package/esm/components/base-select/components/list-desktop/list-popover-desktop.js +4 -0
  103. package/esm/components/base-select/components/list-desktop/types/types.d.ts +3 -0
  104. package/esm/components/base-select/components/list-desktop/types/types.js +1 -0
  105. package/esm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
  106. package/esm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +19 -0
  107. package/esm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
  108. package/esm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +18 -0
  109. package/esm/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
  110. package/esm/components/base-select/components/list-mobile/helpers/index.js +2 -0
  111. package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
  112. package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +20 -0
  113. package/esm/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
  114. package/esm/components/base-select/components/list-mobile/list-mobile.js +18 -0
  115. package/esm/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
  116. package/esm/components/base-select/components/list-mobile/list-modal-mobile.js +32 -0
  117. package/esm/components/base-select/components/list-mobile/types/types.d.ts +4 -0
  118. package/esm/components/base-select/components/list-mobile/types/types.js +1 -0
  119. package/esm/components/base-select/index.css +16 -14
  120. package/esm/components/base-select/mobile.css +19 -17
  121. package/esm/components/base-select/types/component-types.d.ts +50 -0
  122. package/esm/components/base-select/types/component-types.js +1 -0
  123. package/esm/components/checkmark/Component.js +1 -1
  124. package/esm/components/checkmark/index.css +15 -13
  125. package/esm/components/checkmark-mobile/Component.js +1 -1
  126. package/esm/components/checkmark-mobile/index.css +9 -7
  127. package/esm/components/field/Component.js +1 -1
  128. package/esm/components/field/index.css +15 -13
  129. package/esm/components/footer/Component.js +1 -1
  130. package/esm/components/footer/index.css +9 -7
  131. package/esm/components/optgroup/Component.js +1 -1
  132. package/esm/components/optgroup/index.css +12 -10
  133. package/esm/components/option/Component.js +1 -1
  134. package/esm/components/option/index.css +24 -22
  135. package/esm/components/options-list/Component.js +1 -1
  136. package/esm/components/options-list/index.css +16 -14
  137. package/esm/components/search/Component.js +1 -1
  138. package/esm/components/search/index.css +5 -3
  139. package/esm/components/virtual-options-list/Component.js +1 -1
  140. package/esm/components/virtual-options-list/index.css +21 -19
  141. package/esm/list-popover-desktop-f713543b.d.ts +9 -0
  142. package/esm/list-popover-desktop-f713543b.js +16 -0
  143. package/esm/mobile/Component.mobile.js +1 -1
  144. package/esm/mobile.module-98003396.js +4 -0
  145. package/esm/presets/index.js +1 -1
  146. package/esm/presets/useSelectWithApply/hook.js +1 -1
  147. package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  148. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  149. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
  150. package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  151. package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
  152. package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  153. package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  154. package/esm/presets/useSelectWithLoading/hook.js +1 -1
  155. package/esm/presets/useSelectWithLoading/index.css +2 -2
  156. package/esm/shared/index.js +1 -1
  157. package/list-popover-desktop-11171d84.d.ts +9 -0
  158. package/list-popover-desktop-11171d84.js +24 -0
  159. package/mobile/Component.mobile.js +1 -1
  160. package/mobile.module-8f94cd8b.js +6 -0
  161. package/modern/components/arrow/Component.js +1 -1
  162. package/modern/components/arrow/index.css +6 -4
  163. package/modern/components/base-checkmark/Component.js +1 -1
  164. package/modern/components/base-checkmark/index.css +9 -7
  165. package/modern/components/base-option/Component.js +1 -1
  166. package/modern/components/base-option/index.css +21 -19
  167. package/modern/components/base-select/Component.d.ts +8 -14
  168. package/modern/components/base-select/Component.js +23 -56
  169. package/modern/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
  170. package/modern/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +15 -0
  171. package/modern/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
  172. package/modern/components/base-select/components/list-desktop/list-popover-desktop.js +3 -0
  173. package/modern/components/base-select/components/list-desktop/types/types.d.ts +3 -0
  174. package/modern/components/base-select/components/list-desktop/types/types.js +1 -0
  175. package/modern/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
  176. package/modern/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +19 -0
  177. package/modern/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
  178. package/modern/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +18 -0
  179. package/modern/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
  180. package/modern/components/base-select/components/list-mobile/helpers/index.js +2 -0
  181. package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
  182. package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +24 -0
  183. package/modern/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
  184. package/modern/components/base-select/components/list-mobile/list-mobile.js +17 -0
  185. package/modern/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
  186. package/modern/components/base-select/components/list-mobile/list-modal-mobile.js +32 -0
  187. package/modern/components/base-select/components/list-mobile/types/types.d.ts +4 -0
  188. package/modern/components/base-select/components/list-mobile/types/types.js +1 -0
  189. package/modern/components/base-select/index.css +16 -14
  190. package/modern/components/base-select/mobile.css +19 -17
  191. package/modern/components/base-select/types/component-types.d.ts +50 -0
  192. package/modern/components/base-select/types/component-types.js +1 -0
  193. package/modern/components/checkmark/Component.js +1 -1
  194. package/modern/components/checkmark/index.css +15 -13
  195. package/modern/components/checkmark-mobile/Component.js +1 -1
  196. package/modern/components/checkmark-mobile/index.css +9 -7
  197. package/modern/components/field/Component.js +1 -1
  198. package/modern/components/field/index.css +15 -13
  199. package/modern/components/footer/Component.js +1 -1
  200. package/modern/components/footer/index.css +9 -7
  201. package/modern/components/optgroup/Component.js +1 -1
  202. package/modern/components/optgroup/index.css +12 -10
  203. package/modern/components/option/Component.js +1 -1
  204. package/modern/components/option/index.css +24 -22
  205. package/modern/components/options-list/Component.js +1 -1
  206. package/modern/components/options-list/index.css +16 -14
  207. package/modern/components/search/Component.js +1 -1
  208. package/modern/components/search/index.css +5 -3
  209. package/modern/components/virtual-options-list/Component.js +1 -1
  210. package/modern/components/virtual-options-list/index.css +21 -19
  211. package/modern/list-popover-desktop-1f55335b.d.ts +9 -0
  212. package/modern/list-popover-desktop-1f55335b.js +15 -0
  213. package/modern/mobile/Component.mobile.js +1 -1
  214. package/modern/mobile.module-815026ad.js +4 -0
  215. package/modern/presets/index.js +1 -1
  216. package/modern/presets/useSelectWithApply/hook.js +1 -1
  217. package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  218. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  219. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
  220. package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  221. package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
  222. package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  223. package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  224. package/modern/presets/useSelectWithLoading/hook.js +1 -1
  225. package/modern/presets/useSelectWithLoading/index.css +2 -2
  226. package/modern/shared/index.js +1 -1
  227. package/package.json +8 -6
  228. package/presets/index.js +1 -1
  229. package/presets/useSelectWithApply/hook.js +1 -1
  230. package/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  231. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  232. package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
  233. package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  234. package/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
  235. package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  236. package/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  237. package/presets/useSelectWithLoading/hook.js +1 -1
  238. package/presets/useSelectWithLoading/index.css +2 -2
  239. package/shared/index.js +1 -1
  240. package/src/components/base-select/Component.tsx +49 -185
  241. package/src/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.tsx +24 -0
  242. package/src/components/base-select/components/list-desktop/list-popover-desktop.tsx +47 -0
  243. package/src/components/base-select/components/list-desktop/types/types.ts +3 -0
  244. package/src/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.tsx +32 -0
  245. package/src/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.tsx +30 -0
  246. package/src/components/base-select/components/list-mobile/helpers/index.ts +2 -0
  247. package/src/components/base-select/components/list-mobile/list-bottom-sheet-mobile.tsx +84 -0
  248. package/src/components/base-select/components/list-mobile/list-mobile.tsx +39 -0
  249. package/src/components/base-select/components/list-mobile/list-modal-mobile.tsx +94 -0
  250. package/src/components/base-select/components/list-mobile/types/types.ts +4 -0
  251. package/src/components/base-select/types/component-types.ts +39 -0
  252. /package/esm/{hook-86063cab.d.ts → hook-9d222e75.d.ts} +0 -0
  253. /package/esm/{hook-86063cab.js → hook-9d222e75.js} +0 -0
  254. /package/{hook-777449d0.d.ts → hook-01942cdc.d.ts} +0 -0
  255. /package/{hook-777449d0.js → hook-01942cdc.js} +0 -0
  256. /package/modern/{hook-1c546c40.d.ts → hook-ea5654cb.d.ts} +0 -0
  257. /package/modern/{hook-1c546c40.js → hook-ea5654cb.js} +0 -0
@@ -1,9 +1,7 @@
1
1
  /* eslint-disable no-nested-ternary */
2
2
  import React, {
3
- FC,
4
3
  FocusEvent,
5
4
  forwardRef,
6
- ForwardRefExoticComponent,
7
5
  KeyboardEvent,
8
6
  MouseEvent,
9
7
  RefAttributes,
@@ -23,27 +21,10 @@ import {
23
21
  UseMultipleSelectionState,
24
22
  } from 'downshift';
25
23
 
26
- import type { BottomSheetProps } from '@alfalab/core-components-bottom-sheet';
27
- import type { ModalMobileProps } from '@alfalab/core-components-modal/mobile';
28
- import type {
29
- ModalContentProps,
30
- ModalFooterProps,
31
- ModalHeaderProps,
32
- } from '@alfalab/core-components-modal/shared';
33
- import type { PopoverProps } from '@alfalab/core-components-popover';
34
24
  import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
35
25
  import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
36
26
 
37
- import type {
38
- AdditionalMobileProps,
39
- AnyObject,
40
- BaseSelectProps,
41
- BottomSheetSelectMobileProps,
42
- ModalSelectMobileProps,
43
- OptionShape,
44
- OptionsListProps,
45
- SearchProps,
46
- } from '../../typings';
27
+ import type { AnyObject, OptionShape, OptionsListProps, SearchProps } from '../../typings';
47
28
  import {
48
29
  defaultAccessor,
49
30
  defaultFilterFn,
@@ -53,44 +34,33 @@ import {
53
34
  } from '../../utils';
54
35
  import { NativeSelect } from '../native-select';
55
36
 
37
+ import { getListPopoverDesktopProps } from './components/list-desktop/helpers/get-list-popover-desktop-props';
38
+ import { ListPopoverDesktop } from './components/list-desktop/list-popover-desktop';
39
+ import {
40
+ getListBottomSheetMobileProps,
41
+ getListModalMobileProps,
42
+ } from './components/list-mobile/helpers';
43
+ import { ListMobile } from './components/list-mobile/list-mobile';
44
+ import { ComponentProps } from './types/component-types';
45
+
56
46
  import styles from './index.module.css';
57
47
  import mobileStyles from './mobile.module.css';
58
48
 
59
- type ComponentProps = BaseSelectProps &
60
- AdditionalMobileProps &
61
- BottomSheetSelectMobileProps &
62
- ModalSelectMobileProps & {
63
- isBottomSheet?: boolean;
64
- view: 'desktop' | 'mobile';
65
- Popover?: ForwardRefExoticComponent<PopoverProps & RefAttributes<HTMLDivElement>>;
66
- BottomSheet?: React.ForwardRefExoticComponent<
67
- BottomSheetProps & React.RefAttributes<HTMLDivElement>
68
- >;
69
- ModalMobile?: ForwardRefExoticComponent<
70
- ModalMobileProps & RefAttributes<HTMLDivElement>
71
- > & {
72
- Header: FC<ModalHeaderProps>;
73
- Footer: FC<ModalFooterProps>;
74
- Content: FC<ModalContentProps>;
75
- };
76
- };
77
-
78
49
  const itemToString = (option: OptionShape | null) => (option ? option.key : '');
79
50
 
80
51
  const isItemDisabled = (option: OptionShape | null) => Boolean(option?.disabled);
81
52
 
82
- export const BaseSelect = forwardRef(
53
+ export const BaseSelect = forwardRef<unknown, ComponentProps>(
83
54
  // TODO: 😭
84
55
  // eslint-disable-next-line complexity
85
- (
86
- {
56
+ (props, ref) => {
57
+ const {
87
58
  dataTestId,
88
59
  className,
89
60
  fieldClassName,
90
61
  optionGroupClassName,
91
62
  optionsListClassName,
92
63
  optionClassName,
93
- popperClassName,
94
64
  options,
95
65
  autocomplete = false,
96
66
  multiple = false,
@@ -101,8 +71,6 @@ export const BaseSelect = forwardRef(
101
71
  nativeSelect = false,
102
72
  defaultOpen = false,
103
73
  open: openProp,
104
- popoverPosition = 'bottom-start',
105
- preventFlip = true,
106
74
  optionsListWidth = 'content',
107
75
  name,
108
76
  id,
@@ -132,26 +100,15 @@ export const BaseSelect = forwardRef(
132
100
  Optgroup = () => null,
133
101
  Option = () => null,
134
102
  Search = () => null,
135
- updatePopover,
136
- zIndexPopover,
137
103
  showEmptyOptionsList = false,
138
104
  visibleOptions,
139
105
  view,
140
106
  isBottomSheet = true,
141
- footer,
142
- swipeable,
143
107
  modalProps,
144
- popoverProps,
145
- modalFooterProps,
146
- modalHeaderProps,
147
108
  bottomSheetProps,
148
- Popover,
149
- ModalMobile,
150
- BottomSheet,
151
109
  limitDynamicOptionGroupSize,
152
- }: ComponentProps,
153
- ref,
154
- ) => {
110
+ } = props;
111
+ const shouldSearchBlurRef = useRef(true);
155
112
  const rootRef = useRef<HTMLDivElement>(null);
156
113
  const fieldRef = useRef<HTMLInputElement>(null);
157
114
  const listRef = useRef<HTMLDivElement>(null);
@@ -479,6 +436,13 @@ export const BaseSelect = forwardRef(
479
436
  index,
480
437
  item: option,
481
438
  onMouseDown: (event: MouseEvent) => event.preventDefault(),
439
+ onClick: () => {
440
+ if (view === 'mobile' || !showSearch || multiple) return;
441
+ shouldSearchBlurRef.current = false;
442
+ searchRef.current?.blur();
443
+ shouldSearchBlurRef.current = true;
444
+ fieldRef.current?.focus();
445
+ },
482
446
  }),
483
447
  multiple,
484
448
  index,
@@ -576,6 +540,7 @@ export const BaseSelect = forwardRef(
576
540
  };
577
541
 
578
542
  const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
543
+ if (!shouldSearchBlurRef.current) return;
579
544
  searchProps.componentProps?.onBlur?.(event);
580
545
  handleFieldBlur(event);
581
546
  };
@@ -674,130 +639,6 @@ export const BaseSelect = forwardRef(
674
639
  );
675
640
  };
676
641
 
677
- const renderInPopover = () => {
678
- if (!nativeSelect && Popover) {
679
- return (
680
- <Popover
681
- {...popoverProps}
682
- open={open}
683
- withTransition={false}
684
- anchorElement={fieldRef.current as HTMLElement}
685
- position={popoverPosition}
686
- preventFlip={preventFlip}
687
- popperClassName={cn(styles.popoverInner, popperClassName)}
688
- update={updatePopover}
689
- zIndex={zIndexPopover}
690
- >
691
- {renderOptionsList()}
692
- </Popover>
693
- );
694
- }
695
-
696
- return null;
697
- };
698
-
699
- const renderInBottomSheet = () => {
700
- if (!nativeSelect && BottomSheet) {
701
- return (
702
- <BottomSheet
703
- dataTestId={getDataTestId(dataTestId, 'bottom-sheet')}
704
- open={open}
705
- className={mobileStyles.sheet}
706
- contentClassName={mobileStyles.sheetContent}
707
- containerClassName={mobileStyles.sheetContainer}
708
- title={label || placeholder}
709
- actionButton={footer}
710
- stickyHeader={true}
711
- hasCloser={true}
712
- swipeable={swipeable}
713
- initialHeight={showSearch ? 'full' : 'default'}
714
- {...bottomSheetProps}
715
- sheetContainerRef={menuRef}
716
- scrollableContainerRef={scrollableContainerRef}
717
- onClose={() => {
718
- closeMenu();
719
- bottomSheetProps?.onClose?.();
720
- }}
721
- transitionProps={{
722
- ...bottomSheetProps?.transitionProps,
723
- onEntered: handleEntered,
724
- }}
725
- bottomAddons={
726
- <React.Fragment>
727
- {renderSearch()}
728
- {flatOptions.length > 0 && bottomSheetProps?.bottomAddons}
729
- </React.Fragment>
730
- }
731
- containerProps={{
732
- ...bottomSheetProps?.containerProps,
733
- onScroll,
734
- }}
735
- >
736
- {renderOptionsList()}
737
- </BottomSheet>
738
- );
739
- }
740
-
741
- return null;
742
- };
743
-
744
- const renderInModalMobile = () => {
745
- if (!nativeSelect && ModalMobile) {
746
- return (
747
- <ModalMobile
748
- dataTestId={getDataTestId(dataTestId, 'modal')}
749
- open={open}
750
- hasCloser={true}
751
- {...modalProps}
752
- componentRef={menuRef}
753
- onClose={(...args) => {
754
- closeMenu();
755
- modalProps?.onClose?.(...args);
756
- }}
757
- contentClassName={cn(
758
- mobileStyles.sheetContent,
759
- modalProps?.contentClassName,
760
- )}
761
- ref={mergeRefs([
762
- scrollableContainerRef,
763
- modalProps?.ref as React.Ref<HTMLDivElement>,
764
- ])}
765
- wrapperProps={{
766
- ...modalProps?.wrapperProps,
767
- onScroll,
768
- }}
769
- transitionProps={{
770
- ...modalProps?.transitionProps,
771
- onEntered: handleEntered,
772
- }}
773
- >
774
- <ModalMobile.Header
775
- hasCloser={true}
776
- sticky={true}
777
- {...modalHeaderProps}
778
- title={undefined}
779
- bottomAddons={
780
- <React.Fragment>
781
- {renderSearch()}
782
- {flatOptions.length > 0 && modalHeaderProps?.bottomAddons}
783
- </React.Fragment>
784
- }
785
- >
786
- {modalHeaderProps?.title || label || placeholder}
787
- </ModalMobile.Header>
788
-
789
- <ModalMobile.Content flex={true} className={mobileStyles.modalContent}>
790
- {renderOptionsList()}
791
- </ModalMobile.Content>
792
-
793
- {modalFooterProps?.children && <ModalMobile.Footer {...modalFooterProps} />}
794
- </ModalMobile>
795
- );
796
- }
797
-
798
- return null;
799
- };
800
-
801
642
  return (
802
643
  <div
803
644
  {...(disabled && { 'aria-disabled': true })}
@@ -848,9 +689,32 @@ export const BaseSelect = forwardRef(
848
689
 
849
690
  {name && !nativeSelect && renderValue()}
850
691
 
851
- {view === 'desktop' && renderInPopover()}
852
- {view === 'mobile' && isBottomSheet && renderInBottomSheet()}
853
- {view === 'mobile' && !isBottomSheet && renderInModalMobile()}
692
+ {view === 'desktop' && !nativeSelect && (
693
+ <ListPopoverDesktop
694
+ {...getListPopoverDesktopProps(props)}
695
+ open={open}
696
+ fieldRef={fieldRef}
697
+ renderOptionsList={renderOptionsList}
698
+ />
699
+ )}
700
+
701
+ {view === 'mobile' && (
702
+ <ListMobile
703
+ baseProps={
704
+ isBottomSheet
705
+ ? getListBottomSheetMobileProps(props)
706
+ : getListModalMobileProps(props)
707
+ }
708
+ open={open}
709
+ menuRef={menuRef}
710
+ scrollableContainerRef={scrollableContainerRef}
711
+ flatOptions={flatOptions}
712
+ renderOptionsList={renderOptionsList}
713
+ renderSearch={renderSearch}
714
+ closeMenu={closeMenu}
715
+ handleEntered={handleEntered}
716
+ />
717
+ )}
854
718
  </div>
855
719
  );
856
720
  },
@@ -0,0 +1,24 @@
1
+ import { ComponentProps } from '../../../types/component-types';
2
+
3
+ // отделяем необходимые пропсы для передачи в компонент
4
+ export const getListPopoverDesktopProps = (props: ComponentProps) => {
5
+ const {
6
+ Popover,
7
+ popoverProps,
8
+ popoverPosition = 'bottom-start',
9
+ preventFlip = true,
10
+ popperClassName,
11
+ updatePopover,
12
+ zIndexPopover,
13
+ } = props;
14
+
15
+ return {
16
+ Popover,
17
+ popoverProps,
18
+ popoverPosition,
19
+ preventFlip,
20
+ popperClassName,
21
+ updatePopover,
22
+ zIndexPopover,
23
+ };
24
+ };
@@ -0,0 +1,47 @@
1
+ import React, { FC, ReactNode, RefObject } from 'react';
2
+ import cn from 'classnames';
3
+
4
+ import { ListPopoverDesktopRestProps } from './types/types';
5
+
6
+ import styles from '../../index.module.css';
7
+
8
+ type ListPopoverDesktopProps = {
9
+ open: boolean;
10
+ fieldRef: RefObject<HTMLInputElement>;
11
+ renderOptionsList: () => ReactNode;
12
+ } & ListPopoverDesktopRestProps;
13
+
14
+ export const ListPopoverDesktop: FC<ListPopoverDesktopProps> = (props) => {
15
+ const {
16
+ Popover,
17
+ open,
18
+ popoverProps,
19
+ fieldRef,
20
+ popoverPosition = 'bottom-start',
21
+ preventFlip = true,
22
+ popperClassName,
23
+ updatePopover,
24
+ zIndexPopover,
25
+ renderOptionsList,
26
+ } = props;
27
+
28
+ if (Popover) {
29
+ return (
30
+ <Popover
31
+ {...popoverProps}
32
+ open={open}
33
+ withTransition={false}
34
+ anchorElement={fieldRef.current as HTMLElement}
35
+ position={popoverPosition}
36
+ preventFlip={preventFlip}
37
+ popperClassName={cn(styles.popoverInner, popperClassName)}
38
+ update={updatePopover}
39
+ zIndex={zIndexPopover}
40
+ >
41
+ {renderOptionsList()}
42
+ </Popover>
43
+ );
44
+ }
45
+
46
+ return null;
47
+ };
@@ -0,0 +1,3 @@
1
+ import { getListPopoverDesktopProps } from '../helpers/get-list-popover-desktop-props';
2
+
3
+ export type ListPopoverDesktopRestProps = ReturnType<typeof getListPopoverDesktopProps>;
@@ -0,0 +1,32 @@
1
+ import { ComponentProps } from '../../../types/component-types';
2
+
3
+ // отделяем необходимые пропсы для передачи в компонент
4
+ export const getListBottomSheetMobileProps = (props: ComponentProps) => {
5
+ const {
6
+ BottomSheet,
7
+ dataTestId,
8
+ label,
9
+ placeholder,
10
+ footer,
11
+ swipeable,
12
+ showSearch,
13
+ bottomSheetProps,
14
+ isBottomSheet = true,
15
+ nativeSelect = false,
16
+ onScroll,
17
+ } = props;
18
+
19
+ return {
20
+ BottomSheet,
21
+ dataTestId,
22
+ label,
23
+ placeholder,
24
+ footer,
25
+ swipeable,
26
+ showSearch,
27
+ bottomSheetProps,
28
+ isBottomSheet,
29
+ nativeSelect,
30
+ onScroll,
31
+ };
32
+ };
@@ -0,0 +1,30 @@
1
+ import { ComponentProps } from '../../../types/component-types';
2
+
3
+ // отделяем необходимые пропсы для передачи в компонент
4
+ export const getListModalMobileProps = (props: ComponentProps) => {
5
+ const {
6
+ ModalMobile,
7
+ dataTestId,
8
+ modalProps,
9
+ modalHeaderProps,
10
+ modalFooterProps,
11
+ label,
12
+ placeholder,
13
+ isBottomSheet = true,
14
+ nativeSelect = false,
15
+ onScroll,
16
+ } = props;
17
+
18
+ return {
19
+ ModalMobile,
20
+ dataTestId,
21
+ modalProps,
22
+ modalHeaderProps,
23
+ modalFooterProps,
24
+ label,
25
+ placeholder,
26
+ isBottomSheet,
27
+ nativeSelect,
28
+ onScroll,
29
+ };
30
+ };
@@ -0,0 +1,2 @@
1
+ export { getListModalMobileProps } from './get-list-modal-mobile-props';
2
+ export { getListBottomSheetMobileProps } from './get-list-bottom-sheet-mobile-props';
@@ -0,0 +1,84 @@
1
+ import React, { FC, ReactNode, RefObject } from 'react';
2
+
3
+ import { OptionShape } from '@alfalab/core-components-select/typings';
4
+ import { getDataTestId } from '@alfalab/core-components-shared';
5
+
6
+ import { ListBottomSheetMobileRestProps } from './types/types';
7
+
8
+ import mobileStyles from '../../mobile.module.css';
9
+
10
+ type ListMobileProps = {
11
+ open: boolean;
12
+ menuRef: RefObject<HTMLDivElement>;
13
+ scrollableContainerRef: RefObject<HTMLDivElement>;
14
+ flatOptions: OptionShape[];
15
+ closeMenu: () => void;
16
+ handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
17
+ renderSearch: () => ReactNode;
18
+ renderOptionsList: () => ReactNode;
19
+ } & ListBottomSheetMobileRestProps;
20
+
21
+ export const ListBottomSheetMobile: FC<ListMobileProps> = (props) => {
22
+ const {
23
+ BottomSheet,
24
+ dataTestId,
25
+ open,
26
+ label,
27
+ placeholder,
28
+ footer,
29
+ swipeable,
30
+ showSearch,
31
+ bottomSheetProps,
32
+ menuRef,
33
+ scrollableContainerRef,
34
+ onScroll,
35
+ flatOptions,
36
+ closeMenu,
37
+ handleEntered,
38
+ renderSearch,
39
+ renderOptionsList,
40
+ } = props;
41
+
42
+ if (BottomSheet) {
43
+ return (
44
+ <BottomSheet
45
+ dataTestId={getDataTestId(dataTestId, 'bottom-sheet')}
46
+ open={open}
47
+ className={mobileStyles.sheet}
48
+ contentClassName={mobileStyles.sheetContent}
49
+ containerClassName={mobileStyles.sheetContainer}
50
+ title={label || placeholder}
51
+ actionButton={footer}
52
+ stickyHeader={true}
53
+ hasCloser={true}
54
+ swipeable={swipeable}
55
+ initialHeight={showSearch ? 'full' : 'default'}
56
+ {...bottomSheetProps}
57
+ sheetContainerRef={menuRef}
58
+ scrollableContainerRef={scrollableContainerRef}
59
+ onClose={() => {
60
+ closeMenu();
61
+ bottomSheetProps?.onClose?.();
62
+ }}
63
+ transitionProps={{
64
+ ...bottomSheetProps?.transitionProps,
65
+ onEntered: handleEntered,
66
+ }}
67
+ bottomAddons={
68
+ <React.Fragment>
69
+ {renderSearch()}
70
+ {flatOptions.length > 0 && bottomSheetProps?.bottomAddons}
71
+ </React.Fragment>
72
+ }
73
+ containerProps={{
74
+ ...bottomSheetProps?.containerProps,
75
+ onScroll,
76
+ }}
77
+ >
78
+ {renderOptionsList()}
79
+ </BottomSheet>
80
+ );
81
+ }
82
+
83
+ return null;
84
+ };
@@ -0,0 +1,39 @@
1
+ import React, { FC, ReactNode, RefObject } from 'react';
2
+
3
+ import { OptionShape } from '@alfalab/core-components-select/typings';
4
+
5
+ import { ListBottomSheetMobileRestProps, ListModalMobileRestProps } from './types/types';
6
+ import { ListBottomSheetMobile } from './list-bottom-sheet-mobile';
7
+ import { ListModalMobile } from './list-modal-mobile';
8
+
9
+ type ListMobileProps = {
10
+ baseProps: ListBottomSheetMobileRestProps | ListModalMobileRestProps;
11
+ open: boolean;
12
+ menuRef: RefObject<HTMLDivElement>;
13
+ scrollableContainerRef: RefObject<HTMLDivElement>;
14
+ flatOptions: OptionShape[];
15
+ closeMenu: () => void;
16
+ handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
17
+ renderSearch: () => ReactNode;
18
+ renderOptionsList: () => ReactNode;
19
+ };
20
+
21
+ export const ListMobile: FC<ListMobileProps> = (props) => {
22
+ const { baseProps, ...restProps } = props;
23
+ const { isBottomSheet, nativeSelect } = baseProps;
24
+
25
+ if (isBottomSheet && !nativeSelect) {
26
+ return (
27
+ <ListBottomSheetMobile
28
+ {...(baseProps as ListBottomSheetMobileRestProps)}
29
+ {...restProps}
30
+ />
31
+ );
32
+ }
33
+
34
+ if (!isBottomSheet && !nativeSelect) {
35
+ return <ListModalMobile {...(baseProps as ListModalMobileRestProps)} {...restProps} />;
36
+ }
37
+
38
+ return null;
39
+ };
@@ -0,0 +1,94 @@
1
+ import React, { FC, ReactNode, RefObject } from 'react';
2
+ import mergeRefs from 'react-merge-refs';
3
+ import cn from 'classnames';
4
+
5
+ import { OptionShape } from '@alfalab/core-components-select/typings';
6
+ import { getDataTestId } from '@alfalab/core-components-shared';
7
+
8
+ import { ListModalMobileRestProps } from './types/types';
9
+
10
+ import mobileStyles from '../../mobile.module.css';
11
+
12
+ type ListModalMobileProps = {
13
+ open: boolean;
14
+ menuRef: RefObject<HTMLDivElement>;
15
+ scrollableContainerRef: RefObject<HTMLDivElement>;
16
+ flatOptions: OptionShape[];
17
+ closeMenu: () => void;
18
+ handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
19
+ renderSearch: () => ReactNode;
20
+ renderOptionsList: () => ReactNode;
21
+ } & ListModalMobileRestProps;
22
+
23
+ export const ListModalMobile: FC<ListModalMobileProps> = (props) => {
24
+ const {
25
+ ModalMobile,
26
+ dataTestId,
27
+ open,
28
+ modalProps,
29
+ modalHeaderProps,
30
+ modalFooterProps,
31
+ menuRef,
32
+ scrollableContainerRef,
33
+ label,
34
+ placeholder,
35
+ onScroll,
36
+ flatOptions,
37
+ closeMenu,
38
+ handleEntered,
39
+ renderSearch,
40
+ renderOptionsList,
41
+ } = props;
42
+
43
+ if (ModalMobile) {
44
+ return (
45
+ <ModalMobile
46
+ dataTestId={getDataTestId(dataTestId, 'modal')}
47
+ open={open}
48
+ hasCloser={true}
49
+ {...modalProps}
50
+ componentRef={menuRef}
51
+ onClose={(...args) => {
52
+ closeMenu();
53
+ modalProps?.onClose?.(...args);
54
+ }}
55
+ contentClassName={cn(mobileStyles.sheetContent, modalProps?.contentClassName)}
56
+ ref={mergeRefs([
57
+ scrollableContainerRef,
58
+ modalProps?.ref as React.Ref<HTMLDivElement>,
59
+ ])}
60
+ wrapperProps={{
61
+ ...modalProps?.wrapperProps,
62
+ onScroll,
63
+ }}
64
+ transitionProps={{
65
+ ...modalProps?.transitionProps,
66
+ onEntered: handleEntered,
67
+ }}
68
+ >
69
+ <ModalMobile.Header
70
+ hasCloser={true}
71
+ sticky={true}
72
+ {...modalHeaderProps}
73
+ title={undefined}
74
+ bottomAddons={
75
+ <React.Fragment>
76
+ {renderSearch()}
77
+ {flatOptions.length > 0 && modalHeaderProps?.bottomAddons}
78
+ </React.Fragment>
79
+ }
80
+ >
81
+ {modalHeaderProps?.title || label || placeholder}
82
+ </ModalMobile.Header>
83
+
84
+ <ModalMobile.Content flex={true} className={mobileStyles.modalContent}>
85
+ {renderOptionsList()}
86
+ </ModalMobile.Content>
87
+
88
+ {modalFooterProps?.children && <ModalMobile.Footer {...modalFooterProps} />}
89
+ </ModalMobile>
90
+ );
91
+ }
92
+
93
+ return null;
94
+ };
@@ -0,0 +1,4 @@
1
+ import { getListBottomSheetMobileProps, getListModalMobileProps } from '../helpers';
2
+
3
+ export type ListBottomSheetMobileRestProps = ReturnType<typeof getListBottomSheetMobileProps>;
4
+ export type ListModalMobileRestProps = ReturnType<typeof getListModalMobileProps>;