schummar-table 0.5.0-beta-5 → 0.5.0-beta-8
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 +181 -145
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tableTheme.js +170 -149
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +183 -148
- package/dist/es/index.js.map +1 -1
- package/dist/es/mui4Theme.js +1 -1
- package/dist/es/mui5Theme.js +1 -1
- package/dist/es/tableTheme.js +172 -152
- 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 +1 -0
- package/dist/types/theme/defaultTheme/popover.d.ts +4 -1
- package/dist/types/types.d.ts +4 -4
- package/package.json +8 -5
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
|
|
@@ -1748,23 +1818,11 @@ function throttle(fn, ms) {
|
|
|
1748
1818
|
}
|
|
1749
1819
|
});
|
|
1750
1820
|
}
|
|
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
1821
|
const findScrollRoot = (x) => {
|
|
1764
1822
|
const parent = x.parentElement;
|
|
1765
1823
|
if (!parent)
|
|
1766
1824
|
return document.documentElement;
|
|
1767
|
-
if (parent.scrollHeight > parent.clientHeight)
|
|
1825
|
+
if (parent.scrollHeight > parent.clientHeight && getComputedStyle(parent).overflowY !== "visible")
|
|
1768
1826
|
return parent;
|
|
1769
1827
|
return findScrollRoot(parent);
|
|
1770
1828
|
};
|
|
@@ -1775,15 +1833,15 @@ const relativeOffset = (x, y) => {
|
|
|
1775
1833
|
return relativeOffset(x.offsetParent, y) + x.offsetTop;
|
|
1776
1834
|
return 0;
|
|
1777
1835
|
};
|
|
1778
|
-
function Virtualized(
|
|
1779
|
-
var
|
|
1836
|
+
function Virtualized(_e) {
|
|
1837
|
+
var _f = _e, {
|
|
1780
1838
|
header,
|
|
1781
1839
|
children
|
|
1782
|
-
} =
|
|
1840
|
+
} = _f, props = __objRest(_f, [
|
|
1783
1841
|
"header",
|
|
1784
1842
|
"children"
|
|
1785
1843
|
]);
|
|
1786
|
-
var _a, _b,
|
|
1844
|
+
var _a, _b, _c, _d;
|
|
1787
1845
|
const table = useTableContext();
|
|
1788
1846
|
const virtual = table.useState("props.virtual");
|
|
1789
1847
|
const probeRef = react.useRef(null);
|
|
@@ -1807,7 +1865,7 @@ function Virtualized(_c) {
|
|
|
1807
1865
|
const {
|
|
1808
1866
|
rowHeight,
|
|
1809
1867
|
initalRowHeight,
|
|
1810
|
-
overscan =
|
|
1868
|
+
overscan = 100,
|
|
1811
1869
|
overscanTop,
|
|
1812
1870
|
overscanBottom
|
|
1813
1871
|
} = (_a2 = state.props.virtual instanceof Object ? state.props.virtual : void 0) != null ? _a2 : {};
|
|
@@ -1842,15 +1900,20 @@ function Virtualized(_c) {
|
|
|
1842
1900
|
before: before2,
|
|
1843
1901
|
after: after2
|
|
1844
1902
|
};
|
|
1903
|
+
}, {
|
|
1904
|
+
throttle: 16
|
|
1845
1905
|
});
|
|
1846
|
-
const throttleScroll = (_b = (_a = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a.throttleScroll) != null ? _b :
|
|
1906
|
+
const throttleScroll = (_b = (_a = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a.throttleScroll) != null ? _b : 16;
|
|
1847
1907
|
const incCounter = react.useMemo(() => throttle(() => setCounter((c) => c + 1), throttleScroll), [throttleScroll]);
|
|
1848
1908
|
react.useEffect(() => {
|
|
1849
1909
|
if (!virtual || !probeRef.current)
|
|
1850
1910
|
return;
|
|
1851
|
-
|
|
1911
|
+
window.addEventListener("scroll", incCounter, true);
|
|
1912
|
+
return () => {
|
|
1913
|
+
window.removeEventListener("scroll", incCounter, true);
|
|
1914
|
+
};
|
|
1852
1915
|
}, [probeRef.current, incCounter]);
|
|
1853
|
-
(
|
|
1916
|
+
(_d = (_c = table.getState().props).debugRender) == null ? void 0 : _d.call(_c, `Virtualalized render ${from} to ${to}`);
|
|
1854
1917
|
return jsxRuntime.jsxs("div", __spreadProps(__spreadValues({}, props), {
|
|
1855
1918
|
children: [header, virtual && jsxRuntime.jsx("div", {
|
|
1856
1919
|
style: {
|
|
@@ -1934,7 +1997,7 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1934
1997
|
const cssVariables = useCssVariables();
|
|
1935
1998
|
(_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
1936
1999
|
return jsxRuntime.jsx(Virtualized, {
|
|
1937
|
-
className:
|
|
2000
|
+
className: classes == null ? void 0 : classes.table,
|
|
1938
2001
|
css: [cssVariables, tableTheme.defaultClasses.table, {
|
|
1939
2002
|
gridTemplateColumns: [
|
|
1940
2003
|
fullWidth === "right" || fullWidth === true ? "auto" : "0",
|
|
@@ -1955,7 +2018,7 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1955
2018
|
}), jsxRuntime.jsxs("div", {
|
|
1956
2019
|
className: classes == null ? void 0 : classes.headerCell,
|
|
1957
2020
|
css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky],
|
|
1958
|
-
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export, {})]
|
|
2021
|
+
children: [enableSelection && jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && jsxRuntime.jsx(ColumnSelection, {}), enableExport && jsxRuntime.jsx(Export, {}), jsxRuntime.jsx(ResizeHandleView, {})]
|
|
1959
2022
|
}), jsxRuntime.jsx(ColumnHeaderContext.Provider, {
|
|
1960
2023
|
children: activeColumns.map((column) => {
|
|
1961
2024
|
var _a2;
|
|
@@ -1964,13 +2027,13 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1964
2027
|
children: jsxRuntime.jsxs(ColumnHeader, {
|
|
1965
2028
|
className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
|
|
1966
2029
|
css: [tableTheme.defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && tableTheme.defaultClasses.sticky],
|
|
1967
|
-
children: [jsxRuntime.jsx(
|
|
2030
|
+
children: [jsxRuntime.jsx(SortComponent, {
|
|
1968
2031
|
children: column.header
|
|
1969
2032
|
}), jsxRuntime.jsx("div", {
|
|
1970
2033
|
css: {
|
|
1971
2034
|
flex: 1
|
|
1972
2035
|
}
|
|
1973
|
-
}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
2036
|
+
}), jsxRuntime.jsx(FilterControl, {}), jsxRuntime.jsx(ResizeHandle, {})]
|
|
1974
2037
|
}, column.id)
|
|
1975
2038
|
}, column.id);
|
|
1976
2039
|
})
|
|
@@ -1994,13 +2057,13 @@ function toggle(set, value, singleSelect) {
|
|
|
1994
2057
|
}
|
|
1995
2058
|
return newSet;
|
|
1996
2059
|
}
|
|
1997
|
-
function SelectFilter(
|
|
1998
|
-
var
|
|
2060
|
+
function SelectFilter(_g) {
|
|
2061
|
+
var _h = _g, {
|
|
1999
2062
|
options: providedOptions,
|
|
2000
2063
|
stringValue = asString,
|
|
2001
2064
|
render = stringValue,
|
|
2002
2065
|
singleSelect
|
|
2003
|
-
} =
|
|
2066
|
+
} = _h, props = __objRest(_h, [
|
|
2004
2067
|
"options",
|
|
2005
2068
|
"stringValue",
|
|
2006
2069
|
"render",
|
|
@@ -2008,8 +2071,6 @@ function SelectFilter(_e) {
|
|
|
2008
2071
|
]);
|
|
2009
2072
|
const {
|
|
2010
2073
|
components: {
|
|
2011
|
-
TextField,
|
|
2012
|
-
Button,
|
|
2013
2074
|
IconButton,
|
|
2014
2075
|
Checkbox
|
|
2015
2076
|
},
|
|
@@ -2051,24 +2112,7 @@ function SelectFilter(_e) {
|
|
|
2051
2112
|
display: "grid",
|
|
2052
2113
|
gap: "var(--spacing)"
|
|
2053
2114
|
},
|
|
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, {
|
|
2115
|
+
children: [jsxRuntime.jsx(AutoFocusTextField, {
|
|
2072
2116
|
value: query,
|
|
2073
2117
|
onChange: (e) => setQuery(e.target.value),
|
|
2074
2118
|
endIcon: jsxRuntime.jsx(IconButton, {
|
|
@@ -2078,18 +2122,28 @@ function SelectFilter(_e) {
|
|
|
2078
2122
|
css: {
|
|
2079
2123
|
marginBottom: "var(--spacing)"
|
|
2080
2124
|
}
|
|
2081
|
-
}), jsxRuntime.
|
|
2125
|
+
}), jsxRuntime.jsxs("div", {
|
|
2082
2126
|
css: {
|
|
2083
2127
|
maxHeight: "20em",
|
|
2084
2128
|
overflowY: "auto"
|
|
2085
2129
|
},
|
|
2086
|
-
children:
|
|
2130
|
+
children: [jsxRuntime.jsx(FormControlLabel, {
|
|
2131
|
+
disabled: value.size === 0,
|
|
2132
|
+
control: jsxRuntime.jsx(Checkbox, {
|
|
2133
|
+
disabled: value.size === 0,
|
|
2134
|
+
checked: value.size > 0,
|
|
2135
|
+
onChange: () => onChange(/* @__PURE__ */ new Set())
|
|
2136
|
+
}),
|
|
2137
|
+
label: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2138
|
+
children: ["<", text.selected(value.size), ">"]
|
|
2139
|
+
})
|
|
2140
|
+
}), filtered.map((option, index) => jsxRuntime.jsx(FormControlLabel, {
|
|
2087
2141
|
control: jsxRuntime.jsx(Checkbox, {
|
|
2088
2142
|
checked: value.has(option),
|
|
2089
2143
|
onChange: () => onChange(toggle(value, option, singleSelect))
|
|
2090
2144
|
}),
|
|
2091
2145
|
label: render(option)
|
|
2092
|
-
}, index))
|
|
2146
|
+
}, index))]
|
|
2093
2147
|
}), filtered.length === 0 && jsxRuntime.jsx("span", {
|
|
2094
2148
|
css: {
|
|
2095
2149
|
textAlign: "center"
|
|
@@ -2160,6 +2214,7 @@ function useFilter(impl) {
|
|
|
2160
2214
|
});
|
|
2161
2215
|
}
|
|
2162
2216
|
onChange2 == null ? void 0 : onChange2(value2);
|
|
2217
|
+
setDirtyValue(void 0);
|
|
2163
2218
|
}, 500), [table]);
|
|
2164
2219
|
function onChange(value2) {
|
|
2165
2220
|
setDirtyValue(value2);
|
|
@@ -2168,7 +2223,8 @@ function useFilter(impl) {
|
|
|
2168
2223
|
react.useEffect(() => delayedUpdate.flush(), [delayedUpdate]);
|
|
2169
2224
|
return {
|
|
2170
2225
|
value: dirtyValue != null ? dirtyValue : value,
|
|
2171
|
-
onChange
|
|
2226
|
+
onChange,
|
|
2227
|
+
close: react.useContext(FilterControlContext)
|
|
2172
2228
|
};
|
|
2173
2229
|
}
|
|
2174
2230
|
const textMatch = (text, query) => {
|
|
@@ -2190,25 +2246,22 @@ const termMatch = (text, query) => {
|
|
|
2190
2246
|
}
|
|
2191
2247
|
return true;
|
|
2192
2248
|
};
|
|
2193
|
-
function TextFilter(
|
|
2194
|
-
var
|
|
2249
|
+
function TextFilter(_i) {
|
|
2250
|
+
var _j = _i, {
|
|
2195
2251
|
compare = textMatch,
|
|
2196
2252
|
filterBy = asStringOrArray
|
|
2197
|
-
} =
|
|
2253
|
+
} = _j, props = __objRest(_j, [
|
|
2198
2254
|
"compare",
|
|
2199
2255
|
"filterBy"
|
|
2200
2256
|
]);
|
|
2201
2257
|
const {
|
|
2202
2258
|
components: {
|
|
2203
|
-
|
|
2204
|
-
IconButton,
|
|
2205
|
-
Button
|
|
2259
|
+
IconButton
|
|
2206
2260
|
},
|
|
2207
2261
|
icons: {
|
|
2208
2262
|
Search,
|
|
2209
2263
|
Clear
|
|
2210
|
-
}
|
|
2211
|
-
text
|
|
2264
|
+
}
|
|
2212
2265
|
} = useTheme();
|
|
2213
2266
|
const {
|
|
2214
2267
|
value = "",
|
|
@@ -2223,43 +2276,26 @@ function TextFilter(_g) {
|
|
|
2223
2276
|
return compare(value2, filterValue);
|
|
2224
2277
|
}
|
|
2225
2278
|
}));
|
|
2226
|
-
return jsxRuntime.
|
|
2279
|
+
return jsxRuntime.jsx("div", {
|
|
2227
2280
|
css: {
|
|
2228
2281
|
padding: `calc(var(--spacing) * 2)`,
|
|
2229
|
-
display: "grid"
|
|
2230
|
-
gap: "var(--spacing)"
|
|
2282
|
+
display: "grid"
|
|
2231
2283
|
},
|
|
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, {
|
|
2284
|
+
children: jsxRuntime.jsx(AutoFocusTextField, {
|
|
2250
2285
|
value,
|
|
2251
2286
|
onChange: (e) => onChange(e.target.value),
|
|
2252
2287
|
endIcon: jsxRuntime.jsx(IconButton, {
|
|
2253
2288
|
onClick: () => onChange(""),
|
|
2254
2289
|
children: !value ? jsxRuntime.jsx(Search, {}) : jsxRuntime.jsx(Clear, {})
|
|
2255
2290
|
})
|
|
2256
|
-
})
|
|
2291
|
+
})
|
|
2257
2292
|
});
|
|
2258
2293
|
}
|
|
2259
2294
|
exports.TableThemeContext = tableTheme.TableThemeContext;
|
|
2260
2295
|
exports.TableThemeProvider = tableTheme.TableThemeProvider;
|
|
2261
2296
|
exports.configureTableTheme = tableTheme.configureTableTheme;
|
|
2262
2297
|
exports.mergeThemes = tableTheme.mergeThemes;
|
|
2298
|
+
exports.AutoFocusTextField = AutoFocusTextField;
|
|
2263
2299
|
exports.ColumnContext = ColumnContext;
|
|
2264
2300
|
exports.DateFilter = DateFilter;
|
|
2265
2301
|
exports.SelectFilter = SelectFilter;
|