es-grid-template 1.8.71 → 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/body/TableBodyCell.js +49 -40
- 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/body/TableBodyCell.js +49 -40
- 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
|
@@ -153,6 +153,9 @@ const Grid = props => {
|
|
|
153
153
|
onGroupingChange: setGrouping,
|
|
154
154
|
getGroupedRowModel: getGroupedRowModel(),
|
|
155
155
|
// onExpandedChange: setExpanded,
|
|
156
|
+
getRowCanExpand: row => {
|
|
157
|
+
return Array.isArray(row.original.children);
|
|
158
|
+
},
|
|
156
159
|
getExpandedRowModel: getExpandedRowModel(),
|
|
157
160
|
getPaginationRowModel: pagination && !infiniteScroll ? getPaginationRowModel() : undefined,
|
|
158
161
|
onPaginationChange: setPagination
|
|
@@ -83,6 +83,11 @@ export interface IContext<T> {
|
|
|
83
83
|
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
84
84
|
onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
85
85
|
dataSourceFilter?: SourceFilter[];
|
|
86
|
+
onExpandClick?: (args: {
|
|
87
|
+
expandedKeys: string[];
|
|
88
|
+
key: string;
|
|
89
|
+
rowData: any;
|
|
90
|
+
}) => void;
|
|
86
91
|
}
|
|
87
92
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
88
93
|
export type ContextCellChange = {
|
|
@@ -268,7 +268,7 @@ const InternalTable = props => {
|
|
|
268
268
|
setExpanded(convertToObjTrue(defaultExpandedRowKeys ?? []));
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
}, [defaultExpandAllRows, defaultExpandedRowKeys, tableData
|
|
271
|
+
}, [defaultExpandAllRows, defaultExpandedRowKeys, tableData]);
|
|
272
272
|
const triggerGroupColumns = groupedColumns => {
|
|
273
273
|
// const abc = updateColumnsByGroup(columns, groupedColumns)
|
|
274
274
|
|
|
@@ -368,7 +368,7 @@ const InternalTable = props => {
|
|
|
368
368
|
triggerSorter: triggerSorter,
|
|
369
369
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
370
370
|
mergedFilterKeys: mergedFilterKeys,
|
|
371
|
-
editAble:
|
|
371
|
+
editAble: false,
|
|
372
372
|
triggerChangeColumns: triggerChangeColumns,
|
|
373
373
|
triggerGroupColumns: triggerGroupColumns,
|
|
374
374
|
expanded: expanded,
|
|
@@ -323,14 +323,9 @@ const TableBodyCell = props => {
|
|
|
323
323
|
tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
|
|
324
324
|
"data-col-index": colIndex,
|
|
325
325
|
"data-row-index": rowNumber,
|
|
326
|
-
"data-col-key": cell.column.id
|
|
327
|
-
// data-row-key={cell.row.id}
|
|
328
|
-
,
|
|
326
|
+
"data-col-key": cell.column.id,
|
|
329
327
|
"data-tooltip-id": `${id}-tooltip-content`,
|
|
330
|
-
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent))
|
|
331
|
-
// data-tooltip-delay-show={500}
|
|
332
|
-
,
|
|
333
|
-
|
|
328
|
+
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
|
|
334
329
|
className: classNames(`${prefix}-grid-cell`, {
|
|
335
330
|
// [`${prefix}-grid-cell-ellipsis`]: true,
|
|
336
331
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Cell, Table } from "@tanstack/react-table";
|
|
2
|
+
import type { CommandClick } from "../../grid-component/type";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import type { VirtualItem } from "@tanstack/react-virtual";
|
|
5
|
+
interface TableBodyCellProps<T> {
|
|
6
|
+
table: Table<T>;
|
|
7
|
+
tableId: string;
|
|
8
|
+
cell: Cell<T, unknown>;
|
|
9
|
+
commandClick?: (args: CommandClick<T>) => void;
|
|
10
|
+
virtualRow: VirtualItem;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
declare const TableBodyCellRowGroup: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
14
|
+
export default TableBodyCellRowGroup;
|
|
@@ -0,0 +1,196 @@
|
|
|
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 "../../table-component/hook/useColumns";
|
|
7
|
+
const TableBodyCellRowGroup = props => {
|
|
8
|
+
const {
|
|
9
|
+
cell,
|
|
10
|
+
table,
|
|
11
|
+
isEditing,
|
|
12
|
+
colSpan,
|
|
13
|
+
rowSpan,
|
|
14
|
+
sumValue
|
|
15
|
+
} = props;
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
prefix,
|
|
19
|
+
focusedCell,
|
|
20
|
+
setFocusedCell,
|
|
21
|
+
expanded,
|
|
22
|
+
setExpanded,
|
|
23
|
+
expandable,
|
|
24
|
+
isDataTree,
|
|
25
|
+
setIsSelectionChange,
|
|
26
|
+
isSelectionChange,
|
|
27
|
+
selectionSettings,
|
|
28
|
+
wrapSettings
|
|
29
|
+
// dataSource
|
|
30
|
+
} = React.useContext(TableContext);
|
|
31
|
+
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
32
|
+
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
33
|
+
const record = cell.row.original;
|
|
34
|
+
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
35
|
+
const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
|
|
36
|
+
|
|
37
|
+
// const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
38
|
+
const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
|
|
39
|
+
value: cell.getValue(),
|
|
40
|
+
record
|
|
41
|
+
}) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
|
|
42
|
+
const allRows = table.getRowModel().flatRows;
|
|
43
|
+
const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
|
|
44
|
+
const colIndex = cell.column.getIndex();
|
|
45
|
+
const isPinned = cell.column.getIsPinned();
|
|
46
|
+
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
47
|
+
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
48
|
+
const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
|
|
49
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
50
|
+
key: cell.id,
|
|
51
|
+
colSpan: colSpan,
|
|
52
|
+
rowSpan: rowSpan
|
|
53
|
+
// {...cellProps}
|
|
54
|
+
,
|
|
55
|
+
|
|
56
|
+
ref: el => {
|
|
57
|
+
if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
|
|
58
|
+
el?.focus();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
|
|
62
|
+
"data-col-index": colIndex,
|
|
63
|
+
"data-row-index": rowNumber,
|
|
64
|
+
"data-col-key": cell.column.id,
|
|
65
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
66
|
+
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
|
|
67
|
+
className: classNames(`${prefix}-grid-cell`, {
|
|
68
|
+
// [`${prefix}-grid-cell-ellipsis`]: true,
|
|
69
|
+
|
|
70
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content')),
|
|
71
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Content'),
|
|
72
|
+
// [`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
73
|
+
|
|
74
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
75
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
76
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
|
|
77
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
|
|
78
|
+
}),
|
|
79
|
+
style: {
|
|
80
|
+
...cellStyles,
|
|
81
|
+
// display: 'flex',
|
|
82
|
+
width: cell.column.getSize(),
|
|
83
|
+
minWidth: cell.column.getSize(),
|
|
84
|
+
minHeight: 36,
|
|
85
|
+
...getCommonPinningStyles(cell.column)
|
|
86
|
+
},
|
|
87
|
+
onMouseEnter: e => {
|
|
88
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
89
|
+
setIsOpenTooltip(true);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: e => {
|
|
93
|
+
const flatRows = table.getRowModel().flatRows;
|
|
94
|
+
if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
|
|
95
|
+
const nextIndex = cell.row.index + 1;
|
|
96
|
+
// const nextIndex = rowNumber + 1
|
|
97
|
+
|
|
98
|
+
const nextId = flatRows[nextIndex].id;
|
|
99
|
+
setFocusedCell?.({
|
|
100
|
+
colId: cell.column.id,
|
|
101
|
+
rowId: nextId
|
|
102
|
+
});
|
|
103
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
104
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
105
|
+
if (cellFocus) {
|
|
106
|
+
cellFocus.focus();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
110
|
+
const prevIndex = cell.row.index - 1;
|
|
111
|
+
const nextId = flatRows[prevIndex].id;
|
|
112
|
+
setFocusedCell?.({
|
|
113
|
+
colId: cell.column.id,
|
|
114
|
+
rowId: nextId
|
|
115
|
+
});
|
|
116
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
117
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
118
|
+
if (cellFocus) {
|
|
119
|
+
cellFocus.focus();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
123
|
+
toggleRowSelection({
|
|
124
|
+
e,
|
|
125
|
+
cell,
|
|
126
|
+
setIsSelectionChange,
|
|
127
|
+
isSelectionChange,
|
|
128
|
+
selectionSettings
|
|
129
|
+
});
|
|
130
|
+
cell.row.getToggleSelectedHandler()(e);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
onClick: e => {
|
|
134
|
+
const selection = window.getSelection();
|
|
135
|
+
const text = selection ? selection.toString() : "";
|
|
136
|
+
if (text.length > 0 || enableClick === false) {} else {
|
|
137
|
+
if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
|
|
138
|
+
toggleRowSelection({
|
|
139
|
+
e,
|
|
140
|
+
cell,
|
|
141
|
+
setIsSelectionChange,
|
|
142
|
+
isSelectionChange,
|
|
143
|
+
selectionSettings
|
|
144
|
+
});
|
|
145
|
+
setFocusedCell?.({
|
|
146
|
+
colId: cell.column.id,
|
|
147
|
+
rowId: cell.row.id
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree ? /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
className: classNames('ui-rc_cell-content', {})
|
|
154
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
156
|
+
style: {
|
|
157
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
158
|
+
}
|
|
159
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
160
|
+
// onClick: cell.row.getToggleExpandedHandler(),
|
|
161
|
+
|
|
162
|
+
// onClick: (e) => {
|
|
163
|
+
// e.stopPropagation()
|
|
164
|
+
// cell.row.toggleExpanded()
|
|
165
|
+
// },
|
|
166
|
+
|
|
167
|
+
onClick: e => {
|
|
168
|
+
e.stopPropagation();
|
|
169
|
+
const keys = Object.keys(expanded);
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
const tmp = {
|
|
172
|
+
...expanded
|
|
173
|
+
};
|
|
174
|
+
if (keys.includes(cell.row.id)) {
|
|
175
|
+
delete tmp[cell.row.id];
|
|
176
|
+
setExpanded(tmp);
|
|
177
|
+
} else {
|
|
178
|
+
setExpanded(old => ({
|
|
179
|
+
...old,
|
|
180
|
+
[cell.row.id]: true
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
style: {
|
|
185
|
+
cursor: "pointer"
|
|
186
|
+
},
|
|
187
|
+
className: "ui-rc-table-row-expand"
|
|
188
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
189
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
190
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
191
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
192
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
194
|
+
}))), sumValue) : /*#__PURE__*/React.createElement(React.Fragment, null, sumValue));
|
|
195
|
+
};
|
|
196
|
+
export default TableBodyCellRowGroup;
|
|
@@ -9,5 +9,5 @@ interface TableBodyRowProps<T> {
|
|
|
9
9
|
editAble?: boolean;
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
12
|
-
declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, virtualRow, commandClick, contextMenuItems, onContextMenu, rowheight, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
|
|
12
|
+
declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, virtualRow, commandClick, contextMenuItems, onContextMenu, rowheight, editAble, isEditing, isRowEditable, ...rest }: TableBodyRowProps<RecordType>) => React.JSX.Element;
|
|
13
13
|
export default TableBodyRow;
|
|
@@ -4,6 +4,11 @@ import { flexRender } from "@tanstack/react-table";
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { TableContext } from "../useContext";
|
|
6
6
|
import classNames from "classnames";
|
|
7
|
+
import { getFormat } from "../hook/utils";
|
|
8
|
+
import { checkDecimalSeparator, checkThousandSeparator } from "../../table-component/hook/utils";
|
|
9
|
+
import { sumByField } from "../../grid-component/hooks";
|
|
10
|
+
import { numericFormatter } from "react-numeric-component";
|
|
11
|
+
import TableBodyCellRowGroup from "./TableBodyCellRowGroup";
|
|
7
12
|
const TableBodyRow = ({
|
|
8
13
|
tableId,
|
|
9
14
|
table,
|
|
@@ -13,6 +18,9 @@ const TableBodyRow = ({
|
|
|
13
18
|
contextMenuItems,
|
|
14
19
|
onContextMenu,
|
|
15
20
|
rowheight,
|
|
21
|
+
editAble,
|
|
22
|
+
isEditing,
|
|
23
|
+
isRowEditable,
|
|
16
24
|
...rest
|
|
17
25
|
}) => {
|
|
18
26
|
const {
|
|
@@ -21,7 +29,8 @@ const TableBodyRow = ({
|
|
|
21
29
|
focusedCell,
|
|
22
30
|
rowClassName,
|
|
23
31
|
onRowStyles,
|
|
24
|
-
groupSetting
|
|
32
|
+
groupSetting,
|
|
33
|
+
format
|
|
25
34
|
} = React.useContext(TableContext);
|
|
26
35
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
27
36
|
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
@@ -31,6 +40,8 @@ const TableBodyRow = ({
|
|
|
31
40
|
key: row.id,
|
|
32
41
|
"data-row-key": row.id
|
|
33
42
|
}, rest, {
|
|
43
|
+
// data-known-size={37}
|
|
44
|
+
|
|
34
45
|
className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
|
|
35
46
|
[`${prefix}-grid-row-selected`]: row.getIsSelected(),
|
|
36
47
|
[`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId,
|
|
@@ -111,6 +122,37 @@ const TableBodyRow = ({
|
|
|
111
122
|
groupValue: groupValue
|
|
112
123
|
}));
|
|
113
124
|
}
|
|
125
|
+
if (row.subRows.length > 0 && originCol.sumGroup === true && originCol.type === 'number') {
|
|
126
|
+
const colFormat = typeof originCol.format === 'function' ? originCol.format({}) : originCol.format;
|
|
127
|
+
const cellFormat = getFormat(colFormat, format);
|
|
128
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
129
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
130
|
+
const dec = cellFormat?.decimalScale;
|
|
131
|
+
const numericFormatProps = {
|
|
132
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
133
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
134
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
135
|
+
prefix: cellFormat?.prefix,
|
|
136
|
+
suffix: cellFormat?.suffix,
|
|
137
|
+
decimalScale: dec,
|
|
138
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
139
|
+
};
|
|
140
|
+
const childrenData = row.subRows.map(it => it.original);
|
|
141
|
+
const sumValue = sumByField(childrenData, cell.column.id);
|
|
142
|
+
const sumValueFormat = numericFormatter(sumValue.toString(), numericFormatProps);
|
|
143
|
+
return /*#__PURE__*/React.createElement(TableBodyCellRowGroup, _extends({
|
|
144
|
+
table: table,
|
|
145
|
+
tableId: tableId,
|
|
146
|
+
key: cell.id,
|
|
147
|
+
cell: cell,
|
|
148
|
+
commandClick: commandClick,
|
|
149
|
+
virtualRow: virtualRow,
|
|
150
|
+
isEditing: false,
|
|
151
|
+
colSpan: onCellColSpan ?? 1,
|
|
152
|
+
rowSpan: onCellRowSpan ?? 1,
|
|
153
|
+
sumValue: sumValueFormat
|
|
154
|
+
}, otherCellAttributes));
|
|
155
|
+
}
|
|
114
156
|
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
|
|
115
157
|
table: table,
|
|
116
158
|
tableId: tableId,
|
|
@@ -40,6 +40,7 @@ export declare const getDateRangeFormat: (type: EditType | TypeFilter | IColumnT
|
|
|
40
40
|
export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
41
41
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
42
42
|
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
43
|
+
export declare function unGroupData(groupedArray: any[], originData: any[]): any[];
|
|
43
44
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
44
45
|
export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
45
46
|
export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
@@ -272,6 +272,35 @@ export function groupArrayByColumns(arr, columns) {
|
|
|
272
272
|
return arr;
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
+
export function unGroupData(groupedArray, originData) {
|
|
276
|
+
const result = [];
|
|
277
|
+
function traverse(arr) {
|
|
278
|
+
arr.forEach(item => {
|
|
279
|
+
if (item.children && item.children.length > 0) {
|
|
280
|
+
traverse(item.children);
|
|
281
|
+
} else {
|
|
282
|
+
// Đây là data item, không phải group item
|
|
283
|
+
result.push(item);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
traverse(groupedArray);
|
|
288
|
+
|
|
289
|
+
// Tạo map từ id đến index trong originData
|
|
290
|
+
const indexMap = new Map();
|
|
291
|
+
originData.forEach((item, index) => {
|
|
292
|
+
const id = item.id ?? item.rowId;
|
|
293
|
+
indexMap.set(id, index);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Sort result theo thứ tự trong originData
|
|
297
|
+
result.sort((a, b) => {
|
|
298
|
+
const aIndex = indexMap.get(a.id ?? a.rowId) ?? -1;
|
|
299
|
+
const bIndex = indexMap.get(b.id ?? b.rowId) ?? -1;
|
|
300
|
+
return aIndex - bIndex;
|
|
301
|
+
});
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
275
304
|
export const flatColumns2 = columns => {
|
|
276
305
|
return columns.reduce((list, column) => {
|
|
277
306
|
const subColumns = column.children;
|
|
@@ -2,6 +2,8 @@ import styled from "styled-components";
|
|
|
2
2
|
const color = "#000000de";
|
|
3
3
|
const BgColor = "#ffffff";
|
|
4
4
|
const rowSelectedBg = "#FEF2EF";
|
|
5
|
+
const cellSelectedBg = "#F3F8FF";
|
|
6
|
+
const borderSelectedColor = "#0550C5";
|
|
5
7
|
const tableBorderColor = "#e0e0e0";
|
|
6
8
|
const tableBorderColorDark = "#44485E";
|
|
7
9
|
const BgColorDark = "#343e59";
|
|
@@ -9,4 +11,4 @@ const colorDark = "#e6e4f3e6";
|
|
|
9
11
|
export const GridStyle = styled.div.withConfig({
|
|
10
12
|
displayName: "GridStyle",
|
|
11
13
|
componentId: "es-grid-template__sc-rs980s-0"
|
|
12
|
-
})(["&.", "-grid{color:", ";font-size:13px;background-color:", ";table{table-layout:fixed;border-collapse:separate;border-spacing:0;}.", "-grid-container{border:1px solid ", ";.", "-grid-thead{&:has(.resizer.isResizing){.", "-grid-cell{touch-action:none;user-select:none;}}.", "-grid-cell{background-color:#ffffff;&:has(.resizer.isResizing){touch-action:none;user-select:none;}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;touch-action:none;user-select:none;width:5px;}}}tbody{.", "-grid-row{&.", "-grid-row-parent{.", "-grid-cell{font-weight:600;background-color:#f5f5f5;}}}}.", "-grid-tfoot{z-index:3 !important;.ui-rc-grid-footer-row{.ui-rc-grid-cell{border-top:1px solid ", ";border-bottom:1px solid ", ";}}}.", "-grid-cell{padding:7px 8px;.class-content:has(*){background:lightblue;}.class-content:not(:has(*)){background:lightgreen;}&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-righ{text-align:right;justify-content:flex-end;}}.", "-grid-cell:not(:has(*)){&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-right{text-align:right;justify-content:flex-end;}&.", "-grid-cell-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}}&.", "-grid-light{.", "-grid-container{.", "-grid-thead{z-index:3 !important;background-color:", ";font-weight:500;.", "-grid-cell{font-weight:inherit;color:", ";background-color:#ffffff;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-ellipsis{.ui-rc-table-column-title,.", "-grid-cell-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}&.ui-rc-grid-cell-wrap{.ui-rc-table-column-title,.", "-grid-cell-text-wrap{white-space:normal;word-break:break-word;overflow:hidden;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "-grid-filter-column{display:flex;justify-content:space-between;width:100%;align-items:center;position:relative;}.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;touch-action:none;user-select:none;width:5px;}.resizer.isResizing{opacity:1;}}}.", "-grid-tbody{.", "-grid-row{background-color:", ";color:", ";}}tbody{background-color:", ";color:", ";.", "-grid-row{&.ui-rc-grid-row-selected{.", "-grid-cell{background-color:", ";}}}.", "-grid-cell{outline:none;background-color:#ffffff;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-selected{background-color
|
|
14
|
+
})(["&.", "-grid{color:", ";font-size:13px;background-color:", ";table{table-layout:fixed;border-collapse:separate;border-spacing:0;}.", "-grid-container{border:1px solid ", ";.", "-grid-thead{&:has(.resizer.isResizing){.", "-grid-cell{touch-action:none;user-select:none;}}.", "-grid-cell{background-color:#ffffff;&:has(.resizer.isResizing){touch-action:none;user-select:none;}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;touch-action:none;user-select:none;width:5px;}}}tbody{.", "-grid-row{&.", "-grid-row-parent{.", "-grid-cell{font-weight:600;background-color:#f5f5f5;}}}}.", "-grid-tfoot{z-index:3 !important;.ui-rc-grid-footer-row{.ui-rc-grid-cell{border-top:1px solid ", ";border-bottom:1px solid ", ";}}}.", "-grid-cell{padding:7px 8px;.class-content:has(*){background:lightblue;}.class-content:not(:has(*)){background:lightgreen;}&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-righ{text-align:right;justify-content:flex-end;}}.", "-grid-cell:not(:has(*)){&.", "-grid-cell-text-center{text-align:center;justify-content:center;}&.", "-grid-cell-text-right{text-align:right;justify-content:flex-end;}&.", "-grid-cell-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}}&.", "-grid-light{.", "-grid-container{.", "-grid-thead{z-index:3 !important;background-color:", ";font-weight:500;.", "-grid-cell{font-weight:inherit;color:", ";background-color:#ffffff;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-ellipsis{.ui-rc-table-column-title,.", "-grid-cell-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}&.ui-rc-grid-cell-wrap{.ui-rc-table-column-title,.", "-grid-cell-text-wrap{white-space:normal;word-break:break-word;overflow:hidden;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "-grid-filter-column{display:flex;justify-content:space-between;width:100%;align-items:center;position:relative;}.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}.resizer{cursor:col-resize;height:100%;position:absolute;right:0;top:0;touch-action:none;user-select:none;width:5px;}.resizer.isResizing{opacity:1;}}}.", "-grid-tbody{.", "-grid-row{background-color:", ";color:", ";}}tbody{background-color:", ";color:", ";.", "-grid-row{&.ui-rc-grid-row-selected{.", "-grid-cell{background-color:", ";}}}.", "-grid-cell{outline:none;background-color:#ffffff;border-inline-end:1px solid ", ";border-bottom:1px solid ", ";&.ui-rc-grid-cell-selected{background-color:", " !important;}&.disable{background-color:#f0f0f0;}&.cell-editable{user-select:none;&.cell-border-top{&::after{content:\"\";position:absolute;top:0px;left:0;height:1px;width:100%;border-top:1px solid ", ";pointer-events:none;z-index:1;}}&.cell-border-bottom{border-bottom:1px solid ", ";}&.cell-border-left{&::before{content:\"\";position:absolute;top:0;left:0;height:102%;width:1px;border-left:1px solid ", ";pointer-events:none;z-index:1;}}&.cell-border-right{border-inline-end:1px solid ", ";}&.cell-paste-border-top{&::after{content:\"\";position:absolute;top:0px;left:0;height:1px;width:100%;border-top:1px dashed #949494;pointer-events:none;z-index:1;}&.ui-rc-grid-cell-fix-left-last{&::after{left:-100%;}}&.ui-rc-grid-cell-fix-right-first{&::after{left:100%;}}}&.cell-paste-border-bottom{border-bottom:1px dashed #949494;}&.cell-paste-border-left{&::before{content:\"\";position:absolute;top:0;left:0;height:102%;width:1px;border-left:1px dashed #949494;pointer-events:none;z-index:1;}}&.cell-paste-border-right{border-inline-end:1px dashed #949494;}.dragging-point{width:6px;height:6px;position:absolute;cursor:crosshair;right:0px;bottom:0px;&.hidden{display:none;}.dot-point{position:absolute;width:6px;height:6px;border-radius:0px;background-color:", ";bottom:0;right:0;}}}&.cell-editing{padding:0;&:focus-visible{outline:none;}.ant-form-item,.ant-row.ant-form-item-row,.ant-col.ant-form-item-control,.ant-form-item-control-input,.ant-form-item-control-input-content,.ant-input{height:100% !important;&:focus-visible{outline:none;}}textarea.ant-input{line-height:1.8;height:36px !important;min-height:36px !important;}input.be-cell-editing,.ant-picker,.ui-rc-select-selector,.ui-rc-table-select-selector{padding-inline:7px;}.", "-checkbox-wrapper{.", "-checkbox{background-color:red;}.", "-checkbox-input{&:focus-visible{outline:none;}}}.ant-input,.ant-picker{border-radius:0;}.ant-color-picker-trigger{height:100%;border-radius:0;.ant-color-picker-color-block{height:100%;width:100%;}}.", "-table-select-single .", "-table-select-selector,.", "-select-single .", "-select-selector,.ui-rc-table-select-selector{border-radius:0 !important;}.", "-table-select-single:not(.", "-table-select-customize-input){.", "-table-select-selector{.", "-table-select-selection-search-input{height:auto;}}}}}}.", "-grid-tfoot{.", "-grid-footer-row{border-bottom-width:1px;border-bottom-color:", ";border-bottom-style:solid;border-top-width:1px;border-top-color:", ";border-top-style:solid;background-color:#fafafa;}.", "-grid-cell{background-color:inherit;border-inline-end:1px solid ", ";}}}}&.", "-grid-dark{background-color:", ";color:", ";.", "-grid-container{border-color:", ";&::after{border-right-color:", ";}}}}"], props => props.$prefix, color, BgColor, props => props.$prefix, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => props.$prefix, props => `${props.$theme.color ? props.$theme.color : color}`, tableBorderColor, tableBorderColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => `${props.$theme.backgroundColor ? props.$theme.backgroundColor : BgColor}`, props => `${props.$theme.color ? props.$theme.color : color}`, props => props.$prefix, props => props.$prefix, rowSelectedBg, props => props.$prefix, tableBorderColor, tableBorderColor, cellSelectedBg, borderSelectedColor, borderSelectedColor, borderSelectedColor, borderSelectedColor, borderSelectedColor, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, props => props.$prefix, tableBorderColor, tableBorderColor, props => props.$prefix, tableBorderColor, props => props.$prefix, BgColorDark, colorDark, props => props.$prefix, tableBorderColorDark, tableBorderColorDark);
|
|
@@ -173,7 +173,7 @@ const Grid = props => {
|
|
|
173
173
|
t: t,
|
|
174
174
|
windowSize: windowSize,
|
|
175
175
|
table: table,
|
|
176
|
-
editAble:
|
|
176
|
+
editAble: false,
|
|
177
177
|
dataSource: dataSource,
|
|
178
178
|
originData: originData,
|
|
179
179
|
prefix: prefix,
|
|
@@ -243,7 +243,7 @@ const Grid = props => {
|
|
|
243
243
|
id: faker.string.alpha(20),
|
|
244
244
|
t: t,
|
|
245
245
|
table: table,
|
|
246
|
-
editAble:
|
|
246
|
+
editAble: false,
|
|
247
247
|
dataSource: dataSource,
|
|
248
248
|
originData: originData,
|
|
249
249
|
prefix: prefix,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ColumnDef, Table } from "@tanstack/react-table";
|
|
3
|
-
import type { CommandClick } from '../../grid-component/type';
|
|
3
|
+
import type { CommandClick, ContextInfo, PaginationConfig } from '../../grid-component/type';
|
|
4
|
+
import type { ContextMenuItem } from "../..";
|
|
4
5
|
type Props<T> = {
|
|
5
6
|
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
6
7
|
table: Table<T>;
|
|
@@ -14,9 +15,14 @@ type Props<T> = {
|
|
|
14
15
|
loading?: boolean;
|
|
15
16
|
commandClick?: (args: Omit<CommandClick<T>, 'rows'>) => void;
|
|
16
17
|
editAble?: boolean;
|
|
18
|
+
contextMenuItems?: ContextMenuItem[];
|
|
17
19
|
showEmptyText?: boolean;
|
|
18
20
|
contextMenuClick?: any;
|
|
21
|
+
contextMenuOpen?: (args: Omit<ContextInfo<T>, 'item'>) => void;
|
|
22
|
+
contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<T>, 'item' | 'event'>) => string[]);
|
|
19
23
|
next?: () => void;
|
|
24
|
+
pagination?: false | PaginationConfig;
|
|
25
|
+
infiniteScroll?: boolean;
|
|
20
26
|
};
|
|
21
27
|
declare const TableWrapper: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
22
28
|
export default TableWrapper;
|
|
@@ -24,10 +24,13 @@ const TableWrapper = props => {
|
|
|
24
24
|
table,
|
|
25
25
|
height,
|
|
26
26
|
id,
|
|
27
|
-
commandClick
|
|
27
|
+
commandClick,
|
|
28
|
+
editAble
|
|
28
29
|
} = props;
|
|
29
30
|
const {
|
|
30
|
-
prefix
|
|
31
|
+
prefix,
|
|
32
|
+
editingKey,
|
|
33
|
+
rowEditable
|
|
31
34
|
} = useContext(TableContext); //onRowHeaderStyles
|
|
32
35
|
|
|
33
36
|
// ref cho scroll container
|
|
@@ -74,22 +77,38 @@ const TableWrapper = props => {
|
|
|
74
77
|
TableHead: props => /*#__PURE__*/React.createElement("thead", _extends({}, props, {
|
|
75
78
|
className: `${prefix}-grid-thead`
|
|
76
79
|
})),
|
|
80
|
+
// TableBody: (props) => (
|
|
81
|
+
// <tbody {...props} className={`${prefix}-grid-tbody1`} />
|
|
82
|
+
// ),
|
|
83
|
+
|
|
77
84
|
TableFoot: props => /*#__PURE__*/React.createElement("tfoot", _extends({}, props, {
|
|
78
85
|
className: `${prefix}-grid-tfoot`
|
|
79
86
|
})),
|
|
80
87
|
TableRow: props => {
|
|
88
|
+
const {
|
|
89
|
+
item,
|
|
90
|
+
...rest
|
|
91
|
+
} = props;
|
|
81
92
|
const index = props["data-index"];
|
|
82
93
|
const rowheight = props["data-known-size"];
|
|
83
94
|
const row = rows[index];
|
|
95
|
+
const isEditing = row.id === editingKey;
|
|
96
|
+
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
84
97
|
return /*#__PURE__*/React.createElement(TableBodyRow, _extends({
|
|
85
98
|
tableId: id,
|
|
86
99
|
row: row,
|
|
87
100
|
table: table,
|
|
88
101
|
commandClick: commandClick,
|
|
89
|
-
rowheight: rowheight
|
|
90
|
-
|
|
102
|
+
rowheight: editAble ? 37 : rowheight,
|
|
103
|
+
isEditing: isEditing,
|
|
104
|
+
isRowEditable: isRowEditable,
|
|
105
|
+
editAble: editAble
|
|
106
|
+
}, rest));
|
|
91
107
|
}
|
|
92
|
-
}
|
|
108
|
+
},
|
|
109
|
+
defaultItemHeight: 37,
|
|
110
|
+
fixedItemHeight: 37,
|
|
111
|
+
itemSize: () => 37
|
|
93
112
|
|
|
94
113
|
// overscan={{
|
|
95
114
|
// main: 10,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import type { ColumnTable, ExpandableConfig, IFormat, IGroupSetting, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings } from "../grid-component/type";
|
|
2
|
+
import type { ColumnTable, ExpandableConfig, IFormat, IGroupSetting, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "../grid-component/type";
|
|
3
3
|
import type { SubmitHandler } from "react-hook-form";
|
|
4
4
|
import type { ExpandedState, Row, Table } from '@tanstack/react-table';
|
|
5
5
|
export type IPositionCell = {
|
|
6
6
|
rowId: string;
|
|
7
7
|
colId: string;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export interface IContext<T> {
|
|
10
10
|
t?: any;
|
|
11
11
|
prefix: string;
|
|
@@ -48,6 +48,7 @@ export interface IContext<T> {
|
|
|
48
48
|
reset?: any;
|
|
49
49
|
setValue?: any;
|
|
50
50
|
handleCellChange?: (args: ContextCellChange) => void;
|
|
51
|
+
handleCellChangeAndAddRow?: (args: ContextCellChange) => void;
|
|
51
52
|
editingKey?: string;
|
|
52
53
|
setEditingKey?: Dispatch<SetStateAction<string>>;
|
|
53
54
|
rangeState?: RangeState;
|
|
@@ -68,6 +69,7 @@ export interface IContext<T> {
|
|
|
68
69
|
setIsPasting?: Dispatch<SetStateAction<boolean>>;
|
|
69
70
|
focusedCell?: IPositionCell;
|
|
70
71
|
setFocusedCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
72
|
+
cellActive?: any;
|
|
71
73
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
72
74
|
handleDeleteContent?: () => void;
|
|
73
75
|
handleAddMulti?: (item: any, n: number, id?: string) => void;
|
|
@@ -82,12 +84,13 @@ export interface IContext<T> {
|
|
|
82
84
|
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
83
85
|
onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
84
86
|
groupSetting?: IGroupSetting;
|
|
87
|
+
dataSourceFilter?: SourceFilter[];
|
|
85
88
|
}
|
|
86
89
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
87
90
|
export type ContextCellChange = {
|
|
88
91
|
key: string;
|
|
89
92
|
record: any;
|
|
90
|
-
field: string
|
|
93
|
+
field: string;
|
|
91
94
|
option: any;
|
|
92
95
|
indexRow: number;
|
|
93
96
|
indexCol: number;
|
|
@@ -18,4 +18,22 @@ export const TableContext = /*#__PURE__*/createContext({
|
|
|
18
18
|
setFilterChange: () => {},
|
|
19
19
|
setExpanded: () => {},
|
|
20
20
|
handleCellClick: () => {}
|
|
21
|
+
|
|
22
|
+
// startCellRef: { current: undefined } as React.MutableRefObject<IPositionCell | undefined>,
|
|
23
|
+
// endCellRef: { current: undefined } as React.MutableRefObject<IPositionCell | undefined>,
|
|
24
|
+
// focusedCellRef: { current: undefined } as React.MutableRefObject<IPositionCell | undefined>,
|
|
25
|
+
// isSelectingRef: { current: false } as React.MutableRefObject<boolean>,
|
|
26
|
+
|
|
27
|
+
// rangeStateRef: {
|
|
28
|
+
// current: {
|
|
29
|
+
// startRowIndex: undefined,
|
|
30
|
+
// endRowIndex: undefined,
|
|
31
|
+
// startColIndex: undefined,
|
|
32
|
+
// endColIndex: undefined,
|
|
33
|
+
// rowIds: [],
|
|
34
|
+
// colIds: [],
|
|
35
|
+
// colRange: [],
|
|
36
|
+
// rowRange: []
|
|
37
|
+
// }
|
|
38
|
+
// } as React.MutableRefObject<RangeState>
|
|
21
39
|
});
|
|
@@ -9,13 +9,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _tableComponent = _interopRequireDefault(require("../table-component"));
|
|
11
11
|
var _tableVirtuoso = _interopRequireDefault(require("../table-virtuoso"));
|
|
12
|
+
var _groupComponent = _interopRequireDefault(require("../group-component"));
|
|
12
13
|
const TempTable = props => {
|
|
13
14
|
const {
|
|
14
15
|
groupAble,
|
|
15
16
|
editAble,
|
|
16
17
|
...rest
|
|
17
18
|
} = props;
|
|
18
|
-
const TabComponent = groupAble ? _tableVirtuoso.default : _tableComponent.default;
|
|
19
|
+
const TabComponent = groupAble ? editAble ? _groupComponent.default : _tableVirtuoso.default : _tableComponent.default;
|
|
19
20
|
return /*#__PURE__*/_react.default.createElement(TabComponent, (0, _extends2.default)({}, rest, {
|
|
20
21
|
groupAble: groupAble,
|
|
21
22
|
editAble: editAble
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ColumnsTable, ColumnTable } from "./../grid-component/type";
|
|
3
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
4
|
+
export type IColumnsChoose<RecordType> = {
|
|
5
|
+
columns: ColumnDef<RecordType>[];
|
|
6
|
+
originColumns: ColumnTable[];
|
|
7
|
+
columnsGroup?: string[];
|
|
8
|
+
triggerChangeColumns?: (columns: ColumnsTable<RecordType>, keys: string[], type: string) => void;
|
|
9
|
+
t?: any;
|
|
10
|
+
triggerChangeKeys?: any;
|
|
11
|
+
columnHidden: any;
|
|
12
|
+
};
|
|
13
|
+
export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
|