es-grid-template 1.7.25 → 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.
@@ -52,7 +52,8 @@ const TableContainer = props => {
52
52
  triggerChangeColumns,
53
53
  columnHidden,
54
54
  expanded,
55
- setExpanded
55
+ setExpanded,
56
+ showEmptyText
56
57
  } = props;
57
58
  const tableContainerRef = React.useRef(null);
58
59
  const containerRef = React.useRef(null);
@@ -159,7 +160,8 @@ const TableContainer = props => {
159
160
  //our scrollable table container
160
161
  position: 'relative',
161
162
  //needed for sticky header
162
- 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
163
165
  // minWidth: table.getTotalSize()
164
166
  }
165
167
  }, /*#__PURE__*/React.createElement(TableContext.Provider, {
@@ -207,10 +209,9 @@ const TableContainer = props => {
207
209
  fixedRightColumns: fixedRightColumns,
208
210
  commandClick: commandClick,
209
211
  editAble: editAble,
210
- contextMenuItems: contextMenuItems
211
- }), summary && /*#__PURE__*/React.createElement(TableFooter
212
- // tableContainerRef={tableContainerRef}
213
- , {
212
+ contextMenuItems: contextMenuItems,
213
+ showEmptyText: showEmptyText
214
+ }), summary && /*#__PURE__*/React.createElement(TableFooter, {
214
215
  columnVirtualizer: columnVirtualizer,
215
216
  table: table,
216
217
  virtualPaddingLeft: virtualPaddingLeft,
@@ -99,7 +99,8 @@ const TableContainerEdit = props => {
99
99
  columns,
100
100
  propsColumns,
101
101
  triggerChangeColumns,
102
- columnHidden
102
+ columnHidden,
103
+ showEmptyText
103
104
  } = props;
104
105
  const containerRef = React.useRef(null);
105
106
  const bottomToolbarRef = React.useRef(null);
@@ -1164,7 +1165,8 @@ const TableContainerEdit = props => {
1164
1165
  //our scrollable table container
1165
1166
  position: 'relative',
1166
1167
  //needed for sticky header
1167
- height: tableHeight //should be a fixed height
1168
+ // height: tableHeight, //should be a fixed height
1169
+ maxHeight: tableHeight //should be a fixed height
1168
1170
  }
1169
1171
  }, /*#__PURE__*/React.createElement(TableContext.Provider, {
1170
1172
  value: {
@@ -1221,8 +1223,8 @@ const TableContainerEdit = props => {
1221
1223
  }, /*#__PURE__*/React.createElement("table", {
1222
1224
  // className={`${prefix}-grid-container`}
1223
1225
  style: {
1224
- display: 'grid',
1225
- minWidth: table.getTotalSize()
1226
+ display: 'grid'
1227
+ // minWidth: table.getTotalSize()
1226
1228
  }
1227
1229
  }, /*#__PURE__*/React.createElement(TableHead, {
1228
1230
  tableContainerRef: tableContainerRef,
@@ -1243,7 +1245,8 @@ const TableContainerEdit = props => {
1243
1245
  fixedRightColumns: fixedRightColumns,
1244
1246
  commandClick: commandClick,
1245
1247
  editAble: editAble,
1246
- contextMenuItems: contextMenuItems
1248
+ contextMenuItems: contextMenuItems,
1249
+ showEmptyText: showEmptyText
1247
1250
  }), summary && /*#__PURE__*/React.createElement(TableFooter, {
1248
1251
  columnVirtualizer: columnVirtualizer,
1249
1252
  table: table,
@@ -13,7 +13,8 @@ interface TableBodyProps<T> {
13
13
  commandClick?: (args: CommandClick) => void;
14
14
  editAble?: boolean;
15
15
  tableId: string;
16
+ showEmptyText?: boolean;
16
17
  [key: string]: any;
17
18
  }
18
- declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
19
+ declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, showEmptyText, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
19
20
  export default TableBody;
@@ -2,8 +2,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import TableBodyRow from "./TableBodyRow";
3
3
  import { useVirtualizer } from "@tanstack/react-virtual";
4
4
  // import type { Dispatch, SetStateAction } from "react";
5
- import React from "react";
5
+ import React, { Fragment } from "react";
6
6
  import { TableContext } from "../useContext";
7
+ import { Empty } from "rc-master-ui";
7
8
  const TableBody = ({
8
9
  columnVirtualizer,
9
10
  table,
@@ -13,6 +14,7 @@ const TableBody = ({
13
14
  fixedLeftColumns,
14
15
  fixedRightColumns,
15
16
  tableId,
17
+ showEmptyText,
16
18
  ...rest
17
19
  }) => {
18
20
  const {
@@ -20,7 +22,8 @@ const TableBody = ({
20
22
  } = table.getRowModel();
21
23
  const {
22
24
  editingKey,
23
- prefix
25
+ prefix,
26
+ locale
24
27
  } = React.useContext(TableContext);
25
28
 
26
29
  //dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
@@ -38,11 +41,27 @@ const TableBody = ({
38
41
  className: `${prefix}-grid-tbody`,
39
42
  style: {
40
43
  display: 'grid',
41
- height: `${rowVirtualizer.getTotalSize()}px`,
44
+ // height: `${rowVirtualizer.getTotalSize()}px`, //tells scrollbar how big the table is
45
+ height: showEmptyText && rows.length === 0 ? `140px` : `${rowVirtualizer.getTotalSize()}px`,
42
46
  //tells scrollbar how big the table is
43
47
  position: 'relative' //needed for absolute positioning of rows
44
48
  }
45
- }, virtualRows.map(virtualRow => {
49
+ }, showEmptyText && rows.length === 0 ? /*#__PURE__*/React.createElement("tr", {
50
+ style: {
51
+ // transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
52
+ }
53
+ }, /*#__PURE__*/React.createElement("td", {
54
+ // colSpan={30}
55
+ style: {
56
+ position: "sticky",
57
+ left: 0,
58
+ width: tableContainerRef.current?.clientWidth,
59
+ overflow: 'hidden'
60
+ }
61
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Empty, {
62
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
63
+ description: locale?.emptyText
64
+ })))) : /*#__PURE__*/React.createElement(Fragment, null, virtualRows.map(virtualRow => {
46
65
  const row = rows[virtualRow.index];
47
66
  const isEditing = row.id === editingKey;
48
67
  return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, rest, {
@@ -59,6 +78,6 @@ const TableBody = ({
59
78
  fixedRightColumns: fixedRightColumns,
60
79
  isEditing: isEditing
61
80
  }));
62
- }));
81
+ })));
63
82
  };
64
83
  export default TableBody;
@@ -880,7 +880,9 @@ const TableBodyCellEdit = props => {
880
880
  record: record
881
881
  // rowKey={rowKey}
882
882
  }) : /*#__PURE__*/React.createElement("div", {
883
- className: "ui-rc_cell-content"
883
+ className: classNames('ui-rc_cell-content', {
884
+ 'select-cell': ['select', 'selectTable', 'asyncSelect'].includes(getEditType(columnMeta, record))
885
+ })
884
886
  }, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/React.createElement("div", {
885
887
  className: "ui-rc-table-row-expand-trigger",
886
888
  style: {
@@ -914,7 +916,13 @@ const TableBodyCellEdit = props => {
914
916
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
915
917
  })) : /*#__PURE__*/React.createElement("span", {
916
918
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
917
- }))), flexRender(cell.column.columnDef.cell, cell.getContext())), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/React.createElement("div", {
919
+ }))), flexRender(cell.column.columnDef.cell, cell.getContext()), (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/React.createElement("span", {
920
+ className: 'caret-down',
921
+ onClick: e => {
922
+ handleEdit(e);
923
+ // setEditingKey?.(cell.row.id)
924
+ }
925
+ })), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/React.createElement("div", {
918
926
  className: 'dragging-point',
919
927
  onMouseDown: e => {
920
928
  e.preventDefault();
@@ -12,5 +12,5 @@ interface TableHeadRowProps<T> {
12
12
  fixedRightColumns: Column<T, unknown>[];
13
13
  rowHeaderVirtual: VirtualItem;
14
14
  }
15
- declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, fixedLeftColumns, fixedRightColumns, rowHeaderVirtual }: TableHeadRowProps<any>) => React.JSX.Element;
15
+ declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, rowHeaderVirtual }: TableHeadRowProps<any>) => React.JSX.Element;
16
16
  export default TableHeadRow;
@@ -8,8 +8,8 @@ const TableHeadRow = ({
8
8
  columnVirtualizer,
9
9
  rowHeaderVirtualizer,
10
10
  headerGroup,
11
- // virtualPaddingLeft,
12
- // virtualPaddingRight,
11
+ virtualPaddingLeft,
12
+ virtualPaddingRight,
13
13
  fixedLeftColumns,
14
14
  fixedRightColumns,
15
15
  rowHeaderVirtual
@@ -17,9 +17,8 @@ const TableHeadRow = ({
17
17
  const {
18
18
  prefix
19
19
  } = React.useContext(TableContext);
20
-
21
- // const virtualColumns = columnVirtualizer.getVirtualItems()
22
- const virtualColumns = columnVirtualizer.measurementsCache;
20
+ const virtualColumns = columnVirtualizer.getVirtualItems();
21
+ // const virtualColumns = columnVirtualizer.measurementsCache
23
22
 
24
23
  // console.log('virtualColumns', virtualColumns)
25
24
 
@@ -50,6 +49,12 @@ const TableHeadRow = ({
50
49
  header: headerGroup.headers.find(h => h.column.id === column.id)
51
50
  // column={column as any}
52
51
  });
52
+ }) : null, virtualPaddingLeft ? /*#__PURE__*/React.createElement("th", {
53
+ className: "",
54
+ style: {
55
+ display: 'flex',
56
+ width: virtualPaddingLeft
57
+ }
53
58
  }) : null, virtualColumns.map(virtualColumn => {
54
59
  const header = headerGroup.headers[virtualColumn.index];
55
60
  const isFixed = table.getState().columnPinning.left?.includes(header?.column?.id) || table.getState().columnPinning.right?.includes(header?.column?.id);
@@ -71,6 +76,15 @@ const TableHeadRow = ({
71
76
  key: column.id,
72
77
  header: headerGroup.headers.find(h => h.column.id === column.id)
73
78
  // column={column as any}
74
- })) : null));
79
+ })) : null, virtualPaddingRight ?
80
+ /*#__PURE__*/
81
+ //fake empty column to the right for virtualization scroll padding
82
+ React.createElement("th", {
83
+ className: "nnnnnnnnnnnn",
84
+ style: {
85
+ display: 'flex',
86
+ width: virtualPaddingRight
87
+ }
88
+ }) : null));
75
89
  };
76
90
  export default TableHeadRow;
@@ -306,7 +306,7 @@ export function getFixedFields(columns, type) {
306
306
  const result = [];
307
307
  function traverse(cols) {
308
308
  for (const col of cols) {
309
- if (col.fixed === type && col.field) {
309
+ if ((col.fixed ?? col.fixedType) === type && col.field) {
310
310
  result.push(col.field);
311
311
  }
312
312
  if (col.children && col.children.length > 0) {
@@ -1769,13 +1769,13 @@ export function isObjEqual(obj1, obj2) {
1769
1769
  export const sortByType = arr => {
1770
1770
  if (arr) {
1771
1771
  return arr.sort((a, b) => {
1772
- if (a.fixed === 'left' && b.fixed !== 'left') {
1772
+ if ((a.fixed ?? a.fixedType) === 'left' && (b.fixed ?? b.fixedType) !== 'left') {
1773
1773
  return -1;
1774
- } else if (a.fixed !== 'left' && b.fixed === 'left') {
1774
+ } else if ((a.fixed ?? a.fixedType) !== 'left' && (b.fixed ?? b.fixedType) === 'left') {
1775
1775
  return 1;
1776
- } else if (a.fixed === 'right' && b.fixed !== 'right') {
1776
+ } else if ((a.fixed ?? a.fixedType) === 'right' && (b.fixed ?? b.fixedType) !== 'right') {
1777
1777
  return 1;
1778
- } else if (a.fixed !== 'right' && b.fixed === 'right') {
1778
+ } else if ((a.fixed ?? a.fixedType) !== 'right' && (b.fixed ?? b.fixedType) === 'right') {
1779
1779
  return -1;
1780
1780
  }
1781
1781
  return 0;
@@ -1843,14 +1843,9 @@ export const updateColumns1 = (columns, includes) => {
1843
1843
  newColumn.children = updateColumns1(newColumn.children, includes);
1844
1844
  hasVisibleChild = newColumn.children.some(child => !child.hidden);
1845
1845
  }
1846
-
1847
- // newColumn.hidden = newColumn.key && !includes.includes(newColumn.key)
1848
1846
  newColumn.visible = !!(newColumn.field && includes.includes(newColumn.field));
1849
- // newColumn.fixed = newColumn.field && !includes.includes(newColumn.field) ? undefined : newColumn.fixed
1850
-
1851
1847
  if (newColumn.children && newColumn.children.length > 0) {
1852
1848
  newColumn.visible = !hasVisibleChild;
1853
- // newColumn.fixed = !hasVisibleChild ? undefined : newColumn.fixed
1854
1849
  }
1855
1850
  return newColumn;
1856
1851
  });
@@ -49,9 +49,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
49
49
  padding: 7px 8px;
50
50
  border-inline-end: 1px solid $tableBorderColor;
51
51
  // border-bottom: 1px solid $tableBorderColor;
52
-
53
52
  // &.#{$prefix}-grid-cell-fix-left-last {
54
-
55
53
  // &::after {
56
54
  // position: absolute;
57
55
  // top: 0;
@@ -64,10 +62,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
64
62
  // pointer-events: none;
65
63
  // box-shadow: inset 10px 0 8px -8px rgba(5, 5, 5, 0.09);
66
64
  // }
67
-
68
-
69
65
  // }
70
-
71
66
  // &.#{$prefix}-grid-cell-fix-right-first {
72
67
  // &::after {
73
68
  // position: absolute;
@@ -81,7 +76,6 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
81
76
  // pointer-events: none;
82
77
  // box-shadow: inset -10px 0 8px -8px rgba(5, 5, 5, 0.09);
83
78
  // }
84
-
85
79
  // &::before {
86
80
  // content: "";
87
81
  // position: absolute;
@@ -101,6 +95,31 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
101
95
  white-space: nowrap;
102
96
  text-overflow: ellipsis;
103
97
  word-break: keep-all;
98
+
99
+ &.select-cell {
100
+ padding-right: 18px;
101
+ position: relative;
102
+
103
+ }
104
+
105
+ .caret-down {
106
+ float: right;
107
+ position: absolute;
108
+ right: 0;
109
+
110
+ &::before {
111
+ content: '';
112
+ display: inline-block;
113
+ margin-left: 4px;
114
+ vertical-align: middle;
115
+ width: 0;
116
+ height: 0;
117
+ border-left: 5px solid transparent;
118
+ border-right: 5px solid transparent;
119
+ border-top: 5px solid #6f7777;
120
+ }
121
+ }
122
+
104
123
  }
105
124
 
106
125
  }
@@ -42,7 +42,7 @@ const Grid = props => {
42
42
  onSorter,
43
43
  onFilter,
44
44
  groupColumns,
45
- height,
45
+ height = 700,
46
46
  editAble,
47
47
  triggerChangeColumns,
48
48
  ...rest
@@ -203,7 +203,8 @@ const Grid = props => {
203
203
  return /*#__PURE__*/React.createElement("div", {
204
204
  className: `${prefix}-grid`,
205
205
  style: {
206
- height: height ?? undefined
206
+ // height: height ?? undefined
207
+ maxHeight: height ?? undefined
207
208
  }
208
209
  }, /*#__PURE__*/React.createElement(DndContext, {
209
210
  collisionDetection: closestCenter,
@@ -89,7 +89,7 @@ export type ColumnTable<RecordType = AnyObject> = {
89
89
  allowFiltering?: boolean;
90
90
  /**
91
91
  * @deprecated Please use `allowSorter` instead.
92
- * @since 1.0.0
92
+ * @since 1.7.25
93
93
  */
94
94
  sorter?: boolean;
95
95
  allowSorter?: boolean;
@@ -126,7 +126,7 @@ export type ColumnTable<RecordType = AnyObject> = {
126
126
  editFromSettings?: IEditFromSettings;
127
127
  /**
128
128
  * @deprecated Please use `fixed` instead.
129
- * @since 1.6.5
129
+ * @since 1.7.25
130
130
  */
131
131
  fixedType?: FixedType;
132
132
  fixed?: FixedType;
@@ -60,7 +60,8 @@ const TableContainer = props => {
60
60
  triggerChangeColumns,
61
61
  columnHidden,
62
62
  expanded,
63
- setExpanded
63
+ setExpanded,
64
+ showEmptyText
64
65
  } = props;
65
66
  const tableContainerRef = _react.default.useRef(null);
66
67
  const containerRef = _react.default.useRef(null);
@@ -167,7 +168,8 @@ const TableContainer = props => {
167
168
  //our scrollable table container
168
169
  position: 'relative',
169
170
  //needed for sticky header
170
- height: tableHeight ?? '500px' //should be a fixed height
171
+ // height: tableHeight ?? '500px' //should be a fixed height
172
+ maxHeight: tableHeight //should be a fixed height
171
173
  // minWidth: table.getTotalSize()
172
174
  }
173
175
  }, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
@@ -215,10 +217,9 @@ const TableContainer = props => {
215
217
  fixedRightColumns: fixedRightColumns,
216
218
  commandClick: commandClick,
217
219
  editAble: editAble,
218
- contextMenuItems: contextMenuItems
219
- }), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default
220
- // tableContainerRef={tableContainerRef}
221
- , {
220
+ contextMenuItems: contextMenuItems,
221
+ showEmptyText: showEmptyText
222
+ }), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default, {
222
223
  columnVirtualizer: columnVirtualizer,
223
224
  table: table,
224
225
  virtualPaddingLeft: virtualPaddingLeft,
@@ -108,7 +108,8 @@ const TableContainerEdit = props => {
108
108
  columns,
109
109
  propsColumns,
110
110
  triggerChangeColumns,
111
- columnHidden
111
+ columnHidden,
112
+ showEmptyText
112
113
  } = props;
113
114
  const containerRef = _react.default.useRef(null);
114
115
  const bottomToolbarRef = _react.default.useRef(null);
@@ -1173,7 +1174,8 @@ const TableContainerEdit = props => {
1173
1174
  //our scrollable table container
1174
1175
  position: 'relative',
1175
1176
  //needed for sticky header
1176
- height: tableHeight //should be a fixed height
1177
+ // height: tableHeight, //should be a fixed height
1178
+ maxHeight: tableHeight //should be a fixed height
1177
1179
  }
1178
1180
  }, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
1179
1181
  value: {
@@ -1230,8 +1232,8 @@ const TableContainerEdit = props => {
1230
1232
  }, /*#__PURE__*/_react.default.createElement("table", {
1231
1233
  // className={`${prefix}-grid-container`}
1232
1234
  style: {
1233
- display: 'grid',
1234
- minWidth: table.getTotalSize()
1235
+ display: 'grid'
1236
+ // minWidth: table.getTotalSize()
1235
1237
  }
1236
1238
  }, /*#__PURE__*/_react.default.createElement(_TableHead.default, {
1237
1239
  tableContainerRef: tableContainerRef,
@@ -1252,7 +1254,8 @@ const TableContainerEdit = props => {
1252
1254
  fixedRightColumns: fixedRightColumns,
1253
1255
  commandClick: commandClick,
1254
1256
  editAble: editAble,
1255
- contextMenuItems: contextMenuItems
1257
+ contextMenuItems: contextMenuItems,
1258
+ showEmptyText: showEmptyText
1256
1259
  }), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default, {
1257
1260
  columnVirtualizer: columnVirtualizer,
1258
1261
  table: table,
@@ -13,7 +13,8 @@ interface TableBodyProps<T> {
13
13
  commandClick?: (args: CommandClick) => void;
14
14
  editAble?: boolean;
15
15
  tableId: string;
16
+ showEmptyText?: boolean;
16
17
  [key: string]: any;
17
18
  }
18
- declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
19
+ declare const TableBody: <RecordType extends object>({ columnVirtualizer, table, tableContainerRef, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, tableId, showEmptyText, ...rest }: TableBodyProps<RecordType>) => React.JSX.Element;
19
20
  export default TableBody;
@@ -8,8 +8,11 @@ exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _TableBodyRow = _interopRequireDefault(require("./TableBodyRow"));
10
10
  var _reactVirtual = require("@tanstack/react-virtual");
11
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
12
  var _useContext = require("../useContext");
13
+ var _rcMasterUi = require("rc-master-ui");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
16
  // import type { Dispatch, SetStateAction } from "react";
14
17
 
15
18
  const TableBody = ({
@@ -21,6 +24,7 @@ const TableBody = ({
21
24
  fixedLeftColumns,
22
25
  fixedRightColumns,
23
26
  tableId,
27
+ showEmptyText,
24
28
  ...rest
25
29
  }) => {
26
30
  const {
@@ -28,7 +32,8 @@ const TableBody = ({
28
32
  } = table.getRowModel();
29
33
  const {
30
34
  editingKey,
31
- prefix
35
+ prefix,
36
+ locale
32
37
  } = _react.default.useContext(_useContext.TableContext);
33
38
 
34
39
  //dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
@@ -46,11 +51,27 @@ const TableBody = ({
46
51
  className: `${prefix}-grid-tbody`,
47
52
  style: {
48
53
  display: 'grid',
49
- height: `${rowVirtualizer.getTotalSize()}px`,
54
+ // height: `${rowVirtualizer.getTotalSize()}px`, //tells scrollbar how big the table is
55
+ height: showEmptyText && rows.length === 0 ? `140px` : `${rowVirtualizer.getTotalSize()}px`,
50
56
  //tells scrollbar how big the table is
51
57
  position: 'relative' //needed for absolute positioning of rows
52
58
  }
53
- }, virtualRows.map(virtualRow => {
59
+ }, showEmptyText && rows.length === 0 ? /*#__PURE__*/_react.default.createElement("tr", {
60
+ style: {
61
+ // transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
62
+ }
63
+ }, /*#__PURE__*/_react.default.createElement("td", {
64
+ // colSpan={30}
65
+ style: {
66
+ position: "sticky",
67
+ left: 0,
68
+ width: tableContainerRef.current?.clientWidth,
69
+ overflow: 'hidden'
70
+ }
71
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Empty, {
72
+ image: _rcMasterUi.Empty.PRESENTED_IMAGE_SIMPLE,
73
+ description: locale?.emptyText
74
+ })))) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null, virtualRows.map(virtualRow => {
54
75
  const row = rows[virtualRow.index];
55
76
  const isEditing = row.id === editingKey;
56
77
  return /*#__PURE__*/_react.default.createElement(_TableBodyRow.default, (0, _extends2.default)({}, rest, {
@@ -67,6 +88,6 @@ const TableBody = ({
67
88
  fixedRightColumns: fixedRightColumns,
68
89
  isEditing: isEditing
69
90
  }));
70
- }));
91
+ })));
71
92
  };
72
93
  var _default = exports.default = TableBody;
@@ -887,7 +887,9 @@ const TableBodyCellEdit = props => {
887
887
  record: record
888
888
  // rowKey={rowKey}
889
889
  }) : /*#__PURE__*/_react.default.createElement("div", {
890
- className: "ui-rc_cell-content"
890
+ className: (0, _classnames.default)('ui-rc_cell-content', {
891
+ 'select-cell': ['select', 'selectTable', 'asyncSelect'].includes((0, _utils.getEditType)(columnMeta, record))
892
+ })
891
893
  }, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
892
894
  className: "ui-rc-table-row-expand-trigger",
893
895
  style: {
@@ -921,7 +923,13 @@ const TableBodyCellEdit = props => {
921
923
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
922
924
  })) : /*#__PURE__*/_react.default.createElement("span", {
923
925
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
924
- }))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
926
+ }))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext()), (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/_react.default.createElement("span", {
927
+ className: 'caret-down',
928
+ onClick: e => {
929
+ handleEdit(e);
930
+ // setEditingKey?.(cell.row.id)
931
+ }
932
+ })), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
925
933
  className: 'dragging-point',
926
934
  onMouseDown: e => {
927
935
  e.preventDefault();
@@ -12,5 +12,5 @@ interface TableHeadRowProps<T> {
12
12
  fixedRightColumns: Column<T, unknown>[];
13
13
  rowHeaderVirtual: VirtualItem;
14
14
  }
15
- declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, fixedLeftColumns, fixedRightColumns, rowHeaderVirtual }: TableHeadRowProps<any>) => React.JSX.Element;
15
+ declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, rowHeaderVirtual }: TableHeadRowProps<any>) => React.JSX.Element;
16
16
  export default TableHeadRow;
@@ -16,8 +16,8 @@ const TableHeadRow = ({
16
16
  columnVirtualizer,
17
17
  rowHeaderVirtualizer,
18
18
  headerGroup,
19
- // virtualPaddingLeft,
20
- // virtualPaddingRight,
19
+ virtualPaddingLeft,
20
+ virtualPaddingRight,
21
21
  fixedLeftColumns,
22
22
  fixedRightColumns,
23
23
  rowHeaderVirtual
@@ -25,9 +25,8 @@ const TableHeadRow = ({
25
25
  const {
26
26
  prefix
27
27
  } = _react.default.useContext(_useContext.TableContext);
28
-
29
- // const virtualColumns = columnVirtualizer.getVirtualItems()
30
- const virtualColumns = columnVirtualizer.measurementsCache;
28
+ const virtualColumns = columnVirtualizer.getVirtualItems();
29
+ // const virtualColumns = columnVirtualizer.measurementsCache
31
30
 
32
31
  // console.log('virtualColumns', virtualColumns)
33
32
 
@@ -58,6 +57,12 @@ const TableHeadRow = ({
58
57
  header: headerGroup.headers.find(h => h.column.id === column.id)
59
58
  // column={column as any}
60
59
  });
60
+ }) : null, virtualPaddingLeft ? /*#__PURE__*/_react.default.createElement("th", {
61
+ className: "",
62
+ style: {
63
+ display: 'flex',
64
+ width: virtualPaddingLeft
65
+ }
61
66
  }) : null, virtualColumns.map(virtualColumn => {
62
67
  const header = headerGroup.headers[virtualColumn.index];
63
68
  const isFixed = table.getState().columnPinning.left?.includes(header?.column?.id) || table.getState().columnPinning.right?.includes(header?.column?.id);
@@ -79,6 +84,15 @@ const TableHeadRow = ({
79
84
  key: column.id,
80
85
  header: headerGroup.headers.find(h => h.column.id === column.id)
81
86
  // column={column as any}
82
- })) : null));
87
+ })) : null, virtualPaddingRight ?
88
+ /*#__PURE__*/
89
+ //fake empty column to the right for virtualization scroll padding
90
+ _react.default.createElement("th", {
91
+ className: "nnnnnnnnnnnn",
92
+ style: {
93
+ display: 'flex',
94
+ width: virtualPaddingRight
95
+ }
96
+ }) : null));
83
97
  };
84
98
  var _default = exports.default = TableHeadRow;
@@ -367,7 +367,7 @@ function getFixedFields(columns, type) {
367
367
  const result = [];
368
368
  function traverse(cols) {
369
369
  for (const col of cols) {
370
- if (col.fixed === type && col.field) {
370
+ if ((col.fixed ?? col.fixedType) === type && col.field) {
371
371
  result.push(col.field);
372
372
  }
373
373
  if (col.children && col.children.length > 0) {
@@ -1864,13 +1864,13 @@ function isObjEqual(obj1, obj2) {
1864
1864
  const sortByType = arr => {
1865
1865
  if (arr) {
1866
1866
  return arr.sort((a, b) => {
1867
- if (a.fixed === 'left' && b.fixed !== 'left') {
1867
+ if ((a.fixed ?? a.fixedType) === 'left' && (b.fixed ?? b.fixedType) !== 'left') {
1868
1868
  return -1;
1869
- } else if (a.fixed !== 'left' && b.fixed === 'left') {
1869
+ } else if ((a.fixed ?? a.fixedType) !== 'left' && (b.fixed ?? b.fixedType) === 'left') {
1870
1870
  return 1;
1871
- } else if (a.fixed === 'right' && b.fixed !== 'right') {
1871
+ } else if ((a.fixed ?? a.fixedType) === 'right' && (b.fixed ?? b.fixedType) !== 'right') {
1872
1872
  return 1;
1873
- } else if (a.fixed !== 'right' && b.fixed === 'right') {
1873
+ } else if ((a.fixed ?? a.fixedType) !== 'right' && (b.fixed ?? b.fixedType) === 'right') {
1874
1874
  return -1;
1875
1875
  }
1876
1876
  return 0;
@@ -1939,14 +1939,9 @@ const updateColumns1 = (columns, includes) => {
1939
1939
  newColumn.children = updateColumns1(newColumn.children, includes);
1940
1940
  hasVisibleChild = newColumn.children.some(child => !child.hidden);
1941
1941
  }
1942
-
1943
- // newColumn.hidden = newColumn.key && !includes.includes(newColumn.key)
1944
1942
  newColumn.visible = !!(newColumn.field && includes.includes(newColumn.field));
1945
- // newColumn.fixed = newColumn.field && !includes.includes(newColumn.field) ? undefined : newColumn.fixed
1946
-
1947
1943
  if (newColumn.children && newColumn.children.length > 0) {
1948
1944
  newColumn.visible = !hasVisibleChild;
1949
- // newColumn.fixed = !hasVisibleChild ? undefined : newColumn.fixed
1950
1945
  }
1951
1946
  return newColumn;
1952
1947
  });
@@ -49,9 +49,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
49
49
  padding: 7px 8px;
50
50
  border-inline-end: 1px solid $tableBorderColor;
51
51
  // border-bottom: 1px solid $tableBorderColor;
52
-
53
52
  // &.#{$prefix}-grid-cell-fix-left-last {
54
-
55
53
  // &::after {
56
54
  // position: absolute;
57
55
  // top: 0;
@@ -64,10 +62,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
64
62
  // pointer-events: none;
65
63
  // box-shadow: inset 10px 0 8px -8px rgba(5, 5, 5, 0.09);
66
64
  // }
67
-
68
-
69
65
  // }
70
-
71
66
  // &.#{$prefix}-grid-cell-fix-right-first {
72
67
  // &::after {
73
68
  // position: absolute;
@@ -81,7 +76,6 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
81
76
  // pointer-events: none;
82
77
  // box-shadow: inset -10px 0 8px -8px rgba(5, 5, 5, 0.09);
83
78
  // }
84
-
85
79
  // &::before {
86
80
  // content: "";
87
81
  // position: absolute;
@@ -101,6 +95,31 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
101
95
  white-space: nowrap;
102
96
  text-overflow: ellipsis;
103
97
  word-break: keep-all;
98
+
99
+ &.select-cell {
100
+ padding-right: 18px;
101
+ position: relative;
102
+
103
+ }
104
+
105
+ .caret-down {
106
+ float: right;
107
+ position: absolute;
108
+ right: 0;
109
+
110
+ &::before {
111
+ content: '';
112
+ display: inline-block;
113
+ margin-left: 4px;
114
+ vertical-align: middle;
115
+ width: 0;
116
+ height: 0;
117
+ border-left: 5px solid transparent;
118
+ border-right: 5px solid transparent;
119
+ border-top: 5px solid #6f7777;
120
+ }
121
+ }
122
+
104
123
  }
105
124
 
106
125
  }
@@ -44,7 +44,7 @@ const Grid = props => {
44
44
  onSorter,
45
45
  onFilter,
46
46
  groupColumns,
47
- height,
47
+ height = 700,
48
48
  editAble,
49
49
  triggerChangeColumns,
50
50
  ...rest
@@ -205,7 +205,8 @@ const Grid = props => {
205
205
  return /*#__PURE__*/_react.default.createElement("div", {
206
206
  className: `${prefix}-grid`,
207
207
  style: {
208
- height: height ?? undefined
208
+ // height: height ?? undefined
209
+ maxHeight: height ?? undefined
209
210
  }
210
211
  }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
211
212
  collisionDetection: _core.closestCenter,
@@ -89,7 +89,7 @@ export type ColumnTable<RecordType = AnyObject> = {
89
89
  allowFiltering?: boolean;
90
90
  /**
91
91
  * @deprecated Please use `allowSorter` instead.
92
- * @since 1.0.0
92
+ * @since 1.7.25
93
93
  */
94
94
  sorter?: boolean;
95
95
  allowSorter?: boolean;
@@ -126,7 +126,7 @@ export type ColumnTable<RecordType = AnyObject> = {
126
126
  editFromSettings?: IEditFromSettings;
127
127
  /**
128
128
  * @deprecated Please use `fixed` instead.
129
- * @since 1.6.5
129
+ * @since 1.7.25
130
130
  */
131
131
  fixedType?: FixedType;
132
132
  fixed?: FixedType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.7.25",
3
+ "version": "1.7.26",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",