es-grid-template 1.7.24 → 1.7.26
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/ColumnsChoose.d.ts +6 -3
- package/es/table-component/ColumnsChoose.js +31 -382
- package/es/table-component/InternalTable.js +32 -19
- package/es/table-component/TableContainer.d.ts +11 -2
- package/es/table-component/TableContainer.js +134 -14
- package/es/table-component/TableContainerEdit.d.ts +10 -7
- package/es/table-component/TableContainerEdit.js +158 -65
- package/es/table-component/body/EditableCell.js +14 -11
- package/es/table-component/body/TableBody.d.ts +2 -1
- package/es/table-component/body/TableBody.js +25 -6
- package/es/table-component/body/TableBodyCell.d.ts +2 -0
- package/es/table-component/body/TableBodyCell.js +13 -3
- package/es/table-component/body/TableBodyCellEdit.d.ts +2 -1
- package/es/table-component/body/TableBodyCellEdit.js +159 -34
- package/es/table-component/body/TableBodyRow.js +9 -4
- package/es/table-component/components/ControlCheckbox.js +0 -3
- package/es/table-component/components/async-table-select/index.d.ts +1 -1
- package/es/table-component/components/async-table-select/index.js +1 -0
- package/es/table-component/components/command/Command.d.ts +1 -0
- package/es/table-component/components/command/Command.js +6 -1
- package/es/table-component/footer/TableFooterCell.js +45 -3
- package/es/table-component/footer/TableFooterRow.js +3 -1
- package/es/table-component/header/TableHeadCell.js +31 -12
- package/es/table-component/header/TableHeadRow.js +5 -1
- package/es/table-component/hook/useColumns.d.ts +5 -7
- package/es/table-component/hook/useColumns.js +18 -58
- package/es/table-component/hook/utils.d.ts +12 -0
- package/es/table-component/hook/utils.js +140 -2
- package/es/table-component/style.scss +72 -7
- package/es/table-component/table/Grid.d.ts +3 -2
- package/es/table-component/table/Grid.js +25 -100
- package/es/table-component/type.d.ts +34 -3
- package/es/table-component/useContext.d.ts +5 -50
- package/es/table-component/useContext.js +3 -49
- package/lib/table-component/ColumnsChoose.d.ts +6 -3
- package/lib/table-component/ColumnsChoose.js +29 -381
- package/lib/table-component/InternalTable.js +30 -16
- package/lib/table-component/TableContainer.d.ts +11 -2
- package/lib/table-component/TableContainer.js +135 -14
- package/lib/table-component/TableContainerEdit.d.ts +10 -7
- package/lib/table-component/TableContainerEdit.js +157 -64
- package/lib/table-component/body/EditableCell.js +14 -11
- package/lib/table-component/body/TableBody.d.ts +2 -1
- package/lib/table-component/body/TableBody.js +27 -6
- package/lib/table-component/body/TableBodyCell.d.ts +2 -0
- package/lib/table-component/body/TableBodyCell.js +13 -3
- package/lib/table-component/body/TableBodyCellEdit.d.ts +2 -1
- package/lib/table-component/body/TableBodyCellEdit.js +159 -34
- package/lib/table-component/body/TableBodyRow.js +9 -4
- package/lib/table-component/components/ControlCheckbox.js +0 -3
- package/lib/table-component/components/async-table-select/index.d.ts +1 -1
- package/lib/table-component/components/async-table-select/index.js +2 -0
- package/lib/table-component/components/command/Command.d.ts +1 -0
- package/lib/table-component/components/command/Command.js +6 -1
- package/lib/table-component/footer/TableFooterCell.js +46 -2
- package/lib/table-component/footer/TableFooterRow.js +3 -1
- package/lib/table-component/header/TableHeadCell.js +31 -12
- package/lib/table-component/header/TableHeadRow.js +5 -1
- package/lib/table-component/hook/useColumns.d.ts +5 -7
- package/lib/table-component/hook/useColumns.js +17 -57
- package/lib/table-component/hook/utils.d.ts +12 -0
- package/lib/table-component/hook/utils.js +156 -9
- package/lib/table-component/style.scss +72 -7
- package/lib/table-component/table/Grid.d.ts +3 -2
- package/lib/table-component/table/Grid.js +24 -100
- package/lib/table-component/type.d.ts +34 -3
- package/lib/table-component/useContext.d.ts +5 -50
- package/lib/table-component/useContext.js +4 -50
- package/package.json +2 -2
- package/es/table-component/table/GridEdit.d.ts +0 -23
- package/es/table-component/table/GridEdit.js +0 -282
- package/lib/table-component/table/GridEdit.d.ts +0 -23
- package/lib/table-component/table/GridEdit.js +0 -284
|
@@ -14,6 +14,7 @@ var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkb
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _useContext = require("../useContext");
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
17
18
|
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); }
|
|
18
19
|
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; }
|
|
19
20
|
const renderCellIndex = props => {
|
|
@@ -28,7 +29,8 @@ const renderCellIndex = props => {
|
|
|
28
29
|
const renderCommand = args => {
|
|
29
30
|
const {
|
|
30
31
|
cell,
|
|
31
|
-
commandClick
|
|
32
|
+
commandClick,
|
|
33
|
+
id
|
|
32
34
|
} = args;
|
|
33
35
|
const col = cell.column.columnDef.meta ?? {};
|
|
34
36
|
const record = cell.row.original;
|
|
@@ -43,6 +45,7 @@ const renderCommand = args => {
|
|
|
43
45
|
}) : [];
|
|
44
46
|
return /*#__PURE__*/_react.default.createElement(_space.default, null, commands.filter(it => it.visible !== false).map(item => {
|
|
45
47
|
return /*#__PURE__*/_react.default.createElement(_Command.default, {
|
|
48
|
+
id: id,
|
|
46
49
|
key: item.id,
|
|
47
50
|
item: item,
|
|
48
51
|
record: record,
|
|
@@ -101,12 +104,16 @@ const TableBodyCell = props => {
|
|
|
101
104
|
const {
|
|
102
105
|
prefix,
|
|
103
106
|
setIsSelectionChange,
|
|
104
|
-
selectionSettings
|
|
107
|
+
selectionSettings,
|
|
108
|
+
id
|
|
105
109
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
106
110
|
const parrents = cell.row.getParentRows();
|
|
107
111
|
const isPinned = cell.column.getIsPinned();
|
|
108
112
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
109
113
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
114
|
+
const cellContent = (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
115
|
+
const html = _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cellContent));
|
|
116
|
+
const hasValue = html.trim().length > 0;
|
|
110
117
|
return /*#__PURE__*/_react.default.createElement("td", {
|
|
111
118
|
key: cell.id,
|
|
112
119
|
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
@@ -119,6 +126,8 @@ const TableBodyCell = props => {
|
|
|
119
126
|
width: cell.column.getSize(),
|
|
120
127
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
121
128
|
},
|
|
129
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
130
|
+
"data-tooltip-html": !hasValue ? '' : _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cellContent)),
|
|
122
131
|
onClick: event => {
|
|
123
132
|
const element = event.target;
|
|
124
133
|
const container = document.querySelector(".ui-rc-table-row-expand");
|
|
@@ -137,7 +146,8 @@ const TableBodyCell = props => {
|
|
|
137
146
|
cell
|
|
138
147
|
}), cell.column.id === "command" && renderCommand({
|
|
139
148
|
cell,
|
|
140
|
-
commandClick
|
|
149
|
+
commandClick,
|
|
150
|
+
id
|
|
141
151
|
}), cell.column.id === "selection_column" && renderSelection({
|
|
142
152
|
cell,
|
|
143
153
|
table,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Cell, Table } from "@tanstack/react-table";
|
|
2
2
|
import type { CommandClick } from "../type";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
4
|
+
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
interface TableBodyCellProps<T> {
|
|
6
6
|
table: Table<T>;
|
|
7
7
|
rowVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
|
|
@@ -9,6 +9,7 @@ interface TableBodyCellProps<T> {
|
|
|
9
9
|
tableId: string;
|
|
10
10
|
cell: Cell<T, unknown>;
|
|
11
11
|
commandClick?: (args: CommandClick) => void;
|
|
12
|
+
virtualRow: VirtualItem;
|
|
12
13
|
[key: string]: any;
|
|
13
14
|
}
|
|
14
15
|
declare const TableBodyCellEdit: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
@@ -15,6 +15,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
var _useContext = require("../useContext");
|
|
16
16
|
var _EditableCell = _interopRequireDefault(require("./EditableCell"));
|
|
17
17
|
var _constant = require("../hook/constant");
|
|
18
|
+
// import ReactDOMServer from 'react-dom/server'
|
|
19
|
+
|
|
18
20
|
// import { nonActionColumn } from "../hook/constant";
|
|
19
21
|
|
|
20
22
|
// import type { Dispatch, SetStateAction } from "react";
|
|
@@ -33,7 +35,8 @@ const renderCellIndex = props => {
|
|
|
33
35
|
const renderCommand = args => {
|
|
34
36
|
const {
|
|
35
37
|
cell,
|
|
36
|
-
commandClick
|
|
38
|
+
commandClick,
|
|
39
|
+
id
|
|
37
40
|
} = args;
|
|
38
41
|
const col = cell.column.columnDef.meta ?? {};
|
|
39
42
|
const record = cell.row.original;
|
|
@@ -48,6 +51,7 @@ const renderCommand = args => {
|
|
|
48
51
|
}) : [];
|
|
49
52
|
return /*#__PURE__*/_react.default.createElement(_space.default, null, commands.filter(it => it.visible !== false).map(item => {
|
|
50
53
|
return /*#__PURE__*/_react.default.createElement(_Command.default, {
|
|
54
|
+
id: id,
|
|
51
55
|
key: item.id,
|
|
52
56
|
item: item,
|
|
53
57
|
record: record,
|
|
@@ -88,8 +92,10 @@ const TableBodyCellEdit = props => {
|
|
|
88
92
|
isEditing,
|
|
89
93
|
columnVirtualizer,
|
|
90
94
|
rowVirtualizer
|
|
95
|
+
// virtualRow
|
|
91
96
|
} = props;
|
|
92
97
|
const {
|
|
98
|
+
id,
|
|
93
99
|
rowKey,
|
|
94
100
|
editingKey,
|
|
95
101
|
prefix,
|
|
@@ -117,18 +123,28 @@ const TableBodyCellEdit = props => {
|
|
|
117
123
|
handleDeleteContent,
|
|
118
124
|
reset,
|
|
119
125
|
setValue,
|
|
120
|
-
handleAddMulti
|
|
121
|
-
|
|
126
|
+
handleAddMulti,
|
|
127
|
+
dataErrors,
|
|
128
|
+
expanded,
|
|
129
|
+
setExpanded,
|
|
130
|
+
expandable
|
|
122
131
|
} = _react.default.useContext(_useContext.TableContext);
|
|
132
|
+
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
133
|
+
const record = cell.row.original;
|
|
134
|
+
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
123
135
|
|
|
124
|
-
// const
|
|
136
|
+
// const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
137
|
+
// const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
|
|
138
|
+
// const hasValue = html.trim().length > 0;
|
|
139
|
+
|
|
140
|
+
const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
|
|
141
|
+
// const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined
|
|
125
142
|
|
|
126
|
-
const record = cell.row.original;
|
|
127
143
|
const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record);
|
|
128
144
|
// const allRows = table.getRowModel().rows;
|
|
129
145
|
const allRows = table.getRowModel().flatRows;
|
|
130
146
|
|
|
131
|
-
// const rowNumber =
|
|
147
|
+
// const rowNumber = virtualRow.index
|
|
132
148
|
const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
|
|
133
149
|
const colIndex = cell.column.getIndex();
|
|
134
150
|
const isPinned = cell.column.getIsPinned();
|
|
@@ -140,7 +156,6 @@ const TableBodyCellEdit = props => {
|
|
|
140
156
|
const colIds = (0, _utils.getColIdsBetween)(table, startCell.colId, endCell.colId);
|
|
141
157
|
return rowIds.includes(cell.row.id) && colIds.includes(cell.column.id);
|
|
142
158
|
}, [cell.column.id, cell.row.id, endCell, startCell, table]);
|
|
143
|
-
const columnMeta = cell.column.columnDef.meta ?? {};
|
|
144
159
|
const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
|
|
145
160
|
const {
|
|
146
161
|
rowRange,
|
|
@@ -185,7 +200,40 @@ const TableBodyCellEdit = props => {
|
|
|
185
200
|
width: cell.column.getSize(),
|
|
186
201
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
187
202
|
}
|
|
188
|
-
},
|
|
203
|
+
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
|
|
204
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
205
|
+
style: {
|
|
206
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
207
|
+
}
|
|
208
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
209
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
210
|
+
onClick: () => {
|
|
211
|
+
const keys = Object.keys(expanded);
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
const tmp = {
|
|
214
|
+
...expanded
|
|
215
|
+
};
|
|
216
|
+
if (keys.includes(cell.row.id)) {
|
|
217
|
+
delete tmp[cell.row.id];
|
|
218
|
+
setExpanded(tmp);
|
|
219
|
+
} else {
|
|
220
|
+
setExpanded(old => ({
|
|
221
|
+
...old,
|
|
222
|
+
[cell.row.id]: true
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
style: {
|
|
227
|
+
cursor: "pointer"
|
|
228
|
+
},
|
|
229
|
+
className: "ui-rc-table-row-expand"
|
|
230
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
231
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
232
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
233
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
234
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
235
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
236
|
+
}))), renderCellIndex({
|
|
189
237
|
parrents,
|
|
190
238
|
cell
|
|
191
239
|
}));
|
|
@@ -206,7 +254,8 @@ const TableBodyCellEdit = props => {
|
|
|
206
254
|
}
|
|
207
255
|
}, renderCommand({
|
|
208
256
|
cell,
|
|
209
|
-
commandClick
|
|
257
|
+
commandClick,
|
|
258
|
+
id
|
|
210
259
|
}));
|
|
211
260
|
}
|
|
212
261
|
if (cell.column.id === "selection_column") {
|
|
@@ -223,7 +272,40 @@ const TableBodyCellEdit = props => {
|
|
|
223
272
|
width: cell.column.getSize(),
|
|
224
273
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
225
274
|
}
|
|
226
|
-
},
|
|
275
|
+
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
|
|
276
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
277
|
+
style: {
|
|
278
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
279
|
+
}
|
|
280
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
281
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
282
|
+
onClick: () => {
|
|
283
|
+
const keys = Object.keys(expanded);
|
|
284
|
+
// @ts-ignore
|
|
285
|
+
const tmp = {
|
|
286
|
+
...expanded
|
|
287
|
+
};
|
|
288
|
+
if (keys.includes(cell.row.id)) {
|
|
289
|
+
delete tmp[cell.row.id];
|
|
290
|
+
setExpanded(tmp);
|
|
291
|
+
} else {
|
|
292
|
+
setExpanded(old => ({
|
|
293
|
+
...old,
|
|
294
|
+
[cell.row.id]: true
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
style: {
|
|
299
|
+
cursor: "pointer"
|
|
300
|
+
},
|
|
301
|
+
className: "ui-rc-table-row-expand"
|
|
302
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
303
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
304
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
305
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
306
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
307
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
308
|
+
}))), renderSelection({
|
|
227
309
|
cell
|
|
228
310
|
}));
|
|
229
311
|
}
|
|
@@ -278,10 +360,13 @@ const TableBodyCellEdit = props => {
|
|
|
278
360
|
return;
|
|
279
361
|
}
|
|
280
362
|
const columnKey = tmpCols[targetCol].id;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
[
|
|
284
|
-
|
|
363
|
+
const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
|
|
364
|
+
if (!disable) {
|
|
365
|
+
newData[targetRow] = {
|
|
366
|
+
...newData[targetRow],
|
|
367
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
368
|
+
};
|
|
369
|
+
}
|
|
285
370
|
});
|
|
286
371
|
|
|
287
372
|
// Lưu dòng được paste
|
|
@@ -356,7 +441,8 @@ const TableBodyCellEdit = props => {
|
|
|
356
441
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
357
442
|
};
|
|
358
443
|
function handleMouseDown(rowId, colId) {
|
|
359
|
-
|
|
444
|
+
setIsSelecting?.(true);
|
|
445
|
+
if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
360
446
|
setStartCell?.({
|
|
361
447
|
rowId,
|
|
362
448
|
colId
|
|
@@ -365,7 +451,6 @@ const TableBodyCellEdit = props => {
|
|
|
365
451
|
rowId,
|
|
366
452
|
colId
|
|
367
453
|
});
|
|
368
|
-
setIsSelecting?.(true);
|
|
369
454
|
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
370
455
|
rowId,
|
|
371
456
|
colId
|
|
@@ -462,12 +547,10 @@ const TableBodyCellEdit = props => {
|
|
|
462
547
|
triggerDragPaste(selectPasteState, e.ctrlKey);
|
|
463
548
|
} else {
|
|
464
549
|
// if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
|
|
465
|
-
// console.log('fffffffffffff')
|
|
466
550
|
// setRangeState?.(selectState)
|
|
467
551
|
// }
|
|
468
552
|
|
|
469
553
|
if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
|
|
470
|
-
console.log('dfdfghh');
|
|
471
554
|
setRangeState?.(selectState);
|
|
472
555
|
}
|
|
473
556
|
}
|
|
@@ -663,10 +746,16 @@ const TableBodyCellEdit = props => {
|
|
|
663
746
|
"data-col-index": colIndex,
|
|
664
747
|
"data-row-index": rowNumber,
|
|
665
748
|
"data-col-key": cell.column.id,
|
|
666
|
-
"data-row-key": cell.row.id
|
|
749
|
+
"data-row-key": cell.row.id
|
|
750
|
+
// data-tooltip-id={`${id}-tooltip-content`}
|
|
751
|
+
// data-tooltip-html={!isEditing && !hasValue && !message ? undefined : ReactDOMServer.renderToStaticMarkup(<>{rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent}</>)}
|
|
752
|
+
,
|
|
753
|
+
|
|
667
754
|
className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable `, {
|
|
668
755
|
[`${prefix}-grid-cell-ellipsis`]: true,
|
|
669
756
|
'cell-editing': isEditing,
|
|
757
|
+
disable: !(0, _utils.isEditable)(cell.column.columnDef.meta, record),
|
|
758
|
+
isValid: !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id,
|
|
670
759
|
[`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
671
760
|
'cell-border-bottom': !isEditing && isInRange && isBottom,
|
|
672
761
|
'cell-border-right': !isEditing && isInRange && isRight,
|
|
@@ -685,23 +774,25 @@ const TableBodyCellEdit = props => {
|
|
|
685
774
|
height: '36px',
|
|
686
775
|
...(0, _utils.getCommonPinningStyles)(cell.column),
|
|
687
776
|
cursor: isPasting ? 'crosshair' : undefined
|
|
688
|
-
// background: isCellSelected ? '#d0e6ff' : undefined,
|
|
689
|
-
|
|
690
|
-
// outline: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? '1px solid blue' : undefined,
|
|
691
777
|
},
|
|
692
778
|
onMouseDown: () => {
|
|
693
|
-
if (record[rowKey] === editingKey) {
|
|
779
|
+
if (record[rowKey] === editingKey) {
|
|
780
|
+
setFocusedCell?.({
|
|
781
|
+
rowId: cell.row.id,
|
|
782
|
+
colId: cell.column.id
|
|
783
|
+
});
|
|
784
|
+
} else {
|
|
694
785
|
handleMouseDown(cell.row.id, cell.column.id);
|
|
695
786
|
}
|
|
696
787
|
if (record[rowKey] !== editingKey) {
|
|
697
788
|
setTimeout(() => {
|
|
698
789
|
setEditingKey?.('');
|
|
790
|
+
reset?.();
|
|
699
791
|
});
|
|
700
792
|
}
|
|
701
793
|
},
|
|
702
794
|
onMouseEnter: () => handleMouseEnter(cell.row.id, cell.column.id),
|
|
703
795
|
onMouseUp: e => handleMouseUp(e),
|
|
704
|
-
onMouseMove: () => {},
|
|
705
796
|
onKeyDown: e => {
|
|
706
797
|
if (!isEditing) {
|
|
707
798
|
handleKeyDown(e, cell.row.id, cell.column.id);
|
|
@@ -713,6 +804,7 @@ const TableBodyCellEdit = props => {
|
|
|
713
804
|
e.preventDefault();
|
|
714
805
|
e.stopPropagation();
|
|
715
806
|
setEditingKey?.('');
|
|
807
|
+
reset?.();
|
|
716
808
|
const currentRowIndex = allRows.findIndex(r => r.id === cell.row.id);
|
|
717
809
|
const nextRow = allRows[currentRowIndex + 1];
|
|
718
810
|
if (nextRow) {
|
|
@@ -781,18 +873,10 @@ const TableBodyCellEdit = props => {
|
|
|
781
873
|
}
|
|
782
874
|
},
|
|
783
875
|
onDoubleClick: e => {
|
|
784
|
-
console.log('e', e);
|
|
785
876
|
if (!(record[rowKey] === editingKey && canEdit)) {
|
|
786
877
|
handleEdit(e);
|
|
787
878
|
}
|
|
788
879
|
}
|
|
789
|
-
|
|
790
|
-
// onClick={() => {
|
|
791
|
-
// // if (focusedCell?.rowId !== cell.row.id && focusedCell?.colId !== cell.column.id) {
|
|
792
|
-
// // setFocusedCell({ rowId: cell.row.id, colId: cell.column.id })
|
|
793
|
-
// // }
|
|
794
|
-
|
|
795
|
-
// }}
|
|
796
880
|
}, isEditing && canEdit ? /*#__PURE__*/_react.default.createElement(_EditableCell.default, {
|
|
797
881
|
cellEditing: {},
|
|
798
882
|
column: cell.column.columnDef.meta,
|
|
@@ -803,8 +887,49 @@ const TableBodyCellEdit = props => {
|
|
|
803
887
|
record: record
|
|
804
888
|
// rowKey={rowKey}
|
|
805
889
|
}) : /*#__PURE__*/_react.default.createElement("div", {
|
|
806
|
-
className:
|
|
807
|
-
|
|
890
|
+
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
891
|
+
'select-cell': ['select', 'selectTable', 'asyncSelect'].includes((0, _utils.getEditType)(columnMeta, record))
|
|
892
|
+
})
|
|
893
|
+
}, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
|
|
894
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
895
|
+
style: {
|
|
896
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
897
|
+
}
|
|
898
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
899
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
900
|
+
onClick: () => {
|
|
901
|
+
const keys = Object.keys(expanded);
|
|
902
|
+
// @ts-ignore
|
|
903
|
+
const tmp = {
|
|
904
|
+
...expanded
|
|
905
|
+
};
|
|
906
|
+
if (keys.includes(cell.row.id)) {
|
|
907
|
+
delete tmp[cell.row.id];
|
|
908
|
+
setExpanded(tmp);
|
|
909
|
+
} else {
|
|
910
|
+
setExpanded(old => ({
|
|
911
|
+
...old,
|
|
912
|
+
[cell.row.id]: true
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
style: {
|
|
917
|
+
cursor: "pointer"
|
|
918
|
+
},
|
|
919
|
+
className: "ui-rc-table-row-expand"
|
|
920
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
921
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
922
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
923
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
924
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
925
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
926
|
+
}))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext()), (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/_react.default.createElement("span", {
|
|
927
|
+
className: 'caret-down',
|
|
928
|
+
onClick: e => {
|
|
929
|
+
handleEdit(e);
|
|
930
|
+
// setEditingKey?.(cell.row.id)
|
|
931
|
+
}
|
|
932
|
+
})), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
|
|
808
933
|
className: 'dragging-point',
|
|
809
934
|
onMouseDown: e => {
|
|
810
935
|
e.preventDefault();
|
|
@@ -83,6 +83,7 @@ const TableBodyRow = ({
|
|
|
83
83
|
key: cell.id,
|
|
84
84
|
cell: cell,
|
|
85
85
|
commandClick: commandClick,
|
|
86
|
+
virtualRow: virtualRow,
|
|
86
87
|
isEditing: isEditing,
|
|
87
88
|
rowVirtualizer: rowVirtualizer,
|
|
88
89
|
columnVirtualizer: columnVirtualizer
|
|
@@ -92,7 +93,8 @@ const TableBodyRow = ({
|
|
|
92
93
|
key: column.id,
|
|
93
94
|
table: table,
|
|
94
95
|
cell: row.getVisibleCells().find(c => c.column.id === column.id),
|
|
95
|
-
commandClick: commandClick
|
|
96
|
+
commandClick: commandClick,
|
|
97
|
+
virtualRow: virtualRow
|
|
96
98
|
});
|
|
97
99
|
}) : null, virtualPaddingLeft ? /*#__PURE__*/_react.default.createElement("td", {
|
|
98
100
|
className: "",
|
|
@@ -113,14 +115,16 @@ const TableBodyRow = ({
|
|
|
113
115
|
commandClick: commandClick,
|
|
114
116
|
isEditing: isEditing,
|
|
115
117
|
rowVirtualizer: rowVirtualizer,
|
|
116
|
-
columnVirtualizer: columnVirtualizer
|
|
118
|
+
columnVirtualizer: columnVirtualizer,
|
|
119
|
+
virtualRow: virtualRow
|
|
117
120
|
}));
|
|
118
121
|
}
|
|
119
122
|
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, {
|
|
120
123
|
table: table,
|
|
121
124
|
key: cell.id,
|
|
122
125
|
cell: cell,
|
|
123
|
-
commandClick: commandClick
|
|
126
|
+
commandClick: commandClick,
|
|
127
|
+
virtualRow: virtualRow
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
130
|
}), fixedRightColumns.length > 0 ? fixedRightColumns.map(column => {
|
|
@@ -133,7 +137,8 @@ const TableBodyRow = ({
|
|
|
133
137
|
commandClick: commandClick,
|
|
134
138
|
isEditing: isEditing,
|
|
135
139
|
rowVirtualizer: rowVirtualizer,
|
|
136
|
-
columnVirtualizer: columnVirtualizer
|
|
140
|
+
columnVirtualizer: columnVirtualizer,
|
|
141
|
+
virtualRow: virtualRow
|
|
137
142
|
}));
|
|
138
143
|
}
|
|
139
144
|
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, {
|
|
@@ -24,9 +24,6 @@ const ControlCheckbox = props => {
|
|
|
24
24
|
handleCellChange,
|
|
25
25
|
rowKey
|
|
26
26
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
27
|
-
|
|
28
|
-
// const isEdit = getEditType(column, record)
|
|
29
|
-
|
|
30
27
|
const isEdit = _react.default.useMemo(() => {
|
|
31
28
|
return (0, _utils.isEditable)(column, record);
|
|
32
29
|
}, [column, record]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
|
-
import type { TableSelectProps } from "rc-master-ui
|
|
3
|
+
import type { TableSelectProps } from "rc-master-ui";
|
|
4
4
|
import type { LoadOptionsArgs } from '../../type';
|
|
5
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
6
6
|
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
@@ -11,6 +11,8 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
|
11
11
|
var _rcMasterUi = require("rc-master-ui");
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
// import type {TableSelectProps} from "rc-master-ui/es/table-select"
|
|
15
|
+
|
|
14
16
|
// import type {LoadOptionsArgs} from "../type";
|
|
15
17
|
|
|
16
18
|
function AsyncTableSelect({
|
|
@@ -13,13 +13,18 @@ const Command = props => {
|
|
|
13
13
|
const {
|
|
14
14
|
item,
|
|
15
15
|
onClick,
|
|
16
|
-
record
|
|
16
|
+
record,
|
|
17
|
+
id
|
|
17
18
|
} = props;
|
|
18
19
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.template ? /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
21
|
+
"data-tooltip-content": item.tooltip || item.title,
|
|
19
22
|
id: item.id,
|
|
20
23
|
onClick: onClick
|
|
21
24
|
}, typeof item.template === 'function' ? item.template(record) : item.template) : /*#__PURE__*/_react.default.createElement("div", {
|
|
22
25
|
tabIndex: -1,
|
|
26
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
27
|
+
"data-tooltip-content": item.tooltip || item.title,
|
|
23
28
|
style: {
|
|
24
29
|
padding: '3px',
|
|
25
30
|
maxWidth: 45,
|
|
@@ -5,8 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _utils = require("../hook/utils");
|
|
10
|
+
var _useContext = require("../useContext");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _hooks = require("../../grid-component/hooks");
|
|
13
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
16
|
// import type { Person } from "../makeData";
|
|
11
17
|
|
|
12
18
|
// import type { Person } from "../../tanstack-table/makeData";
|
|
@@ -14,11 +20,49 @@ var _utils = require("../hook/utils");
|
|
|
14
20
|
const TableFooterCell = ({
|
|
15
21
|
header
|
|
16
22
|
}) => {
|
|
23
|
+
const isPinned = header.column.getIsPinned();
|
|
24
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
|
|
25
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
|
|
26
|
+
const {
|
|
27
|
+
prefix,
|
|
28
|
+
format,
|
|
29
|
+
dataSource
|
|
30
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
31
|
+
const col = header.column.columnDef.meta ?? {};
|
|
32
|
+
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
33
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
34
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
35
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
36
|
+
|
|
37
|
+
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
38
|
+
const dec = cellFormat?.decimalScale;
|
|
39
|
+
|
|
40
|
+
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
41
|
+
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)(dataSource, col?.field) : 0;
|
|
42
|
+
const value = !(0, _utils.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
43
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
44
|
+
const numberValue = Number(value);
|
|
45
|
+
const numericFormatProps = {
|
|
46
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
47
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
48
|
+
allowNegative: cellFormat?.allowNegative ?? false,
|
|
49
|
+
prefix: cellFormat?.prefix,
|
|
50
|
+
suffix: cellFormat?.suffix,
|
|
51
|
+
decimalScale: dec,
|
|
52
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
53
|
+
};
|
|
17
54
|
return /*#__PURE__*/_react.default.createElement("td", {
|
|
18
55
|
// ref={el => {
|
|
19
56
|
// if (el) columnVirtualizer.measureElement(el)
|
|
20
57
|
// }}
|
|
21
58
|
// data-index={header.id}
|
|
59
|
+
|
|
60
|
+
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
61
|
+
// [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
62
|
+
// [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
63
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
64
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
65
|
+
}),
|
|
22
66
|
key: header.id,
|
|
23
67
|
colSpan: header.colSpan,
|
|
24
68
|
style: {
|
|
@@ -27,6 +71,6 @@ const TableFooterCell = ({
|
|
|
27
71
|
width: header?.getSize() ?? header.column.getSize(),
|
|
28
72
|
backgroundColor: "#fafafa"
|
|
29
73
|
}
|
|
30
|
-
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement("span", null,
|
|
74
|
+
}, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement("span", null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps)) : '');
|
|
31
75
|
};
|
|
32
76
|
var _default = exports.default = TableFooterCell;
|
|
@@ -30,7 +30,9 @@ const TableFooterRow = ({
|
|
|
30
30
|
style: {
|
|
31
31
|
display: "flex",
|
|
32
32
|
width: "100%",
|
|
33
|
-
|
|
33
|
+
borderBottom: "1px solid #e0e0e0",
|
|
34
|
+
borderTop: "1px solid #e0e0e0",
|
|
35
|
+
height: 37
|
|
34
36
|
}
|
|
35
37
|
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
36
38
|
return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|