@transferwise/components 0.0.0-experimental-30a5fa7 → 0.0.0-experimental-ab588f3

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 (37) hide show
  1. package/build/alert/Alert.js +1 -1
  2. package/build/alert/Alert.mjs +1 -1
  3. package/build/button/legacyUtils/legacyUtils.js +1 -1
  4. package/build/button/legacyUtils/legacyUtils.mjs +1 -1
  5. package/build/drawer/Drawer.js +1 -1
  6. package/build/drawer/Drawer.mjs +1 -1
  7. package/build/inputs/SelectInput.js +12 -3
  8. package/build/inputs/SelectInput.js.map +1 -1
  9. package/build/inputs/SelectInput.mjs +12 -3
  10. package/build/inputs/SelectInput.mjs.map +1 -1
  11. package/build/markdown/Markdown.js +1 -1
  12. package/build/markdown/Markdown.mjs +1 -1
  13. package/build/popover/Popover.js +1 -1
  14. package/build/popover/Popover.mjs +1 -1
  15. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  16. package/build/types/utilities/deprecatedProperty/deprecatedProperty.d.ts +6 -8
  17. package/build/types/utilities/deprecatedProperty/deprecatedProperty.d.ts.map +1 -1
  18. package/build/types/utilities/deprecatedProperty/index.d.ts +1 -1
  19. package/build/types/utilities/deprecatedProperty/index.d.ts.map +1 -1
  20. package/build/types/utilities/index.d.ts +2 -2
  21. package/build/types/utilities/index.d.ts.map +1 -1
  22. package/build/types/utilities/logActionRequired.d.ts +2 -2
  23. package/build/types/utilities/logActionRequired.d.ts.map +1 -1
  24. package/build/utilities/logActionRequired.js.map +1 -1
  25. package/build/utilities/logActionRequired.mjs.map +1 -1
  26. package/package.json +3 -3
  27. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +85 -0
  28. package/src/inputs/SelectInput.tsx +15 -8
  29. package/src/utilities/deprecatedProperty/{deprecatedProperty.ts → deprecatedProperty.js} +4 -23
  30. package/src/utilities/deprecatedProperty/{deprecatedProperty.spec.ts → deprecatedProperty.spec.js} +13 -7
  31. package/src/utilities/{logActionRequired.ts → logActionRequired.js} +2 -2
  32. package/build/types/test-utils/style-mock.d.ts +0 -1
  33. package/build/types/test-utils/style-mock.d.ts.map +0 -1
  34. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +0 -78
  35. /package/src/test-utils/{style-mock.ts → style-mock.js} +0 -0
  36. /package/src/utilities/deprecatedProperty/{index.ts → index.js} +0 -0
  37. /package/src/utilities/{index.ts → index.js} +0 -0
@@ -1,22 +1,6 @@
1
1
  import { logActionRequired } from '../logActionRequired';
2
2
 
3
- type DeprecatedMessageType = {
4
- component: string;
5
- propName: string;
6
- message: string;
7
- expiryDate?: Date;
8
- };
9
-
10
- type ValidatorType = (props: Record<string, any>, propName: string, ...rest: any[]) => Error | null;
11
-
12
- type DeprecatedOptionsType = {
13
- component: string;
14
- message?: string;
15
- newProp?: string;
16
- expiryDate?: Date;
17
- };
18
-
19
- const deprecatedMessage = ({ component, propName, message, expiryDate }: DeprecatedMessageType) => {
3
+ const deprecatedMessage = ({ component, propName, message, expiryDate }) => {
20
4
  const messages = [`${component} has deprecated the use of ${propName}.`];
21
5
 
22
6
  if (message) {
@@ -37,14 +21,11 @@ const deprecatedMessage = ({ component, propName, message, expiryDate }: Depreca
37
21
  };
38
22
 
39
23
  const deprecated =
40
- (
41
- validator: ValidatorType,
42
- { component, message = '', newProp: newProperty, expiryDate }: DeprecatedOptionsType,
43
- ) =>
44
- (props: Record<string, any>, propertyName: string, ...rest: any[]) => {
24
+ (validator, { component, message = '', newProp: newProperty = null, expiryDate = null }) =>
25
+ (props, propertyName, ...rest) => {
45
26
  const newPropertyMessage = newProperty ? `Please use ${newProperty} instead.` : message;
46
27
 
47
- if (props[propertyName] !== null && props[propertyName] !== undefined) {
28
+ if (props[propertyName] != null && typeof props[propertyName] !== 'undefined') {
48
29
  logActionRequired(
49
30
  deprecatedMessage({
50
31
  component,
@@ -5,7 +5,6 @@ const props = { prop1: 'prop1', prop2: 'prop2' };
5
5
  const validator = jest.fn();
6
6
 
7
7
  describe('deprecated', () => {
8
- const component = 'Test';
9
8
  const origWarn = console.warn;
10
9
  let mockedWarn;
11
10
 
@@ -23,10 +22,11 @@ describe('deprecated', () => {
23
22
  });
24
23
 
25
24
  describe('if prop has been listed as deprecated', () => {
26
- const propertyName = 'prop1';
27
-
28
25
  it('calls console.warn with the correct message', () => {
26
+ const component = 'Test';
29
27
  const newProperty = 'newProp';
28
+ const propertyName = 'prop1';
29
+
30
30
  const expiryDate = new Date('01-01-2000');
31
31
  const expiryDateString = expiryDate.toLocaleString('en-GB', {
32
32
  year: 'numeric',
@@ -42,6 +42,10 @@ describe('deprecated', () => {
42
42
  });
43
43
 
44
44
  it('calls console.warn with correct message if newProp is not provided', () => {
45
+ const component = 'Test';
46
+
47
+ const propertyName = 'prop1';
48
+
45
49
  const expiryDate = new Date('01-01-2000');
46
50
  const expiryDateString = expiryDate.toLocaleString('en-GB', {
47
51
  year: 'numeric',
@@ -57,6 +61,8 @@ describe('deprecated', () => {
57
61
  });
58
62
 
59
63
  it('calls console.warn with correct message if message is provided', () => {
64
+ const component = 'Test';
65
+ const propertyName = 'prop1';
60
66
  const message = 'Some custom message.';
61
67
 
62
68
  deprecated(validator, { component, message })(props, propertyName);
@@ -68,15 +74,15 @@ describe('deprecated', () => {
68
74
  });
69
75
 
70
76
  describe('if prop has not been listed as deprecated', () => {
71
- const propertyName = 'prop3';
72
-
73
77
  it('calls validator with props', () => {
74
- deprecated(validator, { component })(props, propertyName);
78
+ const propertyName = 'prop3';
79
+ deprecated(validator, {})(props, propertyName);
75
80
  expect(console.warn).not.toHaveBeenCalled();
76
81
  });
77
82
 
78
83
  it('calls validator with expected args', () => {
79
- deprecated(validator, { component })(props, propertyName);
84
+ const propertyName = 'prop3';
85
+ deprecated(validator, {})(props, propertyName);
80
86
  expect(validator).toHaveBeenCalledWith({ prop1: 'prop1', prop2: 'prop2' }, 'prop3');
81
87
  });
82
88
  });
@@ -1,11 +1,11 @@
1
- export function logActionRequired(message: string) {
1
+ export function logActionRequired(message) {
2
2
  if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
3
3
  // eslint-disable-next-line no-console
4
4
  console.warn(message);
5
5
  }
6
6
  }
7
7
 
8
- export function logActionRequiredIf(message: string, conditional: boolean) {
8
+ export function logActionRequiredIf(message, conditional) {
9
9
  if (conditional) {
10
10
  logActionRequired(message);
11
11
  }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=style-mock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style-mock.d.ts","sourceRoot":"","sources":["../../../src/test-utils/style-mock.ts"],"names":[],"mappings":""}
@@ -1,78 +0,0 @@
1
- import { userEvent, within, fn } from '@storybook/test';
2
-
3
- import InputWithDisplayFormat, { InputWithDisplayFormatProps } from '.';
4
- import { Field, FieldProps } from '../field/Field';
5
- import { Meta, type StoryObj } from '@storybook/react';
6
-
7
- type Story = StoryObj<InputWithDisplayFormatProps & { label: string }>;
8
-
9
- const meta = {
10
- title: 'Forms/InputWithDisplayFormat',
11
- component: InputWithDisplayFormat,
12
- render: function Render({ label, ...args }: InputWithDisplayFormatProps & FieldProps) {
13
- return (
14
- <Field label={label} id={args.id}>
15
- <InputWithDisplayFormat id={args.id} {...args} />
16
- </Field>
17
- );
18
- },
19
- args: {
20
- onFocus: fn(),
21
- onBlur: fn(),
22
- onChange: fn(),
23
- },
24
- } satisfies Meta<typeof InputWithDisplayFormat>;
25
- export default meta;
26
-
27
- export const Basic: Story = {
28
- args: {
29
- label: 'Sort Code',
30
- placeholder: '**-**-**',
31
- displayPattern: '**-**-**',
32
- },
33
- };
34
-
35
- export const CardNumber: Story = {
36
- args: {
37
- label: 'Card Number',
38
- placeholder: '**** **** **** **** ***',
39
- displayPattern: '**** **** **** **** ***',
40
- },
41
- };
42
-
43
- export const CVC: Story = {
44
- args: {
45
- label: 'CVC',
46
- placeholder: '***',
47
- displayPattern: '***',
48
- value: '',
49
- },
50
- };
51
-
52
- export const ExpiryDate: Story = {
53
- args: {
54
- label: 'Expiry Date',
55
- placeholder: '** / **',
56
- displayPattern: '** / **',
57
- },
58
- };
59
-
60
- export const SecurityPin: Story = {
61
- args: {
62
- label: 'Security Pin',
63
- placeholder: '*-*-*-*-*-*',
64
- displayPattern: '*-*-*-*-*-*',
65
- },
66
- };
67
-
68
- export const SecurityPinPlay: Story = {
69
- args: {
70
- label: 'Security Pin Play',
71
- placeholder: '*-*-*-*-*-*',
72
- displayPattern: '*-*-*-*-*-*',
73
- },
74
- play: async ({ canvasElement }) => {
75
- const canvas = within(canvasElement);
76
- await userEvent.type(canvas.getByPlaceholderText('*-*-*-*-*-*'), '123456');
77
- },
78
- };
File without changes
File without changes