@synerise/ds-file-uploader 1.3.9 → 1.3.11
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/CHANGELOG.md +8 -0
- package/dist/AvatarUploader/AvatarUploader.d.ts +7 -8
- package/dist/AvatarUploader/AvatarUploader.js +78 -124
- package/dist/AvatarUploader/AvatarUploader.styles.d.ts +26 -27
- package/dist/AvatarUploader/AvatarUploader.styles.js +54 -70
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.const.d.ts +1 -2
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.const.js +14 -10
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.d.ts +2 -3
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.js +49 -90
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.styles.d.ts +16 -17
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.styles.js +69 -91
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.types.d.ts +2 -3
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.types.js +1 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.util.d.ts +1 -2
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.util.js +6 -3
- package/dist/FileUploader.d.ts +6 -7
- package/dist/FileUploader.js +91 -146
- package/dist/FileUploader.styles.d.ts +26 -27
- package/dist/FileUploader.styles.js +58 -78
- package/dist/FileUploader.types.d.ts +2 -3
- package/dist/FileUploader.types.js +1 -1
- package/dist/FileView/FileView.const.d.ts +1 -2
- package/dist/FileView/FileView.const.js +24 -19
- package/dist/FileView/FileView.d.ts +2 -3
- package/dist/FileView/FileView.js +72 -138
- package/dist/FileView/FileView.styles.d.ts +17 -18
- package/dist/FileView/FileView.styles.js +65 -83
- package/dist/FileView/FileView.types.d.ts +2 -3
- package/dist/FileView/FileView.types.js +1 -1
- package/dist/ItemUploader/ItemUploader.d.ts +3 -4
- package/dist/ItemUploader/ItemUploader.js +73 -104
- package/dist/ItemUploader/ItemUploader.styles.d.ts +26 -27
- package/dist/ItemUploader/ItemUploader.styles.js +53 -71
- package/dist/ItemUploader/ItemUploader.types.d.ts +0 -1
- package/dist/ItemUploader/ItemUploader.types.js +1 -1
- package/dist/ItemUploader/UploaderButton/FileViewItem.const.d.ts +0 -1
- package/dist/ItemUploader/UploaderButton/FileViewItem.const.js +16 -11
- package/dist/ItemUploader/UploaderButton/FileViewItem.d.ts +2 -3
- package/dist/ItemUploader/UploaderButton/FileViewItem.js +38 -67
- package/dist/ItemUploader/UploaderButton/FileViewItem.styles.d.ts +12 -13
- package/dist/ItemUploader/UploaderButton/FileViewItem.styles.js +55 -74
- package/dist/index.d.ts +0 -1
- package/dist/index.js +19 -13
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +12 -12
- package/dist/AvatarUploader/AvatarUploader.d.ts.map +0 -1
- package/dist/AvatarUploader/AvatarUploader.styles.d.ts.map +0 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.const.d.ts.map +0 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.d.ts.map +0 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.styles.d.ts.map +0 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.types.d.ts.map +0 -1
- package/dist/AvatarUploader/FileViewAvatar/FileViewAvatar.util.d.ts.map +0 -1
- package/dist/FileUploader.d.ts.map +0 -1
- package/dist/FileUploader.styles.d.ts.map +0 -1
- package/dist/FileUploader.types.d.ts.map +0 -1
- package/dist/FileView/FileView.const.d.ts.map +0 -1
- package/dist/FileView/FileView.d.ts.map +0 -1
- package/dist/FileView/FileView.styles.d.ts.map +0 -1
- package/dist/FileView/FileView.types.d.ts.map +0 -1
- package/dist/ItemUploader/ItemUploader.d.ts.map +0 -1
- package/dist/ItemUploader/ItemUploader.styles.d.ts.map +0 -1
- package/dist/ItemUploader/ItemUploader.types.d.ts.map +0 -1
- package/dist/ItemUploader/UploaderButton/FileViewItem.const.d.ts.map +0 -1
- package/dist/ItemUploader/UploaderButton/FileViewItem.d.ts.map +0 -1
- package/dist/ItemUploader/UploaderButton/FileViewItem.styles.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/dist/FileUploader.js
CHANGED
|
@@ -1,71 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import * as S from './FileUploader.styles';
|
|
11
|
-
import FileView from './FileView/FileView';
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useCallback, useImperativeHandle } from "react";
|
|
3
|
+
import { useDropzone } from "react-dropzone";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import { useTheme } from "@synerise/ds-core";
|
|
6
|
+
import Icon, { InfoFillS, FileUploadL, AddM } from "@synerise/ds-icon";
|
|
7
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
8
|
+
import { Container, Label, DropAreaContainer, DropAreaButton, LargeDropAreaLabel, LargeDropAreaDescription, DropAreaLabel, ErrorMessage, Description } from "./FileUploader.styles.js";
|
|
9
|
+
import FileView from "./FileView/FileView.js";
|
|
12
10
|
function readAsText(file) {
|
|
13
|
-
return new Promise(
|
|
14
|
-
|
|
15
|
-
file.type !==
|
|
16
|
-
reader.onerror =
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
reader.onload = function () {
|
|
20
|
-
return resolve(reader.result);
|
|
21
|
-
};
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const reader = new FileReader();
|
|
13
|
+
file.type !== "text/plain" && resolve(null);
|
|
14
|
+
reader.onerror = () => resolve(null);
|
|
15
|
+
reader.onload = () => resolve(reader.result);
|
|
22
16
|
reader.readAsText(file);
|
|
23
17
|
});
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
buttonLabelLarge: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
55
|
-
id: "DS.FILE-UPLOADER.BUTTON-LABEL-LARGE",
|
|
56
|
-
defaultMessage: "Upload file"
|
|
57
|
-
}),
|
|
58
|
-
buttonDescription: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
59
|
-
id: "DS.FILE-UPLOADER.BUTTON-DESC",
|
|
60
|
-
defaultMessage: "Description"
|
|
61
|
-
})
|
|
62
|
-
}, texts);
|
|
63
|
-
var readFilesContent = useCallback(function (addedFiles) {
|
|
64
|
-
var readerPromises = addedFiles.map(function (file) {
|
|
19
|
+
const FileUploader = forwardRef(({
|
|
20
|
+
className,
|
|
21
|
+
onUpload,
|
|
22
|
+
disabled,
|
|
23
|
+
accept,
|
|
24
|
+
error,
|
|
25
|
+
label,
|
|
26
|
+
onRemove,
|
|
27
|
+
description,
|
|
28
|
+
tooltip,
|
|
29
|
+
filesAmount,
|
|
30
|
+
mode = "single",
|
|
31
|
+
removable = true,
|
|
32
|
+
files = [],
|
|
33
|
+
retry,
|
|
34
|
+
texts,
|
|
35
|
+
...rest
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const [uploadSuccess, setUploadSuccess] = useState(true);
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
const finalTexts = {
|
|
40
|
+
buttonLabel: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.FILE-UPLOADER.BUTTON-LABEL", defaultMessage: "Upload file" }),
|
|
41
|
+
buttonLabelLarge: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.FILE-UPLOADER.BUTTON-LABEL-LARGE", defaultMessage: "Upload file" }),
|
|
42
|
+
buttonDescription: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.FILE-UPLOADER.BUTTON-DESC", defaultMessage: "Description" }),
|
|
43
|
+
...texts
|
|
44
|
+
};
|
|
45
|
+
const readFilesContent = useCallback((addedFiles) => {
|
|
46
|
+
const readerPromises = addedFiles.map((file) => {
|
|
65
47
|
return readAsText(file);
|
|
66
48
|
});
|
|
67
|
-
Promise.all(readerPromises).then(
|
|
68
|
-
|
|
49
|
+
Promise.all(readerPromises).then((filesContent) => {
|
|
50
|
+
const filesWithContent = addedFiles.map((file, index) => {
|
|
69
51
|
return Object.assign(file, {
|
|
70
52
|
content: filesContent[index]
|
|
71
53
|
});
|
|
@@ -73,8 +55,8 @@ var FileUploader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
73
55
|
onUpload && onUpload(filesWithContent);
|
|
74
56
|
});
|
|
75
57
|
}, [onUpload]);
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
const onDrop = useCallback((acceptedFiles) => {
|
|
59
|
+
let possibleUpload = 0;
|
|
78
60
|
if (filesAmount) {
|
|
79
61
|
possibleUpload = filesAmount - files.length;
|
|
80
62
|
}
|
|
@@ -85,91 +67,54 @@ var FileUploader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
85
67
|
readFilesContent(acceptedFiles);
|
|
86
68
|
}
|
|
87
69
|
}, [filesAmount, files, setUploadSuccess, readFilesContent]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
useImperativeHandle(ref, function () {
|
|
101
|
-
return {
|
|
102
|
-
open: open,
|
|
103
|
-
inputRef: inputRef,
|
|
104
|
-
rootRef: rootRef
|
|
105
|
-
};
|
|
70
|
+
const {
|
|
71
|
+
getRootProps,
|
|
72
|
+
getInputProps,
|
|
73
|
+
isDragActive,
|
|
74
|
+
open,
|
|
75
|
+
inputRef,
|
|
76
|
+
rootRef
|
|
77
|
+
} = useDropzone({
|
|
78
|
+
accept: accept ? accept.join(",") : void 0,
|
|
79
|
+
multiple: mode !== "single",
|
|
80
|
+
onDrop,
|
|
81
|
+
disabled
|
|
106
82
|
});
|
|
83
|
+
useImperativeHandle(ref, () => ({
|
|
84
|
+
open,
|
|
85
|
+
inputRef,
|
|
86
|
+
rootRef
|
|
87
|
+
}));
|
|
107
88
|
if (filesAmount && filesAmount < 1) {
|
|
108
89
|
filesAmount = 1;
|
|
109
90
|
throw new Error('Invalid value of property "filesAmount" ');
|
|
110
91
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
isDropping: isDragActive,
|
|
137
|
-
hasError: hasError,
|
|
138
|
-
onMouseDown: function onMouseDown() {
|
|
139
|
-
return setPressed(true);
|
|
140
|
-
},
|
|
141
|
-
onMouseUp: function onMouseUp() {
|
|
142
|
-
return setPressed(false);
|
|
143
|
-
},
|
|
144
|
-
pressed: pressed,
|
|
145
|
-
"data-testid": "droparea",
|
|
146
|
-
filesLength: files.length
|
|
147
|
-
}, mode === 'multi-large' && files.length === 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Icon, {
|
|
148
|
-
color: theme.palette['grey-800'],
|
|
149
|
-
component: /*#__PURE__*/React.createElement(FileUploadL, null),
|
|
150
|
-
size: 48
|
|
151
|
-
}), /*#__PURE__*/React.createElement(S.LargeDropAreaLabel, null, finalTexts.buttonLabelLarge), /*#__PURE__*/React.createElement(S.LargeDropAreaDescription, null, finalTexts.buttonDescription)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Icon, {
|
|
152
|
-
color: theme.palette['grey-600'],
|
|
153
|
-
component: /*#__PURE__*/React.createElement(AddM, null),
|
|
154
|
-
size: 24
|
|
155
|
-
}), /*#__PURE__*/React.createElement(S.DropAreaLabel, null, finalTexts.buttonLabel))))), files.length > 0 && files.map(function (file, index) {
|
|
156
|
-
return /*#__PURE__*/React.createElement(FileView, {
|
|
157
|
-
key: index,
|
|
158
|
-
texts: texts,
|
|
159
|
-
removable: removable,
|
|
160
|
-
onRemove: function onRemove() {
|
|
161
|
-
return _onRemove && _onRemove(file.file, index);
|
|
162
|
-
},
|
|
163
|
-
data: file,
|
|
164
|
-
retry: retry,
|
|
165
|
-
retryButtonProps: _extends({}, getRootProps())
|
|
166
|
-
});
|
|
167
|
-
}), hasError && errors && errors.map(function (errorText, index) {
|
|
168
|
-
return /*#__PURE__*/React.createElement(S.ErrorMessage, {
|
|
169
|
-
key: index
|
|
170
|
-
}, errorText);
|
|
171
|
-
}), description && /*#__PURE__*/React.createElement(S.Description, {
|
|
172
|
-
hasError: hasError
|
|
173
|
-
}, description));
|
|
92
|
+
const hasError = Boolean(error) || !uploadSuccess;
|
|
93
|
+
const [pressed, setPressed] = useState(false);
|
|
94
|
+
const errors = hasError && !uploadSuccess ? [error].concat("To many files uploaded") : [error];
|
|
95
|
+
return /* @__PURE__ */ jsxs(Container, { className: `ds-file-uploader ${className || ""}`, ...rest, children: [
|
|
96
|
+
label && /* @__PURE__ */ jsxs(Label, { children: [
|
|
97
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
98
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { trigger: "hover", placement: "top", title: tooltip, children: /* @__PURE__ */ jsx("span", { "data-testid": "tooltip-info", children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(InfoFillS, {}), size: 24 }) }) })
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropAreaContainer, { ...getRootProps(), canUploadMore: mode !== "single" && files.length > 0, children: [
|
|
101
|
+
/* @__PURE__ */ jsx("input", { ...getInputProps(), "data-testid": "droparea-input" }),
|
|
102
|
+
/* @__PURE__ */ jsx(DropAreaButton, { type: "button", hidden: !(mode !== "single" && (filesAmount ? files.length < filesAmount : true) || files.length === 0), mode, disabled, isDropping: isDragActive, hasError, onMouseDown: () => setPressed(true), onMouseUp: () => setPressed(false), pressed, "data-testid": "droparea", filesLength: files.length, children: mode === "multi-large" && files.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
/* @__PURE__ */ jsx(Icon, { color: theme.palette["grey-800"], component: /* @__PURE__ */ jsx(FileUploadL, {}), size: 48 }),
|
|
104
|
+
/* @__PURE__ */ jsx(LargeDropAreaLabel, { children: finalTexts.buttonLabelLarge }),
|
|
105
|
+
/* @__PURE__ */ jsx(LargeDropAreaDescription, { children: finalTexts.buttonDescription })
|
|
106
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
107
|
+
/* @__PURE__ */ jsx(Icon, { color: theme.palette["grey-600"], component: /* @__PURE__ */ jsx(AddM, {}), size: 24 }),
|
|
108
|
+
/* @__PURE__ */ jsx(DropAreaLabel, { children: finalTexts.buttonLabel })
|
|
109
|
+
] }) })
|
|
110
|
+
] }) }),
|
|
111
|
+
files.length > 0 && files.map((file, index) => /* @__PURE__ */ jsx(FileView, { texts, removable, onRemove: () => onRemove && onRemove(file.file, index), data: file, retry, retryButtonProps: {
|
|
112
|
+
...getRootProps()
|
|
113
|
+
} }, index)),
|
|
114
|
+
hasError && errors && errors.map((errorText, index) => /* @__PURE__ */ jsx(ErrorMessage, { children: errorText }, index)),
|
|
115
|
+
description && /* @__PURE__ */ jsx(Description, { hasError, children: description })
|
|
116
|
+
] });
|
|
174
117
|
});
|
|
175
|
-
export
|
|
118
|
+
export {
|
|
119
|
+
FileUploader as default
|
|
120
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Container: import(
|
|
3
|
-
export declare const Description: import(
|
|
4
|
-
size?: import(
|
|
5
|
-
ellipsis?: import(
|
|
6
|
-
children?: import(
|
|
1
|
+
import { StyledButton } from '@synerise/ds-button';
|
|
2
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const Description: import('styled-components').StyledComponent<({ size, className, children, ellipsis, style, }: {
|
|
4
|
+
size?: import('@synerise/ds-typography').TextSize;
|
|
5
|
+
ellipsis?: import('@synerise/ds-typography/dist/Ellipsis').EllipsisProps;
|
|
6
|
+
children?: import('react').ReactNode;
|
|
7
7
|
className?: string;
|
|
8
|
-
style?: import(
|
|
8
|
+
style?: import('react').CSSProperties;
|
|
9
9
|
}) => React.JSX.Element, any, {
|
|
10
10
|
hasError?: boolean;
|
|
11
11
|
}, never>;
|
|
12
|
-
export declare const DropAreaContainer: import(
|
|
12
|
+
export declare const DropAreaContainer: import('styled-components').StyledComponent<"div", any, {
|
|
13
13
|
canUploadMore: boolean;
|
|
14
14
|
}, never>;
|
|
15
|
-
export declare const DropAreaLabel: import(
|
|
16
|
-
size?: import(
|
|
17
|
-
ellipsis?: import(
|
|
18
|
-
children?: import(
|
|
15
|
+
export declare const DropAreaLabel: import('styled-components').StyledComponent<({ size, className, children, ellipsis, style, }: {
|
|
16
|
+
size?: import('@synerise/ds-typography').TextSize;
|
|
17
|
+
ellipsis?: import('@synerise/ds-typography/dist/Ellipsis').EllipsisProps;
|
|
18
|
+
children?: import('react').ReactNode;
|
|
19
19
|
className?: string;
|
|
20
|
-
style?: import(
|
|
20
|
+
style?: import('react').CSSProperties;
|
|
21
21
|
}) => React.JSX.Element, any, {}, never>;
|
|
22
|
-
export declare const LargeDropAreaLabel: import(
|
|
23
|
-
export declare const LargeDropAreaDescription: import(
|
|
24
|
-
size?: import(
|
|
25
|
-
ellipsis?: import(
|
|
26
|
-
children?: import(
|
|
22
|
+
export declare const LargeDropAreaLabel: import('styled-components').StyledComponent<"label", any, {}, never>;
|
|
23
|
+
export declare const LargeDropAreaDescription: import('styled-components').StyledComponent<({ size, className, children, ellipsis, style, }: {
|
|
24
|
+
size?: import('@synerise/ds-typography').TextSize;
|
|
25
|
+
ellipsis?: import('@synerise/ds-typography/dist/Ellipsis').EllipsisProps;
|
|
26
|
+
children?: import('react').ReactNode;
|
|
27
27
|
className?: string;
|
|
28
|
-
style?: import(
|
|
28
|
+
style?: import('react').CSSProperties;
|
|
29
29
|
}) => React.JSX.Element, any, {}, never>;
|
|
30
|
-
export declare const DropAreaButton: import(
|
|
30
|
+
export declare const DropAreaButton: import('styled-components').StyledComponent<"button", any, {
|
|
31
31
|
isDropping?: boolean;
|
|
32
32
|
hasError?: boolean;
|
|
33
33
|
mode: string;
|
|
@@ -35,13 +35,12 @@ export declare const DropAreaButton: import("styled-components").StyledComponent
|
|
|
35
35
|
filesLength: number;
|
|
36
36
|
hidden: boolean;
|
|
37
37
|
}, never>;
|
|
38
|
-
export declare const ErrorMessage: import(
|
|
39
|
-
size?: import(
|
|
40
|
-
ellipsis?: import(
|
|
41
|
-
children?: import(
|
|
38
|
+
export declare const ErrorMessage: import('styled-components').StyledComponent<({ size, className, children, ellipsis, style, }: {
|
|
39
|
+
size?: import('@synerise/ds-typography').TextSize;
|
|
40
|
+
ellipsis?: import('@synerise/ds-typography/dist/Ellipsis').EllipsisProps;
|
|
41
|
+
children?: import('react').ReactNode;
|
|
42
42
|
className?: string;
|
|
43
|
-
style?: import(
|
|
43
|
+
style?: import('react').CSSProperties;
|
|
44
44
|
}) => React.JSX.Element, any, {}, never>;
|
|
45
|
-
export declare const Label: import(
|
|
45
|
+
export declare const Label: import('styled-components').StyledComponent<"label", any, {}, never>;
|
|
46
46
|
export declare const UploadButton: StyledButton;
|
|
47
|
-
//# sourceMappingURL=FileUploader.styles.d.ts.map
|
|
@@ -1,99 +1,79 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import Button from
|
|
3
|
-
import { IconContainer } from
|
|
4
|
-
import {
|
|
5
|
-
import { hexToRgba } from
|
|
6
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import { IconContainer } from "@synerise/ds-icon";
|
|
4
|
+
import { Label as Label$1, Text } from "@synerise/ds-typography";
|
|
5
|
+
import { hexToRgba } from "@synerise/ds-utils";
|
|
6
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
7
7
|
displayName: "FileUploaderstyles__Container",
|
|
8
8
|
componentId: "sc-62r2x6-0"
|
|
9
9
|
})(["width:100%;"]);
|
|
10
|
-
|
|
10
|
+
const Description = /* @__PURE__ */ styled(Text).withConfig({
|
|
11
11
|
displayName: "FileUploaderstyles__Description",
|
|
12
12
|
componentId: "sc-62r2x6-1"
|
|
13
|
-
})(["&&{margin:", ";display:block;color:", ";}"],
|
|
14
|
-
|
|
15
|
-
}, function (props) {
|
|
16
|
-
return props.theme.palette['grey-500'];
|
|
17
|
-
});
|
|
18
|
-
export var DropAreaContainer = styled.div.withConfig({
|
|
13
|
+
})(["&&{margin:", ";display:block;color:", ";}"], (props) => props.hasError ? "4px 0 8px" : "8px 0 8px", (props) => props.theme.palette["grey-500"]);
|
|
14
|
+
const DropAreaContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
19
15
|
displayName: "FileUploaderstyles__DropAreaContainer",
|
|
20
16
|
componentId: "sc-62r2x6-2"
|
|
21
|
-
})(["width:100%;margin:", ";"],
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
export var DropAreaLabel = styled(Text).withConfig({
|
|
17
|
+
})(["width:100%;margin:", ";"], (props) => props.canUploadMore ? "12px 0 8px" : "0");
|
|
18
|
+
const DropAreaLabel = /* @__PURE__ */ styled(Text).withConfig({
|
|
25
19
|
displayName: "FileUploaderstyles__DropAreaLabel",
|
|
26
20
|
componentId: "sc-62r2x6-3"
|
|
27
|
-
})(["&&{color:", ";font-weight:500;}"],
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
export var LargeDropAreaLabel = styled(TypographyLabel).withConfig({
|
|
21
|
+
})(["&&{color:", ";font-weight:500;}"], (props) => props.theme.palette["grey-600"]);
|
|
22
|
+
const LargeDropAreaLabel = /* @__PURE__ */ styled(Label$1).withConfig({
|
|
31
23
|
displayName: "FileUploaderstyles__LargeDropAreaLabel",
|
|
32
24
|
componentId: "sc-62r2x6-4"
|
|
33
|
-
})(["&&{font-size:14px;margin:4px 0 0;display:block;color:", ";}"],
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
export var LargeDropAreaDescription = styled(Text).withConfig({
|
|
25
|
+
})(["&&{font-size:14px;margin:4px 0 0;display:block;color:", ";}"], (props) => props.theme.palette["grey-800"]);
|
|
26
|
+
const LargeDropAreaDescription = /* @__PURE__ */ styled(Text).withConfig({
|
|
37
27
|
displayName: "FileUploaderstyles__LargeDropAreaDescription",
|
|
38
28
|
componentId: "sc-62r2x6-5"
|
|
39
|
-
})(["&&{margin:4px 0 0;display:block;color:", ";}"],
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
export var DropAreaButton = styled.button.withConfig({
|
|
29
|
+
})(["&&{margin:4px 0 0;display:block;color:", ";}"], (props) => props.theme.palette["grey-600"]);
|
|
30
|
+
const DropAreaButton = /* @__PURE__ */ styled.button.withConfig({
|
|
43
31
|
displayName: "FileUploaderstyles__DropAreaButton",
|
|
44
32
|
componentId: "sc-62r2x6-6"
|
|
45
|
-
})(["display:", ";align-items:center;border:1px dashed ", ";padding:11px 12px;border-radius:3px;cursor:pointer;background-color:transparent;width:100%;height:48px;transition:height 0.03s;", ";", ";", "{color:", ";}", " ", " &:hover:not(:disabled){background-color:", ";border-color:", ";", ",", "{color:", ";}", "{color:", ";}}&:disabled{background-color:", ";", "{color:", ";}}&&:active{color:", ";border-color:", ";background-color:", ";}&:focus:not(:active):not(:disabled){border-color:", ";background-color:", ";}&:disabled{span,", "{opacity:0.4;}}", ""],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, LargeDropAreaLabel, function (props) {
|
|
70
|
-
return props.theme.palette['grey-400'];
|
|
71
|
-
}, function (props) {
|
|
72
|
-
return props.theme.palette['red-400'];
|
|
73
|
-
}, function (props) {
|
|
74
|
-
return props.theme.palette['grey-400'];
|
|
75
|
-
}, function (props) {
|
|
76
|
-
return props.theme.palette['grey-050'];
|
|
77
|
-
}, function (props) {
|
|
78
|
-
return props.theme.palette['blue-600'];
|
|
79
|
-
}, function (props) {
|
|
80
|
-
return props.theme.palette['blue-050'];
|
|
81
|
-
}, IconContainer, function (props) {
|
|
82
|
-
return props.isDropping && !props.disabled && "\n height: " + (props.mode === 'multi-large' && props.filesLength === 0 ? '160px' : 'auto') + ";\n background-color: " + props.theme.palette['blue-050'] + " !important;\n border-color: " + props.theme.palette['blue-300'] + " !important;\n\n span, " + DropAreaLabel + ", " + LargeDropAreaLabel + ", " + LargeDropAreaDescription + " {\n color: " + props.theme.palette['blue-500'] + " !important;\n }\n\n " + IconContainer + " {\n color: " + props.theme.palette['blue-500'] + " !important;\n }\n ";
|
|
83
|
-
});
|
|
84
|
-
export var ErrorMessage = styled(Text).withConfig({
|
|
33
|
+
})(["display:", ";align-items:center;border:1px dashed ", ";padding:11px 12px;border-radius:3px;cursor:pointer;background-color:transparent;width:100%;height:48px;transition:height 0.03s;", ";", ";", "{color:", ";}", " ", " &:hover:not(:disabled){background-color:", ";border-color:", ";", ",", "{color:", ";}", "{color:", ";}}&:disabled{background-color:", ";", "{color:", ";}}&&:active{color:", ";border-color:", ";background-color:", ";}&:focus:not(:active):not(:disabled){border-color:", ";background-color:", ";}&:disabled{span,", "{opacity:0.4;}}", ""], (props) => props.hidden ? "none" : "flex", (props) => props.theme.palette["grey-400"], (props) => props.mode === "multi-large" && props.filesLength === 0 && `
|
|
34
|
+
height: 160px;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
text-align: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
`, (props) => props.mode !== "multi-large" && `
|
|
39
|
+
gap: 12px;
|
|
40
|
+
`, IconContainer, (props) => props.theme.palette["grey-700"], (props) => props.hasError && `
|
|
41
|
+
background-color: ${props.theme.palette["red-050"]};
|
|
42
|
+
border-color: ${props.theme.palette["red-600"]};
|
|
43
|
+
`, (props) => props.pressed && !props.disabled && css(["&&&:active,&&&{background-color:", ";}"], hexToRgba(props.theme.palette["grey-200"], 0.4)), (props) => hexToRgba(props.theme.palette["grey-200"], 0.2), (props) => props.theme.palette["grey-400"], DropAreaLabel, LargeDropAreaLabel, (props) => props.theme.palette["grey-700"], IconContainer, (props) => props.theme.palette["grey-700"], (props) => props.theme.palette["grey-050"], LargeDropAreaLabel, (props) => props.theme.palette["grey-400"], (props) => props.theme.palette["red-400"], (props) => props.theme.palette["grey-400"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-050"], IconContainer, (props) => props.isDropping && !props.disabled && `
|
|
44
|
+
height: ${props.mode === "multi-large" && props.filesLength === 0 ? "160px" : "auto"};
|
|
45
|
+
background-color: ${props.theme.palette["blue-050"]} !important;
|
|
46
|
+
border-color: ${props.theme.palette["blue-300"]} !important;
|
|
47
|
+
|
|
48
|
+
span, ${DropAreaLabel}, ${LargeDropAreaLabel}, ${LargeDropAreaDescription} {
|
|
49
|
+
color: ${props.theme.palette["blue-500"]} !important;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
${IconContainer} {
|
|
53
|
+
color: ${props.theme.palette["blue-500"]} !important;
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
56
|
+
const ErrorMessage = /* @__PURE__ */ styled(Text).withConfig({
|
|
85
57
|
displayName: "FileUploaderstyles__ErrorMessage",
|
|
86
58
|
componentId: "sc-62r2x6-7"
|
|
87
|
-
})(["&&{margin:8px 0 0;display:block;color:", ";}"],
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
export var Label = styled(TypographyLabel).withConfig({
|
|
59
|
+
})(["&&{margin:8px 0 0;display:block;color:", ";}"], (props) => props.theme.palette["red-600"]);
|
|
60
|
+
const Label = /* @__PURE__ */ styled(Label$1).withConfig({
|
|
91
61
|
displayName: "FileUploaderstyles__Label",
|
|
92
62
|
componentId: "sc-62r2x6-8"
|
|
93
|
-
})(["&&{cursor:initial;margin:0 0 8px;display:flex;align-items:center;", "{color:", ";}}"], IconContainer,
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
export var UploadButton = styled(Button).withConfig({
|
|
63
|
+
})(["&&{cursor:initial;margin:0 0 8px;display:flex;align-items:center;", "{color:", ";}}"], IconContainer, (props) => props.theme.palette["grey-400"]);
|
|
64
|
+
const UploadButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
97
65
|
displayName: "FileUploaderstyles__UploadButton",
|
|
98
66
|
componentId: "sc-62r2x6-9"
|
|
99
|
-
})([""]);
|
|
67
|
+
})([""]);
|
|
68
|
+
export {
|
|
69
|
+
Container,
|
|
70
|
+
Description,
|
|
71
|
+
DropAreaButton,
|
|
72
|
+
DropAreaContainer,
|
|
73
|
+
DropAreaLabel,
|
|
74
|
+
ErrorMessage,
|
|
75
|
+
Label,
|
|
76
|
+
LargeDropAreaDescription,
|
|
77
|
+
LargeDropAreaLabel,
|
|
78
|
+
UploadButton
|
|
79
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
3
3
|
export type FileViewTexts = {
|
|
4
4
|
size?: ReactNode;
|
|
5
5
|
cancelText?: ReactNode;
|
|
@@ -55,4 +55,3 @@ export type FileUploaderRef = {
|
|
|
55
55
|
rootRef: RefObject<HTMLElement>;
|
|
56
56
|
};
|
|
57
57
|
export {};
|
|
58
|
-
//# sourceMappingURL=FileUploader.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
export declare const isPreviewableMimeType: (type: string) => type is FileType;
|
|
3
3
|
type FileType = 'image/png' | 'image/gif' | 'image/jpeg' | 'image/svg+xml' | 'text/plain' | 'text/html' | 'video/quicktime' | 'application/pdf' | 'application/zip' | 'audio/mpeg' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'text/csv';
|
|
4
4
|
export declare const previewableMimeTypes: FileType[];
|
|
5
5
|
export declare const ICON_MAP: Record<FileType, React.ReactNode>;
|
|
6
6
|
export {};
|
|
7
|
-
//# sourceMappingURL=FileView.const.d.ts.map
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FileTypeTxt, FileTypePptx, FileTypeXls, FileTypeMp3, FileTypeVideo, FileTypeHtml, FileTypeZip, FileTypePdf, FileTypeSvg, FileTypeImage } from "@synerise/ds-icon";
|
|
3
|
+
const isPreviewableMimeType = (type) => {
|
|
4
4
|
return previewableMimeTypes.includes(type);
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
6
|
+
const previewableMimeTypes = ["image/png", "image/gif", "image/jpeg", "image/svg+xml", "text/plain", "text/html", "video/quicktime", "application/pdf", "application/zip", "audio/mpeg", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "text/csv"];
|
|
7
|
+
const ICON_MAP = {
|
|
8
|
+
"image/png": /* @__PURE__ */ jsx(FileTypeImage, {}),
|
|
9
|
+
"image/gif": /* @__PURE__ */ jsx(FileTypePdf, {}),
|
|
10
|
+
"image/jpeg": /* @__PURE__ */ jsx(FileTypeImage, {}),
|
|
11
|
+
"image/svg+xml": /* @__PURE__ */ jsx(FileTypeSvg, {}),
|
|
12
|
+
"application/pdf": /* @__PURE__ */ jsx(FileTypePdf, {}),
|
|
13
|
+
"application/zip": /* @__PURE__ */ jsx(FileTypeZip, {}),
|
|
14
|
+
"text/plain": /* @__PURE__ */ jsx(FileTypeTxt, {}),
|
|
15
|
+
"text/html": /* @__PURE__ */ jsx(FileTypeHtml, {}),
|
|
16
|
+
"video/quicktime": /* @__PURE__ */ jsx(FileTypeVideo, {}),
|
|
17
|
+
"audio/mpeg": /* @__PURE__ */ jsx(FileTypeMp3, {}),
|
|
18
|
+
"application/vnd.ms-excel": /* @__PURE__ */ jsx(FileTypeXls, {}),
|
|
19
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": /* @__PURE__ */ jsx(FileTypePptx, {}),
|
|
20
|
+
"text/csv": /* @__PURE__ */ jsx(FileTypeTxt, {})
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
ICON_MAP,
|
|
24
|
+
isPreviewableMimeType,
|
|
25
|
+
previewableMimeTypes
|
|
26
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FileViewProps } from './FileView.types';
|
|
3
3
|
declare const FileView: ({ data, texts, onRemove, removable, retry, retryButtonProps, }: FileViewProps) => React.JSX.Element;
|
|
4
4
|
export default FileView;
|
|
5
|
-
//# sourceMappingURL=FileView.d.ts.map
|