es-grid-template 1.8.70 → 1.8.72
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/TempTable.js +2 -1
- package/es/group-component/ColumnsChoose.d.ts +13 -0
- package/es/group-component/ColumnsChoose.js +211 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
- package/es/group-component/ColumnsGroup/index.d.ts +1 -0
- package/es/group-component/ColumnsGroup/index.js +1 -0
- package/es/group-component/ContextMenu.d.ts +19 -0
- package/es/group-component/ContextMenu.js +74 -0
- package/es/group-component/InternalTable.d.ts +8 -0
- package/es/group-component/InternalTable.js +224 -0
- package/es/group-component/TableContainer.d.ts +49 -0
- package/es/group-component/TableContainer.js +375 -0
- package/es/group-component/TableContainerEdit.d.ts +48 -0
- package/es/group-component/TableContainerEdit.js +2068 -0
- package/es/group-component/body/EditableCell.d.ts +16 -0
- package/es/group-component/body/EditableCell.js +1066 -0
- package/es/group-component/body/TableBody.d.ts +14 -0
- package/es/group-component/body/TableBody.js +82 -0
- package/es/group-component/body/TableBodyCell.d.ts +12 -0
- package/es/group-component/body/TableBodyCell.js +587 -0
- package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/es/group-component/body/TableBodyCellEdit.js +1398 -0
- package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/es/group-component/body/TableBodyCellEmpty.js +149 -0
- package/es/group-component/body/TableBodyRow.d.ts +21 -0
- package/es/group-component/body/TableBodyRow.js +199 -0
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
- package/es/group-component/components/ControlCheckbox.d.ts +13 -0
- package/es/group-component/components/ControlCheckbox.js +84 -0
- package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/group-component/components/EditForm/EditForm.js +394 -0
- package/es/group-component/components/EditForm/index.d.ts +1 -0
- package/es/group-component/components/EditForm/index.js +1 -0
- package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/group-component/components/InputControl/InputControl.js +118 -0
- package/es/group-component/components/InputControl/index.d.ts +1 -0
- package/es/group-component/components/InputControl/index.js +1 -0
- package/es/group-component/components/async-select/index.d.ts +11 -0
- package/es/group-component/components/async-select/index.js +38 -0
- package/es/group-component/components/async-table-select/index.d.ts +11 -0
- package/es/group-component/components/async-table-select/index.js +40 -0
- package/es/group-component/components/checkbox-control/index.d.ts +13 -0
- package/es/group-component/components/checkbox-control/index.js +40 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/group-component/components/command/Command.d.ts +10 -0
- package/es/group-component/components/command/Command.js +35 -0
- package/es/group-component/components/number/index.d.ts +12 -0
- package/es/group-component/components/number/index.js +42 -0
- package/es/group-component/components/number-range/index.d.ts +13 -0
- package/es/group-component/components/number-range/index.js +79 -0
- package/es/group-component/features/operator.d.ts +24 -0
- package/es/group-component/features/operator.js +62 -0
- package/es/group-component/footer/TableFooter.d.ts +7 -0
- package/es/group-component/footer/TableFooter.js +34 -0
- package/es/group-component/footer/TableFooterCell.d.ts +7 -0
- package/es/group-component/footer/TableFooterCell.js +66 -0
- package/es/group-component/footer/TableFooterRow.d.ts +8 -0
- package/es/group-component/footer/TableFooterRow.js +30 -0
- package/es/group-component/header/TableHead.d.ts +15 -0
- package/es/group-component/header/TableHead.js +98 -0
- package/es/group-component/header/TableHeadCell.d.ts +15 -0
- package/es/group-component/header/TableHeadCell.js +310 -0
- package/es/group-component/header/TableHeadCell2.d.ts +17 -0
- package/es/group-component/header/TableHeadCell2.js +321 -0
- package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/group-component/header/TableHeadGroupCell.js +94 -0
- package/es/group-component/header/TableHeadRow.d.ts +15 -0
- package/es/group-component/header/TableHeadRow.js +52 -0
- package/es/group-component/header/renderFilter.d.ts +20 -0
- package/es/group-component/header/renderFilter.js +291 -0
- package/es/group-component/hook/convert.d.ts +1 -0
- package/es/group-component/hook/convert.js +28 -0
- package/es/group-component/hook/useColumns.d.ts +28 -0
- package/es/group-component/hook/useColumns.js +306 -0
- package/es/group-component/hook/useFilterOperator.d.ts +7 -0
- package/es/group-component/hook/useFilterOperator.js +33 -0
- package/es/group-component/hook/utils.d.ts +220 -0
- package/es/group-component/hook/utils.js +2340 -0
- package/es/group-component/index.d.ts +2 -0
- package/es/group-component/index.js +2 -0
- package/es/group-component/style.d.ts +22 -0
- package/es/group-component/style.js +48 -0
- package/es/group-component/style.scss +1438 -0
- package/es/group-component/table/Grid.d.ts +33 -0
- package/es/group-component/table/Grid.js +438 -0
- package/es/group-component/table/TableWrapper.d.ts +33 -0
- package/es/group-component/table/TableWrapper.js +250 -0
- package/es/group-component/useContext.d.ts +100 -0
- package/es/group-component/useContext.js +21 -0
- package/es/table-component/InternalTable.js +6 -1
- package/es/table-component/TableContainer.js +4 -2
- package/es/table-component/TableContainerEdit.js +2 -2
- package/es/table-component/body/TableBodyCell.js +49 -40
- package/es/table-component/body/TableBodyCellEdit.js +9 -3
- package/es/table-component/body/TableBodyRow.js +4 -1
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +15 -7
- package/es/table-component/style.js +1 -1
- package/es/table-component/table/Grid.js +3 -0
- package/es/table-component/useContext.d.ts +5 -0
- package/es/table-virtuoso/InternalTable.js +2 -2
- package/es/table-virtuoso/body/TableBodyCell.js +2 -7
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/es/table-virtuoso/body/TableBodyRow.js +43 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -0
- package/es/table-virtuoso/hook/utils.js +29 -0
- package/es/table-virtuoso/style.js +3 -1
- package/es/table-virtuoso/table/Grid.js +2 -2
- package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/es/table-virtuoso/table/TableWrapper.js +24 -5
- package/es/table-virtuoso/useContext.d.ts +6 -3
- package/es/table-virtuoso/useContext.js +18 -0
- package/lib/grid-component/TempTable.js +2 -1
- package/lib/group-component/ColumnsChoose.d.ts +13 -0
- package/lib/group-component/ColumnsChoose.js +221 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
- package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/group-component/ColumnsGroup/index.js +16 -0
- package/lib/group-component/ContextMenu.d.ts +19 -0
- package/lib/group-component/ContextMenu.js +83 -0
- package/lib/group-component/InternalTable.d.ts +8 -0
- package/lib/group-component/InternalTable.js +233 -0
- package/lib/group-component/TableContainer.d.ts +49 -0
- package/lib/group-component/TableContainer.js +382 -0
- package/lib/group-component/TableContainerEdit.d.ts +48 -0
- package/lib/group-component/TableContainerEdit.js +2075 -0
- package/lib/group-component/body/EditableCell.d.ts +16 -0
- package/lib/group-component/body/EditableCell.js +1075 -0
- package/lib/group-component/body/TableBody.d.ts +14 -0
- package/lib/group-component/body/TableBody.js +91 -0
- package/lib/group-component/body/TableBodyCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyCell.js +595 -0
- package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
- package/lib/group-component/body/TableBodyRow.d.ts +21 -0
- package/lib/group-component/body/TableBodyRow.js +206 -0
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
- package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/group-component/components/ControlCheckbox.js +92 -0
- package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/group-component/components/EditForm/EditForm.js +404 -0
- package/lib/group-component/components/EditForm/index.d.ts +1 -0
- package/lib/group-component/components/EditForm/index.js +16 -0
- package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/group-component/components/InputControl/InputControl.js +127 -0
- package/lib/group-component/components/InputControl/index.d.ts +1 -0
- package/lib/group-component/components/InputControl/index.js +16 -0
- package/lib/group-component/components/async-select/index.d.ts +11 -0
- package/lib/group-component/components/async-select/index.js +47 -0
- package/lib/group-component/components/async-table-select/index.d.ts +11 -0
- package/lib/group-component/components/async-table-select/index.js +49 -0
- package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/group-component/components/checkbox-control/index.js +48 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/group-component/components/command/Command.d.ts +10 -0
- package/lib/group-component/components/command/Command.js +44 -0
- package/lib/group-component/components/number/index.d.ts +12 -0
- package/lib/group-component/components/number/index.js +50 -0
- package/lib/group-component/components/number-range/index.d.ts +13 -0
- package/lib/group-component/components/number-range/index.js +87 -0
- package/lib/group-component/features/operator.d.ts +24 -0
- package/lib/group-component/features/operator.js +67 -0
- package/lib/group-component/footer/TableFooter.d.ts +7 -0
- package/lib/group-component/footer/TableFooter.js +44 -0
- package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
- package/lib/group-component/footer/TableFooterCell.js +75 -0
- package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
- package/lib/group-component/footer/TableFooterRow.js +37 -0
- package/lib/group-component/header/TableHead.d.ts +15 -0
- package/lib/group-component/header/TableHead.js +107 -0
- package/lib/group-component/header/TableHeadCell.d.ts +15 -0
- package/lib/group-component/header/TableHeadCell.js +319 -0
- package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/group-component/header/TableHeadCell2.js +330 -0
- package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/group-component/header/TableHeadGroupCell.js +103 -0
- package/lib/group-component/header/TableHeadRow.d.ts +15 -0
- package/lib/group-component/header/TableHeadRow.js +59 -0
- package/lib/group-component/header/renderFilter.d.ts +20 -0
- package/lib/group-component/header/renderFilter.js +301 -0
- package/lib/group-component/hook/convert.d.ts +1 -0
- package/lib/group-component/hook/convert.js +34 -0
- package/lib/group-component/hook/useColumns.d.ts +28 -0
- package/lib/group-component/hook/useColumns.js +318 -0
- package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/group-component/hook/useFilterOperator.js +40 -0
- package/lib/group-component/hook/utils.d.ts +220 -0
- package/lib/group-component/hook/utils.js +2468 -0
- package/lib/group-component/index.d.ts +2 -0
- package/lib/group-component/index.js +9 -0
- package/lib/group-component/style.d.ts +22 -0
- package/lib/group-component/style.js +55 -0
- package/lib/group-component/style.scss +1438 -0
- package/lib/group-component/table/Grid.d.ts +33 -0
- package/lib/group-component/table/Grid.js +443 -0
- package/lib/group-component/table/TableWrapper.d.ts +33 -0
- package/lib/group-component/table/TableWrapper.js +259 -0
- package/lib/group-component/useContext.d.ts +100 -0
- package/lib/group-component/useContext.js +27 -0
- package/lib/table-component/InternalTable.js +6 -1
- package/lib/table-component/TableContainer.js +4 -2
- package/lib/table-component/TableContainerEdit.js +2 -2
- package/lib/table-component/body/TableBodyCell.js +49 -40
- package/lib/table-component/body/TableBodyCellEdit.js +9 -3
- package/lib/table-component/body/TableBodyRow.js +4 -1
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +16 -7
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/table/Grid.js +3 -0
- package/lib/table-component/useContext.d.ts +5 -0
- package/lib/table-virtuoso/InternalTable.js +2 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
- package/lib/table-virtuoso/hook/utils.d.ts +1 -0
- package/lib/table-virtuoso/hook/utils.js +32 -1
- package/lib/table-virtuoso/style.js +3 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/lib/table-virtuoso/table/TableWrapper.js +24 -5
- package/lib/table-virtuoso/useContext.d.ts +6 -3
- package/lib/table-virtuoso/useContext.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Cell, Table } from "@tanstack/react-table";
|
|
2
|
+
import type { CommandClick } from "../../grid-component/type";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableBodyCellProps<T> {
|
|
5
|
+
table: Table<T>;
|
|
6
|
+
tableId: string;
|
|
7
|
+
cell: Cell<T, unknown>;
|
|
8
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
declare const TableBodyCellEmpty: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
12
|
+
export default TableBodyCellEmpty;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import ReactDOMServer from 'react-dom/server';
|
|
2
|
+
import { getCommonPinningStyles } from "../hook/utils";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { TableContext } from "../useContext";
|
|
6
|
+
import { toggleRowSelection } from "../hook/useColumns";
|
|
7
|
+
const TableBodyCellEmpty = props => {
|
|
8
|
+
const {
|
|
9
|
+
cell,
|
|
10
|
+
table,
|
|
11
|
+
isEditing
|
|
12
|
+
} = props;
|
|
13
|
+
const {
|
|
14
|
+
id,
|
|
15
|
+
prefix,
|
|
16
|
+
focusedCell,
|
|
17
|
+
setFocusedCell,
|
|
18
|
+
setIsSelectionChange,
|
|
19
|
+
isSelectionChange,
|
|
20
|
+
selectionSettings,
|
|
21
|
+
wrapSettings,
|
|
22
|
+
setIsSelecting,
|
|
23
|
+
setIsPasting
|
|
24
|
+
} = React.useContext(TableContext);
|
|
25
|
+
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
26
|
+
const record = cell.row.original;
|
|
27
|
+
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
28
|
+
const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
|
|
29
|
+
|
|
30
|
+
// const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
31
|
+
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
32
|
+
value: cell.getValue(),
|
|
33
|
+
record
|
|
34
|
+
}) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
|
|
35
|
+
const allRows = table.getRowModel().flatRows;
|
|
36
|
+
const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
|
|
37
|
+
const colIndex = cell.column.getIndex();
|
|
38
|
+
const isPinned = cell.column.getIsPinned();
|
|
39
|
+
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
40
|
+
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
41
|
+
const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
key: cell.id,
|
|
44
|
+
ref: el => {
|
|
45
|
+
if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
|
|
46
|
+
el?.focus();
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
|
|
50
|
+
"data-col-index": colIndex,
|
|
51
|
+
"data-row-index": rowNumber,
|
|
52
|
+
"data-col-key": cell.column.id
|
|
53
|
+
// data-row-key={cell.row.id}
|
|
54
|
+
,
|
|
55
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
56
|
+
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
|
|
57
|
+
// data-tooltip-delay-show={500}
|
|
58
|
+
,
|
|
59
|
+
|
|
60
|
+
className: classNames(`${prefix}-grid-cell`, {
|
|
61
|
+
// [`${prefix}-grid-cell-ellipsis`]: true,
|
|
62
|
+
|
|
63
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
|
|
64
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
65
|
+
// [`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
66
|
+
|
|
67
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
68
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
69
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
70
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
|
|
71
|
+
}),
|
|
72
|
+
style: {
|
|
73
|
+
...cellStyles,
|
|
74
|
+
display: 'flex',
|
|
75
|
+
width: cell.column.getSize(),
|
|
76
|
+
minWidth: cell.column.getSize(),
|
|
77
|
+
minHeight: 36,
|
|
78
|
+
...getCommonPinningStyles(cell.column)
|
|
79
|
+
},
|
|
80
|
+
onMouseEnter: e => {
|
|
81
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
82
|
+
setIsOpenTooltip(true);
|
|
83
|
+
}
|
|
84
|
+
setIsSelecting?.(false);
|
|
85
|
+
setIsPasting?.(false);
|
|
86
|
+
},
|
|
87
|
+
onKeyDown: e => {
|
|
88
|
+
const flatRows = table.getRowModel().flatRows;
|
|
89
|
+
if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
|
|
90
|
+
const nextIndex = cell.row.index + 1;
|
|
91
|
+
// const nextIndex = rowNumber + 1
|
|
92
|
+
|
|
93
|
+
const nextId = flatRows[nextIndex].id;
|
|
94
|
+
setFocusedCell?.({
|
|
95
|
+
colId: cell.column.id,
|
|
96
|
+
rowId: nextId
|
|
97
|
+
});
|
|
98
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
99
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
100
|
+
if (cellFocus) {
|
|
101
|
+
cellFocus.focus();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
105
|
+
const prevIndex = cell.row.index - 1;
|
|
106
|
+
const nextId = flatRows[prevIndex].id;
|
|
107
|
+
setFocusedCell?.({
|
|
108
|
+
colId: cell.column.id,
|
|
109
|
+
rowId: nextId
|
|
110
|
+
});
|
|
111
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
112
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
113
|
+
if (cellFocus) {
|
|
114
|
+
cellFocus.focus();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
118
|
+
toggleRowSelection({
|
|
119
|
+
e,
|
|
120
|
+
cell,
|
|
121
|
+
setIsSelectionChange,
|
|
122
|
+
isSelectionChange,
|
|
123
|
+
selectionSettings
|
|
124
|
+
});
|
|
125
|
+
cell.row.getToggleSelectedHandler()(e);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
onClick: e => {
|
|
129
|
+
const selection = window.getSelection();
|
|
130
|
+
const text = selection ? selection.toString() : "";
|
|
131
|
+
if (text.length > 0 || enableClick === false) {} else {
|
|
132
|
+
if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
|
|
133
|
+
toggleRowSelection({
|
|
134
|
+
e,
|
|
135
|
+
cell,
|
|
136
|
+
setIsSelectionChange,
|
|
137
|
+
isSelectionChange,
|
|
138
|
+
selectionSettings
|
|
139
|
+
});
|
|
140
|
+
setFocusedCell?.({
|
|
141
|
+
colId: cell.column.id,
|
|
142
|
+
rowId: cell.row.id
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export default TableBodyCellEmpty;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
2
|
+
import { type Column, type Row, type Table } from "@tanstack/react-table";
|
|
3
|
+
import type { CommandClick } from "../../grid-component/type";
|
|
4
|
+
import React from "react";
|
|
5
|
+
interface TableBodyRowProps<T> {
|
|
6
|
+
tableId: string;
|
|
7
|
+
table: Table<T>;
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
9
|
+
row: Row<T>;
|
|
10
|
+
rowVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
11
|
+
virtualPaddingLeft: number | undefined;
|
|
12
|
+
virtualPaddingRight: number | undefined;
|
|
13
|
+
virtualRow: VirtualItem;
|
|
14
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
15
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
16
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
17
|
+
editAble?: boolean;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
declare const TableBodyRow: <RecordType extends object>({ tableId, table, columnVirtualizer, row, rowVirtualizer, virtualPaddingLeft, virtualPaddingRight, virtualRow, fixedLeftColumns, fixedRightColumns, commandClick, editAble, isEditing, contextMenuItems, onContextMenu, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
|
|
21
|
+
export default TableBodyRow;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import TableBodyCell from "./TableBodyCell";
|
|
3
|
+
import TableBodyCellEdit from "./TableBodyCellEdit";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { TableContext } from "../useContext";
|
|
6
|
+
import classNames from "classnames";
|
|
7
|
+
import TableBodyCellEmpty from "./TableBodyCellEmpty";
|
|
8
|
+
// import TableBodyCellEmpty from "./TableBodyCellEmpty"
|
|
9
|
+
|
|
10
|
+
const TableBodyRow = ({
|
|
11
|
+
tableId,
|
|
12
|
+
table,
|
|
13
|
+
columnVirtualizer,
|
|
14
|
+
row,
|
|
15
|
+
rowVirtualizer,
|
|
16
|
+
virtualPaddingLeft,
|
|
17
|
+
virtualPaddingRight,
|
|
18
|
+
virtualRow,
|
|
19
|
+
fixedLeftColumns,
|
|
20
|
+
fixedRightColumns,
|
|
21
|
+
commandClick,
|
|
22
|
+
editAble,
|
|
23
|
+
isEditing,
|
|
24
|
+
contextMenuItems,
|
|
25
|
+
onContextMenu,
|
|
26
|
+
...rest
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
prefix,
|
|
30
|
+
recordDoubleClick,
|
|
31
|
+
focusedCell,
|
|
32
|
+
rowClassName,
|
|
33
|
+
rowEditable,
|
|
34
|
+
onRowStyles,
|
|
35
|
+
groupColumns
|
|
36
|
+
} = React.useContext(TableContext);
|
|
37
|
+
const visibleCells = row.getVisibleCells();
|
|
38
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
39
|
+
const centerCOlumns = virtualColumns.filter(vc => !(table.getState().columnPinning.left?.includes(visibleCells[vc.index].column.id) || table.getState().columnPinning.right?.includes(visibleCells[vc.index].column.id)));
|
|
40
|
+
const leftTemplate = fixedLeftColumns.length > 0 ? fixedLeftColumns.map(it => row.getVisibleCells().find(c => c.column.id === it.id).column.getSize()) : [];
|
|
41
|
+
const rightTemplate = fixedRightColumns.length > 0 ? fixedRightColumns.map(it => row.getVisibleCells().find(c => c.column.id === it.id).column.getSize()) : [];
|
|
42
|
+
const centerTemplate = centerCOlumns.map(it => it.size);
|
|
43
|
+
const virtualLeft = virtualPaddingLeft ? [virtualPaddingLeft] : [];
|
|
44
|
+
const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
|
|
45
|
+
const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
|
|
46
|
+
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
47
|
+
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
48
|
+
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
51
|
+
,
|
|
52
|
+
ref: node => rowVirtualizer.measureElement(node) //measure dynamic row height
|
|
53
|
+
,
|
|
54
|
+
key: row.id,
|
|
55
|
+
"data-row-key": row.id,
|
|
56
|
+
className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
|
|
57
|
+
[`${prefix}-grid-row-selected`]: row.getIsSelected(),
|
|
58
|
+
[`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId && !editAble,
|
|
59
|
+
[`${prefix}-grid-row-parent`]: row.subRows && row.subRows.length > 0
|
|
60
|
+
}),
|
|
61
|
+
style: {
|
|
62
|
+
// display: 'flex',
|
|
63
|
+
display: 'grid',
|
|
64
|
+
// position: 'absolute',
|
|
65
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
66
|
+
//this should always be a `style` as it changes on scroll
|
|
67
|
+
// height: isEditing ? '36px' : undefined,
|
|
68
|
+
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
69
|
+
height: isEditing ? virtualRow.size : undefined,
|
|
70
|
+
minHeight: isEditing ? undefined : virtualRow.size,
|
|
71
|
+
...rowStyles
|
|
72
|
+
},
|
|
73
|
+
onDoubleClick: e => {
|
|
74
|
+
recordDoubleClick?.({
|
|
75
|
+
e,
|
|
76
|
+
rowData: row.original,
|
|
77
|
+
rowIndex: row.index
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
onContextMenu: e => {
|
|
81
|
+
if (contextMenuItems && contextMenuItems.length) {
|
|
82
|
+
onContextMenu?.(row.original)(e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
86
|
+
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
87
|
+
if (row.subRows && row.subRows.length === 0 && groupColumns?.includes(cell.column.id)) {
|
|
88
|
+
return /*#__PURE__*/React.createElement(TableBodyCellEmpty, _extends({}, rest, {
|
|
89
|
+
table: table,
|
|
90
|
+
tableId: tableId,
|
|
91
|
+
key: cell.id,
|
|
92
|
+
cell: cell,
|
|
93
|
+
commandClick: commandClick,
|
|
94
|
+
virtualRow: virtualRow,
|
|
95
|
+
isEditing: isEditing,
|
|
96
|
+
isRowEditable: isRowEditable,
|
|
97
|
+
rowVirtualizer: rowVirtualizer,
|
|
98
|
+
columnVirtualizer: columnVirtualizer
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
if (editAble && row.subRows && row.subRows.length === 0) {
|
|
102
|
+
return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
|
|
103
|
+
table: table,
|
|
104
|
+
tableId: tableId,
|
|
105
|
+
key: cell.id,
|
|
106
|
+
cell: cell,
|
|
107
|
+
commandClick: commandClick,
|
|
108
|
+
virtualRow: virtualRow,
|
|
109
|
+
isEditing: isEditing,
|
|
110
|
+
isRowEditable: isRowEditable,
|
|
111
|
+
rowVirtualizer: rowVirtualizer,
|
|
112
|
+
columnVirtualizer: columnVirtualizer
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
|
|
116
|
+
table: table,
|
|
117
|
+
tableId: tableId,
|
|
118
|
+
key: cell.id,
|
|
119
|
+
cell: cell,
|
|
120
|
+
commandClick: commandClick,
|
|
121
|
+
virtualRow: virtualRow,
|
|
122
|
+
isEditing: false,
|
|
123
|
+
rowVirtualizer: rowVirtualizer,
|
|
124
|
+
columnVirtualizer: columnVirtualizer,
|
|
125
|
+
row: row
|
|
126
|
+
}));
|
|
127
|
+
}) : null, virtualPaddingLeft ? /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
className: "",
|
|
129
|
+
style: {
|
|
130
|
+
display: "flex",
|
|
131
|
+
width: virtualPaddingLeft
|
|
132
|
+
}
|
|
133
|
+
}) : null, virtualColumns.map(vc => {
|
|
134
|
+
const cell = visibleCells[vc.index];
|
|
135
|
+
const isFixed = table.getState().columnPinning.left?.includes(cell.column.id) || table.getState().columnPinning.right?.includes(cell.column.id);
|
|
136
|
+
if (cell && !isFixed) {
|
|
137
|
+
if (editAble && row.subRows && row.subRows.length === 0) {
|
|
138
|
+
return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
|
|
139
|
+
table: table,
|
|
140
|
+
key: cell.id,
|
|
141
|
+
tableId: tableId,
|
|
142
|
+
cell: cell,
|
|
143
|
+
commandClick: commandClick,
|
|
144
|
+
isEditing: isEditing,
|
|
145
|
+
isRowEditable: isRowEditable,
|
|
146
|
+
rowVirtualizer: rowVirtualizer,
|
|
147
|
+
columnVirtualizer: columnVirtualizer,
|
|
148
|
+
virtualRow: virtualRow
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
|
|
152
|
+
table: table,
|
|
153
|
+
key: cell.id,
|
|
154
|
+
tableId: tableId,
|
|
155
|
+
cell: cell,
|
|
156
|
+
commandClick: commandClick,
|
|
157
|
+
isEditing: false,
|
|
158
|
+
rowVirtualizer: rowVirtualizer,
|
|
159
|
+
columnVirtualizer: columnVirtualizer,
|
|
160
|
+
virtualRow: virtualRow,
|
|
161
|
+
row: row
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
}), fixedRightColumns.length > 0 ? fixedRightColumns.map(column => {
|
|
165
|
+
if (editAble) {
|
|
166
|
+
return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, rest, {
|
|
167
|
+
table: table,
|
|
168
|
+
key: column.id,
|
|
169
|
+
tableId: tableId,
|
|
170
|
+
cell: row.getVisibleCells().find(c => c.column.id === column.id),
|
|
171
|
+
commandClick: commandClick,
|
|
172
|
+
isEditing: isEditing,
|
|
173
|
+
isRowEditable: isRowEditable,
|
|
174
|
+
rowVirtualizer: rowVirtualizer,
|
|
175
|
+
columnVirtualizer: columnVirtualizer,
|
|
176
|
+
virtualRow: virtualRow
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({}, rest, {
|
|
180
|
+
table: table,
|
|
181
|
+
key: column.id,
|
|
182
|
+
tableId: tableId,
|
|
183
|
+
cell: row.getVisibleCells().find(c => c.column.id === column.id),
|
|
184
|
+
commandClick: commandClick,
|
|
185
|
+
isEditing: false,
|
|
186
|
+
rowVirtualizer: rowVirtualizer,
|
|
187
|
+
columnVirtualizer: columnVirtualizer,
|
|
188
|
+
virtualRow: virtualRow,
|
|
189
|
+
row: row
|
|
190
|
+
}));
|
|
191
|
+
}) : null, virtualPaddingRight ? /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
className: "",
|
|
193
|
+
style: {
|
|
194
|
+
display: "flex",
|
|
195
|
+
width: virtualPaddingRight
|
|
196
|
+
}
|
|
197
|
+
}) : null);
|
|
198
|
+
};
|
|
199
|
+
export default TableBodyRow;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Cell, Table } from "@tanstack/react-table";
|
|
2
|
+
import type { CommandClick } from "../../grid-component/type";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableBodyCellProps<T> {
|
|
5
|
+
table: Table<T>;
|
|
6
|
+
tableId: string;
|
|
7
|
+
cell: Cell<T, unknown>;
|
|
8
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
declare const TableBodyCell: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
12
|
+
export default TableBodyCell;
|