schummar-table 0.3.2 → 0.5.0-beta-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/assets/tableTheme.0eb513b0.js +215 -0
- package/dist/assets/tableTheme.0eb513b0.js.map +1 -0
- package/dist/assets/tableTheme.65fea986.js +214 -0
- package/dist/assets/tableTheme.65fea986.js.map +1 -0
- package/dist/assets/vendor.a5ec605d.js +2475 -0
- package/dist/assets/vendor.a5ec605d.js.map +1 -0
- package/dist/assets/vendor.c9c3328b.js +2464 -0
- package/dist/assets/vendor.c9c3328b.js.map +1 -0
- package/dist/cjs/mui4Theme.js +7 -0
- package/dist/cjs/mui4Theme.js.map +1 -0
- package/dist/cjs/mui5Theme.js +7 -0
- package/dist/cjs/mui5Theme.js.map +1 -0
- package/dist/cjs/schummar-table.js +1042 -0
- package/dist/cjs/schummar-table.js.map +1 -0
- package/dist/esm/mui4Theme.js +6 -0
- package/dist/esm/mui4Theme.js.map +1 -0
- package/dist/esm/mui5Theme.js +6 -0
- package/dist/esm/mui5Theme.js.map +1 -0
- package/dist/esm/schummar-table.js +1041 -0
- package/dist/esm/schummar-table.js.map +1 -0
- package/dist/{cjs → types}/components/cell.d.ts +1 -1
- package/dist/types/components/columnHeader.d.ts +7 -0
- package/dist/{cjs → types}/components/columnSelection.d.ts +0 -0
- package/dist/types/components/dateFilter.d.ts +8 -0
- package/dist/types/components/datePicker.d.ts +16 -0
- package/dist/types/components/expandControl.d.ts +6 -0
- package/dist/{cjs → types}/components/export.d.ts +0 -0
- package/dist/types/components/filterControl.d.ts +2 -0
- package/dist/types/components/formControlLabel.d.ts +5 -0
- package/dist/types/components/resizeHandle.d.ts +1 -0
- package/dist/{cjs → types}/components/row.d.ts +1 -1
- package/dist/{cjs → types}/components/selectComponent.d.ts +0 -0
- package/dist/types/components/selectFilter.d.ts +8 -0
- package/dist/{cjs → types}/components/sortComponent.d.ts +0 -0
- package/dist/types/components/spinnner.d.ts +3 -0
- package/dist/{cjs → types/components}/table.d.ts +1 -1
- package/dist/types/components/textFilter.d.ts +5 -0
- package/dist/{cjs → types}/components/virtualized.d.ts +0 -0
- package/dist/types/hooks/useFilter.d.ts +5 -0
- package/dist/types/hooks/useTheme.d.ts +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/{cjs → types}/internalState/calcItems.d.ts +0 -0
- package/dist/{cjs → types}/internalState/calcProps.d.ts +0 -0
- package/dist/{cjs → types}/internalState/cleanupState.d.ts +0 -0
- package/dist/{cjs → types}/internalState/filterColumns.d.ts +0 -0
- package/dist/{cjs → types}/internalState/syncSelections.d.ts +0 -0
- package/dist/types/internalState/tableStateStorage.d.ts +11 -0
- package/dist/{cjs → types}/internalState/useTableState.d.ts +0 -0
- package/dist/{cjs → types}/misc/csvExport.d.ts +0 -0
- package/dist/types/misc/debounce.d.ts +4 -0
- package/dist/types/misc/deepPartial.d.ts +3 -0
- package/dist/{cjs → types}/misc/helpers.d.ts +2 -1
- package/dist/types/misc/queue.d.ts +6 -0
- package/dist/{cjs → types}/misc/textMatch.d.ts +0 -0
- package/dist/types/misc/throttle.d.ts +4 -0
- package/dist/types/theme/defaultClasses.d.ts +15 -0
- package/dist/types/theme/defaultColors.d.ts +2 -0
- package/dist/types/theme/defaultIcons.d.ts +2 -0
- package/dist/types/theme/defaultTexts.d.ts +2 -0
- package/dist/types/theme/defaultTheme/badge.d.ts +2 -0
- package/dist/types/theme/defaultTheme/button.d.ts +2 -0
- package/dist/types/theme/defaultTheme/checkbox.d.ts +2 -0
- package/dist/types/theme/defaultTheme/iconButton.d.ts +2 -0
- package/dist/types/theme/defaultTheme/index.d.ts +2 -0
- package/dist/types/theme/defaultTheme/popover.d.ts +4 -0
- package/dist/types/theme/defaultTheme/textField.d.ts +2 -0
- package/dist/types/theme/mui4Theme/index.d.ts +8 -0
- package/dist/types/theme/mui5Theme/index.d.ts +8 -0
- package/dist/types/theme/tableTheme.d.ts +11 -0
- package/dist/types/theme/useCssVariables.d.ts +9 -0
- package/dist/types/types.d.ts +285 -0
- package/package.json +78 -38
- package/dist/cjs/components/cell.js +0 -31
- package/dist/cjs/components/columnSelection.js +0 -37
- package/dist/cjs/components/defaultFilterComponent.d.ts +0 -22
- package/dist/cjs/components/defaultFilterComponent.js +0 -91
- package/dist/cjs/components/expandComponent.d.ts +0 -5
- package/dist/cjs/components/expandComponent.js +0 -38
- package/dist/cjs/components/export.js +0 -48
- package/dist/cjs/components/filterComponent.d.ts +0 -5
- package/dist/cjs/components/filterComponent.js +0 -25
- package/dist/cjs/components/row.js +0 -48
- package/dist/cjs/components/selectComponent.js +0 -61
- package/dist/cjs/components/sortComponent.js +0 -52
- package/dist/cjs/components/textFilterComponent.d.ts +0 -11
- package/dist/cjs/components/textFilterComponent.js +0 -70
- package/dist/cjs/components/useCommonClasses.d.ts +0 -1
- package/dist/cjs/components/useCommonClasses.js +0 -49
- package/dist/cjs/components/virtualized.js +0 -98
- package/dist/cjs/index.d.ts +0 -6
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/internalState/calcItems.js +0 -85
- package/dist/cjs/internalState/calcProps.js +0 -89
- package/dist/cjs/internalState/cleanupState.js +0 -43
- package/dist/cjs/internalState/filterColumns.js +0 -10
- package/dist/cjs/internalState/syncSelections.js +0 -22
- package/dist/cjs/internalState/useTableState.js +0 -62
- package/dist/cjs/misc/csvExport.js +0 -15
- package/dist/cjs/misc/helpers.js +0 -91
- package/dist/cjs/misc/textMatch.js +0 -23
- package/dist/cjs/misc/throttle.d.ts +0 -1
- package/dist/cjs/misc/throttle.js +0 -30
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/table.js +0 -69
- package/dist/cjs/types.d.ts +0 -134
- package/dist/cjs/types.js +0 -2
- package/dist/esm/components/cell.d.ts +0 -6
- package/dist/esm/components/cell.js +0 -28
- package/dist/esm/components/columnSelection.d.ts +0 -2
- package/dist/esm/components/columnSelection.js +0 -33
- package/dist/esm/components/defaultFilterComponent.d.ts +0 -22
- package/dist/esm/components/defaultFilterComponent.js +0 -86
- package/dist/esm/components/expandComponent.d.ts +0 -5
- package/dist/esm/components/expandComponent.js +0 -34
- package/dist/esm/components/export.d.ts +0 -2
- package/dist/esm/components/export.js +0 -44
- package/dist/esm/components/filterComponent.d.ts +0 -5
- package/dist/esm/components/filterComponent.js +0 -21
- package/dist/esm/components/row.d.ts +0 -7
- package/dist/esm/components/row.js +0 -44
- package/dist/esm/components/selectComponent.d.ts +0 -5
- package/dist/esm/components/selectComponent.js +0 -57
- package/dist/esm/components/sortComponent.d.ts +0 -4
- package/dist/esm/components/sortComponent.js +0 -48
- package/dist/esm/components/textFilterComponent.d.ts +0 -11
- package/dist/esm/components/textFilterComponent.js +0 -65
- package/dist/esm/components/useCommonClasses.d.ts +0 -1
- package/dist/esm/components/useCommonClasses.js +0 -46
- package/dist/esm/components/virtualized.d.ts +0 -6
- package/dist/esm/components/virtualized.js +0 -94
- package/dist/esm/index.d.ts +0 -6
- package/dist/esm/index.js +0 -4
- package/dist/esm/internalState/calcItems.d.ts +0 -3
- package/dist/esm/internalState/calcItems.js +0 -81
- package/dist/esm/internalState/calcProps.d.ts +0 -2
- package/dist/esm/internalState/calcProps.js +0 -85
- package/dist/esm/internalState/cleanupState.d.ts +0 -3
- package/dist/esm/internalState/cleanupState.js +0 -39
- package/dist/esm/internalState/filterColumns.d.ts +0 -3
- package/dist/esm/internalState/filterColumns.js +0 -6
- package/dist/esm/internalState/syncSelections.d.ts +0 -3
- package/dist/esm/internalState/syncSelections.js +0 -18
- package/dist/esm/internalState/useTableState.d.ts +0 -3
- package/dist/esm/internalState/useTableState.js +0 -58
- package/dist/esm/misc/csvExport.d.ts +0 -7
- package/dist/esm/misc/csvExport.js +0 -11
- package/dist/esm/misc/helpers.d.ts +0 -14
- package/dist/esm/misc/helpers.js +0 -77
- package/dist/esm/misc/textMatch.d.ts +0 -2
- package/dist/esm/misc/textMatch.js +0 -18
- package/dist/esm/misc/throttle.d.ts +0 -1
- package/dist/esm/misc/throttle.js +0 -26
- package/dist/esm/table.d.ts +0 -8
- package/dist/esm/table.js +0 -63
- package/dist/esm/types.d.ts +0 -134
- package/dist/esm/types.js +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox, FormControlLabel, IconButton, makeStyles, Popover } from '@material-ui/core';
|
|
3
|
-
import { Settings } from '@material-ui/icons';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
import { useTableContext } from '../table';
|
|
6
|
-
const useClasses = makeStyles((theme) => ({
|
|
7
|
-
list: {
|
|
8
|
-
padding: theme.spacing(2),
|
|
9
|
-
display: 'grid',
|
|
10
|
-
},
|
|
11
|
-
}));
|
|
12
|
-
export function ColumnSelection() {
|
|
13
|
-
const classes = useClasses();
|
|
14
|
-
const [anchor, setAnchor] = useState(null);
|
|
15
|
-
const state = useTableContext();
|
|
16
|
-
const columns = state.useState('props.columns');
|
|
17
|
-
const hiddenColumns = state.useState('hiddenColumns');
|
|
18
|
-
const toggle = (column) => {
|
|
19
|
-
const { props: { hiddenColumns: controlledHiddenColumns, onHiddenColumnsChange }, } = state.getState();
|
|
20
|
-
const newValue = new Set(hiddenColumns);
|
|
21
|
-
if (hiddenColumns.has(column.id))
|
|
22
|
-
newValue.delete(column.id);
|
|
23
|
-
else
|
|
24
|
-
newValue.add(column.id);
|
|
25
|
-
if (!controlledHiddenColumns) {
|
|
26
|
-
state.update((state) => {
|
|
27
|
-
state.hiddenColumns = newValue;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
onHiddenColumnsChange === null || onHiddenColumnsChange === void 0 ? void 0 : onHiddenColumnsChange(newValue);
|
|
31
|
-
};
|
|
32
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ color: "inherit", size: "small", onClick: (e) => setAnchor(e.currentTarget) }, { children: _jsx(Settings, {}, void 0) }), void 0), _jsx(Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'left' } }, { children: _jsx("div", Object.assign({ className: classes.list }, { children: columns.map((column) => (_jsx(FormControlLabel, { control: _jsx(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));
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Filter } from './filterComponent';
|
|
3
|
-
export declare class DefaultFilter<T, O> implements Filter<T> {
|
|
4
|
-
readonly values: Set<O>;
|
|
5
|
-
readonly filter: (item: T) => boolean;
|
|
6
|
-
constructor(values: Set<O>, filter: (item: T) => boolean);
|
|
7
|
-
}
|
|
8
|
-
declare type UnwrapArray<O> = O extends Array<infer S> ? S : O;
|
|
9
|
-
export declare function DefaultFilterComponent<V>(props: {
|
|
10
|
-
options?: UnwrapArray<V>[];
|
|
11
|
-
compare?: (a: UnwrapArray<V>, b: UnwrapArray<V>) => boolean;
|
|
12
|
-
stringValue?: (value: UnwrapArray<V>) => string;
|
|
13
|
-
render?: (value: UnwrapArray<V>) => ReactNode;
|
|
14
|
-
}): JSX.Element;
|
|
15
|
-
export declare function DefaultFilterComponent<T, V, O>(props: {
|
|
16
|
-
filterBy?: (value: V, item: T) => O | O[];
|
|
17
|
-
options?: O[];
|
|
18
|
-
compare?: (a: O, b: O) => boolean;
|
|
19
|
-
stringValue?: (value: O) => string;
|
|
20
|
-
render?: (value: O) => ReactNode;
|
|
21
|
-
}): JSX.Element;
|
|
22
|
-
export {};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Checkbox, FormControlLabel, IconButton, makeStyles, TextField } from '@material-ui/core';
|
|
3
|
-
import { Clear, Search } from '@material-ui/icons';
|
|
4
|
-
import { useCallback, useState } from 'react';
|
|
5
|
-
import { asString, defaultEquals, flatMap, orderBy, uniq } from '../misc/helpers';
|
|
6
|
-
import { useColumnContext, useTableContext } from '../table';
|
|
7
|
-
export class DefaultFilter {
|
|
8
|
-
constructor(values, filter) {
|
|
9
|
-
this.values = values;
|
|
10
|
-
this.filter = filter;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const useClasses = makeStyles((theme) => ({
|
|
14
|
-
view: {
|
|
15
|
-
padding: theme.spacing(2),
|
|
16
|
-
display: 'grid',
|
|
17
|
-
'& > :first-child': {
|
|
18
|
-
marginBottom: theme.spacing(2),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
}));
|
|
22
|
-
export function DefaultFilterComponent({ filterBy: _filterBy, options: _options, compare = defaultEquals, stringValue = asString, render = stringValue, }) {
|
|
23
|
-
var _a;
|
|
24
|
-
const classes = useClasses();
|
|
25
|
-
const state = useTableContext();
|
|
26
|
-
const columnId = useColumnContext();
|
|
27
|
-
const filterBy = useCallback((value, item) => {
|
|
28
|
-
const values = _filterBy ? _filterBy(value, item) : value;
|
|
29
|
-
return values instanceof Array ? values : [values];
|
|
30
|
-
}, [_filterBy]);
|
|
31
|
-
const { text, options, filter } = state.useState((state) => {
|
|
32
|
-
const column = state.activeColumns.find((column) => column.id === columnId);
|
|
33
|
-
const _filter = state.filters.get(columnId);
|
|
34
|
-
const filter = _filter instanceof DefaultFilter ? _filter : undefined;
|
|
35
|
-
let options = _options !== null && _options !== void 0 ? _options : orderBy(uniq(flatMap(state.items, (item) => (column ? filterBy(column.value(item), item) : []))));
|
|
36
|
-
if (filter)
|
|
37
|
-
options = options.concat([...filter.values].filter((value) => !options.includes(value)));
|
|
38
|
-
return { text: state.props.text, options, filter };
|
|
39
|
-
}, [_options, columnId, filterBy]);
|
|
40
|
-
const [input, setInput] = useState('');
|
|
41
|
-
const filtered = options.filter((option) => !input || stringValue(option).toLowerCase().includes(input.toLowerCase()));
|
|
42
|
-
function toggle(value) {
|
|
43
|
-
var _a;
|
|
44
|
-
const column = state.getState().activeColumns.find((column) => column.id === columnId);
|
|
45
|
-
if (!column)
|
|
46
|
-
return;
|
|
47
|
-
const newValues = new Set(filter === null || filter === void 0 ? void 0 : filter.values);
|
|
48
|
-
if (newValues === null || newValues === void 0 ? void 0 : newValues.has(value))
|
|
49
|
-
newValues.delete(value);
|
|
50
|
-
else
|
|
51
|
-
newValues === null || newValues === void 0 ? void 0 : newValues.add(value);
|
|
52
|
-
const newFilter = newValues.size === 0
|
|
53
|
-
? undefined
|
|
54
|
-
: new DefaultFilter(newValues, (item) => {
|
|
55
|
-
const itemValues = filterBy(column.value(item), item);
|
|
56
|
-
return [...newValues].some((value) => itemValues.some((itemValue) => compare(value, itemValue)));
|
|
57
|
-
});
|
|
58
|
-
if (!column.filter) {
|
|
59
|
-
state.update((state) => {
|
|
60
|
-
if (newFilter)
|
|
61
|
-
state.filters.set(column.id, newFilter);
|
|
62
|
-
else
|
|
63
|
-
state.filters.delete(column.id);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
(_a = column.onFilterChange) === null || _a === void 0 ? void 0 : _a.call(column, newFilter);
|
|
67
|
-
}
|
|
68
|
-
function deselectAll() {
|
|
69
|
-
var _a;
|
|
70
|
-
const column = state.getState().activeColumns.find((column) => column.id === columnId);
|
|
71
|
-
if (!column)
|
|
72
|
-
return;
|
|
73
|
-
if (!column.filter) {
|
|
74
|
-
state.update((state) => {
|
|
75
|
-
state.filters.delete(column.id);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
(_a = column.onFilterChange) === null || _a === void 0 ? void 0 : _a.call(column);
|
|
79
|
-
}
|
|
80
|
-
return (_jsxs("div", Object.assign({ className: classes.view }, { children: [_jsx(TextField, { value: input, onChange: (e) => setInput(e.target.value), InputProps: {
|
|
81
|
-
endAdornment: input ? (_jsx(IconButton, Object.assign({ onClick: () => setInput('') }, { children: _jsx(Clear, {}, void 0) }), void 0)) : (_jsx(Search, {}, void 0)),
|
|
82
|
-
} }, void 0), _jsx(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) => {
|
|
83
|
-
var _a;
|
|
84
|
-
return (_jsx(FormControlLabel, { control: _jsx(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));
|
|
85
|
-
})] }), void 0));
|
|
86
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { IconButton } from '@material-ui/core';
|
|
3
|
-
import { ChevronRight } from '@material-ui/icons';
|
|
4
|
-
import { getAncestors } from '../misc/helpers';
|
|
5
|
-
import { useTableContext } from '../table';
|
|
6
|
-
export function ExpandComponent({ itemId }) {
|
|
7
|
-
const state = useTableContext();
|
|
8
|
-
const isExpanded = state.useState((state) => state.expanded.has(itemId), [itemId]);
|
|
9
|
-
function toggle() {
|
|
10
|
-
const { props: { expanded: controlledExpanded, expandOnlyOne, onExpandedChange }, expanded, activeItemsById, } = state.getState();
|
|
11
|
-
const newExpanded = new Set(expanded);
|
|
12
|
-
if (expandOnlyOne)
|
|
13
|
-
newExpanded.clear();
|
|
14
|
-
if (isExpanded)
|
|
15
|
-
newExpanded.delete(itemId);
|
|
16
|
-
else {
|
|
17
|
-
newExpanded.add(itemId);
|
|
18
|
-
const item = activeItemsById.get(itemId);
|
|
19
|
-
for (const ancestor of item ? getAncestors(activeItemsById, item) : []) {
|
|
20
|
-
newExpanded.add(ancestor);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(newExpanded);
|
|
24
|
-
if (!controlledExpanded) {
|
|
25
|
-
state.update((state) => {
|
|
26
|
-
state.expanded = newExpanded;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return (_jsx(IconButton, Object.assign({ size: "small", onClick: toggle }, { children: _jsx(ChevronRight, { style: {
|
|
31
|
-
transition: 'all 500ms',
|
|
32
|
-
transform: isExpanded ? 'rotate3d(0, 0, 1, 90deg)' : 'none',
|
|
33
|
-
} }, void 0) }), void 0));
|
|
34
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, IconButton, makeStyles, Popover, Typography } from '@material-ui/core';
|
|
3
|
-
import { AssignmentReturn, CloudDownload } from '@material-ui/icons';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
import { csvExport } from '../misc/csvExport';
|
|
6
|
-
import { useTableContext } from '../table';
|
|
7
|
-
const useClasses = makeStyles((theme) => ({
|
|
8
|
-
dialog: {
|
|
9
|
-
padding: theme.spacing(2),
|
|
10
|
-
display: 'grid',
|
|
11
|
-
justifyItems: 'stretch',
|
|
12
|
-
'& > *': {
|
|
13
|
-
justifyContent: 'start',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
}));
|
|
17
|
-
export function Export() {
|
|
18
|
-
const classes = useClasses();
|
|
19
|
-
const [anchor, setAnchor] = useState(null);
|
|
20
|
-
const state = useTableContext();
|
|
21
|
-
const textTitle = state.useState('props.text.exportTitle');
|
|
22
|
-
const textCopy = state.useState('props.text.exportCopy');
|
|
23
|
-
const textDownload = state.useState('props.text.exportDownload');
|
|
24
|
-
const generate = (options) => {
|
|
25
|
-
const { activeColumns, activeItems } = state.getState();
|
|
26
|
-
const data = [
|
|
27
|
-
activeColumns.map((column) => String(column.id)),
|
|
28
|
-
...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item), item))),
|
|
29
|
-
];
|
|
30
|
-
return csvExport(data, options);
|
|
31
|
-
};
|
|
32
|
-
const copy = () => {
|
|
33
|
-
navigator.clipboard.writeText(generate(state.getState().props.enableExport.copy));
|
|
34
|
-
};
|
|
35
|
-
const download = () => {
|
|
36
|
-
const a = document.createElement('a');
|
|
37
|
-
a.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(generate(state.getState().props.enableExport.download));
|
|
38
|
-
a.download = 'export.csv';
|
|
39
|
-
document.body.appendChild(a);
|
|
40
|
-
a.click();
|
|
41
|
-
document.body.removeChild(a);
|
|
42
|
-
};
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ color: "inherit", size: "small", onClick: (e) => setAnchor(e.currentTarget) }, { children: _jsx(CloudDownload, {}, void 0) }), void 0), _jsx(Popover, Object.assign({ open: !!anchor, onClose: () => setAnchor(null), anchorEl: anchor, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'left' } }, { children: _jsxs("div", Object.assign({ className: classes.dialog }, { children: [_jsx(Typography, Object.assign({ variant: "caption" }, { children: textTitle !== null && textTitle !== void 0 ? textTitle : 'Export' }), void 0), _jsx(Button, Object.assign({ startIcon: _jsx(AssignmentReturn, {}, void 0), fullWidth: true, onClick: copy }, { children: textCopy !== null && textCopy !== void 0 ? textCopy : 'In die Zwischenablage' }), void 0), _jsx(Button, Object.assign({ startIcon: _jsx(CloudDownload, {}, void 0), fullWidth: true, onClick: download }, { children: textDownload !== null && textDownload !== void 0 ? textDownload : 'Herunterladen' }), void 0)] }), void 0) }), void 0)] }, void 0));
|
|
44
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { IconButton, makeStyles, Popover } from '@material-ui/core';
|
|
3
|
-
import { ArrowDropDown, FilterList } from '@material-ui/icons';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
import { useColumnContext, useTableContext } from '../table';
|
|
6
|
-
const useClasses = makeStyles((theme) => ({
|
|
7
|
-
active: {
|
|
8
|
-
background: theme.palette.primary.main,
|
|
9
|
-
},
|
|
10
|
-
}));
|
|
11
|
-
export function FilterComponent() {
|
|
12
|
-
const state = useTableContext();
|
|
13
|
-
const columnId = useColumnContext();
|
|
14
|
-
const classes = useClasses();
|
|
15
|
-
const isActive = state.useState((state) => !!state.filters.get(columnId), [columnId]);
|
|
16
|
-
const filterComponent = state.useState((state) => { var _a; return (_a = state.activeColumns.find((column) => column.id === columnId)) === null || _a === void 0 ? void 0 : _a.filterComponent; });
|
|
17
|
-
const [anchor, setAnchor] = useState(null);
|
|
18
|
-
if (!filterComponent)
|
|
19
|
-
return null;
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ size: "small", color: "inherit", onClick: (e) => setAnchor(e.currentTarget), className: isActive ? classes.active : undefined }, { children: isActive ? _jsx(FilterList, {}, void 0) : _jsx(ArrowDropDown, {}, void 0) }), void 0), _jsx(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));
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Id, InternalColumn } from '../types';
|
|
3
|
-
export declare const calcClassName: (classes: InternalColumn<any, any>['classes'] | undefined, index: number) => string;
|
|
4
|
-
export declare const Row: React.MemoExoticComponent<(<T>({ itemId, rowIndex }: {
|
|
5
|
-
itemId: Id;
|
|
6
|
-
rowIndex: number;
|
|
7
|
-
}) => JSX.Element | null)>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useEffect, useRef } from 'react';
|
|
3
|
-
import { c, getAncestors } from '../misc/helpers';
|
|
4
|
-
import { ColumnContext, useTableContext } from '../table';
|
|
5
|
-
import { Cell } from './cell';
|
|
6
|
-
import { ExpandComponent } from './expandComponent';
|
|
7
|
-
import { SelectComponent } from './selectComponent';
|
|
8
|
-
import { useCommonClasses } from './useCommonClasses';
|
|
9
|
-
export const calcClassName = (classes, index) => 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 });
|
|
10
|
-
export const Row = memo(function Row({ itemId, rowIndex }) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
const commonClasses = useCommonClasses();
|
|
13
|
-
const state = useTableContext();
|
|
14
|
-
const divRef = useRef(null);
|
|
15
|
-
const { className, indent, hasChildren, hasDeferredChildren, columnIds, enableSelection } = state.useState((state) => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
const item = state.activeItemsById.get(itemId);
|
|
18
|
-
const index = !item ? -1 : state.activeItems.indexOf(item);
|
|
19
|
-
return {
|
|
20
|
-
className: calcClassName(state.props.classes, index),
|
|
21
|
-
indent: item ? getAncestors(state.activeItemsById, item).size : 0,
|
|
22
|
-
hasChildren: !!(item === null || item === void 0 ? void 0 : item.children.length),
|
|
23
|
-
hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) === null || _b === void 0 ? void 0 : _b.call(_a, item)),
|
|
24
|
-
columnIds: state.activeColumns.map((column) => column.id),
|
|
25
|
-
enableSelection: state.props.enableSelection,
|
|
26
|
-
};
|
|
27
|
-
}, [itemId]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const div = divRef.current;
|
|
30
|
-
if (!div)
|
|
31
|
-
return;
|
|
32
|
-
const o = new ResizeObserver(() => {
|
|
33
|
-
if (!document.contains(div))
|
|
34
|
-
return;
|
|
35
|
-
state.update((state) => {
|
|
36
|
-
state.rowHeights.set(itemId, div.offsetHeight);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
o.observe(div);
|
|
40
|
-
return () => o.disconnect();
|
|
41
|
-
}, [divRef.current]);
|
|
42
|
-
(_b = (_a = state.getState().props).debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'render row', itemId);
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: c(commonClasses.cellFill, className), ref: divRef }, void 0), _jsxs("div", Object.assign({ className: c(commonClasses.cell, commonClasses.firstCell, className) }, { children: [_jsx("div", { style: { width: indent * 20 } }, void 0), enableSelection && _jsx(SelectComponent, { itemId: itemId }, void 0), (hasChildren || hasDeferredChildren) && _jsx(ExpandComponent, { itemId: itemId }, void 0)] }), void 0), columnIds.map((columnId) => (_jsx(ColumnContext.Provider, Object.assign({ value: columnId }, { children: _jsx(Cell, { itemId: itemId, rowIndex: rowIndex }, void 0) }), columnId))), _jsx("div", { className: c(commonClasses.cellFill, className) }, void 0)] }, void 0));
|
|
44
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox, makeStyles } from '@material-ui/core';
|
|
3
|
-
import { getAncestors, getDescendants } from '../misc/helpers';
|
|
4
|
-
import { useTableContext } from '../table';
|
|
5
|
-
const useClasses = makeStyles({
|
|
6
|
-
justifiedCheckbox: {
|
|
7
|
-
justifySelf: 'start',
|
|
8
|
-
color: 'inherit',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
export function SelectComponent({ itemId }) {
|
|
12
|
-
const classes = useClasses();
|
|
13
|
-
const state = useTableContext();
|
|
14
|
-
const isSelected = state.useState((state) => {
|
|
15
|
-
const itemIds = itemId ? [itemId] : [...state.activeItemsById.keys()];
|
|
16
|
-
return state.activeItemsById.size > 0 && itemIds.every((itemId) => state.selection.has(itemId));
|
|
17
|
-
}, [itemId]);
|
|
18
|
-
function toggle(e) {
|
|
19
|
-
const mouseEvent = e.nativeEvent;
|
|
20
|
-
const { activeItems, activeItemsById, lastSelectedId, selection, props: { selectSyncChildren, selection: controlledSelection, onSelectionChange }, } = state.getState();
|
|
21
|
-
let range;
|
|
22
|
-
if (mouseEvent.shiftKey && itemId) {
|
|
23
|
-
const a = lastSelectedId ? activeItems.findIndex((i) => lastSelectedId === i.id) : 0;
|
|
24
|
-
const b = activeItems.findIndex((item) => item.id === itemId);
|
|
25
|
-
range = activeItems.slice(Math.min(a, b), Math.max(a, b) + 1);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const item = itemId ? activeItemsById.get(itemId) : undefined;
|
|
29
|
-
range = item ? [item] : activeItems;
|
|
30
|
-
}
|
|
31
|
-
const newSelection = new Set(selection);
|
|
32
|
-
for (const item of range) {
|
|
33
|
-
if (isSelected)
|
|
34
|
-
newSelection.delete(item.id);
|
|
35
|
-
else
|
|
36
|
-
newSelection.add(item.id);
|
|
37
|
-
}
|
|
38
|
-
if (selectSyncChildren && isSelected) {
|
|
39
|
-
for (const ancestor of getAncestors(activeItemsById, ...range)) {
|
|
40
|
-
newSelection.delete(ancestor);
|
|
41
|
-
}
|
|
42
|
-
for (const descendant of getDescendants(...range)) {
|
|
43
|
-
newSelection.delete(descendant);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(newSelection);
|
|
47
|
-
if (!controlledSelection) {
|
|
48
|
-
state.update((state) => {
|
|
49
|
-
state.selection = newSelection;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
state.update((state) => {
|
|
53
|
-
state.lastSelectedId = itemId;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return _jsx(Checkbox, { className: classes.justifiedCheckbox, checked: isSelected, onChange: toggle }, void 0);
|
|
57
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Badge, makeStyles } from '@material-ui/core';
|
|
3
|
-
import { ArrowDownward, ArrowUpward } from '@material-ui/icons';
|
|
4
|
-
import { useColumnContext, useTableContext } from '../table';
|
|
5
|
-
const useClasses = makeStyles({
|
|
6
|
-
sortView: {
|
|
7
|
-
userSelect: 'none',
|
|
8
|
-
display: 'grid',
|
|
9
|
-
gridTemplateColumns: 'minmax(0, 1fr) max-content',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
cursor: 'pointer',
|
|
12
|
-
'& > div': {
|
|
13
|
-
overflow: 'hidden',
|
|
14
|
-
textOverflow: 'ellipsis',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
empty: {
|
|
18
|
-
width: 20,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
export function SortComponent({ children }) {
|
|
22
|
-
const classes = useClasses();
|
|
23
|
-
const state = useTableContext();
|
|
24
|
-
const columnId = useColumnContext();
|
|
25
|
-
const { direction, index } = state.useState((state) => {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
const index = (_a = state.sort.findIndex((s) => s.columnId === columnId)) !== null && _a !== void 0 ? _a : -1;
|
|
28
|
-
return {
|
|
29
|
-
direction: (_b = state.sort[index]) === null || _b === void 0 ? void 0 : _b.direction,
|
|
30
|
-
index: index >= 0 ? index + 1 : undefined,
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
function toggle(e) {
|
|
34
|
-
const { props: { sort: controlledSort, onSortChange }, } = state.getState();
|
|
35
|
-
const newDirection = direction === 'asc' ? 'desc' : 'asc';
|
|
36
|
-
const newSort = (e.getModifierState('Control') ? state.getState().sort.filter((s) => s.columnId !== columnId) : []).concat({
|
|
37
|
-
columnId,
|
|
38
|
-
direction: newDirection,
|
|
39
|
-
});
|
|
40
|
-
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(newSort);
|
|
41
|
-
if (!controlledSort) {
|
|
42
|
-
state.update((state) => {
|
|
43
|
-
state.sort = newSort;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return (_jsxs("div", Object.assign({ className: classes.sortView, onClick: toggle }, { children: [_jsx("div", { children: children }, void 0), _jsx(Badge, Object.assign({ badgeContent: index }, { children: direction === 'asc' ? (_jsx(ArrowUpward, { fontSize: "small" }, void 0)) : direction === 'desc' ? (_jsx(ArrowDownward, { fontSize: "small" }, void 0)) : (_jsx("div", { className: classes.empty }, void 0)) }), void 0)] }), void 0));
|
|
48
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Filter } from './filterComponent';
|
|
3
|
-
export declare class TextFilter<T> implements Filter<T> {
|
|
4
|
-
readonly query: string;
|
|
5
|
-
readonly filter: (item: T) => boolean;
|
|
6
|
-
constructor(query: string, filter: (item: T) => boolean);
|
|
7
|
-
}
|
|
8
|
-
export declare function TextFilterComponent<T, V>({ filterBy, compare, }: {
|
|
9
|
-
filterBy?: (value: V, item: T) => string;
|
|
10
|
-
compare?: (a: string, b: string) => boolean;
|
|
11
|
-
}): JSX.Element;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { IconButton, makeStyles, TextField } from '@material-ui/core';
|
|
3
|
-
import { Clear, Search } from '@material-ui/icons';
|
|
4
|
-
import { useEffect, useState } from 'react';
|
|
5
|
-
import { asString } from '../misc/helpers';
|
|
6
|
-
import { textMatch } from '../misc/textMatch';
|
|
7
|
-
import { useColumnContext, useTableContext } from '../table';
|
|
8
|
-
export class TextFilter {
|
|
9
|
-
constructor(query, filter) {
|
|
10
|
-
this.query = query;
|
|
11
|
-
this.filter = filter;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const useClasses = makeStyles((theme) => ({
|
|
15
|
-
view: {
|
|
16
|
-
padding: theme.spacing(2),
|
|
17
|
-
display: 'grid',
|
|
18
|
-
'& > :first-child': {
|
|
19
|
-
marginBottom: theme.spacing(2),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
export function TextFilterComponent({ filterBy = asString, compare = textMatch, }) {
|
|
24
|
-
var _a;
|
|
25
|
-
const classes = useClasses();
|
|
26
|
-
const state = useTableContext();
|
|
27
|
-
const columnId = useColumnContext();
|
|
28
|
-
const _filter = state.useState((state) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const column = state.activeColumns.find((column) => column.id === columnId);
|
|
31
|
-
return (_a = state.filters.get(columnId)) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.defaultFilter;
|
|
32
|
-
}, [columnId]);
|
|
33
|
-
const filter = _filter instanceof TextFilter ? _filter : undefined;
|
|
34
|
-
const [input, setInput] = useState();
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (input === undefined)
|
|
37
|
-
return;
|
|
38
|
-
const handle = setTimeout(() => {
|
|
39
|
-
var _a;
|
|
40
|
-
const column = state.getState().activeColumns.find((column) => column.id === columnId);
|
|
41
|
-
if (!column)
|
|
42
|
-
return;
|
|
43
|
-
const newFilter = input
|
|
44
|
-
? new TextFilter(input, (item) => {
|
|
45
|
-
const itemValue = filterBy(column.value(item), item);
|
|
46
|
-
return compare(itemValue, input);
|
|
47
|
-
})
|
|
48
|
-
: undefined;
|
|
49
|
-
if (!column.filter) {
|
|
50
|
-
state.update((state) => {
|
|
51
|
-
if (newFilter)
|
|
52
|
-
state.filters.set(column.id, newFilter);
|
|
53
|
-
else
|
|
54
|
-
state.filters.delete(column.id);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
(_a = column.onFilterChange) === null || _a === void 0 ? void 0 : _a.call(column, newFilter);
|
|
58
|
-
setInput(undefined);
|
|
59
|
-
}, 500);
|
|
60
|
-
return () => clearTimeout(handle);
|
|
61
|
-
}, [input]);
|
|
62
|
-
return (_jsx("div", Object.assign({ className: classes.view }, { children: _jsx(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: {
|
|
63
|
-
endAdornment: (filter === null || filter === void 0 ? void 0 : filter.query) ? (_jsx(IconButton, Object.assign({ onClick: () => setInput('') }, { children: _jsx(Clear, {}, void 0) }), void 0)) : (_jsx(Search, {}, void 0)),
|
|
64
|
-
} }, void 0) }), void 0));
|
|
65
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "text" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@material-ui/core';
|
|
2
|
-
const cell = (theme) => ({
|
|
3
|
-
padding: theme.spacing(0.1, 1),
|
|
4
|
-
display: 'flex',
|
|
5
|
-
alignItems: 'center',
|
|
6
|
-
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
7
|
-
whiteSpace: 'nowrap',
|
|
8
|
-
overflow: 'hidden',
|
|
9
|
-
});
|
|
10
|
-
export const useCommonClasses = makeStyles((theme) => ({
|
|
11
|
-
table: {
|
|
12
|
-
position: 'relative',
|
|
13
|
-
display: 'grid',
|
|
14
|
-
},
|
|
15
|
-
cell: cell(theme),
|
|
16
|
-
cellFill: {
|
|
17
|
-
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
18
|
-
},
|
|
19
|
-
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)': {
|
|
20
|
-
borderLeft: `1px solid ${theme.palette.background.default}`,
|
|
21
|
-
} }),
|
|
22
|
-
firstCell: {
|
|
23
|
-
justifyContent: 'start',
|
|
24
|
-
},
|
|
25
|
-
sticky: {
|
|
26
|
-
position: 'sticky',
|
|
27
|
-
top: 0,
|
|
28
|
-
zIndex: 1,
|
|
29
|
-
},
|
|
30
|
-
headerFill: {
|
|
31
|
-
borderBottom: `3px solid ${theme.palette.grey[200]}`,
|
|
32
|
-
background: theme.palette.common.white,
|
|
33
|
-
},
|
|
34
|
-
deferredPlaceholder: {
|
|
35
|
-
padding: theme.spacing(1),
|
|
36
|
-
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
37
|
-
gridColumn: '1 / -1',
|
|
38
|
-
display: 'grid',
|
|
39
|
-
justifyContent: 'center',
|
|
40
|
-
},
|
|
41
|
-
text: {
|
|
42
|
-
minWidth: 0,
|
|
43
|
-
overflow: 'hidden',
|
|
44
|
-
textOverflow: 'ellipsis',
|
|
45
|
-
},
|
|
46
|
-
}));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { HTMLProps, ReactNode } from 'react';
|
|
2
|
-
import { Id } from '../types';
|
|
3
|
-
export declare function Virtualized<T>({ header, children, ...props }: {
|
|
4
|
-
header: ReactNode;
|
|
5
|
-
children: (itemIds: Id[], startIndex: number) => ReactNode;
|
|
6
|
-
} & HTMLProps<HTMLDivElement>): JSX.Element;
|