es-grid-template 1.7.26 → 1.7.27
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/table-component/InternalTable.js +69 -4
- package/es/table-component/TableContainerEdit.d.ts +2 -0
- package/es/table-component/TableContainerEdit.js +25 -17
- package/es/table-component/body/TableBody.d.ts +1 -1
- package/es/table-component/body/TableBody.js +27 -0
- package/es/table-component/body/TableBodyCell.js +3 -1
- package/es/table-component/body/TableBodyCellEdit.js +20 -18
- package/es/table-component/footer/TableFooterCell.js +3 -2
- package/es/table-component/header/TableHead.d.ts +1 -1
- package/es/table-component/header/TableHead.js +42 -6
- package/es/table-component/header/TableHeadCell.d.ts +2 -0
- package/es/table-component/header/TableHeadCell.js +16 -47
- package/es/table-component/header/TableHeadRow.d.ts +3 -4
- package/es/table-component/header/TableHeadRow.js +55 -58
- package/es/table-component/hook/convert.d.ts +1 -0
- package/es/table-component/hook/convert.js +28 -0
- package/es/table-component/hook/useColumns.js +1 -0
- package/es/table-component/hook/utils.js +3 -0
- package/es/table-component/style.scss +39 -50
- package/es/table-component/table/Grid.d.ts +2 -0
- package/es/table-component/table/Grid.js +3 -2
- package/es/table-component/type.d.ts +5 -0
- package/lib/table-component/InternalTable.js +69 -4
- package/lib/table-component/TableContainerEdit.d.ts +2 -0
- package/lib/table-component/TableContainerEdit.js +25 -17
- package/lib/table-component/body/TableBody.d.ts +1 -1
- package/lib/table-component/body/TableBody.js +27 -0
- package/lib/table-component/body/TableBodyCell.js +3 -1
- package/lib/table-component/body/TableBodyCellEdit.js +20 -18
- package/lib/table-component/footer/TableFooterCell.js +3 -2
- package/lib/table-component/header/TableHead.d.ts +1 -1
- package/lib/table-component/header/TableHead.js +42 -6
- package/lib/table-component/header/TableHeadCell.d.ts +2 -0
- package/lib/table-component/header/TableHeadCell.js +16 -47
- package/lib/table-component/header/TableHeadRow.d.ts +3 -4
- package/lib/table-component/header/TableHeadRow.js +55 -58
- package/lib/table-component/hook/convert.d.ts +1 -0
- package/lib/table-component/hook/convert.js +34 -0
- package/lib/table-component/hook/useColumns.js +1 -0
- package/lib/table-component/hook/utils.js +3 -0
- package/lib/table-component/style.scss +39 -50
- package/lib/table-component/table/Grid.d.ts +2 -0
- package/lib/table-component/table/Grid.js +3 -2
- package/lib/table-component/type.d.ts +5 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _reactTable = require("@tanstack/react-table");
|
|
9
9
|
var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
|
|
10
10
|
var _Command = _interopRequireDefault(require("../components/command/Command"));
|
|
11
|
+
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
11
12
|
var _utils = require("../hook/utils");
|
|
12
13
|
var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkbox"));
|
|
13
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -15,8 +16,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
16
|
var _useContext = require("../useContext");
|
|
16
17
|
var _EditableCell = _interopRequireDefault(require("./EditableCell"));
|
|
17
18
|
var _constant = require("../hook/constant");
|
|
18
|
-
// import ReactDOMServer from 'react-dom/server'
|
|
19
|
-
|
|
20
19
|
// import { nonActionColumn } from "../hook/constant";
|
|
21
20
|
|
|
22
21
|
// import type { Dispatch, SetStateAction } from "react";
|
|
@@ -132,14 +131,11 @@ const TableBodyCellEdit = props => {
|
|
|
132
131
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
133
132
|
const record = cell.row.original;
|
|
134
133
|
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// const hasValue = html.trim().length > 0;
|
|
139
|
-
|
|
134
|
+
const cellContent = columnMeta.type === 'checkbox' ? '' : (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
135
|
+
const html = _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cellContent));
|
|
136
|
+
const hasValue = html.trim().length > 0;
|
|
140
137
|
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
|
|
143
139
|
const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record);
|
|
144
140
|
// const allRows = table.getRowModel().rows;
|
|
145
141
|
const allRows = table.getRowModel().flatRows;
|
|
@@ -192,7 +188,9 @@ const TableBodyCellEdit = props => {
|
|
|
192
188
|
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
193
189
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
194
190
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
195
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
191
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
192
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
193
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
196
194
|
}),
|
|
197
195
|
style: {
|
|
198
196
|
display: 'flex',
|
|
@@ -244,7 +242,9 @@ const TableBodyCellEdit = props => {
|
|
|
244
242
|
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
245
243
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
246
244
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
247
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
245
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
246
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
247
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
248
248
|
}),
|
|
249
249
|
style: {
|
|
250
250
|
display: 'flex',
|
|
@@ -264,7 +264,9 @@ const TableBodyCellEdit = props => {
|
|
|
264
264
|
className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable111 `, {
|
|
265
265
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
266
266
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
267
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
267
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
268
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
269
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right'
|
|
268
270
|
}),
|
|
269
271
|
style: {
|
|
270
272
|
display: 'flex',
|
|
@@ -746,11 +748,9 @@ const TableBodyCellEdit = props => {
|
|
|
746
748
|
"data-col-index": colIndex,
|
|
747
749
|
"data-row-index": rowNumber,
|
|
748
750
|
"data-col-key": cell.column.id,
|
|
749
|
-
"data-row-key": cell.row.id
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
,
|
|
753
|
-
|
|
751
|
+
"data-row-key": cell.row.id,
|
|
752
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
753
|
+
"data-tooltip-html": !isEditing && !hasValue && !message ? undefined : _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent)),
|
|
754
754
|
className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable `, {
|
|
755
755
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
756
756
|
'cell-editing': isEditing,
|
|
@@ -766,7 +766,9 @@ const TableBodyCellEdit = props => {
|
|
|
766
766
|
'cell-paste-border-top': isInRangePaste && isTopPaste && (pasteRangeState.endRowIndex ?? 0) < (endRowIndex ?? 0),
|
|
767
767
|
'cell-paste-border-left': isInRangePaste && isLeftPaste,
|
|
768
768
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
769
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
769
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
770
|
+
[`${prefix}-grid-cell-text-center`]: columnMeta?.headerTextAlign === 'center',
|
|
771
|
+
[`${prefix}-grid-cell-text-right`]: columnMeta?.headerTextAlign === 'right' || columnMeta.type === 'number'
|
|
770
772
|
}),
|
|
771
773
|
style: {
|
|
772
774
|
display: 'flex',
|
|
@@ -61,7 +61,8 @@ const TableFooterCell = ({
|
|
|
61
61
|
// [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
62
62
|
// [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
63
63
|
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
64
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
64
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
65
|
+
[`${prefix}-grid-cell-text-right`]: true
|
|
65
66
|
}),
|
|
66
67
|
key: header.id,
|
|
67
68
|
colSpan: header.colSpan,
|
|
@@ -71,6 +72,6 @@ const TableFooterCell = ({
|
|
|
71
72
|
width: header?.getSize() ?? header.column.getSize(),
|
|
72
73
|
backgroundColor: "#fafafa"
|
|
73
74
|
}
|
|
74
|
-
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(
|
|
75
|
+
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps)) : '');
|
|
75
76
|
};
|
|
76
77
|
var _default = exports.default = TableFooterCell;
|
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _reactTable = require("@tanstack/react-table");
|
|
8
9
|
var _reactVirtual = require("@tanstack/react-virtual");
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _useContext = require("../useContext");
|
|
11
12
|
var _TableHeadRow = _interopRequireDefault(require("./TableHeadRow"));
|
|
13
|
+
var _utils = require("../hook/utils");
|
|
12
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
16
|
const TableHead = ({
|
|
@@ -32,7 +34,8 @@ const TableHead = ({
|
|
|
32
34
|
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
33
35
|
overscan: 5
|
|
34
36
|
});
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
// const virtualRows = rowVirtualizer.getVirtualItems()
|
|
36
39
|
|
|
37
40
|
// const columnSizingState = table.getState().columnSizing
|
|
38
41
|
|
|
@@ -45,13 +48,12 @@ const TableHead = ({
|
|
|
45
48
|
return /*#__PURE__*/_react.default.createElement("thead", {
|
|
46
49
|
className: `${prefix}-grid-thead`,
|
|
47
50
|
style: {
|
|
48
|
-
display: 'grid',
|
|
51
|
+
// display: 'grid',
|
|
49
52
|
position: 'sticky',
|
|
50
53
|
top: 0,
|
|
51
54
|
zIndex: 1
|
|
52
55
|
}
|
|
53
|
-
},
|
|
54
|
-
const headerGroup = table.getHeaderGroups()[virtualRow.index];
|
|
56
|
+
}, table.getHeaderGroups().map(headerGroup => {
|
|
55
57
|
return /*#__PURE__*/_react.default.createElement(_TableHeadRow.default, {
|
|
56
58
|
table: table,
|
|
57
59
|
columnVirtualizer: columnVirtualizer,
|
|
@@ -61,9 +63,43 @@ const TableHead = ({
|
|
|
61
63
|
virtualPaddingLeft: virtualPaddingLeft,
|
|
62
64
|
virtualPaddingRight: virtualPaddingRight,
|
|
63
65
|
fixedLeftColumns: fixedLeftColumns,
|
|
64
|
-
fixedRightColumns: fixedRightColumns
|
|
65
|
-
rowHeaderVirtual
|
|
66
|
+
fixedRightColumns: fixedRightColumns
|
|
67
|
+
// rowHeaderVirtual={virtualRow}
|
|
66
68
|
});
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
70
|
+
key: headerGroup.id
|
|
71
|
+
}, headerGroup.headers.map(header => {
|
|
72
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
73
|
+
if (columnRelativeDepth > 1) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
let rowSpan = 1;
|
|
77
|
+
if (header.isPlaceholder) {
|
|
78
|
+
const leafs = header.getLeafHeaders();
|
|
79
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement("th", {
|
|
82
|
+
key: header.id,
|
|
83
|
+
colSpan: header.colSpan,
|
|
84
|
+
rowSpan: rowSpan,
|
|
85
|
+
style: {
|
|
86
|
+
padding: '12px',
|
|
87
|
+
textAlign: 'left',
|
|
88
|
+
fontSize: '0.75rem',
|
|
89
|
+
fontWeight: 'medium',
|
|
90
|
+
color: '#6b7280',
|
|
91
|
+
textTransform: 'uppercase',
|
|
92
|
+
letterSpacing: '0.05em',
|
|
93
|
+
// backgroundColor: '#f9fafb',
|
|
94
|
+
// border: '1px solid #e5e7eb',
|
|
95
|
+
width: header.getSize(),
|
|
96
|
+
minWidth: header.getSize(),
|
|
97
|
+
maxWidth: header.getSize(),
|
|
98
|
+
// overflow: 'hidden',
|
|
99
|
+
...(0, _utils.getCommonPinningStyles)(header.column)
|
|
100
|
+
}
|
|
101
|
+
}, (0, _reactTable.flexRender)(header.column.columnDef.header, header.getContext()));
|
|
102
|
+
}));
|
|
67
103
|
}));
|
|
68
104
|
};
|
|
69
105
|
var _default = exports.default = TableHead;
|
|
@@ -9,6 +9,8 @@ interface TableHeadCellProps<T> {
|
|
|
9
9
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
10
10
|
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
11
11
|
rowHeaderVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
|
|
12
|
+
colSpan: any;
|
|
13
|
+
rowSpan: any;
|
|
12
14
|
}
|
|
13
15
|
declare const TableHeadCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
|
|
14
16
|
export default TableHeadCell;
|
|
@@ -33,7 +33,9 @@ const TableHeadCell = props => {
|
|
|
33
33
|
table,
|
|
34
34
|
t,
|
|
35
35
|
columnVirtualizer,
|
|
36
|
-
rowHeaderVirtualizer
|
|
36
|
+
rowHeaderVirtualizer,
|
|
37
|
+
colSpan,
|
|
38
|
+
rowSpan
|
|
37
39
|
} = props;
|
|
38
40
|
const {
|
|
39
41
|
prefix,
|
|
@@ -46,7 +48,7 @@ const TableHeadCell = props => {
|
|
|
46
48
|
locale
|
|
47
49
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
48
50
|
const isPinned = header.column.getIsPinned();
|
|
49
|
-
const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left')
|
|
51
|
+
// const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left')
|
|
50
52
|
const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
|
|
51
53
|
const [selectedKeys, setSelectedKeys] = _react.default.useState([]);
|
|
52
54
|
const [visible, setVisible] = _react.default.useState(false);
|
|
@@ -119,9 +121,9 @@ const TableHeadCell = props => {
|
|
|
119
121
|
};
|
|
120
122
|
const doFilter = type => {
|
|
121
123
|
if (type) {
|
|
122
|
-
header.column.setFilterValue(selectedKeys);
|
|
124
|
+
header.column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? [''] : selectedKeys);
|
|
123
125
|
} else {
|
|
124
|
-
header.column.setFilterValue(
|
|
126
|
+
header.column.setFilterValue(undefined);
|
|
125
127
|
setSelectedKeys([]);
|
|
126
128
|
}
|
|
127
129
|
setFilterChange(true);
|
|
@@ -209,57 +211,24 @@ const TableHeadCell = props => {
|
|
|
209
211
|
// return dropdownContent;
|
|
210
212
|
}
|
|
211
213
|
});
|
|
212
|
-
|
|
213
|
-
// if (header.column.id === "#" || header.column.id === "selection_column") {
|
|
214
|
-
// return (
|
|
215
|
-
// <th
|
|
216
|
-
// ref={el => {
|
|
217
|
-
// if (el) columnVirtualizer.measureElement(el)
|
|
218
|
-
// }}
|
|
219
|
-
// data-index={header.id}
|
|
220
|
-
// // ref={setNodeRef}
|
|
221
|
-
// key={header.id}
|
|
222
|
-
// colSpan={header.colSpan}
|
|
223
|
-
// style={{
|
|
224
|
-
// display: 'flex',
|
|
225
|
-
// ...getCommonPinningStyles(header.column),
|
|
226
|
-
// ...style,
|
|
227
|
-
// width: header?.getSize() ?? header.column.getSize()
|
|
228
|
-
// }}
|
|
229
|
-
// >
|
|
230
|
-
|
|
231
|
-
// {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
|
232
|
-
// {/* <div> */}
|
|
233
|
-
|
|
234
|
-
// <div
|
|
235
|
-
// {...{
|
|
236
|
-
// onDoubleClick: () => header.column.resetSize(),
|
|
237
|
-
|
|
238
|
-
// onMouseDown: header.getResizeHandler(),
|
|
239
|
-
// onTouchStart: header.getResizeHandler(),
|
|
240
|
-
|
|
241
|
-
// className: `resizer ${header.column.getIsResizing() ? "isResizing" : ""
|
|
242
|
-
// }`,
|
|
243
|
-
// }}
|
|
244
|
-
// />
|
|
245
|
-
|
|
246
|
-
// {/* </div> */}
|
|
247
|
-
// </th>
|
|
248
|
-
// )
|
|
249
|
-
// }
|
|
250
|
-
|
|
251
214
|
return /*#__PURE__*/_react.default.createElement("th", {
|
|
252
215
|
// ref={setNodeRef}
|
|
253
216
|
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
254
217
|
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
255
218
|
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
256
|
-
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
257
|
-
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
219
|
+
// [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
220
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
221
|
+
[`${prefix}-grid-cell-text-center`]: originalColumn?.headerTextAlign === 'center',
|
|
222
|
+
[`${prefix}-grid-cell-text-right`]: originalColumn?.headerTextAlign === 'right'
|
|
258
223
|
}),
|
|
224
|
+
colSpan: colSpan,
|
|
225
|
+
rowSpan: rowSpan,
|
|
259
226
|
key: header.id,
|
|
260
227
|
style: {
|
|
261
|
-
display: 'flex',
|
|
228
|
+
// display: 'flex',
|
|
262
229
|
width: header.getSize(),
|
|
230
|
+
minWidth: header.getSize(),
|
|
231
|
+
maxWidth: header.getSize(),
|
|
263
232
|
...(0, _utils.getCommonPinningStyles)(header.column),
|
|
264
233
|
...style
|
|
265
234
|
},
|
|
@@ -291,7 +260,7 @@ const TableHeadCell = props => {
|
|
|
291
260
|
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
292
261
|
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
293
262
|
})
|
|
294
|
-
}, cellContent)), !_constant.nonActionColumn.includes(header.id) && /*#__PURE__*/_react.default.createElement("span", {
|
|
263
|
+
}, cellContent)), !_constant.nonActionColumn.includes(header.column.id) && header.subHeaders.length < 2 && /*#__PURE__*/_react.default.createElement("span", {
|
|
295
264
|
className: "ui-rc-header-trigger"
|
|
296
265
|
}, header.column.getCanSort() && /*#__PURE__*/_react.default.createElement("div", {
|
|
297
266
|
style: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
1
|
+
import { type Column, type HeaderGroup, type Table } from '@tanstack/react-table';
|
|
2
|
+
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
interface TableHeadRowProps<T> {
|
|
5
5
|
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
@@ -10,7 +10,6 @@ interface TableHeadRowProps<T> {
|
|
|
10
10
|
table: Table<T>;
|
|
11
11
|
fixedLeftColumns: Column<T, unknown>[];
|
|
12
12
|
fixedRightColumns: Column<T, unknown>[];
|
|
13
|
-
rowHeaderVirtual: VirtualItem;
|
|
14
13
|
}
|
|
15
|
-
declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup,
|
|
14
|
+
declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, }: TableHeadRowProps<any>) => React.JSX.Element;
|
|
16
15
|
export default TableHeadRow;
|
|
@@ -6,93 +6,90 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _sortable = require("@dnd-kit/sortable");
|
|
9
|
+
var _reactTable = require("@tanstack/react-table");
|
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
|
10
11
|
var _useContext = require("../useContext");
|
|
11
12
|
var _TableHeadCell = _interopRequireDefault(require("./TableHeadCell"));
|
|
13
|
+
var _utils = require("../hook/utils");
|
|
12
14
|
// import type { Person } from "../../tanstack-table/makeData"
|
|
13
15
|
|
|
14
16
|
const TableHeadRow = ({
|
|
15
17
|
table,
|
|
16
18
|
columnVirtualizer,
|
|
17
19
|
rowHeaderVirtualizer,
|
|
18
|
-
headerGroup
|
|
19
|
-
virtualPaddingLeft,
|
|
20
|
-
virtualPaddingRight,
|
|
21
|
-
fixedLeftColumns,
|
|
22
|
-
fixedRightColumns,
|
|
23
|
-
rowHeaderVirtual
|
|
20
|
+
headerGroup
|
|
21
|
+
// virtualPaddingLeft,
|
|
22
|
+
// virtualPaddingRight,
|
|
23
|
+
// fixedLeftColumns,
|
|
24
|
+
// fixedRightColumns,
|
|
25
|
+
// rowHeaderVirtual
|
|
24
26
|
}) => {
|
|
25
27
|
const {
|
|
26
28
|
prefix
|
|
27
29
|
} = _react.default.useContext(_useContext.TableContext);
|
|
28
|
-
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
29
|
-
// const virtualColumns = columnVirtualizer.measurementsCache
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// const virtualColumns = columnVirtualizer.getVirtualItems()
|
|
32
|
+
// const virtualColumns = columnVirtualizer.measurementsCache
|
|
32
33
|
|
|
33
34
|
const columnOrder = table.getState().columnOrder;
|
|
34
35
|
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
35
|
-
key: headerGroup.id
|
|
36
|
-
ref
|
|
37
|
-
|
|
38
|
-
}
|
|
36
|
+
key: headerGroup.id
|
|
37
|
+
// ref={el => {
|
|
38
|
+
// if (el) rowHeaderVirtualizer.measureElement(el)
|
|
39
|
+
// }}
|
|
39
40
|
// data-index={rowHeaderVirtual?.index}
|
|
40
41
|
,
|
|
41
42
|
"data-index": headerGroup.id,
|
|
42
43
|
className: `${prefix}-grid-row`,
|
|
43
44
|
style: {
|
|
44
|
-
display: 'flex',
|
|
45
|
-
width: '100%'
|
|
46
|
-
minHeight: rowHeaderVirtual?.size
|
|
45
|
+
// display: 'flex',
|
|
46
|
+
width: '100%'
|
|
47
|
+
// minHeight: rowHeaderVirtual?.size
|
|
47
48
|
}
|
|
48
49
|
}, /*#__PURE__*/_react.default.createElement(_sortable.SortableContext, {
|
|
49
50
|
items: columnOrder,
|
|
50
51
|
strategy: _sortable.horizontalListSortingStrategy
|
|
51
|
-
},
|
|
52
|
+
}, headerGroup.headers.map(header => {
|
|
53
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
54
|
+
if (columnRelativeDepth > 1) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let rowSpan = 1;
|
|
58
|
+
if (header.isPlaceholder) {
|
|
59
|
+
const leafs = header.getLeafHeaders();
|
|
60
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
61
|
+
}
|
|
52
62
|
return /*#__PURE__*/_react.default.createElement(_TableHeadCell.default, {
|
|
63
|
+
key: header.id,
|
|
64
|
+
header: header,
|
|
65
|
+
table: table,
|
|
53
66
|
columnVirtualizer: columnVirtualizer,
|
|
54
67
|
rowHeaderVirtualizer: rowHeaderVirtualizer,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
header: headerGroup.headers.find(h => h.column.id === column.id)
|
|
58
|
-
// column={column as any}
|
|
68
|
+
colSpan: header.colSpan,
|
|
69
|
+
rowSpan: rowSpan
|
|
59
70
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
table: table,
|
|
84
|
-
key: column.id,
|
|
85
|
-
header: headerGroup.headers.find(h => h.column.id === column.id)
|
|
86
|
-
// column={column as any}
|
|
87
|
-
})) : null, virtualPaddingRight ?
|
|
88
|
-
/*#__PURE__*/
|
|
89
|
-
//fake empty column to the right for virtualization scroll padding
|
|
90
|
-
_react.default.createElement("th", {
|
|
91
|
-
className: "nnnnnnnnnnnn",
|
|
92
|
-
style: {
|
|
93
|
-
display: 'flex',
|
|
94
|
-
width: virtualPaddingRight
|
|
95
|
-
}
|
|
96
|
-
}) : null));
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("th", {
|
|
72
|
+
key: header.id,
|
|
73
|
+
colSpan: header.colSpan,
|
|
74
|
+
rowSpan: rowSpan,
|
|
75
|
+
style: {
|
|
76
|
+
padding: '12px',
|
|
77
|
+
textAlign: 'left',
|
|
78
|
+
fontSize: '0.75rem',
|
|
79
|
+
fontWeight: 'medium',
|
|
80
|
+
color: '#6b7280',
|
|
81
|
+
textTransform: 'uppercase',
|
|
82
|
+
letterSpacing: '0.05em',
|
|
83
|
+
// backgroundColor: '#f9fafb',
|
|
84
|
+
// border: '1px solid #e5e7eb',
|
|
85
|
+
borderLeft: 0,
|
|
86
|
+
width: header.getSize(),
|
|
87
|
+
minWidth: header.getSize(),
|
|
88
|
+
maxWidth: header.getSize(),
|
|
89
|
+
// overflow: 'hidden',
|
|
90
|
+
...(0, _utils.getCommonPinningStyles)(header.column)
|
|
91
|
+
}
|
|
92
|
+
}, (0, _reactTable.flexRender)(header.column.columnDef.header, header.getContext()));
|
|
93
|
+
})));
|
|
97
94
|
};
|
|
98
95
|
var _default = exports.default = TableHeadRow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertColumns(columns: any[]): any[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertColumns = convertColumns;
|
|
7
|
+
var _reactTable = require("@tanstack/react-table");
|
|
8
|
+
const columnHelper = (0, _reactTable.createColumnHelper)();
|
|
9
|
+
function convertColumns(columns) {
|
|
10
|
+
return columns.map(col => {
|
|
11
|
+
if (col.columns) {
|
|
12
|
+
// Group column
|
|
13
|
+
return columnHelper.group({
|
|
14
|
+
...col,
|
|
15
|
+
columns: convertColumns(col.columns) // đệ quy
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
// Accessor column
|
|
19
|
+
let accessor;
|
|
20
|
+
|
|
21
|
+
// Ưu tiên accessorKey nếu có, nếu không thì dùng hàm row => row[col.id]
|
|
22
|
+
if (col.accessorKey) {
|
|
23
|
+
accessor = col.accessorKey;
|
|
24
|
+
} else if (col.id) {
|
|
25
|
+
accessor = row => row[col.id];
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error('Column không có accessorKey hoặc id');
|
|
28
|
+
}
|
|
29
|
+
return columnHelper.accessor(accessor, {
|
|
30
|
+
...col
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -91,6 +91,9 @@ const getCommonPinningStyles = column => {
|
|
|
91
91
|
position: isPinned ? "sticky" : "relative",
|
|
92
92
|
width: column.getSize(),
|
|
93
93
|
zIndex: isPinned ? 2 : 0
|
|
94
|
+
// border: '1px solid #e5e7eb',
|
|
95
|
+
// borderTop: 0,
|
|
96
|
+
// borderBottom: 0
|
|
94
97
|
};
|
|
95
98
|
};
|
|
96
99
|
exports.getCommonPinningStyles = getCommonPinningStyles;
|