@panneau/field-upload 3.0.134 → 3.0.135
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 +113 -27
- package/lib/index.js +114 -27
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -13,7 +13,7 @@ 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
|
-
import { MediaCards } from '@panneau/element-media-card';
|
|
16
|
+
import MediaCard, { MediaCards } from '@panneau/element-media-card';
|
|
17
17
|
import ResourceItemsList from '@panneau/list-resource-items';
|
|
18
18
|
import Dialog from '@panneau/modal-dialog';
|
|
19
19
|
import { useUppy } from '@panneau/uppy';
|
|
@@ -21,10 +21,11 @@ import '@uppy/core/dist/style.css';
|
|
|
21
21
|
import '@uppy/dashboard/dist/style.css';
|
|
22
22
|
import '@uppy/drag-drop/dist/style.css';
|
|
23
23
|
import '@uppy/status-bar/dist/style.css';
|
|
24
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
24
25
|
|
|
25
26
|
var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","dashboardModal":"panneau-field-upload-dashboardModal","uppyDashboardContainer":"panneau-field-upload-uppyDashboardContainer"};
|
|
26
27
|
|
|
27
|
-
var propTypes = {
|
|
28
|
+
var propTypes$1 = {
|
|
28
29
|
value: PropTypes.oneOfType([PropTypes.array, PropTypes.shape({
|
|
29
30
|
filename: PropTypes.string,
|
|
30
31
|
size: PropTypes.number,
|
|
@@ -60,7 +61,7 @@ var propTypes = {
|
|
|
60
61
|
onClickFind: PropTypes.func,
|
|
61
62
|
className: PropTypes.string
|
|
62
63
|
};
|
|
63
|
-
var defaultProps = {
|
|
64
|
+
var defaultProps$1 = {
|
|
64
65
|
value: null,
|
|
65
66
|
types: ['audio', 'image', 'video'],
|
|
66
67
|
fileTypes: null,
|
|
@@ -417,27 +418,10 @@ var UploadField = function UploadField(_ref) {
|
|
|
417
418
|
onQueryChange: onListQueryChange,
|
|
418
419
|
onQueryReset: onListQueryReset,
|
|
419
420
|
baseUrl: null,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
getSelectPropsFromItem: function getSelectPropsFromItem(item) {
|
|
425
|
-
var _ref6 = item || {},
|
|
426
|
-
_ref6$id = _ref6.id,
|
|
427
|
-
itemId = _ref6$id === void 0 ? null : _ref6$id;
|
|
428
|
-
var found = (modalItems || []).find(function () {
|
|
429
|
-
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
430
|
-
_ref7$id = _ref7.id,
|
|
431
|
-
modalItemId = _ref7$id === void 0 ? null : _ref7$id;
|
|
432
|
-
return modalItemId === itemId;
|
|
433
|
-
});
|
|
434
|
-
return {
|
|
435
|
-
outline: !found
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
withoutActionsColumn: true
|
|
440
|
-
}
|
|
421
|
+
showActions: false,
|
|
422
|
+
selectable: true,
|
|
423
|
+
onSelectionChange: onClickSelect,
|
|
424
|
+
multiple: allowMultipleUploads
|
|
441
425
|
}), allowMultipleUploads ? /*#__PURE__*/React.createElement("div", {
|
|
442
426
|
className: "d-flex mt-4 justify-content-between"
|
|
443
427
|
}, modalItems !== null && modalItems.length > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -458,8 +442,8 @@ var UploadField = function UploadField(_ref) {
|
|
|
458
442
|
className: "d-block"
|
|
459
443
|
}, /*#__PURE__*/React.createElement(Label, null, confirmButtonLabel)))) : null) : null);
|
|
460
444
|
};
|
|
461
|
-
UploadField.propTypes = propTypes;
|
|
462
|
-
UploadField.defaultProps = defaultProps;
|
|
445
|
+
UploadField.propTypes = propTypes$1;
|
|
446
|
+
UploadField.defaultProps = defaultProps$1;
|
|
463
447
|
var UploadField$1 = UploadField;
|
|
464
448
|
|
|
465
449
|
var definition = [{
|
|
@@ -553,4 +537,106 @@ var FontField = function FontField(props) {
|
|
|
553
537
|
};
|
|
554
538
|
var FontField$1 = FontField;
|
|
555
539
|
|
|
556
|
-
|
|
540
|
+
var _excluded = ["value", "onChange"];
|
|
541
|
+
var propTypes = {
|
|
542
|
+
value: PropTypes.shape({
|
|
543
|
+
published: PropTypes.bool,
|
|
544
|
+
featured: PropTypes.bool,
|
|
545
|
+
created_at: PropTypes.string,
|
|
546
|
+
updated_at: PropTypes.string
|
|
547
|
+
}),
|
|
548
|
+
onChange: PropTypes.func,
|
|
549
|
+
types: PropTypes.arrayOf(PropTypes.string),
|
|
550
|
+
fileTypes: PropTypes.arrayOf(PropTypes.string)
|
|
551
|
+
};
|
|
552
|
+
var defaultProps = {
|
|
553
|
+
value: null,
|
|
554
|
+
onChange: null,
|
|
555
|
+
types: null,
|
|
556
|
+
fileTypes: null
|
|
557
|
+
};
|
|
558
|
+
var UpdateFileField = function UpdateFileField(_ref) {
|
|
559
|
+
var value = _ref.value;
|
|
560
|
+
_ref.onChange;
|
|
561
|
+
var props = _objectWithoutProperties(_ref, _excluded);
|
|
562
|
+
var _useState = useState(null),
|
|
563
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
564
|
+
newValue = _useState2[0],
|
|
565
|
+
setNewValue = _useState2[1];
|
|
566
|
+
var _useState3 = useState(null),
|
|
567
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
568
|
+
visibleFile = _useState4[0],
|
|
569
|
+
setVisibleFile = _useState4[1];
|
|
570
|
+
var _ref2 = value || {},
|
|
571
|
+
previousId = _ref2.id,
|
|
572
|
+
_ref2$type = _ref2.type,
|
|
573
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
574
|
+
var onUploadChange = useCallback(function () {
|
|
575
|
+
var uploadedFile = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
576
|
+
if (uploadedFile !== null) {
|
|
577
|
+
setVisibleFile(uploadedFile);
|
|
578
|
+
}
|
|
579
|
+
setNewValue(uploadedFile);
|
|
580
|
+
}, [setNewValue, setVisibleFile]);
|
|
581
|
+
var uppyProps = useMemo(function () {
|
|
582
|
+
return {
|
|
583
|
+
meta: {
|
|
584
|
+
previousId: previousId
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}, [previousId]);
|
|
588
|
+
var uploadProps = useMemo(function () {
|
|
589
|
+
if (type === 'image') {
|
|
590
|
+
return {
|
|
591
|
+
types: ['image']
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
if (type === 'audio') {
|
|
595
|
+
return {
|
|
596
|
+
types: ['audio']
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (type === 'video') {
|
|
600
|
+
return {
|
|
601
|
+
types: ['video']
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
if (type === 'document') {
|
|
605
|
+
return {
|
|
606
|
+
types: [],
|
|
607
|
+
fileTypes: ['.pdf']
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
}, [type]);
|
|
612
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
613
|
+
className: "mb-3"
|
|
614
|
+
}, /*#__PURE__*/React.createElement(MediaCard, {
|
|
615
|
+
value: visibleFile || value,
|
|
616
|
+
withoutDescription: true
|
|
617
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
618
|
+
className: "mb-3"
|
|
619
|
+
}, /*#__PURE__*/React.createElement(UploadField$1, Object.assign({}, props, uploadProps, {
|
|
620
|
+
addButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
621
|
+
id: "daHjZg",
|
|
622
|
+
defaultMessage: [{
|
|
623
|
+
"type": 0,
|
|
624
|
+
"value": "Edit file"
|
|
625
|
+
}]
|
|
626
|
+
}),
|
|
627
|
+
allowMultipleUploads: false,
|
|
628
|
+
multiple: false,
|
|
629
|
+
linkPath: "panneauUrl",
|
|
630
|
+
onChange: onUploadChange,
|
|
631
|
+
onClose: onUploadChange,
|
|
632
|
+
maxNumberOfFiles: 1,
|
|
633
|
+
value: newValue,
|
|
634
|
+
withButton: true,
|
|
635
|
+
uppyProps: uppyProps
|
|
636
|
+
}))));
|
|
637
|
+
};
|
|
638
|
+
UpdateFileField.propTypes = propTypes;
|
|
639
|
+
UpdateFileField.defaultProps = defaultProps;
|
|
640
|
+
var UpdateFileField$1 = UpdateFileField;
|
|
641
|
+
|
|
642
|
+
export { AudioField$1 as AudioField, DocumentField$1 as DocumentField, FontField$1 as FontField, ImageField$1 as ImageField, ImagesField$1 as ImagesField, UpdateFileField$1 as UpdateFileField, VideoField$1 as VideoField, UploadField$1 as default, definition };
|
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var core = require('@panneau/core');
|
|
|
17
17
|
var hooks = require('@panneau/core/hooks');
|
|
18
18
|
var Button = require('@panneau/element-button');
|
|
19
19
|
var Label = require('@panneau/element-label');
|
|
20
|
-
var
|
|
20
|
+
var MediaCard = require('@panneau/element-media-card');
|
|
21
21
|
var ResourceItemsList = require('@panneau/list-resource-items');
|
|
22
22
|
var Dialog = require('@panneau/modal-dialog');
|
|
23
23
|
var uppy = require('@panneau/uppy');
|
|
@@ -25,10 +25,11 @@ require('@uppy/core/dist/style.css');
|
|
|
25
25
|
require('@uppy/dashboard/dist/style.css');
|
|
26
26
|
require('@uppy/drag-drop/dist/style.css');
|
|
27
27
|
require('@uppy/status-bar/dist/style.css');
|
|
28
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
28
29
|
|
|
29
30
|
var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","dashboardModal":"panneau-field-upload-dashboardModal","uppyDashboardContainer":"panneau-field-upload-uppyDashboardContainer"};
|
|
30
31
|
|
|
31
|
-
var propTypes = {
|
|
32
|
+
var propTypes$1 = {
|
|
32
33
|
value: PropTypes.oneOfType([PropTypes.array, PropTypes.shape({
|
|
33
34
|
filename: PropTypes.string,
|
|
34
35
|
size: PropTypes.number,
|
|
@@ -64,7 +65,7 @@ var propTypes = {
|
|
|
64
65
|
onClickFind: PropTypes.func,
|
|
65
66
|
className: PropTypes.string
|
|
66
67
|
};
|
|
67
|
-
var defaultProps = {
|
|
68
|
+
var defaultProps$1 = {
|
|
68
69
|
value: null,
|
|
69
70
|
types: ['audio', 'image', 'video'],
|
|
70
71
|
fileTypes: null,
|
|
@@ -344,7 +345,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
344
345
|
return /*#__PURE__*/React.createElement("div", {
|
|
345
346
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
346
347
|
ref: containerRef
|
|
347
|
-
}, hasMedia ? /*#__PURE__*/React.createElement(
|
|
348
|
+
}, hasMedia ? /*#__PURE__*/React.createElement(MediaCard.MediaCards, {
|
|
348
349
|
value: values,
|
|
349
350
|
namePath: namePath,
|
|
350
351
|
thumbnailPath: thumbnailPath,
|
|
@@ -421,27 +422,10 @@ var UploadField = function UploadField(_ref) {
|
|
|
421
422
|
onQueryChange: onListQueryChange,
|
|
422
423
|
onQueryReset: onListQueryReset,
|
|
423
424
|
baseUrl: null,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
getSelectPropsFromItem: function getSelectPropsFromItem(item) {
|
|
429
|
-
var _ref6 = item || {},
|
|
430
|
-
_ref6$id = _ref6.id,
|
|
431
|
-
itemId = _ref6$id === void 0 ? null : _ref6$id;
|
|
432
|
-
var found = (modalItems || []).find(function () {
|
|
433
|
-
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
434
|
-
_ref7$id = _ref7.id,
|
|
435
|
-
modalItemId = _ref7$id === void 0 ? null : _ref7$id;
|
|
436
|
-
return modalItemId === itemId;
|
|
437
|
-
});
|
|
438
|
-
return {
|
|
439
|
-
outline: !found
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
withoutActionsColumn: true
|
|
444
|
-
}
|
|
425
|
+
showActions: false,
|
|
426
|
+
selectable: true,
|
|
427
|
+
onSelectionChange: onClickSelect,
|
|
428
|
+
multiple: allowMultipleUploads
|
|
445
429
|
}), allowMultipleUploads ? /*#__PURE__*/React.createElement("div", {
|
|
446
430
|
className: "d-flex mt-4 justify-content-between"
|
|
447
431
|
}, modalItems !== null && modalItems.length > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -462,8 +446,8 @@ var UploadField = function UploadField(_ref) {
|
|
|
462
446
|
className: "d-block"
|
|
463
447
|
}, /*#__PURE__*/React.createElement(Label, null, confirmButtonLabel)))) : null) : null);
|
|
464
448
|
};
|
|
465
|
-
UploadField.propTypes = propTypes;
|
|
466
|
-
UploadField.defaultProps = defaultProps;
|
|
449
|
+
UploadField.propTypes = propTypes$1;
|
|
450
|
+
UploadField.defaultProps = defaultProps$1;
|
|
467
451
|
var UploadField$1 = UploadField;
|
|
468
452
|
|
|
469
453
|
var definition = [{
|
|
@@ -557,11 +541,114 @@ var FontField = function FontField(props) {
|
|
|
557
541
|
};
|
|
558
542
|
var FontField$1 = FontField;
|
|
559
543
|
|
|
544
|
+
var _excluded = ["value", "onChange"];
|
|
545
|
+
var propTypes = {
|
|
546
|
+
value: PropTypes.shape({
|
|
547
|
+
published: PropTypes.bool,
|
|
548
|
+
featured: PropTypes.bool,
|
|
549
|
+
created_at: PropTypes.string,
|
|
550
|
+
updated_at: PropTypes.string
|
|
551
|
+
}),
|
|
552
|
+
onChange: PropTypes.func,
|
|
553
|
+
types: PropTypes.arrayOf(PropTypes.string),
|
|
554
|
+
fileTypes: PropTypes.arrayOf(PropTypes.string)
|
|
555
|
+
};
|
|
556
|
+
var defaultProps = {
|
|
557
|
+
value: null,
|
|
558
|
+
onChange: null,
|
|
559
|
+
types: null,
|
|
560
|
+
fileTypes: null
|
|
561
|
+
};
|
|
562
|
+
var UpdateFileField = function UpdateFileField(_ref) {
|
|
563
|
+
var value = _ref.value;
|
|
564
|
+
_ref.onChange;
|
|
565
|
+
var props = _objectWithoutProperties(_ref, _excluded);
|
|
566
|
+
var _useState = React.useState(null),
|
|
567
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
568
|
+
newValue = _useState2[0],
|
|
569
|
+
setNewValue = _useState2[1];
|
|
570
|
+
var _useState3 = React.useState(null),
|
|
571
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
572
|
+
visibleFile = _useState4[0],
|
|
573
|
+
setVisibleFile = _useState4[1];
|
|
574
|
+
var _ref2 = value || {},
|
|
575
|
+
previousId = _ref2.id,
|
|
576
|
+
_ref2$type = _ref2.type,
|
|
577
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
578
|
+
var onUploadChange = React.useCallback(function () {
|
|
579
|
+
var uploadedFile = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
580
|
+
if (uploadedFile !== null) {
|
|
581
|
+
setVisibleFile(uploadedFile);
|
|
582
|
+
}
|
|
583
|
+
setNewValue(uploadedFile);
|
|
584
|
+
}, [setNewValue, setVisibleFile]);
|
|
585
|
+
var uppyProps = React.useMemo(function () {
|
|
586
|
+
return {
|
|
587
|
+
meta: {
|
|
588
|
+
previousId: previousId
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}, [previousId]);
|
|
592
|
+
var uploadProps = React.useMemo(function () {
|
|
593
|
+
if (type === 'image') {
|
|
594
|
+
return {
|
|
595
|
+
types: ['image']
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
if (type === 'audio') {
|
|
599
|
+
return {
|
|
600
|
+
types: ['audio']
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
if (type === 'video') {
|
|
604
|
+
return {
|
|
605
|
+
types: ['video']
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
if (type === 'document') {
|
|
609
|
+
return {
|
|
610
|
+
types: [],
|
|
611
|
+
fileTypes: ['.pdf']
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
return null;
|
|
615
|
+
}, [type]);
|
|
616
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
617
|
+
className: "mb-3"
|
|
618
|
+
}, /*#__PURE__*/React.createElement(MediaCard, {
|
|
619
|
+
value: visibleFile || value,
|
|
620
|
+
withoutDescription: true
|
|
621
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
622
|
+
className: "mb-3"
|
|
623
|
+
}, /*#__PURE__*/React.createElement(UploadField$1, Object.assign({}, props, uploadProps, {
|
|
624
|
+
addButtonLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
625
|
+
id: "daHjZg",
|
|
626
|
+
defaultMessage: [{
|
|
627
|
+
"type": 0,
|
|
628
|
+
"value": "Edit file"
|
|
629
|
+
}]
|
|
630
|
+
}),
|
|
631
|
+
allowMultipleUploads: false,
|
|
632
|
+
multiple: false,
|
|
633
|
+
linkPath: "panneauUrl",
|
|
634
|
+
onChange: onUploadChange,
|
|
635
|
+
onClose: onUploadChange,
|
|
636
|
+
maxNumberOfFiles: 1,
|
|
637
|
+
value: newValue,
|
|
638
|
+
withButton: true,
|
|
639
|
+
uppyProps: uppyProps
|
|
640
|
+
}))));
|
|
641
|
+
};
|
|
642
|
+
UpdateFileField.propTypes = propTypes;
|
|
643
|
+
UpdateFileField.defaultProps = defaultProps;
|
|
644
|
+
var UpdateFileField$1 = UpdateFileField;
|
|
645
|
+
|
|
560
646
|
exports.AudioField = AudioField$1;
|
|
561
647
|
exports.DocumentField = DocumentField$1;
|
|
562
648
|
exports.FontField = FontField$1;
|
|
563
649
|
exports.ImageField = ImageField$1;
|
|
564
650
|
exports.ImagesField = ImagesField$1;
|
|
651
|
+
exports.UpdateFileField = UpdateFileField$1;
|
|
565
652
|
exports.VideoField = VideoField$1;
|
|
566
653
|
exports.default = UploadField$1;
|
|
567
654
|
exports.definition = definition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.135",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@panneau/element-button": "^3.0.133",
|
|
62
62
|
"@panneau/element-label": "^3.0.133",
|
|
63
63
|
"@panneau/element-media-card": "^3.0.133",
|
|
64
|
-
"@panneau/list-resource-items": "^3.0.
|
|
64
|
+
"@panneau/list-resource-items": "^3.0.135",
|
|
65
65
|
"@panneau/modal-dialog": "^3.0.133",
|
|
66
66
|
"@panneau/modal-upload": "^3.0.133",
|
|
67
67
|
"@panneau/themes": "^3.0.133",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "e9756936d684d3a9e56482db14e098e01e446d48"
|
|
86
86
|
}
|