@panneau/action-duplicate 4.0.38 → 4.0.40-alpha.1

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.
Files changed (2) hide show
  1. package/dist/index.js +215 -117
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,159 +1,257 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
1
+ import { c } from 'react/compiler-runtime';
5
2
  import { postJSON, getCSRFHeaders } from '@folklore/fetch';
6
- import classNames from 'classnames';
7
- import { useState, useCallback } from 'react';
3
+ import { useState } from 'react';
8
4
  import { FormattedMessage } from 'react-intl';
9
- import { useActionProps } from '@panneau/action-actions';
10
5
  import { useModalsComponentsManager } from '@panneau/core/contexts';
11
6
  import Button from '@panneau/element-button';
12
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
8
 
14
- var _excluded = ["id", "title", "description", "endpoint", "action", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "valueLabelPath", "modalComponent", "withConfirmation", "className"];
15
- function DuplicateAction(_ref) {
16
- var id = _ref.id,
17
- _ref$title = _ref.title,
18
- title = _ref$title === void 0 ? null : _ref$title,
19
- _ref$description = _ref.description,
20
- description = _ref$description === void 0 ? null : _ref$description,
21
- _ref$endpoint = _ref.endpoint,
22
- endpoint = _ref$endpoint === void 0 ? '/duplicate' : _ref$endpoint,
23
- _ref$action = _ref.action,
24
- action = _ref$action === void 0 ? null : _ref$action,
25
- _ref$label = _ref.label,
26
- initialLabel = _ref$label === void 0 ? null : _ref$label,
27
- _ref$icon = _ref.icon,
28
- icon = _ref$icon === void 0 ? 'copy' : _ref$icon,
29
- _ref$value = _ref.value,
30
- value = _ref$value === void 0 ? null : _ref$value,
31
- _ref$theme = _ref.theme,
32
- theme = _ref$theme === void 0 ? 'secondary' : _ref$theme,
33
- _ref$disabled = _ref.disabled,
34
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
35
- _ref$onChange = _ref.onChange,
36
- onChange = _ref$onChange === void 0 ? null : _ref$onChange,
37
- _ref$onConfirmed = _ref.onConfirmed,
38
- onConfirmed = _ref$onConfirmed === void 0 ? null : _ref$onConfirmed,
39
- _ref$valueLabelPath = _ref.valueLabelPath,
40
- valueLabelPath = _ref$valueLabelPath === void 0 ? null : _ref$valueLabelPath,
41
- _ref$modalComponent = _ref.modalComponent,
42
- modalComponent = _ref$modalComponent === void 0 ? 'confirm' : _ref$modalComponent,
43
- _ref$withConfirmation = _ref.withConfirmation,
44
- withConfirmation = _ref$withConfirmation === void 0 ? false : _ref$withConfirmation,
45
- _ref$className = _ref.className,
46
- className = _ref$className === void 0 ? null : _ref$className,
47
- props = _objectWithoutProperties(_ref, _excluded);
48
- var label = initialLabel || /*#__PURE__*/jsx(FormattedMessage, {
49
- id: "HzCxmr",
50
- defaultMessage: [{
51
- "type": 0,
52
- "value": "Duplicate"
53
- }]
54
- });
55
- var ModalComponents = useModalsComponentsManager();
56
- var ModalComponent = ModalComponents.getComponent(modalComponent);
57
- var _useState = useState(false),
58
- _useState2 = _slicedToArray(_useState, 2),
59
- modalOpen = _useState2[0],
60
- setModalOpen = _useState2[1];
61
- var _useState3 = useState(null),
62
- _useState4 = _slicedToArray(_useState3, 2),
63
- error = _useState4[0],
64
- setError = _useState4[1];
65
- var _useActionProps = useActionProps(id, value, valueLabelPath),
66
- ids = _useActionProps.ids,
67
- idLabels = _useActionProps.idLabels,
68
- modalKey = _useActionProps.modalKey;
69
- var onOpen = useCallback(function () {
70
- setModalOpen(true);
71
- }, [setModalOpen]);
72
- var onClose = useCallback(function () {
73
- setModalOpen(false);
74
- }, [setModalOpen]);
75
- var onConfirm = useCallback(function () {
76
- return (action !== null ? action(ids) : postJSON(endpoint, {
77
- ids: ids
9
+ function DuplicateAction(t0) {
10
+ const $ = c(51);
11
+ let id;
12
+ let props;
13
+ let t1;
14
+ let t10;
15
+ let t11;
16
+ let t12;
17
+ let t13;
18
+ let t14;
19
+ let t15;
20
+ let t2;
21
+ let t3;
22
+ let t4;
23
+ let t5;
24
+ let t6;
25
+ let t7;
26
+ let t8;
27
+ let t9;
28
+ if ($[0] !== t0) {
29
+ ({
30
+ id,
31
+ title: t1,
32
+ description: t2,
33
+ endpoint: t3,
34
+ action: t4,
35
+ label: t5,
36
+ icon: t6,
37
+ value: t7,
38
+ theme: t8,
39
+ disabled: t9,
40
+ onChange: t10,
41
+ onConfirmed: t11,
42
+ valueLabelPath: t12,
43
+ modalComponent: t13,
44
+ withConfirmation: t14,
45
+ className: t15,
46
+ ...props
47
+ } = t0);
48
+ $[0] = t0;
49
+ $[1] = id;
50
+ $[2] = props;
51
+ $[3] = t1;
52
+ $[4] = t10;
53
+ $[5] = t11;
54
+ $[6] = t12;
55
+ $[7] = t13;
56
+ $[8] = t14;
57
+ $[9] = t15;
58
+ $[10] = t2;
59
+ $[11] = t3;
60
+ $[12] = t4;
61
+ $[13] = t5;
62
+ $[14] = t6;
63
+ $[15] = t7;
64
+ $[16] = t8;
65
+ $[17] = t9;
66
+ } else {
67
+ id = $[1];
68
+ props = $[2];
69
+ t1 = $[3];
70
+ t10 = $[4];
71
+ t11 = $[5];
72
+ t12 = $[6];
73
+ t13 = $[7];
74
+ t14 = $[8];
75
+ t15 = $[9];
76
+ t2 = $[10];
77
+ t3 = $[11];
78
+ t4 = $[12];
79
+ t5 = $[13];
80
+ t6 = $[14];
81
+ t7 = $[15];
82
+ t8 = $[16];
83
+ t9 = $[17];
84
+ }
85
+ const title = t1 === undefined ? null : t1;
86
+ const description = t2 === undefined ? null : t2;
87
+ const endpoint = t3 === undefined ? "/duplicate" : t3;
88
+ const action = t4 === undefined ? null : t4;
89
+ const initialLabel = t5 === undefined ? null : t5;
90
+ const icon = t6 === undefined ? "copy" : t6;
91
+ const value = t7 === undefined ? null : t7;
92
+ const theme = t8 === undefined ? "secondary" : t8;
93
+ const disabled = t9 === undefined ? false : t9;
94
+ const onChange = t10 === undefined ? null : t10;
95
+ const onConfirmed = t11 === undefined ? null : t11;
96
+ const valueLabelPath = t12 === undefined ? null : t12;
97
+ const modalComponent = t13 === undefined ? "confirm" : t13;
98
+ const withConfirmation = t14 === undefined ? false : t14;
99
+ const className = t15 === undefined ? null : t15;
100
+ let t16;
101
+ if ($[18] !== initialLabel) {
102
+ t16 = initialLabel || /*#__PURE__*/jsx(FormattedMessage, {
103
+ id: "HzCxmr"
104
+ });
105
+ $[18] = initialLabel;
106
+ $[19] = t16;
107
+ } else {
108
+ t16 = $[19];
109
+ }
110
+ const label = t16;
111
+ const ModalComponents = useModalsComponentsManager();
112
+ let t17;
113
+ if ($[20] !== ModalComponents || $[21] !== modalComponent) {
114
+ t17 = ModalComponents.getComponent(modalComponent);
115
+ $[20] = ModalComponents;
116
+ $[21] = modalComponent;
117
+ $[22] = t17;
118
+ } else {
119
+ t17 = $[22];
120
+ }
121
+ const ModalComponent = t17;
122
+ const [modalOpen, setModalOpen] = useState(false);
123
+ const [error, setError] = useState(null);
124
+ const {
125
+ ids,
126
+ idLabels,
127
+ modalKey
128
+ } = useActionProps(id, value, valueLabelPath);
129
+ let t18;
130
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
131
+ t18 = () => {
132
+ setModalOpen(true);
133
+ };
134
+ $[23] = t18;
135
+ } else {
136
+ t18 = $[23];
137
+ }
138
+ const onOpen = t18;
139
+ let t19;
140
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
141
+ t19 = () => {
142
+ setModalOpen(false);
143
+ };
144
+ $[24] = t19;
145
+ } else {
146
+ t19 = $[24];
147
+ }
148
+ const onClosed = t19;
149
+ let t20;
150
+ if ($[25] !== action || $[26] !== endpoint || $[27] !== ids || $[28] !== onChange || $[29] !== onConfirmed) {
151
+ t20 = () => (action !== null ? action(ids) : postJSON(endpoint, {
152
+ ids
78
153
  }, {
79
- credentials: 'include',
154
+ credentials: "include",
80
155
  headers: getCSRFHeaders()
81
- })).then(function (response) {
156
+ })).then(response => {
82
157
  if (onConfirmed !== null) {
83
158
  onConfirmed(response);
84
159
  }
85
160
  if (onChange !== null) {
86
161
  onChange(response);
87
162
  }
88
- onClose();
89
- })["catch"](function (err) {
163
+ }).catch(err => {
90
164
  setError(err);
91
165
  });
92
- }, [ids, endpoint, action, onChange, onClose, setError, onConfirmed]);
93
- return /*#__PURE__*/jsxs(Fragment, {
94
- children: [/*#__PURE__*/jsx(Button, _objectSpread({
95
- className: classNames([_defineProperty({}, className, className !== null)]),
166
+ $[25] = action;
167
+ $[26] = endpoint;
168
+ $[27] = ids;
169
+ $[28] = onChange;
170
+ $[29] = onConfirmed;
171
+ $[30] = t20;
172
+ } else {
173
+ t20 = $[30];
174
+ }
175
+ const onConfirm = t20;
176
+ const t21 = withConfirmation ? onOpen : null;
177
+ const t22 = disabled ? "secondary" : theme;
178
+ let t23;
179
+ if ($[31] !== className || $[32] !== disabled || $[33] !== icon || $[34] !== label || $[35] !== props || $[36] !== t21 || $[37] !== t22) {
180
+ t23 = /*#__PURE__*/jsx(Button, {
181
+ className: className,
96
182
  label: label,
97
183
  icon: icon,
98
- onClick: withConfirmation ? onOpen : null,
184
+ onClick: t21,
99
185
  disabled: disabled,
100
- theme: disabled ? 'secondary' : theme
101
- }, props)), modalOpen ? /*#__PURE__*/jsxs(ModalComponent, {
186
+ theme: t22,
187
+ ...props
188
+ });
189
+ $[31] = className;
190
+ $[32] = disabled;
191
+ $[33] = icon;
192
+ $[34] = label;
193
+ $[35] = props;
194
+ $[36] = t21;
195
+ $[37] = t22;
196
+ $[38] = t23;
197
+ } else {
198
+ t23 = $[38];
199
+ }
200
+ let t24;
201
+ if ($[39] !== ModalComponent || $[40] !== description || $[41] !== error || $[42] !== idLabels || $[43] !== modalKey || $[44] !== modalOpen || $[45] !== onConfirm || $[46] !== title) {
202
+ t24 = modalOpen ? /*#__PURE__*/jsxs(ModalComponent, {
102
203
  id: modalKey,
103
204
  title: title || /*#__PURE__*/jsx(FormattedMessage, {
104
- id: "8T+JE7",
105
- defaultMessage: [{
106
- "type": 0,
107
- "value": "Duplicate"
108
- }]
205
+ id: "8T+JE7"
109
206
  }),
110
207
  onConfirm: onConfirm,
111
- onClose: onClose,
208
+ onClosed: onClosed,
112
209
  confirmButton: {
113
210
  label: /*#__PURE__*/jsx(FormattedMessage, {
114
- id: "UaVu03",
115
- defaultMessage: [{
116
- "type": 0,
117
- "value": "Confirm"
118
- }]
211
+ id: "UaVu03"
119
212
  }),
120
- theme: 'danger'
213
+ theme: "danger"
121
214
  },
122
215
  cancelButton: {
123
216
  label: /*#__PURE__*/jsx(FormattedMessage, {
124
- id: "PyxZY2",
125
- defaultMessage: [{
126
- "type": 0,
127
- "value": "Cancel"
128
- }]
217
+ id: "PyxZY2"
129
218
  })
130
219
  },
131
220
  children: [description !== null ? description : /*#__PURE__*/jsx("p", {
132
221
  children: /*#__PURE__*/jsx(FormattedMessage, {
133
222
  id: "XmY7D8",
134
- defaultMessage: [{
135
- "type": 0,
136
- "value": "The following items will be duplicated: "
137
- }, {
138
- "type": 1,
139
- "value": "ids"
140
- }, {
141
- "type": 0,
142
- "value": ". Are you sure you want to continue?"
143
- }],
144
223
  values: {
145
224
  ids: idLabels
146
225
  }
147
226
  })
148
227
  }), error !== null ? /*#__PURE__*/jsx(FormattedMessage, {
149
- id: "cutyQH",
150
- defaultMessage: [{
151
- "type": 0,
152
- "value": "An error has occured."
153
- }]
228
+ id: "cutyQH"
154
229
  }) : null]
155
- }) : null]
156
- });
230
+ }) : null;
231
+ $[39] = ModalComponent;
232
+ $[40] = description;
233
+ $[41] = error;
234
+ $[42] = idLabels;
235
+ $[43] = modalKey;
236
+ $[44] = modalOpen;
237
+ $[45] = onConfirm;
238
+ $[46] = title;
239
+ $[47] = t24;
240
+ } else {
241
+ t24 = $[47];
242
+ }
243
+ let t25;
244
+ if ($[48] !== t23 || $[49] !== t24) {
245
+ t25 = /*#__PURE__*/jsxs(Fragment, {
246
+ children: [t23, t24]
247
+ });
248
+ $[48] = t23;
249
+ $[49] = t24;
250
+ $[50] = t25;
251
+ } else {
252
+ t25 = $[50];
253
+ }
254
+ return t25;
157
255
  }
158
256
 
159
257
  export { DuplicateAction as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/action-duplicate",
3
- "version": "4.0.38",
3
+ "version": "4.0.40-alpha.1",
4
4
  "description": "Duplicate action",
5
5
  "keywords": [
6
6
  "javascript"
@@ -53,14 +53,14 @@
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.28.6",
55
55
  "@folklore/fetch": "^0.1.21",
56
- "@panneau/core": "^4.0.38",
57
- "@panneau/element-button": "^4.0.38",
58
- "@panneau/themes": "^4.0.38",
56
+ "@panneau/core": "^4.0.40-alpha.1",
57
+ "@panneau/element-button": "^4.0.40-alpha.1",
58
+ "@panneau/themes": "^4.0.40-alpha.1",
59
59
  "classnames": "^2.5.1",
60
60
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "fa4b9c4ec7fe5c0e360dda5a40f8b5d8c7ada651"
65
+ "gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
66
66
  }