es-grid-template 1.9.10 → 1.9.11

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.
@@ -25,6 +25,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
25
25
  title,
26
26
  showToolbar,
27
27
  toolbarItems,
28
+ toolbarMode,
28
29
  pagination,
29
30
  infiniteScroll,
30
31
  dataSource,
@@ -171,7 +172,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
171
172
  }
172
173
  }, /*#__PURE__*/React.createElement(Toolbar, {
173
174
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
174
- mode: 'scroll'
175
+ mode: toolbarMode
175
176
  })), /*#__PURE__*/React.createElement("div", {
176
177
  style: {
177
178
  display: 'flex',
@@ -35,10 +35,6 @@ export const ColumnsChoose = props => {
35
35
  const colsKeys = colsVisiables.map(it => it.field);
36
36
  return colsKeys.filter(it => !columnsGroup?.includes(it));
37
37
  }, [columnsGroup, originColumns]);
38
-
39
- // console.log('defaultSelectedKeys', defaultSelectedKeys)
40
- // console.log('originColumns', originColumns)
41
-
42
38
  const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(defaultSelectedKeys && defaultSelectedKeys.length ? defaultSelectedKeys : undefined, {
43
39
  value: undefined
44
40
  });
@@ -259,6 +259,7 @@ export type TableProps<RecordType = AnyObject> = {
259
259
  /** Toolbar */
260
260
  showToolbar?: boolean;
261
261
  toolbarItems?: ToolbarItem[];
262
+ toolbarMode?: 'scroll';
262
263
  showColumnChoose?: boolean;
263
264
  onChooseColumns?: (props: IOnChooseColumns) => void;
264
265
  fullScreen?: boolean;
@@ -208,9 +208,9 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
208
208
  ellipsis?: boolean;
209
209
  allowResizing?: boolean;
210
210
  allowSelection?: boolean | ((rowData: RecordType) => boolean);
211
- onCellStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
212
- onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
213
- onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
211
+ onCellStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
212
+ onCellHeaderStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
213
+ onCellFooterStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
214
214
  sumGroup?: boolean;
215
215
  getValue?: (row: any, rowIndex: number) => any;
216
216
  getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
@@ -39,6 +39,7 @@ const TableContainer = props => {
39
39
  minHeight,
40
40
  showToolbar,
41
41
  toolbarItems,
42
+ toolbarMode,
42
43
  actionTemplate,
43
44
  pagination,
44
45
  fullScreen,
@@ -221,8 +222,10 @@ const TableContainer = props => {
221
222
  overflow: 'hidden'
222
223
  }
223
224
  }, /*#__PURE__*/React.createElement(Toolbar, {
224
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
225
- mode: 'scroll'
225
+ items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom')
226
+ // mode={'scroll'}
227
+ ,
228
+ mode: toolbarMode
226
229
  })), /*#__PURE__*/React.createElement("div", {
227
230
  style: {
228
231
  display: 'flex',
@@ -90,7 +90,9 @@ const TableContainerEdit = props => {
90
90
  onCellChange,
91
91
  onDataChange,
92
92
  defaultValue,
93
+ showToolbar,
93
94
  toolbarItems,
95
+ toolbarMode,
94
96
  mergedFilterKeys,
95
97
  setMergedFilterKeys,
96
98
  expanded,
@@ -98,7 +100,6 @@ const TableContainerEdit = props => {
98
100
  onBlur,
99
101
  fullScreen,
100
102
  pagination,
101
- showToolbar,
102
103
  actionTemplate,
103
104
  showColumnChoose,
104
105
  height,
@@ -241,6 +242,8 @@ const TableContainerEdit = props => {
241
242
  const [isPasting, setIsPasting] = React.useState(false);
242
243
  // const [isFullScreen] = React.useState(false);
243
244
  const [tableHeight, settableHeight] = React.useState(0);
245
+ const [topToolbarHeight, setTopToolbarHeight] = React.useState(0);
246
+ const [bottomToolbarHeight, setBottomToolbarHeight] = React.useState(0);
244
247
 
245
248
  // const [isAddNewRow, setIsAddNewRow] = React.useState(false)
246
249
 
@@ -641,14 +644,48 @@ const TableContainerEdit = props => {
641
644
  }
642
645
  }, [columnSizingInfo]);
643
646
  React.useEffect(() => {
644
- // const totalHeight = minHeight ?? height
645
647
  const totalHeight = getTableHeight(height, minHeight);
646
648
  if (totalHeight) {
647
- const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
648
- const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
649
- settableHeight(totalHeight - topHeight - bottomHeight);
649
+ // const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0
650
+ // const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0
651
+
652
+ // settableHeight(totalHeight - topHeight - bottomHeight)
653
+ settableHeight(totalHeight - topToolbarHeight - bottomToolbarHeight);
650
654
  }
651
- }, [id, height, editAble, minHeight, toolbarItems]);
655
+ }, [height, minHeight, topToolbarHeight, bottomToolbarHeight]);
656
+ // }, [height, minHeight])
657
+
658
+ React.useEffect(() => {
659
+ if (!topToolbarRef.current) return;
660
+ const observer = new ResizeObserver(entries => {
661
+ const entry = entries[0];
662
+ // const { top, bottom } = entry.contentRect;
663
+ const {
664
+ clientHeight
665
+ } = entry.target;
666
+ setTopToolbarHeight(clientHeight);
667
+ });
668
+ observer.observe(topToolbarRef.current);
669
+ return () => {
670
+ observer.disconnect();
671
+ };
672
+ }, []);
673
+ React.useEffect(() => {
674
+ if (!bottomToolbarRef.current) return;
675
+ const observer = new ResizeObserver(entries => {
676
+ const entry = entries[0];
677
+ // const { top, bottom } = entry.contentRect;
678
+ const {
679
+ clientHeight
680
+ } = entry.target;
681
+ // setBottomToolbarHeight(top + bottom)
682
+ setBottomToolbarHeight(clientHeight);
683
+ });
684
+ observer.observe(bottomToolbarRef.current);
685
+ return () => {
686
+ observer.disconnect();
687
+ };
688
+ }, []);
652
689
  const {
653
690
  control,
654
691
  handleSubmit,
@@ -1919,7 +1956,10 @@ const TableContainerEdit = props => {
1919
1956
  id: id
1920
1957
  }, (showToolbar !== false || fullScreen !== false || showColumnChoose || title) && /*#__PURE__*/React.createElement("div", {
1921
1958
  ref: topToolbarRef,
1922
- className: classNames(`${prefix}-grid-top-toolbar`, {})
1959
+ className: classNames(`${prefix}-grid-top-toolbar`, {}),
1960
+ style: {
1961
+ transition: 'max-height 0.3s ease'
1962
+ }
1923
1963
  }, /*#__PURE__*/React.createElement("div", {
1924
1964
  style: {
1925
1965
  display: 'flex',
@@ -1940,7 +1980,7 @@ const TableContainerEdit = props => {
1940
1980
  width: '100%'
1941
1981
  },
1942
1982
  items: toolbarItemsTop ?? [],
1943
- mode: 'scroll',
1983
+ mode: toolbarMode,
1944
1984
  onClick: ({}) => {
1945
1985
  setEditingKey('');
1946
1986
  }
@@ -2081,7 +2121,10 @@ const TableContainerEdit = props => {
2081
2121
  fixedLeftColumns: fixedLeftColumns,
2082
2122
  fixedRightColumns: fixedRightColumns
2083
2123
  }))), /*#__PURE__*/React.createElement("div", {
2084
- ref: bottomToolbarRef
2124
+ ref: bottomToolbarRef,
2125
+ style: {
2126
+ transition: 'max-height 0.3s ease'
2127
+ }
2085
2128
  }, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
2086
2129
  className: classNames('ui-rc-toolbar-bottom', {
2087
2130
  'ui-rc-toolbar-bottom_border-bottom': !pagination || infiniteScroll
@@ -2091,7 +2134,9 @@ const TableContainerEdit = props => {
2091
2134
  width: '100%'
2092
2135
  },
2093
2136
  items: toolbarItemsBottom ?? [],
2094
- mode: 'scroll',
2137
+ mode: toolbarMode
2138
+ // mode={'scroll'}
2139
+ ,
2095
2140
  onClick: ({}) => {
2096
2141
  setEditingKey('');
2097
2142
  }
@@ -1096,7 +1096,7 @@ const TableBodyCellEdit = props => {
1096
1096
  };
1097
1097
  const cellValue = cell.getValue();
1098
1098
  const rowIndex = cell.row.index;
1099
- const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
1099
+ const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, true);
1100
1100
  return /*#__PURE__*/React.createElement("div", {
1101
1101
  key: cell.id,
1102
1102
  ref: el => {
@@ -293,7 +293,9 @@ const Grid = props => {
293
293
  style: {
294
294
  minHeight: minHeight ?? undefined,
295
295
  maxHeight: height ?? undefined,
296
- backgroundColor: theme?.backgroundColor ?? undefined
296
+ backgroundColor: theme?.backgroundColor ?? undefined,
297
+ transition: 'max-height 0.3s ease',
298
+ overflow: 'hidden'
297
299
  }
298
300
  }, /*#__PURE__*/React.createElement(DndContext, {
299
301
  collisionDetection: closestCenter,
@@ -38,6 +38,7 @@ const TableContainer = props => {
38
38
  setFilterChange,
39
39
  height,
40
40
  minHeight,
41
+ toolbarMode,
41
42
  showToolbar,
42
43
  toolbarItems,
43
44
  actionTemplate,
@@ -181,7 +182,7 @@ const TableContainer = props => {
181
182
  }
182
183
  }, /*#__PURE__*/React.createElement(Toolbar, {
183
184
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
184
- mode: 'scroll'
185
+ mode: toolbarMode
185
186
  })), /*#__PURE__*/React.createElement("div", {
186
187
  style: {
187
188
  display: 'flex',
@@ -35,6 +35,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
35
35
  title,
36
36
  showToolbar,
37
37
  toolbarItems,
38
+ toolbarMode,
38
39
  pagination,
39
40
  infiniteScroll,
40
41
  dataSource,
@@ -181,7 +182,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
181
182
  }
182
183
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
183
184
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
184
- mode: 'scroll'
185
+ mode: toolbarMode
185
186
  })), /*#__PURE__*/_react.default.createElement("div", {
186
187
  style: {
187
188
  display: 'flex',
@@ -44,10 +44,6 @@ const ColumnsChoose = props => {
44
44
  const colsKeys = colsVisiables.map(it => it.field);
45
45
  return colsKeys.filter(it => !columnsGroup?.includes(it));
46
46
  }, [columnsGroup, originColumns]);
47
-
48
- // console.log('defaultSelectedKeys', defaultSelectedKeys)
49
- // console.log('originColumns', originColumns)
50
-
51
47
  const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)(defaultSelectedKeys && defaultSelectedKeys.length ? defaultSelectedKeys : undefined, {
52
48
  value: undefined
53
49
  });
@@ -259,6 +259,7 @@ export type TableProps<RecordType = AnyObject> = {
259
259
  /** Toolbar */
260
260
  showToolbar?: boolean;
261
261
  toolbarItems?: ToolbarItem[];
262
+ toolbarMode?: 'scroll';
262
263
  showColumnChoose?: boolean;
263
264
  onChooseColumns?: (props: IOnChooseColumns) => void;
264
265
  fullScreen?: boolean;
@@ -46,6 +46,7 @@ const TableContainer = props => {
46
46
  minHeight,
47
47
  showToolbar,
48
48
  toolbarItems,
49
+ toolbarMode,
49
50
  actionTemplate,
50
51
  pagination,
51
52
  fullScreen,
@@ -228,8 +229,10 @@ const TableContainer = props => {
228
229
  overflow: 'hidden'
229
230
  }
230
231
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
231
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
232
- mode: 'scroll'
232
+ items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom')
233
+ // mode={'scroll'}
234
+ ,
235
+ mode: toolbarMode
233
236
  })), /*#__PURE__*/_react.default.createElement("div", {
234
237
  style: {
235
238
  display: 'flex',
@@ -97,7 +97,9 @@ const TableContainerEdit = props => {
97
97
  onCellChange,
98
98
  onDataChange,
99
99
  defaultValue,
100
+ showToolbar,
100
101
  toolbarItems,
102
+ toolbarMode,
101
103
  mergedFilterKeys,
102
104
  setMergedFilterKeys,
103
105
  expanded,
@@ -105,7 +107,6 @@ const TableContainerEdit = props => {
105
107
  onBlur,
106
108
  fullScreen,
107
109
  pagination,
108
- showToolbar,
109
110
  actionTemplate,
110
111
  showColumnChoose,
111
112
  height,
@@ -248,6 +249,8 @@ const TableContainerEdit = props => {
248
249
  const [isPasting, setIsPasting] = _react.default.useState(false);
249
250
  // const [isFullScreen] = React.useState(false);
250
251
  const [tableHeight, settableHeight] = _react.default.useState(0);
252
+ const [topToolbarHeight, setTopToolbarHeight] = _react.default.useState(0);
253
+ const [bottomToolbarHeight, setBottomToolbarHeight] = _react.default.useState(0);
251
254
 
252
255
  // const [isAddNewRow, setIsAddNewRow] = React.useState(false)
253
256
 
@@ -648,14 +651,48 @@ const TableContainerEdit = props => {
648
651
  }
649
652
  }, [columnSizingInfo]);
650
653
  _react.default.useEffect(() => {
651
- // const totalHeight = minHeight ?? height
652
654
  const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
653
655
  if (totalHeight) {
654
- const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
655
- const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
656
- settableHeight(totalHeight - topHeight - bottomHeight);
656
+ // const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0
657
+ // const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0
658
+
659
+ // settableHeight(totalHeight - topHeight - bottomHeight)
660
+ settableHeight(totalHeight - topToolbarHeight - bottomToolbarHeight);
657
661
  }
658
- }, [id, height, editAble, minHeight, toolbarItems]);
662
+ }, [height, minHeight, topToolbarHeight, bottomToolbarHeight]);
663
+ // }, [height, minHeight])
664
+
665
+ _react.default.useEffect(() => {
666
+ if (!topToolbarRef.current) return;
667
+ const observer = new ResizeObserver(entries => {
668
+ const entry = entries[0];
669
+ // const { top, bottom } = entry.contentRect;
670
+ const {
671
+ clientHeight
672
+ } = entry.target;
673
+ setTopToolbarHeight(clientHeight);
674
+ });
675
+ observer.observe(topToolbarRef.current);
676
+ return () => {
677
+ observer.disconnect();
678
+ };
679
+ }, []);
680
+ _react.default.useEffect(() => {
681
+ if (!bottomToolbarRef.current) return;
682
+ const observer = new ResizeObserver(entries => {
683
+ const entry = entries[0];
684
+ // const { top, bottom } = entry.contentRect;
685
+ const {
686
+ clientHeight
687
+ } = entry.target;
688
+ // setBottomToolbarHeight(top + bottom)
689
+ setBottomToolbarHeight(clientHeight);
690
+ });
691
+ observer.observe(bottomToolbarRef.current);
692
+ return () => {
693
+ observer.disconnect();
694
+ };
695
+ }, []);
659
696
  const {
660
697
  control,
661
698
  handleSubmit,
@@ -1926,7 +1963,10 @@ const TableContainerEdit = props => {
1926
1963
  id: id
1927
1964
  }, (showToolbar !== false || fullScreen !== false || showColumnChoose || title) && /*#__PURE__*/_react.default.createElement("div", {
1928
1965
  ref: topToolbarRef,
1929
- className: (0, _classnames.default)(`${prefix}-grid-top-toolbar`, {})
1966
+ className: (0, _classnames.default)(`${prefix}-grid-top-toolbar`, {}),
1967
+ style: {
1968
+ transition: 'max-height 0.3s ease'
1969
+ }
1930
1970
  }, /*#__PURE__*/_react.default.createElement("div", {
1931
1971
  style: {
1932
1972
  display: 'flex',
@@ -1947,7 +1987,7 @@ const TableContainerEdit = props => {
1947
1987
  width: '100%'
1948
1988
  },
1949
1989
  items: toolbarItemsTop ?? [],
1950
- mode: 'scroll',
1990
+ mode: toolbarMode,
1951
1991
  onClick: ({}) => {
1952
1992
  setEditingKey('');
1953
1993
  }
@@ -2088,7 +2128,10 @@ const TableContainerEdit = props => {
2088
2128
  fixedLeftColumns: fixedLeftColumns,
2089
2129
  fixedRightColumns: fixedRightColumns
2090
2130
  }))), /*#__PURE__*/_react.default.createElement("div", {
2091
- ref: bottomToolbarRef
2131
+ ref: bottomToolbarRef,
2132
+ style: {
2133
+ transition: 'max-height 0.3s ease'
2134
+ }
2092
2135
  }, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
2093
2136
  className: (0, _classnames.default)('ui-rc-toolbar-bottom', {
2094
2137
  'ui-rc-toolbar-bottom_border-bottom': !pagination || infiniteScroll
@@ -2098,7 +2141,9 @@ const TableContainerEdit = props => {
2098
2141
  width: '100%'
2099
2142
  },
2100
2143
  items: toolbarItemsBottom ?? [],
2101
- mode: 'scroll',
2144
+ mode: toolbarMode
2145
+ // mode={'scroll'}
2146
+ ,
2102
2147
  onClick: ({}) => {
2103
2148
  setEditingKey('');
2104
2149
  }
@@ -1103,7 +1103,7 @@ const TableBodyCellEdit = props => {
1103
1103
  };
1104
1104
  const cellValue = cell.getValue();
1105
1105
  const rowIndex = cell.row.index;
1106
- const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
1106
+ const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, format, true);
1107
1107
  return /*#__PURE__*/_react.default.createElement("div", {
1108
1108
  key: cell.id,
1109
1109
  ref: el => {
@@ -298,7 +298,9 @@ const Grid = props => {
298
298
  style: {
299
299
  minHeight: minHeight ?? undefined,
300
300
  maxHeight: height ?? undefined,
301
- backgroundColor: theme?.backgroundColor ?? undefined
301
+ backgroundColor: theme?.backgroundColor ?? undefined,
302
+ transition: 'max-height 0.3s ease',
303
+ overflow: 'hidden'
302
304
  }
303
305
  }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
304
306
  collisionDetection: _core.closestCenter,
@@ -46,6 +46,7 @@ const TableContainer = props => {
46
46
  setFilterChange,
47
47
  height,
48
48
  minHeight,
49
+ toolbarMode,
49
50
  showToolbar,
50
51
  toolbarItems,
51
52
  actionTemplate,
@@ -189,7 +190,7 @@ const TableContainer = props => {
189
190
  }
190
191
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
191
192
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
192
- mode: 'scroll'
193
+ mode: toolbarMode
193
194
  })), /*#__PURE__*/_react.default.createElement("div", {
194
195
  style: {
195
196
  display: 'flex',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.9.10",
3
+ "version": "1.9.11",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",
@@ -66,7 +66,7 @@
66
66
  "rc-checkbox": "^3.5.0",
67
67
  "rc-dropdown": "^4.2.1",
68
68
  "rc-field-form": "^2.6.0",
69
- "rc-master-ui": "1.1.52",
69
+ "rc-master-ui": "1.1.53",
70
70
  "rc-select": "^14.16.3",
71
71
  "rc-tooltip": "^6.3.0",
72
72
  "rc-tree": "^5.10.1",