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
@@ -11,21 +11,18 @@ import { TableDOMHelper } from "./helpers/TableDOMUtils";
11
11
  import { HtmlTable } from "./html-table";
12
12
  import Loading from "./loading";
13
13
  import { Classes, LOCK_SHADOW_PADDING, StyledArtTableWrapper } from "./styles";
14
- import {
15
- // getScrollbarSize, // scroll mặc định thì bật lên
16
- OVERSCAN_SIZE, shallowEqual, STYLED_REF_PROP, sum, syncScrollLeft, throttledWindowResize$ } from "./utils";
14
+ import { getScrollbarSize, OVERSCAN_SIZE, shallowEqual, STYLED_REF_PROP, sum, syncScrollLeft, throttledWindowResize$ } from "./utils";
17
15
  import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
18
16
  let emptyContentDeprecatedWarned = false;
19
17
  function warnEmptyContentIsDeprecated() {
20
18
  if (!emptyContentDeprecatedWarned) {
21
19
  emptyContentDeprecatedWarned = true;
22
- console.warn('[ali-react-table] `BaseTable` props.emptyContent is deprecated. Please use `props.components.EmptyContent` to customize the table display when there is no data.');
20
+ console.warn('[ali-react-table] BaseTable props.emptyContent 已经过时,请使用 props.components.EmptyContent 来自定义数据为空时的表格表现');
23
21
  }
24
22
  }
25
23
  export class BaseTable extends React.Component {
26
24
  static defaultProps = {
27
25
  showHeader: true,
28
- // theme: undefined,
29
26
  isStickyHeader: true,
30
27
  stickyTop: 0,
31
28
  footerDataSource: [],
@@ -38,8 +35,7 @@ export class BaseTable extends React.Component {
38
35
  isLoading: false,
39
36
  components: {},
40
37
  getRowProps: noop,
41
- dataSource: [],
42
- originData: []
38
+ dataSource: []
43
39
  };
44
40
  // @ts-ignore
45
41
  rowHeightManager = makeRowHeightManager(this.props.dataSource.length, this.props.estimatedRowHeight);
@@ -54,7 +50,7 @@ export class BaseTable extends React.Component {
54
50
  // @ts-ignore
55
51
  props$;
56
52
 
57
- /** @deprecated `BaseTable.getDoms()` is deprecated. Please do not call it. */
53
+ /** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
58
54
  getDoms() {
59
55
  console.warn('[ali-react-table] BaseTable.getDoms() 已经过时');
60
56
  return this.domHelper;
@@ -74,7 +70,7 @@ export class BaseTable extends React.Component {
74
70
  };
75
71
  }
76
72
 
77
- /** Customize the scrollbar width to match the table width, ensuring the scrollbar thumb has the same width */
73
+ /** 自定义滚动条宽度为table宽度,使滚动条滑块宽度相同 */
78
74
  updateStickyScroll() {
79
75
  const {
80
76
  stickyScroll,
@@ -88,11 +84,7 @@ export class BaseTable extends React.Component {
88
84
  const innerTableWidth = tableBodyHtmlTable.offsetWidth;
89
85
  const artTableWidth = artTable.offsetWidth;
90
86
  const stickyScrollHeightProp = this.props.stickyScrollHeight;
91
-
92
- // scroll mặc định thì bật lên
93
- // const stickyScrollHeight = stickyScrollHeightProp === 'auto' ? getScrollbarSize().height : stickyScrollHeightProp
94
- const stickyScrollHeight = stickyScrollHeightProp === 'auto' ? 8 : stickyScrollHeightProp; // height customscrll bar = 8
95
-
87
+ const stickyScrollHeight = stickyScrollHeightProp === 'auto' ? getScrollbarSize().height : stickyScrollHeightProp;
96
88
  stickyScroll.style.marginTop = `-${(stickyScrollHeight ?? 0) + 1}px`;
97
89
  if (artTableWidth >= innerTableWidth) {
98
90
  if (this.state.hasScroll) {
@@ -185,7 +177,6 @@ export class BaseTable extends React.Component {
185
177
  renderTableBody(info) {
186
178
  const {
187
179
  dataSource,
188
- originData = [],
189
180
  getRowProps,
190
181
  primaryKey,
191
182
  isLoading,
@@ -195,7 +186,8 @@ export class BaseTable extends React.Component {
195
186
  id,
196
187
  commandClick,
197
188
  format,
198
- dataRowIds
189
+ dataRowIds,
190
+ originData
199
191
  } = this.props;
200
192
  const tableBodyClassName = cx(Classes.tableBody, Classes.horizontalScrollContainer, {
201
193
  'no-scrollbar': footerDataSource && footerDataSource.length > 0
@@ -237,25 +229,22 @@ export class BaseTable extends React.Component {
237
229
  items: dataRowIds ?? [],
238
230
  strategy: verticalListSortingStrategy
239
231
  }, /*#__PURE__*/React.createElement(HtmlTable, {
240
- id: id ?? '',
241
- commandClick: commandClick,
242
232
  components: components,
243
233
  tbodyHtmlTag: "tbody",
244
- getRowProps: getRowProps
245
-
246
- // -----------------
247
- ,
234
+ getRowProps: getRowProps,
248
235
  primaryKey: primaryKey,
249
236
  data: dataSource.slice(topIndex, bottomIndex),
250
- originData: originData,
251
- format: format,
252
237
  horizontalRenderInfo: info,
253
238
  verticalRenderInfo: {
254
239
  first: 0,
255
240
  offset: topIndex,
256
241
  limit: bottomIndex,
257
242
  last: dataSource.length - 1
258
- }
243
+ },
244
+ id: id ?? '',
245
+ commandClick: commandClick,
246
+ originData: originData ?? [],
247
+ format: format
259
248
  })), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
260
249
  key: "bottom-blank",
261
250
  className: cx(Classes.virtualBlank, 'bottom'),
@@ -272,6 +261,7 @@ export class BaseTable extends React.Component {
272
261
  stickyBottom,
273
262
  components,
274
263
  id,
264
+ originData,
275
265
  format
276
266
  } = this.props;
277
267
  return /*#__PURE__*/React.createElement("div", {
@@ -280,14 +270,9 @@ export class BaseTable extends React.Component {
280
270
  bottom: stickyBottom === 0 ? undefined : stickyBottom
281
271
  }
282
272
  }, /*#__PURE__*/React.createElement(HtmlTable, {
283
- id: id ?? ''
284
- // commandClick={commandClick}
285
- ,
286
273
  components: components,
287
274
  tbodyHtmlTag: "tfoot",
288
275
  data: footerDataSource,
289
- originData: [],
290
- format: format,
291
276
  horizontalRenderInfo: info,
292
277
  getRowProps: getRowProps,
293
278
  primaryKey: primaryKey,
@@ -296,7 +281,11 @@ export class BaseTable extends React.Component {
296
281
  first: 0,
297
282
  last: footerDataSource.length - 1,
298
283
  limit: Infinity
299
- }
284
+ },
285
+ id: id ?? '',
286
+ commandClick: undefined,
287
+ originData: originData ?? [],
288
+ format: format
300
289
  }));
301
290
  }
302
291
  renderLockShadows(info) {
@@ -318,7 +307,6 @@ export class BaseTable extends React.Component {
318
307
  className: cx(Classes.lockShadow, Classes.rightLockShadow)
319
308
  })));
320
309
  }
321
-
322
310
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
323
311
  renderStickyScroll(info) {
324
312
  const {
@@ -332,8 +320,7 @@ export class BaseTable extends React.Component {
332
320
  className: cx(Classes.stickyScroll, Classes.horizontalScrollContainer),
333
321
  style: {
334
322
  display: hasStickyScroll && hasScroll ? 'block' : 'none',
335
- bottom: stickyBottom,
336
- marginTop: 0
323
+ bottom: stickyBottom
337
324
  }
338
325
  }, /*#__PURE__*/React.createElement("div", {
339
326
  className: Classes.stickyScrollItem
@@ -343,12 +330,13 @@ export class BaseTable extends React.Component {
343
330
  const info = calculateRenderInfo(this);
344
331
  this.lastInfo = info;
345
332
  const {
333
+ theme,
346
334
  dataSource,
347
335
  className,
348
336
  style,
349
337
  showHeader,
350
- theme,
351
338
  useOuterBorder,
339
+ // isStickyHead,
352
340
  isStickyHeader,
353
341
  isStickyFooter,
354
342
  isLoading,
@@ -399,15 +387,6 @@ export class BaseTable extends React.Component {
399
387
  this.adjustNeedRenderLock();
400
388
  this.updateRowHeightManager();
401
389
  this.updateScrollLeftWhenLayoutChanged(prevProps, prevState);
402
- this.updateVerticalScrollClass();
403
- }
404
- updateVerticalScrollClass() {
405
- const wrapper = this.domHelper?.artTableWrapper;
406
- if (!wrapper) {
407
- return;
408
- }
409
- const hasVerticalScroll = wrapper.scrollHeight > wrapper.clientHeight + 1;
410
- wrapper.classList.toggle('has-vertical-scroll', hasVerticalScroll);
411
390
  }
412
391
  updateScrollLeftWhenLayoutChanged(prevProps, prevState) {
413
392
  if (prevState != null) {
@@ -433,7 +412,6 @@ export class BaseTable extends React.Component {
433
412
  this.rootSubscription.add(throttledWindowResize$.subscribe(() => {
434
413
  this.updateStickyScroll();
435
414
  this.adjustNeedRenderLock();
436
- this.updateVerticalScrollClass();
437
415
  }));
438
416
 
439
417
  // Scroll synchronization
@@ -1,19 +1,16 @@
1
1
  import { Subscription } from 'rxjs';
2
- /** Version of the `styled-components` library. ali-react-table supports both v3 and v5. */
2
+ /** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
3
3
  export declare const STYLED_VERSION: string;
4
4
  export declare const STYLED_REF_PROP: string;
5
- export declare const OVERSCAN_SIZE = 300;
6
- export declare const AUTO_VIRTUAL_THRESHOLD = 300;
5
+ export declare const OVERSCAN_SIZE = 100;
6
+ export declare const AUTO_VIRTUAL_THRESHOLD = 100;
7
7
  export declare function sum(arr: number[]): number;
8
8
  export declare const throttledWindowResize$: import("rxjs").Observable<Event>;
9
9
  export declare function getScrollbarSize(): {
10
10
  width: number;
11
11
  height: number;
12
12
  };
13
- /**
14
- * Synchronize the `scrollLeft` value among multiple elements.
15
- * The callback will be invoked whenever `scrollLeft` changes.
16
- */
13
+ /** 同步多个元素之间的 scrollLeft, 每当 scrollLeft 发生变化时 callback 会被调用 */
17
14
  export declare function syncScrollLeft(elements: HTMLElement[], callback: (scrollLeft: number) => void): Subscription;
18
15
  /**
19
16
  * Performs equality by iterating through keys on an object and returning false
@@ -2,11 +2,11 @@ import { asyncScheduler, BehaviorSubject, defer, fromEvent, Subscription } from
2
2
  import { map, throttleTime } from 'rxjs/operators';
3
3
  import * as styledComponents from 'styled-components';
4
4
 
5
- /** Version of the `styled-components` library. ali-react-table supports both v3 and v5. */
5
+ /** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
6
6
  export const STYLED_VERSION = styledComponents.createGlobalStyle != null ? 'v5' : 'v3';
7
7
  export const STYLED_REF_PROP = STYLED_VERSION === 'v3' ? 'innerRef' : 'ref';
8
- export const OVERSCAN_SIZE = 300;
9
- export const AUTO_VIRTUAL_THRESHOLD = 300;
8
+ export const OVERSCAN_SIZE = 100;
9
+ export const AUTO_VIRTUAL_THRESHOLD = 100;
10
10
  export function sum(arr) {
11
11
  let result = 0;
12
12
  arr.forEach(x => {
@@ -23,7 +23,7 @@ export const throttledWindowResize$ = defer(() => fromEvent(window, 'resize', {
23
23
  trailing: true
24
24
  })));
25
25
 
26
- /** Get the default scrollbar size */
26
+ /** 获取默认的滚动条大小 */
27
27
  function getScrollbarSizeImpl() {
28
28
  const scrollDiv = document.createElement('div');
29
29
  scrollDiv.style.position = 'absolute';
@@ -49,10 +49,7 @@ export function getScrollbarSize() {
49
49
  return scrollBarSize$.value;
50
50
  }
51
51
 
52
- /**
53
- * Synchronize the `scrollLeft` value among multiple elements.
54
- * The callback will be invoked whenever `scrollLeft` changes.
55
- */
52
+ /** 同步多个元素之间的 scrollLeft, 每当 scrollLeft 发生变化时 callback 会被调用 */
56
53
  export function syncScrollLeft(elements, callback) {
57
54
  const bypassSet = new Set();
58
55
  function publishScrollLeft(origin, scrollLeft) {
@@ -1,6 +1,6 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
2
  import type React from 'react';
3
- import type { ColumnTemplate, CommandItem, FilterOperator, IColumnType, IFormat, ITextAlign, TypeFilter } from '../grid-component/type';
3
+ import type { ColumnTemplate, CommandItem, EditType, FilterOperator, IColumnType, IFormat, ITextAlign, TypeFilter } from '../grid-component/type';
4
4
  export type CellProps = React.TdHTMLAttributes<HTMLTableCellElement>;
5
5
  export type FilterState = {
6
6
  field: any;
@@ -9,11 +9,12 @@ export type FilterState = {
9
9
  filteredKeys: any[];
10
10
  operator: string | undefined;
11
11
  };
12
- export interface ArtColumnStaticPart {
12
+ export interface ArtColumnStaticPart<RecordType = any> {
13
13
  /** Column name */
14
14
  headerText?: string;
15
15
  /** Field in the data */
16
16
  field: string;
17
+ targetField?: string;
17
18
  /** Display title of the column; when rendering on the page, this field overrides the `name` field */
18
19
  title?: ReactNode;
19
20
  headerTemplate?: ReactNode | ((col: any) => ReactNode);
@@ -51,14 +52,18 @@ export interface ArtColumnStaticPart {
51
52
  /** Data source dropdown options for the column */
52
53
  source?: any[];
53
54
  /** Format configuration or formatter function */
54
- format?: IFormat | ((rowData: any) => IFormat);
55
+ format?: IFormat | ((rowData: RecordType) => IFormat);
55
56
  /** Alignment of the text or content inside the cell */
56
57
  textAlign?: ITextAlign;
57
58
  headerTextAlign?: ITextAlign;
58
- onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, column: any) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
59
59
  commandItems?: CommandItem[];
60
- tooltipDescription?: string | ((rowData: any) => string | ReactNode);
60
+ tooltipDescription?: string | ((rowData: RecordType) => string | ReactNode);
61
61
  headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
62
+ editType?: EditType | ((rowData?: RecordType) => EditType);
63
+ /** Cho phép header edit */
64
+ headerEditEnable?: boolean;
65
+ /** Kiểu editor khi edit cell */
66
+ headerEditType?: EditType;
62
67
  }
63
68
  export interface ArtColumnDynamicPart<RecordType = any> {
64
69
  /** Custom data retrieval method */
@@ -56,6 +56,21 @@ export interface ColumnFeatureOptions {
56
56
  wrapSettings?: IWrapSettings;
57
57
  currentPage?: number;
58
58
  pageSize?: number;
59
+ editAble?: boolean;
60
+ rowEditable?: (rowData: any) => boolean;
61
+ setValue?: any;
62
+ reset?: any;
63
+ getValues?: any;
64
+ control?: any;
65
+ errors?: any;
66
+ handleDeleteContent?: () => void;
67
+ tableRef: any;
68
+ triggerPaste?: (pastedRows: any[], pastedColumnsArray: string[], newData: any[], copyRows: any[]) => void;
69
+ handleSubmit: any;
70
+ onSubmit: any;
71
+ handleCellChange: any;
72
+ handleHeaderCellChange?: any;
73
+ dataErrors?: any[];
59
74
  }
60
75
  export declare function columnCustom(opts: ColumnFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
61
76
  export {};