@transferwise/components 46.5.0 → 46.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/i18n/th.json +3 -3
- package/build/index.esm.js +252 -464
- package/build/index.esm.js.map +1 -1
- package/build/index.js +253 -465
- package/build/index.js.map +1 -1
- package/build/main.css +6 -17
- package/build/styles/inputs/Input.css +0 -4
- package/build/styles/inputs/SelectInput.css +6 -1
- package/build/styles/inputs/TextArea.css +0 -4
- package/build/styles/main.css +6 -17
- package/build/styles/select/Select.css +0 -4
- package/build/types/common/locale/index.d.ts +26 -43
- package/build/types/common/locale/index.d.ts.map +1 -1
- package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts +1 -1
- package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts.map +1 -1
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts +2 -2
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts.map +1 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts +5 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts.map +1 -1
- package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts +1 -1
- package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +7 -11
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
- package/build/types/inputWithDisplayFormat/index.d.ts +2 -1
- package/build/types/inputWithDisplayFormat/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +6 -5
- 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/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +7 -11
- package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
- package/build/types/textareaWithDisplayFormat/index.d.ts +2 -1
- package/build/types/textareaWithDisplayFormat/index.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +55 -83
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/build/types/withDisplayFormat/index.d.ts +2 -1
- package/build/types/withDisplayFormat/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/common/locale/{index.spec.js → index.spec.ts} +4 -4
- package/src/common/locale/index.ts +96 -0
- package/src/common/textFormat/formatWithPattern/{formatWithPattern.js → formatWithPattern.ts} +8 -4
- package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.js → getCursorPositionAfterKeystroke.ts} +8 -8
- package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.js → getSymbolsInPatternWithPosition.ts} +7 -2
- package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.js → unformatWithPattern.ts} +3 -2
- package/src/i18n/th.json +3 -3
- package/src/index.ts +3 -0
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +10 -0
- package/src/inputWithDisplayFormat/index.ts +2 -0
- package/src/inputs/Input.css +0 -4
- package/src/inputs/SelectInput.css +6 -1
- package/src/inputs/SelectInput.less +8 -1
- package/src/inputs/SelectInput.spec.tsx +26 -0
- package/src/inputs/SelectInput.story.tsx +73 -1
- package/src/inputs/SelectInput.tsx +104 -85
- package/src/inputs/TextArea.css +0 -4
- package/src/main.css +6 -17
- 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/select/Select.css +0 -4
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.spec.js +3 -1
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +32 -0
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +13 -0
- package/src/textareaWithDisplayFormat/index.ts +2 -0
- package/src/withDisplayFormat/WithDisplayFormat.spec.js +1 -1
- package/src/withDisplayFormat/{WithDisplayFormat.js → WithDisplayFormat.tsx} +127 -107
- package/src/withDisplayFormat/index.ts +2 -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/build/types/utilities/wrapInFragment.d.ts +0 -3
- package/build/types/utilities/wrapInFragment.d.ts.map +0 -1
- package/src/common/locale/index.js +0 -139
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.js +0 -14
- package/src/inputWithDisplayFormat/index.js +0 -1
- 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/textareaWithDisplayFormat/TextareaWithDisplayFormat.js +0 -14
- package/src/textareaWithDisplayFormat/index.js +0 -1
- package/src/utilities/wrapInFragment.tsx +0 -3
- package/src/withDisplayFormat/index.js +0 -1
- /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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/explodeNumberModel/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/explodeNumberModel/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAY,MAAM,KAAG,WAYnD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const findCountryByCode: (code: string) => import("../../data/countries").Country | null;
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/findCountryByCode/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/findCountryByCode/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,SAAU,MAAM,kDAQ7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const findCountryByPrefix: (number: string) => import("../../data/countries").Country | null;
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/findCountryByPrefix/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/findCountryByPrefix/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,WAAY,MAAM,kDAQjD,CAAC"}
|
package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupCountriesByPrefix.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.
|
|
1
|
+
{"version":3,"file":"groupCountriesByPrefix.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,eAAO,MAAM,sBAAsB,cAAe,OAAO,EAAE,2BAS1D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { groupCountriesByPrefix } from
|
|
1
|
+
export { groupCountriesByPrefix } from './groupCountriesByPrefix';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/groupCountriesByPrefix/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/groupCountriesByPrefix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
export { setDefaultPrefix } from
|
|
2
|
-
export { isValidPhoneNumber } from
|
|
3
|
-
export { explodeNumberModel } from
|
|
4
|
-
export { longestMatchingPrefix } from
|
|
5
|
-
export { findCountryByPrefix } from
|
|
6
|
-
export { findCountryByCode } from
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { groupCountriesByPrefix } from "./groupCountriesByPrefix";
|
|
13
|
-
export { excludeCountries } from "./excludeCountries";
|
|
1
|
+
export { setDefaultPrefix } from './setDefaultPrefix';
|
|
2
|
+
export { isValidPhoneNumber } from './isValidPhoneNumber';
|
|
3
|
+
export { explodeNumberModel } from './explodeNumberModel';
|
|
4
|
+
export { longestMatchingPrefix } from './longestMatchingPrefix';
|
|
5
|
+
export { findCountryByPrefix } from './findCountryByPrefix';
|
|
6
|
+
export { findCountryByCode } from './findCountryByCode';
|
|
7
|
+
export { cleanNumber } from './cleanNumber';
|
|
8
|
+
export { isStringNumeric } from './isStringNumeric';
|
|
9
|
+
export { sortArrayByProperty } from './sortArrayByProperty';
|
|
10
|
+
export { groupCountriesByPrefix } from './groupCountriesByPrefix';
|
|
11
|
+
export { excludeCountries } from './excludeCountries';
|
|
14
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/phoneNumberInput/utils/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/phoneNumberInput/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { isStringNumeric } from
|
|
1
|
+
export { isStringNumeric } from './isStringNumeric';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isStringNumeric/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isStringNumeric/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const isStringNumeric: (value: string) => boolean;
|
|
2
2
|
//# sourceMappingURL=isStringNumeric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStringNumeric.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.
|
|
1
|
+
{"version":3,"file":"isStringNumeric.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isStringNumeric/isStringNumeric.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,UAAW,MAAM,YAAgC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { isValidPhoneNumber } from
|
|
1
|
+
export { isValidPhoneNumber } from './isValidPhoneNumber';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isValidPhoneNumber/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isValidPhoneNumber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param phoneNumber
|
|
4
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with at least 4 digits.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isValidPhoneNumber: (phoneNumber: string) => boolean;
|
|
2
7
|
//# sourceMappingURL=isValidPhoneNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidPhoneNumber.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.
|
|
1
|
+
{"version":3,"file":"isValidPhoneNumber.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,gBAAiB,MAAM,YACsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/longestMatchingPrefix/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/longestMatchingPrefix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,eAAO,MAAM,qBAAqB,kBAAmB,OAAO,EAAE,YACa,CAAC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Given a valid locale it returns the correspondent prefix if found or +44 otherwise.
|
|
3
|
+
*
|
|
4
|
+
* @param locale BCP 47 language tag of locale, e.g. `"es-ES"`.
|
|
5
|
+
* @param countryCode Two-letter country code (ISO 3166-1 alpha-2).
|
|
6
|
+
*/
|
|
7
|
+
export declare const setDefaultPrefix: (locale: string, countryCode?: string) => string;
|
|
2
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/setDefaultPrefix/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/setDefaultPrefix/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,gBAAgB,MAAM,WAKpE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { sortArrayByProperty } from
|
|
1
|
+
export { sortArrayByProperty } from './sortArrayByProperty';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/sortArrayByProperty/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/sortArrayByProperty/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function sortArrayByProperty(arrayToSort:
|
|
1
|
+
export declare function sortArrayByProperty<T extends Record<PropertyKey, string>>(arrayToSort: T[], property: keyof T): T[];
|
|
2
2
|
//# sourceMappingURL=sortArrayByProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortArrayByProperty.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.
|
|
1
|
+
{"version":3,"file":"sortArrayByProperty.d.ts","sourceRoot":"","sources":["../../../../../src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,EACvE,WAAW,EAAE,CAAC,EAAE,EAChB,QAAQ,EAAE,MAAM,CAAC,OAGlB"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface TextareaWithDisplayFormatProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare const TextareaWithDisplayFormat: React.FC<TextareaWithDisplayFormatProps>;
|
|
9
|
-
|
|
10
|
-
export default TextareaWithDisplayFormat;
|
|
11
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type WithDisplayFormatProps } from '../withDisplayFormat';
|
|
3
|
+
export interface TextareaWithDisplayFormatProps extends Omit<WithDisplayFormatProps, 'render'> {
|
|
4
|
+
}
|
|
5
|
+
declare const TextareaWithDisplayFormat: (props: TextareaWithDisplayFormatProps) => import("react").JSX.Element;
|
|
6
|
+
export default TextareaWithDisplayFormat;
|
|
7
|
+
//# sourceMappingURL=TextareaWithDisplayFormat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaWithDisplayFormat.d.ts","sourceRoot":"","sources":["../../../src/textareaWithDisplayFormat/TextareaWithDisplayFormat.
|
|
1
|
+
{"version":3,"file":"TextareaWithDisplayFormat.d.ts","sourceRoot":"","sources":["../../../src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx"],"names":[],"mappings":";AACA,OAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,MAAM,WAAW,8BAA+B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC;CAAG;AAEjG,QAAA,MAAM,yBAAyB,UAAW,8BAA8B,gCAKvE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/textareaWithDisplayFormat/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/textareaWithDisplayFormat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,YAAY,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,90 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { HistoryNavigator } from '../common';
|
|
3
|
+
import { InputProps } from '../inputs/Input';
|
|
4
|
+
import { TextAreaProps } from '../inputs/TextArea';
|
|
5
|
+
type HTMLTextElement = HTMLInputElement | HTMLTextAreaElement;
|
|
6
|
+
type TextElementProps = InputProps | TextAreaProps;
|
|
7
|
+
export type EventType = 'KeyDown' | 'Paste' | 'Cut' | 'Undo' | 'Redo' | 'Backspace' | 'Delete' | 'Initial';
|
|
8
|
+
interface WithDisplayFormatState {
|
|
9
|
+
value: string;
|
|
10
|
+
historyNavigator: HistoryNavigator;
|
|
11
|
+
prevDisplayPattern: string;
|
|
12
|
+
triggerType: EventType;
|
|
13
|
+
triggerEvent: React.KeyboardEvent<HTMLTextElement> | null;
|
|
14
|
+
pastedLength: number;
|
|
15
|
+
selectionStart: number;
|
|
16
|
+
selectionEnd: number;
|
|
17
|
+
}
|
|
18
|
+
export interface WithDisplayFormatProps<T extends TextElementProps = TextElementProps> extends Pick<TextElementProps, 'className' | 'disabled' | 'id' | 'maxLength' | 'minLength' | 'name' | 'placeholder' | 'readOnly' | 'required' | 'inputMode'> {
|
|
19
|
+
value?: string;
|
|
20
|
+
displayPattern: string;
|
|
21
|
+
/**
|
|
22
|
+
* autocomplete hides our form help so we need to disable it when help text
|
|
23
|
+
* is present. Chrome ignores autocomplete=off, the only way to disable it is
|
|
24
|
+
* to provide an 'invalid' value, for which 'disabled' serves.
|
|
25
|
+
*/
|
|
26
|
+
autoComplete?: TextElementProps['autoComplete'] | 'disabled';
|
|
27
|
+
onChange?: (value: string) => void;
|
|
28
|
+
onBlur?: (value: string) => void;
|
|
29
|
+
onFocus?: (value: string) => void;
|
|
30
|
+
render: (renderProps: T) => JSX.Element;
|
|
31
|
+
}
|
|
32
|
+
declare class WithDisplayFormat<T extends TextElementProps> extends Component<WithDisplayFormatProps<T>, WithDisplayFormatState> {
|
|
33
|
+
props: WithDisplayFormatProps<T> & Required<Pick<WithDisplayFormatProps<T>, keyof typeof WithDisplayFormat.defaultProps>>;
|
|
34
|
+
static defaultProps: {
|
|
35
|
+
autoComplete: string;
|
|
36
|
+
displayPattern: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
constructor(props: WithDisplayFormatProps);
|
|
40
|
+
static getDerivedStateFromProps({ displayPattern }: WithDisplayFormatProps, { prevDisplayPattern, value, historyNavigator }: WithDisplayFormatState): {
|
|
41
|
+
prevDisplayPattern: string;
|
|
42
|
+
value: string;
|
|
6
43
|
triggerType: null;
|
|
7
44
|
triggerEvent: null;
|
|
8
45
|
pastedLength: number;
|
|
9
46
|
} | null;
|
|
10
|
-
|
|
11
|
-
state: {
|
|
12
|
-
value: any;
|
|
13
|
-
historyNavigator: HistoryNavigator;
|
|
14
|
-
prevDisplayPattern: any;
|
|
15
|
-
triggerType: null;
|
|
16
|
-
triggerEvent: null;
|
|
17
|
-
};
|
|
18
|
-
getUserAction: (unformattedValue: any) => any;
|
|
47
|
+
getUserAction: (unformattedValue: string) => EventType | string;
|
|
19
48
|
resetEvent: () => void;
|
|
20
|
-
detectUndoRedo: (event:
|
|
21
|
-
handleOnKeyDown:
|
|
22
|
-
handleOnPaste:
|
|
23
|
-
handleOnCut:
|
|
24
|
-
isKeyAllowed: (action:
|
|
25
|
-
handleOnChange:
|
|
26
|
-
handleOnBlur:
|
|
27
|
-
handleOnFocus:
|
|
28
|
-
handleDelete: (unformattedValue:
|
|
29
|
-
handleCursorPositioning: (action:
|
|
30
|
-
render():
|
|
49
|
+
detectUndoRedo: (event: React.KeyboardEvent<HTMLTextElement>) => "Undo" | "Redo" | null;
|
|
50
|
+
handleOnKeyDown: React.KeyboardEventHandler<HTMLTextElement>;
|
|
51
|
+
handleOnPaste: React.ClipboardEventHandler<HTMLTextElement>;
|
|
52
|
+
handleOnCut: React.ClipboardEventHandler<HTMLTextElement>;
|
|
53
|
+
isKeyAllowed: (action: EventType | string) => boolean;
|
|
54
|
+
handleOnChange: React.ChangeEventHandler<HTMLTextElement>;
|
|
55
|
+
handleOnBlur: React.FocusEventHandler<HTMLTextElement>;
|
|
56
|
+
handleOnFocus: React.FocusEventHandler<HTMLTextElement>;
|
|
57
|
+
handleDelete: (unformattedValue: string, action: EventType) => string;
|
|
58
|
+
handleCursorPositioning: (action: string) => void;
|
|
59
|
+
render(): JSX.Element;
|
|
31
60
|
}
|
|
32
|
-
|
|
33
|
-
namespace propTypes {
|
|
34
|
-
const autoComplete: any;
|
|
35
|
-
const className: any;
|
|
36
|
-
const disabled: any;
|
|
37
|
-
const id: any;
|
|
38
|
-
const maxLength: any;
|
|
39
|
-
const minLength: any;
|
|
40
|
-
const name: any;
|
|
41
|
-
const onFocus: any;
|
|
42
|
-
const onBlur: any;
|
|
43
|
-
const onChange: any;
|
|
44
|
-
const placeholder: any;
|
|
45
|
-
const readOnly: any;
|
|
46
|
-
const render: any;
|
|
47
|
-
const required: any;
|
|
48
|
-
const displayPattern: any;
|
|
49
|
-
const type: any;
|
|
50
|
-
const inputMode: any;
|
|
51
|
-
const value: any;
|
|
52
|
-
}
|
|
53
|
-
namespace defaultProps {
|
|
54
|
-
const autoComplete_1: string;
|
|
55
|
-
export { autoComplete_1 as autoComplete };
|
|
56
|
-
const className_1: null;
|
|
57
|
-
export { className_1 as className };
|
|
58
|
-
const disabled_1: boolean;
|
|
59
|
-
export { disabled_1 as disabled };
|
|
60
|
-
const id_1: null;
|
|
61
|
-
export { id_1 as id };
|
|
62
|
-
const maxLength_1: null;
|
|
63
|
-
export { maxLength_1 as maxLength };
|
|
64
|
-
const minLength_1: null;
|
|
65
|
-
export { minLength_1 as minLength };
|
|
66
|
-
const name_1: null;
|
|
67
|
-
export { name_1 as name };
|
|
68
|
-
const placeholder_1: null;
|
|
69
|
-
export { placeholder_1 as placeholder };
|
|
70
|
-
const readOnly_1: boolean;
|
|
71
|
-
export { readOnly_1 as readOnly };
|
|
72
|
-
const required_1: boolean;
|
|
73
|
-
export { required_1 as required };
|
|
74
|
-
const displayPattern_1: string;
|
|
75
|
-
export { displayPattern_1 as displayPattern };
|
|
76
|
-
const type_1: string;
|
|
77
|
-
export { type_1 as type };
|
|
78
|
-
const inputMode_1: null;
|
|
79
|
-
export { inputMode_1 as inputMode };
|
|
80
|
-
const value_1: string;
|
|
81
|
-
export { value_1 as value };
|
|
82
|
-
const onFocus_1: null;
|
|
83
|
-
export { onFocus_1 as onFocus };
|
|
84
|
-
const onBlur_1: null;
|
|
85
|
-
export { onBlur_1 as onBlur };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
import { Component } from "react";
|
|
89
|
-
import { HistoryNavigator } from "../common";
|
|
61
|
+
export default WithDisplayFormat;
|
|
90
62
|
//# sourceMappingURL=WithDisplayFormat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WithDisplayFormat.d.ts","sourceRoot":"","sources":["../../../src/withDisplayFormat/WithDisplayFormat.
|
|
1
|
+
{"version":3,"file":"WithDisplayFormat.d.ts","sourceRoot":"","sources":["../../../src/withDisplayFormat/WithDisplayFormat.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/withDisplayFormat/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/withDisplayFormat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.7.0",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
"babel-plugin-formatjs": "^10.5.3",
|
|
69
69
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
70
70
|
"enzyme": "^3.11.0",
|
|
71
|
-
"html-loader": "^1.3.2",
|
|
72
71
|
"jest": "^27.0.6",
|
|
73
72
|
"jest-cli": "^27.0.6",
|
|
74
73
|
"jest-fetch-mock": "^3.0.3",
|
|
@@ -78,12 +77,12 @@
|
|
|
78
77
|
"rollup": "^3.28.1",
|
|
79
78
|
"storybook": "^7.4.5",
|
|
80
79
|
"@transferwise/less-config": "3.1.0",
|
|
81
|
-
"@transferwise/neptune-css": "14.9.
|
|
80
|
+
"@transferwise/neptune-css": "14.9.4",
|
|
82
81
|
"@wise/components-theming": "0.8.4"
|
|
83
82
|
},
|
|
84
83
|
"peerDependencies": {
|
|
85
84
|
"@transferwise/icons": "^3.7.0",
|
|
86
|
-
"@transferwise/neptune-css": "^14.9.
|
|
85
|
+
"@transferwise/neptune-css": "^14.9.4",
|
|
87
86
|
"@wise/art": "^2.7.0",
|
|
88
87
|
"@wise/components-theming": "^0.8.4",
|
|
89
88
|
"react": ">=16.14",
|
|
@@ -24,8 +24,8 @@ describe('locale utils', () => {
|
|
|
24
24
|
['zh_HK', 'zh'],
|
|
25
25
|
['ja-JP', 'ja'],
|
|
26
26
|
['zhHK', null],
|
|
27
|
-
[null, null],
|
|
28
|
-
[undefined, null],
|
|
27
|
+
[null as any, null],
|
|
28
|
+
[undefined as any, null],
|
|
29
29
|
['', null],
|
|
30
30
|
[' ', null],
|
|
31
31
|
['ar-dz', null],
|
|
@@ -51,8 +51,8 @@ describe('locale utils', () => {
|
|
|
51
51
|
['zh_HK', 'zh-HK'],
|
|
52
52
|
['ja-JP', 'ja-JP'],
|
|
53
53
|
['zhHK', null],
|
|
54
|
-
[null, null],
|
|
55
|
-
[undefined, null],
|
|
54
|
+
[null as any, null],
|
|
55
|
+
[undefined as any, null],
|
|
56
56
|
['', null],
|
|
57
57
|
[' ', null],
|
|
58
58
|
['ar-dz', 'ar-DZ'],
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Direction } from '..';
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_LANG = 'en';
|
|
4
|
+
export const DEFAULT_LOCALE = 'en-GB';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Languages written right-to-left.
|
|
8
|
+
*/
|
|
9
|
+
export const RTL_LANGUAGES = ['ar', 'he'];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated The source of truth for supported languages lives in Crab.
|
|
13
|
+
*/
|
|
14
|
+
export const SUPPORTED_LANGUAGES = [
|
|
15
|
+
DEFAULT_LANG,
|
|
16
|
+
'de',
|
|
17
|
+
'es',
|
|
18
|
+
'fr',
|
|
19
|
+
'hu',
|
|
20
|
+
'id',
|
|
21
|
+
'it',
|
|
22
|
+
'ja',
|
|
23
|
+
'pl',
|
|
24
|
+
'pt',
|
|
25
|
+
'ro',
|
|
26
|
+
'ru',
|
|
27
|
+
'th',
|
|
28
|
+
'tr',
|
|
29
|
+
'uk',
|
|
30
|
+
'zh',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Verifies and adjusts locale, replacing `_` with `-`.
|
|
35
|
+
*
|
|
36
|
+
* @param locale `es`, `es_ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
|
|
37
|
+
* @returns `null` if locale is unrecognized by `Intl.Locale`.
|
|
38
|
+
*/
|
|
39
|
+
export function adjustLocale(locale: string) {
|
|
40
|
+
const localeTrimmed = locale?.trim();
|
|
41
|
+
if (localeTrimmed) {
|
|
42
|
+
try {
|
|
43
|
+
return new Intl.Locale(localeTrimmed.replace('_', '-')).baseName;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.error(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Provides corresponding lang (iso2) for provided locale.
|
|
54
|
+
*
|
|
55
|
+
* @deprecated The use of this function almost always breaks language variants
|
|
56
|
+
* e.g. Simplified and Traditional Chinese.
|
|
57
|
+
* There should be no use case for this function.
|
|
58
|
+
* To select the correct translations from a translations object, pass the
|
|
59
|
+
* locale directly into Crab's getLocalisedMessages.
|
|
60
|
+
* @param locale `es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
|
|
61
|
+
* @returns Two-letter ISO 639-1 language code, falling back to `null` if locale is invalid or language is unsupported.
|
|
62
|
+
*/
|
|
63
|
+
export function getLangFromLocale(locale: string) {
|
|
64
|
+
const adjustedLocale = adjustLocale(locale);
|
|
65
|
+
if (adjustedLocale != null) {
|
|
66
|
+
const { language } = new Intl.Locale(adjustedLocale);
|
|
67
|
+
if (SUPPORTED_LANGUAGES.includes(language)) {
|
|
68
|
+
return language;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Provides corresponding country code (iso2) for locales code with explicit region value.
|
|
76
|
+
*
|
|
77
|
+
* @param locale `es-ES`, `en-GB`, `ja-JP`, etc.
|
|
78
|
+
* @returns `null` if the locale is invalid or the region can‘t be identified.
|
|
79
|
+
*/
|
|
80
|
+
export function getCountryFromLocale(locale: string) {
|
|
81
|
+
const adjustedLocale = adjustLocale(locale);
|
|
82
|
+
return adjustedLocale != null ? new Intl.Locale(adjustedLocale).region ?? null : null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Provides the layout direction for a given locale.
|
|
87
|
+
*
|
|
88
|
+
* @param locale `es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP`, etc.
|
|
89
|
+
* @returns The layout direction based on the locale, falling back to `Direction.LTR` if the locale is invalid or unsupported.
|
|
90
|
+
*/
|
|
91
|
+
export function getDirectionFromLocale(locale: string) {
|
|
92
|
+
const adjustedLocale = adjustLocale(locale);
|
|
93
|
+
return adjustedLocale != null && RTL_LANGUAGES.includes(new Intl.Locale(adjustedLocale).language)
|
|
94
|
+
? Direction.RTL
|
|
95
|
+
: Direction.LTR;
|
|
96
|
+
}
|
package/src/common/textFormat/formatWithPattern/{formatWithPattern.js → formatWithPattern.ts}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import getSymbolsInPatternWithPosition from '../getSymbolsInPatternWithPosition';
|
|
2
|
+
import type { SymbolWithPosition } from '../getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition';
|
|
2
3
|
|
|
3
|
-
const formatWithPattern = (value, pattern) => {
|
|
4
|
+
const formatWithPattern = (value: string, pattern: string): string => {
|
|
4
5
|
if (!value || value === '') {
|
|
5
6
|
return '';
|
|
6
7
|
}
|
|
@@ -9,13 +10,16 @@ const formatWithPattern = (value, pattern) => {
|
|
|
9
10
|
|
|
10
11
|
const patternWithSymbolsPosition = getSymbolsInPatternWithPosition(pattern);
|
|
11
12
|
|
|
12
|
-
let patternSymbol = [];
|
|
13
|
+
let patternSymbol: SymbolWithPosition[] = [];
|
|
13
14
|
// valueArray.length increments during the cycle cause we are adding new elements.
|
|
14
15
|
for (let index = 0; index < valueArray.length; index += 1) {
|
|
15
|
-
patternSymbol = patternWithSymbolsPosition.filter((
|
|
16
|
+
patternSymbol = patternWithSymbolsPosition.filter((pattern) => pattern.index === index);
|
|
16
17
|
// Add pattern's symbol at n position
|
|
17
18
|
if (patternSymbol.length === 1) {
|
|
18
|
-
|
|
19
|
+
const last = patternSymbol.pop();
|
|
20
|
+
if (last) {
|
|
21
|
+
valueArray.splice(index, 0, last.symbol);
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import getCountOfSymbolsInSelection from '../getCountOfSymbolsInSelection';
|
|
2
2
|
import { getDistanceToNextSymbol, getDistanceToPreviousSymbol } from '../getDistanceToSymbol';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
action,
|
|
6
|
-
selectionStart,
|
|
7
|
-
selectionEnd,
|
|
8
|
-
pattern,
|
|
9
|
-
pastedLength,
|
|
10
|
-
) => {
|
|
4
|
+
const getCursorPositionAfterActionStroke = (
|
|
5
|
+
action: string,
|
|
6
|
+
selectionStart: number,
|
|
7
|
+
selectionEnd: number,
|
|
8
|
+
pattern: string,
|
|
9
|
+
pastedLength: number,
|
|
10
|
+
): number => {
|
|
11
11
|
let cursorPosition = selectionStart;
|
|
12
12
|
|
|
13
13
|
switch (action) {
|
|
@@ -38,4 +38,4 @@ const getCursorPositionAfteractionstroke = (
|
|
|
38
38
|
return cursorPosition;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export default
|
|
41
|
+
export default getCursorPositionAfterActionStroke;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type SymbolWithPosition = {
|
|
2
|
+
index: number;
|
|
3
|
+
symbol: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const getSymbolsInPatternWithPosition = (pattern: string): SymbolWithPosition[] => {
|
|
7
|
+
const patternWithSymbolsPosition: SymbolWithPosition[] = [];
|
|
3
8
|
const patternArray = pattern.split('');
|
|
4
9
|
patternArray.forEach((symbol, index) => {
|
|
5
10
|
if (symbol !== '*') {
|
package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.js → unformatWithPattern.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const unformatWithPattern = (value, pattern) => {
|
|
1
|
+
const unformatWithPattern = (value: string, pattern: string): string => {
|
|
2
2
|
let valueArray = [''];
|
|
3
3
|
if (value && value.length > 0) {
|
|
4
4
|
valueArray = value.toString().split('');
|
|
@@ -8,6 +8,7 @@ const unformatWithPattern = (value, pattern) => {
|
|
|
8
8
|
return valueArray.join('');
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const getSymbolsInPattern = (pattern)
|
|
11
|
+
const getSymbolsInPattern = (pattern: string): string[] =>
|
|
12
|
+
pattern.split('').filter((symbol) => symbol !== '*');
|
|
12
13
|
|
|
13
14
|
export default unformatWithPattern;
|