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.
Files changed (85) hide show
  1. package/es/ali-table/ColumnsConfig.d.ts +14 -0
  2. package/es/ali-table/ColumnsConfig.js +303 -0
  3. package/es/ali-table/Grid.js +110 -31
  4. package/es/ali-table/InternalTable.js +1208 -18
  5. package/es/ali-table/assets/WebsiteBaseTable.js +7 -3
  6. package/es/ali-table/base-table/calculations.js +23 -22
  7. package/es/ali-table/base-table/cell/EditCell.d.ts +27 -0
  8. package/es/ali-table/base-table/cell/EditCell.js +1252 -0
  9. package/es/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
  10. package/es/ali-table/base-table/cell/HeaderEditCell.js +1252 -0
  11. package/es/ali-table/base-table/header.js +3 -1
  12. package/es/ali-table/base-table/html-table.d.ts +4 -4
  13. package/es/ali-table/base-table/html-table.js +5 -289
  14. package/es/ali-table/base-table/styles.d.ts +2 -1
  15. package/es/ali-table/base-table/styles.js +8 -8
  16. package/es/ali-table/base-table/styles.scss +0 -34
  17. package/es/ali-table/base-table/table.d.ts +13 -10
  18. package/es/ali-table/base-table/table.js +23 -45
  19. package/es/ali-table/base-table/utils.d.ts +4 -7
  20. package/es/ali-table/base-table/utils.js +5 -8
  21. package/es/ali-table/interfaces.d.ts +10 -5
  22. package/es/ali-table/pipeline/features/columnCustom.d.ts +15 -0
  23. package/es/ali-table/pipeline/features/columnCustom.js +913 -36
  24. package/es/ali-table/t-body/RenderRow.d.ts +41 -0
  25. package/es/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +15 -161
  26. package/es/ali-table/utils/constants.d.ts +16 -0
  27. package/es/ali-table/utils/constants.js +21 -0
  28. package/es/ali-table/utils/utility.d.ts +12 -0
  29. package/es/ali-table/utils/utility.js +255 -0
  30. package/es/grid-component/hooks/constant.js +1 -1
  31. package/es/grid-component/type.d.ts +14 -0
  32. package/es/group-component/hook/utils.d.ts +6 -3
  33. package/es/table-component/ColumnsConfig.d.ts +0 -4
  34. package/es/table-component/ColumnsConfig.js +1 -1
  35. package/es/table-component/TableContainer.js +0 -3
  36. package/es/table-component/TableContainerEdit.js +0 -3
  37. package/es/table-component/body/TableBodyCell.js +8 -0
  38. package/es/table-component/hook/utils.d.ts +22 -0
  39. package/es/table-component/hook/utils.js +204 -5
  40. package/lib/ali-table/ColumnsConfig.d.ts +14 -0
  41. package/lib/ali-table/ColumnsConfig.js +313 -0
  42. package/lib/ali-table/Grid.js +109 -30
  43. package/lib/ali-table/InternalTable.js +1203 -15
  44. package/lib/ali-table/assets/WebsiteBaseTable.js +7 -3
  45. package/lib/ali-table/base-table/calculations.js +23 -22
  46. package/lib/ali-table/base-table/cell/EditCell.d.ts +27 -0
  47. package/lib/ali-table/base-table/cell/EditCell.js +1259 -0
  48. package/lib/ali-table/base-table/cell/HeaderEditCell.d.ts +28 -0
  49. package/lib/ali-table/base-table/cell/HeaderEditCell.js +1259 -0
  50. package/lib/ali-table/base-table/header.js +3 -1
  51. package/lib/ali-table/base-table/html-table.d.ts +4 -4
  52. package/lib/ali-table/base-table/html-table.js +7 -291
  53. package/lib/ali-table/base-table/styles.d.ts +2 -1
  54. package/lib/ali-table/base-table/styles.js +8 -8
  55. package/lib/ali-table/base-table/styles.scss +0 -34
  56. package/lib/ali-table/base-table/table.d.ts +13 -10
  57. package/lib/ali-table/base-table/table.js +22 -42
  58. package/lib/ali-table/base-table/utils.d.ts +4 -7
  59. package/lib/ali-table/base-table/utils.js +5 -8
  60. package/lib/ali-table/interfaces.d.ts +10 -5
  61. package/lib/ali-table/pipeline/features/columnCustom.d.ts +15 -0
  62. package/lib/ali-table/pipeline/features/columnCustom.js +926 -53
  63. package/lib/ali-table/t-body/RenderRow.d.ts +41 -0
  64. package/lib/ali-table/{base-table/html-table-new.js → t-body/RenderRow.js} +14 -160
  65. package/lib/ali-table/utils/constants.d.ts +16 -0
  66. package/lib/ali-table/utils/constants.js +27 -0
  67. package/lib/ali-table/utils/utility.d.ts +12 -0
  68. package/lib/ali-table/utils/utility.js +266 -0
  69. package/lib/grid-component/hooks/constant.js +1 -1
  70. package/lib/grid-component/type.d.ts +14 -0
  71. package/lib/group-component/hook/utils.d.ts +3 -0
  72. package/lib/table-component/ColumnsConfig.d.ts +0 -4
  73. package/lib/table-component/ColumnsConfig.js +1 -1
  74. package/lib/table-component/TableContainer.js +0 -3
  75. package/lib/table-component/TableContainerEdit.js +0 -3
  76. package/lib/table-component/body/TableBodyCell.js +8 -0
  77. package/lib/table-component/hook/utils.d.ts +22 -0
  78. package/lib/table-component/hook/utils.js +221 -4
  79. package/package.json +1 -1
  80. package/es/ali-table/base-table/html-table-default.d.ts +0 -20
  81. package/es/ali-table/base-table/html-table-default.js +0 -224
  82. package/es/ali-table/base-table/html-table-new.d.ts +0 -20
  83. package/lib/ali-table/base-table/html-table-default.d.ts +0 -20
  84. package/lib/ali-table/base-table/html-table-default.js +0 -231
  85. 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 = props.theme?.theme === 'dark';
13
+ const isDarkTheme = false;
12
14
  return /*#__PURE__*/React.createElement(DarkSupportBaseTable, _extends({
13
- ref: ref,
14
- theme: props.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 !!defaultValue;
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 The column must have a specified width', column);
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] `column.hidden` is deprecated. If you need to hide this column, please remove it from the `columns` array.', column);
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 === null || !Array.isArray(columns)) {
30
- console.warn('[ali-react-table] `<BaseTable />` props.columns must be an array.', columns);
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 === null) {
40
- if (defaultColumnWidth !== null) {
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
- // Hidden columns will be removed here
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
- // If `nextChildren` is empty, it means all child nodes have been hidden.
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
- // Considering overscan, the middle columns need to render at least this much width
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
- if (col.width ?? 0 + centerRenderWidth < minCenterRenderWidth) {
124
- centerRenderWidth += col.width ?? 0;
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
- const rightBlank = sum(flat.center.slice(flat.center.length - rightBlankCount).map(col => col.width ?? 0));
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
- // Perform a series of calculations to derive all the data required
141
- // for this table render (the code is a bit messy and has significant room for optimization).
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;