es-grid-template 1.8.42 → 1.8.44

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.
@@ -37,7 +37,7 @@ getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayB
37
37
  // import GridEdit from './table/GridEdit'
38
38
  import { convertToTanStackColumns } from "./hook/useColumns";
39
39
  import { convertColumns } from "./hook/convert";
40
- import { Modal } from 'antd';
40
+ // import { Modal } from 'antd'
41
41
  // import { findAllChildrenKeys2 } from '../grid-component/hooks'
42
42
  // import { columns111 } from '../test-2/columns'
43
43
 
@@ -214,77 +214,6 @@ const InternalTable = props => {
214
214
  mergedSelectedKeys: mergedSelectedKeys,
215
215
  expandable: expandable,
216
216
  setColumns: setColumns
217
- })), /*#__PURE__*/React.createElement(Modal, {
218
- open: isFullScreen,
219
- footer: null,
220
- centered: true,
221
- closable: true,
222
- width: '100%',
223
- style: {
224
- maxWidth: '100%',
225
- height: '100%'
226
- }
227
- // onClose={() => setIsFullScreen(false)}
228
- ,
229
- onCancel: () => setIsFullScreen(false)
230
-
231
- // destroyOnClose
232
- ,
233
- styles: {
234
- content: {
235
- height: '100vh',
236
- borderRadius: 0,
237
- padding: '15px 10px'
238
- },
239
- wrapper: {
240
- zIndex: 1050
241
- }
242
- },
243
- destroyOnClose: true
244
- }, /*#__PURE__*/React.createElement("div", {
245
- style: {
246
- paddingTop: 40
247
- }
248
- }, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
249
- t: t
250
- // id={isFullScreen ? faker.string.alpha(20) : id}
251
- ,
252
- id: faker.string.alpha(20),
253
- prefix: prefix,
254
- originData: convertData,
255
- dataSource: mergedData,
256
- locale: locale,
257
- format: format
258
- // columns={columns111 as any}
259
- ,
260
- columns: convertColumns(mergedColumns),
261
- propsColumns: columns,
262
- rowKey: rowKey,
263
- groupSetting: groupSetting,
264
- groupAble: groupAble,
265
- groupColumns: groupColumns,
266
- columnPinning: columnPinning,
267
- columnHidden: columnsHiddenKeys ? convertToObj(columnsHiddenKeys) : columnVisibility,
268
- triggerFilter: setFilterState,
269
- triggerSorter: setSorterStates,
270
- setMergedFilterKeys: setMergedFilterKeys,
271
- mergedFilterKeys: mergedFilterKeys,
272
- expanded: expanded
273
- // onContextMenu={onContextMenu}
274
- // contextMenuItems={contextMenuItems}
275
- ,
276
- editAble: editAble,
277
- triggerChangeColumns: triggerChangeColumns,
278
- setExpanded: setExpanded,
279
- isFullScreen: isFullScreen,
280
- setIsFullScreen: setIsFullScreen,
281
- height: windowSize.innerHeight - 70,
282
- windowSize: windowSize,
283
- isDataTree: isDataTree,
284
- selectionSettings: selectionSettings,
285
- mergedSelectedKeys: mergedSelectedKeys,
286
- expandable: expandable,
287
- setColumns: setColumns
288
- })))));
217
+ })));
289
218
  };
290
219
  export default InternalTable;
@@ -19,7 +19,7 @@ import { ColumnsChoose } from "./ColumnsChoose";
19
19
  import { numericFormatter } from 'react-numeric-component';
20
20
  // import ComponentSpinner from '../grid-component/LoadingSpinner'
21
21
  import TableWrapper from "./table/TableWrapper";
22
- import { sumSize, updateColumnWidthsRecursive } from "./hook/utils";
22
+ import { getTableHeight, sumSize, updateColumnWidthsRecursive } from "./hook/utils";
23
23
  import { useVirtualizer } from '@tanstack/react-virtual';
24
24
  const TableContainer = props => {
25
25
  const {
@@ -84,7 +84,8 @@ const TableContainer = props => {
84
84
  const [tableHeight, settableHeight] = React.useState(0);
85
85
  const [focusedCell, setFocusedCell] = React.useState(undefined);
86
86
  React.useEffect(() => {
87
- const totalHeight = minHeight ?? height;
87
+ // const totalHeight = minHeight ?? height
88
+ const totalHeight = getTableHeight(height, minHeight);
88
89
  if (totalHeight) {
89
90
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
90
91
  const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
@@ -24,7 +24,6 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
24
24
  setSorterChange: Dispatch<SetStateAction<boolean>>;
25
25
  setFilterChange: Dispatch<SetStateAction<boolean>>;
26
26
  onContextMenu?: (data: T) => (event: any) => void;
27
- tableHeight?: number;
28
27
  isDataTree: boolean;
29
28
  windowSize: {
30
29
  innerHeight: number;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { Fragment } from "react";
3
3
  import { useCopyToClipboard } from 'usehooks-ts';
4
- import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getFormat, getRowIdsBetween, getSelectedCellMatrix, isEditable, isFormattedNumber, newGuid, parseExcelClipboardText, sumSize,
4
+ import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getFormat, getRowIdsBetween, getSelectedCellMatrix, getTableHeight, isEditable, isFormattedNumber, newGuid, parseExcelClipboardText, sumSize,
5
5
  // sumSize,
6
6
  unFlattenData, updateArrayByKey, updateColumnWidthsRecursive, updateOrInsert } from "./hook/utils";
7
7
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -79,7 +79,6 @@ const TableContainerEdit = props => {
79
79
  contextMenuItems: propsContext,
80
80
  setSorterChange,
81
81
  setFilterChange,
82
- // tableHeight,
83
82
  onCellPaste,
84
83
  // triggerPaste,
85
84
  validate,
@@ -879,7 +878,8 @@ const TableContainerEdit = props => {
879
878
  // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
880
879
 
881
880
  React.useEffect(() => {
882
- const totalHeight = minHeight ?? height;
881
+ // const totalHeight = minHeight ?? height
882
+ const totalHeight = getTableHeight(height, minHeight);
883
883
  if (totalHeight) {
884
884
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
885
885
  const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
@@ -367,10 +367,13 @@ const EditableCell = props => {
367
367
  // @ts-ignore
368
368
  valueSelectTable = record[fieldValue] ?? value;
369
369
  }
370
- if (isMulti || selectMode === 'checkbox') {
371
- // @ts-ignore
372
- valueSelectTable = !isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
373
- }
370
+
371
+ // if (isMulti || selectMode === 'checkbox') {
372
+ // // @ts-ignore
373
+ // valueSelectTable = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
374
+
375
+ // }
376
+
374
377
  return /*#__PURE__*/React.createElement(AsyncTableSelect
375
378
  // id={`col${indexCol}-record${indexRow}`}
376
379
  , {
@@ -475,10 +478,13 @@ const EditableCell = props => {
475
478
  // @ts-ignore
476
479
  valueSelect = record[fieldValue] ?? value;
477
480
  }
478
- if (isMulti || selectMode === 'checkbox') {
479
- // @ts-ignore
480
- valueSelect = !isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
481
- }
481
+
482
+ // if (isMulti || selectMode === 'checkbox') {
483
+ // // @ts-ignore
484
+ // valueSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
485
+
486
+ // }
487
+
482
488
  return /*#__PURE__*/React.createElement(Select, {
483
489
  options: options,
484
490
  value: valueSelect,
@@ -562,10 +568,13 @@ const EditableCell = props => {
562
568
  // @ts-ignore
563
569
  valueAsyncSelect = record[fieldValue] ?? value;
564
570
  }
565
- if (isMulti || selectMode === 'checkbox') {
566
- // @ts-ignore
567
- valueAsyncSelect = !isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
568
- }
571
+
572
+ // if (isMulti || selectMode === 'checkbox') {
573
+ // // @ts-ignore
574
+ // valueAsyncSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
575
+
576
+ // }
577
+
569
578
  return /*#__PURE__*/React.createElement(AsyncSelect, {
570
579
  options: options,
571
580
  defaultOptions: options,
@@ -694,10 +703,13 @@ const EditableCell = props => {
694
703
  // @ts-ignore
695
704
  valueTreeSelect = record[fieldValue] ?? value;
696
705
  }
697
- if (isMulti || selectMode === 'checkbox') {
698
- // @ts-ignore
699
- valueTreeSelect = !isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
700
- }
706
+
707
+ // if (isMulti || selectMode === 'checkbox') {
708
+ // // @ts-ignore
709
+ // valueTreeSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
710
+
711
+ // }
712
+
701
713
  return /*#__PURE__*/React.createElement(TreeSelect, {
702
714
  id: `col${indexCol}-record${indexRow}`,
703
715
  className: 'be-tree-select',
@@ -387,7 +387,7 @@ const TableBodyCellEdit = props => {
387
387
  colSelectIds.forEach(colId => {
388
388
  const cellll = row.getVisibleCells().find(c => c.column.id === colId);
389
389
  const value = cellll?.getValue();
390
- rowData.push(value !== undefined ? String(value) : '');
390
+ rowData.push(value !== undefined ? value : '');
391
391
  });
392
392
  dataSelected.push(rowData);
393
393
  });
@@ -404,12 +404,11 @@ const TableBodyCellEdit = props => {
404
404
  const targetRow = pasteState.startRowIndex + rowIndex1;
405
405
 
406
406
  // Nếu vượt quá số dòng hiện có, thêm dòng mới
407
- if (targetRow >= newData.length) {
408
- newData.push({
409
- id: undefined,
410
- rowId: newGuid()
411
- });
412
- }
407
+ // if (targetRow >= newData.length) {
408
+
409
+ // newData.push({ id: undefined, rowId: newGuid() })
410
+ // }
411
+
413
412
  rowValues.forEach((cellValue, colIndex1) => {
414
413
  const targetCol = startColIndex + colIndex1;
415
414
  if (targetCol >= tmpCols.length) {
@@ -45,7 +45,7 @@ const TableHead = ({
45
45
  const depth = column.depth ?? 0;
46
46
 
47
47
  // const colSpan = column.columns.length || 1;
48
- const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 2).length;
48
+ const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 1).length;
49
49
  // const colSpan = getVisibleChildCount(column);
50
50
 
51
51
  const rowSpan = column.columns?.length > 0 ? 1 : headerDepth - depth;
@@ -141,7 +141,7 @@ export function convertToTanStackColumns({
141
141
  }
142
142
  },
143
143
  enableResizing: allowResizing !== false,
144
- enableHiding: false,
144
+ // enableHiding: false,
145
145
  // enableResizing: true,
146
146
  id: field,
147
147
  size: width,
@@ -263,8 +263,6 @@ export const toggleRowSelection = props => {
263
263
  let checkedRows = [];
264
264
  const rowParent = row.getParentRow();
265
265
 
266
- // console.log(countUnselectedChildren(row))
267
-
268
266
  // nếu có cha và cha chưa được chọn và tất cả con đã chọn => thêm row cha vào
269
267
  if (rowParent && !rowParent.getIsSelected() && countUnselectedChildren(row) === 1) {
270
268
  rowParent.toggleSelected(!rowParent.getIsSelected());
@@ -152,3 +152,4 @@ export declare function getAllChildren(row: any): any;
152
152
  export declare function toggleRowAndChildren(row: Row<any>, isSelected?: boolean): void;
153
153
  export declare function countUnselectedChildren(row: Row<any>): number;
154
154
  export declare function removeDuplicatesByKey(arr: any[], key?: string): any[];
155
+ export declare const getTableHeight: (height?: number, minHeight?: number) => number;
@@ -1763,7 +1763,7 @@ export function getHiddenParentKeys1(columns, parentKeys = []) {
1763
1763
  for (const column of columns) {
1764
1764
  if (column.children) {
1765
1765
  const currentPath = column.field ? [...parentKeys, column.field] : [...parentKeys];
1766
- const childHiddenParents = getHiddenParentKeys(column.children, currentPath);
1766
+ const childHiddenParents = getHiddenParentKeys1(column.children, currentPath);
1767
1767
  if (childHiddenParents.length > 0) {
1768
1768
  childHiddenParents.forEach(key => hiddenParents.add(key));
1769
1769
  currentPath.forEach(key => hiddenParents.add(key));
@@ -1988,7 +1988,6 @@ export function findFirst(items) {
1988
1988
 
1989
1989
  // // if (requireNonEmpty) {
1990
1990
 
1991
- // // console.log('requireNonEmpty', requireNonEmpty)
1992
1991
  // // if (children.length > 0) {
1993
1992
  // // hasParent = true
1994
1993
  // // }
@@ -2249,4 +2248,22 @@ export function removeDuplicatesByKey(arr, key = 'id') {
2249
2248
  }
2250
2249
  }
2251
2250
  return Array.from(map.values());
2252
- }
2251
+ }
2252
+ export const getTableHeight = (height, minHeight) => {
2253
+ if (height && !minHeight) {
2254
+ return height;
2255
+ }
2256
+ if (minHeight && !height) {
2257
+ return minHeight;
2258
+ }
2259
+ if (minHeight && height) {
2260
+ return Math.max(minHeight, height);
2261
+ // if (height > minHeight) {
2262
+ // return height
2263
+ // }
2264
+
2265
+ // if (minHeight > height) {
2266
+ // return minHeight
2267
+ // }
2268
+ }
2269
+ };
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { Modal } from 'antd';
3
+ import { faker } from '@faker-js/faker';
2
4
  import { getCoreRowModel, getExpandedRowModel,
3
5
  // getFilteredRowModel,
4
6
  getGroupedRowModel, getPaginationRowModel,
@@ -14,7 +16,7 @@ import { arrayMove } from '@dnd-kit/sortable';
14
16
 
15
17
  // import { faker } from '@faker-js/faker'
16
18
 
17
- import React from 'react';
19
+ import React, { Fragment } from 'react';
18
20
  import TableContainer from "../TableContainer";
19
21
  import { OperatorFeature } from "../features/operator";
20
22
  import { convertFilters, convertToObjTrue, filterByIds, filterDataByColumns, getAllRowKey, isObjEqual } from "../hook/utils";
@@ -53,6 +55,7 @@ const Grid = props => {
53
55
  infiniteScroll,
54
56
  mergedSelectedKeys,
55
57
  allowResizing,
58
+ windowSize,
56
59
  ...rest
57
60
  } = props;
58
61
  const [columnResizeMode] = React.useState('onChange');
@@ -86,6 +89,7 @@ const Grid = props => {
86
89
  });
87
90
  const [sorterChange, setSorterChange] = React.useState(false);
88
91
  const [filterChange, setFilterChange] = React.useState(false);
92
+ const [isFullScreen, setIsFullScreen] = React.useState(false);
89
93
  const table = useReactTable({
90
94
  _features: [OperatorFeature],
91
95
  data: dataSource,
@@ -274,7 +278,7 @@ const Grid = props => {
274
278
  }
275
279
  const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {}));
276
280
  const ContainerComponent = editAble ? TableContainerEdit : TableContainer;
277
- return /*#__PURE__*/React.createElement("div", {
281
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
278
282
  className: `${prefix}-grid`,
279
283
  style: {
280
284
  minHeight: minHeight ?? undefined,
@@ -288,6 +292,7 @@ const Grid = props => {
288
292
  }, /*#__PURE__*/React.createElement(ContainerComponent, _extends({}, rest, {
289
293
  id: id,
290
294
  t: t,
295
+ windowSize: windowSize,
291
296
  table: table,
292
297
  editAble: editAble,
293
298
  dataSource: dataSource,
@@ -298,7 +303,7 @@ const Grid = props => {
298
303
  setIsSelectionChange: setIsSelectionChange,
299
304
  setSorterChange: setSorterChange,
300
305
  setFilterChange: setFilterChange,
301
- height: minHeight ?? height ?? 700,
306
+ height: height ?? minHeight ?? 700,
302
307
  minHeight: minHeight,
303
308
  pagination: pagination,
304
309
  columns: columns,
@@ -312,7 +317,82 @@ const Grid = props => {
312
317
  setColumnSizing: setColumnSizing,
313
318
  setColumns: setColumns,
314
319
  columnSizing: columnSizing,
315
- columnSizingInfo: columnSizingInfo
316
- }))));
320
+ columnSizingInfo: columnSizingInfo,
321
+ isFullScreen: isFullScreen,
322
+ setIsFullScreen: setIsFullScreen
323
+ })))), /*#__PURE__*/React.createElement(Modal, {
324
+ open: isFullScreen,
325
+ footer: null,
326
+ centered: true,
327
+ closable: true,
328
+ width: '100%',
329
+ style: {
330
+ maxWidth: '100%',
331
+ height: '100%'
332
+ }
333
+ // onClose={() => setIsFullScreen(false)}
334
+ ,
335
+ onCancel: () => setIsFullScreen(false)
336
+
337
+ // destroyOnClose
338
+ ,
339
+ styles: {
340
+ content: {
341
+ height: '100vh',
342
+ borderRadius: 0,
343
+ padding: '15px 10px'
344
+ },
345
+ wrapper: {
346
+ zIndex: 1050
347
+ }
348
+ },
349
+ destroyOnClose: true
350
+ }, /*#__PURE__*/React.createElement("div", {
351
+ style: {
352
+ paddingTop: 40
353
+ }
354
+ }, /*#__PURE__*/React.createElement("div", {
355
+ className: `${prefix}-grid`,
356
+ style: {
357
+ // minHeight: minHeight ?? undefined,
358
+ maxHeight: windowSize.innerHeight - 70
359
+ }
360
+ }, /*#__PURE__*/React.createElement(DndContext, {
361
+ collisionDetection: closestCenter,
362
+ modifiers: [restrictToHorizontalAxis],
363
+ onDragEnd: handleDragEnd,
364
+ sensors: sensors
365
+ }, /*#__PURE__*/React.createElement(ContainerComponent, _extends({}, rest, {
366
+ id: faker.string.alpha(20),
367
+ t: t,
368
+ table: table,
369
+ editAble: editAble,
370
+ dataSource: dataSource,
371
+ originData: originData,
372
+ prefix: prefix,
373
+ selectionSettings: selectionSettings,
374
+ isSelectionChange: isSelectionChange,
375
+ setIsSelectionChange: setIsSelectionChange,
376
+ setSorterChange: setSorterChange,
377
+ setFilterChange: setFilterChange,
378
+ height: windowSize.innerHeight - 70,
379
+ minHeight: minHeight,
380
+ pagination: pagination,
381
+ columns: columns,
382
+ windowSize: windowSize,
383
+ propsColumns: propsColumns,
384
+ triggerChangeColumns: triggerChangeColumns,
385
+ columnHidden: columnHidden,
386
+ setExpanded: setExpanded,
387
+ expanded: expanded,
388
+ infiniteScroll: infiniteScroll,
389
+ setMergedFilterKeys: setMergedFilterKeys,
390
+ setColumnSizing: setColumnSizing,
391
+ setColumns: setColumns,
392
+ columnSizing: columnSizing,
393
+ columnSizingInfo: columnSizingInfo,
394
+ isFullScreen: isFullScreen,
395
+ setIsFullScreen: setIsFullScreen
396
+ })))))));
317
397
  };
318
398
  export default Grid;
@@ -180,10 +180,10 @@ const TableWrapper = props => {
180
180
  //our scrollable table container
181
181
  position: 'relative',
182
182
  //needed for sticky header
183
- // height: tableHeight ?? '500px' //should be a fixed height
183
+ // height: height, //should be a fixed height
184
184
  maxHeight: height,
185
185
  //should be a fixed height
186
- height: minHeight ? height : undefined //should be a fixed height
186
+ minHeight: minHeight ? height : undefined //should be a fixed height
187
187
  // minWidth: table.getTotalSize()
188
188
  }
189
189
  // onScroll={infiniteScroll ? handleScroll : undefined}
@@ -19,7 +19,6 @@ var _Grid = _interopRequireDefault(require("./table/Grid"));
19
19
  var _utils = require("./hook/utils");
20
20
  var _useColumns = require("./hook/useColumns");
21
21
  var _convert = require("./hook/convert");
22
- var _antd = require("antd");
23
22
  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); }
24
23
  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; }
25
24
  // import en from "rc-master-ui/es/date-picker/locale/en_US"
@@ -44,6 +43,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
44
43
 
45
44
  // import GridEdit from './table/GridEdit'
46
45
 
46
+ // import { Modal } from 'antd'
47
47
  // import { findAllChildrenKeys2 } from '../grid-component/hooks'
48
48
  // import { columns111 } from '../test-2/columns'
49
49
 
@@ -220,77 +220,6 @@ const InternalTable = props => {
220
220
  mergedSelectedKeys: mergedSelectedKeys,
221
221
  expandable: expandable,
222
222
  setColumns: setColumns
223
- })), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
224
- open: isFullScreen,
225
- footer: null,
226
- centered: true,
227
- closable: true,
228
- width: '100%',
229
- style: {
230
- maxWidth: '100%',
231
- height: '100%'
232
- }
233
- // onClose={() => setIsFullScreen(false)}
234
- ,
235
- onCancel: () => setIsFullScreen(false)
236
-
237
- // destroyOnClose
238
- ,
239
- styles: {
240
- content: {
241
- height: '100vh',
242
- borderRadius: 0,
243
- padding: '15px 10px'
244
- },
245
- wrapper: {
246
- zIndex: 1050
247
- }
248
- },
249
- destroyOnClose: true
250
- }, /*#__PURE__*/_react.default.createElement("div", {
251
- style: {
252
- paddingTop: 40
253
- }
254
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, (0, _extends2.default)({}, rest, {
255
- t: t
256
- // id={isFullScreen ? faker.string.alpha(20) : id}
257
- ,
258
- id: _faker.faker.string.alpha(20),
259
- prefix: prefix,
260
- originData: convertData,
261
- dataSource: mergedData,
262
- locale: locale,
263
- format: format
264
- // columns={columns111 as any}
265
- ,
266
- columns: (0, _convert.convertColumns)(mergedColumns),
267
- propsColumns: columns,
268
- rowKey: rowKey,
269
- groupSetting: groupSetting,
270
- groupAble: groupAble,
271
- groupColumns: groupColumns,
272
- columnPinning: columnPinning,
273
- columnHidden: columnsHiddenKeys ? (0, _utils.convertToObj)(columnsHiddenKeys) : columnVisibility,
274
- triggerFilter: setFilterState,
275
- triggerSorter: setSorterStates,
276
- setMergedFilterKeys: setMergedFilterKeys,
277
- mergedFilterKeys: mergedFilterKeys,
278
- expanded: expanded
279
- // onContextMenu={onContextMenu}
280
- // contextMenuItems={contextMenuItems}
281
- ,
282
- editAble: editAble,
283
- triggerChangeColumns: triggerChangeColumns,
284
- setExpanded: setExpanded,
285
- isFullScreen: isFullScreen,
286
- setIsFullScreen: setIsFullScreen,
287
- height: windowSize.innerHeight - 70,
288
- windowSize: windowSize,
289
- isDataTree: isDataTree,
290
- selectionSettings: selectionSettings,
291
- mergedSelectedKeys: mergedSelectedKeys,
292
- expandable: expandable,
293
- setColumns: setColumns
294
- })))));
223
+ })));
295
224
  };
296
225
  var _default = exports.default = InternalTable;
@@ -94,7 +94,8 @@ const TableContainer = props => {
94
94
  const [tableHeight, settableHeight] = _react.default.useState(0);
95
95
  const [focusedCell, setFocusedCell] = _react.default.useState(undefined);
96
96
  _react.default.useEffect(() => {
97
- const totalHeight = minHeight ?? height;
97
+ // const totalHeight = minHeight ?? height
98
+ const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
98
99
  if (totalHeight) {
99
100
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
100
101
  const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
@@ -24,7 +24,6 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
24
24
  setSorterChange: Dispatch<SetStateAction<boolean>>;
25
25
  setFilterChange: Dispatch<SetStateAction<boolean>>;
26
26
  onContextMenu?: (data: T) => (event: any) => void;
27
- tableHeight?: number;
28
27
  isDataTree: boolean;
29
28
  windowSize: {
30
29
  innerHeight: number;
@@ -86,7 +86,6 @@ const TableContainerEdit = props => {
86
86
  contextMenuItems: propsContext,
87
87
  setSorterChange,
88
88
  setFilterChange,
89
- // tableHeight,
90
89
  onCellPaste,
91
90
  // triggerPaste,
92
91
  validate,
@@ -886,7 +885,8 @@ const TableContainerEdit = props => {
886
885
  // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
887
886
 
888
887
  _react.default.useEffect(() => {
889
- const totalHeight = minHeight ?? height;
888
+ // const totalHeight = minHeight ?? height
889
+ const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
890
890
  if (totalHeight) {
891
891
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
892
892
  const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
@@ -369,10 +369,13 @@ const EditableCell = props => {
369
369
  // @ts-ignore
370
370
  valueSelectTable = record[fieldValue] ?? value;
371
371
  }
372
- if (isMulti || selectMode === 'checkbox') {
373
- // @ts-ignore
374
- valueSelectTable = !(0, _utils.isNullOrUndefined)(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
375
- }
372
+
373
+ // if (isMulti || selectMode === 'checkbox') {
374
+ // // @ts-ignore
375
+ // valueSelectTable = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
376
+
377
+ // }
378
+
376
379
  return /*#__PURE__*/_react.default.createElement(_asyncTableSelect.AsyncTableSelect
377
380
  // id={`col${indexCol}-record${indexRow}`}
378
381
  , {
@@ -477,10 +480,13 @@ const EditableCell = props => {
477
480
  // @ts-ignore
478
481
  valueSelect = record[fieldValue] ?? value;
479
482
  }
480
- if (isMulti || selectMode === 'checkbox') {
481
- // @ts-ignore
482
- valueSelect = !(0, _utils.isNullOrUndefined)(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
483
- }
483
+
484
+ // if (isMulti || selectMode === 'checkbox') {
485
+ // // @ts-ignore
486
+ // valueSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
487
+
488
+ // }
489
+
484
490
  return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
485
491
  options: options,
486
492
  value: valueSelect,
@@ -564,10 +570,13 @@ const EditableCell = props => {
564
570
  // @ts-ignore
565
571
  valueAsyncSelect = record[fieldValue] ?? value;
566
572
  }
567
- if (isMulti || selectMode === 'checkbox') {
568
- // @ts-ignore
569
- valueAsyncSelect = !(0, _utils.isNullOrUndefined)(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
570
- }
573
+
574
+ // if (isMulti || selectMode === 'checkbox') {
575
+ // // @ts-ignore
576
+ // valueAsyncSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
577
+
578
+ // }
579
+
571
580
  return /*#__PURE__*/_react.default.createElement(_asyncSelect.AsyncSelect, {
572
581
  options: options,
573
582
  defaultOptions: options,
@@ -696,10 +705,13 @@ const EditableCell = props => {
696
705
  // @ts-ignore
697
706
  valueTreeSelect = record[fieldValue] ?? value;
698
707
  }
699
- if (isMulti || selectMode === 'checkbox') {
700
- // @ts-ignore
701
- valueTreeSelect = !(0, _utils.isNullOrUndefined)(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0 ? options.filter(val => record[dataIndex]?.includes(val[keySelect])) : undefined;
702
- }
708
+
709
+ // if (isMulti || selectMode === 'checkbox') {
710
+ // // @ts-ignore
711
+ // valueTreeSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
712
+
713
+ // }
714
+
703
715
  return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TreeSelect, {
704
716
  id: `col${indexCol}-record${indexRow}`,
705
717
  className: 'be-tree-select',
@@ -393,7 +393,7 @@ const TableBodyCellEdit = props => {
393
393
  colSelectIds.forEach(colId => {
394
394
  const cellll = row.getVisibleCells().find(c => c.column.id === colId);
395
395
  const value = cellll?.getValue();
396
- rowData.push(value !== undefined ? String(value) : '');
396
+ rowData.push(value !== undefined ? value : '');
397
397
  });
398
398
  dataSelected.push(rowData);
399
399
  });
@@ -410,12 +410,11 @@ const TableBodyCellEdit = props => {
410
410
  const targetRow = pasteState.startRowIndex + rowIndex1;
411
411
 
412
412
  // Nếu vượt quá số dòng hiện có, thêm dòng mới
413
- if (targetRow >= newData.length) {
414
- newData.push({
415
- id: undefined,
416
- rowId: (0, _utils.newGuid)()
417
- });
418
- }
413
+ // if (targetRow >= newData.length) {
414
+
415
+ // newData.push({ id: undefined, rowId: newGuid() })
416
+ // }
417
+
419
418
  rowValues.forEach((cellValue, colIndex1) => {
420
419
  const targetCol = startColIndex + colIndex1;
421
420
  if (targetCol >= tmpCols.length) {
@@ -55,7 +55,7 @@ const TableHead = ({
55
55
  const depth = column.depth ?? 0;
56
56
 
57
57
  // const colSpan = column.columns.length || 1;
58
- const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 2).length;
58
+ const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 1).length;
59
59
  // const colSpan = getVisibleChildCount(column);
60
60
 
61
61
  const rowSpan = column.columns?.length > 0 ? 1 : headerDepth - depth;
@@ -152,7 +152,7 @@ function convertToTanStackColumns({
152
152
  }
153
153
  },
154
154
  enableResizing: allowResizing !== false,
155
- enableHiding: false,
155
+ // enableHiding: false,
156
156
  // enableResizing: true,
157
157
  id: field,
158
158
  size: width,
@@ -274,8 +274,6 @@ const toggleRowSelection = props => {
274
274
  let checkedRows = [];
275
275
  const rowParent = row.getParentRow();
276
276
 
277
- // console.log(countUnselectedChildren(row))
278
-
279
277
  // nếu có cha và cha chưa được chọn và tất cả con đã chọn => thêm row cha vào
280
278
  if (rowParent && !rowParent.getIsSelected() && (0, _utils.countUnselectedChildren)(row) === 1) {
281
279
  rowParent.toggleSelected(!rowParent.getIsSelected());
@@ -152,3 +152,4 @@ export declare function getAllChildren(row: any): any;
152
152
  export declare function toggleRowAndChildren(row: Row<any>, isSelected?: boolean): void;
153
153
  export declare function countUnselectedChildren(row: Row<any>): number;
154
154
  export declare function removeDuplicatesByKey(arr: any[], key?: string): any[];
155
+ export declare const getTableHeight: (height?: number, minHeight?: number) => number;
@@ -39,7 +39,7 @@ exports.getHiddenParentKeys1 = getHiddenParentKeys1;
39
39
  exports.getInvisibleColumns = getInvisibleColumns;
40
40
  exports.getNewItemsOnly = exports.getLastSelectCell = void 0;
41
41
  exports.getRowIdsBetween = getRowIdsBetween;
42
- exports.getVisibleColumnKeys1 = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getSelectedCellMatrix = void 0;
42
+ exports.getVisibleColumnKeys1 = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTableHeight = exports.getSelectedCellMatrix = void 0;
43
43
  exports.groupArrayByColumns = groupArrayByColumns;
44
44
  exports.isColor = void 0;
45
45
  exports.isDateString = isDateString;
@@ -1878,7 +1878,7 @@ function getHiddenParentKeys1(columns, parentKeys = []) {
1878
1878
  for (const column of columns) {
1879
1879
  if (column.children) {
1880
1880
  const currentPath = column.field ? [...parentKeys, column.field] : [...parentKeys];
1881
- const childHiddenParents = getHiddenParentKeys(column.children, currentPath);
1881
+ const childHiddenParents = getHiddenParentKeys1(column.children, currentPath);
1882
1882
  if (childHiddenParents.length > 0) {
1883
1883
  childHiddenParents.forEach(key => hiddenParents.add(key));
1884
1884
  currentPath.forEach(key => hiddenParents.add(key));
@@ -2109,7 +2109,6 @@ function findFirst(items) {
2109
2109
 
2110
2110
  // // if (requireNonEmpty) {
2111
2111
 
2112
- // // console.log('requireNonEmpty', requireNonEmpty)
2113
2112
  // // if (children.length > 0) {
2114
2113
  // // hasParent = true
2115
2114
  // // }
@@ -2370,4 +2369,23 @@ function removeDuplicatesByKey(arr, key = 'id') {
2370
2369
  }
2371
2370
  }
2372
2371
  return Array.from(map.values());
2373
- }
2372
+ }
2373
+ const getTableHeight = (height, minHeight) => {
2374
+ if (height && !minHeight) {
2375
+ return height;
2376
+ }
2377
+ if (minHeight && !height) {
2378
+ return minHeight;
2379
+ }
2380
+ if (minHeight && height) {
2381
+ return Math.max(minHeight, height);
2382
+ // if (height > minHeight) {
2383
+ // return height
2384
+ // }
2385
+
2386
+ // if (minHeight > height) {
2387
+ // return minHeight
2388
+ // }
2389
+ }
2390
+ };
2391
+ exports.getTableHeight = getTableHeight;
@@ -6,15 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _antd = require("antd");
10
+ var _faker = require("@faker-js/faker");
9
11
  var _reactTable = require("@tanstack/react-table");
10
12
  var _core = require("@dnd-kit/core");
11
13
  var _modifiers = require("@dnd-kit/modifiers");
12
14
  var _sortable = require("@dnd-kit/sortable");
13
- var _react = _interopRequireDefault(require("react"));
15
+ var _react = _interopRequireWildcard(require("react"));
14
16
  var _TableContainer = _interopRequireDefault(require("../TableContainer"));
15
17
  var _operator = require("../features/operator");
16
18
  var _utils = require("../hook/utils");
17
19
  var _TableContainerEdit = _interopRequireDefault(require("../TableContainerEdit"));
20
+ 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); }
21
+ 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; }
18
22
  // import { makeData } from "../default/makeData";
19
23
 
20
24
  // import { flattenArray, getFixedFields, getInvisibleColumns, unFlattenData, updateOrInsert } from './hook/utils'
@@ -55,6 +59,7 @@ const Grid = props => {
55
59
  infiniteScroll,
56
60
  mergedSelectedKeys,
57
61
  allowResizing,
62
+ windowSize,
58
63
  ...rest
59
64
  } = props;
60
65
  const [columnResizeMode] = _react.default.useState('onChange');
@@ -88,6 +93,7 @@ const Grid = props => {
88
93
  });
89
94
  const [sorterChange, setSorterChange] = _react.default.useState(false);
90
95
  const [filterChange, setFilterChange] = _react.default.useState(false);
96
+ const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
91
97
  const table = (0, _reactTable.useReactTable)({
92
98
  _features: [_operator.OperatorFeature],
93
99
  data: dataSource,
@@ -276,7 +282,7 @@ const Grid = props => {
276
282
  }
277
283
  const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor, {}), (0, _core.useSensor)(_core.TouchSensor, {}), (0, _core.useSensor)(_core.KeyboardSensor, {}));
278
284
  const ContainerComponent = editAble ? _TableContainerEdit.default : _TableContainer.default;
279
- return /*#__PURE__*/_react.default.createElement("div", {
285
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
280
286
  className: `${prefix}-grid`,
281
287
  style: {
282
288
  minHeight: minHeight ?? undefined,
@@ -290,6 +296,7 @@ const Grid = props => {
290
296
  }, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
291
297
  id: id,
292
298
  t: t,
299
+ windowSize: windowSize,
293
300
  table: table,
294
301
  editAble: editAble,
295
302
  dataSource: dataSource,
@@ -300,7 +307,7 @@ const Grid = props => {
300
307
  setIsSelectionChange: setIsSelectionChange,
301
308
  setSorterChange: setSorterChange,
302
309
  setFilterChange: setFilterChange,
303
- height: minHeight ?? height ?? 700,
310
+ height: height ?? minHeight ?? 700,
304
311
  minHeight: minHeight,
305
312
  pagination: pagination,
306
313
  columns: columns,
@@ -314,7 +321,82 @@ const Grid = props => {
314
321
  setColumnSizing: setColumnSizing,
315
322
  setColumns: setColumns,
316
323
  columnSizing: columnSizing,
317
- columnSizingInfo: columnSizingInfo
318
- }))));
324
+ columnSizingInfo: columnSizingInfo,
325
+ isFullScreen: isFullScreen,
326
+ setIsFullScreen: setIsFullScreen
327
+ })))), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
328
+ open: isFullScreen,
329
+ footer: null,
330
+ centered: true,
331
+ closable: true,
332
+ width: '100%',
333
+ style: {
334
+ maxWidth: '100%',
335
+ height: '100%'
336
+ }
337
+ // onClose={() => setIsFullScreen(false)}
338
+ ,
339
+ onCancel: () => setIsFullScreen(false)
340
+
341
+ // destroyOnClose
342
+ ,
343
+ styles: {
344
+ content: {
345
+ height: '100vh',
346
+ borderRadius: 0,
347
+ padding: '15px 10px'
348
+ },
349
+ wrapper: {
350
+ zIndex: 1050
351
+ }
352
+ },
353
+ destroyOnClose: true
354
+ }, /*#__PURE__*/_react.default.createElement("div", {
355
+ style: {
356
+ paddingTop: 40
357
+ }
358
+ }, /*#__PURE__*/_react.default.createElement("div", {
359
+ className: `${prefix}-grid`,
360
+ style: {
361
+ // minHeight: minHeight ?? undefined,
362
+ maxHeight: windowSize.innerHeight - 70
363
+ }
364
+ }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
365
+ collisionDetection: _core.closestCenter,
366
+ modifiers: [_modifiers.restrictToHorizontalAxis],
367
+ onDragEnd: handleDragEnd,
368
+ sensors: sensors
369
+ }, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
370
+ id: _faker.faker.string.alpha(20),
371
+ t: t,
372
+ table: table,
373
+ editAble: editAble,
374
+ dataSource: dataSource,
375
+ originData: originData,
376
+ prefix: prefix,
377
+ selectionSettings: selectionSettings,
378
+ isSelectionChange: isSelectionChange,
379
+ setIsSelectionChange: setIsSelectionChange,
380
+ setSorterChange: setSorterChange,
381
+ setFilterChange: setFilterChange,
382
+ height: windowSize.innerHeight - 70,
383
+ minHeight: minHeight,
384
+ pagination: pagination,
385
+ columns: columns,
386
+ windowSize: windowSize,
387
+ propsColumns: propsColumns,
388
+ triggerChangeColumns: triggerChangeColumns,
389
+ columnHidden: columnHidden,
390
+ setExpanded: setExpanded,
391
+ expanded: expanded,
392
+ infiniteScroll: infiniteScroll,
393
+ setMergedFilterKeys: setMergedFilterKeys,
394
+ setColumnSizing: setColumnSizing,
395
+ setColumns: setColumns,
396
+ columnSizing: columnSizing,
397
+ columnSizingInfo: columnSizingInfo,
398
+ isFullScreen: isFullScreen,
399
+ setIsFullScreen: setIsFullScreen
400
+ })))))));
319
401
  };
320
402
  var _default = exports.default = Grid;
@@ -189,10 +189,10 @@ const TableWrapper = props => {
189
189
  //our scrollable table container
190
190
  position: 'relative',
191
191
  //needed for sticky header
192
- // height: tableHeight ?? '500px' //should be a fixed height
192
+ // height: height, //should be a fixed height
193
193
  maxHeight: height,
194
194
  //should be a fixed height
195
- height: minHeight ? height : undefined //should be a fixed height
195
+ minHeight: minHeight ? height : undefined //should be a fixed height
196
196
  // minWidth: table.getTotalSize()
197
197
  }
198
198
  // onScroll={infiniteScroll ? handleScroll : undefined}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.8.42",
3
+ "version": "1.8.44",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",