@zohodesk/components 1.4.8 → 1.4.10-exp-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/.cli/propValidation_report.html +1 -1
- package/README.md +22 -0
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +16 -8
- package/es/MultiSelect/AdvancedMultiSelect.js +13 -6
- package/es/MultiSelect/EmptyState.js +2 -1
- package/es/MultiSelect/MultiSelect.js +36 -15
- package/es/MultiSelect/MultiSelectWithAvatar.js +9 -2
- package/es/MultiSelect/SelectedOptions.js +4 -2
- package/es/MultiSelect/Suggestions.js +174 -97
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/es/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/es/MultiSelect/constants.js +6 -0
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +18 -55
- package/es/Select/Select.js +13 -3
- package/es/Select/SelectWithIcon.js +1 -1
- package/es/Select/__tests__/Select.spec.js +16 -8
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/es/Select/props/defaultProps.js +1 -0
- package/es/Select/props/propTypes.js +1 -0
- package/es/utils/Common.js +3 -2
- package/es/utils/dropDownUtils.js +28 -7
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +94 -83
- package/lib/MultiSelect/AdvancedMultiSelect.js +16 -7
- package/lib/MultiSelect/EmptyState.js +3 -1
- package/lib/MultiSelect/MultiSelect.js +39 -15
- package/lib/MultiSelect/MultiSelectWithAvatar.js +11 -3
- package/lib/MultiSelect/SelectedOptions.js +4 -2
- package/lib/MultiSelect/Suggestions.js +176 -100
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/lib/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/lib/MultiSelect/constants.js +13 -0
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +17 -55
- package/lib/Select/Select.js +13 -2
- package/lib/Select/SelectWithIcon.js +1 -1
- package/lib/Select/__tests__/Select.spec.js +165 -155
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/lib/Select/props/defaultProps.js +1 -0
- package/lib/Select/props/propTypes.js +1 -0
- package/lib/utils/Common.js +5 -3
- package/lib/utils/dropDownUtils.js +27 -4
- package/package.json +9 -8
|
@@ -18,3 +18,346 @@ exports[`Suggestions rendering the defult props 1`] = `
|
|
|
18
18
|
</div>
|
|
19
19
|
</DocumentFragment>
|
|
20
20
|
`;
|
|
21
|
+
|
|
22
|
+
exports[`Suggestions rendering with limit props 1`] = `
|
|
23
|
+
<DocumentFragment>
|
|
24
|
+
<div
|
|
25
|
+
class="flex coldir"
|
|
26
|
+
data-id="containerComponent"
|
|
27
|
+
data-selector-id="container"
|
|
28
|
+
data-test-id="containerComponent"
|
|
29
|
+
tabindex="0"
|
|
30
|
+
>
|
|
31
|
+
<div
|
|
32
|
+
class="shrinkOff"
|
|
33
|
+
data-id="undefined"
|
|
34
|
+
data-selector-id="box"
|
|
35
|
+
data-test-id="undefined"
|
|
36
|
+
>
|
|
37
|
+
<li
|
|
38
|
+
aria-label="text2"
|
|
39
|
+
aria-selected="true"
|
|
40
|
+
class="list medium default activedefault activewithBorder flex rowdir vCenter"
|
|
41
|
+
data-a11y-inset-focus="true"
|
|
42
|
+
data-a11y-list-active="false"
|
|
43
|
+
data-id="text2"
|
|
44
|
+
data-selected="true"
|
|
45
|
+
data-selector-id="listItem"
|
|
46
|
+
data-test-id="text2"
|
|
47
|
+
data-title="text2"
|
|
48
|
+
role="option"
|
|
49
|
+
style="color: red;"
|
|
50
|
+
tabindex="0"
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
class="leftBox grow basis shrinkOff"
|
|
54
|
+
data-id="boxComponent"
|
|
55
|
+
data-selector-id="box"
|
|
56
|
+
data-test-id="boxComponent"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
class="titleBox shrinkOff"
|
|
60
|
+
data-id="boxComponent"
|
|
61
|
+
data-selector-id="box"
|
|
62
|
+
data-test-id="boxComponent"
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
class="value basisAuto shrinkOn"
|
|
66
|
+
data-id="boxComponent"
|
|
67
|
+
data-selector-id="box"
|
|
68
|
+
data-test-id="boxComponent"
|
|
69
|
+
>
|
|
70
|
+
text2
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</li>
|
|
75
|
+
<li
|
|
76
|
+
aria-label="text3"
|
|
77
|
+
aria-selected="true"
|
|
78
|
+
class="list medium default activedefault activewithBorder flex rowdir vCenter"
|
|
79
|
+
data-a11y-inset-focus="true"
|
|
80
|
+
data-a11y-list-active="false"
|
|
81
|
+
data-id="text3"
|
|
82
|
+
data-selected="true"
|
|
83
|
+
data-selector-id="listItem"
|
|
84
|
+
data-test-id="text3"
|
|
85
|
+
data-title="text3"
|
|
86
|
+
role="option"
|
|
87
|
+
style="color: blue;"
|
|
88
|
+
tabindex="0"
|
|
89
|
+
>
|
|
90
|
+
<div
|
|
91
|
+
class="leftBox grow basis shrinkOff"
|
|
92
|
+
data-id="boxComponent"
|
|
93
|
+
data-selector-id="box"
|
|
94
|
+
data-test-id="boxComponent"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
class="titleBox shrinkOff"
|
|
98
|
+
data-id="boxComponent"
|
|
99
|
+
data-selector-id="box"
|
|
100
|
+
data-test-id="boxComponent"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
class="value basisAuto shrinkOn"
|
|
104
|
+
data-id="boxComponent"
|
|
105
|
+
data-selector-id="box"
|
|
106
|
+
data-test-id="boxComponent"
|
|
107
|
+
>
|
|
108
|
+
text3
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</li>
|
|
113
|
+
<li
|
|
114
|
+
aria-label="text4"
|
|
115
|
+
aria-selected="true"
|
|
116
|
+
class="list medium default activedefault activewithBorder flex rowdir vCenter"
|
|
117
|
+
data-a11y-inset-focus="true"
|
|
118
|
+
data-a11y-list-active="false"
|
|
119
|
+
data-id="text4"
|
|
120
|
+
data-selected="true"
|
|
121
|
+
data-selector-id="listItem"
|
|
122
|
+
data-test-id="text4"
|
|
123
|
+
data-title="text4"
|
|
124
|
+
role="option"
|
|
125
|
+
tabindex="0"
|
|
126
|
+
>
|
|
127
|
+
<div
|
|
128
|
+
class="leftBox grow basis shrinkOff"
|
|
129
|
+
data-id="boxComponent"
|
|
130
|
+
data-selector-id="box"
|
|
131
|
+
data-test-id="boxComponent"
|
|
132
|
+
>
|
|
133
|
+
<div
|
|
134
|
+
class="titleBox shrinkOff"
|
|
135
|
+
data-id="boxComponent"
|
|
136
|
+
data-selector-id="box"
|
|
137
|
+
data-test-id="boxComponent"
|
|
138
|
+
>
|
|
139
|
+
<div
|
|
140
|
+
class="value basisAuto shrinkOn"
|
|
141
|
+
data-id="boxComponent"
|
|
142
|
+
data-selector-id="box"
|
|
143
|
+
data-test-id="boxComponent"
|
|
144
|
+
>
|
|
145
|
+
text4
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</li>
|
|
150
|
+
<li
|
|
151
|
+
aria-label="text5"
|
|
152
|
+
aria-selected="false"
|
|
153
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
154
|
+
data-a11y-inset-focus="true"
|
|
155
|
+
data-a11y-list-active="false"
|
|
156
|
+
data-id="text5"
|
|
157
|
+
data-selector-id="listItem"
|
|
158
|
+
data-test-id="text5"
|
|
159
|
+
data-title="Limit Reached"
|
|
160
|
+
role="option"
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
class="leftBox grow basis shrinkOff"
|
|
164
|
+
data-id="boxComponent"
|
|
165
|
+
data-selector-id="box"
|
|
166
|
+
data-test-id="boxComponent"
|
|
167
|
+
>
|
|
168
|
+
<div
|
|
169
|
+
class="titleBox shrinkOff"
|
|
170
|
+
data-id="boxComponent"
|
|
171
|
+
data-selector-id="box"
|
|
172
|
+
data-test-id="boxComponent"
|
|
173
|
+
>
|
|
174
|
+
<div
|
|
175
|
+
class="value basisAuto shrinkOn"
|
|
176
|
+
data-id="boxComponent"
|
|
177
|
+
data-selector-id="box"
|
|
178
|
+
data-test-id="boxComponent"
|
|
179
|
+
>
|
|
180
|
+
text5
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</li>
|
|
185
|
+
<li
|
|
186
|
+
aria-label="text6"
|
|
187
|
+
aria-selected="false"
|
|
188
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
189
|
+
data-a11y-inset-focus="true"
|
|
190
|
+
data-a11y-list-active="false"
|
|
191
|
+
data-id="text6"
|
|
192
|
+
data-selector-id="listItem"
|
|
193
|
+
data-test-id="text6"
|
|
194
|
+
data-title="Limit Reached"
|
|
195
|
+
role="option"
|
|
196
|
+
>
|
|
197
|
+
<div
|
|
198
|
+
class="leftBox grow basis shrinkOff"
|
|
199
|
+
data-id="boxComponent"
|
|
200
|
+
data-selector-id="box"
|
|
201
|
+
data-test-id="boxComponent"
|
|
202
|
+
>
|
|
203
|
+
<div
|
|
204
|
+
class="titleBox shrinkOff"
|
|
205
|
+
data-id="boxComponent"
|
|
206
|
+
data-selector-id="box"
|
|
207
|
+
data-test-id="boxComponent"
|
|
208
|
+
>
|
|
209
|
+
<div
|
|
210
|
+
class="value basisAuto shrinkOn"
|
|
211
|
+
data-id="boxComponent"
|
|
212
|
+
data-selector-id="box"
|
|
213
|
+
data-test-id="boxComponent"
|
|
214
|
+
>
|
|
215
|
+
text6
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
</li>
|
|
220
|
+
<li
|
|
221
|
+
aria-label="text7"
|
|
222
|
+
aria-selected="false"
|
|
223
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
224
|
+
data-a11y-inset-focus="true"
|
|
225
|
+
data-a11y-list-active="false"
|
|
226
|
+
data-id="text7"
|
|
227
|
+
data-selector-id="listItem"
|
|
228
|
+
data-test-id="text7"
|
|
229
|
+
data-title="Limit Reached"
|
|
230
|
+
role="option"
|
|
231
|
+
>
|
|
232
|
+
<div
|
|
233
|
+
class="leftBox grow basis shrinkOff"
|
|
234
|
+
data-id="boxComponent"
|
|
235
|
+
data-selector-id="box"
|
|
236
|
+
data-test-id="boxComponent"
|
|
237
|
+
>
|
|
238
|
+
<div
|
|
239
|
+
class="titleBox shrinkOff"
|
|
240
|
+
data-id="boxComponent"
|
|
241
|
+
data-selector-id="box"
|
|
242
|
+
data-test-id="boxComponent"
|
|
243
|
+
>
|
|
244
|
+
<div
|
|
245
|
+
class="value basisAuto shrinkOn"
|
|
246
|
+
data-id="boxComponent"
|
|
247
|
+
data-selector-id="box"
|
|
248
|
+
data-test-id="boxComponent"
|
|
249
|
+
>
|
|
250
|
+
text7
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</li>
|
|
255
|
+
<li
|
|
256
|
+
aria-label="text8"
|
|
257
|
+
aria-selected="false"
|
|
258
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
259
|
+
data-a11y-inset-focus="true"
|
|
260
|
+
data-a11y-list-active="false"
|
|
261
|
+
data-id="text8"
|
|
262
|
+
data-selector-id="listItem"
|
|
263
|
+
data-test-id="text8"
|
|
264
|
+
data-title="Limit Reached"
|
|
265
|
+
role="option"
|
|
266
|
+
>
|
|
267
|
+
<div
|
|
268
|
+
class="leftBox grow basis shrinkOff"
|
|
269
|
+
data-id="boxComponent"
|
|
270
|
+
data-selector-id="box"
|
|
271
|
+
data-test-id="boxComponent"
|
|
272
|
+
>
|
|
273
|
+
<div
|
|
274
|
+
class="titleBox shrinkOff"
|
|
275
|
+
data-id="boxComponent"
|
|
276
|
+
data-selector-id="box"
|
|
277
|
+
data-test-id="boxComponent"
|
|
278
|
+
>
|
|
279
|
+
<div
|
|
280
|
+
class="value basisAuto shrinkOn"
|
|
281
|
+
data-id="boxComponent"
|
|
282
|
+
data-selector-id="box"
|
|
283
|
+
data-test-id="boxComponent"
|
|
284
|
+
>
|
|
285
|
+
text8
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</li>
|
|
290
|
+
<li
|
|
291
|
+
aria-label="text9"
|
|
292
|
+
aria-selected="false"
|
|
293
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
294
|
+
data-a11y-inset-focus="true"
|
|
295
|
+
data-a11y-list-active="false"
|
|
296
|
+
data-id="text9"
|
|
297
|
+
data-selector-id="listItem"
|
|
298
|
+
data-test-id="text9"
|
|
299
|
+
data-title="Limit Reached"
|
|
300
|
+
role="option"
|
|
301
|
+
>
|
|
302
|
+
<div
|
|
303
|
+
class="leftBox grow basis shrinkOff"
|
|
304
|
+
data-id="boxComponent"
|
|
305
|
+
data-selector-id="box"
|
|
306
|
+
data-test-id="boxComponent"
|
|
307
|
+
>
|
|
308
|
+
<div
|
|
309
|
+
class="titleBox shrinkOff"
|
|
310
|
+
data-id="boxComponent"
|
|
311
|
+
data-selector-id="box"
|
|
312
|
+
data-test-id="boxComponent"
|
|
313
|
+
>
|
|
314
|
+
<div
|
|
315
|
+
class="value basisAuto shrinkOn"
|
|
316
|
+
data-id="boxComponent"
|
|
317
|
+
data-selector-id="box"
|
|
318
|
+
data-test-id="boxComponent"
|
|
319
|
+
>
|
|
320
|
+
text9
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</li>
|
|
325
|
+
<li
|
|
326
|
+
aria-label="text10"
|
|
327
|
+
aria-selected="false"
|
|
328
|
+
class="list medium default disable withBorder flex rowdir vCenter"
|
|
329
|
+
data-a11y-inset-focus="true"
|
|
330
|
+
data-a11y-list-active="false"
|
|
331
|
+
data-id="text10"
|
|
332
|
+
data-selector-id="listItem"
|
|
333
|
+
data-test-id="text10"
|
|
334
|
+
data-title="Limit Reached"
|
|
335
|
+
role="option"
|
|
336
|
+
>
|
|
337
|
+
<div
|
|
338
|
+
class="leftBox grow basis shrinkOff"
|
|
339
|
+
data-id="boxComponent"
|
|
340
|
+
data-selector-id="box"
|
|
341
|
+
data-test-id="boxComponent"
|
|
342
|
+
>
|
|
343
|
+
<div
|
|
344
|
+
class="titleBox shrinkOff"
|
|
345
|
+
data-id="boxComponent"
|
|
346
|
+
data-selector-id="box"
|
|
347
|
+
data-test-id="boxComponent"
|
|
348
|
+
>
|
|
349
|
+
<div
|
|
350
|
+
class="value basisAuto shrinkOn"
|
|
351
|
+
data-id="boxComponent"
|
|
352
|
+
data-selector-id="box"
|
|
353
|
+
data-test-id="boxComponent"
|
|
354
|
+
>
|
|
355
|
+
text10
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
</li>
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
</DocumentFragment>
|
|
363
|
+
`;
|
|
@@ -86,6 +86,7 @@ export const MultiSelect_defaultProps = {
|
|
|
86
86
|
autoComplete: getLibraryConfig('autoComplete'),
|
|
87
87
|
dataId: 'multiSelect',
|
|
88
88
|
dropBoxSize: 'small',
|
|
89
|
+
isVirtualizerEnabled: false,
|
|
89
90
|
isAnimate: true,
|
|
90
91
|
isDisabled: false,
|
|
91
92
|
isPopupOpenOnEnter: false,
|
|
@@ -167,5 +168,6 @@ export const SelectedOptions_defaultProps = {
|
|
|
167
168
|
};
|
|
168
169
|
export const Suggestions_defaultProps = {
|
|
169
170
|
a11y: {},
|
|
171
|
+
isVirtualizerEnabled: false,
|
|
170
172
|
needMultiLineText: false
|
|
171
173
|
};
|
|
@@ -31,17 +31,20 @@ export const MultiSelect_propTypes = {
|
|
|
31
31
|
disableAction: PropTypes.bool,
|
|
32
32
|
dropBoxSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
33
33
|
emptyMessage: PropTypes.string.isRequired,
|
|
34
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
34
35
|
getContainerRef: PropTypes.func,
|
|
35
36
|
getNextOptions: PropTypes.func,
|
|
36
37
|
getPublicMethods: PropTypes.func,
|
|
37
38
|
getRef: PropTypes.func,
|
|
38
39
|
getTargetRef: PropTypes.func,
|
|
39
40
|
i18nKeys: PropTypes.shape({
|
|
41
|
+
searchText: PropTypes.string,
|
|
40
42
|
clearText: PropTypes.string,
|
|
41
43
|
loadingText: PropTypes.string,
|
|
42
44
|
emptyText: PropTypes.string,
|
|
43
45
|
noMoreText: PropTypes.string,
|
|
44
|
-
searchEmptyText: PropTypes.string
|
|
46
|
+
searchEmptyText: PropTypes.string,
|
|
47
|
+
limitReachedMessage: PropTypes.string
|
|
45
48
|
}),
|
|
46
49
|
a11y: PropTypes.shape({
|
|
47
50
|
clearLabel: PropTypes.string
|
|
@@ -116,7 +119,8 @@ export const MultiSelect_propTypes = {
|
|
|
116
119
|
isFocus: PropTypes.bool,
|
|
117
120
|
allowValueFallback: PropTypes.bool,
|
|
118
121
|
renderCustomClearComponent: PropTypes.func,
|
|
119
|
-
renderCustomToggleIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
122
|
+
renderCustomToggleIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
123
|
+
limit: PropTypes.number
|
|
120
124
|
};
|
|
121
125
|
export const MultiSelectHeader_propTypes = {
|
|
122
126
|
dataId: PropTypes.string,
|
|
@@ -153,7 +157,8 @@ export const SelectedOptions_propTypes = {
|
|
|
153
157
|
})),
|
|
154
158
|
size: PropTypes.oneOf(['medium', 'xmedium']),
|
|
155
159
|
palette: PropTypes.string,
|
|
156
|
-
dataId: PropTypes.string
|
|
160
|
+
dataId: PropTypes.string,
|
|
161
|
+
limit: PropTypes.number
|
|
157
162
|
};
|
|
158
163
|
export const Suggestions_propTypes = {
|
|
159
164
|
a11y: PropTypes.shape({
|
|
@@ -164,6 +169,8 @@ export const Suggestions_propTypes = {
|
|
|
164
169
|
avatarPalette: PropTypes.string,
|
|
165
170
|
className: PropTypes.string,
|
|
166
171
|
dataId: PropTypes.string,
|
|
172
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
173
|
+
setVirtualizerContainerRefFunction: PropTypes.func,
|
|
167
174
|
getRef: PropTypes.func,
|
|
168
175
|
hoverId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
169
176
|
hoverOption: PropTypes.number,
|
|
@@ -183,7 +190,9 @@ export const Suggestions_propTypes = {
|
|
|
183
190
|
logo: PropTypes.string,
|
|
184
191
|
optionType: PropTypes.string,
|
|
185
192
|
listItemProps: PropTypes.object
|
|
186
|
-
}))
|
|
193
|
+
})),
|
|
194
|
+
limit: PropTypes.number,
|
|
195
|
+
limitReachedMessage: PropTypes.string
|
|
187
196
|
};
|
|
188
197
|
export const AdvancedGroupMultiSelect_propTypes = {
|
|
189
198
|
animationStyle: PropTypes.string,
|
|
@@ -201,7 +210,8 @@ export const AdvancedGroupMultiSelect_propTypes = {
|
|
|
201
210
|
loadingText: PropTypes.string,
|
|
202
211
|
emptyText: PropTypes.string,
|
|
203
212
|
noMoreText: PropTypes.string,
|
|
204
|
-
searchEmptyText: PropTypes.string
|
|
213
|
+
searchEmptyText: PropTypes.string,
|
|
214
|
+
limitReachedMessage: PropTypes.string
|
|
205
215
|
}),
|
|
206
216
|
a11y: PropTypes.shape({
|
|
207
217
|
clearLabel: PropTypes.string
|
|
@@ -255,7 +265,8 @@ export const AdvancedGroupMultiSelect_propTypes = {
|
|
|
255
265
|
children: PropTypes.node,
|
|
256
266
|
dataSelectorId: PropTypes.string,
|
|
257
267
|
isFocus: PropTypes.bool,
|
|
258
|
-
allowValueFallback: PropTypes.bool
|
|
268
|
+
allowValueFallback: PropTypes.bool,
|
|
269
|
+
limit: PropTypes.number
|
|
259
270
|
};
|
|
260
271
|
export const AdvancedMultiSelect_propTypes = { ...MultiSelect_propTypes,
|
|
261
272
|
selectedOptionDetails: PropTypes.string,
|
|
@@ -269,68 +280,20 @@ export const AdvancedMultiSelect_propTypes = { ...MultiSelect_propTypes,
|
|
|
269
280
|
selectedOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).isRequired,
|
|
270
281
|
selectedOptionsLimit: PropTypes.number,
|
|
271
282
|
getSelectedOptionDetails: PropTypes.func,
|
|
272
|
-
emptyMessage: PropTypes.string.isRequired,
|
|
273
|
-
isDisabled: PropTypes.bool,
|
|
274
|
-
isReadOnly: PropTypes.bool,
|
|
275
|
-
needLocalSearch: PropTypes.bool,
|
|
276
|
-
needSelectAll: PropTypes.bool,
|
|
277
|
-
onChange: PropTypes.func.isRequired,
|
|
278
|
-
searchEmptyMessage: PropTypes.string,
|
|
279
|
-
placeHolder: PropTypes.string,
|
|
280
|
-
selectAllText: PropTypes.string,
|
|
281
|
-
textField: PropTypes.string,
|
|
282
|
-
valueField: PropTypes.string,
|
|
283
283
|
imageField: PropTypes.string,
|
|
284
284
|
iconName: PropTypes.string,
|
|
285
285
|
prefixText: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
286
286
|
//For grouping multiSelect
|
|
287
287
|
optionType: PropTypes.oneOf(['default', 'avatar', 'icon']),
|
|
288
|
-
needEffect: PropTypes.bool,
|
|
289
288
|
secondaryField: PropTypes.string,
|
|
290
|
-
animationStyle: PropTypes.string,
|
|
291
|
-
defaultDropBoxPosition: PropTypes.oneOf(['bottom', 'top', 'left', 'right']),
|
|
292
|
-
dropBoxSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
293
|
-
isAnimate: PropTypes.bool,
|
|
294
|
-
size: PropTypes.oneOf(['medium', 'xmedium']),
|
|
295
|
-
textBoxSize: PropTypes.oneOf(['small', 'medium', 'xmedium']),
|
|
296
|
-
title: PropTypes.string,
|
|
297
|
-
variant: PropTypes.string,
|
|
298
289
|
dataIdClearIcon: PropTypes.string,
|
|
299
290
|
dataIdLoading: PropTypes.string,
|
|
300
291
|
dataIdMultiSelectComp: PropTypes.string,
|
|
301
292
|
dataIdSelectAllEle: PropTypes.string,
|
|
302
|
-
|
|
303
|
-
/**** Popup Props ****/
|
|
304
|
-
isPopupOpen: PropTypes.bool,
|
|
305
|
-
isPopupReady: PropTypes.bool,
|
|
306
|
-
togglePopup: PropTypes.func,
|
|
307
|
-
getContainerRef: PropTypes.func,
|
|
308
|
-
position: PropTypes.string,
|
|
309
|
-
removeClose: PropTypes.func,
|
|
310
293
|
listItemSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
311
|
-
needBorder: PropTypes.bool,
|
|
312
|
-
htmlId: PropTypes.string,
|
|
313
|
-
i18nKeys: PropTypes.shape({
|
|
314
|
-
clearText: PropTypes.string,
|
|
315
|
-
loadingText: PropTypes.string,
|
|
316
|
-
emptyText: PropTypes.string,
|
|
317
|
-
noMoreText: PropTypes.string,
|
|
318
|
-
searchEmptyText: PropTypes.string
|
|
319
|
-
}),
|
|
320
|
-
a11y: PropTypes.shape({
|
|
321
|
-
clearLabel: PropTypes.string
|
|
322
|
-
}),
|
|
323
|
-
borderColor: PropTypes.oneOf(['transparent', 'default', 'dark']),
|
|
324
|
-
isBoxPaddingNeed: PropTypes.bool,
|
|
325
|
-
isSearchClearOnSelect: PropTypes.bool,
|
|
326
|
-
disabledOptions: PropTypes.arrayOf(PropTypes.string),
|
|
327
|
-
getFooter: PropTypes.func,
|
|
328
294
|
customProps: PropTypes.shape({
|
|
329
295
|
SuggestionsProps: PropTypes.object,
|
|
330
296
|
DropBoxProps: PropTypes.object
|
|
331
297
|
}),
|
|
332
|
-
|
|
333
|
-
dataSelectorId: PropTypes.string,
|
|
334
|
-
customClass: PropTypes.object,
|
|
335
|
-
isFocus: PropTypes.bool
|
|
298
|
+
customClass: PropTypes.object
|
|
336
299
|
};
|
package/es/Select/Select.js
CHANGED
|
@@ -18,7 +18,7 @@ import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
|
|
|
18
18
|
import Loader from '@zohodesk/svg/lib/Loader/Loader';
|
|
19
19
|
/**** Methods ****/
|
|
20
20
|
|
|
21
|
-
import { makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
|
|
21
|
+
import { dummyObj, makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
|
|
22
22
|
import { debounce, scrollTo, getIsEmptyValue, getSearchString, findScrollEnd, getKeyValue } from "../utils/Common.js";
|
|
23
23
|
/**** CSS ****/
|
|
24
24
|
|
|
@@ -106,6 +106,7 @@ export class SelectComponent extends Component {
|
|
|
106
106
|
this.handleAddNewOption = this.handleAddNewOption.bind(this);
|
|
107
107
|
this.handleExposePopupHandlers = this.handleExposePopupHandlers.bind(this);
|
|
108
108
|
this.handleGetAddNewOptionText = this.handleGetAddNewOptionText.bind(this);
|
|
109
|
+
this.setSuggestionsVirtualizerContainerRefFunction = this.setSuggestionsVirtualizerContainerRefFunction.bind(this);
|
|
109
110
|
this.valueInputTypeString = '';
|
|
110
111
|
this.valueInputSearchString = '';
|
|
111
112
|
this.autoSelectSuggestions = [];
|
|
@@ -251,10 +252,10 @@ export class SelectComponent extends Component {
|
|
|
251
252
|
valueField,
|
|
252
253
|
textField,
|
|
253
254
|
allowValueFallback,
|
|
254
|
-
customProps =
|
|
255
|
+
customProps = dummyObj
|
|
255
256
|
} = props;
|
|
256
257
|
let {
|
|
257
|
-
listItemProps =
|
|
258
|
+
listItemProps = dummyObj
|
|
258
259
|
} = customProps;
|
|
259
260
|
return this.formatOptions({
|
|
260
261
|
options,
|
|
@@ -529,6 +530,7 @@ export class SelectComponent extends Component {
|
|
|
529
530
|
|
|
530
531
|
suggestionContainerRef(el) {
|
|
531
532
|
this.suggestionContainer = el;
|
|
533
|
+
typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
|
|
532
534
|
}
|
|
533
535
|
|
|
534
536
|
suggestionItemRef(el, index, id) {
|
|
@@ -676,6 +678,11 @@ export class SelectComponent extends Component {
|
|
|
676
678
|
});
|
|
677
679
|
}
|
|
678
680
|
|
|
681
|
+
setSuggestionsVirtualizerContainerRefFunction(refFunc) {
|
|
682
|
+
this.setSuggestionsVirtualizerRef = refFunc;
|
|
683
|
+
this.suggestionContainer && refFunc(this.suggestionContainer);
|
|
684
|
+
}
|
|
685
|
+
|
|
679
686
|
render() {
|
|
680
687
|
let {
|
|
681
688
|
needSearch,
|
|
@@ -728,6 +735,7 @@ export class SelectComponent extends Component {
|
|
|
728
735
|
targetOffset,
|
|
729
736
|
isRestrictScroll,
|
|
730
737
|
dropBoxPortalId,
|
|
738
|
+
isVirtualizerEnabled,
|
|
731
739
|
renderCustomToggleIndicator,
|
|
732
740
|
renderCustomSearchClearComponent
|
|
733
741
|
} = this.props;
|
|
@@ -932,6 +940,8 @@ export class SelectComponent extends Component {
|
|
|
932
940
|
eleRef: this.suggestionContainerRef
|
|
933
941
|
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
934
942
|
activeId: selectedId,
|
|
943
|
+
isVirtualizerEnabled: isVirtualizerEnabled,
|
|
944
|
+
setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
|
|
935
945
|
suggestions: suggestions,
|
|
936
946
|
getRef: this.suggestionItemRef,
|
|
937
947
|
hoverOption: hoverIndex,
|
|
@@ -193,7 +193,7 @@ class SelectWithIcon extends Component {
|
|
|
193
193
|
} = this.props;
|
|
194
194
|
|
|
195
195
|
if (options.length) {
|
|
196
|
-
datas = options.filter(obj => obj[valueKey].toLowerCase().includes(searchValue.toLowerCase()));
|
|
196
|
+
datas = options.filter(obj => obj[valueKey].toLowerCase().includes(searchValue.toLowerCase().trim()));
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
return datas;
|
|
@@ -246,14 +246,22 @@ describe('Select -', () => {
|
|
|
246
246
|
userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
|
|
247
247
|
expect(getAllByRole(listItemRole)).toHaveLength(1);
|
|
248
248
|
expect(asFragment()).toMatchSnapshot();
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
});
|
|
250
|
+
test('Should render the only options matching search value even with additional spaces before and after', () => {
|
|
251
|
+
const {
|
|
252
|
+
getByRole,
|
|
253
|
+
getAllByRole,
|
|
254
|
+
asFragment,
|
|
255
|
+
getByTestId
|
|
256
|
+
} = render( /*#__PURE__*/React.createElement(Select, {
|
|
257
|
+
needSearch: true,
|
|
258
|
+
options: options
|
|
259
|
+
}));
|
|
260
|
+
userEvent.click(getByRole(selectInputRole));
|
|
261
|
+
userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), ' 2 ');
|
|
262
|
+
expect(getAllByRole(listItemRole)).toHaveLength(1);
|
|
263
|
+
expect(asFragment()).toMatchSnapshot();
|
|
264
|
+
});
|
|
257
265
|
test('Should trigger given onSearch, when type on the search input', async () => {
|
|
258
266
|
const mockOnSearch = jest.fn();
|
|
259
267
|
const {
|