@panneau/action-duplicate 3.0.223 → 3.0.224
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/package.json +10 -7
- package/lib/index.js +0 -189
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/action-duplicate",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.224",
|
|
4
4
|
"description": "Duplicate action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -25,8 +25,11 @@
|
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
27
|
"license": "ISC",
|
|
28
|
-
"
|
|
28
|
+
"type": "module",
|
|
29
29
|
"module": "es/index.js",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./es/index.js"
|
|
32
|
+
},
|
|
30
33
|
"files": [
|
|
31
34
|
"lib",
|
|
32
35
|
"es",
|
|
@@ -47,10 +50,10 @@
|
|
|
47
50
|
"dependencies": {
|
|
48
51
|
"@babel/runtime": "^7.12.5",
|
|
49
52
|
"@folklore/fetch": "^0.1.17",
|
|
50
|
-
"@panneau/core": "^3.0.
|
|
51
|
-
"@panneau/element-button": "^3.0.
|
|
52
|
-
"@panneau/modal-confirm": "^3.0.
|
|
53
|
-
"@panneau/themes": "^3.0.
|
|
53
|
+
"@panneau/core": "^3.0.224",
|
|
54
|
+
"@panneau/element-button": "^3.0.224",
|
|
55
|
+
"@panneau/modal-confirm": "^3.0.224",
|
|
56
|
+
"@panneau/themes": "^3.0.224",
|
|
54
57
|
"classnames": "^2.5.1",
|
|
55
58
|
"prop-types": "^15.7.2",
|
|
56
59
|
"react-intl": "^5.15.8||^6.0.0"
|
|
@@ -58,5 +61,5 @@
|
|
|
58
61
|
"publishConfig": {
|
|
59
62
|
"access": "public"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "c95bd465867c4c7d112bf0ed66036574cc05c627"
|
|
62
65
|
}
|
package/lib/index.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
-
var fetch = require('@folklore/fetch');
|
|
9
|
-
var classNames = require('classnames');
|
|
10
|
-
var PropTypes = require('prop-types');
|
|
11
|
-
var React = require('react');
|
|
12
|
-
var reactIntl = require('react-intl');
|
|
13
|
-
var contexts = require('@panneau/core/contexts');
|
|
14
|
-
var hooks = require('@panneau/core/hooks');
|
|
15
|
-
var Button = require('@panneau/element-button');
|
|
16
|
-
var Confirm = require('@panneau/modal-confirm');
|
|
17
|
-
|
|
18
|
-
var styles = {};
|
|
19
|
-
|
|
20
|
-
var _excluded = ["id", "title", "description", "endpoint", "action", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "valueLabelPath", "withConfirmation", "className"];
|
|
21
|
-
var propTypes = {
|
|
22
|
-
id: PropTypes.string.isRequired,
|
|
23
|
-
title: PropTypes.node,
|
|
24
|
-
description: PropTypes.node,
|
|
25
|
-
endpoint: PropTypes.string,
|
|
26
|
-
action: PropTypes.func,
|
|
27
|
-
// Promise
|
|
28
|
-
label: PropTypes.string,
|
|
29
|
-
value: PropTypes.bool,
|
|
30
|
-
icon: PropTypes.string,
|
|
31
|
-
theme: PropTypes.string,
|
|
32
|
-
disabled: PropTypes.bool,
|
|
33
|
-
onChange: PropTypes.func,
|
|
34
|
-
onConfirmed: PropTypes.func,
|
|
35
|
-
valueLabelPath: PropTypes.string,
|
|
36
|
-
withConfirmation: PropTypes.bool,
|
|
37
|
-
className: PropTypes.string
|
|
38
|
-
};
|
|
39
|
-
var defaultProps = {
|
|
40
|
-
title: null,
|
|
41
|
-
description: null,
|
|
42
|
-
endpoint: '/duplicate',
|
|
43
|
-
action: null,
|
|
44
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
45
|
-
id: "HzCxmr",
|
|
46
|
-
defaultMessage: [{
|
|
47
|
-
"type": 0,
|
|
48
|
-
"value": "Duplicate"
|
|
49
|
-
}]
|
|
50
|
-
}),
|
|
51
|
-
icon: 'copy',
|
|
52
|
-
value: null,
|
|
53
|
-
theme: 'primary',
|
|
54
|
-
disabled: false,
|
|
55
|
-
onChange: null,
|
|
56
|
-
onConfirmed: null,
|
|
57
|
-
valueLabelPath: null,
|
|
58
|
-
withConfirmation: false,
|
|
59
|
-
className: null
|
|
60
|
-
};
|
|
61
|
-
var DuplicateAction = function DuplicateAction(_ref) {
|
|
62
|
-
var id = _ref.id,
|
|
63
|
-
title = _ref.title,
|
|
64
|
-
description = _ref.description,
|
|
65
|
-
endpoint = _ref.endpoint,
|
|
66
|
-
action = _ref.action,
|
|
67
|
-
label = _ref.label,
|
|
68
|
-
icon = _ref.icon,
|
|
69
|
-
value = _ref.value,
|
|
70
|
-
theme = _ref.theme,
|
|
71
|
-
disabled = _ref.disabled,
|
|
72
|
-
onChange = _ref.onChange,
|
|
73
|
-
onConfirmed = _ref.onConfirmed,
|
|
74
|
-
valueLabelPath = _ref.valueLabelPath,
|
|
75
|
-
withConfirmation = _ref.withConfirmation,
|
|
76
|
-
className = _ref.className,
|
|
77
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
78
|
-
var _useModal = contexts.useModal(),
|
|
79
|
-
_useModal$modals = _useModal.modals,
|
|
80
|
-
modals = _useModal$modals === void 0 ? null : _useModal$modals,
|
|
81
|
-
_useModal$register = _useModal.register,
|
|
82
|
-
register = _useModal$register === void 0 ? null : _useModal$register,
|
|
83
|
-
_useModal$unregister = _useModal.unregister,
|
|
84
|
-
unregister = _useModal$unregister === void 0 ? null : _useModal$unregister;
|
|
85
|
-
var _useState = React.useState(null),
|
|
86
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
-
error = _useState2[0],
|
|
88
|
-
setError = _useState2[1];
|
|
89
|
-
var _useActionProps = hooks.useActionProps(id, value, valueLabelPath),
|
|
90
|
-
ids = _useActionProps.ids,
|
|
91
|
-
idLabels = _useActionProps.idLabels,
|
|
92
|
-
modalKey = _useActionProps.modalKey;
|
|
93
|
-
var modal = React.useMemo(function () {
|
|
94
|
-
return (modals || []).find(function (_ref2) {
|
|
95
|
-
var _ref2$id = _ref2.id,
|
|
96
|
-
modalId = _ref2$id === void 0 ? null : _ref2$id;
|
|
97
|
-
return modalId === "".concat(modalKey);
|
|
98
|
-
}) || null;
|
|
99
|
-
}, [modals, modalKey]);
|
|
100
|
-
var onOpen = React.useCallback(function () {
|
|
101
|
-
register(modalKey);
|
|
102
|
-
}, [modalKey, register]);
|
|
103
|
-
var onClose = React.useCallback(function () {
|
|
104
|
-
unregister(modalKey);
|
|
105
|
-
}, [modalKey, unregister]);
|
|
106
|
-
var onConfirm = React.useCallback(function () {
|
|
107
|
-
return (action !== null ? action(ids) : fetch.postJSON(endpoint, {
|
|
108
|
-
ids: ids
|
|
109
|
-
}, {
|
|
110
|
-
credentials: 'include',
|
|
111
|
-
headers: fetch.getCSRFHeaders()
|
|
112
|
-
})).then(function (response) {
|
|
113
|
-
if (onConfirmed !== null) {
|
|
114
|
-
onConfirmed(response);
|
|
115
|
-
}
|
|
116
|
-
if (onChange !== null) {
|
|
117
|
-
onChange(response);
|
|
118
|
-
}
|
|
119
|
-
onClose();
|
|
120
|
-
})["catch"](function (err) {
|
|
121
|
-
setError(err);
|
|
122
|
-
});
|
|
123
|
-
}, [ids, endpoint, action, onChange, onClose, setError]);
|
|
124
|
-
console.log('yoo', label);
|
|
125
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
126
|
-
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
127
|
-
label: label,
|
|
128
|
-
icon: icon,
|
|
129
|
-
onClick: withConfirmation ? onOpen : null,
|
|
130
|
-
disabled: disabled,
|
|
131
|
-
theme: disabled ? 'secondary' : theme
|
|
132
|
-
}, props)), modal !== null ? /*#__PURE__*/React.createElement(Confirm, {
|
|
133
|
-
id: modalKey,
|
|
134
|
-
title: title || /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
135
|
-
id: "8T+JE7",
|
|
136
|
-
defaultMessage: [{
|
|
137
|
-
"type": 0,
|
|
138
|
-
"value": "Duplicate"
|
|
139
|
-
}]
|
|
140
|
-
}),
|
|
141
|
-
onConfirm: onConfirm,
|
|
142
|
-
onClose: onClose,
|
|
143
|
-
confirmButton: {
|
|
144
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
145
|
-
id: "UaVu03",
|
|
146
|
-
defaultMessage: [{
|
|
147
|
-
"type": 0,
|
|
148
|
-
"value": "Confirm"
|
|
149
|
-
}]
|
|
150
|
-
}),
|
|
151
|
-
theme: 'danger'
|
|
152
|
-
},
|
|
153
|
-
cancelButton: {
|
|
154
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
155
|
-
id: "PyxZY2",
|
|
156
|
-
defaultMessage: [{
|
|
157
|
-
"type": 0,
|
|
158
|
-
"value": "Cancel"
|
|
159
|
-
}]
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
}, description !== null ? description : /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
163
|
-
id: "XmY7D8",
|
|
164
|
-
defaultMessage: [{
|
|
165
|
-
"type": 0,
|
|
166
|
-
"value": "The following items will be duplicated: "
|
|
167
|
-
}, {
|
|
168
|
-
"type": 1,
|
|
169
|
-
"value": "ids"
|
|
170
|
-
}, {
|
|
171
|
-
"type": 0,
|
|
172
|
-
"value": ". Are you sure you want to continue?"
|
|
173
|
-
}],
|
|
174
|
-
values: {
|
|
175
|
-
ids: idLabels
|
|
176
|
-
}
|
|
177
|
-
})), error !== null ? /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
178
|
-
id: "cutyQH",
|
|
179
|
-
defaultMessage: [{
|
|
180
|
-
"type": 0,
|
|
181
|
-
"value": "An error has occured."
|
|
182
|
-
}]
|
|
183
|
-
}) : null) : null);
|
|
184
|
-
};
|
|
185
|
-
DuplicateAction.propTypes = propTypes;
|
|
186
|
-
DuplicateAction.defaultProps = defaultProps;
|
|
187
|
-
var DuplicateAction$1 = DuplicateAction;
|
|
188
|
-
|
|
189
|
-
exports.default = DuplicateAction$1;
|