@panneau/field-upload 3.0.310 → 4.0.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/es/index.js +93 -152
- package/package.json +10 -10
package/es/index.js
CHANGED
|
@@ -8,10 +8,8 @@ import DashboardModal from '@uppy/react/dashboard-modal';
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import isArray from 'lodash-es/isArray';
|
|
10
10
|
import isObject from 'lodash-es/isObject';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
11
|
import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
13
12
|
import { FormattedMessage } from 'react-intl';
|
|
14
|
-
import { PropTypes as PropTypes$1 } from '@panneau/core';
|
|
15
13
|
import { useQuery } from '@panneau/core/hooks';
|
|
16
14
|
import Button from '@panneau/element-button';
|
|
17
15
|
import Label from '@panneau/element-label';
|
|
@@ -26,131 +24,94 @@ var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-
|
|
|
26
24
|
|
|
27
25
|
// import '@uppy/react/css/style.css';
|
|
28
26
|
|
|
29
|
-
var
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
27
|
+
var DEFAULT_TYPES = ['audio', 'image', 'video'];
|
|
28
|
+
var DEFAULT_SOURCES = ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
|
|
29
|
+
function UploadField(_ref) {
|
|
30
|
+
var _ref$resource = _ref.resource,
|
|
31
|
+
resource = _ref$resource === void 0 ? 'medias' : _ref$resource,
|
|
32
|
+
_ref$value = _ref.value,
|
|
33
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
34
|
+
_ref$name = _ref.name,
|
|
35
|
+
name = _ref$name === void 0 ? null : _ref$name,
|
|
36
|
+
_ref$types = _ref.types,
|
|
37
|
+
types = _ref$types === void 0 ? DEFAULT_TYPES : _ref$types,
|
|
38
|
+
_ref$fileTypes = _ref.fileTypes,
|
|
39
|
+
fileTypes = _ref$fileTypes === void 0 ? null : _ref$fileTypes,
|
|
40
|
+
_ref$sources = _ref.sources,
|
|
41
|
+
sources = _ref$sources === void 0 ? DEFAULT_SOURCES : _ref$sources,
|
|
42
|
+
_ref$withButton = _ref.withButton,
|
|
43
|
+
withButton = _ref$withButton === void 0 ? false : _ref$withButton,
|
|
44
|
+
_ref$withFind = _ref.withFind,
|
|
45
|
+
withFind = _ref$withFind === void 0 ? false : _ref$withFind,
|
|
46
|
+
_ref$withClearButton = _ref.withClearButton,
|
|
47
|
+
withClearButton = _ref$withClearButton === void 0 ? false : _ref$withClearButton,
|
|
48
|
+
_ref$withoutMedia = _ref.withoutMedia,
|
|
49
|
+
withoutMedia = _ref$withoutMedia === void 0 ? false : _ref$withoutMedia,
|
|
50
|
+
_ref$addButtonLabel = _ref.addButtonLabel,
|
|
51
|
+
initialAddButtonLabel = _ref$addButtonLabel === void 0 ? null : _ref$addButtonLabel,
|
|
52
|
+
_ref$findButtonLabel = _ref.findButtonLabel,
|
|
53
|
+
initialFindButtonLabel = _ref$findButtonLabel === void 0 ? null : _ref$findButtonLabel,
|
|
54
|
+
_ref$clearButtonLabel = _ref.clearButtonLabel,
|
|
55
|
+
initialCleanButtonLabel = _ref$clearButtonLabel === void 0 ? null : _ref$clearButtonLabel,
|
|
56
|
+
_ref$allowMultipleUpl = _ref.allowMultipleUploads,
|
|
57
|
+
allowMultipleUploads = _ref$allowMultipleUpl === void 0 ? false : _ref$allowMultipleUpl,
|
|
58
|
+
_ref$closeAfterFinish = _ref.closeAfterFinish,
|
|
59
|
+
closeAfterFinish = _ref$closeAfterFinish === void 0 ? true : _ref$closeAfterFinish,
|
|
60
|
+
_ref$maxNumberOfFiles = _ref.maxNumberOfFiles,
|
|
61
|
+
maxNumberOfFiles = _ref$maxNumberOfFiles === void 0 ? 1 : _ref$maxNumberOfFiles,
|
|
62
|
+
_ref$namePath = _ref.namePath,
|
|
63
|
+
namePath = _ref$namePath === void 0 ? 'name' : _ref$namePath,
|
|
64
|
+
_ref$thumbnailPath = _ref.thumbnailPath,
|
|
65
|
+
thumbnailPath = _ref$thumbnailPath === void 0 ? 'thumbnail_url' : _ref$thumbnailPath,
|
|
66
|
+
_ref$sizePath = _ref.sizePath,
|
|
67
|
+
sizePath = _ref$sizePath === void 0 ? 'metadata.size' : _ref$sizePath,
|
|
68
|
+
_ref$linkPath = _ref.linkPath,
|
|
69
|
+
linkPath = _ref$linkPath === void 0 ? null : _ref$linkPath,
|
|
70
|
+
_ref$uppyProps = _ref.uppyProps,
|
|
71
|
+
uppyProps = _ref$uppyProps === void 0 ? null : _ref$uppyProps,
|
|
72
|
+
_ref$width = _ref.width,
|
|
73
|
+
width = _ref$width === void 0 ? null : _ref$width,
|
|
74
|
+
_ref$height = _ref.height,
|
|
75
|
+
height = _ref$height === void 0 ? 300 : _ref$height,
|
|
76
|
+
_ref$disabled = _ref.disabled,
|
|
77
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
78
|
+
_ref$uploadDisabled = _ref.uploadDisabled,
|
|
79
|
+
uploadDisabled = _ref$uploadDisabled === void 0 ? false : _ref$uploadDisabled,
|
|
80
|
+
_ref$outline = _ref.outline,
|
|
81
|
+
outline = _ref$outline === void 0 ? true : _ref$outline,
|
|
82
|
+
_ref$loading = _ref.loading,
|
|
83
|
+
parentLoading = _ref$loading === void 0 ? false : _ref$loading,
|
|
84
|
+
_ref$onChange = _ref.onChange,
|
|
85
|
+
onChange = _ref$onChange === void 0 ? null : _ref$onChange,
|
|
86
|
+
_ref$onClear = _ref.onClear,
|
|
87
|
+
onClear = _ref$onClear === void 0 ? null : _ref$onClear,
|
|
88
|
+
_ref$onClickAdd = _ref.onClickAdd,
|
|
89
|
+
onClickAdd = _ref$onClickAdd === void 0 ? null : _ref$onClickAdd,
|
|
90
|
+
_ref$onClickFind = _ref.onClickFind,
|
|
91
|
+
onClickFind = _ref$onClickFind === void 0 ? null : _ref$onClickFind,
|
|
92
|
+
_ref$className = _ref.className,
|
|
93
|
+
className = _ref$className === void 0 ? null : _ref$className;
|
|
94
|
+
var addButtonLabel = initialAddButtonLabel || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
81
95
|
id: "BeKVq6",
|
|
82
96
|
defaultMessage: [{
|
|
83
97
|
"type": 0,
|
|
84
98
|
"value": "Upload file"
|
|
85
99
|
}]
|
|
86
|
-
})
|
|
87
|
-
findButtonLabel
|
|
100
|
+
});
|
|
101
|
+
var findButtonLabel = initialFindButtonLabel || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
88
102
|
id: "une5WQ",
|
|
89
103
|
defaultMessage: [{
|
|
90
104
|
"type": 0,
|
|
91
105
|
"value": "Find a file"
|
|
92
106
|
}]
|
|
93
|
-
})
|
|
94
|
-
clearButtonLabel
|
|
107
|
+
});
|
|
108
|
+
var clearButtonLabel = initialCleanButtonLabel || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
95
109
|
id: "odaCUe",
|
|
96
110
|
defaultMessage: [{
|
|
97
111
|
"type": 0,
|
|
98
112
|
"value": "Clear"
|
|
99
113
|
}]
|
|
100
|
-
})
|
|
101
|
-
allowMultipleUploads: false,
|
|
102
|
-
closeAfterFinish: true,
|
|
103
|
-
maxNumberOfFiles: 1,
|
|
104
|
-
namePath: 'name',
|
|
105
|
-
thumbnailPath: 'thumbnail_url',
|
|
106
|
-
sizePath: 'metadata.size',
|
|
107
|
-
linkPath: null,
|
|
108
|
-
uppyProps: null,
|
|
109
|
-
width: null,
|
|
110
|
-
height: 300,
|
|
111
|
-
disabled: false,
|
|
112
|
-
uploadDisabled: false,
|
|
113
|
-
outline: true,
|
|
114
|
-
loading: false,
|
|
115
|
-
onChange: null,
|
|
116
|
-
onClear: null,
|
|
117
|
-
onClickAdd: null,
|
|
118
|
-
onClickFind: null,
|
|
119
|
-
className: null
|
|
120
|
-
};
|
|
121
|
-
var UploadField = function UploadField(_ref) {
|
|
122
|
-
var resource = _ref.resource,
|
|
123
|
-
value = _ref.value,
|
|
124
|
-
name = _ref.name,
|
|
125
|
-
types = _ref.types,
|
|
126
|
-
fileTypes = _ref.fileTypes,
|
|
127
|
-
sources = _ref.sources,
|
|
128
|
-
withButton = _ref.withButton,
|
|
129
|
-
withFind = _ref.withFind,
|
|
130
|
-
withClearButton = _ref.withClearButton,
|
|
131
|
-
withoutMedia = _ref.withoutMedia,
|
|
132
|
-
addButtonLabel = _ref.addButtonLabel,
|
|
133
|
-
findButtonLabel = _ref.findButtonLabel,
|
|
134
|
-
clearButtonLabel = _ref.clearButtonLabel,
|
|
135
|
-
allowMultipleUploads = _ref.allowMultipleUploads,
|
|
136
|
-
closeAfterFinish = _ref.closeAfterFinish,
|
|
137
|
-
maxNumberOfFiles = _ref.maxNumberOfFiles,
|
|
138
|
-
namePath = _ref.namePath,
|
|
139
|
-
thumbnailPath = _ref.thumbnailPath,
|
|
140
|
-
sizePath = _ref.sizePath,
|
|
141
|
-
linkPath = _ref.linkPath,
|
|
142
|
-
uppyProps = _ref.uppyProps,
|
|
143
|
-
width = _ref.width,
|
|
144
|
-
height = _ref.height,
|
|
145
|
-
disabled = _ref.disabled,
|
|
146
|
-
uploadDisabled = _ref.uploadDisabled,
|
|
147
|
-
outline = _ref.outline,
|
|
148
|
-
parentLoading = _ref.loading,
|
|
149
|
-
onChange = _ref.onChange,
|
|
150
|
-
onClear = _ref.onClear,
|
|
151
|
-
onClickAdd = _ref.onClickAdd,
|
|
152
|
-
onClickFind = _ref.onClickFind,
|
|
153
|
-
className = _ref.className;
|
|
114
|
+
});
|
|
154
115
|
var mergeData = useCallback(function (newValue) {
|
|
155
116
|
// Merge the response from our back-end
|
|
156
117
|
if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
|
|
@@ -176,7 +137,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
176
137
|
newValue = newValue.map(function (val) {
|
|
177
138
|
return mergeData(val);
|
|
178
139
|
});
|
|
179
|
-
} else {
|
|
140
|
+
} else if (newValue !== null) {
|
|
180
141
|
newValue = mergeData(newValue);
|
|
181
142
|
}
|
|
182
143
|
|
|
@@ -266,7 +227,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
266
227
|
setModalItems = _useState6[1];
|
|
267
228
|
var closeResourceModal = useCallback(function () {
|
|
268
229
|
setResourceModalOpen(false);
|
|
269
|
-
setModalItems(
|
|
230
|
+
setModalItems([]);
|
|
270
231
|
}, [resourceModalOpen, setResourceModalOpen, setModalItems]);
|
|
271
232
|
var finalOnClickFind = useCallback(function () {
|
|
272
233
|
if (onClickFind !== null) {
|
|
@@ -311,7 +272,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
311
272
|
// Always multiple onchange
|
|
312
273
|
onChange(modalItems);
|
|
313
274
|
setResourceModalOpen(false);
|
|
314
|
-
setModalItems(
|
|
275
|
+
setModalItems([]);
|
|
315
276
|
}
|
|
316
277
|
}, [onChange, setResourceModalOpen, modalItems, allowMultipleUploads, setModalItems]);
|
|
317
278
|
var initialQuery = useMemo(function () {
|
|
@@ -493,9 +454,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
493
454
|
"value": "Confirm selection"
|
|
494
455
|
}]
|
|
495
456
|
}))))) : null);
|
|
496
|
-
}
|
|
497
|
-
UploadField.propTypes = propTypes$1;
|
|
498
|
-
UploadField.defaultProps = defaultProps$1;
|
|
457
|
+
}
|
|
499
458
|
|
|
500
459
|
var definition = [{
|
|
501
460
|
id: 'upload',
|
|
@@ -518,27 +477,27 @@ var definition = [{
|
|
|
518
477
|
}];
|
|
519
478
|
|
|
520
479
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
521
|
-
|
|
480
|
+
function AudioField(props) {
|
|
522
481
|
var types = useMemo(function () {
|
|
523
482
|
return ['audio'];
|
|
524
483
|
}, []);
|
|
525
484
|
return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
|
|
526
485
|
types: types
|
|
527
486
|
}));
|
|
528
|
-
}
|
|
487
|
+
}
|
|
529
488
|
|
|
530
489
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
531
|
-
|
|
490
|
+
function ImageField(props) {
|
|
532
491
|
var types = useMemo(function () {
|
|
533
492
|
return ['image'];
|
|
534
493
|
}, []);
|
|
535
494
|
return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
|
|
536
495
|
types: types
|
|
537
496
|
}));
|
|
538
|
-
}
|
|
497
|
+
}
|
|
539
498
|
|
|
540
499
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
541
|
-
|
|
500
|
+
function ImagesField(props) {
|
|
542
501
|
var types = useMemo(function () {
|
|
543
502
|
return ['image'];
|
|
544
503
|
}, []);
|
|
@@ -546,20 +505,20 @@ var ImagesField = function ImagesField(props) {
|
|
|
546
505
|
types: types,
|
|
547
506
|
allowMultipleUploads: true
|
|
548
507
|
}));
|
|
549
|
-
}
|
|
508
|
+
}
|
|
550
509
|
|
|
551
510
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
552
|
-
|
|
511
|
+
function VideoField(props) {
|
|
553
512
|
var types = useMemo(function () {
|
|
554
513
|
return ['video'];
|
|
555
514
|
}, []);
|
|
556
515
|
return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
|
|
557
516
|
types: types
|
|
558
517
|
}));
|
|
559
|
-
}
|
|
518
|
+
}
|
|
560
519
|
|
|
561
520
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
562
|
-
|
|
521
|
+
function DocumentField(props) {
|
|
563
522
|
var fileTypes = useMemo(function () {
|
|
564
523
|
return ['.pdf'];
|
|
565
524
|
}, []);
|
|
@@ -570,38 +529,22 @@ var DocumentField = function DocumentField(props) {
|
|
|
570
529
|
fileTypes: fileTypes,
|
|
571
530
|
types: types
|
|
572
531
|
}));
|
|
573
|
-
}
|
|
532
|
+
}
|
|
574
533
|
|
|
575
534
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
576
|
-
|
|
535
|
+
function FontField(props) {
|
|
577
536
|
var fileTypes = useMemo(function () {
|
|
578
537
|
return ['.ttf', '.otf'];
|
|
579
538
|
}, []);
|
|
580
539
|
return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
|
|
581
540
|
fileTypes: fileTypes
|
|
582
541
|
}));
|
|
583
|
-
}
|
|
542
|
+
}
|
|
584
543
|
|
|
585
544
|
var _excluded = ["value", "onChange"];
|
|
586
|
-
|
|
587
|
-
value
|
|
588
|
-
|
|
589
|
-
featured: PropTypes.bool,
|
|
590
|
-
created_at: PropTypes.string,
|
|
591
|
-
updated_at: PropTypes.string
|
|
592
|
-
}),
|
|
593
|
-
onChange: PropTypes.func,
|
|
594
|
-
types: PropTypes.arrayOf(PropTypes.string),
|
|
595
|
-
fileTypes: PropTypes.arrayOf(PropTypes.string)
|
|
596
|
-
};
|
|
597
|
-
var defaultProps = {
|
|
598
|
-
value: null,
|
|
599
|
-
onChange: null,
|
|
600
|
-
types: null,
|
|
601
|
-
fileTypes: null
|
|
602
|
-
};
|
|
603
|
-
var UpdateFileField = function UpdateFileField(_ref) {
|
|
604
|
-
var value = _ref.value;
|
|
545
|
+
function UpdateFileField(_ref) {
|
|
546
|
+
var _ref$value = _ref.value,
|
|
547
|
+
value = _ref$value === void 0 ? null : _ref$value;
|
|
605
548
|
_ref.onChange;
|
|
606
549
|
var props = _objectWithoutProperties(_ref, _excluded);
|
|
607
550
|
var _useState = useState(null),
|
|
@@ -678,8 +621,6 @@ var UpdateFileField = function UpdateFileField(_ref) {
|
|
|
678
621
|
withButton: true,
|
|
679
622
|
uppyProps: uppyProps
|
|
680
623
|
}))));
|
|
681
|
-
}
|
|
682
|
-
UpdateFileField.propTypes = propTypes;
|
|
683
|
-
UpdateFileField.defaultProps = defaultProps;
|
|
624
|
+
}
|
|
684
625
|
|
|
685
626
|
export { AudioField, DocumentField, FontField, ImageField, ImagesField, UpdateFileField, VideoField, UploadField as default, definition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
63
63
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
64
64
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
65
|
-
"@panneau/core": "^
|
|
66
|
-
"@panneau/element-button": "^
|
|
67
|
-
"@panneau/element-label": "^
|
|
68
|
-
"@panneau/element-media-card": "^
|
|
69
|
-
"@panneau/modal-resource-items": "^
|
|
70
|
-
"@panneau/themes": "^
|
|
71
|
-
"@panneau/uppy": "^
|
|
65
|
+
"@panneau/core": "^4.0.0",
|
|
66
|
+
"@panneau/element-button": "^4.0.0",
|
|
67
|
+
"@panneau/element-label": "^4.0.0",
|
|
68
|
+
"@panneau/element-media-card": "^4.0.0",
|
|
69
|
+
"@panneau/modal-resource-items": "^4.0.0",
|
|
70
|
+
"@panneau/themes": "^4.0.0",
|
|
71
|
+
"@panneau/uppy": "^4.0.0",
|
|
72
72
|
"@uppy/core": "^5.1.1",
|
|
73
73
|
"@uppy/dashboard": "^5.0.4",
|
|
74
74
|
"@uppy/react": "^5.1.1",
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"classnames": "^2.5.1",
|
|
77
77
|
"lodash-es": "^4.17.21",
|
|
78
78
|
"prop-types": "^15.7.2",
|
|
79
|
-
"react-intl": "^5.15.8
|
|
79
|
+
"react-intl": "^5.15.8 || ^6.0.0 || ^7.0.0",
|
|
80
80
|
"tailwindcss": "^4.1.17"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "2cca874e0388b4a20c39aadb205c0e67d5a946fc"
|
|
86
86
|
}
|