@panneau/lists 5.0.0-alpha.6 → 5.0.0-alpha.7

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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/ItemDetails.d.ts +4 -2
  3. package/dist/ItemDetails.d.ts.map +1 -1
  4. package/dist/ItemDetails.js +48 -6
  5. package/dist/ItemDetails.js.map +1 -1
  6. package/dist/List.js +54 -12
  7. package/dist/List.js.map +1 -1
  8. package/dist/ListSkeleton.d.ts +17 -0
  9. package/dist/ListSkeleton.d.ts.map +1 -0
  10. package/dist/ListSkeleton.js +111 -0
  11. package/dist/ListSkeleton.js.map +1 -0
  12. package/dist/ListView.d.ts +4 -1
  13. package/dist/ListView.d.ts.map +1 -1
  14. package/dist/ListView.js +494 -179
  15. package/dist/ListView.js.map +1 -1
  16. package/dist/actions/ActionButton.js +79 -21
  17. package/dist/actions/ActionButton.js.map +1 -1
  18. package/dist/actions/ConfirmDialog.js +121 -24
  19. package/dist/actions/ConfirmDialog.js.map +1 -1
  20. package/dist/actions/RowActions.js +1 -1
  21. package/dist/actions/RowActions.js.map +1 -1
  22. package/dist/actions/actions.js.map +1 -1
  23. package/dist/actions/icons.js.map +1 -1
  24. package/dist/cx.js.map +1 -1
  25. package/dist/displays/displays.js +1 -1
  26. package/dist/displays/displays.js.map +1 -1
  27. package/dist/filters/Filters.js +1 -1
  28. package/dist/filters/Filters.js.map +1 -1
  29. package/dist/filters/controls.js +1 -1
  30. package/dist/filters/controls.js.map +1 -1
  31. package/dist/filters/format.js.map +1 -1
  32. package/dist/layouts/CardsLayout.js +1 -1
  33. package/dist/layouts/CardsLayout.js.map +1 -1
  34. package/dist/layouts/ItemTitle.js +20 -7
  35. package/dist/layouts/ItemTitle.js.map +1 -1
  36. package/dist/layouts/TableLayout.js +1 -1
  37. package/dist/layouts/TableLayout.js.map +1 -1
  38. package/dist/layouts/builtIn.js.map +1 -1
  39. package/dist/plugin.js.map +1 -1
  40. package/dist/query.js.map +1 -1
  41. package/dist/selection.js.map +1 -1
  42. package/dist/toolbar/LayoutSwitch.js +1 -1
  43. package/dist/toolbar/LayoutSwitch.js.map +1 -1
  44. package/dist/toolbar/Pagination.js +152 -41
  45. package/dist/toolbar/Pagination.js.map +1 -1
  46. package/dist/toolbar/SearchField.js +1 -1
  47. package/dist/toolbar/SearchField.js.map +1 -1
  48. package/dist/toolbar/SortSelect.js +1 -1
  49. package/dist/toolbar/SortSelect.js.map +1 -1
  50. package/dist/useDraft.js.map +1 -1
  51. package/dist/useListState.js.map +1 -1
  52. package/dist/useRenderValue.js +1 -1
  53. package/dist/useRenderValue.js.map +1 -1
  54. package/dist/values.js.map +1 -1
  55. package/package.json +7 -7
package/dist/ListView.js CHANGED
@@ -5,6 +5,7 @@ import { getColumnValue, toText } from "./values.js";
5
5
  import { cx } from "./cx.js";
6
6
  import { builtInLayouts } from "./layouts/builtIn.js";
7
7
  import { useRenderValue } from "./useRenderValue.js";
8
+ import { ListSkeleton } from "./ListSkeleton.js";
8
9
  import ListView_module_default from "./ListView.module.js";
9
10
  import { ActionButton } from "./actions/ActionButton.js";
10
11
  import { RowActions } from "./actions/RowActions.js";
@@ -16,7 +17,8 @@ import { SearchField } from "./toolbar/SearchField.js";
16
17
  import { SortSelect } from "./toolbar/SortSelect.js";
17
18
  import { useListState } from "./useListState.js";
18
19
  import { usePlugins } from "@panneau/core";
19
- import { Alert, Button, Checkbox, Spinner, usePanneauIntl, useToast } from "@panneau/ui";
20
+ import { c } from "react/compiler-runtime";
21
+ import { Alert, Button, Checkbox, usePanneauIntl, useToast } from "@panneau/ui";
20
22
  import { jsx, jsxs } from "react/jsx-runtime";
21
23
  import { useRef, useState } from "react";
22
24
  //#region src/ListView.tsx
@@ -28,7 +30,34 @@ function keyOf(action, item) {
28
30
  * cards), with sorting, search, filters and their chips, pagination, selection and actions. It
29
31
  * fetches nothing: the caller gives the items of the list's query and their total.
30
32
  */
31
- function ListView({ list, items, columns, total, isLoading = false, error = null, onRetry, filters = [], fields = [], search = false, layouts: layoutsProp = ["table"], layout: controlledLayout, onLayoutChange, perPageOptions, selectable: selectableProp, actions: actionsProp, onAction, previewAction, actionIcons, itemTitle, getItemLabel: getItemLabelProp, getItemHref, currentItemId = null, displays, layoutComponents, filterControls, toolbar, emptyMessage, "aria-label": ariaLabel, className }) {
33
+ function ListView(t0) {
34
+ const $ = c(118);
35
+ const { list, items, columns, total, isLoading: t1, error: t2, onRetry, filters: t3, fields: t4, search: t5, layouts: t6, layout: controlledLayout, onLayoutChange, perPageOptions, selectable: selectableProp, actions: actionsProp, onAction, previewAction, actionIcons, itemTitle, getItemLabel: getItemLabelProp, getItemHref, currentItemId: t7, displays, layoutComponents, filterControls, toolbar, emptyMessage, "aria-label": ariaLabel, className } = t0;
36
+ const isLoading = t1 === void 0 ? false : t1;
37
+ const error = t2 === void 0 ? null : t2;
38
+ let t8;
39
+ if ($[0] !== t3) {
40
+ t8 = t3 === void 0 ? [] : t3;
41
+ $[0] = t3;
42
+ $[1] = t8;
43
+ } else t8 = $[1];
44
+ const filters = t8;
45
+ let t9;
46
+ if ($[2] !== t4) {
47
+ t9 = t4 === void 0 ? [] : t4;
48
+ $[2] = t4;
49
+ $[3] = t9;
50
+ } else t9 = $[3];
51
+ const fields = t9;
52
+ const search = t5 === void 0 ? false : t5;
53
+ let t10;
54
+ if ($[4] !== t6) {
55
+ t10 = t6 === void 0 ? ["table"] : t6;
56
+ $[4] = t6;
57
+ $[5] = t10;
58
+ } else t10 = $[5];
59
+ const layoutsProp = t10;
60
+ const currentItemId = t7 === void 0 ? null : t7;
32
61
  const intl = usePanneauIntl();
33
62
  const toasts = useToast();
34
63
  const plugins = usePlugins();
@@ -39,63 +68,135 @@ function ListView({ list, items, columns, total, isLoading = false, error = null
39
68
  const [preview, setPreview] = useState(null);
40
69
  const confirmation = useRef(0);
41
70
  const [pending, setPending] = useState(null);
42
- const label = ariaLabel ?? intl.formatMessage(messages.list);
71
+ let t11;
72
+ if ($[6] !== ariaLabel || $[7] !== intl) {
73
+ t11 = ariaLabel ?? intl.formatMessage(messages.list);
74
+ $[6] = ariaLabel;
75
+ $[7] = intl;
76
+ $[8] = t11;
77
+ } else t11 = $[8];
78
+ const label = t11;
43
79
  const pageItems = items ?? [];
44
80
  const count = total ?? pageItems.length;
45
- const sort = query.sort ?? [];
46
- const filterValues = query.filter ?? {};
47
- const hasQuery = Object.keys(filterValues).length > 0 || (query.q ?? "") !== "";
48
- const allLayouts = {
49
- ...builtInLayouts,
50
- ...Object.fromEntries(plugins.listLayouts),
51
- ...layoutComponents
52
- };
53
- const available = layoutsProp.filter((id) => allLayouts[id] !== void 0);
54
- const layouts = available.length > 0 ? available : ["table"];
81
+ let t12;
82
+ if ($[9] !== query.sort) {
83
+ t12 = query.sort ?? [];
84
+ $[9] = query.sort;
85
+ $[10] = t12;
86
+ } else t12 = $[10];
87
+ const sort = t12;
88
+ let t13;
89
+ if ($[11] !== query.filter) {
90
+ t13 = query.filter ?? {};
91
+ $[11] = query.filter;
92
+ $[12] = t13;
93
+ } else t13 = $[12];
94
+ const filterValues = t13;
95
+ let t14;
96
+ if ($[13] !== filterValues || $[14] !== query.q) {
97
+ t14 = Object.keys(filterValues).length > 0 || (query.q ?? "") !== "";
98
+ $[13] = filterValues;
99
+ $[14] = query.q;
100
+ $[15] = t14;
101
+ } else t14 = $[15];
102
+ const hasQuery = t14;
103
+ let t15;
104
+ if ($[16] !== plugins.listLayouts) {
105
+ t15 = Object.fromEntries(plugins.listLayouts);
106
+ $[16] = plugins.listLayouts;
107
+ $[17] = t15;
108
+ } else t15 = $[17];
109
+ const t16 = t15;
110
+ let t17;
111
+ if ($[18] !== layoutComponents || $[19] !== t16) {
112
+ t17 = {
113
+ ...builtInLayouts,
114
+ ...t16,
115
+ ...layoutComponents
116
+ };
117
+ $[18] = layoutComponents;
118
+ $[19] = t16;
119
+ $[20] = t17;
120
+ } else t17 = $[20];
121
+ const allLayouts = t17;
122
+ let t18;
123
+ if ($[21] !== allLayouts || $[22] !== layoutsProp) {
124
+ let t19;
125
+ if ($[24] !== allLayouts) {
126
+ t19 = (id) => allLayouts[id] !== void 0;
127
+ $[24] = allLayouts;
128
+ $[25] = t19;
129
+ } else t19 = $[25];
130
+ t18 = layoutsProp.filter(t19);
131
+ $[21] = allLayouts;
132
+ $[22] = layoutsProp;
133
+ $[23] = t18;
134
+ } else t18 = $[23];
135
+ const available = t18;
136
+ let t19;
137
+ if ($[26] !== available) {
138
+ t19 = available.length > 0 ? available : ["table"];
139
+ $[26] = available;
140
+ $[27] = t19;
141
+ } else t19 = $[27];
142
+ const layouts = t19;
55
143
  const layout = controlledLayout ?? uncontrolledLayout ?? layouts[0] ?? "table";
56
144
  const Layout = allLayouts[layout] ?? builtInLayouts.table;
57
145
  const grouped = groupListActions(actionsProp);
58
- const rowActions = grouped.row.filter((action) => hasScope(action, "item"));
59
- const rowMenu = grouped.menu.filter((action_0) => hasScope(action_0, "item"));
60
- const toolbarActions = [...grouped.toolbar, ...grouped.menu].filter((action_1, index, all) => (hasScope(action_1, "selection") || hasScope(action_1, "resource")) && all.findIndex((candidate) => candidate.id === action_1.id) === index);
61
- const selectionActions = toolbarActions.filter((action_2) => hasScope(action_2, "selection"));
62
- const resourceActions = toolbarActions.filter((action_3) => hasScope(action_3, "resource"));
146
+ const rowActions = grouped.row.filter(_temp);
147
+ const rowMenu = grouped.menu.filter(_temp2);
148
+ const toolbarActions = [...grouped.toolbar, ...grouped.menu].filter(_temp3);
149
+ const selectionActions = toolbarActions.filter(_temp4);
150
+ const resourceActions = toolbarActions.filter(_temp5);
63
151
  const selectable = selectableProp ?? selectionActions.length > 0;
64
152
  const selectedCount = selectable ? countSelected(selection, count) : 0;
65
- const selectedItems = pageItems.filter((item) => isItemSelected(selection, item.id));
153
+ let t20;
154
+ if ($[28] !== selection) {
155
+ t20 = (item) => isItemSelected(selection, item.id);
156
+ $[28] = selection;
157
+ $[29] = t20;
158
+ } else t20 = $[29];
159
+ const selectedItems = pageItems.filter(t20);
66
160
  const pageSelection = getPageSelection(selection, pageItems);
67
- const getItemLabel = (item_0) => {
68
- if (getItemLabelProp !== void 0) return getItemLabelProp(item_0);
69
- const titleColumn = columns.find((column) => column.id === itemTitle) ?? (itemTitle === void 0 ? columns[0] : void 0);
70
- const title = titleColumn !== void 0 ? toText(getColumnValue(item_0, titleColumn, intl.locale), intl.locale) : itemTitle !== void 0 ? toText(item_0[itemTitle], intl.locale) : "";
71
- return title !== "" ? title : item_0.id;
72
- };
161
+ let t21;
162
+ if ($[30] !== columns || $[31] !== getItemLabelProp || $[32] !== intl.locale || $[33] !== itemTitle) {
163
+ t21 = (item_0) => {
164
+ if (getItemLabelProp !== void 0) return getItemLabelProp(item_0);
165
+ const titleColumn = columns.find((column) => column.id === itemTitle) ?? (itemTitle === void 0 ? columns[0] : void 0);
166
+ const title = titleColumn !== void 0 ? toText(getColumnValue(item_0, titleColumn, intl.locale), intl.locale) : itemTitle !== void 0 ? toText(item_0[itemTitle], intl.locale) : "";
167
+ return title !== "" ? title : item_0.id;
168
+ };
169
+ $[30] = columns;
170
+ $[31] = getItemLabelProp;
171
+ $[32] = intl.locale;
172
+ $[33] = itemTitle;
173
+ $[34] = t21;
174
+ } else t21 = $[34];
175
+ const getItemLabel = t21;
73
176
  const renderValue = useRenderValue(displays);
74
177
  const closeConfirmation = () => {
75
- confirmation.current += 1;
178
+ confirmation.current = confirmation.current + 1;
76
179
  setConfirming(null);
77
180
  setPreview(null);
78
181
  };
79
182
  const execute = async (event) => {
80
183
  closeConfirmation();
81
184
  setPending(keyOf(event.action, event.item));
82
- try {
83
- const outcome = await onAction?.(event);
185
+ await Promise.resolve().then(() => onAction?.(event)).then((outcome) => {
84
186
  if (event.scope === "selection" && outcome !== false) list.clearSelection();
85
- } catch (caught) {
187
+ }).catch((caught) => {
86
188
  toasts.show({
87
189
  title: intl.formatMessage(messages.actionFailed, { action: event.action.label }),
88
190
  ...caught instanceof Error && caught.message !== "" ? { description: caught.message } : {},
89
191
  tone: "danger"
90
192
  });
91
- } finally {
92
- setPending(null);
93
- }
193
+ });
194
+ setPending(null);
94
195
  };
95
196
  const run = (event_0) => {
96
197
  const { action: action_4, selection: selection_0 } = event_0;
97
198
  if (previewAction !== void 0 && action_4.dryRun === true && selection_0 !== void 0 && "query" in selection_0) {
98
- const current = ++confirmation.current;
199
+ const current = confirmation.current = confirmation.current + 1;
99
200
  const asks = action_4.confirm !== void 0 && action_4.confirm !== false;
100
201
  setConfirming(event_0);
101
202
  setPreview({ status: "loading" });
@@ -155,183 +256,397 @@ function ListView({ list, items, columns, total, isLoading = false, error = null
155
256
  icons: actionIcons
156
257
  });
157
258
  };
259
+ let t22;
260
+ if ($[35] !== intl) {
261
+ t22 = intl.formatMessage(messages.selectPage);
262
+ $[35] = intl;
263
+ $[36] = t22;
264
+ } else t22 = $[36];
158
265
  const pageCheckbox = /* @__PURE__ */ jsx(Checkbox, {
159
- "aria-label": intl.formatMessage(messages.selectPage),
266
+ "aria-label": t22,
160
267
  isSelected: pageSelection === "all",
161
268
  isIndeterminate: pageSelection === "some",
162
269
  isDisabled: pageItems.length === 0,
163
270
  onChange: () => {
164
- const ids = pageItems.map((item_4) => item_4.id);
271
+ const ids = pageItems.map(_temp6);
165
272
  if (pageSelection === "all") list.deselect(ids);
166
273
  else list.select(ids);
167
274
  }
168
275
  });
169
- const sortable = columns.some((column_0) => column_0.sortable === true);
276
+ const sortable = columns.some(_temp7);
170
277
  const showToolbar = search || filters.length > 0 || sortable || layouts.length > 1 || resourceActions.length > 0 || toolbar !== void 0;
171
- const body = (() => {
172
- if (error !== null) return /* @__PURE__ */ jsx(Alert, {
173
- tone: "danger",
174
- title: intl.formatMessage(messages.loadFailed),
175
- actions: onRetry !== void 0 ? /* @__PURE__ */ jsx(Button, {
176
- size: "sm",
177
- onPress: onRetry,
178
- children: intl.formatMessage(messages.retry)
179
- }) : void 0,
180
- children: error.message
181
- });
182
- if (items === void 0) return /* @__PURE__ */ jsx("div", {
183
- className: ListView_module_default.state,
184
- children: /* @__PURE__ */ jsx(Spinner, { showLabel: true })
185
- });
186
- if (pageItems.length === 0) return /* @__PURE__ */ jsxs("div", {
187
- className: ListView_module_default.state,
188
- children: [/* @__PURE__ */ jsx("p", { children: hasQuery ? intl.formatMessage(messages.noResults) : emptyMessage ?? intl.formatMessage(messages.empty) }), hasQuery ? /* @__PURE__ */ jsx(Button, {
189
- size: "sm",
190
- onPress: () => clearFilters(),
191
- children: intl.formatMessage(messages.clearFilters)
192
- }) : null]
193
- });
194
- return /* @__PURE__ */ jsx(Layout, {
278
+ let t23;
279
+ if ($[37] !== filterValues || $[38] !== list || $[39] !== query.q) {
280
+ t23 = function clearFilters() {
281
+ Object.keys(filterValues).forEach((id_0) => list.setFilter(id_0, void 0));
282
+ if ((query.q ?? "") !== "") list.setSearch("");
283
+ };
284
+ $[37] = filterValues;
285
+ $[38] = list;
286
+ $[39] = query.q;
287
+ $[40] = t23;
288
+ } else t23 = $[40];
289
+ const clearFilters = t23;
290
+ let t24;
291
+ bb0: {
292
+ if (error !== null) {
293
+ let t25;
294
+ if ($[41] !== intl) {
295
+ t25 = intl.formatMessage(messages.loadFailed);
296
+ $[41] = intl;
297
+ $[42] = t25;
298
+ } else t25 = $[42];
299
+ let t26;
300
+ if ($[43] !== intl || $[44] !== onRetry) {
301
+ t26 = onRetry !== void 0 ? /* @__PURE__ */ jsx(Button, {
302
+ size: "sm",
303
+ onPress: onRetry,
304
+ children: intl.formatMessage(messages.retry)
305
+ }) : void 0;
306
+ $[43] = intl;
307
+ $[44] = onRetry;
308
+ $[45] = t26;
309
+ } else t26 = $[45];
310
+ let t27;
311
+ if ($[46] !== error.message || $[47] !== t25 || $[48] !== t26) {
312
+ t27 = /* @__PURE__ */ jsx(Alert, {
313
+ tone: "danger",
314
+ title: t25,
315
+ actions: t26,
316
+ children: error.message
317
+ });
318
+ $[46] = error.message;
319
+ $[47] = t25;
320
+ $[48] = t26;
321
+ $[49] = t27;
322
+ } else t27 = $[49];
323
+ t24 = t27;
324
+ break bb0;
325
+ }
326
+ if (items === void 0) {
327
+ let t25;
328
+ if ($[50] !== Layout || $[51] !== columns || $[52] !== label || $[53] !== query.perPage || $[54] !== sort) {
329
+ t25 = /* @__PURE__ */ jsx(ListSkeleton, {
330
+ Layout,
331
+ columns,
332
+ perPage: query.perPage,
333
+ sort,
334
+ label
335
+ });
336
+ $[50] = Layout;
337
+ $[51] = columns;
338
+ $[52] = label;
339
+ $[53] = query.perPage;
340
+ $[54] = sort;
341
+ $[55] = t25;
342
+ } else t25 = $[55];
343
+ t24 = t25;
344
+ break bb0;
345
+ }
346
+ if (pageItems.length === 0) {
347
+ let t25;
348
+ if ($[56] !== emptyMessage || $[57] !== hasQuery || $[58] !== intl) {
349
+ t25 = hasQuery ? intl.formatMessage(messages.noResults) : emptyMessage ?? intl.formatMessage(messages.empty);
350
+ $[56] = emptyMessage;
351
+ $[57] = hasQuery;
352
+ $[58] = intl;
353
+ $[59] = t25;
354
+ } else t25 = $[59];
355
+ let t26;
356
+ if ($[60] !== t25) {
357
+ t26 = /* @__PURE__ */ jsx("p", { children: t25 });
358
+ $[60] = t25;
359
+ $[61] = t26;
360
+ } else t26 = $[61];
361
+ let t27;
362
+ if ($[62] !== clearFilters || $[63] !== hasQuery || $[64] !== intl) {
363
+ t27 = hasQuery ? /* @__PURE__ */ jsx(Button, {
364
+ size: "sm",
365
+ onPress: () => clearFilters(),
366
+ children: intl.formatMessage(messages.clearFilters)
367
+ }) : null;
368
+ $[62] = clearFilters;
369
+ $[63] = hasQuery;
370
+ $[64] = intl;
371
+ $[65] = t27;
372
+ } else t27 = $[65];
373
+ let t28;
374
+ if ($[66] !== t26 || $[67] !== t27) {
375
+ t28 = /* @__PURE__ */ jsxs("div", {
376
+ className: ListView_module_default.state,
377
+ children: [t26, t27]
378
+ });
379
+ $[66] = t26;
380
+ $[67] = t27;
381
+ $[68] = t28;
382
+ } else t28 = $[68];
383
+ t24 = t28;
384
+ break bb0;
385
+ }
386
+ let t25;
387
+ if ($[69] !== currentItemId) {
388
+ t25 = (item_5) => item_5.id === currentItemId;
389
+ $[69] = currentItemId;
390
+ $[70] = t25;
391
+ } else t25 = $[70];
392
+ let t26;
393
+ if ($[71] !== selection) {
394
+ t26 = (item_6) => isItemSelected(selection, item_6.id);
395
+ $[71] = selection;
396
+ $[72] = t26;
397
+ } else t26 = $[72];
398
+ let t27;
399
+ if ($[73] !== list) {
400
+ t27 = (item_7) => list.toggle(item_7.id);
401
+ $[73] = list;
402
+ $[74] = t27;
403
+ } else t27 = $[74];
404
+ let t28;
405
+ if ($[75] !== list) {
406
+ t28 = (column_1) => list.toggleSort(column_1.id);
407
+ $[75] = list;
408
+ $[76] = t28;
409
+ } else t28 = $[76];
410
+ t24 = /* @__PURE__ */ jsx(Layout, {
195
411
  items: pageItems,
196
412
  columns,
197
413
  renderValue,
198
414
  getItemLabel,
199
415
  getItemHref,
200
- isCurrent: (item_5) => item_5.id === currentItemId,
416
+ isCurrent: t25,
201
417
  selectable,
202
- isSelected: (item_6) => isItemSelected(selection, item_6.id),
203
- onToggle: (item_7) => list.toggle(item_7.id),
418
+ isSelected: t26,
419
+ onToggle: t27,
204
420
  renderActions,
205
421
  sort,
206
- onSort: (column_1) => list.toggleSort(column_1.id),
422
+ onSort: t28,
207
423
  label,
208
424
  pageSelection: pageCheckbox
209
425
  });
210
- })();
211
- function clearFilters() {
212
- Object.keys(filterValues).forEach((id_0) => list.setFilter(id_0, void 0));
213
- if ((query.q ?? "") !== "") list.setSearch("");
214
426
  }
215
- return /* @__PURE__ */ jsxs("div", {
216
- className: cx(ListView_module_default.list, className),
217
- children: [
218
- showToolbar ? /* @__PURE__ */ jsxs("div", {
219
- className: ListView_module_default.toolbar,
220
- children: [/* @__PURE__ */ jsxs("div", {
221
- className: ListView_module_default.toolbarStart,
222
- children: [search ? /* @__PURE__ */ jsx(SearchField, {
223
- value: query.q ?? "",
224
- onChange: (q) => list.setSearch(q)
225
- }) : null, filters.length > 0 ? /* @__PURE__ */ jsx(FilterControls, {
226
- filters,
227
- values: filterValues,
228
- onChange: (id_1, value) => list.setFilter(id_1, value),
229
- onLabel: filterLabels.remember,
230
- controls: filterControls,
231
- columns,
232
- fields,
233
- labels: filterLabels.labels
234
- }) : null]
235
- }), /* @__PURE__ */ jsxs("div", {
236
- className: ListView_module_default.toolbarEnd,
237
- children: [
238
- sortable ? /* @__PURE__ */ jsx("div", {
239
- className: layout === "table" ? ListView_module_default.tableSort : void 0,
240
- children: /* @__PURE__ */ jsx(SortSelect, {
241
- columns,
242
- sort,
243
- onChange: (next) => list.setSort(next)
244
- })
245
- }) : null,
246
- layouts.length > 1 ? /* @__PURE__ */ jsx(LayoutSwitch, {
247
- layouts,
248
- value: layout,
249
- onChange: (next_0) => {
250
- setLayout(next_0);
251
- onLayoutChange?.(next_0);
252
- }
253
- }) : null,
254
- resourceActions.filter((action_11) => selectedCount === 0 || !hasScope(action_11, "selection")).map((action_12) => /* @__PURE__ */ jsx(ActionButton, {
255
- action: action_12,
256
- icons: actionIcons,
257
- size: "md",
258
- href: getActionHref(action_12),
259
- isPending: pending === keyOf(action_12),
260
- onPress: () => runOnResource(action_12)
261
- }, action_12.id)),
262
- toolbar
263
- ]
264
- })]
265
- }) : null,
266
- /* @__PURE__ */ jsx(FilterChips, {
427
+ const body = t24;
428
+ let t25;
429
+ if ($[77] !== className) {
430
+ t25 = cx(ListView_module_default.list, className);
431
+ $[77] = className;
432
+ $[78] = t25;
433
+ } else t25 = $[78];
434
+ const t26 = showToolbar ? /* @__PURE__ */ jsxs("div", {
435
+ className: ListView_module_default.toolbar,
436
+ children: [/* @__PURE__ */ jsxs("div", {
437
+ className: ListView_module_default.toolbarStart,
438
+ children: [search ? /* @__PURE__ */ jsx(SearchField, {
439
+ value: query.q ?? "",
440
+ onChange: (q) => list.setSearch(q)
441
+ }) : null, filters.length > 0 ? /* @__PURE__ */ jsx(FilterControls, {
267
442
  filters,
268
443
  values: filterValues,
269
- q: query.q,
270
- onRemove: (id_2) => list.setFilter(id_2, void 0),
271
- onClearSearch: () => list.setSearch(""),
272
- onClear: clearFilters,
444
+ onChange: (id_1, value) => list.setFilter(id_1, value),
445
+ onLabel: filterLabels.remember,
446
+ controls: filterControls,
273
447
  columns,
274
448
  fields,
275
449
  labels: filterLabels.labels
450
+ }) : null]
451
+ }), /* @__PURE__ */ jsxs("div", {
452
+ className: ListView_module_default.toolbarEnd,
453
+ children: [
454
+ sortable ? /* @__PURE__ */ jsx("div", {
455
+ className: layout === "table" ? ListView_module_default.tableSort : void 0,
456
+ children: /* @__PURE__ */ jsx(SortSelect, {
457
+ columns,
458
+ sort,
459
+ onChange: (next) => list.setSort(next)
460
+ })
461
+ }) : null,
462
+ layouts.length > 1 ? /* @__PURE__ */ jsx(LayoutSwitch, {
463
+ layouts,
464
+ value: layout,
465
+ onChange: (next_0) => {
466
+ setLayout(next_0);
467
+ onLayoutChange?.(next_0);
468
+ }
469
+ }) : null,
470
+ resourceActions.filter((action_11) => selectedCount === 0 || !hasScope(action_11, "selection")).map((action_12) => /* @__PURE__ */ jsx(ActionButton, {
471
+ action: action_12,
472
+ icons: actionIcons,
473
+ size: "md",
474
+ href: getActionHref(action_12),
475
+ isPending: pending === keyOf(action_12),
476
+ onPress: () => runOnResource(action_12)
477
+ }, action_12.id)),
478
+ toolbar
479
+ ]
480
+ })]
481
+ }) : null;
482
+ let t27;
483
+ let t28;
484
+ if ($[79] !== list) {
485
+ t27 = (id_2) => list.setFilter(id_2, void 0);
486
+ t28 = () => list.setSearch("");
487
+ $[79] = list;
488
+ $[80] = t27;
489
+ $[81] = t28;
490
+ } else {
491
+ t27 = $[80];
492
+ t28 = $[81];
493
+ }
494
+ let t29;
495
+ if ($[82] !== clearFilters || $[83] !== columns || $[84] !== fields || $[85] !== filterLabels.labels || $[86] !== filterValues || $[87] !== filters || $[88] !== query.q || $[89] !== t27 || $[90] !== t28) {
496
+ t29 = /* @__PURE__ */ jsx(FilterChips, {
497
+ filters,
498
+ values: filterValues,
499
+ q: query.q,
500
+ onRemove: t27,
501
+ onClearSearch: t28,
502
+ onClear: clearFilters,
503
+ columns,
504
+ fields,
505
+ labels: filterLabels.labels
506
+ });
507
+ $[82] = clearFilters;
508
+ $[83] = columns;
509
+ $[84] = fields;
510
+ $[85] = filterLabels.labels;
511
+ $[86] = filterValues;
512
+ $[87] = filters;
513
+ $[88] = query.q;
514
+ $[89] = t27;
515
+ $[90] = t28;
516
+ $[91] = t29;
517
+ } else t29 = $[91];
518
+ const t30 = selectedCount > 0 ? /* @__PURE__ */ jsxs("div", {
519
+ className: ListView_module_default.selection,
520
+ children: [
521
+ /* @__PURE__ */ jsx("span", {
522
+ className: ListView_module_default.selectionCount,
523
+ role: "status",
524
+ children: selection.mode === "all" ? intl.formatMessage(messages.allMatchingSelected, { total: selectedCount }) : intl.formatMessage(messages.selectedCount, { count: selectedCount })
276
525
  }),
277
- selectedCount > 0 ? /* @__PURE__ */ jsxs("div", {
278
- className: ListView_module_default.selection,
279
- children: [
280
- /* @__PURE__ */ jsx("span", {
281
- className: ListView_module_default.selectionCount,
282
- role: "status",
283
- children: selection.mode === "all" ? intl.formatMessage(messages.allMatchingSelected, { total: selectedCount }) : intl.formatMessage(messages.selectedCount, { count: selectedCount })
284
- }),
285
- selection.mode === "ids" && pageSelection === "all" && count > pageItems.length ? /* @__PURE__ */ jsx(Button, {
286
- size: "sm",
287
- variant: "ghost",
288
- onPress: () => list.selectAllMatching(),
289
- children: intl.formatMessage(messages.selectAllMatching, { total: count })
290
- }) : null,
291
- /* @__PURE__ */ jsx(Button, {
292
- size: "sm",
293
- variant: "ghost",
294
- onPress: () => list.clearSelection(),
295
- children: intl.formatMessage(messages.clearSelection)
296
- }),
297
- selectionActions.length > 0 ? /* @__PURE__ */ jsx("div", {
298
- className: ListView_module_default.selectionActions,
299
- children: selectionActions.map((action_13) => {
300
- const skipped_0 = selectedItems.filter((item_8) => !isAllowedOn(action_13, item_8)).length;
301
- return /* @__PURE__ */ jsx(ActionButton, {
302
- action: action_13,
303
- icons: actionIcons,
304
- size: "md",
305
- href: null,
306
- isPending: pending === keyOf(action_13),
307
- isDisabled: pending !== null && pending !== keyOf(action_13) || skipped_0 >= selectedCount,
308
- onPress: () => runOnSelection(action_13)
309
- }, action_13.id);
310
- })
311
- }) : null
312
- ]
526
+ selection.mode === "ids" && pageSelection === "all" && count > pageItems.length ? /* @__PURE__ */ jsx(Button, {
527
+ size: "sm",
528
+ variant: "ghost",
529
+ onPress: () => list.selectAllMatching(),
530
+ children: intl.formatMessage(messages.selectAllMatching, { total: count })
313
531
  }) : null,
314
- /* @__PURE__ */ jsx("div", {
315
- className: ListView_module_default.body,
316
- "aria-busy": isLoading && items !== void 0,
317
- children: body
532
+ /* @__PURE__ */ jsx(Button, {
533
+ size: "sm",
534
+ variant: "ghost",
535
+ onPress: () => list.clearSelection(),
536
+ children: intl.formatMessage(messages.clearSelection)
318
537
  }),
319
- total !== void 0 && error === null && total > 0 ? /* @__PURE__ */ jsx(Pagination, {
320
- page: query.page ?? 1,
321
- perPage: query.perPage ?? pageItems.length,
322
- total,
323
- onPageChange: (page) => list.setPage(page),
324
- perPageOptions,
325
- onPerPageChange: (perPage) => list.setPerPage(perPage)
326
- }) : null,
327
- /* @__PURE__ */ jsx(ConfirmDialog, {
328
- event: confirming,
329
- preview,
330
- onConfirm: (event_1) => void execute(event_1),
331
- onCancel: closeConfirmation
332
- })
538
+ selectionActions.length > 0 ? /* @__PURE__ */ jsx("div", {
539
+ className: ListView_module_default.selectionActions,
540
+ children: selectionActions.map((action_13) => {
541
+ const skipped_0 = selectedItems.filter((item_8) => !isAllowedOn(action_13, item_8)).length;
542
+ return /* @__PURE__ */ jsx(ActionButton, {
543
+ action: action_13,
544
+ icons: actionIcons,
545
+ size: "md",
546
+ href: null,
547
+ isPending: pending === keyOf(action_13),
548
+ isDisabled: pending !== null && pending !== keyOf(action_13) || skipped_0 >= selectedCount,
549
+ onPress: () => runOnSelection(action_13)
550
+ }, action_13.id);
551
+ })
552
+ }) : null
333
553
  ]
334
- });
554
+ }) : null;
555
+ const t31 = isLoading && items !== void 0;
556
+ let t32;
557
+ if ($[92] !== body || $[93] !== t31) {
558
+ t32 = /* @__PURE__ */ jsx("div", {
559
+ className: ListView_module_default.body,
560
+ "aria-busy": t31,
561
+ children: body
562
+ });
563
+ $[92] = body;
564
+ $[93] = t31;
565
+ $[94] = t32;
566
+ } else t32 = $[94];
567
+ let t33;
568
+ if ($[95] !== error || $[96] !== list || $[97] !== pageItems || $[98] !== perPageOptions || $[99] !== query.page || $[100] !== query.perPage || $[101] !== total) {
569
+ t33 = total !== void 0 && error === null && total > 0 ? /* @__PURE__ */ jsx(Pagination, {
570
+ page: query.page ?? 1,
571
+ perPage: query.perPage ?? pageItems.length,
572
+ total,
573
+ onPageChange: (page) => list.setPage(page),
574
+ perPageOptions,
575
+ onPerPageChange: (perPage) => list.setPerPage(perPage)
576
+ }) : null;
577
+ $[95] = error;
578
+ $[96] = list;
579
+ $[97] = pageItems;
580
+ $[98] = perPageOptions;
581
+ $[99] = query.page;
582
+ $[100] = query.perPage;
583
+ $[101] = total;
584
+ $[102] = t33;
585
+ } else t33 = $[102];
586
+ let t34;
587
+ if ($[103] !== execute) {
588
+ t34 = (event_1) => void execute(event_1);
589
+ $[103] = execute;
590
+ $[104] = t34;
591
+ } else t34 = $[104];
592
+ let t35;
593
+ if ($[105] !== closeConfirmation || $[106] !== confirming || $[107] !== preview || $[108] !== t34) {
594
+ t35 = /* @__PURE__ */ jsx(ConfirmDialog, {
595
+ event: confirming,
596
+ preview,
597
+ onConfirm: t34,
598
+ onCancel: closeConfirmation
599
+ });
600
+ $[105] = closeConfirmation;
601
+ $[106] = confirming;
602
+ $[107] = preview;
603
+ $[108] = t34;
604
+ $[109] = t35;
605
+ } else t35 = $[109];
606
+ let t36;
607
+ if ($[110] !== t25 || $[111] !== t26 || $[112] !== t29 || $[113] !== t30 || $[114] !== t32 || $[115] !== t33 || $[116] !== t35) {
608
+ t36 = /* @__PURE__ */ jsxs("div", {
609
+ className: t25,
610
+ children: [
611
+ t26,
612
+ t29,
613
+ t30,
614
+ t32,
615
+ t33,
616
+ t35
617
+ ]
618
+ });
619
+ $[110] = t25;
620
+ $[111] = t26;
621
+ $[112] = t29;
622
+ $[113] = t30;
623
+ $[114] = t32;
624
+ $[115] = t33;
625
+ $[116] = t35;
626
+ $[117] = t36;
627
+ } else t36 = $[117];
628
+ return t36;
629
+ }
630
+ function _temp7(column_0) {
631
+ return column_0.sortable === true;
632
+ }
633
+ function _temp6(item_4) {
634
+ return item_4.id;
635
+ }
636
+ function _temp5(action_3) {
637
+ return hasScope(action_3, "resource");
638
+ }
639
+ function _temp4(action_2) {
640
+ return hasScope(action_2, "selection");
641
+ }
642
+ function _temp3(action_1, index, all) {
643
+ return (hasScope(action_1, "selection") || hasScope(action_1, "resource")) && all.findIndex((candidate) => candidate.id === action_1.id) === index;
644
+ }
645
+ function _temp2(action_0) {
646
+ return hasScope(action_0, "item");
647
+ }
648
+ function _temp(action) {
649
+ return hasScope(action, "item");
335
650
  }
336
651
  //#endregion
337
652
  export { ListView };