@transferwise/components 0.0.0-experimental-2e23c2a → 0.0.0-experimental-16e2eec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.esm.js +185 -343
- package/build/index.esm.js.map +1 -1
- package/build/index.js +184 -342
- package/build/index.js.map +1 -1
- package/build/main.css +1 -3
- package/build/styles/inputs/SelectInput.css +1 -3
- package/build/styles/main.css +1 -3
- package/build/types/common/locale/index.d.ts +26 -43
- package/build/types/common/locale/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +5 -6
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +22 -27
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/phoneNumberInput/data/countries.d.ts +5 -10
- package/build/types/phoneNumberInput/data/countries.d.ts.map +1 -1
- package/build/types/phoneNumberInput/index.d.ts +1 -1
- package/build/types/phoneNumberInput/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/cleanNumber/cleanNumber.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/cleanNumber/cleanNumber.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/cleanNumber/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/cleanNumber/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts +8 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/excludeCountries/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/explodeNumberModel/index.d.ts +8 -4
- package/build/types/phoneNumberInput/utils/explodeNumberModel/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/findCountryByCode/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/findCountryByCode/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/findCountryByPrefix/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/findCountryByPrefix/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts +2 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/index.d.ts +11 -13
- package/build/types/phoneNumberInput/utils/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/isStringNumeric/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/isStringNumeric/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/isStringNumeric/isStringNumeric.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/isStringNumeric/isStringNumeric.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts +6 -1
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts +2 -1
- package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/setDefaultPrefix/index.d.ts +7 -1
- package/build/types/phoneNumberInput/utils/setDefaultPrefix/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/index.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/index.d.ts.map +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts +1 -1
- package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts.map +1 -1
- package/build/types/utilities/wrapInFragment.d.ts +3 -0
- package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/common/locale/{index.spec.js → index.spec.ts} +4 -4
- package/src/common/locale/index.ts +96 -0
- package/src/inputs/SelectInput.css +1 -3
- package/src/inputs/SelectInput.less +1 -4
- package/src/inputs/SelectInput.spec.tsx +0 -26
- package/src/inputs/SelectInput.story.tsx +1 -73
- package/src/inputs/SelectInput.tsx +85 -104
- package/src/main.css +1 -3
- package/src/phoneNumberInput/PhoneNumberInput.spec.js +18 -22
- package/src/phoneNumberInput/PhoneNumberInput.tsx +193 -0
- package/src/phoneNumberInput/data/{countries.js → countries.ts} +9 -1
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +3 -0
- package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.spec.js → excludeCountries.spec.ts} +1 -1
- package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.js → excludeCountries.ts} +6 -5
- package/src/phoneNumberInput/utils/explodeNumberModel/{explodeNumberModel.spec.js → explodeNumberModel.spec.ts} +1 -1
- package/src/phoneNumberInput/utils/explodeNumberModel/index.ts +24 -0
- package/src/phoneNumberInput/utils/findCountryByCode/{findCountryByCode.spec.js → findCountryByCode.spec.ts} +0 -1
- package/src/phoneNumberInput/utils/findCountryByCode/index.ts +12 -0
- package/src/phoneNumberInput/utils/findCountryByPrefix/index.ts +12 -0
- package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.spec.ts +102 -0
- package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.ts +12 -0
- package/src/phoneNumberInput/utils/{index.js → index.ts} +0 -2
- package/src/phoneNumberInput/utils/isStringNumeric/{isStringNumeric.spec.js → isStringNumeric.spec.ts} +0 -1
- package/src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.ts +1 -0
- package/src/phoneNumberInput/utils/isValidPhoneNumber/{isValidPhoneNumber.spec.js → isValidPhoneNumber.spec.ts} +1 -1
- package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts +7 -0
- package/src/phoneNumberInput/utils/longestMatchingPrefix/index.ts +4 -0
- package/src/phoneNumberInput/utils/setDefaultPrefix/index.ts +20 -0
- package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.ts +6 -0
- package/src/utilities/wrapInFragment.tsx +3 -0
- package/build/types/phoneNumberInput/utils/filterOptionsForQuery/index.d.ts +0 -2
- package/build/types/phoneNumberInput/utils/filterOptionsForQuery/index.d.ts.map +0 -1
- package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/index.d.ts +0 -2
- package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/index.d.ts.map +0 -1
- package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.d.ts +0 -3
- package/build/types/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.d.ts.map +0 -1
- package/src/common/locale/index.js +0 -139
- package/src/phoneNumberInput/PhoneNumberInput.js +0 -210
- package/src/phoneNumberInput/data/countries.spec.js +0 -12
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.js +0 -4
- package/src/phoneNumberInput/utils/explodeNumberModel/index.js +0 -27
- package/src/phoneNumberInput/utils/filterOptionsForQuery/filterOptionsForQuery.spec.js +0 -36
- package/src/phoneNumberInput/utils/filterOptionsForQuery/index.js +0 -11
- package/src/phoneNumberInput/utils/findCountryByCode/index.js +0 -10
- package/src/phoneNumberInput/utils/findCountryByPrefix/index.js +0 -11
- package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.js +0 -26
- package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.spec.js +0 -67
- package/src/phoneNumberInput/utils/isOptionAndFitsQuery/index.js +0 -1
- package/src/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.js +0 -25
- package/src/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.spec.js +0 -66
- package/src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.js +0 -1
- package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js +0 -10
- package/src/phoneNumberInput/utils/longestMatchingPrefix/index.js +0 -2
- package/src/phoneNumberInput/utils/setDefaultPrefix/index.js +0 -25
- package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.js +0 -3
- /package/src/phoneNumberInput/{PhoneNumberInput.story.js → PhoneNumberInput.story.tsx} +0 -0
- /package/src/phoneNumberInput/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/cleanNumber/{cleanNumber.spec.js → cleanNumber.spec.ts} +0 -0
- /package/src/phoneNumberInput/utils/cleanNumber/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/excludeCountries/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/findCountryByPrefix/{findCountryByPrefix.spec.js → findCountryByPrefix.spec.ts} +0 -0
- /package/src/phoneNumberInput/utils/groupCountriesByPrefix/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/isStringNumeric/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/isValidPhoneNumber/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/longestMatchingPrefix/{longestMatchingPrefix.spec.js → longestMatchingPrefix.spec.ts} +0 -0
- /package/src/phoneNumberInput/utils/setDefaultPrefix/{setDefaultPrefix.spec.js → setDefaultPrefix.spec.ts} +0 -0
- /package/src/phoneNumberInput/utils/sortArrayByProperty/{index.js → index.ts} +0 -0
- /package/src/phoneNumberInput/utils/sortArrayByProperty/{sortArrayByProperty.spec.js → sortArrayByProperty.spec.ts} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
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
|
|
374
|
-
* Returns null if locale is unrecognized by {Intl.Locale}
|
|
356
|
+
* Verifies and adjusts locale, replacing `_` with `-`.
|
|
375
357
|
*
|
|
376
|
-
* @param
|
|
377
|
-
* @returns
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
|
405
|
-
* @returns
|
|
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
|
|
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
|
|
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
|
|
432
|
-
* @returns
|
|
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
|
-
|
|
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
|
|
456
|
-
* @returns
|
|
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
|
-
|
|
460
|
-
|
|
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
|
/**
|
|
@@ -6454,6 +6399,12 @@ const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWit
|
|
|
6454
6399
|
});
|
|
6455
6400
|
});
|
|
6456
6401
|
|
|
6402
|
+
function wrapInFragment(value) {
|
|
6403
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
6404
|
+
children: value
|
|
6405
|
+
});
|
|
6406
|
+
}
|
|
6407
|
+
|
|
6457
6408
|
var messages$4 = defineMessages({
|
|
6458
6409
|
noResultsFound: {
|
|
6459
6410
|
id: "neptune.SelectInput.noResultsFound"
|
|
@@ -6794,10 +6745,10 @@ const defaultRenderTrigger = ({
|
|
|
6794
6745
|
children: /*#__PURE__*/jsx(SelectInputTriggerButton, {
|
|
6795
6746
|
as: ButtonInput,
|
|
6796
6747
|
size: size,
|
|
6797
|
-
children: /*#__PURE__*/
|
|
6798
|
-
className:
|
|
6799
|
-
children: content
|
|
6800
|
-
})
|
|
6748
|
+
children: placeholderShown ? /*#__PURE__*/jsxs("span", {
|
|
6749
|
+
className: "np-select-input-placeholder",
|
|
6750
|
+
children: [" ", content]
|
|
6751
|
+
}) : content
|
|
6801
6752
|
})
|
|
6802
6753
|
});
|
|
6803
6754
|
function SelectInputClearButton({
|
|
@@ -6818,13 +6769,12 @@ function SelectInputClearButton({
|
|
|
6818
6769
|
const noop = () => {};
|
|
6819
6770
|
function SelectInput({
|
|
6820
6771
|
name,
|
|
6821
|
-
multiple = false,
|
|
6822
6772
|
placeholder,
|
|
6823
6773
|
items,
|
|
6824
6774
|
defaultValue,
|
|
6825
6775
|
value: controlledValue,
|
|
6826
6776
|
compareValues,
|
|
6827
|
-
renderValue =
|
|
6777
|
+
renderValue = wrapInFragment,
|
|
6828
6778
|
renderFooter,
|
|
6829
6779
|
renderTrigger = defaultRenderTrigger,
|
|
6830
6780
|
filterable,
|
|
@@ -6853,7 +6803,6 @@ function SelectInput({
|
|
|
6853
6803
|
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
6854
6804
|
return /*#__PURE__*/jsx(Listbox, {
|
|
6855
6805
|
name: name,
|
|
6856
|
-
multiple: multiple,
|
|
6857
6806
|
defaultValue: defaultValue,
|
|
6858
6807
|
value: controlledValue
|
|
6859
6808
|
// TODO: Remove assertion when upgrading TypeScript to v5
|
|
@@ -6862,78 +6811,73 @@ function SelectInput({
|
|
|
6862
6811
|
by: compareValues,
|
|
6863
6812
|
disabled: disabled,
|
|
6864
6813
|
onChange: value => {
|
|
6865
|
-
|
|
6866
|
-
setOpen(false);
|
|
6867
|
-
}
|
|
6814
|
+
setOpen(false);
|
|
6868
6815
|
onChange?.(value);
|
|
6869
6816
|
},
|
|
6870
6817
|
children: ({
|
|
6871
6818
|
disabled: uiDisabled,
|
|
6872
6819
|
value
|
|
6873
|
-
}) => {
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6820
|
+
}) => /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6821
|
+
placement: "bottom-start",
|
|
6822
|
+
open: open,
|
|
6823
|
+
renderTrigger: ({
|
|
6824
|
+
ref,
|
|
6825
|
+
getInteractionProps
|
|
6826
|
+
}) => /*#__PURE__*/jsx(SelectInputTriggerButtonPropsContext.Provider, {
|
|
6827
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6828
|
+
value: {
|
|
6829
|
+
ref: mergeRefs([ref, triggerRef]),
|
|
6830
|
+
...mergeProps({
|
|
6831
|
+
onClick: () => {
|
|
6832
|
+
setOpen(prev => !prev);
|
|
6833
|
+
},
|
|
6834
|
+
onKeyDown: event => {
|
|
6835
|
+
if (event.key === ' ' || event.key === 'Enter' || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
6887
6836
|
setOpen(prev => !prev);
|
|
6888
|
-
},
|
|
6889
|
-
onKeyDown: event => {
|
|
6890
|
-
if (event.key === ' ' || event.key === 'Enter' || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
6891
|
-
setOpen(prev => !prev);
|
|
6892
|
-
}
|
|
6893
6837
|
}
|
|
6894
|
-
}
|
|
6895
|
-
},
|
|
6896
|
-
children: renderTrigger({
|
|
6897
|
-
content: !placeholderShown ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6898
|
-
value: true,
|
|
6899
|
-
children: multiple && Array.isArray(value) ? value.map(option => renderValue(option, true)).join(', ') : renderValue(value, true)
|
|
6900
|
-
}) : placeholder,
|
|
6901
|
-
placeholderShown,
|
|
6902
|
-
clear: onClear != null ? () => {
|
|
6903
|
-
onClear();
|
|
6904
|
-
triggerRef.current?.focus({
|
|
6905
|
-
preventScroll: true
|
|
6906
|
-
});
|
|
6907
|
-
} : undefined,
|
|
6908
|
-
disabled: uiDisabled,
|
|
6909
|
-
size,
|
|
6910
|
-
className
|
|
6911
|
-
})
|
|
6912
|
-
}),
|
|
6913
|
-
initialFocusRef: controllerRef,
|
|
6914
|
-
size: filterable ? 'lg' : 'md',
|
|
6915
|
-
padding: "none",
|
|
6916
|
-
onClose: () => {
|
|
6917
|
-
setOpen(false);
|
|
6918
|
-
},
|
|
6919
|
-
onCloseEnd: () => {
|
|
6920
|
-
if (filterQuery !== '') {
|
|
6921
|
-
setFilterQuery('');
|
|
6922
|
-
}
|
|
6838
|
+
}
|
|
6839
|
+
}, getInteractionProps())
|
|
6923
6840
|
},
|
|
6924
|
-
children:
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6841
|
+
children: renderTrigger({
|
|
6842
|
+
content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6843
|
+
value: true,
|
|
6844
|
+
children: renderValue(value, true)
|
|
6845
|
+
}) : placeholder,
|
|
6846
|
+
placeholderShown: value == null,
|
|
6847
|
+
clear: onClear != null ? () => {
|
|
6848
|
+
onClear();
|
|
6849
|
+
triggerRef.current?.focus({
|
|
6850
|
+
preventScroll: true
|
|
6851
|
+
});
|
|
6852
|
+
} : undefined,
|
|
6853
|
+
disabled: uiDisabled,
|
|
6854
|
+
size,
|
|
6855
|
+
className
|
|
6934
6856
|
})
|
|
6935
|
-
})
|
|
6936
|
-
|
|
6857
|
+
}),
|
|
6858
|
+
initialFocusRef: controllerRef,
|
|
6859
|
+
size: filterable ? 'lg' : 'md',
|
|
6860
|
+
padding: "none",
|
|
6861
|
+
onClose: () => {
|
|
6862
|
+
setOpen(false);
|
|
6863
|
+
},
|
|
6864
|
+
onCloseEnd: () => {
|
|
6865
|
+
if (filterQuery !== '') {
|
|
6866
|
+
setFilterQuery('');
|
|
6867
|
+
}
|
|
6868
|
+
},
|
|
6869
|
+
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6870
|
+
items: items,
|
|
6871
|
+
renderValue: renderValue,
|
|
6872
|
+
renderFooter: renderFooter,
|
|
6873
|
+
filterable: filterable,
|
|
6874
|
+
filterPlaceholder: filterPlaceholder,
|
|
6875
|
+
searchInputRef: searchInputRef,
|
|
6876
|
+
listboxRef: listboxRef,
|
|
6877
|
+
filterQuery: filterQuery,
|
|
6878
|
+
onFilterChange: setFilterQuery
|
|
6879
|
+
})
|
|
6880
|
+
})
|
|
6937
6881
|
});
|
|
6938
6882
|
}
|
|
6939
6883
|
function SelectInputTriggerButton({
|
|
@@ -6996,7 +6940,7 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
|
|
|
6996
6940
|
});
|
|
6997
6941
|
function SelectInputOptions({
|
|
6998
6942
|
items,
|
|
6999
|
-
renderValue =
|
|
6943
|
+
renderValue = wrapInFragment,
|
|
7000
6944
|
renderFooter,
|
|
7001
6945
|
filterable = false,
|
|
7002
6946
|
filterPlaceholder,
|
|
@@ -9568,111 +9512,79 @@ const countries = [{
|
|
|
9568
9512
|
iso3: 'ZWE',
|
|
9569
9513
|
phone: '+263'
|
|
9570
9514
|
}];
|
|
9571
|
-
var countries$1 = countries;
|
|
9572
9515
|
|
|
9573
9516
|
const longestMatchingPrefix = matchingCodes => matchingCodes.reduce((a, b) => a.phone.length > b.phone.length ? a : b);
|
|
9574
9517
|
|
|
9575
9518
|
const findCountryByCode = code => {
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
matchingCodes
|
|
9519
|
+
if (code.length === 2) {
|
|
9520
|
+
const matchingCodes = countries.filter(country => code.toUpperCase() === country.iso2);
|
|
9521
|
+
if (matchingCodes.length > 0) {
|
|
9522
|
+
return longestMatchingPrefix(matchingCodes);
|
|
9523
|
+
}
|
|
9579
9524
|
}
|
|
9580
|
-
return
|
|
9525
|
+
return null;
|
|
9581
9526
|
};
|
|
9582
9527
|
|
|
9583
9528
|
/**
|
|
9584
9529
|
* Default phone code, the UK one `+44`
|
|
9585
9530
|
*/
|
|
9586
9531
|
const DEFAULT_PHONE_CODE = '+44';
|
|
9587
|
-
|
|
9588
9532
|
/**
|
|
9589
9533
|
* Given a valid locale it returns the correspondent prefix if found or +44 otherwise.
|
|
9590
9534
|
*
|
|
9591
|
-
* @param
|
|
9592
|
-
* @param countryCode
|
|
9593
|
-
* @returns {string}
|
|
9535
|
+
* @param locale BCP 47 language tag of locale, e.g. `"es-ES"`.
|
|
9536
|
+
* @param countryCode Two-letter country code (ISO 3166-1 alpha-2).
|
|
9594
9537
|
*/
|
|
9595
9538
|
const setDefaultPrefix = (locale, countryCode) => {
|
|
9596
|
-
const country = findCountryByCode(countryCode)
|
|
9597
|
-
|
|
9598
|
-
findCountryByCode(getCountryFromLocale(locale)) ||
|
|
9599
|
-
// when `locale` code is only two chars value: `fr`, `es`
|
|
9600
|
-
findCountryByCode(locale);
|
|
9601
|
-
return country?.phone || DEFAULT_PHONE_CODE;
|
|
9539
|
+
const country = (countryCode != null ? findCountryByCode(countryCode) : null) ?? findCountryByCode(getCountryFromLocale(locale) ?? locale);
|
|
9540
|
+
return country?.phone ?? DEFAULT_PHONE_CODE;
|
|
9602
9541
|
};
|
|
9603
9542
|
|
|
9604
9543
|
/**
|
|
9605
9544
|
*
|
|
9606
9545
|
* @param phoneNumber
|
|
9607
|
-
* @returns
|
|
9608
|
-
* at least 4 digits.
|
|
9546
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with at least 4 digits.
|
|
9609
9547
|
*/
|
|
9610
|
-
const isValidPhoneNumber = phoneNumber => /^\+[\d-\s]+$/.test(phoneNumber) &&
|
|
9548
|
+
const isValidPhoneNumber = phoneNumber => /^\+[\d-\s]+$/.test(phoneNumber) && (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= 4;
|
|
9611
9549
|
|
|
9612
9550
|
const findCountryByPrefix = number => {
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9551
|
+
if (number.length > 1) {
|
|
9552
|
+
const matchingCodes = countries.filter(country => number.startsWith(country.phone));
|
|
9553
|
+
if (matchingCodes.length > 0) {
|
|
9554
|
+
return longestMatchingPrefix(matchingCodes);
|
|
9555
|
+
}
|
|
9616
9556
|
}
|
|
9617
|
-
return
|
|
9557
|
+
return null;
|
|
9618
9558
|
};
|
|
9619
9559
|
|
|
9620
9560
|
/**
|
|
9621
|
-
*
|
|
9622
|
-
* {prefix=+44 ,suffix=7573135343}
|
|
9623
|
-
*
|
|
9624
|
-
* @param {string} number - a string that defines a phone number.
|
|
9625
|
-
* @returns {{prefix: (string|*), suffix: string, format: string}}
|
|
9561
|
+
* @param number Phone number in a format like "+447573135343"
|
|
9626
9562
|
*/
|
|
9627
9563
|
const explodeNumberModel = number => {
|
|
9628
|
-
let prefix = '';
|
|
9629
|
-
let suffix = '';
|
|
9630
|
-
let format = '';
|
|
9631
9564
|
const country = findCountryByPrefix(number);
|
|
9632
|
-
|
|
9633
|
-
prefix
|
|
9634
|
-
suffix
|
|
9635
|
-
format
|
|
9636
|
-
}
|
|
9637
|
-
prefix
|
|
9638
|
-
suffix
|
|
9639
|
-
format = '';
|
|
9640
|
-
}
|
|
9641
|
-
return {
|
|
9642
|
-
prefix,
|
|
9643
|
-
suffix,
|
|
9644
|
-
format
|
|
9565
|
+
return country ? {
|
|
9566
|
+
prefix: country.phone,
|
|
9567
|
+
suffix: number.slice(country.phone.length),
|
|
9568
|
+
format: country.phoneFormat
|
|
9569
|
+
} : {
|
|
9570
|
+
prefix: null,
|
|
9571
|
+
suffix: number.slice(1)
|
|
9645
9572
|
};
|
|
9646
9573
|
};
|
|
9647
9574
|
|
|
9648
9575
|
const DIGITS_MATCH = /^$|^(\+)|([\d]+)/g;
|
|
9649
|
-
const cleanNumber = number => number.match(DIGITS_MATCH)
|
|
9576
|
+
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
9650
9577
|
|
|
9651
|
-
|
|
9652
|
-
|
|
9578
|
+
function sortArrayByProperty(arrayToSort, property) {
|
|
9579
|
+
return [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
|
|
9580
|
+
}
|
|
9653
9581
|
|
|
9654
9582
|
const groupCountriesByPrefix = countries => {
|
|
9655
|
-
const
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
phone
|
|
9661
|
-
} = country;
|
|
9662
|
-
if (accumulator[phone]) {
|
|
9663
|
-
const previousValue = accumulator[phone];
|
|
9664
|
-
accumulator[phone] = {
|
|
9665
|
-
...previousValue,
|
|
9666
|
-
name: isArray(previousValue.name) ? [...previousValue.name, name] : [previousValue.name, name],
|
|
9667
|
-
iso2: isArray(previousValue.iso2) ? [...previousValue.iso2, iso2] : [previousValue.iso2, iso2],
|
|
9668
|
-
iso3: isArray(previousValue.iso3) ? [...previousValue.iso3, iso3] : [previousValue.iso3, iso3]
|
|
9669
|
-
};
|
|
9670
|
-
} else {
|
|
9671
|
-
accumulator[phone] = country;
|
|
9672
|
-
}
|
|
9673
|
-
return accumulator;
|
|
9674
|
-
}, {});
|
|
9675
|
-
return Object.values(groupedArray);
|
|
9583
|
+
const countriesByPrefix = new Map();
|
|
9584
|
+
countries.forEach(country => {
|
|
9585
|
+
countriesByPrefix.set(country.phone, [...(countriesByPrefix.get(country.phone) ?? []), country]);
|
|
9586
|
+
});
|
|
9587
|
+
return countriesByPrefix;
|
|
9676
9588
|
};
|
|
9677
9589
|
|
|
9678
9590
|
// Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
|
|
@@ -9680,41 +9592,38 @@ const filterCountriesByIso3 = (countries, iso3Codes) => {
|
|
|
9680
9592
|
const iso3CodesSet = new Set(iso3Codes);
|
|
9681
9593
|
return countries.filter(country => !iso3CodesSet.has(country.iso3));
|
|
9682
9594
|
};
|
|
9683
|
-
|
|
9684
9595
|
/**
|
|
9685
9596
|
* Removes the countries sepecified in the second param
|
|
9686
9597
|
*
|
|
9687
|
-
* @param
|
|
9688
|
-
* @param
|
|
9689
|
-
* @returns
|
|
9598
|
+
* @param countries list of country metadata objects
|
|
9599
|
+
* @param disabledCountries list of iso3 country codes to remove from the list
|
|
9690
9600
|
*/
|
|
9691
9601
|
const excludeCountries = (countries, disabledCountries) => {
|
|
9692
9602
|
return disabledCountries.length > 0 ? filterCountriesByIso3(countries, disabledCountries) : countries;
|
|
9693
9603
|
};
|
|
9694
9604
|
|
|
9695
9605
|
const ALLOWED_PHONE_CHARS = /^$|^[\d-\s]+$/;
|
|
9696
|
-
const
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9606
|
+
const defaultSelectProps = {};
|
|
9607
|
+
const defaultDisabledCountries = [];
|
|
9608
|
+
const PhoneNumberInput = ({
|
|
9609
|
+
id,
|
|
9610
|
+
required,
|
|
9611
|
+
disabled,
|
|
9612
|
+
initialValue,
|
|
9613
|
+
onChange,
|
|
9614
|
+
onFocus,
|
|
9615
|
+
onBlur,
|
|
9616
|
+
countryCode,
|
|
9617
|
+
searchPlaceholder = 'Prefix',
|
|
9618
|
+
size = Size.MEDIUM,
|
|
9619
|
+
placeholder,
|
|
9620
|
+
selectProps = defaultSelectProps,
|
|
9621
|
+
disabledCountries = defaultDisabledCountries
|
|
9622
|
+
}) => {
|
|
9711
9623
|
const {
|
|
9712
9624
|
locale
|
|
9713
9625
|
} = useIntl();
|
|
9714
|
-
const
|
|
9715
|
-
const {
|
|
9716
|
-
initialValue
|
|
9717
|
-
} = props;
|
|
9626
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
9718
9627
|
const cleanValue = initialValue ? cleanNumber(initialValue) : null;
|
|
9719
9628
|
if (!cleanValue || !isValidPhoneNumber(cleanValue)) {
|
|
9720
9629
|
return {
|
|
@@ -9723,54 +9632,16 @@ const PhoneNumberInput = props => {
|
|
|
9723
9632
|
};
|
|
9724
9633
|
}
|
|
9725
9634
|
return explodeNumberModel(cleanValue);
|
|
9726
|
-
};
|
|
9727
|
-
const [internalValue, setInternalValue] = useState(getInitialValue());
|
|
9635
|
+
});
|
|
9728
9636
|
const [broadcastedValue, setBroadcastedValue] = useState(null);
|
|
9729
|
-
const
|
|
9730
|
-
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
9731
|
-
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
9732
|
-
return listSortedByISO3.map(option => {
|
|
9733
|
-
const {
|
|
9734
|
-
phone,
|
|
9735
|
-
iso3,
|
|
9736
|
-
iso2,
|
|
9737
|
-
name
|
|
9738
|
-
} = option;
|
|
9739
|
-
let note = '';
|
|
9740
|
-
if (iso3) {
|
|
9741
|
-
note = isArray(iso3) ? iso3.join(', ') : iso3;
|
|
9742
|
-
} else if (iso2) {
|
|
9743
|
-
note = isArray(iso2) ? iso2.join(', ') : iso2;
|
|
9744
|
-
}
|
|
9745
|
-
return {
|
|
9746
|
-
type: 'option',
|
|
9747
|
-
value: {
|
|
9748
|
-
value: phone,
|
|
9749
|
-
label: phone,
|
|
9750
|
-
note: note
|
|
9751
|
-
},
|
|
9752
|
-
filterMatchers: [phone, note, name]
|
|
9753
|
-
};
|
|
9754
|
-
});
|
|
9755
|
-
};
|
|
9756
|
-
const options = getSelectOptions();
|
|
9757
|
-
const onPrefixChange = ({
|
|
9758
|
-
value
|
|
9759
|
-
}) => {
|
|
9760
|
-
setInternalValue({
|
|
9761
|
-
prefix: value,
|
|
9762
|
-
suffix: internalValue.suffix
|
|
9763
|
-
});
|
|
9764
|
-
};
|
|
9637
|
+
const countriesByPrefix = useMemo(() => groupCountriesByPrefix(sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3')), [disabledCountries]);
|
|
9765
9638
|
const onSuffixChange = event => {
|
|
9766
|
-
const
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
suffix: value
|
|
9773
|
-
});
|
|
9639
|
+
const suffix = event.target.value;
|
|
9640
|
+
if (ALLOWED_PHONE_CHARS.test(suffix)) {
|
|
9641
|
+
setInternalValue(prev => ({
|
|
9642
|
+
...prev,
|
|
9643
|
+
suffix
|
|
9644
|
+
}));
|
|
9774
9645
|
}
|
|
9775
9646
|
};
|
|
9776
9647
|
const onPaste = event => {
|
|
@@ -9778,31 +9649,22 @@ const PhoneNumberInput = props => {
|
|
|
9778
9649
|
return;
|
|
9779
9650
|
}
|
|
9780
9651
|
const pastedValue = (event.nativeEvent.clipboardData.getData('text/plain') || '').replace(/(\s|-)+/g, '');
|
|
9781
|
-
const
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
} = explodeNumberModel(pastedValue);
|
|
9785
|
-
const selectedPrefix = options.find(({
|
|
9786
|
-
value
|
|
9787
|
-
}) => value.value === pastedPrefix);
|
|
9788
|
-
if (selectedPrefix && ALLOWED_PHONE_CHARS.test(pastedSuffix)) {
|
|
9789
|
-
setInternalValue({
|
|
9790
|
-
prefix: pastedPrefix,
|
|
9791
|
-
suffix: pastedSuffix
|
|
9792
|
-
});
|
|
9652
|
+
const pastedNumber = explodeNumberModel(pastedValue);
|
|
9653
|
+
if (pastedNumber.prefix != null && countriesByPrefix.has(pastedNumber.prefix) && ALLOWED_PHONE_CHARS.test(pastedNumber.suffix)) {
|
|
9654
|
+
setInternalValue(pastedNumber);
|
|
9793
9655
|
}
|
|
9794
9656
|
};
|
|
9795
9657
|
useEffect(() => {
|
|
9796
9658
|
if (broadcastedValue === null) {
|
|
9797
9659
|
return setBroadcastedValue(internalValue);
|
|
9798
9660
|
}
|
|
9799
|
-
const internalPhoneNumber = internalValue.prefix
|
|
9800
|
-
const broadcastedPhoneNumber = broadcastedValue.prefix
|
|
9661
|
+
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
9662
|
+
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
9801
9663
|
if (internalPhoneNumber === broadcastedPhoneNumber) {
|
|
9802
9664
|
return;
|
|
9803
9665
|
}
|
|
9804
9666
|
const newValue = isValidPhoneNumber(internalPhoneNumber) ? cleanNumber(internalPhoneNumber) : null;
|
|
9805
|
-
onChange(newValue, internalValue.prefix);
|
|
9667
|
+
onChange(newValue, internalValue.prefix ?? '');
|
|
9806
9668
|
setBroadcastedValue(internalValue);
|
|
9807
9669
|
}, [onChange, broadcastedValue, internalValue]);
|
|
9808
9670
|
return /*#__PURE__*/jsxs("div", {
|
|
@@ -9810,18 +9672,29 @@ const PhoneNumberInput = props => {
|
|
|
9810
9672
|
children: [/*#__PURE__*/jsx("div", {
|
|
9811
9673
|
className: "tw-telephone__country-select",
|
|
9812
9674
|
children: /*#__PURE__*/jsx(SelectInput, {
|
|
9813
|
-
placeholder: "Select an option
|
|
9814
|
-
items:
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9675
|
+
placeholder: "Select an option\u2026",
|
|
9676
|
+
items: [...countriesByPrefix].map(([prefix, countries]) => ({
|
|
9677
|
+
type: 'option',
|
|
9678
|
+
value: prefix,
|
|
9679
|
+
filterMatchers: [prefix, ...countries.map(country => country.name), ...countries.map(country => country.iso3)]
|
|
9680
|
+
})),
|
|
9681
|
+
value: internalValue.prefix,
|
|
9682
|
+
renderValue: (prefix, withinTrigger) => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
9683
|
+
title: prefix,
|
|
9684
|
+
note: withinTrigger ? undefined : countriesByPrefix.get(prefix)?.map(country => country.iso3).join(', ')
|
|
9819
9685
|
}),
|
|
9820
9686
|
filterable: true,
|
|
9821
9687
|
filterPlaceholder: searchPlaceholder,
|
|
9822
9688
|
disabled: disabled,
|
|
9823
9689
|
size: size,
|
|
9824
|
-
onChange:
|
|
9690
|
+
onChange: prefix => {
|
|
9691
|
+
const country = prefix != null ? findCountryByPrefix(prefix) : null;
|
|
9692
|
+
setInternalValue(prev => ({
|
|
9693
|
+
...prev,
|
|
9694
|
+
prefix,
|
|
9695
|
+
format: country?.phoneFormat
|
|
9696
|
+
}));
|
|
9697
|
+
},
|
|
9825
9698
|
...selectProps
|
|
9826
9699
|
})
|
|
9827
9700
|
}), /*#__PURE__*/jsx("div", {
|
|
@@ -9847,37 +9720,6 @@ const PhoneNumberInput = props => {
|
|
|
9847
9720
|
})]
|
|
9848
9721
|
});
|
|
9849
9722
|
};
|
|
9850
|
-
PhoneNumberInput.propTypes = {
|
|
9851
|
-
id: PropTypes.string,
|
|
9852
|
-
required: PropTypes.bool,
|
|
9853
|
-
disabled: PropTypes.bool,
|
|
9854
|
-
initialValue: PropTypes.string,
|
|
9855
|
-
onChange: PropTypes.func.isRequired,
|
|
9856
|
-
onFocus: PropTypes.func,
|
|
9857
|
-
onBlur: PropTypes.func,
|
|
9858
|
-
countryCode: PropTypes.string,
|
|
9859
|
-
searchPlaceholder: PropTypes.string,
|
|
9860
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
9861
|
-
placeholder: PropTypes.string,
|
|
9862
|
-
selectProps: PropTypes.object,
|
|
9863
|
-
/** List of iso3 codes of countries to remove from the list */
|
|
9864
|
-
disabledCountries: PropTypes.arrayOf(PropTypes.string)
|
|
9865
|
-
};
|
|
9866
|
-
PhoneNumberInput.defaultProps = {
|
|
9867
|
-
id: null,
|
|
9868
|
-
required: false,
|
|
9869
|
-
disabled: false,
|
|
9870
|
-
initialValue: null,
|
|
9871
|
-
onFocus() {},
|
|
9872
|
-
onBlur() {},
|
|
9873
|
-
countryCode: null,
|
|
9874
|
-
searchPlaceholder: 'Prefix',
|
|
9875
|
-
size: Size.MEDIUM,
|
|
9876
|
-
placeholder: '',
|
|
9877
|
-
selectProps: {},
|
|
9878
|
-
disabledCountries: []
|
|
9879
|
-
};
|
|
9880
|
-
var PhoneNumberInput$1 = PhoneNumberInput;
|
|
9881
9723
|
|
|
9882
9724
|
const Progress = ({
|
|
9883
9725
|
className,
|
|
@@ -15598,5 +15440,5 @@ const translations = {
|
|
|
15598
15440
|
'zh-HK': zhHK
|
|
15599
15441
|
};
|
|
15600
15442
|
|
|
15601
|
-
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
|
|
15443
|
+
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, 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 };
|
|
15602
15444
|
//# sourceMappingURL=index.esm.js.map
|