@pingux/astro 1.32.1-alpha.6 → 1.32.1

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.
@@ -131,31 +131,31 @@ test('should upload a file if label clicked', /*#__PURE__*/_asyncToGenerator( /*
131
131
  }
132
132
  }, _callee2);
133
133
  })));
134
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
135
- var imageUploadLabel, imagePreview;
134
+ test('should show the menu if image preview is clicked when preview image exists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
135
+ var imagePreview;
136
136
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
137
137
  while (1) {
138
138
  switch (_context3.prev = _context3.next) {
139
139
  case 0:
140
140
  getComponent();
141
- imageUploadLabel = screen.getByText(testLabel);
142
141
  fireEvent.change(screen.getByTestId('image-upload-input'), {
143
142
  target: {
144
143
  files: [file]
145
144
  }
146
145
  });
147
- _context3.next = 5;
146
+ _context3.next = 4;
148
147
  return screen.findByTestId(imageUploadImagePreview);
149
148
 
150
- case 5:
149
+ case 4:
151
150
  imagePreview = _context3.sent;
152
151
  expect(imagePreview).toBeInTheDocument();
153
- expect(imagePreview).toHaveAttribute('src');
154
- userEvent.click(imageUploadLabel);
152
+ expect(imagePreview).toHaveAttribute('src'); // Click on the image preview button
153
+
154
+ userEvent.click(screen.getByRole('button'));
155
155
  expect(screen.getByText('Upload New Image')).toBeInTheDocument();
156
156
  expect(screen.getByText('Remove Image')).toBeInTheDocument();
157
157
 
158
- case 11:
158
+ case 10:
159
159
  case "end":
160
160
  return _context3.stop();
161
161
  }
@@ -352,8 +352,8 @@ test('loader size can be changed via the prop', function () {
352
352
  'font-size': "".concat(testLoaderSize, "px")
353
353
  });
354
354
  });
355
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
356
- var customUploadProp, customRemoveProp, imageUploadLabel, imagePreview;
355
+ test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
356
+ var customUploadProp, customRemoveProp, imagePreview;
357
357
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
358
358
  while (1) {
359
359
  switch (_context6.prev = _context6.next) {
@@ -364,24 +364,24 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
364
364
  uploadItemText: customUploadProp,
365
365
  removeItemText: customRemoveProp
366
366
  });
367
- imageUploadLabel = screen.getByText(testLabel);
368
367
  fireEvent.change(screen.getByTestId('image-upload-input'), {
369
368
  target: {
370
369
  files: [file]
371
370
  }
372
371
  });
373
- _context6.next = 7;
372
+ _context6.next = 6;
374
373
  return screen.findByTestId(imageUploadImagePreview);
375
374
 
376
- case 7:
375
+ case 6:
377
376
  imagePreview = _context6.sent;
378
377
  expect(imagePreview).toBeInTheDocument();
379
- expect(imagePreview).toHaveAttribute('src');
380
- userEvent.click(imageUploadLabel);
378
+ expect(imagePreview).toHaveAttribute('src'); // Click on the image preview button
379
+
380
+ userEvent.click(screen.getByRole('button'));
381
381
  expect(screen.getByText(customUploadProp)).toBeInTheDocument();
382
382
  expect(screen.getByText(customRemoveProp)).toBeInTheDocument();
383
383
 
384
- case 13:
384
+ case 12:
385
385
  case "end":
386
386
  return _context6.stop();
387
387
  }
@@ -431,11 +431,13 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
431
431
  }, ariaProps, inputProps)), helperText && ___EmotionJSX(FieldHelperText, {
432
432
  status: status
433
433
  }, helperText), ___EmotionJSX(PopoverContainer, {
434
- ref: popoverRef,
435
434
  hasNoArrow: true,
435
+ isDismissable: true,
436
436
  isNonModal: true,
437
437
  isOpen: isOpen,
438
+ onClose: close,
438
439
  placement: placement,
440
+ ref: popoverRef,
439
441
  style: style
440
442
  }, listbox));
441
443
  });
@@ -76,7 +76,8 @@ test('opens listbox on focus and fires "onFocus', function () {
76
76
  onFocus: onFocus
77
77
  });
78
78
  var input = screen.getByRole('combobox');
79
- input.focus();
79
+ userEvent.tab();
80
+ expect(input).toHaveFocus();
80
81
  expect(screen.getByRole('listbox')).toBeInTheDocument();
81
82
  var options = screen.getAllByRole('option');
82
83
  expect(options.length).toBe(items.length);
@@ -89,7 +90,8 @@ test('closes listbox on blur and fires "onBlur"', function () {
89
90
  onBlur: onBlur
90
91
  });
91
92
  var input = screen.getByRole('combobox');
92
- input.focus();
93
+ userEvent.tab();
94
+ expect(input).toHaveFocus();
93
95
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
94
96
  input.blur();
95
97
  expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
@@ -101,7 +103,8 @@ test('opening and closing listbox fires "onOpenChange"', function () {
101
103
  onOpenChange: onOpenChange
102
104
  });
103
105
  var input = screen.getByRole('combobox');
104
- input.focus();
106
+ userEvent.tab();
107
+ expect(input).toHaveFocus();
105
108
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
106
109
  expect(onOpenChange).toHaveBeenCalledWith(true);
107
110
  input.blur();
@@ -111,7 +114,8 @@ test('opening and closing listbox fires "onOpenChange"', function () {
111
114
  test('multiple selection is enabled, option disappears after selection', function () {
112
115
  getComponent();
113
116
  var input = screen.getByRole('combobox');
114
- input.focus();
117
+ userEvent.tab();
118
+ expect(input).toHaveFocus();
115
119
  var listbox = screen.getByRole('listbox');
116
120
  expect(listbox).toHaveAttribute('aria-multiselectable', 'true');
117
121
  var options = within(listbox).getAllByRole('option');
@@ -125,7 +129,8 @@ test('multiple selection is enabled, option disappears after selection', functio
125
129
  test('clicking an option renders chip with option name', function () {
126
130
  getComponent();
127
131
  var input = screen.getByRole('combobox');
128
- input.focus();
132
+ userEvent.tab();
133
+ expect(input).toHaveFocus();
129
134
  var options = screen.getAllByRole('option');
130
135
  var firstOption = options[0];
131
136
  firstOption.click();
@@ -138,7 +143,8 @@ test('clicking an option renders chip with option name', function () {
138
143
  test('clicking on delete button deletes selection, and re-adds option to list', function () {
139
144
  getComponent();
140
145
  var input = screen.getByRole('combobox');
141
- input.focus();
146
+ userEvent.tab();
147
+ expect(input).toHaveFocus();
142
148
  var options = screen.getAllByRole('option');
143
149
  var firstOption = options[0];
144
150
  firstOption.click();
@@ -148,7 +154,8 @@ test('clicking on delete button deletes selection, and re-adds option to list',
148
154
  var deleteButton = chip.nextSibling;
149
155
  deleteButton.click();
150
156
  expect(chip).not.toBeInTheDocument();
151
- input.focus();
157
+ userEvent.tab();
158
+ expect(input).toHaveFocus();
152
159
  var updatedOptions = screen.getAllByRole('option');
153
160
  expect(updatedOptions[0]).toBeInTheDocument();
154
161
  expect(updatedOptions[0]).toHaveTextContent(items[0].name);
@@ -159,7 +166,8 @@ test('clicking an option fires "onSelectionChange"', function () {
159
166
  onSelectionChange: onSelectionChange
160
167
  });
161
168
  var input = screen.getByRole('combobox');
162
- input.focus();
169
+ userEvent.tab();
170
+ expect(input).toHaveFocus();
163
171
  var listbox = screen.getByRole('listbox');
164
172
  var options = within(listbox).getAllByRole('option');
165
173
  var firstOption = options[0];
@@ -253,7 +261,8 @@ test('in non-restrictive mode the value that was already selected using the list
253
261
  onSelectionChange: onSelectionChange
254
262
  });
255
263
  var input = screen.getByRole('combobox');
256
- input.focus();
264
+ userEvent.tab();
265
+ expect(input).toHaveFocus();
257
266
  var listbox = screen.getByRole('listbox');
258
267
  var options = within(listbox).getAllByRole('option');
259
268
  var firstOption = options[0];
@@ -268,7 +277,8 @@ test('in non-restrictive mode the value that was already selected using the list
268
277
  test('options can be focused via keyboard', function () {
269
278
  getComponent();
270
279
  var input = screen.getByRole('combobox');
271
- input.focus();
280
+ userEvent.tab();
281
+ expect(input).toHaveFocus();
272
282
  var listbox = screen.getByRole('listbox');
273
283
  expect(listbox).toBeInTheDocument();
274
284
  var options = within(listbox).getAllByRole('option');
@@ -284,7 +294,8 @@ test('options can be focused via keyboard', function () {
284
294
  test('options can be selected via keyboard', function () {
285
295
  getComponent();
286
296
  var input = screen.getByRole('combobox');
287
- input.focus();
297
+ userEvent.tab();
298
+ expect(input).toHaveFocus();
288
299
  var listbox = screen.getByRole('listbox');
289
300
  expect(listbox).toBeInTheDocument();
290
301
  var options = within(listbox).getAllByRole('option');
@@ -394,4 +405,19 @@ test('read only keys with read only field', function () {
394
405
  var textArea = screen.getByLabelText(defaultProps.label);
395
406
  expect(textArea).toHaveClass('is-read-only');
396
407
  expect(screen.queryByRole('option')).not.toBeInTheDocument();
408
+ });
409
+ test('popover closes on input blur', function () {
410
+ getComponent();
411
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
412
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
413
+ var input = screen.getByRole('combobox');
414
+ userEvent.click(input);
415
+ expect(screen.queryByRole('listbox')).toBeInTheDocument();
416
+ expect(screen.queryAllByRole('option')).toHaveLength(3);
417
+ expect(screen.queryByRole('option', {
418
+ name: 'Aardvark'
419
+ })).toBeInTheDocument();
420
+ userEvent.click(document.body);
421
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
422
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
397
423
  });
@@ -96,7 +96,7 @@ export var PopoverWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
96
96
  });
97
97
 
98
98
  var _useOverlay = useOverlay(_objectSpread(_objectSpread({}, props), {}, {
99
- isDismissable: isDismissable && isOpen
99
+ shouldCloseOnBlur: !isNotClosedOnBlur
100
100
  }), popoverRef),
101
101
  overlayProps = _useOverlay.overlayProps;
102
102
 
@@ -391,4 +391,19 @@ test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator(
391
391
  }
392
392
  }
393
393
  }, _callee);
394
- })));
394
+ })));
395
+ test('popover closes on button blur', function () {
396
+ getComponent();
397
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
398
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
399
+ var button = screen.getByRole('button');
400
+ userEvent.click(button);
401
+ expect(screen.queryByRole('listbox')).toBeInTheDocument();
402
+ expect(screen.queryAllByRole('option')).toHaveLength(3);
403
+ expect(screen.queryByRole('option', {
404
+ name: 'a'
405
+ })).toBeInTheDocument();
406
+ userEvent.click(document.body);
407
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
408
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
409
+ });
@@ -201,14 +201,14 @@ var useSelectField = function useSelectField(props, ref) {
201
201
  }));
202
202
 
203
203
  var overlay = ___EmotionJSX(PopoverContainer, {
204
- isOpen: state.isOpen,
205
- ref: popoverRef,
206
- placement: placement,
207
204
  hasNoArrow: true,
208
- onClose: state.close,
209
- style: style,
205
+ isDismissable: true,
210
206
  isNonModal: true,
211
- isDismissable: true
207
+ isOpen: state.isOpen,
208
+ onClose: state.close,
209
+ placement: placement,
210
+ ref: popoverRef,
211
+ style: style
212
212
  }, ___EmotionJSX(ScrollBox, scrollBoxProps, listbox));
213
213
 
214
214
  return {
@@ -136,12 +136,8 @@ var Row = /*#__PURE__*/memo(function (props) {
136
136
  sx: sx.comboBoxField
137
137
  },
138
138
  containerProps: {
139
- 'aria-label': 'selection field',
140
139
  width: '100%',
141
- maxWidth: '310px',
142
- sx: {
143
- width: '100%'
144
- }
140
+ maxWidth: '310px'
145
141
  },
146
142
  inputValue: inputValue,
147
143
  onInputChange: setInputValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.32.1-alpha.6",
3
+ "version": "1.32.1",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",