@neo4j-ndl/react 0.6.2 → 0.6.3
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.
|
@@ -15,6 +15,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) "Neo4j"
|
|
21
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
22
|
+
*
|
|
23
|
+
* This file is part of Neo4j.
|
|
24
|
+
*
|
|
25
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
26
|
+
* it under the terms of the GNU General Public License as published by
|
|
27
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
28
|
+
* (at your option) any later version.
|
|
29
|
+
*
|
|
30
|
+
* This program is distributed in the hope that it will be useful,
|
|
31
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
32
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
33
|
+
* GNU General Public License for more details.
|
|
34
|
+
*
|
|
35
|
+
* You should have received a copy of the GNU General Public License
|
|
36
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
37
|
+
*/
|
|
38
|
+
const react_1 = require("react");
|
|
39
|
+
const detect_browser_1 = require("detect-browser");
|
|
18
40
|
const classnames_1 = __importDefault(require("classnames"));
|
|
19
41
|
const Cloud_1 = __importDefault(require("./icons/Cloud"));
|
|
20
42
|
const File_1 = __importDefault(require("./icons/File"));
|
|
@@ -28,15 +50,8 @@ const react_dropzone_1 = require("react-dropzone");
|
|
|
28
50
|
*
|
|
29
51
|
*
|
|
30
52
|
*/
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
if (!paramAcceptedFiles)
|
|
34
|
-
return true;
|
|
35
|
-
const acceptedFileTypes = Array.isArray(paramAcceptedFiles)
|
|
36
|
-
? paramAcceptedFiles.join(',')
|
|
37
|
-
: paramAcceptedFiles;
|
|
38
|
-
return acceptedFileTypes.indexOf(fileType) > -1;
|
|
39
|
-
};
|
|
53
|
+
const browser = (0, detect_browser_1.detect)();
|
|
54
|
+
const isSafari = (browser === null || browser === void 0 ? void 0 : browser.name) === 'safari';
|
|
40
55
|
/**
|
|
41
56
|
*
|
|
42
57
|
*
|
|
@@ -45,38 +60,44 @@ const isFileValid = (fileType, paramAcceptedFiles) => {
|
|
|
45
60
|
*
|
|
46
61
|
*/
|
|
47
62
|
const DragAndDrop = (props) => {
|
|
48
|
-
var _a, _b, _c;
|
|
49
63
|
const { dropZoneOptions, supportedFilesDescription, loadingComponent, isTesting } = props, otherProps = __rest(props, ["dropZoneOptions", "supportedFilesDescription", "loadingComponent", "isTesting"]);
|
|
50
|
-
const
|
|
64
|
+
const [currentFileExtension, setCurrentFileExtension] = (0, react_1.useState)(null);
|
|
65
|
+
const { getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject, } = (0, react_dropzone_1.useDropzone)(Object.assign(Object.assign({
|
|
51
66
|
// If the developer does not pass this function, then the browser will automatically download the dragged file. To empty function avoids that.
|
|
52
|
-
onDrop: () => null
|
|
67
|
+
onDrop: () => null, onDragEnter: (event) => {
|
|
68
|
+
const { items } = event.dataTransfer;
|
|
69
|
+
if (items.length > 0) {
|
|
70
|
+
console.log(`Type will be ${items[0].type}`);
|
|
71
|
+
setCurrentFileExtension(items[0].type);
|
|
72
|
+
}
|
|
73
|
+
}, onDragLeave: () => setCurrentFileExtension(null) }, dropZoneOptions), { disabled: (dropZoneOptions === null || dropZoneOptions === void 0 ? void 0 : dropZoneOptions.disabled) || !!loadingComponent }));
|
|
53
74
|
const [dropZoneRef, { width }] = (0, react_use_1.useMeasure)();
|
|
54
75
|
/**
|
|
55
76
|
* Returns the file extension, and if not supported
|
|
56
77
|
* returns "???" to be displayed in the file icon.
|
|
57
78
|
*/
|
|
58
|
-
const getFileTypeAbbr = (
|
|
79
|
+
const getFileTypeAbbr = (0, react_1.useCallback)(() => {
|
|
59
80
|
var _a;
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
/**
|
|
82
|
+
* File API is not consistent across browsers.
|
|
83
|
+
* We will strive to support the best user experience possible
|
|
84
|
+
* in Chrome and Firefox and provide basic working functionality in Safari.
|
|
85
|
+
* Source: https://react-dropzone.js.org/#browser-limitations
|
|
86
|
+
*/
|
|
87
|
+
if (!isDragAccept) {
|
|
62
88
|
return '???';
|
|
63
89
|
}
|
|
64
90
|
else {
|
|
65
|
-
return (_a =
|
|
91
|
+
return (_a = currentFileExtension === null || currentFileExtension === void 0 ? void 0 : currentFileExtension.split('/').slice(-1).pop()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
66
92
|
}
|
|
67
|
-
};
|
|
68
|
-
const isDraggedFileValid = isDragActive &&
|
|
69
|
-
draggedFiles.length > 0 &&
|
|
70
|
-
isFileValid((_a = draggedFiles[0]) === null || _a === void 0 ? void 0 : _a.type, dropZoneOptions === null || dropZoneOptions === void 0 ? void 0 : dropZoneOptions.accept);
|
|
93
|
+
}, [isDragAccept, currentFileExtension]);
|
|
71
94
|
const isUploading = !!loadingComponent;
|
|
72
|
-
const computedFileImage = (isDragActive &&
|
|
95
|
+
const computedFileImage = (isDragActive && isDragAccept) || isUploading ? ((0, jsx_runtime_1.jsx)(File_1.default, {})) : ((0, jsx_runtime_1.jsx)(InvalidFile_1.default, {}));
|
|
73
96
|
const wrapperClasses = (0, classnames_1.default)(`ndl-drag-and-drop`, props.className, {
|
|
74
97
|
'drag-active': isDragActive,
|
|
75
|
-
'file-invalid': isDragActive &&
|
|
98
|
+
'file-invalid': isDragActive && isDragReject,
|
|
76
99
|
});
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, otherProps, { ref: dropZoneRef, className: wrapperClasses }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-inner-content" }, getRootProps(), { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps())), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-inner" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-header" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "upload-img-wrapper" }, { children: width > 230 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(isDragActive || isUploading) && !isTesting && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "upload-img-label" }, { children: getFileTypeAbbr(isUploading
|
|
78
|
-
? (_b = acceptedFiles[0]) === null || _b === void 0 ? void 0 : _b.type
|
|
79
|
-
: (_c = draggedFiles[0]) === null || _c === void 0 ? void 0 : _c.type) }))), isUploading || isDragActive ? (computedFileImage) : ((0, jsx_runtime_1.jsx)(Cloud_1.default, {}))] })) })), !isUploading && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dnd-title-container" }, { children: [(0, jsx_runtime_1.jsxs)("h5", Object.assign({ className: "dnd-title" }, { children: ["Drag ", (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "n-font-light" }, { children: "&" })), " Drop"] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dnd-subtitle" }, { children: [(0, jsx_runtime_1.jsx)("span", { children: "or" }), ' ', (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "dnd-browse-link" }, { children: "browse" }))] }))] })))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-footer" }, { children: [isUploading && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loadingComponent }), !isUploading && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "ndl-file-support-text" }, { children: supportedFilesDescription })))] }))] }))] })) })));
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, otherProps, { ref: dropZoneRef, className: wrapperClasses }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-inner-content" }, getRootProps(), { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps())), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-inner" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-header" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "upload-img-wrapper" }, { children: width > 230 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(isDragActive || isUploading) && !isTesting && !isSafari && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "upload-img-label" }, { children: getFileTypeAbbr() }))), (isUploading || isDragActive) && !isSafari ? (computedFileImage) : ((0, jsx_runtime_1.jsx)(Cloud_1.default, {}))] })) })), !isUploading && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dnd-title-container" }, { children: [(0, jsx_runtime_1.jsxs)("h5", Object.assign({ className: "dnd-title" }, { children: ["Drag ", (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "n-font-light" }, { children: "&" })), " Drop"] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dnd-subtitle" }, { children: [(0, jsx_runtime_1.jsx)("span", { children: "or" }), ' ', (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "dnd-browse-link" }, { children: "browse" }))] }))] })))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "ndl-drag-and-drop-footer" }, { children: [isUploading && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loadingComponent }), !isUploading && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "ndl-file-support-text" }, { children: supportedFilesDescription })))] }))] }))] })) })));
|
|
80
101
|
};
|
|
81
102
|
exports.default = DragAndDrop;
|
|
82
103
|
//# sourceMappingURL=DragAndDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/drag-and-drop/DragAndDrop.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/drag-and-drop/DragAndDrop.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iCAA8C;AAC9C,mDAAwC;AACxC,4DAAoC;AACpC,0DAAuC;AACvC,wDAAqC;AACrC,sEAAmD;AACnD,yCAAuC;AACvC,mDAA8D;AAyB9D;;;;;;GAMG;AAEH,MAAM,OAAO,GAAG,IAAA,uBAAM,GAAE,CAAC;AAEzB,MAAM,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IAC9C,MAAM,EACJ,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,KAEP,KAAK,EADJ,UAAU,UACX,KAAK,EANH,iFAML,CAAQ,CAAC;IAEV,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GACnD,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IAEhC,MAAM,EACJ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,GAAG,IAAA,4BAAW;QACb,8IAA8I;QAC9I,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAClB,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC;YACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC7C,uBAAuB,CAAC,KAAK,CAAC,CAAC,CA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,EAAI,EAC9B,+CAAK,SAAS,EAAC,yBAAyB,iBACtC,+CAAK,SAAS,EAAC,0BAA0B,iBACvC,8CAAK,SAAS,EAAC,oBAAoB,gBAEhC,KAAK,GAAG,GAAG,IAAI,CACd,6DACG,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,IAAI,CAC3D,+CAAM,SAAS,EAAC,kBAAkB,gBAC/B,eAAe,EAAE,IACb,CACR,EAEA,CAAC,WAAW,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC5C,iBAAiB,CAClB,CAAC,CAAC,CAAC,CACF,uBAAC,eAAU,KAAG,CACf,IACA,CACJ,IACG,EACL,CAAC,WAAW,IAAI,CACf,+CAAK,SAAS,EAAC,qBAAqB,iBAClC,8CAAI,SAAS,EAAC,WAAW,0BAClB,+CAAM,SAAS,EAAC,cAAc,uBAAS,cACzC,EACL,+CAAK,SAAS,EAAC,cAAc,iBAC3B,kDAAe,EAAC,GAAG,EACnB,+CAAM,SAAS,EAAC,iBAAiB,4BAAc,KAC3C,KACF,CACP,KACG,EACN,+CAAK,SAAS,EAAC,0BAA0B,iBACtC,WAAW,IAAI,2DAAG,gBAAgB,GAAI,EACtC,CAAC,WAAW,IAAI,CACf,8CAAK,SAAS,EAAC,uBAAuB,gBACnC,yBAAyB,IACtB,CACP,KACG,KACF,KACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
|
@@ -10,6 +10,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) "Neo4j"
|
|
16
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
+
*
|
|
18
|
+
* This file is part of Neo4j.
|
|
19
|
+
*
|
|
20
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
+
* it under the terms of the GNU General Public License as published by
|
|
22
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
+
* (at your option) any later version.
|
|
24
|
+
*
|
|
25
|
+
* This program is distributed in the hope that it will be useful,
|
|
26
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
+
* GNU General Public License for more details.
|
|
29
|
+
*
|
|
30
|
+
* You should have received a copy of the GNU General Public License
|
|
31
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
+
*/
|
|
33
|
+
import { useCallback, useState } from 'react';
|
|
34
|
+
import { detect } from 'detect-browser';
|
|
13
35
|
import classnames from 'classnames';
|
|
14
36
|
import CloudImage from './icons/Cloud';
|
|
15
37
|
import FileImage from './icons/File';
|
|
@@ -23,15 +45,8 @@ import { useDropzone } from 'react-dropzone';
|
|
|
23
45
|
*
|
|
24
46
|
*
|
|
25
47
|
*/
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
if (!paramAcceptedFiles)
|
|
29
|
-
return true;
|
|
30
|
-
const acceptedFileTypes = Array.isArray(paramAcceptedFiles)
|
|
31
|
-
? paramAcceptedFiles.join(',')
|
|
32
|
-
: paramAcceptedFiles;
|
|
33
|
-
return acceptedFileTypes.indexOf(fileType) > -1;
|
|
34
|
-
};
|
|
48
|
+
const browser = detect();
|
|
49
|
+
const isSafari = (browser === null || browser === void 0 ? void 0 : browser.name) === 'safari';
|
|
35
50
|
/**
|
|
36
51
|
*
|
|
37
52
|
*
|
|
@@ -40,38 +55,44 @@ const isFileValid = (fileType, paramAcceptedFiles) => {
|
|
|
40
55
|
*
|
|
41
56
|
*/
|
|
42
57
|
const DragAndDrop = (props) => {
|
|
43
|
-
var _a, _b, _c;
|
|
44
58
|
const { dropZoneOptions, supportedFilesDescription, loadingComponent, isTesting } = props, otherProps = __rest(props, ["dropZoneOptions", "supportedFilesDescription", "loadingComponent", "isTesting"]);
|
|
45
|
-
const
|
|
59
|
+
const [currentFileExtension, setCurrentFileExtension] = useState(null);
|
|
60
|
+
const { getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject, } = useDropzone(Object.assign(Object.assign({
|
|
46
61
|
// If the developer does not pass this function, then the browser will automatically download the dragged file. To empty function avoids that.
|
|
47
|
-
onDrop: () => null
|
|
62
|
+
onDrop: () => null, onDragEnter: (event) => {
|
|
63
|
+
const { items } = event.dataTransfer;
|
|
64
|
+
if (items.length > 0) {
|
|
65
|
+
console.log(`Type will be ${items[0].type}`);
|
|
66
|
+
setCurrentFileExtension(items[0].type);
|
|
67
|
+
}
|
|
68
|
+
}, onDragLeave: () => setCurrentFileExtension(null) }, dropZoneOptions), { disabled: (dropZoneOptions === null || dropZoneOptions === void 0 ? void 0 : dropZoneOptions.disabled) || !!loadingComponent }));
|
|
48
69
|
const [dropZoneRef, { width }] = useMeasure();
|
|
49
70
|
/**
|
|
50
71
|
* Returns the file extension, and if not supported
|
|
51
72
|
* returns "???" to be displayed in the file icon.
|
|
52
73
|
*/
|
|
53
|
-
const getFileTypeAbbr = (
|
|
74
|
+
const getFileTypeAbbr = useCallback(() => {
|
|
54
75
|
var _a;
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
/**
|
|
77
|
+
* File API is not consistent across browsers.
|
|
78
|
+
* We will strive to support the best user experience possible
|
|
79
|
+
* in Chrome and Firefox and provide basic working functionality in Safari.
|
|
80
|
+
* Source: https://react-dropzone.js.org/#browser-limitations
|
|
81
|
+
*/
|
|
82
|
+
if (!isDragAccept) {
|
|
57
83
|
return '???';
|
|
58
84
|
}
|
|
59
85
|
else {
|
|
60
|
-
return (_a =
|
|
86
|
+
return (_a = currentFileExtension === null || currentFileExtension === void 0 ? void 0 : currentFileExtension.split('/').slice(-1).pop()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
61
87
|
}
|
|
62
|
-
};
|
|
63
|
-
const isDraggedFileValid = isDragActive &&
|
|
64
|
-
draggedFiles.length > 0 &&
|
|
65
|
-
isFileValid((_a = draggedFiles[0]) === null || _a === void 0 ? void 0 : _a.type, dropZoneOptions === null || dropZoneOptions === void 0 ? void 0 : dropZoneOptions.accept);
|
|
88
|
+
}, [isDragAccept, currentFileExtension]);
|
|
66
89
|
const isUploading = !!loadingComponent;
|
|
67
|
-
const computedFileImage = (isDragActive &&
|
|
90
|
+
const computedFileImage = (isDragActive && isDragAccept) || isUploading ? (_jsx(FileImage, {})) : (_jsx(InvalidFileImage, {}));
|
|
68
91
|
const wrapperClasses = classnames(`ndl-drag-and-drop`, props.className, {
|
|
69
92
|
'drag-active': isDragActive,
|
|
70
|
-
'file-invalid': isDragActive &&
|
|
93
|
+
'file-invalid': isDragActive && isDragReject,
|
|
71
94
|
});
|
|
72
|
-
return (_jsx("div", Object.assign({}, otherProps, { ref: dropZoneRef, className: wrapperClasses }, { children: _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-inner-content" }, getRootProps(), { children: [_jsx("input", Object.assign({}, getInputProps())), _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-inner" }, { children: [_jsxs("div", Object.assign({ className: "ndl-drag-and-drop-header" }, { children: [_jsx("div", Object.assign({ className: "upload-img-wrapper" }, { children: width > 230 && (_jsxs(_Fragment, { children: [(isDragActive || isUploading) && !isTesting && (_jsx("span", Object.assign({ className: "upload-img-label" }, { children: getFileTypeAbbr(isUploading
|
|
73
|
-
? (_b = acceptedFiles[0]) === null || _b === void 0 ? void 0 : _b.type
|
|
74
|
-
: (_c = draggedFiles[0]) === null || _c === void 0 ? void 0 : _c.type) }))), isUploading || isDragActive ? (computedFileImage) : (_jsx(CloudImage, {}))] })) })), !isUploading && (_jsxs("div", Object.assign({ className: "dnd-title-container" }, { children: [_jsxs("h5", Object.assign({ className: "dnd-title" }, { children: ["Drag ", _jsx("span", Object.assign({ className: "n-font-light" }, { children: "&" })), " Drop"] })), _jsxs("div", Object.assign({ className: "dnd-subtitle" }, { children: [_jsx("span", { children: "or" }), ' ', _jsx("span", Object.assign({ className: "dnd-browse-link" }, { children: "browse" }))] }))] })))] })), _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-footer" }, { children: [isUploading && _jsx(_Fragment, { children: loadingComponent }), !isUploading && (_jsx("div", Object.assign({ className: "ndl-file-support-text" }, { children: supportedFilesDescription })))] }))] }))] })) })));
|
|
95
|
+
return (_jsx("div", Object.assign({}, otherProps, { ref: dropZoneRef, className: wrapperClasses }, { children: _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-inner-content" }, getRootProps(), { children: [_jsx("input", Object.assign({}, getInputProps())), _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-inner" }, { children: [_jsxs("div", Object.assign({ className: "ndl-drag-and-drop-header" }, { children: [_jsx("div", Object.assign({ className: "upload-img-wrapper" }, { children: width > 230 && (_jsxs(_Fragment, { children: [(isDragActive || isUploading) && !isTesting && !isSafari && (_jsx("span", Object.assign({ className: "upload-img-label" }, { children: getFileTypeAbbr() }))), (isUploading || isDragActive) && !isSafari ? (computedFileImage) : (_jsx(CloudImage, {}))] })) })), !isUploading && (_jsxs("div", Object.assign({ className: "dnd-title-container" }, { children: [_jsxs("h5", Object.assign({ className: "dnd-title" }, { children: ["Drag ", _jsx("span", Object.assign({ className: "n-font-light" }, { children: "&" })), " Drop"] })), _jsxs("div", Object.assign({ className: "dnd-subtitle" }, { children: [_jsx("span", { children: "or" }), ' ', _jsx("span", Object.assign({ className: "dnd-browse-link" }, { children: "browse" }))] }))] })))] })), _jsxs("div", Object.assign({ className: "ndl-drag-and-drop-footer" }, { children: [isUploading && _jsx(_Fragment, { children: loadingComponent }), !isUploading && (_jsx("div", Object.assign({ className: "ndl-file-support-text" }, { children: supportedFilesDescription })))] }))] }))] })) })));
|
|
75
96
|
};
|
|
76
97
|
export default DragAndDrop;
|
|
77
98
|
//# sourceMappingURL=DragAndDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/drag-and-drop/DragAndDrop.tsx"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/drag-and-drop/DragAndDrop.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAmB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAyB9D;;;;;;GAMG;AAEH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB,MAAM,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IAC9C,MAAM,EACJ,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,KAEP,KAAK,EADJ,UAAU,UACX,KAAK,EANH,iFAML,CAAQ,CAAC;IAEV,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GACnD,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAEhC,MAAM,EACJ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,GAAG,WAAW;QACb,8IAA8I;QAC9I,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAClB,WAAW,E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y of the GNU General Public License
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
/// <reference types="react" />
|
|
22
22
|
import { DropzoneOptions } from 'react-dropzone';
|
|
23
23
|
import { ElementBase } from '../helpers';
|
|
24
24
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "React implementation of Neo4j Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"button",
|
|
@@ -68,9 +68,10 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@heroicons/react": "^1.0.5",
|
|
71
|
-
"@neo4j-ndl/base": "^0.6.
|
|
71
|
+
"@neo4j-ndl/base": "^0.6.2",
|
|
72
72
|
"classnames": "^2.3.1",
|
|
73
|
-
"
|
|
73
|
+
"detect-browser": "^5.3.0",
|
|
74
|
+
"react-dropzone": "^14.0.0",
|
|
74
75
|
"react-select": "^5.3.2",
|
|
75
76
|
"react-table": "^7.7.0",
|
|
76
77
|
"react-use": "^17.4.0"
|