@panneau/field-upload 3.0.191 → 3.0.193
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 +45 -5
- package/lib/index.js +45 -5
- package/package.json +9 -9
package/es/index.js
CHANGED
|
@@ -51,6 +51,7 @@ var propTypes$1 = {
|
|
|
51
51
|
width: PropTypes.number,
|
|
52
52
|
height: PropTypes.number,
|
|
53
53
|
disabled: PropTypes.bool,
|
|
54
|
+
loading: PropTypes.bool,
|
|
54
55
|
onChange: PropTypes.func,
|
|
55
56
|
onClear: PropTypes.func,
|
|
56
57
|
onClickAdd: PropTypes.func,
|
|
@@ -99,6 +100,7 @@ var defaultProps$1 = {
|
|
|
99
100
|
width: null,
|
|
100
101
|
height: 300,
|
|
101
102
|
disabled: false,
|
|
103
|
+
loading: false,
|
|
102
104
|
onChange: null,
|
|
103
105
|
onClear: null,
|
|
104
106
|
onClickAdd: null,
|
|
@@ -129,6 +131,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
129
131
|
width = _ref.width,
|
|
130
132
|
height = _ref.height,
|
|
131
133
|
disabled = _ref.disabled,
|
|
134
|
+
parentLoading = _ref.loading,
|
|
132
135
|
onChange = _ref.onChange,
|
|
133
136
|
onClear = _ref.onClear,
|
|
134
137
|
onClickAdd = _ref.onClickAdd;
|
|
@@ -311,6 +314,37 @@ var UploadField = function UploadField(_ref) {
|
|
|
311
314
|
setFinalUppy(uppy);
|
|
312
315
|
}
|
|
313
316
|
}, [uppy, finalUppy]);
|
|
317
|
+
|
|
318
|
+
// Uppy state
|
|
319
|
+
var _useState5 = useState(false),
|
|
320
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
321
|
+
loading = _useState6[0],
|
|
322
|
+
setLoading = _useState6[1];
|
|
323
|
+
var startLoading = useCallback(function () {
|
|
324
|
+
setLoading(true);
|
|
325
|
+
}, []);
|
|
326
|
+
var endLoading = useCallback(function () {
|
|
327
|
+
setLoading(false);
|
|
328
|
+
}, []);
|
|
329
|
+
useEffect(function () {
|
|
330
|
+
if (uppy !== null) {
|
|
331
|
+
uppy.on('upload', startLoading);
|
|
332
|
+
uppy.on('complete', endLoading);
|
|
333
|
+
uppy.on('upload-error', endLoading);
|
|
334
|
+
uppy.on('error', endLoading);
|
|
335
|
+
uppy.on('cancell-all', endLoading);
|
|
336
|
+
}
|
|
337
|
+
return function () {
|
|
338
|
+
if (uppy !== null) {
|
|
339
|
+
uppy.off('upload', startLoading);
|
|
340
|
+
uppy.off('complete', endLoading);
|
|
341
|
+
uppy.off('upload-error', endLoading);
|
|
342
|
+
uppy.off('error', endLoading);
|
|
343
|
+
uppy.off('cancell-all', endLoading);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}, [uppy, startLoading, endLoading]);
|
|
347
|
+
var finalLoading = loading || parentLoading;
|
|
314
348
|
return /*#__PURE__*/React.createElement("div", {
|
|
315
349
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
316
350
|
ref: containerRef
|
|
@@ -329,8 +363,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
329
363
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
330
364
|
type: "button",
|
|
331
365
|
theme: "primary",
|
|
332
|
-
onClick: onClickClear
|
|
333
|
-
outline: true
|
|
366
|
+
onClick: onClickClear
|
|
334
367
|
}, /*#__PURE__*/React.createElement(Label, null, clearButtonLabel)))) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && withButton ? /*#__PURE__*/React.createElement("div", {
|
|
335
368
|
className: "row"
|
|
336
369
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -339,10 +372,17 @@ var UploadField = function UploadField(_ref) {
|
|
|
339
372
|
id: "trigger-uppy",
|
|
340
373
|
type: "button",
|
|
341
374
|
theme: "primary",
|
|
375
|
+
icon: finalLoading ? 'loading' : 'upload',
|
|
376
|
+
iconPosition: "right",
|
|
342
377
|
onClick: onClickAdd || openModal,
|
|
343
|
-
disabled: disabled
|
|
344
|
-
|
|
345
|
-
|
|
378
|
+
disabled: finalLoading || disabled
|
|
379
|
+
}, /*#__PURE__*/React.createElement(Label, null, finalLoading ? /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
380
|
+
id: "NozDYd",
|
|
381
|
+
defaultMessage: [{
|
|
382
|
+
"type": 0,
|
|
383
|
+
"value": "Uploading"
|
|
384
|
+
}]
|
|
385
|
+
}) : addButtonLabel)))) : null, !disabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
|
|
346
386
|
className: styles.dashboard
|
|
347
387
|
}, /*#__PURE__*/React.createElement(Dashboard, Object.assign({
|
|
348
388
|
uppy: finalUppy
|
package/lib/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var propTypes$1 = {
|
|
|
55
55
|
width: PropTypes.number,
|
|
56
56
|
height: PropTypes.number,
|
|
57
57
|
disabled: PropTypes.bool,
|
|
58
|
+
loading: PropTypes.bool,
|
|
58
59
|
onChange: PropTypes.func,
|
|
59
60
|
onClear: PropTypes.func,
|
|
60
61
|
onClickAdd: PropTypes.func,
|
|
@@ -103,6 +104,7 @@ var defaultProps$1 = {
|
|
|
103
104
|
width: null,
|
|
104
105
|
height: 300,
|
|
105
106
|
disabled: false,
|
|
107
|
+
loading: false,
|
|
106
108
|
onChange: null,
|
|
107
109
|
onClear: null,
|
|
108
110
|
onClickAdd: null,
|
|
@@ -133,6 +135,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
133
135
|
width = _ref.width,
|
|
134
136
|
height = _ref.height,
|
|
135
137
|
disabled = _ref.disabled,
|
|
138
|
+
parentLoading = _ref.loading,
|
|
136
139
|
onChange = _ref.onChange,
|
|
137
140
|
onClear = _ref.onClear,
|
|
138
141
|
onClickAdd = _ref.onClickAdd;
|
|
@@ -315,6 +318,37 @@ var UploadField = function UploadField(_ref) {
|
|
|
315
318
|
setFinalUppy(uppy$1);
|
|
316
319
|
}
|
|
317
320
|
}, [uppy$1, finalUppy]);
|
|
321
|
+
|
|
322
|
+
// Uppy state
|
|
323
|
+
var _useState5 = React.useState(false),
|
|
324
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
325
|
+
loading = _useState6[0],
|
|
326
|
+
setLoading = _useState6[1];
|
|
327
|
+
var startLoading = React.useCallback(function () {
|
|
328
|
+
setLoading(true);
|
|
329
|
+
}, []);
|
|
330
|
+
var endLoading = React.useCallback(function () {
|
|
331
|
+
setLoading(false);
|
|
332
|
+
}, []);
|
|
333
|
+
React.useEffect(function () {
|
|
334
|
+
if (uppy$1 !== null) {
|
|
335
|
+
uppy$1.on('upload', startLoading);
|
|
336
|
+
uppy$1.on('complete', endLoading);
|
|
337
|
+
uppy$1.on('upload-error', endLoading);
|
|
338
|
+
uppy$1.on('error', endLoading);
|
|
339
|
+
uppy$1.on('cancell-all', endLoading);
|
|
340
|
+
}
|
|
341
|
+
return function () {
|
|
342
|
+
if (uppy$1 !== null) {
|
|
343
|
+
uppy$1.off('upload', startLoading);
|
|
344
|
+
uppy$1.off('complete', endLoading);
|
|
345
|
+
uppy$1.off('upload-error', endLoading);
|
|
346
|
+
uppy$1.off('error', endLoading);
|
|
347
|
+
uppy$1.off('cancell-all', endLoading);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}, [uppy$1, startLoading, endLoading]);
|
|
351
|
+
var finalLoading = loading || parentLoading;
|
|
318
352
|
return /*#__PURE__*/React.createElement("div", {
|
|
319
353
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
320
354
|
ref: containerRef
|
|
@@ -333,8 +367,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
333
367
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
334
368
|
type: "button",
|
|
335
369
|
theme: "primary",
|
|
336
|
-
onClick: onClickClear
|
|
337
|
-
outline: true
|
|
370
|
+
onClick: onClickClear
|
|
338
371
|
}, /*#__PURE__*/React.createElement(Label, null, clearButtonLabel)))) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && withButton ? /*#__PURE__*/React.createElement("div", {
|
|
339
372
|
className: "row"
|
|
340
373
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -343,10 +376,17 @@ var UploadField = function UploadField(_ref) {
|
|
|
343
376
|
id: "trigger-uppy",
|
|
344
377
|
type: "button",
|
|
345
378
|
theme: "primary",
|
|
379
|
+
icon: finalLoading ? 'loading' : 'upload',
|
|
380
|
+
iconPosition: "right",
|
|
346
381
|
onClick: onClickAdd || openModal,
|
|
347
|
-
disabled: disabled
|
|
348
|
-
|
|
349
|
-
|
|
382
|
+
disabled: finalLoading || disabled
|
|
383
|
+
}, /*#__PURE__*/React.createElement(Label, null, finalLoading ? /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
384
|
+
id: "NozDYd",
|
|
385
|
+
defaultMessage: [{
|
|
386
|
+
"type": 0,
|
|
387
|
+
"value": "Uploading"
|
|
388
|
+
}]
|
|
389
|
+
}) : addButtonLabel)))) : null, !disabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
|
|
350
390
|
className: styles.dashboard
|
|
351
391
|
}, /*#__PURE__*/React.createElement(react.Dashboard, Object.assign({
|
|
352
392
|
uppy: finalUppy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.193",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
58
58
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
59
59
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
60
|
-
"@panneau/core": "^3.0.
|
|
61
|
-
"@panneau/element-button": "^3.0.
|
|
62
|
-
"@panneau/element-label": "^3.0.
|
|
63
|
-
"@panneau/element-media-card": "^3.0.
|
|
64
|
-
"@panneau/list-resource-items": "^3.0.
|
|
65
|
-
"@panneau/themes": "^3.0.
|
|
66
|
-
"@panneau/uppy": "^3.0.
|
|
60
|
+
"@panneau/core": "^3.0.193",
|
|
61
|
+
"@panneau/element-button": "^3.0.193",
|
|
62
|
+
"@panneau/element-label": "^3.0.193",
|
|
63
|
+
"@panneau/element-media-card": "^3.0.193",
|
|
64
|
+
"@panneau/list-resource-items": "^3.0.193",
|
|
65
|
+
"@panneau/themes": "^3.0.193",
|
|
66
|
+
"@panneau/uppy": "^3.0.193",
|
|
67
67
|
"@uppy/core": "^3.9.1",
|
|
68
68
|
"@uppy/dashboard": "^3.7.3",
|
|
69
69
|
"@uppy/drag-drop": "^3.0.3",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "cd6f69216ddbee75b352f3bd1d39352ff3332848"
|
|
84
84
|
}
|