es-grid-template 1.7.23 → 1.7.25
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/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/es/table-component/ColumnsChoose.d.ts +13 -0
- package/es/table-component/ColumnsChoose.js +206 -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 +308 -0
- package/es/table-component/TableContainer.d.ts +31 -0
- package/es/table-component/TableContainer.js +249 -0
- package/es/table-component/TableContainerEdit.d.ts +31 -0
- package/es/table-component/TableContainerEdit.js +1301 -0
- package/es/table-component/body/EditableCell.d.ts +16 -0
- package/es/table-component/body/EditableCell.js +1039 -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 +12 -0
- package/es/table-component/body/TableBodyCell.js +149 -0
- package/es/table-component/body/TableBodyCellEdit.d.ts +16 -0
- package/es/table-component/body/TableBodyCellEdit.js +931 -0
- package/es/table-component/body/TableBodyRow.d.ts +21 -0
- package/es/table-component/body/TableBodyRow.js +151 -0
- package/es/table-component/components/ControlCheckbox.d.ts +13 -0
- package/es/table-component/components/ControlCheckbox.js +84 -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 +44 -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 +10 -0
- package/es/table-component/components/command/Command.js +33 -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 +66 -0
- package/es/table-component/footer/TableFooterRow.d.ts +14 -0
- package/es/table-component/footer/TableFooterRow.js +73 -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 +343 -0
- package/es/table-component/header/TableHeadRow.d.ts +16 -0
- package/es/table-component/header/TableHeadRow.js +76 -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 +9 -0
- package/es/table-component/hook/useColumns.js +169 -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 +133 -0
- package/es/table-component/hook/utils.js +1870 -0
- package/es/table-component/index.d.ts +5 -0
- package/es/table-component/index.js +2 -0
- package/es/table-component/style.scss +1129 -0
- package/es/table-component/table/Grid.d.ts +24 -0
- package/es/table-component/table/Grid.js +234 -0
- package/es/table-component/type.d.ts +513 -0
- package/es/table-component/type.js +1 -0
- package/es/table-component/useContext.d.ts +74 -0
- package/es/table-component/useContext.js +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -1
- package/lib/table-component/ColumnsChoose.d.ts +13 -0
- package/lib/table-component/ColumnsChoose.js +216 -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 +313 -0
- package/lib/table-component/TableContainer.d.ts +31 -0
- package/lib/table-component/TableContainer.js +257 -0
- package/lib/table-component/TableContainerEdit.d.ts +31 -0
- package/lib/table-component/TableContainerEdit.js +1310 -0
- package/lib/table-component/body/EditableCell.d.ts +16 -0
- package/lib/table-component/body/EditableCell.js +1041 -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 +12 -0
- package/lib/table-component/body/TableBodyCell.js +158 -0
- package/lib/table-component/body/TableBodyCellEdit.d.ts +16 -0
- package/lib/table-component/body/TableBodyCellEdit.js +938 -0
- package/lib/table-component/body/TableBodyRow.d.ts +21 -0
- package/lib/table-component/body/TableBodyRow.js +158 -0
- package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/table-component/components/ControlCheckbox.js +92 -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 +53 -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 +10 -0
- package/lib/table-component/components/command/Command.js +42 -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 +76 -0
- package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
- package/lib/table-component/footer/TableFooterRow.js +81 -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 +352 -0
- package/lib/table-component/header/TableHeadRow.d.ts +16 -0
- package/lib/table-component/header/TableHeadRow.js +84 -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 +9 -0
- package/lib/table-component/hook/useColumns.js +180 -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 +133 -0
- package/lib/table-component/hook/utils.js +1969 -0
- package/lib/table-component/index.d.ts +5 -0
- package/lib/table-component/index.js +9 -0
- package/lib/table-component/style.scss +1129 -0
- package/lib/table-component/table/Grid.d.ts +24 -0
- package/lib/table-component/table/Grid.js +236 -0
- package/lib/table-component/type.d.ts +513 -0
- package/lib/table-component/type.js +5 -0
- package/lib/table-component/useContext.d.ts +74 -0
- package/lib/table-component/useContext.js +21 -0
- package/package.json +4 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OperatorFeature = void 0;
|
|
7
|
+
var _reactTable = require("@tanstack/react-table");
|
|
8
|
+
// TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
|
|
9
|
+
|
|
10
|
+
// define types for our new feature's table options
|
|
11
|
+
|
|
12
|
+
// Define types for our new feature's table APIs
|
|
13
|
+
// export interface OperatorInstance {
|
|
14
|
+
// setDensity: (updater: Updater<OpetorState>) => void
|
|
15
|
+
|
|
16
|
+
// toggleDensity: (value?: OpetorState) => void
|
|
17
|
+
// }
|
|
18
|
+
|
|
19
|
+
// Use declaration merging to add our new feature APIs and state types to TanStack Table's existing types.
|
|
20
|
+
|
|
21
|
+
const OperatorFeature = exports.OperatorFeature = {
|
|
22
|
+
// define the new feature's initial state
|
|
23
|
+
getInitialState: state => {
|
|
24
|
+
return {
|
|
25
|
+
operator: [],
|
|
26
|
+
...state
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
// define the new feature's default options
|
|
30
|
+
getDefaultOptions: table => {
|
|
31
|
+
return {
|
|
32
|
+
enableOperator: true,
|
|
33
|
+
onColumnOperatorChange: (0, _reactTable.makeStateUpdater)('operator', table)
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
// if you need to add a default column definition...
|
|
37
|
+
// getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
|
|
38
|
+
// return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
|
|
39
|
+
// },
|
|
40
|
+
|
|
41
|
+
// define the new feature's table instance methods
|
|
42
|
+
|
|
43
|
+
// if you need to add row instance APIs...
|
|
44
|
+
// createRow: <TData extends RowData>(row, table): void => {},
|
|
45
|
+
// if you need to add cell instance APIs...
|
|
46
|
+
// createCell: <TData extends RowData>(cell, column, row, table): void => {},
|
|
47
|
+
// if you need to add column instance APIs...
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
|
+
createColumn: (column, table) => {
|
|
50
|
+
column.getFilterOperator = () => {
|
|
51
|
+
return table.getState().operator?.find(op => op.id === column.id)?.operator ?? undefined;
|
|
52
|
+
};
|
|
53
|
+
column.setFilterOperator = updater => {
|
|
54
|
+
const safeUpdater = old => {
|
|
55
|
+
const others = old.filter(op => op.id !== column.id);
|
|
56
|
+
return [...others, {
|
|
57
|
+
id: column.id,
|
|
58
|
+
operator: updater
|
|
59
|
+
}];
|
|
60
|
+
};
|
|
61
|
+
return table.options.onColumnOperatorChange?.(safeUpdater);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// if you need to add header instance APIs...
|
|
66
|
+
// createHeader: <TData extends RowData>(header, table): void => {},
|
|
67
|
+
};
|
|
@@ -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,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _TableFooterRow = _interopRequireDefault(require("./TableFooterRow"));
|
|
10
|
+
var _useContext = require("../useContext");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
const TableFooter = ({
|
|
15
|
+
columnVirtualizer,
|
|
16
|
+
table,
|
|
17
|
+
virtualPaddingLeft,
|
|
18
|
+
virtualPaddingRight,
|
|
19
|
+
...rest
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
prefix
|
|
23
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement("tfoot", {
|
|
25
|
+
className: `${prefix}-grid-tfoot`,
|
|
26
|
+
style: {
|
|
27
|
+
display: "grid",
|
|
28
|
+
position: "sticky",
|
|
29
|
+
bottom: 0,
|
|
30
|
+
zIndex: 1
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_TableFooterRow.default, (0, _extends2.default)({
|
|
33
|
+
table: table,
|
|
34
|
+
columnVirtualizer: columnVirtualizer,
|
|
35
|
+
headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
|
|
36
|
+
// key={headerGroup.id}
|
|
37
|
+
,
|
|
38
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
39
|
+
virtualPaddingRight: virtualPaddingRight
|
|
40
|
+
}, rest)));
|
|
41
|
+
};
|
|
42
|
+
var _default = exports.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,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _utils = require("../hook/utils");
|
|
10
|
+
var _useContext = require("../useContext");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _hooks = require("../../grid-component/hooks");
|
|
13
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
// import type { Person } from "../makeData";
|
|
17
|
+
|
|
18
|
+
// import type { Person } from "../../tanstack-table/makeData";
|
|
19
|
+
|
|
20
|
+
const TableFooterCell = ({
|
|
21
|
+
header
|
|
22
|
+
}) => {
|
|
23
|
+
const isPinned = header.column.getIsPinned();
|
|
24
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
|
|
25
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
|
|
26
|
+
const {
|
|
27
|
+
prefix,
|
|
28
|
+
format,
|
|
29
|
+
dataSource
|
|
30
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
31
|
+
const col = header.column.columnDef.meta ?? {};
|
|
32
|
+
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
33
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
34
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
35
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
36
|
+
|
|
37
|
+
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
38
|
+
const dec = cellFormat?.decimalScale;
|
|
39
|
+
|
|
40
|
+
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
41
|
+
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)(dataSource, col?.field) : 0;
|
|
42
|
+
const value = !(0, _utils.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
43
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
44
|
+
const numberValue = Number(value);
|
|
45
|
+
const numericFormatProps = {
|
|
46
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
47
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
48
|
+
allowNegative: cellFormat?.allowNegative ?? false,
|
|
49
|
+
prefix: cellFormat?.prefix,
|
|
50
|
+
suffix: cellFormat?.suffix,
|
|
51
|
+
decimalScale: dec,
|
|
52
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement("td", {
|
|
55
|
+
// ref={el => {
|
|
56
|
+
// if (el) columnVirtualizer.measureElement(el)
|
|
57
|
+
// }}
|
|
58
|
+
// data-index={header.id}
|
|
59
|
+
|
|
60
|
+
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
61
|
+
// [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
62
|
+
// [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
63
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
64
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
65
|
+
}),
|
|
66
|
+
key: header.id,
|
|
67
|
+
colSpan: header.colSpan,
|
|
68
|
+
style: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
...(0, _utils.getCommonPinningStyles)(header.column),
|
|
71
|
+
width: header?.getSize() ?? header.column.getSize(),
|
|
72
|
+
backgroundColor: "#fafafa"
|
|
73
|
+
}
|
|
74
|
+
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement("span", null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps)) : '');
|
|
75
|
+
};
|
|
76
|
+
var _default = exports.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,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _TableFooterCell = _interopRequireDefault(require("./TableFooterCell"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
// import type { Person } from "../makeData";
|
|
11
|
+
|
|
12
|
+
// import type { Person } from "../../tanstack-table/makeData";
|
|
13
|
+
// import TableHeadCell from "./TableHeadCell";
|
|
14
|
+
|
|
15
|
+
const TableFooterRow = ({
|
|
16
|
+
table,
|
|
17
|
+
// columnVirtualizer,
|
|
18
|
+
headerGroup,
|
|
19
|
+
virtualPaddingLeft,
|
|
20
|
+
virtualPaddingRight,
|
|
21
|
+
fixedLeftColumns,
|
|
22
|
+
fixedRightColumns,
|
|
23
|
+
// virtualColumns,
|
|
24
|
+
columnVirtualizer
|
|
25
|
+
}) => {
|
|
26
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
28
|
+
// data-index={headerGroup.id}
|
|
29
|
+
key: headerGroup.id,
|
|
30
|
+
style: {
|
|
31
|
+
display: "flex",
|
|
32
|
+
width: "100%",
|
|
33
|
+
borderBottom: "1px solid #e0e0e0",
|
|
34
|
+
borderTop: "1px solid #e0e0e0",
|
|
35
|
+
height: 37
|
|
36
|
+
}
|
|
37
|
+
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
39
|
+
columnVirtualizer: columnVirtualizer,
|
|
40
|
+
key: column.id,
|
|
41
|
+
header: headerGroup.headers.find(h => h.column.id === column.id),
|
|
42
|
+
column: column
|
|
43
|
+
});
|
|
44
|
+
}) : null, virtualPaddingLeft ? /*#__PURE__*/_react.default.createElement("td", {
|
|
45
|
+
className: "",
|
|
46
|
+
style: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
width: virtualPaddingLeft
|
|
49
|
+
}
|
|
50
|
+
}) : null, virtualColumns.map(virtualColumn => {
|
|
51
|
+
const header = headerGroup.headers[virtualColumn.index];
|
|
52
|
+
const isFixed = table.getState().columnPinning.left?.includes(header.column.id) || table.getState().columnPinning.right?.includes(header.column.id);
|
|
53
|
+
// const isFixed = table.getState().columnPinning.left?.includes(header.column.id)
|
|
54
|
+
|
|
55
|
+
if (header && !isFixed) {
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
57
|
+
key: header.id,
|
|
58
|
+
header: header,
|
|
59
|
+
column: virtualColumn,
|
|
60
|
+
columnVirtualizer: columnVirtualizer
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}),
|
|
65
|
+
//fake empty column to the right for virtualization scroll padding
|
|
66
|
+
fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
67
|
+
key: column.id,
|
|
68
|
+
header: headerGroup.headers.find(h => h.column.id === column.id),
|
|
69
|
+
column: column
|
|
70
|
+
})) : null, virtualPaddingRight ?
|
|
71
|
+
/*#__PURE__*/
|
|
72
|
+
//fake empty column to the right for virtualization scroll padding
|
|
73
|
+
_react.default.createElement("td", {
|
|
74
|
+
className: "",
|
|
75
|
+
style: {
|
|
76
|
+
display: "flex",
|
|
77
|
+
width: virtualPaddingRight
|
|
78
|
+
}
|
|
79
|
+
}) : null);
|
|
80
|
+
};
|
|
81
|
+
var _default = exports.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,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _reactVirtual = require("@tanstack/react-virtual");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _useContext = require("../useContext");
|
|
11
|
+
var _TableHeadRow = _interopRequireDefault(require("./TableHeadRow"));
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
const TableHead = ({
|
|
15
|
+
tableContainerRef,
|
|
16
|
+
columnVirtualizer,
|
|
17
|
+
table,
|
|
18
|
+
virtualPaddingLeft,
|
|
19
|
+
virtualPaddingRight,
|
|
20
|
+
fixedLeftColumns,
|
|
21
|
+
fixedRightColumns
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
prefix
|
|
25
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
26
|
+
const rowVirtualizer = (0, _reactVirtual.useVirtualizer)({
|
|
27
|
+
count: table.getHeaderGroups().length,
|
|
28
|
+
estimateSize: () => 34,
|
|
29
|
+
//estimate row height for accurate scrollbar dragging
|
|
30
|
+
getScrollElement: () => tableContainerRef.current,
|
|
31
|
+
//measure dynamic row height, except in firefox because it measures table border height incorrectly
|
|
32
|
+
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
33
|
+
overscan: 5
|
|
34
|
+
});
|
|
35
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
36
|
+
|
|
37
|
+
// const columnSizingState = table.getState().columnSizing
|
|
38
|
+
|
|
39
|
+
// React.useEffect(() => {
|
|
40
|
+
// requestAnimationFrame(() => {
|
|
41
|
+
// rowVirtualizer.measure()
|
|
42
|
+
// })
|
|
43
|
+
// }, [columnSizingState, rowVirtualizer])
|
|
44
|
+
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement("thead", {
|
|
46
|
+
className: `${prefix}-grid-thead`,
|
|
47
|
+
style: {
|
|
48
|
+
display: 'grid',
|
|
49
|
+
position: 'sticky',
|
|
50
|
+
top: 0,
|
|
51
|
+
zIndex: 1
|
|
52
|
+
}
|
|
53
|
+
}, virtualRows.map(virtualRow => {
|
|
54
|
+
const headerGroup = table.getHeaderGroups()[virtualRow.index];
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_TableHeadRow.default, {
|
|
56
|
+
table: table,
|
|
57
|
+
columnVirtualizer: columnVirtualizer,
|
|
58
|
+
rowHeaderVirtualizer: rowVirtualizer,
|
|
59
|
+
headerGroup: headerGroup,
|
|
60
|
+
key: headerGroup.id,
|
|
61
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
62
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
63
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
64
|
+
fixedRightColumns: fixedRightColumns,
|
|
65
|
+
rowHeaderVirtual: virtualRow
|
|
66
|
+
});
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
var _default = exports.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;
|