@transferwise/components 0.0.0-experimental-e3593b2 → 0.0.0-experimental-a33db42

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 (68) hide show
  1. package/build/dateLookup/dateTrigger/DateTrigger.js +4 -8
  2. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  3. package/build/dateLookup/dateTrigger/DateTrigger.mjs +4 -8
  4. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  5. package/build/field/Field.js +2 -9
  6. package/build/field/Field.js.map +1 -1
  7. package/build/field/Field.mjs +2 -9
  8. package/build/field/Field.mjs.map +1 -1
  9. package/build/i18n/en.json +1 -3
  10. package/build/i18n/en.json.js +1 -3
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +1 -3
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/label/Label.js +1 -29
  15. package/build/label/Label.js.map +1 -1
  16. package/build/label/Label.mjs +2 -30
  17. package/build/label/Label.mjs.map +1 -1
  18. package/build/main.css +8 -0
  19. package/build/moneyInput/MoneyInput.js +11 -29
  20. package/build/moneyInput/MoneyInput.js.map +1 -1
  21. package/build/moneyInput/MoneyInput.mjs +11 -29
  22. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  23. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +8 -0
  24. package/build/styles/main.css +8 -0
  25. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  26. package/build/types/field/Field.d.ts +2 -4
  27. package/build/types/field/Field.d.ts.map +1 -1
  28. package/build/types/index.d.ts +1 -1
  29. package/build/types/index.d.ts.map +1 -1
  30. package/build/types/label/Label.d.ts +1 -10
  31. package/build/types/label/Label.d.ts.map +1 -1
  32. package/build/types/moneyInput/MoneyInput.d.ts +0 -1
  33. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  34. package/package.json +3 -3
  35. package/src/dateInput/DateInput.tests.story.tsx +32 -8
  36. package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
  37. package/src/dateLookup/dateTrigger/DateTrigger.css +8 -0
  38. package/src/dateLookup/dateTrigger/DateTrigger.less +8 -0
  39. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
  40. package/src/dateLookup/dateTrigger/DateTrigger.tsx +4 -9
  41. package/src/field/Field.spec.tsx +3 -3
  42. package/src/field/Field.story.tsx +3 -40
  43. package/src/field/Field.tests.story.tsx +33 -0
  44. package/src/field/Field.tsx +6 -12
  45. package/src/i18n/en.json +1 -3
  46. package/src/index.ts +1 -1
  47. package/src/inlineAlert/InlineAlert.story.tsx +21 -8
  48. package/src/inputs/InputGroup.spec.tsx +1 -1
  49. package/src/inputs/SearchInput.spec.tsx +1 -1
  50. package/src/inputs/SelectInput.spec.tsx +1 -1
  51. package/src/label/Label.story.tsx +21 -37
  52. package/src/label/Label.tsx +2 -44
  53. package/src/main.css +8 -0
  54. package/src/moneyInput/MoneyInput.story.tsx +0 -34
  55. package/src/moneyInput/MoneyInput.tsx +0 -21
  56. package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
  57. package/src/select/Select.rtl.spec.tsx +1 -1
  58. package/src/switch/Switch.spec.tsx +1 -1
  59. package/build/label/Label.messages.js +0 -15
  60. package/build/label/Label.messages.js.map +0 -1
  61. package/build/label/Label.messages.mjs +0 -13
  62. package/build/label/Label.messages.mjs.map +0 -1
  63. package/build/types/label/Label.messages.d.ts +0 -12
  64. package/build/types/label/Label.messages.d.ts.map +0 -1
  65. package/build/types/label/index.d.ts +0 -3
  66. package/build/types/label/index.d.ts.map +0 -1
  67. package/src/label/Label.messages.tsx +0 -12
  68. package/src/label/index.ts +0 -2
@@ -149,40 +149,6 @@ export const BalanceCurrencies: Story = {
149
149
  },
150
150
  };
151
151
 
152
- export const MaxLengthOverride: Story = {
153
- args: {
154
- ...SingleCurrency.args,
155
- maxLengthOverride: 5,
156
- },
157
- play: async ({ canvasElement }) => {
158
- await userEvent.tab();
159
- await userEvent.keyboard('12.345');
160
-
161
- await expect(within(canvasElement).getByRole('textbox')).toHaveValue('12.34');
162
- },
163
- };
164
-
165
- export const MaxLengthOverrideWithCommaDecimalSeparator: Story = {
166
- ...MaxLengthOverride,
167
- decorators: [
168
- (Story) => {
169
- const locale = 'de';
170
- return (
171
- <Provider i18n={{ locale, messages: translations[locale] }}>
172
- <Story />
173
- </Provider>
174
- );
175
- },
176
- ],
177
- play: async ({ canvasElement }) => {
178
- await userEvent.tab();
179
- await userEvent.keyboard('12,345');
180
- await userEvent.tab();
181
-
182
- await expect(within(canvasElement).getByRole('textbox')).toHaveValue('12.34');
183
- },
184
- };
185
-
186
152
  export const OpenedInput: Story = {
187
153
  ...MultipleCurrencies,
188
154
  play: async ({ canvasElement }) => {
@@ -41,16 +41,11 @@ const formatAmountIfSet = ({
41
41
  amount,
42
42
  currency,
43
43
  locale,
44
- maxLengthOverride,
45
44
  }: {
46
45
  amount: number | null | undefined;
47
46
  currency: string;
48
47
  locale: string;
49
- maxLengthOverride?: number;
50
48
  }) => {
51
- if (maxLengthOverride) {
52
- return amount != null ? String(amount) : '';
53
- }
54
49
  return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';
55
50
  };
56
51
 
@@ -58,16 +53,11 @@ const parseNumber = ({
58
53
  amount,
59
54
  currency,
60
55
  locale,
61
- maxLengthOverride,
62
56
  }: {
63
57
  amount: string;
64
58
  currency: string;
65
59
  locale: string;
66
- maxLengthOverride?: number;
67
60
  }) => {
68
- if (maxLengthOverride && amount.length > maxLengthOverride) {
69
- return 0;
70
- }
71
61
  return parseAmount(amount, currency, locale);
72
62
  };
73
63
 
@@ -105,7 +95,6 @@ export interface MoneyInputProps extends WrappedComponentProps {
105
95
  onCustomAction?: () => void;
106
96
  classNames?: Record<string, string>;
107
97
  selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;
108
- maxLengthOverride?: number;
109
98
  }
110
99
 
111
100
  type MoneyInputPropsWithInputAttributes = MoneyInputProps & Partial<WithInputAttributesProps>;
@@ -136,7 +125,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
136
125
  amount: props.amount,
137
126
  currency: props.selectedCurrency.currency,
138
127
  locale: props.intl.locale,
139
- maxLengthOverride: props.maxLengthOverride,
140
128
  }),
141
129
  locale: props.intl.locale,
142
130
  };
@@ -151,7 +139,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
151
139
  amount: nextProps.amount,
152
140
  currency: nextProps.selectedCurrency.currency,
153
141
  locale: nextProps.intl.locale,
154
- maxLengthOverride: nextProps.maxLengthOverride,
155
142
  }),
156
143
  });
157
144
  }
@@ -179,7 +166,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
179
166
  amount: paste,
180
167
  currency: this.props.selectedCurrency.currency,
181
168
  locale,
182
- maxLengthOverride: this.props.maxLengthOverride,
183
169
  });
184
170
 
185
171
  if (isNumberOrNull(parsed)) {
@@ -188,7 +174,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
188
174
  amount: parsed,
189
175
  currency: this.props.selectedCurrency.currency,
190
176
  locale,
191
- maxLengthOverride: this.props.maxLengthOverride,
192
177
  }),
193
178
  });
194
179
  this.props.onAmountChange?.(parsed);
@@ -208,7 +193,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
208
193
  amount: value,
209
194
  currency: this.props.selectedCurrency.currency,
210
195
  locale: this.state.locale,
211
- maxLengthOverride: this.props.maxLengthOverride,
212
196
  });
213
197
  if (isNumberOrNull(parsed)) {
214
198
  this.props.onAmountChange?.(parsed);
@@ -256,7 +240,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
256
240
  amount: previousState.formattedAmount,
257
241
  currency: this.props.selectedCurrency.currency,
258
242
  locale: previousState.locale,
259
- maxLengthOverride: this.props.maxLengthOverride,
260
243
  });
261
244
  if (!isNumberOrNull(parsed)) {
262
245
  return {
@@ -268,7 +251,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
268
251
  amount: parsed,
269
252
  currency: this.props.selectedCurrency.currency,
270
253
  locale: previousState.locale,
271
- maxLengthOverride: this.props.maxLengthOverride,
272
254
  }),
273
255
  };
274
256
  });
@@ -304,7 +286,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
304
286
  size,
305
287
  addon,
306
288
  selectProps,
307
- maxLengthOverride,
308
289
  } = this.props;
309
290
  const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
310
291
 
@@ -351,12 +332,10 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
351
332
  value={this.state.formattedAmount}
352
333
  inputMode="decimal"
353
334
  disabled={disabled}
354
- maxLength={maxLengthOverride}
355
335
  placeholder={formatAmountIfSet({
356
336
  amount: this.props.placeholder,
357
337
  currency: this.props.selectedCurrency.currency,
358
338
  locale: this.state.locale,
359
- maxLengthOverride: this.props.maxLengthOverride,
360
339
  })}
361
340
  autoComplete="off"
362
341
  onKeyDown={this.handleKeyDown}
@@ -1,4 +1,4 @@
1
- import { render, screen } from '../test-utils';
1
+ import { render, screen } from '@testing-library/react';
2
2
 
3
3
  import RadioGroup from '.';
4
4
  import { Field } from '../field/Field';
@@ -12,6 +12,6 @@ describe('Select', () => {
12
12
  <Select options={options} selected={options[0]} onChange={() => {}} />
13
13
  </Field>,
14
14
  );
15
- expect(screen.getByLabelText(/Currency/)).toHaveTextContent('USD');
15
+ expect(screen.getByLabelText('Currency')).toHaveTextContent('USD');
16
16
  });
17
17
  });
@@ -85,7 +85,7 @@ describe('Switch', () => {
85
85
 
86
86
  it('supports `Field` for labeling', () => {
87
87
  render(
88
- <Field label="Dark mode" required>
88
+ <Field label="Dark mode">
89
89
  <Switch checked onClick={props.onClick} />
90
90
  </Field>,
91
91
  );
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var reactIntl = require('react-intl');
4
-
5
- var messages = reactIntl.defineMessages({
6
- optionalLabel: {
7
- id: "neptune.Label.optional"
8
- },
9
- optionalAriaLabel: {
10
- id: "neptune.aria.Label.optional"
11
- }
12
- });
13
-
14
- module.exports = messages;
15
- //# sourceMappingURL=Label.messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.js","sources":["../../src/label/Label.messages.tsx"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n optionalLabel: {\n id: 'neptune.Label.optional',\n defaultMessage: '(Optional)',\n },\n optionalAriaLabel: {\n id: 'neptune.aria.Label.optional',\n defaultMessage: 'This field is optional',\n },\n});\n"],"names":["defineMessages","optionalLabel","id","optionalAriaLabel"],"mappings":";;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,aAAa,EAAE;IACbC,EAAE,EAAA,wBAAA;GAEH;AACDC,EAAAA,iBAAiB,EAAE;IACjBD,EAAE,EAAA,6BAAA;AAEH,GAAA;AACF,CAAA,CAAC;;;;"}
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- var messages = defineMessages({
4
- optionalLabel: {
5
- id: "neptune.Label.optional"
6
- },
7
- optionalAriaLabel: {
8
- id: "neptune.aria.Label.optional"
9
- }
10
- });
11
-
12
- export { messages as default };
13
- //# sourceMappingURL=Label.messages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.mjs","sources":["../../src/label/Label.messages.tsx"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n optionalLabel: {\n id: 'neptune.Label.optional',\n defaultMessage: '(Optional)',\n },\n optionalAriaLabel: {\n id: 'neptune.aria.Label.optional',\n defaultMessage: 'This field is optional',\n },\n});\n"],"names":["defineMessages","optionalLabel","id","optionalAriaLabel"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,aAAa,EAAE;IACbC,EAAE,EAAA,wBAAA;GAEH;AACDC,EAAAA,iBAAiB,EAAE;IACjBD,EAAE,EAAA,6BAAA;AAEH,GAAA;AACF,CAAA,CAAC;;;;"}
@@ -1,12 +0,0 @@
1
- declare const _default: {
2
- optionalLabel: {
3
- id: string;
4
- defaultMessage: string;
5
- };
6
- optionalAriaLabel: {
7
- id: string;
8
- defaultMessage: string;
9
- };
10
- };
11
- export default _default;
12
- //# sourceMappingURL=Label.messages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.d.ts","sourceRoot":"","sources":["../../../src/label/Label.messages.tsx"],"names":[],"mappings":";;;;;;;;;;AAEA,wBASG"}
@@ -1,3 +0,0 @@
1
- export { Label } from './Label';
2
- export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './Label';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/label/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,12 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- export default defineMessages({
4
- optionalLabel: {
5
- id: 'neptune.Label.optional',
6
- defaultMessage: '(Optional)',
7
- },
8
- optionalAriaLabel: {
9
- id: 'neptune.aria.Label.optional',
10
- defaultMessage: 'This field is optional',
11
- },
12
- });
@@ -1,2 +0,0 @@
1
- export { Label } from './Label';
2
- export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './Label';