es-grid-template 1.9.53 → 1.9.56
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/ali-table/Grid.d.ts +1 -0
- package/es/ali-table/Grid.js +12 -4
- package/es/ali-table/InternalTable.js +39 -7
- package/es/ali-table/base-table/html-table-default.d.ts +20 -0
- package/es/ali-table/base-table/html-table-default.js +224 -0
- package/es/ali-table/base-table/html-table-new.d.ts +20 -0
- package/es/ali-table/base-table/html-table-new.js +417 -0
- package/es/ali-table/base-table/html-table.js +324 -182
- package/es/ali-table/base-table/styles.d.ts +1 -0
- package/es/ali-table/base-table/styles.js +5 -4
- package/es/ali-table/base-table/table.d.ts +4 -0
- package/es/ali-table/base-table/table.js +24 -5
- package/es/ali-table/pipeline/features/columnCustom.js +3 -3
- package/es/ali-table/pipeline/features/pagination.js +1 -1
- package/es/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/es/grid-component/control/InputControl/InputControl.js +2 -3
- package/es/grid-component/hooks/calender.d.ts +19 -0
- package/es/grid-component/hooks/calender.js +32 -0
- package/es/grid-component/type.d.ts +15 -2
- package/es/group-component/ColumnsChoose.js +1 -2
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +1 -2
- package/es/group-component/TableContainerEdit.js +3 -4
- package/es/group-component/body/EditableCell.js +7 -6
- package/es/group-component/body/TableBodyRow.js +15 -4
- package/es/group-component/components/EditForm/EditForm.js +1 -2
- package/es/group-component/components/InputControl/InputControl.js +1 -2
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +1 -2
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
- package/es/group-component/components/checkbox-filter/FilterSearch.js +0 -3
- package/es/group-component/header/TableHeadCell.js +1 -2
- package/es/group-component/header/TableHeadCell2.js +1 -2
- package/es/group-component/hook/utils.d.ts +4 -4
- package/es/group-component/table/Grid.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +1 -1
- package/es/table-component/ColumnsChoose.js +1 -1
- package/es/table-component/ColumnsConfig.d.ts +17 -0
- package/es/table-component/ColumnsConfig.js +303 -0
- package/es/table-component/ContextMenu.js +1 -1
- package/es/table-component/InternalTable.js +30 -9
- package/es/table-component/TableContainer.js +4 -2
- package/es/table-component/TableContainerEdit.js +18 -5
- package/es/table-component/body/EditableCell.js +104 -119
- package/es/table-component/body/TableBodyCellEdit.js +1 -1
- package/es/table-component/body/TableBodyRow.js +0 -5
- package/es/table-component/components/EditForm/EditForm.js +1 -4
- package/es/table-component/components/InputControl/InputControl.js +1 -1
- package/es/table-component/components/checkbox-filter/CheckboxFilter.js +1 -2
- package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
- package/es/table-component/components/checkbox-filter/FilterSearch.js +4 -2
- package/es/table-component/header/TableHeadCell.js +1 -1
- package/es/table-component/header/TableHeadCell2.js +1 -1
- package/es/table-component/header/TableHeadRow.js +6 -6
- package/es/table-component/hook/utils.d.ts +3 -3
- package/es/table-component/hook/utils.js +28 -4
- package/es/table-component/style.js +2 -2
- package/es/table-component/table/Grid.js +2 -1
- package/es/table-virtuoso/ColumnsGroup/ColumnsGroup.js +1 -1
- package/es/table-virtuoso/header/TableHeadCell.js +1 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -1
- package/es/table-virtuoso/table/Grid.js +1 -1
- package/es/table-virtuoso/table/TableContainer.js +1 -1
- package/es/table-virtuoso/table/TableWrapper.d.ts +1 -2
- package/es/table-virtuoso/table/TableWrapper.js +1 -0
- package/lib/ali-table/Grid.d.ts +1 -0
- package/lib/ali-table/Grid.js +12 -4
- package/lib/ali-table/InternalTable.js +39 -7
- package/lib/ali-table/base-table/html-table-default.d.ts +20 -0
- package/lib/ali-table/base-table/html-table-default.js +231 -0
- package/lib/ali-table/base-table/html-table-new.d.ts +20 -0
- package/lib/ali-table/base-table/html-table-new.js +424 -0
- package/lib/ali-table/base-table/html-table.js +324 -182
- package/lib/ali-table/base-table/styles.d.ts +1 -0
- package/lib/ali-table/base-table/styles.js +5 -4
- package/lib/ali-table/base-table/table.d.ts +4 -0
- package/lib/ali-table/base-table/table.js +24 -5
- package/lib/ali-table/pipeline/features/columnCustom.js +4 -4
- package/lib/ali-table/pipeline/features/pagination.js +1 -1
- package/lib/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/lib/grid-component/control/InputControl/InputControl.js +4 -6
- package/lib/grid-component/hooks/calender.d.ts +19 -0
- package/lib/grid-component/hooks/calender.js +40 -0
- package/lib/grid-component/type.d.ts +15 -2
- package/lib/group-component/ColumnsChoose.js +6 -7
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +3 -4
- package/lib/group-component/TableContainerEdit.js +4 -5
- package/lib/group-component/body/EditableCell.js +14 -13
- package/lib/group-component/body/TableBodyRow.js +15 -4
- package/lib/group-component/components/EditForm/EditForm.js +1 -2
- package/lib/group-component/components/InputControl/InputControl.js +4 -6
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +1 -2
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +0 -2
- package/lib/group-component/header/TableHeadCell.js +3 -4
- package/lib/group-component/header/TableHeadCell2.js +3 -4
- package/lib/group-component/hook/utils.d.ts +1 -1
- package/lib/group-component/table/Grid.js +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/table-component/ColumnsChoose.js +5 -5
- package/lib/table-component/ColumnsConfig.d.ts +17 -0
- package/lib/table-component/ColumnsConfig.js +313 -0
- package/lib/table-component/ContextMenu.js +3 -3
- package/lib/table-component/InternalTable.js +25 -8
- package/lib/table-component/TableContainer.js +4 -2
- package/lib/table-component/TableContainerEdit.js +20 -8
- package/lib/table-component/body/EditableCell.js +113 -129
- package/lib/table-component/body/TableBodyCellEdit.js +1 -1
- package/lib/table-component/body/TableBodyRow.js +0 -5
- package/lib/table-component/components/EditForm/EditForm.js +3 -6
- package/lib/table-component/components/InputControl/InputControl.js +1 -2
- package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +1 -2
- package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
- package/lib/table-component/components/checkbox-filter/FilterSearch.js +5 -2
- package/lib/table-component/header/TableHeadCell.js +4 -5
- package/lib/table-component/header/TableHeadCell2.js +2 -3
- package/lib/table-component/header/TableHeadRow.js +6 -6
- package/lib/table-component/hook/utils.d.ts +3 -3
- package/lib/table-component/hook/utils.js +28 -4
- package/lib/table-component/style.js +2 -2
- package/lib/table-component/table/Grid.js +3 -2
- package/lib/table-virtuoso/ColumnsGroup/ColumnsGroup.js +3 -4
- package/lib/table-virtuoso/header/TableHeadCell.js +4 -5
- package/lib/table-virtuoso/hook/utils.d.ts +1 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableContainer.js +1 -1
- package/lib/table-virtuoso/table/TableWrapper.d.ts +1 -2
- package/lib/table-virtuoso/table/TableWrapper.js +2 -0
- package/package.json +2 -3
- /package/es/{datepicker → datePicker}/index.d.ts +0 -0
- /package/es/{datepicker → datePicker}/index.js +0 -0
- /package/lib/{datepicker → datePicker}/index.d.ts +0 -0
- /package/lib/{datepicker → datePicker}/index.js +0 -0
package/es/ali-table/Grid.d.ts
CHANGED
package/es/ali-table/Grid.js
CHANGED
|
@@ -56,7 +56,8 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
56
56
|
useVirtual,
|
|
57
57
|
useOuterBorder = true,
|
|
58
58
|
showHeader = true,
|
|
59
|
-
gridLines
|
|
59
|
+
gridLines,
|
|
60
|
+
dataRowIds
|
|
60
61
|
} = props;
|
|
61
62
|
const {
|
|
62
63
|
cssVariables
|
|
@@ -163,16 +164,20 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
163
164
|
[`${prefix}-grid-line-horizontal`]: gridLines === 'Horizontal',
|
|
164
165
|
[`${prefix}-grid-line-vertical`]: gridLines === 'Vertical',
|
|
165
166
|
[`${prefix}-grid-line-none`]: gridLines === 'None',
|
|
166
|
-
[`use-outer-border`]: useOuterBorder
|
|
167
|
+
[`use-outer-border`]: useOuterBorder,
|
|
168
|
+
[`auto-height`]: !minHeight
|
|
169
|
+
// [`has-title`]: showToolbar !== false && ( fullScreen !== false || title || topToolbaritems.length > 0)
|
|
167
170
|
}),
|
|
168
171
|
style: {
|
|
169
|
-
maxHeight: height ?? 700,
|
|
172
|
+
// maxHeight: height ?? 700,
|
|
173
|
+
maxHeight: height ?? minHeight,
|
|
174
|
+
// height: height ?? minHeight,
|
|
170
175
|
minHeight,
|
|
171
176
|
display: 'flex',
|
|
172
177
|
flexDirection: 'column',
|
|
173
178
|
...artTableWrapperProps.style
|
|
174
179
|
}
|
|
175
|
-
},
|
|
180
|
+
}, showToolbar !== false && (fullScreen !== false || title || topToolbaritems.length > 0) && /*#__PURE__*/React.createElement("div", {
|
|
176
181
|
className: classNames(`${prefix}-grid-top`, {})
|
|
177
182
|
}, /*#__PURE__*/React.createElement("div", {
|
|
178
183
|
style: {
|
|
@@ -242,6 +247,8 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
242
247
|
isStickyHeader: true,
|
|
243
248
|
stickyBottom: 0,
|
|
244
249
|
stickyTop: 0,
|
|
250
|
+
isBottom: !!(bottom || pagination && !infiniteScroll),
|
|
251
|
+
isTitle: !!(showToolbar !== false && (fullScreen !== false || title || topToolbaritems.length > 0)),
|
|
245
252
|
defaultColumnWidth: 100,
|
|
246
253
|
originData: originData,
|
|
247
254
|
format: format
|
|
@@ -296,6 +303,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
296
303
|
};
|
|
297
304
|
},
|
|
298
305
|
theme: theme,
|
|
306
|
+
dataRowIds: dataRowIds,
|
|
299
307
|
footerDataSource: footerDataSource
|
|
300
308
|
})), (bottom || pagination && !infiniteScroll) && /*#__PURE__*/React.createElement("div", {
|
|
301
309
|
className: classNames(`${prefix}-grid-bottom`, {})
|
|
@@ -8,12 +8,14 @@ import "./base-table/styles.scss";
|
|
|
8
8
|
import { addRowIdArray, filterDataByColumns, flatColumns2,
|
|
9
9
|
// getInvisibleColumns,
|
|
10
10
|
getVisibleFields, groupArrayByColumns, isTreeArray, revertConvertFilters, sortByType, sumFields } from "../table-component/hook/utils";
|
|
11
|
-
import { CustomProvider, ConfigProvider } from 'rc-master-ui';
|
|
12
|
-
import { Modal } from 'antd';
|
|
11
|
+
import { CustomProvider, ConfigProvider, Modal } from 'rc-master-ui';
|
|
13
12
|
import { getLocale, getLocales } from "../locale/useLocale";
|
|
14
13
|
import { TableContext } from "./useContext";
|
|
15
14
|
import Grid from "./Grid";
|
|
16
15
|
import { getParentKeysLarge, getRowsByKeysKeepTreeOrder } from "./utils/selected";
|
|
16
|
+
import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
|
|
17
|
+
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
18
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
17
19
|
const InternalTable = props => {
|
|
18
20
|
const {
|
|
19
21
|
t,
|
|
@@ -42,6 +44,7 @@ const InternalTable = props => {
|
|
|
42
44
|
footerDataSource,
|
|
43
45
|
summary,
|
|
44
46
|
useVirtual,
|
|
47
|
+
rowDnd,
|
|
45
48
|
...rest
|
|
46
49
|
} = props;
|
|
47
50
|
const prefix = 'ui-rc';
|
|
@@ -81,8 +84,8 @@ const InternalTable = props => {
|
|
|
81
84
|
const [filterState, setFilterState] = React.useState(undefined);
|
|
82
85
|
const [sortState, setSortState] = React.useState(undefined);
|
|
83
86
|
const columns = React.useMemo(() => {
|
|
84
|
-
return sortByType(propColumns);
|
|
85
|
-
}, [propColumns]);
|
|
87
|
+
return sortByType(propColumns, rowDnd);
|
|
88
|
+
}, [propColumns, rowDnd]);
|
|
86
89
|
const convertData = React.useMemo(() => {
|
|
87
90
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
88
91
|
return groupArrayByColumns(dataSource, groupColumns);
|
|
@@ -128,6 +131,7 @@ const InternalTable = props => {
|
|
|
128
131
|
// return getInvisibleColumns(columns)
|
|
129
132
|
// }, [columns])
|
|
130
133
|
|
|
134
|
+
const dataIds = React.useMemo(() => mergedData.map(it => it.rowId), [mergedData]);
|
|
131
135
|
const columnVisibility = React.useMemo(() => {
|
|
132
136
|
return getVisibleFields(columns);
|
|
133
137
|
}, [columns]);
|
|
@@ -228,6 +232,27 @@ const InternalTable = props => {
|
|
|
228
232
|
|
|
229
233
|
// }
|
|
230
234
|
|
|
235
|
+
// reorder rows after drag & drop
|
|
236
|
+
function handleDragEnd(event) {
|
|
237
|
+
const {
|
|
238
|
+
active,
|
|
239
|
+
over
|
|
240
|
+
} = event;
|
|
241
|
+
if (over && active.id !== over.id) {
|
|
242
|
+
// data dạng phẳng
|
|
243
|
+
|
|
244
|
+
const oldIndex = dataIds.indexOf(active.id);
|
|
245
|
+
const newIndex = dataIds.indexOf(over.id);
|
|
246
|
+
const rs = arrayMove(mergedData, oldIndex, newIndex); // this is just a splice util
|
|
247
|
+
|
|
248
|
+
if (rowDnd?.onChange) {
|
|
249
|
+
rowDnd?.onChange({
|
|
250
|
+
rows: rs
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {}));
|
|
231
256
|
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
232
257
|
locale: language,
|
|
233
258
|
theme: {
|
|
@@ -286,6 +311,11 @@ const InternalTable = props => {
|
|
|
286
311
|
lang,
|
|
287
312
|
locale
|
|
288
313
|
}
|
|
314
|
+
}, /*#__PURE__*/React.createElement(DndContext, {
|
|
315
|
+
collisionDetection: closestCenter,
|
|
316
|
+
modifiers: [restrictToVerticalAxis],
|
|
317
|
+
onDragEnd: handleDragEnd,
|
|
318
|
+
sensors: sensors
|
|
289
319
|
}, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
290
320
|
id: id,
|
|
291
321
|
useVirtual: {
|
|
@@ -306,7 +336,8 @@ const InternalTable = props => {
|
|
|
306
336
|
onFilter: onFilter,
|
|
307
337
|
onSorter: onSorter,
|
|
308
338
|
defaultFilter: defaultFilter,
|
|
309
|
-
defaultSorter: defaultSorter
|
|
339
|
+
defaultSorter: defaultSorter,
|
|
340
|
+
dataRowIds: dataIds
|
|
310
341
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
311
342
|
open: isFullScreen,
|
|
312
343
|
footer: null,
|
|
@@ -356,7 +387,8 @@ const InternalTable = props => {
|
|
|
356
387
|
onFilter: onFilter,
|
|
357
388
|
onSorter: onSorter,
|
|
358
389
|
defaultFilter: defaultFilter,
|
|
359
|
-
defaultSorter: defaultSorter
|
|
360
|
-
|
|
390
|
+
defaultSorter: defaultSorter,
|
|
391
|
+
dataRowIds: dataIds
|
|
392
|
+
}))))))));
|
|
361
393
|
};
|
|
362
394
|
export default InternalTable;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { RenderInfo } from './interfaces';
|
|
3
|
+
import type { BaseTableProps } from './table';
|
|
4
|
+
import type { CommandClick, IFormat } from '../../grid-component/type';
|
|
5
|
+
export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowProps' | 'primaryKey' | 'components'>> {
|
|
6
|
+
tbodyHtmlTag: 'tbody' | 'tfoot';
|
|
7
|
+
data: any[];
|
|
8
|
+
originData: any[];
|
|
9
|
+
format?: IFormat;
|
|
10
|
+
id: string;
|
|
11
|
+
commandClick?: (args: CommandClick<any>) => void;
|
|
12
|
+
horizontalRenderInfo: Pick<RenderInfo, 'flat' | 'visible' | 'horizontalRenderRange' | 'stickyLeftMap' | 'stickyRightMap'>;
|
|
13
|
+
verticalRenderInfo: {
|
|
14
|
+
offset: number;
|
|
15
|
+
first: number;
|
|
16
|
+
last: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, data, originData, format, commandClick, id, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo, components: { Row, Cell, TableBody }, }: HtmlTableProps): JSX.Element;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { internals } from "../internals";
|
|
5
|
+
import { Colgroup } from "./colgroup";
|
|
6
|
+
import SpanManager from "./helpers/SpanManager";
|
|
7
|
+
import { Classes } from "./styles";
|
|
8
|
+
import { nonActionColumn } from "../../grid-component/hooks";
|
|
9
|
+
import { Space } from 'rc-master-ui';
|
|
10
|
+
import Command from "../../table-component/components/command/Command";
|
|
11
|
+
import { renderValueCell } from "../../table-component/hook/useColumns";
|
|
12
|
+
export function HtmlTable({
|
|
13
|
+
tbodyHtmlTag,
|
|
14
|
+
getRowProps,
|
|
15
|
+
primaryKey,
|
|
16
|
+
data,
|
|
17
|
+
originData,
|
|
18
|
+
format,
|
|
19
|
+
commandClick,
|
|
20
|
+
id,
|
|
21
|
+
verticalRenderInfo: verInfo,
|
|
22
|
+
horizontalRenderInfo: hozInfo,
|
|
23
|
+
components: {
|
|
24
|
+
Row,
|
|
25
|
+
Cell,
|
|
26
|
+
TableBody
|
|
27
|
+
}
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
flat,
|
|
31
|
+
horizontalRenderRange: hoz
|
|
32
|
+
} = hozInfo;
|
|
33
|
+
const spanManager = new SpanManager();
|
|
34
|
+
const fullFlatCount = flat.full.length;
|
|
35
|
+
const leftFlatCount = flat.left.length;
|
|
36
|
+
const rightFlatCount = flat.right.length;
|
|
37
|
+
const tbody = TableBody != null && tbodyHtmlTag === 'tbody' ? /*#__PURE__*/React.createElement(TableBody, {
|
|
38
|
+
tbodyProps: {
|
|
39
|
+
children: data.map(renderRow)
|
|
40
|
+
}
|
|
41
|
+
}) : ( /*#__PURE__*/React.createElement(tbodyHtmlTag, null, data.map(renderRow)));
|
|
42
|
+
return /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement(Colgroup, {
|
|
43
|
+
descriptors: hozInfo.visible
|
|
44
|
+
}), tbody);
|
|
45
|
+
function renderRow(row, i) {
|
|
46
|
+
const rowIndex = verInfo.offset + i;
|
|
47
|
+
spanManager.stripUpwards(rowIndex);
|
|
48
|
+
const rowProps = getRowProps(row, rowIndex);
|
|
49
|
+
const rowClass = cx(Classes.tableRow, {
|
|
50
|
+
first: rowIndex === verInfo.first,
|
|
51
|
+
last: rowIndex === verInfo.last,
|
|
52
|
+
even: rowIndex % 2 === 0,
|
|
53
|
+
odd: rowIndex % 2 === 1
|
|
54
|
+
}, rowProps?.className);
|
|
55
|
+
const onContextMenu = rowProps?.onContextMenu;
|
|
56
|
+
const trProps = {
|
|
57
|
+
...rowProps,
|
|
58
|
+
className: rowClass,
|
|
59
|
+
onContextMenu: tbodyHtmlTag === 'tbody' ? onContextMenu : undefined,
|
|
60
|
+
'data-rowindex': rowIndex,
|
|
61
|
+
children: hozInfo.visible.map(descriptor => {
|
|
62
|
+
if (descriptor.type === 'blank') {
|
|
63
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
64
|
+
key: descriptor.blankSide
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return renderBodyCell(row, rowIndex, descriptor.col, descriptor.colIndex);
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
const key = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
71
|
+
if (Row != null && tbodyHtmlTag === 'tbody') {
|
|
72
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
73
|
+
key,
|
|
74
|
+
row,
|
|
75
|
+
rowIndex,
|
|
76
|
+
trProps
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return /*#__PURE__*/React.createElement("tr", _extends({
|
|
80
|
+
key: key
|
|
81
|
+
}, trProps));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function renderBodyCell(row, rowIndex, column, colIndex) {
|
|
85
|
+
if (spanManager.testSkip(rowIndex, colIndex)) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const value = internals.safeGetValue(column, row, rowIndex);
|
|
89
|
+
const cellProps = column.getCellProps?.(value, row, rowIndex) ?? {};
|
|
90
|
+
const a = renderValueCell(column, value, row, rowIndex, colIndex, format, false);
|
|
91
|
+
|
|
92
|
+
// let cellContent: ReactNode = value
|
|
93
|
+
let cellContent = a;
|
|
94
|
+
|
|
95
|
+
// if (column.render) {
|
|
96
|
+
// cellContent = column.render(value, row, rowIndex)
|
|
97
|
+
// }
|
|
98
|
+
// if (column.field === '#') {
|
|
99
|
+
|
|
100
|
+
// cellContent = findItemPath(originData, row, primaryKey)
|
|
101
|
+
// }
|
|
102
|
+
|
|
103
|
+
if (column.field === 'command') {
|
|
104
|
+
const commands = column.commandItems ? column.commandItems.map(it => {
|
|
105
|
+
return {
|
|
106
|
+
...it,
|
|
107
|
+
visible: typeof it.visible === 'function' ? it.visible?.(row) : it.visible
|
|
108
|
+
};
|
|
109
|
+
}) : [];
|
|
110
|
+
cellContent = /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: "ui-rc_cell-content"
|
|
112
|
+
}, /*#__PURE__*/React.createElement(Space, null, commands.filter(it => it.visible !== false).map(item => {
|
|
113
|
+
return /*#__PURE__*/React.createElement(Command, {
|
|
114
|
+
id: id,
|
|
115
|
+
key: item.id,
|
|
116
|
+
item: item,
|
|
117
|
+
record: row,
|
|
118
|
+
onClick: () => {
|
|
119
|
+
commandClick?.({
|
|
120
|
+
id: item.id,
|
|
121
|
+
// rowId: getRowKey(record, index) as any,
|
|
122
|
+
rowId: row.rowId,
|
|
123
|
+
rowData: row,
|
|
124
|
+
index: rowIndex,
|
|
125
|
+
rows: [...originData]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
})));
|
|
130
|
+
}
|
|
131
|
+
if (column.template) {
|
|
132
|
+
cellContent = column.template({
|
|
133
|
+
value,
|
|
134
|
+
rowData: row,
|
|
135
|
+
index: rowIndex,
|
|
136
|
+
field: column.field ?? ''
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//
|
|
141
|
+
|
|
142
|
+
let colSpan = 1;
|
|
143
|
+
let rowSpan = 1;
|
|
144
|
+
if (column.getSpanRect) {
|
|
145
|
+
const spanRect = column.getSpanRect(value, row, rowIndex);
|
|
146
|
+
colSpan = spanRect == null ? 1 : spanRect.right - colIndex;
|
|
147
|
+
rowSpan = spanRect == null ? 1 : spanRect.bottom - rowIndex;
|
|
148
|
+
} else {
|
|
149
|
+
if (cellProps.colSpan != null) {
|
|
150
|
+
colSpan = cellProps.colSpan;
|
|
151
|
+
}
|
|
152
|
+
if (cellProps.rowSpan != null) {
|
|
153
|
+
rowSpan = cellProps.rowSpan;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// rowSpan/colSpan should not be too large to avoid affecting cells that are not rendered due to virtual scrolling
|
|
158
|
+
rowSpan = Math.min(rowSpan, verInfo.limit - rowIndex);
|
|
159
|
+
colSpan = Math.min(colSpan, leftFlatCount + hoz.rightIndex - colIndex);
|
|
160
|
+
const hasSpan = colSpan > 1 || rowSpan > 1;
|
|
161
|
+
if (hasSpan) {
|
|
162
|
+
spanManager.add(rowIndex, colIndex, colSpan, rowSpan);
|
|
163
|
+
}
|
|
164
|
+
const positionStyle = {};
|
|
165
|
+
if (colIndex < leftFlatCount) {
|
|
166
|
+
positionStyle.position = 'sticky';
|
|
167
|
+
positionStyle.left = hozInfo.stickyLeftMap.get(colIndex);
|
|
168
|
+
} else if (colIndex >= fullFlatCount - rightFlatCount) {
|
|
169
|
+
positionStyle.position = 'sticky';
|
|
170
|
+
positionStyle.right = hozInfo.stickyRightMap.get(colIndex);
|
|
171
|
+
}
|
|
172
|
+
const tdProps = {
|
|
173
|
+
...cellProps,
|
|
174
|
+
className: cx(Classes.tableCell, cellProps.className, {
|
|
175
|
+
first: colIndex === 0,
|
|
176
|
+
last: colIndex + colSpan === fullFlatCount,
|
|
177
|
+
'lock-left': colIndex < leftFlatCount,
|
|
178
|
+
'lock-right': colIndex >= fullFlatCount - rightFlatCount
|
|
179
|
+
}),
|
|
180
|
+
...(hasSpan ? {
|
|
181
|
+
colSpan,
|
|
182
|
+
rowSpan
|
|
183
|
+
} : null),
|
|
184
|
+
style: {
|
|
185
|
+
textAlign: column.textAlign,
|
|
186
|
+
...cellProps.style,
|
|
187
|
+
...positionStyle
|
|
188
|
+
},
|
|
189
|
+
// children: <div className='ui-rc_cell-content'>{cellContent}</div>
|
|
190
|
+
|
|
191
|
+
children: cellContent
|
|
192
|
+
// children: () => {
|
|
193
|
+
// return (
|
|
194
|
+
// <span className='abcccc'>{cellContent}</span>
|
|
195
|
+
// )
|
|
196
|
+
// },
|
|
197
|
+
};
|
|
198
|
+
if (tbodyHtmlTag === 'tfoot') {
|
|
199
|
+
if (!nonActionColumn.includes(column.field) && column.isSummary !== false) {
|
|
200
|
+
return /*#__PURE__*/React.createElement("td", _extends({
|
|
201
|
+
key: colIndex
|
|
202
|
+
}, tdProps));
|
|
203
|
+
} else {
|
|
204
|
+
return /*#__PURE__*/React.createElement("td", _extends({
|
|
205
|
+
key: colIndex
|
|
206
|
+
}, tdProps), '');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (Cell != null && tbodyHtmlTag === 'tbody') {
|
|
210
|
+
return /*#__PURE__*/React.createElement(Cell, {
|
|
211
|
+
key: colIndex,
|
|
212
|
+
tdProps: tdProps,
|
|
213
|
+
row: row,
|
|
214
|
+
rowIndex: rowIndex,
|
|
215
|
+
column: column,
|
|
216
|
+
colIndex: colIndex
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
return /*#__PURE__*/React.createElement("td", _extends({
|
|
220
|
+
key: colIndex
|
|
221
|
+
}, tdProps));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { RenderInfo } from './interfaces';
|
|
3
|
+
import type { BaseTableProps } from './table';
|
|
4
|
+
import type { CommandClick, IFormat } from '../../grid-component/type';
|
|
5
|
+
export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowProps' | 'primaryKey' | 'components'>> {
|
|
6
|
+
tbodyHtmlTag: 'tbody' | 'tfoot';
|
|
7
|
+
data: any[];
|
|
8
|
+
originData: any[];
|
|
9
|
+
format?: IFormat;
|
|
10
|
+
id: string;
|
|
11
|
+
commandClick?: (args: CommandClick<any>) => void;
|
|
12
|
+
horizontalRenderInfo: Pick<RenderInfo, 'flat' | 'visible' | 'horizontalRenderRange' | 'stickyLeftMap' | 'stickyRightMap'>;
|
|
13
|
+
verticalRenderInfo: {
|
|
14
|
+
offset: number;
|
|
15
|
+
first: number;
|
|
16
|
+
last: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, data, originData, format, commandClick, id, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo, components: { Row, Cell, TableBody }, }: HtmlTableProps): JSX.Element;
|