@adapttable/mui 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,1930 @@
1
+ 'use strict';
2
+
3
+ var core = require('@adapttable/core');
4
+ var material = require('@mui/material');
5
+ var react = require('react');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ // src/components/SavedViewsMenu.tsx
9
+ function SavedViewsMenu({
10
+ options,
11
+ labels
12
+ }) {
13
+ const { views, save, apply, remove } = core.useSavedViews(options);
14
+ const [anchor, setAnchor] = react.useState(null);
15
+ const [name, setName] = react.useState("");
16
+ const trimmed = name.trim();
17
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18
+ /* @__PURE__ */ jsxRuntime.jsx(
19
+ material.Button,
20
+ {
21
+ size: "small",
22
+ variant: "outlined",
23
+ "aria-expanded": anchor !== null,
24
+ "aria-haspopup": "true",
25
+ onClick: (e) => setAnchor(e.currentTarget),
26
+ children: labels.savedViews
27
+ }
28
+ ),
29
+ /* @__PURE__ */ jsxRuntime.jsx(
30
+ material.Popover,
31
+ {
32
+ anchorEl: anchor,
33
+ open: anchor !== null,
34
+ onClose: () => setAnchor(null),
35
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
36
+ children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { p: 0.75, minWidth: 250 }, children: [
37
+ views.map((view) => /* @__PURE__ */ jsxRuntime.jsxs(
38
+ material.Stack,
39
+ {
40
+ direction: "row",
41
+ alignItems: "center",
42
+ spacing: 0.5,
43
+ children: [
44
+ /* @__PURE__ */ jsxRuntime.jsx(
45
+ material.Button,
46
+ {
47
+ size: "small",
48
+ fullWidth: true,
49
+ sx: { justifyContent: "flex-start" },
50
+ onClick: () => {
51
+ apply(view.name);
52
+ setAnchor(null);
53
+ },
54
+ children: view.name
55
+ }
56
+ ),
57
+ /* @__PURE__ */ jsxRuntime.jsx(
58
+ material.IconButton,
59
+ {
60
+ size: "small",
61
+ "aria-label": `${labels.deleteView}: ${view.name}`,
62
+ onClick: () => remove(view.name),
63
+ children: "\xD7"
64
+ }
65
+ )
66
+ ]
67
+ },
68
+ view.name
69
+ )),
70
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { my: 0.5 } }),
71
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx(
73
+ material.TextField,
74
+ {
75
+ size: "small",
76
+ value: name,
77
+ placeholder: labels.viewName,
78
+ slotProps: { htmlInput: { "aria-label": labels.viewName } },
79
+ onChange: (e) => setName(e.target.value)
80
+ }
81
+ ),
82
+ /* @__PURE__ */ jsxRuntime.jsx(
83
+ material.Button,
84
+ {
85
+ size: "small",
86
+ variant: "contained",
87
+ disabled: trimmed === "",
88
+ onClick: () => {
89
+ save(trimmed);
90
+ setName("");
91
+ },
92
+ children: labels.saveView
93
+ }
94
+ )
95
+ ] })
96
+ ] })
97
+ }
98
+ )
99
+ ] });
100
+ }
101
+ function scalarText(value) {
102
+ return typeof value === "string" || typeof value === "number" ? String(value) : "";
103
+ }
104
+ function selectedList(value) {
105
+ return Array.isArray(value) ? value : [];
106
+ }
107
+ function TextFilter({ def, source }) {
108
+ return /* @__PURE__ */ jsxRuntime.jsx(
109
+ material.TextField,
110
+ {
111
+ size: "small",
112
+ label: core.filterLabel(def),
113
+ placeholder: def.placeholder,
114
+ value: scalarText(source.extra[def.key]),
115
+ onChange: (e) => source.setExtra(def.key, e.target.value)
116
+ }
117
+ );
118
+ }
119
+ function SelectFilter({ def, source }) {
120
+ const { options, loading } = core.useFilterOptions(def);
121
+ return /* @__PURE__ */ jsxRuntime.jsxs(
122
+ material.TextField,
123
+ {
124
+ select: true,
125
+ size: "small",
126
+ label: core.filterLabel(def),
127
+ value: scalarText(source.extra[def.key]),
128
+ onChange: (e) => source.setExtra(def.key, e.target.value),
129
+ slotProps: {
130
+ select: { native: true },
131
+ inputLabel: { shrink: true }
132
+ },
133
+ children: [
134
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "All" }),
135
+ loading && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "\u2026" }),
136
+ options.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
137
+ ]
138
+ }
139
+ );
140
+ }
141
+ function MultiSelectFilter({ def, source }) {
142
+ const { options, loading } = core.useFilterOptions(def);
143
+ const checked = selectedList(source.extra[def.key]);
144
+ const toggle = (value, on) => {
145
+ const next = on ? [...checked, value] : checked.filter((v) => v !== value);
146
+ source.setExtra(def.key, next);
147
+ };
148
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.FormControl, { component: "fieldset", variant: "standard", children: [
149
+ /* @__PURE__ */ jsxRuntime.jsx(material.FormLabel, { component: "legend", children: core.filterLabel(def) }),
150
+ /* @__PURE__ */ jsxRuntime.jsx(material.FormGroup, { row: true, sx: { columnGap: 1.5 }, children: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 16 }) : options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
151
+ material.FormControlLabel,
152
+ {
153
+ label: option.label,
154
+ control: /* @__PURE__ */ jsxRuntime.jsx(
155
+ material.Checkbox,
156
+ {
157
+ size: "small",
158
+ checked: checked.includes(option.value),
159
+ onChange: (_, on) => toggle(option.value, on)
160
+ }
161
+ )
162
+ },
163
+ option.value
164
+ )) })
165
+ ] });
166
+ }
167
+ function RangeFilter({
168
+ def,
169
+ type,
170
+ source,
171
+ labels
172
+ }) {
173
+ const suffixes = core.RANGE_SUFFIXES[type];
174
+ const lowKey = def.key + suffixes.start;
175
+ const highKey = def.key + suffixes.end;
176
+ const opLabelKeys = core.RANGE_OP_LABEL_KEYS[type === "dateRange" ? "date" : "number"];
177
+ const state = core.readRangeWidget(source.extra, lowKey, highKey);
178
+ const [op, setOp] = react.useState(state.op);
179
+ const single = op === "lte" ? state.b : state.a;
180
+ const commit = (next, a, b) => source.setExtras(core.writeRangeWidget(next, a, b, lowKey, highKey));
181
+ const changeOp = (raw) => {
182
+ const next = core.RANGE_OPS.find((candidate) => candidate === raw);
183
+ setOp(next);
184
+ commit(next, single, op === "between" ? state.b : "");
185
+ };
186
+ const input = (label, value, write) => /* @__PURE__ */ jsxRuntime.jsx(
187
+ material.TextField,
188
+ {
189
+ size: "small",
190
+ sx: { flex: "1 1 7rem", minWidth: "7rem" },
191
+ type: type === "dateRange" ? "date" : "number",
192
+ label,
193
+ value,
194
+ onChange: (e) => write(e.target.value),
195
+ slotProps: { inputLabel: { shrink: true } }
196
+ }
197
+ );
198
+ let bounds = null;
199
+ if (op === "between") {
200
+ bounds = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
201
+ input(labels.from, state.a, (raw) => commit("between", raw, state.b)),
202
+ input(labels.to, state.b, (raw) => commit("between", state.a, raw))
203
+ ] });
204
+ } else if (op !== void 0) {
205
+ bounds = input(labels.value, single, (raw) => commit(op, raw, ""));
206
+ }
207
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.FormControl, { component: "fieldset", variant: "standard", sx: { width: "100%" }, children: [
208
+ /* @__PURE__ */ jsxRuntime.jsx(material.FormLabel, { component: "legend", sx: { mb: 0.75 }, children: core.filterLabel(def) }),
209
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: [
210
+ /* @__PURE__ */ jsxRuntime.jsxs(
211
+ material.TextField,
212
+ {
213
+ select: true,
214
+ size: "small",
215
+ label: labels.operator,
216
+ value: op ?? "",
217
+ onChange: (e) => changeOp(e.target.value),
218
+ slotProps: {
219
+ select: { native: true },
220
+ inputLabel: { shrink: true }
221
+ },
222
+ sx: { flex: "0 0 8.5rem", width: "8.5rem" },
223
+ children: [
224
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "" }),
225
+ core.RANGE_OPS.map((candidate) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: candidate, children: labels[opLabelKeys[candidate]] }, candidate))
226
+ ]
227
+ }
228
+ ),
229
+ bounds
230
+ ] })
231
+ ] });
232
+ }
233
+ function FilterField({
234
+ def,
235
+ source,
236
+ labels
237
+ }) {
238
+ switch (def.type) {
239
+ case "text":
240
+ return /* @__PURE__ */ jsxRuntime.jsx(TextFilter, { def, source });
241
+ case "select":
242
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectFilter, { def, source });
243
+ case "multiSelect":
244
+ return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectFilter, { def, source });
245
+ case "dateRange":
246
+ case "numberRange":
247
+ return /* @__PURE__ */ jsxRuntime.jsx(
248
+ RangeFilter,
249
+ {
250
+ def,
251
+ type: def.type,
252
+ source,
253
+ labels
254
+ }
255
+ );
256
+ }
257
+ }
258
+ function AutoFilterForm({
259
+ defs,
260
+ source,
261
+ labels
262
+ }) {
263
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Stack, { spacing: 1.5, children: defs.map((def) => /* @__PURE__ */ jsxRuntime.jsx(FilterField, { def, source, labels }, def.key)) });
264
+ }
265
+ function FilterPopover({
266
+ open,
267
+ onClose,
268
+ anchorEl,
269
+ filters,
270
+ activeFilterCount,
271
+ onClearFilters,
272
+ labels,
273
+ dir = "ltr"
274
+ }) {
275
+ react.useEffect(() => {
276
+ if (!open) return;
277
+ const onKeyDown = (event) => {
278
+ if (event.key === "Escape") onClose();
279
+ };
280
+ document.addEventListener("keydown", onKeyDown);
281
+ return () => document.removeEventListener("keydown", onKeyDown);
282
+ }, [open, onClose]);
283
+ return /* @__PURE__ */ jsxRuntime.jsx(
284
+ material.Popper,
285
+ {
286
+ open: open && anchorEl !== null,
287
+ anchorEl,
288
+ placement: dir === "rtl" ? "bottom-start" : "bottom-end",
289
+ modifiers: [{ name: "offset", options: { offset: [0, 4] } }],
290
+ style: { zIndex: 1300 },
291
+ children: /* @__PURE__ */ jsxRuntime.jsx(material.ClickAwayListener, { mouseEvent: "onMouseDown", onClickAway: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
292
+ material.Paper,
293
+ {
294
+ elevation: 8,
295
+ sx: {
296
+ width: 360,
297
+ maxWidth: "calc(100vw - 32px)",
298
+ borderRadius: 2
299
+ },
300
+ children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { p: 2, display: "flex", flexDirection: "column", gap: 2 }, children: [
301
+ /* @__PURE__ */ jsxRuntime.jsxs(
302
+ material.Stack,
303
+ {
304
+ direction: "row",
305
+ justifyContent: "space-between",
306
+ alignItems: "center",
307
+ children: [
308
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle1", fontWeight: 600, children: labels.filters }),
309
+ /* @__PURE__ */ jsxRuntime.jsx(
310
+ material.Button,
311
+ {
312
+ size: "small",
313
+ onClick: onClearFilters,
314
+ disabled: activeFilterCount === 0,
315
+ children: labels.clearAll
316
+ }
317
+ )
318
+ ]
319
+ }
320
+ ),
321
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: filters })
322
+ ] })
323
+ }
324
+ ) })
325
+ }
326
+ );
327
+ }
328
+ function FiltersIcon() {
329
+ return /* @__PURE__ */ jsxRuntime.jsx(
330
+ "svg",
331
+ {
332
+ width: "16",
333
+ height: "16",
334
+ viewBox: "0 0 24 24",
335
+ fill: "none",
336
+ stroke: "currentColor",
337
+ strokeWidth: "1.8",
338
+ strokeLinecap: "round",
339
+ strokeLinejoin: "round",
340
+ "aria-hidden": "true",
341
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 5h18l-7 8v5l-4 2v-7L3 5Z" })
342
+ }
343
+ );
344
+ }
345
+ function SearchIcon() {
346
+ return /* @__PURE__ */ jsxRuntime.jsxs(
347
+ "svg",
348
+ {
349
+ width: "18",
350
+ height: "18",
351
+ viewBox: "0 0 24 24",
352
+ fill: "none",
353
+ stroke: "currentColor",
354
+ strokeWidth: "1.8",
355
+ strokeLinecap: "round",
356
+ strokeLinejoin: "round",
357
+ "aria-hidden": "true",
358
+ children: [
359
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "7" }),
360
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m21 21-4.3-4.3" })
361
+ ]
362
+ }
363
+ );
364
+ }
365
+ var srOnly = {
366
+ position: "absolute",
367
+ width: 1,
368
+ height: 1,
369
+ padding: 0,
370
+ margin: -1,
371
+ overflow: "hidden",
372
+ clip: "rect(0 0 0 0)",
373
+ whiteSpace: "nowrap",
374
+ border: 0
375
+ };
376
+ function Toolbar({
377
+ table,
378
+ hideSearch,
379
+ searchPlaceholder,
380
+ sortByOptions,
381
+ customToolbar,
382
+ hasFilters,
383
+ activeFilterCount,
384
+ showRowsPerPage,
385
+ filtersMode,
386
+ filters,
387
+ filtersOpen,
388
+ onToggleFilters,
389
+ onFiltersTriggerPointerDown,
390
+ onCloseFilters,
391
+ onClearFilters,
392
+ dir,
393
+ columnMenu
394
+ }) {
395
+ const { labels, source } = table;
396
+ const sortOptions = sortByOptions ?? (table.isMobile ? table.sortByOptions : void 0);
397
+ const searchProps = table.getSearchInputProps(
398
+ searchPlaceholder ? { placeholder: searchPlaceholder } : void 0
399
+ );
400
+ const filtersAnchorRef = react.useRef(null);
401
+ const filtersButton = hasFilters ? /* @__PURE__ */ jsxRuntime.jsx(material.Badge, { color: "primary", badgeContent: activeFilterCount, children: /* @__PURE__ */ jsxRuntime.jsx(
402
+ material.Button,
403
+ {
404
+ ref: filtersAnchorRef,
405
+ variant: "outlined",
406
+ size: "small",
407
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(FiltersIcon, {}),
408
+ "aria-expanded": filtersMode === "popover" ? filtersOpen : void 0,
409
+ onPointerDown: onFiltersTriggerPointerDown,
410
+ onClick: onToggleFilters,
411
+ children: labels.filters
412
+ }
413
+ ) }) : null;
414
+ return /* @__PURE__ */ jsxRuntime.jsxs(
415
+ material.Stack,
416
+ {
417
+ direction: "row",
418
+ spacing: 1,
419
+ flexWrap: "wrap",
420
+ useFlexGap: true,
421
+ alignItems: "center",
422
+ justifyContent: "space-between",
423
+ children: [
424
+ !hideSearch && /* @__PURE__ */ jsxRuntime.jsx(
425
+ material.TextField,
426
+ {
427
+ size: "small",
428
+ value: searchProps.value,
429
+ placeholder: searchProps.placeholder,
430
+ slotProps: {
431
+ htmlInput: { "aria-label": labels.search, type: "search" },
432
+ input: {
433
+ startAdornment: /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntime.jsx(SearchIcon, {}) })
434
+ }
435
+ },
436
+ onChange: searchProps.onChange,
437
+ sx: { flex: 1, minWidth: 160, maxWidth: 360 }
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsxRuntime.jsxs(
441
+ material.Stack,
442
+ {
443
+ direction: "row",
444
+ spacing: 1,
445
+ alignItems: "center",
446
+ flexWrap: "wrap",
447
+ useFlexGap: true,
448
+ children: [
449
+ sortOptions && sortOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
450
+ material.TextField,
451
+ {
452
+ select: true,
453
+ size: "small",
454
+ label: labels.sortBy,
455
+ value: source.sortBy ?? "",
456
+ onChange: (e) => source.setSort(
457
+ e.target.value || void 0,
458
+ source.sortDir ?? "asc"
459
+ ),
460
+ sx: { minWidth: 160 },
461
+ children: [
462
+ /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: "", children: "\u2014" }),
463
+ sortOptions.map((o) => /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: o.value, children: o.label }, o.value))
464
+ ]
465
+ }
466
+ ),
467
+ customToolbar,
468
+ filtersButton,
469
+ hasFilters && filtersMode === "popover" && /* @__PURE__ */ jsxRuntime.jsx(
470
+ FilterPopover,
471
+ {
472
+ open: filtersOpen,
473
+ onClose: onCloseFilters,
474
+ anchorEl: filtersAnchorRef.current,
475
+ filters,
476
+ activeFilterCount,
477
+ onClearFilters,
478
+ labels,
479
+ dir
480
+ }
481
+ ),
482
+ columnMenu,
483
+ showRowsPerPage && /* @__PURE__ */ jsxRuntime.jsx(
484
+ material.TextField,
485
+ {
486
+ select: true,
487
+ size: "small",
488
+ label: labels.rowsPerPage,
489
+ value: source.limit,
490
+ onChange: (e) => source.setLimit(Number(e.target.value)),
491
+ sx: { minWidth: 110 },
492
+ children: core.pageSizeOptions(source.limit).map((n) => /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: n, children: n }, n))
493
+ }
494
+ )
495
+ ]
496
+ }
497
+ )
498
+ ]
499
+ }
500
+ );
501
+ }
502
+ function Chips({
503
+ chips,
504
+ onClearAll,
505
+ labels
506
+ }) {
507
+ if (chips.length === 0) return null;
508
+ return /* @__PURE__ */ jsxRuntime.jsxs(
509
+ material.Stack,
510
+ {
511
+ direction: "row",
512
+ spacing: 0.5,
513
+ flexWrap: "wrap",
514
+ useFlexGap: true,
515
+ component: "ul",
516
+ sx: { listStyle: "none", p: 0, m: 0 },
517
+ "aria-label": labels.filters,
518
+ children: [
519
+ chips.map((chip) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
520
+ material.Chip,
521
+ {
522
+ label: chip.label,
523
+ size: "small",
524
+ onDelete: chip.onRemove,
525
+ deleteIcon: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-label": `${labels.clearAll}: ${chip.label}`, children: "\xD7" })
526
+ }
527
+ ) }, chip.key)),
528
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(material.Button, { size: "small", onClick: onClearAll, children: labels.clearAll }) })
529
+ ]
530
+ }
531
+ );
532
+ }
533
+ function BulkBar({
534
+ selection,
535
+ total,
536
+ bulkActions,
537
+ confirm,
538
+ labels
539
+ }) {
540
+ const {
541
+ selectedIds,
542
+ selectedCount,
543
+ headerState,
544
+ visibleIds,
545
+ allMatching,
546
+ selectAllMatching,
547
+ clear
548
+ } = selection;
549
+ const { pending, run } = core.useBulkActionRunner({
550
+ confirm,
551
+ cancelLabel: labels.cancel,
552
+ onComplete: clear
553
+ });
554
+ if (selectedCount === 0) return null;
555
+ const ids = [...selectedIds];
556
+ const showBanner = headerState === "all" && total > visibleIds.length;
557
+ return /* @__PURE__ */ jsxRuntime.jsxs(
558
+ material.Stack,
559
+ {
560
+ direction: "row",
561
+ spacing: 1,
562
+ alignItems: "center",
563
+ justifyContent: "space-between",
564
+ flexWrap: "wrap",
565
+ useFlexGap: true,
566
+ children: [
567
+ /* @__PURE__ */ jsxRuntime.jsxs(
568
+ material.Stack,
569
+ {
570
+ direction: "row",
571
+ spacing: 1,
572
+ alignItems: "center",
573
+ flexWrap: "wrap",
574
+ useFlexGap: true,
575
+ children: [
576
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", children: labels.selectedCount(selectedCount) }),
577
+ showBanner && (allMatching ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
578
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: labels.allMatchingSelected(total) }),
579
+ /* @__PURE__ */ jsxRuntime.jsx(
580
+ material.Button,
581
+ {
582
+ size: "small",
583
+ variant: "text",
584
+ onClick: clear,
585
+ disabled: pending !== null,
586
+ children: labels.clearAll
587
+ }
588
+ )
589
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
590
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: labels.pageSelected(visibleIds.length) }),
591
+ /* @__PURE__ */ jsxRuntime.jsx(
592
+ material.Button,
593
+ {
594
+ size: "small",
595
+ variant: "text",
596
+ onClick: selectAllMatching,
597
+ disabled: pending !== null,
598
+ children: labels.selectAllMatching(total)
599
+ }
600
+ )
601
+ ] }))
602
+ ]
603
+ }
604
+ ),
605
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, flexWrap: "wrap", useFlexGap: true, children: [
606
+ /* @__PURE__ */ jsxRuntime.jsx(
607
+ material.Button,
608
+ {
609
+ size: "small",
610
+ variant: "text",
611
+ onClick: clear,
612
+ disabled: pending !== null,
613
+ children: labels.clearAll
614
+ }
615
+ ),
616
+ bulkActions.map((action) => {
617
+ const reason = core.resolveDisabledReason(action.disabledReason?.(ids));
618
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: reason ?? "", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(
619
+ material.Button,
620
+ {
621
+ size: "small",
622
+ variant: "contained",
623
+ color: action.color,
624
+ startIcon: action.icon,
625
+ disabled: reason !== void 0 || pending !== null,
626
+ onClick: () => run(
627
+ action,
628
+ ids,
629
+ allMatching ? { allMatching: true, total } : void 0
630
+ ),
631
+ children: action.label
632
+ }
633
+ ) }) }, action.key);
634
+ })
635
+ ] })
636
+ ]
637
+ }
638
+ );
639
+ }
640
+ function Footer({
641
+ pagination,
642
+ total,
643
+ limit,
644
+ setPage,
645
+ setLimit,
646
+ labels
647
+ }) {
648
+ return /* @__PURE__ */ jsxRuntime.jsxs(
649
+ material.Stack,
650
+ {
651
+ direction: "row",
652
+ spacing: 2,
653
+ alignItems: "center",
654
+ justifyContent: "space-between",
655
+ flexWrap: "wrap",
656
+ useFlexGap: true,
657
+ children: [
658
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1.5, alignItems: "center", useFlexGap: true, children: [
659
+ /* @__PURE__ */ jsxRuntime.jsx(
660
+ material.TextField,
661
+ {
662
+ select: true,
663
+ size: "small",
664
+ label: labels.rowsPerPage,
665
+ value: String(limit),
666
+ onChange: (e) => setLimit(Number(e.target.value)),
667
+ sx: { minWidth: 100 },
668
+ children: core.pageSizeOptions(limit).map((n) => /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: String(n), children: n }, n))
669
+ }
670
+ ),
671
+ total > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "caption", color: "text.secondary", children: labels.showing({
672
+ from: pagination.fromIndex,
673
+ to: pagination.toIndex,
674
+ total
675
+ }) })
676
+ ] }),
677
+ /* @__PURE__ */ jsxRuntime.jsx(
678
+ material.Pagination,
679
+ {
680
+ count: pagination.totalPages,
681
+ page: pagination.safePage,
682
+ onChange: (_, page) => setPage(page),
683
+ size: "small",
684
+ getItemAriaLabel: (type, page) => {
685
+ if (type === "page") return labels.goToPage(page);
686
+ return type === "previous" ? labels.previousPage : labels.nextPage;
687
+ }
688
+ }
689
+ )
690
+ ]
691
+ }
692
+ );
693
+ }
694
+ function ErrorState({
695
+ error,
696
+ labels,
697
+ onRetry
698
+ }) {
699
+ return /* @__PURE__ */ jsxRuntime.jsxs(
700
+ material.Alert,
701
+ {
702
+ severity: "error",
703
+ action: onRetry ? /* @__PURE__ */ jsxRuntime.jsx(material.Button, { color: "inherit", size: "small", onClick: onRetry, children: labels.retry }) : void 0,
704
+ children: [
705
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: labels.errorTitle }),
706
+ " \u2014 ",
707
+ error.message
708
+ ]
709
+ }
710
+ );
711
+ }
712
+ function LoadingState({
713
+ rows,
714
+ columns,
715
+ loadingLabel
716
+ }) {
717
+ return /* @__PURE__ */ jsxRuntime.jsxs(
718
+ material.Box,
719
+ {
720
+ role: "status",
721
+ "aria-busy": "true",
722
+ "aria-live": "polite",
723
+ "data-testid": "adapttable-loading",
724
+ children: [
725
+ Array.from({ length: rows }, (_, r) => /* @__PURE__ */ jsxRuntime.jsx(material.Stack, { direction: "row", spacing: 2, sx: { py: 1 }, children: Array.from({ length: Math.max(columns, 1) }, (_2, c) => /* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { variant: "text", width: c === 0 ? "30%" : "20%" }, c)) }, r)),
726
+ loadingLabel ? /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: srOnly, children: loadingLabel }) : null
727
+ ]
728
+ }
729
+ );
730
+ }
731
+ function FilterDrawer({
732
+ open,
733
+ onClose,
734
+ filters,
735
+ activeFilterCount,
736
+ onClearFilters,
737
+ labels,
738
+ dir = "ltr"
739
+ }) {
740
+ return /* @__PURE__ */ jsxRuntime.jsx(
741
+ material.Drawer,
742
+ {
743
+ anchor: dir === "rtl" ? "left" : "right",
744
+ open,
745
+ onClose,
746
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
747
+ material.Box,
748
+ {
749
+ sx: {
750
+ width: 360,
751
+ p: 2,
752
+ display: "flex",
753
+ flexDirection: "column",
754
+ gap: 2,
755
+ height: "100%"
756
+ },
757
+ children: [
758
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", children: labels.filters }),
759
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { flex: 1, display: "flex", flexDirection: "column", gap: 2 }, children: filters }),
760
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", justifyContent: "space-between", children: [
761
+ /* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: onClearFilters, disabled: activeFilterCount === 0, children: labels.clearAll }),
762
+ /* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "contained", onClick: onClose, children: labels.applyFilters })
763
+ ] })
764
+ ]
765
+ }
766
+ )
767
+ }
768
+ );
769
+ }
770
+ function VisibilityToggle({
771
+ hidden,
772
+ name,
773
+ labels,
774
+ onToggle
775
+ }) {
776
+ return /* @__PURE__ */ jsxRuntime.jsx(
777
+ material.IconButton,
778
+ {
779
+ size: "small",
780
+ "aria-label": `${hidden ? labels.showColumn : labels.hideColumn}: ${name}`,
781
+ "aria-pressed": !hidden,
782
+ color: hidden ? "default" : "primary",
783
+ onClick: onToggle,
784
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.EyeIcon, { off: hidden })
785
+ }
786
+ );
787
+ }
788
+ function RowName({
789
+ hidden,
790
+ name
791
+ }) {
792
+ return /* @__PURE__ */ jsxRuntime.jsx(
793
+ material.Typography,
794
+ {
795
+ variant: "body2",
796
+ sx: {
797
+ flex: 1,
798
+ color: hidden ? "text.disabled" : "text.primary",
799
+ textDecoration: hidden ? "line-through" : "none"
800
+ },
801
+ children: name
802
+ }
803
+ );
804
+ }
805
+ function PinToggle({
806
+ active,
807
+ label,
808
+ onClick
809
+ }) {
810
+ return /* @__PURE__ */ jsxRuntime.jsx(
811
+ material.IconButton,
812
+ {
813
+ size: "small",
814
+ color: active ? "primary" : "default",
815
+ "aria-label": label,
816
+ onClick,
817
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.PinIcon, {})
818
+ }
819
+ );
820
+ }
821
+ function ActionsRow({
822
+ layout,
823
+ labels
824
+ }) {
825
+ const hidden = layout.isHidden(core.ACTIONS_COLUMN_KEY);
826
+ const pinned = layout.state.pinned[core.ACTIONS_COLUMN_KEY] === "right";
827
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
828
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { my: 0.5 } }),
829
+ /* @__PURE__ */ jsxRuntime.jsxs(
830
+ material.Stack,
831
+ {
832
+ direction: "row",
833
+ alignItems: "center",
834
+ spacing: 0.5,
835
+ sx: { px: 0.5, py: 0.25 },
836
+ children: [
837
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { "aria-hidden": true, sx: { width: 24 } }),
838
+ /* @__PURE__ */ jsxRuntime.jsx(
839
+ VisibilityToggle,
840
+ {
841
+ hidden,
842
+ name: labels.actions,
843
+ labels,
844
+ onToggle: () => layout.toggleVisible(core.ACTIONS_COLUMN_KEY)
845
+ }
846
+ ),
847
+ /* @__PURE__ */ jsxRuntime.jsx(RowName, { hidden, name: labels.actions }),
848
+ /* @__PURE__ */ jsxRuntime.jsx(
849
+ PinToggle,
850
+ {
851
+ active: pinned,
852
+ label: `${pinned ? labels.unpin : labels.pinRight}: ${labels.actions}`,
853
+ onClick: () => layout.setPinned(core.ACTIONS_COLUMN_KEY, pinned ? void 0 : "right")
854
+ }
855
+ )
856
+ ]
857
+ }
858
+ )
859
+ ] });
860
+ }
861
+ function ColumnMenu({
862
+ allColumns,
863
+ layout,
864
+ labels,
865
+ hasRowActions
866
+ }) {
867
+ const drag = core.useColumnDragState();
868
+ const [anchor, setAnchor] = react.useState(null);
869
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
870
+ /* @__PURE__ */ jsxRuntime.jsx(
871
+ material.Button,
872
+ {
873
+ size: "small",
874
+ variant: "outlined",
875
+ "aria-expanded": anchor !== null,
876
+ "aria-haspopup": "true",
877
+ onClick: (e) => setAnchor(e.currentTarget),
878
+ children: labels.columns
879
+ }
880
+ ),
881
+ /* @__PURE__ */ jsxRuntime.jsx(
882
+ material.Popover,
883
+ {
884
+ anchorEl: anchor,
885
+ open: anchor !== null,
886
+ onClose: () => setAnchor(null),
887
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
888
+ children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { p: 0.75, minWidth: 250 }, children: [
889
+ /* @__PURE__ */ jsxRuntime.jsx(
890
+ material.Typography,
891
+ {
892
+ variant: "caption",
893
+ sx: {
894
+ display: "block",
895
+ px: 1,
896
+ pb: 0.5,
897
+ fontWeight: 600,
898
+ textTransform: "uppercase",
899
+ letterSpacing: "0.06em",
900
+ color: "text.secondary"
901
+ },
902
+ children: labels.columns
903
+ }
904
+ ),
905
+ core.columnMenuRows(allColumns, layout).map((r) => {
906
+ const indicator = drag.rowAttrs(r.key, r.index);
907
+ const edge = indicator["data-drop"];
908
+ const edgeOffset = edge === "before" ? "2px" : "-2px";
909
+ return /* @__PURE__ */ jsxRuntime.jsxs(
910
+ material.Stack,
911
+ {
912
+ direction: "row",
913
+ alignItems: "center",
914
+ spacing: 0.5,
915
+ sx: {
916
+ px: 0.5,
917
+ py: 0.25,
918
+ cursor: "grab",
919
+ opacity: "data-dragging" in indicator ? 0.4 : void 0,
920
+ boxShadow: edge ? (theme) => `inset 0 ${edgeOffset} 0 0 ${theme.palette.primary.main}` : void 0
921
+ },
922
+ ...drag.rowDragProps(r.key, r.index),
923
+ ...drag.dropProps(r.index, layout.move),
924
+ ...indicator,
925
+ children: [
926
+ /* @__PURE__ */ jsxRuntime.jsx(
927
+ material.IconButton,
928
+ {
929
+ size: "small",
930
+ sx: { cursor: "grab", color: "text.disabled" },
931
+ ...core.columnReorderKeyProps(
932
+ r.key,
933
+ r.index,
934
+ layout.move,
935
+ `${labels.moveLeft} / ${labels.moveRight}: ${r.name}`
936
+ ),
937
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.GripIcon, {})
938
+ }
939
+ ),
940
+ /* @__PURE__ */ jsxRuntime.jsx(
941
+ VisibilityToggle,
942
+ {
943
+ hidden: r.hidden,
944
+ name: r.name,
945
+ labels,
946
+ onToggle: () => layout.toggleVisible(r.key)
947
+ }
948
+ ),
949
+ /* @__PURE__ */ jsxRuntime.jsx(RowName, { hidden: r.hidden, name: r.name }),
950
+ /* @__PURE__ */ jsxRuntime.jsx(
951
+ PinToggle,
952
+ {
953
+ active: r.pinned !== void 0,
954
+ label: `${core.pinActionLabel(r.pinned, labels)}: ${r.name}`,
955
+ onClick: () => layout.setPinned(r.key, core.nextPinSide(r.pinned))
956
+ }
957
+ )
958
+ ]
959
+ },
960
+ r.key
961
+ );
962
+ }),
963
+ hasRowActions && /* @__PURE__ */ jsxRuntime.jsx(ActionsRow, { layout, labels }),
964
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { my: 0.5 } }),
965
+ /* @__PURE__ */ jsxRuntime.jsx(
966
+ material.Button,
967
+ {
968
+ size: "small",
969
+ fullWidth: true,
970
+ sx: { justifyContent: "flex-start" },
971
+ onClick: () => layout.reset(),
972
+ children: labels.resetColumns
973
+ }
974
+ )
975
+ ] })
976
+ }
977
+ )
978
+ ] });
979
+ }
980
+ var RESIZE_HANDLE_SX = {
981
+ position: "absolute",
982
+ insetInlineEnd: 0,
983
+ top: 0,
984
+ height: "100%",
985
+ width: 8,
986
+ cursor: "col-resize",
987
+ touchAction: "none",
988
+ userSelect: "none"
989
+ };
990
+ function muiColor(color) {
991
+ return color === "danger" || color === "red" || color === "error" ? "error" : "default";
992
+ }
993
+ var EXPAND_WIDTH = 48;
994
+ function useStableToggle(target) {
995
+ const ref = react.useRef(target);
996
+ ref.current = target;
997
+ return react.useCallback((id) => ref.current?.toggle(id), []);
998
+ }
999
+ function ExpandChevron({
1000
+ expanded,
1001
+ dir
1002
+ }) {
1003
+ let transform;
1004
+ if (expanded) transform = "rotate(90deg)";
1005
+ else if (dir === "rtl") transform = "rotate(180deg)";
1006
+ return /* @__PURE__ */ jsxRuntime.jsx(
1007
+ material.Box,
1008
+ {
1009
+ component: "span",
1010
+ "aria-hidden": true,
1011
+ sx: { display: "inline-flex", transition: "transform 150ms", transform },
1012
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1013
+ "svg",
1014
+ {
1015
+ width: "1em",
1016
+ height: "1em",
1017
+ viewBox: "0 0 24 24",
1018
+ fill: "none",
1019
+ stroke: "currentColor",
1020
+ strokeWidth: "2",
1021
+ strokeLinecap: "round",
1022
+ strokeLinejoin: "round",
1023
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 6l6 6-6 6" })
1024
+ }
1025
+ )
1026
+ }
1027
+ );
1028
+ }
1029
+ function ExpandToggle({
1030
+ id,
1031
+ expanded,
1032
+ onToggle,
1033
+ dir,
1034
+ expandLabel,
1035
+ collapseLabel
1036
+ }) {
1037
+ return /* @__PURE__ */ jsxRuntime.jsx(
1038
+ material.IconButton,
1039
+ {
1040
+ size: "small",
1041
+ "aria-expanded": expanded,
1042
+ "aria-label": expanded ? collapseLabel : expandLabel,
1043
+ onClick: () => onToggle(id),
1044
+ children: /* @__PURE__ */ jsxRuntime.jsx(ExpandChevron, { expanded, dir })
1045
+ }
1046
+ );
1047
+ }
1048
+ function muiAlign(align) {
1049
+ if (align === "center") return "center";
1050
+ if (align === "end") return "end";
1051
+ return "start";
1052
+ }
1053
+ function RowActionButtons({
1054
+ row,
1055
+ actions,
1056
+ confirm,
1057
+ cancelLabel
1058
+ }) {
1059
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Stack, { direction: "row", spacing: 0.5, justifyContent: "flex-end", children: actions.map((action) => {
1060
+ if (action.isHidden?.(row)) return null;
1061
+ const reason = core.resolveDisabledReason(action.disabledReason?.(row));
1062
+ const disabled = reason !== void 0 || (action.isDisabled?.(row) ?? false);
1063
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: reason ?? action.label, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(
1064
+ material.IconButton,
1065
+ {
1066
+ size: "small",
1067
+ color: muiColor(action.color),
1068
+ disabled,
1069
+ "aria-label": action.label,
1070
+ onClick: (
1071
+ // The disabled attribute already blocks activation, so
1072
+ // attach the handler only when the action can run.
1073
+ disabled ? void 0 : (e) => {
1074
+ e.stopPropagation();
1075
+ core.runRowAction(action, row, confirm, cancelLabel);
1076
+ }
1077
+ ),
1078
+ children: action.icon ?? /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "caption", children: action.label })
1079
+ }
1080
+ ) }) }, action.key);
1081
+ }) });
1082
+ }
1083
+ var DESKTOP_ROW_COMPARED = [
1084
+ "row",
1085
+ "index",
1086
+ "selected",
1087
+ "expanded",
1088
+ "columns",
1089
+ "sx",
1090
+ "columnSpan",
1091
+ "size",
1092
+ "dir",
1093
+ "className",
1094
+ "hasSelection",
1095
+ "hasExpansion",
1096
+ "showActions",
1097
+ "selectRowLabel",
1098
+ "cancelLabel",
1099
+ "expandLabel",
1100
+ "collapseLabel"
1101
+ ];
1102
+ function desktopRowPropsAreEqual(prev, next) {
1103
+ return DESKTOP_ROW_COMPARED.every((key) => prev[key] === next[key]);
1104
+ }
1105
+ function DesktopRowImpl({
1106
+ row,
1107
+ index,
1108
+ selected,
1109
+ expanded,
1110
+ columns,
1111
+ sx,
1112
+ columnSpan,
1113
+ dir,
1114
+ className,
1115
+ hasSelection,
1116
+ hasExpansion,
1117
+ showActions,
1118
+ selectRowLabel,
1119
+ cancelLabel,
1120
+ expandLabel,
1121
+ collapseLabel,
1122
+ id,
1123
+ rowActions,
1124
+ confirm,
1125
+ renderRowDetail,
1126
+ onToggleSelect,
1127
+ onToggleExpand,
1128
+ onRowClick,
1129
+ prefetch,
1130
+ measureElement
1131
+ }) {
1132
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1133
+ /* @__PURE__ */ jsxRuntime.jsxs(
1134
+ material.TableRow,
1135
+ {
1136
+ ...core.rowClickProps(row, onRowClick),
1137
+ className,
1138
+ ref: measureElement,
1139
+ "data-index": index,
1140
+ hover: true,
1141
+ selected,
1142
+ onMouseEnter: prefetch ? () => prefetch(row) : void 0,
1143
+ children: [
1144
+ hasExpansion && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox", sx: sx.expand, children: /* @__PURE__ */ jsxRuntime.jsx(
1145
+ ExpandToggle,
1146
+ {
1147
+ id,
1148
+ expanded,
1149
+ onToggle: onToggleExpand,
1150
+ dir,
1151
+ expandLabel,
1152
+ collapseLabel
1153
+ }
1154
+ ) }),
1155
+ hasSelection && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox", sx: sx.selection, children: /* @__PURE__ */ jsxRuntime.jsx(
1156
+ material.Checkbox,
1157
+ {
1158
+ slotProps: { input: { "aria-label": selectRowLabel } },
1159
+ checked: selected,
1160
+ onChange: () => onToggleSelect(id)
1161
+ }
1162
+ ) }),
1163
+ columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { sx: sx.cells[column.key], children: column.Cell ? /* @__PURE__ */ jsxRuntime.jsx(column.Cell, { row, rowIndex: index }) : column.accessor?.(row) }, column.key)),
1164
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { sx: sx.actions, children: /* @__PURE__ */ jsxRuntime.jsx(
1165
+ RowActionButtons,
1166
+ {
1167
+ row,
1168
+ actions: rowActions,
1169
+ confirm,
1170
+ cancelLabel
1171
+ }
1172
+ ) })
1173
+ ]
1174
+ }
1175
+ ),
1176
+ expanded && /* @__PURE__ */ jsxRuntime.jsx(material.TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { colSpan: columnSpan, children: renderRowDetail(row) }) })
1177
+ ] });
1178
+ }
1179
+ var DesktopRow = react.memo(
1180
+ DesktopRowImpl,
1181
+ desktopRowPropsAreEqual
1182
+ );
1183
+ function DesktopTable({
1184
+ table,
1185
+ rows,
1186
+ rowActions,
1187
+ confirm,
1188
+ getRowId,
1189
+ size,
1190
+ dir,
1191
+ prefetch,
1192
+ onRowClick,
1193
+ rowClassName,
1194
+ renderRowDetail,
1195
+ summaryRow,
1196
+ expansion,
1197
+ rowEntries,
1198
+ paddingTop = 0,
1199
+ paddingBottom = 0,
1200
+ measureElement,
1201
+ stickyHeader = false,
1202
+ stickyTop = 0,
1203
+ pinOffset,
1204
+ maxHeight,
1205
+ virtualScrollRef,
1206
+ setWidth,
1207
+ columnWidths,
1208
+ resizeLabel = "Resize column",
1209
+ actionsPinned = false
1210
+ }) {
1211
+ const { columns, selection, labels, showActions, entries, columnSpan } = core.tableRenderModel({
1212
+ table,
1213
+ rows,
1214
+ rowActions,
1215
+ getRowId,
1216
+ rowEntries,
1217
+ renderRowDetail,
1218
+ expansion
1219
+ });
1220
+ const groupRow = core.headerGroupRow(columns);
1221
+ const summaryCells = summaryRow?.(rows);
1222
+ const isExpanded = expansion && renderRowDetail ? expansion.isExpanded : void 0;
1223
+ const expandActive = isExpanded !== void 0;
1224
+ const onToggleSelect = useStableToggle(selection);
1225
+ const onToggleExpand = useStableToggle(expansion);
1226
+ const hasPinned = actionsPinned || table.columns.some((c) => pinOffset?.(c.key) != null);
1227
+ const overflow = core.useHorizontalOverflow();
1228
+ const inScrollBox = maxHeight != null || hasPinned || overflow.overflowing;
1229
+ const headSx = stickyHeader ? {
1230
+ position: "sticky",
1231
+ top: inScrollBox ? 0 : stickyTop,
1232
+ zIndex: core.PIN_Z.header,
1233
+ bgcolor: "background.paper"
1234
+ } : void 0;
1235
+ const selectionWidth = 48;
1236
+ const actionsWidth = 120;
1237
+ const leadLeft = (expandActive ? EXPAND_WIDTH : 0) + (selection ? selectionWidth : 0);
1238
+ const leadRight = showActions ? actionsWidth : 0;
1239
+ const leads = { left: leadLeft, right: leadRight };
1240
+ const selectionLead = expandActive ? EXPAND_WIDTH : 0;
1241
+ const hasLeftPin = table.columns.some(
1242
+ (c) => pinOffset?.(c.key)?.side === "left"
1243
+ );
1244
+ const hasRightPin = table.columns.some(
1245
+ (c) => pinOffset?.(c.key)?.side === "right"
1246
+ );
1247
+ const stickActions = hasRightPin || actionsPinned;
1248
+ const headCellSx = (column) => {
1249
+ const pin = core.pinnedCellStyle(
1250
+ pinOffset?.(column.key),
1251
+ core.PIN_Z.headerPinned,
1252
+ leads
1253
+ );
1254
+ const width = pin ? core.pinnedColumnWidth(column, columnWidths) : columnWidths?.[column.key] ?? column.width;
1255
+ const needsRelative = Boolean(setWidth) && !headSx && !pin;
1256
+ return {
1257
+ ...headSx,
1258
+ ...pin && { ...pin, bgcolor: "background.paper" },
1259
+ ...needsRelative && { position: "relative" },
1260
+ textAlign: muiAlign(column.align),
1261
+ ...width != null && { width }
1262
+ };
1263
+ };
1264
+ const edgeHeadSx = (side, active, lead = 0) => {
1265
+ const pin = core.edgePinStyle(side, active, core.PIN_Z.headerPinned);
1266
+ return {
1267
+ ...headSx,
1268
+ ...pin && { ...pin, bgcolor: "background.paper" },
1269
+ ...pin && lead > 0 && { insetInlineStart: lead }
1270
+ };
1271
+ };
1272
+ const rowSx = react.useMemo(() => {
1273
+ const edge = (side, active, lead = 0) => {
1274
+ const pin = core.edgePinStyle(side, active, core.PIN_Z.body);
1275
+ if (!pin) return void 0;
1276
+ return {
1277
+ ...pin,
1278
+ ...lead > 0 && { insetInlineStart: lead },
1279
+ bgcolor: "background.paper"
1280
+ };
1281
+ };
1282
+ const cells = {};
1283
+ for (const column of columns) {
1284
+ const pin = core.pinnedCellStyle(pinOffset?.(column.key), core.PIN_Z.body, {
1285
+ left: leadLeft,
1286
+ right: leadRight
1287
+ });
1288
+ cells[column.key] = {
1289
+ ...pin && { ...pin, bgcolor: "background.paper" },
1290
+ textAlign: muiAlign(column.align)
1291
+ };
1292
+ }
1293
+ return {
1294
+ cells,
1295
+ expand: edge("left", hasLeftPin),
1296
+ selection: edge("left", hasLeftPin, selectionLead),
1297
+ actions: { ...edge("right", stickActions), textAlign: "end" }
1298
+ };
1299
+ }, [
1300
+ columns,
1301
+ pinOffset,
1302
+ leadLeft,
1303
+ leadRight,
1304
+ hasLeftPin,
1305
+ stickActions,
1306
+ selectionLead
1307
+ ]);
1308
+ let boxSx;
1309
+ if (maxHeight != null) {
1310
+ boxSx = { maxHeight, overflow: "auto" };
1311
+ } else if (hasPinned || overflow.overflowing) {
1312
+ boxSx = { overflowX: "auto" };
1313
+ }
1314
+ const minWidth = core.tableMinWidth(columns, {
1315
+ widths: columnWidths,
1316
+ extra: leadLeft + leadRight
1317
+ });
1318
+ return /* @__PURE__ */ jsxRuntime.jsx(
1319
+ material.Box,
1320
+ {
1321
+ ref: (node) => {
1322
+ overflow.ref(node);
1323
+ virtualScrollRef?.(node);
1324
+ },
1325
+ sx: boxSx,
1326
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1327
+ material.Table,
1328
+ {
1329
+ size,
1330
+ "aria-label": table.getTableProps()["aria-label"],
1331
+ sx: minWidth > 0 ? { minWidth } : void 0,
1332
+ children: [
1333
+ /* @__PURE__ */ jsxRuntime.jsxs(material.TableHead, { children: [
1334
+ groupRow && // Decorative group row. It deliberately skips the sticky `headSx`
1335
+ // treatment: sticking both header rows at the same `top` would
1336
+ // overlap them, so only the sortable header row pins.
1337
+ /* @__PURE__ */ jsxRuntime.jsxs(material.TableRow, { children: [
1338
+ expandActive && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox" }),
1339
+ selection && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox" }),
1340
+ groupRow.map((cell) => /* @__PURE__ */ jsxRuntime.jsx(
1341
+ material.TableCell,
1342
+ {
1343
+ colSpan: cell.span,
1344
+ sx: { textAlign: "center", fontWeight: 600 },
1345
+ children: cell.label
1346
+ },
1347
+ cell.key
1348
+ )),
1349
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, {})
1350
+ ] }),
1351
+ /* @__PURE__ */ jsxRuntime.jsxs(material.TableRow, { children: [
1352
+ expandActive && /* @__PURE__ */ jsxRuntime.jsx(
1353
+ material.TableCell,
1354
+ {
1355
+ padding: "checkbox",
1356
+ sx: edgeHeadSx("left", hasLeftPin)
1357
+ }
1358
+ ),
1359
+ selection && /* @__PURE__ */ jsxRuntime.jsx(
1360
+ material.TableCell,
1361
+ {
1362
+ padding: "checkbox",
1363
+ sx: edgeHeadSx("left", hasLeftPin, selectionLead),
1364
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1365
+ material.Checkbox,
1366
+ {
1367
+ slotProps: { input: { "aria-label": labels.selectAll } },
1368
+ checked: selection.headerState === "all",
1369
+ indeterminate: selection.headerState === "some",
1370
+ onChange: selection.toggleAll
1371
+ }
1372
+ )
1373
+ }
1374
+ ),
1375
+ columns.map((column) => {
1376
+ const headerCellProps = table.getHeaderCellProps(column);
1377
+ const ariaSort = headerCellProps["aria-sort"];
1378
+ const active = ariaSort === "ascending" || ariaSort === "descending";
1379
+ const sortIndex = headerCellProps["data-sort-index"];
1380
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1381
+ material.TableCell,
1382
+ {
1383
+ "aria-sort": ariaSort,
1384
+ "data-sort-index": sortIndex,
1385
+ sx: headCellSx(column),
1386
+ children: [
1387
+ column.sortable ? /* @__PURE__ */ jsxRuntime.jsxs(
1388
+ material.TableSortLabel,
1389
+ {
1390
+ active,
1391
+ direction: ariaSort === "descending" ? "desc" : "asc",
1392
+ onClick: table.getSortButtonProps(column).onClick,
1393
+ children: [
1394
+ column.header,
1395
+ sortIndex !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { fontSize: 10, ml: 0.5 }, children: sortIndex })
1396
+ ]
1397
+ }
1398
+ ) : column.header,
1399
+ setWidth && /* @__PURE__ */ jsxRuntime.jsx(
1400
+ material.Box,
1401
+ {
1402
+ component: "span",
1403
+ sx: RESIZE_HANDLE_SX,
1404
+ ...core.columnResizeHandleProps(
1405
+ column.key,
1406
+ setWidth,
1407
+ `${resizeLabel}: ${typeof column.header === "string" ? column.header : column.key}`
1408
+ )
1409
+ }
1410
+ )
1411
+ ]
1412
+ },
1413
+ column.key
1414
+ );
1415
+ }),
1416
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(
1417
+ material.TableCell,
1418
+ {
1419
+ sx: { ...edgeHeadSx("right", stickActions), textAlign: "end" },
1420
+ children: labels.actions
1421
+ }
1422
+ )
1423
+ ] })
1424
+ ] }),
1425
+ /* @__PURE__ */ jsxRuntime.jsxs(material.TableBody, { children: [
1426
+ paddingTop > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.TableRow, { "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
1427
+ material.TableCell,
1428
+ {
1429
+ colSpan: columnSpan,
1430
+ sx: { height: paddingTop, p: 0 }
1431
+ }
1432
+ ) }),
1433
+ entries.map(({ row, index, key }) => {
1434
+ const id = getRowId(row);
1435
+ return /* @__PURE__ */ jsxRuntime.jsx(
1436
+ DesktopRow,
1437
+ {
1438
+ row,
1439
+ index,
1440
+ selected: selection?.isSelected(id) ?? false,
1441
+ expanded: isExpanded ? isExpanded(id) : false,
1442
+ columns,
1443
+ sx: rowSx,
1444
+ columnSpan,
1445
+ size,
1446
+ dir,
1447
+ className: rowClassName?.(row, index),
1448
+ hasSelection: Boolean(selection),
1449
+ hasExpansion: expandActive,
1450
+ showActions,
1451
+ selectRowLabel: labels.selectRow,
1452
+ cancelLabel: labels.cancel,
1453
+ expandLabel: labels.expandRow,
1454
+ collapseLabel: labels.collapseRow,
1455
+ id,
1456
+ rowActions,
1457
+ confirm,
1458
+ renderRowDetail,
1459
+ onToggleSelect,
1460
+ onToggleExpand,
1461
+ onRowClick,
1462
+ prefetch,
1463
+ measureElement
1464
+ },
1465
+ key
1466
+ );
1467
+ }),
1468
+ paddingBottom > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.TableRow, { "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
1469
+ material.TableCell,
1470
+ {
1471
+ colSpan: columnSpan,
1472
+ sx: { height: paddingBottom, p: 0 }
1473
+ }
1474
+ ) })
1475
+ ] }),
1476
+ summaryCells && /* @__PURE__ */ jsxRuntime.jsx(material.TableFooter, { children: /* @__PURE__ */ jsxRuntime.jsxs(material.TableRow, { children: [
1477
+ expandActive && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox" }),
1478
+ selection && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, { padding: "checkbox" }),
1479
+ columns.map((column) => (
1480
+ // One cell per column keeps the summary aligned under its
1481
+ // column; keys absent from the result render empty cells.
1482
+ /* @__PURE__ */ jsxRuntime.jsx(
1483
+ material.TableCell,
1484
+ {
1485
+ sx: { textAlign: muiAlign(column.align) },
1486
+ children: summaryCells[column.key]
1487
+ },
1488
+ column.key
1489
+ )
1490
+ )),
1491
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(material.TableCell, {})
1492
+ ] }) })
1493
+ ]
1494
+ }
1495
+ )
1496
+ }
1497
+ );
1498
+ }
1499
+ function mobileLabel(column) {
1500
+ return column.mobileLabel ?? (typeof column.header === "string" ? column.header : column.key);
1501
+ }
1502
+ function MobileCards({
1503
+ table,
1504
+ rows,
1505
+ rowActions,
1506
+ confirm,
1507
+ getRowId,
1508
+ size,
1509
+ dir,
1510
+ onRowClick,
1511
+ rowClassName,
1512
+ renderRowDetail,
1513
+ summaryRow,
1514
+ expansion,
1515
+ rowEntries,
1516
+ paddingTop = 0,
1517
+ paddingBottom = 0,
1518
+ measureElement
1519
+ }) {
1520
+ const { columns, selection, labels } = table;
1521
+ const entries = core.resolveVirtualRows(rows, getRowId, rowEntries);
1522
+ const compact = size === "small";
1523
+ const expand = expansion && renderRowDetail ? expansion : void 0;
1524
+ const summaryCells = summaryRow?.(rows);
1525
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1526
+ material.Stack,
1527
+ {
1528
+ spacing: compact ? 1 : 1.5,
1529
+ role: "list",
1530
+ "aria-label": table.getTableProps()["aria-label"],
1531
+ children: [
1532
+ paddingTop > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { "aria-hidden": true, sx: { height: paddingTop } }),
1533
+ entries.map(({ row, index, key }) => {
1534
+ const id = getRowId(row);
1535
+ return /* @__PURE__ */ jsxRuntime.jsx(
1536
+ material.Card,
1537
+ {
1538
+ ref: measureElement,
1539
+ "data-index": index,
1540
+ variant: "outlined",
1541
+ role: "listitem",
1542
+ className: rowClassName?.(row, index),
1543
+ ...core.rowClickProps(row, onRowClick),
1544
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1545
+ material.CardContent,
1546
+ {
1547
+ sx: compact ? { p: 1.25, "&:last-child": { pb: 1.25 } } : void 0,
1548
+ children: [
1549
+ selection && /* @__PURE__ */ jsxRuntime.jsx(
1550
+ material.Checkbox,
1551
+ {
1552
+ slotProps: { input: { "aria-label": labels.selectRow } },
1553
+ checked: selection.isSelected(id),
1554
+ onChange: () => selection.toggle(id)
1555
+ }
1556
+ ),
1557
+ expand && /* @__PURE__ */ jsxRuntime.jsx(
1558
+ ExpandToggle,
1559
+ {
1560
+ id,
1561
+ expanded: expand.isExpanded(id),
1562
+ onToggle: expand.toggle,
1563
+ dir,
1564
+ expandLabel: labels.expandRow,
1565
+ collapseLabel: labels.collapseRow
1566
+ }
1567
+ ),
1568
+ columns.map((column) => /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { mb: compact ? 0.5 : 1 }, children: [
1569
+ /* @__PURE__ */ jsxRuntime.jsx(
1570
+ material.Typography,
1571
+ {
1572
+ variant: "caption",
1573
+ color: "text.secondary",
1574
+ display: "block",
1575
+ children: mobileLabel(column)
1576
+ }
1577
+ ),
1578
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { component: "div", variant: "body2", children: column.Cell ? /* @__PURE__ */ jsxRuntime.jsx(column.Cell, { row, rowIndex: index }) : column.accessor?.(row) })
1579
+ ] }, column.key)),
1580
+ rowActions && rowActions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1581
+ RowActionButtons,
1582
+ {
1583
+ row,
1584
+ actions: rowActions,
1585
+ confirm,
1586
+ cancelLabel: labels.cancel
1587
+ }
1588
+ ),
1589
+ expand?.isExpanded(id) && // Inside the card — and therefore inside the measured
1590
+ // element — so virtualization keeps accurate card heights.
1591
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mt: 1 }, children: renderRowDetail(row) })
1592
+ ]
1593
+ }
1594
+ )
1595
+ },
1596
+ key
1597
+ );
1598
+ }),
1599
+ summaryCells && /* @__PURE__ */ jsxRuntime.jsx(material.Card, { variant: "outlined", role: "listitem", children: /* @__PURE__ */ jsxRuntime.jsx(
1600
+ material.CardContent,
1601
+ {
1602
+ sx: compact ? { p: 1.25, "&:last-child": { pb: 1.25 } } : void 0,
1603
+ children: columns.map((column) => {
1604
+ const value = summaryCells[column.key];
1605
+ if (value === void 0) return null;
1606
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { mb: compact ? 0.5 : 1 }, children: [
1607
+ /* @__PURE__ */ jsxRuntime.jsx(
1608
+ material.Typography,
1609
+ {
1610
+ variant: "caption",
1611
+ color: "text.secondary",
1612
+ display: "block",
1613
+ children: mobileLabel(column)
1614
+ }
1615
+ ),
1616
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { component: "div", variant: "body2", children: value })
1617
+ ] }, column.key);
1618
+ })
1619
+ }
1620
+ ) }),
1621
+ paddingBottom > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { "aria-hidden": true, sx: { height: paddingBottom } })
1622
+ ]
1623
+ }
1624
+ );
1625
+ }
1626
+ function tableSize(size, density) {
1627
+ if (size) return size;
1628
+ return density === "compact" ? "small" : "medium";
1629
+ }
1630
+ function resizeSetter(enabled, setWidth) {
1631
+ return enabled ? setWidth : void 0;
1632
+ }
1633
+ function resolveActionsColumn(declared, layout) {
1634
+ const hasRowActions = (declared?.length ?? 0) > 0;
1635
+ const rowActions = hasRowActions && !layout.isHidden(core.ACTIONS_COLUMN_KEY) ? declared : void 0;
1636
+ const actionsPinned = rowActions !== void 0 && layout.state.pinned[core.ACTIONS_COLUMN_KEY] === "right";
1637
+ return { hasRowActions, rowActions, actionsPinned };
1638
+ }
1639
+ function useChromeProps(props) {
1640
+ const { source, runtime } = core.useTableData({
1641
+ locale: props.locale,
1642
+ source: props.source,
1643
+ data: props.data,
1644
+ total: props.total,
1645
+ loading: props.loading,
1646
+ onQueryChange: props.onQueryChange,
1647
+ columns: props.columns,
1648
+ filters: props.filters,
1649
+ adapter: props.urlSync === false ? void 0 : props.urlAdapter,
1650
+ enabled: props.urlSync,
1651
+ urlKey: props.urlKey
1652
+ });
1653
+ let filtersNode;
1654
+ if (core.isDeclarativeFilters(props.filters) || props.filters === void 0) {
1655
+ filtersNode = runtime.defs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1656
+ AutoFilterForm,
1657
+ {
1658
+ defs: runtime.defs,
1659
+ source,
1660
+ labels: core.resolveLabels(props.labels)
1661
+ }
1662
+ ) : void 0;
1663
+ } else {
1664
+ filtersNode = props.filters;
1665
+ }
1666
+ return {
1667
+ ...props,
1668
+ source,
1669
+ filters: filtersNode,
1670
+ filterLabels: { ...runtime.filterLabels, ...props.filterLabels }
1671
+ };
1672
+ }
1673
+ function DataTable(props) {
1674
+ const { slots, className } = props;
1675
+ const size = tableSize(props.size, props.density);
1676
+ const { filtersMode = "popover" } = props;
1677
+ const chromeProps = useChromeProps(props);
1678
+ const { source, filters: filtersNode } = chromeProps;
1679
+ const c = core.useTableChrome(chromeProps);
1680
+ const { table, confirm, getRowId } = c;
1681
+ const { labels } = table;
1682
+ const [filtersOpen, setFiltersOpen] = react.useState(false);
1683
+ const filtersTrigger = core.useFilterTriggerToggle(filtersOpen, setFiltersOpen);
1684
+ const rootRef = react.useRef(null);
1685
+ core.useChromeScrollReset(rootRef, c, chromeProps);
1686
+ const { virtualization, loadMoreRef, canLoadMore, virtualScrollRef } = core.useChromeBodyData(c, chromeProps);
1687
+ const { hasRowActions, rowActions, actionsPinned } = resolveActionsColumn(
1688
+ props.rowActions,
1689
+ c.columnLayout
1690
+ );
1691
+ const columnMenu = props.enableColumnMenu && !c.isMobile && /* @__PURE__ */ jsxRuntime.jsx(
1692
+ ColumnMenu,
1693
+ {
1694
+ allColumns: c.allColumns,
1695
+ layout: c.columnLayout,
1696
+ labels,
1697
+ hasRowActions
1698
+ }
1699
+ );
1700
+ const savedViewsMenu = props.savedViews && /* @__PURE__ */ jsxRuntime.jsx(
1701
+ SavedViewsMenu,
1702
+ {
1703
+ options: {
1704
+ adapter: props.urlAdapter,
1705
+ urlKey: props.urlKey,
1706
+ ...props.savedViews
1707
+ },
1708
+ labels
1709
+ }
1710
+ );
1711
+ let body;
1712
+ if (c.body === "skeleton") {
1713
+ body = slots?.skeleton ?? /* @__PURE__ */ jsxRuntime.jsx(
1714
+ LoadingState,
1715
+ {
1716
+ rows: props.skeletonRows ?? source.limit,
1717
+ columns: table.columns.length,
1718
+ loadingLabel: labels.loading
1719
+ }
1720
+ );
1721
+ } else if (c.body === "empty") {
1722
+ body = slots?.empty ?? /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { role: "status", spacing: 1.5, alignItems: "center", sx: { py: 6 }, children: [
1723
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { color: "text.secondary", align: "center", children: c.emptyVariant === "noResults" ? labels.noResults : labels.noData }),
1724
+ c.emptyVariant === "noResults" && /* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "outlined", size: "small", onClick: c.clearFilters, children: labels.clearAll })
1725
+ ] });
1726
+ } else if (c.body === "mobile") {
1727
+ body = /* @__PURE__ */ jsxRuntime.jsx(
1728
+ MobileCards,
1729
+ {
1730
+ table,
1731
+ rows: source.rows,
1732
+ rowActions,
1733
+ confirm,
1734
+ getRowId,
1735
+ size,
1736
+ dir: props.dir,
1737
+ onRowClick: props.onRowClick,
1738
+ rowClassName: props.rowClassName,
1739
+ renderRowDetail: props.renderRowDetail,
1740
+ summaryRow: props.summaryRow,
1741
+ expansion: c.detail?.expansion,
1742
+ rowEntries: virtualization.enabled ? virtualization.rows : void 0,
1743
+ paddingTop: virtualization.paddingTop,
1744
+ paddingBottom: virtualization.paddingBottom,
1745
+ measureElement: virtualization.measureElement
1746
+ }
1747
+ );
1748
+ } else {
1749
+ body = /* @__PURE__ */ jsxRuntime.jsx(
1750
+ DesktopTable,
1751
+ {
1752
+ table,
1753
+ rows: source.rows,
1754
+ rowActions,
1755
+ actionsPinned,
1756
+ confirm,
1757
+ getRowId,
1758
+ size,
1759
+ dir: props.dir,
1760
+ prefetch: props.prefetch,
1761
+ onRowClick: props.onRowClick,
1762
+ rowClassName: props.rowClassName,
1763
+ renderRowDetail: props.renderRowDetail,
1764
+ summaryRow: props.summaryRow,
1765
+ expansion: c.detail?.expansion,
1766
+ rowEntries: virtualization.enabled ? virtualization.rows : void 0,
1767
+ paddingTop: virtualization.paddingTop,
1768
+ paddingBottom: virtualization.paddingBottom,
1769
+ measureElement: virtualization.measureElement,
1770
+ stickyHeader: props.stickyHeader,
1771
+ stickyTop: props.stickyTop,
1772
+ pinOffset: c.columnLayout.pinOffset,
1773
+ maxHeight: props.maxHeight,
1774
+ virtualScrollRef,
1775
+ setWidth: resizeSetter(props.resizableColumns, c.columnLayout.setWidth),
1776
+ columnWidths: c.columnLayout.state.widths,
1777
+ resizeLabel: labels.resizeColumn
1778
+ }
1779
+ );
1780
+ }
1781
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1782
+ material.Paper,
1783
+ {
1784
+ ref: rootRef,
1785
+ variant: "outlined",
1786
+ dir: props.dir,
1787
+ className,
1788
+ "aria-busy": c.isRefreshing || void 0,
1789
+ sx: { p: 1.5 },
1790
+ children: [
1791
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { spacing: 1.5, children: [
1792
+ /* @__PURE__ */ jsxRuntime.jsx(
1793
+ Toolbar,
1794
+ {
1795
+ table,
1796
+ hideSearch: props.hideSearch,
1797
+ searchPlaceholder: props.searchPlaceholder,
1798
+ sortByOptions: props.sortByOptions,
1799
+ customToolbar: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1800
+ savedViewsMenu,
1801
+ props.toolbar
1802
+ ] }),
1803
+ hasFilters: Boolean(filtersNode),
1804
+ activeFilterCount: c.activeFilterCount,
1805
+ showRowsPerPage: canLoadMore,
1806
+ filtersMode,
1807
+ filters: filtersNode,
1808
+ filtersOpen,
1809
+ onToggleFilters: filtersTrigger.onClick,
1810
+ onFiltersTriggerPointerDown: filtersTrigger.onPointerDown,
1811
+ onCloseFilters: () => setFiltersOpen(false),
1812
+ onClearFilters: c.clearFilters,
1813
+ dir: props.dir,
1814
+ columnMenu
1815
+ }
1816
+ ),
1817
+ c.isRefreshing && /* @__PURE__ */ jsxRuntime.jsx(material.LinearProgress, { "aria-label": labels.loading }),
1818
+ /* @__PURE__ */ jsxRuntime.jsx(
1819
+ Chips,
1820
+ {
1821
+ chips: c.mergedChips,
1822
+ onClearAll: c.clearFilters,
1823
+ labels
1824
+ }
1825
+ ),
1826
+ table.selection && props.bulkActions && /* @__PURE__ */ jsxRuntime.jsx(
1827
+ BulkBar,
1828
+ {
1829
+ selection: table.selection,
1830
+ total: source.total,
1831
+ bulkActions: props.bulkActions,
1832
+ confirm,
1833
+ labels
1834
+ }
1835
+ ),
1836
+ source.error ? /* @__PURE__ */ jsxRuntime.jsx(
1837
+ ErrorState,
1838
+ {
1839
+ error: source.error,
1840
+ labels,
1841
+ onRetry: source.refetch ? () => void source.refetch?.() : void 0
1842
+ }
1843
+ ) : body,
1844
+ canLoadMore && source.hasNextPage && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref: loadMoreRef, display: "flex", justifyContent: "center", py: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
1845
+ material.Button,
1846
+ {
1847
+ variant: "outlined",
1848
+ size: "small",
1849
+ disabled: source.isFetchingNextPage,
1850
+ onClick: () => source.fetchNextPage(),
1851
+ children: labels.loadMore
1852
+ }
1853
+ ) }),
1854
+ c.showFooter && /* @__PURE__ */ jsxRuntime.jsx(
1855
+ Footer,
1856
+ {
1857
+ pagination: table.pagination,
1858
+ total: source.total,
1859
+ limit: source.limit,
1860
+ setPage: source.setPage,
1861
+ setLimit: source.setLimit,
1862
+ labels
1863
+ }
1864
+ )
1865
+ ] }),
1866
+ filtersNode && filtersMode === "drawer" && /* @__PURE__ */ jsxRuntime.jsx(
1867
+ FilterDrawer,
1868
+ {
1869
+ open: filtersOpen,
1870
+ onClose: () => setFiltersOpen(false),
1871
+ filters: filtersNode,
1872
+ activeFilterCount: c.activeFilterCount,
1873
+ onClearFilters: c.clearFilters,
1874
+ labels,
1875
+ dir: props.dir
1876
+ }
1877
+ )
1878
+ ]
1879
+ }
1880
+ );
1881
+ }
1882
+
1883
+ Object.defineProperty(exports, "createHistoryAdapter", {
1884
+ enumerable: true,
1885
+ get: function () { return core.createHistoryAdapter; }
1886
+ });
1887
+ Object.defineProperty(exports, "createMemoryAdapter", {
1888
+ enumerable: true,
1889
+ get: function () { return core.createMemoryAdapter; }
1890
+ });
1891
+ Object.defineProperty(exports, "defaultConfirm", {
1892
+ enumerable: true,
1893
+ get: function () { return core.defaultConfirm; }
1894
+ });
1895
+ Object.defineProperty(exports, "defaultLabels", {
1896
+ enumerable: true,
1897
+ get: function () { return core.defaultLabels; }
1898
+ });
1899
+ Object.defineProperty(exports, "deriveSortByOptions", {
1900
+ enumerable: true,
1901
+ get: function () { return core.deriveSortByOptions; }
1902
+ });
1903
+ Object.defineProperty(exports, "getHistoryAdapter", {
1904
+ enumerable: true,
1905
+ get: function () { return core.getHistoryAdapter; }
1906
+ });
1907
+ Object.defineProperty(exports, "useBackendData", {
1908
+ enumerable: true,
1909
+ get: function () { return core.useBackendData; }
1910
+ });
1911
+ Object.defineProperty(exports, "useDataTable", {
1912
+ enumerable: true,
1913
+ get: function () { return core.useDataTable; }
1914
+ });
1915
+ Object.defineProperty(exports, "useFrontendData", {
1916
+ enumerable: true,
1917
+ get: function () { return core.useFrontendData; }
1918
+ });
1919
+ Object.defineProperty(exports, "useSavedViews", {
1920
+ enumerable: true,
1921
+ get: function () { return core.useSavedViews; }
1922
+ });
1923
+ Object.defineProperty(exports, "useTableUrlState", {
1924
+ enumerable: true,
1925
+ get: function () { return core.useTableUrlState; }
1926
+ });
1927
+ exports.DataTable = DataTable;
1928
+ exports.SavedViewsMenu = SavedViewsMenu;
1929
+ //# sourceMappingURL=index.cjs.map
1930
+ //# sourceMappingURL=index.cjs.map