@panneau/lists 5.0.0-alpha.2 → 5.0.0-alpha.21

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 (165) hide show
  1. package/README.md +17 -15
  2. package/dist/ItemDetails.css +50 -0
  3. package/dist/ItemDetails.d.ts +27 -0
  4. package/dist/ItemDetails.d.ts.map +1 -0
  5. package/dist/ItemDetails.js +134 -0
  6. package/dist/ItemDetails.js.map +1 -0
  7. package/dist/ItemDetails.module.js +20 -0
  8. package/dist/ItemDetails.module.js.map +1 -0
  9. package/dist/List.d.ts +3 -3
  10. package/dist/List.d.ts.map +1 -1
  11. package/dist/List.js +31 -10
  12. package/dist/List.js.map +1 -1
  13. package/dist/ListSkeleton.d.ts +19 -0
  14. package/dist/ListSkeleton.d.ts.map +1 -0
  15. package/dist/ListSkeleton.js +115 -0
  16. package/dist/ListSkeleton.js.map +1 -0
  17. package/dist/ListView.d.ts +73 -8
  18. package/dist/ListView.d.ts.map +1 -1
  19. package/dist/ListView.js +616 -218
  20. package/dist/ListView.js.map +1 -1
  21. package/dist/actions/ActionButton.d.ts +8 -2
  22. package/dist/actions/ActionButton.d.ts.map +1 -1
  23. package/dist/actions/ActionButton.js +98 -26
  24. package/dist/actions/ActionButton.js.map +1 -1
  25. package/dist/actions/Actions.css +16 -38
  26. package/dist/actions/Actions.module.js +6 -6
  27. package/dist/actions/Actions.module.js.map +1 -1
  28. package/dist/actions/ConfirmDialog.d.ts +20 -4
  29. package/dist/actions/ConfirmDialog.d.ts.map +1 -1
  30. package/dist/actions/ConfirmDialog.js +110 -92
  31. package/dist/actions/ConfirmDialog.js.map +1 -1
  32. package/dist/actions/RowActions.d.ts +25 -9
  33. package/dist/actions/RowActions.d.ts.map +1 -1
  34. package/dist/actions/RowActions.js +151 -80
  35. package/dist/actions/RowActions.js.map +1 -1
  36. package/dist/actions/actions.d.ts +5 -4
  37. package/dist/actions/actions.d.ts.map +1 -1
  38. package/dist/actions/actions.js +7 -14
  39. package/dist/actions/actions.js.map +1 -1
  40. package/dist/actions/fit.d.ts +25 -0
  41. package/dist/actions/fit.d.ts.map +1 -0
  42. package/dist/actions/fit.js +197 -0
  43. package/dist/actions/fit.js.map +1 -0
  44. package/dist/actions/icons.d.ts +5 -0
  45. package/dist/actions/icons.d.ts.map +1 -1
  46. package/dist/actions/icons.js +15 -1
  47. package/dist/actions/icons.js.map +1 -1
  48. package/dist/columns.d.ts +10 -0
  49. package/dist/columns.d.ts.map +1 -0
  50. package/dist/columns.js +25 -0
  51. package/dist/columns.js.map +1 -0
  52. package/dist/cx.js.map +1 -1
  53. package/dist/displays/Displays.css +48 -0
  54. package/dist/displays/Displays.module.js +18 -2
  55. package/dist/displays/Displays.module.js.map +1 -1
  56. package/dist/displays/displays.d.ts +62 -6
  57. package/dist/displays/displays.d.ts.map +1 -1
  58. package/dist/displays/displays.js +1151 -89
  59. package/dist/displays/displays.js.map +1 -1
  60. package/dist/filters/Filters.css +25 -11
  61. package/dist/filters/Filters.d.ts +1 -1
  62. package/dist/filters/Filters.js.map +1 -1
  63. package/dist/filters/Filters.module.js +5 -1
  64. package/dist/filters/Filters.module.js.map +1 -1
  65. package/dist/filters/controls.d.ts +1 -1
  66. package/dist/filters/controls.d.ts.map +1 -1
  67. package/dist/filters/controls.js +57 -35
  68. package/dist/filters/controls.js.map +1 -1
  69. package/dist/filters/format.d.ts +1 -1
  70. package/dist/filters/format.js.map +1 -1
  71. package/dist/images.d.ts +7 -0
  72. package/dist/images.d.ts.map +1 -0
  73. package/dist/images.js +39 -0
  74. package/dist/images.js.map +1 -0
  75. package/dist/index.d.ts +22 -18
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +7 -3
  78. package/dist/inline/Inline.css +58 -0
  79. package/dist/inline/Inline.module.js +20 -0
  80. package/dist/inline/Inline.module.js.map +1 -0
  81. package/dist/inline/InlineCell.d.ts +29 -0
  82. package/dist/inline/InlineCell.d.ts.map +1 -0
  83. package/dist/inline/InlineCell.js +490 -0
  84. package/dist/inline/InlineCell.js.map +1 -0
  85. package/dist/inline/editable.d.ts +12 -0
  86. package/dist/inline/editable.d.ts.map +1 -0
  87. package/dist/inline/editable.js +29 -0
  88. package/dist/inline/editable.js.map +1 -0
  89. package/dist/layouts/CalendarLayout.css +153 -0
  90. package/dist/layouts/CalendarLayout.d.ts +9 -0
  91. package/dist/layouts/CalendarLayout.d.ts.map +1 -0
  92. package/dist/layouts/CalendarLayout.js +303 -0
  93. package/dist/layouts/CalendarLayout.js.map +1 -0
  94. package/dist/layouts/CalendarLayout.module.js +28 -0
  95. package/dist/layouts/CalendarLayout.module.js.map +1 -0
  96. package/dist/layouts/CardsLayout.css +5 -0
  97. package/dist/layouts/CardsLayout.d.ts +2 -2
  98. package/dist/layouts/CardsLayout.d.ts.map +1 -1
  99. package/dist/layouts/CardsLayout.js +92 -91
  100. package/dist/layouts/CardsLayout.js.map +1 -1
  101. package/dist/layouts/CardsLayout.module.js.map +1 -1
  102. package/dist/layouts/GalleryLayout.css +87 -0
  103. package/dist/layouts/GalleryLayout.d.ts +8 -0
  104. package/dist/layouts/GalleryLayout.d.ts.map +1 -0
  105. package/dist/layouts/GalleryLayout.js +152 -0
  106. package/dist/layouts/GalleryLayout.js.map +1 -0
  107. package/dist/layouts/GalleryLayout.module.js +26 -0
  108. package/dist/layouts/GalleryLayout.module.js.map +1 -0
  109. package/dist/layouts/ItemTitle.d.ts +3 -1
  110. package/dist/layouts/ItemTitle.d.ts.map +1 -1
  111. package/dist/layouts/ItemTitle.js +12 -8
  112. package/dist/layouts/ItemTitle.js.map +1 -1
  113. package/dist/layouts/TableLayout.css +56 -0
  114. package/dist/layouts/TableLayout.d.ts +5 -4
  115. package/dist/layouts/TableLayout.d.ts.map +1 -1
  116. package/dist/layouts/TableLayout.js +171 -101
  117. package/dist/layouts/TableLayout.js.map +1 -1
  118. package/dist/layouts/TableLayout.module.js +8 -4
  119. package/dist/layouts/TableLayout.module.js.map +1 -1
  120. package/dist/layouts/builtIn.d.ts +2 -2
  121. package/dist/layouts/builtIn.d.ts.map +1 -1
  122. package/dist/layouts/builtIn.js +6 -2
  123. package/dist/layouts/builtIn.js.map +1 -1
  124. package/dist/layouts/calendarDays.d.ts +14 -0
  125. package/dist/layouts/calendarDays.d.ts.map +1 -0
  126. package/dist/layouts/calendarDays.js +44 -0
  127. package/dist/layouts/calendarDays.js.map +1 -0
  128. package/dist/plugin.d.ts +1 -1
  129. package/dist/plugin.js.map +1 -1
  130. package/dist/query.d.ts +4 -3
  131. package/dist/query.d.ts.map +1 -1
  132. package/dist/query.js +15 -4
  133. package/dist/query.js.map +1 -1
  134. package/dist/selection.d.ts +1 -1
  135. package/dist/selection.js.map +1 -1
  136. package/dist/toolbar/ColumnMenu.d.ts +17 -0
  137. package/dist/toolbar/ColumnMenu.d.ts.map +1 -0
  138. package/dist/toolbar/ColumnMenu.js +193 -0
  139. package/dist/toolbar/ColumnMenu.js.map +1 -0
  140. package/dist/toolbar/LayoutSwitch.d.ts.map +1 -1
  141. package/dist/toolbar/LayoutSwitch.js +73 -55
  142. package/dist/toolbar/LayoutSwitch.js.map +1 -1
  143. package/dist/toolbar/Pagination.d.ts +33 -0
  144. package/dist/toolbar/Pagination.d.ts.map +1 -1
  145. package/dist/toolbar/Pagination.js +282 -42
  146. package/dist/toolbar/Pagination.js.map +1 -1
  147. package/dist/toolbar/SearchField.js.map +1 -1
  148. package/dist/toolbar/SortSelect.d.ts +1 -1
  149. package/dist/toolbar/SortSelect.js.map +1 -1
  150. package/dist/toolbar/Toolbar.css +36 -0
  151. package/dist/toolbar/Toolbar.module.js +12 -2
  152. package/dist/toolbar/Toolbar.module.js.map +1 -1
  153. package/dist/types.d.ts +69 -1
  154. package/dist/types.d.ts.map +1 -1
  155. package/dist/useDraft.js.map +1 -1
  156. package/dist/useListState.js.map +1 -1
  157. package/dist/useRenderValue.d.ts +10 -0
  158. package/dist/useRenderValue.d.ts.map +1 -0
  159. package/dist/useRenderValue.js +84 -0
  160. package/dist/useRenderValue.js.map +1 -0
  161. package/dist/values.d.ts +4 -1
  162. package/dist/values.d.ts.map +1 -1
  163. package/dist/values.js +6 -2
  164. package/dist/values.js.map +1 -1
  165. package/package.json +9 -9
@@ -1,7 +1,9 @@
1
1
  import { messages } from "../messages.js";
2
2
  import Actions_module_default from "./Actions.module.js";
3
+ import { asksConfirmation } from "@panneau/core";
3
4
  import { c } from "react/compiler-runtime";
4
- import { Button, Dialog, usePanneauIntl } from "@panneau/ui";
5
+ import { getActionLabel } from "@panneau/intl";
6
+ import { Button, Dialog, Spinner, usePanneauIntl } from "@panneau/ui";
5
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
8
  //#region src/actions/ConfirmDialog.tsx
7
9
  /** Formats an ICU message of the definition (`{count, plural, …}`) in the locale. */
@@ -12,23 +14,30 @@ function formatDefinitionMessage(intl, message, values) {
12
14
  return message;
13
15
  }
14
16
  }
15
- /** Whether an action needs a confirmation: it asks for one, or some selected items are skipped. */
17
+ /**
18
+ * Whether an action needs a confirmation: it asks for one, or it is undoable but runs on more items
19
+ * than an undo can put back (`asksConfirmation()`, decision 0063), or some selected items are
20
+ * skipped.
21
+ */
16
22
  function needsConfirmation(event) {
17
- const { confirm } = event.action;
18
- return confirm !== void 0 && confirm !== false || event.skipped.length > 0;
23
+ return asksConfirmation(event.action, event.count) || event.skipped.length > 0;
19
24
  }
20
25
  /**
21
26
  * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU
22
- * message with `{count}`), or default ones, and how many selected items will be skipped.
27
+ * message with `{count}`), or default ones, and how many selected items will be skipped: those of
28
+ * the current page that don't allow it, or the backend's count for every item matching a query.
23
29
  */
24
30
  function ConfirmDialog(t0) {
25
31
  const $ = c(40);
26
- const { event, onConfirm, onCancel } = t0;
32
+ const { event, preview: t1, onConfirm, onCancel } = t0;
33
+ const preview = t1 === void 0 ? null : t1;
27
34
  const intl = usePanneauIntl();
28
35
  if (event === null) return null;
29
- const { action, count, skipped } = event;
36
+ const { action, count } = event;
37
+ const loading = preview?.status === "loading";
38
+ const skipped = preview?.status === "done" ? preview.skipped : event.skipped.length;
30
39
  let T0;
31
- let t1;
40
+ let t10;
32
41
  let t2;
33
42
  let t3;
34
43
  let t4;
@@ -37,119 +46,128 @@ function ConfirmDialog(t0) {
37
46
  let t7;
38
47
  let t8;
39
48
  let t9;
40
- if ($[0] !== action.confirm || $[1] !== action.destructive || $[2] !== action.label || $[3] !== count || $[4] !== event || $[5] !== intl || $[6] !== onCancel || $[7] !== onConfirm) {
49
+ if ($[0] !== action || $[1] !== count || $[2] !== event || $[3] !== intl || $[4] !== loading || $[5] !== onCancel || $[6] !== onConfirm) {
41
50
  const confirm = typeof action.confirm === "object" ? action.confirm : {};
51
+ const label = getActionLabel(action, intl);
42
52
  const values = {
43
53
  count,
44
- action: action.label
54
+ action: label
45
55
  };
46
56
  T0 = Dialog;
47
- t3 = true;
48
- if ($[18] !== onCancel) {
49
- t4 = (open) => {
57
+ t4 = true;
58
+ if ($[17] !== onCancel) {
59
+ t5 = (open) => {
50
60
  if (!open) onCancel();
51
61
  };
52
- $[18] = onCancel;
53
- $[19] = t4;
54
- } else t4 = $[19];
55
- t5 = "alertdialog";
56
- t6 = false;
57
- t7 = "sm";
58
- t8 = confirm.title !== void 0 ? formatDefinitionMessage(intl, confirm.title, values) : intl.formatMessage(messages.confirmTitle, { action: action.label });
59
- let t10;
60
- if ($[20] !== event || $[21] !== onConfirm) {
61
- t10 = () => onConfirm(event);
62
- $[20] = event;
63
- $[21] = onConfirm;
64
- $[22] = t10;
65
- } else t10 = $[22];
66
- t9 = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
62
+ $[17] = onCancel;
63
+ $[18] = t5;
64
+ } else t5 = $[18];
65
+ t6 = "alertdialog";
66
+ t7 = false;
67
+ t8 = "sm";
68
+ t9 = confirm.title !== void 0 ? formatDefinitionMessage(intl, confirm.title, values) : intl.formatMessage(messages.confirmTitle, { action: label });
69
+ let t11;
70
+ if ($[19] !== event || $[20] !== onConfirm) {
71
+ t11 = () => onConfirm(event);
72
+ $[19] = event;
73
+ $[20] = onConfirm;
74
+ $[21] = t11;
75
+ } else t11 = $[21];
76
+ t10 = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
67
77
  variant: "ghost",
68
78
  onPress: onCancel,
69
79
  children: confirm.cancelLabel ?? intl.formatMessage(messages.cancel)
70
80
  }), /* @__PURE__ */ jsx(Button, {
71
81
  variant: action.destructive === true ? "danger" : "primary",
72
82
  autoFocus: true,
73
- onPress: t10,
74
- children: confirm.confirmLabel ?? action.label
83
+ isDisabled: loading,
84
+ onPress: t11,
85
+ children: confirm.confirmLabel ?? label
75
86
  })] });
76
- t1 = Actions_module_default.message;
77
- t2 = confirm.message !== void 0 ? formatDefinitionMessage(intl, confirm.message, values) : intl.formatMessage(messages.confirmMessage, values);
78
- $[0] = action.confirm;
79
- $[1] = action.destructive;
80
- $[2] = action.label;
81
- $[3] = count;
82
- $[4] = event;
83
- $[5] = intl;
84
- $[6] = onCancel;
85
- $[7] = onConfirm;
86
- $[8] = T0;
87
- $[9] = t1;
88
- $[10] = t2;
89
- $[11] = t3;
90
- $[12] = t4;
91
- $[13] = t5;
92
- $[14] = t6;
93
- $[15] = t7;
94
- $[16] = t8;
95
- $[17] = t9;
87
+ t2 = Actions_module_default.message;
88
+ t3 = confirm.message !== void 0 ? formatDefinitionMessage(intl, confirm.message, values) : intl.formatMessage(messages.confirmMessage, values);
89
+ $[0] = action;
90
+ $[1] = count;
91
+ $[2] = event;
92
+ $[3] = intl;
93
+ $[4] = loading;
94
+ $[5] = onCancel;
95
+ $[6] = onConfirm;
96
+ $[7] = T0;
97
+ $[8] = t10;
98
+ $[9] = t2;
99
+ $[10] = t3;
100
+ $[11] = t4;
101
+ $[12] = t5;
102
+ $[13] = t6;
103
+ $[14] = t7;
104
+ $[15] = t8;
105
+ $[16] = t9;
96
106
  } else {
97
- T0 = $[8];
98
- t1 = $[9];
99
- t2 = $[10];
100
- t3 = $[11];
101
- t4 = $[12];
102
- t5 = $[13];
103
- t6 = $[14];
104
- t7 = $[15];
105
- t8 = $[16];
106
- t9 = $[17];
107
+ T0 = $[7];
108
+ t10 = $[8];
109
+ t2 = $[9];
110
+ t3 = $[10];
111
+ t4 = $[11];
112
+ t5 = $[12];
113
+ t6 = $[13];
114
+ t7 = $[14];
115
+ t8 = $[15];
116
+ t9 = $[16];
107
117
  }
108
- let t10;
109
- if ($[23] !== t1 || $[24] !== t2) {
110
- t10 = /* @__PURE__ */ jsx("p", {
111
- className: t1,
112
- children: t2
113
- });
114
- $[23] = t1;
115
- $[24] = t2;
116
- $[25] = t10;
117
- } else t10 = $[25];
118
118
  let t11;
119
- if ($[26] !== intl || $[27] !== skipped.length) {
120
- t11 = skipped.length > 0 ? /* @__PURE__ */ jsx("p", {
119
+ if ($[22] !== t2 || $[23] !== t3) {
120
+ t11 = /* @__PURE__ */ jsx("p", {
121
+ className: t2,
122
+ children: t3
123
+ });
124
+ $[22] = t2;
125
+ $[23] = t3;
126
+ $[24] = t11;
127
+ } else t11 = $[24];
128
+ let t12;
129
+ if ($[25] !== intl || $[26] !== loading || $[27] !== skipped) {
130
+ t12 = loading ? /* @__PURE__ */ jsx("div", {
121
131
  className: Actions_module_default.skipped,
122
- children: intl.formatMessage(messages.confirmSkipped, { count: skipped.length })
132
+ children: /* @__PURE__ */ jsx(Spinner, {
133
+ size: "sm",
134
+ label: intl.formatMessage(messages.confirmChecking),
135
+ showLabel: true
136
+ })
137
+ }) : skipped > 0 ? /* @__PURE__ */ jsx("p", {
138
+ className: Actions_module_default.skipped,
139
+ children: intl.formatMessage(messages.confirmSkipped, { count: skipped })
123
140
  }) : null;
124
- $[26] = intl;
125
- $[27] = skipped.length;
126
- $[28] = t11;
127
- } else t11 = $[28];
128
- let t12;
129
- if ($[29] !== T0 || $[30] !== t10 || $[31] !== t11 || $[32] !== t3 || $[33] !== t4 || $[34] !== t5 || $[35] !== t6 || $[36] !== t7 || $[37] !== t8 || $[38] !== t9) {
130
- t12 = /* @__PURE__ */ jsxs(T0, {
131
- isOpen: t3,
132
- onOpenChange: t4,
133
- role: t5,
134
- isDismissable: t6,
135
- size: t7,
136
- title: t8,
137
- footer: t9,
138
- children: [t10, t11]
141
+ $[25] = intl;
142
+ $[26] = loading;
143
+ $[27] = skipped;
144
+ $[28] = t12;
145
+ } else t12 = $[28];
146
+ let t13;
147
+ if ($[29] !== T0 || $[30] !== t10 || $[31] !== t11 || $[32] !== t12 || $[33] !== t4 || $[34] !== t5 || $[35] !== t6 || $[36] !== t7 || $[37] !== t8 || $[38] !== t9) {
148
+ t13 = /* @__PURE__ */ jsxs(T0, {
149
+ isOpen: t4,
150
+ onOpenChange: t5,
151
+ role: t6,
152
+ isDismissable: t7,
153
+ size: t8,
154
+ title: t9,
155
+ footer: t10,
156
+ children: [t11, t12]
139
157
  });
140
158
  $[29] = T0;
141
159
  $[30] = t10;
142
160
  $[31] = t11;
143
- $[32] = t3;
161
+ $[32] = t12;
144
162
  $[33] = t4;
145
163
  $[34] = t5;
146
164
  $[35] = t6;
147
165
  $[36] = t7;
148
166
  $[37] = t8;
149
167
  $[38] = t9;
150
- $[39] = t12;
151
- } else t12 = $[39];
152
- return t12;
168
+ $[39] = t13;
169
+ } else t13 = $[39];
170
+ return t13;
153
171
  }
154
172
  //#endregion
155
173
  export { ConfirmDialog, needsConfirmation };
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmDialog.js","names":["onCancel","_c","_Fragment","styles"],"sources":["../../src/actions/ConfirmDialog.tsx"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport type { ListActionEvent } from '../types';\nimport styles from './Actions.module.css';\n\n/** Formats an ICU message of the definition (`{count, plural, …}`) in the locale. */\nfunction formatDefinitionMessage(\n intl: IntlShape,\n message: string,\n values: Record<string, unknown>,\n) {\n try {\n return String(\n intl.formatters\n .getMessageFormat(message, intl.locale)\n .format(values as Record<string, string | number>),\n );\n } catch {\n return message;\n }\n}\n\n/** Whether an action needs a confirmation: it asks for one, or some selected items are skipped. */\nexport function needsConfirmation(event: ListActionEvent): boolean {\n const { confirm } = event.action;\n return (confirm !== undefined && confirm !== false) || event.skipped.length > 0;\n}\n\nexport interface ConfirmDialogProps {\n /** The action to confirm, or `null` when the dialog is closed. */\n event: ListActionEvent | null;\n onConfirm: (event: ListActionEvent) => void;\n onCancel: () => void;\n}\n\n/**\n * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU\n * message with `{count}`), or default ones, and how many selected items will be skipped.\n */\nexport function ConfirmDialog({ event, onConfirm, onCancel }: ConfirmDialogProps) {\n const intl = usePanneauIntl();\n if (event === null) {\n return null;\n }\n const { action, count, skipped } = event;\n const confirm = typeof action.confirm === 'object' ? action.confirm : {};\n const values = { count, action: action.label };\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onCancel();\n }\n }}\n role=\"alertdialog\"\n isDismissable={false}\n size=\"sm\"\n title={\n confirm.title !== undefined\n ? formatDefinitionMessage(intl, confirm.title, values)\n : intl.formatMessage(messages.confirmTitle, { action: action.label })\n }\n footer={\n <>\n <Button variant=\"ghost\" onPress={onCancel}>\n {confirm.cancelLabel ?? intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variant={action.destructive === true ? 'danger' : 'primary'}\n autoFocus\n onPress={() => onConfirm(event)}\n >\n {confirm.confirmLabel ?? action.label}\n </Button>\n </>\n }\n >\n <p className={styles.message}>\n {confirm.message !== undefined\n ? formatDefinitionMessage(intl, confirm.message, values)\n : intl.formatMessage(messages.confirmMessage, values)}\n </p>\n {skipped.length > 0 ? (\n <p className={styles.skipped}>\n {intl.formatMessage(messages.confirmSkipped, { count: skipped.length })}\n </p>\n ) : null}\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;AASA,SAAS,wBACL,MACA,SACA,QACF;CACE,IAAI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EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,QAAA,EAAA,QAAA,QAAA,QAAA;EACH,MAAA,QAAO,SAAU,IACd,oBAAA,KAAA;GAAc,WAAAA,uBAAM;GACf,UAAA,KAAI,cAAe,SAAQ,gBAAiB,EAAA,OAAS,QAAO,OAAQ,CAAC;EACtE,CAAA,IAHP;EAIO,EAAA,MAAA;EAAA,EAAA,MAAA,QAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,EAAA,QAAA,OAAA,EAAA,QAAA,OAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAvCZ,MAAA,qBAAC,IAAD;GACI,QAAA;GACc,cAAA;GAKT,MAAA;GACU,eAAA;GACV,MAAA;GAED,OAAA;GAKA,QAAA;GAhBR,UAAA,CA8BI,KAKC,GAnCE;;EAwCE,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,OAxCT;AAwCS"}
1
+ {"version":3,"file":"ConfirmDialog.js","names":["IntlShape","asksConfirmation","getActionLabel","Button","Dialog","Spinner","usePanneauIntl","messages","ListActionEvent","ListActionPreview","styles","formatDefinitionMessage","intl","message","values","Record","String","formatters","getMessageFormat","locale","format","needsConfirmation","event","action","count","skipped","length","ConfirmPreview","status","ConfirmDialogProps","preview","onConfirm","onCancel","ConfirmDialog","t0","$","_c","t1","undefined","loading","T0","t10","t2","t3","t4","t5","t6","t7","t8","t9","confirm","label","open","title","formatMessage","confirmTitle","t11","cancelLabel","cancel","destructive","confirmLabel","confirmMessage","t12","confirmChecking","confirmSkipped","t13","_c","_Fragment","styles"],"sources":["../../src/actions/ConfirmDialog.tsx"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport { asksConfirmation } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport { Button, Dialog, Spinner, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport type { ListActionEvent, ListActionPreview } from '../types';\nimport styles from './Actions.module.css';\n\n/** Formats an ICU message of the definition (`{count, plural, …}`) in the locale. */\nfunction formatDefinitionMessage(\n intl: IntlShape,\n message: string,\n values: Record<string, unknown>,\n) {\n try {\n return String(\n intl.formatters\n .getMessageFormat(message, intl.locale)\n .format(values as Record<string, string | number>),\n );\n } catch {\n return message;\n }\n}\n\n/**\n * Whether an action needs a confirmation: it asks for one, or it is undoable but runs on more items\n * than an undo can put back (`asksConfirmation()`, decision 0063), or some selected items are\n * skipped.\n */\nexport function needsConfirmation(event: ListActionEvent): boolean {\n return asksConfirmation(event.action, event.count) || event.skipped.length > 0;\n}\n\n/** The dry run of a query selection: in progress, or done with the backend's count. */\nexport type ConfirmPreview = { status: 'loading' } | ({ status: 'done' } & ListActionPreview);\n\nexport interface ConfirmDialogProps {\n /** The action to confirm, or `null` when the dialog is closed. */\n event: ListActionEvent | null;\n /**\n * What the backend told about a query selection. Its count of skipped items replaces the\n * count of the current page; while it loads, the dialog says so and can't be confirmed.\n */\n preview?: ConfirmPreview | null;\n onConfirm: (event: ListActionEvent) => void;\n onCancel: () => void;\n}\n\n/**\n * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU\n * message with `{count}`), or default ones, and how many selected items will be skipped: those of\n * the current page that don't allow it, or the backend's count for every item matching a query.\n */\nexport function ConfirmDialog({ event, preview = null, onConfirm, onCancel }: ConfirmDialogProps) {\n const intl = usePanneauIntl();\n if (event === null) {\n return null;\n }\n const { action, count } = event;\n const loading = preview?.status === 'loading';\n const skipped = preview?.status === 'done' ? preview.skipped : event.skipped.length;\n const confirm = typeof action.confirm === 'object' ? action.confirm : {};\n const label = getActionLabel(action, intl);\n const values = { count, action: label };\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onCancel();\n }\n }}\n role=\"alertdialog\"\n isDismissable={false}\n size=\"sm\"\n title={\n confirm.title !== undefined\n ? formatDefinitionMessage(intl, confirm.title, values)\n : intl.formatMessage(messages.confirmTitle, { action: label })\n }\n footer={\n <>\n <Button variant=\"ghost\" onPress={onCancel}>\n {confirm.cancelLabel ?? intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variant={action.destructive === true ? 'danger' : 'primary'}\n autoFocus\n isDisabled={loading}\n onPress={() => onConfirm(event)}\n >\n {confirm.confirmLabel ?? label}\n </Button>\n </>\n }\n >\n <p className={styles.message}>\n {confirm.message !== undefined\n ? formatDefinitionMessage(intl, confirm.message, values)\n : intl.formatMessage(messages.confirmMessage, values)}\n </p>\n {loading ? (\n <div className={styles.skipped}>\n <Spinner\n size=\"sm\"\n label={intl.formatMessage(messages.confirmChecking)}\n showLabel\n />\n </div>\n ) : skipped > 0 ? (\n <p className={styles.skipped}>\n {intl.formatMessage(messages.confirmSkipped, { count: skipped })}\n </p>\n ) : null}\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,SAASW,wBACLC,MACAC,SACAC,QACF;CACE,IAAI;EACA,OAAOE,OACHJ,KAAKK,WACAC,iBAAiBL,SAASD,KAAKO,MAAM,CAAC,CACtCC,OAAON,MAAyC,CACzD;CACJ,QAAQ;EACJ,OAAOD;CACX;AACJ;;;;;;AAOA,SAAgBQ,kBAAkBC,OAAiC;CAC/D,OAAOrB,iBAAiBqB,MAAMC,QAAQD,MAAME,KAAK,KAAKF,MAAMG,QAAQC,SAAS;AACjF;;;;;;AAsBA,SAAOO,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAuB,MAAA,EAAAd,OAA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,MAAAa;EAAAb,EAAA,MAAAc;EAAAd,EAAA,MAAA8B;CAAA,OAAAA,MAAA9B,EAAA;CAAA,OAjDT8B;AAiDS"}
@@ -1,20 +1,36 @@
1
+ import type { ItemAction } from '@panneau/core';
1
2
  import type { Action } from '@panneau/protocol';
2
- import type { ListItem } from '../types';
3
- import { type ActionIcons } from './icons';
3
+ import { type ActionIcons } from './icons.js';
4
4
  export interface RowActionsProps {
5
- item: ListItem;
6
5
  /** The label of the item, for the accessible names of its actions. */
7
6
  itemLabel: string;
8
- /** Actions shown as buttons. */
9
- actions: readonly Action[];
10
- /** Actions in the overflow menu. */
11
- menu: readonly Action[];
7
+ /** Actions placed in `row`, with their links (`selectItemActions()` of `@panneau/core`). */
8
+ actions: readonly ItemAction[];
9
+ /** Actions placed in `menu`: icons too while they fit, the first to go in the menu. */
10
+ menu: readonly ItemAction[];
12
11
  /** Id of the action that is running on this item, if any. */
13
12
  pending: string | null;
14
13
  onRun: (action: Action) => void;
15
14
  /** Icons of actions by id, over the icon the action names. */
16
15
  icons?: ActionIcons | undefined;
16
+ /**
17
+ * The actions of every row of the list, in order (`orderRowActions()`): a row keeps the place
18
+ * of those it doesn't have, so the actions of the rows line up. Without it, its own.
19
+ */
20
+ slots?: readonly ItemAction[] | undefined;
21
+ /** The id of the main action of rows, which keeps its label (`show` or `edit`). */
22
+ primary?: string | null | undefined;
17
23
  }
18
- /** The actions of a row: buttons, then an overflow menu. */
19
- export declare function RowActions({ item, itemLabel, actions, menu, pending, onRun, icons, }: RowActionsProps): import("react").JSX.Element;
24
+ /**
25
+ * The actions of a row in their order: those placed in `row`, then those placed in `menu`, and
26
+ * those that destroy last. The last ones are the first to go in the menu.
27
+ */
28
+ export declare function orderRowActions(actions: readonly ItemAction[], menu: readonly ItemAction[]): ItemAction[];
29
+ /**
30
+ * The actions of a row (decision 0060): their icons, in their colors, with their labels as names
31
+ * and tooltips, but the main action, which keeps its label while the row has room; and when the
32
+ * icons don't fit, the last ones in an overflow menu, which never holds a single action. How they fit is the same for every row of the list (`RowActionsFit`), and a
33
+ * row keeps the place of the actions of other rows that it doesn't have, so they line up.
34
+ */
35
+ export declare function RowActions({ itemLabel, actions, menu, pending, onRun, icons, slots, primary, }: RowActionsProps): import("react").JSX.Element;
20
36
  //# sourceMappingURL=RowActions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RowActions.d.ts","sourceRoot":"","sources":["../../src/actions/RowActions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,oCAAoC;IACpC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACnC;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,GACR,EAAE,eAAe,+BAwDjB"}
1
+ {"version":3,"file":"RowActions.d.ts","sourceRoot":"","sources":["../../src/actions/RowActions.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC5B,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,uFAAuF;IACvF,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC;IAC1C,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC3B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,IAAI,EAAE,SAAS,UAAU,EAAE,GAC5B,UAAU,EAAE,CASd;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACvB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAc,GACjB,EAAE,eAAe,+BA0FjB"}
@@ -1,99 +1,170 @@
1
- import { getActionHref } from "./actions.js";
2
1
  import { messages } from "../messages.js";
3
2
  import Actions_module_default from "./Actions.module.js";
4
3
  import { getActionIcon } from "./icons.js";
4
+ import { RowActionsFit } from "./fit.js";
5
5
  import { ActionButton } from "./ActionButton.js";
6
6
  import { c } from "react/compiler-runtime";
7
+ import { getActionLabel } from "@panneau/intl";
7
8
  import { IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from "@panneau/ui";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import { Ellipsis } from "lucide-react";
11
+ import { use } from "react";
10
12
  //#region src/actions/RowActions.tsx
11
- /** The actions of a row: buttons, then an overflow menu. */
13
+ /**
14
+ * The actions of a row in their order: those placed in `row`, then those placed in `menu`, and
15
+ * those that destroy last. The last ones are the first to go in the menu.
16
+ */
17
+ function orderRowActions(actions, menu) {
18
+ const all = [...actions, ...menu].filter((entry, index, list) => list.findIndex((other) => other.action.id === entry.action.id) === index);
19
+ return [...all.filter(({ action }) => action.destructive !== true), ...all.filter(({ action }) => action.destructive === true)];
20
+ }
21
+ /**
22
+ * The actions of a row (decision 0060): their icons, in their colors, with their labels as names
23
+ * and tooltips, but the main action, which keeps its label while the row has room; and when the
24
+ * icons don't fit, the last ones in an overflow menu, which never holds a single action. How they fit is the same for every row of the list (`RowActionsFit`), and a
25
+ * row keeps the place of the actions of other rows that it doesn't have, so they line up.
26
+ */
12
27
  function RowActions(t0) {
13
- const $ = c(26);
14
- const { item, itemLabel, actions, menu, pending, onRun, icons } = t0;
28
+ const $ = c(30);
29
+ const { itemLabel, actions, menu, pending, onRun, icons, slots, primary: t1 } = t0;
30
+ const primary = t1 === void 0 ? null : t1;
15
31
  const intl = usePanneauIntl();
16
- let t1;
17
- if ($[0] !== actions || $[1] !== icons || $[2] !== intl || $[3] !== item || $[4] !== itemLabel || $[5] !== onRun || $[6] !== pending) {
18
- let t2;
19
- if ($[8] !== icons || $[9] !== intl || $[10] !== item || $[11] !== itemLabel || $[12] !== onRun || $[13] !== pending) {
20
- t2 = (action) => /* @__PURE__ */ jsx(ActionButton, {
21
- action,
32
+ const level = use(RowActionsFit);
33
+ let t2;
34
+ if ($[0] !== actions || $[1] !== icons || $[2] !== intl || $[3] !== itemLabel || $[4] !== level || $[5] !== menu || $[6] !== onRun || $[7] !== pending || $[8] !== primary || $[9] !== slots) {
35
+ const own = orderRowActions(actions, menu);
36
+ let t3;
37
+ if ($[11] !== slots) {
38
+ t3 = (t4) => {
39
+ const { action } = t4;
40
+ return slots?.some((slot) => slot.action.id === action.id) !== true;
41
+ };
42
+ $[11] = slots;
43
+ $[12] = t3;
44
+ } else t3 = $[12];
45
+ const all = [...slots ?? [], ...own.filter(t3)];
46
+ const find = (slot_0) => own.find((t4) => {
47
+ const { action: action_0 } = t4;
48
+ return action_0.id === slot_0.action.id;
49
+ });
50
+ const inMenu = level >= 2 && all.length >= 2 ? Math.min(level, all.length) : 0;
51
+ const shown = all.slice(0, all.length - inMenu);
52
+ const overflow = all.slice(all.length - inMenu).flatMap((slot_1) => find(slot_1) ?? []);
53
+ let t5;
54
+ if ($[13] !== intl || $[14] !== itemLabel) {
55
+ t5 = (action_1) => intl.formatMessage(messages.actionOnItem, {
56
+ action: getActionLabel(action_1, intl),
57
+ item: itemLabel
58
+ });
59
+ $[13] = intl;
60
+ $[14] = itemLabel;
61
+ $[15] = t5;
62
+ } else t5 = $[15];
63
+ const name = t5;
64
+ let t6;
65
+ if ($[16] !== icons || $[17] !== level || $[18] !== name || $[19] !== onRun || $[20] !== pending || $[21] !== primary) {
66
+ t6 = (entry) => /* @__PURE__ */ jsx(ActionButton, {
67
+ action: entry.action,
22
68
  icons,
23
- href: getActionHref(action, item),
24
- isPending: pending === action.id,
25
- isDisabled: pending !== null && pending !== action.id,
26
- "aria-label": intl.formatMessage(messages.actionOnItem, {
27
- action: action.label,
28
- item: itemLabel
29
- }),
30
- onPress: () => onRun(action)
31
- }, action.id);
32
- $[8] = icons;
33
- $[9] = intl;
34
- $[10] = item;
35
- $[11] = itemLabel;
36
- $[12] = onRun;
37
- $[13] = pending;
38
- $[14] = t2;
39
- } else t2 = $[14];
40
- t1 = actions.map(t2);
69
+ href: entry.href,
70
+ iconOnly: level >= 1 || entry.action.id !== primary,
71
+ isPending: pending === entry.action.id,
72
+ isDisabled: pending !== null && pending !== entry.action.id,
73
+ "aria-label": name(entry.action),
74
+ onPress: () => onRun(entry.action)
75
+ }, entry.action.id);
76
+ $[16] = icons;
77
+ $[17] = level;
78
+ $[18] = name;
79
+ $[19] = onRun;
80
+ $[20] = pending;
81
+ $[21] = primary;
82
+ $[22] = t6;
83
+ } else t6 = $[22];
84
+ const button = t6;
85
+ const placeholder = _temp;
86
+ let t7;
87
+ if ($[23] !== intl || $[24] !== itemLabel) {
88
+ t7 = intl.formatMessage(messages.itemActions, { item: itemLabel });
89
+ $[23] = intl;
90
+ $[24] = itemLabel;
91
+ $[25] = t7;
92
+ } else t7 = $[25];
93
+ const t8 = overflow.length >= 2;
94
+ const t9 = pending !== null && overflow.some((t10) => {
95
+ const { action: action_2 } = t10;
96
+ return action_2.id === pending;
97
+ });
98
+ let t11;
99
+ if ($[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
100
+ t11 = /* @__PURE__ */ jsx(IconButton, {
101
+ icon: Ellipsis,
102
+ size: "sm",
103
+ appearance: "subtle",
104
+ label: t7,
105
+ showTooltip: t8,
106
+ isPending: t9
107
+ });
108
+ $[26] = t7;
109
+ $[27] = t8;
110
+ $[28] = t9;
111
+ $[29] = t11;
112
+ } else t11 = $[29];
113
+ const menuButton = t11;
114
+ t2 = /* @__PURE__ */ jsxs("div", {
115
+ className: Actions_module_default.row,
116
+ "data-row-actions": all.length,
117
+ children: [shown.map((slot_2) => {
118
+ const entry_0 = find(slot_2);
119
+ return entry_0 !== void 0 ? button(entry_0) : placeholder(slot_2.action.id, button({
120
+ ...slot_2,
121
+ href: null
122
+ }));
123
+ }), overflow.length >= 2 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [menuButton, /* @__PURE__ */ jsx(Menu, {
124
+ placement: "bottom end",
125
+ onAction: (key_0) => {
126
+ const entry_1 = overflow.find((t12) => {
127
+ const { action: action_3 } = t12;
128
+ return action_3.id === key_0;
129
+ });
130
+ if (entry_1 !== void 0 && entry_1.href === null) onRun(entry_1.action);
131
+ },
132
+ children: overflow.map((t13) => {
133
+ const { action: action_4, href } = t13;
134
+ const icon = getActionIcon(action_4, icons);
135
+ return /* @__PURE__ */ jsx(MenuItem, {
136
+ id: action_4.id,
137
+ isDanger: action_4.destructive === true,
138
+ ...icon !== void 0 ? { icon } : {},
139
+ ...href !== null ? { href } : {},
140
+ children: getActionLabel(action_4, intl)
141
+ }, action_4.id);
142
+ })
143
+ })] }) : overflow.length === 1 && overflow[0] !== void 0 ? button(overflow[0]) : inMenu > 0 ? placeholder("menu", menuButton) : null]
144
+ });
41
145
  $[0] = actions;
42
146
  $[1] = icons;
43
147
  $[2] = intl;
44
- $[3] = item;
45
- $[4] = itemLabel;
46
- $[5] = onRun;
47
- $[6] = pending;
48
- $[7] = t1;
49
- } else t1 = $[7];
50
- let t2;
51
- if ($[15] !== icons || $[16] !== intl || $[17] !== item || $[18] !== itemLabel || $[19] !== menu || $[20] !== onRun || $[21] !== pending) {
52
- t2 = menu.length > 0 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsx(IconButton, {
53
- icon: Ellipsis,
54
- size: "sm",
55
- label: intl.formatMessage(messages.itemActions, { item: itemLabel }),
56
- isPending: pending !== null && menu.some((action_0) => action_0.id === pending)
57
- }), /* @__PURE__ */ jsx(Menu, {
58
- placement: "bottom end",
59
- onAction: (key) => {
60
- const action_1 = menu.find((candidate) => candidate.id === key);
61
- if (action_1 !== void 0 && getActionHref(action_1, item) === null) onRun(action_1);
62
- },
63
- children: menu.map((action_2) => {
64
- const href = getActionHref(action_2, item);
65
- const icon = getActionIcon(action_2, icons);
66
- return /* @__PURE__ */ jsx(MenuItem, {
67
- id: action_2.id,
68
- isDanger: action_2.destructive === true,
69
- ...icon !== void 0 ? { icon } : {},
70
- ...href !== null ? { href } : {},
71
- children: action_2.label
72
- }, action_2.id);
73
- })
74
- })] }) : null;
75
- $[15] = icons;
76
- $[16] = intl;
77
- $[17] = item;
78
- $[18] = itemLabel;
79
- $[19] = menu;
80
- $[20] = onRun;
81
- $[21] = pending;
82
- $[22] = t2;
83
- } else t2 = $[22];
84
- let t3;
85
- if ($[23] !== t1 || $[24] !== t2) {
86
- t3 = /* @__PURE__ */ jsxs("div", {
87
- className: Actions_module_default.row,
88
- children: [t1, t2]
89
- });
90
- $[23] = t1;
91
- $[24] = t2;
92
- $[25] = t3;
93
- } else t3 = $[25];
94
- return t3;
148
+ $[3] = itemLabel;
149
+ $[4] = level;
150
+ $[5] = menu;
151
+ $[6] = onRun;
152
+ $[7] = pending;
153
+ $[8] = primary;
154
+ $[9] = slots;
155
+ $[10] = t2;
156
+ } else t2 = $[10];
157
+ return t2;
158
+ }
159
+ function _temp(key, content) {
160
+ return /* @__PURE__ */ jsx("span", {
161
+ className: Actions_module_default.placeholder,
162
+ "aria-hidden": "true",
163
+ inert: true,
164
+ children: content
165
+ }, key);
95
166
  }
96
167
  //#endregion
97
- export { RowActions };
168
+ export { RowActions, orderRowActions };
98
169
 
99
170
  //# sourceMappingURL=RowActions.js.map