@am92/react-design-system 2.9.12 → 2.10.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/dist/Components/DsBottomSheet/DsBottomSheet.Component.js +6 -6
- package/dist/Components/DsDialog/DsDialog.Component.js +4 -4
- package/dist/Components/DsFileUploader/DsFileUploader.Component.d.ts +2 -3
- package/dist/Components/DsFileUploader/DsFileUploader.Component.js +109 -158
- package/dist/Components/DsFileUploader/DsFileUploader.Overrides.d.ts +5 -1
- package/dist/Components/DsFileUploader/DsFileUploader.Overrides.js +6 -1
- package/dist/Components/DsFileUploader/DsFileUploader.Types.d.ts +306 -13
- package/dist/Components/DsFileUploader/DsFileUploader.Types.js +46 -4
- package/dist/Components/DsFileUploader/DsFileUploaderPreview/DsFileUploaderImagePreview.Component.d.ts +11 -0
- package/dist/Components/DsFileUploader/DsFileUploaderPreview/DsFileUploaderImagePreview.Component.js +68 -0
- package/dist/Components/DsFileUploader/DsFileUploaderPreview/DsFileUploaderPreview.Component.d.ts +14 -0
- package/dist/Components/DsFileUploader/DsFileUploaderPreview/DsFileUploaderPreview.Component.js +28 -0
- package/dist/Components/DsFileUploader/FileUploaderFiles.d.ts +3 -0
- package/dist/Components/DsFileUploader/FileUploaderFiles.js +48 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderActionButton.Component.d.ts +10 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderActionButton.Component.js +18 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderDropZone.d.ts +10 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderDropZone.js +130 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderSelectedFilesSegment.d.ts +10 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderSelectedFilesSegment.js +21 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderUploadedFilesSegment.d.ts +10 -0
- package/dist/Components/DsFileUploader/Slots/DsFileUploaderUploadedFilesSegment.js +21 -0
- package/dist/Components/DsFileUploader/converter.d.ts +2 -0
- package/dist/Components/DsFileUploader/converter.js +25 -0
- package/dist/Components/DsFileUploader/helpers.d.ts +9 -0
- package/dist/Components/DsFileUploader/helpers.js +88 -0
- package/dist/Components/DsFileUploader/validator.d.ts +2 -0
- package/dist/Components/DsFileUploader/validator.js +37 -0
- package/dist/Theme/componentOverrides.d.ts +3 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import { DsDialogContent } from '../DsDialogContent';
|
|
|
9
9
|
import { DsButton } from '../DsButton';
|
|
10
10
|
import { DsDialogActions } from '../DsDialogActions';
|
|
11
11
|
import { DsPaper } from '../DsPaper';
|
|
12
|
-
export const DsBottomSheet = inProps => {
|
|
12
|
+
export const DsBottomSheet = (inProps) => {
|
|
13
13
|
const props = { ...DsBottomSheetDefaultProps, ...inProps };
|
|
14
14
|
const handleDrawerClose = (event, reason) => {
|
|
15
15
|
const { onClose } = props;
|
|
@@ -36,7 +36,7 @@ export const DsBottomSheet = inProps => {
|
|
|
36
36
|
if (kicker) {
|
|
37
37
|
accessibilityProps['aria-describedby'] = kicker;
|
|
38
38
|
}
|
|
39
|
-
return (_jsxs(DsDrawer, { ...accessibilityProps, ...DrawerProps, anchor:
|
|
39
|
+
return (_jsxs(DsDrawer, { ...accessibilityProps, ...DrawerProps, anchor: 'bottom', PaperProps: {
|
|
40
40
|
...PaperProps,
|
|
41
41
|
sx: {
|
|
42
42
|
background: 'transparent',
|
|
@@ -53,7 +53,7 @@ export const DsBottomSheet = inProps => {
|
|
|
53
53
|
p: 'var(--ds-spacing-glacial)',
|
|
54
54
|
mb: 'var(--ds-spacing-bitterCold)',
|
|
55
55
|
...CloseIconButtonProps?.sx
|
|
56
|
-
}, children: _jsx(DsRemixIcon, { className:
|
|
56
|
+
}, children: _jsx(DsRemixIcon, { className: 'ri-close-line', ...CloseIconProps }) })), _jsxs(DsPaper, { ...ContainerProps, sx: {
|
|
57
57
|
minHeight: 0,
|
|
58
58
|
display: 'flex',
|
|
59
59
|
flexDirection: 'column',
|
|
@@ -63,7 +63,7 @@ export const DsBottomSheet = inProps => {
|
|
|
63
63
|
borderTopLeftRadius: 'var(--ds-radius-bitterCold)',
|
|
64
64
|
borderTopRightRadius: 'var(--ds-radius-bitterCold)',
|
|
65
65
|
...ContainerProps?.sx
|
|
66
|
-
}, children: [kicker && (_jsx(DsTypography, { variant:
|
|
66
|
+
}, children: [kicker && (_jsx(DsTypography, { variant: 'subheadingSemiboldDefault', color: 'text.tertiary', ...KickerProps, sx: {
|
|
67
67
|
px: 'var(--ds-spacing-bitterCold)',
|
|
68
68
|
mb: 'var(--ds-spacing-quickFreeze)',
|
|
69
69
|
textTransform: 'uppercase',
|
|
@@ -72,7 +72,7 @@ export const DsBottomSheet = inProps => {
|
|
|
72
72
|
mb: 'var(--ds-spacing-zero)',
|
|
73
73
|
px: 'var(--ds-spacing-bitterCold)',
|
|
74
74
|
...TitleProps?.sx
|
|
75
|
-
}, children: title })), description && (_jsx(DsTypography, { variant:
|
|
75
|
+
}, children: title })), description && (_jsx(DsTypography, { variant: 'bodyRegularMedium', color: 'text.secondary', ...DescriptionProps, sx: {
|
|
76
76
|
px: 'var(--ds-spacing-bitterCold)',
|
|
77
77
|
mt: 'var(--ds-spacing-quickFreeze)',
|
|
78
78
|
...DescriptionProps?.sx
|
|
@@ -85,5 +85,5 @@ export const DsBottomSheet = inProps => {
|
|
|
85
85
|
mt: 'var(--ds-spacing-bitterCold)',
|
|
86
86
|
pt: isFlushed ? undefined : 'var(--ds-spacing-bitterCold)',
|
|
87
87
|
...ActionsProps?.sx
|
|
88
|
-
}, children: [(secondaryButtonText || secondaryButtonProps?.children) && (_jsx(DsButton, { color:
|
|
88
|
+
}, children: [(secondaryButtonText || secondaryButtonProps?.children) && (_jsx(DsButton, { color: 'secondary', size: 'large', fullWidth: true, ...secondaryButtonProps, children: secondaryButtonText || secondaryButtonProps?.children })), (primaryButtonText || primaryButtonProps?.children) && (_jsx(DsButton, { size: 'large', fullWidth: true, ...primaryButtonProps, children: primaryButtonText || primaryButtonProps?.children }))] }))] })] }));
|
|
89
89
|
};
|
|
@@ -44,7 +44,7 @@ export const DsDialog = inProps => {
|
|
|
44
44
|
},
|
|
45
45
|
...PaperProps?.sx
|
|
46
46
|
}
|
|
47
|
-
}, children: [kicker && (_jsx(DsTypography, { variant:
|
|
47
|
+
}, children: [kicker && (_jsx(DsTypography, { variant: 'subheadingSemiboldDefault', color: 'var(--ds-colour-typoTertiary)', ...KickerProps, sx: {
|
|
48
48
|
px: {
|
|
49
49
|
xs: 'var(--ds-spacing-bitterCold)',
|
|
50
50
|
md: 'var(--ds-spacing-warm)'
|
|
@@ -59,7 +59,7 @@ export const DsDialog = inProps => {
|
|
|
59
59
|
md: 'var(--ds-spacing-warm)'
|
|
60
60
|
},
|
|
61
61
|
...TitleProps?.sx
|
|
62
|
-
}, children: title })), description && (_jsx(DsTypography, { variant:
|
|
62
|
+
}, children: title })), description && (_jsx(DsTypography, { variant: 'bodyRegularMedium', color: 'var(--ds-colour-typoSecondary)', ...DescriptionProps, sx: {
|
|
63
63
|
px: {
|
|
64
64
|
xs: 'var(--ds-spacing-bitterCold)',
|
|
65
65
|
md: 'var(--ds-spacing-warm)'
|
|
@@ -78,7 +78,7 @@ export const DsDialog = inProps => {
|
|
|
78
78
|
md: 'var(--ds-spacing-warm)'
|
|
79
79
|
},
|
|
80
80
|
...CloseIconButtonProps?.sx
|
|
81
|
-
}, children: _jsx(DsRemixIcon, { className:
|
|
81
|
+
}, children: _jsx(DsRemixIcon, { className: 'ri-close-line', ...CloseIconProps }) })), children && (_jsx(DsDialogContent, { ...ContentProps, sx: {
|
|
82
82
|
px: {
|
|
83
83
|
xs: 'var(--ds-spacing-bitterCold)',
|
|
84
84
|
md: 'var(--ds-spacing-warm)'
|
|
@@ -100,5 +100,5 @@ export const DsDialog = inProps => {
|
|
|
100
100
|
},
|
|
101
101
|
mt: 'var(--ds-spacing-glacial)',
|
|
102
102
|
...ActionsProps?.sx
|
|
103
|
-
}, children: [(secondaryButtonText || secondaryButtonProps?.children) && (_jsx(DsButton, { color:
|
|
103
|
+
}, children: [(secondaryButtonText || secondaryButtonProps?.children) && (_jsx(DsButton, { color: 'secondary', size: 'medium', fullWidth: true, ...secondaryButtonProps, children: secondaryButtonText || secondaryButtonProps?.children })), (primaryButtonText || primaryButtonProps?.children) && (_jsx(DsButton, { size: 'medium', fullWidth: true, ...primaryButtonProps, children: primaryButtonText || primaryButtonProps?.children }))] }))] }));
|
|
104
104
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const DsFileUploader: FC<DsFileUploaderProps>;
|
|
1
|
+
import type { IDsFileUploaderProps, TContentType, TMultiple } from './DsFileUploader.Types';
|
|
2
|
+
export declare const DsFileUploader: <Multiple extends TMultiple, ContentType extends TContentType>(inProps: IDsFileUploaderProps<Multiple, ContentType>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,182 +1,133 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import {
|
|
3
|
-
import { DsBox } from '../DsBox';
|
|
4
|
-
import { DsButton } from '../DsButton';
|
|
5
|
-
import { DsIconButton } from '../DsIconButton';
|
|
6
|
-
import { DsInput } from '../DsInput';
|
|
7
|
-
import { DsRemixIcon } from '../DsRemixIcon';
|
|
8
|
-
import { DsStack } from '../DsStack';
|
|
9
|
-
import { DsTypography } from '../DsTypography';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
10
3
|
import { DsFileUploaderDefaultProps } from './DsFileUploader.Types';
|
|
4
|
+
import FileUploaderFiles from './FileUploaderFiles';
|
|
5
|
+
import { getDefaultValue, getValidProcessedFile, mergeProps } from './helpers';
|
|
6
|
+
import { DsFileUploaderDropZone } from './Slots/DsFileUploaderDropZone';
|
|
7
|
+
import { DsStack } from '../DsStack';
|
|
8
|
+
import { DsInputLabel } from '../DsInputLabel';
|
|
11
9
|
export const DsFileUploader = (inProps) => {
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
23
|
-
};
|
|
24
|
-
const getFileIconClass = (mimeType) => {
|
|
25
|
-
if (mimeType.includes('image/')) {
|
|
26
|
-
return 'ri-image-2-line';
|
|
10
|
+
// Merge user props with default props, handling nested slots and slotProps gracefully
|
|
11
|
+
const props = mergeProps(inProps, DsFileUploaderDefaultProps);
|
|
12
|
+
const defaultValue = getDefaultValue(props);
|
|
13
|
+
const [files, setFiles] = useState(defaultValue);
|
|
14
|
+
const { InputLabelProps, name, value, uploadedValue, accept = '*', minSize, maxSize, onChange, onError, onDelete, onPreview, onDownload, multiple, slotProps = {}, variant, contentType, canDeleteFile, slots = {} } = props;
|
|
15
|
+
// Effective file type accept string — pulled from DropZone slotProps or `accept`
|
|
16
|
+
const allowedFiles = (slotProps?.DropZone && slotProps?.DropZone.InputProps?.accept) || accept;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (value !== undefined) {
|
|
19
|
+
setFiles(value);
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
}, [value]);
|
|
22
|
+
// Handles selected or dropped files after validation
|
|
23
|
+
const handleFiles = (processedFiles) => {
|
|
24
|
+
const { valid, invalid } = processedFiles;
|
|
25
|
+
// If not controlled, update internal state
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
setFiles(valid);
|
|
30
28
|
}
|
|
31
|
-
return 'ri-file-list-2-line';
|
|
32
|
-
};
|
|
33
|
-
const handleOnClick = (event) => {
|
|
34
|
-
inputRef?.current?.click();
|
|
35
|
-
};
|
|
36
|
-
const handleRemoveFile = (index) => () => {
|
|
37
|
-
const { onChange, name } = props;
|
|
38
|
-
const tempFiles = [...files];
|
|
39
|
-
tempFiles.splice(index, 1);
|
|
40
|
-
setFiles(tempFiles);
|
|
41
29
|
if (onChange && typeof onChange === 'function') {
|
|
42
|
-
onChange(name,
|
|
30
|
+
onChange(name, valid);
|
|
31
|
+
}
|
|
32
|
+
if (invalid !== null) {
|
|
33
|
+
if (invalid && onError && typeof onError === 'function') {
|
|
34
|
+
onError(name, invalid);
|
|
35
|
+
}
|
|
43
36
|
}
|
|
44
37
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const stateFiles = files;
|
|
38
|
+
// Triggered when a user selects files via the input element
|
|
39
|
+
const handleFileSelect = async (event) => {
|
|
48
40
|
const { target } = event;
|
|
49
41
|
const { files: selectedFiles } = target;
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (onChange && typeof onChange === 'function') {
|
|
54
|
-
onChange(name, newFiles);
|
|
42
|
+
if (!multiple && uploadedValue) {
|
|
43
|
+
if (onDelete && typeof onDelete === 'function') {
|
|
44
|
+
onDelete(name, uploadedValue);
|
|
55
45
|
}
|
|
56
46
|
}
|
|
47
|
+
if (selectedFiles) {
|
|
48
|
+
const processedFiles = await getValidProcessedFile(selectedFiles, files ?? null, accept, minSize, maxSize, contentType);
|
|
49
|
+
handleFiles(processedFiles);
|
|
50
|
+
}
|
|
57
51
|
};
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
// Triggered when a user drops files into the drop zone
|
|
53
|
+
const handleDropFile = async (event) => {
|
|
60
54
|
event.preventDefault();
|
|
61
|
-
const {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const items = event.dataTransfer.items
|
|
68
|
-
? [...event.dataTransfer.items]
|
|
69
|
-
: [...event.dataTransfer.files];
|
|
70
|
-
items.forEach(item => {
|
|
71
|
-
let file;
|
|
72
|
-
if (!multiple && files.length) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (item instanceof DataTransferItem) {
|
|
76
|
-
if (item.kind === 'file') {
|
|
77
|
-
file = item.getAsFile();
|
|
55
|
+
const { dataTransfer } = event;
|
|
56
|
+
if (dataTransfer) {
|
|
57
|
+
const { files: selectedFiles } = dataTransfer;
|
|
58
|
+
if (!multiple && uploadedValue) {
|
|
59
|
+
if (onDelete && typeof onDelete === 'function') {
|
|
60
|
+
onDelete(name, uploadedValue);
|
|
78
61
|
}
|
|
79
62
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!file) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const { type } = file;
|
|
87
|
-
const astrerikType = `${type.split('/')[0]}/*`;
|
|
88
|
-
if (accept.includes(type) || accept.includes(astrerikType)) {
|
|
89
|
-
files.push(file);
|
|
63
|
+
if (files) {
|
|
64
|
+
const processedFiles = await getValidProcessedFile(selectedFiles, files ?? null, accept, minSize, maxSize);
|
|
65
|
+
handleFiles(processedFiles);
|
|
90
66
|
}
|
|
91
|
-
});
|
|
92
|
-
const stateFiles = files;
|
|
93
|
-
const newFiles = multiple
|
|
94
|
-
? [...stateFiles, ...files]
|
|
95
|
-
: (files[0] && [files[0]]) || (stateFiles[0] && [stateFiles[0]]) || [];
|
|
96
|
-
setFiles(newFiles);
|
|
97
|
-
if (onChange && typeof onChange === 'function') {
|
|
98
|
-
onChange(name, newFiles);
|
|
99
67
|
}
|
|
100
68
|
};
|
|
101
|
-
|
|
102
|
-
|
|
69
|
+
// Prevent default behavior to allow dropping
|
|
70
|
+
const handleDragOverHandler = event => {
|
|
103
71
|
event.preventDefault();
|
|
104
72
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
73
|
+
// Triggered when a user removes a file
|
|
74
|
+
const handleRemoveFile = async (name, file) => {
|
|
75
|
+
// Async handler for delete operations
|
|
76
|
+
if (canDeleteFile && typeof canDeleteFile === 'function') {
|
|
77
|
+
const canDelete = await canDeleteFile(name, file);
|
|
78
|
+
if (!canDelete)
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (onDelete && typeof onDelete === 'function') {
|
|
82
|
+
onDelete(name, file);
|
|
83
|
+
}
|
|
84
|
+
// Update internal state after deletion
|
|
85
|
+
if (Array.isArray(files)) {
|
|
86
|
+
const newFiles = files.filter(f => f !== file);
|
|
87
|
+
const valid = newFiles;
|
|
88
|
+
const invalid = [];
|
|
89
|
+
handleFiles({
|
|
90
|
+
valid: valid,
|
|
91
|
+
invalid: invalid
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
handleFiles({
|
|
96
|
+
valid: null,
|
|
97
|
+
invalid: null
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
// Preview handler
|
|
102
|
+
const handlePreviewFileAction = (name, file) => {
|
|
103
|
+
if (onPreview && typeof onPreview === 'function') {
|
|
104
|
+
onPreview(name, file);
|
|
108
105
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
borderRadius: 'var(--ds-radius-glacial)',
|
|
115
|
-
borderWidth: '1px',
|
|
116
|
-
borderStyle: 'solid',
|
|
117
|
-
borderColor: 'var(--ds-colour-strokeDefault)',
|
|
118
|
-
backgroundColor: 'var(--ds-colour-surfacePrimary)',
|
|
119
|
-
cursor: 'pointer',
|
|
120
|
-
'&:hover': {
|
|
121
|
-
borderColor: 'var(--ds-colour-strokeSecondarySelected)',
|
|
122
|
-
backgroundColor: 'var(--ds-colour-stateSelectedSecondaryHover)'
|
|
123
|
-
}
|
|
124
|
-
}, children: [_jsx(DsRemixIcon, { sx: {
|
|
125
|
-
p: 'var(--ds-spacing-quickFreeze)',
|
|
126
|
-
borderRadius: 'var(--ds-radius-quickFreeze)',
|
|
127
|
-
backgroundColor: 'var(--ds-colour-neutral2)',
|
|
128
|
-
color: 'var(--ds-colour-actionTertiary)'
|
|
129
|
-
}, className: getFileIconClass(file.type) }), _jsxs(DsBox, { sx: {
|
|
130
|
-
display: 'flex',
|
|
131
|
-
flexGrow: 1,
|
|
132
|
-
minWidth: 0,
|
|
133
|
-
flexDirection: 'column'
|
|
134
|
-
}, children: [_jsx(DsTypography, { component: "div", variant: "subheadingSemiboldDefault", noWrap: true, children: file.name }), _jsx(DsTypography, { component: "div", variant: "bodyRegularSmall", noWrap: true, sx: {
|
|
135
|
-
color: 'var(--ds-colour-typoTertiary)'
|
|
136
|
-
}, children: humaniseSize(file.size) })] }), _jsx(DsIconButton, { onClick: handleRemoveFile(index), children: _jsx(DsRemixIcon, { className: "ri-close-line" }) })] }, `${file.name}-${index}`));
|
|
106
|
+
};
|
|
107
|
+
// Download handler
|
|
108
|
+
const handleDownloadFileAction = (name, file) => {
|
|
109
|
+
if (onDownload && typeof onDownload === 'function') {
|
|
110
|
+
onDownload(name, file);
|
|
137
111
|
}
|
|
138
|
-
return (_jsx(DsStack, { sx: {
|
|
139
|
-
mt: 'var(--ds-spacing-warm)',
|
|
140
|
-
width: '100%'
|
|
141
|
-
}, spacing: "var(--ds-spacing-glacial)", direction: "column", children: Files }));
|
|
142
112
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
top: 0,
|
|
164
|
-
left: 0,
|
|
165
|
-
height: '100%',
|
|
166
|
-
width: '100%',
|
|
167
|
-
opacity: 0,
|
|
168
|
-
cursor: 'pointer',
|
|
169
|
-
margin: 'var(--ds-spacing-zero) !important'
|
|
170
|
-
}, onChange: handleChange, onDrop: handleDrop, onDragOver: handleDragOverHandler, disableUnderline: true, inputProps: {
|
|
171
|
-
title: titleButtonText,
|
|
172
|
-
ref: inputRef,
|
|
173
|
-
value: '',
|
|
174
|
-
...InputProps,
|
|
175
|
-
style: {
|
|
176
|
-
height: '100%',
|
|
177
|
-
width: '100%',
|
|
178
|
-
cursor: 'pointer',
|
|
179
|
-
...InputProps?.style
|
|
180
|
-
}
|
|
181
|
-
} })] }), renderFiles()] }));
|
|
113
|
+
// Visibility conditions for selected and uploaded sections
|
|
114
|
+
const isSelectedSegmentVisible = multiple
|
|
115
|
+
? Array.isArray(files) && files.length > 0
|
|
116
|
+
: files;
|
|
117
|
+
const isUploadedSegmentVisible = multiple
|
|
118
|
+
? Array.isArray(uploadedValue) && uploadedValue.length > 0
|
|
119
|
+
: uploadedValue;
|
|
120
|
+
const { SelectedItemSegment, UploadedItemSegment } = slots;
|
|
121
|
+
return (_jsxs(DsStack, { direction: "column", sx: {
|
|
122
|
+
gap: 'var(--ds-spacing-bitterCold)',
|
|
123
|
+
width: '100%',
|
|
124
|
+
p: 'var(--ds-spacing-bitterCold)'
|
|
125
|
+
}, children: [_jsx(DsInputLabel, { sx: { mb: 'var(--ds-spacing-zero)', ...InputLabelProps?.sx }, ...InputLabelProps }), _jsx(DsFileUploaderDropZone, { variant: variant, ...slotProps?.DropZone, InputProps: {
|
|
126
|
+
accept: allowedFiles || accept,
|
|
127
|
+
multiple: multiple,
|
|
128
|
+
onChange: handleFileSelect,
|
|
129
|
+
onDrop: handleDropFile,
|
|
130
|
+
onDragOver: handleDragOverHandler,
|
|
131
|
+
...slotProps?.DropZone?.InputProps
|
|
132
|
+
} }), isSelectedSegmentVisible && SelectedItemSegment && (_jsx(SelectedItemSegment, { onPreview: handlePreviewFileAction, onDownload: handleDownloadFileAction, onDelete: handleRemoveFile, ...slotProps?.SelectedItemSegment, children: _jsx(FileUploaderFiles, { slots: slots, slotProps: slotProps, files: files || undefined }) })), isUploadedSegmentVisible && UploadedItemSegment && (_jsx(UploadedItemSegment, { onPreview: handlePreviewFileAction, onDownload: handleDownloadFileAction, onDelete: handleRemoveFile, ...slotProps?.UploadedItemSegment, children: _jsx(FileUploaderFiles, { slots: slots, slotProps: slotProps, files: uploadedValue || undefined }) }))] }));
|
|
182
133
|
};
|