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.
Files changed (73) hide show
  1. package/es/table-component/ColumnsChoose.d.ts +6 -3
  2. package/es/table-component/ColumnsChoose.js +31 -382
  3. package/es/table-component/InternalTable.js +32 -19
  4. package/es/table-component/TableContainer.d.ts +11 -2
  5. package/es/table-component/TableContainer.js +134 -14
  6. package/es/table-component/TableContainerEdit.d.ts +10 -7
  7. package/es/table-component/TableContainerEdit.js +158 -65
  8. package/es/table-component/body/EditableCell.js +14 -11
  9. package/es/table-component/body/TableBody.d.ts +2 -1
  10. package/es/table-component/body/TableBody.js +25 -6
  11. package/es/table-component/body/TableBodyCell.d.ts +2 -0
  12. package/es/table-component/body/TableBodyCell.js +13 -3
  13. package/es/table-component/body/TableBodyCellEdit.d.ts +2 -1
  14. package/es/table-component/body/TableBodyCellEdit.js +159 -34
  15. package/es/table-component/body/TableBodyRow.js +9 -4
  16. package/es/table-component/components/ControlCheckbox.js +0 -3
  17. package/es/table-component/components/async-table-select/index.d.ts +1 -1
  18. package/es/table-component/components/async-table-select/index.js +1 -0
  19. package/es/table-component/components/command/Command.d.ts +1 -0
  20. package/es/table-component/components/command/Command.js +6 -1
  21. package/es/table-component/footer/TableFooterCell.js +45 -3
  22. package/es/table-component/footer/TableFooterRow.js +3 -1
  23. package/es/table-component/header/TableHeadCell.js +31 -12
  24. package/es/table-component/header/TableHeadRow.js +5 -1
  25. package/es/table-component/hook/useColumns.d.ts +5 -7
  26. package/es/table-component/hook/useColumns.js +18 -58
  27. package/es/table-component/hook/utils.d.ts +12 -0
  28. package/es/table-component/hook/utils.js +140 -2
  29. package/es/table-component/style.scss +72 -7
  30. package/es/table-component/table/Grid.d.ts +3 -2
  31. package/es/table-component/table/Grid.js +25 -100
  32. package/es/table-component/type.d.ts +34 -3
  33. package/es/table-component/useContext.d.ts +5 -50
  34. package/es/table-component/useContext.js +3 -49
  35. package/lib/table-component/ColumnsChoose.d.ts +6 -3
  36. package/lib/table-component/ColumnsChoose.js +29 -381
  37. package/lib/table-component/InternalTable.js +30 -16
  38. package/lib/table-component/TableContainer.d.ts +11 -2
  39. package/lib/table-component/TableContainer.js +135 -14
  40. package/lib/table-component/TableContainerEdit.d.ts +10 -7
  41. package/lib/table-component/TableContainerEdit.js +157 -64
  42. package/lib/table-component/body/EditableCell.js +14 -11
  43. package/lib/table-component/body/TableBody.d.ts +2 -1
  44. package/lib/table-component/body/TableBody.js +27 -6
  45. package/lib/table-component/body/TableBodyCell.d.ts +2 -0
  46. package/lib/table-component/body/TableBodyCell.js +13 -3
  47. package/lib/table-component/body/TableBodyCellEdit.d.ts +2 -1
  48. package/lib/table-component/body/TableBodyCellEdit.js +159 -34
  49. package/lib/table-component/body/TableBodyRow.js +9 -4
  50. package/lib/table-component/components/ControlCheckbox.js +0 -3
  51. package/lib/table-component/components/async-table-select/index.d.ts +1 -1
  52. package/lib/table-component/components/async-table-select/index.js +2 -0
  53. package/lib/table-component/components/command/Command.d.ts +1 -0
  54. package/lib/table-component/components/command/Command.js +6 -1
  55. package/lib/table-component/footer/TableFooterCell.js +46 -2
  56. package/lib/table-component/footer/TableFooterRow.js +3 -1
  57. package/lib/table-component/header/TableHeadCell.js +31 -12
  58. package/lib/table-component/header/TableHeadRow.js +5 -1
  59. package/lib/table-component/hook/useColumns.d.ts +5 -7
  60. package/lib/table-component/hook/useColumns.js +17 -57
  61. package/lib/table-component/hook/utils.d.ts +12 -0
  62. package/lib/table-component/hook/utils.js +156 -9
  63. package/lib/table-component/style.scss +72 -7
  64. package/lib/table-component/table/Grid.d.ts +3 -2
  65. package/lib/table-component/table/Grid.js +24 -100
  66. package/lib/table-component/type.d.ts +34 -3
  67. package/lib/table-component/useContext.d.ts +5 -50
  68. package/lib/table-component/useContext.js +4 -50
  69. package/package.json +2 -2
  70. package/es/table-component/table/GridEdit.d.ts +0 -23
  71. package/es/table-component/table/GridEdit.js +0 -282
  72. package/lib/table-component/table/GridEdit.d.ts +0 -23
  73. package/lib/table-component/table/GridEdit.js +0 -284
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  // import type { Dispatch, SetStateAction } from "react";
2
3
 
3
4
  import React from 'react';
@@ -5,11 +6,18 @@ import TableHead from "./header/TableHead";
5
6
  import { sumSize } from "./hook/utils";
6
7
  import { useVirtualizer } from '@tanstack/react-virtual';
7
8
  import classNames from 'classnames';
8
- import TableBody from "./body/TableBody";
9
+ // import TableBody from './body/TableBody'
9
10
  import { TableContext } from "./useContext";
11
+ import Pagination from 'rc-master-ui/es/pagination';
12
+ import { Toolbar } from 'rc-master-ui';
13
+ import { Maximize, Minimize } from 'becoxy-icons';
14
+ import { ColumnsChoose } from "./ColumnsChoose";
15
+ import TableFooter from "./footer/TableFooter";
16
+ import TableBody from "./body/TableBody";
17
+ import { numericFormatter } from 'react-numeric-component';
10
18
  const TableContainer = props => {
11
19
  const {
12
- // t,
20
+ t,
13
21
  table,
14
22
  id,
15
23
  prefix,
@@ -29,10 +37,37 @@ const TableContainer = props => {
29
37
  contextMenuItems,
30
38
  setSorterChange,
31
39
  setFilterChange,
32
- tableHeight
40
+ height,
41
+ showToolbar,
42
+ toolbarItems,
43
+ actionTemplate,
44
+ pagination,
45
+ fullScreen,
46
+ showColumnChoose,
47
+ summary,
48
+ locale,
49
+ groupColumns,
50
+ columns,
51
+ propsColumns,
52
+ triggerChangeColumns,
53
+ columnHidden,
54
+ expanded,
55
+ setExpanded,
56
+ showEmptyText
33
57
  } = props;
34
58
  const tableContainerRef = React.useRef(null);
59
+ const containerRef = React.useRef(null);
60
+ const bottomToolbarRef = React.useRef(null);
61
+ const topToolbarRef = React.useRef(null);
35
62
  const visibleColumns = table.getVisibleLeafColumns();
63
+ const [isFullScreen] = React.useState(false);
64
+ const [tableHeight, settableHeight] = React.useState(0);
65
+ React.useEffect(() => {
66
+ const totalHeight = height;
67
+ if (totalHeight && topToolbarRef.current && bottomToolbarRef.current) {
68
+ settableHeight(totalHeight - topToolbarRef.current.offsetHeight - bottomToolbarRef.current.offsetHeight);
69
+ }
70
+ }, [id, height, editAble]);
36
71
  const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
37
72
  const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
38
73
  const columnVirtualizer = useVirtualizer({
@@ -43,15 +78,6 @@ const TableContainer = props => {
43
78
  measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
44
79
  overscan: 3 //how many columns to render on each side off screen each way (adjust this for performance)
45
80
  });
46
-
47
- // const columnSizingState = table.getState().columnSizing
48
-
49
- // React.useEffect(() => {
50
- // requestAnimationFrame(() => {
51
- // columnVirtualizer.measure()
52
- // })
53
- // }, [columnSizingState, columnVirtualizer])
54
-
55
81
  const virtualColumns = columnVirtualizer.getVirtualItems();
56
82
  const cacheColumns = columnVirtualizer.measurementsCache;
57
83
  const rightCols = table.getState().columnPinning.right?.length ? [...cacheColumns].slice(-(table.getState().columnPinning.right?.length ?? 0)) : [];
@@ -68,6 +94,61 @@ const TableContainer = props => {
68
94
  virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
69
95
  }
70
96
  return /*#__PURE__*/React.createElement("div", {
97
+ ref: containerRef,
98
+ id: id
99
+ }, (showToolbar !== false || fullScreen !== false) && /*#__PURE__*/React.createElement("div", {
100
+ ref: topToolbarRef,
101
+ className: classNames(`${prefix}-grid-top-toolbar`, {})
102
+ }, /*#__PURE__*/React.createElement("div", {
103
+ style: {
104
+ display: 'flex',
105
+ justifyContent: 'space-between',
106
+ alignItems: 'center',
107
+ gap: '.75rem'
108
+ }
109
+ }, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/React.createElement("div", {
110
+ style: {
111
+ flex: 1,
112
+ overflow: 'hidden'
113
+ }
114
+ }, /*#__PURE__*/React.createElement(Toolbar, {
115
+ items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
116
+ mode: 'scroll'
117
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
118
+ fontSize: 16
119
+ // onClick={() => handleFullScreen?.()}
120
+ ,
121
+ "data-tooltip-id": "tooltip-icon",
122
+ "data-tooltip-content": t ? t('Minimized') : 'Minimized'
123
+ }) : /*#__PURE__*/React.createElement(Maximize, {
124
+ fontSize: 16
125
+ // onClick={() => handleFullScreen?.()}
126
+ ,
127
+ "data-tooltip-id": "tooltip-icon",
128
+ "data-tooltip-content": t ? t('Full screen') : 'Full screen'
129
+ })), /*#__PURE__*/React.createElement("div", {
130
+ style: {
131
+ display: 'flex',
132
+ justifyContent: 'space-between',
133
+ alignItems: 'center',
134
+ gap: '.75rem'
135
+ }
136
+ }, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/React.createElement(Pagination, _extends({
137
+ showSizeChanger: true,
138
+ responsive: true,
139
+ size: 'small',
140
+ rootClassName: 'top-pagination',
141
+ showTotal: (total, range) =>
142
+ // @ts-ignore
143
+ `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
144
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
145
+ columnHidden: columnHidden,
146
+ columns: columns,
147
+ originColumns: propsColumns,
148
+ t: t,
149
+ columnsGroup: groupColumns,
150
+ triggerChangeColumns: triggerChangeColumns
151
+ })))), /*#__PURE__*/React.createElement("div", {
71
152
  className: classNames(`${prefix}-grid-container`, {
72
153
  'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
73
154
  'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
@@ -79,16 +160,20 @@ const TableContainer = props => {
79
160
  //our scrollable table container
80
161
  position: 'relative',
81
162
  //needed for sticky header
82
- height: tableHeight ?? '500px' //should be a fixed height
163
+ // height: tableHeight ?? '500px' //should be a fixed height
164
+ maxHeight: tableHeight //should be a fixed height
83
165
  // minWidth: table.getTotalSize()
84
166
  }
85
167
  }, /*#__PURE__*/React.createElement(TableContext.Provider, {
86
168
  value: {
169
+ locale,
87
170
  prefix,
88
171
  id,
89
172
  rowKey,
90
173
  format,
91
174
  expandable,
175
+ expanded,
176
+ setExpanded,
92
177
  dataSource,
93
178
  originData,
94
179
  // triggerFilter,
@@ -124,7 +209,42 @@ const TableContainer = props => {
124
209
  fixedRightColumns: fixedRightColumns,
125
210
  commandClick: commandClick,
126
211
  editAble: editAble,
127
- contextMenuItems: contextMenuItems
212
+ contextMenuItems: contextMenuItems,
213
+ showEmptyText: showEmptyText
214
+ }), summary && /*#__PURE__*/React.createElement(TableFooter, {
215
+ columnVirtualizer: columnVirtualizer,
216
+ table: table,
217
+ virtualPaddingLeft: virtualPaddingLeft,
218
+ virtualPaddingRight: virtualPaddingRight,
219
+ fixedLeftColumns: fixedLeftColumns,
220
+ fixedRightColumns: fixedRightColumns
221
+ })))), /*#__PURE__*/React.createElement("div", {
222
+ ref: bottomToolbarRef
223
+ }, pagination && /*#__PURE__*/React.createElement(Pagination
224
+ // style={{padding: '0.75rem 1rem'}}
225
+ , _extends({}, pagination, {
226
+ rootClassName: 'pagination-template',
227
+ showSizeChanger: true,
228
+ responsive: true,
229
+ size: 'small',
230
+ total: pagination.total,
231
+ pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
232
+ showTotal: (total, range) => `${numericFormatter((range[0] ?? 0).toString(), {
233
+ thousandSeparator: '.'
234
+ })}-${numericFormatter((range[1] ?? 0).toString(), {
235
+ thousandSeparator: '.'
236
+ })} / ${numericFormatter((total ?? 0).toString(), {
237
+ thousandSeparator: '.'
238
+ })} items`,
239
+ pageSizeOptions: [20, 50, 100, 1000, 10000],
240
+ onChange: (page, pageSize) => {
241
+ if (pagination.onChange) {
242
+ pagination.onChange(page, pageSize);
243
+ } else {
244
+ table.setPageIndex(page - 1);
245
+ table.setPageSize(pageSize);
246
+ }
247
+ }
128
248
  }))));
129
249
  };
130
250
  export default TableContainer;
@@ -1,13 +1,14 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
  import React from "react";
3
- import type { Table } from "@tanstack/react-table";
4
- import type { TableProps } from "./type";
3
+ import type { ColumnDef, Table } from "@tanstack/react-table";
4
+ import type { ColumnsTable, TableProps } from "./type";
5
5
  type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
6
6
  table: Table<T>;
7
7
  prefix: string;
8
8
  id: string;
9
9
  rowKey: any;
10
10
  originData: T[];
11
+ propsColumns: ColumnsTable;
11
12
  setIsSelectionChange: Dispatch<SetStateAction<{
12
13
  isChange: boolean;
13
14
  type: string;
@@ -18,11 +19,13 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
18
19
  onContextMenu?: (data: T) => (event: any) => void;
19
20
  tableHeight?: number;
20
21
  triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
21
- triggerChangeData?: (newData: T[], type: string) => void;
22
- mergedFilterKeys: any;
23
- setMergedFilterKeys: any;
24
- setExpanded: any;
25
- expanded: any;
22
+ mergedFilterKeys?: any;
23
+ setMergedFilterKeys?: any;
24
+ setExpanded?: any;
25
+ expanded?: any;
26
+ columns: ColumnDef<T>[];
27
+ triggerChangeColumns: any;
28
+ columnHidden: any;
26
29
  };
27
30
  declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
28
31
  export default TableContainerEdit;