@panneau/action-duplicate 4.0.39 → 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 +214 -114
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,157 +1,257 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
1
+ import { c } from 'react/compiler-runtime';
4
2
  import { postJSON, getCSRFHeaders } from '@folklore/fetch';
5
- import { useState, useCallback } from 'react';
3
+ import { useState } from 'react';
6
4
  import { FormattedMessage } from 'react-intl';
7
- import { useActionProps } from '@panneau/action-actions';
8
5
  import { useModalsComponentsManager } from '@panneau/core/contexts';
9
6
  import Button from '@panneau/element-button';
10
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
8
 
12
- var _excluded = ["id", "title", "description", "endpoint", "action", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "valueLabelPath", "modalComponent", "withConfirmation", "className"];
13
- function DuplicateAction(_ref) {
14
- var id = _ref.id,
15
- _ref$title = _ref.title,
16
- title = _ref$title === void 0 ? null : _ref$title,
17
- _ref$description = _ref.description,
18
- description = _ref$description === void 0 ? null : _ref$description,
19
- _ref$endpoint = _ref.endpoint,
20
- endpoint = _ref$endpoint === void 0 ? '/duplicate' : _ref$endpoint,
21
- _ref$action = _ref.action,
22
- action = _ref$action === void 0 ? null : _ref$action,
23
- _ref$label = _ref.label,
24
- initialLabel = _ref$label === void 0 ? null : _ref$label,
25
- _ref$icon = _ref.icon,
26
- icon = _ref$icon === void 0 ? 'copy' : _ref$icon,
27
- _ref$value = _ref.value,
28
- value = _ref$value === void 0 ? null : _ref$value,
29
- _ref$theme = _ref.theme,
30
- theme = _ref$theme === void 0 ? 'secondary' : _ref$theme,
31
- _ref$disabled = _ref.disabled,
32
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
33
- _ref$onChange = _ref.onChange,
34
- onChange = _ref$onChange === void 0 ? null : _ref$onChange,
35
- _ref$onConfirmed = _ref.onConfirmed,
36
- onConfirmed = _ref$onConfirmed === void 0 ? null : _ref$onConfirmed,
37
- _ref$valueLabelPath = _ref.valueLabelPath,
38
- valueLabelPath = _ref$valueLabelPath === void 0 ? null : _ref$valueLabelPath,
39
- _ref$modalComponent = _ref.modalComponent,
40
- modalComponent = _ref$modalComponent === void 0 ? 'confirm' : _ref$modalComponent,
41
- _ref$withConfirmation = _ref.withConfirmation,
42
- withConfirmation = _ref$withConfirmation === void 0 ? false : _ref$withConfirmation,
43
- _ref$className = _ref.className,
44
- className = _ref$className === void 0 ? null : _ref$className,
45
- props = _objectWithoutProperties(_ref, _excluded);
46
- var label = initialLabel || /*#__PURE__*/jsx(FormattedMessage, {
47
- id: "HzCxmr",
48
- defaultMessage: [{
49
- "type": 0,
50
- "value": "Duplicate"
51
- }]
52
- });
53
- var ModalComponents = useModalsComponentsManager();
54
- var ModalComponent = ModalComponents.getComponent(modalComponent);
55
- var _useState = useState(false),
56
- _useState2 = _slicedToArray(_useState, 2),
57
- modalOpen = _useState2[0],
58
- setModalOpen = _useState2[1];
59
- var _useState3 = useState(null),
60
- _useState4 = _slicedToArray(_useState3, 2),
61
- error = _useState4[0],
62
- setError = _useState4[1];
63
- var _useActionProps = useActionProps(id, value, valueLabelPath),
64
- ids = _useActionProps.ids,
65
- idLabels = _useActionProps.idLabels,
66
- modalKey = _useActionProps.modalKey;
67
- var onOpen = useCallback(function () {
68
- setModalOpen(true);
69
- }, [setModalOpen]);
70
- var onClose = useCallback(function () {
71
- setModalOpen(false);
72
- }, [setModalOpen]);
73
- var onConfirm = useCallback(function () {
74
- return (action !== null ? action(ids) : postJSON(endpoint, {
75
- 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
76
153
  }, {
77
- credentials: 'include',
154
+ credentials: "include",
78
155
  headers: getCSRFHeaders()
79
- })).then(function (response) {
156
+ })).then(response => {
80
157
  if (onConfirmed !== null) {
81
158
  onConfirmed(response);
82
159
  }
83
160
  if (onChange !== null) {
84
161
  onChange(response);
85
162
  }
86
- onClose();
87
- })["catch"](function (err) {
163
+ }).catch(err => {
88
164
  setError(err);
89
165
  });
90
- }, [ids, endpoint, action, onChange, onClose, setError, onConfirmed]);
91
- return /*#__PURE__*/jsxs(Fragment, {
92
- children: [/*#__PURE__*/jsx(Button, _objectSpread({
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, {
93
181
  className: className,
94
182
  label: label,
95
183
  icon: icon,
96
- onClick: withConfirmation ? onOpen : null,
184
+ onClick: t21,
97
185
  disabled: disabled,
98
- theme: disabled ? 'secondary' : theme
99
- }, 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, {
100
203
  id: modalKey,
101
204
  title: title || /*#__PURE__*/jsx(FormattedMessage, {
102
- id: "8T+JE7",
103
- defaultMessage: [{
104
- "type": 0,
105
- "value": "Duplicate"
106
- }]
205
+ id: "8T+JE7"
107
206
  }),
108
207
  onConfirm: onConfirm,
109
- onClose: onClose,
208
+ onClosed: onClosed,
110
209
  confirmButton: {
111
210
  label: /*#__PURE__*/jsx(FormattedMessage, {
112
- id: "UaVu03",
113
- defaultMessage: [{
114
- "type": 0,
115
- "value": "Confirm"
116
- }]
211
+ id: "UaVu03"
117
212
  }),
118
- theme: 'danger'
213
+ theme: "danger"
119
214
  },
120
215
  cancelButton: {
121
216
  label: /*#__PURE__*/jsx(FormattedMessage, {
122
- id: "PyxZY2",
123
- defaultMessage: [{
124
- "type": 0,
125
- "value": "Cancel"
126
- }]
217
+ id: "PyxZY2"
127
218
  })
128
219
  },
129
220
  children: [description !== null ? description : /*#__PURE__*/jsx("p", {
130
221
  children: /*#__PURE__*/jsx(FormattedMessage, {
131
222
  id: "XmY7D8",
132
- defaultMessage: [{
133
- "type": 0,
134
- "value": "The following items will be duplicated: "
135
- }, {
136
- "type": 1,
137
- "value": "ids"
138
- }, {
139
- "type": 0,
140
- "value": ". Are you sure you want to continue?"
141
- }],
142
223
  values: {
143
224
  ids: idLabels
144
225
  }
145
226
  })
146
227
  }), error !== null ? /*#__PURE__*/jsx(FormattedMessage, {
147
- id: "cutyQH",
148
- defaultMessage: [{
149
- "type": 0,
150
- "value": "An error has occured."
151
- }]
228
+ id: "cutyQH"
152
229
  }) : null]
153
- }) : null]
154
- });
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;
155
255
  }
156
256
 
157
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.39",
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.39",
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": "621c5233f083c1ba95cd46cd427c38361723d5d6"
65
+ "gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
66
66
  }