@transferwise/components 46.36.0 → 46.36.1
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.js +1 -4
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -4
- package/build/index.mjs.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/moneyInput/MoneyInput.story.tsx +40 -2
- package/src/moneyInput/MoneyInput.tsx +1 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EAAQ,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAuB,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,EAKL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EAAQ,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACp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c,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,KAAK,kCAAkC,GAAG,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;;;;AAmZ9F,wBAAmF"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { FORCE_RE_RENDER } from '@storybook/core-events';
|
|
2
|
+
import { addons, useGlobals } from '@storybook/manager-api';
|
|
1
3
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { within, userEvent } from '@storybook/test';
|
|
4
|
+
import { expect, within, userEvent } from '@storybook/test';
|
|
3
5
|
import { Lock } from '@transferwise/icons';
|
|
4
|
-
import React, { useState } from 'react';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
5
7
|
|
|
6
8
|
import MoneyInput, { CurrencyOptionItem } from '.';
|
|
9
|
+
import Provider from '../provider/Provider';
|
|
10
|
+
import translations from '../i18n';
|
|
7
11
|
|
|
8
12
|
export default {
|
|
9
13
|
component: MoneyInput,
|
|
@@ -148,6 +152,40 @@ export const BalanceCurrencies: Story = {
|
|
|
148
152
|
},
|
|
149
153
|
};
|
|
150
154
|
|
|
155
|
+
export const MaxLengthOverride: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
...SingleCurrency.args,
|
|
158
|
+
maxLengthOverride: 5,
|
|
159
|
+
},
|
|
160
|
+
play: async ({ canvasElement }) => {
|
|
161
|
+
await userEvent.tab();
|
|
162
|
+
await userEvent.keyboard('12.345');
|
|
163
|
+
|
|
164
|
+
await expect(within(canvasElement).getByRole('textbox')).toHaveValue('12.34');
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const MaxLengthOverrideWithCommaDecimalSeparator: Story = {
|
|
169
|
+
...MaxLengthOverride,
|
|
170
|
+
decorators: [
|
|
171
|
+
(Story) => {
|
|
172
|
+
const locale = 'de';
|
|
173
|
+
return (
|
|
174
|
+
<Provider i18n={{ locale, messages: translations[locale] }}>
|
|
175
|
+
<Story />
|
|
176
|
+
</Provider>
|
|
177
|
+
);
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
play: async ({ canvasElement }) => {
|
|
181
|
+
await userEvent.tab();
|
|
182
|
+
await userEvent.keyboard('12,345');
|
|
183
|
+
await userEvent.tab();
|
|
184
|
+
|
|
185
|
+
await expect(within(canvasElement).getByRole('textbox')).toHaveValue('12.34');
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
151
189
|
export const OpenedInput: Story = {
|
|
152
190
|
...MultipleCurrencies,
|
|
153
191
|
play: async ({ canvasElement }) => {
|
|
@@ -65,13 +65,10 @@ const parseNumber = ({
|
|
|
65
65
|
locale: string;
|
|
66
66
|
maxLengthOverride?: number;
|
|
67
67
|
}) => {
|
|
68
|
-
if (!maxLengthOverride) {
|
|
69
|
-
return parseAmount(amount, currency, locale);
|
|
70
|
-
}
|
|
71
68
|
if (maxLengthOverride && amount.length > maxLengthOverride) {
|
|
72
69
|
return 0;
|
|
73
70
|
}
|
|
74
|
-
return
|
|
71
|
+
return parseAmount(amount, currency, locale);
|
|
75
72
|
};
|
|
76
73
|
|
|
77
74
|
const allowedInputKeys = new Set([
|