@pingux/astro 1.37.0 → 1.37.1-alpha.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/lib/cjs/components/MultivaluesField/MultivaluesField.js +51 -26
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +173 -11
- package/lib/cjs/hooks/useField/useField.js +3 -2
- package/lib/components/MultivaluesField/MultivaluesField.js +51 -26
- package/lib/components/MultivaluesField/MultivaluesField.test.js +144 -11
- package/lib/hooks/useField/useField.js +3 -2
- package/package.json +1 -1
- package/NOTICE.html +0 -4665
@@ -158,6 +158,62 @@ test('clicking an option renders chip with option name', function () {
|
|
158
158
|
var chipContainer = chip.parentElement;
|
159
159
|
expect(chipContainer).toHaveAttribute('role', 'presentation');
|
160
160
|
});
|
161
|
+
test('after clicking an option, and then clicking the text input, the listbox remains open', function () {
|
162
|
+
getComponent();
|
163
|
+
var input = screen.getByRole('combobox');
|
164
|
+
userEvent.tab();
|
165
|
+
expect(input).toHaveFocus();
|
166
|
+
var options = screen.getAllByRole('option');
|
167
|
+
var firstOption = options[0];
|
168
|
+
firstOption.click();
|
169
|
+
expect(firstOption).not.toBeInTheDocument();
|
170
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
171
|
+
userEvent.click(input);
|
172
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
173
|
+
});
|
174
|
+
test('no chips are rendered, if nothing is selected', function () {
|
175
|
+
getComponent({
|
176
|
+
isReadOnly: false
|
177
|
+
});
|
178
|
+
expect(screen.queryByRole('presentation')).not.toBeInTheDocument(0);
|
179
|
+
});
|
180
|
+
test('after clicking an option, and then typing a custom input, the listbox remains open and filters the options', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
181
|
+
var input, options, firstOption, value, listbox, filteredOptions;
|
182
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
183
|
+
while (1) {
|
184
|
+
switch (_context.prev = _context.next) {
|
185
|
+
case 0:
|
186
|
+
getComponent({
|
187
|
+
mode: 'non-restrictive'
|
188
|
+
});
|
189
|
+
input = screen.getByRole('combobox');
|
190
|
+
userEvent.tab();
|
191
|
+
expect(input).toHaveFocus();
|
192
|
+
options = screen.getAllByRole('option');
|
193
|
+
firstOption = options[0];
|
194
|
+
firstOption.click();
|
195
|
+
expect(firstOption).not.toBeInTheDocument();
|
196
|
+
_context.next = 10;
|
197
|
+
return userEvent.clear(input);
|
198
|
+
|
199
|
+
case 10:
|
200
|
+
value = 'ka';
|
201
|
+
_context.next = 13;
|
202
|
+
return userEvent.type(input, value);
|
203
|
+
|
204
|
+
case 13:
|
205
|
+
listbox = screen.queryByRole('listbox');
|
206
|
+
expect(listbox).toBeInTheDocument();
|
207
|
+
filteredOptions = within(listbox).getAllByRole('option');
|
208
|
+
expect(filteredOptions.length).toBe(1);
|
209
|
+
|
210
|
+
case 17:
|
211
|
+
case "end":
|
212
|
+
return _context.stop();
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}, _callee);
|
216
|
+
})));
|
161
217
|
test('clicking on delete button deletes selection, and re-adds option to list', function () {
|
162
218
|
getComponent();
|
163
219
|
var input = screen.getByRole('combobox');
|
@@ -201,7 +257,8 @@ test('clicking an option fires "onSelectionChange"', function () {
|
|
201
257
|
test('changing the input value opens listbox, filters options, and fires "onInputChange"', function () {
|
202
258
|
var onInputChange = jest.fn();
|
203
259
|
getComponent({
|
204
|
-
onInputChange: onInputChange
|
260
|
+
onInputChange: onInputChange,
|
261
|
+
mode: 'non-restrictive'
|
205
262
|
});
|
206
263
|
var input = screen.getByRole('combobox');
|
207
264
|
var value = 'aa';
|
@@ -213,6 +270,71 @@ test('changing the input value opens listbox, filters options, and fires "onInpu
|
|
213
270
|
expect(onInputChange).toBeCalledTimes(value.length);
|
214
271
|
expect(onInputChange).toHaveBeenCalledWith(value);
|
215
272
|
});
|
273
|
+
test('in non-restrictive mode, a chip gets added if there is input, onBlur', function () {
|
274
|
+
getComponent({
|
275
|
+
mode: 'non-restrictive'
|
276
|
+
});
|
277
|
+
var input = screen.getByRole('combobox');
|
278
|
+
var value = 'custom';
|
279
|
+
userEvent.type(input, value);
|
280
|
+
userEvent.tab();
|
281
|
+
var chip = screen.queryByText(value);
|
282
|
+
expect(chip).toBeInTheDocument();
|
283
|
+
var chipContainer = chip.parentElement;
|
284
|
+
expect(chipContainer).toHaveAttribute('role', 'presentation');
|
285
|
+
expect(input.value).toBe('');
|
286
|
+
});
|
287
|
+
test('in non-restrictive mode, a chip gets added if there is only one matching filtered option, onBlur', function () {
|
288
|
+
getComponent({
|
289
|
+
mode: 'non-restrictive'
|
290
|
+
});
|
291
|
+
var input = screen.getByRole('combobox');
|
292
|
+
userEvent.tab();
|
293
|
+
var listbox = screen.getByRole('listbox');
|
294
|
+
var options = within(listbox).getAllByRole('option');
|
295
|
+
var firstOption = options[0];
|
296
|
+
var value = 'Aardvark';
|
297
|
+
userEvent.type(input, value);
|
298
|
+
userEvent.tab();
|
299
|
+
var chip = screen.queryByText(value);
|
300
|
+
expect(chip).toBeInTheDocument();
|
301
|
+
var chipContainer = chip.parentElement;
|
302
|
+
expect(chipContainer).toHaveAttribute('role', 'presentation');
|
303
|
+
expect(firstOption).not.toBeInTheDocument();
|
304
|
+
});
|
305
|
+
test('dropdown with options reappears after entering a custom input', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
306
|
+
var input, value1, value2, listbox, options2;
|
307
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
308
|
+
while (1) {
|
309
|
+
switch (_context2.prev = _context2.next) {
|
310
|
+
case 0:
|
311
|
+
getComponent({
|
312
|
+
mode: 'non-restrictive'
|
313
|
+
});
|
314
|
+
input = screen.getByRole('combobox');
|
315
|
+
value1 = 'longstring';
|
316
|
+
userEvent.type(input, value1);
|
317
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
318
|
+
value2 = '';
|
319
|
+
_context2.next = 8;
|
320
|
+
return userEvent.clear(input);
|
321
|
+
|
322
|
+
case 8:
|
323
|
+
_context2.next = 10;
|
324
|
+
return userEvent.type(input, value2);
|
325
|
+
|
326
|
+
case 10:
|
327
|
+
listbox = screen.getByRole('listbox');
|
328
|
+
options2 = within(listbox).getAllByRole('option');
|
329
|
+
expect(options2.length).toBe(items.length);
|
330
|
+
|
331
|
+
case 13:
|
332
|
+
case "end":
|
333
|
+
return _context2.stop();
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}, _callee2);
|
337
|
+
})));
|
216
338
|
test('changing the input value and hitting enter by default do nothing', function () {
|
217
339
|
getComponent();
|
218
340
|
var input = screen.getByRole('combobox');
|
@@ -220,8 +342,7 @@ test('changing the input value and hitting enter by default do nothing', functio
|
|
220
342
|
var value = 'custom';
|
221
343
|
userEvent.type(input, value);
|
222
344
|
userEvent.type(input, '{enter}');
|
223
|
-
expect(input).toHaveValue(
|
224
|
-
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
345
|
+
expect(input).toHaveValue('');
|
225
346
|
});
|
226
347
|
test('changing the input value and hitting enter creates new value in non-restrictive mode', function () {
|
227
348
|
getComponent({
|
@@ -239,6 +360,18 @@ test('changing the input value and hitting enter creates new value in non-restri
|
|
239
360
|
var chipContainer = chip.parentElement;
|
240
361
|
expect(chipContainer).toHaveAttribute('role', 'presentation');
|
241
362
|
});
|
363
|
+
test('pressing enter, when the input values is an empty string does not add an option, in non-restrictive mode', function () {
|
364
|
+
var onSelectionChange = jest.fn();
|
365
|
+
getComponent({
|
366
|
+
mode: 'non-restrictive',
|
367
|
+
onSelectionChange: onSelectionChange
|
368
|
+
});
|
369
|
+
var input = screen.getByRole('combobox');
|
370
|
+
expect(input).toHaveValue('');
|
371
|
+
userEvent.type(input, '{enter}');
|
372
|
+
expect(input).toHaveValue('');
|
373
|
+
expect(onSelectionChange).toBeCalledTimes(0);
|
374
|
+
});
|
242
375
|
test('in non-restrictive mode "onSelectionChange" returns entered keys', function () {
|
243
376
|
var onSelectionChange = jest.fn();
|
244
377
|
getComponent({
|
@@ -350,28 +483,28 @@ test('selected keys', function () {
|
|
350
483
|
var secondChip = screen.getByText(items[2].name);
|
351
484
|
expect(secondChip).toBeInTheDocument();
|
352
485
|
});
|
353
|
-
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
486
|
+
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
354
487
|
var _getComponent, container, results;
|
355
488
|
|
356
|
-
return _regeneratorRuntime.wrap(function
|
489
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
357
490
|
while (1) {
|
358
|
-
switch (
|
491
|
+
switch (_context3.prev = _context3.next) {
|
359
492
|
case 0:
|
360
493
|
jest.useRealTimers();
|
361
494
|
_getComponent = getComponent(), container = _getComponent.container;
|
362
|
-
|
495
|
+
_context3.next = 4;
|
363
496
|
return axe(container);
|
364
497
|
|
365
498
|
case 4:
|
366
|
-
results =
|
499
|
+
results = _context3.sent;
|
367
500
|
expect(results).toHaveNoViolations();
|
368
501
|
|
369
502
|
case 6:
|
370
503
|
case "end":
|
371
|
-
return
|
504
|
+
return _context3.stop();
|
372
505
|
}
|
373
506
|
}
|
374
|
-
},
|
507
|
+
}, _callee3);
|
375
508
|
})));
|
376
509
|
test('read only keys', function () {
|
377
510
|
getComponent({
|
@@ -450,7 +583,7 @@ test('form does not submit when adding custom value', function () {
|
|
450
583
|
expect(input).toHaveValue('');
|
451
584
|
var value = 'custom';
|
452
585
|
userEvent.type(input, value);
|
453
|
-
expect(input).toHaveValue(
|
586
|
+
expect(input).toHaveValue('');
|
454
587
|
userEvent.type(input, '{enter}');
|
455
588
|
expect(onFormSubmit).not.toHaveBeenCalled();
|
456
589
|
});
|
@@ -9,7 +9,7 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "children", "className", "containerProps", "controlProps", "defaultText", "defaultValue", "direction", "disabledKeys", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "hintText", "id", "isDefaultSelected", "isDisabled", "isIndeterminate", "isReadOnly", "isRequired", "isSelected", "label", "labelMode", "labelProps", "maxLength", "name", "onBlur", "onChange", "onClear", "onFocus", "onFocusChange", "onLoadMore", "onOpenChange", "onSelectionChange", "placeholder", "role", "selectedKey", "spellCheck", "status", "statusClasses", "type", "value"];
|
12
|
+
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "children", "className", "containerProps", "controlProps", "defaultText", "defaultValue", "direction", "disabledKeys", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "hintText", "id", "isDefaultSelected", "isDisabled", "isIndeterminate", "isReadOnly", "isRequired", "isRestrictiveMultivalues", "isSelected", "label", "labelMode", "labelProps", "maxLength", "name", "onBlur", "onChange", "onClear", "onFocus", "onFocusChange", "onLoadMore", "onOpenChange", "onSelectionChange", "placeholder", "role", "selectedKey", "spellCheck", "status", "statusClasses", "type", "value"];
|
13
13
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
15
15
|
|
@@ -58,6 +58,7 @@ var useField = function useField() {
|
|
58
58
|
isIndeterminate = props.isIndeterminate,
|
59
59
|
isReadOnly = props.isReadOnly,
|
60
60
|
isRequired = props.isRequired,
|
61
|
+
isRestrictiveMultivalues = props.isRestrictiveMultivalues,
|
61
62
|
isSelected = props.isSelected,
|
62
63
|
label = props.label,
|
63
64
|
labelMode = props.labelMode,
|
@@ -187,7 +188,7 @@ var useField = function useField() {
|
|
187
188
|
name: name,
|
188
189
|
onChange: fieldOnChange,
|
189
190
|
placeholder: placeholder,
|
190
|
-
readOnly: isReadOnly,
|
191
|
+
readOnly: isRestrictiveMultivalues ? true : isReadOnly,
|
191
192
|
required: isRequired,
|
192
193
|
role: role,
|
193
194
|
spellCheck: spellCheck,
|