@transferwise/components 46.100.1 → 46.101.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.
Files changed (190) hide show
  1. package/build/avatarLayout/AvatarLayout.js +1 -1
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +1 -1
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/dateLookup/DateLookup.js +3 -2
  6. package/build/dateLookup/DateLookup.js.map +1 -1
  7. package/build/dateLookup/DateLookup.mjs +3 -2
  8. package/build/dateLookup/DateLookup.mjs.map +1 -1
  9. package/build/i18n/en.json +2 -0
  10. package/build/i18n/en.json.js +2 -0
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +2 -0
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/main.css +4 -94
  15. package/build/styles/accordion/Accordion.css +27 -16
  16. package/build/styles/avatar/Avatar.css +95 -50
  17. package/build/styles/inputs/Input.css +37 -21
  18. package/build/styles/inputs/TextArea.css +35 -20
  19. package/build/styles/loader/Loader.css +4 -90
  20. package/build/styles/main.css +4 -94
  21. package/build/styles/popover/Popover.css +19 -12
  22. package/build/styles/select/Select.css +131 -68
  23. package/build/styles/switch/Switch.css +27 -16
  24. package/build/styles/tile/Tile.css +31 -18
  25. package/build/types/dateLookup/DateLookup.d.ts +2 -2
  26. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  27. package/build/types/test-utils/index.d.ts +4 -0
  28. package/build/types/test-utils/index.d.ts.map +1 -1
  29. package/build/types/test-utils/story-config.d.ts +2 -3
  30. package/build/types/test-utils/story-config.d.ts.map +1 -1
  31. package/build/types/upload/Upload.d.ts +6 -2
  32. package/build/types/upload/Upload.d.ts.map +1 -1
  33. package/build/types/upload/Upload.messages.d.ts +8 -0
  34. package/build/types/upload/Upload.messages.d.ts.map +1 -1
  35. package/build/types/uploadInput/UploadInput.d.ts +1 -1
  36. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
  37. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  38. package/build/upload/Upload.js +16 -9
  39. package/build/upload/Upload.js.map +1 -1
  40. package/build/upload/Upload.messages.js +6 -0
  41. package/build/upload/Upload.messages.js.map +1 -1
  42. package/build/upload/Upload.messages.mjs +6 -0
  43. package/build/upload/Upload.messages.mjs.map +1 -1
  44. package/build/upload/Upload.mjs +16 -9
  45. package/build/upload/Upload.mjs.map +1 -1
  46. package/build/uploadInput/UploadInput.js +1 -1
  47. package/build/uploadInput/UploadInput.js.map +1 -1
  48. package/build/uploadInput/UploadInput.mjs +1 -1
  49. package/build/uploadInput/UploadInput.mjs.map +1 -1
  50. package/build/uploadInput/uploadButton/UploadButton.js +7 -4
  51. package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
  52. package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
  53. package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
  54. package/package.json +19 -27
  55. package/src/accordion/Accordion.css +27 -16
  56. package/src/accordion/Accordion.story.tsx +1 -1
  57. package/src/actionButton/ActionButton.story.tsx +3 -2
  58. package/src/actionOption/ActionOption.story.tsx +2 -2
  59. package/src/alert/Alert.story.tsx +2 -2
  60. package/src/alert/Alert.tests.story.tsx +2 -2
  61. package/src/avatar/Avatar.css +95 -50
  62. package/src/avatar/Avatar.spec.tsx +1 -1
  63. package/src/avatar/Avatar.story.tsx +3 -2
  64. package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  66. package/src/avatarView/AvatarView.story.tsx +1 -1
  67. package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
  68. package/src/badge/Badge.story.tsx +49 -28
  69. package/src/button/Button.accessibility.docs.mdx +1 -1
  70. package/src/button/Button.story.tsx +2 -2
  71. package/src/button/Button.tests.story.tsx +2 -2
  72. package/src/button/LegacyButton.story.tsx +3 -2
  73. package/src/card/Card.story.tsx +2 -2
  74. package/src/carousel/Carousel.story.tsx +1 -1
  75. package/src/checkbox/Checkbox.story.tsx +2 -2
  76. package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
  77. package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
  78. package/src/chevron/Chevron.story.tsx +1 -1
  79. package/src/chips/Chips.story.tsx +1 -1
  80. package/src/circularButton/CircularButton.story.tsx +1 -1
  81. package/src/circularButton/CircularButton.tests.story.tsx +1 -1
  82. package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
  83. package/src/common/card/Card.story.tsx +1 -1
  84. package/src/common/circle/Circle.story.tsx +2 -2
  85. package/src/common/locale/index.spec.ts +28 -16
  86. package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
  87. package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
  88. package/src/dateInput/DateInput.story.tsx +2 -2
  89. package/src/dateInput/DateInput.tests.story.tsx +2 -2
  90. package/src/dateLookup/DateLookup.spec.tsx +5 -5
  91. package/src/dateLookup/DateLookup.story.tsx +43 -71
  92. package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
  93. package/src/dateLookup/DateLookup.tsx +4 -1
  94. package/src/decision/Decision.story.tsx +24 -49
  95. package/src/definitionList/DefinitionList.story.tsx +1 -1
  96. package/src/dimmer/Dimmer.story.tsx +2 -2
  97. package/src/divider/Divider.accessibility.docs.mdx +1 -1
  98. package/src/divider/Divider.story.tsx +1 -1
  99. package/src/drawer/Drawer.story.tsx +13 -7
  100. package/src/dropFade/DropFade.story.tsx +1 -1
  101. package/src/emphasis/Emphasis.spec.tsx +8 -8
  102. package/src/emphasis/Emphasis.story.tsx +1 -1
  103. package/src/field/Field.story.tsx +3 -3
  104. package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
  105. package/src/i18n/en.json +2 -0
  106. package/src/iconButton/IconButton.story.tsx +2 -2
  107. package/src/image/Image.story.tsx +27 -54
  108. package/src/info/Info.story.tsx +2 -2
  109. package/src/inlineAlert/InlineAlert.story.tsx +1 -1
  110. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
  111. package/src/inputs/Input.css +37 -21
  112. package/src/inputs/InputGroup.story.tsx +1 -1
  113. package/src/inputs/SearchInput.story.tsx +1 -1
  114. package/src/inputs/SelectInput.docs.mdx +1 -1
  115. package/src/inputs/SelectInput.story.tsx +2 -2
  116. package/src/inputs/TextArea.css +35 -20
  117. package/src/instructionsList/InstructionsList.story.tsx +2 -2
  118. package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
  119. package/src/loader/Loader.css +4 -90
  120. package/src/loader/Loader.story.tsx +1 -1
  121. package/src/logo/Logo.story.tsx +1 -1
  122. package/src/main.css +4 -94
  123. package/src/markdown/Markdown.story.tsx +1 -1
  124. package/src/modal/Modal.story.tsx +2 -2
  125. package/src/money/Money.story.tsx +1 -1
  126. package/src/moneyInput/MoneyInput.docs.mdx +1 -1
  127. package/src/moneyInput/MoneyInput.spec.tsx +8 -5
  128. package/src/moneyInput/MoneyInput.story.tsx +2 -2
  129. package/src/moneyInput/currencyFormatting.spec.ts +1 -1
  130. package/src/navigationOption/NavigationOption.story.tsx +265 -226
  131. package/src/nudge/Nudge.story.tsx +1 -1
  132. package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
  133. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
  134. package/src/phoneNumberInput/utils/setDefaultPrefix/setDefaultPrefix.spec.ts +6 -3
  135. package/src/popover/Popover.css +19 -12
  136. package/src/popover/Popover.story.tsx +2 -2
  137. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
  138. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
  139. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
  140. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
  141. package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
  142. package/src/progress/Progress.story.tsx +1 -1
  143. package/src/progressBar/ProgressBar.story.tsx +1 -1
  144. package/src/promoCard/PromoCard.story.tsx +1 -1
  145. package/src/promoCard/PromoCardGroup.story.tsx +1 -1
  146. package/src/provider/Provider.spec.tsx +2 -2
  147. package/src/provider/Provider.story.tsx +1 -1
  148. package/src/provider/direction/DirectionProvider.spec.tsx +1 -1
  149. package/src/provider/language/LanguageProvider.spec.tsx +1 -1
  150. package/src/provider/theme/ThemeProvider.story.tsx +1 -1
  151. package/src/radio/Radio.story.tsx +59 -42
  152. package/src/radioGroup/RadioGroup.story.tsx +2 -2
  153. package/src/radioOption/RadioOption.story.tsx +73 -38
  154. package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
  155. package/src/select/Select.css +131 -68
  156. package/src/select/Select.story.tsx +385 -397
  157. package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
  158. package/src/snackbar/Snackbar.story.tsx +50 -36
  159. package/src/snackbar/Snackbar.tests.story.tsx +3 -2
  160. package/src/statusIcon/StatusIcon.docs.mdx +1 -1
  161. package/src/statusIcon/StatusIcon.spec.tsx +8 -5
  162. package/src/statusIcon/StatusIcon.story.tsx +1 -1
  163. package/src/stepper/Stepper.story.tsx +2 -2
  164. package/src/stepper/Stepper.tests.story.tsx +2 -2
  165. package/src/sticky/Sticky.story.tsx +1 -1
  166. package/src/summary/Summary.story.tsx +18 -17
  167. package/src/switch/Switch.css +27 -16
  168. package/src/switch/Switch.story.tsx +2 -2
  169. package/src/switchOption/SwitchOption.story.tsx +1 -1
  170. package/src/table/Table.story.tsx +1 -1
  171. package/src/test-utils/story-config.ts +9 -6
  172. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
  173. package/src/tile/Tile.css +31 -18
  174. package/src/tile/Tile.story.tsx +43 -43
  175. package/src/tooltip/Tooltip.story.tsx +2 -2
  176. package/src/typeahead/Typeahead.story.tsx +2 -2
  177. package/src/upload/Upload.messages.ts +8 -0
  178. package/src/upload/Upload.spec.tsx +6 -0
  179. package/src/upload/Upload.story.tsx +120 -5
  180. package/src/upload/Upload.tests.story.tsx +5 -3
  181. package/src/upload/Upload.tsx +24 -15
  182. package/src/upload/utils/isTypeValid/isTypeValid.spec.ts +3 -1
  183. package/src/uploadInput/UploadInput.story.tsx +1 -1
  184. package/src/uploadInput/UploadInput.tests.story.tsx +10 -3
  185. package/src/uploadInput/UploadInput.tsx +2 -2
  186. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
  187. package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
  188. package/src/withId/withId.docs.mdx +1 -1
  189. package/src/withId/withId.story.tsx +1 -1
  190. package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { userEvent, within } from '@storybook/test';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { userEvent, within } from 'storybook/test';
3
3
 
4
4
  import Button from '../button';
5
5
  import { storyConfig } from '../test-utils';
@@ -1,6 +1,6 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { Search as SearchIcon } from '@transferwise/icons';
3
- import { userEvent, within, fn } from '@storybook/test';
3
+ import { userEvent, within, fn } from 'storybook/test';
4
4
 
5
5
  import Typeahead, { type TypeaheadOption } from './Typeahead';
6
6
  import { Size } from '../common';
@@ -17,6 +17,10 @@ export default defineMessages({
17
17
  id: 'neptune.Upload.csTooLargeMessage',
18
18
  defaultMessage: 'Please provide a file smaller than {maxSize}MB',
19
19
  },
20
+ csTooLargeNoLimitMessage: {
21
+ id: 'neptune.Upload.csTooLargeNoLimitMessage',
22
+ defaultMessage: 'Please provide a smaller file',
23
+ },
20
24
  csWrongTypeMessage: {
21
25
  id: 'neptune.Upload.csWrongTypeMessage',
22
26
  defaultMessage: 'File type not supported. Please try again with a different file',
@@ -41,6 +45,10 @@ export default defineMessages({
41
45
  id: 'neptune.Upload.usPlaceholder',
42
46
  defaultMessage: 'Drag and drop a file less than {maxSize}MB',
43
47
  },
48
+ usPlaceholderNoLimit: {
49
+ id: 'neptune.Upload.usPlaceholderNoLimit',
50
+ defaultMessage: 'Drag and drop a file',
51
+ },
44
52
  retry: {
45
53
  id: 'neptune.Upload.retry',
46
54
  defaultMessage: 'Retry',
@@ -355,4 +355,10 @@ describe('Upload Component', () => {
355
355
  expect(container.querySelector('.droppable-processing')).not.toBeInTheDocument();
356
356
  expect(props.onStart).not.toHaveBeenCalled();
357
357
  });
358
+
359
+ test('should remove max size limit, when maxSize is the `null`', async () => {
360
+ render(<Upload {...props} usPlaceholder={undefined} maxSize={null} />);
361
+ expect(await screen.findByText(/Drag and drop a file/i)).toBeInTheDocument();
362
+ expect(screen.queryByText(/less than/i)).not.toBeInTheDocument();
363
+ });
358
364
  });
@@ -1,20 +1,136 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
1
+ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { fn } from 'storybook/test';
3
3
 
4
4
  import Upload from '.';
5
5
  import { MAX_SIZE_DEFAULT } from './Upload';
6
- import { Field } from '../field/Field';
7
6
 
8
7
  const meta = {
9
8
  component: Upload,
10
9
  title: 'Forms/Upload',
11
-
10
+ args: {
11
+ // Set all props to undefined so Storybook can auto-detect them
12
+ animationDelay: undefined,
13
+ csButtonText: undefined,
14
+ csFailureText: undefined,
15
+ csSuccessText: undefined,
16
+ csTooLargeMessage: undefined,
17
+ csWrongTypeMessage: undefined,
18
+ httpOptions: undefined,
19
+ fetcher: undefined,
20
+ maxSize: undefined,
21
+ psButtonText: undefined,
22
+ psButtonDisabled: undefined,
23
+ psProcessingText: undefined,
24
+ size: undefined,
25
+ usAccept: undefined,
26
+ usButtonText: undefined,
27
+ usButtonRetryText: undefined,
28
+ usDisabled: undefined,
29
+ usDropMessage: undefined,
30
+ usHelpImage: undefined,
31
+ usLabel: undefined,
32
+ usPlaceholder: undefined,
33
+ errorIconLabel: undefined,
34
+ onCancel: undefined,
35
+ onFailure: undefined,
36
+ onStart: undefined,
37
+ onSuccess: undefined,
38
+ uploadStep: undefined,
39
+ },
12
40
  argTypes: {
13
41
  maxSize: {
14
42
  control: {
15
43
  type: 'number',
16
44
  min: 0,
17
45
  },
46
+ description:
47
+ 'Filesize expressed in Bytes.<br />If set to `null`, no size limit will be applied.',
48
+ table: {
49
+ type: {
50
+ summary: 'number | null',
51
+ },
52
+ defaultValue: {
53
+ summary: MAX_SIZE_DEFAULT.toString(),
54
+ detail: '5 MB',
55
+ },
56
+ },
57
+ },
58
+ fetcher: {
59
+ description:
60
+ 'You can provide a fetcher function with the same interface as the global fetch function, which is used by default.',
61
+ table: {
62
+ type: {
63
+ summary: 'PostDataFetcher',
64
+ },
65
+ },
66
+ control: false,
67
+ },
68
+ usAccept: {
69
+ description:
70
+ 'You can provide multiple rules separated by comma, e.g.: "application/pdf,image/*".\nUsing "*" will allow every file type to be uploaded.',
71
+ },
72
+ errorIconLabel: {
73
+ description:
74
+ "Override for the InlineAlert icon's default, accessible name announced by the screen readers",
75
+ },
76
+ usHelpImage: {
77
+ control: false,
78
+ table: {
79
+ type: {
80
+ summary: 'ReactNode',
81
+ },
82
+ },
83
+ },
84
+ httpOptions: {
85
+ table: {
86
+ type: {
87
+ summary:
88
+ 'PostDataHTTPOptions & { fileInputName?: string; data?: Record<string, string | Blob>; }',
89
+ },
90
+ },
91
+ },
92
+ size: {
93
+ table: {
94
+ type: {
95
+ summary: `Size.SMALL | Size.MEDIUM | Size.LARGE`,
96
+ },
97
+ },
98
+ },
99
+ uploadStep: {
100
+ description: '**@deprecated** Only a single variant exists, please remove this prop.',
101
+ table: {
102
+ type: {
103
+ summary: '"uploadImageStep"',
104
+ },
105
+ },
106
+ },
107
+ onCancel: {
108
+ table: {
109
+ type: {
110
+ summary: '() => void',
111
+ },
112
+ },
113
+ },
114
+ onFailure: {
115
+ table: {
116
+ type: {
117
+ summary: '(error: unknown) => void',
118
+ },
119
+ },
120
+ },
121
+ onStart: {
122
+ table: {
123
+ type: {
124
+ summary: '(file: File) => void',
125
+ },
126
+ },
127
+ },
128
+ onSuccess: {
129
+ table: {
130
+ type: {
131
+ summary: '(response: string | Response, fileName: string) => void',
132
+ },
133
+ },
18
134
  },
19
135
  },
20
136
  } satisfies Meta<typeof Upload>;
@@ -24,7 +140,6 @@ type Story = StoryObj<typeof meta>;
24
140
 
25
141
  export const Basic: Story = {
26
142
  args: {
27
- maxSize: MAX_SIZE_DEFAULT,
28
143
  usAccept: 'image/*',
29
144
  usLabel: 'Front of your ID document',
30
145
  usDisabled: false,
@@ -1,8 +1,6 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
1
+ import type { Meta } from '@storybook/react-webpack5';
3
2
 
4
3
  import Upload from '.';
5
- import { MAX_SIZE_DEFAULT } from './Upload';
6
4
  import { Field } from '../field/Field';
7
5
 
8
6
  const meta = {
@@ -59,6 +57,10 @@ export const MaxSizes = () => {
59
57
  <Upload usLabel="Pick a file, any file" maxSize={maxSize} />
60
58
  </Field>
61
59
  ))}
60
+
61
+ <Field label="Max size: null (no limit)">
62
+ <Upload usLabel="Pick a file, any file" maxSize={null} />
63
+ </Field>
62
64
  </div>
63
65
  <div style={{ flex: 1 }}>
64
66
  {decimalSizes.map((maxSize) => (
@@ -10,7 +10,6 @@ import messages from './Upload.messages';
10
10
  import { UploadImageStep, ProcessingStep, CompleteStep } from './steps';
11
11
  import { postData, asyncFileRead, isSizeValid, isTypeValid, getFileType } from './utils';
12
12
  import { PostDataFetcher, PostDataHTTPOptions, ResponseError } from './utils/postData/postData';
13
- import { ProcessIndicatorStatus } from '../processIndicator';
14
13
 
15
14
  export const MAX_SIZE_DEFAULT = 5000000;
16
15
 
@@ -31,10 +30,14 @@ export interface UploadProps extends WrappedComponentProps {
31
30
  };
32
31
  /**
33
32
  * You can provide a fetcher function with the same interface as the global fetch function, which is used by default.
34
- * function fetcher(input: RequestInfo, init?: RequestInit): Promise<Response>
33
+ * `function fetcher(input: RequestInfo, init?: RequestInit): Promise<Response>`
35
34
  */
36
35
  fetcher?: PostDataFetcher;
37
- maxSize?: number;
36
+ /**
37
+ * Filesize expressed in B.<br />If set to `null`, no size limit will be applied.
38
+ * @default 5000000 (5 MB)
39
+ */
40
+ maxSize?: number | null;
38
41
  psButtonText?: string;
39
42
  psButtonDisabled?: boolean;
40
43
  psProcessingText?: string;
@@ -114,9 +117,9 @@ export class Upload extends Component<UploadProps, UploadState> {
114
117
  case 413:
115
118
  return (
116
119
  csTooLargeMessage ||
117
- intl.formatMessage(messages.csTooLargeMessage, {
118
- maxSize: roundFileSize(maxSize),
119
- })
120
+ (typeof maxSize === 'number'
121
+ ? intl.formatMessage(messages.csTooLargeMessage, { maxSize: roundFileSize(maxSize) })
122
+ : intl.formatMessage(messages.csTooLargeNoLimitMessage))
120
123
  );
121
124
  case 415:
122
125
  return csWrongTypeMessage || intl.formatMessage(messages.csWrongTypeMessage);
@@ -279,7 +282,7 @@ export class Upload extends Component<UploadProps, UploadState> {
279
282
  return false;
280
283
  }
281
284
 
282
- if (!isSizeValid(file, maxSize)) {
285
+ if (typeof maxSize === 'number' && !isSizeValid(file, maxSize)) {
283
286
  this.asyncResponse(
284
287
  new ResponseError(
285
288
  new Response(null, {
@@ -344,6 +347,18 @@ export class Upload extends Component<UploadProps, UploadState> {
344
347
  uploadedImage,
345
348
  } = this.state;
346
349
 
350
+ const placeholder = ((): string => {
351
+ if (usPlaceholder) {
352
+ return usPlaceholder;
353
+ }
354
+
355
+ if (typeof maxSize === 'number') {
356
+ return intl.formatMessage(messages.usPlaceholder, { maxSize: roundFileSize(maxSize) });
357
+ }
358
+
359
+ return intl.formatMessage(messages.usPlaceholderNoLimit);
360
+ })();
361
+
347
362
  return (
348
363
  <div
349
364
  className={clsx('droppable-area', {
@@ -370,10 +385,7 @@ export class Upload extends Component<UploadProps, UploadState> {
370
385
  usDisabled={usDisabled}
371
386
  usHelpImage={usHelpImage}
372
387
  usLabel={usLabel}
373
- usPlaceholder={
374
- usPlaceholder ||
375
- intl.formatMessage(messages.usPlaceholder, { maxSize: roundFileSize(maxSize) })
376
- }
388
+ usPlaceholder={placeholder}
377
389
  />
378
390
  )}
379
391
 
@@ -400,10 +412,7 @@ export class Upload extends Component<UploadProps, UploadState> {
400
412
  usDisabled={usDisabled}
401
413
  usHelpImage={null}
402
414
  usLabel={usLabel}
403
- usPlaceholder={
404
- usPlaceholder ||
405
- intl.formatMessage(messages.usPlaceholder, { maxSize: roundFileSize(maxSize) })
406
- }
415
+ usPlaceholder={placeholder}
407
416
  errorMessage={this.getErrorMessage(
408
417
  response != null &&
409
418
  typeof response === 'object' &&
@@ -12,7 +12,9 @@ const data64Img = 'data:image/png;something';
12
12
 
13
13
  describe('isTypeValid', () => {
14
14
  describe('when type is provided', () => {
15
- it.each([pdfFile, pngFile])('returns true for wildcard rule %s', (file) => {
15
+ const files = [pdfFile, pngFile] as const;
16
+
17
+ it.each(files)('returns true for wildcard rule %s', (file: (typeof files)[number]) => {
16
18
  expect(isTypeValid(file, '*')).toBe(true);
17
19
  });
18
20
 
@@ -1,4 +1,4 @@
1
- import { StoryFn, Meta } from '@storybook/react';
1
+ import { StoryFn, Meta } from '@storybook/react-webpack5';
2
2
 
3
3
  import { Field } from '../field/Field';
4
4
 
@@ -1,10 +1,10 @@
1
- import { action } from '@storybook/addon-actions';
2
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { action } from 'storybook/actions';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
 
4
4
  import { Status } from '../common';
5
5
  import UploadInput, { UploadInputProps } from './UploadInput';
6
6
  import { UploadedFile, UploadResponse } from './types';
7
- import { userEvent } from '@storybook/test';
7
+ import { userEvent } from 'storybook/test';
8
8
 
9
9
  const meta: Meta<typeof UploadInput> = {
10
10
  title: 'Forms/UploadInput/Tests',
@@ -233,6 +233,13 @@ export const WithFileSizeErrorMessage: Story = {
233
233
  },
234
234
  };
235
235
 
236
+ export const WithNoSizeLimit: Story = {
237
+ args: {
238
+ ...props,
239
+ sizeLimit: null,
240
+ },
241
+ };
242
+
236
243
  export const WithCustomUploadButtonTitle: Story = {
237
244
  args: {
238
245
  ...props,
@@ -91,7 +91,7 @@ export type UploadInputProps = {
91
91
  maxFilesErrorMessage?: string;
92
92
 
93
93
  /**
94
- * Error message to show when files over a allowed size limit are uploaded
94
+ * Error message to show when files over allowed size limit are uploaded
95
95
  */
96
96
  sizeLimitErrorMessage?: string;
97
97
  } & Pick<
@@ -269,7 +269,7 @@ const UploadInput = ({
269
269
  continue;
270
270
  }
271
271
 
272
- if (!isSizeValid(file, sizeLimit * 1000)) {
272
+ if (typeof sizeLimit === 'number' && !isSizeValid(file, sizeLimit * 1000)) {
273
273
  const failureMessage = sizeLimitErrorMessage || formatMessage(MESSAGES.fileIsTooLarge);
274
274
  handleFileUploadFailure(file, failureMessage);
275
275
  continue;
@@ -96,6 +96,12 @@ describe('UploadButton', () => {
96
96
  expect(screen.getByText('All file types, less than 5MB')).toBeInTheDocument();
97
97
  });
98
98
 
99
+ it('should show no file size limit if sizeLimit is set to `null`', () => {
100
+ renderComponent({ ...props, fileTypes: ['*'], sizeLimit: null });
101
+ expect(screen.getByText('All file types')).toBeInTheDocument();
102
+ expect(screen.queryByText(/less than/i)).not.toBeInTheDocument();
103
+ });
104
+
99
105
  it('should show custom description if provided', () => {
100
106
  const description = 'Test description';
101
107
  renderComponent({ ...props, fileTypes: ['*'], description });
@@ -42,9 +42,11 @@ export type UploadButtonProps = {
42
42
  fileTypes?: AllowedFileTypes;
43
43
 
44
44
  /**
45
- * Size limit in KBs 1000 KB = 1 MB (default: 5000 KB)
45
+ * Size limit in KBs (1000 KB = 1 MB).
46
+ * If set to `null`, no size limit will be applied.
47
+ * @default 5000
46
48
  */
47
- sizeLimit?: number;
49
+ sizeLimit?: number | null;
48
50
 
49
51
  /**
50
52
  * Description for the upload button
@@ -173,10 +175,14 @@ const UploadButton = forwardRef<HTMLInputElement | null, UploadButtonProps>(
173
175
  const derivedFileDescription =
174
176
  fileTypesDescription === '*' ? formatMessage(MESSAGES.allFileTypes) : fileTypesDescription;
175
177
 
176
- return formatMessage(MESSAGES.instructions, {
177
- fileTypes: derivedFileDescription,
178
- size: Math.round(sizeLimit / 1000),
179
- });
178
+ if (typeof sizeLimit === 'number') {
179
+ return formatMessage(MESSAGES.instructions, {
180
+ fileTypes: derivedFileDescription,
181
+ size: Math.round(sizeLimit / 1000),
182
+ });
183
+ }
184
+
185
+ return derivedFileDescription;
180
186
  }
181
187
 
182
188
  function getAcceptedTypes(): Pick<React.ComponentPropsWithoutRef<'input'>, 'accept'> {
@@ -1,4 +1,4 @@
1
- import { Meta, Canvas, Source } from '@storybook/blocks';
1
+ import { Meta, Canvas, Source } from '@storybook/addon-docs/blocks';
2
2
  import { WithoutId, WithCustomId, WithEmptyId } from './withId.story';
3
3
  import { withIdSource } from './story/source';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { Button, withId, type WithIdProps } from '..';
3
3
 
4
4
  type Story = StoryObj<typeof withId>;
@@ -1,21 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ResponsivePanel on desktop renders Panel 1`] = `
4
- <div>
5
- <div
6
- class="np-panel np-panel--open"
7
- >
8
- children
9
- </div>
10
- </div>
11
- `;
12
-
13
- exports[`ResponsivePanel on mobile renders bottomSheet 1`] = `
14
- <div>
15
- <div
16
- class="np-bottom-sheet"
17
- >
18
- children
19
- </div>
20
- </div>
21
- `;