@panneau/field-upload 3.0.190 → 3.0.192

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 CHANGED
@@ -311,6 +311,36 @@ var UploadField = function UploadField(_ref) {
311
311
  setFinalUppy(uppy);
312
312
  }
313
313
  }, [uppy, finalUppy]);
314
+
315
+ // Uppy state
316
+ var _useState5 = useState(false),
317
+ _useState6 = _slicedToArray(_useState5, 2),
318
+ loading = _useState6[0],
319
+ setLoading = _useState6[1];
320
+ var startLoading = useCallback(function () {
321
+ setLoading(true);
322
+ }, []);
323
+ var endLoading = useCallback(function () {
324
+ setLoading(false);
325
+ }, []);
326
+ useEffect(function () {
327
+ if (uppy !== null) {
328
+ uppy.on('upload', startLoading);
329
+ uppy.on('complete', endLoading);
330
+ uppy.on('upload-error', endLoading);
331
+ uppy.on('error', endLoading);
332
+ uppy.on('cancell-all', endLoading);
333
+ }
334
+ return function () {
335
+ if (uppy !== null) {
336
+ uppy.off('upload', startLoading);
337
+ uppy.off('complete', endLoading);
338
+ uppy.off('upload-error', endLoading);
339
+ uppy.off('error', endLoading);
340
+ uppy.off('cancell-all', endLoading);
341
+ }
342
+ };
343
+ }, [uppy, startLoading, endLoading]);
314
344
  return /*#__PURE__*/React.createElement("div", {
315
345
  className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
316
346
  ref: containerRef
@@ -329,8 +359,7 @@ var UploadField = function UploadField(_ref) {
329
359
  }, /*#__PURE__*/React.createElement(Button, {
330
360
  type: "button",
331
361
  theme: "primary",
332
- onClick: onClickClear,
333
- outline: true
362
+ onClick: onClickClear
334
363
  }, /*#__PURE__*/React.createElement(Label, null, clearButtonLabel)))) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && withButton ? /*#__PURE__*/React.createElement("div", {
335
364
  className: "row"
336
365
  }, /*#__PURE__*/React.createElement("div", {
@@ -339,10 +368,17 @@ var UploadField = function UploadField(_ref) {
339
368
  id: "trigger-uppy",
340
369
  type: "button",
341
370
  theme: "primary",
371
+ icon: loading ? 'loading' : 'upload',
372
+ iconPosition: "right",
342
373
  onClick: onClickAdd || openModal,
343
- disabled: disabled,
344
- outline: true
345
- }, /*#__PURE__*/React.createElement(Label, null, addButtonLabel)))) : null, !disabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
374
+ disabled: loading || disabled
375
+ }, /*#__PURE__*/React.createElement(Label, null, loading ? /*#__PURE__*/React.createElement(FormattedMessage, {
376
+ id: "NozDYd",
377
+ defaultMessage: [{
378
+ "type": 0,
379
+ "value": "Uploading"
380
+ }]
381
+ }) : addButtonLabel)))) : null, !disabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
346
382
  className: styles.dashboard
347
383
  }, /*#__PURE__*/React.createElement(Dashboard, Object.assign({
348
384
  uppy: finalUppy
package/lib/index.js CHANGED
@@ -315,6 +315,36 @@ var UploadField = function UploadField(_ref) {
315
315
  setFinalUppy(uppy$1);
316
316
  }
317
317
  }, [uppy$1, finalUppy]);
318
+
319
+ // Uppy state
320
+ var _useState5 = React.useState(false),
321
+ _useState6 = _slicedToArray(_useState5, 2),
322
+ loading = _useState6[0],
323
+ setLoading = _useState6[1];
324
+ var startLoading = React.useCallback(function () {
325
+ setLoading(true);
326
+ }, []);
327
+ var endLoading = React.useCallback(function () {
328
+ setLoading(false);
329
+ }, []);
330
+ React.useEffect(function () {
331
+ if (uppy$1 !== null) {
332
+ uppy$1.on('upload', startLoading);
333
+ uppy$1.on('complete', endLoading);
334
+ uppy$1.on('upload-error', endLoading);
335
+ uppy$1.on('error', endLoading);
336
+ uppy$1.on('cancell-all', endLoading);
337
+ }
338
+ return function () {
339
+ if (uppy$1 !== null) {
340
+ uppy$1.off('upload', startLoading);
341
+ uppy$1.off('complete', endLoading);
342
+ uppy$1.off('upload-error', endLoading);
343
+ uppy$1.off('error', endLoading);
344
+ uppy$1.off('cancell-all', endLoading);
345
+ }
346
+ };
347
+ }, [uppy$1, startLoading, endLoading]);
318
348
  return /*#__PURE__*/React.createElement("div", {
319
349
  className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
320
350
  ref: containerRef
@@ -333,8 +363,7 @@ var UploadField = function UploadField(_ref) {
333
363
  }, /*#__PURE__*/React.createElement(Button, {
334
364
  type: "button",
335
365
  theme: "primary",
336
- onClick: onClickClear,
337
- outline: true
366
+ onClick: onClickClear
338
367
  }, /*#__PURE__*/React.createElement(Label, null, clearButtonLabel)))) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && withButton ? /*#__PURE__*/React.createElement("div", {
339
368
  className: "row"
340
369
  }, /*#__PURE__*/React.createElement("div", {
@@ -343,10 +372,17 @@ var UploadField = function UploadField(_ref) {
343
372
  id: "trigger-uppy",
344
373
  type: "button",
345
374
  theme: "primary",
375
+ icon: loading ? 'loading' : 'upload',
376
+ iconPosition: "right",
346
377
  onClick: onClickAdd || openModal,
347
- disabled: disabled,
348
- outline: true
349
- }, /*#__PURE__*/React.createElement(Label, null, addButtonLabel)))) : null, !disabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
378
+ disabled: loading || disabled
379
+ }, /*#__PURE__*/React.createElement(Label, null, loading ? /*#__PURE__*/React.createElement(reactIntl.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", {
350
386
  className: styles.dashboard
351
387
  }, /*#__PURE__*/React.createElement(react.Dashboard, Object.assign({
352
388
  uppy: finalUppy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/field-upload",
3
- "version": "3.0.190",
3
+ "version": "3.0.192",
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.190",
61
- "@panneau/element-button": "^3.0.190",
62
- "@panneau/element-label": "^3.0.190",
63
- "@panneau/element-media-card": "^3.0.190",
64
- "@panneau/list-resource-items": "^3.0.190",
65
- "@panneau/themes": "^3.0.190",
66
- "@panneau/uppy": "^3.0.190",
60
+ "@panneau/core": "^3.0.192",
61
+ "@panneau/element-button": "^3.0.192",
62
+ "@panneau/element-label": "^3.0.192",
63
+ "@panneau/element-media-card": "^3.0.192",
64
+ "@panneau/list-resource-items": "^3.0.192",
65
+ "@panneau/themes": "^3.0.192",
66
+ "@panneau/uppy": "^3.0.192",
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": "ec38fa9c18606a8d5566183b8acf659a894eca0d"
83
+ "gitHead": "fdea2ce9766bf695810d652ddd7db8d768ea5332"
84
84
  }