@alfalab/core-components-select 17.21.2 → 17.21.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 (244) hide show
  1. package/components/arrow/Component.js +1 -1
  2. package/components/arrow/index.css +5 -5
  3. package/components/base-checkmark/Component.js +1 -1
  4. package/components/base-checkmark/index.css +6 -6
  5. package/components/base-option/Component.js +4 -3
  6. package/components/base-option/index.css +20 -15
  7. package/components/base-select/Component.js +4 -3
  8. package/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
  9. package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
  10. package/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
  11. package/components/base-select/index.css +17 -12
  12. package/components/base-select/mobile.css +12 -12
  13. package/components/checkmark/Component.js +1 -1
  14. package/components/checkmark/index.css +10 -10
  15. package/components/checkmark-mobile/Component.js +1 -1
  16. package/components/checkmark-mobile/index.css +6 -6
  17. package/components/clear-button/Component.js +1 -1
  18. package/components/clear-button/index.css +5 -5
  19. package/components/field/Component.js +1 -1
  20. package/components/field/index.css +14 -14
  21. package/components/footer/Component.js +1 -1
  22. package/components/footer/index.css +5 -5
  23. package/components/optgroup/Component.js +1 -1
  24. package/components/optgroup/index.css +5 -6
  25. package/components/option/desktop/Component.js +1 -1
  26. package/components/option/desktop/index.css +21 -22
  27. package/components/option/mobile/Component.js +1 -1
  28. package/components/option/mobile/index.css +18 -19
  29. package/components/options-list/Component.js +12 -5
  30. package/components/options-list/index.css +10 -11
  31. package/components/search/Component.js +1 -1
  32. package/components/search/index.css +2 -2
  33. package/components/virtual-options-list/Component.js +1 -1
  34. package/components/virtual-options-list/index.css +14 -15
  35. package/cssm/components/base-option/Component.js +3 -2
  36. package/cssm/components/base-option/index.module.css +7 -2
  37. package/cssm/components/base-select/Component.js +2 -1
  38. package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +1 -1
  39. package/cssm/components/base-select/index.module.css +7 -2
  40. package/cssm/components/optgroup/index.module.css +1 -2
  41. package/cssm/components/option/desktop/index.module.css +2 -3
  42. package/cssm/components/option/index.module.css +2 -3
  43. package/cssm/components/option/mobile/index.module.css +2 -3
  44. package/cssm/components/options-list/Component.js +11 -4
  45. package/cssm/components/options-list/index.module.css +1 -2
  46. package/cssm/components/virtual-options-list/index.module.css +1 -2
  47. package/{hook-5412b662.js → cssm/hook-7f1b6f47.js} +3 -3
  48. package/cssm/mobile/Component.mobile.js +1 -1
  49. package/cssm/presets/index.js +1 -1
  50. package/cssm/presets/useSelectWithApply/hook.js +1 -1
  51. package/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  52. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
  53. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -2
  54. package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +6 -2
  55. package/cssm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
  56. package/cssm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +6 -2
  57. package/cssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +7 -3
  58. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  59. package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  60. package/cssm/shared/index.js +1 -1
  61. package/cssm/utils.d.ts +1 -1
  62. package/cssm/utils.js +12 -24
  63. package/esm/components/arrow/Component.js +1 -1
  64. package/esm/components/arrow/index.css +5 -5
  65. package/esm/components/base-checkmark/Component.js +1 -1
  66. package/esm/components/base-checkmark/index.css +6 -6
  67. package/esm/components/base-option/Component.js +4 -3
  68. package/esm/components/base-option/index.css +20 -15
  69. package/esm/components/base-select/Component.js +4 -3
  70. package/esm/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
  71. package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
  72. package/esm/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
  73. package/esm/components/base-select/index.css +17 -12
  74. package/esm/components/base-select/mobile.css +12 -12
  75. package/esm/components/checkmark/Component.js +1 -1
  76. package/esm/components/checkmark/index.css +10 -10
  77. package/esm/components/checkmark-mobile/Component.js +1 -1
  78. package/esm/components/checkmark-mobile/index.css +6 -6
  79. package/esm/components/clear-button/Component.js +1 -1
  80. package/esm/components/clear-button/index.css +5 -5
  81. package/esm/components/field/Component.js +1 -1
  82. package/esm/components/field/index.css +14 -14
  83. package/esm/components/footer/Component.js +1 -1
  84. package/esm/components/footer/index.css +5 -5
  85. package/esm/components/optgroup/Component.js +1 -1
  86. package/esm/components/optgroup/index.css +5 -6
  87. package/esm/components/option/desktop/Component.js +1 -1
  88. package/esm/components/option/desktop/index.css +21 -22
  89. package/esm/components/option/mobile/Component.js +1 -1
  90. package/esm/components/option/mobile/index.css +18 -19
  91. package/esm/components/options-list/Component.js +12 -5
  92. package/esm/components/options-list/index.css +10 -11
  93. package/esm/components/search/Component.js +1 -1
  94. package/esm/components/search/index.css +2 -2
  95. package/esm/components/virtual-options-list/Component.js +1 -1
  96. package/esm/components/virtual-options-list/index.css +14 -15
  97. package/esm/{hook-e9905b00.js → hook-56374bc2.js} +3 -3
  98. package/esm/{list-popover-desktop-d8567402.js → list-popover-desktop-d897cee0.js} +1 -1
  99. package/esm/mobile/Component.mobile.js +1 -1
  100. package/esm/mobile.module-ebe00eaa.js +4 -0
  101. package/esm/presets/index.js +1 -1
  102. package/esm/presets/useSelectWithApply/hook.js +1 -1
  103. package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  104. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
  105. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -3
  106. package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
  107. package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
  108. package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +7 -3
  109. package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
  110. package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  111. package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  112. package/esm/presets/useSelectWithLoading/hook.js +1 -1
  113. package/esm/presets/useSelectWithLoading/index.css +2 -2
  114. package/esm/shared/index.js +1 -1
  115. package/esm/utils.d.ts +1 -1
  116. package/esm/utils.js +12 -24
  117. package/{cssm/hook-42ec365f.js → hook-7eb4a9bb.js} +3 -3
  118. package/{list-popover-desktop-d6bb8493.js → list-popover-desktop-b51713d2.js} +1 -1
  119. package/mobile/Component.mobile.js +1 -1
  120. package/mobile.module-a01cc277.js +6 -0
  121. package/modern/components/arrow/Component.js +1 -1
  122. package/modern/components/arrow/index.css +5 -5
  123. package/modern/components/base-checkmark/Component.js +1 -1
  124. package/modern/components/base-checkmark/index.css +6 -6
  125. package/modern/components/base-option/Component.js +4 -3
  126. package/modern/components/base-option/index.css +20 -15
  127. package/modern/components/base-select/Component.js +4 -3
  128. package/modern/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
  129. package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
  130. package/modern/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
  131. package/modern/components/base-select/index.css +17 -12
  132. package/modern/components/base-select/mobile.css +12 -12
  133. package/modern/components/checkmark/Component.js +1 -1
  134. package/modern/components/checkmark/index.css +10 -10
  135. package/modern/components/checkmark-mobile/Component.js +1 -1
  136. package/modern/components/checkmark-mobile/index.css +6 -6
  137. package/modern/components/clear-button/Component.js +1 -1
  138. package/modern/components/clear-button/index.css +5 -5
  139. package/modern/components/field/Component.js +1 -1
  140. package/modern/components/field/index.css +14 -14
  141. package/modern/components/footer/Component.js +1 -1
  142. package/modern/components/footer/index.css +5 -5
  143. package/modern/components/optgroup/Component.js +1 -1
  144. package/modern/components/optgroup/index.css +5 -6
  145. package/modern/components/option/desktop/Component.js +1 -1
  146. package/modern/components/option/desktop/index.css +21 -22
  147. package/modern/components/option/mobile/Component.js +1 -1
  148. package/modern/components/option/mobile/index.css +18 -19
  149. package/modern/components/options-list/Component.js +4 -5
  150. package/modern/components/options-list/index.css +10 -11
  151. package/modern/components/search/Component.js +1 -1
  152. package/modern/components/search/index.css +2 -2
  153. package/modern/components/virtual-options-list/Component.js +1 -1
  154. package/modern/components/virtual-options-list/index.css +14 -15
  155. package/{moderncssm/hook-54090d24.js → modern/hook-2f7a71de.js} +3 -3
  156. package/modern/{list-popover-desktop-92897a4e.js → list-popover-desktop-6e43d72c.js} +1 -1
  157. package/modern/mobile/Component.mobile.js +1 -1
  158. package/modern/mobile.module-208550e0.js +4 -0
  159. package/modern/presets/index.js +1 -1
  160. package/modern/presets/useSelectWithApply/hook.js +1 -1
  161. package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  162. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
  163. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -3
  164. package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
  165. package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
  166. package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +6 -2
  167. package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
  168. package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  169. package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  170. package/modern/presets/useSelectWithLoading/hook.js +1 -1
  171. package/modern/presets/useSelectWithLoading/index.css +2 -2
  172. package/modern/shared/index.js +1 -1
  173. package/modern/utils.d.ts +1 -1
  174. package/modern/utils.js +10 -22
  175. package/moderncssm/components/base-option/Component.js +3 -2
  176. package/moderncssm/components/base-option/index.module.css +7 -0
  177. package/moderncssm/components/base-select/Component.js +2 -1
  178. package/moderncssm/components/base-select/index.module.css +4 -0
  179. package/moderncssm/components/optgroup/index.module.css +0 -1
  180. package/moderncssm/components/option/desktop/index.module.css +1 -2
  181. package/moderncssm/components/option/index.module.css +1 -2
  182. package/moderncssm/components/option/mobile/index.module.css +1 -2
  183. package/moderncssm/components/options-list/Component.js +3 -4
  184. package/moderncssm/components/options-list/index.module.css +0 -1
  185. package/moderncssm/components/virtual-options-list/index.module.css +0 -1
  186. package/{modern/hook-433ed72d.js → moderncssm/hook-4849257f.js} +3 -3
  187. package/moderncssm/mobile/Component.mobile.js +1 -1
  188. package/moderncssm/presets/index.js +1 -1
  189. package/moderncssm/presets/useSelectWithApply/hook.js +1 -1
  190. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  191. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
  192. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +4 -2
  193. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +3 -0
  194. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
  195. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +5 -1
  196. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +5 -1
  197. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  198. package/moderncssm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  199. package/moderncssm/shared/index.js +1 -1
  200. package/moderncssm/utils.d.ts +1 -1
  201. package/moderncssm/utils.js +10 -22
  202. package/package.json +13 -13
  203. package/presets/index.js +1 -1
  204. package/presets/useSelectWithApply/hook.js +1 -1
  205. package/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
  206. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
  207. package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +6 -3
  208. package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
  209. package/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
  210. package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +7 -3
  211. package/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
  212. package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
  213. package/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
  214. package/presets/useSelectWithLoading/hook.js +1 -1
  215. package/presets/useSelectWithLoading/index.css +2 -2
  216. package/shared/index.js +1 -1
  217. package/src/components/base-option/Component.tsx +3 -1
  218. package/src/components/base-option/index.module.css +9 -0
  219. package/src/components/base-select/Component.tsx +9 -4
  220. package/src/components/base-select/index.module.css +5 -0
  221. package/src/components/optgroup/index.module.css +0 -1
  222. package/src/components/option/index.module.css +0 -1
  223. package/src/components/options-list/Component.tsx +3 -2
  224. package/src/components/options-list/index.module.css +0 -1
  225. package/src/components/virtual-options-list/index.module.css +0 -1
  226. package/src/presets/useSelectWithApply/options-list-with-apply/Component.tsx +4 -1
  227. package/src/presets/useSelectWithApply/options-list-with-apply/footer/Component.tsx +6 -2
  228. package/src/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +4 -0
  229. package/src/presets/useSelectWithApply/options-list-with-apply/header/Component.tsx +11 -1
  230. package/src/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +3 -0
  231. package/src/utils.ts +9 -24
  232. package/utils.d.ts +1 -1
  233. package/utils.js +12 -24
  234. package/esm/mobile.module-17a9a022.js +0 -4
  235. package/mobile.module-abcf78b8.js +0 -6
  236. package/modern/mobile.module-dae5cd65.js +0 -4
  237. /package/cssm/{hook-42ec365f.d.ts → hook-7f1b6f47.d.ts} +0 -0
  238. /package/esm/{hook-e9905b00.d.ts → hook-56374bc2.d.ts} +0 -0
  239. /package/esm/{list-popover-desktop-d8567402.d.ts → list-popover-desktop-d897cee0.d.ts} +0 -0
  240. /package/{hook-5412b662.d.ts → hook-7eb4a9bb.d.ts} +0 -0
  241. /package/{list-popover-desktop-d6bb8493.d.ts → list-popover-desktop-b51713d2.d.ts} +0 -0
  242. /package/modern/{hook-433ed72d.d.ts → hook-2f7a71de.d.ts} +0 -0
  243. /package/modern/{list-popover-desktop-92897a4e.d.ts → list-popover-desktop-6e43d72c.d.ts} +0 -0
  244. /package/moderncssm/{hook-54090d24.d.ts → hook-4849257f.d.ts} +0 -0
@@ -30,6 +30,10 @@
30
30
  &.checkmarkAfter.checkmarkAfter {
31
31
  padding: var(--gap-0) var(--gap-12) var(--gap-0) var(--gap-0);
32
32
 
33
+ &.size-72 {
34
+ padding-right: var(--gap-16);
35
+ }
36
+
33
37
  &.mobile {
34
38
  padding-right: var(--gap-20);
35
39
  }
@@ -38,6 +42,11 @@
38
42
  &.textContent {
39
43
  padding: var(--gap-12);
40
44
 
45
+ &.size-72 {
46
+ padding-left: var(--gap-16);
47
+ padding-right: var(--gap-16);
48
+ }
49
+
41
50
  &.mobile {
42
51
  padding: var(--gap-16) var(--gap-20) var(--gap-16) var(--gap-16);
43
52
  }
@@ -24,6 +24,7 @@ import {
24
24
  import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
25
25
  import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
26
26
 
27
+ import { SIZE_TO_CLASSNAME_MAP } from '../../consts';
27
28
  import type { AnyObject, OptionShape, OptionsListProps, SearchProps } from '../../typings';
28
29
  import {
29
30
  defaultAccessor,
@@ -565,10 +566,14 @@ export const BaseSelect = forwardRef<unknown, ComponentProps>(
565
566
  onChange={handleChange}
566
567
  dataTestId={getDataTestId(dataTestId, 'search')}
567
568
  onClear={handleClear}
568
- className={cn(searchProps?.componentProps?.className, {
569
- [styles.search]: view === 'desktop',
570
- [mobileStyles.search]: view === 'mobile',
571
- })}
569
+ className={cn(
570
+ searchProps?.componentProps?.className,
571
+ {
572
+ [styles.search]: view === 'desktop',
573
+ [mobileStyles.search]: view === 'mobile',
574
+ },
575
+ size && styles[SIZE_TO_CLASSNAME_MAP[size]],
576
+ )}
572
577
  ref={mergeRefs([searchRef, searchProps?.componentProps?.ref || null])}
573
578
  />
574
579
  );
@@ -69,6 +69,11 @@
69
69
  .search {
70
70
  margin: var(--gap-12) var(--gap-12) var(--gap-0);
71
71
 
72
+ &.size-72 {
73
+ margin-left: var(--gap-16);
74
+ margin-right: var(--gap-16);
75
+ }
76
+
72
77
  &:last-child {
73
78
  margin-bottom: var(--gap-12);
74
79
  }
@@ -23,7 +23,6 @@
23
23
  color: var(--select-optgroup-color);
24
24
  }
25
25
 
26
- .size-64,
27
26
  .size-72 {
28
27
  padding-left: var(--select-optgroup-l-left-padding);
29
28
  padding-right: var(--select-optgroup-l-right-padding);
@@ -53,7 +53,6 @@
53
53
  min-height: var(--size-xl-height);
54
54
  }
55
55
 
56
- .size-64,
57
56
  .size-72 {
58
57
  padding-left: var(--select-option-l-left-padding);
59
58
  padding-right: var(--select-option-l-right-padding);
@@ -120,8 +120,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
120
120
 
121
121
  const actualOptionsCount = limitDynamicOptionGroupSize && options.length > 0;
122
122
 
123
- const measured = useVisibleOptions({
124
- ...(!nativeScrollbar && { styleTargetRef: scrollbarRef }),
123
+ const [measured, height] = useVisibleOptions({
125
124
  visibleOptions,
126
125
  listRef,
127
126
  open,
@@ -168,6 +167,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
168
167
  <Scrollbar
169
168
  className={cn(styles.scrollable, scrollbarClassName)}
170
169
  ref={scrollbarRef}
170
+ style={{ height }}
171
171
  horizontalAutoStretch={optionsListWidth === 'content'}
172
172
  scrollableNodeProps={scrollableNodeProps}
173
173
  contentNodeProps={{ ref: listRef }}
@@ -191,6 +191,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
191
191
  className={cn(styles.scrollable, scrollbarClassName)}
192
192
  ref={mergeRefs([listRef, ref])}
193
193
  onScroll={handleScroll}
194
+ style={{ height }}
194
195
  >
195
196
  {renderListItems()}
196
197
  </div>
@@ -44,7 +44,6 @@
44
44
  color: var(--select-options-list-empty-placeholder-color);
45
45
  }
46
46
 
47
- .size-64 .emptyPlaceholder,
48
47
  .size-72 .emptyPlaceholder {
49
48
  padding: var(--gap-24) var(--gap-16);
50
49
  }
@@ -72,7 +72,6 @@
72
72
  flex: 1;
73
73
  }
74
74
 
75
- .size-64 .emptyPlaceholder,
76
75
  .size-72 .emptyPlaceholder {
77
76
  padding: var(--gap-24) var(--gap-16);
78
77
  }
@@ -39,6 +39,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
39
39
  header,
40
40
  headerProps,
41
41
  setSelectedDraft,
42
+ size,
42
43
  ...restProps
43
44
  }: OptionsListWithApplyProps,
44
45
  ref,
@@ -98,7 +99,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
98
99
  <React.Fragment>
99
100
  {header}
100
101
  {showHeaderWithSelectAll && flatOptions.length > 0 && (
101
- <Header {...headerProps} />
102
+ <Header {...headerProps} size={size} />
102
103
  )}
103
104
  </React.Fragment>
104
105
  );
@@ -107,6 +108,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
107
108
  return (
108
109
  <OptionsList
109
110
  {...restProps}
111
+ size={size}
110
112
  ref={ref}
111
113
  visibleOptions={visibleOptions}
112
114
  toggleMenu={toggleMenu}
@@ -124,6 +126,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
124
126
  showClear={showClear}
125
127
  selectedDraft={selectedDraft}
126
128
  dataTestId={restProps?.dataTestId}
129
+ size={size}
127
130
  />
128
131
  }
129
132
  />
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
+ import cn from 'classnames';
2
3
 
3
4
  import { ButtonDesktop } from '@alfalab/core-components-button/desktop';
4
5
  import { getDataTestId } from '@alfalab/core-components-shared';
5
6
 
6
- import { OptionShape } from '../../../../typings';
7
+ import { SIZE_TO_CLASSNAME_MAP } from '../../../../consts';
8
+ import { OptionShape, OptionsListProps } from '../../../../typings';
7
9
 
8
10
  import styles from './index.module.css';
9
11
 
@@ -13,6 +15,7 @@ export type FooterProps = {
13
15
  showClear?: boolean;
14
16
  selectedDraft?: OptionShape[];
15
17
  dataTestId?: string;
18
+ size?: OptionsListProps['size'];
16
19
  };
17
20
 
18
21
  export const Footer = ({
@@ -21,11 +24,12 @@ export const Footer = ({
21
24
  showClear,
22
25
  selectedDraft = [],
23
26
  dataTestId,
27
+ size,
24
28
  }: FooterProps) => (
25
29
  <div
26
30
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
27
31
  tabIndex={0}
28
- className={styles.footer}
32
+ className={cn(styles.footer, size && styles[SIZE_TO_CLASSNAME_MAP[size]])}
29
33
  >
30
34
  <ButtonDesktop
31
35
  size={32}
@@ -6,6 +6,10 @@
6
6
  padding: var(--gap-12);
7
7
  outline: none;
8
8
 
9
+ &.size-72 {
10
+ padding: var(--gap-12) var(--gap-16);
11
+ }
12
+
9
13
  & > .button + .button {
10
14
  margin-left: var(--select-option-list-footer-button-gap);
11
15
  }
@@ -3,6 +3,9 @@ import cn from 'classnames';
3
3
 
4
4
  import { Checkbox, CheckboxProps } from '@alfalab/core-components-checkbox';
5
5
 
6
+ import { SIZE_TO_CLASSNAME_MAP } from '../../../../consts';
7
+ import { OptionsListProps } from '../../../../typings';
8
+
6
9
  import styles from './index.module.css';
7
10
 
8
11
  export type HeaderProps = {
@@ -11,6 +14,7 @@ export type HeaderProps = {
11
14
  onChange?: CheckboxProps['onChange'];
12
15
  mobile?: boolean;
13
16
  dataTestId?: string;
17
+ size?: OptionsListProps['size'];
14
18
  };
15
19
 
16
20
  export const Header: React.FC<HeaderProps> = ({
@@ -19,8 +23,14 @@ export const Header: React.FC<HeaderProps> = ({
19
23
  indeterminate,
20
24
  mobile,
21
25
  dataTestId,
26
+ size,
22
27
  }) => (
23
- <div className={cn({ [styles.desktop]: !mobile, [styles.mobile]: mobile })}>
28
+ <div
29
+ className={cn(size && styles[SIZE_TO_CLASSNAME_MAP[size]], {
30
+ [styles.desktop]: !mobile,
31
+ [styles.mobile]: mobile,
32
+ })}
33
+ >
24
34
  <Checkbox
25
35
  block={true}
26
36
  indeterminate={indeterminate}
@@ -2,6 +2,9 @@
2
2
 
3
3
  .desktop {
4
4
  padding: var(--gap-12);
5
+ &.size-72 {
6
+ padding-left: var(--gap-16);
7
+ }
5
8
  }
6
9
 
7
10
  .mobile {
package/src/utils.ts CHANGED
@@ -231,24 +231,22 @@ export function useVirtualVisibleOptions({
231
231
  export function useVisibleOptions({
232
232
  visibleOptions,
233
233
  listRef,
234
- styleTargetRef = listRef,
235
234
  open,
236
- invalidate,
237
235
  options,
238
236
  size,
239
237
  actualOptionsCount,
240
238
  }: useVisibleOptionsArgs) {
241
239
  const [, runIfMounted] = useIsMounted();
242
240
  const [measured, setMeasured] = useState(false);
241
+ const [height, setHeight] = useState<number | undefined>();
243
242
 
244
243
  useEffect(() => {
245
244
  const measureOptionHeight = (element: HTMLElement) =>
246
245
  typeof size === 'number' ? Math.min(element.clientHeight, size) : element.clientHeight;
247
246
 
248
247
  const list = listRef.current;
249
- const styleTarget = styleTargetRef.current;
250
248
 
251
- if (open && list && styleTarget && visibleOptions > 0) {
249
+ if (open && list && visibleOptions > 0) {
252
250
  const childCount = list.children.length;
253
251
  const optionsNodes = ([] as HTMLElement[]).slice.call(
254
252
  list.children,
@@ -256,7 +254,7 @@ export function useVisibleOptions({
256
254
  visibleOptions + 1,
257
255
  );
258
256
 
259
- let height = optionsNodes
257
+ let measuredHeight = optionsNodes
260
258
  .slice(0, visibleOptions)
261
259
  .reduce((acc, child) => acc + measureOptionHeight(child), 0);
262
260
 
@@ -266,7 +264,7 @@ export function useVisibleOptions({
266
264
  );
267
265
 
268
266
  // Если кол-во опций больше visibleOptions на 1, то показываем все опции, иначе добавляем половинку
269
- height += Math.round(
267
+ measuredHeight += Math.round(
270
268
  childCount - visibleOptions === 1
271
269
  ? lastVisibleOptionHeight
272
270
  : lastVisibleOptionHeight / 2,
@@ -281,43 +279,30 @@ export function useVisibleOptions({
281
279
  0,
282
280
  );
283
281
 
284
- height =
282
+ measuredHeight =
285
283
  Math.min(
286
284
  actualCount === 0 ? /** empty placeholder */ 1 : actualCount,
287
285
  visibleOptions,
288
286
  ) * size;
289
287
 
290
288
  if (visibleOptions < actualCount) {
291
- height += size / 2;
289
+ measuredHeight += size / 2;
292
290
  }
293
291
  }
294
292
 
295
- const prevHeight = styleTarget.style.height;
296
-
297
- styleTarget.style.height = `${height}px`;
293
+ setHeight(measuredHeight);
298
294
 
299
295
  setMeasured(true);
300
296
 
301
297
  return () => {
302
- styleTarget.style.height = prevHeight;
303
298
  runIfMounted(() => setMeasured(false));
304
299
  };
305
300
  }
306
301
 
307
302
  return fnUtils.noop;
308
- }, [
309
- actualOptionsCount,
310
- listRef,
311
- open,
312
- options,
313
- size,
314
- styleTargetRef,
315
- visibleOptions,
316
- invalidate,
317
- runIfMounted,
318
- ]);
303
+ }, [actualOptionsCount, listRef, open, options, size, visibleOptions, runIfMounted]);
319
304
 
320
- return measured;
305
+ return [measured, height] as const;
321
306
  }
322
307
 
323
308
  export function defaultFilterFn(optionText: string, search: string) {
package/utils.d.ts CHANGED
@@ -46,7 +46,7 @@ type useVisibleOptionsArgs = {
46
46
  actualOptionsCount?: boolean;
47
47
  };
48
48
  declare function useVirtualVisibleOptions({ visibleOptions, listRef, styleTargetRef, open, invalidate, options, size, actualOptionsCount, }: useVisibleOptionsArgs): void;
49
- declare function useVisibleOptions({ visibleOptions, listRef, styleTargetRef, open, invalidate, options, size, actualOptionsCount, }: useVisibleOptionsArgs): boolean;
49
+ declare function useVisibleOptions({ visibleOptions, listRef, open, options, size, actualOptionsCount, }: useVisibleOptionsArgs): readonly [boolean, number | undefined];
50
50
  declare function defaultFilterFn(optionText: string, search: string): boolean;
51
51
  declare function defaultGroupAccessor(option: GroupShape): string | undefined;
52
52
  declare function defaultAccessor(option: OptionShape): string;
package/utils.js CHANGED
@@ -124,25 +124,25 @@ function useVirtualVisibleOptions(_a) {
124
124
  ]);
125
125
  }
126
126
  function useVisibleOptions(_a) {
127
- var visibleOptions = _a.visibleOptions, listRef = _a.listRef, _b = _a.styleTargetRef, styleTargetRef = _b === void 0 ? listRef : _b, open = _a.open, invalidate = _a.invalidate, options = _a.options, size = _a.size, actualOptionsCount = _a.actualOptionsCount;
128
- var _c = coreComponentsShared.useIsMounted(), runIfMounted = _c[1];
129
- var _d = React.useState(false), measured = _d[0], setMeasured = _d[1];
127
+ var visibleOptions = _a.visibleOptions, listRef = _a.listRef, open = _a.open, options = _a.options, size = _a.size, actualOptionsCount = _a.actualOptionsCount;
128
+ var _b = coreComponentsShared.useIsMounted(), runIfMounted = _b[1];
129
+ var _c = React.useState(false), measured = _c[0], setMeasured = _c[1];
130
+ var _d = React.useState(), height = _d[0], setHeight = _d[1];
130
131
  React.useEffect(function () {
131
132
  var measureOptionHeight = function (element) {
132
133
  return typeof size === 'number' ? Math.min(element.clientHeight, size) : element.clientHeight;
133
134
  };
134
135
  var list = listRef.current;
135
- var styleTarget = styleTargetRef.current;
136
- if (open && list && styleTarget && visibleOptions > 0) {
136
+ if (open && list && visibleOptions > 0) {
137
137
  var childCount = list.children.length;
138
138
  var optionsNodes = [].slice.call(list.children, 0, visibleOptions + 1);
139
- var height = optionsNodes
139
+ var measuredHeight = optionsNodes
140
140
  .slice(0, visibleOptions)
141
141
  .reduce(function (acc, child) { return acc + measureOptionHeight(child); }, 0);
142
142
  if (visibleOptions < childCount) {
143
143
  var lastVisibleOptionHeight = measureOptionHeight(optionsNodes[optionsNodes.length - 1]);
144
144
  // Если кол-во опций больше visibleOptions на 1, то показываем все опции, иначе добавляем половинку
145
- height += Math.round(childCount - visibleOptions === 1
145
+ measuredHeight += Math.round(childCount - visibleOptions === 1
146
146
  ? lastVisibleOptionHeight
147
147
  : lastVisibleOptionHeight / 2);
148
148
  }
@@ -150,33 +150,21 @@ function useVisibleOptions(_a) {
150
150
  actualOptionsCount &&
151
151
  typeof size === 'number') {
152
152
  var actualCount = (options !== null && options !== void 0 ? options : []).reduce(function (sum, option) { return sum + 1 + (isGroup(option) ? option.options.length : 0); }, 0);
153
- height =
153
+ measuredHeight =
154
154
  Math.min(actualCount === 0 ? /** empty placeholder */ 1 : actualCount, visibleOptions) * size;
155
155
  if (visibleOptions < actualCount) {
156
- height += size / 2;
156
+ measuredHeight += size / 2;
157
157
  }
158
158
  }
159
- var prevHeight_1 = styleTarget.style.height;
160
- styleTarget.style.height = "".concat(height, "px");
159
+ setHeight(measuredHeight);
161
160
  setMeasured(true);
162
161
  return function () {
163
- styleTarget.style.height = prevHeight_1;
164
162
  runIfMounted(function () { return setMeasured(false); });
165
163
  };
166
164
  }
167
165
  return coreComponentsShared.fnUtils.noop;
168
- }, [
169
- actualOptionsCount,
170
- listRef,
171
- open,
172
- options,
173
- size,
174
- styleTargetRef,
175
- visibleOptions,
176
- invalidate,
177
- runIfMounted,
178
- ]);
179
- return measured;
166
+ }, [actualOptionsCount, listRef, open, options, size, visibleOptions, runIfMounted]);
167
+ return [measured, height];
180
168
  }
181
169
  function defaultFilterFn(optionText, search) {
182
170
  if (!search)
@@ -1,4 +0,0 @@
1
- var mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
2
- require('./components/base-select/mobile.css')
3
-
4
- export { mobileStyles as m };
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
4
- require('./components/base-select/mobile.css')
5
-
6
- exports.mobileStyles = mobileStyles;
@@ -1,4 +0,0 @@
1
- const mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
2
- require('./components/base-select/mobile.css')
3
-
4
- export { mobileStyles as m };
File without changes
File without changes
File without changes