@onewelcome/react-lib-components 1.6.0 → 1.8.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 (53) hide show
  1. package/README.md +4 -4
  2. package/dist/Form/FileUpload/FileItem/FileItem.d.ts +17 -0
  3. package/dist/Form/FileUpload/FileUpload.d.ts +26 -0
  4. package/dist/Icon/Icon.d.ts +4 -1
  5. package/dist/ProgressBar/ProgressBar.d.ts +2 -1
  6. package/dist/Typography/Typography.d.ts +1 -1
  7. package/dist/_BaseStyling_/BaseStyling.d.ts +23 -0
  8. package/dist/hooks/useUploadFile.d.ts +22 -0
  9. package/dist/react-lib-components.cjs.development.js +130 -98
  10. package/dist/react-lib-components.cjs.development.js.map +1 -1
  11. package/dist/react-lib-components.cjs.production.min.js +1 -1
  12. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  13. package/dist/react-lib-components.esm.js +130 -98
  14. package/dist/react-lib-components.esm.js.map +1 -1
  15. package/dist/util/helper.d.ts +7 -0
  16. package/package.json +24 -21
  17. package/src/Breadcrumbs/Breadcrumbs.module.scss +2 -2
  18. package/src/Button/Button.module.scss +14 -2
  19. package/src/ContextMenu/ContextMenuItem.module.scss +1 -0
  20. package/src/DataGrid/DataGridHeader/DataGridHeader.module.scss +1 -1
  21. package/src/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +1 -1
  22. package/src/Form/Fieldset/Fieldset.module.scss +8 -1
  23. package/src/Form/FileUpload/FileItem/FileItem.modules.scss +75 -0
  24. package/src/Form/FileUpload/FileItem/FileItem.test.tsx +103 -0
  25. package/src/Form/FileUpload/FileItem/FileItem.tsx +141 -0
  26. package/src/Form/FileUpload/FileUpload.module.scss +106 -0
  27. package/src/Form/FileUpload/FileUpload.test.tsx +374 -0
  28. package/src/Form/FileUpload/FileUpload.tsx +251 -0
  29. package/src/Form/Input/Input.module.scss +9 -3
  30. package/src/Form/Select/Select.module.scss +26 -3
  31. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +3 -1
  32. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss +9 -1
  33. package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +11 -2
  34. package/src/Icon/Icon.module.scss +12 -0
  35. package/src/Icon/Icon.tsx +4 -1
  36. package/src/Link/Link.module.scss +1 -1
  37. package/src/Notifications/Banner/Banner.module.scss +2 -2
  38. package/src/Pagination/Pagination.module.scss +1 -0
  39. package/src/ProgressBar/ProgressBar.module.scss +11 -9
  40. package/src/ProgressBar/ProgressBar.test.tsx +21 -0
  41. package/src/ProgressBar/ProgressBar.tsx +7 -2
  42. package/src/Tabs/TabButton.module.scss +3 -3
  43. package/src/Tabs/Tabs.module.scss +1 -0
  44. package/src/Typography/Typography.module.scss +4 -4
  45. package/src/Typography/Typography.tsx +1 -1
  46. package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +17 -7
  47. package/src/_BaseStyling_/BaseStyling.tsx +73 -27
  48. package/src/hooks/useUploadFile.test.ts +211 -0
  49. package/src/hooks/useUploadFile.tsx +136 -0
  50. package/src/mixins.module.scss +26 -7
  51. package/src/util/helper.test.tsx +188 -16
  52. package/src/util/helper.tsx +38 -0
  53. package/src/variables.scss +18 -0
@@ -0,0 +1,374 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useEffect, useRef } from "react";
18
+ import { FileType, FileUpload, Props } from "./FileUpload";
19
+ import { createEvent, fireEvent, render, waitFor } from "@testing-library/react";
20
+
21
+ import user from "@testing-library/user-event";
22
+ import { act } from "react-dom/test-utils";
23
+
24
+ const defaultParams: Props = {
25
+ accept: ".pdf, .jpg, .txt",
26
+ title: "File Upload test",
27
+ multiple: false,
28
+ fileList: []
29
+ };
30
+
31
+ const createComponent = (params?: (defaultParams: Props) => Props, dataTesId?: string) => {
32
+ let parameters: Props = defaultParams;
33
+ const id = dataTesId || "file-upload";
34
+ if (params) {
35
+ parameters = params(defaultParams);
36
+ }
37
+ const queries = render(<FileUpload {...parameters} data-testid={id} />);
38
+ const component = queries.getByTestId(id);
39
+ const container = queries.container;
40
+
41
+ return {
42
+ ...queries,
43
+ container,
44
+ component
45
+ };
46
+ };
47
+
48
+ describe("component should render", () => {
49
+ it("renders without crashing", () => {
50
+ const { component } = createComponent();
51
+
52
+ expect(component).toBeDefined();
53
+ });
54
+ });
55
+
56
+ describe("ref should work", () => {
57
+ it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
58
+ const ExampleComponent = ({
59
+ propagateRef
60
+ }: {
61
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
62
+ }) => {
63
+ const ref = useRef(null);
64
+
65
+ useEffect(() => {
66
+ if (ref.current) {
67
+ propagateRef && propagateRef(ref);
68
+ }
69
+ }, [ref]);
70
+
71
+ return <FileUpload {...defaultParams} data-ref="testing" ref={ref} />;
72
+ };
73
+
74
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
75
+ expect(ref.current).toHaveAttribute("data-ref", "testing");
76
+ };
77
+
78
+ render(<ExampleComponent propagateRef={refCheck} />);
79
+ });
80
+ });
81
+
82
+ describe("File upload properties", () => {
83
+ it("is disabled", () => {
84
+ const { container } = createComponent(
85
+ defaultParams => ({
86
+ ...defaultParams,
87
+ disabled: true
88
+ }),
89
+ "file-upload-1"
90
+ );
91
+ const dropZone = container.querySelector(".file-dropzone");
92
+ expect(dropZone).toHaveClass("disabled");
93
+ });
94
+
95
+ it("shows success", () => {
96
+ const { container } = createComponent(
97
+ defaultParams => ({
98
+ ...defaultParams,
99
+ success: true
100
+ }),
101
+ "file-upload-2"
102
+ );
103
+
104
+ const dropZone = container.querySelector(".file-dropzone");
105
+ expect(dropZone).toHaveClass("success");
106
+ const icon = container.querySelector("[data-icon-status='success']");
107
+ expect(icon).toBeDefined();
108
+ });
109
+
110
+ it("shows error", () => {
111
+ const { container } = createComponent(
112
+ defaultParams => ({
113
+ ...defaultParams,
114
+ error: true
115
+ }),
116
+ "file-upload-3"
117
+ );
118
+
119
+ const dropZone = container.querySelector(".file-dropzone");
120
+ expect(dropZone).toHaveClass("error");
121
+ const icon = container.querySelector("[data-icon-status='error']");
122
+ expect(icon).toBeDefined();
123
+ });
124
+
125
+ it("has multiple attribute setup on the input", () => {
126
+ const { component } = createComponent(
127
+ defaultParams => ({
128
+ ...defaultParams,
129
+ multiple: true
130
+ }),
131
+ "file-upload-4"
132
+ );
133
+
134
+ expect(component).toHaveAttribute("multiple");
135
+ });
136
+
137
+ it("has the correct drag and drop label", () => {
138
+ const text = "test drag and drop text";
139
+ const { container } = createComponent(
140
+ defaultParams => ({
141
+ ...defaultParams,
142
+ dragAndDropText: text
143
+ }),
144
+ "file-upload-5"
145
+ );
146
+
147
+ expect(container.querySelector(".drag-and-drop-text")).toHaveTextContent(text);
148
+ });
149
+
150
+ it("has the correct button label", () => {
151
+ const text = "Test";
152
+ const { container } = createComponent(
153
+ defaultParams => ({
154
+ ...defaultParams,
155
+ selectButtonText: text
156
+ }),
157
+ "file-upload-6"
158
+ );
159
+
160
+ expect(container.querySelector("button")).toHaveTextContent(text);
161
+ });
162
+
163
+ afterEach(() => {
164
+ jest.clearAllMocks();
165
+ });
166
+ });
167
+
168
+ describe("File Upload should display items based on file list", () => {
169
+ it("should display the file list with each status", () => {
170
+ const file: FileType = {
171
+ name: "test",
172
+ size: 2,
173
+ type: "text",
174
+ status: "completed"
175
+ };
176
+ const { container } = createComponent(
177
+ defaultParams => ({
178
+ ...defaultParams,
179
+ fileList: [file]
180
+ }),
181
+ "file-upload-10"
182
+ );
183
+
184
+ const fileEl = container.querySelector(`#${file.name}`);
185
+ expect(fileEl).toBeDefined();
186
+ expect(fileEl).toHaveClass(file.status as string);
187
+ });
188
+ });
189
+
190
+ describe("file drag and drop properties", () => {
191
+ it("should call all the drag and drop callback provided", async () => {
192
+ const onDrop = jest.fn();
193
+ const onDragOver = jest.fn();
194
+ const onDragLeave = jest.fn();
195
+ const { container } = createComponent(
196
+ defaultParams => ({
197
+ ...defaultParams,
198
+ accept: ".png",
199
+ onDrop,
200
+ onDragOver,
201
+ onDragLeave,
202
+ fileList: []
203
+ }),
204
+ "file-upload-6"
205
+ );
206
+
207
+ const file = new File([""], "test.png", {
208
+ type: "image/png"
209
+ });
210
+
211
+ const eventData = {
212
+ dataTransfer: {
213
+ files: [file]
214
+ }
215
+ };
216
+
217
+ const dropZone = container.querySelector(".file-dropzone") as Element;
218
+ const dragEnterEvent = createEvent.dragEnter(dropZone, eventData);
219
+ const dragOverEvent = createEvent.dragOver(dropZone, eventData);
220
+ const dropEvent = createEvent.drop(dropZone, eventData);
221
+ const dragLeaveEvent = createEvent.dragLeave(dropZone, eventData);
222
+
223
+ await waitFor(() => {
224
+ fireEvent(dropZone, dragEnterEvent);
225
+ });
226
+
227
+ await waitFor(() => {
228
+ fireEvent(dropZone, dragLeaveEvent);
229
+ });
230
+
231
+ expect(onDragLeave).toHaveBeenCalled();
232
+
233
+ await waitFor(() => {
234
+ fireEvent(dropZone, dragOverEvent);
235
+ });
236
+
237
+ expect(dropZone).toHaveClass("drag-active");
238
+
239
+ expect(onDragOver).toHaveBeenCalled();
240
+
241
+ await waitFor(() => {
242
+ fireEvent(dropZone, dropEvent);
243
+ });
244
+
245
+ expect(onDrop).toHaveBeenCalled();
246
+ });
247
+
248
+ afterEach(() => {
249
+ jest.clearAllMocks();
250
+ });
251
+ });
252
+
253
+ describe("upload action", () => {
254
+ it("shows accepts only files that follow the type rules", async () => {
255
+ const onChange = jest.fn();
256
+ const { component } = createComponent(
257
+ defaultParams => ({
258
+ ...defaultParams,
259
+ onChange,
260
+ fileList: [],
261
+ accept: ".pdf"
262
+ }),
263
+ "file-upload-7"
264
+ );
265
+ const str = "test";
266
+ const blob = new Blob([str]);
267
+ const file = new File([blob], "test.pdf", {
268
+ type: "application/pdf"
269
+ });
270
+ File.prototype.text = jest.fn().mockResolvedValueOnce(str);
271
+ await act(async () => {
272
+ await waitFor(() => {
273
+ user.upload(component, file);
274
+ });
275
+ });
276
+
277
+ const file2 = new File([blob], "test.jpg", {
278
+ type: "application/jpg"
279
+ });
280
+
281
+ await act(async () => {
282
+ await waitFor(() => {
283
+ user.upload(component, file2);
284
+ });
285
+ });
286
+ expect(onChange).toHaveBeenCalledTimes(1);
287
+ });
288
+
289
+ it("doesn't upload a file two times", async () => {
290
+ const onChange = jest.fn();
291
+ const { component } = createComponent(
292
+ defaultParams => ({
293
+ ...defaultParams,
294
+ maxFileSize: 1024 * 1024,
295
+ onChange,
296
+ fileList: []
297
+ }),
298
+ "file-upload-9"
299
+ );
300
+ const value = "test";
301
+ const blob = new Blob([value]);
302
+ const file = new File([blob], "test.pdf", {
303
+ type: "application/pdf"
304
+ });
305
+ Object.defineProperty(file, "size", { value: 1024 * 1024 * 2 });
306
+ File.prototype.text = jest.fn().mockResolvedValueOnce(value);
307
+ await act(async () => {
308
+ await waitFor(() => {
309
+ user.upload(component, file);
310
+ });
311
+ });
312
+ await act(async () => {
313
+ await waitFor(() => {
314
+ user.upload(component, file);
315
+ });
316
+ });
317
+ expect(onChange).toHaveBeenCalledTimes(1);
318
+ });
319
+
320
+ it("doesn't allows files to be dropped according to the accepted file types", async () => {
321
+ const onDrop = jest.fn();
322
+ const { container } = createComponent(
323
+ defaultParams => ({
324
+ ...defaultParams,
325
+ accept: ".jpg",
326
+ onDrop,
327
+ fileList: []
328
+ }),
329
+ "file-upload-10"
330
+ );
331
+
332
+ const file = new File([""], "test.png", {
333
+ type: "image/png"
334
+ });
335
+
336
+ const eventData = {
337
+ dataTransfer: {
338
+ files: [file]
339
+ }
340
+ };
341
+ const dropZone = container.querySelector(".file-dropzone") as Element;
342
+ const dropEvent = createEvent.drop(dropZone, eventData);
343
+ await waitFor(() => {
344
+ fireEvent(dropZone, dropEvent);
345
+ });
346
+
347
+ expect(onDrop).toHaveBeenCalledTimes(0);
348
+ });
349
+
350
+ afterEach(() => {
351
+ jest.clearAllMocks();
352
+ });
353
+ });
354
+
355
+ describe("FileUpload should validate files on first render", () => {
356
+ const onChange = jest.fn();
357
+ const { component } = createComponent(
358
+ defaultParams => ({
359
+ ...defaultParams,
360
+ onChange,
361
+ fileList: [
362
+ {
363
+ name: "test",
364
+ type: "text/txt",
365
+ size: 1024 * 1024
366
+ }
367
+ ]
368
+ }),
369
+ "file-upload-8"
370
+ );
371
+
372
+ expect(component).toBeDefined();
373
+ expect(onChange).toHaveBeenCalled();
374
+ });
@@ -0,0 +1,251 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, {
18
+ DragEvent,
19
+ DragEventHandler,
20
+ ForwardRefRenderFunction,
21
+ useEffect,
22
+ useRef,
23
+ useState
24
+ } from "react";
25
+ import { Button } from "../../Button/Button";
26
+ import { FILE_ACTION, FileItem, Props as FileConfig } from "./FileItem/FileItem";
27
+ import { Props as InputProps } from "../Input/Input";
28
+ import { Typography } from "../../Typography/Typography";
29
+ import classes from "./FileUpload.module.scss";
30
+ import { Icon, Icons } from "../../Icon/Icon";
31
+ import { useDetermineStatusIcon } from "../../hooks/useDetermineStatusIcon";
32
+
33
+ type FileUploadType = Omit<InputProps, "onDrop" | "type" | "onChange" | "suffix" | "prefix">;
34
+ export type FileType = Omit<FileConfig, "onRequestedFileAction"> &
35
+ Pick<File, "size" | "type"> & { data?: any };
36
+
37
+ export interface Props extends FileUploadType {
38
+ accept: string;
39
+ title: string;
40
+ multiple: boolean;
41
+ fileList: FileType[];
42
+ exceedingMaxSizeErrorText?: string;
43
+ maxFileSize?: number;
44
+ selectButtonText?: string;
45
+ dragAndDropText?: string;
46
+ subText?: string;
47
+ onDragOver?: DragEventHandler;
48
+ onDragEnter?: DragEventHandler;
49
+ onDragLeave?: DragEventHandler;
50
+ onDrop?: (e: FileType[]) => void;
51
+ onChange?: (e: FileType[]) => void;
52
+ onRequestedFileAction?: (action: FILE_ACTION, name: FileType["name"]) => void;
53
+ }
54
+
55
+ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
56
+ {
57
+ name,
58
+ accept,
59
+ error,
60
+ success,
61
+ maxFileSize,
62
+ multiple,
63
+ id,
64
+ title,
65
+ labeledBy,
66
+ disabled = false,
67
+ onChange,
68
+ dragAndDropText = "Drop file here or",
69
+ selectButtonText = "Select file",
70
+ onDragOver,
71
+ onDragLeave,
72
+ wrapperProps,
73
+ onDrop,
74
+ subText,
75
+ onRequestedFileAction,
76
+ exceedingMaxSizeErrorText,
77
+ fileList,
78
+ ...rest
79
+ }: Props,
80
+ ref
81
+ ) => {
82
+ const labelRef = useRef(null);
83
+ const [dragActive, setDragActive] = useState(false);
84
+ const [inputError, setInputError] = useState(false);
85
+ const icon = useDetermineStatusIcon({ success, error });
86
+ let dropzoneClassNames = [classes["file-dropzone"]];
87
+ let subTextClass = [classes["file-selector-sub-text"]];
88
+ dragActive && dropzoneClassNames.push(classes["drag-active"]);
89
+ inputError ||
90
+ (error && dropzoneClassNames.push(classes["error"]) && subTextClass.push(classes["error"]));
91
+ disabled && dropzoneClassNames.push(classes["disabled"]);
92
+ success && !error && dropzoneClassNames.push(classes["success"]);
93
+
94
+ const getFileList = (files: FileList | null): FileType[] => {
95
+ let savedFiles = fileList ? [...fileList] : [];
96
+ const fileNames = fileList.map(el => el.name);
97
+ files?.length &&
98
+ Array.from(files as ArrayLike<File>).forEach(el => {
99
+ if (!fileNames.includes(el.name)) {
100
+ savedFiles = multiple
101
+ ? [
102
+ ...savedFiles,
103
+ {
104
+ ...validateUpload(el),
105
+ data: el
106
+ }
107
+ ]
108
+ : [
109
+ {
110
+ ...validateUpload(el),
111
+ data: el
112
+ }
113
+ ];
114
+ }
115
+ });
116
+ return savedFiles;
117
+ };
118
+ const onInputChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
119
+ e.preventDefault();
120
+ e.stopPropagation();
121
+ let files = getFileList(e.target.files);
122
+ files.length && verifyExtensionValidity(files[files.length - 1]) && onChange && onChange(files);
123
+ };
124
+
125
+ const verifyExtensionValidity = (file: FileType) => {
126
+ const extension = file.name.split(".").pop();
127
+ return extension && accept.includes(extension);
128
+ };
129
+
130
+ const validateUpload = (file: FileType) => {
131
+ const result: FileType = {
132
+ name: file.name,
133
+ size: file.size,
134
+ type: file.type
135
+ };
136
+
137
+ let err = false;
138
+ if (maxFileSize && file.size && file.size >= maxFileSize) {
139
+ const mb = (file.size / (1024 * 1024)).toFixed(2);
140
+ result.error =
141
+ exceedingMaxSizeErrorText ||
142
+ `The maximum allowed file size is ${mb}MB. Upload a smaller file.`;
143
+ result.status = "error";
144
+ err = true;
145
+ }
146
+ setInputError(err);
147
+ return result;
148
+ };
149
+
150
+ useEffect(() => {
151
+ if (fileList.length) {
152
+ const validatedFiles = fileList.map(file => validateUpload(file));
153
+ onChange && onChange(validatedFiles);
154
+ }
155
+ }, []);
156
+
157
+ const handleOnDragOver = (e: DragEvent<HTMLDivElement>) => {
158
+ e.preventDefault();
159
+ e.stopPropagation();
160
+ setDragActive(true);
161
+ onDragOver && onDragOver(e);
162
+ };
163
+
164
+ const handleOnDragLeave = (e: DragEvent<HTMLDivElement>) => {
165
+ e.preventDefault();
166
+ e.stopPropagation();
167
+ const target = e.target as HTMLElement;
168
+ if (target?.classList.contains(classes["file-dropzone"])) {
169
+ setDragActive(false);
170
+ }
171
+ onDragLeave && onDragLeave(e);
172
+ };
173
+
174
+ const handleOnDrop = async (e: DragEvent<HTMLDivElement>) => {
175
+ e.preventDefault();
176
+ e.stopPropagation();
177
+ if (e?.dataTransfer?.files && e.dataTransfer.files.length) {
178
+ const extension = e?.dataTransfer?.files[0].name.split(".").pop();
179
+ if (extension && accept && !accept.includes(extension)) {
180
+ setDragActive(false);
181
+ return;
182
+ }
183
+ const validatedFiles = getFileList(e.dataTransfer.files);
184
+ onDrop && onDrop(validatedFiles);
185
+ }
186
+ setDragActive(false);
187
+ };
188
+
189
+ return (
190
+ <div className={classes["file-upload-wrapper"]} {...wrapperProps}>
191
+ <div
192
+ className={dropzoneClassNames.join(" ")}
193
+ onDragOver={e => !disabled && handleOnDragOver(e)}
194
+ onDragLeave={e => !disabled && handleOnDragLeave(e)}
195
+ onDrop={e => !disabled && handleOnDrop(e)}
196
+ >
197
+ <Typography variant="body-bold" className={classes["file-upload-title"]} ref={labelRef}>
198
+ {title}
199
+ </Typography>
200
+ <div className={classes["file-select"]}>
201
+ <Icon className={"drop-file-icon"} icon={Icons.FileUpload} />
202
+ <Typography variant="body" className={"drag-and-drop-text"}>
203
+ {dragAndDropText}
204
+ </Typography>
205
+ <div className={classes["file-upload-btn"]}>
206
+ <Button variant="outline" disabled={disabled}>
207
+ {selectButtonText}
208
+ </Button>
209
+ <input
210
+ className={classes["upload-input"]}
211
+ {...rest}
212
+ ref={ref}
213
+ aria-labelledby={labeledBy}
214
+ type="file"
215
+ name={name}
216
+ {...(multiple && { multiple: true })}
217
+ disabled={disabled}
218
+ accept={accept}
219
+ onChange={onInputChange}
220
+ spellCheck={rest.spellCheck || false}
221
+ />
222
+ </div>
223
+ {!disabled && icon}
224
+ <span className={classes["outline"]}></span>
225
+ </div>
226
+ {subText && (
227
+ <Typography variant={"sub-text"} className={subTextClass.join(" ")}>
228
+ {subText}
229
+ </Typography>
230
+ )}
231
+ </div>
232
+ {fileList?.length > 0 && (
233
+ <ul className={classes["file-list"]}>
234
+ {fileList.map(({ name, status, progress, error }) => (
235
+ <li key={name} className={status} id={name}>
236
+ <FileItem
237
+ name={name}
238
+ status={status}
239
+ progress={progress}
240
+ error={error}
241
+ onRequestedFileAction={onRequestedFileAction}
242
+ />
243
+ </li>
244
+ ))}
245
+ </ul>
246
+ )}
247
+ </div>
248
+ );
249
+ };
250
+
251
+ export const FileUpload = React.forwardRef(FileUploadComponent);
@@ -14,7 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @use "../../mixins.module.scss";
17
+ @use "src/mixins.module";
18
+ @use "src/variables";
18
19
 
19
20
  .input-wrapper {
20
21
  position: relative;
@@ -24,7 +25,7 @@
24
25
  border: 0;
25
26
  border-radius: var(--input-border-radius);
26
27
  background-color: var(--input-background-color);
27
- padding: 0 1.25rem;
28
+ padding: 0 variables.$form-element-horizontal-padding-mobile;
28
29
  @include mixins.transition(all, 0.2s, ease-in-out);
29
30
 
30
31
  // General autofill styles
@@ -111,7 +112,6 @@
111
112
  }
112
113
 
113
114
  &:disabled {
114
- background-color: var(--disabled);
115
115
  cursor: not-allowed;
116
116
  }
117
117
 
@@ -142,3 +142,9 @@
142
142
  display: block;
143
143
  z-index: 1;
144
144
  }
145
+
146
+ @media only screen and (min-width: 30em) {
147
+ .input-wrapper {
148
+ padding: 0 variables.$form-element-horizontal-padding-desktop;
149
+ }
150
+ }
@@ -14,7 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @use "../../mixins.module.scss";
17
+ @use "src/mixins.module";
18
+ @use "src/variables";
18
19
 
19
20
  $listItemHeight: 2.125rem;
20
21
 
@@ -41,7 +42,11 @@ $listItemHeight: 2.125rem;
41
42
  &:not(.expanded) {
42
43
  button:focus:not(.error) {
43
44
  border: var(--input-border-width-focus) solid var(--color-focus);
44
- padding: 0 calc(1.25rem - var(--input-border-width-focus) + var(--input-border-width));
45
+ padding: 0
46
+ calc(
47
+ variables.$form-element-horizontal-padding-mobile - var(--input-border-width-focus) +
48
+ var(--input-border-width)
49
+ );
45
50
  }
46
51
  }
47
52
 
@@ -56,7 +61,7 @@ $listItemHeight: 2.125rem;
56
61
  position: relative;
57
62
  width: 100%;
58
63
  min-height: calc(4rem - (2 * var(--input-border-width)));
59
- padding: 0 1.25rem;
64
+ padding: 0 variables.$form-element-horizontal-padding-mobile;
60
65
  background-color: transparent;
61
66
  border-color: var(--light-grey-border);
62
67
  border-style: var(--input-border-style);
@@ -215,3 +220,21 @@ $listItemHeight: 2.125rem;
215
220
  pointer-events: none;
216
221
  }
217
222
  }
223
+
224
+ @media only screen and (min-width: 30em) {
225
+ .select {
226
+ .custom-select {
227
+ padding: 0 variables.$form-element-horizontal-padding-desktop;
228
+ }
229
+
230
+ &:not(.expanded) {
231
+ button:focus:not(.error) {
232
+ padding: 0
233
+ calc(
234
+ variables.$form-element-horizontal-padding-desktop - var(--input-border-width-focus) +
235
+ var(--input-border-width)
236
+ );
237
+ }
238
+ }
239
+ }
240
+ }