@alepha/ui 0.39.0 → 0.40.0

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 (187) hide show
  1. package/README.md +4 -2
  2. package/dist/admin/AdminJobExecutionSheet.d.ts.map +1 -1
  3. package/dist/admin/AdminJobExecutionSheet.js +7 -0
  4. package/dist/admin/AdminJobExecutionSheet.js.map +1 -1
  5. package/dist/admin/analytics/RequestDialog.js +1 -1
  6. package/dist/admin/analytics/RequestDialog.js.map +1 -1
  7. package/dist/ai/AiChat.d.ts +6 -3
  8. package/dist/ai/AiChat.d.ts.map +1 -1
  9. package/dist/ai/AiChat.js +34 -5
  10. package/dist/ai/AiChat.js.map +1 -1
  11. package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
  12. package/dist/ai/AiChatConfirmCard.js +5 -1
  13. package/dist/ai/AiChatConfirmCard.js.map +1 -1
  14. package/dist/ai/AiChatFloat.d.ts +14 -0
  15. package/dist/ai/AiChatFloat.d.ts.map +1 -0
  16. package/dist/ai/AiChatFloat.js +30 -0
  17. package/dist/ai/AiChatFloat.js.map +1 -0
  18. package/dist/ai/AiChatMessage.js +2 -2
  19. package/dist/ai/AiChatMessage.js.map +1 -1
  20. package/dist/ai/AiChatPanel.d.ts +19 -0
  21. package/dist/ai/AiChatPanel.d.ts.map +1 -1
  22. package/dist/ai/AiChatPanel.js +65 -19
  23. package/dist/ai/AiChatPanel.js.map +1 -1
  24. package/dist/ai/AiChatToolStepDetails.d.ts +14 -0
  25. package/dist/ai/AiChatToolStepDetails.d.ts.map +1 -0
  26. package/dist/ai/AiChatToolStepDetails.js +34 -0
  27. package/dist/ai/AiChatToolStepDetails.js.map +1 -0
  28. package/dist/ai/AiChatToolTrace.d.ts +50 -0
  29. package/dist/ai/AiChatToolTrace.d.ts.map +1 -0
  30. package/dist/ai/AiChatToolTrace.js +91 -0
  31. package/dist/ai/AiChatToolTrace.js.map +1 -0
  32. package/dist/ai/index.d.ts +4 -2
  33. package/dist/ai/index.d.ts.map +1 -1
  34. package/dist/ai/index.js +3 -1
  35. package/dist/core/Button.d.ts.map +1 -1
  36. package/dist/core/Button.js +17 -1
  37. package/dist/core/Button.js.map +1 -1
  38. package/dist/core/Dialog.d.ts.map +1 -1
  39. package/dist/core/Dialog.js +1 -1
  40. package/dist/core/Dialog.js.map +1 -1
  41. package/dist/core/TimeAgo.d.ts +3 -4
  42. package/dist/core/TimeAgo.d.ts.map +1 -1
  43. package/dist/core/TimeAgo.js +3 -4
  44. package/dist/core/TimeAgo.js.map +1 -1
  45. package/dist/i18n/en/index.d.ts +22 -0
  46. package/dist/i18n/en/index.d.ts.map +1 -0
  47. package/dist/i18n/en/index.js +1 -0
  48. package/dist/i18n/en/uiEn.d.ts +37 -0
  49. package/dist/i18n/en/uiEn.d.ts.map +1 -0
  50. package/dist/i18n/en/uiEn.js +1468 -0
  51. package/dist/i18n/en/uiEn.js.map +1 -0
  52. package/dist/i18n/fr/uiFr.d.ts +3 -2
  53. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  54. package/dist/i18n/fr/uiFr.js +7 -2
  55. package/dist/i18n/fr/uiFr.js.map +1 -1
  56. package/dist/markdown/MarkdownView.d.ts +14 -0
  57. package/dist/markdown/MarkdownView.d.ts.map +1 -1
  58. package/dist/markdown/MarkdownView.js +16 -3
  59. package/dist/markdown/MarkdownView.js.map +1 -1
  60. package/dist/markdown/highlightLines.d.ts +27 -0
  61. package/dist/markdown/highlightLines.d.ts.map +1 -0
  62. package/dist/markdown/highlightLines.js +91 -0
  63. package/dist/markdown/highlightLines.js.map +1 -0
  64. package/dist/markdown/index.d.ts +5 -2
  65. package/dist/markdown/index.d.ts.map +1 -1
  66. package/dist/markdown/index.js +2 -1
  67. package/dist/shell/ButtonInbox.d.ts +8 -0
  68. package/dist/shell/ButtonInbox.d.ts.map +1 -1
  69. package/dist/shell/ButtonInbox.js +3 -1
  70. package/dist/shell/ButtonInbox.js.map +1 -1
  71. package/dist/shell/PlateLayout.d.ts.map +1 -1
  72. package/dist/shell/PlateLayout.js +2 -2
  73. package/dist/shell/PlateLayout.js.map +1 -1
  74. package/dist/sortable/index.d.ts +17 -0
  75. package/dist/sortable/index.d.ts.map +1 -0
  76. package/dist/sortable/index.js +4 -0
  77. package/dist/sortable/useSortableItem.d.ts +32 -0
  78. package/dist/sortable/useSortableItem.d.ts.map +1 -0
  79. package/dist/sortable/useSortableItem.js +35 -0
  80. package/dist/sortable/useSortableItem.js.map +1 -0
  81. package/dist/sortable/useSortableList.d.ts +85 -0
  82. package/dist/sortable/useSortableList.d.ts.map +1 -0
  83. package/dist/sortable/useSortableList.js +125 -0
  84. package/dist/sortable/useSortableList.js.map +1 -0
  85. package/dist/table/DataTable.d.ts.map +1 -1
  86. package/dist/table/DataTable.js +9 -6
  87. package/dist/table/DataTable.js.map +1 -1
  88. package/dist/table/DataTableRowActionGroupItem.d.ts +23 -0
  89. package/dist/table/DataTableRowActionGroupItem.d.ts.map +1 -0
  90. package/dist/table/DataTableRowActionGroupItem.js +38 -0
  91. package/dist/table/DataTableRowActionGroupItem.js.map +1 -0
  92. package/dist/table/DataTableRowActionItem.d.ts.map +1 -1
  93. package/dist/table/DataTableRowActionItem.js +15 -2
  94. package/dist/table/DataTableRowActionItem.js.map +1 -1
  95. package/dist/table/DataTableRowActionsInline.d.ts.map +1 -1
  96. package/dist/table/DataTableRowActionsInline.js +2 -1
  97. package/dist/table/DataTableRowActionsInline.js.map +1 -1
  98. package/dist/table/DataTableRowActionsMenu.d.ts +3 -2
  99. package/dist/table/DataTableRowActionsMenu.d.ts.map +1 -1
  100. package/dist/table/DataTableRowActionsMenu.js +12 -14
  101. package/dist/table/DataTableRowActionsMenu.js.map +1 -1
  102. package/dist/table/dataTableBaseProps.d.ts +16 -2
  103. package/dist/table/dataTableBaseProps.d.ts.map +1 -1
  104. package/dist/table/dataTablePersistence.d.ts +53 -11
  105. package/dist/table/dataTablePersistence.d.ts.map +1 -1
  106. package/dist/table/dataTablePersistence.js +66 -29
  107. package/dist/table/dataTablePersistence.js.map +1 -1
  108. package/dist/table/dataTableTypes.d.ts +20 -3
  109. package/dist/table/dataTableTypes.d.ts.map +1 -1
  110. package/dist/table/index.d.ts +8 -1
  111. package/dist/table/index.d.ts.map +1 -1
  112. package/dist/table/index.js +2 -1
  113. package/dist/table/useDataTableColumns.d.ts.map +1 -1
  114. package/dist/table/useDataTableColumns.js +4 -4
  115. package/dist/table/useDataTableColumns.js.map +1 -1
  116. package/dist/table/useDataTableData.d.ts.map +1 -1
  117. package/dist/table/useDataTableData.js +3 -3
  118. package/dist/table/useDataTableData.js.map +1 -1
  119. package/dist/table/useDataTableFilterForm.d.ts.map +1 -1
  120. package/dist/table/useDataTableFilterForm.js +6 -2
  121. package/dist/table/useDataTableFilterForm.js.map +1 -1
  122. package/dist/table/useDataTableFilterVisibility.d.ts +5 -0
  123. package/dist/table/useDataTableFilterVisibility.d.ts.map +1 -1
  124. package/dist/table/useDataTableFilterVisibility.js +16 -8
  125. package/dist/table/useDataTableFilterVisibility.js.map +1 -1
  126. package/dist/table/useDataTableRefresh.d.ts.map +1 -1
  127. package/dist/table/useDataTableRefresh.js +3 -2
  128. package/dist/table/useDataTableRefresh.js.map +1 -1
  129. package/dist/table/useDataTableSummary.d.ts +5 -0
  130. package/dist/table/useDataTableSummary.d.ts.map +1 -1
  131. package/dist/table/useDataTableSummary.js +6 -6
  132. package/dist/table/useDataTableSummary.js.map +1 -1
  133. package/docs/packages-alepha-ui-ai.md +3 -3
  134. package/docs/packages-alepha-ui-i18n-en.md +35 -0
  135. package/docs/packages-alepha-ui-markdown.md +3 -1
  136. package/docs/packages-alepha-ui-overview.md +4 -2
  137. package/docs/packages-alepha-ui-sortable.md +34 -0
  138. package/docs/packages-alepha-ui-table.md +7 -1
  139. package/package.json +21 -3
  140. package/src/admin/AdminJobExecutionSheet.tsx +9 -0
  141. package/src/admin/analytics/RequestDialog.tsx +1 -1
  142. package/src/ai/AiChat.tsx +44 -6
  143. package/src/ai/AiChatConfirmCard.tsx +7 -1
  144. package/src/ai/AiChatFloat.tsx +46 -0
  145. package/src/ai/AiChatMessage.tsx +2 -2
  146. package/src/ai/AiChatPanel.tsx +154 -47
  147. package/src/ai/AiChatToolStepDetails.tsx +42 -0
  148. package/src/ai/AiChatToolTrace.tsx +167 -0
  149. package/src/ai/__tests__/AiChat.browser.spec.tsx +270 -2
  150. package/src/ai/index.ts +4 -2
  151. package/src/core/Button.tsx +26 -1
  152. package/src/core/Dialog.tsx +6 -2
  153. package/src/core/TimeAgo.tsx +3 -4
  154. package/src/core/__tests__/Button.browser.spec.tsx +57 -0
  155. package/src/i18n/en/__tests__/uiEn.spec.ts +110 -0
  156. package/src/i18n/en/index.ts +22 -0
  157. package/src/i18n/en/uiEn.ts +1647 -0
  158. package/src/i18n/fr/uiFr.ts +7 -2
  159. package/src/markdown/MarkdownView.tsx +30 -1
  160. package/src/markdown/__tests__/highlightLines.spec.ts +45 -0
  161. package/src/markdown/highlightLines.ts +120 -0
  162. package/src/markdown/index.ts +14 -2
  163. package/src/shell/ButtonInbox.tsx +11 -1
  164. package/src/shell/PlateLayout.tsx +18 -9
  165. package/src/shell/__tests__/ButtonInbox.browser.spec.tsx +40 -0
  166. package/src/shell/__tests__/PlateLayout.browser.spec.tsx +19 -2
  167. package/src/sortable/__tests__/useSortableList.browser.spec.tsx +157 -0
  168. package/src/sortable/index.ts +22 -0
  169. package/src/sortable/useSortableItem.ts +65 -0
  170. package/src/sortable/useSortableList.ts +231 -0
  171. package/src/table/DataTable.tsx +8 -5
  172. package/src/table/DataTableRowActionGroupItem.tsx +75 -0
  173. package/src/table/DataTableRowActionItem.tsx +6 -0
  174. package/src/table/DataTableRowActionsInline.tsx +3 -1
  175. package/src/table/DataTableRowActionsMenu.tsx +33 -49
  176. package/src/table/__tests__/DataTablePersistenceStorage.browser.spec.tsx +204 -0
  177. package/src/table/__tests__/DataTableRowActionGroup.browser.spec.tsx +118 -1
  178. package/src/table/dataTableBaseProps.ts +16 -2
  179. package/src/table/dataTablePersistence.ts +118 -32
  180. package/src/table/dataTableTypes.ts +20 -3
  181. package/src/table/index.ts +14 -1
  182. package/src/table/useDataTableColumns.ts +9 -4
  183. package/src/table/useDataTableData.ts +8 -3
  184. package/src/table/useDataTableFilterForm.ts +6 -2
  185. package/src/table/useDataTableFilterVisibility.ts +20 -7
  186. package/src/table/useDataTableRefresh.ts +4 -2
  187. package/src/table/useDataTableSummary.ts +25 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSortableItem.js","names":[],"sources":["../../src/sortable/useSortableItem.ts"],"sourcesContent":["import {\n type UniqueIdentifier,\n useDraggable,\n useDroppable,\n} from \"@dnd-kit/core\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport type { CSSProperties, PointerEvent } from \"react\";\n\nexport interface SortableItem {\n /**\n * The item's element: what moves, and what another item is dropped on.\n */\n ref: (node: HTMLElement | null) => void;\n /**\n * Where the item is while dragged.\n */\n style: CSSProperties;\n /**\n * The drag's start, for the element a press begins on: the item itself,\n * in the capture phase so a control inside it (a menu trigger) cannot\n * swallow the press, or a grip of its own.\n */\n onPointerDown: ((event: PointerEvent<HTMLElement>) => void) | undefined;\n isDragging: boolean;\n /**\n * Another item is held over this one: where a drop lands.\n */\n isOver: boolean;\n}\n\n/**\n * One item of a {@link useSortableList}: the element both dragged and dropped\n * on, and only the pointer listener of `@dnd-kit`. The keyboard move is the\n * list's own (`onKeyDown`), on whichever element of the item takes focus.\n */\nexport const useSortableItem = (\n id: UniqueIdentifier,\n options: { disabled?: boolean } = {},\n): SortableItem => {\n const disabled = !!options.disabled;\n const {\n listeners,\n setNodeRef: setDragRef,\n transform,\n isDragging,\n } = useDraggable({ id, disabled });\n const { setNodeRef: setDropRef, isOver } = useDroppable({ id, disabled });\n return {\n ref: (node) => {\n setDragRef(node);\n setDropRef(node);\n },\n style: {\n transform: CSS.Translate.toString(transform),\n zIndex: isDragging ? 10 : undefined,\n },\n onPointerDown: disabled\n ? undefined\n : (listeners?.onPointerDown as\n | ((event: PointerEvent<HTMLElement>) => void)\n | undefined),\n isDragging,\n isOver: isOver && !isDragging,\n };\n};\n"],"mappings":";;;;;;;;AAmCA,MAAa,mBACX,IACA,UAAkC,CAAC,MAClB;CACjB,MAAM,WAAW,CAAC,CAAC,QAAQ;CAC3B,MAAM,EACJ,WACA,YAAY,YACZ,WACA,eACE,aAAa;EAAE;EAAI;CAAS,CAAC;CACjC,MAAM,EAAE,YAAY,YAAY,WAAW,aAAa;EAAE;EAAI;CAAS,CAAC;CACxE,OAAO;EACL,MAAM,SAAS;GACb,WAAW,IAAI;GACf,WAAW,IAAI;EACjB;EACA,OAAO;GACL,WAAW,IAAI,UAAU,SAAS,SAAS;GAC3C,QAAQ,aAAa,KAAK,KAAA;EAC5B;EACA,eAAe,WACX,KAAA,IACC,WAAW;EAGhB;EACA,QAAQ,UAAU,CAAC;CACrB;AACF"}
@@ -0,0 +1,85 @@
1
+ import { type DndContextProps, type UniqueIdentifier } from "@dnd-kit/core";
2
+ import { type KeyboardEvent } from "react";
3
+ /**
4
+ * What a sortable list says to a screen reader as an item is moved from the
5
+ * keyboard. The words are the app's, in its own language.
6
+ */
7
+ export interface SortableListAnnouncements {
8
+ picked: (label: string) => string;
9
+ moved: (label: string, position: number, total: number) => string;
10
+ dropped: (label: string) => string;
11
+ cancelled: (label: string) => string;
12
+ }
13
+ export interface UseSortableListOptions<Id extends UniqueIdentifier> {
14
+ /**
15
+ * The order the app holds, as the server last answered it.
16
+ */
17
+ ids: readonly Id[];
18
+ /**
19
+ * A drop that changed the order: `next` is the whole list as now shown,
20
+ * `previous` the order it replaced, for a save that puts it back on a
21
+ * refusal. The list keeps showing `next` until `ids` changes.
22
+ */
23
+ onReorder: (next: Id[], previous: Id[]) => void;
24
+ /**
25
+ * The item's name, for the announcements.
26
+ */
27
+ labelOf: (id: Id) => string;
28
+ announcements: SortableListAnnouncements;
29
+ /**
30
+ * How far a pointer moves before a press becomes a drag, in pixels, so a
31
+ * plain click stays a click. Default 6.
32
+ */
33
+ activationDistance?: number;
34
+ /**
35
+ * Called as a pointer drag starts: a list of links swallows the click the
36
+ * drop ends with, for one.
37
+ */
38
+ onDragStart?: () => void;
39
+ }
40
+ export interface SortableList<Id extends UniqueIdentifier> {
41
+ /**
42
+ * The order to draw: the one held after a drop or a keyboard step, until
43
+ * `ids` catches up, else `ids`.
44
+ */
45
+ order: Id[];
46
+ /**
47
+ * Spread on the `DndContext` around the list.
48
+ */
49
+ contextProps: Pick<DndContextProps, "id" | "sensors" | "modifiers" | "autoScroll" | "onDragStart" | "onDragEnd" | "onDragCancel">;
50
+ /**
51
+ * The keyboard move, for the item's focusable element: Space picks it up,
52
+ * the arrows move it, Space or Enter drops it and Escape (or Tab) puts it
53
+ * back.
54
+ */
55
+ onKeyDown: (id: Id) => (event: KeyboardEvent<HTMLElement>) => void;
56
+ /**
57
+ * The item held by the keyboard, if any.
58
+ */
59
+ picked: Id | undefined;
60
+ /**
61
+ * True while a pointer drag runs.
62
+ */
63
+ dragging: boolean;
64
+ /**
65
+ * The live region's text: render it in an `aria-live="assertive"` element.
66
+ */
67
+ announcement: string;
68
+ }
69
+ /**
70
+ * A vertical list reordered by dragging or from the keyboard, on `@dnd-kit`
71
+ * (pointer and touch sensors, and a keyboard move of its own).
72
+ *
73
+ * It holds what every such list needs and nothing of how it looks: the
74
+ * activation distance, a vertical-only modifier that keeps an item inside the
75
+ * list, the drop index, the order held between a drop and the server's
76
+ * answer, and the keyboard move with its screen-reader announcements. Each
77
+ * item uses {@link useSortableItem}; the list draws `order` inside a
78
+ * `DndContext` given `contextProps`.
79
+ *
80
+ * The keyboard move is the list's own rather than `@dnd-kit`'s
81
+ * `KeyboardSensor`: it moves by one place per arrow, inside a list that may
82
+ * scroll, and says where the item is at each step.
83
+ */
84
+ export declare const useSortableList: <Id extends UniqueIdentifier>(options: UseSortableListOptions<Id>) => SortableList<Id>;
85
+ //# sourceMappingURL=useSortableList.d.ts.map
@@ -0,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C;IACF;;;;OAIG;IACH,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACnE;;OAEG;IACH,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;IACvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAI,EAAE,SAAS,gBAAgB,WAChD,sBAAsB,CAAC,EAAE,CAAC,KAClC,YAAY,CAAC,EAAE,CA2HjB,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { useId, useState } from "react";
2
+ import { PointerSensor, TouchSensor, useSensor, useSensors } from "@dnd-kit/core";
3
+ // src/sortable/useSortableList.ts
4
+ /**
5
+ * A vertical list reordered by dragging or from the keyboard, on `@dnd-kit`
6
+ * (pointer and touch sensors, and a keyboard move of its own).
7
+ *
8
+ * It holds what every such list needs and nothing of how it looks: the
9
+ * activation distance, a vertical-only modifier that keeps an item inside the
10
+ * list, the drop index, the order held between a drop and the server's
11
+ * answer, and the keyboard move with its screen-reader announcements. Each
12
+ * item uses {@link useSortableItem}; the list draws `order` inside a
13
+ * `DndContext` given `contextProps`.
14
+ *
15
+ * The keyboard move is the list's own rather than `@dnd-kit`'s
16
+ * `KeyboardSensor`: it moves by one place per arrow, inside a list that may
17
+ * scroll, and says where the item is at each step.
18
+ */
19
+ const useSortableList = (options) => {
20
+ const dndId = useId();
21
+ const key = options.ids.join("\0");
22
+ const [pending, setPending] = useState();
23
+ const [picked, setPicked] = useState();
24
+ const [dragging, setDragging] = useState(false);
25
+ const [announcement, setAnnouncement] = useState("");
26
+ const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: options.activationDistance ?? 6 } }), useSensor(TouchSensor, { activationConstraint: {
27
+ delay: 200,
28
+ tolerance: 6
29
+ } }));
30
+ if (pending && !picked && pending.base !== key) setPending(void 0);
31
+ const order = pending ? pending.order : [...options.ids];
32
+ const move = (list, from, to) => {
33
+ const next = [...list];
34
+ next.splice(to, 0, ...next.splice(from, 1));
35
+ return next;
36
+ };
37
+ const save = (next, previous) => {
38
+ setPending({
39
+ order: next,
40
+ base: key
41
+ });
42
+ options.onReorder(next, previous);
43
+ };
44
+ const vertical = ({ transform, draggingNodeRect, containerNodeRect }) => {
45
+ let y = transform.y;
46
+ if (draggingNodeRect && containerNodeRect) y = Math.min(Math.max(y, containerNodeRect.top - draggingNodeRect.top), containerNodeRect.bottom - draggingNodeRect.bottom);
47
+ return {
48
+ ...transform,
49
+ x: 0,
50
+ y
51
+ };
52
+ };
53
+ const onDragEnd = (event) => {
54
+ setDragging(false);
55
+ const from = order.findIndex((id) => id === event.active.id);
56
+ const to = event.over ? order.findIndex((id) => id === event.over.id) : -1;
57
+ if (from < 0 || to < 0 || from === to) return;
58
+ save(move(order, from, to), order);
59
+ };
60
+ const onKeyDown = (id) => (event) => {
61
+ const label = options.labelOf(id);
62
+ const held = picked?.id === id;
63
+ if (event.key === " " && !held) {
64
+ event.preventDefault();
65
+ setPicked({
66
+ id,
67
+ before: order
68
+ });
69
+ setAnnouncement(options.announcements.picked(label));
70
+ return;
71
+ }
72
+ if (!held) return;
73
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
74
+ event.preventDefault();
75
+ const from = order.indexOf(id);
76
+ const to = from + (event.key === "ArrowUp" ? -1 : 1);
77
+ if (to < 0 || to >= order.length) return;
78
+ setPending({
79
+ order: move(order, from, to),
80
+ base: key
81
+ });
82
+ setAnnouncement(options.announcements.moved(label, to + 1, order.length));
83
+ return;
84
+ }
85
+ if (event.key === " " || event.key === "Enter") {
86
+ event.preventDefault();
87
+ setPicked(void 0);
88
+ setAnnouncement(options.announcements.dropped(label));
89
+ if (order.join("\0") !== picked.before.join("\0")) save(order, picked.before);
90
+ else setPending(void 0);
91
+ return;
92
+ }
93
+ if (event.key === "Escape" || event.key === "Tab") {
94
+ if (event.key === "Escape") event.preventDefault();
95
+ setPending(void 0);
96
+ setPicked(void 0);
97
+ setAnnouncement(options.announcements.cancelled(label));
98
+ }
99
+ };
100
+ return {
101
+ order,
102
+ contextProps: {
103
+ id: dndId,
104
+ sensors,
105
+ modifiers: [vertical],
106
+ autoScroll: { threshold: {
107
+ x: 0,
108
+ y: .2
109
+ } },
110
+ onDragStart: () => {
111
+ setDragging(true);
112
+ options.onDragStart?.();
113
+ },
114
+ onDragEnd,
115
+ onDragCancel: () => setDragging(false)
116
+ },
117
+ onKeyDown,
118
+ picked: picked?.id,
119
+ dragging,
120
+ announcement
121
+ };
122
+ };
123
+ export { useSortableList };
124
+
125
+ //# sourceMappingURL=useSortableList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSortableList.js","names":[],"sources":["../../src/sortable/useSortableList.ts"],"sourcesContent":["import {\n type DndContextProps,\n type DragEndEvent,\n type Modifier,\n PointerSensor,\n TouchSensor,\n type UniqueIdentifier,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { type KeyboardEvent, useId, useState } from \"react\";\n\n/**\n * What a sortable list says to a screen reader as an item is moved from the\n * keyboard. The words are the app's, in its own language.\n */\nexport interface SortableListAnnouncements {\n picked: (label: string) => string;\n moved: (label: string, position: number, total: number) => string;\n dropped: (label: string) => string;\n cancelled: (label: string) => string;\n}\n\nexport interface UseSortableListOptions<Id extends UniqueIdentifier> {\n /**\n * The order the app holds, as the server last answered it.\n */\n ids: readonly Id[];\n /**\n * A drop that changed the order: `next` is the whole list as now shown,\n * `previous` the order it replaced, for a save that puts it back on a\n * refusal. The list keeps showing `next` until `ids` changes.\n */\n onReorder: (next: Id[], previous: Id[]) => void;\n /**\n * The item's name, for the announcements.\n */\n labelOf: (id: Id) => string;\n announcements: SortableListAnnouncements;\n /**\n * How far a pointer moves before a press becomes a drag, in pixels, so a\n * plain click stays a click. Default 6.\n */\n activationDistance?: number;\n /**\n * Called as a pointer drag starts: a list of links swallows the click the\n * drop ends with, for one.\n */\n onDragStart?: () => void;\n}\n\nexport interface SortableList<Id extends UniqueIdentifier> {\n /**\n * The order to draw: the one held after a drop or a keyboard step, until\n * `ids` catches up, else `ids`.\n */\n order: Id[];\n /**\n * Spread on the `DndContext` around the list.\n */\n contextProps: Pick<\n DndContextProps,\n | \"id\"\n | \"sensors\"\n | \"modifiers\"\n | \"autoScroll\"\n | \"onDragStart\"\n | \"onDragEnd\"\n | \"onDragCancel\"\n >;\n /**\n * The keyboard move, for the item's focusable element: Space picks it up,\n * the arrows move it, Space or Enter drops it and Escape (or Tab) puts it\n * back.\n */\n onKeyDown: (id: Id) => (event: KeyboardEvent<HTMLElement>) => void;\n /**\n * The item held by the keyboard, if any.\n */\n picked: Id | undefined;\n /**\n * True while a pointer drag runs.\n */\n dragging: boolean;\n /**\n * The live region's text: render it in an `aria-live=\"assertive\"` element.\n */\n announcement: string;\n}\n\n/**\n * A vertical list reordered by dragging or from the keyboard, on `@dnd-kit`\n * (pointer and touch sensors, and a keyboard move of its own).\n *\n * It holds what every such list needs and nothing of how it looks: the\n * activation distance, a vertical-only modifier that keeps an item inside the\n * list, the drop index, the order held between a drop and the server's\n * answer, and the keyboard move with its screen-reader announcements. Each\n * item uses {@link useSortableItem}; the list draws `order` inside a\n * `DndContext` given `contextProps`.\n *\n * The keyboard move is the list's own rather than `@dnd-kit`'s\n * `KeyboardSensor`: it moves by one place per arrow, inside a list that may\n * scroll, and says where the item is at each step.\n */\nexport const useSortableList = <Id extends UniqueIdentifier>(\n options: UseSortableListOptions<Id>,\n): SortableList<Id> => {\n const dndId = useId();\n const key = options.ids.join(\"\\u0000\");\n // The order shown before the app holds it, and the order the app held\n // when it was set: once `ids` moves (the save read back, or the server\n // said otherwise) it hands back to `ids`.\n const [pending, setPending] = useState<\n { order: Id[]; base: string } | undefined\n >();\n const [picked, setPicked] = useState<{ id: Id; before: Id[] } | undefined>();\n const [dragging, setDragging] = useState(false);\n const [announcement, setAnnouncement] = useState(\"\");\n const sensors = useSensors(\n useSensor(PointerSensor, {\n activationConstraint: { distance: options.activationDistance ?? 6 },\n }),\n useSensor(TouchSensor, {\n activationConstraint: { delay: 200, tolerance: 6 },\n }),\n );\n\n // Adjusted during render, React's \"adjust state when a prop changes\": the\n // held order never outlives the answer, and no effect runs a second pass.\n if (pending && !picked && pending.base !== key) {\n setPending(undefined);\n }\n const order = pending ? pending.order : [...options.ids];\n\n const move = (list: Id[], from: number, to: number): Id[] => {\n const next = [...list];\n next.splice(to, 0, ...next.splice(from, 1));\n return next;\n };\n\n const save = (next: Id[], previous: Id[]) => {\n setPending({ order: next, base: key });\n options.onReorder(next, previous);\n };\n\n // One column: an item moves up and down it, never sideways, and never\n // past its ends.\n const vertical: Modifier = ({\n transform,\n draggingNodeRect,\n containerNodeRect,\n }) => {\n let y = transform.y;\n if (draggingNodeRect && containerNodeRect) {\n y = Math.min(\n Math.max(y, containerNodeRect.top - draggingNodeRect.top),\n containerNodeRect.bottom - draggingNodeRect.bottom,\n );\n }\n return { ...transform, x: 0, y };\n };\n\n const onDragEnd = (event: DragEndEvent) => {\n setDragging(false);\n const from = order.findIndex((id) => id === event.active.id);\n const to = event.over ? order.findIndex((id) => id === event.over!.id) : -1;\n if (from < 0 || to < 0 || from === to) return;\n save(move(order, from, to), order);\n };\n\n const onKeyDown = (id: Id) => (event: KeyboardEvent<HTMLElement>) => {\n const label = options.labelOf(id);\n const held = picked?.id === id;\n if (event.key === \" \" && !held) {\n event.preventDefault();\n setPicked({ id, before: order });\n setAnnouncement(options.announcements.picked(label));\n return;\n }\n if (!held) return;\n if (event.key === \"ArrowUp\" || event.key === \"ArrowDown\") {\n event.preventDefault();\n const from = order.indexOf(id);\n const to = from + (event.key === \"ArrowUp\" ? -1 : 1);\n if (to < 0 || to >= order.length) return;\n // Drawn now, saved on the drop.\n setPending({ order: move(order, from, to), base: key });\n setAnnouncement(options.announcements.moved(label, to + 1, order.length));\n return;\n }\n if (event.key === \" \" || event.key === \"Enter\") {\n event.preventDefault();\n setPicked(undefined);\n setAnnouncement(options.announcements.dropped(label));\n if (order.join(\"\\u0000\") !== picked.before.join(\"\\u0000\")) {\n save(order, picked.before);\n } else {\n setPending(undefined);\n }\n return;\n }\n if (event.key === \"Escape\" || event.key === \"Tab\") {\n if (event.key === \"Escape\") event.preventDefault();\n setPending(undefined);\n setPicked(undefined);\n setAnnouncement(options.announcements.cancelled(label));\n }\n };\n\n return {\n order,\n contextProps: {\n id: dndId,\n sensors,\n modifiers: [vertical],\n // Vertical only: the column has nothing to scroll sideways.\n autoScroll: { threshold: { x: 0, y: 0.2 } },\n onDragStart: () => {\n setDragging(true);\n options.onDragStart?.();\n },\n onDragEnd,\n onDragCancel: () => setDragging(false),\n },\n onKeyDown,\n picked: picked?.id,\n dragging,\n announcement,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyGA,MAAa,mBACX,YACqB;CACrB,MAAM,QAAQ,MAAM;CACpB,MAAM,MAAM,QAAQ,IAAI,KAAK,IAAQ;CAIrC,MAAM,CAAC,SAAS,cAAc,SAE5B;CACF,MAAM,CAAC,QAAQ,aAAa,SAA+C;CAC3E,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CACnD,MAAM,UAAU,WACd,UAAU,eAAe,EACvB,sBAAsB,EAAE,UAAU,QAAQ,sBAAsB,EAAE,EACpE,CAAC,GACD,UAAU,aAAa,EACrB,sBAAsB;EAAE,OAAO;EAAK,WAAW;CAAE,EACnD,CAAC,CACH;CAIA,IAAI,WAAW,CAAC,UAAU,QAAQ,SAAS,KACzC,WAAW,KAAA,CAAS;CAEtB,MAAM,QAAQ,UAAU,QAAQ,QAAQ,CAAC,GAAG,QAAQ,GAAG;CAEvD,MAAM,QAAQ,MAAY,MAAc,OAAqB;EAC3D,MAAM,OAAO,CAAC,GAAG,IAAI;EACrB,KAAK,OAAO,IAAI,GAAG,GAAG,KAAK,OAAO,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CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,EACD,KAAK,CAAC,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,SAExD,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,sBAg2B5B,CAAC"}
1
+ {"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../src/table/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAsBlE,OAAO,KAAK,EAEV,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EAKhB,MAAM,qBAAqB,CAAC;AAY7B,MAAM,MAAM,cAAc,CACxB,CAAC,EACD,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,IACvD,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,EACD,KAAK,CAAC,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,SAExD,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,sBAm2B5B,CAAC"}
@@ -66,7 +66,7 @@ const DataTable = (props) => {
66
66
  const columnsKey = props.persist?.columns === false ? void 0 : props.persistenceKey;
67
67
  const sortKey = props.persist?.sort === false ? void 0 : props.persistenceKey;
68
68
  const sizeKey = props.pageSizes?.length === 0 ? void 0 : props.persistenceKey;
69
- const [size, setSize] = useState(() => persistedSize(sizeKey, props.defaultSize));
69
+ const [size, setSize] = useState(() => persistedSize(sizeKey, props.defaultSize, props.persistenceStorage));
70
70
  const alepha = useAlepha();
71
71
  const { tr } = useI18n();
72
72
  const toast = useToast();
@@ -100,7 +100,8 @@ const DataTable = (props) => {
100
100
  }, [alepha, form]);
101
101
  const filterVisibility = useDataTableFilterVisibility({
102
102
  definition: filterDefinition,
103
- filtersKey
103
+ filtersKey,
104
+ persistenceStorage: props.persistenceStorage
104
105
  });
105
106
  const headerFilters = {};
106
107
  const popupFilters = {};
@@ -168,6 +169,7 @@ const DataTable = (props) => {
168
169
  const summary = useDataTableSummary({
169
170
  summary: untyped.summary,
170
171
  persistenceKey: props.persistenceKey,
172
+ persistenceStorage: props.persistenceStorage,
171
173
  refreshKey,
172
174
  form,
173
175
  alepha
@@ -275,10 +277,11 @@ const DataTable = (props) => {
275
277
  if (scopeRef.current !== props.persistenceKey) {
276
278
  scopeRef.current = props.persistenceKey;
277
279
  setPage(0);
278
- setSize(persistedSize(sizeKey, props.defaultSize));
279
- setSort(persistedSort(sortKey, props.defaultSort));
280
- setVisibleColumns(persistedColumns(columnsKey, props.columns));
281
- setColumnOrder(persistedOrder(columnsKey, props.columns));
280
+ const storage = props.persistenceStorage;
281
+ setSize(persistedSize(sizeKey, props.defaultSize, storage));
282
+ setSort(persistedSort(sortKey, props.defaultSort, storage));
283
+ setVisibleColumns(persistedColumns(columnsKey, props.columns, storage));
284
+ setColumnOrder(persistedOrder(columnsKey, props.columns, storage));
282
285
  filterVisibility.rereadShown(filtersKey);
283
286
  summary.resetScope(props.persistenceKey);
284
287
  clearSelection();
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableCompactPager } from \"./DataTableCompactPager.tsx\";\nimport type { DataTableFilterBarField } from \"./DataTableFilterBar.tsx\";\nimport { dataTableFilterBarFields } from \"./dataTableFilterFields.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderFilter } from \"./DataTableHeaderFilter.tsx\";\nimport { DataTableHeaderPopup } from \"./DataTableHeaderPopup.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DataTablePresetRail } from \"./DataTablePresetRail.tsx\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n DataTableStatCard,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useDataTableWake } from \"./useDataTableWake.ts\";\nimport { useOptimisticRows } from \"./useOptimisticRows.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n // `filters.onChange` (#Q3779): every value on mount, then after each\n // change. Read through a ref so a new callback each render neither\n // resubscribes nor fires.\n const onFiltersChange = useRef(untyped.filters?.onChange);\n onFiltersChange.current = untyped.filters?.onChange;\n // The current filter values as state too, so a summary tile standing for\n // some of them (`DataTableStatCard.filter`) redraws pressed or not.\n const [filterValues, setFilterValues] = useState<Record<string, unknown>>(\n () => ({ ...form?.currentValues }),\n );\n useEffect(() => {\n if (!form) return;\n onFiltersChange.current?.({ ...form.currentValues });\n // No `setFilterValues` here: the state starts from the form's values,\n // and every change after that comes through the event below.\n return alepha.events.on(\"form:changed\", (event) => {\n if (event.id !== form.id) return;\n onFiltersChange.current?.({ ...form.currentValues });\n setFilterValues({ ...form.currentValues });\n });\n }, [alepha, form]);\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n });\n\n // The filters that sit in a column's header, by column: the first field\n // naming a column wins it. Only for the bar the table draws itself - a\n // caller's `filters.render` owns where its filters go, and the bar's rule\n // that a set filter shows on it is what makes a header filter safe.\n const headerFilters: Record<string, DataTableFilterBarField> = {};\n // Under `headerPopup`, every field naming a column, so a `min` / `max`\n // pair lands in one popup.\n const popupFilters: Record<string, DataTableFilterBarField[]> = {};\n if (untyped.filters && !untyped.filters.render && filterDefinition) {\n for (const field of dataTableFilterBarFields(\n untyped.filters.fields,\n filterDefinition,\n )) {\n if (!field.column || field.hidden) continue;\n if (!(field.column in headerFilters)) headerFilters[field.column] = field;\n const fields = (popupFilters[field.column] ??= []);\n const ranged = field.range !== undefined;\n if (fields.length === 0 || (ranged && fields.every((f) => f.range))) {\n fields.push(field);\n }\n }\n }\n const headerPopup = props.headerPopup\n ? (columnKey: string, def: ColumnDef<T>) => {\n const fields = form ? (popupFilters[columnKey] ?? []) : [];\n if (fields.length === 0 && !def.sortable) return undefined;\n const field = def.sortKey ?? columnKey;\n return (\n <DataTableHeaderPopup\n form={form ?? undefined}\n label={def.label}\n hinted={Boolean(def.hint)}\n fields={fields}\n sortable={Boolean(def.sortable)}\n sorted={sort?.field === field ? sort.direction : null}\n onSort={(direction) => setSortTo(columnKey, def, direction)}\n />\n );\n }\n : undefined;\n const headerFilter = (columnKey: string) => {\n const field = headerFilters[columnKey];\n if (!field || !form) return undefined;\n return (\n <DataTableHeaderFilter\n form={form}\n field={field}\n shown={filterVisibility.shown}\n onShownChange={filterVisibility.setShown}\n />\n );\n };\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data: serverData,\n meta,\n rowFilters,\n groupCounts,\n loading,\n loadedRequestId,\n lastRequestId,\n isStatic,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n // `onPage`: the page on screen and how many there are, whenever either\n // moves. Through a ref so an inline callback does not re-fire it.\n const onPageRef = useRef(props.onPage);\n onPageRef.current = props.onPage;\n const totalPages = meta?.totalPages ?? 0;\n useEffect(() => {\n onPageRef.current?.({ page, totalPages });\n }, [page, totalPages]);\n\n const {\n refresh,\n reload,\n handleRefreshClick,\n resetFilters,\n canShare,\n shareFilters,\n } = useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n /**\n * A row's key from the row alone, so a row redrawn by an optimistic patch\n * (a new object) keeps the key of the one it replaces.\n */\n const keyOf = useCallback(\n (item: T, index: number): string => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n },\n [page, props.rowKey],\n );\n\n const serverRowKeys = useMemo(\n () => serverData.map((item, index) => keyOf(item, index)),\n [serverData, keyOf],\n );\n\n // -- Optimistic overlay ----------------------------------------------------\n\n const serverKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));\n return map;\n }, [serverData, serverRowKeys]);\n\n const overlayKey = useCallback(\n (item: T) => serverKeyByItem.get(item) ?? keyOf(item, -1),\n [serverKeyByItem, keyOf],\n );\n\n const overlay = useOptimisticRows<T>({\n data: serverData,\n rowKeys: serverRowKeys,\n rowKey: overlayKey,\n loadedRequestId,\n lastRequestId,\n reload,\n isStatic,\n });\n const data = overlay.data;\n const rowKeys = overlay.rowKeys;\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // Back on the tab: a background reload, unless the rows are fresh or the\n // reader is mid-selection or mid-edit (#Q4069).\n const rootRef = useRef<HTMLDivElement | null>(null);\n useDataTableWake({\n enabled: props.refreshOnFocus === true && !isStatic,\n loadedRequestId,\n freshMs: 10_000,\n selecting: selection.size > 0,\n root: rootRef,\n reload,\n });\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * React re-renders before committing this, so no frame, no fetch and no\n * effect ever sees the OUTGOING scope's state under the INCOMING key. The\n * sort used to be written by an effect keyed on `persistenceKey`, which\n * would have stored the project you just left over the one you just\n * opened; every write is now the reader's own act.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n setSize(persistedSize(sizeKey, props.defaultSize));\n setSort(persistedSort(sortKey, props.defaultSort));\n setVisibleColumns(persistedColumns(columnsKey, props.columns));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n // The selection is the scope's rows: a bulk action after the switch must\n // not receive rows of the project just left, off screen by now.\n clearSelection();\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n const bulkCtx: BulkActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n\n /**\n * How many filters currently narrow the list: a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n /**\n * Whether the filters are the table's declared default view\n * (`initialValues`), such as an inbox that opens on `status: open`. An\n * empty page there means the list has nothing, so its `emptyMessage`\n * still applies (#Q3820): only a filter the reader set is a \"no match\".\n */\n const filtersAtDefault = useMemo(() => {\n if (!props.filters || !form) return true;\n const canonical = (values: Record<string, unknown>) => {\n const clean = cleanFilterValues(values);\n return JSON.stringify(\n Object.keys(clean)\n .sort()\n .map((key) => [key, clean[key]]),\n );\n };\n return (\n canonical(form.currentValues ?? {}) ===\n canonical((props.filters.initialValues ?? {}) as Record<string, unknown>)\n );\n }, [props.filters, form, refreshKey]);\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n !props.hideToolbar &&\n (Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu);\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n // `density=\"compact\"` defaults the padding to `small` and the type to\n // `text-xs`; an explicit `cellPadding` keeps the padding half its own.\n const compact = props.density === \"compact\";\n const cellPadding =\n DATA_TABLE_CELL_PADDING[\n props.cellPadding ?? (compact ? \"small\" : \"normal\")\n ];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n // `pagination={false}` holds for static rows only: a fetched table is\n // paged by the server, and hiding its pager would hide rows.\n const unpaged = props.pagination === false && Boolean(props.data);\n // `\"compact\"` swaps the footer for the small pager under the rows, for a\n // static and a fetched table alike: rows stay reachable, the band goes.\n const compactPager = props.pagination === \"compact\";\n const showFooter =\n !unpaged &&\n !compactPager &&\n ((props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1));\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n // The presets rail (`filters.presets`), from `md` up: on a phone the\n // filter dialog is the table's whole filter surface.\n const presets = untyped.filters?.presets;\n const rail =\n presets &&\n presets.items.length > 0 &&\n form &&\n filterDefinition &&\n !isMobile ? (\n <DataTablePresetRail\n form={form}\n keys={filterDefinition.keys}\n kept={filterDefinition.kept}\n presets={presets}\n onApply={(preset) => {\n const values = preset.values as Record<string, unknown>;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const kept = filterDefinition.kept;\n const current = (form.currentValues ?? {}) as Record<string, unknown>;\n // Every key but the kept ones (`keepOnPreset`), so a preset is\n // the whole filter: what it does not name is cleared, the way\n // Reset filters clears it.\n for (const key of filterDefinition.keys) {\n if (kept.includes(key)) continue;\n inputs[key]?.set?.(values[key]);\n }\n // The bar then shows the preset's filters, and a kept one still\n // holding a value, and nothing else.\n filterVisibility.setShown(\n [\n ...Object.keys(values).filter(\n (key) =>\n !kept.includes(key) && !isEmptyFilterValue(values[key]),\n ),\n ...kept.filter((key) => !isEmptyFilterValue(current[key])),\n ].filter((key) => filterDefinition.modes[key] !== \"locked\"),\n true,\n );\n }}\n onAll={resetFilters}\n className={cn(\n // `flat`: no frame of its own either, only the line between the\n // rail and the rows, which the table's flattened start edge no\n // longer draws.\n props.flat && \"rounded-none border-y-0 border-s-0 border-e\",\n props.chromeClassName,\n )}\n />\n ) : undefined;\n\n // A summary tile standing for filter values (`DataTableStatCard.filter`):\n // a click sets them and shows them on the bar, or clears them when they\n // all hold already.\n const selectCard = (card: DataTableStatCard) => {\n if (!form || !filterDefinition || !card.filter) return;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const keys = Object.keys(card.filter).filter((key) =>\n filterDefinition.keys.includes(key),\n );\n if (isCardActive(card, filterValues)) {\n for (const key of keys) inputs[key]?.set?.(undefined);\n return;\n }\n for (const key of keys) inputs[key]?.set?.(card.filter[key]);\n // A key the tile clears (`undefined`) adds no chip to the bar.\n const setting = keys.filter((key) => card.filter?.[key] !== undefined);\n filterVisibility.setShown(\n [...new Set([...filterVisibility.shown, ...setting])].filter(\n (key) => filterDefinition.modes[key] !== \"locked\",\n ),\n true,\n );\n };\n\n const table = (\n <div\n ref={rootRef}\n className={cn(\n \"flex flex-col gap-2\",\n // Beside the rail the table and the rail are one panel: every band\n // squares its start corners against the rail's squared end ones.\n rail ? \"min-h-0 min-w-0 flex-1 [&>*]:rounded-s-none\" : props.className,\n )}\n >\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n isActive={(card) => isCardActive(card, filterValues)}\n onSelect={form && filterDefinition ? selectCard : undefined}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n headerPopup={props.headerPopup}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary ? \"-mt-2 rounded-t-none border-t-0\" : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n // `bg-card`: the rows are content between the chrome bands, and\n // keep their own surface on a muted page (a Plate's body) instead\n // of taking the chrome's colour through a transparent panel.\n \"bg-card flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table\n className={cn(\n isEmptyState && \"h-full\",\n compact && \"text-xs [&_th]:text-xs\",\n )}\n >\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over.\n\n The lines sit on the cells, not on the `<thead>`: WebKit paints\n no `box-shadow` on a table section, so on Safari the header had\n no bottom line at all. Not `chrome` either, for the same reason,\n and because `cn` does not know `chrome` is a background: it kept\n `TableHeader`'s `bg-muted/50` beside it, which won. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow draws the\n // same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 [&_th]:shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n headerFilter={headerFilter}\n headerPopup={headerPopup}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n leaving={overlay.leaving}\n flash={overlay.flash}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n filtersAtDefault={filtersAtDefault}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n rowActionsDisplay={props.rowActionsDisplay}\n striped={props.striped}\n onRowClick={props.onRowClick}\n isRowActive={props.isRowActive}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n groupBy={props.groupBy}\n groupCounts={groupCounts}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {compactPager && <DataTableCompactPager meta={meta} setPage={setPage} />}\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(squareRight?.bottom, flatBottom, props.chromeClassName)}\n />\n )}\n </div>\n );\n\n return (\n <ClientOnly>\n {rail ? (\n <div className={cn(\"flex min-h-0\", props.className)}>\n {rail}\n {table}\n </div>\n ) : (\n table\n )}\n </ClientOnly>\n );\n};\n\n/**\n * Whether every filter value a summary tile stands for holds now. Compared\n * as JSON, so an array value matches the same members in the same order; an\n * `undefined` value (the tile clears that filter) holds while the field is\n * empty: unset, `\"\"` or an emptied multi-select.\n */\nconst isCardActive = (\n card: DataTableStatCard,\n values: Record<string, unknown>,\n): boolean => {\n if (!card.filter) return false;\n const entries = Object.entries(card.filter);\n const empty = (value: unknown) =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n return (\n entries.length > 0 &&\n entries.every(([key, value]) =>\n value === undefined\n ? empty(values[key])\n : JSON.stringify(values[key]) === JSON.stringify(value),\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI,KAAA,IAAY,MAAM;CAKpD,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,WAAW,CAC1C;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;;;;;;;;;;;CAWvB,MAAM,WAAW,YAAY;CAE7B,MAAM,EAAE,MAAM,YAAY,qBAAqB,uBAAuB;EACpE,OAAO;EACP;EACA;CACF,CAAC;CAKD,MAAM,kBAAkB,OAAO,QAAQ,SAAS,QAAQ;CACxD,gBAAgB,UAAU,QAAQ,SAAS;CAG3C,MAAM,CAAC,cAAc,mBAAmB,gBAC/B,EAAE,GAAG,MAAM,cAAc,EAClC;CACA,gBAAgB;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AW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GAAG,aAAa,QAAQ,YAAY,MAAM,eAAe;GACrE,CAAA;EAEA;;CAGP,OACE,oBAAC,YAAD,EAAA,UACG,OACC,qBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,MAAM,SAAS;EAAlD,UAAA,CACG,MACA,KACE;CAEL,CAAA,IAAA,MAEQ,CAAA;AAEhB;;;;;;;AAQA,MAAM,gBACJ,MACA,WACY;CACZ,IAAI,CAAC,KAAK,QAAQ,OAAO;CACzB,MAAM,UAAU,OAAO,QAAQ,KAAK,MAAM;CAC1C,MAAM,SAAS,UACb,UAAU,KAAA,KACV,UAAU,QACV,UAAU,MACT,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;CAC5C,OACE,QAAQ,SAAS,KACjB,QAAQ,OAAO,CAAC,KAAK,WACnB,UAAU,KAAA,IACN,MAAM,OAAO,IAAI,IACjB,KAAK,UAAU,OAAO,IAAI,MAAM,KAAK,UAAU,KAAK,CAC1D;AAEJ"}
1
+ {"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableCompactPager } from \"./DataTableCompactPager.tsx\";\nimport type { DataTableFilterBarField } from \"./DataTableFilterBar.tsx\";\nimport { dataTableFilterBarFields } from \"./dataTableFilterFields.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderFilter } from \"./DataTableHeaderFilter.tsx\";\nimport { DataTableHeaderPopup } from \"./DataTableHeaderPopup.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DataTablePresetRail } from \"./DataTablePresetRail.tsx\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n DataTableStatCard,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useDataTableWake } from \"./useDataTableWake.ts\";\nimport { useOptimisticRows } from \"./useOptimisticRows.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize, props.persistenceStorage),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n // `filters.onChange` (#Q3779): every value on mount, then after each\n // change. Read through a ref so a new callback each render neither\n // resubscribes nor fires.\n const onFiltersChange = useRef(untyped.filters?.onChange);\n onFiltersChange.current = untyped.filters?.onChange;\n // The current filter values as state too, so a summary tile standing for\n // some of them (`DataTableStatCard.filter`) redraws pressed or not.\n const [filterValues, setFilterValues] = useState<Record<string, unknown>>(\n () => ({ ...form?.currentValues }),\n );\n useEffect(() => {\n if (!form) return;\n onFiltersChange.current?.({ ...form.currentValues });\n // No `setFilterValues` here: the state starts from the form's values,\n // and every change after that comes through the event below.\n return alepha.events.on(\"form:changed\", (event) => {\n if (event.id !== form.id) return;\n onFiltersChange.current?.({ ...form.currentValues });\n setFilterValues({ ...form.currentValues });\n });\n }, [alepha, form]);\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n persistenceStorage: props.persistenceStorage,\n });\n\n // The filters that sit in a column's header, by column: the first field\n // naming a column wins it. Only for the bar the table draws itself - a\n // caller's `filters.render` owns where its filters go, and the bar's rule\n // that a set filter shows on it is what makes a header filter safe.\n const headerFilters: Record<string, DataTableFilterBarField> = {};\n // Under `headerPopup`, every field naming a column, so a `min` / `max`\n // pair lands in one popup.\n const popupFilters: Record<string, DataTableFilterBarField[]> = {};\n if (untyped.filters && !untyped.filters.render && filterDefinition) {\n for (const field of dataTableFilterBarFields(\n untyped.filters.fields,\n filterDefinition,\n )) {\n if (!field.column || field.hidden) continue;\n if (!(field.column in headerFilters)) headerFilters[field.column] = field;\n const fields = (popupFilters[field.column] ??= []);\n const ranged = field.range !== undefined;\n if (fields.length === 0 || (ranged && fields.every((f) => f.range))) {\n fields.push(field);\n }\n }\n }\n const headerPopup = props.headerPopup\n ? (columnKey: string, def: ColumnDef<T>) => {\n const fields = form ? (popupFilters[columnKey] ?? []) : [];\n if (fields.length === 0 && !def.sortable) return undefined;\n const field = def.sortKey ?? columnKey;\n return (\n <DataTableHeaderPopup\n form={form ?? undefined}\n label={def.label}\n hinted={Boolean(def.hint)}\n fields={fields}\n sortable={Boolean(def.sortable)}\n sorted={sort?.field === field ? sort.direction : null}\n onSort={(direction) => setSortTo(columnKey, def, direction)}\n />\n );\n }\n : undefined;\n const headerFilter = (columnKey: string) => {\n const field = headerFilters[columnKey];\n if (!field || !form) return undefined;\n return (\n <DataTableHeaderFilter\n form={form}\n field={field}\n shown={filterVisibility.shown}\n onShownChange={filterVisibility.setShown}\n />\n );\n };\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data: serverData,\n meta,\n rowFilters,\n groupCounts,\n loading,\n loadedRequestId,\n lastRequestId,\n isStatic,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n // `onPage`: the page on screen and how many there are, whenever either\n // moves. Through a ref so an inline callback does not re-fire it.\n const onPageRef = useRef(props.onPage);\n onPageRef.current = props.onPage;\n const totalPages = meta?.totalPages ?? 0;\n useEffect(() => {\n onPageRef.current?.({ page, totalPages });\n }, [page, totalPages]);\n\n const {\n refresh,\n reload,\n handleRefreshClick,\n resetFilters,\n canShare,\n shareFilters,\n } = useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n persistenceStorage: props.persistenceStorage,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n /**\n * A row's key from the row alone, so a row redrawn by an optimistic patch\n * (a new object) keeps the key of the one it replaces.\n */\n const keyOf = useCallback(\n (item: T, index: number): string => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n },\n [page, props.rowKey],\n );\n\n const serverRowKeys = useMemo(\n () => serverData.map((item, index) => keyOf(item, index)),\n [serverData, keyOf],\n );\n\n // -- Optimistic overlay ----------------------------------------------------\n\n const serverKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));\n return map;\n }, [serverData, serverRowKeys]);\n\n const overlayKey = useCallback(\n (item: T) => serverKeyByItem.get(item) ?? keyOf(item, -1),\n [serverKeyByItem, keyOf],\n );\n\n const overlay = useOptimisticRows<T>({\n data: serverData,\n rowKeys: serverRowKeys,\n rowKey: overlayKey,\n loadedRequestId,\n lastRequestId,\n reload,\n isStatic,\n });\n const data = overlay.data;\n const rowKeys = overlay.rowKeys;\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // Back on the tab: a background reload, unless the rows are fresh or the\n // reader is mid-selection or mid-edit (#Q4069).\n const rootRef = useRef<HTMLDivElement | null>(null);\n useDataTableWake({\n enabled: props.refreshOnFocus === true && !isStatic,\n loadedRequestId,\n freshMs: 10_000,\n selecting: selection.size > 0,\n root: rootRef,\n reload,\n });\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * React re-renders before committing this, so no frame, no fetch and no\n * effect ever sees the OUTGOING scope's state under the INCOMING key. The\n * sort used to be written by an effect keyed on `persistenceKey`, which\n * would have stored the project you just left over the one you just\n * opened; every write is now the reader's own act.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n const storage = props.persistenceStorage;\n setSize(persistedSize(sizeKey, props.defaultSize, storage));\n setSort(persistedSort(sortKey, props.defaultSort, storage));\n setVisibleColumns(persistedColumns(columnsKey, props.columns, storage));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns, storage));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n // The selection is the scope's rows: a bulk action after the switch must\n // not receive rows of the project just left, off screen by now.\n clearSelection();\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n const bulkCtx: BulkActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n\n /**\n * How many filters currently narrow the list: a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n /**\n * Whether the filters are the table's declared default view\n * (`initialValues`), such as an inbox that opens on `status: open`. An\n * empty page there means the list has nothing, so its `emptyMessage`\n * still applies (#Q3820): only a filter the reader set is a \"no match\".\n */\n const filtersAtDefault = useMemo(() => {\n if (!props.filters || !form) return true;\n const canonical = (values: Record<string, unknown>) => {\n const clean = cleanFilterValues(values);\n return JSON.stringify(\n Object.keys(clean)\n .sort()\n .map((key) => [key, clean[key]]),\n );\n };\n return (\n canonical(form.currentValues ?? {}) ===\n canonical((props.filters.initialValues ?? {}) as Record<string, unknown>)\n );\n }, [props.filters, form, refreshKey]);\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n !props.hideToolbar &&\n (Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu);\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n // `density=\"compact\"` defaults the padding to `small` and the type to\n // `text-xs`; an explicit `cellPadding` keeps the padding half its own.\n const compact = props.density === \"compact\";\n const cellPadding =\n DATA_TABLE_CELL_PADDING[\n props.cellPadding ?? (compact ? \"small\" : \"normal\")\n ];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n // `pagination={false}` holds for static rows only: a fetched table is\n // paged by the server, and hiding its pager would hide rows.\n const unpaged = props.pagination === false && Boolean(props.data);\n // `\"compact\"` swaps the footer for the small pager under the rows, for a\n // static and a fetched table alike: rows stay reachable, the band goes.\n const compactPager = props.pagination === \"compact\";\n const showFooter =\n !unpaged &&\n !compactPager &&\n ((props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1));\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n // The presets rail (`filters.presets`), from `md` up: on a phone the\n // filter dialog is the table's whole filter surface.\n const presets = untyped.filters?.presets;\n const rail =\n presets &&\n presets.items.length > 0 &&\n form &&\n filterDefinition &&\n !isMobile ? (\n <DataTablePresetRail\n form={form}\n keys={filterDefinition.keys}\n kept={filterDefinition.kept}\n presets={presets}\n onApply={(preset) => {\n const values = preset.values as Record<string, unknown>;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const kept = filterDefinition.kept;\n const current = (form.currentValues ?? {}) as Record<string, unknown>;\n // Every key but the kept ones (`keepOnPreset`), so a preset is\n // the whole filter: what it does not name is cleared, the way\n // Reset filters clears it.\n for (const key of filterDefinition.keys) {\n if (kept.includes(key)) continue;\n inputs[key]?.set?.(values[key]);\n }\n // The bar then shows the preset's filters, and a kept one still\n // holding a value, and nothing else.\n filterVisibility.setShown(\n [\n ...Object.keys(values).filter(\n (key) =>\n !kept.includes(key) && !isEmptyFilterValue(values[key]),\n ),\n ...kept.filter((key) => !isEmptyFilterValue(current[key])),\n ].filter((key) => filterDefinition.modes[key] !== \"locked\"),\n true,\n );\n }}\n onAll={resetFilters}\n className={cn(\n // `flat`: no frame of its own either, only the line between the\n // rail and the rows, which the table's flattened start edge no\n // longer draws.\n props.flat && \"rounded-none border-y-0 border-s-0 border-e\",\n props.chromeClassName,\n )}\n />\n ) : undefined;\n\n // A summary tile standing for filter values (`DataTableStatCard.filter`):\n // a click sets them and shows them on the bar, or clears them when they\n // all hold already.\n const selectCard = (card: DataTableStatCard) => {\n if (!form || !filterDefinition || !card.filter) return;\n const inputs = form.input as unknown as Record<\n string,\n { set?: (value: unknown) => void } | undefined\n >;\n const keys = Object.keys(card.filter).filter((key) =>\n filterDefinition.keys.includes(key),\n );\n if (isCardActive(card, filterValues)) {\n for (const key of keys) inputs[key]?.set?.(undefined);\n return;\n }\n for (const key of keys) inputs[key]?.set?.(card.filter[key]);\n // A key the tile clears (`undefined`) adds no chip to the bar.\n const setting = keys.filter((key) => card.filter?.[key] !== undefined);\n filterVisibility.setShown(\n [...new Set([...filterVisibility.shown, ...setting])].filter(\n (key) => filterDefinition.modes[key] !== \"locked\",\n ),\n true,\n );\n };\n\n const table = (\n <div\n ref={rootRef}\n className={cn(\n \"flex flex-col gap-2\",\n // Beside the rail the table and the rail are one panel: every band\n // squares its start corners against the rail's squared end ones.\n rail ? \"min-h-0 min-w-0 flex-1 [&>*]:rounded-s-none\" : props.className,\n )}\n >\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n isActive={(card) => isCardActive(card, filterValues)}\n onSelect={form && filterDefinition ? selectCard : undefined}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n headerPopup={props.headerPopup}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary ? \"-mt-2 rounded-t-none border-t-0\" : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n // `bg-card`: the rows are content between the chrome bands, and\n // keep their own surface on a muted page (a Plate's body) instead\n // of taking the chrome's colour through a transparent panel.\n \"bg-card flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table\n className={cn(\n isEmptyState && \"h-full\",\n compact && \"text-xs [&_th]:text-xs\",\n )}\n >\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over.\n\n The lines sit on the cells, not on the `<thead>`: WebKit paints\n no `box-shadow` on a table section, so on Safari the header had\n no bottom line at all. Not `chrome` either, for the same reason,\n and because `cn` does not know `chrome` is a background: it kept\n `TableHeader`'s `bg-muted/50` beside it, which won. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow draws the\n // same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 [&_th]:shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n headerFilter={headerFilter}\n headerPopup={headerPopup}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n leaving={overlay.leaving}\n flash={overlay.flash}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n filtersAtDefault={filtersAtDefault}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n rowActionsDisplay={props.rowActionsDisplay}\n striped={props.striped}\n onRowClick={props.onRowClick}\n isRowActive={props.isRowActive}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n groupBy={props.groupBy}\n groupCounts={groupCounts}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {compactPager && <DataTableCompactPager meta={meta} setPage={setPage} />}\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(squareRight?.bottom, flatBottom, props.chromeClassName)}\n />\n )}\n </div>\n );\n\n return (\n <ClientOnly>\n {rail ? (\n <div className={cn(\"flex min-h-0\", props.className)}>\n {rail}\n {table}\n </div>\n ) : (\n table\n )}\n </ClientOnly>\n );\n};\n\n/**\n * Whether every filter value a summary tile stands for holds now. Compared\n * as JSON, so an array value matches the same members in the same order; an\n * `undefined` value (the tile clears that filter) holds while the field is\n * empty: unset, `\"\"` or an emptied multi-select.\n */\nconst isCardActive = (\n card: DataTableStatCard,\n values: Record<string, unknown>,\n): boolean => {\n if (!card.filter) return false;\n const entries = Object.entries(card.filter);\n const empty = (value: unknown) =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n return (\n entries.length > 0 &&\n entries.every(([key, value]) =>\n value === undefined\n ? empty(values[key])\n : JSON.stringify(values[key]) === JSON.stringify(value),\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI,KAAA,IAAY,MAAM;CAKpD,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,aAAa,MAAM,kBAAkB,CACpE;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;;;;;;;;;;;CAWvB,MAAM,WAAW,YAAY;CAE7B,MAAM,EAAE,MAAM,YAAY,qBAAqB,uBAAuB;EACpE,OAAO;EACP;EACA;CACF,CAAC;CAKD,MAAM,kBAAkB,OAAO,QAAQ,SAAS,QAAQ;CACxD,gBAAgB,UAAU,QAAQ,SAAS;CAG3C,MAAM,CAAC,cAAc,mBAAmB,gBAC/B,EAAE,GAAG,MAAM,cAAc,EAClC;CACA,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,gBAAgB,UAAU,EAAE,GAAG,KAAK,cAAc,CAAC;EAG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C,iBAAD;IACE,WAAW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GAAG,aAAa,QAAQ,YAAY,MAAM,eAAe;GACrE,CAAA;EAEA;;CAGP,OACE,oBAAC,YAAD,EAAA,UACG,OACC,qBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,MAAM,SAAS;EAAlD,UAAA,CACG,MACA,KACE;CAEL,CAAA,IAAA,MAEQ,CAAA;AAEhB;;;;;;;AAQA,MAAM,gBACJ,MACA,WACY;CACZ,IAAI,CAAC,KAAK,QAAQ,OAAO;CACzB,MAAM,UAAU,OAAO,QAAQ,KAAK,MAAM;CAC1C,MAAM,SAAS,UACb,UAAU,KAAA,KACV,UAAU,QACV,UAAU,MACT,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;CAC5C,OACE,QAAQ,SAAS,KACjB,QAAQ,OAAO,CAAC,KAAK,WACnB,UAAU,KAAA,IACN,MAAM,OAAO,IAAI,IACjB,KAAK,UAAU,OAAO,IAAI,MAAM,KAAK,UAAU,KAAK,CAC1D;AAEJ"}
@@ -0,0 +1,23 @@
1
+ import type { RowActionContext, RowActionEntry, RowActionGroup } from "./dataTableTypes.ts";
2
+ export interface DataTableRowActionGroupItemProps<T> {
3
+ group: RowActionGroup<T>;
4
+ item: T;
5
+ ctx: RowActionContext;
6
+ }
7
+ /**
8
+ * A row action group as a submenu: its trigger, then its children, each an
9
+ * action or a group of its own, drawn the same way one level further in.
10
+ * An empty child group is left out, as the row menu leaves out an empty
11
+ * group.
12
+ */
13
+ export declare const DataTableRowActionGroupItem: <T>(props: DataTableRowActionGroupItemProps<T>) => import("react").JSX.Element;
14
+ /**
15
+ * Whether an entry is a group rather than an action: it has `children`.
16
+ */
17
+ export declare function isRowActionGroup<T>(entry: RowActionEntry<T>): entry is RowActionGroup<T>;
18
+ /**
19
+ * Whether an entry holds anything to click: an action does, a group does
20
+ * when one of its children does, at any depth.
21
+ */
22
+ export declare function hasRowAction<T>(entry: RowActionEntry<T>): boolean;
23
+ //# sourceMappingURL=DataTableRowActionGroupItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableRowActionGroupItem.d.ts","sourceRoot":"","sources":["../../src/table/DataTableRowActionGroupItem.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,gCAAgC,CAAC,CAAC;IACjD,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,gBAAgB,CAAC;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,CAAC,SACpC,gCAAgC,CAAC,CAAC,CAAC,gCAgC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GACvB,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,CAE5B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAEjE"}
@@ -0,0 +1,38 @@
1
+ import { DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from "../core/DropdownMenu.js";
2
+ import { DataTableRowActionItem } from "./DataTableRowActionItem.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/table/DataTableRowActionGroupItem.tsx
5
+ /**
6
+ * A row action group as a submenu: its trigger, then its children, each an
7
+ * action or a group of its own, drawn the same way one level further in.
8
+ * An empty child group is left out, as the row menu leaves out an empty
9
+ * group.
10
+ */
11
+ const DataTableRowActionGroupItem = (props) => {
12
+ const Icon = props.group.icon;
13
+ return /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [Icon && /* @__PURE__ */ jsx(Icon, { className: "me-2 size-4" }), props.group.label] }), /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: props.group.children.filter(hasRowAction).map((child) => isRowActionGroup(child) ? /* @__PURE__ */ jsx(DataTableRowActionGroupItem, {
14
+ group: child,
15
+ item: props.item,
16
+ ctx: props.ctx
17
+ }, child.label) : /* @__PURE__ */ jsx(DataTableRowActionItem, {
18
+ action: child,
19
+ item: props.item,
20
+ ctx: props.ctx
21
+ }, child.label)) })] });
22
+ };
23
+ /**
24
+ * Whether an entry is a group rather than an action: it has `children`.
25
+ */
26
+ function isRowActionGroup(entry) {
27
+ return "children" in entry;
28
+ }
29
+ /**
30
+ * Whether an entry holds anything to click: an action does, a group does
31
+ * when one of its children does, at any depth.
32
+ */
33
+ function hasRowAction(entry) {
34
+ return isRowActionGroup(entry) ? entry.children.some(hasRowAction) : true;
35
+ }
36
+ export { DataTableRowActionGroupItem, hasRowAction, isRowActionGroup };
37
+
38
+ //# sourceMappingURL=DataTableRowActionGroupItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableRowActionGroupItem.js","names":[],"sources":["../../src/table/DataTableRowActionGroupItem.tsx"],"sourcesContent":["import {\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"../core/DropdownMenu.tsx\";\nimport { DataTableRowActionItem } from \"./DataTableRowActionItem.tsx\";\nimport type {\n RowActionContext,\n RowActionEntry,\n RowActionGroup,\n} from \"./dataTableTypes.ts\";\n\nexport interface DataTableRowActionGroupItemProps<T> {\n group: RowActionGroup<T>;\n item: T;\n ctx: RowActionContext;\n}\n\n/**\n * A row action group as a submenu: its trigger, then its children, each an\n * action or a group of its own, drawn the same way one level further in.\n * An empty child group is left out, as the row menu leaves out an empty\n * group.\n */\nexport const DataTableRowActionGroupItem = <T,>(\n props: DataTableRowActionGroupItemProps<T>,\n) => {\n const Icon = props.group.icon;\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n {Icon && <Icon className=\"me-2 size-4\" />}\n {props.group.label}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n {props.group.children\n .filter(hasRowAction)\n .map((child) =>\n isRowActionGroup(child) ? (\n <DataTableRowActionGroupItem\n key={child.label}\n group={child}\n item={props.item}\n ctx={props.ctx}\n />\n ) : (\n <DataTableRowActionItem\n key={child.label}\n action={child}\n item={props.item}\n ctx={props.ctx}\n />\n ),\n )}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n};\n\n/**\n * Whether an entry is a group rather than an action: it has `children`.\n */\nexport function isRowActionGroup<T>(\n entry: RowActionEntry<T>,\n): entry is RowActionGroup<T> {\n return \"children\" in entry;\n}\n\n/**\n * Whether an entry holds anything to click: an action does, a group does\n * when one of its children does, at any depth.\n */\nexport function hasRowAction<T>(entry: RowActionEntry<T>): boolean {\n return isRowActionGroup(entry) ? entry.children.some(hasRowAction) : true;\n}\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,+BACX,UACG;CACH,MAAM,OAAO,MAAM,MAAM;CACzB,OACE,qBAAC,iBAAD,EAAA,UAAA,CACE,qBAAC,wBAAD,EAAA,UAAA,CACG,QAAQ,oBAAC,MAAD,EAAM,WAAU,cAAe,CAAA,GACvC,MAAM,MAAM,KACS,EAAA,CAAA,GACxB,oBAAC,wBAAD,EAAA,UACG,MAAM,MAAM,SACV,OAAO,YAAY,CAAC,CACpB,KAAK,UACJ,iBAAiB,KAAK,IACpB,oBAAC,6BAAD;EAEE,OAAO;EACP,MAAM,MAAM;EACZ,KAAK,MAAM;CACZ,GAJM,MAAM,KAIZ,IAED,oBAAC,wBAAD;EAEE,QAAQ;EACR,MAAM,MAAM;EACZ,KAAK,MAAM;CACZ,GAJM,MAAM,KAIZ,CAEL,EACoB,CAAA,CACT,EAAA,CAAA;AAErB;;;;AAKA,SAAgB,iBACd,OAC4B;CAC5B,OAAO,cAAc;AACvB;;;;;AAMA,SAAgB,aAAgB,OAAmC;CACjE,OAAO,iBAAiB,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,IAAI;AACvE"}