es-grid-template 1.7.22 → 1.7.24
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/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +5 -1
- package/es/grid-component/TableGrid.js +2 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/es/table-component/ColumnsChoose.d.ts +10 -0
- package/es/table-component/ColumnsChoose.js +557 -0
- package/es/table-component/ContextMenu.d.ts +20 -0
- package/es/table-component/ContextMenu.js +75 -0
- package/es/table-component/InternalTable.d.ts +9 -0
- package/es/table-component/InternalTable.js +295 -0
- package/es/table-component/TableContainer.d.ts +22 -0
- package/es/table-component/TableContainer.js +130 -0
- package/es/table-component/TableContainerEdit.d.ts +28 -0
- package/es/table-component/TableContainerEdit.js +1211 -0
- package/es/table-component/body/EditableCell.d.ts +16 -0
- package/es/table-component/body/EditableCell.js +1036 -0
- package/es/table-component/body/TableBody.d.ts +19 -0
- package/es/table-component/body/TableBody.js +64 -0
- package/es/table-component/body/TableBodyCell.d.ts +10 -0
- package/es/table-component/body/TableBodyCell.js +139 -0
- package/es/table-component/body/TableBodyCellEdit.d.ts +15 -0
- package/es/table-component/body/TableBodyCellEdit.js +814 -0
- package/es/table-component/body/TableBodyRow.d.ts +21 -0
- package/es/table-component/body/TableBodyRow.js +146 -0
- package/es/table-component/components/ControlCheckbox.d.ts +13 -0
- package/es/table-component/components/ControlCheckbox.js +87 -0
- package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/table-component/components/EditForm/EditForm.js +395 -0
- package/es/table-component/components/EditForm/index.d.ts +1 -0
- package/es/table-component/components/EditForm/index.js +1 -0
- package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/table-component/components/InputControl/InputControl.js +121 -0
- package/es/table-component/components/InputControl/index.d.ts +1 -0
- package/es/table-component/components/InputControl/index.js +1 -0
- package/es/table-component/components/async-select/index.d.ts +11 -0
- package/es/table-component/components/async-select/index.js +41 -0
- package/es/table-component/components/async-table-select/index.d.ts +11 -0
- package/es/table-component/components/async-table-select/index.js +43 -0
- package/es/table-component/components/checkbox-control/index.d.ts +13 -0
- package/es/table-component/components/checkbox-control/index.js +40 -0
- package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
- package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/table-component/components/command/Command.d.ts +9 -0
- package/es/table-component/components/command/Command.js +28 -0
- package/es/table-component/components/number/index.d.ts +10 -0
- package/es/table-component/components/number/index.js +42 -0
- package/es/table-component/components/number-range/index.d.ts +11 -0
- package/es/table-component/components/number-range/index.js +66 -0
- package/es/table-component/features/operator.d.ts +24 -0
- package/es/table-component/features/operator.js +62 -0
- package/es/table-component/footer/TableFooter.d.ts +13 -0
- package/es/table-component/footer/TableFooter.js +33 -0
- package/es/table-component/footer/TableFooterCell.d.ts +10 -0
- package/es/table-component/footer/TableFooterCell.js +24 -0
- package/es/table-component/footer/TableFooterRow.d.ts +14 -0
- package/es/table-component/footer/TableFooterRow.js +71 -0
- package/es/table-component/header/TableHead.d.ts +14 -0
- package/es/table-component/header/TableHead.js +60 -0
- package/es/table-component/header/TableHeadCell.d.ts +14 -0
- package/es/table-component/header/TableHeadCell.js +324 -0
- package/es/table-component/header/TableHeadRow.d.ts +16 -0
- package/es/table-component/header/TableHeadRow.js +86 -0
- package/es/table-component/header/renderFilter.d.ts +20 -0
- package/es/table-component/header/renderFilter.js +281 -0
- package/es/table-component/hook/constant.d.ts +73 -0
- package/es/table-component/hook/constant.js +240 -0
- package/es/table-component/hook/useColumns.d.ts +11 -0
- package/es/table-component/hook/useColumns.js +209 -0
- package/es/table-component/hook/useFilterOperator.d.ts +7 -0
- package/es/table-component/hook/useFilterOperator.js +33 -0
- package/es/table-component/hook/utils.d.ts +121 -0
- package/es/table-component/hook/utils.js +1727 -0
- package/es/table-component/index.d.ts +5 -0
- package/es/table-component/index.js +2 -0
- package/es/table-component/style.scss +1083 -0
- package/es/table-component/table/Grid.d.ts +23 -0
- package/es/table-component/table/Grid.js +310 -0
- package/es/table-component/table/GridEdit.d.ts +23 -0
- package/es/table-component/table/GridEdit.js +282 -0
- package/es/table-component/type.d.ts +482 -0
- package/es/table-component/type.js +1 -0
- package/es/table-component/useContext.d.ts +119 -0
- package/es/table-component/useContext.js +61 -0
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +5 -1
- package/lib/grid-component/TableGrid.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -1
- package/lib/table-component/ColumnsChoose.d.ts +10 -0
- package/lib/table-component/ColumnsChoose.js +568 -0
- package/lib/table-component/ContextMenu.d.ts +20 -0
- package/lib/table-component/ContextMenu.js +85 -0
- package/lib/table-component/InternalTable.d.ts +9 -0
- package/lib/table-component/InternalTable.js +299 -0
- package/lib/table-component/TableContainer.d.ts +22 -0
- package/lib/table-component/TableContainer.js +137 -0
- package/lib/table-component/TableContainerEdit.d.ts +28 -0
- package/lib/table-component/TableContainerEdit.js +1220 -0
- package/lib/table-component/body/EditableCell.d.ts +16 -0
- package/lib/table-component/body/EditableCell.js +1038 -0
- package/lib/table-component/body/TableBody.d.ts +19 -0
- package/lib/table-component/body/TableBody.js +72 -0
- package/lib/table-component/body/TableBodyCell.d.ts +10 -0
- package/lib/table-component/body/TableBodyCell.js +148 -0
- package/lib/table-component/body/TableBodyCellEdit.d.ts +15 -0
- package/lib/table-component/body/TableBodyCellEdit.js +821 -0
- package/lib/table-component/body/TableBodyRow.d.ts +21 -0
- package/lib/table-component/body/TableBodyRow.js +153 -0
- package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/table-component/components/ControlCheckbox.js +95 -0
- package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/table-component/components/EditForm/EditForm.js +406 -0
- package/lib/table-component/components/EditForm/index.d.ts +1 -0
- package/lib/table-component/components/EditForm/index.js +16 -0
- package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/table-component/components/InputControl/InputControl.js +131 -0
- package/lib/table-component/components/InputControl/index.d.ts +1 -0
- package/lib/table-component/components/InputControl/index.js +16 -0
- package/lib/table-component/components/async-select/index.d.ts +11 -0
- package/lib/table-component/components/async-select/index.js +49 -0
- package/lib/table-component/components/async-table-select/index.d.ts +11 -0
- package/lib/table-component/components/async-table-select/index.js +51 -0
- package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/table-component/components/checkbox-control/index.js +48 -0
- package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
- package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/table-component/components/command/Command.d.ts +9 -0
- package/lib/table-component/components/command/Command.js +37 -0
- package/lib/table-component/components/number/index.d.ts +10 -0
- package/lib/table-component/components/number/index.js +50 -0
- package/lib/table-component/components/number-range/index.d.ts +11 -0
- package/lib/table-component/components/number-range/index.js +74 -0
- package/lib/table-component/features/operator.d.ts +24 -0
- package/lib/table-component/features/operator.js +67 -0
- package/lib/table-component/footer/TableFooter.d.ts +13 -0
- package/lib/table-component/footer/TableFooter.js +42 -0
- package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
- package/lib/table-component/footer/TableFooterCell.js +32 -0
- package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
- package/lib/table-component/footer/TableFooterRow.js +79 -0
- package/lib/table-component/header/TableHead.d.ts +14 -0
- package/lib/table-component/header/TableHead.js +69 -0
- package/lib/table-component/header/TableHeadCell.d.ts +14 -0
- package/lib/table-component/header/TableHeadCell.js +333 -0
- package/lib/table-component/header/TableHeadRow.d.ts +16 -0
- package/lib/table-component/header/TableHeadRow.js +94 -0
- package/lib/table-component/header/renderFilter.d.ts +20 -0
- package/lib/table-component/header/renderFilter.js +291 -0
- package/lib/table-component/hook/constant.d.ts +73 -0
- package/lib/table-component/hook/constant.js +247 -0
- package/lib/table-component/hook/useColumns.d.ts +11 -0
- package/lib/table-component/hook/useColumns.js +220 -0
- package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-component/hook/useFilterOperator.js +40 -0
- package/lib/table-component/hook/utils.d.ts +121 -0
- package/lib/table-component/hook/utils.js +1817 -0
- package/lib/table-component/index.d.ts +5 -0
- package/lib/table-component/index.js +9 -0
- package/lib/table-component/style.scss +1083 -0
- package/lib/table-component/table/Grid.d.ts +23 -0
- package/lib/table-component/table/Grid.js +313 -0
- package/lib/table-component/table/GridEdit.d.ts +23 -0
- package/lib/table-component/table/GridEdit.js +284 -0
- package/lib/table-component/type.d.ts +482 -0
- package/lib/table-component/type.js +5 -0
- package/lib/table-component/useContext.d.ts +119 -0
- package/lib/table-component/useContext.js +67 -0
- package/package.json +3 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { NumericFormat } from "react-numeric-component";
|
|
3
|
+
import { Input } from "rc-master-ui";
|
|
4
|
+
import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
|
|
5
|
+
// import type {IFormat} from "../type"
|
|
6
|
+
// import {checkDecimalSeparator, checkThousandSeparator} from "../hooks"
|
|
7
|
+
|
|
8
|
+
const NumberInput = props => {
|
|
9
|
+
const {
|
|
10
|
+
t,
|
|
11
|
+
value,
|
|
12
|
+
format,
|
|
13
|
+
onChange
|
|
14
|
+
} = props;
|
|
15
|
+
const values = React.useMemo(() => [value], [value]);
|
|
16
|
+
|
|
17
|
+
// const [values, setValues] = React.useState<any[]>(() =>
|
|
18
|
+
// mergedValues,
|
|
19
|
+
// );
|
|
20
|
+
|
|
21
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(NumericFormat, {
|
|
22
|
+
value: values[0] ?? ''
|
|
23
|
+
// value={min}
|
|
24
|
+
,
|
|
25
|
+
thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
26
|
+
decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
27
|
+
allowNegative: true,
|
|
28
|
+
customInput: Input,
|
|
29
|
+
className: 'rounded-0 input-element',
|
|
30
|
+
onValueChange: vals => {
|
|
31
|
+
// onChangeValueFilter(type, values.floatValue, 'min')
|
|
32
|
+
|
|
33
|
+
// setValues([vals.floatValue, values[1]])
|
|
34
|
+
onChange?.([vals.floatValue]);
|
|
35
|
+
}
|
|
36
|
+
// placeholder={t ? t('Min') : 'Min'}
|
|
37
|
+
,
|
|
38
|
+
placeholder: t ? t('Enter') : 'Enter',
|
|
39
|
+
autoFocus: true
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
export default NumberInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IFormat } from "../../type";
|
|
3
|
+
type Props = {
|
|
4
|
+
t?: any;
|
|
5
|
+
format?: IFormat;
|
|
6
|
+
min: number | string | undefined;
|
|
7
|
+
max: number | string | undefined;
|
|
8
|
+
onChange?: (values: any[]) => void;
|
|
9
|
+
};
|
|
10
|
+
declare const NumberRange: (props: Props) => React.JSX.Element;
|
|
11
|
+
export default NumberRange;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { NumericFormat } from "react-numeric-component";
|
|
3
|
+
import { Input } from "rc-master-ui";
|
|
4
|
+
import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
|
|
5
|
+
// import type {IFormat} from "../type"
|
|
6
|
+
// import {checkDecimalSeparator, checkThousandSeparator} from "../hooks"
|
|
7
|
+
|
|
8
|
+
const NumberRange = props => {
|
|
9
|
+
const {
|
|
10
|
+
t,
|
|
11
|
+
max,
|
|
12
|
+
min,
|
|
13
|
+
format,
|
|
14
|
+
onChange
|
|
15
|
+
} = props;
|
|
16
|
+
const values = React.useMemo(() => [min, max], [min, max]);
|
|
17
|
+
|
|
18
|
+
// const [values, setValues] = React.useState<any[]>(() =>
|
|
19
|
+
// mergedValues,
|
|
20
|
+
// );
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: '',
|
|
24
|
+
style: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
columnGap: 5
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
|
|
30
|
+
value: values[0] ?? ''
|
|
31
|
+
// value={min}
|
|
32
|
+
,
|
|
33
|
+
thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
34
|
+
decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
35
|
+
allowNegative: true,
|
|
36
|
+
customInput: Input,
|
|
37
|
+
className: ' rounded-0 input-element',
|
|
38
|
+
onValueChange: vals => {
|
|
39
|
+
// onChangeValueFilter(type, values.floatValue, 'min')
|
|
40
|
+
|
|
41
|
+
// setValues([vals.floatValue, values[1]])
|
|
42
|
+
onChange?.([vals.floatValue, max]);
|
|
43
|
+
}
|
|
44
|
+
// placeholder={t ? t('Min') : 'Min'}
|
|
45
|
+
,
|
|
46
|
+
placeholder: t ? t('From') : 'From',
|
|
47
|
+
autoFocus: true
|
|
48
|
+
})), /*#__PURE__*/React.createElement("span", null, " - "), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
|
|
49
|
+
value: values[1] ?? ''
|
|
50
|
+
// value={max}
|
|
51
|
+
,
|
|
52
|
+
thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
53
|
+
decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
|
|
54
|
+
allowNegative: true,
|
|
55
|
+
customInput: Input,
|
|
56
|
+
className: ' rounded-0 input-element',
|
|
57
|
+
onValueChange: vals => {
|
|
58
|
+
// setValues([values[0], vals.floatValue])
|
|
59
|
+
onChange?.([min, vals.floatValue]);
|
|
60
|
+
}
|
|
61
|
+
// placeholder={t ? t('Max') : 'Max'}
|
|
62
|
+
,
|
|
63
|
+
placeholder: t ? t('To') : 'To'
|
|
64
|
+
}))));
|
|
65
|
+
};
|
|
66
|
+
export default NumberRange;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OnChangeFn, RowData, TableFeature } from '@tanstack/react-table';
|
|
2
|
+
export type ColumnOperatorState = ColumnOperator[];
|
|
3
|
+
export interface OperatorTableState {
|
|
4
|
+
operator: ColumnOperatorState;
|
|
5
|
+
}
|
|
6
|
+
export interface ColumnOperator {
|
|
7
|
+
id: string;
|
|
8
|
+
operator: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OperatorOptions {
|
|
11
|
+
enableOperator?: boolean;
|
|
12
|
+
onColumnOperatorChange?: OnChangeFn<ColumnOperatorState>;
|
|
13
|
+
}
|
|
14
|
+
declare module '@tanstack/react-table' {
|
|
15
|
+
interface TableState extends OperatorTableState {
|
|
16
|
+
}
|
|
17
|
+
interface TableOptionsResolved<TData extends RowData> extends OperatorOptions {
|
|
18
|
+
}
|
|
19
|
+
interface Column<TData extends RowData, TValue> {
|
|
20
|
+
getFilterOperator: () => string;
|
|
21
|
+
setFilterOperator: (operator: string) => void;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const OperatorFeature: TableFeature<any>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
|
|
2
|
+
|
|
3
|
+
import { makeStateUpdater } from '@tanstack/react-table';
|
|
4
|
+
|
|
5
|
+
// define types for our new feature's table options
|
|
6
|
+
|
|
7
|
+
// Define types for our new feature's table APIs
|
|
8
|
+
// export interface OperatorInstance {
|
|
9
|
+
// setDensity: (updater: Updater<OpetorState>) => void
|
|
10
|
+
|
|
11
|
+
// toggleDensity: (value?: OpetorState) => void
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// Use declaration merging to add our new feature APIs and state types to TanStack Table's existing types.
|
|
15
|
+
|
|
16
|
+
export const OperatorFeature = {
|
|
17
|
+
// define the new feature's initial state
|
|
18
|
+
getInitialState: state => {
|
|
19
|
+
return {
|
|
20
|
+
operator: [],
|
|
21
|
+
...state
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
// define the new feature's default options
|
|
25
|
+
getDefaultOptions: table => {
|
|
26
|
+
return {
|
|
27
|
+
enableOperator: true,
|
|
28
|
+
onColumnOperatorChange: makeStateUpdater('operator', table)
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
// if you need to add a default column definition...
|
|
32
|
+
// getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
|
|
33
|
+
// return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
|
|
34
|
+
// },
|
|
35
|
+
|
|
36
|
+
// define the new feature's table instance methods
|
|
37
|
+
|
|
38
|
+
// if you need to add row instance APIs...
|
|
39
|
+
// createRow: <TData extends RowData>(row, table): void => {},
|
|
40
|
+
// if you need to add cell instance APIs...
|
|
41
|
+
// createCell: <TData extends RowData>(cell, column, row, table): void => {},
|
|
42
|
+
// if you need to add column instance APIs...
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
+
createColumn: (column, table) => {
|
|
45
|
+
column.getFilterOperator = () => {
|
|
46
|
+
return table.getState().operator?.find(op => op.id === column.id)?.operator ?? undefined;
|
|
47
|
+
};
|
|
48
|
+
column.setFilterOperator = updater => {
|
|
49
|
+
const safeUpdater = old => {
|
|
50
|
+
const others = old.filter(op => op.id !== column.id);
|
|
51
|
+
return [...others, {
|
|
52
|
+
id: column.id,
|
|
53
|
+
operator: updater
|
|
54
|
+
}];
|
|
55
|
+
};
|
|
56
|
+
return table.options.onColumnOperatorChange?.(safeUpdater);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// if you need to add header instance APIs...
|
|
61
|
+
// createHeader: <TData extends RowData>(header, table): void => {},
|
|
62
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Column, Table } from "@tanstack/react-table";
|
|
2
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableFooterProps<T> {
|
|
5
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
6
|
+
table: Table<T>;
|
|
7
|
+
virtualPaddingLeft: number | undefined;
|
|
8
|
+
virtualPaddingRight: number | undefined;
|
|
9
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
10
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
11
|
+
}
|
|
12
|
+
declare const TableFooter: <RecordType extends object>({ columnVirtualizer, table, virtualPaddingLeft, virtualPaddingRight, ...rest }: TableFooterProps<RecordType>) => React.JSX.Element;
|
|
13
|
+
export default TableFooter;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import TableFooterRow from "./TableFooterRow";
|
|
3
|
+
import { TableContext } from "../useContext";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
|
+
const TableFooter = ({
|
|
6
|
+
columnVirtualizer,
|
|
7
|
+
table,
|
|
8
|
+
virtualPaddingLeft,
|
|
9
|
+
virtualPaddingRight,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
const {
|
|
13
|
+
prefix
|
|
14
|
+
} = useContext(TableContext);
|
|
15
|
+
return /*#__PURE__*/React.createElement("tfoot", {
|
|
16
|
+
className: `${prefix}-grid-tfoot`,
|
|
17
|
+
style: {
|
|
18
|
+
display: "grid",
|
|
19
|
+
position: "sticky",
|
|
20
|
+
bottom: 0,
|
|
21
|
+
zIndex: 1
|
|
22
|
+
}
|
|
23
|
+
}, /*#__PURE__*/React.createElement(TableFooterRow, _extends({
|
|
24
|
+
table: table,
|
|
25
|
+
columnVirtualizer: columnVirtualizer,
|
|
26
|
+
headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
|
|
27
|
+
// key={headerGroup.id}
|
|
28
|
+
,
|
|
29
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
30
|
+
virtualPaddingRight: virtualPaddingRight
|
|
31
|
+
}, rest)));
|
|
32
|
+
};
|
|
33
|
+
export default TableFooter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Header } from "@tanstack/react-table";
|
|
2
|
+
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableFooterCellProps<T> {
|
|
5
|
+
columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
6
|
+
header: Header<T, unknown>;
|
|
7
|
+
column: VirtualItem;
|
|
8
|
+
}
|
|
9
|
+
declare const TableFooterCell: <RecordType extends object>({ header }: TableFooterCellProps<RecordType>) => React.JSX.Element;
|
|
10
|
+
export default TableFooterCell;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
// import type { Person } from "../makeData";
|
|
3
|
+
import { getCommonPinningStyles } from "../hook/utils";
|
|
4
|
+
// import type { Person } from "../../tanstack-table/makeData";
|
|
5
|
+
|
|
6
|
+
const TableFooterCell = ({
|
|
7
|
+
header
|
|
8
|
+
}) => {
|
|
9
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
10
|
+
// ref={el => {
|
|
11
|
+
// if (el) columnVirtualizer.measureElement(el)
|
|
12
|
+
// }}
|
|
13
|
+
// data-index={header.id}
|
|
14
|
+
key: header.id,
|
|
15
|
+
colSpan: header.colSpan,
|
|
16
|
+
style: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
...getCommonPinningStyles(header.column),
|
|
19
|
+
width: header?.getSize() ?? header.column.getSize(),
|
|
20
|
+
backgroundColor: "#fafafa"
|
|
21
|
+
}
|
|
22
|
+
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/React.createElement("span", null, "aaa") : '');
|
|
23
|
+
};
|
|
24
|
+
export default TableFooterCell;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Column, HeaderGroup, Table } from "@tanstack/react-table";
|
|
2
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableFooterRowProps<T> {
|
|
5
|
+
table: Table<T>;
|
|
6
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
7
|
+
headerGroup: HeaderGroup<T>;
|
|
8
|
+
virtualPaddingLeft: number | undefined;
|
|
9
|
+
virtualPaddingRight: number | undefined;
|
|
10
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
11
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
12
|
+
}
|
|
13
|
+
declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, columnVirtualizer }: TableFooterRowProps<RecordType>) => React.JSX.Element;
|
|
14
|
+
export default TableFooterRow;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// import type { Person } from "../makeData";
|
|
2
|
+
import TableFooterCell from "./TableFooterCell";
|
|
3
|
+
import React from "react";
|
|
4
|
+
// import type { Person } from "../../tanstack-table/makeData";
|
|
5
|
+
// import TableHeadCell from "./TableHeadCell";
|
|
6
|
+
|
|
7
|
+
const TableFooterRow = ({
|
|
8
|
+
table,
|
|
9
|
+
// columnVirtualizer,
|
|
10
|
+
headerGroup,
|
|
11
|
+
virtualPaddingLeft,
|
|
12
|
+
virtualPaddingRight,
|
|
13
|
+
fixedLeftColumns,
|
|
14
|
+
fixedRightColumns,
|
|
15
|
+
// virtualColumns,
|
|
16
|
+
columnVirtualizer
|
|
17
|
+
}) => {
|
|
18
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
19
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
20
|
+
// data-index={headerGroup.id}
|
|
21
|
+
key: headerGroup.id,
|
|
22
|
+
style: {
|
|
23
|
+
display: "flex",
|
|
24
|
+
width: "100%",
|
|
25
|
+
borderTop: "1px solid #e0e0e0"
|
|
26
|
+
}
|
|
27
|
+
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
28
|
+
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
29
|
+
columnVirtualizer: columnVirtualizer,
|
|
30
|
+
key: column.id,
|
|
31
|
+
header: headerGroup.headers.find(h => h.column.id === column.id),
|
|
32
|
+
column: column
|
|
33
|
+
});
|
|
34
|
+
}) : null, virtualPaddingLeft ? /*#__PURE__*/React.createElement("td", {
|
|
35
|
+
className: "",
|
|
36
|
+
style: {
|
|
37
|
+
display: "flex",
|
|
38
|
+
width: virtualPaddingLeft
|
|
39
|
+
}
|
|
40
|
+
}) : null, virtualColumns.map(virtualColumn => {
|
|
41
|
+
const header = headerGroup.headers[virtualColumn.index];
|
|
42
|
+
const isFixed = table.getState().columnPinning.left?.includes(header.column.id) || table.getState().columnPinning.right?.includes(header.column.id);
|
|
43
|
+
// const isFixed = table.getState().columnPinning.left?.includes(header.column.id)
|
|
44
|
+
|
|
45
|
+
if (header && !isFixed) {
|
|
46
|
+
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
47
|
+
key: header.id,
|
|
48
|
+
header: header,
|
|
49
|
+
column: virtualColumn,
|
|
50
|
+
columnVirtualizer: columnVirtualizer
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}),
|
|
55
|
+
//fake empty column to the right for virtualization scroll padding
|
|
56
|
+
fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
57
|
+
key: column.id,
|
|
58
|
+
header: headerGroup.headers.find(h => h.column.id === column.id),
|
|
59
|
+
column: column
|
|
60
|
+
})) : null, virtualPaddingRight ?
|
|
61
|
+
/*#__PURE__*/
|
|
62
|
+
//fake empty column to the right for virtualization scroll padding
|
|
63
|
+
React.createElement("td", {
|
|
64
|
+
className: "",
|
|
65
|
+
style: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
width: virtualPaddingRight
|
|
68
|
+
}
|
|
69
|
+
}) : null);
|
|
70
|
+
};
|
|
71
|
+
export default TableFooterRow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Column, Table } from '@tanstack/react-table';
|
|
2
|
+
import { type Virtualizer } from '@tanstack/react-virtual';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
interface TableHeadProps<T> {
|
|
5
|
+
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
6
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
7
|
+
table: Table<T>;
|
|
8
|
+
virtualPaddingLeft: number | undefined;
|
|
9
|
+
virtualPaddingRight: number | undefined;
|
|
10
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
11
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
12
|
+
}
|
|
13
|
+
declare const TableHead: <RecordType extends object>({ tableContainerRef, columnVirtualizer, table, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns }: TableHeadProps<RecordType>) => React.JSX.Element;
|
|
14
|
+
export default TableHead;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { TableContext } from "../useContext";
|
|
4
|
+
import TableHeadRow from "./TableHeadRow";
|
|
5
|
+
const TableHead = ({
|
|
6
|
+
tableContainerRef,
|
|
7
|
+
columnVirtualizer,
|
|
8
|
+
table,
|
|
9
|
+
virtualPaddingLeft,
|
|
10
|
+
virtualPaddingRight,
|
|
11
|
+
fixedLeftColumns,
|
|
12
|
+
fixedRightColumns
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
prefix
|
|
16
|
+
} = useContext(TableContext);
|
|
17
|
+
const rowVirtualizer = useVirtualizer({
|
|
18
|
+
count: table.getHeaderGroups().length,
|
|
19
|
+
estimateSize: () => 34,
|
|
20
|
+
//estimate row height for accurate scrollbar dragging
|
|
21
|
+
getScrollElement: () => tableContainerRef.current,
|
|
22
|
+
//measure dynamic row height, except in firefox because it measures table border height incorrectly
|
|
23
|
+
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
24
|
+
overscan: 5
|
|
25
|
+
});
|
|
26
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
27
|
+
|
|
28
|
+
// const columnSizingState = table.getState().columnSizing
|
|
29
|
+
|
|
30
|
+
// React.useEffect(() => {
|
|
31
|
+
// requestAnimationFrame(() => {
|
|
32
|
+
// rowVirtualizer.measure()
|
|
33
|
+
// })
|
|
34
|
+
// }, [columnSizingState, rowVirtualizer])
|
|
35
|
+
|
|
36
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
37
|
+
className: `${prefix}-grid-thead`,
|
|
38
|
+
style: {
|
|
39
|
+
display: 'grid',
|
|
40
|
+
position: 'sticky',
|
|
41
|
+
top: 0,
|
|
42
|
+
zIndex: 1
|
|
43
|
+
}
|
|
44
|
+
}, virtualRows.map(virtualRow => {
|
|
45
|
+
const headerGroup = table.getHeaderGroups()[virtualRow.index];
|
|
46
|
+
return /*#__PURE__*/React.createElement(TableHeadRow, {
|
|
47
|
+
table: table,
|
|
48
|
+
columnVirtualizer: columnVirtualizer,
|
|
49
|
+
rowHeaderVirtualizer: rowVirtualizer,
|
|
50
|
+
headerGroup: headerGroup,
|
|
51
|
+
key: headerGroup.id,
|
|
52
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
53
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
54
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
55
|
+
fixedRightColumns: fixedRightColumns,
|
|
56
|
+
rowHeaderVirtual: virtualRow
|
|
57
|
+
});
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
export default TableHead;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Table } from '@tanstack/react-table';
|
|
2
|
+
import { type Header } from '@tanstack/react-table';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
5
|
+
interface TableHeadCellProps<T> {
|
|
6
|
+
t?: any;
|
|
7
|
+
table: Table<T>;
|
|
8
|
+
header: Header<T, unknown>;
|
|
9
|
+
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
10
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
11
|
+
rowHeaderVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
|
|
12
|
+
}
|
|
13
|
+
declare const TableHeadCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
|
|
14
|
+
export default TableHeadCell;
|