@alfalab/core-components-select 15.3.0 → 16.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/Component.desktop.d.ts +3 -15
  2. package/Component.desktop.js +4 -2
  3. package/Component.mobile.d.ts +3 -39
  4. package/Component.mobile.js +23 -10
  5. package/Component.modal.mobile.d.ts +2 -256
  6. package/Component.modal.mobile.js +23 -35
  7. package/Component.responsive.d.ts +3 -17
  8. package/Component.responsive.js +11 -13
  9. package/components/arrow/Component.js +1 -1
  10. package/components/arrow/index.css +5 -5
  11. package/components/base-checkmark/Component.js +1 -1
  12. package/components/base-checkmark/index.css +4 -4
  13. package/components/base-option/Component.js +1 -1
  14. package/components/base-option/index.css +16 -16
  15. package/components/base-select/Component.d.ts +17 -2
  16. package/components/base-select/Component.js +188 -81
  17. package/components/base-select/index.css +12 -12
  18. package/components/base-select/index.js +1 -1
  19. package/{esm/components/base-select-mobile/index.css → components/base-select/mobile.css} +13 -22
  20. package/components/checkmark/Component.js +1 -1
  21. package/components/checkmark/index.css +11 -11
  22. package/components/checkmark-mobile/Component.js +1 -1
  23. package/components/checkmark-mobile/index.css +6 -6
  24. package/components/field/Component.js +1 -1
  25. package/components/field/index.css +15 -17
  26. package/components/footer/Component.d.ts +12 -0
  27. package/components/{base-select-mobile/footer → footer}/Component.js +6 -5
  28. package/components/{base-select-mobile/footer → footer}/index.css +6 -6
  29. package/components/footer/index.d.ts +1 -0
  30. package/components/{base-select-mobile/footer → footer}/index.js +3 -2
  31. package/components/index.js +2 -1
  32. package/components/optgroup/Component.js +1 -1
  33. package/components/optgroup/index.css +7 -7
  34. package/components/option/Component.js +1 -1
  35. package/components/option/index.css +24 -24
  36. package/components/options-list/Component.js +7 -3
  37. package/components/options-list/index.css +11 -11
  38. package/components/options-list/index.js +2 -1
  39. package/components/search/Component.d.ts +2 -4
  40. package/components/search/Component.js +1 -1
  41. package/components/search/index.css +2 -2
  42. package/components/virtual-options-list/Component.js +7 -3
  43. package/components/virtual-options-list/index.css +18 -18
  44. package/components/virtual-options-list/index.js +2 -1
  45. package/cssm/Component.desktop.d.ts +3 -15
  46. package/cssm/Component.desktop.js +5 -2
  47. package/cssm/Component.mobile.d.ts +3 -39
  48. package/cssm/Component.mobile.js +27 -13
  49. package/cssm/Component.modal.mobile.d.ts +2 -256
  50. package/cssm/Component.modal.mobile.js +28 -39
  51. package/cssm/Component.responsive.d.ts +3 -17
  52. package/cssm/Component.responsive.js +13 -15
  53. package/cssm/components/arrow/index.module.css +2 -2
  54. package/cssm/components/base-option/index.module.css +3 -3
  55. package/cssm/components/base-select/Component.d.ts +17 -2
  56. package/cssm/components/base-select/Component.js +186 -80
  57. package/cssm/components/base-select/index.js +2 -1
  58. package/cssm/components/base-select/index.module.css +2 -2
  59. package/cssm/components/{base-select-mobile/index.module.css → base-select/mobile.module.css} +0 -9
  60. package/cssm/components/checkmark/index.module.css +1 -1
  61. package/cssm/components/field/index.module.css +3 -5
  62. package/cssm/components/footer/Component.d.ts +12 -0
  63. package/cssm/components/{base-select-mobile/footer → footer}/Component.js +5 -4
  64. package/cssm/components/footer/index.d.ts +1 -0
  65. package/cssm/components/{base-select-mobile/footer → footer}/index.js +3 -2
  66. package/cssm/components/{base-select-mobile/footer → footer}/index.module.css +1 -1
  67. package/cssm/components/index.js +3 -1
  68. package/cssm/components/optgroup/index.module.css +1 -1
  69. package/cssm/components/option/index.module.css +4 -4
  70. package/cssm/components/options-list/Component.js +6 -2
  71. package/cssm/components/options-list/index.js +2 -1
  72. package/cssm/components/options-list/index.module.css +2 -2
  73. package/cssm/components/search/Component.d.ts +2 -4
  74. package/cssm/components/virtual-options-list/Component.js +6 -2
  75. package/cssm/components/virtual-options-list/index.js +2 -1
  76. package/cssm/components/virtual-options-list/index.module.css +3 -3
  77. package/cssm/desktop/index.d.ts +2 -2
  78. package/cssm/desktop/index.js +4 -1
  79. package/cssm/{hook-244c8d6e.js → hook-2f9ec939.js} +9 -5
  80. package/{esm/hook-8abfea97.d.ts → cssm/hook-ad89c253.d.ts} +3 -2
  81. package/cssm/index.d.ts +2 -2
  82. package/cssm/index.js +10 -9
  83. package/cssm/mobile/index.d.ts +1 -3
  84. package/cssm/mobile/index.js +15 -10
  85. package/cssm/presets/index.d.ts +1 -1
  86. package/cssm/presets/index.js +3 -2
  87. package/cssm/presets/useSelectWithApply/hook.js +3 -2
  88. package/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
  89. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  90. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
  91. package/cssm/shared/index.d.ts +9 -2
  92. package/cssm/shared/index.js +50 -48
  93. package/cssm/typings.d.ts +86 -7
  94. package/desktop/index.d.ts +2 -2
  95. package/desktop/index.js +3 -1
  96. package/esm/Component.desktop.d.ts +3 -15
  97. package/esm/Component.desktop.js +4 -2
  98. package/esm/Component.mobile.d.ts +3 -39
  99. package/esm/Component.mobile.js +22 -9
  100. package/esm/Component.modal.mobile.d.ts +2 -256
  101. package/esm/Component.modal.mobile.js +24 -36
  102. package/esm/Component.responsive.d.ts +3 -17
  103. package/esm/Component.responsive.js +11 -13
  104. package/esm/components/arrow/Component.js +1 -1
  105. package/esm/components/arrow/index.css +5 -5
  106. package/esm/components/base-checkmark/Component.js +1 -1
  107. package/esm/components/base-checkmark/index.css +4 -4
  108. package/esm/components/base-option/Component.js +1 -1
  109. package/esm/components/base-option/index.css +16 -16
  110. package/esm/components/base-select/Component.d.ts +17 -2
  111. package/esm/components/base-select/Component.js +190 -83
  112. package/esm/components/base-select/index.css +12 -12
  113. package/esm/components/base-select/index.js +1 -1
  114. package/{modern/components/base-select-mobile/index.css → esm/components/base-select/mobile.css} +13 -22
  115. package/esm/components/checkmark/Component.js +1 -1
  116. package/esm/components/checkmark/index.css +11 -11
  117. package/esm/components/checkmark-mobile/Component.js +1 -1
  118. package/esm/components/checkmark-mobile/index.css +6 -6
  119. package/esm/components/field/Component.js +1 -1
  120. package/esm/components/field/index.css +15 -17
  121. package/esm/components/footer/Component.d.ts +12 -0
  122. package/esm/components/{base-select-mobile/footer → footer}/Component.js +6 -5
  123. package/esm/components/{base-select-mobile/footer → footer}/index.css +6 -6
  124. package/esm/components/footer/index.d.ts +1 -0
  125. package/esm/components/{base-select-mobile/footer → footer}/index.js +1 -0
  126. package/esm/components/index.js +2 -1
  127. package/esm/components/optgroup/Component.js +1 -1
  128. package/esm/components/optgroup/index.css +7 -7
  129. package/esm/components/option/Component.js +1 -1
  130. package/esm/components/option/index.css +24 -24
  131. package/esm/components/options-list/Component.js +7 -3
  132. package/esm/components/options-list/index.css +11 -11
  133. package/esm/components/options-list/index.js +2 -1
  134. package/esm/components/search/Component.d.ts +2 -4
  135. package/esm/components/search/Component.js +1 -1
  136. package/esm/components/search/index.css +2 -2
  137. package/esm/components/virtual-options-list/Component.js +7 -3
  138. package/esm/components/virtual-options-list/index.css +18 -18
  139. package/esm/components/virtual-options-list/index.js +2 -1
  140. package/esm/desktop/index.d.ts +2 -2
  141. package/esm/desktop/index.js +3 -1
  142. package/{hook-8abfea97.d.ts → esm/hook-ad89c253.d.ts} +3 -2
  143. package/esm/{hook-70d58270.js → hook-d82699d1.js} +10 -6
  144. package/esm/index.d.ts +2 -2
  145. package/esm/index.js +8 -7
  146. package/esm/mobile/index.d.ts +1 -3
  147. package/esm/mobile/index.js +12 -8
  148. package/esm/presets/index.d.ts +1 -1
  149. package/esm/presets/index.js +3 -2
  150. package/esm/presets/useSelectWithApply/hook.js +3 -2
  151. package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
  152. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  153. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  154. package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  155. package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  156. package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  157. package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
  158. package/esm/presets/useSelectWithLoading/hook.js +1 -1
  159. package/esm/presets/useSelectWithLoading/index.css +2 -2
  160. package/esm/shared/index.d.ts +9 -2
  161. package/esm/shared/index.js +30 -29
  162. package/esm/typings.d.ts +86 -7
  163. package/{cssm/hook-8abfea97.d.ts → hook-ad89c253.d.ts} +3 -2
  164. package/{hook-0a5c9f56.js → hook-df30325f.js} +9 -5
  165. package/index.d.ts +2 -2
  166. package/index.js +8 -7
  167. package/mobile/index.d.ts +1 -3
  168. package/mobile/index.js +12 -8
  169. package/modern/Component.desktop.d.ts +3 -15
  170. package/modern/Component.desktop.js +5 -3
  171. package/modern/Component.mobile.d.ts +3 -39
  172. package/modern/Component.mobile.js +29 -13
  173. package/modern/Component.modal.mobile.d.ts +2 -256
  174. package/modern/Component.modal.mobile.js +23 -43
  175. package/modern/Component.responsive.d.ts +3 -17
  176. package/modern/Component.responsive.js +11 -13
  177. package/modern/components/arrow/Component.js +1 -1
  178. package/modern/components/arrow/index.css +5 -5
  179. package/modern/components/base-checkmark/Component.js +1 -1
  180. package/modern/components/base-checkmark/index.css +4 -4
  181. package/modern/components/base-option/Component.js +1 -1
  182. package/modern/components/base-option/index.css +16 -16
  183. package/modern/components/base-select/Component.d.ts +17 -2
  184. package/modern/components/base-select/Component.js +179 -72
  185. package/modern/components/base-select/index.css +12 -12
  186. package/modern/components/base-select/index.js +1 -1
  187. package/{components/base-select-mobile/index.css → modern/components/base-select/mobile.css} +13 -22
  188. package/modern/components/checkmark/Component.js +1 -1
  189. package/modern/components/checkmark/index.css +11 -11
  190. package/modern/components/checkmark-mobile/Component.js +1 -1
  191. package/modern/components/checkmark-mobile/index.css +6 -6
  192. package/modern/components/field/Component.js +1 -1
  193. package/modern/components/field/index.css +15 -17
  194. package/modern/components/footer/Component.d.ts +12 -0
  195. package/modern/components/{base-select-mobile/footer → footer}/Component.js +5 -4
  196. package/modern/components/{base-select-mobile/footer → footer}/index.css +6 -6
  197. package/modern/components/footer/index.d.ts +1 -0
  198. package/modern/components/{base-select-mobile/footer → footer}/index.js +1 -0
  199. package/modern/components/index.js +2 -1
  200. package/modern/components/optgroup/Component.js +1 -1
  201. package/modern/components/optgroup/index.css +7 -7
  202. package/modern/components/option/Component.js +1 -1
  203. package/modern/components/option/index.css +24 -24
  204. package/modern/components/options-list/Component.js +5 -3
  205. package/modern/components/options-list/index.css +11 -11
  206. package/modern/components/options-list/index.js +2 -1
  207. package/modern/components/search/Component.d.ts +2 -4
  208. package/modern/components/search/Component.js +1 -1
  209. package/modern/components/search/index.css +2 -2
  210. package/modern/components/virtual-options-list/Component.js +5 -3
  211. package/modern/components/virtual-options-list/index.css +18 -18
  212. package/modern/components/virtual-options-list/index.js +2 -1
  213. package/modern/desktop/index.d.ts +2 -2
  214. package/modern/desktop/index.js +3 -1
  215. package/modern/{hook-8abfea97.d.ts → hook-ad89c253.d.ts} +3 -2
  216. package/modern/{hook-4eceefed.js → hook-d879e08e.js} +7 -3
  217. package/modern/index.d.ts +2 -2
  218. package/modern/index.js +8 -7
  219. package/modern/mobile/index.d.ts +1 -3
  220. package/modern/mobile/index.js +12 -8
  221. package/modern/presets/index.d.ts +1 -1
  222. package/modern/presets/index.js +3 -2
  223. package/modern/presets/useSelectWithApply/hook.js +3 -2
  224. package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
  225. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  226. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  227. package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  228. package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  229. package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  230. package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
  231. package/modern/presets/useSelectWithLoading/hook.js +1 -1
  232. package/modern/presets/useSelectWithLoading/index.css +2 -2
  233. package/modern/shared/index.d.ts +9 -2
  234. package/modern/shared/index.js +29 -28
  235. package/modern/typings.d.ts +86 -7
  236. package/package.json +13 -11
  237. package/presets/index.d.ts +1 -1
  238. package/presets/index.js +3 -2
  239. package/presets/useSelectWithApply/hook.js +3 -2
  240. package/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
  241. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
  242. package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
  243. package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
  244. package/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
  245. package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  246. package/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
  247. package/presets/useSelectWithLoading/hook.js +1 -1
  248. package/presets/useSelectWithLoading/index.css +2 -2
  249. package/shared/index.d.ts +9 -2
  250. package/shared/index.js +39 -38
  251. package/src/Component.desktop.tsx +5 -14
  252. package/src/Component.mobile.tsx +38 -57
  253. package/src/Component.modal.mobile.tsx +5 -147
  254. package/src/Component.responsive.tsx +9 -44
  255. package/src/components/base-select/Component.tsx +380 -156
  256. package/src/components/base-select/index.module.css +1 -1
  257. package/src/components/{base-select-mobile/index.module.css → base-select/mobile.module.css} +0 -15
  258. package/src/components/{base-select-mobile/footer → footer}/Component.tsx +22 -4
  259. package/src/components/{base-select-mobile/footer → footer}/index.module.css +1 -1
  260. package/src/components/footer/index.ts +1 -0
  261. package/src/components/options-list/Component.tsx +6 -2
  262. package/src/components/virtual-options-list/Component.tsx +6 -2
  263. package/src/desktop/index.ts +2 -1
  264. package/src/index.ts +2 -4
  265. package/src/mobile/index.ts +1 -2
  266. package/src/presets/useSelectWithApply/hook.tsx +9 -3
  267. package/src/shared/index.ts +10 -2
  268. package/src/typings.ts +110 -9
  269. package/src/vars.css +1 -1
  270. package/typings.d.ts +86 -7
  271. package/components/base-select-mobile/Component.d.ts +0 -71
  272. package/components/base-select-mobile/Component.js +0 -296
  273. package/components/base-select-mobile/footer/Component.d.ts +0 -9
  274. package/components/base-select-mobile/footer/index.d.ts +0 -1
  275. package/components/base-select-mobile/index.d.ts +0 -1
  276. package/components/base-select-mobile/index.js +0 -36
  277. package/cssm/components/base-select-mobile/Component.d.ts +0 -71
  278. package/cssm/components/base-select-mobile/Component.js +0 -303
  279. package/cssm/components/base-select-mobile/footer/Component.d.ts +0 -9
  280. package/cssm/components/base-select-mobile/footer/index.d.ts +0 -1
  281. package/cssm/components/base-select-mobile/index.d.ts +0 -1
  282. package/cssm/components/base-select-mobile/index.js +0 -45
  283. package/esm/components/base-select-mobile/Component.d.ts +0 -71
  284. package/esm/components/base-select-mobile/Component.js +0 -286
  285. package/esm/components/base-select-mobile/footer/Component.d.ts +0 -9
  286. package/esm/components/base-select-mobile/footer/index.d.ts +0 -1
  287. package/esm/components/base-select-mobile/index.d.ts +0 -1
  288. package/esm/components/base-select-mobile/index.js +0 -28
  289. package/modern/components/base-select-mobile/Component.d.ts +0 -71
  290. package/modern/components/base-select-mobile/Component.js +0 -285
  291. package/modern/components/base-select-mobile/footer/Component.d.ts +0 -9
  292. package/modern/components/base-select-mobile/footer/index.d.ts +0 -1
  293. package/modern/components/base-select-mobile/index.d.ts +0 -1
  294. package/modern/components/base-select-mobile/index.js +0 -27
  295. package/src/components/base-select-mobile/Component.tsx +0 -572
  296. package/src/components/base-select-mobile/footer/index.ts +0 -1
  297. package/src/components/base-select-mobile/index.ts +0 -1
  298. /package/cssm/{hook-244c8d6e.d.ts → hook-2f9ec939.d.ts} +0 -0
  299. /package/esm/{hook-70d58270.d.ts → hook-d82699d1.d.ts} +0 -0
  300. /package/{hook-0a5c9f56.d.ts → hook-df30325f.d.ts} +0 -0
  301. /package/modern/{hook-4eceefed.d.ts → hook-d879e08e.d.ts} +0 -0
@@ -18,7 +18,7 @@
18
18
  position: relative;
19
19
  }
20
20
 
21
- .optionsList {
21
+ .optionsListWrapper {
22
22
  position: relative;
23
23
  padding-top: var(--select-options-list-top-padding);
24
24
  padding-bottom: var(--select-options-list-bottom-padding);
@@ -1,13 +1,6 @@
1
1
  @import '@alfalab/core-components-themes/src/default.css';
2
2
  @import '../../vars.css';
3
3
 
4
- .component {
5
- width: max-content;
6
- position: relative;
7
- outline: 0;
8
- max-width: 100%;
9
- }
10
-
11
4
  .sheet {
12
5
  overflow: hidden;
13
6
  }
@@ -26,10 +19,6 @@
26
19
  padding: 0;
27
20
  }
28
21
 
29
- .block {
30
- width: 100%;
31
- }
32
-
33
22
  .optionsListWrapper {
34
23
  flex: 1;
35
24
  }
@@ -44,10 +33,6 @@
44
33
  flex: 1;
45
34
  }
46
35
 
47
- .emptySearchPlaceholder {
48
- text-align: center;
49
- }
50
-
51
36
  .search {
52
37
  padding: var(--gap-xs);
53
38
  }
@@ -3,6 +3,7 @@ import cn from 'classnames';
3
3
 
4
4
  import { BaseModalContext } from '@alfalab/core-components-base-modal';
5
5
  import { ButtonMobile } from '@alfalab/core-components-button/mobile';
6
+ import { getDataTestId } from '@alfalab/core-components-shared';
6
7
 
7
8
  import styles from './index.module.css';
8
9
 
@@ -10,9 +11,19 @@ export type FooterProps = {
10
11
  handleClear?: () => void;
11
12
  handleApply?: () => void;
12
13
  showClear?: boolean;
14
+ clearText?: string;
15
+ applyText?: string;
16
+ dataTestId?: string;
13
17
  };
14
18
 
15
- export const Footer = ({ handleApply, handleClear, showClear }: FooterProps) => {
19
+ export const Footer = ({
20
+ handleApply,
21
+ handleClear,
22
+ showClear,
23
+ clearText = 'Сбросить',
24
+ applyText = 'Применить',
25
+ dataTestId,
26
+ }: FooterProps) => {
16
27
  const { footerHighlighted, setHasFooter } = useContext(BaseModalContext);
17
28
 
18
29
  useEffect(() => {
@@ -33,13 +44,20 @@ export const Footer = ({ handleApply, handleClear, showClear }: FooterProps) =>
33
44
  view='secondary'
34
45
  className={styles.button}
35
46
  onClick={handleClear}
47
+ dataTestId={getDataTestId(dataTestId, 'clear')}
36
48
  >
37
- Сбросить
49
+ {clearText}
38
50
  </ButtonMobile>
39
51
  )}
40
52
 
41
- <ButtonMobile size='m' view='primary' className={styles.button} onClick={handleApply}>
42
- Применить
53
+ <ButtonMobile
54
+ size='m'
55
+ view='primary'
56
+ className={styles.button}
57
+ onClick={handleApply}
58
+ dataTestId={getDataTestId(dataTestId, 'apply')}
59
+ >
60
+ {applyText}
43
61
  </ButtonMobile>
44
62
  </div>
45
63
  );
@@ -1,5 +1,5 @@
1
1
  @import '@alfalab/core-components-themes/src/default.css';
2
- @import '../../../vars.css';
2
+ @import '../../vars.css';
3
3
 
4
4
  .footer {
5
5
  display: flex;
@@ -0,0 +1 @@
1
+ export { Footer } from './Component';
@@ -2,8 +2,9 @@ import React, { forwardRef, useRef } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
 
5
+ import { useMatchMedia } from '@alfalab/core-components-mq';
5
6
  import { Scrollbar } from '@alfalab/core-components-scrollbar';
6
- import { useMedia } from '@alfalab/hooks';
7
+ import { isClient } from '@alfalab/core-components-shared';
7
8
 
8
9
  import { DEFAULT_VISIBLE_OPTIONS } from '../../consts';
9
10
  import { GroupShape, OptionShape, OptionsListProps } from '../../typings';
@@ -45,7 +46,10 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
45
46
  },
46
47
  ref,
47
48
  ) => {
48
- let [nativeScrollbar] = useMedia<boolean>([[true, '(max-width: 1023px)']], false);
49
+ const query = '(max-width: 1023px)';
50
+ let [nativeScrollbar] = useMatchMedia(query, () =>
51
+ isClient() ? window.matchMedia(query).matches : true,
52
+ );
49
53
 
50
54
  nativeScrollbar = Boolean(nativeScrollbarProp ?? nativeScrollbar);
51
55
 
@@ -3,8 +3,9 @@ import mergeRefs from 'react-merge-refs';
3
3
  import { useVirtual } from 'react-virtual';
4
4
  import cn from 'classnames';
5
5
 
6
+ import { useMatchMedia } from '@alfalab/core-components-mq';
6
7
  import { Scrollbar } from '@alfalab/core-components-scrollbar';
7
- import { useMedia } from '@alfalab/hooks';
8
+ import { isClient } from '@alfalab/core-components-shared';
8
9
 
9
10
  import { DEFAULT_VISIBLE_OPTIONS } from '../../consts';
10
11
  import { GroupShape, OptionShape, OptionsListProps } from '../../typings';
@@ -44,7 +45,10 @@ export const VirtualOptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
44
45
  const [visibleOptionsInvalidateKey, setVisibleOptionsInvalidateKey] = useState('');
45
46
  const prevHighlightedIndex = usePrevious(highlightedIndex) || -1;
46
47
 
47
- let [nativeScrollbar] = useMedia<boolean>([[true, '(max-width: 1023px)']], false);
48
+ const query = '(max-width: 1023px)';
49
+ let [nativeScrollbar] = useMatchMedia(query, () =>
50
+ isClient() ? window.matchMedia(query).matches : true,
51
+ );
48
52
 
49
53
  const rowVirtualizer = useVirtual({
50
54
  size: flatOptions.length,
@@ -1 +1,2 @@
1
- export { SelectDesktop, SelectDesktopProps } from '../Component.desktop';
1
+ export { SelectDesktop } from '../Component.desktop';
2
+ export type { SelectDesktopProps } from '../typings';
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
- export {
2
- SelectResponsive as Select,
3
- SelectResponsiveProps as SelectProps,
4
- } from './Component.responsive';
1
+ export { SelectResponsive as Select } from './Component.responsive';
2
+ export type { SelectProps } from './typings';
@@ -1,5 +1,4 @@
1
1
  export { SelectMobile } from '../Component.mobile';
2
2
  export { SelectModalMobile } from '../Component.modal.mobile';
3
3
 
4
- export type { SelectMobileProps } from '../Component.mobile';
5
- export type { SelectModalMobileProps } from '../Component.modal.mobile';
4
+ export type { SelectMobileProps, SelectModalMobileProps } from '../typings';
@@ -73,18 +73,24 @@ export function useSelectWithApply({
73
73
  showSearch,
74
74
  searchProps = {},
75
75
  }: UseSelectWithApplyProps) {
76
- const [search, setSearch] = useState('');
76
+ const [searchState, setSearchState] = useState('');
77
+
78
+ const [search, setSearch] =
79
+ typeof searchProps?.value === 'string'
80
+ ? [searchProps.value, searchProps.onChange]
81
+ : [searchState, setSearchState];
77
82
 
78
83
  const accessor = searchProps.accessor || defaultAccessor;
84
+ const filterFn = searchProps.filterFn || defaultFilterFn;
79
85
 
80
86
  const { flatOptions, selectedOptions } = useMemo(
81
87
  () =>
82
88
  processOptions(
83
89
  options,
84
90
  selected,
85
- showSearch ? (option) => defaultFilterFn(accessor(option), search) : undefined,
91
+ showSearch ? (option) => filterFn(accessor(option), search) : undefined,
86
92
  ),
87
- [accessor, options, search, selected, showSearch],
93
+ [filterFn, accessor, options, search, selected, showSearch],
88
94
  );
89
95
 
90
96
  const [selectedDraft, setSelectedDraft] = useState<OptionShape[]>(selectedOptions);
@@ -1,5 +1,13 @@
1
- export * from '../components';
2
1
  export * from '../presets';
3
2
  export * from '../typings';
4
3
  export * from '../utils';
5
- export type { AdditionalMobileProps } from '../Component.mobile';
4
+
5
+ export * from '../components/option';
6
+ export * from '../components/base-option';
7
+ export * from '../components/options-list';
8
+ export * from '../components/virtual-options-list';
9
+ export * from '../components/field';
10
+ export * from '../components/arrow';
11
+ export * from '../components/base-select';
12
+ export * from '../components/optgroup';
13
+ export * from '../components/footer';
package/src/typings.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AriaAttributes,
3
3
  FC,
4
4
  FocusEvent,
@@ -9,8 +9,14 @@ import {
9
9
  SVGProps,
10
10
  } from 'react';
11
11
 
12
- import { InputProps } from '@alfalab/core-components-input';
13
- import { PopoverProps } from '@alfalab/core-components-popover';
12
+ import type { BottomSheetProps } from '@alfalab/core-components-bottom-sheet';
13
+ import type { FormControlProps } from '@alfalab/core-components-form-control';
14
+ import type { InputProps } from '@alfalab/core-components-input';
15
+ import type { ModalProps } from '@alfalab/core-components-modal';
16
+ import type { ModalFooterProps, ModalHeaderProps } from '@alfalab/core-components-modal/shared';
17
+ import type { PopoverProps } from '@alfalab/core-components-popover';
18
+
19
+ import type { UseSelectWithApplyProps } from './presets/useSelectWithApply/hook';
14
20
 
15
21
  // eslint-disable-next-line
16
22
  export type AnyObject = Record<string, any>;
@@ -284,7 +290,7 @@ export type BaseSelectProps = {
284
290
  /**
285
291
  * Компонент поиска
286
292
  */
287
- Search?: FC<SearchProps & RefAttributes<HTMLInputElement>>;
293
+ Search?: FC<SearchProps>;
288
294
 
289
295
  /**
290
296
  * Настройки поиска
@@ -292,6 +298,7 @@ export type BaseSelectProps = {
292
298
  searchProps?: {
293
299
  componentProps?: SearchProps;
294
300
  accessor?: (option: OptionShape) => string;
301
+ filterFn?: (optionText: string, search: string) => boolean;
295
302
  value?: string;
296
303
  onChange?: (value: string) => void;
297
304
  };
@@ -665,10 +672,10 @@ export type OptionProps = {
665
672
  */
666
673
  innerProps: {
667
674
  id: string;
668
- onClick: (event: MouseEvent<HTMLDivElement>) => void;
669
- onMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
670
- onMouseMove: (event: MouseEvent<HTMLDivElement>) => void;
671
- role: string;
675
+ onClick?: (event: MouseEvent<HTMLDivElement>) => void;
676
+ onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
677
+ onMouseMove?: (event: MouseEvent<HTMLDivElement>) => void;
678
+ role?: string;
672
679
  } & RefAttributes<HTMLDivElement> &
673
680
  AriaAttributes;
674
681
 
@@ -720,4 +727,98 @@ export type CheckmarkProps = {
720
727
  icon?: FC<SVGProps<SVGSVGElement>>;
721
728
  };
722
729
 
723
- export type SearchProps = InputProps;
730
+ export type SearchProps = InputProps & RefAttributes<HTMLInputElement>;
731
+
732
+ export type SelectFieldProps = Omit<FormControlProps, 'size'> & Record<string, unknown>;
733
+
734
+ export type AdditionalMobileProps = {
735
+ /**
736
+ * Показывать кнопку 'Сбросить' в футере мобильного компонента
737
+ */
738
+ showClear?: UseSelectWithApplyProps['showClear'];
739
+
740
+ /**
741
+ * Показывать пункт "Выбрать все"
742
+ */
743
+ showSelectAll?: UseSelectWithApplyProps['showSelectAll'];
744
+
745
+ /**
746
+ * Показывать пункт "Выбрать все" в заголовке списка у мобильного компонента
747
+ */
748
+ showHeaderWithSelectAll?: UseSelectWithApplyProps['showHeaderWithSelectAll'];
749
+
750
+ /**
751
+ * Использовать ли хук useSelectWithApply в мобильном компоненте
752
+ */
753
+ useWithApplyHook?: boolean;
754
+ };
755
+
756
+ export type BottomSheetSelectMobileProps = {
757
+ /**
758
+ * Футер
759
+ * @deprecated Используйте bottomSheetProps.actionButton
760
+ */
761
+ footer?: ReactNode;
762
+
763
+ /**
764
+ * Будет ли свайпаться шторка
765
+ * @deprecated Используйте bottomSheetProps.swipeable
766
+ */
767
+ swipeable?: boolean;
768
+
769
+ /**
770
+ * Дополнительные пропсы шторки
771
+ */
772
+ bottomSheetProps?: Partial<BottomSheetProps>;
773
+ };
774
+
775
+ export type ModalSelectMobileProps = {
776
+ /**
777
+ * Дополнительные пропсы шапки модалки
778
+ */
779
+ modalHeaderProps?: Partial<ModalHeaderProps>;
780
+
781
+ /**
782
+ * Дополнительные пропсы модалки
783
+ */
784
+ modalProps?: Partial<ModalProps & RefAttributes<HTMLDivElement>>;
785
+
786
+ /**
787
+ * Дополнительные пропсы футера модалки
788
+ */
789
+ modalFooterProps?: Partial<ModalFooterProps>;
790
+ };
791
+
792
+ type ConditionalMobileProps =
793
+ | ({ isBottomSheet?: true } & BottomSheetSelectMobileProps)
794
+ | ({ isBottomSheet: false } & ModalSelectMobileProps);
795
+
796
+ export type SelectModalMobileProps = Omit<BaseSelectProps, 'Checkmark'> &
797
+ AdditionalMobileProps &
798
+ ModalSelectMobileProps;
799
+
800
+ export type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark'> &
801
+ AdditionalMobileProps &
802
+ ConditionalMobileProps;
803
+
804
+ export type SelectDesktopProps = Omit<BaseSelectProps, 'fieldProps'> & {
805
+ /**
806
+ * Пропсы, которые будут прокинуты в компонент поля
807
+ */
808
+ fieldProps?: SelectFieldProps;
809
+ };
810
+
811
+ export type SelectProps = BaseSelectProps &
812
+ AdditionalMobileProps &
813
+ ConditionalMobileProps & {
814
+ /**
815
+ * Контрольная точка, с нее начинается desktop версия
816
+ * @default 1024
817
+ */
818
+ breakpoint?: number;
819
+
820
+ /**
821
+ * Значение по-умолчанию для хука useMatchMedia
822
+ */
823
+ defaultMatchMediaValue?: boolean | (() => boolean);
824
+ };
package/src/vars.css CHANGED
@@ -1,6 +1,6 @@
1
1
  :root {
2
2
  --select-error-color: var(--color-light-text-negative);
3
- --select-arrow-color: var(--color-light-graphic-primary);
3
+ --select-arrow-color: var(--color-light-neutral-translucent-700);
4
4
  --select-arrow-hover-opacity: 0.7;
5
5
 
6
6
  /* options list */
package/typings.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { AriaAttributes, FC, FocusEvent, MouseEvent, ReactElement, ReactNode, RefAttributes, SVGProps } from 'react';
2
+ import { BottomSheetProps } from "@alfalab/core-components-bottom-sheet";
3
+ import { FormControlProps } from "@alfalab/core-components-form-control";
2
4
  import { InputProps } from "@alfalab/core-components-input";
5
+ import { ModalProps } from "@alfalab/core-components-modal";
6
+ import { ModalFooterProps, ModalHeaderProps } from "@alfalab/core-components-modal/shared";
3
7
  import { PopoverProps } from "@alfalab/core-components-popover";
8
+ import { UseSelectWithApplyProps } from "./hook-ad89c253";
4
9
  type AnyObject = Record<string, any>;
5
10
  type OptionShape = {
6
11
  /**
@@ -217,13 +222,14 @@ type BaseSelectProps = {
217
222
  /**
218
223
  * Компонент поиска
219
224
  */
220
- Search?: FC<SearchProps & RefAttributes<HTMLInputElement>>;
225
+ Search?: FC<SearchProps>;
221
226
  /**
222
227
  * Настройки поиска
223
228
  */
224
229
  searchProps?: {
225
230
  componentProps?: SearchProps;
226
231
  accessor?: (option: OptionShape) => string;
232
+ filterFn?: (optionText: string, search: string) => boolean;
227
233
  value?: string;
228
234
  onChange?: (value: string) => void;
229
235
  };
@@ -528,10 +534,10 @@ type OptionProps = {
528
534
  */
529
535
  innerProps: {
530
536
  id: string;
531
- onClick: (event: MouseEvent<HTMLDivElement>) => void;
532
- onMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
533
- onMouseMove: (event: MouseEvent<HTMLDivElement>) => void;
534
- role: string;
537
+ onClick?: (event: MouseEvent<HTMLDivElement>) => void;
538
+ onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
539
+ onMouseMove?: (event: MouseEvent<HTMLDivElement>) => void;
540
+ role?: string;
535
541
  } & RefAttributes<HTMLDivElement> & AriaAttributes;
536
542
  /**
537
543
  * Идентификатор для систем автоматизированного тестирования
@@ -572,5 +578,78 @@ type CheckmarkProps = {
572
578
  */
573
579
  icon?: FC<SVGProps<SVGSVGElement>>;
574
580
  };
575
- type SearchProps = InputProps;
576
- export { AnyObject, OptionShape, GroupShape, BaseSelectChangePayload, BaseSelectProps, FieldProps, ArrowProps, OptionsListProps, OptgroupProps, OptionProps, CheckmarkProps, SearchProps };
581
+ type SearchProps = InputProps & RefAttributes<HTMLInputElement>;
582
+ type SelectFieldProps = Omit<FormControlProps, 'size'> & Record<string, unknown>;
583
+ type AdditionalMobileProps = {
584
+ /**
585
+ * Показывать кнопку 'Сбросить' в футере мобильного компонента
586
+ */
587
+ showClear?: UseSelectWithApplyProps['showClear'];
588
+ /**
589
+ * Показывать пункт "Выбрать все"
590
+ */
591
+ showSelectAll?: UseSelectWithApplyProps['showSelectAll'];
592
+ /**
593
+ * Показывать пункт "Выбрать все" в заголовке списка у мобильного компонента
594
+ */
595
+ showHeaderWithSelectAll?: UseSelectWithApplyProps['showHeaderWithSelectAll'];
596
+ /**
597
+ * Использовать ли хук useSelectWithApply в мобильном компоненте
598
+ */
599
+ useWithApplyHook?: boolean;
600
+ };
601
+ type BottomSheetSelectMobileProps = {
602
+ /**
603
+ * Футер
604
+ * @deprecated Используйте bottomSheetProps.actionButton
605
+ */
606
+ footer?: ReactNode;
607
+ /**
608
+ * Будет ли свайпаться шторка
609
+ * @deprecated Используйте bottomSheetProps.swipeable
610
+ */
611
+ swipeable?: boolean;
612
+ /**
613
+ * Дополнительные пропсы шторки
614
+ */
615
+ bottomSheetProps?: Partial<BottomSheetProps>;
616
+ };
617
+ type ModalSelectMobileProps = {
618
+ /**
619
+ * Дополнительные пропсы шапки модалки
620
+ */
621
+ modalHeaderProps?: Partial<ModalHeaderProps>;
622
+ /**
623
+ * Дополнительные пропсы модалки
624
+ */
625
+ modalProps?: Partial<ModalProps & RefAttributes<HTMLDivElement>>;
626
+ /**
627
+ * Дополнительные пропсы футера модалки
628
+ */
629
+ modalFooterProps?: Partial<ModalFooterProps>;
630
+ };
631
+ type ConditionalMobileProps = ({
632
+ isBottomSheet?: true;
633
+ } & BottomSheetSelectMobileProps) | ({
634
+ isBottomSheet: false;
635
+ } & ModalSelectMobileProps);
636
+ type SelectModalMobileProps = Omit<BaseSelectProps, 'Checkmark'> & AdditionalMobileProps & ModalSelectMobileProps;
637
+ type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark'> & AdditionalMobileProps & ConditionalMobileProps;
638
+ type SelectDesktopProps = Omit<BaseSelectProps, 'fieldProps'> & {
639
+ /**
640
+ * Пропсы, которые будут прокинуты в компонент поля
641
+ */
642
+ fieldProps?: SelectFieldProps;
643
+ };
644
+ type SelectProps = BaseSelectProps & AdditionalMobileProps & ConditionalMobileProps & {
645
+ /**
646
+ * Контрольная точка, с нее начинается desktop версия
647
+ * @default 1024
648
+ */
649
+ breakpoint?: number;
650
+ /**
651
+ * Значение по-умолчанию для хука useMatchMedia
652
+ */
653
+ defaultMatchMediaValue?: boolean | (() => boolean);
654
+ };
655
+ export { AnyObject, OptionShape, GroupShape, BaseSelectChangePayload, BaseSelectProps, FieldProps, ArrowProps, OptionsListProps, OptgroupProps, OptionProps, CheckmarkProps, SearchProps, SelectFieldProps, AdditionalMobileProps, BottomSheetSelectMobileProps, ModalSelectMobileProps, SelectModalMobileProps, SelectMobileProps, SelectDesktopProps, SelectProps };
@@ -1,71 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ReactNode } from "react";
4
- import { BottomSheetProps } from "@alfalab/core-components-bottom-sheet";
5
- import { ModalMobile } from "@alfalab/core-components-modal/mobile";
6
- import { BaseSelectProps } from "../../typings";
7
- type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark' | 'onScroll'> & {
8
- /**
9
- * Футер
10
- * @deprecated Используйте bottomSheetProps.actionButton
11
- */
12
- footer?: ReactNode;
13
- /**
14
- * Будет ли свайпаться шторка
15
- * @deprecated Используйте bottomSheetProps.swipeable
16
- */
17
- swipeable?: boolean;
18
- /**
19
- * Отображать в BottomSheet
20
- */
21
- isBottomSheet?: boolean;
22
- /**
23
- * Дополнительные пропсы шторки
24
- */
25
- bottomSheetProps?: Partial<BottomSheetProps>;
26
- /**
27
- * Дополнительные пропсы модалки
28
- */
29
- modalProps?: Partial<React.ComponentProps<typeof ModalMobile>>;
30
- /**
31
- * Дополнительные пропсы шапки модалки
32
- */
33
- modalHeaderProps?: Partial<React.ComponentProps<typeof ModalMobile.Header>>;
34
- /**
35
- * Дополнительные пропсы футера модалки
36
- */
37
- modalFooterProps?: Partial<React.ComponentProps<typeof ModalMobile.Footer>>;
38
- };
39
- declare const BaseSelectMobile: React.ForwardRefExoticComponent<Omit<BaseSelectProps, "onScroll" | "Checkmark"> & {
40
- /**
41
- * Футер
42
- * @deprecated Используйте bottomSheetProps.actionButton
43
- */
44
- footer?: ReactNode;
45
- /**
46
- * Будет ли свайпаться шторка
47
- * @deprecated Используйте bottomSheetProps.swipeable
48
- */
49
- swipeable?: boolean | undefined;
50
- /**
51
- * Отображать в BottomSheet
52
- */
53
- isBottomSheet?: boolean | undefined;
54
- /**
55
- * Дополнительные пропсы шторки
56
- */
57
- bottomSheetProps?: Partial<BottomSheetProps> | undefined;
58
- /**
59
- * Дополнительные пропсы модалки
60
- */
61
- modalProps?: Partial<import("@alfalab/core-components-modal/mobile").ModalMobileProps & React.RefAttributes<HTMLDivElement>> | undefined;
62
- /**
63
- * Дополнительные пропсы шапки модалки
64
- */
65
- modalHeaderProps?: Partial<import("../../Component.modal.mobile").HeaderProps> | undefined;
66
- /**
67
- * Дополнительные пропсы футера модалки
68
- */
69
- modalFooterProps?: Partial<import("../../Component.modal.mobile").FooterProps> | undefined;
70
- } & React.RefAttributes<unknown>>;
71
- export { SelectMobileProps, BaseSelectMobile };