@hitachivantara/uikit-react-core 5.83.1 → 5.84.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.
- package/dist/cjs/FileUploader/DropZone/DropZone.cjs +29 -14
- package/dist/cjs/FileUploader/DropZone/DropZone.styles.cjs +14 -26
- package/dist/cjs/FileUploader/FileUploader.cjs +12 -12
- package/dist/cjs/FileUploader/FileUploader.styles.cjs +8 -0
- package/dist/cjs/FileUploader/utils.cjs +0 -1
- package/dist/cjs/FormElement/Suggestions/Suggestions.cjs +1 -1
- package/dist/cjs/FormElement/Suggestions/Suggestions.styles.cjs +1 -0
- package/dist/cjs/Select/Select.cjs +5 -3
- package/dist/cjs/Select/Select.styles.cjs +7 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/esm/FileUploader/DropZone/DropZone.js +30 -15
- package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
- package/dist/esm/FileUploader/DropZone/DropZone.styles.js +14 -26
- package/dist/esm/FileUploader/DropZone/DropZone.styles.js.map +1 -1
- package/dist/esm/FileUploader/FileUploader.js +14 -13
- package/dist/esm/FileUploader/FileUploader.js.map +1 -1
- package/dist/esm/FileUploader/FileUploader.styles.js +8 -0
- package/dist/esm/FileUploader/FileUploader.styles.js.map +1 -0
- package/dist/esm/FileUploader/utils.js +1 -2
- package/dist/esm/FileUploader/utils.js.map +1 -1
- package/dist/esm/FormElement/Suggestions/Suggestions.js +2 -2
- package/dist/esm/FormElement/Suggestions/Suggestions.js.map +1 -1
- package/dist/esm/FormElement/Suggestions/Suggestions.styles.js +1 -0
- package/dist/esm/FormElement/Suggestions/Suggestions.styles.js.map +1 -1
- package/dist/esm/ListContainer/ListItem/ListItem.js.map +1 -1
- package/dist/esm/Select/Select.js +5 -3
- package/dist/esm/Select/Select.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +7 -1
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/index.js +128 -126
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +311 -252
- package/package.json +6 -6
|
@@ -4,14 +4,34 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
6
6
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
7
|
+
const useLabels = require("../../hooks/useLabels.cjs");
|
|
7
8
|
const useUniqueId = require("../../hooks/useUniqueId.cjs");
|
|
8
9
|
const helpers = require("../../utils/helpers.cjs");
|
|
9
10
|
const setId = require("../../utils/setId.cjs");
|
|
10
11
|
const utils = require("../utils.cjs");
|
|
11
12
|
const DropZone_styles = require("./DropZone.styles.cjs");
|
|
13
|
+
const context = require("../../FormElement/context.cjs");
|
|
12
14
|
const Label = require("../../FormElement/Label/Label.cjs");
|
|
13
15
|
const InfoMessage = require("../../FormElement/InfoMessage/InfoMessage.cjs");
|
|
14
|
-
const
|
|
16
|
+
const DEFAULT_LABELS = {
|
|
17
|
+
/** Extensions of the accepted file types */
|
|
18
|
+
acceptedFiles: "",
|
|
19
|
+
/** Dropzone area label. @deprecated use `label` prop instead */
|
|
20
|
+
dropzone: "Label",
|
|
21
|
+
/** Size file warning label. */
|
|
22
|
+
sizeWarning: "Max. file size:",
|
|
23
|
+
/** Size file warning label. */
|
|
24
|
+
drag: "Drop files here or",
|
|
25
|
+
/** Size file warning label. */
|
|
26
|
+
selectFiles: "click to upload",
|
|
27
|
+
/** Theming sheet used to style components */
|
|
28
|
+
dropFiles: "Drop files here",
|
|
29
|
+
/** Message to display when file size is greater than allowed */
|
|
30
|
+
fileSizeError: "The file exceeds the maximum upload size",
|
|
31
|
+
/** Message to display when file type is greater than allowed */
|
|
32
|
+
fileTypeError: "File type not allowed for upload",
|
|
33
|
+
removeFileButtonLabel: "Remove File"
|
|
34
|
+
};
|
|
15
35
|
function validateAccept(file, acceptAttr) {
|
|
16
36
|
if (!file || !acceptAttr) return true;
|
|
17
37
|
const acceptEntries = acceptAttr.split(",");
|
|
@@ -33,17 +53,19 @@ const HvDropZone = (props) => {
|
|
|
33
53
|
const {
|
|
34
54
|
id: idProp,
|
|
35
55
|
classes: classesProp,
|
|
36
|
-
|
|
56
|
+
label,
|
|
57
|
+
labels: labelsProp,
|
|
37
58
|
accept,
|
|
38
59
|
maxFileSize,
|
|
39
60
|
inputProps,
|
|
40
61
|
hideLabels,
|
|
41
62
|
multiple = true,
|
|
42
|
-
disabled = false,
|
|
43
63
|
onFilesAdded
|
|
44
64
|
} = uikitReactUtils.useDefaultProps("HvDropZone", props);
|
|
45
65
|
const id = useUniqueId.useUniqueId(idProp);
|
|
66
|
+
const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProp);
|
|
46
67
|
const { classes, cx } = DropZone_styles.useClasses(classesProp);
|
|
68
|
+
const { disabled } = React.useContext(context.HvFormElementContext);
|
|
47
69
|
const [dragState, setDragState] = React.useState(false);
|
|
48
70
|
const inputRef = React.useRef(null);
|
|
49
71
|
const handleDragLeave = () => {
|
|
@@ -85,7 +107,7 @@ const HvDropZone = (props) => {
|
|
|
85
107
|
showGutter: true,
|
|
86
108
|
id: setId.setId(id, "input-file-label"),
|
|
87
109
|
htmlFor: setId.setId(id, "input-file"),
|
|
88
|
-
label: labels?.dropzone,
|
|
110
|
+
label: label ?? labels?.dropzone,
|
|
89
111
|
className: classes.dropZoneLabel
|
|
90
112
|
}
|
|
91
113
|
),
|
|
@@ -140,16 +162,9 @@ const HvDropZone = (props) => {
|
|
|
140
162
|
...inputProps
|
|
141
163
|
}
|
|
142
164
|
),
|
|
143
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes?.dropArea, children: dragState ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
iconSize: "M",
|
|
148
|
-
className: classes.dropZoneAreaIcon,
|
|
149
|
-
color: disabled ? "secondary_60" : "secondary"
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxRuntime.jsxs(Typography.HvTypography, { className: classes.dragText, children: [
|
|
165
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes?.dropArea, children: dragState ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.dragText, children: labels?.dropFiles }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Doc, { size: "M", className: classes.dropZoneAreaIcon }),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.dragText, children: [
|
|
153
168
|
labels?.drag,
|
|
154
169
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
155
170
|
"span",
|
|
@@ -10,15 +10,13 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvDropZone"
|
|
|
10
10
|
display: "flex",
|
|
11
11
|
border: `1px dashed ${uikitStyles.theme.colors.secondary_60}`,
|
|
12
12
|
cursor: "pointer",
|
|
13
|
-
|
|
13
|
+
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
14
14
|
borderRadius: uikitStyles.theme.radii.round,
|
|
15
15
|
"&:hover": {
|
|
16
|
-
|
|
17
|
-
border: `1px dashed ${uikitStyles.theme.colors.secondary}`
|
|
16
|
+
borderColor: uikitStyles.theme.colors.secondary
|
|
18
17
|
},
|
|
19
18
|
"&:focus-within": {
|
|
20
|
-
|
|
21
|
-
border: `1px dashed ${uikitStyles.theme.colors.secondary}`,
|
|
19
|
+
borderColor: uikitStyles.theme.colors.secondary,
|
|
22
20
|
...focusUtils.outlineStyles
|
|
23
21
|
}
|
|
24
22
|
},
|
|
@@ -31,22 +29,16 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvDropZone"
|
|
|
31
29
|
}
|
|
32
30
|
},
|
|
33
31
|
dragAction: {
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
33
|
+
borderColor: uikitStyles.theme.colors.primary
|
|
36
34
|
},
|
|
37
35
|
dropZoneContainerDisabled: {
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
color: uikitStyles.theme.colors.secondary_60,
|
|
37
|
+
backgroundColor: uikitStyles.theme.colors.atmo3,
|
|
38
|
+
borderColor: "currentcolor",
|
|
40
39
|
cursor: "not-allowed",
|
|
41
40
|
"&:hover": {
|
|
42
|
-
|
|
43
|
-
border: `1px dashed ${uikitStyles.theme.colors.secondary_60}`
|
|
44
|
-
},
|
|
45
|
-
"& $dragText": {
|
|
46
|
-
color: uikitStyles.theme.colors.secondary_60
|
|
47
|
-
},
|
|
48
|
-
"& $selectFilesText": {
|
|
49
|
-
color: uikitStyles.theme.colors.secondary_60
|
|
41
|
+
borderColor: "currentcolor"
|
|
50
42
|
}
|
|
51
43
|
},
|
|
52
44
|
inputArea: {
|
|
@@ -61,7 +53,8 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvDropZone"
|
|
|
61
53
|
},
|
|
62
54
|
dropArea: {
|
|
63
55
|
display: "flex",
|
|
64
|
-
margin:
|
|
56
|
+
margin: uikitStyles.theme.spacing("md", "auto"),
|
|
57
|
+
gap: uikitStyles.theme.space.xs,
|
|
65
58
|
minHeight: 48
|
|
66
59
|
},
|
|
67
60
|
dropZoneAreaLabels: {
|
|
@@ -69,16 +62,11 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvDropZone"
|
|
|
69
62
|
maxWidth: 120,
|
|
70
63
|
margin: "auto"
|
|
71
64
|
},
|
|
72
|
-
dropZoneAreaIcon: {
|
|
73
|
-
margin: "auto",
|
|
74
|
-
marginRight: uikitStyles.theme.space.xs
|
|
75
|
-
},
|
|
65
|
+
dropZoneAreaIcon: {},
|
|
76
66
|
dropZoneLabel: {},
|
|
77
|
-
dragText: {
|
|
78
|
-
...uikitStyles.theme.typography.body
|
|
79
|
-
},
|
|
67
|
+
dragText: {},
|
|
80
68
|
selectFilesText: {
|
|
81
|
-
|
|
69
|
+
fontWeight: uikitStyles.theme.typography.label.fontWeight
|
|
82
70
|
}
|
|
83
71
|
});
|
|
84
72
|
exports.staticClasses = staticClasses;
|
|
@@ -4,44 +4,43 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
5
5
|
const useLabels = require("../hooks/useLabels.cjs");
|
|
6
6
|
const setId = require("../utils/setId.cjs");
|
|
7
|
+
const FileUploader_styles = require("./FileUploader.styles.cjs");
|
|
7
8
|
const DropZone = require("./DropZone/DropZone.cjs");
|
|
8
9
|
const FileList = require("./FileList/FileList.cjs");
|
|
10
|
+
const FormElement = require("../FormElement/FormElement.cjs");
|
|
9
11
|
const DEFAULT_LABELS = {
|
|
10
|
-
dropzone: "Label",
|
|
11
|
-
sizeWarning: "Max. file size:",
|
|
12
|
-
drag: "Drop files here or",
|
|
13
|
-
selectFiles: "click to upload",
|
|
14
|
-
dropFiles: "Drop files here",
|
|
15
|
-
fileSizeError: "The file exceeds the maximum upload size",
|
|
16
|
-
fileTypeError: "File type not allowed for upload",
|
|
17
12
|
removeFileButtonLabel: "Remove File"
|
|
18
13
|
};
|
|
19
14
|
const HvFileUploader = (props) => {
|
|
20
15
|
const {
|
|
21
16
|
id,
|
|
22
17
|
className,
|
|
18
|
+
classes: classesProp,
|
|
23
19
|
labels: labelsProp,
|
|
24
20
|
fileList,
|
|
25
21
|
multiple = true,
|
|
26
|
-
|
|
27
|
-
hideLabels
|
|
22
|
+
label,
|
|
23
|
+
hideLabels,
|
|
28
24
|
maxFileSize = Infinity,
|
|
29
25
|
inputProps = {},
|
|
26
|
+
accept,
|
|
30
27
|
acceptedFiles = [],
|
|
28
|
+
// TODO: consider adding/replacing with onFilesChange
|
|
31
29
|
onFilesAdded,
|
|
32
30
|
onFileRemoved,
|
|
33
31
|
...others
|
|
34
32
|
} = uikitReactUtils.useDefaultProps("HvFileUploader", props);
|
|
33
|
+
const { classes, cx } = FileUploader_styles.useClasses(classesProp);
|
|
35
34
|
const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProp);
|
|
36
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormElement.HvFormElement, { id, className: cx(classes.root, className), ...others, children: [
|
|
37
36
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
38
37
|
DropZone.HvDropZone,
|
|
39
38
|
{
|
|
40
39
|
id: setId.setId(id, "dropzone"),
|
|
40
|
+
label,
|
|
41
41
|
labels,
|
|
42
42
|
multiple,
|
|
43
|
-
|
|
44
|
-
accept: acceptedFiles.join(","),
|
|
43
|
+
accept: accept ?? acceptedFiles.join(","),
|
|
45
44
|
maxFileSize,
|
|
46
45
|
onFilesAdded,
|
|
47
46
|
inputProps,
|
|
@@ -59,4 +58,5 @@ const HvFileUploader = (props) => {
|
|
|
59
58
|
)
|
|
60
59
|
] });
|
|
61
60
|
};
|
|
61
|
+
exports.fileUploaderClasses = FileUploader_styles.staticClasses;
|
|
62
62
|
exports.HvFileUploader = HvFileUploader;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
4
|
+
const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvFileUploader", {
|
|
5
|
+
root: {}
|
|
6
|
+
});
|
|
7
|
+
exports.staticClasses = staticClasses;
|
|
8
|
+
exports.useClasses = useClasses;
|
|
@@ -26,7 +26,7 @@ const HvSuggestions = React.forwardRef(function HvSuggestions2(props, extRef) {
|
|
|
26
26
|
onSuggestionSelected,
|
|
27
27
|
popperProps,
|
|
28
28
|
...others
|
|
29
|
-
} = props;
|
|
29
|
+
} = uikitReactUtils.useDefaultProps("HvSuggestions", props);
|
|
30
30
|
const { classes, cx } = Suggestions_styles.useClasses(classesProp);
|
|
31
31
|
const { rootId } = uikitReactUtils.useTheme();
|
|
32
32
|
const context$1 = React.useContext(context.HvFormElementContext);
|
|
@@ -6,6 +6,7 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvSuggestio
|
|
|
6
6
|
root: { position: "relative" },
|
|
7
7
|
list: {
|
|
8
8
|
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
9
|
+
border: `1px solid ${uikitStyles.theme.colors.secondary}`,
|
|
9
10
|
boxShadow: uikitStyles.theme.colors.shadow,
|
|
10
11
|
padding: uikitStyles.theme.space.xs,
|
|
11
12
|
width: "100%"
|
|
@@ -17,7 +17,6 @@ const FormElement = require("../FormElement/FormElement.cjs");
|
|
|
17
17
|
const Label = require("../FormElement/Label/Label.cjs");
|
|
18
18
|
const InfoMessage = require("../FormElement/InfoMessage/InfoMessage.cjs");
|
|
19
19
|
const DropdownButton = require("../DropdownButton/DropdownButton.cjs");
|
|
20
|
-
const Panel = require("../Panel/Panel.cjs");
|
|
21
20
|
const ListContainer = require("../ListContainer/ListContainer.cjs");
|
|
22
21
|
const WarningText = require("../FormElement/WarningText/WarningText.cjs");
|
|
23
22
|
function defaultRenderValue(options) {
|
|
@@ -194,8 +193,10 @@ const HvSelect = generic.fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
194
193
|
}
|
|
195
194
|
],
|
|
196
195
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
197
|
-
|
|
196
|
+
ListContainer.HvListContainer,
|
|
198
197
|
{
|
|
198
|
+
condensed: true,
|
|
199
|
+
selectable: true,
|
|
199
200
|
style: {
|
|
200
201
|
width: variableWidth ? "auto" : (buttonRef.current?.clientWidth || 0) + 2
|
|
201
202
|
},
|
|
@@ -203,7 +204,8 @@ const HvSelect = generic.fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
203
204
|
[classes.panelOpenedUp]: placement.includes("top"),
|
|
204
205
|
[classes.panelOpenedDown]: placement.includes("bottom")
|
|
205
206
|
}),
|
|
206
|
-
|
|
207
|
+
...getListboxProps(),
|
|
208
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(useSelect.SelectProvider, { value: contextValue, children })
|
|
207
209
|
}
|
|
208
210
|
)
|
|
209
211
|
}
|
|
@@ -28,7 +28,13 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvSelect",
|
|
|
28
28
|
maxHeight: 400,
|
|
29
29
|
border: `1px solid ${uikitStyles.theme.colors.secondary}`,
|
|
30
30
|
marginTop: -1,
|
|
31
|
-
marginBottom: -1
|
|
31
|
+
marginBottom: -1,
|
|
32
|
+
// panel styles
|
|
33
|
+
position: "relative",
|
|
34
|
+
padding: uikitStyles.theme.space.xs,
|
|
35
|
+
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
36
|
+
overflowY: "auto",
|
|
37
|
+
borderRadius: "inherit"
|
|
32
38
|
},
|
|
33
39
|
panelOpenedUp: {
|
|
34
40
|
borderRadius: `${uikitStyles.theme.radii.base} ${uikitStyles.theme.radii.base} 0 0`
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -155,6 +155,7 @@ const Preview_styles = require("./FileUploader/Preview/Preview.styles.cjs");
|
|
|
155
155
|
const Preview = require("./FileUploader/Preview/Preview.cjs");
|
|
156
156
|
const File_styles = require("./FileUploader/File/File.styles.cjs");
|
|
157
157
|
const File = require("./FileUploader/File/File.cjs");
|
|
158
|
+
const FileUploader_styles = require("./FileUploader/FileUploader.styles.cjs");
|
|
158
159
|
const FileUploader = require("./FileUploader/FileUploader.cjs");
|
|
159
160
|
const FilterGroup_styles = require("./FilterGroup/FilterGroup.styles.cjs");
|
|
160
161
|
const FilterGroup = require("./FilterGroup/FilterGroup.cjs");
|
|
@@ -508,6 +509,7 @@ exports.fileUploaderPreviewClasses = Preview_styles.staticClasses;
|
|
|
508
509
|
exports.HvFileUploaderPreview = Preview.HvFileUploaderPreview;
|
|
509
510
|
exports.fileClasses = File_styles.staticClasses;
|
|
510
511
|
exports.HvFile = File.HvFile;
|
|
512
|
+
exports.fileUploaderClasses = FileUploader_styles.staticClasses;
|
|
511
513
|
exports.HvFileUploader = FileUploader.HvFileUploader;
|
|
512
514
|
exports.filterGroupClasses = FilterGroup_styles.staticClasses;
|
|
513
515
|
exports.HvFilterGroup = FilterGroup.HvFilterGroup;
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef } from "react";
|
|
2
|
+
import { useContext, useState, useRef } from "react";
|
|
3
3
|
import { Doc } from "@hitachivantara/uikit-react-icons";
|
|
4
4
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
5
|
+
import { useLabels } from "../../hooks/useLabels.js";
|
|
5
6
|
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
6
7
|
import { uniqueId } from "../../utils/helpers.js";
|
|
7
8
|
import { setId } from "../../utils/setId.js";
|
|
8
9
|
import { convertUnits } from "../utils.js";
|
|
9
10
|
import { useClasses } from "./DropZone.styles.js";
|
|
10
11
|
import { staticClasses } from "./DropZone.styles.js";
|
|
12
|
+
import { HvFormElementContext } from "../../FormElement/context.js";
|
|
11
13
|
import { HvLabel } from "../../FormElement/Label/Label.js";
|
|
12
14
|
import { HvInfoMessage } from "../../FormElement/InfoMessage/InfoMessage.js";
|
|
13
|
-
|
|
15
|
+
const DEFAULT_LABELS = {
|
|
16
|
+
/** Extensions of the accepted file types */
|
|
17
|
+
acceptedFiles: "",
|
|
18
|
+
/** Dropzone area label. @deprecated use `label` prop instead */
|
|
19
|
+
dropzone: "Label",
|
|
20
|
+
/** Size file warning label. */
|
|
21
|
+
sizeWarning: "Max. file size:",
|
|
22
|
+
/** Size file warning label. */
|
|
23
|
+
drag: "Drop files here or",
|
|
24
|
+
/** Size file warning label. */
|
|
25
|
+
selectFiles: "click to upload",
|
|
26
|
+
/** Theming sheet used to style components */
|
|
27
|
+
dropFiles: "Drop files here",
|
|
28
|
+
/** Message to display when file size is greater than allowed */
|
|
29
|
+
fileSizeError: "The file exceeds the maximum upload size",
|
|
30
|
+
/** Message to display when file type is greater than allowed */
|
|
31
|
+
fileTypeError: "File type not allowed for upload",
|
|
32
|
+
removeFileButtonLabel: "Remove File"
|
|
33
|
+
};
|
|
14
34
|
function validateAccept(file, acceptAttr) {
|
|
15
35
|
if (!file || !acceptAttr) return true;
|
|
16
36
|
const acceptEntries = acceptAttr.split(",");
|
|
@@ -32,17 +52,19 @@ const HvDropZone = (props) => {
|
|
|
32
52
|
const {
|
|
33
53
|
id: idProp,
|
|
34
54
|
classes: classesProp,
|
|
35
|
-
|
|
55
|
+
label,
|
|
56
|
+
labels: labelsProp,
|
|
36
57
|
accept,
|
|
37
58
|
maxFileSize,
|
|
38
59
|
inputProps,
|
|
39
60
|
hideLabels,
|
|
40
61
|
multiple = true,
|
|
41
|
-
disabled = false,
|
|
42
62
|
onFilesAdded
|
|
43
63
|
} = useDefaultProps("HvDropZone", props);
|
|
44
64
|
const id = useUniqueId(idProp);
|
|
65
|
+
const labels = useLabels(DEFAULT_LABELS, labelsProp);
|
|
45
66
|
const { classes, cx } = useClasses(classesProp);
|
|
67
|
+
const { disabled } = useContext(HvFormElementContext);
|
|
46
68
|
const [dragState, setDragState] = useState(false);
|
|
47
69
|
const inputRef = useRef(null);
|
|
48
70
|
const handleDragLeave = () => {
|
|
@@ -84,7 +106,7 @@ const HvDropZone = (props) => {
|
|
|
84
106
|
showGutter: true,
|
|
85
107
|
id: setId(id, "input-file-label"),
|
|
86
108
|
htmlFor: setId(id, "input-file"),
|
|
87
|
-
label: labels?.dropzone,
|
|
109
|
+
label: label ?? labels?.dropzone,
|
|
88
110
|
className: classes.dropZoneLabel
|
|
89
111
|
}
|
|
90
112
|
),
|
|
@@ -139,16 +161,9 @@ const HvDropZone = (props) => {
|
|
|
139
161
|
...inputProps
|
|
140
162
|
}
|
|
141
163
|
),
|
|
142
|
-
/* @__PURE__ */ jsx("div", { className: classes?.dropArea, children: dragState ? /* @__PURE__ */ jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsx(
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
iconSize: "M",
|
|
147
|
-
className: classes.dropZoneAreaIcon,
|
|
148
|
-
color: disabled ? "secondary_60" : "secondary"
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxs(HvTypography, { className: classes.dragText, children: [
|
|
164
|
+
/* @__PURE__ */ jsx("div", { className: classes?.dropArea, children: dragState ? /* @__PURE__ */ jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsx("div", { className: classes.dragText, children: labels?.dropFiles }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
165
|
+
/* @__PURE__ */ jsx(Doc, { size: "M", className: classes.dropZoneAreaIcon }),
|
|
166
|
+
/* @__PURE__ */ jsx("div", { className: classes.dropZoneAreaLabels, children: /* @__PURE__ */ jsxs("div", { className: classes.dragText, children: [
|
|
152
167
|
labels?.drag,
|
|
153
168
|
/* @__PURE__ */ jsx(
|
|
154
169
|
"span",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.js","sources":["../../../../src/FileUploader/DropZone/DropZone.tsx"],"sourcesContent":["import { useRef, useState } from \"react\";\nimport { Doc } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvInfoMessage, HvLabel } from \"../../FormElement\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { HvTypography } from \"../../Typography\";\nimport { uniqueId } from \"../../utils/helpers\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFileData, HvFilesAddedEvent } from \"../File\";\nimport { convertUnits } from \"../utils\";\nimport { staticClasses, useClasses } from \"./DropZone.styles\";\n\nexport { staticClasses as dropZoneClasses };\n\nexport type HvDropZoneClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropZoneLabels {\n /**\n * Extensions of the accepted file types\n */\n acceptedFiles?: string;\n /**\n * Dropzone area label.\n */\n dropzone?: string;\n /**\n * Size file warning label.\n */\n sizeWarning?: string;\n /**\n * Size file warning label.\n */\n drag?: string;\n /**\n * Size file warning label.\n */\n selectFiles?: string;\n /**\n * Theming sheet used to style components\n * */\n dropFiles?: string;\n /**\n * Message to display when file size is greater than allowed\n * */\n fileSizeError?: string;\n /**\n * Message to display when file type is greater than allowed\n * */\n fileTypeError?: string;\n}\n\nexport interface HvDropZoneProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Labels to present in FileUploader.\n */\n labels?: HvDropZoneLabels;\n /**\n * Whether the Dropzone should accept multiple files at once.\n */\n multiple?: boolean;\n /**\n * If the input is disabled or not\n */\n disabled?: boolean;\n /**\n * Files extensions accepted for upload.\n */\n accept?: React.InputHTMLAttributes<HTMLInputElement>[\"accept\"];\n /**\n * Max upload size\n * */\n maxFileSize: number;\n /**\n * Function responsible for processing files added to the drop zone.\n */\n onFilesAdded?: HvFilesAddedEvent;\n /**\n * Whether the DropZone should hide labels or not.\n */\n hideLabels?: boolean;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvDropZoneClasses;\n}\n\n// TODO: remove/review in `v6`: delegate to HTML `accept` and/or add custom validation\nfunction validateAccept(file?: File, acceptAttr?: string) {\n if (!file || !acceptAttr) return true;\n\n const acceptEntries = acceptAttr.split(\",\");\n const fileName = file.name || \"\";\n const mimeType = (file.type || \"\").toLowerCase();\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\");\n\n return acceptEntries.some((type) => {\n const validType = type.trim().toLowerCase();\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType);\n }\n // This is something like a image/* mime type\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\");\n }\n return mimeType === validType;\n });\n}\n\nexport const HvDropZone = (props: HvDropZoneProps) => {\n const {\n id: idProp,\n classes: classesProp,\n labels,\n accept,\n maxFileSize,\n inputProps,\n hideLabels,\n multiple = true,\n disabled = false,\n onFilesAdded,\n } = useDefaultProps(\"HvDropZone\", props);\n const id = useUniqueId(idProp);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [dragState, setDragState] = useState(false);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const handleDragLeave = () => {\n setDragState(false);\n };\n\n const handleDragEnter: React.DragEventHandler = (event) => {\n if (disabled) return;\n event.stopPropagation();\n event.preventDefault();\n setDragState(true);\n };\n\n const onChangeHandler = (filesList: FileList) => {\n const filesToProcess = Object.values(filesList);\n\n const newFiles = filesToProcess.map((file) => {\n const newFile: HvFileData = new File([file], file.name, {\n type: file.type,\n lastModified: file.lastModified,\n });\n newFile.id = uniqueId(\"uploaded-file-data-\");\n\n const isSizeAllowed = file.size <= maxFileSize;\n const isFileAccepted =\n !accept ||\n accept.includes(file.type?.split(\"/\")[1]) || // TODO: remove in v6\n validateAccept(file, accept);\n\n if (!isFileAccepted) {\n newFile.errorMessage = labels?.fileTypeError;\n newFile.status = \"fail\";\n } else if (!isSizeAllowed) {\n newFile.errorMessage = labels?.fileSizeError;\n newFile.status = \"fail\";\n }\n\n return newFile;\n });\n\n onFilesAdded?.(newFiles);\n };\n\n return (\n <>\n {!hideLabels && (\n <div id={id} className={classes.dropZoneLabelsGroup}>\n <HvLabel\n showGutter\n id={setId(id, \"input-file-label\")}\n htmlFor={setId(id, \"input-file\")}\n label={labels?.dropzone}\n className={classes.dropZoneLabel}\n />\n <HvInfoMessage id={setId(id, \"description\")}>\n {Number.isInteger(maxFileSize) &&\n `${labels?.sizeWarning} ${convertUnits(maxFileSize)}`}\n {labels?.acceptedFiles\n ? labels.acceptedFiles\n : accept && `\\u00A0(${accept?.replaceAll(\",\", \", \")})`}\n </HvInfoMessage>\n </div>\n )}\n <div\n id={setId(id, \"input-file-container\")}\n className={cx(classes.dropZoneContainer, {\n [classes.dragAction]: dragState,\n [classes.dropZoneContainerDisabled]: disabled,\n })}\n >\n <input\n id={setId(id, \"input-file\")}\n className={classes.inputArea}\n type=\"file\"\n multiple={multiple}\n disabled={disabled}\n title={!disabled ? `${labels?.drag}\\xa0${labels?.selectFiles}` : \"\"}\n onClick={() => {\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n }}\n onChange={() => {\n if (!disabled && inputRef.current?.files) {\n onChangeHandler(inputRef.current.files);\n }\n }}\n onDragEnter={handleDragEnter}\n onDragOver={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDropCapture={handleDragLeave}\n onDrop={(event) => {\n if (disabled) return;\n\n const { files } = event.dataTransfer;\n if (multiple === true || files.length === 1) {\n event.stopPropagation();\n event.preventDefault();\n onChangeHandler(files);\n }\n }}\n ref={inputRef}\n accept={accept}\n {...inputProps}\n />\n <div className={classes?.dropArea}>\n {dragState ? (\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.dropFiles}\n </HvTypography>\n </div>\n ) : (\n <>\n <Doc\n iconSize=\"M\"\n className={classes.dropZoneAreaIcon}\n color={disabled ? \"secondary_60\" : \"secondary\"}\n />\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.drag}\n <span\n className={classes.selectFilesText}\n >{`\\xa0${labels?.selectFiles}`}</span>\n </HvTypography>\n </div>\n </>\n )}\n </div>\n </div>\n </>\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AAA,YACrC;AAAA,YACA,oBAAC,SAAI,WAAW,QAAQ,oBACtB,UAAC,qBAAA,cAAA,EAAa,WAAW,QAAQ,UAC9B,UAAA;AAAA,cAAQ,QAAA;AAAA,cACT;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW,QAAQ;AAAA,kBACnB,UAAA,IAAO,QAAQ,WAAW;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAG,EAAA,CACjC,EACF,CAAA;AAAA,UAAA,EAAA,CACF,EAEJ,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DropZone.js","sources":["../../../../src/FileUploader/DropZone/DropZone.tsx"],"sourcesContent":["import { useContext, useRef, useState } from \"react\";\nimport { Doc } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvFormElementContext,\n HvFormElementProps,\n HvInfoMessage,\n HvLabel,\n} from \"../../FormElement\";\nimport { useLabels } from \"../../hooks/useLabels\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { uniqueId } from \"../../utils/helpers\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFileData, HvFilesAddedEvent } from \"../File\";\nimport { convertUnits } from \"../utils\";\nimport { staticClasses, useClasses } from \"./DropZone.styles\";\n\nexport { staticClasses as dropZoneClasses };\n\nexport type HvDropZoneClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n /** Extensions of the accepted file types */\n acceptedFiles: \"\",\n /** Dropzone area label. @deprecated use `label` prop instead */\n dropzone: \"Label\",\n /** Size file warning label. */\n sizeWarning: \"Max. file size:\",\n /** Size file warning label. */\n drag: \"Drop files here or\",\n /** Size file warning label. */\n selectFiles: \"click to upload\",\n /** Theming sheet used to style components */\n dropFiles: \"Drop files here\",\n /** Message to display when file size is greater than allowed */\n fileSizeError: \"The file exceeds the maximum upload size\",\n /** Message to display when file type is greater than allowed */\n fileTypeError: \"File type not allowed for upload\",\n\n removeFileButtonLabel: \"Remove File\",\n};\n\nexport type HvDropZoneLabels = Partial<typeof DEFAULT_LABELS>;\n\nexport interface HvDropZoneProps\n extends Pick<HvFormElementProps, \"id\" | \"disabled\" | \"label\"> {\n /**\n * Labels to present in FileUploader.\n */\n labels?: HvDropZoneLabels;\n /**\n * Whether the Dropzone should accept multiple files at once.\n */\n multiple?: boolean;\n /**\n * Files extensions accepted for upload.\n */\n accept?: React.InputHTMLAttributes<HTMLInputElement>[\"accept\"];\n /**\n * Max upload size\n * */\n maxFileSize: number;\n /**\n * Function responsible for processing files added to the drop zone.\n */\n onFilesAdded?: HvFilesAddedEvent;\n /**\n * Whether the DropZone should hide labels or not.\n */\n hideLabels?: boolean;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvDropZoneClasses;\n}\n\n// TODO: remove/review in `v6`: delegate to HTML `accept` and/or add custom validation\nfunction validateAccept(file?: File, acceptAttr?: string) {\n if (!file || !acceptAttr) return true;\n\n const acceptEntries = acceptAttr.split(\",\");\n const fileName = file.name || \"\";\n const mimeType = (file.type || \"\").toLowerCase();\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\");\n\n return acceptEntries.some((type) => {\n const validType = type.trim().toLowerCase();\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType);\n }\n // This is something like a image/* mime type\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\");\n }\n return mimeType === validType;\n });\n}\n\nexport const HvDropZone = (props: HvDropZoneProps) => {\n const {\n id: idProp,\n classes: classesProp,\n label,\n labels: labelsProp,\n accept,\n maxFileSize,\n inputProps,\n hideLabels,\n multiple = true,\n onFilesAdded,\n } = useDefaultProps(\"HvDropZone\", props);\n const id = useUniqueId(idProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const { classes, cx } = useClasses(classesProp);\n const { disabled } = useContext(HvFormElementContext);\n\n const [dragState, setDragState] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleDragLeave = () => {\n setDragState(false);\n };\n\n const handleDragEnter: React.DragEventHandler = (event) => {\n if (disabled) return;\n event.stopPropagation();\n event.preventDefault();\n setDragState(true);\n };\n\n const onChangeHandler = (filesList: FileList) => {\n const filesToProcess = Object.values(filesList);\n\n const newFiles = filesToProcess.map((file) => {\n const newFile: HvFileData = new File([file], file.name, {\n type: file.type,\n lastModified: file.lastModified,\n });\n newFile.id = uniqueId(\"uploaded-file-data-\");\n\n const isSizeAllowed = file.size <= maxFileSize;\n const isFileAccepted =\n !accept ||\n accept.includes(file.type?.split(\"/\")[1]) || // TODO: remove in v6\n validateAccept(file, accept);\n\n if (!isFileAccepted) {\n newFile.errorMessage = labels?.fileTypeError;\n newFile.status = \"fail\";\n } else if (!isSizeAllowed) {\n newFile.errorMessage = labels?.fileSizeError;\n newFile.status = \"fail\";\n }\n\n return newFile;\n });\n\n onFilesAdded?.(newFiles);\n };\n\n return (\n <>\n {!hideLabels && (\n <div id={id} className={classes.dropZoneLabelsGroup}>\n <HvLabel\n showGutter\n id={setId(id, \"input-file-label\")}\n htmlFor={setId(id, \"input-file\")}\n label={label ?? labels?.dropzone}\n className={classes.dropZoneLabel}\n />\n <HvInfoMessage id={setId(id, \"description\")}>\n {Number.isInteger(maxFileSize) &&\n `${labels?.sizeWarning} ${convertUnits(maxFileSize)}`}\n {labels?.acceptedFiles\n ? labels.acceptedFiles\n : accept && `\\u00A0(${accept?.replaceAll(\",\", \", \")})`}\n </HvInfoMessage>\n </div>\n )}\n <div\n id={setId(id, \"input-file-container\")}\n className={cx(classes.dropZoneContainer, {\n [classes.dragAction]: dragState,\n [classes.dropZoneContainerDisabled]: disabled,\n })}\n >\n <input\n id={setId(id, \"input-file\")}\n className={classes.inputArea}\n type=\"file\"\n multiple={multiple}\n disabled={disabled}\n title={!disabled ? `${labels?.drag}\\xa0${labels?.selectFiles}` : \"\"}\n onClick={() => {\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n }}\n onChange={() => {\n if (!disabled && inputRef.current?.files) {\n onChangeHandler(inputRef.current.files);\n }\n }}\n onDragEnter={handleDragEnter}\n onDragOver={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDropCapture={handleDragLeave}\n onDrop={(event) => {\n if (disabled) return;\n\n const { files } = event.dataTransfer;\n if (multiple === true || files.length === 1) {\n event.stopPropagation();\n event.preventDefault();\n onChangeHandler(files);\n }\n }}\n ref={inputRef}\n accept={accept}\n {...inputProps}\n />\n <div className={classes?.dropArea}>\n {dragState ? (\n <div className={classes.dropZoneAreaLabels}>\n <div className={classes.dragText}>{labels?.dropFiles}</div>\n </div>\n ) : (\n <>\n <Doc size=\"M\" className={classes.dropZoneAreaIcon} />\n <div className={classes.dropZoneAreaLabels}>\n <div className={classes.dragText}>\n {labels?.drag}\n <span\n className={classes.selectFilesText}\n >{`\\xa0${labels?.selectFiles}`}</span>\n </div>\n </div>\n </>\n )}\n </div>\n </div>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,iBAAiB;AAAA;AAAA,EAErB,eAAe;AAAA;AAAA,EAEf,UAAU;AAAA;AAAA,EAEV,aAAa;AAAA;AAAA,EAEb,MAAM;AAAA;AAAA,EAEN,aAAa;AAAA;AAAA,EAEb,WAAW;AAAA;AAAA,EAEX,eAAe;AAAA;AAAA,EAEf,eAAe;AAAA,EAEf,uBAAuB;AACzB;AAyCA,SAAS,eAAe,MAAa,YAAqB;AACxD,MAAI,CAAC,QAAQ,CAAC,WAAmB,QAAA;AAE3B,QAAA,gBAAgB,WAAW,MAAM,GAAG;AACpC,QAAA,WAAW,KAAK,QAAQ;AAC9B,QAAM,YAAY,KAAK,QAAQ,IAAI,YAAY;AAC/C,QAAM,eAAe,SAAS,QAAQ,SAAS,EAA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;AAAA,YAAG,EAAA,CACjC,EACF,CAAA;AAAA,UAAA,EAAA,CACF,EAEJ,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
@@ -8,15 +8,13 @@ const { staticClasses, useClasses } = createClasses("HvDropZone", {
|
|
|
8
8
|
display: "flex",
|
|
9
9
|
border: `1px dashed ${theme.colors.secondary_60}`,
|
|
10
10
|
cursor: "pointer",
|
|
11
|
-
|
|
11
|
+
backgroundColor: theme.colors.atmo1,
|
|
12
12
|
borderRadius: theme.radii.round,
|
|
13
13
|
"&:hover": {
|
|
14
|
-
|
|
15
|
-
border: `1px dashed ${theme.colors.secondary}`
|
|
14
|
+
borderColor: theme.colors.secondary
|
|
16
15
|
},
|
|
17
16
|
"&:focus-within": {
|
|
18
|
-
|
|
19
|
-
border: `1px dashed ${theme.colors.secondary}`,
|
|
17
|
+
borderColor: theme.colors.secondary,
|
|
20
18
|
...outlineStyles
|
|
21
19
|
}
|
|
22
20
|
},
|
|
@@ -29,22 +27,16 @@ const { staticClasses, useClasses } = createClasses("HvDropZone", {
|
|
|
29
27
|
}
|
|
30
28
|
},
|
|
31
29
|
dragAction: {
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
backgroundColor: theme.colors.atmo1,
|
|
31
|
+
borderColor: theme.colors.primary
|
|
34
32
|
},
|
|
35
33
|
dropZoneContainerDisabled: {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
color: theme.colors.secondary_60,
|
|
35
|
+
backgroundColor: theme.colors.atmo3,
|
|
36
|
+
borderColor: "currentcolor",
|
|
38
37
|
cursor: "not-allowed",
|
|
39
38
|
"&:hover": {
|
|
40
|
-
|
|
41
|
-
border: `1px dashed ${theme.colors.secondary_60}`
|
|
42
|
-
},
|
|
43
|
-
"& $dragText": {
|
|
44
|
-
color: theme.colors.secondary_60
|
|
45
|
-
},
|
|
46
|
-
"& $selectFilesText": {
|
|
47
|
-
color: theme.colors.secondary_60
|
|
39
|
+
borderColor: "currentcolor"
|
|
48
40
|
}
|
|
49
41
|
},
|
|
50
42
|
inputArea: {
|
|
@@ -59,7 +51,8 @@ const { staticClasses, useClasses } = createClasses("HvDropZone", {
|
|
|
59
51
|
},
|
|
60
52
|
dropArea: {
|
|
61
53
|
display: "flex",
|
|
62
|
-
margin:
|
|
54
|
+
margin: theme.spacing("md", "auto"),
|
|
55
|
+
gap: theme.space.xs,
|
|
63
56
|
minHeight: 48
|
|
64
57
|
},
|
|
65
58
|
dropZoneAreaLabels: {
|
|
@@ -67,16 +60,11 @@ const { staticClasses, useClasses } = createClasses("HvDropZone", {
|
|
|
67
60
|
maxWidth: 120,
|
|
68
61
|
margin: "auto"
|
|
69
62
|
},
|
|
70
|
-
dropZoneAreaIcon: {
|
|
71
|
-
margin: "auto",
|
|
72
|
-
marginRight: theme.space.xs
|
|
73
|
-
},
|
|
63
|
+
dropZoneAreaIcon: {},
|
|
74
64
|
dropZoneLabel: {},
|
|
75
|
-
dragText: {
|
|
76
|
-
...theme.typography.body
|
|
77
|
-
},
|
|
65
|
+
dragText: {},
|
|
78
66
|
selectFilesText: {
|
|
79
|
-
|
|
67
|
+
fontWeight: theme.typography.label.fontWeight
|
|
80
68
|
}
|
|
81
69
|
});
|
|
82
70
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.styles.js","sources":["../../../../src/FileUploader/DropZone/DropZone.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropZone\", {\n dropZoneContainer: {\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n border: `1px dashed ${theme.colors.secondary_60}`,\n cursor: \"pointer\",\n
|
|
1
|
+
{"version":3,"file":"DropZone.styles.js","sources":["../../../../src/FileUploader/DropZone/DropZone.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropZone\", {\n dropZoneContainer: {\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n border: `1px dashed ${theme.colors.secondary_60}`,\n cursor: \"pointer\",\n backgroundColor: theme.colors.atmo1,\n borderRadius: theme.radii.round,\n\n \"&:hover\": {\n borderColor: theme.colors.secondary,\n },\n\n \"&:focus-within\": {\n borderColor: theme.colors.secondary,\n ...outlineStyles,\n },\n },\n dropZoneLabelsGroup: {\n display: \"flex\",\n justifyContent: \"start\",\n\n \"& label:nth-of-type(1)\": {},\n\n \"& p:nth-of-type(2)\": {\n marginLeft: \"auto\",\n },\n },\n dragAction: {\n backgroundColor: theme.colors.atmo1,\n borderColor: theme.colors.primary,\n },\n dropZoneContainerDisabled: {\n color: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo3,\n borderColor: \"currentcolor\",\n cursor: \"not-allowed\",\n \"&:hover\": {\n borderColor: \"currentcolor\",\n },\n },\n inputArea: {\n opacity: 0,\n width: \"100%\",\n position: \"absolute\",\n height: \"100%\",\n cursor: \"pointer\",\n\n \"&:disabled\": {\n cursor: \"not-allowed\",\n },\n },\n dropArea: {\n display: \"flex\",\n margin: theme.spacing(\"md\", \"auto\"),\n gap: theme.space.xs,\n minHeight: 48,\n },\n dropZoneAreaLabels: {\n display: \"flex\",\n maxWidth: 120,\n margin: \"auto\",\n },\n dropZoneAreaIcon: {},\n dropZoneLabel: {},\n dragText: {},\n selectFilesText: {\n fontWeight: theme.typography.label.fontWeight,\n },\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,cAAc;AAAA,EACvE,mBAAmB;AAAA,IACjB,UAAU;AAAA,IACV,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ,cAAc,MAAM,OAAO,YAAY;A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x } from "react/jsx-runtime";
|
|
|
2
2
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
3
3
|
import { useLabels } from "../hooks/useLabels.js";
|
|
4
4
|
import { setId } from "../utils/setId.js";
|
|
5
|
+
import { useClasses } from "./FileUploader.styles.js";
|
|
6
|
+
import { staticClasses } from "./FileUploader.styles.js";
|
|
5
7
|
import { HvDropZone } from "./DropZone/DropZone.js";
|
|
6
8
|
import { HvFileList } from "./FileList/FileList.js";
|
|
9
|
+
import { HvFormElement } from "../FormElement/FormElement.js";
|
|
7
10
|
const DEFAULT_LABELS = {
|
|
8
|
-
dropzone: "Label",
|
|
9
|
-
sizeWarning: "Max. file size:",
|
|
10
|
-
drag: "Drop files here or",
|
|
11
|
-
selectFiles: "click to upload",
|
|
12
|
-
dropFiles: "Drop files here",
|
|
13
|
-
fileSizeError: "The file exceeds the maximum upload size",
|
|
14
|
-
fileTypeError: "File type not allowed for upload",
|
|
15
11
|
removeFileButtonLabel: "Remove File"
|
|
16
12
|
};
|
|
17
13
|
const HvFileUploader = (props) => {
|
|
18
14
|
const {
|
|
19
15
|
id,
|
|
20
16
|
className,
|
|
17
|
+
classes: classesProp,
|
|
21
18
|
labels: labelsProp,
|
|
22
19
|
fileList,
|
|
23
20
|
multiple = true,
|
|
24
|
-
|
|
25
|
-
hideLabels
|
|
21
|
+
label,
|
|
22
|
+
hideLabels,
|
|
26
23
|
maxFileSize = Infinity,
|
|
27
24
|
inputProps = {},
|
|
25
|
+
accept,
|
|
28
26
|
acceptedFiles = [],
|
|
27
|
+
// TODO: consider adding/replacing with onFilesChange
|
|
29
28
|
onFilesAdded,
|
|
30
29
|
onFileRemoved,
|
|
31
30
|
...others
|
|
32
31
|
} = useDefaultProps("HvFileUploader", props);
|
|
32
|
+
const { classes, cx } = useClasses(classesProp);
|
|
33
33
|
const labels = useLabels(DEFAULT_LABELS, labelsProp);
|
|
34
|
-
return /* @__PURE__ */ jsxs(
|
|
34
|
+
return /* @__PURE__ */ jsxs(HvFormElement, { id, className: cx(classes.root, className), ...others, children: [
|
|
35
35
|
/* @__PURE__ */ jsx(
|
|
36
36
|
HvDropZone,
|
|
37
37
|
{
|
|
38
38
|
id: setId(id, "dropzone"),
|
|
39
|
+
label,
|
|
39
40
|
labels,
|
|
40
41
|
multiple,
|
|
41
|
-
|
|
42
|
-
accept: acceptedFiles.join(","),
|
|
42
|
+
accept: accept ?? acceptedFiles.join(","),
|
|
43
43
|
maxFileSize,
|
|
44
44
|
onFilesAdded,
|
|
45
45
|
inputProps,
|
|
@@ -58,5 +58,6 @@ const HvFileUploader = (props) => {
|
|
|
58
58
|
] });
|
|
59
59
|
};
|
|
60
60
|
export {
|
|
61
|
-
HvFileUploader
|
|
61
|
+
HvFileUploader,
|
|
62
|
+
staticClasses as fileUploaderClasses
|
|
62
63
|
};
|