@panneau/action-duplicate 3.0.225 → 3.0.228
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 +20 -27
- package/package.json +8 -7
package/es/index.js
CHANGED
|
@@ -4,16 +4,15 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import { postJSON, getCSRFHeaders } from '@folklore/fetch';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import React, { useState,
|
|
7
|
+
import React, { useState, useCallback } from 'react';
|
|
8
8
|
import { FormattedMessage } from 'react-intl';
|
|
9
|
-
import {
|
|
9
|
+
import { useModalsComponentsManager } from '@panneau/core/contexts';
|
|
10
10
|
import { useActionProps } from '@panneau/core/hooks';
|
|
11
11
|
import Button from '@panneau/element-button';
|
|
12
|
-
import Confirm from '@panneau/modal-confirm';
|
|
13
12
|
|
|
14
13
|
var styles = {};
|
|
15
14
|
|
|
16
|
-
var _excluded = ["id", "title", "description", "endpoint", "action", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "valueLabelPath", "withConfirmation", "className"];
|
|
15
|
+
var _excluded = ["id", "title", "description", "endpoint", "action", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "valueLabelPath", "modalComponent", "withConfirmation", "className"];
|
|
17
16
|
var propTypes = {
|
|
18
17
|
id: PropTypes.string.isRequired,
|
|
19
18
|
title: PropTypes.node,
|
|
@@ -29,6 +28,7 @@ var propTypes = {
|
|
|
29
28
|
onChange: PropTypes.func,
|
|
30
29
|
onConfirmed: PropTypes.func,
|
|
31
30
|
valueLabelPath: PropTypes.string,
|
|
31
|
+
modalComponent: PropTypes.string,
|
|
32
32
|
withConfirmation: PropTypes.bool,
|
|
33
33
|
className: PropTypes.string
|
|
34
34
|
};
|
|
@@ -51,6 +51,7 @@ var defaultProps = {
|
|
|
51
51
|
onChange: null,
|
|
52
52
|
onConfirmed: null,
|
|
53
53
|
valueLabelPath: null,
|
|
54
|
+
modalComponent: 'confirm',
|
|
54
55
|
withConfirmation: false,
|
|
55
56
|
className: null
|
|
56
57
|
};
|
|
@@ -68,37 +69,30 @@ var DuplicateAction = function DuplicateAction(_ref) {
|
|
|
68
69
|
onChange = _ref.onChange,
|
|
69
70
|
onConfirmed = _ref.onConfirmed,
|
|
70
71
|
valueLabelPath = _ref.valueLabelPath,
|
|
72
|
+
modalComponent = _ref.modalComponent,
|
|
71
73
|
withConfirmation = _ref.withConfirmation,
|
|
72
74
|
className = _ref.className,
|
|
73
75
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_useModal$register = _useModal.register,
|
|
78
|
-
register = _useModal$register === void 0 ? null : _useModal$register,
|
|
79
|
-
_useModal$unregister = _useModal.unregister,
|
|
80
|
-
unregister = _useModal$unregister === void 0 ? null : _useModal$unregister;
|
|
81
|
-
var _useState = useState(null),
|
|
76
|
+
var ModalComponents = useModalsComponentsManager();
|
|
77
|
+
var ModalComponent = ModalComponents.getComponent(modalComponent);
|
|
78
|
+
var _useState = useState(false),
|
|
82
79
|
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
modalOpen = _useState2[0],
|
|
81
|
+
setModalOpen = _useState2[1];
|
|
82
|
+
var _useState3 = useState(null),
|
|
83
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
84
|
+
error = _useState4[0],
|
|
85
|
+
setError = _useState4[1];
|
|
85
86
|
var _useActionProps = useActionProps(id, value, valueLabelPath),
|
|
86
87
|
ids = _useActionProps.ids,
|
|
87
88
|
idLabels = _useActionProps.idLabels,
|
|
88
89
|
modalKey = _useActionProps.modalKey;
|
|
89
|
-
var modal = useMemo(function () {
|
|
90
|
-
return (modals || []).find(function (_ref2) {
|
|
91
|
-
var _ref2$id = _ref2.id,
|
|
92
|
-
modalId = _ref2$id === void 0 ? null : _ref2$id;
|
|
93
|
-
return modalId === "".concat(modalKey);
|
|
94
|
-
}) || null;
|
|
95
|
-
}, [modals, modalKey]);
|
|
96
90
|
var onOpen = useCallback(function () {
|
|
97
|
-
|
|
98
|
-
}, [
|
|
91
|
+
setModalOpen(true);
|
|
92
|
+
}, [setModalOpen]);
|
|
99
93
|
var onClose = useCallback(function () {
|
|
100
|
-
|
|
101
|
-
}, [
|
|
94
|
+
setModalOpen(false);
|
|
95
|
+
}, [setModalOpen]);
|
|
102
96
|
var onConfirm = useCallback(function () {
|
|
103
97
|
return (action !== null ? action(ids) : postJSON(endpoint, {
|
|
104
98
|
ids: ids
|
|
@@ -117,7 +111,6 @@ var DuplicateAction = function DuplicateAction(_ref) {
|
|
|
117
111
|
setError(err);
|
|
118
112
|
});
|
|
119
113
|
}, [ids, endpoint, action, onChange, onClose, setError]);
|
|
120
|
-
console.log('yoo', label);
|
|
121
114
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
122
115
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
123
116
|
label: label,
|
|
@@ -125,7 +118,7 @@ var DuplicateAction = function DuplicateAction(_ref) {
|
|
|
125
118
|
onClick: withConfirmation ? onOpen : null,
|
|
126
119
|
disabled: disabled,
|
|
127
120
|
theme: disabled ? 'secondary' : theme
|
|
128
|
-
}, props)),
|
|
121
|
+
}, props)), modalOpen ? /*#__PURE__*/React.createElement(ModalComponent, {
|
|
129
122
|
id: modalKey,
|
|
130
123
|
title: title || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
131
124
|
id: "8T+JE7",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/action-duplicate",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.228",
|
|
4
4
|
"description": "Duplicate action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"type": "module",
|
|
29
29
|
"module": "es/index.js",
|
|
30
30
|
"exports": {
|
|
31
|
-
".": "./es/index.js"
|
|
31
|
+
".": "./es/index.js",
|
|
32
|
+
"./assets/css/styles": "./assets/css/styles.css",
|
|
33
|
+
"./assets/css/styles.css": "./assets/css/styles.css"
|
|
32
34
|
},
|
|
33
35
|
"files": [
|
|
34
36
|
"lib",
|
|
@@ -50,10 +52,9 @@
|
|
|
50
52
|
"dependencies": {
|
|
51
53
|
"@babel/runtime": "^7.12.5",
|
|
52
54
|
"@folklore/fetch": "^0.1.17",
|
|
53
|
-
"@panneau/core": "^3.0.
|
|
54
|
-
"@panneau/element-button": "^3.0.
|
|
55
|
-
"@panneau/
|
|
56
|
-
"@panneau/themes": "^3.0.224",
|
|
55
|
+
"@panneau/core": "^3.0.228",
|
|
56
|
+
"@panneau/element-button": "^3.0.228",
|
|
57
|
+
"@panneau/themes": "^3.0.228",
|
|
57
58
|
"classnames": "^2.5.1",
|
|
58
59
|
"prop-types": "^15.7.2",
|
|
59
60
|
"react-intl": "^5.15.8||^6.0.0"
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"publishConfig": {
|
|
62
63
|
"access": "public"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2adf72884fb88052c6a6822e6f32169bb1dfe18b"
|
|
65
66
|
}
|