es-grid-template 1.8.55 → 1.8.57
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/type.d.ts +8 -0
- package/es/table-component/TableContainer.js +15 -0
- package/es/table-component/TableContainerEdit.js +13 -12
- package/es/table-component/body/TableBodyCell.js +24 -62
- package/es/table-component/body/TableBodyCellEdit.js +14 -9
- package/es/table-component/body/TableBodyRow.js +7 -12
- package/es/table-component/footer/TableFooterCell.js +2 -2
- package/es/table-component/footer/TableFooterRow.js +8 -4
- package/es/table-component/header/TableHead.js +4 -1
- package/es/table-component/header/TableHeadCell2.js +7 -48
- package/es/table-component/header/TableHeadGroupCell.js +13 -225
- package/es/table-component/header/TableHeadRow.js +7 -19
- package/es/table-component/hook/useColumns.js +17 -3
- package/es/table-component/hook/utils.js +0 -17
- package/es/table-component/style.scss +270 -15
- package/es/table-component/table/Grid.js +14 -25
- package/es/table-component/type.d.ts +8 -1
- package/es/table-component/useContext.d.ts +4 -1
- package/lib/grid-component/type.d.ts +8 -0
- package/lib/table-component/TableContainer.js +15 -0
- package/lib/table-component/TableContainerEdit.js +13 -12
- package/lib/table-component/body/TableBodyCell.js +24 -62
- package/lib/table-component/body/TableBodyCellEdit.js +14 -9
- package/lib/table-component/body/TableBodyRow.js +7 -12
- package/lib/table-component/footer/TableFooterCell.js +2 -2
- package/lib/table-component/footer/TableFooterRow.js +8 -4
- package/lib/table-component/header/TableHead.js +4 -1
- package/lib/table-component/header/TableHeadCell2.js +7 -48
- package/lib/table-component/header/TableHeadGroupCell.js +11 -223
- package/lib/table-component/header/TableHeadRow.js +7 -20
- package/lib/table-component/hook/useColumns.js +17 -3
- package/lib/table-component/hook/utils.js +0 -17
- package/lib/table-component/style.scss +270 -15
- package/lib/table-component/table/Grid.js +14 -25
- package/lib/table-component/type.d.ts +8 -1
- package/lib/table-component/useContext.d.ts +4 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
|
9
9
|
import type { ColorPickerProps } from "antd";
|
|
10
10
|
import type { FixedType } from "rc-base-table/lib/interface";
|
|
11
11
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
12
|
+
import type { Cell, Header, Row } from '@tanstack/react-table';
|
|
12
13
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
13
14
|
export type AnyObject = Record<PropertyKey, any>;
|
|
14
15
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
@@ -135,6 +136,9 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
|
|
|
135
136
|
editFromSettings?: IEditFromSettings;
|
|
136
137
|
fixedType?: FixedType;
|
|
137
138
|
headerTextWrap?: boolean;
|
|
139
|
+
onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
140
|
+
onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
141
|
+
onCellFooterStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
138
142
|
};
|
|
139
143
|
export type IFormOpen = {
|
|
140
144
|
value?: any;
|
|
@@ -193,6 +197,7 @@ export type Sort = {
|
|
|
193
197
|
export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale'> {
|
|
194
198
|
editAble?: boolean;
|
|
195
199
|
infiniteScroll?: boolean;
|
|
200
|
+
theme?: 'dark' | 'light';
|
|
196
201
|
next?: () => void;
|
|
197
202
|
locale?: Locale;
|
|
198
203
|
groupAble?: boolean;
|
|
@@ -266,6 +271,9 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
266
271
|
wrapSettings?: IWrapSettings;
|
|
267
272
|
actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
|
|
268
273
|
fullScreen?: boolean;
|
|
274
|
+
onRowStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | ((data: RecordType, row: Row<RecordType>) => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
275
|
+
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
276
|
+
onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
269
277
|
}
|
|
270
278
|
export type PaginationConfig = TablePaginationConfig & {
|
|
271
279
|
currentPage?: number;
|
|
@@ -76,6 +76,9 @@ const TableContainer = props => {
|
|
|
76
76
|
columnSizing,
|
|
77
77
|
columnSizingInfo,
|
|
78
78
|
rowClassName,
|
|
79
|
+
onRowStyles,
|
|
80
|
+
onRowFooterStyles,
|
|
81
|
+
onRowHeaderStyles,
|
|
79
82
|
title
|
|
80
83
|
} = props;
|
|
81
84
|
const tableContainerRef = React.useRef(null);
|
|
@@ -93,6 +96,15 @@ const TableContainer = props => {
|
|
|
93
96
|
settableHeight(totalHeight - topHeight - bottomHeight);
|
|
94
97
|
}
|
|
95
98
|
}, [id, height, editAble, minHeight]);
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
const handleClickOutside = () => {
|
|
101
|
+
setFocusedCell(undefined);
|
|
102
|
+
};
|
|
103
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
104
|
+
return () => {
|
|
105
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
96
108
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
97
109
|
const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
|
|
98
110
|
const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
|
|
@@ -261,6 +273,9 @@ const TableContainer = props => {
|
|
|
261
273
|
focusedCell,
|
|
262
274
|
setFocusedCell,
|
|
263
275
|
rowClassName,
|
|
276
|
+
onRowStyles,
|
|
277
|
+
onRowFooterStyles,
|
|
278
|
+
onRowHeaderStyles,
|
|
264
279
|
table,
|
|
265
280
|
pagination
|
|
266
281
|
}
|
|
@@ -125,7 +125,8 @@ const TableContainerEdit = props => {
|
|
|
125
125
|
setColumns,
|
|
126
126
|
columnSizing,
|
|
127
127
|
columnSizingInfo,
|
|
128
|
-
rowClassName
|
|
128
|
+
rowClassName,
|
|
129
|
+
onRowStyles
|
|
129
130
|
} = props;
|
|
130
131
|
const containerRef = React.useRef(null);
|
|
131
132
|
const bottomToolbarRef = React.useRef(null);
|
|
@@ -1895,7 +1896,8 @@ const TableContainerEdit = props => {
|
|
|
1895
1896
|
handleCellClick,
|
|
1896
1897
|
pagination,
|
|
1897
1898
|
rowClassName,
|
|
1898
|
-
rowEditable
|
|
1899
|
+
rowEditable,
|
|
1900
|
+
onRowStyles
|
|
1899
1901
|
}
|
|
1900
1902
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1901
1903
|
contextMenuItems: contextMenuItems,
|
|
@@ -1924,14 +1926,15 @@ const TableContainerEdit = props => {
|
|
|
1924
1926
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
1925
1927
|
ref: bottomToolbarRef
|
|
1926
1928
|
}, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
1927
|
-
className: 'ui-rc-toolbar-bottom'
|
|
1929
|
+
className: classNames('ui-rc-toolbar-bottom', {
|
|
1930
|
+
'ui-rc-toolbar-bottom_border-bottom': !pagination || infiniteScroll
|
|
1931
|
+
})
|
|
1928
1932
|
// style={{ border: '0 1px 1px 1px solid #e0e0e0' }}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
}
|
|
1933
|
+
// style={{
|
|
1934
|
+
// borderBottom: '1px solid #e0e0e0',
|
|
1935
|
+
// borderRight: '1px solid #e0e0e0',
|
|
1936
|
+
// borderLeft: '1px solid #e0e0e0'
|
|
1937
|
+
// }}
|
|
1935
1938
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1936
1939
|
style: {
|
|
1937
1940
|
width: '100%'
|
|
@@ -1941,9 +1944,7 @@ const TableContainerEdit = props => {
|
|
|
1941
1944
|
onClick: ({}) => {
|
|
1942
1945
|
setEditingKey('');
|
|
1943
1946
|
}
|
|
1944
|
-
})), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
1945
|
-
// style={{padding: '0.75rem 1rem'}}
|
|
1946
|
-
, _extends({}, pagination, {
|
|
1947
|
+
})), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
|
|
1947
1948
|
rootClassName: 'pagination-template',
|
|
1948
1949
|
showSizeChanger: true,
|
|
1949
1950
|
responsive: true,
|
|
@@ -168,6 +168,7 @@ const TableBodyCell = props => {
|
|
|
168
168
|
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
169
169
|
const record = cell.row.original;
|
|
170
170
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
171
|
+
const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
|
|
171
172
|
|
|
172
173
|
// const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
173
174
|
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
@@ -197,18 +198,13 @@ const TableBodyCell = props => {
|
|
|
197
198
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
198
199
|
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
199
200
|
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
200
|
-
// [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
|
|
201
|
-
// [`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id),
|
|
202
201
|
}),
|
|
203
202
|
style: {
|
|
203
|
+
...cellStyles,
|
|
204
204
|
display: 'flex',
|
|
205
|
-
// height: '36px',
|
|
206
205
|
userSelect: 'none',
|
|
207
206
|
width: cell.column.getSize(),
|
|
208
|
-
// flexBasis: cell.column.getSize(),
|
|
209
207
|
minWidth: cell.column.getSize(),
|
|
210
|
-
// flex: 1,
|
|
211
|
-
// maxWidth: cell.column.getSize(),
|
|
212
208
|
...getCommonPinningStyles(cell.column)
|
|
213
209
|
},
|
|
214
210
|
onClick: e => {
|
|
@@ -272,12 +268,10 @@ const TableBodyCell = props => {
|
|
|
272
268
|
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
273
269
|
}),
|
|
274
270
|
style: {
|
|
271
|
+
...cellStyles,
|
|
275
272
|
display: 'flex',
|
|
276
|
-
// height: '36px',
|
|
277
273
|
width: cell.column.getSize(),
|
|
278
274
|
minWidth: cell.column.getSize(),
|
|
279
|
-
// flex: 1,
|
|
280
|
-
// maxWidth: cell.column.getSize(),
|
|
281
275
|
...getCommonPinningStyles(cell.column)
|
|
282
276
|
}
|
|
283
277
|
}, renderCommand({
|
|
@@ -298,51 +292,16 @@ const TableBodyCell = props => {
|
|
|
298
292
|
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
|
|
299
293
|
}),
|
|
300
294
|
style: {
|
|
295
|
+
...cellStyles,
|
|
301
296
|
display: 'flex',
|
|
302
|
-
// height: '36px',
|
|
303
297
|
minHeight: 36,
|
|
304
298
|
width: cell.column.getSize(),
|
|
305
299
|
minWidth: cell.column.getSize(),
|
|
306
|
-
// flex: 1,
|
|
307
|
-
// maxWidth: cell.column.getSize(),
|
|
308
300
|
...getCommonPinningStyles(cell.column)
|
|
309
301
|
}
|
|
310
302
|
}, /*#__PURE__*/React.createElement("div", {
|
|
311
303
|
className: classNames('ui-rc_cell-content', {})
|
|
312
|
-
}, cell.column.
|
|
313
|
-
className: "ui-rc-table-row-expand-trigger",
|
|
314
|
-
style: {
|
|
315
|
-
paddingLeft: `${cell.row.depth * 25}px`
|
|
316
|
-
}
|
|
317
|
-
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
318
|
-
// onClick: row.getToggleExpandedHandler(),
|
|
319
|
-
onClick: () => {
|
|
320
|
-
const keys = Object.keys(expanded);
|
|
321
|
-
// @ts-ignore
|
|
322
|
-
const tmp = {
|
|
323
|
-
...expanded
|
|
324
|
-
};
|
|
325
|
-
if (keys.includes(cell.row.id)) {
|
|
326
|
-
delete tmp[cell.row.id];
|
|
327
|
-
setExpanded(tmp);
|
|
328
|
-
} else {
|
|
329
|
-
setExpanded(old => ({
|
|
330
|
-
...old,
|
|
331
|
-
[cell.row.id]: true
|
|
332
|
-
}));
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
style: {
|
|
336
|
-
cursor: "pointer"
|
|
337
|
-
},
|
|
338
|
-
className: "ui-rc-table-row-expand"
|
|
339
|
-
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
340
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
341
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
342
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
343
|
-
})) : /*#__PURE__*/React.createElement("span", {
|
|
344
|
-
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
345
|
-
}))), cell.column.id === "selection_column" && renderSelection({
|
|
304
|
+
}, cell.column.id === "selection_column" && renderSelection({
|
|
346
305
|
cell,
|
|
347
306
|
table,
|
|
348
307
|
selectionSettings,
|
|
@@ -385,13 +344,11 @@ const TableBodyCell = props => {
|
|
|
385
344
|
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
|
|
386
345
|
}),
|
|
387
346
|
style: {
|
|
347
|
+
...cellStyles,
|
|
388
348
|
display: 'flex',
|
|
389
349
|
width: cell.column.getSize(),
|
|
390
350
|
minWidth: cell.column.getSize(),
|
|
391
351
|
minHeight: 36,
|
|
392
|
-
// flex: 1,
|
|
393
|
-
// maxWidth: cell.column.getSize(),
|
|
394
|
-
// height: '36px',
|
|
395
352
|
...getCommonPinningStyles(cell.column)
|
|
396
353
|
},
|
|
397
354
|
onMouseEnter: e => {
|
|
@@ -466,24 +423,29 @@ const TableBodyCell = props => {
|
|
|
466
423
|
// })
|
|
467
424
|
// }
|
|
468
425
|
}
|
|
469
|
-
}
|
|
426
|
+
},
|
|
427
|
+
onKeyUp: () => {}
|
|
470
428
|
|
|
471
429
|
// onDoubleClick={() => { }}
|
|
472
430
|
,
|
|
473
431
|
|
|
474
432
|
onClick: e => {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
433
|
+
const selection = window.getSelection();
|
|
434
|
+
const text = selection ? selection.toString() : "";
|
|
435
|
+
if (text.length > 0) {} else {
|
|
436
|
+
if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
|
|
437
|
+
toggleRowSelection({
|
|
438
|
+
e,
|
|
439
|
+
cell,
|
|
440
|
+
setIsSelectionChange,
|
|
441
|
+
isSelectionChange,
|
|
442
|
+
selectionSettings
|
|
443
|
+
});
|
|
444
|
+
setFocusedCell?.({
|
|
445
|
+
colId: cell.column.id,
|
|
446
|
+
rowId: cell.row.id
|
|
447
|
+
});
|
|
448
|
+
}
|
|
487
449
|
}
|
|
488
450
|
}
|
|
489
451
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -242,12 +242,18 @@ const TableBodyCellEdit = props => {
|
|
|
242
242
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
243
243
|
const record = cell.row.original;
|
|
244
244
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
245
|
-
const
|
|
245
|
+
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
246
|
+
|
|
247
|
+
// const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
246
248
|
// const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
|
|
247
249
|
// const hasValue = html.trim().length > 0;
|
|
248
250
|
|
|
249
251
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
250
252
|
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
253
|
+
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
254
|
+
value: cell.getValue(),
|
|
255
|
+
record
|
|
256
|
+
}) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
|
|
251
257
|
const canEdit = isEditable(cell.column.columnDef.meta, record) && isRowEditable !== false;
|
|
252
258
|
|
|
253
259
|
// const allRows = table.getRowModel().rows;
|
|
@@ -429,7 +435,10 @@ const TableBodyCellEdit = props => {
|
|
|
429
435
|
const rs = unFlattenData(rsFilterData);
|
|
430
436
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
431
437
|
};
|
|
432
|
-
function handleMouseEnter(rowId, colId) {
|
|
438
|
+
function handleMouseEnter(e, rowId, colId) {
|
|
439
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
440
|
+
setIsOpenTooltip(true);
|
|
441
|
+
}
|
|
433
442
|
if (isSelecting) {
|
|
434
443
|
setEndCell?.({
|
|
435
444
|
rowId,
|
|
@@ -1044,12 +1053,8 @@ const TableBodyCellEdit = props => {
|
|
|
1044
1053
|
"data-col-key": cell.column.id,
|
|
1045
1054
|
"data-row-key": cell.row.id,
|
|
1046
1055
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
1047
|
-
"data-tooltip-delay-show": 500
|
|
1048
|
-
|
|
1049
|
-
// data-tooltip-content={!isEditing && !message ? undefined : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? '']}
|
|
1050
|
-
// data-tooltip-content={isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : record[columnMeta.field ?? '']}
|
|
1051
|
-
,
|
|
1052
|
-
"data-tooltip-html": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent)),
|
|
1056
|
+
"data-tooltip-delay-show": 500,
|
|
1057
|
+
"data-tooltip-html": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
|
|
1053
1058
|
className: classNames(`${prefix}-grid-cell cell-editable editable `, {
|
|
1054
1059
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
1055
1060
|
'cell-editing': isEditing,
|
|
@@ -1099,7 +1104,7 @@ const TableBodyCellEdit = props => {
|
|
|
1099
1104
|
}
|
|
1100
1105
|
}
|
|
1101
1106
|
},
|
|
1102
|
-
onMouseEnter:
|
|
1107
|
+
onMouseEnter: e => handleMouseEnter(e, cell.row.id, cell.column.id),
|
|
1103
1108
|
onMouseUp: e => handleMouseUp(e),
|
|
1104
1109
|
onKeyDown: e => {
|
|
1105
1110
|
if (!isEditing) {
|
|
@@ -27,7 +27,8 @@ const TableBodyRow = ({
|
|
|
27
27
|
recordDoubleClick,
|
|
28
28
|
focusedCell,
|
|
29
29
|
rowClassName,
|
|
30
|
-
rowEditable
|
|
30
|
+
rowEditable,
|
|
31
|
+
onRowStyles
|
|
31
32
|
} = React.useContext(TableContext);
|
|
32
33
|
const visibleCells = row.getVisibleCells();
|
|
33
34
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
@@ -39,23 +40,18 @@ const TableBodyRow = ({
|
|
|
39
40
|
const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
|
|
40
41
|
const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
|
|
41
42
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
43
|
+
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
42
44
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
43
45
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
46
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
45
47
|
,
|
|
46
48
|
ref: node => rowVirtualizer.measureElement(node) //measure dynamic row height
|
|
47
49
|
,
|
|
48
|
-
key: row.id
|
|
49
|
-
|
|
50
|
-
,
|
|
51
|
-
"data-row-key": row.id
|
|
52
|
-
|
|
53
|
-
// className={} ui-rc-table-row-selected
|
|
54
|
-
,
|
|
50
|
+
key: row.id,
|
|
51
|
+
"data-row-key": row.id,
|
|
55
52
|
className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
|
|
56
53
|
[`${prefix}-grid-row-selected`]: row.getIsSelected(),
|
|
57
54
|
[`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId && !editAble
|
|
58
|
-
// [`${prefix}-grid-row-focus`]: true,
|
|
59
55
|
}),
|
|
60
56
|
style: {
|
|
61
57
|
// display: 'flex',
|
|
@@ -63,12 +59,11 @@ const TableBodyRow = ({
|
|
|
63
59
|
// position: 'absolute',
|
|
64
60
|
transform: `translateY(${virtualRow.start}px)`,
|
|
65
61
|
//this should always be a `style` as it changes on scroll
|
|
66
|
-
// width: '100%',
|
|
67
62
|
// height: isEditing ? '36px' : undefined,
|
|
68
63
|
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
69
|
-
// gridTemplateColumns: `repeat(${centerCOlumns.length + fixedLeftColumns.length + fixedRightColumns.length}, minmax(0, 1fr))`,
|
|
70
64
|
height: isEditing ? virtualRow.size : undefined,
|
|
71
|
-
minHeight: isEditing ? undefined : virtualRow.size
|
|
65
|
+
minHeight: isEditing ? undefined : virtualRow.size,
|
|
66
|
+
...rowStyles
|
|
72
67
|
},
|
|
73
68
|
onDoubleClick: e => {
|
|
74
69
|
recordDoubleClick?.({
|
|
@@ -62,8 +62,8 @@ const TableFooterCell = ({
|
|
|
62
62
|
display: 'flex',
|
|
63
63
|
...getCommonPinningStyles(column),
|
|
64
64
|
// width: column?.getSize() ?? column.getSize(),
|
|
65
|
-
minWidth: column?.getSize()
|
|
66
|
-
backgroundColor: "#fafafa"
|
|
65
|
+
minWidth: column?.getSize()
|
|
66
|
+
// backgroundColor: "#fafafa",
|
|
67
67
|
}
|
|
68
68
|
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : numericFormatter(cellValue, numericFormatProps)) : '');
|
|
69
69
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// import type { Person } from "../makeData";
|
|
3
3
|
import TableFooterCell from "./TableFooterCell";
|
|
4
4
|
import React from "react";
|
|
5
|
+
import { TableContext } from "../useContext";
|
|
5
6
|
// import type { Person } from "../../tanstack-table/makeData";
|
|
6
7
|
// import TableHeadCell from "./TableHeadCell";
|
|
7
8
|
|
|
@@ -20,20 +21,23 @@ const TableFooterRow = ({
|
|
|
20
21
|
|
|
21
22
|
// const a = table.getVisibleFlatColumns()
|
|
22
23
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
24
|
+
const {
|
|
25
|
+
onRowFooterStyles
|
|
26
|
+
} = React.useContext(TableContext);
|
|
27
|
+
const rowStyles = typeof onRowFooterStyles === 'function' ? onRowFooterStyles() : onRowFooterStyles;
|
|
23
28
|
|
|
24
29
|
// const
|
|
25
30
|
|
|
26
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
-
// data-index={headerGroup.id}
|
|
28
32
|
key: headerGroup.id,
|
|
29
33
|
style: {
|
|
34
|
+
...rowStyles,
|
|
30
35
|
display: "grid",
|
|
31
36
|
width: "100%",
|
|
32
|
-
borderBottom: "1px solid #e0e0e0",
|
|
33
|
-
borderTop: "1px solid #e0e0e0",
|
|
34
37
|
height: 37,
|
|
35
38
|
gridTemplateColumns: `${table.getVisibleLeafColumns().map(n => `${n.getSize()}fr`).join(" ")}`
|
|
36
|
-
}
|
|
39
|
+
},
|
|
40
|
+
className: "ui-rc-grid-footer-row"
|
|
37
41
|
}, visibleColumns.map(header => {
|
|
38
42
|
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
39
43
|
key: header.id
|
|
@@ -24,15 +24,18 @@ const TableHead = ({
|
|
|
24
24
|
// fixedRightColumns
|
|
25
25
|
}) => {
|
|
26
26
|
const {
|
|
27
|
-
prefix
|
|
27
|
+
prefix,
|
|
28
|
+
onRowHeaderStyles
|
|
28
29
|
} = useContext(TableContext);
|
|
29
30
|
const headerGroups = table.getFlatHeaders();
|
|
30
31
|
const leafColumns = table.getVisibleFlatColumns();
|
|
31
32
|
// const leafColumns11 = table.getIsAllColumnsVisible();
|
|
32
33
|
const headerDepth = table.getHeaderGroups().length;
|
|
34
|
+
const rowStyles = typeof onRowHeaderStyles === 'function' ? onRowHeaderStyles() : onRowHeaderStyles;
|
|
33
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
36
|
className: `${prefix}-grid-thead`,
|
|
35
37
|
style: {
|
|
38
|
+
...rowStyles,
|
|
36
39
|
display: 'grid',
|
|
37
40
|
position: 'sticky',
|
|
38
41
|
top: 0,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// import { useSortable } from "@dnd-kit/sortable"
|
|
2
|
-
|
|
3
1
|
import { flexRender } from '@tanstack/react-table';
|
|
4
2
|
import React, { useContext } from 'react';
|
|
5
|
-
// import { CSS } from '@dnd-kit/utilities'
|
|
6
|
-
// import type { Virtualizer } from '@tanstack/react-virtual'
|
|
7
3
|
import { Button, Space } from 'antd';
|
|
8
4
|
import { ArrowDown, ArrowUp, FilterFill, SortCancel } from 'becoxy-icons';
|
|
9
5
|
import classNames from 'classnames';
|
|
@@ -13,11 +9,6 @@ import { excludeItems, extendsObject, getCommonPinningStyles, getDefaultOperator
|
|
|
13
9
|
import { TableContext } from "../useContext";
|
|
14
10
|
import { renderFilter } from "./renderFilter";
|
|
15
11
|
import ReactDOMServer from 'react-dom/server';
|
|
16
|
-
|
|
17
|
-
// import { ColumnTable } from "../type";
|
|
18
|
-
|
|
19
|
-
// import { Tooltip } from 'react-tooltip'
|
|
20
|
-
|
|
21
12
|
const TableHeadCell2 = props => {
|
|
22
13
|
const {
|
|
23
14
|
column,
|
|
@@ -25,9 +16,6 @@ const TableHeadCell2 = props => {
|
|
|
25
16
|
getPopupContainer,
|
|
26
17
|
table,
|
|
27
18
|
depth,
|
|
28
|
-
// t,
|
|
29
|
-
// columnVirtualizer,
|
|
30
|
-
// rowHeaderVirtualizer,
|
|
31
19
|
colSpan,
|
|
32
20
|
rowSpan
|
|
33
21
|
} = props;
|
|
@@ -52,33 +40,16 @@ const TableHeadCell2 = props => {
|
|
|
52
40
|
const {
|
|
53
41
|
filterIcon
|
|
54
42
|
} = column.columnDef.meta ?? {};
|
|
55
|
-
|
|
56
|
-
// const column = (column.columnDef ?? {}) as ColumnTable
|
|
57
|
-
// const column = column.columnDef
|
|
58
|
-
|
|
59
43
|
const originalColumn = column.columnDef.meta ?? {};
|
|
44
|
+
const cellStyles = typeof originalColumn.onCellHeaderStyles === 'function' ? originalColumn.onCellHeaderStyles(header) : originalColumn.onCellHeaderStyles;
|
|
60
45
|
const filtered = (column.getFilterValue() ?? []).length > 0;
|
|
61
46
|
const cellContent = flexRender(column.columnDef.header, header.getContext());
|
|
62
|
-
// const cellContent = 'aaaa'
|
|
63
|
-
|
|
64
47
|
const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
|
|
65
48
|
const hasValue = html.trim().length > 0;
|
|
66
|
-
|
|
67
|
-
// const filtered = column.getIsFiltered()
|
|
68
|
-
|
|
69
|
-
// const { attributes, isDragging, listeners, setNodeRef, transform } =
|
|
70
|
-
// useSortable({
|
|
71
|
-
// id: column.id,
|
|
72
|
-
// })
|
|
73
|
-
|
|
74
49
|
const style = {
|
|
75
|
-
// opacity: isDragging ? 0.8 : 1,
|
|
76
|
-
// position: 'relative',
|
|
77
|
-
// transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
|
|
78
50
|
transition: 'width transform 0.2s ease-in-out',
|
|
79
|
-
whiteSpace: 'nowrap'
|
|
80
|
-
|
|
81
|
-
// zIndex: isDragging ? 1 : 0,
|
|
51
|
+
whiteSpace: 'nowrap',
|
|
52
|
+
...cellStyles
|
|
82
53
|
};
|
|
83
54
|
const getDropdownTrigger = () => {
|
|
84
55
|
let iconFilter;
|
|
@@ -232,25 +203,15 @@ const TableHeadCell2 = props => {
|
|
|
232
203
|
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
233
204
|
[`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
|
|
234
205
|
[`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
|
|
235
|
-
})
|
|
236
|
-
// colSpan={colSpan}
|
|
237
|
-
// rowSpan={rowSpan}
|
|
238
|
-
,
|
|
239
|
-
|
|
206
|
+
}),
|
|
240
207
|
key: column.id,
|
|
241
208
|
style: {
|
|
242
|
-
|
|
243
|
-
// width: column.getSize(),
|
|
209
|
+
...style,
|
|
244
210
|
minWidth: column.getSize(),
|
|
245
|
-
// flex: 1,
|
|
246
|
-
// flexGrow: column.getSize(),
|
|
247
|
-
|
|
248
211
|
gridRow: `${depth + 1} / span ${rowSpan}`,
|
|
249
212
|
gridColumn: `span ${colSpan}`,
|
|
250
|
-
// maxWidth: header.getSize(),
|
|
251
213
|
...getCommonPinningStyles(column),
|
|
252
|
-
width: 'auto'
|
|
253
|
-
...style
|
|
214
|
+
width: 'auto'
|
|
254
215
|
},
|
|
255
216
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
256
217
|
"data-tooltip-delay-show": 500,
|
|
@@ -261,9 +222,7 @@ const TableHeadCell2 = props => {
|
|
|
261
222
|
[`${prefix}-grid-selection-column`]: column.id === 'selection_column'
|
|
262
223
|
})
|
|
263
224
|
}, column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== true && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/React.createElement(Checkbox, {
|
|
264
|
-
checked: table.getIsAllRowsSelected()
|
|
265
|
-
// indeterminate={table.getIsSomeRowsSelected()}
|
|
266
|
-
,
|
|
225
|
+
checked: table.getIsAllRowsSelected(),
|
|
267
226
|
indeterminate: table.getIsSomePageRowsSelected(),
|
|
268
227
|
onChange: e => {
|
|
269
228
|
table.getToggleAllRowsSelectedHandler()(e);
|