es-grid-template 1.9.59 → 1.9.60
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/ColumnsConfig.d.ts +14 -0
- package/es/ali-table/ColumnsConfig.js +303 -0
- package/es/ali-table/Grid.js +110 -31
- package/es/ali-table/InternalTable.js +1208 -18
- package/es/ali-table/assets/WebsiteBaseTable.js +7 -3
- package/es/ali-table/base-table/calculations.js +23 -22
- package/es/ali-table/base-table/cell/EditCell.d.ts +27 -0
- package/es/ali-table/base-table/cell/EditCell.js +1252 -0
- package/es/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
- package/es/ali-table/base-table/cell/HeaderEditCell.js +1252 -0
- package/es/ali-table/base-table/header.js +3 -1
- package/es/ali-table/base-table/html-table.d.ts +4 -4
- package/es/ali-table/base-table/html-table.js +5 -289
- package/es/ali-table/base-table/styles.d.ts +2 -1
- package/es/ali-table/base-table/styles.js +8 -8
- package/es/ali-table/base-table/styles.scss +0 -34
- package/es/ali-table/base-table/table.d.ts +13 -10
- package/es/ali-table/base-table/table.js +23 -45
- package/es/ali-table/base-table/utils.d.ts +4 -7
- package/es/ali-table/base-table/utils.js +5 -8
- package/es/ali-table/interfaces.d.ts +10 -5
- package/es/ali-table/pipeline/features/columnCustom.d.ts +15 -0
- package/es/ali-table/pipeline/features/columnCustom.js +913 -36
- package/es/ali-table/t-body/RenderRow.d.ts +41 -0
- package/es/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +15 -161
- package/es/ali-table/utils/constants.d.ts +16 -0
- package/es/ali-table/utils/constants.js +21 -0
- package/es/ali-table/utils/utility.d.ts +12 -0
- package/es/ali-table/utils/utility.js +255 -0
- package/es/grid-component/hooks/constant.js +1 -1
- package/es/grid-component/type.d.ts +14 -0
- package/es/group-component/hook/utils.d.ts +6 -3
- package/es/table-component/ColumnsConfig.d.ts +0 -4
- package/es/table-component/ColumnsConfig.js +1 -1
- package/es/table-component/TableContainer.js +0 -3
- package/es/table-component/TableContainerEdit.js +0 -3
- package/es/table-component/body/TableBodyCell.js +8 -0
- package/es/table-component/hook/utils.d.ts +22 -0
- package/es/table-component/hook/utils.js +204 -5
- package/lib/ali-table/ColumnsConfig.d.ts +14 -0
- package/lib/ali-table/ColumnsConfig.js +313 -0
- package/lib/ali-table/Grid.js +109 -30
- package/lib/ali-table/InternalTable.js +1203 -15
- package/lib/ali-table/assets/WebsiteBaseTable.js +7 -3
- package/lib/ali-table/base-table/calculations.js +23 -22
- package/lib/ali-table/base-table/cell/EditCell.d.ts +27 -0
- package/lib/ali-table/base-table/cell/EditCell.js +1259 -0
- package/lib/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
- package/lib/ali-table/base-table/cell/HeaderEditCell.js +1259 -0
- package/lib/ali-table/base-table/header.js +3 -1
- package/lib/ali-table/base-table/html-table.d.ts +4 -4
- package/lib/ali-table/base-table/html-table.js +7 -291
- package/lib/ali-table/base-table/styles.d.ts +2 -1
- package/lib/ali-table/base-table/styles.js +8 -8
- package/lib/ali-table/base-table/styles.scss +0 -34
- package/lib/ali-table/base-table/table.d.ts +13 -10
- package/lib/ali-table/base-table/table.js +22 -42
- package/lib/ali-table/base-table/utils.d.ts +4 -7
- package/lib/ali-table/base-table/utils.js +5 -8
- package/lib/ali-table/interfaces.d.ts +10 -5
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +15 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +926 -53
- package/lib/ali-table/t-body/RenderRow.d.ts +41 -0
- package/lib/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +14 -160
- package/lib/ali-table/utils/constants.d.ts +16 -0
- package/lib/ali-table/utils/constants.js +27 -0
- package/lib/ali-table/utils/utility.d.ts +12 -0
- package/lib/ali-table/utils/utility.js +266 -0
- package/lib/grid-component/hooks/constant.js +1 -1
- package/lib/grid-component/type.d.ts +14 -0
- package/lib/group-component/hook/utils.d.ts +3 -0
- package/lib/table-component/ColumnsConfig.d.ts +0 -4
- package/lib/table-component/ColumnsConfig.js +1 -1
- package/lib/table-component/TableContainer.js +0 -3
- package/lib/table-component/TableContainerEdit.js +0 -3
- package/lib/table-component/body/TableBodyCell.js +8 -0
- package/lib/table-component/hook/utils.d.ts +22 -0
- package/lib/table-component/hook/utils.js +221 -4
- package/package.json +1 -1
- package/es/ali-table/base-table/html-table-default.d.ts +0 -20
- package/es/ali-table/base-table/html-table-default.js +0 -224
- package/es/ali-table/base-table/html-table-new.d.ts +0 -20
- package/lib/ali-table/base-table/html-table-default.d.ts +0 -20
- package/lib/ali-table/base-table/html-table-default.js +0 -231
- package/lib/ali-table/base-table/html-table-new.d.ts +0 -20
|
@@ -3,15 +3,19 @@ import cx from 'classnames';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { BaseTable } from "../base-table/table";
|
|
6
|
+
// import { BaseTable } from 'ali-react-table'
|
|
7
|
+
|
|
6
8
|
const DarkSupportBaseTable = styled(BaseTable).withConfig({
|
|
7
9
|
displayName: "DarkSupportBaseTable",
|
|
8
10
|
componentId: "es-grid-template__sc-4ltmbz-0"
|
|
9
11
|
})(["", ";&.dark{--bgcolor:#343e59;--footer-bgcolor:#2e3342;--header-bgcolor:#343e59;--hover-bgcolor:#232b43;--header-hover-bgcolor:#606164;--highlight-bgcolor:#eff2f5;--header-highlight-bgcolor:#191a1b;--color:#dadde1;--header-color:#dadde1;--lock-shadow:rgb(37 37 37 / 0.5) 0 0 6px 2px;--border-color:#5d5f61;}"], props => props.css);
|
|
10
12
|
export const WebsiteBaseTable = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
11
|
-
const isDarkTheme =
|
|
13
|
+
const isDarkTheme = false;
|
|
12
14
|
return /*#__PURE__*/React.createElement(DarkSupportBaseTable, _extends({
|
|
13
|
-
ref: ref
|
|
14
|
-
theme
|
|
15
|
+
ref: ref
|
|
16
|
+
// theme={props.theme}
|
|
17
|
+
,
|
|
18
|
+
|
|
15
19
|
className: cx({
|
|
16
20
|
dark: isDarkTheme
|
|
17
21
|
}, props.className)
|
|
@@ -2,7 +2,7 @@ import { collectNodes, isLeafNode } from "../utils";
|
|
|
2
2
|
import { AUTO_VIRTUAL_THRESHOLD, OVERSCAN_SIZE, sum } from "./utils";
|
|
3
3
|
function resolveVirtualEnabled(virtualEnum, defaultValue) {
|
|
4
4
|
if (virtualEnum == null || virtualEnum === 'auto') {
|
|
5
|
-
return
|
|
5
|
+
return defaultValue;
|
|
6
6
|
}
|
|
7
7
|
return virtualEnum;
|
|
8
8
|
}
|
|
@@ -10,24 +10,21 @@ let lockColumnNeedSpecifiedWidthWarned = false;
|
|
|
10
10
|
function warnLockColumnNeedSpecifiedWidth(column) {
|
|
11
11
|
if (!lockColumnNeedSpecifiedWidthWarned) {
|
|
12
12
|
lockColumnNeedSpecifiedWidthWarned = true;
|
|
13
|
-
console.warn('[ali-react-table] lock=true
|
|
13
|
+
console.warn('[ali-react-table] lock=true 的列需要指定宽度', column);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
let columnHiddenDeprecatedWarned = false;
|
|
17
17
|
function warnColumnHiddenDeprecated(column) {
|
|
18
18
|
if (!columnHiddenDeprecatedWarned) {
|
|
19
19
|
columnHiddenDeprecatedWarned = true;
|
|
20
|
-
console.warn('[ali-react-table]
|
|
20
|
+
console.warn('[ali-react-table] column.hidden 已经过时,如果需要隐藏该列,请将其从 columns 数组中移除', column);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Validate column configuration, set default widths,
|
|
26
|
-
* and remove hidden columns
|
|
27
|
-
*/
|
|
24
|
+
/** 检查列配置 & 设置默认宽度 & 剔除隐藏的列 */
|
|
28
25
|
function processColumns(columns, defaultColumnWidth) {
|
|
29
|
-
if (columns
|
|
30
|
-
console.warn('[ali-react-table]
|
|
26
|
+
if (columns == null || !Array.isArray(columns)) {
|
|
27
|
+
console.warn('[ali-react-table] <BaseTable /> props.columns 需要传入一个数组', columns);
|
|
31
28
|
// eslint-disable-next-line no-param-reassign
|
|
32
29
|
columns = [];
|
|
33
30
|
}
|
|
@@ -36,8 +33,8 @@ function processColumns(columns, defaultColumnWidth) {
|
|
|
36
33
|
function dfs(columns) {
|
|
37
34
|
const result = [];
|
|
38
35
|
for (let column of columns) {
|
|
39
|
-
if (column.width
|
|
40
|
-
if (defaultColumnWidth
|
|
36
|
+
if (column.width == null) {
|
|
37
|
+
if (defaultColumnWidth != null) {
|
|
41
38
|
column = {
|
|
42
39
|
...column,
|
|
43
40
|
width: defaultColumnWidth
|
|
@@ -48,15 +45,14 @@ function processColumns(columns, defaultColumnWidth) {
|
|
|
48
45
|
}
|
|
49
46
|
if (isLeafNode(column)) {
|
|
50
47
|
if (column.hidden) {
|
|
51
|
-
//
|
|
48
|
+
// 被隐藏的列 会在这里被剔除
|
|
52
49
|
warnColumnHiddenDeprecated(column);
|
|
53
50
|
} else {
|
|
54
51
|
result.push(column);
|
|
55
52
|
}
|
|
56
53
|
} else {
|
|
57
54
|
const nextChildren = dfs(column.children ?? []);
|
|
58
|
-
//
|
|
59
|
-
// In this case, hide the parent node here as well.
|
|
55
|
+
// 如果 nextChildren 为空,说明所有的子节点均被隐藏了,在这里隐藏父节点
|
|
60
56
|
if (nextChildren.length > 0) {
|
|
61
57
|
result.push({
|
|
62
58
|
...column,
|
|
@@ -116,19 +112,22 @@ function getHorizontalRenderRange({
|
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
//
|
|
115
|
+
// 考虑 over scan 之后,中间部分的列至少需要渲染的宽度
|
|
120
116
|
const minCenterRenderWidth = maxRenderWidth + (overscannedOffsetX - leftBlank) + 2 * OVERSCAN_SIZE;
|
|
121
117
|
while (leftIndex + centerCount < flat.center.length) {
|
|
122
118
|
const col = flat.center[leftIndex + centerCount];
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
if (col.width + centerRenderWidth < minCenterRenderWidth) {
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
centerRenderWidth += col.width;
|
|
125
123
|
centerCount += 1;
|
|
126
124
|
} else {
|
|
127
125
|
break;
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
const rightBlankCount = flat.center.length - leftIndex - centerCount;
|
|
131
|
-
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
const rightBlank = sum(flat.center.slice(flat.center.length - rightBlankCount).map(col => col.width));
|
|
132
131
|
return {
|
|
133
132
|
leftIndex: leftIndex,
|
|
134
133
|
leftBlank,
|
|
@@ -137,10 +136,8 @@ function getHorizontalRenderRange({
|
|
|
137
136
|
};
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
// TODO: Consider moving the header computation logic into this file as well.
|
|
143
|
-
// There is likely some duplicated calculation logic at the moment.
|
|
139
|
+
// 一顿计算,将表格本次渲染所需要的数据都给算出来(代码写得有点乱,有较大优化空间)
|
|
140
|
+
// todo 可以考虑下将 header 部分的计算逻辑也放到这个文件中,目前应该有一些重复的计算逻辑
|
|
144
141
|
export function calculateRenderInfo(table) {
|
|
145
142
|
const {
|
|
146
143
|
offsetX,
|
|
@@ -152,6 +149,7 @@ export function calculateRenderInfo(table) {
|
|
|
152
149
|
dataSource: dataSourceProp,
|
|
153
150
|
defaultColumnWidth
|
|
154
151
|
} = table.props;
|
|
152
|
+
// @ts-ignore
|
|
155
153
|
const columns = processColumns(columnsProp, defaultColumnWidth);
|
|
156
154
|
const leftNestedLockCount = getLeftNestedLockCount(columns);
|
|
157
155
|
const fullFlat = collectNodes(columns, 'leaf-only');
|
|
@@ -184,8 +182,11 @@ export function calculateRenderInfo(table) {
|
|
|
184
182
|
const shouldEnableHozVirtual = fullFlat.length >= AUTO_VIRTUAL_THRESHOLD && fullFlat.every(col => col.width != null);
|
|
185
183
|
const shouldEnableVerVirtual = dataSourceProp.length >= AUTO_VIRTUAL_THRESHOLD;
|
|
186
184
|
useVirtual = {
|
|
185
|
+
// @ts-ignore
|
|
187
186
|
horizontal: resolveVirtualEnabled(typeof useVirtualProp === 'object' ? useVirtualProp.horizontal : useVirtualProp, shouldEnableHozVirtual),
|
|
187
|
+
// @ts-ignore
|
|
188
188
|
vertical: resolveVirtualEnabled(typeof useVirtualProp === 'object' ? useVirtualProp.vertical : useVirtualProp, shouldEnableVerVirtual),
|
|
189
|
+
// @ts-ignore
|
|
189
190
|
header: resolveVirtualEnabled(typeof useVirtualProp === 'object' ? useVirtualProp.header : useVirtualProp, false)
|
|
190
191
|
};
|
|
191
192
|
flat = {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Column } from "@tanstack/react-table";
|
|
3
|
+
import type { ColumnTable, EditType, IFormat } from "../../../grid-component/type";
|
|
4
|
+
interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
+
t?: any;
|
|
6
|
+
dataIndex: string;
|
|
7
|
+
editType: EditType;
|
|
8
|
+
record: DataType;
|
|
9
|
+
format?: IFormat;
|
|
10
|
+
column: ColumnTable<DataType>;
|
|
11
|
+
indexRow: number;
|
|
12
|
+
indexCol: number;
|
|
13
|
+
cellEditing?: any;
|
|
14
|
+
visibleColumns?: Column<DataType>[];
|
|
15
|
+
handleNextCell?: () => void;
|
|
16
|
+
control?: any;
|
|
17
|
+
getValues?: any;
|
|
18
|
+
errors?: any;
|
|
19
|
+
rowKey?: any;
|
|
20
|
+
startCell?: any;
|
|
21
|
+
handleCellChange?: any;
|
|
22
|
+
tableId: string;
|
|
23
|
+
onSubmit: any;
|
|
24
|
+
handleSubmit: any;
|
|
25
|
+
}
|
|
26
|
+
declare const EditCell: <T>(props: EditableCellProps<T>) => JSX.Element;
|
|
27
|
+
export default EditCell;
|