schummar-table 0.5.0-beta-6 → 0.5.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/cjs/index.js +197 -155
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mui4Theme.js.map +1 -1
- package/dist/cjs/mui5Theme.js.map +1 -1
- package/dist/cjs/tableTheme.js +317 -295
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +199 -158
- package/dist/es/index.js.map +1 -1
- package/dist/es/mui4Theme.js +1 -1
- package/dist/es/mui4Theme.js.map +1 -1
- package/dist/es/mui5Theme.js +1 -1
- package/dist/es/mui5Theme.js.map +1 -1
- package/dist/es/tableTheme.js +319 -298
- package/dist/es/tableTheme.js.map +1 -1
- package/dist/types/components/autoFocusTextField.d.ts +5 -0
- package/dist/types/components/dateFilter.d.ts +2 -0
- package/dist/types/components/datePicker.d.ts +0 -1
- package/dist/types/components/filterControl.d.ts +2 -1
- package/dist/types/components/formControlLabel.d.ts +2 -1
- package/dist/types/components/resizeHandle.d.ts +4 -0
- package/dist/types/hooks/useFilter.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/theme/defaultTheme/defaultTableTheme.d.ts +2 -0
- package/dist/types/theme/defaultTheme/popover.d.ts +4 -1
- package/dist/types/theme/mui4Theme/index.d.ts +2 -3
- package/dist/types/theme/mui5Theme/index.d.ts +2 -3
- package/dist/types/theme/tableTheme.d.ts +5 -6
- package/dist/types/types.d.ts +9 -5
- package/package.json +2 -3
package/dist/cjs/index.js
CHANGED
|
@@ -33,13 +33,36 @@ var __objRest = (source, exclude) => {
|
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports[Symbol.toStringTag] = "Module";
|
|
35
35
|
var react = require("react");
|
|
36
|
-
var dayzed = require("dayzed");
|
|
37
36
|
var tableTheme = require("./tableTheme.js");
|
|
38
37
|
var jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
38
|
+
var dayzed = require("dayzed");
|
|
39
39
|
var immer = require("immer");
|
|
40
40
|
var react$1 = require("schummar-state/react");
|
|
41
41
|
require("@emotion/react");
|
|
42
42
|
require("react-dom");
|
|
43
|
+
function useTheme() {
|
|
44
|
+
const table = useTableContext();
|
|
45
|
+
return table.useState("theme");
|
|
46
|
+
}
|
|
47
|
+
function AutoFocusTextField(props) {
|
|
48
|
+
const {
|
|
49
|
+
components: {
|
|
50
|
+
TextField
|
|
51
|
+
}
|
|
52
|
+
} = useTheme();
|
|
53
|
+
const ref = react.useRef(null);
|
|
54
|
+
const {
|
|
55
|
+
visible
|
|
56
|
+
} = react.useContext(tableTheme.PopoverContext);
|
|
57
|
+
react.useLayoutEffect(() => {
|
|
58
|
+
if (visible && ref.current) {
|
|
59
|
+
ref.current.focus();
|
|
60
|
+
}
|
|
61
|
+
}, [visible]);
|
|
62
|
+
return jsxRuntime.jsx(TextField, __spreadProps(__spreadValues({}, props), {
|
|
63
|
+
inputRef: ref
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
43
66
|
function useCssVariables() {
|
|
44
67
|
const table = useTableContext();
|
|
45
68
|
return table.useState((state) => ({
|
|
@@ -56,13 +79,6 @@ const weekDays = [0, 1, 2, 3, 4, 5, 6];
|
|
|
56
79
|
const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
57
80
|
const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
58
81
|
const endOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, -1);
|
|
59
|
-
const today = () => {
|
|
60
|
-
const today2 = startOfDay(new Date());
|
|
61
|
-
return {
|
|
62
|
-
min: today2,
|
|
63
|
-
max: today2
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
82
|
function dateIntersect(a, b) {
|
|
67
83
|
if (a instanceof Date) {
|
|
68
84
|
a = {
|
|
@@ -310,6 +326,7 @@ function YearSelector({
|
|
|
310
326
|
locale
|
|
311
327
|
}) {
|
|
312
328
|
const [input, setInput] = react.useState();
|
|
329
|
+
const ref = react.useRef(null);
|
|
313
330
|
function apply() {
|
|
314
331
|
onChange(Number(input));
|
|
315
332
|
setInput(void 0);
|
|
@@ -322,6 +339,10 @@ function YearSelector({
|
|
|
322
339
|
});
|
|
323
340
|
return (year) => format(new Date(year, 0, 1));
|
|
324
341
|
}, [locale]);
|
|
342
|
+
react.useLayoutEffect(() => {
|
|
343
|
+
var _a;
|
|
344
|
+
return (_a = ref.current) == null ? void 0 : _a.focus();
|
|
345
|
+
}, [ref.current]);
|
|
325
346
|
if (input === void 0) {
|
|
326
347
|
return jsxRuntime.jsx("div", {
|
|
327
348
|
onClick: () => setInput(String(value)),
|
|
@@ -329,6 +350,7 @@ function YearSelector({
|
|
|
329
350
|
});
|
|
330
351
|
}
|
|
331
352
|
return jsxRuntime.jsx("input", {
|
|
353
|
+
ref,
|
|
332
354
|
css: {
|
|
333
355
|
width: "4ch"
|
|
334
356
|
},
|
|
@@ -406,49 +428,66 @@ function DateFilter(_a) {
|
|
|
406
428
|
return jsxRuntime.jsxs("div", {
|
|
407
429
|
css: {
|
|
408
430
|
padding: "calc(var(--spacing) * 2)",
|
|
409
|
-
display: "grid"
|
|
410
|
-
gap: "var(--spacing)",
|
|
411
|
-
justifyItems: "center"
|
|
431
|
+
display: "grid"
|
|
412
432
|
},
|
|
413
|
-
children: [jsxRuntime.jsxs("div", {
|
|
433
|
+
children: [!singleSelect && jsxRuntime.jsxs("div", {
|
|
414
434
|
css: {
|
|
415
435
|
marginBottom: "var(--spacing)",
|
|
416
|
-
display: "
|
|
417
|
-
|
|
418
|
-
gap: "calc(var(--spacing) * 4)",
|
|
419
|
-
justifyContent: "space-between",
|
|
420
|
-
alignItems: "center"
|
|
436
|
+
display: "flex",
|
|
437
|
+
justifyContent: "center"
|
|
421
438
|
},
|
|
422
|
-
children: [
|
|
423
|
-
css: {
|
|
424
|
-
minWidth: "22ch"
|
|
425
|
-
},
|
|
426
|
-
children: !value ? text.dateFilter : value instanceof Date ? formatDate(value) : [formatDate(value.min), formatDate(value.max)].join(" - ")
|
|
427
|
-
}), jsxRuntime.jsxs("div", {
|
|
428
|
-
css: {
|
|
429
|
-
display: "grid",
|
|
430
|
-
gridAutoFlow: "column",
|
|
431
|
-
gap: "var(--spacing)"
|
|
432
|
-
},
|
|
433
|
-
children: [jsxRuntime.jsx(Button, {
|
|
434
|
-
variant: "contained",
|
|
435
|
-
onClick: () => onChange(today()),
|
|
436
|
-
children: text.today
|
|
437
|
-
}), jsxRuntime.jsx(Button, {
|
|
438
|
-
variant: "contained",
|
|
439
|
-
onClick: () => onChange(null),
|
|
440
|
-
children: text.reset
|
|
441
|
-
})]
|
|
442
|
-
})]
|
|
439
|
+
children: [value ? formatDate(value instanceof Date ? value : value.min) : "", " -", " ", value ? formatDate(value instanceof Date ? value : value.max) : ""]
|
|
443
440
|
}), jsxRuntime.jsx(DatePicker, {
|
|
444
441
|
rangeSelect: !singleSelect,
|
|
445
442
|
value,
|
|
446
443
|
onChange,
|
|
447
444
|
locale,
|
|
448
445
|
firstDayOfWeek
|
|
446
|
+
}), jsxRuntime.jsxs("div", {
|
|
447
|
+
css: {
|
|
448
|
+
marginTop: "var(--spacing)",
|
|
449
|
+
display: "grid",
|
|
450
|
+
gridAutoFlow: "column",
|
|
451
|
+
justifyContent: "center"
|
|
452
|
+
},
|
|
453
|
+
children: [jsxRuntime.jsx(Button, {
|
|
454
|
+
variant: "text",
|
|
455
|
+
onClick: () => onChange(today()),
|
|
456
|
+
children: text.today
|
|
457
|
+
}), jsxRuntime.jsx(Button, {
|
|
458
|
+
variant: "text",
|
|
459
|
+
onClick: () => onChange(thisWeek(firstDayOfWeek)),
|
|
460
|
+
children: text.thisWeek
|
|
461
|
+
}), jsxRuntime.jsx(Button, {
|
|
462
|
+
variant: "text",
|
|
463
|
+
onClick: () => onChange(null),
|
|
464
|
+
children: text.reset
|
|
465
|
+
})]
|
|
449
466
|
})]
|
|
450
467
|
});
|
|
451
468
|
}
|
|
469
|
+
const today = () => {
|
|
470
|
+
const today2 = startOfDay(new Date());
|
|
471
|
+
return {
|
|
472
|
+
min: today2,
|
|
473
|
+
max: today2
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
const thisWeek = (firstDayOfWeek = 0) => {
|
|
477
|
+
const now = new Date();
|
|
478
|
+
const min = new Date(now);
|
|
479
|
+
let diff = min.getDay() - firstDayOfWeek;
|
|
480
|
+
if (diff < 0) {
|
|
481
|
+
diff += 7;
|
|
482
|
+
}
|
|
483
|
+
min.setDate(min.getDate() - diff);
|
|
484
|
+
const max = new Date(min);
|
|
485
|
+
max.setDate(max.getDate() + 6);
|
|
486
|
+
return {
|
|
487
|
+
min: startOfDay(min),
|
|
488
|
+
max: endOfDay(max)
|
|
489
|
+
};
|
|
490
|
+
};
|
|
452
491
|
const flatMap = (arr, flatMap2) => {
|
|
453
492
|
return [...arr].reduce((out, cur) => out.concat(flatMap2(cur)), []);
|
|
454
493
|
};
|
|
@@ -529,10 +568,11 @@ const cx = (...classNames) => classNames.flatMap((entry) => {
|
|
|
529
568
|
}).join(" ");
|
|
530
569
|
function FormControlLabel({
|
|
531
570
|
control,
|
|
532
|
-
label
|
|
571
|
+
label,
|
|
572
|
+
disabled
|
|
533
573
|
}) {
|
|
534
574
|
return jsxRuntime.jsxs("label", {
|
|
535
|
-
css: {
|
|
575
|
+
css: [{
|
|
536
576
|
display: "flex",
|
|
537
577
|
alignItems: "center",
|
|
538
578
|
cursor: "pointer",
|
|
@@ -540,7 +580,9 @@ function FormControlLabel({
|
|
|
540
580
|
"& > *": {
|
|
541
581
|
cursor: "pointer"
|
|
542
582
|
}
|
|
543
|
-
},
|
|
583
|
+
}, disabled && {
|
|
584
|
+
color: "rgba(0, 0, 0, 0.26)"
|
|
585
|
+
}],
|
|
544
586
|
children: [control, jsxRuntime.jsx("span", {
|
|
545
587
|
css: {
|
|
546
588
|
marginLeft: "var(--spacing)"
|
|
@@ -1257,7 +1299,11 @@ function Export() {
|
|
|
1257
1299
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1258
1300
|
children: [jsxRuntime.jsx(IconButton, {
|
|
1259
1301
|
onClick: (e) => setAnchor(anchor ? null : e.currentTarget),
|
|
1260
|
-
children: jsxRuntime.jsx(Export2, {
|
|
1302
|
+
children: jsxRuntime.jsx(Export2, {
|
|
1303
|
+
css: !!anchor && {
|
|
1304
|
+
color: "var(--primaryMain)"
|
|
1305
|
+
}
|
|
1306
|
+
})
|
|
1261
1307
|
}), jsxRuntime.jsx(Popover, {
|
|
1262
1308
|
open: !!anchor,
|
|
1263
1309
|
onClose: () => setAnchor(null),
|
|
@@ -1291,10 +1337,7 @@ function Export() {
|
|
|
1291
1337
|
})]
|
|
1292
1338
|
});
|
|
1293
1339
|
}
|
|
1294
|
-
|
|
1295
|
-
const table = useTableContext();
|
|
1296
|
-
return table.useState("theme");
|
|
1297
|
-
}
|
|
1340
|
+
const FilterControlContext = react.createContext(() => void 0);
|
|
1298
1341
|
function FilterControl() {
|
|
1299
1342
|
const table = useTableContext();
|
|
1300
1343
|
const columnId = useColumnContext();
|
|
@@ -1319,16 +1362,33 @@ function FilterControl() {
|
|
|
1319
1362
|
var _a;
|
|
1320
1363
|
return (_a = state.activeColumns.find((column) => column.id === columnId)) == null ? void 0 : _a.filter;
|
|
1321
1364
|
});
|
|
1365
|
+
function reset() {
|
|
1366
|
+
table.update((state) => {
|
|
1367
|
+
state.filterValues.delete(columnId);
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
const close = react.useCallback(function() {
|
|
1371
|
+
setAnchor(null);
|
|
1372
|
+
}, []);
|
|
1322
1373
|
if (!filter)
|
|
1323
1374
|
return null;
|
|
1324
|
-
return jsxRuntime.jsxs(
|
|
1325
|
-
|
|
1375
|
+
return jsxRuntime.jsxs(FilterControlContext.Provider, {
|
|
1376
|
+
value: close,
|
|
1377
|
+
children: [jsxRuntime.jsx("div", {
|
|
1326
1378
|
onClick: (e) => setAnchor(e.currentTarget),
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1379
|
+
onContextMenu: (e) => {
|
|
1380
|
+
reset();
|
|
1381
|
+
e.preventDefault();
|
|
1382
|
+
return false;
|
|
1383
|
+
},
|
|
1384
|
+
children: jsxRuntime.jsx(IconButton, {
|
|
1385
|
+
css: [{
|
|
1386
|
+
color: "#b0bac9"
|
|
1387
|
+
}, isActive && {
|
|
1388
|
+
color: "var(--primaryMain) !important"
|
|
1389
|
+
}],
|
|
1390
|
+
children: isActive ? jsxRuntime.jsx(FilterList, {}) : jsxRuntime.jsx(ArrowDropDown, {})
|
|
1391
|
+
})
|
|
1332
1392
|
}), jsxRuntime.jsx("div", {
|
|
1333
1393
|
onPointerDown: (e) => {
|
|
1334
1394
|
e.stopPropagation();
|
|
@@ -1381,7 +1441,21 @@ function ResizeHandle() {
|
|
|
1381
1441
|
}
|
|
1382
1442
|
});
|
|
1383
1443
|
}
|
|
1384
|
-
return jsxRuntime.jsx(
|
|
1444
|
+
return jsxRuntime.jsx(ResizeHandleView, {
|
|
1445
|
+
enabled,
|
|
1446
|
+
onPointerDown: enabled ? onPointerDown : void 0,
|
|
1447
|
+
onPointerMove: enabled ? onPointerMove : void 0,
|
|
1448
|
+
onPointerUp: enabled ? onPointerUp : void 0,
|
|
1449
|
+
onDoubleClick: enabled ? onDoubleClick : void 0
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
function ResizeHandleView(_c) {
|
|
1453
|
+
var _d = _c, {
|
|
1454
|
+
enabled
|
|
1455
|
+
} = _d, props = __objRest(_d, [
|
|
1456
|
+
"enabled"
|
|
1457
|
+
]);
|
|
1458
|
+
return jsxRuntime.jsx("div", __spreadValues({
|
|
1385
1459
|
css: {
|
|
1386
1460
|
alignSelf: "stretch",
|
|
1387
1461
|
padding: "0 5px",
|
|
@@ -1391,16 +1465,12 @@ function ResizeHandle() {
|
|
|
1391
1465
|
"&:after": {
|
|
1392
1466
|
content: '""',
|
|
1393
1467
|
width: 1,
|
|
1394
|
-
height: "1.
|
|
1395
|
-
background: "
|
|
1468
|
+
height: "1.5em",
|
|
1469
|
+
background: "#c9cfda",
|
|
1396
1470
|
transition: "transform 300ms"
|
|
1397
1471
|
}
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
onPointerMove: enabled ? onPointerMove : void 0,
|
|
1401
|
-
onPointerUp: enabled ? onPointerUp : void 0,
|
|
1402
|
-
onDoubleClick: enabled ? onDoubleClick : void 0
|
|
1403
|
-
});
|
|
1472
|
+
}
|
|
1473
|
+
}, props));
|
|
1404
1474
|
}
|
|
1405
1475
|
const Cell = react.memo(function Cell2({
|
|
1406
1476
|
itemId,
|
|
@@ -1562,7 +1632,7 @@ function SelectComponent({
|
|
|
1562
1632
|
return jsxRuntime.jsx(Checkbox, {
|
|
1563
1633
|
css: {
|
|
1564
1634
|
justifySelf: "start",
|
|
1565
|
-
color: "
|
|
1635
|
+
color: "#c9cfda"
|
|
1566
1636
|
},
|
|
1567
1637
|
checked: isSelected,
|
|
1568
1638
|
onChange: toggle2
|
|
@@ -1669,7 +1739,7 @@ function SortComponent({
|
|
|
1669
1739
|
index: index2 >= 0 && state.sort.length > 1 ? index2 + 1 : void 0
|
|
1670
1740
|
};
|
|
1671
1741
|
});
|
|
1672
|
-
function toggle2(e) {
|
|
1742
|
+
function toggle2(e, off) {
|
|
1673
1743
|
const {
|
|
1674
1744
|
props: {
|
|
1675
1745
|
sort: controlledSort,
|
|
@@ -1677,16 +1747,21 @@ function SortComponent({
|
|
|
1677
1747
|
}
|
|
1678
1748
|
} = table.getState();
|
|
1679
1749
|
const newDirection = direction === "asc" ? "desc" : "asc";
|
|
1680
|
-
const newSort =
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1750
|
+
const newSort = e.getModifierState("Control") || off ? table.getState().sort.filter((s) => s.columnId !== columnId) : [];
|
|
1751
|
+
if (!off) {
|
|
1752
|
+
newSort.push({
|
|
1753
|
+
columnId,
|
|
1754
|
+
direction: newDirection
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1684
1757
|
onSortChange == null ? void 0 : onSortChange(newSort);
|
|
1685
1758
|
if (!controlledSort) {
|
|
1686
1759
|
table.update((state) => {
|
|
1687
1760
|
state.sort = newSort;
|
|
1688
1761
|
});
|
|
1689
1762
|
}
|
|
1763
|
+
e.preventDefault();
|
|
1764
|
+
return false;
|
|
1690
1765
|
}
|
|
1691
1766
|
return jsxRuntime.jsxs("div", {
|
|
1692
1767
|
css: {
|
|
@@ -1700,7 +1775,8 @@ function SortComponent({
|
|
|
1700
1775
|
textOverflow: "ellipsis"
|
|
1701
1776
|
}
|
|
1702
1777
|
},
|
|
1703
|
-
onClick: toggle2,
|
|
1778
|
+
onClick: (e) => toggle2(e),
|
|
1779
|
+
onContextMenu: (e) => toggle2(e, true),
|
|
1704
1780
|
children: [jsxRuntime.jsx("div", {
|
|
1705
1781
|
children
|
|
1706
1782
|
}), jsxRuntime.jsx(Badge, {
|
|
@@ -1748,23 +1824,11 @@ function throttle(fn, ms) {
|
|
|
1748
1824
|
}
|
|
1749
1825
|
});
|
|
1750
1826
|
}
|
|
1751
|
-
const onAncestorScroll = (x, onScroll) => {
|
|
1752
|
-
const find = (x2) => x2.parentElement ? [x2.parentElement, ...find(x2.parentElement)] : [document];
|
|
1753
|
-
const ancestors = find(x);
|
|
1754
|
-
for (const ancestor of ancestors) {
|
|
1755
|
-
ancestor.addEventListener("scroll", onScroll);
|
|
1756
|
-
}
|
|
1757
|
-
return () => {
|
|
1758
|
-
for (const ancestor of ancestors) {
|
|
1759
|
-
ancestor.removeEventListener("scroll", onScroll);
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
};
|
|
1763
1827
|
const findScrollRoot = (x) => {
|
|
1764
1828
|
const parent = x.parentElement;
|
|
1765
1829
|
if (!parent)
|
|
1766
1830
|
return document.documentElement;
|
|
1767
|
-
if (parent.scrollHeight > parent.clientHeight)
|
|
1831
|
+
if (parent.scrollHeight > parent.clientHeight && getComputedStyle(parent).overflowY !== "visible")
|
|
1768
1832
|
return parent;
|
|
1769
1833
|
return findScrollRoot(parent);
|
|
1770
1834
|
};
|
|
@@ -1775,15 +1839,15 @@ const relativeOffset = (x, y) => {
|
|
|
1775
1839
|
return relativeOffset(x.offsetParent, y) + x.offsetTop;
|
|
1776
1840
|
return 0;
|
|
1777
1841
|
};
|
|
1778
|
-
function Virtualized(
|
|
1779
|
-
var
|
|
1842
|
+
function Virtualized(_e) {
|
|
1843
|
+
var _f = _e, {
|
|
1780
1844
|
header,
|
|
1781
1845
|
children
|
|
1782
|
-
} =
|
|
1846
|
+
} = _f, props = __objRest(_f, [
|
|
1783
1847
|
"header",
|
|
1784
1848
|
"children"
|
|
1785
1849
|
]);
|
|
1786
|
-
var _a, _b,
|
|
1850
|
+
var _a, _b, _c, _d;
|
|
1787
1851
|
const table = useTableContext();
|
|
1788
1852
|
const virtual = table.useState("props.virtual");
|
|
1789
1853
|
const probeRef = react.useRef(null);
|
|
@@ -1807,7 +1871,7 @@ function Virtualized(_c) {
|
|
|
1807
1871
|
const {
|
|
1808
1872
|
rowHeight,
|
|
1809
1873
|
initalRowHeight,
|
|
1810
|
-
overscan =
|
|
1874
|
+
overscan = 100,
|
|
1811
1875
|
overscanTop,
|
|
1812
1876
|
overscanBottom
|
|
1813
1877
|
} = (_a2 = state.props.virtual instanceof Object ? state.props.virtual : void 0) != null ? _a2 : {};
|
|
@@ -1842,15 +1906,20 @@ function Virtualized(_c) {
|
|
|
1842
1906
|
before: before2,
|
|
1843
1907
|
after: after2
|
|
1844
1908
|
};
|
|
1909
|
+
}, {
|
|
1910
|
+
throttle: 16
|
|
1845
1911
|
});
|
|
1846
|
-
const throttleScroll = (_b = (_a = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a.throttleScroll) != null ? _b :
|
|
1912
|
+
const throttleScroll = (_b = (_a = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a.throttleScroll) != null ? _b : 16;
|
|
1847
1913
|
const incCounter = react.useMemo(() => throttle(() => setCounter((c) => c + 1), throttleScroll), [throttleScroll]);
|
|
1848
1914
|
react.useEffect(() => {
|
|
1849
1915
|
if (!virtual || !probeRef.current)
|
|
1850
1916
|
return;
|
|
1851
|
-
|
|
1917
|
+
window.addEventListener("scroll", incCounter, true);
|
|
1918
|
+
return () => {
|
|
1919
|
+
window.removeEventListener("scroll", incCounter, true);
|
|
1920
|
+
};
|
|
1852
1921
|
}, [probeRef.current, incCounter]);
|
|
1853
|
-
(
|
|
1922
|
+
(_d = (_c = table.getState().props).debugRender) == null ? void 0 : _d.call(_c, `Virtualalized render ${from} to ${to}`);
|
|
1854
1923
|
return jsxRuntime.jsxs("div", __spreadProps(__spreadValues({}, props), {
|
|
1855
1924
|
children: [header, virtual && jsxRuntime.jsx("div", {
|
|
1856
1925
|
style: {
|
|
@@ -1934,7 +2003,7 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1934
2003
|
const cssVariables = useCssVariables();
|
|
1935
2004
|
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
1936
2005
|
return jsxRuntime.jsx(Virtualized, {
|
|
1937
|
-
className:
|
|
2006
|
+
className: classes == null ? void 0 : classes.table,
|
|
1938
2007
|
css: [cssVariables, tableTheme.defaultClasses.table, {
|
|
1939
2008
|
gridTemplateColumns: [
|
|
1940
2009
|
fullWidth === "right" || fullWidth === true ? "auto" : "0",
|
|
@@ -1951,11 +2020,11 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1951
2020
|
header: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1952
2021
|
children: [jsxRuntime.jsx("div", {
|
|
1953
2022
|
className: classes == null ? void 0 : classes.headerCell,
|
|
1954
|
-
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky]
|
|
2023
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1955
2024
|
}), jsxRuntime.jsxs("div", {
|
|
1956
2025
|
className: classes == null ? void 0 : classes.headerCell,
|
|
1957
|
-
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky],
|
|
1958
|
-
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export, {})]
|
|
2026
|
+
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
2027
|
+
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export, {}), jsxRuntime.jsx(ResizeHandleView, {})]
|
|
1959
2028
|
}), jsxRuntime.jsx(ColumnHeaderContext.Provider, {
|
|
1960
2029
|
children: activeColumns.map((column) => {
|
|
1961
2030
|
var _a2;
|
|
@@ -1963,20 +2032,20 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1963
2032
|
value: column.id,
|
|
1964
2033
|
children: jsxRuntime.jsxs(ColumnHeader, {
|
|
1965
2034
|
className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
|
|
1966
|
-
css: [tableTheme.defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky],
|
|
1967
|
-
children: [jsxRuntime.jsx(
|
|
2035
|
+
css: [tableTheme.defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
|
|
2036
|
+
children: [jsxRuntime.jsx(SortComponent, {
|
|
1968
2037
|
children: column.header
|
|
1969
2038
|
}), jsxRuntime.jsx("div", {
|
|
1970
2039
|
css: {
|
|
1971
2040
|
flex: 1
|
|
1972
2041
|
}
|
|
1973
|
-
}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
2042
|
+
}), jsxRuntime.jsx(FilterControl, {}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
1974
2043
|
}, column.id)
|
|
1975
2044
|
}, column.id);
|
|
1976
2045
|
})
|
|
1977
2046
|
}), jsxRuntime.jsx("div", {
|
|
1978
2047
|
className: classes == null ? void 0 : classes.headerCell,
|
|
1979
|
-
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky]
|
|
2048
|
+
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1980
2049
|
})]
|
|
1981
2050
|
}),
|
|
1982
2051
|
children: (itemIds, startIndex) => itemIds.map((itemId, index) => jsxRuntime.jsx(Row, {
|
|
@@ -1994,13 +2063,13 @@ function toggle(set, value, singleSelect) {
|
|
|
1994
2063
|
}
|
|
1995
2064
|
return newSet;
|
|
1996
2065
|
}
|
|
1997
|
-
function SelectFilter(
|
|
1998
|
-
var
|
|
2066
|
+
function SelectFilter(_g) {
|
|
2067
|
+
var _h = _g, {
|
|
1999
2068
|
options: providedOptions,
|
|
2000
2069
|
stringValue = asString,
|
|
2001
2070
|
render = stringValue,
|
|
2002
2071
|
singleSelect
|
|
2003
|
-
} =
|
|
2072
|
+
} = _h, props = __objRest(_h, [
|
|
2004
2073
|
"options",
|
|
2005
2074
|
"stringValue",
|
|
2006
2075
|
"render",
|
|
@@ -2008,8 +2077,6 @@ function SelectFilter(_e) {
|
|
|
2008
2077
|
]);
|
|
2009
2078
|
const {
|
|
2010
2079
|
components: {
|
|
2011
|
-
TextField,
|
|
2012
|
-
Button,
|
|
2013
2080
|
IconButton,
|
|
2014
2081
|
Checkbox
|
|
2015
2082
|
},
|
|
@@ -2051,24 +2118,7 @@ function SelectFilter(_e) {
|
|
|
2051
2118
|
display: "grid",
|
|
2052
2119
|
gap: "var(--spacing)"
|
|
2053
2120
|
},
|
|
2054
|
-
children: [jsxRuntime.
|
|
2055
|
-
css: {
|
|
2056
|
-
marginBottom: "var(--spacing)",
|
|
2057
|
-
display: "grid",
|
|
2058
|
-
gridAutoFlow: "column",
|
|
2059
|
-
gap: "var(--spacing)",
|
|
2060
|
-
justifyContent: "space-between",
|
|
2061
|
-
alignItems: "center"
|
|
2062
|
-
},
|
|
2063
|
-
children: [jsxRuntime.jsx("div", {
|
|
2064
|
-
children: text.selectFilter
|
|
2065
|
-
}), jsxRuntime.jsx(Button, {
|
|
2066
|
-
variant: "contained",
|
|
2067
|
-
onClick: () => onChange(/* @__PURE__ */ new Set()),
|
|
2068
|
-
disabled: value.size === 0,
|
|
2069
|
-
children: text.reset
|
|
2070
|
-
})]
|
|
2071
|
-
}), jsxRuntime.jsx(TextField, {
|
|
2121
|
+
children: [jsxRuntime.jsx(AutoFocusTextField, {
|
|
2072
2122
|
value: query,
|
|
2073
2123
|
onChange: (e) => setQuery(e.target.value),
|
|
2074
2124
|
endIcon: jsxRuntime.jsx(IconButton, {
|
|
@@ -2078,18 +2128,28 @@ function SelectFilter(_e) {
|
|
|
2078
2128
|
css: {
|
|
2079
2129
|
marginBottom: "var(--spacing)"
|
|
2080
2130
|
}
|
|
2081
|
-
}), jsxRuntime.
|
|
2131
|
+
}), jsxRuntime.jsxs("div", {
|
|
2082
2132
|
css: {
|
|
2083
2133
|
maxHeight: "20em",
|
|
2084
2134
|
overflowY: "auto"
|
|
2085
2135
|
},
|
|
2086
|
-
children:
|
|
2136
|
+
children: [jsxRuntime.jsx(FormControlLabel, {
|
|
2137
|
+
disabled: value.size === 0,
|
|
2138
|
+
control: jsxRuntime.jsx(Checkbox, {
|
|
2139
|
+
disabled: value.size === 0,
|
|
2140
|
+
checked: value.size > 0,
|
|
2141
|
+
onChange: () => onChange(/* @__PURE__ */ new Set())
|
|
2142
|
+
}),
|
|
2143
|
+
label: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2144
|
+
children: ["<", text.selected(value.size), ">"]
|
|
2145
|
+
})
|
|
2146
|
+
}), filtered.map((option, index) => jsxRuntime.jsx(FormControlLabel, {
|
|
2087
2147
|
control: jsxRuntime.jsx(Checkbox, {
|
|
2088
2148
|
checked: value.has(option),
|
|
2089
2149
|
onChange: () => onChange(toggle(value, option, singleSelect))
|
|
2090
2150
|
}),
|
|
2091
2151
|
label: render(option)
|
|
2092
|
-
}, index))
|
|
2152
|
+
}, index))]
|
|
2093
2153
|
}), filtered.length === 0 && jsxRuntime.jsx("span", {
|
|
2094
2154
|
css: {
|
|
2095
2155
|
textAlign: "center"
|
|
@@ -2160,6 +2220,7 @@ function useFilter(impl) {
|
|
|
2160
2220
|
});
|
|
2161
2221
|
}
|
|
2162
2222
|
onChange2 == null ? void 0 : onChange2(value2);
|
|
2223
|
+
setDirtyValue(void 0);
|
|
2163
2224
|
}, 500), [table]);
|
|
2164
2225
|
function onChange(value2) {
|
|
2165
2226
|
setDirtyValue(value2);
|
|
@@ -2168,7 +2229,8 @@ function useFilter(impl) {
|
|
|
2168
2229
|
react.useEffect(() => delayedUpdate.flush(), [delayedUpdate]);
|
|
2169
2230
|
return {
|
|
2170
2231
|
value: dirtyValue != null ? dirtyValue : value,
|
|
2171
|
-
onChange
|
|
2232
|
+
onChange,
|
|
2233
|
+
close: react.useContext(FilterControlContext)
|
|
2172
2234
|
};
|
|
2173
2235
|
}
|
|
2174
2236
|
const textMatch = (text, query) => {
|
|
@@ -2190,25 +2252,22 @@ const termMatch = (text, query) => {
|
|
|
2190
2252
|
}
|
|
2191
2253
|
return true;
|
|
2192
2254
|
};
|
|
2193
|
-
function TextFilter(
|
|
2194
|
-
var
|
|
2255
|
+
function TextFilter(_i) {
|
|
2256
|
+
var _j = _i, {
|
|
2195
2257
|
compare = textMatch,
|
|
2196
2258
|
filterBy = asStringOrArray
|
|
2197
|
-
} =
|
|
2259
|
+
} = _j, props = __objRest(_j, [
|
|
2198
2260
|
"compare",
|
|
2199
2261
|
"filterBy"
|
|
2200
2262
|
]);
|
|
2201
2263
|
const {
|
|
2202
2264
|
components: {
|
|
2203
|
-
|
|
2204
|
-
IconButton,
|
|
2205
|
-
Button
|
|
2265
|
+
IconButton
|
|
2206
2266
|
},
|
|
2207
2267
|
icons: {
|
|
2208
2268
|
Search,
|
|
2209
2269
|
Clear
|
|
2210
|
-
}
|
|
2211
|
-
text
|
|
2270
|
+
}
|
|
2212
2271
|
} = useTheme();
|
|
2213
2272
|
const {
|
|
2214
2273
|
value = "",
|
|
@@ -2223,43 +2282,26 @@ function TextFilter(_g) {
|
|
|
2223
2282
|
return compare(value2, filterValue);
|
|
2224
2283
|
}
|
|
2225
2284
|
}));
|
|
2226
|
-
return jsxRuntime.
|
|
2285
|
+
return jsxRuntime.jsx("div", {
|
|
2227
2286
|
css: {
|
|
2228
2287
|
padding: `calc(var(--spacing) * 2)`,
|
|
2229
|
-
display: "grid"
|
|
2230
|
-
gap: "var(--spacing)"
|
|
2288
|
+
display: "grid"
|
|
2231
2289
|
},
|
|
2232
|
-
children:
|
|
2233
|
-
css: {
|
|
2234
|
-
marginBottom: "var(--spacing)",
|
|
2235
|
-
display: "grid",
|
|
2236
|
-
gridAutoFlow: "column",
|
|
2237
|
-
gap: "var(--spacing)",
|
|
2238
|
-
justifyContent: "space-between",
|
|
2239
|
-
alignItems: "center"
|
|
2240
|
-
},
|
|
2241
|
-
children: [jsxRuntime.jsx("div", {
|
|
2242
|
-
children: text.textFilter
|
|
2243
|
-
}), jsxRuntime.jsx(Button, {
|
|
2244
|
-
variant: "contained",
|
|
2245
|
-
onClick: () => onChange(""),
|
|
2246
|
-
disabled: !value,
|
|
2247
|
-
children: text.reset
|
|
2248
|
-
})]
|
|
2249
|
-
}), jsxRuntime.jsx(TextField, {
|
|
2290
|
+
children: jsxRuntime.jsx(AutoFocusTextField, {
|
|
2250
2291
|
value,
|
|
2251
2292
|
onChange: (e) => onChange(e.target.value),
|
|
2252
2293
|
endIcon: jsxRuntime.jsx(IconButton, {
|
|
2253
2294
|
onClick: () => onChange(""),
|
|
2254
2295
|
children: !value ? jsxRuntime.jsx(Search, {}) : jsxRuntime.jsx(Clear, {})
|
|
2255
2296
|
})
|
|
2256
|
-
})
|
|
2297
|
+
})
|
|
2257
2298
|
});
|
|
2258
2299
|
}
|
|
2259
2300
|
exports.TableThemeContext = tableTheme.TableThemeContext;
|
|
2260
2301
|
exports.TableThemeProvider = tableTheme.TableThemeProvider;
|
|
2261
2302
|
exports.configureTableTheme = tableTheme.configureTableTheme;
|
|
2262
2303
|
exports.mergeThemes = tableTheme.mergeThemes;
|
|
2304
|
+
exports.AutoFocusTextField = AutoFocusTextField;
|
|
2263
2305
|
exports.ColumnContext = ColumnContext;
|
|
2264
2306
|
exports.DateFilter = DateFilter;
|
|
2265
2307
|
exports.SelectFilter = SelectFilter;
|