schummar-table 0.1.0 → 0.3.1
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/components/cell.d.ts +3 -2
- package/dist/cjs/components/cell.js +19 -14
- package/dist/cjs/components/columnSelection.js +4 -4
- package/dist/cjs/components/defaultFilterComponent.js +11 -12
- package/dist/cjs/components/expandComponent.js +3 -3
- package/dist/cjs/components/export.d.ts +2 -0
- package/dist/cjs/components/export.js +48 -0
- package/dist/cjs/components/filterComponent.js +5 -5
- package/dist/cjs/components/row.d.ts +2 -1
- package/dist/cjs/components/row.js +11 -10
- package/dist/cjs/components/selectComponent.js +5 -5
- package/dist/cjs/components/sortComponent.js +4 -4
- package/dist/cjs/components/textFilterComponent.js +7 -7
- package/dist/cjs/components/useCommonClasses.d.ts +1 -1
- package/dist/cjs/components/useCommonClasses.js +11 -7
- package/dist/cjs/components/virtualized.d.ts +1 -1
- package/dist/cjs/components/virtualized.js +10 -10
- package/dist/cjs/internalState/calcItems.js +7 -7
- package/dist/cjs/internalState/calcProps.js +50 -35
- package/dist/cjs/internalState/cleanupState.js +3 -3
- package/dist/cjs/internalState/filterColumns.js +1 -1
- package/dist/cjs/internalState/syncSelections.js +1 -1
- package/dist/cjs/internalState/useTableState.js +8 -8
- package/dist/cjs/misc/csvExport.d.ts +7 -0
- package/dist/cjs/misc/csvExport.js +15 -0
- package/dist/cjs/misc/helpers.js +1 -1
- package/dist/cjs/misc/textMatch.js +1 -1
- package/dist/cjs/table.js +16 -12
- package/dist/cjs/types.d.ts +26 -4
- package/dist/esm/components/cell.d.ts +3 -2
- package/dist/esm/components/cell.js +17 -12
- package/dist/esm/components/columnSelection.js +1 -1
- package/dist/esm/components/defaultFilterComponent.js +1 -2
- package/dist/esm/components/expandComponent.js +1 -1
- package/dist/esm/components/export.d.ts +2 -0
- package/dist/esm/components/export.js +44 -0
- package/dist/esm/components/row.d.ts +2 -1
- package/dist/esm/components/row.js +4 -3
- package/dist/esm/components/useCommonClasses.d.ts +1 -1
- package/dist/esm/components/useCommonClasses.js +10 -6
- package/dist/esm/components/virtualized.d.ts +1 -1
- package/dist/esm/components/virtualized.js +5 -5
- package/dist/esm/internalState/calcProps.js +51 -36
- package/dist/esm/misc/csvExport.d.ts +7 -0
- package/dist/esm/misc/csvExport.js +11 -0
- package/dist/esm/table.js +6 -2
- package/dist/esm/types.d.ts +26 -4
- package/package.json +16 -13
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Id } from '..';
|
|
3
|
-
export declare const Cell: React.MemoExoticComponent<(<T>({ itemId }: {
|
|
3
|
+
export declare const Cell: React.MemoExoticComponent<(<T>({ itemId, rowIndex }: {
|
|
4
4
|
itemId: Id;
|
|
5
|
-
|
|
5
|
+
rowIndex: number;
|
|
6
|
+
}) => JSX.Element | null)>;
|
|
@@ -7,20 +7,25 @@ const __1 = require("..");
|
|
|
7
7
|
const helpers_1 = require("../misc/helpers");
|
|
8
8
|
const row_1 = require("./row");
|
|
9
9
|
const useCommonClasses_1 = require("./useCommonClasses");
|
|
10
|
-
exports.Cell = react_1.memo(function Cell({ itemId }) {
|
|
10
|
+
exports.Cell = (0, react_1.memo)(function Cell({ itemId, rowIndex }) {
|
|
11
11
|
var _a, _b;
|
|
12
|
-
const commonClasses = useCommonClasses_1.useCommonClasses();
|
|
13
|
-
const state = __1.useTableContext();
|
|
14
|
-
const columnId = __1.useColumnContext();
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
content: item && column && column.renderCell(column.value(item), item),
|
|
22
|
-
};
|
|
23
|
-
}, [itemId, columnId]);
|
|
12
|
+
const commonClasses = (0, useCommonClasses_1.useCommonClasses)();
|
|
13
|
+
const state = (0, __1.useTableContext)();
|
|
14
|
+
const columnId = (0, __1.useColumnContext)();
|
|
15
|
+
const column = state.useState((state) => state.activeColumns.find((column) => column.id === columnId), [columnId]);
|
|
16
|
+
const item = state.useState((state) => state.activeItemsById.get(itemId), [itemId]);
|
|
17
|
+
const classes = state.useState('props.classes');
|
|
18
|
+
let wrapCell = state.useState('props.wrapCell');
|
|
19
|
+
if (!column || !item)
|
|
20
|
+
return null;
|
|
24
21
|
(_b = (_a = state.getState().props).debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'render cell', itemId, columnId);
|
|
25
|
-
|
|
22
|
+
const className = (0, helpers_1.c)((0, row_1.calcClassName)(classes, rowIndex), (0, row_1.calcClassName)(column === null || column === void 0 ? void 0 : column.classes, rowIndex));
|
|
23
|
+
const content = column.renderCell(column.value(item), item);
|
|
24
|
+
if (!wrapCell && typeof content === 'string') {
|
|
25
|
+
wrapCell = (content) => ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, helpers_1.c)(commonClasses.cell, className) }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ className: (0, helpers_1.c)(commonClasses.text) }, { children: content }), void 0) }), void 0));
|
|
26
|
+
}
|
|
27
|
+
else if (!wrapCell) {
|
|
28
|
+
wrapCell = (content) => (0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, helpers_1.c)(commonClasses.cell, className) }, { children: content }), void 0);
|
|
29
|
+
}
|
|
30
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: wrapCell(content, item) }, void 0);
|
|
26
31
|
});
|
|
@@ -6,7 +6,7 @@ const core_1 = require("@material-ui/core");
|
|
|
6
6
|
const icons_1 = require("@material-ui/icons");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const table_1 = require("../table");
|
|
9
|
-
const useClasses = core_1.makeStyles((theme) => ({
|
|
9
|
+
const useClasses = (0, core_1.makeStyles)((theme) => ({
|
|
10
10
|
list: {
|
|
11
11
|
padding: theme.spacing(2),
|
|
12
12
|
display: 'grid',
|
|
@@ -14,8 +14,8 @@ const useClasses = core_1.makeStyles((theme) => ({
|
|
|
14
14
|
}));
|
|
15
15
|
function ColumnSelection() {
|
|
16
16
|
const classes = useClasses();
|
|
17
|
-
const [anchor, setAnchor] = react_1.useState(null);
|
|
18
|
-
const state = table_1.useTableContext();
|
|
17
|
+
const [anchor, setAnchor] = (0, react_1.useState)(null);
|
|
18
|
+
const state = (0, table_1.useTableContext)();
|
|
19
19
|
const columns = state.useState('props.columns');
|
|
20
20
|
const hiddenColumns = state.useState('hiddenColumns');
|
|
21
21
|
const toggle = (column) => {
|
|
@@ -32,6 +32,6 @@ function ColumnSelection() {
|
|
|
32
32
|
}
|
|
33
33
|
onHiddenColumnsChange === null || onHiddenColumnsChange === void 0 ? void 0 : onHiddenColumnsChange(newValue);
|
|
34
34
|
};
|
|
35
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx(core_1.IconButton, Object.assign({ color: "inherit", onClick: (e) => setAnchor(e.currentTarget) }, { children: jsx_runtime_1.jsx(icons_1.Settings, {}, void 0) }), void 0), jsx_runtime_1.jsx(core_1.Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: '
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ color: "inherit", size: "small", onClick: (e) => setAnchor(e.currentTarget) }, { children: (0, jsx_runtime_1.jsx)(icons_1.Settings, {}, void 0) }), void 0), (0, jsx_runtime_1.jsx)(core_1.Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'left' } }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.list }, { children: columns.map((column) => ((0, jsx_runtime_1.jsx)(core_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(core_1.Checkbox, { checked: !hiddenColumns.has(column.id), onChange: () => toggle(column), disabled: column.cannotHide }, void 0), label: column.header }, column.id))) }), void 0) }), void 0)] }, void 0));
|
|
36
36
|
}
|
|
37
37
|
exports.ColumnSelection = ColumnSelection;
|
|
@@ -14,7 +14,7 @@ class DefaultFilter {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.DefaultFilter = DefaultFilter;
|
|
17
|
-
const useClasses = core_1.makeStyles((theme) => ({
|
|
17
|
+
const useClasses = (0, core_1.makeStyles)((theme) => ({
|
|
18
18
|
view: {
|
|
19
19
|
padding: theme.spacing(2),
|
|
20
20
|
display: 'grid',
|
|
@@ -26,23 +26,22 @@ const useClasses = core_1.makeStyles((theme) => ({
|
|
|
26
26
|
function DefaultFilterComponent({ filterBy: _filterBy, options: _options, compare = helpers_1.defaultEquals, stringValue = helpers_1.asString, render = stringValue, }) {
|
|
27
27
|
var _a;
|
|
28
28
|
const classes = useClasses();
|
|
29
|
-
const state = table_1.useTableContext();
|
|
30
|
-
const columnId = table_1.useColumnContext();
|
|
31
|
-
const
|
|
32
|
-
const filterBy = react_1.useCallback((value, item) => {
|
|
29
|
+
const state = (0, table_1.useTableContext)();
|
|
30
|
+
const columnId = (0, table_1.useColumnContext)();
|
|
31
|
+
const filterBy = (0, react_1.useCallback)((value, item) => {
|
|
33
32
|
const values = _filterBy ? _filterBy(value, item) : value;
|
|
34
33
|
return values instanceof Array ? values : [values];
|
|
35
|
-
},
|
|
34
|
+
}, [_filterBy]);
|
|
36
35
|
const { text, options, filter } = state.useState((state) => {
|
|
37
36
|
const column = state.activeColumns.find((column) => column.id === columnId);
|
|
38
37
|
const _filter = state.filters.get(columnId);
|
|
39
38
|
const filter = _filter instanceof DefaultFilter ? _filter : undefined;
|
|
40
|
-
let options = _options !== null && _options !== void 0 ? _options : helpers_1.orderBy(helpers_1.uniq(helpers_1.flatMap(state.items, (item) => (column ? filterBy(column.value(item), item) : []))));
|
|
39
|
+
let options = _options !== null && _options !== void 0 ? _options : (0, helpers_1.orderBy)((0, helpers_1.uniq)((0, helpers_1.flatMap)(state.items, (item) => (column ? filterBy(column.value(item), item) : []))));
|
|
41
40
|
if (filter)
|
|
42
41
|
options = options.concat([...filter.values].filter((value) => !options.includes(value)));
|
|
43
42
|
return { text: state.props.text, options, filter };
|
|
44
43
|
}, [_options, columnId, filterBy]);
|
|
45
|
-
const [input, setInput] = react_1.useState('');
|
|
44
|
+
const [input, setInput] = (0, react_1.useState)('');
|
|
46
45
|
const filtered = options.filter((option) => !input || stringValue(option).toLowerCase().includes(input.toLowerCase()));
|
|
47
46
|
function toggle(value) {
|
|
48
47
|
var _a;
|
|
@@ -82,11 +81,11 @@ function DefaultFilterComponent({ filterBy: _filterBy, options: _options, compar
|
|
|
82
81
|
}
|
|
83
82
|
(_a = column.onFilterChange) === null || _a === void 0 ? void 0 : _a.call(column);
|
|
84
83
|
}
|
|
85
|
-
return (jsx_runtime_1.jsxs("div", Object.assign({ className: classes.view }, { children: [jsx_runtime_1.jsx(core_1.TextField, { value: input, onChange: (e) => setInput(e.target.value), InputProps: {
|
|
86
|
-
endAdornment: input ? (jsx_runtime_1.jsx(core_1.IconButton, Object.assign({ onClick: () => setInput('') }, { children: jsx_runtime_1.jsx(icons_1.Clear, {}, void 0) }), void 0)) : (jsx_runtime_1.jsx(icons_1.Search, {}, void 0)),
|
|
87
|
-
} }, void 0), jsx_runtime_1.jsx(core_1.Button, Object.assign({ variant: "outlined", onClick: deselectAll, disabled: !filter }, { children: (_a = text === null || text === void 0 ? void 0 : text.deselectAll) !== null && _a !== void 0 ? _a : 'Deselect all' }), void 0), filtered.map((value, index) => {
|
|
84
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes.view }, { children: [(0, jsx_runtime_1.jsx)(core_1.TextField, { value: input, onChange: (e) => setInput(e.target.value), InputProps: {
|
|
85
|
+
endAdornment: input ? ((0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ onClick: () => setInput('') }, { children: (0, jsx_runtime_1.jsx)(icons_1.Clear, {}, void 0) }), void 0)) : ((0, jsx_runtime_1.jsx)(icons_1.Search, {}, void 0)),
|
|
86
|
+
} }, void 0), (0, jsx_runtime_1.jsx)(core_1.Button, Object.assign({ variant: "outlined", onClick: deselectAll, disabled: !filter }, { children: (_a = text === null || text === void 0 ? void 0 : text.deselectAll) !== null && _a !== void 0 ? _a : 'Deselect all' }), void 0), filtered.map((value, index) => {
|
|
88
87
|
var _a;
|
|
89
|
-
return (jsx_runtime_1.jsx(core_1.FormControlLabel, { control: jsx_runtime_1.jsx(core_1.Checkbox, { checked: (_a = filter === null || filter === void 0 ? void 0 : filter.values.has(value)) !== null && _a !== void 0 ? _a : false, onChange: () => toggle(value) }, void 0), label: render(value) }, index));
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(core_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(core_1.Checkbox, { checked: (_a = filter === null || filter === void 0 ? void 0 : filter.values.has(value)) !== null && _a !== void 0 ? _a : false, onChange: () => toggle(value) }, void 0), label: render(value) }, index));
|
|
90
89
|
})] }), void 0));
|
|
91
90
|
}
|
|
92
91
|
exports.DefaultFilterComponent = DefaultFilterComponent;
|
|
@@ -7,7 +7,7 @@ const icons_1 = require("@material-ui/icons");
|
|
|
7
7
|
const helpers_1 = require("../misc/helpers");
|
|
8
8
|
const table_1 = require("../table");
|
|
9
9
|
function ExpandComponent({ itemId }) {
|
|
10
|
-
const state = table_1.useTableContext();
|
|
10
|
+
const state = (0, table_1.useTableContext)();
|
|
11
11
|
const isExpanded = state.useState((state) => state.expanded.has(itemId), [itemId]);
|
|
12
12
|
function toggle() {
|
|
13
13
|
const { props: { expanded: controlledExpanded, expandOnlyOne, onExpandedChange }, expanded, activeItemsById, } = state.getState();
|
|
@@ -19,7 +19,7 @@ function ExpandComponent({ itemId }) {
|
|
|
19
19
|
else {
|
|
20
20
|
newExpanded.add(itemId);
|
|
21
21
|
const item = activeItemsById.get(itemId);
|
|
22
|
-
for (const ancestor of item ? helpers_1.getAncestors(activeItemsById, item) : []) {
|
|
22
|
+
for (const ancestor of item ? (0, helpers_1.getAncestors)(activeItemsById, item) : []) {
|
|
23
23
|
newExpanded.add(ancestor);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -30,7 +30,7 @@ function ExpandComponent({ itemId }) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
return (jsx_runtime_1.jsx(core_1.IconButton, Object.assign({ onClick: toggle }, { children: jsx_runtime_1.jsx(icons_1.ChevronRight, { style: {
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ size: "small", onClick: toggle }, { children: (0, jsx_runtime_1.jsx)(icons_1.ChevronRight, { style: {
|
|
34
34
|
transition: 'all 500ms',
|
|
35
35
|
transform: isExpanded ? 'rotate3d(0, 0, 1, 90deg)' : 'none',
|
|
36
36
|
} }, void 0) }), void 0));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Export = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@material-ui/core");
|
|
6
|
+
const icons_1 = require("@material-ui/icons");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const csvExport_1 = require("../misc/csvExport");
|
|
9
|
+
const table_1 = require("../table");
|
|
10
|
+
const useClasses = (0, core_1.makeStyles)((theme) => ({
|
|
11
|
+
dialog: {
|
|
12
|
+
padding: theme.spacing(2),
|
|
13
|
+
display: 'grid',
|
|
14
|
+
justifyItems: 'stretch',
|
|
15
|
+
'& > *': {
|
|
16
|
+
justifyContent: 'start',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
function Export() {
|
|
21
|
+
const classes = useClasses();
|
|
22
|
+
const [anchor, setAnchor] = (0, react_1.useState)(null);
|
|
23
|
+
const state = (0, table_1.useTableContext)();
|
|
24
|
+
const textTitle = state.useState('props.text.exportTitle');
|
|
25
|
+
const textCopy = state.useState('props.text.exportCopy');
|
|
26
|
+
const textDownload = state.useState('props.text.exportDownload');
|
|
27
|
+
const generate = (options) => {
|
|
28
|
+
const { activeColumns, activeItems } = state.getState();
|
|
29
|
+
const data = [
|
|
30
|
+
activeColumns.map((column) => String(column.id)),
|
|
31
|
+
...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item), item))),
|
|
32
|
+
];
|
|
33
|
+
return (0, csvExport_1.csvExport)(data, options);
|
|
34
|
+
};
|
|
35
|
+
const copy = () => {
|
|
36
|
+
navigator.clipboard.writeText(generate(state.getState().props.enableExport.copy));
|
|
37
|
+
};
|
|
38
|
+
const download = () => {
|
|
39
|
+
const a = document.createElement('a');
|
|
40
|
+
a.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(generate(state.getState().props.enableExport.download));
|
|
41
|
+
a.download = 'export.csv';
|
|
42
|
+
document.body.appendChild(a);
|
|
43
|
+
a.click();
|
|
44
|
+
document.body.removeChild(a);
|
|
45
|
+
};
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ color: "inherit", size: "small", onClick: (e) => setAnchor(e.currentTarget) }, { children: (0, jsx_runtime_1.jsx)(icons_1.CloudDownload, {}, void 0) }), void 0), (0, jsx_runtime_1.jsx)(core_1.Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'left' } }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes.dialog }, { children: [(0, jsx_runtime_1.jsx)(core_1.Typography, Object.assign({ variant: "caption" }, { children: textTitle !== null && textTitle !== void 0 ? textTitle : 'Export' }), void 0), (0, jsx_runtime_1.jsx)(core_1.Button, Object.assign({ startIcon: (0, jsx_runtime_1.jsx)(icons_1.AssignmentReturn, {}, void 0), fullWidth: true, onClick: copy }, { children: textCopy !== null && textCopy !== void 0 ? textCopy : 'In die Zwischenablage' }), void 0), (0, jsx_runtime_1.jsx)(core_1.Button, Object.assign({ startIcon: (0, jsx_runtime_1.jsx)(icons_1.CloudDownload, {}, void 0), fullWidth: true, onClick: download }, { children: textDownload !== null && textDownload !== void 0 ? textDownload : 'Herunterladen' }), void 0)] }), void 0) }), void 0)] }, void 0));
|
|
47
|
+
}
|
|
48
|
+
exports.Export = Export;
|
|
@@ -6,20 +6,20 @@ const core_1 = require("@material-ui/core");
|
|
|
6
6
|
const icons_1 = require("@material-ui/icons");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const table_1 = require("../table");
|
|
9
|
-
const useClasses = core_1.makeStyles((theme) => ({
|
|
9
|
+
const useClasses = (0, core_1.makeStyles)((theme) => ({
|
|
10
10
|
active: {
|
|
11
11
|
background: theme.palette.primary.main,
|
|
12
12
|
},
|
|
13
13
|
}));
|
|
14
14
|
function FilterComponent() {
|
|
15
|
-
const state = table_1.useTableContext();
|
|
16
|
-
const columnId = table_1.useColumnContext();
|
|
15
|
+
const state = (0, table_1.useTableContext)();
|
|
16
|
+
const columnId = (0, table_1.useColumnContext)();
|
|
17
17
|
const classes = useClasses();
|
|
18
18
|
const isActive = state.useState((state) => !!state.filters.get(columnId), [columnId]);
|
|
19
19
|
const filterComponent = state.useState((state) => { var _a; return (_a = state.activeColumns.find((column) => column.id === columnId)) === null || _a === void 0 ? void 0 : _a.filterComponent; });
|
|
20
|
-
const [anchor, setAnchor] = react_1.useState(null);
|
|
20
|
+
const [anchor, setAnchor] = (0, react_1.useState)(null);
|
|
21
21
|
if (!filterComponent)
|
|
22
22
|
return null;
|
|
23
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx(core_1.IconButton, Object.assign({ size: "small", color: "inherit", onClick: (e) => setAnchor(e.currentTarget), className: isActive ? classes.active : undefined }, { children: isActive ? jsx_runtime_1.jsx(icons_1.FilterList, {}, void 0) : jsx_runtime_1.jsx(icons_1.ArrowDropDown, {}, void 0) }), void 0), jsx_runtime_1.jsx(core_1.Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' } }, { children: filterComponent }), void 0)] }, void 0));
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ size: "small", color: "inherit", onClick: (e) => setAnchor(e.currentTarget), className: isActive ? classes.active : undefined }, { children: isActive ? (0, jsx_runtime_1.jsx)(icons_1.FilterList, {}, void 0) : (0, jsx_runtime_1.jsx)(icons_1.ArrowDropDown, {}, void 0) }), void 0), (0, jsx_runtime_1.jsx)(core_1.Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' } }, { children: filterComponent }), void 0)] }, void 0));
|
|
24
24
|
}
|
|
25
25
|
exports.FilterComponent = FilterComponent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Id, InternalColumn } from '../types';
|
|
3
3
|
export declare const calcClassName: (classes: InternalColumn<any, any>['classes'] | undefined, index: number) => string;
|
|
4
|
-
export declare const Row: React.MemoExoticComponent<(<T>({ itemId }: {
|
|
4
|
+
export declare const Row: React.MemoExoticComponent<(<T>({ itemId, rowIndex }: {
|
|
5
5
|
itemId: Id;
|
|
6
|
+
rowIndex: number;
|
|
6
7
|
}) => JSX.Element | null)>;
|
|
@@ -9,26 +9,27 @@ const cell_1 = require("./cell");
|
|
|
9
9
|
const expandComponent_1 = require("./expandComponent");
|
|
10
10
|
const selectComponent_1 = require("./selectComponent");
|
|
11
11
|
const useCommonClasses_1 = require("./useCommonClasses");
|
|
12
|
-
const calcClassName = (classes, index) => helpers_1.c(classes === null || classes === void 0 ? void 0 : classes.cell, (classes === null || classes === void 0 ? void 0 : classes.evenCell) === undefined ? undefined : { [classes.evenCell]: index % 2 === 0 }, (classes === null || classes === void 0 ? void 0 : classes.oddCell) === undefined ? undefined : { [classes.oddCell]: index % 2 === 1 });
|
|
12
|
+
const calcClassName = (classes, index) => (0, helpers_1.c)(classes === null || classes === void 0 ? void 0 : classes.cell, (classes === null || classes === void 0 ? void 0 : classes.evenCell) === undefined ? undefined : { [classes.evenCell]: index % 2 === 0 }, (classes === null || classes === void 0 ? void 0 : classes.oddCell) === undefined ? undefined : { [classes.oddCell]: index % 2 === 1 });
|
|
13
13
|
exports.calcClassName = calcClassName;
|
|
14
|
-
exports.Row = react_1.memo(function Row({ itemId }) {
|
|
14
|
+
exports.Row = (0, react_1.memo)(function Row({ itemId, rowIndex }) {
|
|
15
15
|
var _a, _b;
|
|
16
|
-
const commonClasses = useCommonClasses_1.useCommonClasses();
|
|
17
|
-
const state = table_1.useTableContext();
|
|
18
|
-
const divRef = react_1.useRef(null);
|
|
19
|
-
const { className, indent, hasChildren, hasDeferredChildren, columnIds } = state.useState((state) => {
|
|
16
|
+
const commonClasses = (0, useCommonClasses_1.useCommonClasses)();
|
|
17
|
+
const state = (0, table_1.useTableContext)();
|
|
18
|
+
const divRef = (0, react_1.useRef)(null);
|
|
19
|
+
const { className, indent, hasChildren, hasDeferredChildren, columnIds, enableSelection } = state.useState((state) => {
|
|
20
20
|
var _a, _b;
|
|
21
21
|
const item = state.activeItemsById.get(itemId);
|
|
22
22
|
const index = !item ? -1 : state.activeItems.indexOf(item);
|
|
23
23
|
return {
|
|
24
|
-
className: exports.calcClassName(state.props.classes, index),
|
|
25
|
-
indent: item ? helpers_1.getAncestors(state.activeItemsById, item).size : 0,
|
|
24
|
+
className: (0, exports.calcClassName)(state.props.classes, index),
|
|
25
|
+
indent: item ? (0, helpers_1.getAncestors)(state.activeItemsById, item).size : 0,
|
|
26
26
|
hasChildren: !!(item === null || item === void 0 ? void 0 : item.children.length),
|
|
27
27
|
hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) === null || _b === void 0 ? void 0 : _b.call(_a, item)),
|
|
28
28
|
columnIds: state.activeColumns.map((column) => column.id),
|
|
29
|
+
enableSelection: state.props.enableSelection,
|
|
29
30
|
};
|
|
30
31
|
}, [itemId]);
|
|
31
|
-
react_1.useEffect(() => {
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
32
33
|
const div = divRef.current;
|
|
33
34
|
if (!div)
|
|
34
35
|
return;
|
|
@@ -43,5 +44,5 @@ exports.Row = react_1.memo(function Row({ itemId }) {
|
|
|
43
44
|
return () => o.disconnect();
|
|
44
45
|
}, [divRef.current]);
|
|
45
46
|
(_b = (_a = state.getState().props).debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'render row', itemId);
|
|
46
|
-
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx("div", { className: helpers_1.c(commonClasses.cellFill, className), ref: divRef }, void 0), jsx_runtime_1.jsxs("div", Object.assign({ className: helpers_1.c(commonClasses.cell, commonClasses.firstCell, className) }, { children: [jsx_runtime_1.jsx("div", { style: { width: indent * 20 } }, void 0), jsx_runtime_1.jsx(selectComponent_1.SelectComponent, { itemId: itemId }, void 0), (hasChildren || hasDeferredChildren) && jsx_runtime_1.jsx(expandComponent_1.ExpandComponent, { itemId: itemId }, void 0)] }), void 0), columnIds.map((columnId) => (jsx_runtime_1.jsx(table_1.ColumnContext.Provider, Object.assign({ value: columnId }, { children: jsx_runtime_1.jsx(cell_1.Cell, { itemId: itemId }, void 0) }), columnId))), jsx_runtime_1.jsx("div", { className: helpers_1.c(commonClasses.cellFill, className) }, void 0)] }, void 0));
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: (0, helpers_1.c)(commonClasses.cellFill, className), ref: divRef }, void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, helpers_1.c)(commonClasses.cell, commonClasses.firstCell, className) }, { children: [(0, jsx_runtime_1.jsx)("div", { style: { width: indent * 20 } }, void 0), enableSelection && (0, jsx_runtime_1.jsx)(selectComponent_1.SelectComponent, { itemId: itemId }, void 0), (hasChildren || hasDeferredChildren) && (0, jsx_runtime_1.jsx)(expandComponent_1.ExpandComponent, { itemId: itemId }, void 0)] }), void 0), columnIds.map((columnId) => ((0, jsx_runtime_1.jsx)(table_1.ColumnContext.Provider, Object.assign({ value: columnId }, { children: (0, jsx_runtime_1.jsx)(cell_1.Cell, { itemId: itemId, rowIndex: rowIndex }, void 0) }), columnId))), (0, jsx_runtime_1.jsx)("div", { className: (0, helpers_1.c)(commonClasses.cellFill, className) }, void 0)] }, void 0));
|
|
47
48
|
});
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const core_1 = require("@material-ui/core");
|
|
6
6
|
const helpers_1 = require("../misc/helpers");
|
|
7
7
|
const table_1 = require("../table");
|
|
8
|
-
const useClasses = core_1.makeStyles({
|
|
8
|
+
const useClasses = (0, core_1.makeStyles)({
|
|
9
9
|
justifiedCheckbox: {
|
|
10
10
|
justifySelf: 'start',
|
|
11
11
|
color: 'inherit',
|
|
@@ -13,7 +13,7 @@ const useClasses = core_1.makeStyles({
|
|
|
13
13
|
});
|
|
14
14
|
function SelectComponent({ itemId }) {
|
|
15
15
|
const classes = useClasses();
|
|
16
|
-
const state = table_1.useTableContext();
|
|
16
|
+
const state = (0, table_1.useTableContext)();
|
|
17
17
|
const isSelected = state.useState((state) => {
|
|
18
18
|
const itemIds = itemId ? [itemId] : [...state.activeItemsById.keys()];
|
|
19
19
|
return state.activeItemsById.size > 0 && itemIds.every((itemId) => state.selection.has(itemId));
|
|
@@ -39,10 +39,10 @@ function SelectComponent({ itemId }) {
|
|
|
39
39
|
newSelection.add(item.id);
|
|
40
40
|
}
|
|
41
41
|
if (selectSyncChildren && isSelected) {
|
|
42
|
-
for (const ancestor of helpers_1.getAncestors(activeItemsById, ...range)) {
|
|
42
|
+
for (const ancestor of (0, helpers_1.getAncestors)(activeItemsById, ...range)) {
|
|
43
43
|
newSelection.delete(ancestor);
|
|
44
44
|
}
|
|
45
|
-
for (const descendant of helpers_1.getDescendants(...range)) {
|
|
45
|
+
for (const descendant of (0, helpers_1.getDescendants)(...range)) {
|
|
46
46
|
newSelection.delete(descendant);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -56,6 +56,6 @@ function SelectComponent({ itemId }) {
|
|
|
56
56
|
state.lastSelectedId = itemId;
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
return jsx_runtime_1.jsx(core_1.Checkbox, { className: classes.justifiedCheckbox, checked: isSelected, onChange: toggle }, void 0);
|
|
59
|
+
return (0, jsx_runtime_1.jsx)(core_1.Checkbox, { className: classes.justifiedCheckbox, checked: isSelected, onChange: toggle }, void 0);
|
|
60
60
|
}
|
|
61
61
|
exports.SelectComponent = SelectComponent;
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const core_1 = require("@material-ui/core");
|
|
6
6
|
const icons_1 = require("@material-ui/icons");
|
|
7
7
|
const table_1 = require("../table");
|
|
8
|
-
const useClasses = core_1.makeStyles({
|
|
8
|
+
const useClasses = (0, core_1.makeStyles)({
|
|
9
9
|
sortView: {
|
|
10
10
|
userSelect: 'none',
|
|
11
11
|
display: 'grid',
|
|
@@ -23,8 +23,8 @@ const useClasses = core_1.makeStyles({
|
|
|
23
23
|
});
|
|
24
24
|
function SortComponent({ children }) {
|
|
25
25
|
const classes = useClasses();
|
|
26
|
-
const state = table_1.useTableContext();
|
|
27
|
-
const columnId = table_1.useColumnContext();
|
|
26
|
+
const state = (0, table_1.useTableContext)();
|
|
27
|
+
const columnId = (0, table_1.useColumnContext)();
|
|
28
28
|
const { direction, index } = state.useState((state) => {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
const index = (_a = state.sort.findIndex((s) => s.columnId === columnId)) !== null && _a !== void 0 ? _a : -1;
|
|
@@ -47,6 +47,6 @@ function SortComponent({ children }) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
return (jsx_runtime_1.jsxs("div", Object.assign({ className: classes.sortView, onClick: toggle }, { children: [jsx_runtime_1.jsx("div", { children: children }, void 0), jsx_runtime_1.jsx(core_1.Badge, Object.assign({ badgeContent: index }, { children: direction === 'asc' ? (jsx_runtime_1.jsx(icons_1.ArrowUpward, { fontSize: "small" }, void 0)) : direction === 'desc' ? (jsx_runtime_1.jsx(icons_1.ArrowDownward, { fontSize: "small" }, void 0)) : (jsx_runtime_1.jsx("div", { className: classes.empty }, void 0)) }), void 0)] }), void 0));
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes.sortView, onClick: toggle }, { children: [(0, jsx_runtime_1.jsx)("div", { children: children }, void 0), (0, jsx_runtime_1.jsx)(core_1.Badge, Object.assign({ badgeContent: index }, { children: direction === 'asc' ? ((0, jsx_runtime_1.jsx)(icons_1.ArrowUpward, { fontSize: "small" }, void 0)) : direction === 'desc' ? ((0, jsx_runtime_1.jsx)(icons_1.ArrowDownward, { fontSize: "small" }, void 0)) : ((0, jsx_runtime_1.jsx)("div", { className: classes.empty }, void 0)) }), void 0)] }), void 0));
|
|
51
51
|
}
|
|
52
52
|
exports.SortComponent = SortComponent;
|
|
@@ -16,7 +16,7 @@ class TextFilter {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.TextFilter = TextFilter;
|
|
19
|
-
const useClasses = core_1.makeStyles((theme) => ({
|
|
19
|
+
const useClasses = (0, core_1.makeStyles)((theme) => ({
|
|
20
20
|
view: {
|
|
21
21
|
padding: theme.spacing(2),
|
|
22
22
|
display: 'grid',
|
|
@@ -28,16 +28,16 @@ const useClasses = core_1.makeStyles((theme) => ({
|
|
|
28
28
|
function TextFilterComponent({ filterBy = helpers_1.asString, compare = textMatch_1.textMatch, }) {
|
|
29
29
|
var _a;
|
|
30
30
|
const classes = useClasses();
|
|
31
|
-
const state = table_1.useTableContext();
|
|
32
|
-
const columnId = table_1.useColumnContext();
|
|
31
|
+
const state = (0, table_1.useTableContext)();
|
|
32
|
+
const columnId = (0, table_1.useColumnContext)();
|
|
33
33
|
const _filter = state.useState((state) => {
|
|
34
34
|
var _a;
|
|
35
35
|
const column = state.activeColumns.find((column) => column.id === columnId);
|
|
36
36
|
return (_a = state.filters.get(columnId)) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.defaultFilter;
|
|
37
37
|
}, [columnId]);
|
|
38
38
|
const filter = _filter instanceof TextFilter ? _filter : undefined;
|
|
39
|
-
const [input, setInput] = react_1.useState();
|
|
40
|
-
react_1.useEffect(() => {
|
|
39
|
+
const [input, setInput] = (0, react_1.useState)();
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
41
|
if (input === undefined)
|
|
42
42
|
return;
|
|
43
43
|
const handle = setTimeout(() => {
|
|
@@ -64,8 +64,8 @@ function TextFilterComponent({ filterBy = helpers_1.asString, compare = textMatc
|
|
|
64
64
|
}, 500);
|
|
65
65
|
return () => clearTimeout(handle);
|
|
66
66
|
}, [input]);
|
|
67
|
-
return (jsx_runtime_1.jsx("div", Object.assign({ className: classes.view }, { children: jsx_runtime_1.jsx(core_1.TextField, { value: (_a = input !== null && input !== void 0 ? input : filter === null || filter === void 0 ? void 0 : filter.query) !== null && _a !== void 0 ? _a : '', onChange: (e) => setInput(e.target.value), InputProps: {
|
|
68
|
-
endAdornment: (filter === null || filter === void 0 ? void 0 : filter.query) ? (jsx_runtime_1.jsx(core_1.IconButton, Object.assign({ onClick: () => setInput('') }, { children: jsx_runtime_1.jsx(icons_1.Clear, {}, void 0) }), void 0)) : (jsx_runtime_1.jsx(icons_1.Search, {}, void 0)),
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.view }, { children: (0, jsx_runtime_1.jsx)(core_1.TextField, { value: (_a = input !== null && input !== void 0 ? input : filter === null || filter === void 0 ? void 0 : filter.query) !== null && _a !== void 0 ? _a : '', onChange: (e) => setInput(e.target.value), InputProps: {
|
|
68
|
+
endAdornment: (filter === null || filter === void 0 ? void 0 : filter.query) ? ((0, jsx_runtime_1.jsx)(core_1.IconButton, Object.assign({ onClick: () => setInput('') }, { children: (0, jsx_runtime_1.jsx)(icons_1.Clear, {}, void 0) }), void 0)) : ((0, jsx_runtime_1.jsx)(icons_1.Search, {}, void 0)),
|
|
69
69
|
} }, void 0) }), void 0));
|
|
70
70
|
}
|
|
71
71
|
exports.TextFilterComponent = TextFilterComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
1
|
+
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "text" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
@@ -3,16 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCommonClasses = void 0;
|
|
4
4
|
const core_1 = require("@material-ui/core");
|
|
5
5
|
const cell = (theme) => ({
|
|
6
|
-
padding: theme.spacing(0.
|
|
7
|
-
display: '
|
|
8
|
-
gridAutoFlow: 'column',
|
|
6
|
+
padding: theme.spacing(0.1, 1),
|
|
7
|
+
display: 'flex',
|
|
9
8
|
alignItems: 'center',
|
|
10
9
|
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
11
10
|
whiteSpace: 'nowrap',
|
|
12
11
|
overflow: 'hidden',
|
|
13
|
-
textOverflow: 'ellipsis',
|
|
14
12
|
});
|
|
15
|
-
exports.useCommonClasses = core_1.makeStyles((theme) => ({
|
|
13
|
+
exports.useCommonClasses = (0, core_1.makeStyles)((theme) => ({
|
|
16
14
|
table: {
|
|
17
15
|
position: 'relative',
|
|
18
16
|
display: 'grid',
|
|
@@ -21,7 +19,7 @@ exports.useCommonClasses = core_1.makeStyles((theme) => ({
|
|
|
21
19
|
cellFill: {
|
|
22
20
|
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
23
21
|
},
|
|
24
|
-
headerCell: Object.assign(Object.assign({}, cell(theme)), { borderBottom:
|
|
22
|
+
headerCell: Object.assign(Object.assign({}, cell(theme)), { borderBottom: `2px solid ${theme.palette.grey[400]}`, gridTemplateColumns: 'minmax(0, 1fr) max-content', background: theme.palette.common.white, '&:not(:first-child)': {
|
|
25
23
|
borderLeft: `1px solid ${theme.palette.background.default}`,
|
|
26
24
|
} }),
|
|
27
25
|
firstCell: {
|
|
@@ -33,7 +31,8 @@ exports.useCommonClasses = core_1.makeStyles((theme) => ({
|
|
|
33
31
|
zIndex: 1,
|
|
34
32
|
},
|
|
35
33
|
headerFill: {
|
|
36
|
-
|
|
34
|
+
borderBottom: `3px solid ${theme.palette.grey[200]}`,
|
|
35
|
+
background: theme.palette.common.white,
|
|
37
36
|
},
|
|
38
37
|
deferredPlaceholder: {
|
|
39
38
|
padding: theme.spacing(1),
|
|
@@ -42,4 +41,9 @@ exports.useCommonClasses = core_1.makeStyles((theme) => ({
|
|
|
42
41
|
display: 'grid',
|
|
43
42
|
justifyContent: 'center',
|
|
44
43
|
},
|
|
44
|
+
text: {
|
|
45
|
+
minWidth: 0,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
textOverflow: 'ellipsis',
|
|
48
|
+
},
|
|
45
49
|
}));
|
|
@@ -2,5 +2,5 @@ import { HTMLProps, ReactNode } from 'react';
|
|
|
2
2
|
import { Id } from '../types';
|
|
3
3
|
export declare function Virtualized<T>({ header, children, ...props }: {
|
|
4
4
|
header: ReactNode;
|
|
5
|
-
children: (itemIds: Id[]) => ReactNode;
|
|
5
|
+
children: (itemIds: Id[], startIndex: number) => ReactNode;
|
|
6
6
|
} & HTMLProps<HTMLDivElement>): JSX.Element;
|
|
@@ -46,11 +46,11 @@ const relativeOffset = (x, y) => {
|
|
|
46
46
|
function Virtualized(_a) {
|
|
47
47
|
var _b, _c, _d, _e;
|
|
48
48
|
var { header, children } = _a, props = __rest(_a, ["header", "children"]);
|
|
49
|
-
const state = table_1.useTableContext();
|
|
49
|
+
const state = (0, table_1.useTableContext)();
|
|
50
50
|
const virtual = state.useState('props.virtual');
|
|
51
|
-
const probeRef = react_1.useRef(null);
|
|
52
|
-
const [counter, setCounter] = react_1.useState(0);
|
|
53
|
-
const { itemIds = [], from, to, before = 0, after = 0, } = state.useState((state) => {
|
|
51
|
+
const probeRef = (0, react_1.useRef)(null);
|
|
52
|
+
const [counter, setCounter] = (0, react_1.useState)(0);
|
|
53
|
+
const { itemIds = [], from = 0, to, before = 0, after = 0, } = state.useState((state) => {
|
|
54
54
|
var _a;
|
|
55
55
|
const itemIds = state.activeItems.map((item) => item.id);
|
|
56
56
|
const root = probeRef.current && findScrollRoot(probeRef.current);
|
|
@@ -58,7 +58,7 @@ function Virtualized(_a) {
|
|
|
58
58
|
return { itemIds };
|
|
59
59
|
if (!probeRef.current || !root || !document.contains(root))
|
|
60
60
|
return {};
|
|
61
|
-
const { rowHeight, initalRowHeight } = (_a = (state.props.virtual instanceof Object ? state.props.virtual : undefined)) !== null && _a !== void 0 ? _a : {};
|
|
61
|
+
const { rowHeight, initalRowHeight, overscan = 200, overscanTop, overscanBottom, } = (_a = (state.props.virtual instanceof Object ? state.props.virtual : undefined)) !== null && _a !== void 0 ? _a : {};
|
|
62
62
|
let totalHeight = 0;
|
|
63
63
|
const rowHeights = itemIds.map((itemId, index) => {
|
|
64
64
|
var _a, _b;
|
|
@@ -72,13 +72,13 @@ function Virtualized(_a) {
|
|
|
72
72
|
const bottomOfTable = topOfTable + root.clientHeight - headerHeight;
|
|
73
73
|
let from = 0, to = itemIds.length, before = 0, after = 0;
|
|
74
74
|
for (const h of rowHeights) {
|
|
75
|
-
if (before + h > topOfTable)
|
|
75
|
+
if (before + h > topOfTable - (overscanTop !== null && overscanTop !== void 0 ? overscanTop : overscan))
|
|
76
76
|
break;
|
|
77
77
|
from++;
|
|
78
78
|
before += h;
|
|
79
79
|
}
|
|
80
80
|
for (const h of rowHeights.reverse()) {
|
|
81
|
-
if (after + h > totalHeight - bottomOfTable)
|
|
81
|
+
if (after + h > totalHeight - bottomOfTable - (overscanBottom !== null && overscanBottom !== void 0 ? overscanBottom : overscan))
|
|
82
82
|
break;
|
|
83
83
|
to--;
|
|
84
84
|
after += h;
|
|
@@ -86,13 +86,13 @@ function Virtualized(_a) {
|
|
|
86
86
|
return { itemIds: itemIds.slice(from, to), from, to, before, after };
|
|
87
87
|
}, [probeRef.current, counter]);
|
|
88
88
|
const throttleScroll = (_c = (_b = (typeof virtual === 'boolean' ? undefined : virtual)) === null || _b === void 0 ? void 0 : _b.throttleScroll) !== null && _c !== void 0 ? _c : 500;
|
|
89
|
-
const incCounter = react_1.useMemo(() => throttle_1.throttle(() => setCounter((c) => c + 1), throttleScroll), [throttleScroll]);
|
|
90
|
-
react_1.useEffect(() => {
|
|
89
|
+
const incCounter = (0, react_1.useMemo)(() => (0, throttle_1.throttle)(() => setCounter((c) => c + 1), throttleScroll), [throttleScroll]);
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
91
91
|
if (!virtual || !probeRef.current)
|
|
92
92
|
return;
|
|
93
93
|
return onAncestorScroll(probeRef.current, incCounter);
|
|
94
94
|
}, [probeRef.current, incCounter]);
|
|
95
95
|
(_e = (_d = state.getState().props).debug) === null || _e === void 0 ? void 0 : _e.call(_d, `Virtualalized render ${from} to ${to}`);
|
|
96
|
-
return (jsx_runtime_1.jsxs("div", Object.assign({}, props, { children: [header, virtual && jsx_runtime_1.jsx("div", { style: { gridColumn: '1 / -1', height: before }, ref: probeRef }, void 0), children(itemIds), virtual && jsx_runtime_1.jsx("div", { style: { gridColumn: '1 / -1', height: after } }, void 0)] }), void 0));
|
|
96
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, props, { children: [header, virtual && (0, jsx_runtime_1.jsx)("div", { style: { gridColumn: '1 / -1', height: before }, ref: probeRef }, void 0), children(itemIds, from), virtual && (0, jsx_runtime_1.jsx)("div", { style: { gridColumn: '1 / -1', height: after } }, void 0)] }), void 0));
|
|
97
97
|
}
|
|
98
98
|
exports.Virtualized = Virtualized;
|
|
@@ -5,7 +5,7 @@ const immer_1 = require("immer");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const helpers_1 = require("../misc/helpers");
|
|
7
7
|
function calcItems(state) {
|
|
8
|
-
react_1.useEffect(() => state.addReaction((state) => [
|
|
8
|
+
(0, react_1.useEffect)(() => state.addReaction((state) => [
|
|
9
9
|
state.props.items,
|
|
10
10
|
state.props.id,
|
|
11
11
|
state.props.parentId,
|
|
@@ -21,14 +21,14 @@ function calcItems(state) {
|
|
|
21
21
|
sorted = tableItems;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
const selectors = helpers_1.flatMap(sort, (sort) => {
|
|
24
|
+
const selectors = (0, helpers_1.flatMap)(sort, (sort) => {
|
|
25
25
|
const column = activeColumns.find((column) => column.id === sort.columnId);
|
|
26
26
|
if (!column)
|
|
27
27
|
return [];
|
|
28
28
|
const sortBy = column.sortBy instanceof Array ? column.sortBy : [column.sortBy];
|
|
29
29
|
return sortBy.map((sortBy) => ({ selector: (item) => sortBy(column.value(item), item), direction: sort.direction }));
|
|
30
30
|
}).filter(Boolean);
|
|
31
|
-
sorted = helpers_1.orderBy(tableItems, selectors.map((x) => x.selector), selectors.map((x) => x.direction));
|
|
31
|
+
sorted = (0, helpers_1.orderBy)(tableItems, selectors.map((x) => x.selector), selectors.map((x) => x.direction));
|
|
32
32
|
}
|
|
33
33
|
const lookup = new Map();
|
|
34
34
|
for (const item of sorted) {
|
|
@@ -76,10 +76,10 @@ function calcItems(state) {
|
|
|
76
76
|
return isActive;
|
|
77
77
|
})
|
|
78
78
|
.reverse();
|
|
79
|
-
draft.items = immer_1.castDraft(allItems);
|
|
80
|
-
draft.itemsById = immer_1.castDraft(allItemsById);
|
|
81
|
-
draft.activeItems = immer_1.castDraft(activeItems);
|
|
82
|
-
draft.activeItemsById = immer_1.castDraft(activeItemsById);
|
|
79
|
+
draft.items = (0, immer_1.castDraft)(allItems);
|
|
80
|
+
draft.itemsById = (0, immer_1.castDraft)(allItemsById);
|
|
81
|
+
draft.activeItems = (0, immer_1.castDraft)(activeItems);
|
|
82
|
+
draft.activeItemsById = (0, immer_1.castDraft)(activeItemsById);
|
|
83
83
|
}, { runNow: true }), [state]);
|
|
84
84
|
}
|
|
85
85
|
exports.calcItems = calcItems;
|