@pingux/astro 2.217.1 → 2.218.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.
@@ -246,10 +246,68 @@ test('should call onChange cb (when provided) when a file is uploaded', function
246
246
  });
247
247
  expect(testOnChange).toHaveBeenCalledTimes(1);
248
248
  });
249
- test('should call onRemove cb (when provided) when a file is uploaded', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
250
- var testOnRemove, imagePreview;
249
+ test('should call onChange cb and render preview when a .ico file with type image/vnd.microsoft.icon is uploaded', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
250
+ var testOnChange;
251
251
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
252
252
  while (1) switch (_context5.prev = _context5.next) {
253
+ case 0:
254
+ testOnChange = jest.fn();
255
+ getComponent({
256
+ onChange: testOnChange
257
+ });
258
+ _react2.fireEvent.change(_testWrapper.screen.getByTestId('image-upload-input'), {
259
+ target: {
260
+ files: [new File(['(⌐□_□)'], 'favicon.ico', {
261
+ type: 'image/vnd.microsoft.icon'
262
+ })]
263
+ }
264
+ });
265
+ expect(testOnChange).toHaveBeenCalledTimes(1);
266
+ _context5.t0 = expect;
267
+ _context5.next = 7;
268
+ return _testWrapper.screen.findByTestId(imageUploadImagePreview);
269
+ case 7:
270
+ _context5.t1 = _context5.sent;
271
+ (0, _context5.t0)(_context5.t1).toBeInTheDocument();
272
+ case 9:
273
+ case "end":
274
+ return _context5.stop();
275
+ }
276
+ }, _callee5);
277
+ })));
278
+ test('should call onChange cb and render preview when a .ico file with type image/x-icon is uploaded', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
279
+ var testOnChange;
280
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
281
+ while (1) switch (_context6.prev = _context6.next) {
282
+ case 0:
283
+ testOnChange = jest.fn();
284
+ getComponent({
285
+ onChange: testOnChange
286
+ });
287
+ _react2.fireEvent.change(_testWrapper.screen.getByTestId('image-upload-input'), {
288
+ target: {
289
+ files: [new File(['(⌐□_□)'], 'favicon.ico', {
290
+ type: 'image/x-icon'
291
+ })]
292
+ }
293
+ });
294
+ expect(testOnChange).toHaveBeenCalledTimes(1);
295
+ _context6.t0 = expect;
296
+ _context6.next = 7;
297
+ return _testWrapper.screen.findByTestId(imageUploadImagePreview);
298
+ case 7:
299
+ _context6.t1 = _context6.sent;
300
+ (0, _context6.t0)(_context6.t1).toBeInTheDocument();
301
+ case 9:
302
+ case "end":
303
+ return _context6.stop();
304
+ }
305
+ }, _callee6);
306
+ })));
307
+ test('should call onRemove cb (when provided) when a file is uploaded', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
308
+ var testOnRemove, imagePreview;
309
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
310
+ while (1) switch (_context7.prev = _context7.next) {
253
311
  case 0:
254
312
  testOnRemove = jest.fn();
255
313
  getComponent({
@@ -260,29 +318,29 @@ test('should call onRemove cb (when provided) when a file is uploaded', /*#__PUR
260
318
  files: [file]
261
319
  }
262
320
  });
263
- _context5.next = 5;
321
+ _context7.next = 5;
264
322
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
265
323
  case 5:
266
- imagePreview = _context5.sent;
267
- _context5.next = 8;
324
+ imagePreview = _context7.sent;
325
+ _context7.next = 8;
268
326
  return _userEvent["default"].click(_testWrapper.screen.getByTestId(testButtonId));
269
327
  case 8:
270
- _context5.t0 = expect;
271
- _context5.next = 11;
328
+ _context7.t0 = expect;
329
+ _context7.next = 11;
272
330
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
273
331
  case 11:
274
- _context5.t1 = _context5.sent;
275
- (0, _context5.t0)(_context5.t1).toBeInTheDocument();
276
- _context5.next = 15;
332
+ _context7.t1 = _context7.sent;
333
+ (0, _context7.t0)(_context7.t1).toBeInTheDocument();
334
+ _context7.next = 15;
277
335
  return _userEvent["default"].click(_testWrapper.screen.getByText('Remove Image'));
278
336
  case 15:
279
337
  expect(imagePreview).not.toBeInTheDocument();
280
338
  expect(testOnRemove).toHaveBeenCalledTimes(1);
281
339
  case 17:
282
340
  case "end":
283
- return _context5.stop();
341
+ return _context7.stop();
284
342
  }
285
- }, _callee5);
343
+ }, _callee7);
286
344
  })));
287
345
  test('should not call onChange cb (when provided) if uploaded file is not allowed by fileTypes', function () {
288
346
  var testOnChange = jest.fn();
@@ -345,9 +403,9 @@ test('should render loader if isLoading prop is true', function () {
345
403
  });
346
404
  expect(_testWrapper.screen.queryByRole('alert')).toBeInTheDocument();
347
405
  });
348
- test('should render image preview and menu when previewImage prop is supplied', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
349
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
350
- while (1) switch (_context6.prev = _context6.next) {
406
+ test('should render image preview and menu when previewImage prop is supplied', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
407
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
408
+ while (1) switch (_context8.prev = _context8.next) {
351
409
  case 0:
352
410
  getComponent({
353
411
  previewImage: 'test'
@@ -355,16 +413,16 @@ test('should render image preview and menu when previewImage prop is supplied',
355
413
  expect(_testWrapper.screen.queryByTestId(imageUploadImagePreview)).toBeInTheDocument();
356
414
  expect(_testWrapper.screen.queryByTestId(imageUploadImagePreview)).toHaveAttribute('src', 'test');
357
415
  expect(_testWrapper.screen.queryByTestId(imageUploadNoImagePreview)).not.toBeInTheDocument();
358
- _context6.next = 6;
416
+ _context8.next = 6;
359
417
  return _userEvent["default"].click(_testWrapper.screen.getByTestId(testButtonId));
360
418
  case 6:
361
419
  expect(_testWrapper.screen.getByText('Upload New Image')).toBeInTheDocument();
362
420
  expect(_testWrapper.screen.getByText('Remove Image')).toBeInTheDocument();
363
421
  case 8:
364
422
  case "end":
365
- return _context6.stop();
423
+ return _context8.stop();
366
424
  }
367
- }, _callee6);
425
+ }, _callee8);
368
426
  })));
369
427
  test('loader size can be changed via the prop', function () {
370
428
  var testLoaderSize = 17;
@@ -374,14 +432,14 @@ test('loader size can be changed via the prop', function () {
374
432
  });
375
433
  expect(_testWrapper.screen.getByTestId('image-preview-button__loader')).toBeInTheDocument();
376
434
  });
377
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
435
+ test('should show the menu if label clicked when preview image exists', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
378
436
  var imageUploadButton, imagePreview, imageUploadLabel;
379
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
380
- while (1) switch (_context7.prev = _context7.next) {
437
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
438
+ while (1) switch (_context9.prev = _context9.next) {
381
439
  case 0:
382
440
  getComponent();
383
441
  imageUploadButton = _testWrapper.screen.getByTestId(testButtonId);
384
- _context7.next = 4;
442
+ _context9.next = 4;
385
443
  return _userEvent["default"].click(imageUploadButton);
386
444
  case 4:
387
445
  _react2.fireEvent.change(_testWrapper.screen.getByTestId('image-upload-input'), {
@@ -389,10 +447,10 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
389
447
  files: [file]
390
448
  }
391
449
  });
392
- _context7.next = 7;
450
+ _context9.next = 7;
393
451
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
394
452
  case 7:
395
- imagePreview = _context7.sent;
453
+ imagePreview = _context9.sent;
396
454
  expect(imagePreview).toBeInTheDocument();
397
455
  expect(imagePreview).toHaveAttribute('src');
398
456
 
@@ -407,14 +465,14 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
407
465
  expect(_testWrapper.screen.getByText('Remove Image')).toBeInTheDocument();
408
466
  case 16:
409
467
  case "end":
410
- return _context7.stop();
468
+ return _context9.stop();
411
469
  }
412
- }, _callee7);
470
+ }, _callee9);
413
471
  })));
414
- test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
472
+ test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0() {
415
473
  var customUploadProp, customRemoveProp, imagePreview;
416
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
417
- while (1) switch (_context8.prev = _context8.next) {
474
+ return _regeneratorRuntime().wrap(function _callee0$(_context0) {
475
+ while (1) switch (_context0.prev = _context0.next) {
418
476
  case 0:
419
477
  customUploadProp = 'Custom Upload';
420
478
  customRemoveProp = 'Custom Remove';
@@ -427,24 +485,24 @@ test('should show the menu if label clicked when preview image exists with custo
427
485
  files: [file]
428
486
  }
429
487
  });
430
- _context8.next = 6;
488
+ _context0.next = 6;
431
489
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
432
490
  case 6:
433
- imagePreview = _context8.sent;
491
+ imagePreview = _context0.sent;
434
492
  expect(imagePreview).toBeInTheDocument();
435
493
  expect(imagePreview).toHaveAttribute('src');
436
494
 
437
495
  // Click on the image preview button
438
- _context8.next = 11;
496
+ _context0.next = 11;
439
497
  return _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
440
498
  case 11:
441
499
  expect(_testWrapper.screen.getByText(customUploadProp)).toBeInTheDocument();
442
500
  expect(_testWrapper.screen.getByText(customRemoveProp)).toBeInTheDocument();
443
501
  case 13:
444
502
  case "end":
445
- return _context8.stop();
503
+ return _context0.stop();
446
504
  }
447
- }, _callee8);
505
+ }, _callee0);
448
506
  })));
449
507
  test('should render node element if passed as default image', function () {
450
508
  getComponent({
@@ -456,10 +514,10 @@ test('should render node element if passed as default image', function () {
456
514
  expect(img).toBeInstanceOf(HTMLImageElement);
457
515
  expect(img).toBeInTheDocument();
458
516
  });
459
- test('should implement popover menu props', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
517
+ test('should implement popover menu props', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1() {
460
518
  var imagePreview;
461
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
462
- while (1) switch (_context9.prev = _context9.next) {
519
+ return _regeneratorRuntime().wrap(function _callee1$(_context1) {
520
+ while (1) switch (_context1.prev = _context1.next) {
463
521
  case 0:
464
522
  getComponent({
465
523
  popoverMenuProps: {
@@ -471,15 +529,15 @@ test('should implement popover menu props', /*#__PURE__*/(0, _asyncToGenerator2[
471
529
  files: [file]
472
530
  }
473
531
  });
474
- _context9.next = 4;
532
+ _context1.next = 4;
475
533
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
476
534
  case 4:
477
- imagePreview = _context9.sent;
535
+ imagePreview = _context1.sent;
478
536
  expect(imagePreview).toBeInTheDocument();
479
537
  expect(imagePreview).toHaveAttribute('src');
480
538
 
481
539
  // Click on the image preview button
482
- _context9.next = 9;
540
+ _context1.next = 9;
483
541
  return _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
484
542
  case 9:
485
543
  expect(_testWrapper.screen.getByRole('presentation')).toBeInTheDocument();
@@ -487,7 +545,7 @@ test('should implement popover menu props', /*#__PURE__*/(0, _asyncToGenerator2[
487
545
  expect(_testWrapper.screen.getByRole('presentation')).toHaveAttribute('data-popover-placement', 'right');
488
546
  case 12:
489
547
  case "end":
490
- return _context9.stop();
548
+ return _context1.stop();
491
549
  }
492
- }, _callee9);
550
+ }, _callee1);
493
551
  })));
@@ -13,11 +13,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
13
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
14
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
15
15
  var _react = _interopRequireWildcard(require("react"));
16
+ var _hooks = require("../../hooks");
16
17
  var _index = require("../../index");
17
18
  var _react2 = require("@emotion/react");
18
19
  var _excluded = ["children", "helpHint", "containerProps", "textProps", "helpHintProps"];
19
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
21
  var displayName = 'PairLabel';
22
+ var H4 = 'h4';
23
+ var H5 = 'h5';
21
24
  var PairLabel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
22
25
  var children = props.children,
23
26
  helpHint = props.helpHint,
@@ -25,19 +28,25 @@ var PairLabel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
25
28
  textProps = props.textProps,
26
29
  helpHintProps = props.helpHintProps,
27
30
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
31
+ var _useGetTheme = (0, _hooks.useGetTheme)(),
32
+ isOnyx = _useGetTheme.themeState.isOnyx;
28
33
  var _React$Children$toArr = _react["default"].Children.toArray(children),
29
34
  _React$Children$toArr2 = (0, _slicedToArray2["default"])(_React$Children$toArr, 2),
30
35
  label = _React$Children$toArr2[0],
31
36
  icon = _React$Children$toArr2[1];
37
+ var defaultTextProps = isOnyx ? {
38
+ variant: H5,
39
+ as: H5
40
+ } : {
41
+ variant: H4,
42
+ as: H4
43
+ };
32
44
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
33
45
  ref: ref,
34
46
  isRow: true,
35
47
  alignItems: "center",
36
48
  gap: "sm"
37
- }, others, containerProps), (0, _react2.jsx)(_index.Text, (0, _extends2["default"])({
38
- variant: "h4",
39
- as: "h4"
40
- }, textProps), label), icon, helpHint && (0, _react2.jsx)(_index.HelpHint, (0, _extends2["default"])({
49
+ }, others, containerProps), (0, _react2.jsx)(_index.Text, (0, _extends2["default"])({}, defaultTextProps, textProps), label), icon, helpHint && (0, _react2.jsx)(_index.HelpHint, (0, _extends2["default"])({
41
50
  iconButtonProps: {
42
51
  'aria-label': "".concat(label, " help hint")
43
52
  }
@@ -18,7 +18,7 @@ var _interactions = require("@react-aria/interactions");
18
18
  var _ = require("../..");
19
19
  var _hooks = require("../../hooks");
20
20
  var _react2 = require("@emotion/react");
21
- var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef"];
21
+ var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef", "focusScopeProps"];
22
22
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
23
  var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
24
24
  var _props$sx;
@@ -30,6 +30,7 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
30
30
  state = props.state,
31
31
  size = props.size,
32
32
  triggerRef = props.triggerRef,
33
+ focusScopeProps = props.focusScopeProps,
33
34
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
34
35
  var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
35
36
  onClose = _useOverlayPanelState.onClose;
@@ -55,9 +56,9 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
55
56
  onClose(state, triggerRef, onCloseProp);
56
57
  }
57
58
  };
58
- return (0, _react2.jsx)(_reactAria.FocusScope, {
59
+ return (0, _react2.jsx)(_reactAria.FocusScope, (0, _extends2["default"])({
59
60
  autoFocus: true
60
- }, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
61
+ }, focusScopeProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
61
62
  variant: "overlayPanel.container",
62
63
  ref: overlayPanelRef
63
64
  }, others, {
@@ -141,6 +141,16 @@ test('triggerRef.current.focus() fires when provided', function () {
141
141
  });
142
142
  expect(focusFunction).toHaveBeenCalled();
143
143
  });
144
+ test('focusScopeProps are forwarded to FocusScope', function () {
145
+ getComponent({
146
+ children: (0, _react2.jsx)("div", null, "Test"),
147
+ focusScopeProps: {
148
+ contain: true
149
+ }
150
+ });
151
+ var overlayPanel = _testWrapper.screen.getByTestId(testId);
152
+ expect(overlayPanel).toBeInTheDocument();
153
+ });
144
154
  test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
145
155
  var onClose = jest.fn();
146
156
  var focusFunction = jest.fn();
@@ -35,7 +35,7 @@ var _ = require("../..");
35
35
  var _hooks = require("../../hooks");
36
36
  var _pendoID = require("../../utils/devUtils/constants/pendoID");
37
37
  var _react2 = require("@emotion/react");
38
- var _excluded = ["countryValue", "defaultCountryValue", "helperText", "isReadOnly", "labelMode", "onCountryChange", "status"];
38
+ var _excluded = ["countryValue", "defaultCountryValue", "helperText", "isReadOnly", "onCountryChange", "status"];
39
39
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
40
40
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty2(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
41
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -77,34 +77,24 @@ var parsePaste = function parsePaste(raw) {
77
77
  localNumber: digitsOnly
78
78
  };
79
79
  };
80
- var closedState = function closedState(selectedKey) {
81
- var dialCode = selectedKey ? toDialCode(selectedKey) : '';
82
- return {
83
- isOpen: false,
84
- inputValue: dialCode,
85
- searchValue: dialCode,
86
- items: allCountries
87
- };
88
- };
89
80
  var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
90
81
  var countryValue = props.countryValue,
91
82
  defaultCountryValue = props.defaultCountryValue,
92
83
  helperText = props.helperText,
93
84
  isReadOnly = props.isReadOnly,
94
- labelMode = props.labelMode,
95
85
  onCountryChange = props.onCountryChange,
96
86
  status = props.status,
97
87
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
98
88
  var _useField = (0, _hooks.useField)(_objectSpread({
99
89
  status: status,
100
- isReadOnly: isReadOnly,
101
- labelMode: labelMode
90
+ isReadOnly: isReadOnly
102
91
  }, others)),
103
92
  fieldContainerProps = _useField.fieldContainerProps,
104
93
  fieldControlInputProps = _useField.fieldControlInputProps,
105
94
  fieldControlWrapperProps = _useField.fieldControlWrapperProps,
106
95
  fieldLabelProps = _useField.fieldLabelProps;
107
- var onChange = fieldControlInputProps.onChange;
96
+ var onChange = fieldControlInputProps.onChange,
97
+ fieldValue = fieldControlInputProps.value;
108
98
  var inputRef = (0, _hooks.useLocalOrForwardRef)(ref);
109
99
  var helperTextId = (0, _uuid.v4)();
110
100
  (0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
@@ -113,6 +103,15 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
113
103
  }),
114
104
  contains = _useFilter.contains;
115
105
  var _useState = (0, _react.useState)(function () {
106
+ return String(fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
107
+ }),
108
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
109
+ phoneNumber = _useState2[0],
110
+ setPhoneNumber = _useState2[1];
111
+ (0, _react.useEffect)(function () {
112
+ if (fieldValue !== undefined) setPhoneNumber(String(fieldValue));
113
+ }, [fieldValue]);
114
+ var _useState3 = (0, _react.useState)(function () {
116
115
  var key = countryValue !== null && countryValue !== void 0 ? countryValue : defaultCountryValue;
117
116
  if (key && getCountry(key)) {
118
117
  var dialCode = toDialCode(key);
@@ -132,9 +131,9 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
132
131
  isOpen: false
133
132
  };
134
133
  }),
135
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
136
- fieldState = _useState2[0],
137
- setFieldState = _useState2[1];
134
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
135
+ fieldState = _useState4[0],
136
+ setFieldState = _useState4[1];
138
137
  var isControlledCountry = countryValue !== undefined;
139
138
  var currentSelectedKey = isControlledCountry ? countryValue !== null && countryValue !== void 0 ? countryValue : null : fieldState.selectedKey;
140
139
  var closedDisplayValue = isControlledCountry ? toDialCode(countryValue !== null && countryValue !== void 0 ? countryValue : '') : fieldState.inputValue;
@@ -152,7 +151,6 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
152
151
  setFieldState(function (prev) {
153
152
  return _objectSpread(_objectSpread({}, prev), {}, {
154
153
  inputValue: value,
155
- selectedKey: null,
156
154
  searchValue: value,
157
155
  items: newItems
158
156
  });
@@ -171,14 +169,25 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
171
169
  if (onCountryChange) onCountryChange(key);
172
170
  }, [onCountryChange]);
173
171
  var onOpenChangeHandler = (0, _react.useCallback)(function (open) {
174
- if (!open || isReadOnly) {
172
+ if (isReadOnly) return;
173
+ if (open) {
175
174
  setFieldState(function (prev) {
176
- return _objectSpread(_objectSpread({}, prev), closedState(prev.selectedKey));
175
+ return _objectSpread(_objectSpread({}, prev), {}, {
176
+ isOpen: true,
177
+ items: allCountries
178
+ });
177
179
  });
178
180
  } else {
179
181
  setFieldState(function (prev) {
182
+ if (!prev.selectedKey) return _objectSpread(_objectSpread({}, prev), {}, {
183
+ isOpen: false,
184
+ items: allCountries
185
+ });
186
+ var dialCode = toDialCode(prev.selectedKey);
180
187
  return _objectSpread(_objectSpread({}, prev), {}, {
181
- isOpen: true,
188
+ isOpen: false,
189
+ inputValue: dialCode,
190
+ searchValue: dialCode,
182
191
  items: allCountries
183
192
  });
184
193
  });
@@ -187,17 +196,17 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
187
196
  var handlePhoneChange = (0, _react.useCallback)(function (e) {
188
197
  if (!onChange) return;
189
198
  if (validatePhoneNumber(e.target.value)) {
199
+ setPhoneNumber(e.target.value);
190
200
  onChange(e);
191
- } else if (inputRef.current) {
192
- inputRef.current.value = '';
193
201
  }
194
- }, [inputRef, onChange]);
202
+ }, [onChange]);
195
203
  var commitPaste = (0, _react.useCallback)(function (raw) {
196
204
  if (!inputRef.current || !onChange) return;
197
205
  var _parsePaste = parsePaste(raw),
198
206
  countryKey = _parsePaste.countryKey,
199
207
  localNumber = _parsePaste.localNumber;
200
208
  if (countryKey) selectionHandler(countryKey);
209
+ setPhoneNumber(localNumber);
201
210
  inputRef.current.value = localNumber;
202
211
  var event = {
203
212
  target: inputRef.current,
@@ -225,7 +234,11 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
225
234
  width: '100%'
226
235
  } : {
227
236
  transition: '0.2s width ease',
228
- width: '110px'
237
+ width: '110px',
238
+ '& input': {
239
+ borderTopRightRadius: '0 !important',
240
+ borderBottomRightRadius: '0 !important'
241
+ }
229
242
  });
230
243
  var countryLabel = function countryLabel(c) {
231
244
  var _context4, _context5;
@@ -281,12 +294,19 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
281
294
  }), (0, _react2.jsx)(_.Box, {
282
295
  sx: {
283
296
  ml: '110px',
284
- width: '100%',
285
- visibility: fieldState.isOpen ? 'hidden' : undefined
297
+ width: 'calc(100% - 110px)',
298
+ visibility: fieldState.isOpen ? 'hidden' : undefined,
299
+ '& input': {
300
+ borderTopLeftRadius: '0 !important',
301
+ borderBottomLeftRadius: '0 !important',
302
+ borderLeft: 0
303
+ }
286
304
  }
287
305
  }, (0, _react2.jsx)(_.Input, (0, _extends2["default"])({
288
306
  ref: inputRef
289
307
  }, fieldControlInputProps, {
308
+ type: "tel",
309
+ value: phoneNumber,
290
310
  "aria-describedby": [helperText && helperTextId, fieldControlInputProps['aria-describedby']].join(fieldControlInputProps['aria-describedby'] ? ' ' : '') || undefined,
291
311
  onChange: handlePhoneChange,
292
312
  onPaste: handlePhonePaste
@@ -44,7 +44,9 @@ var _default = exports["default"] = {
44
44
  };
45
45
  var Default = exports.Default = function Default(args) {
46
46
  return (0, _react2.jsx)(_index.PhoneNumberField, (0, _extends2["default"])({
47
- label: "Phone Number"
47
+ label: "Phone Number",
48
+ defaultCountryValue: "US",
49
+ value: "2025550177"
48
50
  }, args));
49
51
  };
50
52
  Default.parameters = {
@@ -54,11 +56,11 @@ Default.parameters = {
54
56
  }
55
57
  };
56
58
  var Controlled = exports.Controlled = function Controlled() {
57
- var _useState = (0, _react.useState)(''),
59
+ var _useState = (0, _react.useState)('2025550177'),
58
60
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
59
61
  value = _useState2[0],
60
62
  setValue = _useState2[1];
61
- var _useState3 = (0, _react.useState)(undefined),
63
+ var _useState3 = (0, _react.useState)('US'),
62
64
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
63
65
  countryValue = _useState4[0],
64
66
  setCountryValue = _useState4[1];
@@ -34,6 +34,11 @@ input.fieldControlWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper)
34
34
  '> input': {
35
35
  backgroundColor: 'disabled'
36
36
  }
37
+ },
38
+ '&.is-read-only': {
39
+ '> input': {
40
+ backgroundColor: 'disabled'
41
+ }
37
42
  }
38
43
  });
39
44
  input.multivaluesWrapper = {
@@ -1,3 +1,4 @@
1
+ import { FocusScopeProps } from 'react-aria';
1
2
  import { OverlayTriggerState } from 'react-stately';
2
3
  import { ThemeUICSSObject } from 'theme-ui';
3
4
  import { UseOverlayPanelStateReturnOnClose } from '../hooks/useOverlayPanelState/useOverlayPanelState';
@@ -22,4 +23,7 @@ export interface OverlayPanelProps extends BoxProps, TestingAttributes {
22
23
  /** Inline styling prop for item */
23
24
  sx?: ThemeUICSSObject;
24
25
  state?: OverlayPanelState;
26
+ /** Props object that is spread into the internal FocusScope.
27
+ * Useful for controlling focus with greater precision. */
28
+ focusScopeProps?: Omit<FocusScopeProps, 'children'>;
25
29
  }
@@ -1,14 +1,12 @@
1
- import { UseFieldProps } from '../hooks/useField/useField';
1
+ import React from 'react';
2
+ import { ContainerProps } from '../hooks/useField/useField';
2
3
  import { TestingAttributes } from './shared/test';
3
- import { Status } from './item';
4
- import { HelpHintProps } from '.';
5
- export interface PhoneNumberFieldProps extends UseFieldProps<HTMLInputElement>, TestingAttributes {
4
+ import { HelpHintProps, LabelProps, Status, ValidPositiveInteger } from '.';
5
+ export interface PhoneNumberFieldProps extends TestingAttributes {
6
6
  /** The rendered label for the field. */
7
7
  label?: string | React.ReactNode;
8
8
  /** The value for the phone number input element (controlled). */
9
9
  value?: string;
10
- /** The default value for the phone number input element (uncontrolled). */
11
- defaultValue?: string;
12
10
  /**
13
11
  * Callback fired when the phone number value is changed.
14
12
  *
@@ -30,16 +28,24 @@ export interface PhoneNumberFieldProps extends UseFieldProps<HTMLInputElement>,
30
28
  isDisabled?: boolean;
31
29
  /** Whether the input can be selected, but not changed by the user. */
32
30
  isReadOnly?: boolean;
33
- /** Whether the field is required. */
31
+ /** Whether user input is required on the input before form submission. */
34
32
  isRequired?: boolean;
35
33
  /** The name for the input element. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname). */
36
34
  name?: string;
37
35
  /** The unique identifier for the input element. */
38
36
  id?: string;
39
- /** Props object that is spread directly into the helphint element. */
37
+ /** The placeholder text to display in the input element. */
38
+ placeholder?: string;
39
+ /** The maximum number of characters allowed. */
40
+ maxLength?: ValidPositiveInteger;
41
+ /** Props object spread into the label element. */
42
+ labelProps?: LabelProps;
43
+ /** Props object spread into the outer container element. */
44
+ containerProps?: ContainerProps;
45
+ /** Props object spread into the help hint element. */
40
46
  helpHintProps?: HelpHintProps;
41
47
  /** Hint text to display in the help hint tooltip. */
42
48
  hintText?: string;
43
- /** The placeholder text to display in the input element. */
44
- placeholder?: string;
49
+ /** The autocomplete attribute for the phone input. */
50
+ autoComplete?: string;
45
51
  }
@@ -13,5 +13,5 @@ var _context;
13
13
  */
14
14
 
15
15
  var htmlElements = exports.htmlElements = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'listing', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'nobr', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'plaintext', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp'];
16
- var supportedImageTypes = exports.supportedImageTypes = ['image', 'image/apng', 'image/avif', 'image/gif', 'image/jpeg', 'image/png', 'image/svg', 'image/svg+xml', 'image/webp'];
16
+ var supportedImageTypes = exports.supportedImageTypes = ['image', 'image/apng', 'image/avif', 'image/gif', 'image/jpeg', 'image/png', 'image/svg', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/webp', 'image/x-icon'];
17
17
  var imageUploadPropTypes = exports.imageUploadPropTypes = (0, _concat["default"])(_context = ['application', 'application', 'audio', 'example', 'model', 'text', 'video']).call(_context, supportedImageTypes);
@@ -243,10 +243,68 @@ test('should call onChange cb (when provided) when a file is uploaded', function
243
243
  });
244
244
  expect(testOnChange).toHaveBeenCalledTimes(1);
245
245
  });
246
- test('should call onRemove cb (when provided) when a file is uploaded', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
247
- var testOnRemove, imagePreview;
246
+ test('should call onChange cb and render preview when a .ico file with type image/vnd.microsoft.icon is uploaded', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
247
+ var testOnChange;
248
248
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
249
249
  while (1) switch (_context5.prev = _context5.next) {
250
+ case 0:
251
+ testOnChange = jest.fn();
252
+ getComponent({
253
+ onChange: testOnChange
254
+ });
255
+ fireEvent.change(screen.getByTestId('image-upload-input'), {
256
+ target: {
257
+ files: [new File(['(⌐□_□)'], 'favicon.ico', {
258
+ type: 'image/vnd.microsoft.icon'
259
+ })]
260
+ }
261
+ });
262
+ expect(testOnChange).toHaveBeenCalledTimes(1);
263
+ _context5.t0 = expect;
264
+ _context5.next = 7;
265
+ return screen.findByTestId(imageUploadImagePreview);
266
+ case 7:
267
+ _context5.t1 = _context5.sent;
268
+ (0, _context5.t0)(_context5.t1).toBeInTheDocument();
269
+ case 9:
270
+ case "end":
271
+ return _context5.stop();
272
+ }
273
+ }, _callee5);
274
+ })));
275
+ test('should call onChange cb and render preview when a .ico file with type image/x-icon is uploaded', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
276
+ var testOnChange;
277
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
278
+ while (1) switch (_context6.prev = _context6.next) {
279
+ case 0:
280
+ testOnChange = jest.fn();
281
+ getComponent({
282
+ onChange: testOnChange
283
+ });
284
+ fireEvent.change(screen.getByTestId('image-upload-input'), {
285
+ target: {
286
+ files: [new File(['(⌐□_□)'], 'favicon.ico', {
287
+ type: 'image/x-icon'
288
+ })]
289
+ }
290
+ });
291
+ expect(testOnChange).toHaveBeenCalledTimes(1);
292
+ _context6.t0 = expect;
293
+ _context6.next = 7;
294
+ return screen.findByTestId(imageUploadImagePreview);
295
+ case 7:
296
+ _context6.t1 = _context6.sent;
297
+ (0, _context6.t0)(_context6.t1).toBeInTheDocument();
298
+ case 9:
299
+ case "end":
300
+ return _context6.stop();
301
+ }
302
+ }, _callee6);
303
+ })));
304
+ test('should call onRemove cb (when provided) when a file is uploaded', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
305
+ var testOnRemove, imagePreview;
306
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
307
+ while (1) switch (_context7.prev = _context7.next) {
250
308
  case 0:
251
309
  testOnRemove = jest.fn();
252
310
  getComponent({
@@ -257,29 +315,29 @@ test('should call onRemove cb (when provided) when a file is uploaded', /*#__PUR
257
315
  files: [file]
258
316
  }
259
317
  });
260
- _context5.next = 5;
318
+ _context7.next = 5;
261
319
  return screen.findByTestId(imageUploadImagePreview);
262
320
  case 5:
263
- imagePreview = _context5.sent;
264
- _context5.next = 8;
321
+ imagePreview = _context7.sent;
322
+ _context7.next = 8;
265
323
  return userEvent.click(screen.getByTestId(testButtonId));
266
324
  case 8:
267
- _context5.t0 = expect;
268
- _context5.next = 11;
325
+ _context7.t0 = expect;
326
+ _context7.next = 11;
269
327
  return screen.findByTestId(imageUploadImagePreview);
270
328
  case 11:
271
- _context5.t1 = _context5.sent;
272
- (0, _context5.t0)(_context5.t1).toBeInTheDocument();
273
- _context5.next = 15;
329
+ _context7.t1 = _context7.sent;
330
+ (0, _context7.t0)(_context7.t1).toBeInTheDocument();
331
+ _context7.next = 15;
274
332
  return userEvent.click(screen.getByText('Remove Image'));
275
333
  case 15:
276
334
  expect(imagePreview).not.toBeInTheDocument();
277
335
  expect(testOnRemove).toHaveBeenCalledTimes(1);
278
336
  case 17:
279
337
  case "end":
280
- return _context5.stop();
338
+ return _context7.stop();
281
339
  }
282
- }, _callee5);
340
+ }, _callee7);
283
341
  })));
284
342
  test('should not call onChange cb (when provided) if uploaded file is not allowed by fileTypes', function () {
285
343
  var testOnChange = jest.fn();
@@ -342,9 +400,9 @@ test('should render loader if isLoading prop is true', function () {
342
400
  });
343
401
  expect(screen.queryByRole('alert')).toBeInTheDocument();
344
402
  });
345
- test('should render image preview and menu when previewImage prop is supplied', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
346
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
347
- while (1) switch (_context6.prev = _context6.next) {
403
+ test('should render image preview and menu when previewImage prop is supplied', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
404
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
405
+ while (1) switch (_context8.prev = _context8.next) {
348
406
  case 0:
349
407
  getComponent({
350
408
  previewImage: 'test'
@@ -352,16 +410,16 @@ test('should render image preview and menu when previewImage prop is supplied',
352
410
  expect(screen.queryByTestId(imageUploadImagePreview)).toBeInTheDocument();
353
411
  expect(screen.queryByTestId(imageUploadImagePreview)).toHaveAttribute('src', 'test');
354
412
  expect(screen.queryByTestId(imageUploadNoImagePreview)).not.toBeInTheDocument();
355
- _context6.next = 6;
413
+ _context8.next = 6;
356
414
  return userEvent.click(screen.getByTestId(testButtonId));
357
415
  case 6:
358
416
  expect(screen.getByText('Upload New Image')).toBeInTheDocument();
359
417
  expect(screen.getByText('Remove Image')).toBeInTheDocument();
360
418
  case 8:
361
419
  case "end":
362
- return _context6.stop();
420
+ return _context8.stop();
363
421
  }
364
- }, _callee6);
422
+ }, _callee8);
365
423
  })));
366
424
  test('loader size can be changed via the prop', function () {
367
425
  var testLoaderSize = 17;
@@ -371,14 +429,14 @@ test('loader size can be changed via the prop', function () {
371
429
  });
372
430
  expect(screen.getByTestId('image-preview-button__loader')).toBeInTheDocument();
373
431
  });
374
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
432
+ test('should show the menu if label clicked when preview image exists', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
375
433
  var imageUploadButton, imagePreview, imageUploadLabel;
376
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
377
- while (1) switch (_context7.prev = _context7.next) {
434
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
435
+ while (1) switch (_context9.prev = _context9.next) {
378
436
  case 0:
379
437
  getComponent();
380
438
  imageUploadButton = screen.getByTestId(testButtonId);
381
- _context7.next = 4;
439
+ _context9.next = 4;
382
440
  return userEvent.click(imageUploadButton);
383
441
  case 4:
384
442
  fireEvent.change(screen.getByTestId('image-upload-input'), {
@@ -386,10 +444,10 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
386
444
  files: [file]
387
445
  }
388
446
  });
389
- _context7.next = 7;
447
+ _context9.next = 7;
390
448
  return screen.findByTestId(imageUploadImagePreview);
391
449
  case 7:
392
- imagePreview = _context7.sent;
450
+ imagePreview = _context9.sent;
393
451
  expect(imagePreview).toBeInTheDocument();
394
452
  expect(imagePreview).toHaveAttribute('src');
395
453
 
@@ -404,14 +462,14 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
404
462
  expect(screen.getByText('Remove Image')).toBeInTheDocument();
405
463
  case 16:
406
464
  case "end":
407
- return _context7.stop();
465
+ return _context9.stop();
408
466
  }
409
- }, _callee7);
467
+ }, _callee9);
410
468
  })));
411
- test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
469
+ test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0() {
412
470
  var customUploadProp, customRemoveProp, imagePreview;
413
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
414
- while (1) switch (_context8.prev = _context8.next) {
471
+ return _regeneratorRuntime().wrap(function _callee0$(_context0) {
472
+ while (1) switch (_context0.prev = _context0.next) {
415
473
  case 0:
416
474
  customUploadProp = 'Custom Upload';
417
475
  customRemoveProp = 'Custom Remove';
@@ -424,24 +482,24 @@ test('should show the menu if label clicked when preview image exists with custo
424
482
  files: [file]
425
483
  }
426
484
  });
427
- _context8.next = 6;
485
+ _context0.next = 6;
428
486
  return screen.findByTestId(imageUploadImagePreview);
429
487
  case 6:
430
- imagePreview = _context8.sent;
488
+ imagePreview = _context0.sent;
431
489
  expect(imagePreview).toBeInTheDocument();
432
490
  expect(imagePreview).toHaveAttribute('src');
433
491
 
434
492
  // Click on the image preview button
435
- _context8.next = 11;
493
+ _context0.next = 11;
436
494
  return userEvent.click(screen.getByRole('button'));
437
495
  case 11:
438
496
  expect(screen.getByText(customUploadProp)).toBeInTheDocument();
439
497
  expect(screen.getByText(customRemoveProp)).toBeInTheDocument();
440
498
  case 13:
441
499
  case "end":
442
- return _context8.stop();
500
+ return _context0.stop();
443
501
  }
444
- }, _callee8);
502
+ }, _callee0);
445
503
  })));
446
504
  test('should render node element if passed as default image', function () {
447
505
  getComponent({
@@ -453,10 +511,10 @@ test('should render node element if passed as default image', function () {
453
511
  expect(img).toBeInstanceOf(HTMLImageElement);
454
512
  expect(img).toBeInTheDocument();
455
513
  });
456
- test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
514
+ test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1() {
457
515
  var imagePreview;
458
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
459
- while (1) switch (_context9.prev = _context9.next) {
516
+ return _regeneratorRuntime().wrap(function _callee1$(_context1) {
517
+ while (1) switch (_context1.prev = _context1.next) {
460
518
  case 0:
461
519
  getComponent({
462
520
  popoverMenuProps: {
@@ -468,15 +526,15 @@ test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator(/*#__
468
526
  files: [file]
469
527
  }
470
528
  });
471
- _context9.next = 4;
529
+ _context1.next = 4;
472
530
  return screen.findByTestId(imageUploadImagePreview);
473
531
  case 4:
474
- imagePreview = _context9.sent;
532
+ imagePreview = _context1.sent;
475
533
  expect(imagePreview).toBeInTheDocument();
476
534
  expect(imagePreview).toHaveAttribute('src');
477
535
 
478
536
  // Click on the image preview button
479
- _context9.next = 9;
537
+ _context1.next = 9;
480
538
  return userEvent.click(screen.getByRole('button'));
481
539
  case 9:
482
540
  expect(screen.getByRole('presentation')).toBeInTheDocument();
@@ -484,7 +542,7 @@ test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator(/*#__
484
542
  expect(screen.getByRole('presentation')).toHaveAttribute('data-popover-placement', 'right');
485
543
  case 12:
486
544
  case "end":
487
- return _context9.stop();
545
+ return _context1.stop();
488
546
  }
489
- }, _callee9);
547
+ }, _callee1);
490
548
  })));
@@ -3,9 +3,12 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
4
  var _excluded = ["children", "helpHint", "containerProps", "textProps", "helpHintProps"];
5
5
  import React, { forwardRef } from 'react';
6
+ import { useGetTheme } from '../../hooks';
6
7
  import { Box, HelpHint, Text } from '../../index';
7
8
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
9
  var displayName = 'PairLabel';
10
+ var H4 = 'h4';
11
+ var H5 = 'h5';
9
12
  var PairLabel = /*#__PURE__*/forwardRef(function (props, ref) {
10
13
  var children = props.children,
11
14
  helpHint = props.helpHint,
@@ -13,19 +16,25 @@ var PairLabel = /*#__PURE__*/forwardRef(function (props, ref) {
13
16
  textProps = props.textProps,
14
17
  helpHintProps = props.helpHintProps,
15
18
  others = _objectWithoutProperties(props, _excluded);
19
+ var _useGetTheme = useGetTheme(),
20
+ isOnyx = _useGetTheme.themeState.isOnyx;
16
21
  var _React$Children$toArr = React.Children.toArray(children),
17
22
  _React$Children$toArr2 = _slicedToArray(_React$Children$toArr, 2),
18
23
  label = _React$Children$toArr2[0],
19
24
  icon = _React$Children$toArr2[1];
25
+ var defaultTextProps = isOnyx ? {
26
+ variant: H5,
27
+ as: H5
28
+ } : {
29
+ variant: H4,
30
+ as: H4
31
+ };
20
32
  return ___EmotionJSX(Box, _extends({
21
33
  ref: ref,
22
34
  isRow: true,
23
35
  alignItems: "center",
24
36
  gap: "sm"
25
- }, others, containerProps), ___EmotionJSX(Text, _extends({
26
- variant: "h4",
27
- as: "h4"
28
- }, textProps), label), icon, helpHint && ___EmotionJSX(HelpHint, _extends({
37
+ }, others, containerProps), ___EmotionJSX(Text, _extends({}, defaultTextProps, textProps), label), icon, helpHint && ___EmotionJSX(HelpHint, _extends({
29
38
  iconButtonProps: {
30
39
  'aria-label': "".concat(label, " help hint")
31
40
  }
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef"];
4
+ var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef", "focusScopeProps"];
5
5
  import React, { forwardRef, useEffect } from 'react';
6
6
  import { FocusScope } from 'react-aria';
7
7
  import { setInteractionModality } from '@react-aria/interactions';
@@ -18,6 +18,7 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
18
18
  state = props.state,
19
19
  size = props.size,
20
20
  triggerRef = props.triggerRef,
21
+ focusScopeProps = props.focusScopeProps,
21
22
  others = _objectWithoutProperties(props, _excluded);
22
23
  var _useOverlayPanelState = useOverlayPanelState(),
23
24
  onClose = _useOverlayPanelState.onClose;
@@ -43,9 +44,9 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
43
44
  onClose(state, triggerRef, onCloseProp);
44
45
  }
45
46
  };
46
- return ___EmotionJSX(FocusScope, {
47
+ return ___EmotionJSX(FocusScope, _extends({
47
48
  autoFocus: true
48
- }, ___EmotionJSX(Box, _extends({
49
+ }, focusScopeProps), ___EmotionJSX(Box, _extends({
49
50
  variant: "overlayPanel.container",
50
51
  ref: overlayPanelRef
51
52
  }, others, {
@@ -138,6 +138,16 @@ test('triggerRef.current.focus() fires when provided', function () {
138
138
  });
139
139
  expect(focusFunction).toHaveBeenCalled();
140
140
  });
141
+ test('focusScopeProps are forwarded to FocusScope', function () {
142
+ getComponent({
143
+ children: ___EmotionJSX("div", null, "Test"),
144
+ focusScopeProps: {
145
+ contain: true
146
+ }
147
+ });
148
+ var overlayPanel = screen.getByTestId(testId);
149
+ expect(overlayPanel).toBeInTheDocument();
150
+ });
141
151
  test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
142
152
  var onClose = jest.fn();
143
153
  var focusFunction = jest.fn();
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
4
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
5
- var _excluded = ["countryValue", "defaultCountryValue", "helperText", "isReadOnly", "labelMode", "onCountryChange", "status"];
5
+ var _excluded = ["countryValue", "defaultCountryValue", "helperText", "isReadOnly", "onCountryChange", "status"];
6
6
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
@@ -20,7 +20,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
20
20
  import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
21
21
  import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
22
22
  import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
23
- import React, { forwardRef, useCallback, useState } from 'react';
23
+ import React, { forwardRef, useCallback, useEffect, useState } from 'react';
24
24
  import { useFilter } from '@react-aria/i18n';
25
25
  import { countries as countriesObj } from 'countries-list';
26
26
  import { v4 as uuid } from 'uuid';
@@ -66,34 +66,24 @@ var parsePaste = function parsePaste(raw) {
66
66
  localNumber: digitsOnly
67
67
  };
68
68
  };
69
- var closedState = function closedState(selectedKey) {
70
- var dialCode = selectedKey ? toDialCode(selectedKey) : '';
71
- return {
72
- isOpen: false,
73
- inputValue: dialCode,
74
- searchValue: dialCode,
75
- items: allCountries
76
- };
77
- };
78
69
  var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
79
70
  var countryValue = props.countryValue,
80
71
  defaultCountryValue = props.defaultCountryValue,
81
72
  helperText = props.helperText,
82
73
  isReadOnly = props.isReadOnly,
83
- labelMode = props.labelMode,
84
74
  onCountryChange = props.onCountryChange,
85
75
  status = props.status,
86
76
  others = _objectWithoutProperties(props, _excluded);
87
77
  var _useField = useField(_objectSpread({
88
78
  status: status,
89
- isReadOnly: isReadOnly,
90
- labelMode: labelMode
79
+ isReadOnly: isReadOnly
91
80
  }, others)),
92
81
  fieldContainerProps = _useField.fieldContainerProps,
93
82
  fieldControlInputProps = _useField.fieldControlInputProps,
94
83
  fieldControlWrapperProps = _useField.fieldControlWrapperProps,
95
84
  fieldLabelProps = _useField.fieldLabelProps;
96
- var onChange = fieldControlInputProps.onChange;
85
+ var onChange = fieldControlInputProps.onChange,
86
+ fieldValue = fieldControlInputProps.value;
97
87
  var inputRef = useLocalOrForwardRef(ref);
98
88
  var helperTextId = uuid();
99
89
  usePropWarning(props, 'disabled', 'isDisabled');
@@ -102,6 +92,15 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
102
92
  }),
103
93
  contains = _useFilter.contains;
104
94
  var _useState = useState(function () {
95
+ return String(fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
96
+ }),
97
+ _useState2 = _slicedToArray(_useState, 2),
98
+ phoneNumber = _useState2[0],
99
+ setPhoneNumber = _useState2[1];
100
+ useEffect(function () {
101
+ if (fieldValue !== undefined) setPhoneNumber(String(fieldValue));
102
+ }, [fieldValue]);
103
+ var _useState3 = useState(function () {
105
104
  var key = countryValue !== null && countryValue !== void 0 ? countryValue : defaultCountryValue;
106
105
  if (key && getCountry(key)) {
107
106
  var dialCode = toDialCode(key);
@@ -121,9 +120,9 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
121
120
  isOpen: false
122
121
  };
123
122
  }),
124
- _useState2 = _slicedToArray(_useState, 2),
125
- fieldState = _useState2[0],
126
- setFieldState = _useState2[1];
123
+ _useState4 = _slicedToArray(_useState3, 2),
124
+ fieldState = _useState4[0],
125
+ setFieldState = _useState4[1];
127
126
  var isControlledCountry = countryValue !== undefined;
128
127
  var currentSelectedKey = isControlledCountry ? countryValue !== null && countryValue !== void 0 ? countryValue : null : fieldState.selectedKey;
129
128
  var closedDisplayValue = isControlledCountry ? toDialCode(countryValue !== null && countryValue !== void 0 ? countryValue : '') : fieldState.inputValue;
@@ -141,7 +140,6 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
141
140
  setFieldState(function (prev) {
142
141
  return _objectSpread(_objectSpread({}, prev), {}, {
143
142
  inputValue: value,
144
- selectedKey: null,
145
143
  searchValue: value,
146
144
  items: newItems
147
145
  });
@@ -160,14 +158,25 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
160
158
  if (onCountryChange) onCountryChange(key);
161
159
  }, [onCountryChange]);
162
160
  var onOpenChangeHandler = useCallback(function (open) {
163
- if (!open || isReadOnly) {
161
+ if (isReadOnly) return;
162
+ if (open) {
164
163
  setFieldState(function (prev) {
165
- return _objectSpread(_objectSpread({}, prev), closedState(prev.selectedKey));
164
+ return _objectSpread(_objectSpread({}, prev), {}, {
165
+ isOpen: true,
166
+ items: allCountries
167
+ });
166
168
  });
167
169
  } else {
168
170
  setFieldState(function (prev) {
171
+ if (!prev.selectedKey) return _objectSpread(_objectSpread({}, prev), {}, {
172
+ isOpen: false,
173
+ items: allCountries
174
+ });
175
+ var dialCode = toDialCode(prev.selectedKey);
169
176
  return _objectSpread(_objectSpread({}, prev), {}, {
170
- isOpen: true,
177
+ isOpen: false,
178
+ inputValue: dialCode,
179
+ searchValue: dialCode,
171
180
  items: allCountries
172
181
  });
173
182
  });
@@ -176,17 +185,17 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
176
185
  var handlePhoneChange = useCallback(function (e) {
177
186
  if (!onChange) return;
178
187
  if (validatePhoneNumber(e.target.value)) {
188
+ setPhoneNumber(e.target.value);
179
189
  onChange(e);
180
- } else if (inputRef.current) {
181
- inputRef.current.value = '';
182
190
  }
183
- }, [inputRef, onChange]);
191
+ }, [onChange]);
184
192
  var commitPaste = useCallback(function (raw) {
185
193
  if (!inputRef.current || !onChange) return;
186
194
  var _parsePaste = parsePaste(raw),
187
195
  countryKey = _parsePaste.countryKey,
188
196
  localNumber = _parsePaste.localNumber;
189
197
  if (countryKey) selectionHandler(countryKey);
198
+ setPhoneNumber(localNumber);
190
199
  inputRef.current.value = localNumber;
191
200
  var event = {
192
201
  target: inputRef.current,
@@ -214,7 +223,11 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
214
223
  width: '100%'
215
224
  } : {
216
225
  transition: '0.2s width ease',
217
- width: '110px'
226
+ width: '110px',
227
+ '& input': {
228
+ borderTopRightRadius: '0 !important',
229
+ borderBottomRightRadius: '0 !important'
230
+ }
218
231
  });
219
232
  var countryLabel = function countryLabel(c) {
220
233
  var _context4, _context5;
@@ -270,12 +283,19 @@ var PhoneNumberField = /*#__PURE__*/forwardRef(function (props, ref) {
270
283
  }), ___EmotionJSX(Box, {
271
284
  sx: {
272
285
  ml: '110px',
273
- width: '100%',
274
- visibility: fieldState.isOpen ? 'hidden' : undefined
286
+ width: 'calc(100% - 110px)',
287
+ visibility: fieldState.isOpen ? 'hidden' : undefined,
288
+ '& input': {
289
+ borderTopLeftRadius: '0 !important',
290
+ borderBottomLeftRadius: '0 !important',
291
+ borderLeft: 0
292
+ }
275
293
  }
276
294
  }, ___EmotionJSX(Input, _extends({
277
295
  ref: inputRef
278
296
  }, fieldControlInputProps, {
297
+ type: "tel",
298
+ value: phoneNumber,
279
299
  "aria-describedby": [helperText && helperTextId, fieldControlInputProps['aria-describedby']].join(fieldControlInputProps['aria-describedby'] ? ' ' : '') || undefined,
280
300
  onChange: handlePhoneChange,
281
301
  onPaste: handlePhonePaste
@@ -34,7 +34,9 @@ export default {
34
34
  };
35
35
  export var Default = function Default(args) {
36
36
  return ___EmotionJSX(PhoneNumberField, _extends({
37
- label: "Phone Number"
37
+ label: "Phone Number",
38
+ defaultCountryValue: "US",
39
+ value: "2025550177"
38
40
  }, args));
39
41
  };
40
42
  Default.parameters = {
@@ -44,11 +46,11 @@ Default.parameters = {
44
46
  }
45
47
  };
46
48
  export var Controlled = function Controlled() {
47
- var _useState = useState(''),
49
+ var _useState = useState('2025550177'),
48
50
  _useState2 = _slicedToArray(_useState, 2),
49
51
  value = _useState2[0],
50
52
  setValue = _useState2[1];
51
- var _useState3 = useState(undefined),
53
+ var _useState3 = useState('US'),
52
54
  _useState4 = _slicedToArray(_useState3, 2),
53
55
  countryValue = _useState4[0],
54
56
  setCountryValue = _useState4[1];
@@ -27,6 +27,11 @@ input.fieldControlWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper)
27
27
  '> input': {
28
28
  backgroundColor: 'disabled'
29
29
  }
30
+ },
31
+ '&.is-read-only': {
32
+ '> input': {
33
+ backgroundColor: 'disabled'
34
+ }
30
35
  }
31
36
  });
32
37
  input.multivaluesWrapper = {
@@ -5,5 +5,5 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
5
5
  */
6
6
 
7
7
  export var htmlElements = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'listing', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'nobr', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'plaintext', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp'];
8
- export var supportedImageTypes = ['image', 'image/apng', 'image/avif', 'image/gif', 'image/jpeg', 'image/png', 'image/svg', 'image/svg+xml', 'image/webp'];
8
+ export var supportedImageTypes = ['image', 'image/apng', 'image/avif', 'image/gif', 'image/jpeg', 'image/png', 'image/svg', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/webp', 'image/x-icon'];
9
9
  export var imageUploadPropTypes = _concatInstanceProperty(_context = ['application', 'application', 'audio', 'example', 'model', 'text', 'video']).call(_context, supportedImageTypes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.217.1",
3
+ "version": "2.218.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",