selectic 3.0.21 → 3.1.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/dist/selectic.common.js +545 -67
- package/dist/selectic.esm.js +546 -69
- package/doc/changeIcons.md +118 -0
- package/doc/changeText.md +1 -1
- package/doc/domProperties.md +57 -19
- package/doc/extendedProperties.md +83 -72
- package/doc/main.md +2 -0
- package/doc/params.md +177 -112
- package/doc/properties.md +42 -0
- package/package.json +4 -4
- package/src/ExtendedList.tsx +53 -6
- package/src/Filter.tsx +11 -9
- package/src/Icon.tsx +199 -0
- package/src/List.tsx +12 -6
- package/src/MainInput.tsx +15 -11
- package/src/Store.tsx +290 -123
- package/src/css/selectic.css +24 -0
- package/src/icons/caret-down.tsx +21 -0
- package/src/icons/caret-up.tsx +21 -0
- package/src/icons/check.tsx +23 -0
- package/src/icons/question.tsx +21 -0
- package/src/icons/search.tsx +21 -0
- package/src/icons/spinner.tsx +21 -0
- package/src/icons/strikeThrough.tsx +21 -0
- package/src/icons/times.tsx +21 -0
- package/src/index.tsx +78 -37
- package/test/Store/Store_computed.spec.js +84 -0
- package/test/Store/changeIcons.spec.js +154 -0
- package/test/Store/selectGroup.spec.js +389 -0
- package/test/Store/selectItem.spec.js +100 -46
- package/test/helper.js +38 -34
- package/types/ExtendedList.d.ts +7 -2
- package/types/Icon.d.ts +25 -0
- package/types/Store.d.ts +142 -5
- package/types/icons/caret-down.d.ts +6 -0
- package/types/icons/caret-up.d.ts +6 -0
- package/types/icons/check.d.ts +6 -0
- package/types/icons/question.d.ts +6 -0
- package/types/icons/search.d.ts +6 -0
- package/types/icons/spinner.d.ts +6 -0
- package/types/icons/strikeThrough.d.ts +6 -0
- package/types/icons/times.d.ts +6 -0
- package/types/index.d.ts +74 -1
|
@@ -28,16 +28,18 @@ tape.test('selectItem()', (st) => {
|
|
|
28
28
|
|
|
29
29
|
t.is(store.state.internalValue, null);
|
|
30
30
|
|
|
31
|
-
store.selectItem(2, true);
|
|
31
|
+
const result1 = store.selectItem(2, true);
|
|
32
32
|
t.is(store.state.internalValue, 2);
|
|
33
33
|
t.is(store.state.status.hasChanged, true);
|
|
34
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
34
35
|
|
|
35
36
|
/* reset status to check that it is modified */
|
|
36
37
|
store.state.status.hasChanged = false;
|
|
37
38
|
|
|
38
|
-
store.selectItem(5, true);
|
|
39
|
+
const result2 = store.selectItem(5, true);
|
|
39
40
|
t.is(store.state.internalValue, 5);
|
|
40
41
|
t.is(store.state.status.hasChanged, true);
|
|
42
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
41
43
|
t.end();
|
|
42
44
|
});
|
|
43
45
|
|
|
@@ -48,27 +50,31 @@ tape.test('selectItem()', (st) => {
|
|
|
48
50
|
/* reset status to check that it is modified */
|
|
49
51
|
store.state.status.hasChanged = false;
|
|
50
52
|
|
|
51
|
-
store.selectItem(2, false);
|
|
53
|
+
const result = store.selectItem(2, false);
|
|
52
54
|
t.is(store.state.internalValue, null);
|
|
53
55
|
t.is(store.state.status.hasChanged, true);
|
|
54
56
|
|
|
55
57
|
t.is(store.state.selectionIsExcluded, false);
|
|
58
|
+
t.is(result, true, 'should return if a change occurs');
|
|
56
59
|
t.end();
|
|
57
60
|
});
|
|
58
61
|
|
|
59
|
-
sTest.test('should not change when applying on
|
|
62
|
+
sTest.test('should not change when applying on item with same state', (t) => {
|
|
60
63
|
const store = getStore();
|
|
61
64
|
|
|
62
65
|
store.selectItem(2, true);
|
|
63
66
|
/* reset status to check that it is not modified */
|
|
64
67
|
store.state.status.hasChanged = false;
|
|
65
68
|
|
|
66
|
-
store.selectItem(2, true);
|
|
69
|
+
const result1 = store.selectItem(2, true);
|
|
67
70
|
t.is(store.state.internalValue, 2);
|
|
71
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
68
72
|
|
|
69
|
-
store.selectItem(5, false);
|
|
73
|
+
const result2 = store.selectItem(5, false);
|
|
70
74
|
t.is(store.state.internalValue, 2);
|
|
71
75
|
t.is(store.state.status.hasChanged, false);
|
|
76
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
77
|
+
|
|
72
78
|
t.end();
|
|
73
79
|
});
|
|
74
80
|
|
|
@@ -79,38 +85,44 @@ tape.test('selectItem()', (st) => {
|
|
|
79
85
|
/* reset status to check that it is not modified */
|
|
80
86
|
store.state.status.hasChanged = false;
|
|
81
87
|
|
|
82
|
-
store.selectItem(4, true);
|
|
88
|
+
const result1 = store.selectItem(4, true);
|
|
83
89
|
t.is(store.state.internalValue, 2);
|
|
84
90
|
t.is(store.state.status.hasChanged, false);
|
|
91
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
85
92
|
|
|
86
93
|
store.state.internalValue = 4;
|
|
87
94
|
store.state.status.hasChanged = false;
|
|
88
95
|
|
|
89
|
-
store.selectItem(4, false);
|
|
96
|
+
const result2 = store.selectItem(4, false);
|
|
90
97
|
t.is(store.state.internalValue, 4);
|
|
91
98
|
t.is(store.state.status.hasChanged, false);
|
|
99
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
100
|
+
|
|
92
101
|
t.end();
|
|
93
102
|
});
|
|
94
103
|
|
|
95
104
|
sTest.test('should select items when toggling', (t) => {
|
|
96
105
|
const store = getStore();
|
|
97
106
|
|
|
98
|
-
store.selectItem(2);
|
|
107
|
+
const result1 = store.selectItem(2);
|
|
99
108
|
t.is(store.state.internalValue, 2);
|
|
100
109
|
t.is(store.state.status.hasChanged, true);
|
|
110
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
101
111
|
|
|
102
112
|
/* reset status to check that it is modified */
|
|
103
113
|
store.state.status.hasChanged = false;
|
|
104
114
|
|
|
105
115
|
/* In single value, toggling will not unselect */
|
|
106
|
-
store.selectItem(2);
|
|
116
|
+
const result2 = store.selectItem(2);
|
|
107
117
|
t.is(store.state.internalValue, 2);
|
|
108
118
|
t.is(store.state.status.hasChanged, false);
|
|
119
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
109
120
|
|
|
110
121
|
/* disabled case */
|
|
111
|
-
store.selectItem(4);
|
|
122
|
+
const result3 = store.selectItem(4);
|
|
112
123
|
t.is(store.state.internalValue, 2);
|
|
113
124
|
t.is(store.state.status.hasChanged, false);
|
|
125
|
+
t.is(result3, false, 'should return if a change occurs');
|
|
114
126
|
|
|
115
127
|
t.is(store.state.selectionIsExcluded, false);
|
|
116
128
|
t.end();
|
|
@@ -120,15 +132,19 @@ tape.test('selectItem()', (st) => {
|
|
|
120
132
|
const store = getStore();
|
|
121
133
|
store.commit('isOpen', true);
|
|
122
134
|
|
|
123
|
-
store.selectItem(2, true);
|
|
135
|
+
const result1 = store.selectItem(2, true);
|
|
124
136
|
t.is(store.state.filteredOptions[2].selected, true);
|
|
137
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
125
138
|
|
|
126
|
-
store.selectItem(5, true);
|
|
139
|
+
const result2 = store.selectItem(5, true);
|
|
127
140
|
t.is(store.state.filteredOptions[2].selected, false);
|
|
128
141
|
t.is(store.state.filteredOptions[5].selected, true);
|
|
142
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
129
143
|
|
|
130
|
-
store.selectItem(5, false);
|
|
144
|
+
const result3 = store.selectItem(5, false);
|
|
131
145
|
t.is(store.state.filteredOptions[5].selected, false);
|
|
146
|
+
t.is(result3, true, 'should return if a change occurs');
|
|
147
|
+
|
|
132
148
|
t.end();
|
|
133
149
|
});
|
|
134
150
|
|
|
@@ -159,43 +175,50 @@ tape.test('selectItem()', (st) => {
|
|
|
159
175
|
store.commit('isOpen', true);
|
|
160
176
|
store.state.internalValue = 1;
|
|
161
177
|
|
|
162
|
-
store.selectItem(null);
|
|
178
|
+
const result1 = store.selectItem(null);
|
|
163
179
|
t.is(store.state.isOpen, false);
|
|
164
180
|
t.is(store.state.internalValue, null);
|
|
165
181
|
t.is(store.state.status.hasChanged, true);
|
|
182
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
166
183
|
|
|
167
184
|
store.state.status.hasChanged = false;
|
|
168
185
|
store.state.internalValue = 2;
|
|
169
186
|
|
|
170
187
|
/* applied also when selectic is closed */
|
|
171
|
-
store.selectItem(null);
|
|
188
|
+
const result2 = store.selectItem(null);
|
|
172
189
|
t.is(store.state.internalValue, null);
|
|
173
190
|
t.is(store.state.status.hasChanged, true);
|
|
191
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
174
192
|
|
|
175
193
|
store.state.status.hasChanged = false;
|
|
176
194
|
store.state.internalValue = 3;
|
|
177
195
|
|
|
178
196
|
/* ignore the selected argument */
|
|
179
|
-
store.selectItem(null, false);
|
|
197
|
+
const result3 = store.selectItem(null, false);
|
|
180
198
|
t.is(store.state.internalValue, null);
|
|
181
199
|
t.is(store.state.status.hasChanged, true);
|
|
200
|
+
t.is(result3, true, 'should return if a change occurs');
|
|
201
|
+
|
|
182
202
|
t.end();
|
|
183
203
|
});
|
|
184
204
|
|
|
185
205
|
sTest.test('should reject invalid value with strictValue', (t) => {
|
|
186
206
|
const store = getStore();
|
|
187
207
|
|
|
188
|
-
store.selectItem(456, true);
|
|
208
|
+
const result1 = store.selectItem(456, true);
|
|
189
209
|
t.is(store.state.internalValue, null);
|
|
190
210
|
t.is(store.state.status.hasChanged, false);
|
|
211
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
191
212
|
|
|
192
213
|
store.selectItem(2, true);
|
|
193
214
|
/* reset status to check that it is not modified */
|
|
194
215
|
store.state.status.hasChanged = false;
|
|
195
216
|
|
|
196
|
-
store.selectItem('3', true);
|
|
217
|
+
const result2 = store.selectItem('3', true);
|
|
197
218
|
t.is(store.state.internalValue, 2);
|
|
198
219
|
t.is(store.state.status.hasChanged, false);
|
|
220
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
221
|
+
|
|
199
222
|
t.end();
|
|
200
223
|
});
|
|
201
224
|
});
|
|
@@ -222,13 +245,15 @@ tape.test('selectItem()', (st) => {
|
|
|
222
245
|
|
|
223
246
|
t.deepEqual(store.state.internalValue, []);
|
|
224
247
|
|
|
225
|
-
store.selectItem(2, true);
|
|
248
|
+
const result1 = store.selectItem(2, true);
|
|
226
249
|
t.deepEqual(store.state.internalValue, [2]);
|
|
227
250
|
t.is(store.state.status.hasChanged, true);
|
|
251
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
228
252
|
|
|
229
|
-
store.selectItem(5, true);
|
|
253
|
+
const result2 = store.selectItem(5, true);
|
|
230
254
|
t.deepEqual(store.state.internalValue, [2, 5]);
|
|
231
255
|
t.is(store.state.status.hasChanged, true);
|
|
256
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
232
257
|
|
|
233
258
|
t.is(store.state.selectionIsExcluded, false);
|
|
234
259
|
t.end();
|
|
@@ -237,14 +262,20 @@ tape.test('selectItem()', (st) => {
|
|
|
237
262
|
sTest.test('should keep order in which they where selected', (t) => {
|
|
238
263
|
const store = getStore();
|
|
239
264
|
|
|
240
|
-
store.selectItem(2, true);
|
|
241
|
-
store.selectItem(5, true);
|
|
242
|
-
store.selectItem(1, true);
|
|
243
|
-
store.selectItem(3, true);
|
|
265
|
+
const result1 = store.selectItem(2, true);
|
|
266
|
+
const result2 = store.selectItem(5, true);
|
|
267
|
+
const result3 = store.selectItem(1, true);
|
|
268
|
+
const result4 = store.selectItem(3, true);
|
|
244
269
|
t.deepEqual(store.state.internalValue, [2, 5, 1, 3]);
|
|
270
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
271
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
272
|
+
t.is(result3, true, 'should return if a change occurs');
|
|
273
|
+
t.is(result4, true, 'should return if a change occurs');
|
|
245
274
|
|
|
246
|
-
store.selectItem(5, true);
|
|
275
|
+
const result5 = store.selectItem(5, true);
|
|
247
276
|
t.deepEqual(store.state.internalValue, [2, 5, 1, 3]);
|
|
277
|
+
t.is(result5, false, 'should return if a change occurs');
|
|
278
|
+
|
|
248
279
|
t.end();
|
|
249
280
|
});
|
|
250
281
|
|
|
@@ -255,9 +286,10 @@ tape.test('selectItem()', (st) => {
|
|
|
255
286
|
/* reset status to check that it is modified */
|
|
256
287
|
store.state.status.hasChanged = false;
|
|
257
288
|
|
|
258
|
-
store.selectItem(2, false);
|
|
289
|
+
const result1 = store.selectItem(2, false);
|
|
259
290
|
t.deepEqual(store.state.internalValue, []);
|
|
260
291
|
t.is(store.state.status.hasChanged, true);
|
|
292
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
261
293
|
|
|
262
294
|
store.selectItem(2, true);
|
|
263
295
|
store.selectItem(3, true);
|
|
@@ -265,25 +297,30 @@ tape.test('selectItem()', (st) => {
|
|
|
265
297
|
/* reset status to check that it is modified */
|
|
266
298
|
store.state.status.hasChanged = false;
|
|
267
299
|
|
|
268
|
-
store.selectItem(3, false);
|
|
300
|
+
const result2 = store.selectItem(3, false);
|
|
269
301
|
t.deepEqual(store.state.internalValue, [2, 5]);
|
|
270
302
|
t.is(store.state.status.hasChanged, true);
|
|
303
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
304
|
+
|
|
271
305
|
t.end();
|
|
272
306
|
});
|
|
273
307
|
|
|
274
|
-
sTest.test('should not change when applying on
|
|
308
|
+
sTest.test('should not change when applying on item with same state', (t) => {
|
|
275
309
|
const store = getStore();
|
|
276
310
|
|
|
277
311
|
store.selectItem(2, true);
|
|
278
312
|
/* reset status to check that it is not modified */
|
|
279
313
|
store.state.status.hasChanged = false;
|
|
280
314
|
|
|
281
|
-
store.selectItem(2, true);
|
|
315
|
+
const result1 = store.selectItem(2, true);
|
|
282
316
|
t.deepEqual(store.state.internalValue, [2]);
|
|
317
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
283
318
|
|
|
284
|
-
store.selectItem(5, false);
|
|
319
|
+
const result2 = store.selectItem(5, false);
|
|
285
320
|
t.deepEqual(store.state.internalValue, [2]);
|
|
286
321
|
t.is(store.state.status.hasChanged, false);
|
|
322
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
323
|
+
|
|
287
324
|
t.end();
|
|
288
325
|
});
|
|
289
326
|
|
|
@@ -294,40 +331,46 @@ tape.test('selectItem()', (st) => {
|
|
|
294
331
|
/* reset status to check that it is not modified */
|
|
295
332
|
store.state.status.hasChanged = false;
|
|
296
333
|
|
|
297
|
-
store.selectItem(4, true);
|
|
334
|
+
const result1 = store.selectItem(4, true);
|
|
298
335
|
t.deepEqual(store.state.internalValue, [2]);
|
|
299
336
|
t.is(store.state.status.hasChanged, false);
|
|
337
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
300
338
|
|
|
301
339
|
store.state.internalValue = [1, 4];
|
|
302
340
|
store.state.status.hasChanged = false;
|
|
303
341
|
|
|
304
|
-
store.selectItem(4, false);
|
|
342
|
+
const result2 = store.selectItem(4, false);
|
|
305
343
|
t.deepEqual(store.state.internalValue, [1, 4]);
|
|
306
344
|
t.is(store.state.status.hasChanged, false);
|
|
345
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
346
|
+
|
|
307
347
|
t.end();
|
|
308
348
|
});
|
|
309
349
|
|
|
310
350
|
sTest.test('should toggle item selection', (t) => {
|
|
311
351
|
const store = getStore();
|
|
312
352
|
|
|
313
|
-
store.selectItem(2);
|
|
353
|
+
const result1 = store.selectItem(2);
|
|
314
354
|
t.deepEqual(store.state.internalValue, [2]);
|
|
315
355
|
t.is(store.state.status.hasChanged, true);
|
|
356
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
316
357
|
|
|
317
358
|
/* reset status to check that it is modified */
|
|
318
359
|
store.state.status.hasChanged = false;
|
|
319
360
|
|
|
320
|
-
store.selectItem(2);
|
|
361
|
+
const result2 = store.selectItem(2);
|
|
321
362
|
t.deepEqual(store.state.internalValue, []);
|
|
322
363
|
t.is(store.state.status.hasChanged, true);
|
|
364
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
323
365
|
|
|
324
366
|
/* reset status to check that it is modified */
|
|
325
367
|
store.state.status.hasChanged = false;
|
|
326
368
|
|
|
327
369
|
/* disabled case */
|
|
328
|
-
store.selectItem(4);
|
|
370
|
+
const result3 = store.selectItem(4);
|
|
329
371
|
t.deepEqual(store.state.internalValue, []);
|
|
330
372
|
t.is(store.state.status.hasChanged, false);
|
|
373
|
+
t.is(result3, false, 'should return if a change occurs');
|
|
331
374
|
|
|
332
375
|
t.is(store.state.selectionIsExcluded, false);
|
|
333
376
|
t.end();
|
|
@@ -369,48 +412,55 @@ tape.test('selectItem()', (st) => {
|
|
|
369
412
|
const store = getStore();
|
|
370
413
|
store.state.internalValue = [1, 4];
|
|
371
414
|
|
|
372
|
-
store.selectItem(null);
|
|
415
|
+
const result1 = store.selectItem(null);
|
|
373
416
|
t.deepEqual(store.state.internalValue, []);
|
|
374
417
|
t.is(store.state.status.hasChanged, true);
|
|
418
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
375
419
|
|
|
376
420
|
store.state.status.hasChanged = false;
|
|
377
421
|
store.state.internalValue = [2, 4];
|
|
378
422
|
|
|
379
423
|
/* ignore the selected argument */
|
|
380
|
-
store.selectItem(null, false);
|
|
424
|
+
const result2 = store.selectItem(null, false);
|
|
381
425
|
t.deepEqual(store.state.internalValue, []);
|
|
382
426
|
t.is(store.state.status.hasChanged, true);
|
|
427
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
383
428
|
|
|
384
429
|
store.state.status.hasChanged = false;
|
|
385
430
|
store.state.internalValue = [3, 4];
|
|
386
431
|
|
|
387
432
|
/* applied also when selectic is open */
|
|
388
433
|
store.commit('isOpen', true);
|
|
389
|
-
store.selectItem(null);
|
|
434
|
+
const result3 = store.selectItem(null);
|
|
390
435
|
t.is(store.state.isOpen, true);
|
|
391
436
|
t.deepEqual(store.state.internalValue, []);
|
|
392
437
|
t.is(store.state.status.hasChanged, true);
|
|
438
|
+
t.is(result3, true, 'should return if a change occurs');
|
|
393
439
|
t.end();
|
|
394
440
|
});
|
|
395
441
|
|
|
396
442
|
sTest.test('should not change when applying on invalid values with strictValue', (t) => {
|
|
397
443
|
const store = getStore();
|
|
398
444
|
|
|
399
|
-
store.selectItem(1.5, true);
|
|
445
|
+
const result1 = store.selectItem(1.5, true);
|
|
400
446
|
t.deepEqual(store.state.internalValue, []);
|
|
401
447
|
t.is(store.state.status.hasChanged, false);
|
|
448
|
+
t.is(result1, false, 'should return if a change occurs');
|
|
402
449
|
|
|
403
450
|
store.selectItem(2, true);
|
|
404
451
|
/* reset status to check that it is not modified */
|
|
405
452
|
store.state.status.hasChanged = false;
|
|
406
453
|
|
|
407
|
-
store.selectItem(-42, true);
|
|
454
|
+
const result2 = store.selectItem(-42, true);
|
|
408
455
|
t.deepEqual(store.state.internalValue, [2]);
|
|
409
456
|
t.is(store.state.status.hasChanged, false);
|
|
457
|
+
t.is(result2, false, 'should return if a change occurs');
|
|
410
458
|
|
|
411
|
-
store.selectItem('2', false);
|
|
459
|
+
const result3 = store.selectItem('2', false);
|
|
412
460
|
t.deepEqual(store.state.internalValue, [2]);
|
|
413
461
|
t.is(store.state.status.hasChanged, false);
|
|
462
|
+
t.is(result3, false, 'should return if a change occurs');
|
|
463
|
+
|
|
414
464
|
t.end();
|
|
415
465
|
});
|
|
416
466
|
|
|
@@ -418,21 +468,25 @@ tape.test('selectItem()', (st) => {
|
|
|
418
468
|
const store = getStore();
|
|
419
469
|
store.state.internalValue = [1, 4, 5];
|
|
420
470
|
|
|
421
|
-
store.selectItem(6, true);
|
|
471
|
+
const result1 = store.selectItem(6, true);
|
|
422
472
|
t.deepEqual(store.state.internalValue, [6]);
|
|
423
473
|
t.is(store.state.status.hasChanged, true);
|
|
474
|
+
t.is(result1, true, 'should return if a change occurs');
|
|
424
475
|
|
|
425
|
-
store.selectItem(7, true);
|
|
476
|
+
const result2 = store.selectItem(7, true);
|
|
426
477
|
t.deepEqual(store.state.internalValue, [7]);
|
|
427
478
|
t.is(store.state.status.hasChanged, true);
|
|
479
|
+
t.is(result2, true, 'should return if a change occurs');
|
|
428
480
|
|
|
429
|
-
store.selectItem(1, true);
|
|
481
|
+
const result3 = store.selectItem(1, true);
|
|
430
482
|
t.deepEqual(store.state.internalValue, [1]);
|
|
431
483
|
t.is(store.state.status.hasChanged, true);
|
|
484
|
+
t.is(result3, true, 'should return if a change occurs');
|
|
432
485
|
|
|
433
|
-
store.selectItem(5, true);
|
|
486
|
+
const result4 = store.selectItem(5, true);
|
|
434
487
|
t.deepEqual(store.state.internalValue, [1, 5]);
|
|
435
488
|
t.is(store.state.status.hasChanged, true);
|
|
489
|
+
t.is(result4, true, 'should return if a change occurs');
|
|
436
490
|
|
|
437
491
|
t.is(store.state.selectionIsExcluded, false);
|
|
438
492
|
t.end();
|
package/test/helper.js
CHANGED
|
@@ -4,46 +4,45 @@ const sleep = _.sleep;
|
|
|
4
4
|
|
|
5
5
|
function getInitialState(replacedAttributes) {
|
|
6
6
|
return _.deepExtend({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
placeholder: '',
|
|
10
|
-
hideFilter: false,
|
|
11
|
-
keepFilterOpen: false,
|
|
12
|
-
allowRevert: undefined,
|
|
13
|
-
forceSelectAll: 'auto',
|
|
7
|
+
activeItemIdx: -1,
|
|
8
|
+
allOptions: [],
|
|
14
9
|
allowClearSelection: false,
|
|
15
|
-
|
|
10
|
+
allowRevert: undefined,
|
|
16
11
|
autoDisabled: true,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
autoSelect: true,
|
|
13
|
+
disabled: false,
|
|
14
|
+
disableGroupSelection: false,
|
|
15
|
+
dynOptions: [],
|
|
16
|
+
filteredOptions: [],
|
|
17
|
+
forceSelectAll: 'auto',
|
|
18
|
+
groups: new Map(),
|
|
19
|
+
hideFilter: false,
|
|
20
20
|
internalValue: null,
|
|
21
21
|
isOpen: false,
|
|
22
|
+
keepFilterOpen: false,
|
|
23
|
+
listPosition: 'auto',
|
|
24
|
+
multiple: false,
|
|
25
|
+
offsetItem: 0,
|
|
26
|
+
optionBehaviorOperation: 'sort',
|
|
27
|
+
optionBehaviorOrder: ['O', 'D', 'E'],
|
|
28
|
+
pageSize: 100,
|
|
29
|
+
placeholder: '',
|
|
22
30
|
searchText: '',
|
|
23
|
-
selectionIsExcluded: false,
|
|
24
|
-
allOptions: [],
|
|
25
|
-
dynOptions: [],
|
|
26
|
-
filteredOptions: [],
|
|
27
31
|
selectedOptions: null,
|
|
32
|
+
selectionIsExcluded: false,
|
|
33
|
+
selectionOverflow: 'collapsed',
|
|
34
|
+
strictValue: false,
|
|
28
35
|
totalAllOptions: 0,
|
|
29
36
|
totalDynOptions: 0,
|
|
30
37
|
totalFilteredOptions: Infinity,
|
|
31
|
-
offsetItem: 0,
|
|
32
|
-
activeItemIdx: -1,
|
|
33
|
-
pageSize: 100,
|
|
34
|
-
listPosition: 'auto',
|
|
35
|
-
groups: new Map(),
|
|
36
|
-
|
|
37
|
-
optionBehaviorOperation: 'sort',
|
|
38
|
-
optionBehaviorOrder: ['O', 'D', 'E'],
|
|
39
38
|
|
|
40
39
|
status: {
|
|
41
|
-
searching: false,
|
|
42
|
-
errorMessage: '',
|
|
43
40
|
areAllSelected: false,
|
|
44
|
-
hasChanged: false,
|
|
45
41
|
automaticChange: false,
|
|
46
42
|
automaticClose: false,
|
|
43
|
+
errorMessage: '',
|
|
44
|
+
hasChanged: false,
|
|
45
|
+
searching: false,
|
|
47
46
|
},
|
|
48
47
|
}, replacedAttributes);
|
|
49
48
|
}
|
|
@@ -62,7 +61,7 @@ function getOptions(size, prefix, offset, groupName) {
|
|
|
62
61
|
};
|
|
63
62
|
|
|
64
63
|
if (groupName) {
|
|
65
|
-
obj.group = groupName;
|
|
64
|
+
obj.group = typeof groupName === 'function' ? groupName(index) : groupName;
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
options.push(obj);
|
|
@@ -120,13 +119,18 @@ function buildFetchCb({
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
const nb = Math.min(limit, total - offset);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
const groupName = group.length ? (index) => {
|
|
123
|
+
let name = undefined;
|
|
124
|
+
|
|
125
|
+
group.every((g) => {
|
|
126
|
+
if (index >= g.offset) {
|
|
127
|
+
name = g.name;
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return name;
|
|
133
|
+
} : undefined;
|
|
130
134
|
|
|
131
135
|
function resolveFetch() {
|
|
132
136
|
let result = {
|
package/types/ExtendedList.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vue, h } from 'vtyx';
|
|
2
|
-
import Store from './Store';
|
|
2
|
+
import Store, { OptionItem } from './Store';
|
|
3
3
|
export interface Props {
|
|
4
4
|
store: Store;
|
|
5
5
|
width: number;
|
|
@@ -15,7 +15,8 @@ export default class ExtendedList extends Vue<Props> {
|
|
|
15
15
|
private elementTop;
|
|
16
16
|
private elementBottom;
|
|
17
17
|
private width;
|
|
18
|
-
private
|
|
18
|
+
private topGroupName;
|
|
19
|
+
private topGroupId;
|
|
19
20
|
private listHeight;
|
|
20
21
|
private listWidth;
|
|
21
22
|
private availableSpace;
|
|
@@ -30,10 +31,14 @@ export default class ExtendedList extends Vue<Props> {
|
|
|
30
31
|
get position(): 'top' | 'bottom';
|
|
31
32
|
get horizontalStyle(): string;
|
|
32
33
|
get positionStyle(): string;
|
|
34
|
+
get topGroup(): OptionItem | undefined;
|
|
35
|
+
get topGroupSelected(): boolean;
|
|
36
|
+
get topGroupDisabled(): boolean;
|
|
33
37
|
onFilteredOptionsChange(): void;
|
|
34
38
|
onHideFilterChange(): void;
|
|
35
39
|
private getGroup;
|
|
36
40
|
private computeListSize;
|
|
41
|
+
private clickHeaderGroup;
|
|
37
42
|
mounted(): void;
|
|
38
43
|
unmounted(): void;
|
|
39
44
|
render(): h.JSX.Element;
|
package/types/Icon.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Vue } from 'vtyx';
|
|
2
|
+
import Store from './Store';
|
|
3
|
+
export interface Props {
|
|
4
|
+
store: Store;
|
|
5
|
+
icon: string;
|
|
6
|
+
spin?: boolean;
|
|
7
|
+
title?: string;
|
|
8
|
+
}
|
|
9
|
+
export default class Icon extends Vue<Props> {
|
|
10
|
+
private store;
|
|
11
|
+
private icon;
|
|
12
|
+
private spin?;
|
|
13
|
+
private title?;
|
|
14
|
+
private get rawIconValue();
|
|
15
|
+
private get family();
|
|
16
|
+
private get iconValue();
|
|
17
|
+
private get vueIcon();
|
|
18
|
+
private get spinClass();
|
|
19
|
+
private get spinActive();
|
|
20
|
+
private renderInnerIcon;
|
|
21
|
+
private renderSpanIcon;
|
|
22
|
+
render(): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>;
|
|
25
|
+
}
|