@transferwise/components 0.0.0-experimental-778ee44 → 0.0.0-experimental-ae2a4e7

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.
Files changed (153) hide show
  1. package/build/index.esm.js +226 -327
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +227 -328
  4. package/build/index.js.map +1 -1
  5. package/build/types/common/locale/index.d.ts +26 -43
  6. package/build/types/common/locale/index.d.ts.map +1 -1
  7. package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts +1 -1
  8. package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts.map +1 -1
  9. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts +2 -3
  10. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts.map +1 -1
  11. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts +1 -5
  12. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts.map +1 -1
  13. package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts +1 -1
  14. package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts.map +1 -1
  15. package/build/types/index.d.ts +0 -2
  16. package/build/types/index.d.ts.map +1 -1
  17. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +11 -5
  18. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
  19. package/build/types/inputWithDisplayFormat/index.d.ts +1 -2
  20. package/build/types/inputWithDisplayFormat/index.d.ts.map +1 -1
  21. package/build/types/inputs/Input.d.ts +6 -8
  22. package/build/types/inputs/Input.d.ts.map +1 -1
  23. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +30 -27
  24. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  25. package/build/types/phoneNumberInput/data/countries.d.ts +5 -10
  26. package/build/types/phoneNumberInput/data/countries.d.ts.map +1 -1
  27. package/build/types/phoneNumberInput/index.d.ts +1 -1
  28. package/build/types/phoneNumberInput/index.d.ts.map +1 -1
  29. package/build/types/phoneNumberInput/utils/cleanNumber/cleanNumber.d.ts +1 -1
  30. package/build/types/phoneNumberInput/utils/cleanNumber/cleanNumber.d.ts.map +1 -1
  31. package/build/types/phoneNumberInput/utils/cleanNumber/index.d.ts +1 -1
  32. package/build/types/phoneNumberInput/utils/cleanNumber/index.d.ts.map +1 -1
  33. package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts +8 -1
  34. package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts.map +1 -1
  35. package/build/types/phoneNumberInput/utils/excludeCountries/index.d.ts +1 -1
  36. package/build/types/phoneNumberInput/utils/excludeCountries/index.d.ts.map +1 -1
  37. package/build/types/phoneNumberInput/utils/explodeNumberModel/index.d.ts +8 -4
  38. package/build/types/phoneNumberInput/utils/explodeNumberModel/index.d.ts.map +1 -1
  39. package/build/types/phoneNumberInput/utils/findCountryByCode/index.d.ts +1 -1
  40. package/build/types/phoneNumberInput/utils/findCountryByCode/index.d.ts.map +1 -1
  41. package/build/types/phoneNumberInput/utils/findCountryByPrefix/index.d.ts +1 -1
  42. package/build/types/phoneNumberInput/utils/findCountryByPrefix/index.d.ts.map +1 -1
  43. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts +2 -1
  44. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts.map +1 -1
  45. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/index.d.ts +1 -1
  46. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/index.d.ts.map +1 -1
  47. package/build/types/phoneNumberInput/utils/index.d.ts +11 -13
  48. package/build/types/phoneNumberInput/utils/index.d.ts.map +1 -1
  49. package/build/types/phoneNumberInput/utils/isStringNumeric/index.d.ts +1 -1
  50. package/build/types/phoneNumberInput/utils/isStringNumeric/index.d.ts.map +1 -1
  51. package/build/types/phoneNumberInput/utils/isStringNumeric/isStringNumeric.d.ts +1 -1
  52. package/build/types/phoneNumberInput/utils/isStringNumeric/isStringNumeric.d.ts.map +1 -1
  53. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/index.d.ts +1 -1
  54. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/index.d.ts.map +1 -1
  55. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts +6 -1
  56. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts.map +1 -1
  57. package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts +2 -1
  58. package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts.map +1 -1
  59. package/build/types/phoneNumberInput/utils/setDefaultPrefix/index.d.ts +7 -1
  60. package/build/types/phoneNumberInput/utils/setDefaultPrefix/index.d.ts.map +1 -1
  61. package/build/types/phoneNumberInput/utils/sortArrayByProperty/index.d.ts +1 -1
  62. package/build/types/phoneNumberInput/utils/sortArrayByProperty/index.d.ts.map +1 -1
  63. package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts +1 -1
  64. package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts.map +1 -1
  65. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +11 -5
  66. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
  67. package/build/types/textareaWithDisplayFormat/index.d.ts +1 -2
  68. package/build/types/textareaWithDisplayFormat/index.d.ts.map +1 -1
  69. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +82 -55
  70. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  71. package/build/types/withDisplayFormat/index.d.ts +1 -2
  72. package/build/types/withDisplayFormat/index.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/src/common/locale/{index.spec.js → index.spec.ts} +0 -4
  75. package/src/common/locale/index.ts +96 -0
  76. package/src/common/textFormat/formatWithPattern/{formatWithPattern.ts → formatWithPattern.js} +4 -8
  77. package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.ts → getCursorPositionAfterKeystroke.js} +8 -9
  78. package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.ts → getSymbolsInPatternWithPosition.js} +2 -7
  79. package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.ts → unformatWithPattern.js} +2 -3
  80. package/src/index.ts +0 -2
  81. package/src/inputWithDisplayFormat/InputWithDisplayFormat.js +14 -0
  82. package/src/inputWithDisplayFormat/index.js +1 -0
  83. package/src/inputs/Input.tsx +11 -6
  84. package/src/phoneNumberInput/PhoneNumberInput.spec.js +18 -22
  85. package/src/phoneNumberInput/PhoneNumberInput.tsx +201 -0
  86. package/src/phoneNumberInput/data/{countries.js → countries.ts} +9 -1
  87. package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +3 -0
  88. package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.spec.js → excludeCountries.spec.ts} +1 -1
  89. package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.js → excludeCountries.ts} +6 -5
  90. package/src/phoneNumberInput/utils/explodeNumberModel/{explodeNumberModel.spec.js → explodeNumberModel.spec.ts} +1 -1
  91. package/src/phoneNumberInput/utils/explodeNumberModel/index.ts +25 -0
  92. package/src/phoneNumberInput/utils/findCountryByCode/{findCountryByCode.spec.js → findCountryByCode.spec.ts} +0 -1
  93. package/src/phoneNumberInput/utils/findCountryByCode/index.ts +12 -0
  94. package/src/phoneNumberInput/utils/findCountryByPrefix/index.ts +12 -0
  95. package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.spec.ts +102 -0
  96. package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.ts +12 -0
  97. package/src/phoneNumberInput/utils/{index.js → index.ts} +0 -2
  98. package/src/phoneNumberInput/utils/isStringNumeric/{isStringNumeric.spec.js → isStringNumeric.spec.ts} +0 -1
  99. package/src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.ts +1 -0
  100. package/src/phoneNumberInput/utils/isValidPhoneNumber/{isValidPhoneNumber.spec.js → isValidPhoneNumber.spec.ts} +1 -1
  101. package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts +7 -0
  102. package/src/phoneNumberInput/utils/longestMatchingPrefix/index.ts +4 -0
  103. package/src/phoneNumberInput/utils/setDefaultPrefix/index.ts +20 -0
  104. package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.ts +6 -0
  105. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.js +14 -0
  106. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.spec.js +1 -3
  107. package/src/textareaWithDisplayFormat/index.js +1 -0
  108. package/src/withDisplayFormat/{WithDisplayFormat.tsx → WithDisplayFormat.js} +104 -111
  109. package/src/withDisplayFormat/index.js +1 -0
  110. package/build/types/phoneNumberInput/utils/filterOptionsForQuery/index.d.ts +0 -2
  111. package/build/types/phoneNumberInput/utils/filterOptionsForQuery/index.d.ts.map +0 -1
  112. package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/index.d.ts +0 -2
  113. package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/index.d.ts.map +0 -1
  114. package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.d.ts +0 -3
  115. package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.d.ts.map +0 -1
  116. package/src/common/locale/index.js +0 -139
  117. package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +0 -11
  118. package/src/inputWithDisplayFormat/index.ts +0 -2
  119. package/src/phoneNumberInput/PhoneNumberInput.js +0 -210
  120. package/src/phoneNumberInput/data/countries.spec.js +0 -12
  121. package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.js +0 -4
  122. package/src/phoneNumberInput/utils/explodeNumberModel/index.js +0 -27
  123. package/src/phoneNumberInput/utils/filterOptionsForQuery/filterOptionsForQuery.spec.js +0 -36
  124. package/src/phoneNumberInput/utils/filterOptionsForQuery/index.js +0 -11
  125. package/src/phoneNumberInput/utils/findCountryByCode/index.js +0 -10
  126. package/src/phoneNumberInput/utils/findCountryByPrefix/index.js +0 -11
  127. package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.js +0 -26
  128. package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.spec.js +0 -67
  129. package/src/phoneNumberInput/utils/isOptionAndFitsQuery/index.js +0 -1
  130. package/src/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.js +0 -25
  131. package/src/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.spec.js +0 -66
  132. package/src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.js +0 -1
  133. package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js +0 -10
  134. package/src/phoneNumberInput/utils/longestMatchingPrefix/index.js +0 -2
  135. package/src/phoneNumberInput/utils/setDefaultPrefix/index.js +0 -25
  136. package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.js +0 -3
  137. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +0 -32
  138. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +0 -11
  139. package/src/textareaWithDisplayFormat/index.ts +0 -2
  140. package/src/withDisplayFormat/index.ts +0 -2
  141. /package/src/phoneNumberInput/{PhoneNumberInput.story.js → PhoneNumberInput.story.tsx} +0 -0
  142. /package/src/phoneNumberInput/{index.js → index.ts} +0 -0
  143. /package/src/phoneNumberInput/utils/cleanNumber/{cleanNumber.spec.js → cleanNumber.spec.ts} +0 -0
  144. /package/src/phoneNumberInput/utils/cleanNumber/{index.js → index.ts} +0 -0
  145. /package/src/phoneNumberInput/utils/excludeCountries/{index.js → index.ts} +0 -0
  146. /package/src/phoneNumberInput/utils/findCountryByPrefix/{findCountryByPrefix.spec.js → findCountryByPrefix.spec.ts} +0 -0
  147. /package/src/phoneNumberInput/utils/groupCountriesByPrefix/{index.js → index.ts} +0 -0
  148. /package/src/phoneNumberInput/utils/isStringNumeric/{index.js → index.ts} +0 -0
  149. /package/src/phoneNumberInput/utils/isValidPhoneNumber/{index.js → index.ts} +0 -0
  150. /package/src/phoneNumberInput/utils/longestMatchingPrefix/{longestMatchingPrefix.spec.js → longestMatchingPrefix.spec.ts} +0 -0
  151. /package/src/phoneNumberInput/utils/setDefaultPrefix/{setDefaultPrefix.spec.js → setDefaultPrefix.spec.ts} +0 -0
  152. /package/src/phoneNumberInput/utils/sortArrayByProperty/{index.js → index.ts} +0 -0
  153. /package/src/phoneNumberInput/utils/sortArrayByProperty/{sortArrayByProperty.spec.js → sortArrayByProperty.spec.ts} +0 -0
@@ -19,7 +19,7 @@ import { CSSTransition } from 'react-transition-group';
19
19
  import { usePopper } from 'react-popper';
20
20
  import throttle from 'lodash.throttle';
21
21
  import { createPortal } from 'react-dom';
22
- import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
22
+ import { isUndefined, isKey, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
23
23
  import { Flag, Illustration } from '@wise/art';
24
24
  import clamp$2 from 'lodash.clamp';
25
25
  import debounce from 'lodash.debounce';
@@ -342,131 +342,76 @@ const Key = {
342
342
  COMMA: ','
343
343
  };
344
344
 
345
- /**
346
- * Default language
347
- *
348
- * @type {string}
349
- */
350
345
  const DEFAULT_LANG = 'en';
351
-
352
- /**
353
- * Default locale
354
- *
355
- * @type {string}
356
- */
357
346
  const DEFAULT_LOCALE = 'en-GB';
358
-
359
347
  /**
360
- * Array of languages that are written from the right to the left
361
- *
362
- * @type {string[]}
348
+ * Languages written right-to-left.
363
349
  */
364
350
  const RTL_LANGUAGES = ['ar', 'he'];
365
-
366
351
  /**
367
352
  * @deprecated The source of truth for supported languages lives in Crab.
368
- * @type {string[]}
369
353
  */
370
354
  const SUPPORTED_LANGUAGES = [DEFAULT_LANG, 'de', 'es', 'fr', 'hu', 'id', 'it', 'ja', 'pl', 'pt', 'ro', 'ru', 'th', 'tr', 'uk', 'zh'];
371
-
372
355
  /**
373
- * Verifies and adjusts locale (replace `_` with `-`)
374
- * Returns null if locale is unrecognized by {Intl.Locale}
356
+ * Verifies and adjusts locale, replacing `_` with `-`.
375
357
  *
376
- * @param {string} locale (`es`, `es_ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
377
- * @returns {string|null}
358
+ * @param locale `es`, `es_ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
359
+ * @returns `null` if locale is unrecognized by `Intl.Locale`.
378
360
  */
379
361
  function adjustLocale(locale) {
380
- if (!locale || locale.trim().length === 0) {
381
- return null;
382
- }
383
- try {
384
- const {
385
- baseName
386
- } = new Intl.Locale(locale.trim().replace('_', '-'));
387
- return baseName;
388
- } catch (error) {
389
- // eslint-disable-next-line no-console
390
- console.error(error);
391
- return null;
362
+ const localeTrimmed = locale?.trim();
363
+ if (localeTrimmed) {
364
+ try {
365
+ return new Intl.Locale(localeTrimmed.replace('_', '-')).baseName;
366
+ } catch (error) {
367
+ // eslint-disable-next-line no-console
368
+ console.error(error);
369
+ }
392
370
  }
371
+ return null;
393
372
  }
394
-
395
373
  /**
396
- * Provides corresponding lang (iso2) for provided locale
397
- * if locale is invalid or language is unsupported returns null
374
+ * Provides corresponding lang (iso2) for provided locale.
398
375
  *
399
376
  * @deprecated The use of this function almost always breaks language variants
400
377
  * e.g. Simplified and Traditional Chinese.
401
378
  * There should be no use case for this function.
402
379
  * To select the correct translations from a translations object, pass the
403
380
  * locale directly into Crab's getLocalisedMessages.
404
- * @param {string} locale (`es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
405
- * @returns {string|null} two-letter ISO639-1 language
381
+ * @param locale `es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
382
+ * @returns Two-letter ISO 639-1 language code, falling back to `null` if locale is invalid or language is unsupported.
406
383
  */
407
384
  function getLangFromLocale(locale) {
408
385
  const adjustedLocale = adjustLocale(locale);
409
- if (adjustedLocale === null) {
410
- return null;
411
- }
412
- try {
386
+ if (adjustedLocale != null) {
413
387
  const {
414
388
  language
415
389
  } = new Intl.Locale(adjustedLocale);
416
390
  if (SUPPORTED_LANGUAGES.includes(language)) {
417
391
  return language;
418
392
  }
419
- return null;
420
- } catch (error) {
421
- // eslint-disable-next-line no-console
422
- console.error(error);
423
- return null;
424
393
  }
394
+ return null;
425
395
  }
426
-
427
396
  /**
428
- * Provides corresponding country code (iso2) for locales code with explicit region value (`es-ES`, `en-GB`, `ja-JP` etc.)
429
- * if the value is invalid or missing region it returns null
397
+ * Provides corresponding country code (iso2) for locales code with explicit region value.
430
398
  *
431
- * @param {string} locale
432
- * @returns {string|null}
399
+ * @param locale `es-ES`, `en-GB`, `ja-JP`, etc.
400
+ * @returns `null` if the locale is invalid or the region can‘t be identified.
433
401
  */
434
402
  function getCountryFromLocale(locale) {
435
403
  const adjustedLocale = adjustLocale(locale);
436
- if (adjustedLocale === null) {
437
- return null;
438
- }
439
- try {
440
- const {
441
- region
442
- } = new Intl.Locale(adjustedLocale);
443
- return region ?? null;
444
- } catch (error) {
445
- // eslint-disable-next-line no-console
446
- console.error(error);
447
- return null;
448
- }
404
+ return adjustedLocale != null ? new Intl.Locale(adjustedLocale).region ?? null : null;
449
405
  }
450
-
451
406
  /**
452
407
  * Provides the layout direction for a given locale.
453
- * If locale is invalid or language is unsupported returns Direction.LTR
454
408
  *
455
- * @param {string} locale (`es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
456
- * @returns {Direction} The layout direction based on the locale
409
+ * @param locale `es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
410
+ * @returns The layout direction based on the locale, falling back to `Direction.LTR` if the locale is invalid or unsupported.
457
411
  */
458
412
  function getDirectionFromLocale(locale) {
459
- try {
460
- const adjustedLocale = adjustLocale(locale);
461
- const {
462
- language
463
- } = new Intl.Locale(adjustedLocale);
464
- return RTL_LANGUAGES.includes(language) ? Direction.RTL : Direction.LTR;
465
- } catch (error) {
466
- // eslint-disable-next-line no-console
467
- console.error(error);
468
- return Direction.LTR;
469
- }
413
+ const adjustedLocale = adjustLocale(locale);
414
+ return adjustedLocale != null && RTL_LANGUAGES.includes(new Intl.Locale(adjustedLocale).language) ? Direction.RTL : Direction.LTR;
470
415
  }
471
416
 
472
417
  /**
@@ -7263,13 +7208,10 @@ const formatWithPattern = (value, pattern) => {
7263
7208
  let patternSymbol = [];
7264
7209
  // valueArray.length increments during the cycle cause we are adding new elements.
7265
7210
  for (let index = 0; index < valueArray.length; index += 1) {
7266
- patternSymbol = patternWithSymbolsPosition.filter(pattern => pattern.index === index);
7211
+ patternSymbol = patternWithSymbolsPosition.filter(symbol => symbol.index === index);
7267
7212
  // Add pattern's symbol at n position
7268
7213
  if (patternSymbol.length === 1) {
7269
- const last = patternSymbol.pop();
7270
- if (last) {
7271
- valueArray.splice(index, 0, last.symbol);
7272
- }
7214
+ valueArray.splice(index, 0, patternSymbol.pop().symbol);
7273
7215
  }
7274
7216
  }
7275
7217
  return valueArray.join('');
@@ -7315,7 +7257,7 @@ const countConsecutiveSymbols = (selectionStart, applicablePattern, direction) =
7315
7257
  return groupSize;
7316
7258
  };
7317
7259
 
7318
- const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd, pattern, pastedLength) => {
7260
+ const getCursorPositionAfteractionstroke = (action, selectionStart, selectionEnd, pattern, pastedLength) => {
7319
7261
  let cursorPosition = selectionStart;
7320
7262
  switch (action) {
7321
7263
  case 'Backspace':
@@ -7337,34 +7279,36 @@ const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd
7337
7279
  }
7338
7280
  return cursorPosition;
7339
7281
  };
7340
- var getCursorPositionAfterKeystroke = getCursorPositionAfterActionStroke;
7282
+ var getCursorPositionAfterKeystroke = getCursorPositionAfteractionstroke;
7341
7283
 
7342
7284
  class WithDisplayFormat extends Component {
7343
- static defaultProps = {
7344
- autoComplete: 'off',
7345
- displayPattern: '',
7346
- type: 'text',
7347
- value: ''
7348
- };
7349
7285
  constructor(props) {
7350
7286
  super(props);
7351
- const unformattedValue = unformatWithPattern$1(props.value, props.displayPattern);
7287
+ const {
7288
+ value,
7289
+ displayPattern
7290
+ } = props;
7291
+ const unformattedValue = unformatWithPattern$1(value, displayPattern);
7352
7292
  this.state = {
7353
- value: formatWithPattern$1(unformattedValue, props.displayPattern),
7293
+ value: formatWithPattern$1(unformattedValue, displayPattern),
7354
7294
  historyNavigator: new HistoryNavigator$1(),
7355
7295
  prevDisplayPattern: props.displayPattern,
7356
7296
  triggerType: null,
7357
7297
  triggerEvent: null
7358
7298
  };
7359
7299
  }
7360
- static getDerivedStateFromProps({
7361
- displayPattern
7362
- }, {
7363
- prevDisplayPattern = displayPattern,
7364
- value,
7365
- historyNavigator
7366
- }) {
7367
- if (prevDisplayPattern !== displayPattern) {
7300
+ static getDerivedStateFromProps(nextProps, previousState) {
7301
+ const {
7302
+ displayPattern
7303
+ } = nextProps;
7304
+ const {
7305
+ prevDisplayPattern
7306
+ } = previousState;
7307
+ if (previousState.prevDisplayPattern !== displayPattern) {
7308
+ const {
7309
+ value,
7310
+ historyNavigator
7311
+ } = previousState;
7368
7312
  const unFormattedValue = unformatWithPattern$1(value, prevDisplayPattern);
7369
7313
  historyNavigator.reset();
7370
7314
  return {
@@ -7386,27 +7330,25 @@ class WithDisplayFormat extends Component {
7386
7330
  const {
7387
7331
  displayPattern
7388
7332
  } = this.props;
7389
- if (triggerEvent) {
7390
- const charCode = String.fromCharCode(triggerEvent.which).toLowerCase();
7391
- if (triggerType === 'Paste' || triggerType === 'Cut') {
7392
- return triggerType;
7393
- }
7394
- if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && charCode === 'z') {
7395
- return triggerEvent.shiftKey ? 'Redo' : 'Undo';
7396
- }
7397
- // Detect mouse event redo
7398
- if (triggerEvent.ctrlKey && charCode === 'd') {
7399
- return 'Delete';
7400
- }
7401
- // Android Fix.
7402
- if (typeof triggerEvent.key === 'undefined' && unformattedValue.length <= unformatWithPattern$1(value, displayPattern).length) {
7333
+ const charCode = String.fromCharCode(triggerEvent.which).toLowerCase();
7334
+ if (triggerType === 'Paste' || triggerType === 'Cut') {
7335
+ return triggerType;
7336
+ }
7337
+ if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && charCode === 'z') {
7338
+ return triggerEvent.shiftKey ? 'Redo' : 'Undo';
7339
+ }
7340
+ // Detect mouse event redo
7341
+ if (triggerEvent.ctrlKey && charCode === 'd') {
7342
+ return 'Delete';
7343
+ }
7344
+
7345
+ // Android Fix.
7346
+ if (typeof triggerEvent.key === 'undefined') {
7347
+ if (unformattedValue.length <= unformatWithPattern$1(value, displayPattern).length) {
7403
7348
  return 'Backspace';
7404
7349
  }
7405
- return triggerEvent.key;
7406
- } else {
7407
- // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
7408
- return 'Paste';
7409
7350
  }
7351
+ return triggerEvent.key;
7410
7352
  };
7411
7353
  resetEvent = () => {
7412
7354
  this.setState({
@@ -7434,6 +7376,7 @@ class WithDisplayFormat extends Component {
7434
7376
  const {
7435
7377
  displayPattern
7436
7378
  } = this.props;
7379
+
7437
7380
  // Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.
7438
7381
  let newFormattedValue = '';
7439
7382
  if (this.detectUndoRedo(event) === 'Undo') {
@@ -7482,6 +7425,7 @@ class WithDisplayFormat extends Component {
7482
7425
  handleOnChange = event => {
7483
7426
  const {
7484
7427
  historyNavigator,
7428
+ triggerEvent,
7485
7429
  triggerType
7486
7430
  } = this.state;
7487
7431
  const {
@@ -7492,7 +7436,9 @@ class WithDisplayFormat extends Component {
7492
7436
  value
7493
7437
  } = event.target;
7494
7438
  let unformattedValue = unformatWithPattern$1(value, displayPattern);
7495
- const action = this.getUserAction(unformattedValue);
7439
+ const action = triggerEvent === null ?
7440
+ // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
7441
+ 'Paste' : this.getUserAction(unformattedValue);
7496
7442
  if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {
7497
7443
  return;
7498
7444
  }
@@ -7502,18 +7448,19 @@ class WithDisplayFormat extends Component {
7502
7448
  const newFormattedValue = formatWithPattern$1(unformattedValue, displayPattern);
7503
7449
  historyNavigator.add(unformattedValue);
7504
7450
  this.handleCursorPositioning(action);
7451
+ const broadcastValue = unformatWithPattern$1(newFormattedValue, displayPattern);
7505
7452
  this.setState({
7506
7453
  value: newFormattedValue
7507
- }, () => {
7508
- this.resetEvent();
7509
- if (onChange) {
7510
- const broadcastValue = unformatWithPattern$1(newFormattedValue, displayPattern);
7511
- onChange(broadcastValue);
7512
- }
7513
- });
7454
+ }, this.resetEvent(), onChange(broadcastValue));
7514
7455
  };
7515
7456
  handleOnBlur = event => {
7516
- this.props.onBlur?.(unformatWithPattern$1(event.target.value, this.props.displayPattern));
7457
+ const {
7458
+ displayPattern,
7459
+ onBlur
7460
+ } = this.props;
7461
+ if (onBlur) {
7462
+ onBlur(unformatWithPattern$1(event.target.value, displayPattern));
7463
+ }
7517
7464
  };
7518
7465
  handleOnFocus = event => {
7519
7466
  const {
@@ -7612,13 +7559,62 @@ class WithDisplayFormat extends Component {
7612
7559
  return this.props.render(renderProps);
7613
7560
  }
7614
7561
  }
7562
+ WithDisplayFormat.propTypes = {
7563
+ /**
7564
+ * autocomplete hides our form help so we need to disable it when help text
7565
+ * is present. Chrome ignores autocomplete=off, the only way to disable it is
7566
+ * to provide an 'invalid' value, for which 'disabled' serves.
7567
+ */
7568
+ autoComplete: PropTypes.oneOf(['on', 'off', 'disabled']),
7569
+ className: PropTypes.string,
7570
+ disabled: PropTypes.bool,
7571
+ id: PropTypes.string,
7572
+ maxLength: PropTypes.number,
7573
+ minLength: PropTypes.number,
7574
+ name: PropTypes.string,
7575
+ onFocus: PropTypes.func,
7576
+ onBlur: PropTypes.func,
7577
+ onChange: PropTypes.func.isRequired,
7578
+ placeholder: PropTypes.string,
7579
+ readOnly: PropTypes.bool,
7580
+ render: PropTypes.func.isRequired,
7581
+ required: PropTypes.bool,
7582
+ displayPattern: PropTypes.string,
7583
+ type: PropTypes.string,
7584
+ inputMode: PropTypes.string,
7585
+ value: PropTypes.string
7586
+ };
7587
+ WithDisplayFormat.defaultProps = {
7588
+ autoComplete: 'off',
7589
+ className: null,
7590
+ disabled: false,
7591
+ id: null,
7592
+ maxLength: null,
7593
+ minLength: null,
7594
+ name: null,
7595
+ placeholder: null,
7596
+ readOnly: false,
7597
+ required: false,
7598
+ displayPattern: '',
7599
+ type: 'text',
7600
+ inputMode: null,
7601
+ value: '',
7602
+ onFocus: null,
7603
+ onBlur: null
7604
+ };
7605
+ var WithDisplayFormat$1 = WithDisplayFormat;
7615
7606
 
7616
- const InputWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat, {
7607
+ const InputWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat$1, {
7617
7608
  ...props,
7618
- render: renderProps => /*#__PURE__*/jsx(Input, {
7609
+ render: renderProps => /*#__PURE__*/jsx("input", {
7619
7610
  ...renderProps
7620
7611
  })
7621
7612
  });
7613
+ InputWithDisplayFormat.propTypes = {
7614
+ displayPattern: PropTypes.string.isRequired,
7615
+ onChange: PropTypes.func.isRequired
7616
+ };
7617
+ var InputWithDisplayFormat$1 = InputWithDisplayFormat;
7622
7618
 
7623
7619
  const InstructionsList = ({
7624
7620
  dos,
@@ -9567,111 +9563,80 @@ const countries = [{
9567
9563
  iso3: 'ZWE',
9568
9564
  phone: '+263'
9569
9565
  }];
9570
- var countries$1 = countries;
9571
9566
 
9572
9567
  const longestMatchingPrefix = matchingCodes => matchingCodes.reduce((a, b) => a.phone.length > b.phone.length ? a : b);
9573
9568
 
9574
9569
  const findCountryByCode = code => {
9575
- let matchingCodes;
9576
- if (code && code.length === 2) {
9577
- matchingCodes = countries$1.filter(country => code.toUpperCase() === country.iso2);
9570
+ if (code.length === 2) {
9571
+ const matchingCodes = countries.filter(country => code.toUpperCase() === country.iso2);
9572
+ if (matchingCodes.length > 0) {
9573
+ return longestMatchingPrefix(matchingCodes);
9574
+ }
9578
9575
  }
9579
- return matchingCodes && matchingCodes.length > 0 ? longestMatchingPrefix(matchingCodes) : null;
9576
+ return null;
9580
9577
  };
9581
9578
 
9582
9579
  /**
9583
9580
  * Default phone code, the UK one `+44`
9584
9581
  */
9585
9582
  const DEFAULT_PHONE_CODE = '+44';
9586
-
9587
9583
  /**
9588
9584
  * Given a valid locale it returns the correspondent prefix if found or +44 otherwise.
9589
9585
  *
9590
- * @param {string} locale - a string that represent the locale ex:'es-ES'
9591
- * @param countryCode
9592
- * @returns {string}
9586
+ * @param locale BCP 47 language tag of locale.
9587
+ * @param countryCode Two-letter country code (ISO 3166-1 alpha-2).
9593
9588
  */
9594
9589
  const setDefaultPrefix = (locale, countryCode) => {
9595
- const country = findCountryByCode(countryCode) ||
9596
- // when `locale` code has explicit region: `en-GB`, `en-US`, `ar-AE`
9597
- findCountryByCode(getCountryFromLocale(locale)) ||
9598
- // when `locale` code is only two chars value: `fr`, `es`
9599
- findCountryByCode(locale);
9600
- return country?.phone || DEFAULT_PHONE_CODE;
9590
+ const country = (countryCode != null ? findCountryByCode(countryCode) : null) ?? findCountryByCode(getCountryFromLocale(locale) ?? locale);
9591
+ return country?.phone ?? DEFAULT_PHONE_CODE;
9601
9592
  };
9602
9593
 
9603
9594
  /**
9604
9595
  *
9605
9596
  * @param phoneNumber
9606
- * @returns {boolean} - returns true for number that starts with '+' and contains a mix of digits and spaces with
9607
- * at least 4 digits.
9597
+ * @returns True if number that starts with "+"" and contains a mix of digits and spaces with at least 4 digits.
9608
9598
  */
9609
- const isValidPhoneNumber = phoneNumber => /^\+[\d-\s]+$/.test(phoneNumber) && phoneNumber.match(/\d+/g) && phoneNumber.match(/\d+/g).join('').length >= 4;
9599
+ const isValidPhoneNumber = phoneNumber => /^\+[\d-\s]+$/.test(phoneNumber) && (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= 4;
9610
9600
 
9611
9601
  const findCountryByPrefix = number => {
9612
- let matchingCodes = null;
9613
- if (number && number.length > 1) {
9614
- matchingCodes = countries$1.filter(country => number.indexOf(country.phone) === 0);
9602
+ if (number.length > 1) {
9603
+ const matchingCodes = countries.filter(country => number.startsWith(country.phone));
9604
+ if (matchingCodes.length > 0) {
9605
+ return longestMatchingPrefix(matchingCodes);
9606
+ }
9615
9607
  }
9616
- return matchingCodes && matchingCodes.length > 0 ? longestMatchingPrefix(matchingCodes) : null;
9608
+ return null;
9617
9609
  };
9618
9610
 
9619
9611
  /**
9620
- * Given a sting in a valid format ex:'+447573135343' it returns an object of shape
9621
- * {prefix=+44 ,suffix=7573135343}
9622
- *
9623
- * @param {string} number - a string that defines a phone number.
9624
- * @returns {{prefix: (string|*), suffix: string, format: string}}
9612
+ * @param number Phone number in a format like "+447573135343"
9625
9613
  */
9626
9614
  const explodeNumberModel = number => {
9627
- let prefix = '';
9628
- let suffix = '';
9629
- let format = '';
9630
9615
  const country = findCountryByPrefix(number);
9631
- if (country) {
9632
- prefix = country.phone;
9633
- suffix = number.slice(country.phone.length);
9634
- format = country.phoneFormat || '';
9635
- } else {
9636
- prefix = '';
9637
- suffix = number.slice(1);
9638
- format = '';
9639
- }
9640
- return {
9641
- prefix,
9642
- suffix,
9643
- format
9616
+ return country ? {
9617
+ prefix: country.phone,
9618
+ suffix: number.slice(country.phone.length),
9619
+ format: country.phoneFormat
9620
+ } : {
9621
+ prefix: null,
9622
+ suffix: number.slice(1),
9623
+ format: undefined
9644
9624
  };
9645
9625
  };
9646
9626
 
9647
9627
  const DIGITS_MATCH = /^$|^(\+)|([\d]+)/g;
9648
- const cleanNumber = number => number.match(DIGITS_MATCH) && number.match(DIGITS_MATCH).join('') || '';
9628
+ const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
9649
9629
 
9650
- // Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
9651
- const sortArrayByProperty = (arrayToSort, property) => [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
9630
+ function sortArrayByProperty(arrayToSort, property) {
9631
+ return [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
9632
+ }
9652
9633
 
9653
9634
  const groupCountriesByPrefix = countries => {
9654
- const groupedArray = countries.reduce((accumulator, country) => {
9655
- const {
9656
- name,
9657
- iso2,
9658
- iso3,
9659
- phone
9660
- } = country;
9661
- if (accumulator[phone]) {
9662
- const previousValue = accumulator[phone];
9663
- accumulator[phone] = {
9664
- ...previousValue,
9665
- name: isArray(previousValue.name) ? [...previousValue.name, name] : [previousValue.name, name],
9666
- iso2: isArray(previousValue.iso2) ? [...previousValue.iso2, iso2] : [previousValue.iso2, iso2],
9667
- iso3: isArray(previousValue.iso3) ? [...previousValue.iso3, iso3] : [previousValue.iso3, iso3]
9668
- };
9669
- } else {
9670
- accumulator[phone] = country;
9671
- }
9672
- return accumulator;
9673
- }, {});
9674
- return Object.values(groupedArray);
9635
+ const countriesByPrefix = new Map();
9636
+ countries.forEach(country => {
9637
+ countriesByPrefix.set(country.phone, [...(countriesByPrefix.get(country.phone) ?? []), country]);
9638
+ });
9639
+ return countriesByPrefix;
9675
9640
  };
9676
9641
 
9677
9642
  // Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
@@ -9679,97 +9644,57 @@ const filterCountriesByIso3 = (countries, iso3Codes) => {
9679
9644
  const iso3CodesSet = new Set(iso3Codes);
9680
9645
  return countries.filter(country => !iso3CodesSet.has(country.iso3));
9681
9646
  };
9682
-
9683
9647
  /**
9684
9648
  * Removes the countries sepecified in the second param
9685
9649
  *
9686
- * @param {Array} countries: list of country metadata objects
9687
- * @param {Array} disabledCountries: list of iso3 country codes to remove from the list
9688
- * @returns
9650
+ * @param countries list of country metadata objects
9651
+ * @param disabledCountries list of iso3 country codes to remove from the list
9689
9652
  */
9690
9653
  const excludeCountries = (countries, disabledCountries) => {
9691
9654
  return disabledCountries.length > 0 ? filterCountriesByIso3(countries, disabledCountries) : countries;
9692
9655
  };
9693
9656
 
9694
9657
  const ALLOWED_PHONE_CHARS = /^$|^[\d-\s]+$/;
9695
- const PhoneNumberInput = props => {
9696
- const {
9697
- id,
9698
- onChange,
9699
- searchPlaceholder,
9700
- disabled,
9701
- required,
9702
- size,
9703
- placeholder,
9704
- onFocus,
9705
- onBlur,
9706
- countryCode,
9707
- selectProps,
9708
- disabledCountries
9709
- } = props;
9658
+ const defaultSelectProps = {};
9659
+ const defaultDisabledCountries = [];
9660
+ const PhoneNumberInput = ({
9661
+ id,
9662
+ required,
9663
+ disabled,
9664
+ initialValue,
9665
+ onChange,
9666
+ onFocus,
9667
+ onBlur,
9668
+ countryCode,
9669
+ searchPlaceholder = 'Prefix',
9670
+ size = Size.MEDIUM,
9671
+ placeholder,
9672
+ selectProps = defaultSelectProps,
9673
+ disabledCountries = defaultDisabledCountries
9674
+ }) => {
9710
9675
  const {
9711
9676
  locale
9712
9677
  } = useIntl();
9713
- const getInitialValue = () => {
9714
- const {
9715
- initialValue
9716
- } = props;
9678
+ const [internalValue, setInternalValue] = useState(() => {
9717
9679
  const cleanValue = initialValue ? cleanNumber(initialValue) : null;
9718
9680
  if (!cleanValue || !isValidPhoneNumber(cleanValue)) {
9719
9681
  return {
9720
9682
  prefix: setDefaultPrefix(locale, countryCode),
9721
- suffix: ''
9683
+ suffix: '',
9684
+ format: undefined
9722
9685
  };
9723
9686
  }
9724
9687
  return explodeNumberModel(cleanValue);
9725
- };
9726
- const [internalValue, setInternalValue] = useState(getInitialValue());
9688
+ });
9727
9689
  const [broadcastedValue, setBroadcastedValue] = useState(null);
9728
- const getSelectOptions = () => {
9729
- const countriesList = excludeCountries(countries$1, disabledCountries);
9730
- const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
9731
- return listSortedByISO3.map(option => {
9732
- const {
9733
- phone,
9734
- iso3,
9735
- iso2,
9736
- name
9737
- } = option;
9738
- let note = '';
9739
- if (iso3) {
9740
- note = isArray(iso3) ? iso3.join(', ') : iso3;
9741
- } else if (iso2) {
9742
- note = isArray(iso2) ? iso2.join(', ') : iso2;
9743
- }
9744
- return {
9745
- type: 'option',
9746
- value: {
9747
- value: phone,
9748
- label: phone,
9749
- note: note
9750
- },
9751
- filterMatchers: [phone, note, name]
9752
- };
9753
- });
9754
- };
9755
- const options = getSelectOptions();
9756
- const onPrefixChange = ({
9757
- value
9758
- }) => {
9759
- setInternalValue({
9760
- prefix: value,
9761
- suffix: internalValue.suffix
9762
- });
9763
- };
9690
+ const countriesByPrefix = useMemo(() => groupCountriesByPrefix(sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3')), [disabledCountries]);
9764
9691
  const onSuffixChange = event => {
9765
- const {
9766
- value = ''
9767
- } = event.target;
9768
- if (ALLOWED_PHONE_CHARS.test(value)) {
9769
- setInternalValue({
9770
- prefix: internalValue.prefix,
9771
- suffix: value
9772
- });
9692
+ const suffix = event.target.value;
9693
+ if (ALLOWED_PHONE_CHARS.test(suffix)) {
9694
+ setInternalValue(prev => ({
9695
+ ...prev,
9696
+ suffix
9697
+ }));
9773
9698
  }
9774
9699
  };
9775
9700
  const onPaste = event => {
@@ -9777,31 +9702,22 @@ const PhoneNumberInput = props => {
9777
9702
  return;
9778
9703
  }
9779
9704
  const pastedValue = (event.nativeEvent.clipboardData.getData('text/plain') || '').replace(/(\s|-)+/g, '');
9780
- const {
9781
- prefix: pastedPrefix,
9782
- suffix: pastedSuffix
9783
- } = explodeNumberModel(pastedValue);
9784
- const selectedPrefix = options.find(({
9785
- value
9786
- }) => value.value === pastedPrefix);
9787
- if (selectedPrefix && ALLOWED_PHONE_CHARS.test(pastedSuffix)) {
9788
- setInternalValue({
9789
- prefix: pastedPrefix,
9790
- suffix: pastedSuffix
9791
- });
9705
+ const pastedNumber = explodeNumberModel(pastedValue);
9706
+ if (pastedNumber.prefix != null && countriesByPrefix.has(pastedNumber.prefix) && ALLOWED_PHONE_CHARS.test(pastedNumber.suffix)) {
9707
+ setInternalValue(pastedNumber);
9792
9708
  }
9793
9709
  };
9794
9710
  useEffect(() => {
9795
9711
  if (broadcastedValue === null) {
9796
9712
  return setBroadcastedValue(internalValue);
9797
9713
  }
9798
- const internalPhoneNumber = internalValue.prefix + internalValue.suffix;
9799
- const broadcastedPhoneNumber = broadcastedValue.prefix + broadcastedValue.suffix;
9714
+ const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
9715
+ const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
9800
9716
  if (internalPhoneNumber === broadcastedPhoneNumber) {
9801
9717
  return;
9802
9718
  }
9803
9719
  const newValue = isValidPhoneNumber(internalPhoneNumber) ? cleanNumber(internalPhoneNumber) : null;
9804
- onChange(newValue, internalValue.prefix);
9720
+ onChange(newValue, internalValue.prefix ?? '');
9805
9721
  setBroadcastedValue(internalValue);
9806
9722
  }, [onChange, broadcastedValue, internalValue]);
9807
9723
  return /*#__PURE__*/jsxs("div", {
@@ -9809,18 +9725,27 @@ const PhoneNumberInput = props => {
9809
9725
  children: [/*#__PURE__*/jsx("div", {
9810
9726
  className: "tw-telephone__country-select",
9811
9727
  children: /*#__PURE__*/jsx(SelectInput, {
9812
- placeholder: "Select an option...",
9813
- items: options,
9814
- value: options.find(item => item.value.value === internalValue.prefix)?.value,
9815
- renderValue: (option, withinTrigger) => /*#__PURE__*/jsx(SelectInputOptionContent, {
9816
- title: option.label,
9817
- note: withinTrigger ? undefined : option.note
9728
+ placeholder: "Select an option\u2026",
9729
+ items: [...countriesByPrefix].map(([prefix, countries]) => ({
9730
+ type: 'option',
9731
+ value: prefix,
9732
+ filterMatchers: [prefix, ...countries.map(country => country.name), ...countries.map(country => country.iso3)]
9733
+ })),
9734
+ value: internalValue.prefix,
9735
+ renderValue: (prefix, withinTrigger) => /*#__PURE__*/jsx(SelectInputOptionContent, {
9736
+ title: prefix,
9737
+ note: withinTrigger ? undefined : countriesByPrefix.get(prefix)?.map(country => country.iso3).join(', ')
9818
9738
  }),
9819
9739
  filterable: true,
9820
9740
  filterPlaceholder: searchPlaceholder,
9821
9741
  disabled: disabled,
9822
9742
  size: size,
9823
- onChange: onPrefixChange,
9743
+ onChange: prefix => {
9744
+ setInternalValue(prev => ({
9745
+ ...prev,
9746
+ prefix
9747
+ }));
9748
+ },
9824
9749
  ...selectProps
9825
9750
  })
9826
9751
  }), /*#__PURE__*/jsx("div", {
@@ -9846,37 +9771,6 @@ const PhoneNumberInput = props => {
9846
9771
  })]
9847
9772
  });
9848
9773
  };
9849
- PhoneNumberInput.propTypes = {
9850
- id: PropTypes.string,
9851
- required: PropTypes.bool,
9852
- disabled: PropTypes.bool,
9853
- initialValue: PropTypes.string,
9854
- onChange: PropTypes.func.isRequired,
9855
- onFocus: PropTypes.func,
9856
- onBlur: PropTypes.func,
9857
- countryCode: PropTypes.string,
9858
- searchPlaceholder: PropTypes.string,
9859
- size: PropTypes.oneOf(['sm', 'md', 'lg']),
9860
- placeholder: PropTypes.string,
9861
- selectProps: PropTypes.object,
9862
- /** List of iso3 codes of countries to remove from the list */
9863
- disabledCountries: PropTypes.arrayOf(PropTypes.string)
9864
- };
9865
- PhoneNumberInput.defaultProps = {
9866
- id: null,
9867
- required: false,
9868
- disabled: false,
9869
- initialValue: null,
9870
- onFocus() {},
9871
- onBlur() {},
9872
- countryCode: null,
9873
- searchPlaceholder: 'Prefix',
9874
- size: Size.MEDIUM,
9875
- placeholder: '',
9876
- selectProps: {},
9877
- disabledCountries: []
9878
- };
9879
- var PhoneNumberInput$1 = PhoneNumberInput;
9880
9774
 
9881
9775
  const Progress = ({
9882
9776
  className,
@@ -12295,12 +12189,17 @@ Tabs.defaultProps = {
12295
12189
  };
12296
12190
  var Tabs$1 = Tabs;
12297
12191
 
12298
- const TextareaWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat, {
12192
+ const TextareaWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat$1, {
12299
12193
  ...props,
12300
- render: renderProps => /*#__PURE__*/jsx(TextArea, {
12194
+ render: renderProps => /*#__PURE__*/jsx("textarea", {
12301
12195
  ...renderProps
12302
12196
  })
12303
12197
  });
12198
+ TextareaWithDisplayFormat.propTypes = {
12199
+ displayPattern: PropTypes.string.isRequired,
12200
+ onChange: PropTypes.func.isRequired
12201
+ };
12202
+ var TextareaWithDisplayFormat$1 = TextareaWithDisplayFormat;
12304
12203
 
12305
12204
  /* eslint-disable jsx-a11y/no-autofocus */
12306
12205
  /* eslint-disable jsx-a11y/click-events-have-key-events */
@@ -15597,5 +15496,5 @@ const translations = {
15597
15496
  'zh-HK': zhHK
15598
15497
  };
15599
15498
 
15600
- export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput$1 as PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15499
+ export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat$1 as InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15601
15500
  //# sourceMappingURL=index.esm.js.map