@panneau/field-upload 3.0.308 → 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.
@@ -1 +1 @@
1
- .panneau-field-upload-container{position:relative;width:100%}.panneau-field-upload-container .panneau-field-upload-dashboard{position:relative}.panneau-field-upload-container .panneau-field-upload-dashboardModal{position:relative;z-index:10001}.panneau-field-upload-container .panneau-field-upload-uppyDashboardContainer{margin-top:10px}
1
+ .panneau-field-upload-container{position:relative;width:100%}.panneau-field-upload-container .panneau-field-upload-dashboard{position:relative}.panneau-field-upload-container .panneau-field-upload-dashboardModal{position:relative;z-index:10001}.panneau-field-upload-container .panneau-field-upload-uppyDashboardContainer{margin-top:0}
package/es/index.js CHANGED
@@ -2,153 +2,116 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
5
- import { Dashboard, DashboardModal } from '@uppy/react';
5
+ import { UppyContextProvider } from '@uppy/react';
6
+ import Dashboard from '@uppy/react/dashboard';
7
+ import DashboardModal from '@uppy/react/dashboard-modal';
6
8
  import classNames from 'classnames';
7
9
  import isArray from 'lodash-es/isArray';
8
10
  import isObject from 'lodash-es/isObject';
9
- import PropTypes from 'prop-types';
10
11
  import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
11
12
  import { FormattedMessage } from 'react-intl';
12
- import { PropTypes as PropTypes$1 } from '@panneau/core';
13
13
  import { useQuery } from '@panneau/core/hooks';
14
14
  import Button from '@panneau/element-button';
15
15
  import Label from '@panneau/element-label';
16
16
  import MediaCard, { MediaCards } from '@panneau/element-media-card';
17
17
  import ModalResourceItems from '@panneau/modal-resource-items';
18
18
  import { useUppy } from '@panneau/uppy';
19
- import '@uppy/core/dist/style.css';
20
- import '@uppy/dashboard/dist/style.css';
21
- import '@uppy/drag-drop/dist/style.css';
22
- import '@uppy/status-bar/dist/style.css';
19
+ import '@uppy/core/css/style.css';
20
+ import '@uppy/dashboard/css/style.css';
23
21
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
24
22
 
25
23
  var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","dashboardModal":"panneau-field-upload-dashboardModal"};
26
24
 
27
- var propTypes$1 = {
28
- resource: PropTypes.string,
29
- value: PropTypes.oneOfType([PropTypes.array, PropTypes.shape({
30
- filename: PropTypes.string,
31
- size: PropTypes.number,
32
- url: PropTypes.string
33
- })]),
34
- name: PropTypes.string,
35
- types: PropTypes.arrayOf(PropTypes.oneOf(['audio', 'image', 'video', 'document'])),
36
- fileTypes: PropTypes.arrayOf(PropTypes.string),
37
- sources: PropTypes.arrayOf(PropTypes.oneOf(['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'])),
38
- withButton: PropTypes.bool,
39
- withFind: PropTypes.bool,
40
- withClearButton: PropTypes.bool,
41
- withoutMedia: PropTypes.bool,
42
- addButtonLabel: PropTypes$1.label,
43
- findButtonLabel: PropTypes$1.label,
44
- clearButtonLabel: PropTypes$1.label,
45
- allowMultipleUploads: PropTypes.bool,
46
- closeAfterFinish: PropTypes.bool,
47
- maxNumberOfFiles: PropTypes.number,
48
- namePath: PropTypes.string,
49
- thumbnailPath: PropTypes.string,
50
- sizePath: PropTypes.string,
51
- linkPath: PropTypes.string,
52
- uppyProps: PropTypes.shape({
53
- withUUID: PropTypes.bool
54
- }),
55
- width: PropTypes.number,
56
- height: PropTypes.number,
57
- disabled: PropTypes.bool,
58
- uploadDisabled: PropTypes.bool,
59
- outline: PropTypes.bool,
60
- loading: PropTypes.bool,
61
- onChange: PropTypes.func,
62
- onClear: PropTypes.func,
63
- onClickAdd: PropTypes.func,
64
- onClickFind: PropTypes.func,
65
- className: PropTypes.string
66
- };
67
- var defaultProps$1 = {
68
- resource: 'medias',
69
- value: null,
70
- name: null,
71
- types: ['audio', 'image', 'video'],
72
- fileTypes: null,
73
- sources: ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'],
74
- withButton: false,
75
- withFind: false,
76
- withClearButton: false,
77
- withoutMedia: false,
78
- addButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
25
+ // import '@uppy/react/css/style.css';
26
+
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, {
79
95
  id: "BeKVq6",
80
96
  defaultMessage: [{
81
97
  "type": 0,
82
98
  "value": "Upload file"
83
99
  }]
84
- }),
85
- findButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
100
+ });
101
+ var findButtonLabel = initialFindButtonLabel || /*#__PURE__*/React.createElement(FormattedMessage, {
86
102
  id: "une5WQ",
87
103
  defaultMessage: [{
88
104
  "type": 0,
89
105
  "value": "Find a file"
90
106
  }]
91
- }),
92
- clearButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
107
+ });
108
+ var clearButtonLabel = initialCleanButtonLabel || /*#__PURE__*/React.createElement(FormattedMessage, {
93
109
  id: "odaCUe",
94
110
  defaultMessage: [{
95
111
  "type": 0,
96
112
  "value": "Clear"
97
113
  }]
98
- }),
99
- allowMultipleUploads: false,
100
- closeAfterFinish: true,
101
- maxNumberOfFiles: 1,
102
- namePath: 'name',
103
- thumbnailPath: 'thumbnail_url',
104
- sizePath: 'metadata.size',
105
- linkPath: null,
106
- uppyProps: null,
107
- width: null,
108
- height: 300,
109
- disabled: false,
110
- uploadDisabled: false,
111
- outline: true,
112
- loading: false,
113
- onChange: null,
114
- onClear: null,
115
- onClickAdd: null,
116
- onClickFind: null,
117
- className: null
118
- };
119
- var UploadField = function UploadField(_ref) {
120
- var resource = _ref.resource,
121
- value = _ref.value,
122
- name = _ref.name,
123
- types = _ref.types,
124
- fileTypes = _ref.fileTypes,
125
- sources = _ref.sources,
126
- withButton = _ref.withButton,
127
- withFind = _ref.withFind,
128
- withClearButton = _ref.withClearButton,
129
- withoutMedia = _ref.withoutMedia,
130
- addButtonLabel = _ref.addButtonLabel,
131
- findButtonLabel = _ref.findButtonLabel,
132
- clearButtonLabel = _ref.clearButtonLabel,
133
- allowMultipleUploads = _ref.allowMultipleUploads,
134
- closeAfterFinish = _ref.closeAfterFinish,
135
- maxNumberOfFiles = _ref.maxNumberOfFiles,
136
- namePath = _ref.namePath,
137
- thumbnailPath = _ref.thumbnailPath,
138
- sizePath = _ref.sizePath,
139
- linkPath = _ref.linkPath,
140
- uppyProps = _ref.uppyProps,
141
- width = _ref.width,
142
- height = _ref.height,
143
- disabled = _ref.disabled,
144
- uploadDisabled = _ref.uploadDisabled,
145
- outline = _ref.outline,
146
- parentLoading = _ref.loading,
147
- onChange = _ref.onChange,
148
- onClear = _ref.onClear,
149
- onClickAdd = _ref.onClickAdd,
150
- onClickFind = _ref.onClickFind,
151
- className = _ref.className;
114
+ });
152
115
  var mergeData = useCallback(function (newValue) {
153
116
  // Merge the response from our back-end
154
117
  if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
@@ -174,7 +137,7 @@ var UploadField = function UploadField(_ref) {
174
137
  newValue = newValue.map(function (val) {
175
138
  return mergeData(val);
176
139
  });
177
- } else {
140
+ } else if (newValue !== null) {
178
141
  newValue = mergeData(newValue);
179
142
  }
180
143
 
@@ -264,7 +227,7 @@ var UploadField = function UploadField(_ref) {
264
227
  setModalItems = _useState6[1];
265
228
  var closeResourceModal = useCallback(function () {
266
229
  setResourceModalOpen(false);
267
- setModalItems(null);
230
+ setModalItems([]);
268
231
  }, [resourceModalOpen, setResourceModalOpen, setModalItems]);
269
232
  var finalOnClickFind = useCallback(function () {
270
233
  if (onClickFind !== null) {
@@ -309,7 +272,7 @@ var UploadField = function UploadField(_ref) {
309
272
  // Always multiple onchange
310
273
  onChange(modalItems);
311
274
  setResourceModalOpen(false);
312
- setModalItems(null);
275
+ setModalItems([]);
313
276
  }
314
277
  }, [onChange, setResourceModalOpen, modalItems, allowMultipleUploads, setModalItems]);
315
278
  var initialQuery = useMemo(function () {
@@ -324,7 +287,7 @@ var UploadField = function UploadField(_ref) {
324
287
  onListQueryReset = _useQuery.onQueryReset;
325
288
  var containerRef = useRef(null);
326
289
 
327
- // Keep this stable, uppy doesnt like
290
+ // Keep this stable, uppy doesnt like changes
328
291
  var _useState7 = useState(null),
329
292
  _useState8 = _slicedToArray(_useState7, 2),
330
293
  finalUppy = _useState8[0],
@@ -413,7 +376,9 @@ var UploadField = function UploadField(_ref) {
413
376
  onClick: finalOnClickFind,
414
377
  disabled: disabled,
415
378
  outline: outline
416
- }, /*#__PURE__*/React.createElement(Label, null, findButtonLabel))) : null) : null, !uploadDisabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
379
+ }, /*#__PURE__*/React.createElement(Label, null, findButtonLabel))) : null) : null, finalUppy !== null ? /*#__PURE__*/React.createElement(UppyContextProvider, {
380
+ uppy: finalUppy
381
+ }, !uploadDisabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/React.createElement("div", {
417
382
  className: styles.dashboard
418
383
  }, /*#__PURE__*/React.createElement(Dashboard, Object.assign({
419
384
  uppy: finalUppy
@@ -444,7 +409,7 @@ var UploadField = function UploadField(_ref) {
444
409
  showAddFilesPanel: true,
445
410
  doneButtonHandler: closeModal,
446
411
  closeAfterFinish: closeAfterFinish
447
- }) : null, showResourceModal ? /*#__PURE__*/React.createElement(ModalResourceItems, {
412
+ }) : null) : null, showResourceModal ? /*#__PURE__*/React.createElement(ModalResourceItems, {
448
413
  id: "upload-".concat(name),
449
414
  resource: resource,
450
415
  query: listQuery,
@@ -489,9 +454,7 @@ var UploadField = function UploadField(_ref) {
489
454
  "value": "Confirm selection"
490
455
  }]
491
456
  }))))) : null);
492
- };
493
- UploadField.propTypes = propTypes$1;
494
- UploadField.defaultProps = defaultProps$1;
457
+ }
495
458
 
496
459
  var definition = [{
497
460
  id: 'upload',
@@ -514,27 +477,27 @@ var definition = [{
514
477
  }];
515
478
 
516
479
  /* eslint-disable react/jsx-props-no-spreading */
517
- var AudioField = function AudioField(props) {
480
+ function AudioField(props) {
518
481
  var types = useMemo(function () {
519
482
  return ['audio'];
520
483
  }, []);
521
484
  return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
522
485
  types: types
523
486
  }));
524
- };
487
+ }
525
488
 
526
489
  /* eslint-disable react/jsx-props-no-spreading */
527
- var ImageField = function ImageField(props) {
490
+ function ImageField(props) {
528
491
  var types = useMemo(function () {
529
492
  return ['image'];
530
493
  }, []);
531
494
  return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
532
495
  types: types
533
496
  }));
534
- };
497
+ }
535
498
 
536
499
  /* eslint-disable react/jsx-props-no-spreading */
537
- var ImagesField = function ImagesField(props) {
500
+ function ImagesField(props) {
538
501
  var types = useMemo(function () {
539
502
  return ['image'];
540
503
  }, []);
@@ -542,20 +505,20 @@ var ImagesField = function ImagesField(props) {
542
505
  types: types,
543
506
  allowMultipleUploads: true
544
507
  }));
545
- };
508
+ }
546
509
 
547
510
  /* eslint-disable react/jsx-props-no-spreading */
548
- var VideoField = function VideoField(props) {
511
+ function VideoField(props) {
549
512
  var types = useMemo(function () {
550
513
  return ['video'];
551
514
  }, []);
552
515
  return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
553
516
  types: types
554
517
  }));
555
- };
518
+ }
556
519
 
557
520
  /* eslint-disable react/jsx-props-no-spreading */
558
- var DocumentField = function DocumentField(props) {
521
+ function DocumentField(props) {
559
522
  var fileTypes = useMemo(function () {
560
523
  return ['.pdf'];
561
524
  }, []);
@@ -566,38 +529,22 @@ var DocumentField = function DocumentField(props) {
566
529
  fileTypes: fileTypes,
567
530
  types: types
568
531
  }));
569
- };
532
+ }
570
533
 
571
534
  /* eslint-disable react/jsx-props-no-spreading */
572
- var FontField = function FontField(props) {
535
+ function FontField(props) {
573
536
  var fileTypes = useMemo(function () {
574
537
  return ['.ttf', '.otf'];
575
538
  }, []);
576
539
  return /*#__PURE__*/React.createElement(UploadField, Object.assign({}, props, {
577
540
  fileTypes: fileTypes
578
541
  }));
579
- };
542
+ }
580
543
 
581
544
  var _excluded = ["value", "onChange"];
582
- var propTypes = {
583
- value: PropTypes.shape({
584
- published: PropTypes.bool,
585
- featured: PropTypes.bool,
586
- created_at: PropTypes.string,
587
- updated_at: PropTypes.string
588
- }),
589
- onChange: PropTypes.func,
590
- types: PropTypes.arrayOf(PropTypes.string),
591
- fileTypes: PropTypes.arrayOf(PropTypes.string)
592
- };
593
- var defaultProps = {
594
- value: null,
595
- onChange: null,
596
- types: null,
597
- fileTypes: null
598
- };
599
- var UpdateFileField = function UpdateFileField(_ref) {
600
- var value = _ref.value;
545
+ function UpdateFileField(_ref) {
546
+ var _ref$value = _ref.value,
547
+ value = _ref$value === void 0 ? null : _ref$value;
601
548
  _ref.onChange;
602
549
  var props = _objectWithoutProperties(_ref, _excluded);
603
550
  var _useState = useState(null),
@@ -674,8 +621,6 @@ var UpdateFileField = function UpdateFileField(_ref) {
674
621
  withButton: true,
675
622
  uppyProps: uppyProps
676
623
  }))));
677
- };
678
- UpdateFileField.propTypes = propTypes;
679
- UpdateFileField.defaultProps = defaultProps;
624
+ }
680
625
 
681
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.0.308",
3
+ "version": "4.0.0",
4
4
  "description": "An Upload field",
5
5
  "keywords": [
6
6
  "javascript"
@@ -62,28 +62,25 @@
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": "^3.0.307",
66
- "@panneau/element-button": "^3.0.308",
67
- "@panneau/element-label": "^3.0.307",
68
- "@panneau/element-media-card": "^3.0.308",
69
- "@panneau/modal-resource-items": "^3.0.308",
70
- "@panneau/themes": "^3.0.308",
71
- "@panneau/uppy": "^3.0.307",
72
- "@uppy/core": "^3.9.1",
73
- "@uppy/dashboard": "^3.7.3",
74
- "@uppy/drag-drop": "^3.0.3",
75
- "@uppy/file-input": "^3.0.4",
76
- "@uppy/progress-bar": "^3.0.4",
77
- "@uppy/react": "^3.3.0",
78
- "@uppy/status-bar": "^3.2.7",
79
- "@uppy/utils": "^5.7.2",
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
+ "@uppy/core": "^5.1.1",
73
+ "@uppy/dashboard": "^5.0.4",
74
+ "@uppy/react": "^5.1.1",
75
+ "@uppy/utils": "^7.1.3",
80
76
  "classnames": "^2.5.1",
81
77
  "lodash-es": "^4.17.21",
82
78
  "prop-types": "^15.7.2",
83
- "react-intl": "^5.15.8||^6.0.0"
79
+ "react-intl": "^5.15.8 || ^6.0.0 || ^7.0.0",
80
+ "tailwindcss": "^4.1.17"
84
81
  },
85
82
  "publishConfig": {
86
83
  "access": "public"
87
84
  },
88
- "gitHead": "8711276a09fcda499a4a2f206554f9cd995976f5"
85
+ "gitHead": "2cca874e0388b4a20c39aadb205c0e67d5a946fc"
89
86
  }