@panneau/modal-resource-items 4.0.39 → 4.0.40-alpha.3

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/dist/index.d.ts CHANGED
@@ -1,18 +1,24 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
+ import { Resource, Item } from '@panneau/core';
3
4
 
4
5
  interface ModalResourceItemsProps {
5
- id: string | number;
6
- resource?: string | null;
6
+ id?: string;
7
+ resource?: Resource | string | null;
7
8
  title?: string | null;
8
9
  query?: Record<string, unknown> | null;
9
10
  paginated?: boolean;
10
11
  size?: string;
11
- onClose?: (() => void) | null;
12
+ withoutCloseOnSelect?: boolean;
13
+ onClosed?: (() => void) | null;
14
+ onSelect?: ((item: Item[] | null) => void) | null;
15
+ multiple?: boolean;
12
16
  listProps?: Record<string, unknown> | null;
17
+ confirmButton?: Record<string, unknown> | null;
18
+ cancelButton?: Record<string, unknown> | null;
13
19
  className?: string | null;
14
20
  children?: ReactNode | null;
15
21
  }
16
- declare function ModalResourceItems({ id, resource: providedResource, title, query: initialQuery, paginated, size, onClose, listProps, className, children, ...props }: ModalResourceItemsProps): react_jsx_runtime.JSX.Element;
22
+ declare function ModalResourceItems({ id, resource: providedResource, title, query: initialQuery, paginated, size, onClosed, onSelect, multiple, listProps, confirmButton, cancelButton, withoutCloseOnSelect, className, children, ...props }: ModalResourceItemsProps): react_jsx_runtime.JSX.Element;
17
23
 
18
24
  export { ModalResourceItems as default };
package/dist/index.js CHANGED
@@ -1,82 +1,318 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
- import isObject from 'lodash/isObject';
4
- import { useMemo, useCallback } from 'react';
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useState } from 'react';
5
3
  import { FormattedMessage } from 'react-intl';
6
4
  import { usePanneauResource } from '@panneau/core/contexts';
7
5
  import { useQuery } from '@panneau/core/hooks';
8
6
  import { useResourceValues } from '@panneau/intl';
9
7
  import ResourceItemsList from '@panneau/list-resource-items';
10
8
  import Dialog from '@panneau/modal-dialog';
11
- import { jsxs, jsx } from 'react/jsx-runtime';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
10
 
13
- var _excluded = ["id", "resource", "title", "query", "paginated", "size", "onClose", "listProps", "className", "children"];
14
- function ModalResourceItems(_ref) {
15
- var id = _ref.id,
16
- _ref$resource = _ref.resource,
17
- providedResource = _ref$resource === void 0 ? null : _ref$resource,
18
- _ref$title = _ref.title,
19
- title = _ref$title === void 0 ? null : _ref$title,
20
- _ref$query = _ref.query,
21
- initialQuery = _ref$query === void 0 ? null : _ref$query,
22
- _ref$paginated = _ref.paginated,
23
- paginated = _ref$paginated === void 0 ? true : _ref$paginated,
24
- _ref$size = _ref.size,
25
- size = _ref$size === void 0 ? 'xl' : _ref$size,
26
- _ref$onClose = _ref.onClose,
27
- onClose = _ref$onClose === void 0 ? null : _ref$onClose,
28
- _ref$listProps = _ref.listProps,
29
- listProps = _ref$listProps === void 0 ? null : _ref$listProps,
30
- _ref$className = _ref.className,
31
- className = _ref$className === void 0 ? null : _ref$className,
32
- _ref$children = _ref.children,
33
- children = _ref$children === void 0 ? null : _ref$children,
34
- props = _objectWithoutProperties(_ref, _excluded);
35
- var panneauResource = usePanneauResource(providedResource);
36
- var resource = isObject(providedResource) ? providedResource : panneauResource;
37
- var resourceValues = useResourceValues(resource);
38
- var finalQuery = useMemo(function () {
39
- return _objectSpread({}, initialQuery);
40
- }, [initialQuery]);
41
- var _useQuery = useQuery(finalQuery, paginated),
42
- query = _useQuery.query,
43
- onPageChange = _useQuery.onPageChange,
44
- onQueryChange = _useQuery.onQueryChange,
45
- onQueryReset = _useQuery.onQueryReset;
46
- var finalOnPageChange = useCallback(function (e) {
47
- var pageNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
48
- e.preventDefault();
49
- e.stopPropagation();
50
- onPageChange(pageNumber);
51
- }, [onPageChange]);
52
- var finalOnQueryChange = useCallback(function (newQuery) {
53
- onQueryChange(newQuery);
54
- }, [onQueryChange]);
55
- return /*#__PURE__*/jsxs(Dialog, {
56
- id: id,
57
- title: title || /*#__PURE__*/jsx(FormattedMessage, {
58
- values: resourceValues,
11
+ function ModalResourceItems(t0) {
12
+ const $ = c(63);
13
+ let id;
14
+ let props;
15
+ let t1;
16
+ let t10;
17
+ let t11;
18
+ let t12;
19
+ let t13;
20
+ let t14;
21
+ let t2;
22
+ let t3;
23
+ let t4;
24
+ let t5;
25
+ let t6;
26
+ let t7;
27
+ let t8;
28
+ let t9;
29
+ if ($[0] !== t0) {
30
+ ({
31
+ id,
32
+ resource: t1,
33
+ title: t2,
34
+ query: t3,
35
+ paginated: t4,
36
+ size: t5,
37
+ onClosed: t6,
38
+ onSelect: t7,
39
+ multiple: t8,
40
+ listProps: t9,
41
+ confirmButton: t10,
42
+ cancelButton: t11,
43
+ withoutCloseOnSelect: t12,
44
+ className: t13,
45
+ children: t14,
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] = t2;
58
+ $[10] = t3;
59
+ $[11] = t4;
60
+ $[12] = t5;
61
+ $[13] = t6;
62
+ $[14] = t7;
63
+ $[15] = t8;
64
+ $[16] = t9;
65
+ } else {
66
+ id = $[1];
67
+ props = $[2];
68
+ t1 = $[3];
69
+ t10 = $[4];
70
+ t11 = $[5];
71
+ t12 = $[6];
72
+ t13 = $[7];
73
+ t14 = $[8];
74
+ t2 = $[9];
75
+ t3 = $[10];
76
+ t4 = $[11];
77
+ t5 = $[12];
78
+ t6 = $[13];
79
+ t7 = $[14];
80
+ t8 = $[15];
81
+ t9 = $[16];
82
+ }
83
+ const providedResource = t1 === undefined ? null : t1;
84
+ const title = t2 === undefined ? null : t2;
85
+ const initialQuery = t3 === undefined ? null : t3;
86
+ const paginated = t4 === undefined ? true : t4;
87
+ const size = t5 === undefined ? "xl" : t5;
88
+ const onClosed = t6 === undefined ? null : t6;
89
+ const onSelect = t7 === undefined ? null : t7;
90
+ const multiple = t8 === undefined ? false : t8;
91
+ const confirmButton = t10 === undefined ? null : t10;
92
+ const cancelButton = t11 === undefined ? null : t11;
93
+ const withoutCloseOnSelect = t12 === undefined ? false : t12;
94
+ const className = t13 === undefined ? null : t13;
95
+ const children = t14 === undefined ? null : t14;
96
+ const [opened, setOpened] = useState(true);
97
+ let t15;
98
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
99
+ t15 = () => {
100
+ setOpened(false);
101
+ };
102
+ $[17] = t15;
103
+ } else {
104
+ t15 = $[17];
105
+ }
106
+ const requestClose = t15;
107
+ const resource = usePanneauResource(providedResource);
108
+ const resourceValues = useResourceValues(resource);
109
+ let t16;
110
+ if ($[18] !== initialQuery) {
111
+ t16 = {
112
+ ...initialQuery
113
+ };
114
+ $[18] = initialQuery;
115
+ $[19] = t16;
116
+ } else {
117
+ t16 = $[19];
118
+ }
119
+ const finalQuery = t16;
120
+ const {
121
+ query,
122
+ onPageChange,
123
+ onQueryChange,
124
+ onQueryReset
125
+ } = useQuery(finalQuery, paginated);
126
+ let t17;
127
+ if ($[20] !== onPageChange) {
128
+ t17 = (e, t18) => {
129
+ const pageNumber = t18 === undefined ? null : t18;
130
+ e.preventDefault();
131
+ e.stopPropagation();
132
+ onPageChange(pageNumber);
133
+ };
134
+ $[20] = onPageChange;
135
+ $[21] = t17;
136
+ } else {
137
+ t17 = $[21];
138
+ }
139
+ const finalOnPageChange = t17;
140
+ let t18;
141
+ if ($[22] !== onQueryChange) {
142
+ t18 = newQuery => {
143
+ onQueryChange(newQuery);
144
+ };
145
+ $[22] = onQueryChange;
146
+ $[23] = t18;
147
+ } else {
148
+ t18 = $[23];
149
+ }
150
+ const finalOnQueryChange = t18;
151
+ const [selectedItems, setSelectedItems] = useState(null);
152
+ let t19;
153
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
154
+ t19 = newSelectedItems => {
155
+ setSelectedItems(newSelectedItems);
156
+ };
157
+ $[24] = t19;
158
+ } else {
159
+ t19 = $[24];
160
+ }
161
+ const onSelectionChange = t19;
162
+ let t20;
163
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
164
+ t20 = () => {
165
+ setSelectedItems(null);
166
+ requestClose();
167
+ };
168
+ $[25] = t20;
169
+ } else {
170
+ t20 = $[25];
171
+ }
172
+ const onClickCancel = t20;
173
+ let t21;
174
+ if ($[26] !== onSelect || $[27] !== selectedItems || $[28] !== withoutCloseOnSelect) {
175
+ t21 = () => {
176
+ if (onSelect !== null) {
177
+ onSelect(selectedItems);
178
+ }
179
+ if (!withoutCloseOnSelect) {
180
+ requestClose();
181
+ }
182
+ };
183
+ $[26] = onSelect;
184
+ $[27] = selectedItems;
185
+ $[28] = withoutCloseOnSelect;
186
+ $[29] = t21;
187
+ } else {
188
+ t21 = $[29];
189
+ }
190
+ const onClickConfirm = t21;
191
+ const t22 = id || `resource-items-modal-${resource?.id}`;
192
+ let t23;
193
+ if ($[30] !== resourceValues || $[31] !== title) {
194
+ t23 = title || /*#__PURE__*/jsx(FormattedMessage, {
59
195
  id: "XLVfN6",
60
- defaultMessage: [{
61
- "type": 0,
62
- "value": "Find "
63
- }, {
64
- "type": 1,
65
- "value": "a_singular"
66
- }]
67
- }),
68
- size: size,
69
- onClose: onClose,
70
- className: className,
71
- children: [/*#__PURE__*/jsx(ResourceItemsList, _objectSpread({
196
+ values: resourceValues
197
+ });
198
+ $[30] = resourceValues;
199
+ $[31] = title;
200
+ $[32] = t23;
201
+ } else {
202
+ t23 = $[32];
203
+ }
204
+ let t24;
205
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
206
+ t24 = /*#__PURE__*/jsx(FormattedMessage, {
207
+ id: "PyxZY2"
208
+ });
209
+ $[33] = t24;
210
+ } else {
211
+ t24 = $[33];
212
+ }
213
+ let t25;
214
+ if ($[34] !== cancelButton) {
215
+ t25 = {
216
+ id: "no",
217
+ label: t24,
218
+ theme: "secondary",
219
+ onClick: onClickCancel,
220
+ ...cancelButton
221
+ };
222
+ $[34] = cancelButton;
223
+ $[35] = t25;
224
+ } else {
225
+ t25 = $[35];
226
+ }
227
+ const t26 = selectedItems == null || selectedItems.length === 0;
228
+ let t27;
229
+ if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
230
+ t27 = /*#__PURE__*/jsx(FormattedMessage, {
231
+ id: "UaVu03"
232
+ });
233
+ $[36] = t27;
234
+ } else {
235
+ t27 = $[36];
236
+ }
237
+ let t28;
238
+ if ($[37] !== confirmButton || $[38] !== onClickConfirm || $[39] !== t26) {
239
+ t28 = {
240
+ id: "yes",
241
+ disabled: t26,
242
+ label: t27,
243
+ theme: "primary",
244
+ onClick: onClickConfirm,
245
+ ...confirmButton
246
+ };
247
+ $[37] = confirmButton;
248
+ $[38] = onClickConfirm;
249
+ $[39] = t26;
250
+ $[40] = t28;
251
+ } else {
252
+ t28 = $[40];
253
+ }
254
+ let t29;
255
+ if ($[41] !== t25 || $[42] !== t28) {
256
+ t29 = [t25, t28];
257
+ $[41] = t25;
258
+ $[42] = t28;
259
+ $[43] = t29;
260
+ } else {
261
+ t29 = $[43];
262
+ }
263
+ let t30;
264
+ if ($[44] !== finalOnPageChange || $[45] !== finalOnQueryChange || $[46] !== multiple || $[47] !== onQueryReset || $[48] !== props || $[49] !== query || $[50] !== resource || $[51] !== selectedItems) {
265
+ t30 = /*#__PURE__*/jsx(ResourceItemsList, {
72
266
  resource: resource,
73
267
  query: query,
74
268
  onPageChange: finalOnPageChange,
75
269
  onQueryChange: finalOnQueryChange,
76
270
  onQueryReset: onQueryReset,
77
- listProps: listProps
78
- }, props)), children]
79
- });
271
+ selectable: true,
272
+ selectedItems: selectedItems,
273
+ onSelectionChange: onSelectionChange,
274
+ multipleSelection: multiple,
275
+ ...props
276
+ });
277
+ $[44] = finalOnPageChange;
278
+ $[45] = finalOnQueryChange;
279
+ $[46] = multiple;
280
+ $[47] = onQueryReset;
281
+ $[48] = props;
282
+ $[49] = query;
283
+ $[50] = resource;
284
+ $[51] = selectedItems;
285
+ $[52] = t30;
286
+ } else {
287
+ t30 = $[52];
288
+ }
289
+ let t31;
290
+ if ($[53] !== children || $[54] !== className || $[55] !== onClosed || $[56] !== opened || $[57] !== size || $[58] !== t22 || $[59] !== t23 || $[60] !== t29 || $[61] !== t30) {
291
+ t31 = /*#__PURE__*/jsxs(Dialog, {
292
+ id: t22,
293
+ title: t23,
294
+ size: size,
295
+ visible: opened,
296
+ requestClose: requestClose,
297
+ onClosed: onClosed,
298
+ buttons: t29,
299
+ className: className,
300
+ children: [t30, children]
301
+ });
302
+ $[53] = children;
303
+ $[54] = className;
304
+ $[55] = onClosed;
305
+ $[56] = opened;
306
+ $[57] = size;
307
+ $[58] = t22;
308
+ $[59] = t23;
309
+ $[60] = t29;
310
+ $[61] = t30;
311
+ $[62] = t31;
312
+ } else {
313
+ t31 = $[62];
314
+ }
315
+ return t31;
80
316
  }
81
317
 
82
318
  export { ModalResourceItems as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-resource-items",
3
- "version": "4.0.39",
3
+ "version": "4.0.40-alpha.3",
4
4
  "description": "Resource items modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,11 +52,11 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.28.6",
55
- "@panneau/core": "^4.0.38",
56
- "@panneau/intl": "^4.0.38",
57
- "@panneau/list-resource-items": "^4.0.39",
58
- "@panneau/modal-dialog": "^4.0.39",
59
- "@panneau/themes": "^4.0.38",
55
+ "@panneau/core": "^4.0.40-alpha.3",
56
+ "@panneau/intl": "^4.0.40-alpha.3",
57
+ "@panneau/list-resource-items": "^4.0.40-alpha.3",
58
+ "@panneau/modal-dialog": "^4.0.40-alpha.3",
59
+ "@panneau/themes": "^4.0.40-alpha.3",
60
60
  "classnames": "^2.5.1",
61
61
  "lodash": "^4.17.21",
62
62
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "621c5233f083c1ba95cd46cd427c38361723d5d6"
67
+ "gitHead": "1735964a2702ae0480b642225286e4184f36680d"
68
68
  }