@panneau/action-upload 3.0.244 → 3.0.245
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 +54 -59
- package/package.json +3 -3
- package/assets/css/styles.css +0 -0
package/es/index.js
CHANGED
@@ -1,84 +1,79 @@
|
|
1
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import React from 'react';
|
3
|
+
import React, { useCallback } from 'react';
|
4
4
|
import { FormattedMessage } from 'react-intl';
|
5
|
+
import { useFieldsComponentsManager } from '@panneau/core/contexts';
|
5
6
|
|
6
|
-
var _excluded = ["
|
7
|
+
var _excluded = ["endpoint", "action", "label", "value", "icon", "theme", "disabled", "onConfirmed", "fieldComponent", "className"];
|
7
8
|
|
8
|
-
// TODO:
|
9
|
+
// TODO: figure out what happens when an item / multiple items are selected
|
9
10
|
|
10
11
|
var propTypes = {
|
11
|
-
|
12
|
-
|
13
|
-
description: PropTypes.node,
|
14
|
-
fields: PropTypes.arrayOf(PropTypes.shape({})),
|
12
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
13
|
+
id: PropTypes.string,
|
15
14
|
endpoint: PropTypes.string,
|
15
|
+
action: PropTypes.func,
|
16
|
+
// Promise
|
16
17
|
label: PropTypes.string,
|
17
|
-
value: PropTypes.
|
18
|
+
value: PropTypes.shape({}),
|
18
19
|
icon: PropTypes.string,
|
19
20
|
theme: PropTypes.string,
|
20
21
|
disabled: PropTypes.bool,
|
21
|
-
|
22
|
+
fieldComponent: PropTypes.string,
|
22
23
|
onConfirmed: PropTypes.func,
|
23
|
-
withConfirmation: PropTypes.bool,
|
24
24
|
className: PropTypes.string
|
25
25
|
};
|
26
26
|
var defaultProps = {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
32
|
-
id: "rklw2v",
|
33
|
-
defaultMessage: [{
|
34
|
-
"type": 0,
|
35
|
-
"value": "Add a file"
|
36
|
-
}]
|
37
|
-
}),
|
38
|
-
icon: 'upload',
|
27
|
+
id: null,
|
28
|
+
endpoint: '/import',
|
29
|
+
action: null,
|
30
|
+
label: null,
|
39
31
|
value: null,
|
32
|
+
icon: 'upload',
|
40
33
|
theme: 'primary',
|
41
34
|
disabled: false,
|
42
|
-
|
35
|
+
fieldComponent: 'upload',
|
43
36
|
onConfirmed: null,
|
44
|
-
withConfirmation: false,
|
45
37
|
className: null
|
46
38
|
};
|
47
|
-
var
|
48
|
-
_ref.
|
49
|
-
_ref.
|
50
|
-
_ref.
|
51
|
-
_ref.fields;
|
52
|
-
_ref.endpoint;
|
53
|
-
_ref.label;
|
54
|
-
_ref.icon;
|
39
|
+
var ImportAction = function ImportAction(_ref) {
|
40
|
+
_ref.endpoint;
|
41
|
+
_ref.action;
|
42
|
+
var label = _ref.label;
|
55
43
|
_ref.value;
|
56
|
-
_ref.
|
57
|
-
_ref.
|
58
|
-
_ref.
|
59
|
-
_ref.onConfirmed
|
60
|
-
_ref.
|
61
|
-
_ref.className
|
62
|
-
_objectWithoutProperties(_ref, _excluded);
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
44
|
+
var icon = _ref.icon,
|
45
|
+
theme = _ref.theme,
|
46
|
+
disabled = _ref.disabled,
|
47
|
+
onConfirmed = _ref.onConfirmed,
|
48
|
+
fieldComponent = _ref.fieldComponent,
|
49
|
+
className = _ref.className,
|
50
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
51
|
+
var FieldComponents = useFieldsComponentsManager();
|
52
|
+
var FieldComponent = FieldComponents.getComponent(fieldComponent);
|
53
|
+
var onComplete = useCallback(function (data) {
|
54
|
+
if (onConfirmed !== null) {
|
55
|
+
onConfirmed(data);
|
56
|
+
}
|
57
|
+
}, [onConfirmed]);
|
58
|
+
return /*#__PURE__*/React.createElement(FieldComponent, Object.assign({
|
59
|
+
withButton: true,
|
60
|
+
outline: false,
|
61
|
+
theme: theme,
|
62
|
+
addButtonIcon: icon,
|
63
|
+
addButtonLabel: label || /*#__PURE__*/React.createElement(FormattedMessage, {
|
64
|
+
id: "eL+nIp",
|
65
|
+
defaultMessage: [{
|
66
|
+
"type": 0,
|
67
|
+
"value": "Add file"
|
68
|
+
}]
|
69
|
+
}),
|
70
|
+
onChange: onComplete,
|
71
|
+
disabled: disabled,
|
72
|
+
className: className
|
73
|
+
}, props));
|
79
74
|
};
|
80
|
-
|
81
|
-
|
82
|
-
var UploadAction
|
75
|
+
ImportAction.propTypes = propTypes;
|
76
|
+
ImportAction.defaultProps = defaultProps;
|
77
|
+
var UploadAction = ImportAction;
|
83
78
|
|
84
|
-
export { UploadAction
|
79
|
+
export { UploadAction as default };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@panneau/action-upload",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.245",
|
4
4
|
"description": "Upload action",
|
5
5
|
"keywords": [
|
6
6
|
"javascript"
|
@@ -53,7 +53,7 @@
|
|
53
53
|
"@babel/runtime": "^7.12.5",
|
54
54
|
"@panneau/core": "^3.0.244",
|
55
55
|
"@panneau/element-button": "^3.0.244",
|
56
|
-
"@panneau/field-upload": "^3.0.
|
56
|
+
"@panneau/field-upload": "^3.0.245",
|
57
57
|
"@panneau/themes": "^3.0.244",
|
58
58
|
"classnames": "^2.5.1",
|
59
59
|
"prop-types": "^15.7.2",
|
@@ -62,5 +62,5 @@
|
|
62
62
|
"publishConfig": {
|
63
63
|
"access": "public"
|
64
64
|
},
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "9365cf9236eaa94e879099b12cccb5cf22645e1e"
|
66
66
|
}
|
package/assets/css/styles.css
DELETED
File without changes
|