@panneau/modal-medias-picker 3.0.139 → 3.0.140
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 +56 -8
- package/lib/index.js +55 -7
- package/package.json +7 -6
package/es/index.js
CHANGED
@@ -1,31 +1,46 @@
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
1
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
2
4
|
import PropTypes from 'prop-types';
|
3
|
-
import React, { useCallback } from 'react';
|
5
|
+
import React, { useState, useCallback } from 'react';
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
4
7
|
import { MediasPicker } from '@panneau/medias';
|
5
8
|
import Dialog from '@panneau/modal-dialog';
|
6
9
|
|
7
|
-
var _excluded = ["title", "onClose", "onChange", "onConfirm", "multiple"];
|
10
|
+
var _excluded = ["title", "onClose", "onChange", "onConfirm", "confirmButton", "cancelButton", "multiple"];
|
8
11
|
var propTypes = {
|
9
12
|
title: PropTypes.string,
|
10
13
|
multiple: PropTypes.bool,
|
11
14
|
onConfirm: PropTypes.func,
|
12
15
|
onClose: PropTypes.func,
|
13
|
-
onChange: PropTypes.func
|
16
|
+
onChange: PropTypes.func,
|
17
|
+
// eslint-disable-next-line react/forbid-prop-types
|
18
|
+
confirmButton: PropTypes.any,
|
19
|
+
// eslint-disable-next-line react/forbid-prop-types
|
20
|
+
cancelButton: PropTypes.any
|
14
21
|
};
|
15
22
|
var defaultProps = {
|
16
23
|
title: null,
|
17
24
|
multiple: false,
|
18
25
|
onConfirm: null,
|
19
26
|
onClose: null,
|
20
|
-
onChange: null
|
27
|
+
onChange: null,
|
28
|
+
confirmButton: null,
|
29
|
+
cancelButton: null
|
21
30
|
};
|
22
31
|
function MediasPickerModal(_ref) {
|
23
32
|
var title = _ref.title,
|
24
33
|
onClose = _ref.onClose,
|
25
34
|
onChange = _ref.onChange,
|
26
35
|
onConfirm = _ref.onConfirm,
|
36
|
+
confirmButton = _ref.confirmButton,
|
37
|
+
cancelButton = _ref.cancelButton,
|
27
38
|
multiple = _ref.multiple,
|
28
39
|
props = _objectWithoutProperties(_ref, _excluded);
|
40
|
+
var _useState = useState(null),
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
42
|
+
count = _useState2[0],
|
43
|
+
setCount = _useState2[1];
|
29
44
|
var onSelectionConfirm = useCallback(function () {
|
30
45
|
if (onConfirm !== null) {
|
31
46
|
onConfirm();
|
@@ -33,16 +48,49 @@ function MediasPickerModal(_ref) {
|
|
33
48
|
if (onClose !== null) {
|
34
49
|
onClose();
|
35
50
|
}
|
36
|
-
}, [onConfirm]);
|
51
|
+
}, [onConfirm, onClose]);
|
52
|
+
var onSelectionChange = useCallback(function (items) {
|
53
|
+
if (onChange !== null) {
|
54
|
+
onChange(items);
|
55
|
+
}
|
56
|
+
setCount(items !== null ? items.length : 0);
|
57
|
+
}, [onChange, setCount]);
|
37
58
|
return /*#__PURE__*/React.createElement(Dialog, {
|
38
59
|
size: "lg",
|
39
60
|
onClose: onClose,
|
40
|
-
title: title
|
61
|
+
title: title,
|
62
|
+
buttons: [_objectSpread({
|
63
|
+
id: 'cancel',
|
64
|
+
name: 'cancel',
|
65
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
66
|
+
id: "PyxZY2",
|
67
|
+
defaultMessage: [{
|
68
|
+
"type": 0,
|
69
|
+
"value": "Cancel"
|
70
|
+
}]
|
71
|
+
}),
|
72
|
+
theme: 'secondary',
|
73
|
+
onClick: onClose
|
74
|
+
}, cancelButton), _objectSpread({
|
75
|
+
id: 'confirm',
|
76
|
+
name: 'confirm',
|
77
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
78
|
+
id: "rvOVCV",
|
79
|
+
defaultMessage: [{
|
80
|
+
"type": 0,
|
81
|
+
"value": "Confirm selection"
|
82
|
+
}]
|
83
|
+
}),
|
84
|
+
theme: 'primary',
|
85
|
+
onClick: onConfirm,
|
86
|
+
disabled: count === null || count < 1
|
87
|
+
}, confirmButton)]
|
41
88
|
}, /*#__PURE__*/React.createElement(MediasPicker, Object.assign({}, props, {
|
42
|
-
onChange:
|
89
|
+
onChange: onSelectionChange,
|
43
90
|
onConfirm: onSelectionConfirm,
|
44
91
|
onClose: onClose,
|
45
|
-
multiple: multiple
|
92
|
+
multiple: multiple,
|
93
|
+
withoutButtons: true
|
46
94
|
})));
|
47
95
|
}
|
48
96
|
MediasPickerModal.propTypes = propTypes;
|
package/lib/index.js
CHANGED
@@ -2,34 +2,49 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
6
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
5
7
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
6
8
|
var PropTypes = require('prop-types');
|
7
9
|
var React = require('react');
|
10
|
+
var reactIntl = require('react-intl');
|
8
11
|
var medias = require('@panneau/medias');
|
9
12
|
var Dialog = require('@panneau/modal-dialog');
|
10
13
|
|
11
|
-
var _excluded = ["title", "onClose", "onChange", "onConfirm", "multiple"];
|
14
|
+
var _excluded = ["title", "onClose", "onChange", "onConfirm", "confirmButton", "cancelButton", "multiple"];
|
12
15
|
var propTypes = {
|
13
16
|
title: PropTypes.string,
|
14
17
|
multiple: PropTypes.bool,
|
15
18
|
onConfirm: PropTypes.func,
|
16
19
|
onClose: PropTypes.func,
|
17
|
-
onChange: PropTypes.func
|
20
|
+
onChange: PropTypes.func,
|
21
|
+
// eslint-disable-next-line react/forbid-prop-types
|
22
|
+
confirmButton: PropTypes.any,
|
23
|
+
// eslint-disable-next-line react/forbid-prop-types
|
24
|
+
cancelButton: PropTypes.any
|
18
25
|
};
|
19
26
|
var defaultProps = {
|
20
27
|
title: null,
|
21
28
|
multiple: false,
|
22
29
|
onConfirm: null,
|
23
30
|
onClose: null,
|
24
|
-
onChange: null
|
31
|
+
onChange: null,
|
32
|
+
confirmButton: null,
|
33
|
+
cancelButton: null
|
25
34
|
};
|
26
35
|
function MediasPickerModal(_ref) {
|
27
36
|
var title = _ref.title,
|
28
37
|
onClose = _ref.onClose,
|
29
38
|
onChange = _ref.onChange,
|
30
39
|
onConfirm = _ref.onConfirm,
|
40
|
+
confirmButton = _ref.confirmButton,
|
41
|
+
cancelButton = _ref.cancelButton,
|
31
42
|
multiple = _ref.multiple,
|
32
43
|
props = _objectWithoutProperties(_ref, _excluded);
|
44
|
+
var _useState = React.useState(null),
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
46
|
+
count = _useState2[0],
|
47
|
+
setCount = _useState2[1];
|
33
48
|
var onSelectionConfirm = React.useCallback(function () {
|
34
49
|
if (onConfirm !== null) {
|
35
50
|
onConfirm();
|
@@ -37,16 +52,49 @@ function MediasPickerModal(_ref) {
|
|
37
52
|
if (onClose !== null) {
|
38
53
|
onClose();
|
39
54
|
}
|
40
|
-
}, [onConfirm]);
|
55
|
+
}, [onConfirm, onClose]);
|
56
|
+
var onSelectionChange = React.useCallback(function (items) {
|
57
|
+
if (onChange !== null) {
|
58
|
+
onChange(items);
|
59
|
+
}
|
60
|
+
setCount(items !== null ? items.length : 0);
|
61
|
+
}, [onChange, setCount]);
|
41
62
|
return /*#__PURE__*/React.createElement(Dialog, {
|
42
63
|
size: "lg",
|
43
64
|
onClose: onClose,
|
44
|
-
title: title
|
65
|
+
title: title,
|
66
|
+
buttons: [_objectSpread({
|
67
|
+
id: 'cancel',
|
68
|
+
name: 'cancel',
|
69
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
70
|
+
id: "PyxZY2",
|
71
|
+
defaultMessage: [{
|
72
|
+
"type": 0,
|
73
|
+
"value": "Cancel"
|
74
|
+
}]
|
75
|
+
}),
|
76
|
+
theme: 'secondary',
|
77
|
+
onClick: onClose
|
78
|
+
}, cancelButton), _objectSpread({
|
79
|
+
id: 'confirm',
|
80
|
+
name: 'confirm',
|
81
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
82
|
+
id: "rvOVCV",
|
83
|
+
defaultMessage: [{
|
84
|
+
"type": 0,
|
85
|
+
"value": "Confirm selection"
|
86
|
+
}]
|
87
|
+
}),
|
88
|
+
theme: 'primary',
|
89
|
+
onClick: onConfirm,
|
90
|
+
disabled: count === null || count < 1
|
91
|
+
}, confirmButton)]
|
45
92
|
}, /*#__PURE__*/React.createElement(medias.MediasPicker, Object.assign({}, props, {
|
46
|
-
onChange:
|
93
|
+
onChange: onSelectionChange,
|
47
94
|
onConfirm: onSelectionConfirm,
|
48
95
|
onClose: onClose,
|
49
|
-
multiple: multiple
|
96
|
+
multiple: multiple,
|
97
|
+
withoutButtons: true
|
50
98
|
})));
|
51
99
|
}
|
52
100
|
MediasPickerModal.propTypes = propTypes;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@panneau/modal-medias-picker",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.140",
|
4
4
|
"description": "Medias picker modal",
|
5
5
|
"keywords": [
|
6
6
|
"javascript"
|
@@ -46,9 +46,9 @@
|
|
46
46
|
},
|
47
47
|
"dependencies": {
|
48
48
|
"@babel/runtime": "^7.12.5",
|
49
|
-
"@panneau/core": "^3.0.
|
50
|
-
"@panneau/medias": "^3.0.
|
51
|
-
"@panneau/modal-dialog": "^3.0.
|
49
|
+
"@panneau/core": "^3.0.140",
|
50
|
+
"@panneau/medias": "^3.0.140",
|
51
|
+
"@panneau/modal-dialog": "^3.0.140",
|
52
52
|
"@uppy/core": "^3.9.1",
|
53
53
|
"@uppy/dashboard": "^3.7.3",
|
54
54
|
"@uppy/drag-drop": "^3.0.3",
|
@@ -58,10 +58,11 @@
|
|
58
58
|
"@uppy/status-bar": "^3.2.7",
|
59
59
|
"@uppy/utils": "^5.7.2",
|
60
60
|
"lodash": "^4.17.21",
|
61
|
-
"prop-types": "^15.7.2"
|
61
|
+
"prop-types": "^15.7.2",
|
62
|
+
"react-intl": "^5.15.8||^6.0.0"
|
62
63
|
},
|
63
64
|
"publishConfig": {
|
64
65
|
"access": "public"
|
65
66
|
},
|
66
|
-
"gitHead": "
|
67
|
+
"gitHead": "f148a421cabe2dfa529d2df1eaae42d0f4bb32c5"
|
67
68
|
}
|