@adapttable/mantine 0.1.1 → 0.2.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.
- package/CHANGELOG.md +34 -0
- package/dist/index.cjs +1902 -1932
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +197 -151
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +197 -150
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1848 -1900
- package/dist/index.js.map +1 -1
- package/package.json +17 -15
package/dist/index.js
CHANGED
|
@@ -1,1952 +1,1900 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ACTIONS_COLUMN_KEY, EyeIcon, GripIcon, PIN_Z, PinIcon, RANGE_OPS, RANGE_OP_LABEL_KEYS, RANGE_SUFFIXES, columnMenuRows, columnReorderKeyProps, columnResizeHandleProps, createHistoryAdapter, createMemoryAdapter, defaultConfirm, defaultLabels, deriveSortByOptions, edgePinStyle, filterLabel, getHistoryAdapter, headerGroupRow, isDeclarativeFilters, nextPinSide, pageSizeOptions, pinActionLabel, pinnedCellStyle, pinnedColumnWidth, readRangeWidget, resolveDisabledReason, resolveLabels, rowClickProps, runRowAction, tableMinWidth, tableRenderModel, useBackendData, useBulkActionRunner, useChromeBodyData, useChromeScrollReset, useColumnDragState, useDataTable, useFilterOptions, useFilterTriggerToggle, useFrontendData, useHorizontalOverflow, usePrefersReducedMotion, useSavedViews, useSavedViews as useSavedViews$1, useTableChrome, useTableData, useTableUrlState, writeRangeWidget } from "@adapttable/core";
|
|
2
|
+
import { ActionIcon, Alert, Anchor, Badge, Box, Button, Card, Checkbox, Drawer, Group, Input, Loader, Menu, NativeSelect, NumberInput, Pagination, Paper, Pill, Popover, Progress, Select, Skeleton, Stack, Table, Text, TextInput, Tooltip, VisuallyHidden } from "@mantine/core";
|
|
3
|
+
import { useElementSize } from "@mantine/hooks";
|
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/animation/useMountStagger.ts
|
|
7
|
+
/**
|
|
8
|
+
* Dependency-free entrance stagger using the Web Animations API. Animates
|
|
9
|
+
* descendants marked with `data-stagger` once on mount (and whenever
|
|
10
|
+
* `deps` change), honoring `prefers-reduced-motion`. Works without GSAP;
|
|
11
|
+
* GSAP fans can swap in their own hook of the same shape.
|
|
12
|
+
*
|
|
13
|
+
* @param ref - Ref to the container whose `[data-stagger]` items animate.
|
|
14
|
+
* @param deps - Re-run the stagger when these change (e.g. the row set).
|
|
15
|
+
* @param options - See {@link MountStaggerOptions}.
|
|
16
|
+
*/
|
|
9
17
|
function useMountStagger(ref, deps, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
const reduced = usePrefersReducedMotion();
|
|
19
|
+
const { enabled, step = 40, duration = 320 } = options;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!enabled || reduced) return;
|
|
22
|
+
const root = ref.current;
|
|
23
|
+
if (!root) return;
|
|
24
|
+
root.querySelectorAll("[data-stagger]").forEach((el, index) => {
|
|
25
|
+
if (typeof el.animate !== "function") return;
|
|
26
|
+
el.animate([{
|
|
27
|
+
opacity: 0,
|
|
28
|
+
transform: "translateY(8px)"
|
|
29
|
+
}, {
|
|
30
|
+
opacity: 1,
|
|
31
|
+
transform: "translateY(0)"
|
|
32
|
+
}], {
|
|
33
|
+
duration,
|
|
34
|
+
delay: index * step,
|
|
35
|
+
easing: "cubic-bezier(0.16, 1, 0.3, 1)",
|
|
36
|
+
fill: "both"
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}, [
|
|
40
|
+
enabled,
|
|
41
|
+
reduced,
|
|
42
|
+
step,
|
|
43
|
+
duration,
|
|
44
|
+
ref,
|
|
45
|
+
deps.map(String).join("|")
|
|
46
|
+
]);
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Anchor,
|
|
65
|
-
{
|
|
66
|
-
component: "button",
|
|
67
|
-
type: "button",
|
|
68
|
-
fz: "xs",
|
|
69
|
-
fw: 600,
|
|
70
|
-
onClick: onClearAll,
|
|
71
|
-
children: clearAllLabel
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
);
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/ActiveFilterChips.tsx
|
|
50
|
+
/** A wrapping strip of removable filter chips. Renders nothing when empty. */
|
|
51
|
+
function ActiveFilterChips({ chips, onClearAll, label, clearAllLabel }) {
|
|
52
|
+
if (chips.length === 0) return null;
|
|
53
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
54
|
+
gap: 6,
|
|
55
|
+
"aria-label": label,
|
|
56
|
+
component: "ul",
|
|
57
|
+
style: {
|
|
58
|
+
listStyle: "none",
|
|
59
|
+
padding: 0,
|
|
60
|
+
margin: 0
|
|
61
|
+
},
|
|
62
|
+
children: [chips.map((chip) => /* @__PURE__ */ jsx(Pill, {
|
|
63
|
+
component: "li",
|
|
64
|
+
withRemoveButton: true,
|
|
65
|
+
onRemove: chip.onRemove,
|
|
66
|
+
removeButtonProps: { "aria-label": `${clearAllLabel}: ${chip.label}` },
|
|
67
|
+
children: chip.label
|
|
68
|
+
}, chip.key)), onClearAll && /* @__PURE__ */ jsx(Anchor, {
|
|
69
|
+
component: "button",
|
|
70
|
+
type: "button",
|
|
71
|
+
fz: "xs",
|
|
72
|
+
fw: 600,
|
|
73
|
+
onClick: onClearAll,
|
|
74
|
+
children: clearAllLabel
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/AutoFilterForm.tsx
|
|
80
|
+
/** A scalar filter value as input text (`""` when unset). */
|
|
81
|
+
const asText = (value) => value == null ? "" : String(value);
|
|
82
|
+
/** A multi-select value as an array, tolerating a scalar from the URL. */
|
|
83
|
+
const asList = (value) => {
|
|
84
|
+
if (value == null || value === "") return [];
|
|
85
|
+
return Array.isArray(value) ? value : [String(value)];
|
|
86
|
+
};
|
|
87
|
+
/** The select's raw option value parsed back to a known operator. */
|
|
88
|
+
const asOp = (value) => RANGE_OPS.find((op) => op === value);
|
|
89
|
+
/** Which operator label set each range type reads. */
|
|
90
|
+
const RANGE_FLAVOUR = {
|
|
91
|
+
numberRange: "number",
|
|
92
|
+
dateRange: "date"
|
|
82
93
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
] });
|
|
94
|
+
/**
|
|
95
|
+
* The operator-first control shared by the `numberRange` / `dateRange`
|
|
96
|
+
* types: pick a comparison (Equal / At least / …), then fill ONE value —
|
|
97
|
+
* or From/To when "Between". The persisted state stays the inclusive
|
|
98
|
+
* `Min`/`Max` (`From`/`To`) pair via {@link readRangeWidget} /
|
|
99
|
+
* {@link writeRangeWidget}, so URLs, chips and predicates are unchanged.
|
|
100
|
+
*/
|
|
101
|
+
function RangeField({ def, source, kind, labels }) {
|
|
102
|
+
const label = filterLabel(def);
|
|
103
|
+
const lowKey = def.key + RANGE_SUFFIXES[kind].start;
|
|
104
|
+
const highKey = def.key + RANGE_SUFFIXES[kind].end;
|
|
105
|
+
const derived = readRangeWidget(source.extra, lowKey, highKey);
|
|
106
|
+
const [chosen, setChosen] = useState(null);
|
|
107
|
+
const op = chosen ?? derived.op ?? null;
|
|
108
|
+
const low = asText(source.extra[lowKey]);
|
|
109
|
+
const high = asText(source.extra[highKey]);
|
|
110
|
+
/** The one visible value outside "Between" (`lte` stores the upper bound). */
|
|
111
|
+
const single = op === "lte" ? high : low;
|
|
112
|
+
const write = (nextOp, a, b) => source.setExtras(writeRangeWidget(nextOp, a, b, lowKey, highKey));
|
|
113
|
+
const handleOp = (value) => {
|
|
114
|
+
const next = asOp(value);
|
|
115
|
+
setChosen(next ?? null);
|
|
116
|
+
write(next, single, "");
|
|
117
|
+
};
|
|
118
|
+
const flavour = RANGE_FLAVOUR[kind];
|
|
119
|
+
const opLabelKeys = RANGE_OP_LABEL_KEYS[flavour];
|
|
120
|
+
const data = RANGE_OPS.map((value) => ({
|
|
121
|
+
value,
|
|
122
|
+
label: labels[opLabelKeys[value]]
|
|
123
|
+
}));
|
|
124
|
+
const valueInput = (text, value, commit) => flavour === "number" ? /* @__PURE__ */ jsx(NumberInput, {
|
|
125
|
+
size: "sm",
|
|
126
|
+
hideControls: true,
|
|
127
|
+
style: {
|
|
128
|
+
flex: "1 1 6rem",
|
|
129
|
+
minWidth: "6rem"
|
|
130
|
+
},
|
|
131
|
+
"aria-label": `${label} ${text}`,
|
|
132
|
+
placeholder: text,
|
|
133
|
+
value,
|
|
134
|
+
onChange: (next) => commit(String(next))
|
|
135
|
+
}) : /* @__PURE__ */ jsx(TextInput, {
|
|
136
|
+
type: "date",
|
|
137
|
+
size: "sm",
|
|
138
|
+
style: {
|
|
139
|
+
flex: "1 1 8.5rem",
|
|
140
|
+
minWidth: "8.5rem"
|
|
141
|
+
},
|
|
142
|
+
"aria-label": `${label} ${text}`,
|
|
143
|
+
placeholder: text,
|
|
144
|
+
value,
|
|
145
|
+
onChange: (e) => commit(e.currentTarget.value)
|
|
146
|
+
});
|
|
147
|
+
let values = null;
|
|
148
|
+
if (op === "between") values = /* @__PURE__ */ jsxs(Fragment, { children: [valueInput(labels.from, low, (next) => write("between", next, high)), valueInput(labels.to, high, (next) => write("between", low, next))] });
|
|
149
|
+
else if (op) values = valueInput(labels.value, single, (next) => write(op, next, ""));
|
|
150
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
151
|
+
gap: 4,
|
|
152
|
+
children: [/* @__PURE__ */ jsx(Input.Label, {
|
|
153
|
+
size: "sm",
|
|
154
|
+
children: label
|
|
155
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
156
|
+
gap: "xs",
|
|
157
|
+
align: "flex-start",
|
|
158
|
+
children: [/* @__PURE__ */ jsx(Select, {
|
|
159
|
+
size: "sm",
|
|
160
|
+
clearable: true,
|
|
161
|
+
style: {
|
|
162
|
+
flex: "0 0 8.5rem",
|
|
163
|
+
width: "8.5rem"
|
|
164
|
+
},
|
|
165
|
+
"aria-label": `${label} ${labels.operator}`,
|
|
166
|
+
placeholder: labels.operator,
|
|
167
|
+
data,
|
|
168
|
+
value: op,
|
|
169
|
+
onChange: handleOp,
|
|
170
|
+
comboboxProps: { withinPortal: false }
|
|
171
|
+
}), values]
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
164
174
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Single-choice control. Options resolve through {@link useFilterOptions}
|
|
177
|
+
* (static array, async loader, or none); while a loader is in flight the
|
|
178
|
+
* select shows one disabled placeholder option.
|
|
179
|
+
*/
|
|
180
|
+
function SelectControl({ def, source }) {
|
|
181
|
+
const label = filterLabel(def);
|
|
182
|
+
const { options, loading } = useFilterOptions(def);
|
|
183
|
+
return /* @__PURE__ */ jsx(NativeSelect, {
|
|
184
|
+
size: "sm",
|
|
185
|
+
label,
|
|
186
|
+
data: loading ? [{
|
|
187
|
+
value: "",
|
|
188
|
+
label: "…",
|
|
189
|
+
disabled: true
|
|
190
|
+
}] : [{
|
|
191
|
+
value: "",
|
|
192
|
+
label: "All"
|
|
193
|
+
}, ...options],
|
|
194
|
+
value: asText(source.extra[def.key]),
|
|
195
|
+
onChange: (e) => source.setExtra(def.key, e.currentTarget.value)
|
|
196
|
+
});
|
|
182
197
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
);
|
|
198
|
+
/**
|
|
199
|
+
* Multi-choice control. Options resolve through {@link useFilterOptions};
|
|
200
|
+
* while a loader is in flight the group shows a small spinner instead of
|
|
201
|
+
* checkboxes.
|
|
202
|
+
*/
|
|
203
|
+
function MultiSelectControl({ def, source }) {
|
|
204
|
+
const label = filterLabel(def);
|
|
205
|
+
const { options, loading } = useFilterOptions(def);
|
|
206
|
+
return /* @__PURE__ */ jsx(Checkbox.Group, {
|
|
207
|
+
label,
|
|
208
|
+
value: asList(source.extra[def.key]),
|
|
209
|
+
onChange: (values) => source.setExtra(def.key, values),
|
|
210
|
+
children: /* @__PURE__ */ jsx(Group, {
|
|
211
|
+
gap: "sm",
|
|
212
|
+
mt: 4,
|
|
213
|
+
children: loading ? /* @__PURE__ */ jsx(Loader, { size: "xs" }) : options.map((option) => /* @__PURE__ */ jsx(Checkbox, {
|
|
214
|
+
size: "sm",
|
|
215
|
+
value: option.value,
|
|
216
|
+
label: option.label
|
|
217
|
+
}, option.value))
|
|
218
|
+
})
|
|
219
|
+
});
|
|
206
220
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
221
|
+
/** One labeled, kit-native control for a single filter definition. */
|
|
222
|
+
function FilterControl({ def, source, labels }) {
|
|
223
|
+
switch (def.type) {
|
|
224
|
+
case "text": return /* @__PURE__ */ jsx(TextInput, {
|
|
225
|
+
size: "sm",
|
|
226
|
+
label: filterLabel(def),
|
|
227
|
+
placeholder: def.placeholder,
|
|
228
|
+
value: asText(source.extra[def.key]),
|
|
229
|
+
onChange: (e) => source.setExtra(def.key, e.currentTarget.value)
|
|
230
|
+
});
|
|
231
|
+
case "select": return /* @__PURE__ */ jsx(SelectControl, {
|
|
232
|
+
def,
|
|
233
|
+
source
|
|
234
|
+
});
|
|
235
|
+
case "multiSelect": return /* @__PURE__ */ jsx(MultiSelectControl, {
|
|
236
|
+
def,
|
|
237
|
+
source
|
|
238
|
+
});
|
|
239
|
+
case "dateRange":
|
|
240
|
+
case "numberRange": return /* @__PURE__ */ jsx(RangeField, {
|
|
241
|
+
def,
|
|
242
|
+
source,
|
|
243
|
+
kind: def.type,
|
|
244
|
+
labels
|
|
245
|
+
});
|
|
246
|
+
}
|
|
232
247
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
248
|
+
/**
|
|
249
|
+
* The auto-built filter form: one labeled, Mantine-native control per
|
|
250
|
+
* declarative {@link FilterDef}. Values live in the source's `extra` bag
|
|
251
|
+
* (so the URL, chips and — on frontend data — the predicate all follow);
|
|
252
|
+
* clearing a control writes the empty value, which drops the URL param.
|
|
253
|
+
* Range types render operator-first: an operator select plus one value
|
|
254
|
+
* input (two for "Between"), persisted as the inclusive pair.
|
|
255
|
+
*
|
|
256
|
+
* @typeParam TRow - The row type.
|
|
257
|
+
*/
|
|
258
|
+
function AutoFilterForm({ defs, source, labels }) {
|
|
259
|
+
return /* @__PURE__ */ jsx(Stack, {
|
|
260
|
+
gap: "sm",
|
|
261
|
+
children: defs.map((def) => /* @__PURE__ */ jsx(FilterControl, {
|
|
262
|
+
def,
|
|
263
|
+
source,
|
|
264
|
+
labels
|
|
265
|
+
}, def.key))
|
|
266
|
+
});
|
|
247
267
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/components/BulkActionBar.tsx
|
|
270
|
+
/** Selection toolbar: count, clear, and the configured bulk-action buttons. */
|
|
271
|
+
function BulkActionBar({ selection, total, bulkActions, confirm, labels }) {
|
|
272
|
+
const { selectedIds, selectedCount, clear, allMatching } = selection;
|
|
273
|
+
const { pending, run } = useBulkActionRunner({
|
|
274
|
+
confirm,
|
|
275
|
+
cancelLabel: labels.cancel,
|
|
276
|
+
onComplete: clear
|
|
277
|
+
});
|
|
278
|
+
if (selectedCount === 0) return null;
|
|
279
|
+
const ids = [...selectedIds];
|
|
280
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
281
|
+
gap: "xs",
|
|
282
|
+
children: [/* @__PURE__ */ jsxs(Group, {
|
|
283
|
+
justify: "space-between",
|
|
284
|
+
wrap: "wrap",
|
|
285
|
+
gap: "sm",
|
|
286
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
287
|
+
fz: "sm",
|
|
288
|
+
children: labels.selectedCount(selectedCount)
|
|
289
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
290
|
+
gap: "xs",
|
|
291
|
+
wrap: "wrap",
|
|
292
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
293
|
+
size: "xs",
|
|
294
|
+
variant: "subtle",
|
|
295
|
+
onClick: clear,
|
|
296
|
+
disabled: pending !== null,
|
|
297
|
+
children: labels.clearAll
|
|
298
|
+
}), bulkActions.map((action) => /* @__PURE__ */ jsx(BulkButton, {
|
|
299
|
+
action,
|
|
300
|
+
ids,
|
|
301
|
+
pending,
|
|
302
|
+
onRun: (a) => {
|
|
303
|
+
if (allMatching) run(a, ids, {
|
|
304
|
+
allMatching: true,
|
|
305
|
+
total
|
|
306
|
+
});
|
|
307
|
+
else run(a, ids);
|
|
308
|
+
}
|
|
309
|
+
}, action.key))]
|
|
310
|
+
})]
|
|
311
|
+
}), /* @__PURE__ */ jsx(ScopeBanner, {
|
|
312
|
+
selection,
|
|
313
|
+
total,
|
|
314
|
+
labels
|
|
315
|
+
})]
|
|
316
|
+
});
|
|
294
317
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Gmail-style scope banner. When every row on the page is selected but more
|
|
320
|
+
* rows match elsewhere, offer to widen the selection to all matching rows;
|
|
321
|
+
* once widened, announce the scope and offer to clear it.
|
|
322
|
+
*/
|
|
323
|
+
function ScopeBanner({ selection, total, labels }) {
|
|
324
|
+
if (selection.headerState !== "all" || total <= selection.visibleIds.length) return null;
|
|
325
|
+
return /* @__PURE__ */ jsx(Group, {
|
|
326
|
+
role: "status",
|
|
327
|
+
gap: "xs",
|
|
328
|
+
wrap: "wrap",
|
|
329
|
+
children: selection.allMatching ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
|
|
330
|
+
fz: "sm",
|
|
331
|
+
children: labels.allMatchingSelected(total)
|
|
332
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
333
|
+
size: "xs",
|
|
334
|
+
variant: "subtle",
|
|
335
|
+
onClick: selection.clear,
|
|
336
|
+
children: labels.clearAll
|
|
337
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
|
|
338
|
+
fz: "sm",
|
|
339
|
+
children: labels.pageSelected(selection.selectedCount)
|
|
340
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
341
|
+
size: "xs",
|
|
342
|
+
variant: "light",
|
|
343
|
+
onClick: selection.selectAllMatching,
|
|
344
|
+
children: labels.selectAllMatching(total)
|
|
345
|
+
})] })
|
|
346
|
+
});
|
|
318
347
|
}
|
|
319
|
-
function BulkButton({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
);
|
|
339
|
-
if (reason !== void 0) {
|
|
340
|
-
return /* @__PURE__ */ jsx(Tooltip, { label: reason, withArrow: true, openDelay: 150, children: /* @__PURE__ */ jsx("div", { children: button }) });
|
|
341
|
-
}
|
|
342
|
-
return button;
|
|
348
|
+
function BulkButton({ action, ids, pending, onRun }) {
|
|
349
|
+
const reason = resolveDisabledReason(action.disabledReason?.(ids));
|
|
350
|
+
const ineligible = reason !== void 0;
|
|
351
|
+
const button = /* @__PURE__ */ jsx(Button, {
|
|
352
|
+
size: "xs",
|
|
353
|
+
color: action.color,
|
|
354
|
+
leftSection: action.icon,
|
|
355
|
+
onClick: () => onRun(action),
|
|
356
|
+
loading: pending === action.key,
|
|
357
|
+
disabled: ineligible || pending !== null && pending !== action.key,
|
|
358
|
+
children: action.label
|
|
359
|
+
});
|
|
360
|
+
if (reason !== void 0) return /* @__PURE__ */ jsx(Tooltip, {
|
|
361
|
+
label: reason,
|
|
362
|
+
withArrow: true,
|
|
363
|
+
openDelay: 150,
|
|
364
|
+
children: /* @__PURE__ */ jsx("div", { children: button })
|
|
365
|
+
});
|
|
366
|
+
return button;
|
|
343
367
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
/* @__PURE__ */ jsx(
|
|
364
|
-
Text,
|
|
365
|
-
{
|
|
366
|
-
size: "sm",
|
|
367
|
-
style: { flex: 1 },
|
|
368
|
-
c: hidden ? "dimmed" : void 0,
|
|
369
|
-
td: hidden ? "line-through" : void 0,
|
|
370
|
-
children: name
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
] });
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/components/ColumnMenu.tsx
|
|
370
|
+
/** The eye toggle + struck-through name shared by data and actions rows. */
|
|
371
|
+
function RowVisibility({ hidden, name, labels, onToggle }) {
|
|
372
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActionIcon, {
|
|
373
|
+
variant: hidden ? "subtle" : "light",
|
|
374
|
+
color: hidden ? "gray" : "blue",
|
|
375
|
+
size: "sm",
|
|
376
|
+
"aria-label": `${hidden ? labels.showColumn : labels.hideColumn}: ${name}`,
|
|
377
|
+
"aria-pressed": !hidden,
|
|
378
|
+
onClick: onToggle,
|
|
379
|
+
children: /* @__PURE__ */ jsx(EyeIcon, { off: hidden })
|
|
380
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
381
|
+
size: "sm",
|
|
382
|
+
style: { flex: 1 },
|
|
383
|
+
c: hidden ? "dimmed" : void 0,
|
|
384
|
+
td: hidden ? "line-through" : void 0,
|
|
385
|
+
children: name
|
|
386
|
+
})] });
|
|
374
387
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
size: "sm",
|
|
386
|
-
"aria-label": label,
|
|
387
|
-
onClick,
|
|
388
|
-
children: /* @__PURE__ */ jsx(PinIcon, {})
|
|
389
|
-
}
|
|
390
|
-
);
|
|
388
|
+
/** The pin control shared by data and actions rows. */
|
|
389
|
+
function PinToggle({ pinned, label, onClick }) {
|
|
390
|
+
return /* @__PURE__ */ jsx(ActionIcon, {
|
|
391
|
+
variant: pinned ? "filled" : "subtle",
|
|
392
|
+
color: pinned ? "blue" : "gray",
|
|
393
|
+
size: "sm",
|
|
394
|
+
"aria-label": label,
|
|
395
|
+
onClick,
|
|
396
|
+
children: /* @__PURE__ */ jsx(PinIcon, {})
|
|
397
|
+
});
|
|
391
398
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
399
|
+
/**
|
|
400
|
+
* The injected actions column's menu row: the same eye toggle as data
|
|
401
|
+
* columns plus a pin toggle that flips right ↔ unpinned in one click. No
|
|
402
|
+
* drag grip (the column always trails) and no left pin.
|
|
403
|
+
*/
|
|
404
|
+
function ActionsRow({ layout, labels }) {
|
|
405
|
+
const hidden = layout.isHidden(ACTIONS_COLUMN_KEY);
|
|
406
|
+
const pinned = layout.state.pinned[ACTIONS_COLUMN_KEY] === "right";
|
|
407
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
408
|
+
justify: "flex-start",
|
|
409
|
+
wrap: "nowrap",
|
|
410
|
+
gap: 6,
|
|
411
|
+
px: 4,
|
|
412
|
+
py: 2,
|
|
413
|
+
children: [
|
|
414
|
+
/* @__PURE__ */ jsx(Box, { w: 22 }),
|
|
415
|
+
/* @__PURE__ */ jsx(RowVisibility, {
|
|
416
|
+
hidden,
|
|
417
|
+
name: labels.actions,
|
|
418
|
+
labels,
|
|
419
|
+
onToggle: () => layout.toggleVisible(ACTIONS_COLUMN_KEY)
|
|
420
|
+
}),
|
|
421
|
+
/* @__PURE__ */ jsx(PinToggle, {
|
|
422
|
+
pinned,
|
|
423
|
+
label: `${pinned ? labels.unpin : labels.pinRight}: ${labels.actions}`,
|
|
424
|
+
onClick: () => layout.setPinned(ACTIONS_COLUMN_KEY, pinned ? void 0 : "right")
|
|
425
|
+
})
|
|
426
|
+
]
|
|
427
|
+
});
|
|
418
428
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
)
|
|
505
|
-
] }) })
|
|
506
|
-
] });
|
|
429
|
+
/**
|
|
430
|
+
* Column-management popover: per-column drag grip (reorder), eye (show/hide),
|
|
431
|
+
* and pin toggle. Keyboard users focus a grip and use arrow keys.
|
|
432
|
+
*/
|
|
433
|
+
function ColumnMenu({ allColumns, layout, labels, hasRowActions = false }) {
|
|
434
|
+
const drag = useColumnDragState();
|
|
435
|
+
return /* @__PURE__ */ jsxs(Menu, {
|
|
436
|
+
closeOnItemClick: false,
|
|
437
|
+
position: "bottom-end",
|
|
438
|
+
withinPortal: true,
|
|
439
|
+
children: [/* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(Button, {
|
|
440
|
+
variant: "default",
|
|
441
|
+
size: "sm",
|
|
442
|
+
children: labels.columns
|
|
443
|
+
}) }), /* @__PURE__ */ jsx(Menu.Dropdown, { children: /* @__PURE__ */ jsxs(Box, {
|
|
444
|
+
p: 4,
|
|
445
|
+
miw: 250,
|
|
446
|
+
children: [
|
|
447
|
+
/* @__PURE__ */ jsx(Text, {
|
|
448
|
+
size: "xs",
|
|
449
|
+
c: "dimmed",
|
|
450
|
+
fw: 600,
|
|
451
|
+
tt: "uppercase",
|
|
452
|
+
px: 4,
|
|
453
|
+
pb: 6,
|
|
454
|
+
children: labels.columns
|
|
455
|
+
}),
|
|
456
|
+
columnMenuRows(allColumns, layout).map((r) => {
|
|
457
|
+
const indicator = drag.rowAttrs(r.key, r.index);
|
|
458
|
+
const edge = indicator["data-drop"];
|
|
459
|
+
const edgeOffset = edge === "before" ? "2px" : "-2px";
|
|
460
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
461
|
+
justify: "flex-start",
|
|
462
|
+
wrap: "nowrap",
|
|
463
|
+
gap: 6,
|
|
464
|
+
px: 4,
|
|
465
|
+
py: 2,
|
|
466
|
+
style: {
|
|
467
|
+
cursor: "grab",
|
|
468
|
+
opacity: "data-dragging" in indicator ? .4 : void 0,
|
|
469
|
+
boxShadow: edge ? `inset 0 ${edgeOffset} 0 0 var(--mantine-primary-color-filled)` : void 0
|
|
470
|
+
},
|
|
471
|
+
...drag.rowDragProps(r.key, r.index),
|
|
472
|
+
...drag.dropProps(r.index, layout.move),
|
|
473
|
+
...indicator,
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ jsx(ActionIcon, {
|
|
476
|
+
variant: "subtle",
|
|
477
|
+
color: "gray",
|
|
478
|
+
size: "sm",
|
|
479
|
+
style: { cursor: "grab" },
|
|
480
|
+
...columnReorderKeyProps(r.key, r.index, layout.move, `${labels.moveLeft} / ${labels.moveRight}: ${r.name}`),
|
|
481
|
+
children: /* @__PURE__ */ jsx(GripIcon, {})
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ jsx(RowVisibility, {
|
|
484
|
+
hidden: r.hidden,
|
|
485
|
+
name: r.name,
|
|
486
|
+
labels,
|
|
487
|
+
onToggle: () => layout.toggleVisible(r.key)
|
|
488
|
+
}),
|
|
489
|
+
/* @__PURE__ */ jsx(PinToggle, {
|
|
490
|
+
pinned: r.pinned !== void 0,
|
|
491
|
+
label: `${pinActionLabel(r.pinned, labels)}: ${r.name}`,
|
|
492
|
+
onClick: () => layout.setPinned(r.key, nextPinSide(r.pinned))
|
|
493
|
+
})
|
|
494
|
+
]
|
|
495
|
+
}, r.key);
|
|
496
|
+
}),
|
|
497
|
+
hasRowActions && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Menu.Divider, {}), /* @__PURE__ */ jsx(ActionsRow, {
|
|
498
|
+
layout,
|
|
499
|
+
labels
|
|
500
|
+
})] }),
|
|
501
|
+
/* @__PURE__ */ jsx(Menu.Divider, {}),
|
|
502
|
+
/* @__PURE__ */ jsx(Button, {
|
|
503
|
+
variant: "subtle",
|
|
504
|
+
size: "xs",
|
|
505
|
+
fullWidth: true,
|
|
506
|
+
justify: "flex-start",
|
|
507
|
+
onClick: () => layout.reset(),
|
|
508
|
+
children: labels.resetColumns
|
|
509
|
+
})
|
|
510
|
+
]
|
|
511
|
+
}) })]
|
|
512
|
+
});
|
|
507
513
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/density.ts
|
|
516
|
+
/**
|
|
517
|
+
* Maps each {@link Density} to the Mantine `<Table>` spacing props.
|
|
518
|
+
* `comfortable` keeps the original `sm`/`md` rhythm; `compact` tightens
|
|
519
|
+
* rows with a 4px vertical gap and `sm` horizontal padding.
|
|
520
|
+
*/
|
|
521
|
+
const DENSITY_SPACING = {
|
|
522
|
+
comfortable: {
|
|
523
|
+
verticalSpacing: "sm",
|
|
524
|
+
horizontalSpacing: "md"
|
|
525
|
+
},
|
|
526
|
+
compact: {
|
|
527
|
+
verticalSpacing: 4,
|
|
528
|
+
horizontalSpacing: "sm"
|
|
529
|
+
}
|
|
513
530
|
};
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
style,
|
|
533
|
-
"aria-hidden": "true",
|
|
534
|
-
focusable: "false",
|
|
535
|
-
children
|
|
536
|
-
}
|
|
537
|
-
);
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/icons.tsx
|
|
533
|
+
function Svg({ size = 16, className, style, children }) {
|
|
534
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
535
|
+
width: size,
|
|
536
|
+
height: size,
|
|
537
|
+
viewBox: "0 0 24 24",
|
|
538
|
+
fill: "none",
|
|
539
|
+
stroke: "currentColor",
|
|
540
|
+
strokeWidth: 2,
|
|
541
|
+
strokeLinecap: "round",
|
|
542
|
+
strokeLinejoin: "round",
|
|
543
|
+
className,
|
|
544
|
+
style,
|
|
545
|
+
"aria-hidden": "true",
|
|
546
|
+
focusable: "false",
|
|
547
|
+
children
|
|
548
|
+
});
|
|
538
549
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
})
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
550
|
+
/** Magnifying-glass search icon. */
|
|
551
|
+
const SearchIcon = (p) => /* @__PURE__ */ jsxs(Svg, {
|
|
552
|
+
...p,
|
|
553
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
554
|
+
cx: "11",
|
|
555
|
+
cy: "11",
|
|
556
|
+
r: "7"
|
|
557
|
+
}), /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })]
|
|
558
|
+
});
|
|
559
|
+
/** Up chevron (active ascending sort). */
|
|
560
|
+
const ChevronUpIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
561
|
+
...p,
|
|
562
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 15 6-6 6 6" })
|
|
563
|
+
});
|
|
564
|
+
/** Down chevron (active descending sort). */
|
|
565
|
+
const ChevronDownIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
566
|
+
...p,
|
|
567
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
568
|
+
});
|
|
569
|
+
/** Right chevron (collapsed row-detail toggle; rotates 90° when expanded). */
|
|
570
|
+
const ChevronRightIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
571
|
+
...p,
|
|
572
|
+
children: /* @__PURE__ */ jsx("path", { d: "m9 6 6 6-6 6" })
|
|
573
|
+
});
|
|
574
|
+
/** Up/down selector (inactive sortable column). */
|
|
575
|
+
const SelectorIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
576
|
+
...p,
|
|
577
|
+
children: /* @__PURE__ */ jsx("path", { d: "m8 9 4-4 4 4M8 15l4 4 4-4" })
|
|
578
|
+
});
|
|
579
|
+
/** Small ✕ used on chips. */
|
|
580
|
+
const CloseIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
581
|
+
...p,
|
|
582
|
+
children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" })
|
|
583
|
+
});
|
|
584
|
+
/** Sliders icon for the Filters button. */
|
|
585
|
+
const FiltersIcon = (p) => /* @__PURE__ */ jsx(Svg, {
|
|
586
|
+
...p,
|
|
587
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 6h16M7 12h10M10 18h4" })
|
|
588
|
+
});
|
|
589
|
+
/** Triangle alert icon for the error state. */
|
|
590
|
+
const AlertIcon = (p) => /* @__PURE__ */ jsxs(Svg, {
|
|
591
|
+
...p,
|
|
592
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z" }), /* @__PURE__ */ jsx("path", { d: "M12 9v4M12 17h.01" })]
|
|
593
|
+
});
|
|
594
|
+
/** Refresh icon for retry. */
|
|
595
|
+
const RefreshIcon = (p) => /* @__PURE__ */ jsxs(Svg, {
|
|
596
|
+
...p,
|
|
597
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-3-6.7L21 8" }), /* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" })]
|
|
598
|
+
});
|
|
599
|
+
/** Inbox icon for the empty state. */
|
|
600
|
+
const InboxIcon = (p) => /* @__PURE__ */ jsxs(Svg, {
|
|
601
|
+
...p,
|
|
602
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M22 12h-6l-2 3h-4l-2-3H2" }), /* @__PURE__ */ jsx("path", { d: "M5.5 5.1 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.5-6.9A2 2 0 0 0 16.8 4H7.2a2 2 0 0 0-1.7 1.1Z" })]
|
|
603
|
+
});
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/components/ExpandToggle.tsx
|
|
606
|
+
/**
|
|
607
|
+
* The chevron that toggles a row's detail panel — shared by the desktop
|
|
608
|
+
* table's leading cell and the mobile card. It is a real button, so the
|
|
609
|
+
* row-click interactive-child guard already keeps it from activating
|
|
610
|
+
* `onRowClick`.
|
|
611
|
+
*/
|
|
612
|
+
function ExpandToggle({ expanded, expandLabel, collapseLabel, onToggle }) {
|
|
613
|
+
return /* @__PURE__ */ jsx(ActionIcon, {
|
|
614
|
+
variant: "subtle",
|
|
615
|
+
color: "gray",
|
|
616
|
+
size: "sm",
|
|
617
|
+
"aria-expanded": expanded,
|
|
618
|
+
"aria-label": expanded ? collapseLabel : expandLabel,
|
|
619
|
+
onClick: onToggle,
|
|
620
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
621
|
+
size: 14,
|
|
622
|
+
style: {
|
|
623
|
+
transform: expanded ? "rotate(90deg)" : "rotate(0deg)",
|
|
624
|
+
transition: "transform 150ms ease"
|
|
625
|
+
}
|
|
626
|
+
})
|
|
627
|
+
});
|
|
588
628
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/components/DesktopTable.tsx
|
|
631
|
+
/** Inline style for an absolutely-positioned column-resize handle. */
|
|
632
|
+
const RESIZE_HANDLE_STYLE = {
|
|
633
|
+
position: "absolute",
|
|
634
|
+
insetInlineEnd: 0,
|
|
635
|
+
top: 0,
|
|
636
|
+
height: "100%",
|
|
637
|
+
width: 8,
|
|
638
|
+
cursor: "col-resize",
|
|
639
|
+
touchAction: "none",
|
|
640
|
+
userSelect: "none"
|
|
598
641
|
};
|
|
599
|
-
function SortIcon({
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}) {
|
|
603
|
-
if (!active) return /* @__PURE__ */ jsx(SelectorIcon, { size: 12 });
|
|
604
|
-
return dir === "asc" ? /* @__PURE__ */ jsx(ChevronUpIcon, { size: 12 }) : /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12 });
|
|
642
|
+
function SortIcon({ active, dir }) {
|
|
643
|
+
if (!active) return /* @__PURE__ */ jsx(SelectorIcon, { size: 12 });
|
|
644
|
+
return dir === "asc" ? /* @__PURE__ */ jsx(ChevronUpIcon, { size: 12 }) : /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12 });
|
|
605
645
|
}
|
|
606
|
-
function HeaderCell({
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
646
|
+
function HeaderCell({ table, column, stickyStyle, resizeHandle }) {
|
|
647
|
+
const cellProps = table.getHeaderCellProps(column);
|
|
648
|
+
const headerStyle = {
|
|
649
|
+
...cellProps.style,
|
|
650
|
+
...stickyStyle
|
|
651
|
+
};
|
|
652
|
+
if (!column.sortable) return /* @__PURE__ */ jsxs(Table.Th, {
|
|
653
|
+
...cellProps,
|
|
654
|
+
style: headerStyle,
|
|
655
|
+
children: [column.header, resizeHandle]
|
|
656
|
+
});
|
|
657
|
+
const buttonProps = table.getSortButtonProps(column);
|
|
658
|
+
const sortIndex = buttonProps["data-sort-index"];
|
|
659
|
+
const level = table.source.sortLevels.find((l) => l.key === column.key);
|
|
660
|
+
const active = level !== void 0 || table.sortBy === column.key;
|
|
661
|
+
return /* @__PURE__ */ jsxs(Table.Th, {
|
|
662
|
+
...cellProps,
|
|
663
|
+
style: headerStyle,
|
|
664
|
+
children: [/* @__PURE__ */ jsxs(Group, {
|
|
665
|
+
component: "button",
|
|
666
|
+
gap: 6,
|
|
667
|
+
wrap: "nowrap",
|
|
668
|
+
display: "inline-flex",
|
|
669
|
+
style: {
|
|
670
|
+
background: "none",
|
|
671
|
+
border: 0,
|
|
672
|
+
cursor: "pointer",
|
|
673
|
+
font: "inherit",
|
|
674
|
+
padding: 0,
|
|
675
|
+
color: active ? "var(--mantine-primary-color-filled)" : "inherit"
|
|
676
|
+
},
|
|
677
|
+
...buttonProps,
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ jsx("span", { children: column.header }),
|
|
680
|
+
/* @__PURE__ */ jsx(SortIcon, {
|
|
681
|
+
active,
|
|
682
|
+
dir: level?.dir ?? table.sortDir
|
|
683
|
+
}),
|
|
684
|
+
typeof sortIndex === "number" && /* @__PURE__ */ jsx(Badge, {
|
|
685
|
+
component: "span",
|
|
686
|
+
size: "xs",
|
|
687
|
+
variant: "light",
|
|
688
|
+
children: sortIndex
|
|
689
|
+
})
|
|
690
|
+
]
|
|
691
|
+
}), resizeHandle]
|
|
692
|
+
});
|
|
653
693
|
}
|
|
654
|
-
function RowActions({
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
{
|
|
691
|
-
variant: "subtle",
|
|
692
|
-
color: action.color,
|
|
693
|
-
size: "compact-sm",
|
|
694
|
-
disabled,
|
|
695
|
-
onClick: handleClick,
|
|
696
|
-
children: action.label
|
|
697
|
-
},
|
|
698
|
-
action.key
|
|
699
|
-
);
|
|
700
|
-
}) });
|
|
694
|
+
function RowActions({ row, actions, confirm, cancelLabel }) {
|
|
695
|
+
return /* @__PURE__ */ jsx(Group, {
|
|
696
|
+
gap: 4,
|
|
697
|
+
justify: "flex-end",
|
|
698
|
+
wrap: "nowrap",
|
|
699
|
+
children: actions.map((action) => {
|
|
700
|
+
if (action.isHidden?.(row)) return null;
|
|
701
|
+
const reason = resolveDisabledReason(action.disabledReason?.(row));
|
|
702
|
+
const disabled = reason !== void 0 || (action.isDisabled?.(row) ?? false);
|
|
703
|
+
const handleClick = disabled ? void 0 : (e) => {
|
|
704
|
+
e.stopPropagation();
|
|
705
|
+
runRowAction(action, row, confirm, cancelLabel);
|
|
706
|
+
};
|
|
707
|
+
return action.icon ? /* @__PURE__ */ jsx(Tooltip, {
|
|
708
|
+
label: reason ?? action.label,
|
|
709
|
+
withArrow: true,
|
|
710
|
+
openDelay: 200,
|
|
711
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
712
|
+
variant: "subtle",
|
|
713
|
+
color: action.color,
|
|
714
|
+
size: "sm",
|
|
715
|
+
disabled,
|
|
716
|
+
"aria-label": action.label,
|
|
717
|
+
onClick: handleClick,
|
|
718
|
+
children: action.icon
|
|
719
|
+
})
|
|
720
|
+
}, action.key) : /* @__PURE__ */ jsx(Button, {
|
|
721
|
+
variant: "subtle",
|
|
722
|
+
color: action.color,
|
|
723
|
+
size: "compact-sm",
|
|
724
|
+
disabled,
|
|
725
|
+
onClick: handleClick,
|
|
726
|
+
children: action.label
|
|
727
|
+
}, action.key);
|
|
728
|
+
})
|
|
729
|
+
});
|
|
701
730
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
731
|
+
/** Every row prop the memo comparator checks with `Object.is`. */
|
|
732
|
+
const COMPARED_ROW_PROPS = [
|
|
733
|
+
"row",
|
|
734
|
+
"index",
|
|
735
|
+
"id",
|
|
736
|
+
"columns",
|
|
737
|
+
"getCellProps",
|
|
738
|
+
"selected",
|
|
739
|
+
"selectLabel",
|
|
740
|
+
"onToggleSelect",
|
|
741
|
+
"expanded",
|
|
742
|
+
"expandLabel",
|
|
743
|
+
"collapseLabel",
|
|
744
|
+
"onToggleExpand",
|
|
745
|
+
"renderRowDetail",
|
|
746
|
+
"columnSpan",
|
|
747
|
+
"rowActions",
|
|
748
|
+
"confirm",
|
|
749
|
+
"cancelLabel",
|
|
750
|
+
"onRowClick",
|
|
751
|
+
"prefetch",
|
|
752
|
+
"className",
|
|
753
|
+
"measureElement",
|
|
754
|
+
"pinSignature"
|
|
725
755
|
];
|
|
756
|
+
/**
|
|
757
|
+
* Row memo comparator: `Object.is` over every prop except the per-render
|
|
758
|
+
* style derivations excluded above. All event handlers passed to the row
|
|
759
|
+
* are identity-stable (or compared here, so a changed handler re-renders
|
|
760
|
+
* the row and is captured fresh) — a held row can never fire a stale
|
|
761
|
+
* closure.
|
|
762
|
+
*/
|
|
726
763
|
function desktopRowPropsEqual(prev, next) {
|
|
727
|
-
|
|
764
|
+
return COMPARED_ROW_PROPS.every((key) => Object.is(prev[key], next[key]));
|
|
728
765
|
}
|
|
766
|
+
/**
|
|
767
|
+
* Sticky style for a leading chrome cell (chevron / checkbox) pinned
|
|
768
|
+
* `inset` px past the inline-start edge, active only while a data column is
|
|
769
|
+
* pinned on that side. Body cells pass a `background` so scrolled data
|
|
770
|
+
* never shows through.
|
|
771
|
+
*/
|
|
729
772
|
function leadingPinStyle(active, inset, zIndex, background) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
773
|
+
if (!active) return void 0;
|
|
774
|
+
const style = pinnedCellStyle({
|
|
775
|
+
side: "left",
|
|
776
|
+
inset
|
|
777
|
+
}, zIndex);
|
|
778
|
+
return background ? {
|
|
779
|
+
...style,
|
|
780
|
+
background
|
|
781
|
+
} : style;
|
|
733
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* Visual fingerprint of the pin layout (sides, insets, edge-pinned chrome
|
|
785
|
+
* columns). Memoized rows compare this one string instead of the per-render
|
|
786
|
+
* style objects derived from it.
|
|
787
|
+
*/
|
|
734
788
|
function pinLayoutSignature(columns, pinOffset, hasLeftPin, actionsEdgePinned) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return `${perColumn.join("|")}|${String(hasLeftPin)}|${String(actionsEdgePinned)}`;
|
|
789
|
+
return `${columns.map((column) => {
|
|
790
|
+
const pin = pinOffset?.(column.key);
|
|
791
|
+
return pin ? `${column.key}:${pin.side}${pin.inset}` : column.key;
|
|
792
|
+
}).join("|")}|${String(hasLeftPin)}|${String(actionsEdgePinned)}`;
|
|
740
793
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
})
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
Table.Td,
|
|
801
|
-
{
|
|
802
|
-
...getCellProps(column),
|
|
803
|
-
style: pinStyleFor(column.key),
|
|
804
|
-
children: column.Cell ? /* @__PURE__ */ jsx(column.Cell, { row, rowIndex: index }) : column.accessor?.(row)
|
|
805
|
-
},
|
|
806
|
-
column.key
|
|
807
|
-
)),
|
|
808
|
-
showActions && /* @__PURE__ */ jsx(Table.Td, { ta: "end", style: actionsCellStyle, children: /* @__PURE__ */ jsx(
|
|
809
|
-
RowActions,
|
|
810
|
-
{
|
|
811
|
-
row,
|
|
812
|
-
actions: rowActions,
|
|
813
|
-
confirm,
|
|
814
|
-
cancelLabel
|
|
815
|
-
}
|
|
816
|
-
) })
|
|
817
|
-
]
|
|
818
|
-
}
|
|
819
|
-
),
|
|
820
|
-
expanded === true && /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnSpan, children: renderRowDetail(row) }) })
|
|
821
|
-
] });
|
|
794
|
+
/**
|
|
795
|
+
* One desktop row (plus its detail row when expanded), extracted so it can
|
|
796
|
+
* be memoized: typing in the search box or toggling another row's checkbox
|
|
797
|
+
* re-renders the table chrome but leaves untouched rows alone.
|
|
798
|
+
*/
|
|
799
|
+
function DesktopRowBase({ row, index, id, columns, getCellProps, selected, selectLabel, onToggleSelect, expanded, expandLabel, collapseLabel, onToggleExpand, renderRowDetail, columnSpan, rowActions, confirm, cancelLabel, onRowClick, prefetch, className, measureElement, pinStyleFor, selectionCellStyle, expansionCellStyle, actionsCellStyle }) {
|
|
800
|
+
const showActions = (rowActions?.length ?? 0) > 0;
|
|
801
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Table.Tr, {
|
|
802
|
+
role: "row",
|
|
803
|
+
"data-index": index,
|
|
804
|
+
"aria-selected": selected,
|
|
805
|
+
...rowClickProps(row, onRowClick),
|
|
806
|
+
className,
|
|
807
|
+
ref: measureElement,
|
|
808
|
+
"data-stagger": "",
|
|
809
|
+
onMouseEnter: prefetch ? () => prefetch(row) : void 0,
|
|
810
|
+
children: [
|
|
811
|
+
expanded !== void 0 && /* @__PURE__ */ jsx(Table.Td, {
|
|
812
|
+
ta: "center",
|
|
813
|
+
style: expansionCellStyle,
|
|
814
|
+
children: /* @__PURE__ */ jsx(ExpandToggle, {
|
|
815
|
+
expanded,
|
|
816
|
+
expandLabel,
|
|
817
|
+
collapseLabel,
|
|
818
|
+
onToggle: () => onToggleExpand(id)
|
|
819
|
+
})
|
|
820
|
+
}),
|
|
821
|
+
selected !== void 0 && /* @__PURE__ */ jsx(Table.Td, {
|
|
822
|
+
ta: "center",
|
|
823
|
+
style: selectionCellStyle,
|
|
824
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
825
|
+
"aria-label": selectLabel,
|
|
826
|
+
checked: selected,
|
|
827
|
+
onChange: () => onToggleSelect(id)
|
|
828
|
+
})
|
|
829
|
+
}),
|
|
830
|
+
columns.map((column) => /* @__PURE__ */ jsx(Table.Td, {
|
|
831
|
+
...getCellProps(column),
|
|
832
|
+
style: pinStyleFor(column.key),
|
|
833
|
+
children: column.Cell ? /* @__PURE__ */ jsx(column.Cell, {
|
|
834
|
+
row,
|
|
835
|
+
rowIndex: index
|
|
836
|
+
}) : column.accessor?.(row)
|
|
837
|
+
}, column.key)),
|
|
838
|
+
showActions && /* @__PURE__ */ jsx(Table.Td, {
|
|
839
|
+
ta: "end",
|
|
840
|
+
style: actionsCellStyle,
|
|
841
|
+
children: /* @__PURE__ */ jsx(RowActions, {
|
|
842
|
+
row,
|
|
843
|
+
actions: rowActions,
|
|
844
|
+
confirm,
|
|
845
|
+
cancelLabel
|
|
846
|
+
})
|
|
847
|
+
})
|
|
848
|
+
]
|
|
849
|
+
}), expanded === true && /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, {
|
|
850
|
+
colSpan: columnSpan,
|
|
851
|
+
children: renderRowDetail(row)
|
|
852
|
+
}) })] });
|
|
822
853
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
return /* @__PURE__ */ jsx(
|
|
1057
|
-
Row,
|
|
1058
|
-
{
|
|
1059
|
-
row,
|
|
1060
|
-
index,
|
|
1061
|
-
id,
|
|
1062
|
-
columns,
|
|
1063
|
-
getCellProps: table.getCellProps,
|
|
1064
|
-
selected: selection?.isSelected(id),
|
|
1065
|
-
selectLabel: labels.selectRow,
|
|
1066
|
-
onToggleSelect: toggleSelect,
|
|
1067
|
-
expanded: expansion?.isExpanded(id),
|
|
1068
|
-
expandLabel: labels.expandRow,
|
|
1069
|
-
collapseLabel: labels.collapseRow,
|
|
1070
|
-
onToggleExpand: expansion?.toggle,
|
|
1071
|
-
renderRowDetail,
|
|
1072
|
-
columnSpan,
|
|
1073
|
-
rowActions,
|
|
1074
|
-
confirm,
|
|
1075
|
-
cancelLabel: labels.cancel,
|
|
1076
|
-
onRowClick,
|
|
1077
|
-
prefetch,
|
|
1078
|
-
className: rowClassName?.(row, index),
|
|
1079
|
-
measureElement,
|
|
1080
|
-
pinStyleFor: bodyPinStyle,
|
|
1081
|
-
selectionCellStyle,
|
|
1082
|
-
expansionCellStyle,
|
|
1083
|
-
actionsCellStyle,
|
|
1084
|
-
pinSignature
|
|
1085
|
-
},
|
|
1086
|
-
key
|
|
1087
|
-
);
|
|
1088
|
-
}),
|
|
1089
|
-
paddingBottom > 0 && /* @__PURE__ */ jsx(Table.Tr, { "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
1090
|
-
Table.Td,
|
|
1091
|
-
{
|
|
1092
|
-
colSpan: columnSpan,
|
|
1093
|
-
style: { height: paddingBottom, padding: 0 }
|
|
1094
|
-
}
|
|
1095
|
-
) })
|
|
1096
|
-
] }),
|
|
1097
|
-
summaryCells && /* @__PURE__ */ jsx(Table.Tfoot, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
1098
|
-
expandable && /* @__PURE__ */ jsx(Table.Td, {}),
|
|
1099
|
-
selection && /* @__PURE__ */ jsx(Table.Td, {}),
|
|
1100
|
-
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1101
|
-
Table.Td,
|
|
1102
|
-
{
|
|
1103
|
-
...table.getCellProps(column),
|
|
1104
|
-
fw: 600,
|
|
1105
|
-
c: "dimmed",
|
|
1106
|
-
children: summaryCells[column.key]
|
|
1107
|
-
},
|
|
1108
|
-
column.key
|
|
1109
|
-
)),
|
|
1110
|
-
showActions && /* @__PURE__ */ jsx(Table.Td, {})
|
|
1111
|
-
] }) })
|
|
1112
|
-
]
|
|
1113
|
-
}
|
|
1114
|
-
)
|
|
1115
|
-
}
|
|
1116
|
-
);
|
|
854
|
+
/** Desktop table rendering driven by core prop-getters. */
|
|
855
|
+
function DesktopTable({ table, rows, rowActions, confirm, prefetch, onRowClick, rowClassName, renderRowDetail, summaryRow, expansion, getRowId, bodyRef, className, rowEntries, paddingTop = 0, paddingBottom = 0, measureElement, stickyHeaderOffset = 0, stickyHeader = false, pinOffset, maxHeight, virtualScrollRef, setWidth, columnWidths, resizeLabel = "Resize column", actionsPinned = false, density = "comfortable" }) {
|
|
856
|
+
const { columns, selection, labels, showActions, entries, columnSpan } = tableRenderModel({
|
|
857
|
+
table,
|
|
858
|
+
rows,
|
|
859
|
+
rowActions,
|
|
860
|
+
getRowId,
|
|
861
|
+
rowEntries,
|
|
862
|
+
renderRowDetail,
|
|
863
|
+
expansion
|
|
864
|
+
});
|
|
865
|
+
const expandable = expansion !== void 0;
|
|
866
|
+
const groupCells = headerGroupRow(columns);
|
|
867
|
+
const summaryCells = summaryRow?.(rows);
|
|
868
|
+
const hasRightPin = table.columns.some((c) => pinOffset?.(c.key)?.side === "right");
|
|
869
|
+
const actionsEdgePinned = showActions && (hasRightPin || actionsPinned);
|
|
870
|
+
const hasPinned = table.columns.some((c) => pinOffset?.(c.key) != null) || actionsEdgePinned;
|
|
871
|
+
const { ref: wrapperRef, overflowing } = useHorizontalOverflow();
|
|
872
|
+
const headerCellStyle = stickyHeader ? {
|
|
873
|
+
position: "sticky",
|
|
874
|
+
top: maxHeight != null || hasPinned || overflowing ? 0 : stickyHeaderOffset,
|
|
875
|
+
zIndex: PIN_Z.header,
|
|
876
|
+
background: "var(--mantine-color-body)",
|
|
877
|
+
boxShadow: "0 1px 0 var(--mantine-color-default-border)"
|
|
878
|
+
} : { background: "var(--mantine-color-body)" };
|
|
879
|
+
const expansionWidth = 36;
|
|
880
|
+
const selectionWidth = 40;
|
|
881
|
+
const actionsWidth = 120;
|
|
882
|
+
const expansionLead = expandable ? expansionWidth : 0;
|
|
883
|
+
const leads = {
|
|
884
|
+
left: expansionLead + (selection ? selectionWidth : 0),
|
|
885
|
+
right: showActions ? actionsWidth : 0
|
|
886
|
+
};
|
|
887
|
+
const hasLeftPin = table.columns.some((c) => pinOffset?.(c.key)?.side === "left");
|
|
888
|
+
const pinBg = "var(--mantine-color-body)";
|
|
889
|
+
const headerStyleFor = (column) => {
|
|
890
|
+
const key = column.key;
|
|
891
|
+
const pin = pinnedCellStyle(pinOffset?.(key), PIN_Z.headerPinned, leads);
|
|
892
|
+
const merged = {
|
|
893
|
+
...headerCellStyle,
|
|
894
|
+
...pin,
|
|
895
|
+
width: pin ? pinnedColumnWidth(column, columnWidths) : columnWidths?.[key]
|
|
896
|
+
};
|
|
897
|
+
if (setWidth && !merged.position) merged.position = "relative";
|
|
898
|
+
return merged;
|
|
899
|
+
};
|
|
900
|
+
const expansionHeaderStyle = {
|
|
901
|
+
...headerCellStyle,
|
|
902
|
+
...leadingPinStyle(hasLeftPin, 0, PIN_Z.headerPinned)
|
|
903
|
+
};
|
|
904
|
+
const selectionHeaderStyle = {
|
|
905
|
+
...headerCellStyle,
|
|
906
|
+
...leadingPinStyle(hasLeftPin, expansionLead, PIN_Z.headerPinned)
|
|
907
|
+
};
|
|
908
|
+
const actionsHeaderStyle = {
|
|
909
|
+
...headerCellStyle,
|
|
910
|
+
...edgePinStyle("right", actionsEdgePinned, PIN_Z.headerPinned)
|
|
911
|
+
};
|
|
912
|
+
const edgeBodyStyle = (side, active) => {
|
|
913
|
+
const pin = edgePinStyle(side, active, PIN_Z.body);
|
|
914
|
+
return pin ? {
|
|
915
|
+
...pin,
|
|
916
|
+
background: pinBg
|
|
917
|
+
} : void 0;
|
|
918
|
+
};
|
|
919
|
+
const expansionCellStyle = leadingPinStyle(hasLeftPin, 0, PIN_Z.body, pinBg);
|
|
920
|
+
const selectionCellStyle = leadingPinStyle(hasLeftPin, expansionLead, PIN_Z.body, pinBg);
|
|
921
|
+
const actionsCellStyle = edgeBodyStyle("right", actionsEdgePinned);
|
|
922
|
+
const columnName = (column) => typeof column.header === "string" ? column.header : column.key;
|
|
923
|
+
const resizeHandleFor = (column) => setWidth ? /* @__PURE__ */ jsx("span", {
|
|
924
|
+
...columnResizeHandleProps(column.key, setWidth, `${resizeLabel}: ${columnName(column)}`),
|
|
925
|
+
style: RESIZE_HANDLE_STYLE
|
|
926
|
+
}) : void 0;
|
|
927
|
+
const bodyPinStyle = (key) => {
|
|
928
|
+
const pin = pinnedCellStyle(pinOffset?.(key), PIN_Z.body, leads);
|
|
929
|
+
return pin ? {
|
|
930
|
+
...pin,
|
|
931
|
+
background: pinBg
|
|
932
|
+
} : void 0;
|
|
933
|
+
};
|
|
934
|
+
const { verticalSpacing, horizontalSpacing } = DENSITY_SPACING[density];
|
|
935
|
+
const minWidth = tableMinWidth(columns, {
|
|
936
|
+
widths: columnWidths,
|
|
937
|
+
extra: expansionLead + (selection ? 40 : 0) + (showActions ? 120 : 0)
|
|
938
|
+
});
|
|
939
|
+
const selectionRef = useRef(selection);
|
|
940
|
+
selectionRef.current = selection;
|
|
941
|
+
const toggleSelect = useCallback((id) => selectionRef.current.toggle(id), []);
|
|
942
|
+
const Row = useMemo(() => memo(DesktopRowBase, desktopRowPropsEqual), []);
|
|
943
|
+
const pinSignature = pinLayoutSignature(columns, pinOffset, hasLeftPin, actionsEdgePinned);
|
|
944
|
+
return /* @__PURE__ */ jsx("div", {
|
|
945
|
+
ref: (node) => {
|
|
946
|
+
wrapperRef(node);
|
|
947
|
+
virtualScrollRef?.(node);
|
|
948
|
+
},
|
|
949
|
+
style: maxHeight == null ? {
|
|
950
|
+
width: "100%",
|
|
951
|
+
...hasPinned || overflowing ? { overflowX: "auto" } : {}
|
|
952
|
+
} : {
|
|
953
|
+
width: "100%",
|
|
954
|
+
maxHeight,
|
|
955
|
+
overflow: "auto"
|
|
956
|
+
},
|
|
957
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
958
|
+
...table.getTableProps(),
|
|
959
|
+
className,
|
|
960
|
+
highlightOnHover: true,
|
|
961
|
+
verticalSpacing,
|
|
962
|
+
horizontalSpacing,
|
|
963
|
+
miw: Math.max(480, minWidth),
|
|
964
|
+
style: stickyHeader ? {
|
|
965
|
+
borderCollapse: "separate",
|
|
966
|
+
borderSpacing: 0
|
|
967
|
+
} : void 0,
|
|
968
|
+
children: [
|
|
969
|
+
/* @__PURE__ */ jsxs(Table.Thead, {
|
|
970
|
+
style: { background: "var(--mantine-color-body)" },
|
|
971
|
+
children: [groupCells && /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
972
|
+
expandable && /* @__PURE__ */ jsx(Table.Th, {}),
|
|
973
|
+
selection && /* @__PURE__ */ jsx(Table.Th, {}),
|
|
974
|
+
groupCells.map((cell) => /* @__PURE__ */ jsx(Table.Th, {
|
|
975
|
+
colSpan: cell.span,
|
|
976
|
+
ta: "center",
|
|
977
|
+
fw: 600,
|
|
978
|
+
style: { borderBottom: "1px solid var(--mantine-color-default-border)" },
|
|
979
|
+
children: cell.label
|
|
980
|
+
}, cell.key)),
|
|
981
|
+
showActions && /* @__PURE__ */ jsx(Table.Th, {})
|
|
982
|
+
] }), /* @__PURE__ */ jsxs(Table.Tr, {
|
|
983
|
+
...table.getHeaderRowProps(),
|
|
984
|
+
children: [
|
|
985
|
+
expandable && /* @__PURE__ */ jsx(Table.Th, {
|
|
986
|
+
w: expansionWidth,
|
|
987
|
+
ta: "center",
|
|
988
|
+
style: expansionHeaderStyle,
|
|
989
|
+
children: /* @__PURE__ */ jsx(VisuallyHidden, { children: labels.expandRow })
|
|
990
|
+
}),
|
|
991
|
+
selection && /* @__PURE__ */ jsx(Table.Th, {
|
|
992
|
+
w: selectionWidth,
|
|
993
|
+
ta: "center",
|
|
994
|
+
style: selectionHeaderStyle,
|
|
995
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
996
|
+
"aria-label": labels.selectAll,
|
|
997
|
+
checked: selection.headerState === "all",
|
|
998
|
+
indeterminate: selection.headerState === "some",
|
|
999
|
+
onChange: selection.toggleAll
|
|
1000
|
+
})
|
|
1001
|
+
}),
|
|
1002
|
+
columns.map((column) => /* @__PURE__ */ jsx(HeaderCell, {
|
|
1003
|
+
table,
|
|
1004
|
+
column,
|
|
1005
|
+
stickyStyle: headerStyleFor(column),
|
|
1006
|
+
resizeHandle: resizeHandleFor(column)
|
|
1007
|
+
}, column.key)),
|
|
1008
|
+
showActions && /* @__PURE__ */ jsx(Table.Th, {
|
|
1009
|
+
ta: "end",
|
|
1010
|
+
w: actionsWidth,
|
|
1011
|
+
style: actionsHeaderStyle,
|
|
1012
|
+
children: labels.actions
|
|
1013
|
+
})
|
|
1014
|
+
]
|
|
1015
|
+
})]
|
|
1016
|
+
}),
|
|
1017
|
+
/* @__PURE__ */ jsxs(Table.Tbody, {
|
|
1018
|
+
ref: bodyRef,
|
|
1019
|
+
children: [
|
|
1020
|
+
paddingTop > 0 && /* @__PURE__ */ jsx(Table.Tr, {
|
|
1021
|
+
"aria-hidden": true,
|
|
1022
|
+
children: /* @__PURE__ */ jsx(Table.Td, {
|
|
1023
|
+
colSpan: columnSpan,
|
|
1024
|
+
style: {
|
|
1025
|
+
height: paddingTop,
|
|
1026
|
+
padding: 0
|
|
1027
|
+
}
|
|
1028
|
+
})
|
|
1029
|
+
}),
|
|
1030
|
+
entries.map(({ row, index, key }) => {
|
|
1031
|
+
const id = getRowId(row);
|
|
1032
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
1033
|
+
row,
|
|
1034
|
+
index,
|
|
1035
|
+
id,
|
|
1036
|
+
columns,
|
|
1037
|
+
getCellProps: table.getCellProps,
|
|
1038
|
+
selected: selection?.isSelected(id),
|
|
1039
|
+
selectLabel: labels.selectRow,
|
|
1040
|
+
onToggleSelect: toggleSelect,
|
|
1041
|
+
expanded: expansion?.isExpanded(id),
|
|
1042
|
+
expandLabel: labels.expandRow,
|
|
1043
|
+
collapseLabel: labels.collapseRow,
|
|
1044
|
+
onToggleExpand: expansion?.toggle,
|
|
1045
|
+
renderRowDetail,
|
|
1046
|
+
columnSpan,
|
|
1047
|
+
rowActions,
|
|
1048
|
+
confirm,
|
|
1049
|
+
cancelLabel: labels.cancel,
|
|
1050
|
+
onRowClick,
|
|
1051
|
+
prefetch,
|
|
1052
|
+
className: rowClassName?.(row, index),
|
|
1053
|
+
measureElement,
|
|
1054
|
+
pinStyleFor: bodyPinStyle,
|
|
1055
|
+
selectionCellStyle,
|
|
1056
|
+
expansionCellStyle,
|
|
1057
|
+
actionsCellStyle,
|
|
1058
|
+
pinSignature
|
|
1059
|
+
}, key);
|
|
1060
|
+
}),
|
|
1061
|
+
paddingBottom > 0 && /* @__PURE__ */ jsx(Table.Tr, {
|
|
1062
|
+
"aria-hidden": true,
|
|
1063
|
+
children: /* @__PURE__ */ jsx(Table.Td, {
|
|
1064
|
+
colSpan: columnSpan,
|
|
1065
|
+
style: {
|
|
1066
|
+
height: paddingBottom,
|
|
1067
|
+
padding: 0
|
|
1068
|
+
}
|
|
1069
|
+
})
|
|
1070
|
+
})
|
|
1071
|
+
]
|
|
1072
|
+
}),
|
|
1073
|
+
summaryCells && /* @__PURE__ */ jsx(Table.Tfoot, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
1074
|
+
expandable && /* @__PURE__ */ jsx(Table.Td, {}),
|
|
1075
|
+
selection && /* @__PURE__ */ jsx(Table.Td, {}),
|
|
1076
|
+
columns.map((column) => /* @__PURE__ */ jsx(Table.Td, {
|
|
1077
|
+
...table.getCellProps(column),
|
|
1078
|
+
fw: 600,
|
|
1079
|
+
c: "dimmed",
|
|
1080
|
+
children: summaryCells[column.key]
|
|
1081
|
+
}, column.key)),
|
|
1082
|
+
showActions && /* @__PURE__ */ jsx(Table.Td, {})
|
|
1083
|
+
] }) })
|
|
1084
|
+
]
|
|
1085
|
+
})
|
|
1086
|
+
});
|
|
1117
1087
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region src/components/EmptyState.tsx
|
|
1090
|
+
/** Centred "nothing to show" placeholder. */
|
|
1091
|
+
function EmptyState({ title, description, icon, action }) {
|
|
1092
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
1093
|
+
role: "status",
|
|
1094
|
+
align: "center",
|
|
1095
|
+
justify: "center",
|
|
1096
|
+
gap: 6,
|
|
1097
|
+
py: 48,
|
|
1098
|
+
px: 16,
|
|
1099
|
+
children: [
|
|
1100
|
+
/* @__PURE__ */ jsx(Text, {
|
|
1101
|
+
c: "dimmed",
|
|
1102
|
+
"aria-hidden": true,
|
|
1103
|
+
children: icon ?? /* @__PURE__ */ jsx(InboxIcon, { size: 40 })
|
|
1104
|
+
}),
|
|
1105
|
+
/* @__PURE__ */ jsx(Text, {
|
|
1106
|
+
fw: 600,
|
|
1107
|
+
fz: "md",
|
|
1108
|
+
children: title
|
|
1109
|
+
}),
|
|
1110
|
+
description && /* @__PURE__ */ jsx(Text, {
|
|
1111
|
+
c: "dimmed",
|
|
1112
|
+
fz: "sm",
|
|
1113
|
+
ta: "center",
|
|
1114
|
+
maw: 360,
|
|
1115
|
+
children: description
|
|
1116
|
+
}),
|
|
1117
|
+
action
|
|
1118
|
+
]
|
|
1119
|
+
});
|
|
1141
1120
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
);
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region src/components/ErrorState.tsx
|
|
1123
|
+
/** Inline error alert with an optional retry button. */
|
|
1124
|
+
function ErrorState({ error, title, message, retryLabel, onRetry, isRetrying }) {
|
|
1125
|
+
return /* @__PURE__ */ jsx(Alert, {
|
|
1126
|
+
icon: /* @__PURE__ */ jsx(AlertIcon, { size: 16 }),
|
|
1127
|
+
color: "red",
|
|
1128
|
+
variant: "light",
|
|
1129
|
+
title,
|
|
1130
|
+
children: /* @__PURE__ */ jsxs(Group, {
|
|
1131
|
+
justify: "space-between",
|
|
1132
|
+
align: "center",
|
|
1133
|
+
wrap: "nowrap",
|
|
1134
|
+
gap: "md",
|
|
1135
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Text, {
|
|
1136
|
+
fz: "sm",
|
|
1137
|
+
children: message
|
|
1138
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
1139
|
+
fz: "xs",
|
|
1140
|
+
c: "dimmed",
|
|
1141
|
+
mt: 2,
|
|
1142
|
+
children: error.message
|
|
1143
|
+
})] }), onRetry && /* @__PURE__ */ jsx(Button, {
|
|
1144
|
+
size: "xs",
|
|
1145
|
+
variant: "light",
|
|
1146
|
+
color: "red",
|
|
1147
|
+
leftSection: /* @__PURE__ */ jsx(RefreshIcon, { size: 14 }),
|
|
1148
|
+
onClick: onRetry,
|
|
1149
|
+
loading: isRetrying,
|
|
1150
|
+
children: retryLabel
|
|
1151
|
+
})]
|
|
1152
|
+
})
|
|
1153
|
+
});
|
|
1177
1154
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region src/components/FilterDrawer.tsx
|
|
1157
|
+
/** Right-side drawer holding the caller's filter widgets + apply/clear. */
|
|
1158
|
+
function FilterDrawer({ opened, onClose, filters, activeFilterCount, onClearFilters, labels, dir = "ltr" }) {
|
|
1159
|
+
return /* @__PURE__ */ jsx(Drawer, {
|
|
1160
|
+
opened,
|
|
1161
|
+
onClose,
|
|
1162
|
+
position: dir === "rtl" ? "left" : "right",
|
|
1163
|
+
size: 380,
|
|
1164
|
+
title: labels.filters,
|
|
1165
|
+
overlayProps: {
|
|
1166
|
+
opacity: .4,
|
|
1167
|
+
blur: 2
|
|
1168
|
+
},
|
|
1169
|
+
closeButtonProps: { "aria-label": labels.cancel },
|
|
1170
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1171
|
+
gap: "md",
|
|
1172
|
+
mih: "60vh",
|
|
1173
|
+
justify: "space-between",
|
|
1174
|
+
children: [/* @__PURE__ */ jsx(Stack, {
|
|
1175
|
+
gap: "md",
|
|
1176
|
+
children: filters
|
|
1177
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
1178
|
+
justify: "space-between",
|
|
1179
|
+
pt: "md",
|
|
1180
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1181
|
+
variant: "subtle",
|
|
1182
|
+
onClick: onClearFilters,
|
|
1183
|
+
disabled: activeFilterCount === 0,
|
|
1184
|
+
children: labels.clearAll
|
|
1185
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1186
|
+
onClick: onClose,
|
|
1187
|
+
children: labels.applyFilters
|
|
1188
|
+
})]
|
|
1189
|
+
})]
|
|
1190
|
+
})
|
|
1191
|
+
});
|
|
1214
1192
|
}
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region src/components/MobileCards.tsx
|
|
1215
1195
|
function mobileLabel(column) {
|
|
1216
|
-
|
|
1196
|
+
return column.mobileLabel ?? (typeof column.header === "string" ? column.header : column.key);
|
|
1217
1197
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1198
|
+
/** Mobile rendering: one Mantine Card per row with labelled key/value rows. */
|
|
1199
|
+
function MobileCards({ table, rows, rowActions, confirm, getRowId, bodyRef, className, rowEntries, paddingTop = 0, paddingBottom = 0, measureElement, density = "comfortable", onRowClick, rowClassName, renderRowDetail, summaryRow, expansion }) {
|
|
1200
|
+
const { columns, selection, labels } = table;
|
|
1201
|
+
const compact = density === "compact";
|
|
1202
|
+
const cardPadding = compact ? "sm" : "md";
|
|
1203
|
+
const cardGap = compact ? 4 : "xs";
|
|
1204
|
+
const entries = rowEntries ?? rows.map((row, index) => ({
|
|
1205
|
+
row,
|
|
1206
|
+
index,
|
|
1207
|
+
key: getRowId(row)
|
|
1208
|
+
}));
|
|
1209
|
+
const summaryCells = summaryRow?.(rows);
|
|
1210
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
1211
|
+
gap: compact ? "xs" : "sm",
|
|
1212
|
+
ref: bodyRef,
|
|
1213
|
+
className,
|
|
1214
|
+
...table.getTableProps({ role: "list" }),
|
|
1215
|
+
children: [
|
|
1216
|
+
paddingTop > 0 && /* @__PURE__ */ jsx("div", {
|
|
1217
|
+
"aria-hidden": true,
|
|
1218
|
+
style: { height: paddingTop }
|
|
1219
|
+
}),
|
|
1220
|
+
entries.map(({ row, index, key }) => {
|
|
1221
|
+
const id = getRowId(row);
|
|
1222
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
1223
|
+
...rowClickProps(row, onRowClick),
|
|
1224
|
+
className: rowClassName?.(row, index),
|
|
1225
|
+
ref: measureElement,
|
|
1226
|
+
"data-index": index,
|
|
1227
|
+
withBorder: true,
|
|
1228
|
+
radius: "md",
|
|
1229
|
+
padding: cardPadding,
|
|
1230
|
+
role: "listitem",
|
|
1231
|
+
"data-stagger": "",
|
|
1232
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1233
|
+
gap: cardGap,
|
|
1234
|
+
children: [
|
|
1235
|
+
selection && /* @__PURE__ */ jsx(Checkbox, {
|
|
1236
|
+
"aria-label": labels.selectRow,
|
|
1237
|
+
checked: selection.isSelected(id),
|
|
1238
|
+
onChange: () => selection.toggle(id)
|
|
1239
|
+
}),
|
|
1240
|
+
expansion && /* @__PURE__ */ jsx(Group, {
|
|
1241
|
+
justify: "flex-end",
|
|
1242
|
+
children: /* @__PURE__ */ jsx(ExpandToggle, {
|
|
1243
|
+
expanded: expansion.isExpanded(id),
|
|
1244
|
+
expandLabel: labels.expandRow,
|
|
1245
|
+
collapseLabel: labels.collapseRow,
|
|
1246
|
+
onToggle: () => expansion.toggle(id)
|
|
1247
|
+
})
|
|
1248
|
+
}),
|
|
1249
|
+
columns.map((column) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Text, {
|
|
1250
|
+
fz: "xs",
|
|
1251
|
+
c: "dimmed",
|
|
1252
|
+
tt: "uppercase",
|
|
1253
|
+
fw: 500,
|
|
1254
|
+
children: mobileLabel(column)
|
|
1255
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
1256
|
+
component: "div",
|
|
1257
|
+
fz: "sm",
|
|
1258
|
+
children: column.Cell ? /* @__PURE__ */ jsx(column.Cell, {
|
|
1259
|
+
row,
|
|
1260
|
+
rowIndex: index
|
|
1261
|
+
}) : column.accessor?.(row)
|
|
1262
|
+
})] }, column.key)),
|
|
1263
|
+
expansion?.isExpanded(id) === true && /* @__PURE__ */ jsx("div", { children: renderRowDetail(row) }),
|
|
1264
|
+
rowActions && rowActions.length > 0 && /* @__PURE__ */ jsx(Group, {
|
|
1265
|
+
gap: 4,
|
|
1266
|
+
justify: "flex-end",
|
|
1267
|
+
pt: 4,
|
|
1268
|
+
children: rowActions.map((action) => {
|
|
1269
|
+
if (action.isHidden?.(row)) return null;
|
|
1270
|
+
const reason = resolveDisabledReason(action.disabledReason?.(row));
|
|
1271
|
+
const disabled = reason !== void 0 || (action.isDisabled?.(row) ?? false);
|
|
1272
|
+
const run = disabled ? void 0 : () => runRowAction(action, row, confirm, labels.cancel);
|
|
1273
|
+
return action.icon ? /* @__PURE__ */ jsx(Tooltip, {
|
|
1274
|
+
label: reason ?? action.label,
|
|
1275
|
+
withArrow: true,
|
|
1276
|
+
openDelay: 200,
|
|
1277
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
1278
|
+
variant: "subtle",
|
|
1279
|
+
color: action.color,
|
|
1280
|
+
size: "sm",
|
|
1281
|
+
disabled,
|
|
1282
|
+
"aria-label": action.label,
|
|
1283
|
+
onClick: run,
|
|
1284
|
+
children: action.icon
|
|
1285
|
+
})
|
|
1286
|
+
}, action.key) : /* @__PURE__ */ jsx(Button, {
|
|
1287
|
+
variant: "subtle",
|
|
1288
|
+
color: action.color,
|
|
1289
|
+
size: "compact-sm",
|
|
1290
|
+
disabled,
|
|
1291
|
+
onClick: run,
|
|
1292
|
+
children: action.label
|
|
1293
|
+
}, action.key);
|
|
1294
|
+
})
|
|
1295
|
+
})
|
|
1296
|
+
]
|
|
1297
|
+
})
|
|
1298
|
+
}, key);
|
|
1299
|
+
}),
|
|
1300
|
+
paddingBottom > 0 && /* @__PURE__ */ jsx("div", {
|
|
1301
|
+
"aria-hidden": true,
|
|
1302
|
+
style: { height: paddingBottom }
|
|
1303
|
+
}),
|
|
1304
|
+
summaryCells && /* @__PURE__ */ jsx(Card, {
|
|
1305
|
+
withBorder: true,
|
|
1306
|
+
radius: "md",
|
|
1307
|
+
padding: cardPadding,
|
|
1308
|
+
role: "listitem",
|
|
1309
|
+
children: /* @__PURE__ */ jsx(Stack, {
|
|
1310
|
+
gap: cardGap,
|
|
1311
|
+
children: columns.filter((column) => summaryCells[column.key] !== void 0).map((column) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Text, {
|
|
1312
|
+
fz: "xs",
|
|
1313
|
+
c: "dimmed",
|
|
1314
|
+
tt: "uppercase",
|
|
1315
|
+
fw: 500,
|
|
1316
|
+
children: mobileLabel(column)
|
|
1317
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
1318
|
+
component: "div",
|
|
1319
|
+
fz: "sm",
|
|
1320
|
+
fw: 600,
|
|
1321
|
+
children: summaryCells[column.key]
|
|
1322
|
+
})] }, column.key))
|
|
1323
|
+
})
|
|
1324
|
+
})
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1346
1327
|
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1328
|
+
//#endregion
|
|
1329
|
+
//#region src/components/PaginationFooter.tsx
|
|
1330
|
+
/** Desktop pagination bar: page-size + range on the left, pager on the right. */
|
|
1331
|
+
function PaginationFooter({ page, totalPages, limit, total, fromIndex, toIndex, onPageChange, onLimitChange, labels }) {
|
|
1332
|
+
const safeTotalPages = Math.max(totalPages, 1);
|
|
1333
|
+
const safePage = Math.min(Math.max(page, 1), safeTotalPages);
|
|
1334
|
+
const options = pageSizeOptions(limit).map((n) => ({
|
|
1335
|
+
value: String(n),
|
|
1336
|
+
label: String(n)
|
|
1337
|
+
}));
|
|
1338
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1339
|
+
justify: "space-between",
|
|
1340
|
+
align: "center",
|
|
1341
|
+
wrap: "wrap",
|
|
1342
|
+
gap: "md",
|
|
1343
|
+
pt: "xs",
|
|
1344
|
+
children: [/* @__PURE__ */ jsxs(Group, {
|
|
1345
|
+
gap: "xs",
|
|
1346
|
+
align: "center",
|
|
1347
|
+
wrap: "nowrap",
|
|
1348
|
+
children: [
|
|
1349
|
+
/* @__PURE__ */ jsx(Text, {
|
|
1350
|
+
fz: "xs",
|
|
1351
|
+
c: "dimmed",
|
|
1352
|
+
children: labels.rowsPerPage
|
|
1353
|
+
}),
|
|
1354
|
+
/* @__PURE__ */ jsx(Select, {
|
|
1355
|
+
"aria-label": labels.rowsPerPage,
|
|
1356
|
+
data: options,
|
|
1357
|
+
value: String(limit),
|
|
1358
|
+
onChange: (v) => onLimitChange(Number(v)),
|
|
1359
|
+
size: "xs",
|
|
1360
|
+
w: 76,
|
|
1361
|
+
allowDeselect: false,
|
|
1362
|
+
comboboxProps: { withinPortal: false }
|
|
1363
|
+
}),
|
|
1364
|
+
total > 0 && /* @__PURE__ */ jsx(Text, {
|
|
1365
|
+
fz: "xs",
|
|
1366
|
+
c: "dimmed",
|
|
1367
|
+
children: labels.showing({
|
|
1368
|
+
from: fromIndex,
|
|
1369
|
+
to: toIndex,
|
|
1370
|
+
total
|
|
1371
|
+
})
|
|
1372
|
+
})
|
|
1373
|
+
]
|
|
1374
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
1375
|
+
gap: "sm",
|
|
1376
|
+
align: "center",
|
|
1377
|
+
wrap: "nowrap",
|
|
1378
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1379
|
+
fz: "xs",
|
|
1380
|
+
c: "dimmed",
|
|
1381
|
+
children: labels.pageOf({
|
|
1382
|
+
page: safePage,
|
|
1383
|
+
total: safeTotalPages
|
|
1384
|
+
})
|
|
1385
|
+
}), /* @__PURE__ */ jsx(Pagination, {
|
|
1386
|
+
total: safeTotalPages,
|
|
1387
|
+
value: safePage,
|
|
1388
|
+
onChange: onPageChange,
|
|
1389
|
+
size: "sm",
|
|
1390
|
+
siblings: 1,
|
|
1391
|
+
boundaries: 1,
|
|
1392
|
+
getControlProps: (control) => ({ "aria-label": control === "previous" ? labels.previousPage : labels.nextPage })
|
|
1393
|
+
})]
|
|
1394
|
+
})]
|
|
1395
|
+
});
|
|
1400
1396
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1397
|
+
//#endregion
|
|
1398
|
+
//#region src/components/SavedViewsMenu.tsx
|
|
1399
|
+
/**
|
|
1400
|
+
* Saved-views menu: lists every captured view (click a name to apply it, the
|
|
1401
|
+
* trailing ✕ to delete it) above a save row that captures the table's
|
|
1402
|
+
* CURRENT URL state under the typed name. Pairs with core's `useSavedViews`
|
|
1403
|
+
* and composes into the `toolbar` slot — or let `<DataTable savedViews>`
|
|
1404
|
+
* mount it for you next to the Columns menu.
|
|
1405
|
+
*/
|
|
1406
|
+
function SavedViewsMenu({ views, labels }) {
|
|
1407
|
+
const [name, setName] = useState("");
|
|
1408
|
+
const trimmed = name.trim();
|
|
1409
|
+
const handleSave = () => {
|
|
1410
|
+
views.save(trimmed);
|
|
1411
|
+
setName("");
|
|
1412
|
+
};
|
|
1413
|
+
return /* @__PURE__ */ jsxs(Menu, {
|
|
1414
|
+
closeOnItemClick: false,
|
|
1415
|
+
position: "bottom-end",
|
|
1416
|
+
withinPortal: true,
|
|
1417
|
+
children: [/* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(Button, {
|
|
1418
|
+
variant: "default",
|
|
1419
|
+
size: "sm",
|
|
1420
|
+
children: labels.savedViews
|
|
1421
|
+
}) }), /* @__PURE__ */ jsx(Menu.Dropdown, { children: /* @__PURE__ */ jsxs(Box, {
|
|
1422
|
+
p: 4,
|
|
1423
|
+
miw: 220,
|
|
1424
|
+
children: [
|
|
1425
|
+
/* @__PURE__ */ jsx(Text, {
|
|
1426
|
+
size: "xs",
|
|
1427
|
+
c: "dimmed",
|
|
1428
|
+
fw: 600,
|
|
1429
|
+
tt: "uppercase",
|
|
1430
|
+
px: 4,
|
|
1431
|
+
pb: 6,
|
|
1432
|
+
children: labels.savedViews
|
|
1433
|
+
}),
|
|
1434
|
+
views.views.map((view) => /* @__PURE__ */ jsxs(Group, {
|
|
1435
|
+
gap: 6,
|
|
1436
|
+
px: 4,
|
|
1437
|
+
py: 2,
|
|
1438
|
+
wrap: "nowrap",
|
|
1439
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1440
|
+
variant: "subtle",
|
|
1441
|
+
size: "compact-sm",
|
|
1442
|
+
justify: "flex-start",
|
|
1443
|
+
style: { flex: 1 },
|
|
1444
|
+
onClick: () => views.apply(view.name),
|
|
1445
|
+
children: view.name
|
|
1446
|
+
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
1447
|
+
variant: "subtle",
|
|
1448
|
+
color: "gray",
|
|
1449
|
+
size: "sm",
|
|
1450
|
+
"aria-label": `${labels.deleteView}: ${view.name}`,
|
|
1451
|
+
onClick: () => views.remove(view.name),
|
|
1452
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { size: 12 })
|
|
1453
|
+
})]
|
|
1454
|
+
}, view.name)),
|
|
1455
|
+
/* @__PURE__ */ jsx(Menu.Divider, {}),
|
|
1456
|
+
/* @__PURE__ */ jsxs(Group, {
|
|
1457
|
+
gap: 6,
|
|
1458
|
+
p: 4,
|
|
1459
|
+
wrap: "nowrap",
|
|
1460
|
+
children: [/* @__PURE__ */ jsx(TextInput, {
|
|
1461
|
+
size: "xs",
|
|
1462
|
+
style: { flex: 1 },
|
|
1463
|
+
placeholder: labels.viewName,
|
|
1464
|
+
value: name,
|
|
1465
|
+
onChange: (e) => setName(e.currentTarget.value)
|
|
1466
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1467
|
+
size: "xs",
|
|
1468
|
+
disabled: trimmed === "",
|
|
1469
|
+
onClick: handleSave,
|
|
1470
|
+
children: labels.saveView
|
|
1471
|
+
})]
|
|
1472
|
+
})
|
|
1473
|
+
]
|
|
1474
|
+
}) })]
|
|
1475
|
+
});
|
|
1455
1476
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
})
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
height: 14,
|
|
1477
|
-
radius: "sm",
|
|
1478
|
-
width: c === 0 ? "70%" : "55%"
|
|
1479
|
-
}
|
|
1480
|
-
) }, c)) }, r)) })
|
|
1481
|
-
] }),
|
|
1482
|
-
loadingLabel ? /* @__PURE__ */ jsx(VisuallyHidden, { children: loadingLabel }) : null
|
|
1483
|
-
] });
|
|
1477
|
+
//#endregion
|
|
1478
|
+
//#region src/components/TableSkeleton.tsx
|
|
1479
|
+
/** Loading placeholder that mirrors the table shape to avoid layout shift. */
|
|
1480
|
+
function TableSkeleton({ columns, rows = 5, loadingLabel }) {
|
|
1481
|
+
const colKeys = Array.from({ length: Math.max(columns, 1) }, (_, i) => i);
|
|
1482
|
+
const rowKeys = Array.from({ length: rows }, (_, i) => i);
|
|
1483
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1484
|
+
role: "status",
|
|
1485
|
+
"aria-busy": "true",
|
|
1486
|
+
"aria-live": "polite",
|
|
1487
|
+
children: [/* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsx(Table.Tr, { children: colKeys.map((c) => /* @__PURE__ */ jsx(Table.Th, { children: /* @__PURE__ */ jsx(Skeleton, {
|
|
1488
|
+
height: 12,
|
|
1489
|
+
radius: "sm",
|
|
1490
|
+
width: c === 0 ? "55%" : "40%"
|
|
1491
|
+
}) }, c)) }) }), /* @__PURE__ */ jsx(Table.Tbody, { children: rowKeys.map((r) => /* @__PURE__ */ jsx(Table.Tr, { children: colKeys.map((c) => /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Skeleton, {
|
|
1492
|
+
height: 14,
|
|
1493
|
+
radius: "sm",
|
|
1494
|
+
width: c === 0 ? "70%" : "55%"
|
|
1495
|
+
}) }, c)) }, r)) })] }), loadingLabel ? /* @__PURE__ */ jsx(VisuallyHidden, { children: loadingLabel }) : null]
|
|
1496
|
+
});
|
|
1484
1497
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
] })
|
|
1523
|
-
]
|
|
1524
|
-
}
|
|
1525
|
-
);
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/components/FilterPopover.tsx
|
|
1500
|
+
/**
|
|
1501
|
+
* Anchored filter card (the default filter container). Opens under the Filters
|
|
1502
|
+
* button and tracks it on scroll. No backdrop — the background stays visible
|
|
1503
|
+
* and interactive; clicking outside or pressing Escape closes it. Pair with
|
|
1504
|
+
* `filtersMode="drawer"` for the slide-in panel instead.
|
|
1505
|
+
*/
|
|
1506
|
+
function FilterPopover({ open, onClose, filters, activeFilterCount, onClearFilters, labels, dir = "ltr", children }) {
|
|
1507
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
1508
|
+
opened: open,
|
|
1509
|
+
onDismiss: onClose,
|
|
1510
|
+
position: dir === "rtl" ? "bottom-start" : "bottom-end",
|
|
1511
|
+
withinPortal: true,
|
|
1512
|
+
shadow: "md",
|
|
1513
|
+
radius: "md",
|
|
1514
|
+
width: 340,
|
|
1515
|
+
children: [/* @__PURE__ */ jsx(Popover.Target, { children }), /* @__PURE__ */ jsxs(Popover.Dropdown, { children: [/* @__PURE__ */ jsxs(Group, {
|
|
1516
|
+
justify: "space-between",
|
|
1517
|
+
align: "center",
|
|
1518
|
+
mb: "sm",
|
|
1519
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1520
|
+
fw: 600,
|
|
1521
|
+
fz: "sm",
|
|
1522
|
+
children: labels.filters
|
|
1523
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1524
|
+
variant: "subtle",
|
|
1525
|
+
size: "compact-xs",
|
|
1526
|
+
onClick: onClearFilters,
|
|
1527
|
+
disabled: activeFilterCount === 0,
|
|
1528
|
+
children: labels.clearAll
|
|
1529
|
+
})]
|
|
1530
|
+
}), /* @__PURE__ */ jsx(Stack, {
|
|
1531
|
+
gap: "md",
|
|
1532
|
+
children: filters
|
|
1533
|
+
})] })]
|
|
1534
|
+
});
|
|
1526
1535
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
/* @__PURE__ */ jsx(Text, { fz: "xs", c: "dimmed", children: labels.rowsPerPage }),
|
|
1615
|
-
/* @__PURE__ */ jsx(
|
|
1616
|
-
Select,
|
|
1617
|
-
{
|
|
1618
|
-
"aria-label": labels.rowsPerPage,
|
|
1619
|
-
data: pageSizeOptions(source.limit).map((n) => ({
|
|
1620
|
-
value: String(n),
|
|
1621
|
-
label: String(n)
|
|
1622
|
-
})),
|
|
1623
|
-
value: String(source.limit),
|
|
1624
|
-
onChange: (v) => source.setLimit(Number(v)),
|
|
1625
|
-
size: "sm",
|
|
1626
|
-
w: 80,
|
|
1627
|
-
allowDeselect: false,
|
|
1628
|
-
comboboxProps: { withinPortal: false }
|
|
1629
|
-
}
|
|
1630
|
-
)
|
|
1631
|
-
] })
|
|
1632
|
-
] })
|
|
1633
|
-
]
|
|
1634
|
-
}
|
|
1635
|
-
);
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region src/components/Toolbar.tsx
|
|
1538
|
+
/** Sticky toolbar: search, optional sort select, custom slot, filters, size. */
|
|
1539
|
+
function Toolbar({ table, hideSearch, searchPlaceholder, sortByOptions, customToolbar, hasFilters, activeFilterCount, onToggleFilters, onFiltersTriggerPointerDown, onCloseFilters, filtersOpen, filtersMode, filters, onClearFilters, dir, columnMenu, showRowsPerPage, className }) {
|
|
1540
|
+
const { labels, source } = table;
|
|
1541
|
+
const searchProps = table.getSearchInputProps(searchPlaceholder ? { placeholder: searchPlaceholder } : void 0);
|
|
1542
|
+
const sortOptions = sortByOptions ?? (table.isMobile ? table.sortByOptions : void 0);
|
|
1543
|
+
const filtersButton = /* @__PURE__ */ jsx(Button, {
|
|
1544
|
+
variant: "default",
|
|
1545
|
+
size: "sm",
|
|
1546
|
+
"aria-expanded": filtersMode === "popover" ? filtersOpen : void 0,
|
|
1547
|
+
"data-active": filtersOpen || void 0,
|
|
1548
|
+
leftSection: /* @__PURE__ */ jsx(FiltersIcon, { size: 16 }),
|
|
1549
|
+
rightSection: activeFilterCount > 0 ? /* @__PURE__ */ jsx(Badge, {
|
|
1550
|
+
size: "sm",
|
|
1551
|
+
circle: true,
|
|
1552
|
+
children: activeFilterCount
|
|
1553
|
+
}) : void 0,
|
|
1554
|
+
onPointerDown: onFiltersTriggerPointerDown,
|
|
1555
|
+
onClick: onToggleFilters,
|
|
1556
|
+
children: labels.filters
|
|
1557
|
+
});
|
|
1558
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1559
|
+
gap: "sm",
|
|
1560
|
+
justify: "space-between",
|
|
1561
|
+
align: "center",
|
|
1562
|
+
className,
|
|
1563
|
+
children: [!hideSearch && /* @__PURE__ */ jsx(TextInput, {
|
|
1564
|
+
...searchProps,
|
|
1565
|
+
leftSection: /* @__PURE__ */ jsx(SearchIcon, { size: 14 }),
|
|
1566
|
+
size: "sm",
|
|
1567
|
+
style: {
|
|
1568
|
+
flex: 1,
|
|
1569
|
+
minWidth: 160,
|
|
1570
|
+
maxWidth: 360
|
|
1571
|
+
}
|
|
1572
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
1573
|
+
gap: "xs",
|
|
1574
|
+
align: "center",
|
|
1575
|
+
children: [
|
|
1576
|
+
sortOptions && sortOptions.length > 0 && /* @__PURE__ */ jsx(Select, {
|
|
1577
|
+
"aria-label": labels.sortBy,
|
|
1578
|
+
placeholder: labels.sortBy,
|
|
1579
|
+
data: sortOptions,
|
|
1580
|
+
value: source.sortBy ?? null,
|
|
1581
|
+
onChange: (v) => source.setSort(v ?? void 0, source.sortDir ?? "asc"),
|
|
1582
|
+
clearable: true,
|
|
1583
|
+
size: "sm",
|
|
1584
|
+
w: 160,
|
|
1585
|
+
comboboxProps: { withinPortal: false }
|
|
1586
|
+
}),
|
|
1587
|
+
customToolbar,
|
|
1588
|
+
hasFilters && (filtersMode === "popover" ? /* @__PURE__ */ jsx(FilterPopover, {
|
|
1589
|
+
open: filtersOpen,
|
|
1590
|
+
onClose: onCloseFilters,
|
|
1591
|
+
filters,
|
|
1592
|
+
activeFilterCount,
|
|
1593
|
+
onClearFilters,
|
|
1594
|
+
labels,
|
|
1595
|
+
dir,
|
|
1596
|
+
children: filtersButton
|
|
1597
|
+
}) : filtersButton),
|
|
1598
|
+
columnMenu,
|
|
1599
|
+
showRowsPerPage && /* @__PURE__ */ jsxs(Group, {
|
|
1600
|
+
gap: "xs",
|
|
1601
|
+
align: "center",
|
|
1602
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1603
|
+
fz: "xs",
|
|
1604
|
+
c: "dimmed",
|
|
1605
|
+
children: labels.rowsPerPage
|
|
1606
|
+
}), /* @__PURE__ */ jsx(Select, {
|
|
1607
|
+
"aria-label": labels.rowsPerPage,
|
|
1608
|
+
data: pageSizeOptions(source.limit).map((n) => ({
|
|
1609
|
+
value: String(n),
|
|
1610
|
+
label: String(n)
|
|
1611
|
+
})),
|
|
1612
|
+
value: String(source.limit),
|
|
1613
|
+
onChange: (v) => source.setLimit(Number(v)),
|
|
1614
|
+
size: "sm",
|
|
1615
|
+
w: 80,
|
|
1616
|
+
allowDeselect: false,
|
|
1617
|
+
comboboxProps: { withinPortal: false }
|
|
1618
|
+
})]
|
|
1619
|
+
})
|
|
1620
|
+
]
|
|
1621
|
+
})]
|
|
1622
|
+
});
|
|
1636
1623
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1624
|
+
//#endregion
|
|
1625
|
+
//#region src/DataTable.tsx
|
|
1626
|
+
const stickyToolbarStyle = (top) => ({
|
|
1627
|
+
position: "sticky",
|
|
1628
|
+
top,
|
|
1629
|
+
zIndex: 3,
|
|
1630
|
+
background: "var(--mantine-color-body)",
|
|
1631
|
+
paddingBottom: "var(--mantine-spacing-xs)"
|
|
1643
1632
|
});
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
})
|
|
1648
|
-
if (!enabled) return null;
|
|
1649
|
-
return /* @__PURE__ */ jsx(ColumnMenu, { ...props });
|
|
1633
|
+
/** The Columns menu, rendered inline in the toolbar — or nothing when off. */
|
|
1634
|
+
function ColumnMenuSlot({ enabled, ...props }) {
|
|
1635
|
+
if (!enabled) return null;
|
|
1636
|
+
return /* @__PURE__ */ jsx(ColumnMenu, { ...props });
|
|
1650
1637
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1638
|
+
/**
|
|
1639
|
+
* The Saved-views menu in the toolbar. A component (not inline JSX) so
|
|
1640
|
+
* `useSavedViews` only runs when the `savedViews` prop is set.
|
|
1641
|
+
*/
|
|
1642
|
+
function SavedViewsSlot({ options, labels }) {
|
|
1643
|
+
return /* @__PURE__ */ jsx(SavedViewsMenu, {
|
|
1644
|
+
views: useSavedViews$1(options),
|
|
1645
|
+
labels
|
|
1646
|
+
});
|
|
1657
1647
|
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Resolve the data tier (source ▸ server ▸ frontend) and the declarative
|
|
1650
|
+
* filter runtime into the full chrome prop set: the RESOLVED source, the
|
|
1651
|
+
* filters node (auto-built form for the declarative array, JSX as-is) and
|
|
1652
|
+
* the chip-label resolvers (derived under the caller's — the user wins
|
|
1653
|
+
* per key). Everything downstream consumes these.
|
|
1654
|
+
*/
|
|
1658
1655
|
function useResolvedTableProps(props) {
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1656
|
+
const { source, runtime } = useTableData({
|
|
1657
|
+
locale: props.locale,
|
|
1658
|
+
source: props.source,
|
|
1659
|
+
data: props.data,
|
|
1660
|
+
total: props.total,
|
|
1661
|
+
loading: props.loading,
|
|
1662
|
+
onQueryChange: props.onQueryChange,
|
|
1663
|
+
columns: props.columns,
|
|
1664
|
+
filters: props.filters,
|
|
1665
|
+
urlKey: props.urlKey,
|
|
1666
|
+
adapter: props.urlSync === false ? void 0 : props.urlAdapter,
|
|
1667
|
+
enabled: props.urlSync
|
|
1668
|
+
});
|
|
1669
|
+
const labels = useMemo(() => resolveLabels(props.labels), [props.labels]);
|
|
1670
|
+
let filters;
|
|
1671
|
+
if (isDeclarativeFilters(props.filters) || props.filters === void 0) filters = runtime.defs.length > 0 ? /* @__PURE__ */ jsx(AutoFilterForm, {
|
|
1672
|
+
defs: runtime.defs,
|
|
1673
|
+
source,
|
|
1674
|
+
labels
|
|
1675
|
+
}) : void 0;
|
|
1676
|
+
else filters = props.filters;
|
|
1677
|
+
const filterLabels = useMemo(() => ({
|
|
1678
|
+
...runtime.filterLabels,
|
|
1679
|
+
...props.filterLabels
|
|
1680
|
+
}), [runtime.filterLabels, props.filterLabels]);
|
|
1681
|
+
return {
|
|
1682
|
+
...props,
|
|
1683
|
+
source,
|
|
1684
|
+
filters,
|
|
1685
|
+
filterLabels
|
|
1686
|
+
};
|
|
1684
1687
|
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Batteries-included Mantine data table. Drop in `columns`, a `rowKey`,
|
|
1690
|
+
* and a data tier — raw `data` (frontend), `data` + `onQueryChange`
|
|
1691
|
+
* (server), or a prebuilt `source` — to get a fully styled, sortable,
|
|
1692
|
+
* filterable, paginated table with selection, bulk actions, RTL, dark
|
|
1693
|
+
* mode, and optional entrance animation.
|
|
1694
|
+
*
|
|
1695
|
+
* @typeParam TRow - The row type.
|
|
1696
|
+
*/
|
|
1685
1697
|
function DataTable(props) {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
] })
|
|
1885
|
-
}
|
|
1886
|
-
),
|
|
1887
|
-
chrome.isRefreshing && /* @__PURE__ */ jsx(
|
|
1888
|
-
Progress,
|
|
1889
|
-
{
|
|
1890
|
-
size: "xs",
|
|
1891
|
-
animated: true,
|
|
1892
|
-
value: 100,
|
|
1893
|
-
"aria-label": table.labels.loading
|
|
1894
|
-
}
|
|
1895
|
-
),
|
|
1896
|
-
source.error && /* @__PURE__ */ jsx(
|
|
1897
|
-
ErrorState,
|
|
1898
|
-
{
|
|
1899
|
-
error: source.error,
|
|
1900
|
-
title: table.labels.errorTitle,
|
|
1901
|
-
message: table.labels.errorMessage,
|
|
1902
|
-
retryLabel: table.labels.retry,
|
|
1903
|
-
onRetry: source.refetch ? () => void source.refetch?.() : void 0,
|
|
1904
|
-
isRetrying: source.isFetching
|
|
1905
|
-
}
|
|
1906
|
-
),
|
|
1907
|
-
!source.error && body,
|
|
1908
|
-
canLoadMore && source.hasNextPage && /* @__PURE__ */ jsx(Group, { ref: loadMoreRef, justify: "center", py: "xs", children: /* @__PURE__ */ jsx(
|
|
1909
|
-
Button,
|
|
1910
|
-
{
|
|
1911
|
-
variant: "default",
|
|
1912
|
-
size: "sm",
|
|
1913
|
-
loading: source.isFetchingNextPage,
|
|
1914
|
-
onClick: () => source.fetchNextPage(),
|
|
1915
|
-
children: table.labels.loadMore
|
|
1916
|
-
}
|
|
1917
|
-
) }),
|
|
1918
|
-
chrome.showFooter && /* @__PURE__ */ jsx(Box, { className: classNames?.footer, children: /* @__PURE__ */ jsx(
|
|
1919
|
-
PaginationFooter,
|
|
1920
|
-
{
|
|
1921
|
-
page: table.pagination.safePage,
|
|
1922
|
-
totalPages: table.pagination.totalPages,
|
|
1923
|
-
limit: source.limit,
|
|
1924
|
-
total: source.total,
|
|
1925
|
-
fromIndex: table.pagination.fromIndex,
|
|
1926
|
-
toIndex: table.pagination.toIndex,
|
|
1927
|
-
onPageChange: source.setPage,
|
|
1928
|
-
onLimitChange: source.setLimit,
|
|
1929
|
-
labels: table.labels
|
|
1930
|
-
}
|
|
1931
|
-
) })
|
|
1932
|
-
] }),
|
|
1933
|
-
filters && filtersMode === "drawer" && /* @__PURE__ */ jsx(
|
|
1934
|
-
FilterDrawer,
|
|
1935
|
-
{
|
|
1936
|
-
opened: drawerOpened,
|
|
1937
|
-
onClose: () => setDrawerOpened(false),
|
|
1938
|
-
filters,
|
|
1939
|
-
activeFilterCount: chrome.activeFilterCount,
|
|
1940
|
-
onClearFilters: chrome.clearFilters,
|
|
1941
|
-
labels: table.labels,
|
|
1942
|
-
dir
|
|
1943
|
-
}
|
|
1944
|
-
)
|
|
1945
|
-
]
|
|
1946
|
-
}
|
|
1947
|
-
);
|
|
1698
|
+
const chromeProps = useResolvedTableProps(props);
|
|
1699
|
+
const { source, rowActions, searchPlaceholder, sortByOptions, dir, prefetch, hideSearch, filters, filtersMode = "popover", bulkActions, slots, classNames, toolbar: customToolbar, skeletonRows, stickyTop = 0, animate = false, stickyHeader = false, enableColumnMenu = false, savedViews } = chromeProps;
|
|
1700
|
+
const density = chromeProps.density ?? "comfortable";
|
|
1701
|
+
const chrome = useTableChrome(chromeProps);
|
|
1702
|
+
const { table, isMobile, confirm, getRowId } = chrome;
|
|
1703
|
+
const hasRowActions = (rowActions?.length ?? 0) > 0;
|
|
1704
|
+
const visibleRowActions = chrome.columnLayout.isHidden(ACTIONS_COLUMN_KEY) ? void 0 : rowActions;
|
|
1705
|
+
const actionsPinned = chrome.columnLayout.state.pinned[ACTIONS_COLUMN_KEY] === "right";
|
|
1706
|
+
const { virtualization, loadMoreRef, canLoadMore, virtualScrollRef } = useChromeBodyData(chrome, chromeProps);
|
|
1707
|
+
const [drawerOpened, setDrawerOpened] = useState(false);
|
|
1708
|
+
const filtersTrigger = useFilterTriggerToggle(drawerOpened, setDrawerOpened);
|
|
1709
|
+
const rootRef = useRef(null);
|
|
1710
|
+
const { ref: toolbarRef, height: toolbarHeight } = useElementSize();
|
|
1711
|
+
const desktopBodyRef = useRef(null);
|
|
1712
|
+
const mobileBodyRef = useRef(null);
|
|
1713
|
+
useChromeScrollReset(rootRef, chrome, chromeProps);
|
|
1714
|
+
useMountStagger(isMobile ? mobileBodyRef : desktopBodyRef, [virtualization.rows.length, isMobile], { enabled: animate });
|
|
1715
|
+
let body;
|
|
1716
|
+
if (chrome.body === "skeleton") body = slots?.skeleton ?? /* @__PURE__ */ jsx(TableSkeleton, {
|
|
1717
|
+
columns: table.columns.length || 1,
|
|
1718
|
+
rows: skeletonRows ?? source.limit,
|
|
1719
|
+
loadingLabel: table.labels.loading
|
|
1720
|
+
});
|
|
1721
|
+
else if (chrome.body === "empty") body = slots?.empty ?? (chrome.emptyVariant === "noResults" ? /* @__PURE__ */ jsx(EmptyState, {
|
|
1722
|
+
title: table.labels.noResults,
|
|
1723
|
+
action: /* @__PURE__ */ jsx(Button, {
|
|
1724
|
+
variant: "light",
|
|
1725
|
+
size: "sm",
|
|
1726
|
+
onClick: chrome.clearFilters,
|
|
1727
|
+
children: table.labels.clearAll
|
|
1728
|
+
})
|
|
1729
|
+
}) : /* @__PURE__ */ jsx(EmptyState, { title: table.labels.noData }));
|
|
1730
|
+
else if (chrome.body === "mobile") body = /* @__PURE__ */ jsx(MobileCards, {
|
|
1731
|
+
table,
|
|
1732
|
+
rows: source.rows,
|
|
1733
|
+
rowActions: visibleRowActions,
|
|
1734
|
+
confirm,
|
|
1735
|
+
getRowId,
|
|
1736
|
+
onRowClick: props.onRowClick,
|
|
1737
|
+
rowClassName: props.rowClassName,
|
|
1738
|
+
renderRowDetail: props.renderRowDetail,
|
|
1739
|
+
summaryRow: props.summaryRow,
|
|
1740
|
+
expansion: chrome.detail?.expansion,
|
|
1741
|
+
bodyRef: mobileBodyRef,
|
|
1742
|
+
className: classNames?.card,
|
|
1743
|
+
rowEntries: virtualization.enabled ? virtualization.rows : void 0,
|
|
1744
|
+
paddingTop: virtualization.paddingTop,
|
|
1745
|
+
paddingBottom: virtualization.paddingBottom,
|
|
1746
|
+
measureElement: virtualization.measureElement,
|
|
1747
|
+
density
|
|
1748
|
+
});
|
|
1749
|
+
else body = /* @__PURE__ */ jsx(DesktopTable, {
|
|
1750
|
+
table,
|
|
1751
|
+
rows: source.rows,
|
|
1752
|
+
rowActions: visibleRowActions,
|
|
1753
|
+
confirm,
|
|
1754
|
+
prefetch,
|
|
1755
|
+
onRowClick: props.onRowClick,
|
|
1756
|
+
rowClassName: props.rowClassName,
|
|
1757
|
+
renderRowDetail: props.renderRowDetail,
|
|
1758
|
+
summaryRow: props.summaryRow,
|
|
1759
|
+
expansion: chrome.detail?.expansion,
|
|
1760
|
+
getRowId,
|
|
1761
|
+
bodyRef: desktopBodyRef,
|
|
1762
|
+
className: classNames?.table,
|
|
1763
|
+
rowEntries: virtualization.enabled ? virtualization.rows : void 0,
|
|
1764
|
+
paddingTop: virtualization.paddingTop,
|
|
1765
|
+
paddingBottom: virtualization.paddingBottom,
|
|
1766
|
+
measureElement: virtualization.measureElement,
|
|
1767
|
+
stickyHeaderOffset: stickyTop + toolbarHeight,
|
|
1768
|
+
stickyHeader,
|
|
1769
|
+
pinOffset: chrome.columnLayout.pinOffset,
|
|
1770
|
+
actionsPinned,
|
|
1771
|
+
maxHeight: props.maxHeight,
|
|
1772
|
+
virtualScrollRef,
|
|
1773
|
+
setWidth: props.resizableColumns ? chrome.columnLayout.setWidth : void 0,
|
|
1774
|
+
columnWidths: chrome.columnLayout.state.widths,
|
|
1775
|
+
resizeLabel: table.labels.resizeColumn,
|
|
1776
|
+
density
|
|
1777
|
+
});
|
|
1778
|
+
return /* @__PURE__ */ jsxs(Paper, {
|
|
1779
|
+
ref: rootRef,
|
|
1780
|
+
p: "xs",
|
|
1781
|
+
radius: "md",
|
|
1782
|
+
withBorder: true,
|
|
1783
|
+
dir,
|
|
1784
|
+
"aria-busy": chrome.isRefreshing || void 0,
|
|
1785
|
+
className: classNames?.root,
|
|
1786
|
+
children: [/* @__PURE__ */ jsxs(Stack, {
|
|
1787
|
+
gap: "xs",
|
|
1788
|
+
children: [
|
|
1789
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1790
|
+
ref: toolbarRef,
|
|
1791
|
+
style: stickyToolbarStyle(stickyTop),
|
|
1792
|
+
className: classNames?.toolbar,
|
|
1793
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1794
|
+
gap: "xs",
|
|
1795
|
+
children: [
|
|
1796
|
+
/* @__PURE__ */ jsx(Toolbar, {
|
|
1797
|
+
table,
|
|
1798
|
+
hideSearch,
|
|
1799
|
+
searchPlaceholder,
|
|
1800
|
+
sortByOptions,
|
|
1801
|
+
customToolbar,
|
|
1802
|
+
hasFilters: Boolean(filters),
|
|
1803
|
+
activeFilterCount: chrome.activeFilterCount,
|
|
1804
|
+
filtersMode,
|
|
1805
|
+
filters,
|
|
1806
|
+
filtersOpen: drawerOpened,
|
|
1807
|
+
onToggleFilters: filtersTrigger.onClick,
|
|
1808
|
+
onFiltersTriggerPointerDown: filtersTrigger.onPointerDown,
|
|
1809
|
+
onCloseFilters: () => setDrawerOpened(false),
|
|
1810
|
+
onClearFilters: chrome.clearFilters,
|
|
1811
|
+
dir,
|
|
1812
|
+
columnMenu: /* @__PURE__ */ jsxs(Fragment, { children: [savedViews && /* @__PURE__ */ jsx(SavedViewsSlot, {
|
|
1813
|
+
options: {
|
|
1814
|
+
adapter: chromeProps.urlAdapter,
|
|
1815
|
+
urlKey: chromeProps.urlKey,
|
|
1816
|
+
...savedViews
|
|
1817
|
+
},
|
|
1818
|
+
labels: table.labels
|
|
1819
|
+
}), /* @__PURE__ */ jsx(ColumnMenuSlot, {
|
|
1820
|
+
enabled: enableColumnMenu && !isMobile,
|
|
1821
|
+
allColumns: chrome.allColumns,
|
|
1822
|
+
layout: chrome.columnLayout,
|
|
1823
|
+
labels: table.labels,
|
|
1824
|
+
hasRowActions
|
|
1825
|
+
})] }),
|
|
1826
|
+
showRowsPerPage: canLoadMore
|
|
1827
|
+
}),
|
|
1828
|
+
/* @__PURE__ */ jsx(ActiveFilterChips, {
|
|
1829
|
+
chips: chrome.mergedChips,
|
|
1830
|
+
onClearAll: chrome.clearFilters,
|
|
1831
|
+
label: table.labels.filters,
|
|
1832
|
+
clearAllLabel: table.labels.clearAll
|
|
1833
|
+
}),
|
|
1834
|
+
table.selection && bulkActions && /* @__PURE__ */ jsx(BulkActionBar, {
|
|
1835
|
+
selection: table.selection,
|
|
1836
|
+
total: source.total,
|
|
1837
|
+
bulkActions,
|
|
1838
|
+
confirm,
|
|
1839
|
+
labels: table.labels
|
|
1840
|
+
})
|
|
1841
|
+
]
|
|
1842
|
+
})
|
|
1843
|
+
}),
|
|
1844
|
+
chrome.isRefreshing && /* @__PURE__ */ jsx(Progress, {
|
|
1845
|
+
size: "xs",
|
|
1846
|
+
animated: true,
|
|
1847
|
+
value: 100,
|
|
1848
|
+
"aria-label": table.labels.loading
|
|
1849
|
+
}),
|
|
1850
|
+
source.error && /* @__PURE__ */ jsx(ErrorState, {
|
|
1851
|
+
error: source.error,
|
|
1852
|
+
title: table.labels.errorTitle,
|
|
1853
|
+
message: table.labels.errorMessage,
|
|
1854
|
+
retryLabel: table.labels.retry,
|
|
1855
|
+
onRetry: source.refetch ? () => void source.refetch?.() : void 0,
|
|
1856
|
+
isRetrying: source.isFetching
|
|
1857
|
+
}),
|
|
1858
|
+
!source.error && body,
|
|
1859
|
+
canLoadMore && source.hasNextPage && /* @__PURE__ */ jsx(Group, {
|
|
1860
|
+
ref: loadMoreRef,
|
|
1861
|
+
justify: "center",
|
|
1862
|
+
py: "xs",
|
|
1863
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
1864
|
+
variant: "default",
|
|
1865
|
+
size: "sm",
|
|
1866
|
+
loading: source.isFetchingNextPage,
|
|
1867
|
+
onClick: () => source.fetchNextPage(),
|
|
1868
|
+
children: table.labels.loadMore
|
|
1869
|
+
})
|
|
1870
|
+
}),
|
|
1871
|
+
chrome.showFooter && /* @__PURE__ */ jsx(Box, {
|
|
1872
|
+
className: classNames?.footer,
|
|
1873
|
+
children: /* @__PURE__ */ jsx(PaginationFooter, {
|
|
1874
|
+
page: table.pagination.safePage,
|
|
1875
|
+
totalPages: table.pagination.totalPages,
|
|
1876
|
+
limit: source.limit,
|
|
1877
|
+
total: source.total,
|
|
1878
|
+
fromIndex: table.pagination.fromIndex,
|
|
1879
|
+
toIndex: table.pagination.toIndex,
|
|
1880
|
+
onPageChange: source.setPage,
|
|
1881
|
+
onLimitChange: source.setLimit,
|
|
1882
|
+
labels: table.labels
|
|
1883
|
+
})
|
|
1884
|
+
})
|
|
1885
|
+
]
|
|
1886
|
+
}), filters && filtersMode === "drawer" && /* @__PURE__ */ jsx(FilterDrawer, {
|
|
1887
|
+
opened: drawerOpened,
|
|
1888
|
+
onClose: () => setDrawerOpened(false),
|
|
1889
|
+
filters,
|
|
1890
|
+
activeFilterCount: chrome.activeFilterCount,
|
|
1891
|
+
onClearFilters: chrome.clearFilters,
|
|
1892
|
+
labels: table.labels,
|
|
1893
|
+
dir
|
|
1894
|
+
})]
|
|
1895
|
+
});
|
|
1948
1896
|
}
|
|
1897
|
+
//#endregion
|
|
1898
|
+
export { ActiveFilterChips, AutoFilterForm, DataTable, EmptyState, ErrorState, PaginationFooter, SavedViewsMenu, TableSkeleton, createHistoryAdapter, createMemoryAdapter, defaultConfirm, defaultLabels, deriveSortByOptions, getHistoryAdapter, useBackendData, useDataTable, useFrontendData, useMountStagger, useSavedViews, useTableUrlState };
|
|
1949
1899
|
|
|
1950
|
-
export { ActiveFilterChips, AutoFilterForm, DataTable, EmptyState, ErrorState, PaginationFooter, SavedViewsMenu, TableSkeleton, useMountStagger };
|
|
1951
|
-
//# sourceMappingURL=index.js.map
|
|
1952
1900
|
//# sourceMappingURL=index.js.map
|