@transferwise/components 0.0.0-experimental-07e5f39 → 0.0.0-experimental-df1dfb0
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/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js +1 -1
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js.map +1 -1
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs +1 -1
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs.map +1 -1
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts +1 -1
- package/package.json +1 -1
- package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +1 -1
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +29 -0
- package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param phoneNumber
|
|
6
|
-
* @returns True if number that starts with "+" and contains a mix of digits and spaces with
|
|
6
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with a configurable min length that defaults to 4.
|
|
7
7
|
*/
|
|
8
8
|
const isValidPhoneNumber = (phoneNumber, minLength = 4) => /^\+[\d-\s]+$/.test(phoneNumber) && (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= minLength;
|
|
9
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidPhoneNumber.js","sources":["../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts"],"sourcesContent":["/**\n *\n * @param phoneNumber\n * @returns True if number that starts with \"+\" and contains a mix of digits and spaces with
|
|
1
|
+
{"version":3,"file":"isValidPhoneNumber.js","sources":["../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts"],"sourcesContent":["/**\n *\n * @param phoneNumber\n * @returns True if number that starts with \"+\" and contains a mix of digits and spaces with a configurable min length that defaults to 4.\n */\nexport const isValidPhoneNumber = (phoneNumber: string, minLength = 4) =>\n /^\\+[\\d-\\s]+$/.test(phoneNumber) &&\n (phoneNumber.match(/\\d+/g)?.join('').length ?? 0) >= minLength;\n"],"names":["isValidPhoneNumber","phoneNumber","minLength","test","match","join","length"],"mappings":";;AAAA;;;;AAIG;AACUA,MAAAA,kBAAkB,GAAGA,CAACC,WAAmB,EAAEC,SAAS,GAAG,CAAC,KACnE,cAAc,CAACC,IAAI,CAACF,WAAW,CAAC,IAChC,CAACA,WAAW,CAACG,KAAK,CAAC,MAAM,CAAC,EAAEC,IAAI,CAAC,EAAE,CAAC,CAACC,MAAM,IAAI,CAAC,KAAKJ;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param phoneNumber
|
|
4
|
-
* @returns True if number that starts with "+" and contains a mix of digits and spaces with
|
|
4
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with a configurable min length that defaults to 4.
|
|
5
5
|
*/
|
|
6
6
|
const isValidPhoneNumber = (phoneNumber, minLength = 4) => /^\+[\d-\s]+$/.test(phoneNumber) && (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= minLength;
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidPhoneNumber.mjs","sources":["../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts"],"sourcesContent":["/**\n *\n * @param phoneNumber\n * @returns True if number that starts with \"+\" and contains a mix of digits and spaces with
|
|
1
|
+
{"version":3,"file":"isValidPhoneNumber.mjs","sources":["../../../../src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts"],"sourcesContent":["/**\n *\n * @param phoneNumber\n * @returns True if number that starts with \"+\" and contains a mix of digits and spaces with a configurable min length that defaults to 4.\n */\nexport const isValidPhoneNumber = (phoneNumber: string, minLength = 4) =>\n /^\\+[\\d-\\s]+$/.test(phoneNumber) &&\n (phoneNumber.match(/\\d+/g)?.join('').length ?? 0) >= minLength;\n"],"names":["isValidPhoneNumber","phoneNumber","minLength","test","match","join","length"],"mappings":"AAAA;;;;AAIG;AACUA,MAAAA,kBAAkB,GAAGA,CAACC,WAAmB,EAAEC,SAAS,GAAG,CAAC,KACnE,cAAc,CAACC,IAAI,CAACF,WAAW,CAAC,IAChC,CAACA,WAAW,CAACG,KAAK,CAAC,MAAM,CAAC,EAAEC,IAAI,CAAC,EAAE,CAAC,CAACC,MAAM,IAAI,CAAC,KAAKJ;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param phoneNumber
|
|
4
|
-
* @returns True if number that starts with "+" and contains a mix of digits and spaces with
|
|
4
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with a configurable min length that defaults to 4.
|
|
5
5
|
*/
|
|
6
6
|
export declare const isValidPhoneNumber: (phoneNumber: string, minLength?: number) => boolean;
|
|
7
7
|
//# sourceMappingURL=isValidPhoneNumber.d.ts.map
|
package/package.json
CHANGED
|
@@ -160,7 +160,7 @@ describe('PhoneNumberInput', () => {
|
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
describe('when an partial model is supplied (with a matching prefix)', () => {
|
|
163
|
-
it('should set the select to the matching prefix and put the rest of the
|
|
163
|
+
it('should set the select to the matching prefix and put the rest of the number in the suffix', () => {
|
|
164
164
|
customRender({ initialValue: '+123' });
|
|
165
165
|
expect(getPrefixEl()).toHaveTextContent('+1');
|
|
166
166
|
expect(getInputEl()).toHaveValue('23');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import Header from '../header';
|
|
3
5
|
import PhoneNumberInput from './PhoneNumberInput';
|
|
4
6
|
|
|
5
7
|
const meta = {
|
|
@@ -22,3 +24,30 @@ export const Basic = {
|
|
|
22
24
|
onChange: () => {},
|
|
23
25
|
},
|
|
24
26
|
} satisfies Story;
|
|
27
|
+
|
|
28
|
+
export const InitialValue = () => {
|
|
29
|
+
const initialValues = [
|
|
30
|
+
null,
|
|
31
|
+
'+44',
|
|
32
|
+
'+441',
|
|
33
|
+
'+1',
|
|
34
|
+
'+12',
|
|
35
|
+
'+1234',
|
|
36
|
+
'+1264',
|
|
37
|
+
'+992',
|
|
38
|
+
'+9999',
|
|
39
|
+
'+99992',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
return initialValues.map((initialValue) => (
|
|
43
|
+
<Fragment key={initialValue}>
|
|
44
|
+
<Header title={`initialValue: ${JSON.stringify(initialValue)}`} />
|
|
45
|
+
<PhoneNumberInput
|
|
46
|
+
initialValue={initialValue ?? undefined}
|
|
47
|
+
placeholder="placeholder"
|
|
48
|
+
onChange={() => {}}
|
|
49
|
+
/>
|
|
50
|
+
<br />
|
|
51
|
+
</Fragment>
|
|
52
|
+
));
|
|
53
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param phoneNumber
|
|
4
|
-
* @returns True if number that starts with "+" and contains a mix of digits and spaces with
|
|
4
|
+
* @returns True if number that starts with "+" and contains a mix of digits and spaces with a configurable min length that defaults to 4.
|
|
5
5
|
*/
|
|
6
6
|
export const isValidPhoneNumber = (phoneNumber: string, minLength = 4) =>
|
|
7
7
|
/^\+[\d-\s]+$/.test(phoneNumber) &&
|