@alfalab/core-components-select 10.3.0 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/Component.d.ts +1 -1
- package/dist/Component.js +1 -1
- package/dist/components/arrow/Component.js +1 -1
- package/dist/components/arrow/index.css +3 -3
- package/dist/components/base-select/Component.js +23 -22
- package/dist/components/base-select/index.css +7 -7
- package/dist/components/base-select/index.js +1 -1
- package/dist/components/checkmark/Component.js +2 -2
- package/dist/components/checkmark/index.css +7 -7
- package/dist/components/field/Component.d.ts +1 -1
- package/dist/components/field/Component.js +3 -3
- package/dist/components/field/index.css +9 -9
- package/dist/components/field/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/native-select/Component.js +1 -1
- package/dist/components/native-select/index.js +1 -1
- package/dist/components/optgroup/Component.js +1 -1
- package/dist/components/optgroup/index.css +6 -6
- package/dist/components/option/Component.js +2 -2
- package/dist/components/option/index.css +20 -20
- package/dist/components/option/index.js +1 -1
- package/dist/components/options-list/Component.js +13 -8
- package/dist/components/options-list/index.css +9 -5
- package/dist/components/options-list/index.js +1 -0
- package/dist/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/components/virtual-options-list/Component.js +22 -18
- package/dist/components/virtual-options-list/index.css +15 -12
- package/dist/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/Component.d.ts +1 -1
- package/dist/cssm/components/base-select/Component.js +21 -20
- package/dist/cssm/components/checkmark/Component.js +1 -1
- package/dist/cssm/components/field/Component.d.ts +1 -1
- package/dist/cssm/components/field/Component.js +1 -1
- package/dist/cssm/components/options-list/Component.js +12 -7
- package/dist/cssm/components/options-list/index.js +1 -0
- package/dist/cssm/components/options-list/index.module.css +4 -0
- package/dist/cssm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/cssm/components/virtual-options-list/Component.js +21 -17
- package/dist/cssm/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/components/virtual-options-list/index.module.css +4 -1
- package/dist/cssm/hook-45e5f3a8.d.ts +12 -0
- package/dist/cssm/hook-45e5f3a8.js +147 -0
- package/dist/cssm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/cssm/index.js +7 -1
- package/dist/cssm/intersection-observer-8c55e13a.d.ts +1 -0
- package/dist/cssm/intersection-observer-8c55e13a.js +893 -0
- package/dist/cssm/presets/index.d.ts +1 -0
- package/dist/cssm/presets/index.js +29 -1
- package/dist/cssm/presets/useLazyLoading/hook.js +1 -892
- package/dist/cssm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/hook.js +46 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.module.css +38 -0
- package/dist/cssm/typings.d.ts +39 -6
- package/dist/esm/Component.d.ts +1 -1
- package/dist/esm/Component.js +1 -1
- package/dist/esm/components/arrow/Component.js +1 -1
- package/dist/esm/components/arrow/index.css +3 -3
- package/dist/esm/components/base-select/Component.js +23 -22
- package/dist/esm/components/base-select/index.css +7 -7
- package/dist/esm/components/base-select/index.js +1 -1
- package/dist/esm/components/checkmark/Component.js +2 -2
- package/dist/esm/components/checkmark/index.css +7 -7
- package/dist/esm/components/field/Component.d.ts +1 -1
- package/dist/esm/components/field/Component.js +3 -3
- package/dist/esm/components/field/index.css +9 -9
- package/dist/esm/components/field/index.js +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/native-select/Component.js +1 -1
- package/dist/esm/components/native-select/index.js +1 -1
- package/dist/esm/components/optgroup/Component.js +1 -1
- package/dist/esm/components/optgroup/index.css +6 -6
- package/dist/esm/components/option/Component.js +2 -2
- package/dist/esm/components/option/index.css +20 -20
- package/dist/esm/components/option/index.js +1 -1
- package/dist/esm/components/options-list/Component.js +14 -9
- package/dist/esm/components/options-list/index.css +9 -5
- package/dist/esm/components/options-list/index.js +1 -0
- package/dist/esm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/esm/components/virtual-options-list/Component.js +22 -18
- package/dist/esm/components/virtual-options-list/index.css +15 -12
- package/dist/esm/components/virtual-options-list/index.js +1 -0
- package/dist/esm/hook-a01ac265.d.ts +12 -0
- package/dist/esm/hook-a01ac265.js +131 -0
- package/dist/esm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/intersection-observer-2080f60e.d.ts +1 -0
- package/dist/esm/intersection-observer-2080f60e.js +891 -0
- package/dist/esm/presets/index.d.ts +1 -0
- package/dist/esm/presets/index.js +20 -1
- package/dist/esm/presets/useLazyLoading/hook.js +3 -894
- package/dist/esm/presets/useLazyLoading/index.css +2 -2
- package/dist/esm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/hook.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.js +26 -0
- package/dist/esm/presets/useSelectWithLoading/hook.js +2 -2
- package/dist/esm/presets/useSelectWithLoading/index.css +2 -2
- package/dist/esm/{tslib.es6-5a8a0ede.d.ts → tslib.es6-11a0bbd3.d.ts} +0 -0
- package/dist/esm/{tslib.es6-5a8a0ede.js → tslib.es6-11a0bbd3.js} +0 -0
- package/dist/esm/typings.d.ts +39 -6
- package/dist/hook-4f9a90b8.d.ts +12 -0
- package/dist/hook-4f9a90b8.js +140 -0
- package/dist/hook-f5b8fe4f.d.ts +61 -0
- package/dist/index.js +6 -1
- package/dist/intersection-observer-c983b2d1.d.ts +1 -0
- package/dist/intersection-observer-c983b2d1.js +893 -0
- package/dist/modern/Component.d.ts +1 -1
- package/dist/modern/components/arrow/Component.js +1 -1
- package/dist/modern/components/arrow/index.css +3 -3
- package/dist/modern/components/base-select/Component.js +17 -14
- package/dist/modern/components/base-select/index.css +7 -7
- package/dist/modern/components/checkmark/Component.js +2 -2
- package/dist/modern/components/checkmark/index.css +7 -7
- package/dist/modern/components/field/Component.d.ts +1 -1
- package/dist/modern/components/field/Component.js +2 -2
- package/dist/modern/components/field/index.css +9 -9
- package/dist/modern/components/optgroup/Component.js +1 -1
- package/dist/modern/components/optgroup/index.css +6 -6
- package/dist/modern/components/option/Component.js +1 -1
- package/dist/modern/components/option/index.css +20 -20
- package/dist/modern/components/options-list/Component.js +11 -7
- package/dist/modern/components/options-list/index.css +9 -5
- package/dist/modern/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/modern/components/virtual-options-list/Component.js +20 -17
- package/dist/modern/components/virtual-options-list/index.css +15 -12
- package/dist/modern/hook-cdda7a62.d.ts +12 -0
- package/dist/modern/hook-cdda7a62.js +132 -0
- package/dist/modern/hook-f5b8fe4f.d.ts +61 -0
- package/dist/modern/index.js +3 -0
- package/dist/modern/intersection-observer-2080f60e.d.ts +1 -0
- package/dist/modern/intersection-observer-2080f60e.js +891 -0
- package/dist/modern/presets/index.d.ts +1 -0
- package/dist/modern/presets/index.js +19 -0
- package/dist/modern/presets/useLazyLoading/hook.js +2 -893
- package/dist/modern/presets/useLazyLoading/index.css +2 -2
- package/dist/modern/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/hook.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.js +25 -0
- package/dist/modern/presets/useSelectWithLoading/hook.js +1 -1
- package/dist/modern/presets/useSelectWithLoading/index.css +2 -2
- package/dist/modern/typings.d.ts +39 -6
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +22 -1
- package/dist/presets/useLazyLoading/hook.js +3 -894
- package/dist/presets/useLazyLoading/index.css +2 -2
- package/dist/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/presets/useSelectWithApply/hook.js +35 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.js +34 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.js +34 -0
- package/dist/presets/useSelectWithLoading/hook.js +2 -2
- package/dist/presets/useSelectWithLoading/index.css +2 -2
- package/dist/{tslib.es6-f6070e97.d.ts → tslib.es6-edfcd771.d.ts} +0 -0
- package/dist/{tslib.es6-f6070e97.js → tslib.es6-edfcd771.js} +0 -0
- package/dist/typings.d.ts +39 -6
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 19plr */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-border-link: #007aff;
|
|
4
4
|
--color-light-text-secondary: #546272;
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
|
|
27
27
|
/* optgroup */
|
|
28
28
|
}
|
|
29
|
-
.
|
|
29
|
+
.select__component_1m09f {
|
|
30
30
|
width: 100%;
|
|
31
31
|
outline: none;
|
|
32
32
|
}
|
|
33
|
-
.
|
|
33
|
+
.select__field_1m09f:not(.select__disabled_1m09f) {
|
|
34
34
|
cursor: pointer
|
|
35
35
|
}
|
|
36
|
-
.
|
|
36
|
+
.select__field_1m09f:not(.select__disabled_1m09f):hover .select__arrow_1m09f {
|
|
37
37
|
opacity: var(--select-arrow-hover-opacity);
|
|
38
38
|
}
|
|
39
|
-
.
|
|
39
|
+
.select__disabled_1m09f {
|
|
40
40
|
cursor: var(--disabled-cursor);
|
|
41
41
|
}
|
|
42
42
|
/* TODO: Заюзать переменные из инпута */
|
|
43
|
-
.
|
|
43
|
+
.select__placeholder_1m09f {
|
|
44
44
|
color: var(--color-light-text-secondary);
|
|
45
45
|
}
|
|
46
|
-
.
|
|
46
|
+
.select__contentWrapper_1m09f {
|
|
47
47
|
font-size: 16px;
|
|
48
48
|
line-height: 20px;
|
|
49
49
|
font-weight: 400;
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
overflow: hidden;
|
|
54
54
|
width: 100%;
|
|
55
55
|
}
|
|
56
|
-
.
|
|
56
|
+
.select__value_1m09f {
|
|
57
57
|
overflow: hidden;
|
|
58
58
|
text-overflow: ellipsis;
|
|
59
59
|
text-align: left;
|
|
60
60
|
}
|
|
61
|
-
.
|
|
61
|
+
.select__focusVisible_1m09f {
|
|
62
62
|
outline: 2px solid var(--focus-color);
|
|
63
63
|
outline-offset: 2px;
|
|
64
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
var styles = {"optgroup":"
|
|
4
|
+
var styles = {"optgroup":"select__optgroup_1p5d6","label":"select__label_1p5d6","l":"select__l_1p5d6","xl":"select__xl_1p5d6"};
|
|
5
5
|
require('./index.css')
|
|
6
6
|
|
|
7
7
|
var Optgroup = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: pa8y1 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
--color-light-text-secondary: #546272;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
--select-optgroup-l-left-padding: var(--gap-m);
|
|
34
34
|
--select-optgroup-l-right-padding: var(--gap-m);
|
|
35
35
|
}
|
|
36
|
-
.
|
|
36
|
+
.select__optgroup_1p5d6 {
|
|
37
37
|
position: relative;
|
|
38
38
|
display: flex;
|
|
39
39
|
align-items: center;
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
background: var(--select-optgroup-background);
|
|
44
44
|
min-height: 40px
|
|
45
45
|
}
|
|
46
|
-
.
|
|
46
|
+
.select__optgroup_1p5d6 + *[role='option']:before {
|
|
47
47
|
display: none;
|
|
48
48
|
}
|
|
49
|
-
.
|
|
49
|
+
.select__label_1p5d6 {
|
|
50
50
|
font-size: 12px;
|
|
51
51
|
line-height: 16px;
|
|
52
52
|
font-weight: 500;
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
display: block;
|
|
57
57
|
color: var(--select-optgroup-color);
|
|
58
58
|
}
|
|
59
|
-
.
|
|
60
|
-
.
|
|
59
|
+
.select__l_1p5d6,
|
|
60
|
+
.select__xl_1p5d6 {
|
|
61
61
|
padding-left: var(--select-optgroup-l-left-padding);
|
|
62
62
|
padding-right: var(--select-optgroup-l-right-padding);
|
|
63
63
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as __assign } from '../../tslib.es6-
|
|
1
|
+
import { a as __assign } from '../../tslib.es6-11a0bbd3.js';
|
|
2
2
|
import React, { isValidElement } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import '@alfalab/core-components-checkbox/dist/esm';
|
|
5
5
|
import { Checkmark } from '../checkmark/Component.js';
|
|
6
6
|
|
|
7
|
-
var styles = {"option":"
|
|
7
|
+
var styles = {"option":"select__option_1qa7d","disabled":"select__disabled_1qa7d","s":"select__s_1qa7d","m":"select__m_1qa7d","l":"select__l_1qa7d","xl":"select__xl_1qa7d","selected":"select__selected_1qa7d","highlighted":"select__highlighted_1qa7d","content":"select__content_1qa7d","textContent":"select__textContent_1qa7d"};
|
|
8
8
|
require('./index.css')
|
|
9
9
|
|
|
10
10
|
var Option = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: jfu8g */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
--color-light-bg-secondary: #f3f4f5;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
/* optgroup */
|
|
55
55
|
}
|
|
56
|
-
.
|
|
56
|
+
.select__option_1qa7d {
|
|
57
57
|
font-size: 16px;
|
|
58
58
|
line-height: 20px;
|
|
59
59
|
font-weight: 400;
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
position: relative;
|
|
70
70
|
cursor: pointer
|
|
71
71
|
}
|
|
72
|
-
.
|
|
72
|
+
.select__option_1qa7d:not(.select__disabled_1qa7d):active {
|
|
73
73
|
background: var(--select-option-active-background);
|
|
74
74
|
color: var(--select-option-active-color);
|
|
75
75
|
}
|
|
76
|
-
.
|
|
76
|
+
.select__option_1qa7d:before {
|
|
77
77
|
content: '';
|
|
78
78
|
position: absolute;
|
|
79
79
|
left: var(--select-option-left-padding);
|
|
@@ -84,60 +84,60 @@
|
|
|
84
84
|
display: var(--select-option-divider-display);
|
|
85
85
|
transition: opacity 0.2s ease;
|
|
86
86
|
}
|
|
87
|
-
.
|
|
87
|
+
.select__option_1qa7d:first-child:before {
|
|
88
88
|
display: none;
|
|
89
89
|
}
|
|
90
|
-
.
|
|
90
|
+
.select__s_1qa7d {
|
|
91
91
|
min-height: var(--size-s-height);
|
|
92
92
|
}
|
|
93
|
-
.
|
|
93
|
+
.select__m_1qa7d {
|
|
94
94
|
min-height: var(--size-m-height);
|
|
95
95
|
}
|
|
96
|
-
.
|
|
96
|
+
.select__l_1qa7d {
|
|
97
97
|
min-height: var(--size-l-height);
|
|
98
98
|
}
|
|
99
|
-
.
|
|
99
|
+
.select__xl_1qa7d {
|
|
100
100
|
min-height: var(--size-xl-height);
|
|
101
101
|
}
|
|
102
|
-
.
|
|
103
|
-
.
|
|
102
|
+
.select__l_1qa7d,
|
|
103
|
+
.select__xl_1qa7d {
|
|
104
104
|
padding-left: var(--select-option-l-left-padding);
|
|
105
105
|
padding-right: var(--select-option-l-right-padding)
|
|
106
106
|
}
|
|
107
|
-
.
|
|
107
|
+
.select__l_1qa7d:before, .select__xl_1qa7d:before {
|
|
108
108
|
left: var(--select-option-l-left-padding);
|
|
109
109
|
right: var(--select-option-l-right-padding);
|
|
110
110
|
}
|
|
111
|
-
.
|
|
111
|
+
.select__selected_1qa7d {
|
|
112
112
|
background: var(--select-option-selected-background);
|
|
113
113
|
color: var(--select-option-selected-color);
|
|
114
114
|
cursor: default;
|
|
115
115
|
}
|
|
116
|
-
.
|
|
116
|
+
.select__highlighted_1qa7d {
|
|
117
117
|
background: var(--select-option-hover-background);
|
|
118
118
|
color: var(--select-option-hover-color)
|
|
119
119
|
}
|
|
120
|
-
.
|
|
121
|
-
.
|
|
120
|
+
.select__highlighted_1qa7d:before,
|
|
121
|
+
.select__highlighted_1qa7d + .select__option_1qa7d:before {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
}
|
|
124
|
-
.
|
|
124
|
+
.select__disabled_1qa7d {
|
|
125
125
|
cursor: var(--disabled-cursor);
|
|
126
126
|
background: var(--select-option-disabled-background);
|
|
127
127
|
color: var(--select-option-disabled-color);
|
|
128
128
|
}
|
|
129
|
-
.
|
|
129
|
+
.select__content_1qa7d {
|
|
130
130
|
overflow: hidden;
|
|
131
131
|
text-overflow: ellipsis;
|
|
132
132
|
flex: 1;
|
|
133
133
|
}
|
|
134
|
-
.
|
|
134
|
+
.select__textContent_1qa7d {
|
|
135
135
|
padding-top: var(--gap-s);
|
|
136
136
|
padding-bottom: var(--gap-s);
|
|
137
137
|
}
|
|
138
138
|
/* IE min-height fix */
|
|
139
139
|
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
140
|
-
.
|
|
140
|
+
.select__option_1qa7d:after {
|
|
141
141
|
min-height: inherit;
|
|
142
142
|
font-size: 0;
|
|
143
143
|
content: '';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as __assign } from '../../tslib.es6-11a0bbd3.js';
|
|
2
|
+
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
2
3
|
import cn from 'classnames';
|
|
3
4
|
import { useVisibleOptions, isGroup } from '../../utils.js';
|
|
4
5
|
import mergeRefs from 'react-merge-refs';
|
|
5
6
|
import { Optgroup } from '../optgroup/Component.js';
|
|
6
7
|
|
|
7
|
-
var styles = {"optionsList":"
|
|
8
|
+
var styles = {"optionsList":"select__optionsList_6utg9","scrollable":"select__scrollable_6utg9","emptyPlaceholder":"select__emptyPlaceholder_6utg9","l":"select__l_6utg9","xl":"select__xl_6utg9"};
|
|
8
9
|
require('./index.css')
|
|
9
10
|
|
|
10
11
|
var createCounter = function () {
|
|
@@ -13,10 +14,11 @@ var createCounter = function () {
|
|
|
13
14
|
return function () { return count++; };
|
|
14
15
|
};
|
|
15
16
|
var OptionsList = forwardRef(function (_a, ref) {
|
|
16
|
-
var _b = _a.size, size = _b === void 0 ? 's' : _b, className = _a.className, Option = _a.Option, _c = _a.options, options = _c === void 0 ? [] : _c, _d = _a.Optgroup, Optgroup$1 = _d === void 0 ? Optgroup : _d, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _e = _a.visibleOptions, visibleOptions = _e === void 0 ? 5 : _e, onScroll = _a.onScroll, open = _a.open;
|
|
17
|
+
var _b = _a.size, size = _b === void 0 ? 's' : _b, className = _a.className, Option = _a.Option, getOptionProps = _a.getOptionProps, _c = _a.options, options = _c === void 0 ? [] : _c, _d = _a.Optgroup, Optgroup$1 = _d === void 0 ? Optgroup : _d, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _e = _a.visibleOptions, visibleOptions = _e === void 0 ? 5 : _e, onScroll = _a.onScroll, open = _a.open, header = _a.header, footer = _a.footer;
|
|
18
|
+
var renderOption = useCallback(function (option, index) { return (React.createElement(Option, __assign({ key: option.key }, getOptionProps(option, index)))); }, [getOptionProps]);
|
|
17
19
|
var listRef = useRef(null);
|
|
18
20
|
var counter = createCounter();
|
|
19
|
-
var renderGroup = useCallback(function (group) { return (React.createElement(Optgroup$1, { label: group.label, key: group.label, size: size }, group.options.map(function (option) { return
|
|
21
|
+
var renderGroup = useCallback(function (group) { return (React.createElement(Optgroup$1, { label: group.label, key: group.label, size: size }, group.options.map(function (option) { return renderOption(option, counter()); }))); }, [counter, renderOption, size]);
|
|
20
22
|
useVisibleOptions({
|
|
21
23
|
visibleOptions: visibleOptions,
|
|
22
24
|
listRef: listRef,
|
|
@@ -26,11 +28,14 @@ var OptionsList = forwardRef(function (_a, ref) {
|
|
|
26
28
|
if (options.length === 0 && !emptyPlaceholder) {
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
29
|
-
return (React.createElement("div", { className: cn(styles.optionsList, styles[size], className), "data-test-id": dataTestId
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return (React.createElement("div", { className: cn(styles.optionsList, styles[size], className), "data-test-id": dataTestId },
|
|
32
|
+
header,
|
|
33
|
+
React.createElement("div", { className: styles.scrollable, ref: mergeRefs([listRef, ref]), onScroll: onScroll },
|
|
34
|
+
options.map(function (option) {
|
|
35
|
+
return isGroup(option) ? renderGroup(option) : renderOption(option, counter());
|
|
36
|
+
}),
|
|
37
|
+
emptyPlaceholder && options.length === 0 && (React.createElement("div", { className: styles.emptyPlaceholder }, emptyPlaceholder))),
|
|
38
|
+
footer));
|
|
34
39
|
});
|
|
35
40
|
|
|
36
41
|
export { OptionsList };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: llpjm */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-text-secondary: #546272;
|
|
4
4
|
}
|
|
@@ -26,17 +26,21 @@
|
|
|
26
26
|
|
|
27
27
|
/* optgroup */
|
|
28
28
|
}
|
|
29
|
-
.
|
|
29
|
+
.select__optionsList_6utg9 {
|
|
30
30
|
overflow: auto;
|
|
31
31
|
width: 100%;
|
|
32
32
|
outline: none;
|
|
33
33
|
box-sizing: border-box;
|
|
34
34
|
}
|
|
35
|
-
.
|
|
35
|
+
.select__scrollable_6utg9 {
|
|
36
|
+
overflow: auto;
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
.select__emptyPlaceholder_6utg9 {
|
|
36
40
|
padding: var(--gap-m) var(--gap-s);
|
|
37
41
|
color: var(--select-options-list-empty-placeholder-color);
|
|
38
42
|
}
|
|
39
|
-
.
|
|
40
|
-
.
|
|
43
|
+
.select__l_6utg9 .select__emptyPlaceholder_6utg9,
|
|
44
|
+
.select__xl_6utg9 .select__emptyPlaceholder_6utg9 {
|
|
41
45
|
padding: var(--gap-xl) var(--gap-m);
|
|
42
46
|
}
|
|
@@ -6,5 +6,5 @@ type VirtualOptionsList = OptionsListProps & {
|
|
|
6
6
|
*/
|
|
7
7
|
overscan?: number;
|
|
8
8
|
};
|
|
9
|
-
declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, onScroll, }: VirtualOptionsList) => JSX.Element;
|
|
9
|
+
declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, getOptionProps, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, onScroll, header, footer, }: VirtualOptionsList) => JSX.Element;
|
|
10
10
|
export { VirtualOptionsList };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { a as __assign } from '../../tslib.es6-11a0bbd3.js';
|
|
1
2
|
import React, { useRef, useState, useEffect, useMemo } from 'react';
|
|
2
3
|
import cn from 'classnames';
|
|
3
4
|
import { usePrevious, lastIndexOf, useVisibleOptions, isGroup } from '../../utils.js';
|
|
4
5
|
import { Optgroup } from '../optgroup/Component.js';
|
|
5
6
|
import { useVirtual } from 'react-virtual';
|
|
6
7
|
|
|
7
|
-
var styles = {"virtualOptionsList":"
|
|
8
|
+
var styles = {"virtualOptionsList":"select__virtualOptionsList_1ryi1","scrollable":"select__scrollable_1ryi1","inner":"select__inner_1ryi1","virtualRow":"select__virtualRow_1ryi1","highlighted":"select__highlighted_1ryi1","emptyPlaceholder":"select__emptyPlaceholder_1ryi1","l":"select__l_1ryi1","xl":"select__xl_1ryi1"};
|
|
8
9
|
require('./index.css')
|
|
9
10
|
|
|
10
11
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
11
12
|
var VirtualOptionsList = function (_a) {
|
|
12
|
-
var _b = _a.size, size = _b === void 0 ? 's' : _b, _c = _a.flatOptions, flatOptions = _c === void 0 ? [] : _c, _d = _a.highlightedIndex, highlightedIndex = _d === void 0 ? -1 : _d, className = _a.className, Option = _a.Option, open = _a.open, _e = _a.options, options = _e === void 0 ? [] : _e, _f = _a.overscan, overscan = _f === void 0 ? 10 : _f, _g = _a.Optgroup, Optgroup$1 = _g === void 0 ? Optgroup : _g, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _h = _a.visibleOptions, visibleOptions = _h === void 0 ? 5 : _h, onScroll = _a.onScroll;
|
|
13
|
+
var _b = _a.size, size = _b === void 0 ? 's' : _b, _c = _a.flatOptions, flatOptions = _c === void 0 ? [] : _c, _d = _a.highlightedIndex, highlightedIndex = _d === void 0 ? -1 : _d, className = _a.className, getOptionProps = _a.getOptionProps, Option = _a.Option, open = _a.open, _e = _a.options, options = _e === void 0 ? [] : _e, _f = _a.overscan, overscan = _f === void 0 ? 10 : _f, _g = _a.Optgroup, Optgroup$1 = _g === void 0 ? Optgroup : _g, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _h = _a.visibleOptions, visibleOptions = _h === void 0 ? 5 : _h, onScroll = _a.onScroll, header = _a.header, footer = _a.footer;
|
|
13
14
|
var listRef = useRef(null);
|
|
14
15
|
var parentRef = useRef(null);
|
|
15
16
|
var _j = useState(0), visibleOptionsInvalidateKey = _j[0], setVisibleOptionsInvalidateKey = _j[1];
|
|
@@ -76,22 +77,25 @@ var VirtualOptionsList = function (_a) {
|
|
|
76
77
|
return acc;
|
|
77
78
|
}, {});
|
|
78
79
|
}, [options]);
|
|
79
|
-
return (React.createElement("div", { className: cn(styles.virtualOptionsList, styles[size], className),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
return (React.createElement("div", { className: cn(styles.virtualOptionsList, styles[size], className), "data-test-id": dataTestId },
|
|
81
|
+
header,
|
|
82
|
+
React.createElement("div", { className: styles.scrollable, ref: parentRef, onScroll: onScroll },
|
|
83
|
+
React.createElement("div", { className: styles.inner, style: {
|
|
84
|
+
height: rowVirtualizer.totalSize + "px",
|
|
85
|
+
}, ref: listRef }, rowVirtualizer.virtualItems.map(function (virtualRow) {
|
|
86
|
+
var _a;
|
|
87
|
+
var option = flatOptions[virtualRow.index];
|
|
88
|
+
var group = options[groupStartIndexes[virtualRow.index]];
|
|
89
|
+
return (React.createElement("div", { key: virtualRow.index, ref: virtualRow.measureRef, className: cn(styles.virtualRow, (_a = {},
|
|
90
|
+
_a[styles.highlighted] = highlightedIndex === virtualRow.index,
|
|
91
|
+
_a)), style: {
|
|
92
|
+
transform: "translateY(" + virtualRow.start + "px)",
|
|
93
|
+
} },
|
|
94
|
+
group && React.createElement(Optgroup$1, { label: group.label }),
|
|
95
|
+
!isGroup(option) && (React.createElement(Option, __assign({}, getOptionProps(option, virtualRow.index))))));
|
|
96
|
+
}))),
|
|
97
|
+
emptyPlaceholder && options.length === 0 && (React.createElement("div", { className: styles.emptyPlaceholder }, emptyPlaceholder)),
|
|
98
|
+
footer));
|
|
95
99
|
};
|
|
96
100
|
|
|
97
101
|
export { VirtualOptionsList };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1cdpu */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-border-primary: #dbdee1;
|
|
4
4
|
--color-light-text-secondary: #546272;
|
|
@@ -32,24 +32,27 @@
|
|
|
32
32
|
|
|
33
33
|
/* optgroup */
|
|
34
34
|
}
|
|
35
|
-
.
|
|
36
|
-
overflow: auto;
|
|
35
|
+
.select__virtualOptionsList_1ryi1 {
|
|
37
36
|
width: 100%;
|
|
38
37
|
outline: none;
|
|
39
38
|
box-sizing: border-box;
|
|
40
39
|
position: relative;
|
|
41
40
|
}
|
|
42
|
-
.
|
|
41
|
+
.select__scrollable_1ryi1 {
|
|
42
|
+
overflow: auto;
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
.select__inner_1ryi1 {
|
|
43
46
|
position: relative;
|
|
44
47
|
width: 100%;
|
|
45
48
|
}
|
|
46
|
-
.
|
|
49
|
+
.select__virtualRow_1ryi1 {
|
|
47
50
|
position: absolute;
|
|
48
51
|
top: 0;
|
|
49
52
|
left: 0;
|
|
50
53
|
width: 100%
|
|
51
54
|
}
|
|
52
|
-
.
|
|
55
|
+
.select__virtualRow_1ryi1:before {
|
|
53
56
|
content: '';
|
|
54
57
|
position: absolute;
|
|
55
58
|
z-index: 1;
|
|
@@ -60,18 +63,18 @@
|
|
|
60
63
|
background: var(--select-option-divider-background);
|
|
61
64
|
display: var(--select-option-divider-display);
|
|
62
65
|
}
|
|
63
|
-
.
|
|
66
|
+
.select__virtualRow_1ryi1:first-child:before {
|
|
64
67
|
display: none;
|
|
65
68
|
}
|
|
66
|
-
.
|
|
67
|
-
.
|
|
69
|
+
.select__highlighted_1ryi1:before,
|
|
70
|
+
.select__highlighted_1ryi1 + .select__virtualRow_1ryi1:before {
|
|
68
71
|
display: none;
|
|
69
72
|
}
|
|
70
|
-
.
|
|
73
|
+
.select__emptyPlaceholder_1ryi1 {
|
|
71
74
|
padding: var(--gap-m) var(--gap-s);
|
|
72
75
|
color: var(--select-options-list-empty-placeholder-color);
|
|
73
76
|
}
|
|
74
|
-
.
|
|
75
|
-
.
|
|
77
|
+
.select__l_1ryi1 .select__emptyPlaceholder_1ryi1,
|
|
78
|
+
.select__xl_1ryi1 .select__emptyPlaceholder_1ryi1 {
|
|
76
79
|
padding: var(--gap-xl) var(--gap-m);
|
|
77
80
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { OptionShape, OptionsListProps } from "./typings";
|
|
4
|
+
declare const OptionsListWithApply: React.ForwardRefExoticComponent<OptionsListProps & {
|
|
5
|
+
showClear?: boolean | undefined;
|
|
6
|
+
onApply?: (() => void) | undefined;
|
|
7
|
+
onClear?: (() => void) | undefined;
|
|
8
|
+
onClose?: (() => void) | undefined;
|
|
9
|
+
selectedDraft?: OptionShape[] | undefined;
|
|
10
|
+
OptionsList?: React.FC<OptionsListProps & React.RefAttributes<unknown>> | undefined;
|
|
11
|
+
} & React.RefAttributes<unknown>>;
|
|
12
|
+
export { OptionsListWithApply };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { _ as __rest, a as __assign, b as __spreadArrays } from './tslib.es6-11a0bbd3.js';
|
|
2
|
+
import React, { forwardRef, useRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import '@alfalab/hooks';
|
|
5
|
+
import '@alfalab/core-components-form-control/dist/esm';
|
|
6
|
+
import { processOptions } from './utils.js';
|
|
7
|
+
import '@alfalab/icons-glyph/ChevronDownMIcon';
|
|
8
|
+
import { OptionsList } from './components/options-list/Component.js';
|
|
9
|
+
import '@alfalab/core-components-checkbox/dist/esm';
|
|
10
|
+
import './components/base-select/Component.js';
|
|
11
|
+
import './Component.js';
|
|
12
|
+
import 'react-virtual';
|
|
13
|
+
import '@alfalab/core-components-skeleton/dist/esm';
|
|
14
|
+
import './intersection-observer-2080f60e.js';
|
|
15
|
+
import { Button } from '@alfalab/core-components-button/dist/esm';
|
|
16
|
+
|
|
17
|
+
var styles = {"footer":"select__footer_1lf9t","withBorder":"select__withBorder_1lf9t"};
|
|
18
|
+
require('./presets/useSelectWithApply/options-list-with-apply/index.css')
|
|
19
|
+
|
|
20
|
+
var OptionsListWithApply = forwardRef(function (_a, ref) {
|
|
21
|
+
var _b;
|
|
22
|
+
var toggleMenu = _a.toggleMenu, _c = _a.OptionsList, OptionsList$1 = _c === void 0 ? OptionsList : _c, defaultGetOptionProps = _a.getOptionProps, _d = _a.showClear, showClear = _d === void 0 ? true : _d, _e = _a.selectedDraft, selectedDraft = _e === void 0 ? [] : _e, _f = _a.flatOptions, flatOptions = _f === void 0 ? [] : _f, _g = _a.onApply, onApply = _g === void 0 ? function () { return null; } : _g, _h = _a.onClear, onClear = _h === void 0 ? function () { return null; } : _h, _j = _a.onClose, onClose = _j === void 0 ? function () { return null; } : _j, _k = _a.visibleOptions, visibleOptions = _k === void 0 ? 5 : _k, restProps = __rest(_a, ["toggleMenu", "OptionsList", "getOptionProps", "showClear", "selectedDraft", "flatOptions", "onApply", "onClear", "onClose", "visibleOptions"]);
|
|
23
|
+
var footerRef = useRef(null);
|
|
24
|
+
var getOptionProps = useCallback(function (option, index) {
|
|
25
|
+
var optionProps = defaultGetOptionProps(option, index);
|
|
26
|
+
var selected = option.key === SELECT_ALL_KEY
|
|
27
|
+
? selectedDraft.length === flatOptions.length - 1
|
|
28
|
+
: selectedDraft.includes(option);
|
|
29
|
+
return __assign(__assign({}, optionProps), { selected: selected });
|
|
30
|
+
}, [defaultGetOptionProps, flatOptions.length, selectedDraft]);
|
|
31
|
+
var handleApply = useCallback(function () {
|
|
32
|
+
onApply();
|
|
33
|
+
toggleMenu();
|
|
34
|
+
}, [onApply, toggleMenu]);
|
|
35
|
+
var handleClear = useCallback(function () {
|
|
36
|
+
onClear();
|
|
37
|
+
toggleMenu();
|
|
38
|
+
}, [onClear, toggleMenu]);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
var activeElement = document.activeElement;
|
|
41
|
+
setTimeout(function () {
|
|
42
|
+
if (footerRef.current) {
|
|
43
|
+
footerRef.current.focus();
|
|
44
|
+
}
|
|
45
|
+
}, 0);
|
|
46
|
+
return function () {
|
|
47
|
+
onClose();
|
|
48
|
+
if (activeElement) {
|
|
49
|
+
activeElement.focus();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, []);
|
|
54
|
+
return (React.createElement(OptionsList$1, __assign({}, restProps, { ref: ref, visibleOptions: visibleOptions, toggleMenu: toggleMenu, flatOptions: flatOptions, getOptionProps: getOptionProps, footer: React.createElement("div", {
|
|
55
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
56
|
+
tabIndex: 0, className: cn(styles.footer, (_b = {},
|
|
57
|
+
_b[styles.withBorder] = visibleOptions && flatOptions.length > visibleOptions,
|
|
58
|
+
_b)), ref: footerRef },
|
|
59
|
+
React.createElement(Button, { size: 'xxs', view: 'primary', onClick: handleApply }, "\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C"),
|
|
60
|
+
showClear && (React.createElement(Button, { size: 'xxs', view: 'secondary', onClick: handleClear }, "\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C"))) })));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var SELECT_ALL_KEY = 'select_all';
|
|
64
|
+
var selectAllOption = { key: SELECT_ALL_KEY, content: 'Выбрать все' };
|
|
65
|
+
function useSelectWithApply(_a) {
|
|
66
|
+
var options = _a.options, selected = _a.selected, _b = _a.onChange, onChange = _b === void 0 ? function () { return null; } : _b, OptionsList = _a.OptionsList, _c = _a.showClear, showClear = _c === void 0 ? true : _c, _d = _a.showSelectAll, showSelectAll = _d === void 0 ? false : _d;
|
|
67
|
+
var _e = useMemo(function () { return processOptions(options, selected); }, [
|
|
68
|
+
options,
|
|
69
|
+
selected,
|
|
70
|
+
]), flatOptions = _e.flatOptions, selectedOptions = _e.selectedOptions;
|
|
71
|
+
var _f = useState(selectedOptions), selectedDraft = _f[0], setSelectedDraft = _f[1];
|
|
72
|
+
var selectedOptionsRef = useRef(selectedOptions);
|
|
73
|
+
var handleApply = useCallback(function () {
|
|
74
|
+
onChange({
|
|
75
|
+
selected: selectedDraft[0],
|
|
76
|
+
selectedMultiple: selectedDraft,
|
|
77
|
+
initiator: null,
|
|
78
|
+
});
|
|
79
|
+
}, [onChange, selectedDraft]);
|
|
80
|
+
var handleClear = useCallback(function () {
|
|
81
|
+
setSelectedDraft([]);
|
|
82
|
+
onChange({
|
|
83
|
+
selected: null,
|
|
84
|
+
selectedMultiple: [],
|
|
85
|
+
initiator: null,
|
|
86
|
+
});
|
|
87
|
+
}, [onChange]);
|
|
88
|
+
var handleChange = useCallback(function (_a) {
|
|
89
|
+
var initiator = _a.initiator, restArgs = __rest(_a, ["initiator"]);
|
|
90
|
+
if (!initiator) {
|
|
91
|
+
onChange(__assign({ initiator: null }, restArgs));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
var initiatorSelected = selectedDraft.includes(initiator) ||
|
|
95
|
+
(initiator.key === SELECT_ALL_KEY && selectedDraft.length === flatOptions.length);
|
|
96
|
+
if (initiator.key === SELECT_ALL_KEY) {
|
|
97
|
+
setSelectedDraft(initiatorSelected ? [] : flatOptions);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
setSelectedDraft(initiatorSelected
|
|
101
|
+
? selectedDraft.filter(function (o) { return o !== initiator; })
|
|
102
|
+
: selectedDraft.concat(initiator));
|
|
103
|
+
}
|
|
104
|
+
}, [flatOptions, onChange, selectedDraft]);
|
|
105
|
+
var handleClose = useCallback(function () {
|
|
106
|
+
setSelectedDraft(selectedOptionsRef.current);
|
|
107
|
+
}, []);
|
|
108
|
+
useEffect(function () {
|
|
109
|
+
setSelectedDraft(selectedOptions);
|
|
110
|
+
selectedOptionsRef.current = selectedOptions;
|
|
111
|
+
}, [selectedOptions]);
|
|
112
|
+
var memoizedOptions = useMemo(function () { return (showSelectAll ? __spreadArrays([selectAllOption], options) : options); }, [options, showSelectAll]);
|
|
113
|
+
return {
|
|
114
|
+
OptionsList: OptionsListWithApply,
|
|
115
|
+
optionsListProps: {
|
|
116
|
+
OptionsList: OptionsList,
|
|
117
|
+
showClear: showClear && (selectedDraft.length > 0 || selectedOptions.length > 0),
|
|
118
|
+
onClear: handleClear,
|
|
119
|
+
onApply: handleApply,
|
|
120
|
+
onClose: handleClose,
|
|
121
|
+
selectedDraft: selectedDraft,
|
|
122
|
+
},
|
|
123
|
+
allowUnselect: true,
|
|
124
|
+
multiple: true,
|
|
125
|
+
options: memoizedOptions,
|
|
126
|
+
onChange: handleChange,
|
|
127
|
+
selected: selected,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { OptionsListWithApply as O, SELECT_ALL_KEY as S, useSelectWithApply as u };
|