es-grid-template 1.8.21 → 1.8.23

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.
@@ -106,7 +106,7 @@ const TableContainer = props => {
106
106
  // },
107
107
 
108
108
  measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
109
- overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
109
+ overscan: 3 //how many columns to render on each side off screen each way (adjust this for performance)
110
110
  });
111
111
  const virtualColumns = columnVirtualizer.getVirtualItems();
112
112
  const cacheColumns = columnVirtualizer.measurementsCache;
@@ -148,6 +148,8 @@ const TableContainer = props => {
148
148
  // }
149
149
 
150
150
  if (columnSizingInfo.isResizingColumn === false) {
151
+ // khi resize end
152
+
151
153
  const aa = updateColumnWidthsRecursive(propsColumns, columnSizing);
152
154
  setColumns(aa);
153
155
 
@@ -1819,7 +1819,8 @@ const TableContainerEdit = props => {
1819
1819
  handleAddMulti,
1820
1820
  dataErrors,
1821
1821
  windowSize,
1822
- handleCellClick
1822
+ handleCellClick,
1823
+ pagination
1823
1824
  }
1824
1825
  }, /*#__PURE__*/React.createElement(TableWrapper, {
1825
1826
  contextMenuItems: contextMenuItems,
@@ -358,7 +358,6 @@ const TableBodyCell = props => {
358
358
  // height: '36px',
359
359
  ...getCommonPinningStyles(cell.column)
360
360
  },
361
- onMouseDown: () => {},
362
361
  onMouseEnter: e => {
363
362
  if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
364
363
  setIsOpenTooltip(true);
@@ -415,41 +414,6 @@ const TableBodyCell = props => {
415
414
  });
416
415
  }
417
416
  }
418
- }, /*#__PURE__*/React.createElement("div", {
419
- className: classNames('ui-rc_cell-content', {})
420
- }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
421
- className: "ui-rc-table-row-expand-trigger",
422
- style: {
423
- paddingLeft: `${cell.row.depth * 25}px`
424
- }
425
- }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
426
- // onClick: row.getToggleExpandedHandler(),
427
- onClick: () => {
428
- const keys = Object.keys(expanded);
429
- // @ts-ignore
430
- const tmp = {
431
- ...expanded
432
- };
433
- if (keys.includes(cell.row.id)) {
434
- delete tmp[cell.row.id];
435
- setExpanded(tmp);
436
- } else {
437
- setExpanded(old => ({
438
- ...old,
439
- [cell.row.id]: true
440
- }));
441
- }
442
- },
443
- style: {
444
- cursor: "pointer"
445
- },
446
- className: "ui-rc-table-row-expand"
447
- }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
448
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
449
- }) : /*#__PURE__*/React.createElement("span", {
450
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
451
- })) : /*#__PURE__*/React.createElement("span", {
452
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
453
- }))), flexRender(cell.column.columnDef.cell, cell.getContext())));
417
+ }, flexRender(cell.column.columnDef.cell, cell.getContext()));
454
418
  };
455
419
  export default TableBodyCell;
@@ -19,13 +19,19 @@ import { nonActionColumn } from "../hook/constant";
19
19
  const renderCellIndex = props => {
20
20
  const {
21
21
  parrents,
22
- cell
22
+ cell,
23
+ pagination
23
24
  } = props;
25
+ if (parrents && parrents.length > 0) {
26
+ return /*#__PURE__*/React.createElement("span", {
27
+ className: "ui-rc_cell-content"
28
+ }, parrents.map(pr => {
29
+ return `${pr.index + 1}.`;
30
+ }), cell.row.index + 1);
31
+ }
24
32
  return /*#__PURE__*/React.createElement("span", {
25
33
  className: "ui-rc_cell-content"
26
- }, parrents.map(pr => {
27
- return `${pr.index + 1}.`;
28
- }), cell.row.index + 1);
34
+ }, cell.row.index + (pagination ? (pagination.currentPage ?? 1 - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
29
35
  };
30
36
  const renderCommand = args => {
31
37
  const {
@@ -189,7 +195,8 @@ const TableBodyCellEdit = props => {
189
195
  isDataTree,
190
196
  handleCellClick,
191
197
  setIsSelectionChange,
192
- selectionSettings
198
+ selectionSettings,
199
+ pagination
193
200
  } = React.useContext(TableContext);
194
201
  const expandIconColumnIndex = expandable?.expandIconColumnIndex;
195
202
  const record = cell.row.original;
@@ -828,7 +835,8 @@ const TableBodyCellEdit = props => {
828
835
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
829
836
  }))), renderCellIndex({
830
837
  parrents,
831
- cell
838
+ cell,
839
+ pagination
832
840
  }));
833
841
  }
834
842
  if (cell.column.id === "command") {
@@ -144,7 +144,7 @@ export function convertToTanStackColumns({
144
144
  // enableResizing: true,
145
145
  id: field,
146
146
  size: width,
147
- accessorKey: field ?? '',
147
+ accessorKey: field,
148
148
  sortDescFirst: false,
149
149
  minSize: minWidth,
150
150
  // maxSize: maxWidth,
@@ -66,6 +66,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
66
66
 
67
67
  &.#{$prefix}-grid-cell-text-center {
68
68
  text-align: center;
69
+ justify-content: center;
69
70
 
70
71
  }
71
72
 
@@ -268,7 +269,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
268
269
 
269
270
  &:hover {
270
271
  .#{$prefix}-grid-cell:not(.editable) {
271
- background-color: $rowHoverBg;
272
+ // background-color: $rowHoverBg;
272
273
 
273
274
  &.cell-editable, &.#{$prefix}-grid-cell-index, &.#{$prefix}-grid-cell-selection {
274
275
  // background-color: transparent;
@@ -146,7 +146,7 @@ const Grid = props => {
146
146
  const abb = table.getVisibleLeafColumns()?.[0];
147
147
  if (abb && Object.keys(columnSizingInfo).length === 0) {
148
148
  setColumnSizing({
149
- "#": abb.getSize()
149
+ [abb.id]: abb.getSize()
150
150
  });
151
151
  }
152
152
  }
@@ -81,7 +81,7 @@ export type ColumnTemplate<RecordType> = {
81
81
  field: string;
82
82
  };
83
83
  export type ColumnTable<RecordType = AnyObject> = {
84
- field?: string;
84
+ field: string;
85
85
  width?: number;
86
86
  maxWidth?: number;
87
87
  minWidth?: number;
@@ -1,5 +1,5 @@
1
1
  import type { Dispatch, SetStateAction } from 'react';
2
- import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
2
+ import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
3
3
  import type { SubmitHandler } from "react-hook-form";
4
4
  import type { ExpandedState } from '@tanstack/react-table';
5
5
  export type IPositionCell = {
@@ -67,6 +67,7 @@ export interface IContext<T> {
67
67
  dataErrors?: any[];
68
68
  isDataTree: boolean;
69
69
  handleCellClick?: (rowNumber: number, record: T, column: ColumnTable, rowId: string, cellValue: any) => void;
70
+ pagination?: false | PaginationConfig;
70
71
  }
71
72
  export declare const TableContext: import("react").Context<IContext<any>>;
72
73
  export type ContextCellChange = {
@@ -116,7 +116,7 @@ const TableContainer = props => {
116
116
  // },
117
117
 
118
118
  measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
119
- overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
119
+ overscan: 3 //how many columns to render on each side off screen each way (adjust this for performance)
120
120
  });
121
121
  const virtualColumns = columnVirtualizer.getVirtualItems();
122
122
  const cacheColumns = columnVirtualizer.measurementsCache;
@@ -158,6 +158,8 @@ const TableContainer = props => {
158
158
  // }
159
159
 
160
160
  if (columnSizingInfo.isResizingColumn === false) {
161
+ // khi resize end
162
+
161
163
  const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
162
164
  setColumns(aa);
163
165
 
@@ -1826,7 +1826,8 @@ const TableContainerEdit = props => {
1826
1826
  handleAddMulti,
1827
1827
  dataErrors,
1828
1828
  windowSize,
1829
- handleCellClick
1829
+ handleCellClick,
1830
+ pagination
1830
1831
  }
1831
1832
  }, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
1832
1833
  contextMenuItems: contextMenuItems,
@@ -365,7 +365,6 @@ const TableBodyCell = props => {
365
365
  // height: '36px',
366
366
  ...(0, _utils.getCommonPinningStyles)(cell.column)
367
367
  },
368
- onMouseDown: () => {},
369
368
  onMouseEnter: e => {
370
369
  if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
371
370
  setIsOpenTooltip(true);
@@ -422,41 +421,6 @@ const TableBodyCell = props => {
422
421
  });
423
422
  }
424
423
  }
425
- }, /*#__PURE__*/_react.default.createElement("div", {
426
- className: (0, _classnames.default)('ui-rc_cell-content', {})
427
- }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
428
- className: "ui-rc-table-row-expand-trigger",
429
- style: {
430
- paddingLeft: `${cell.row.depth * 25}px`
431
- }
432
- }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
433
- // onClick: row.getToggleExpandedHandler(),
434
- onClick: () => {
435
- const keys = Object.keys(expanded);
436
- // @ts-ignore
437
- const tmp = {
438
- ...expanded
439
- };
440
- if (keys.includes(cell.row.id)) {
441
- delete tmp[cell.row.id];
442
- setExpanded(tmp);
443
- } else {
444
- setExpanded(old => ({
445
- ...old,
446
- [cell.row.id]: true
447
- }));
448
- }
449
- },
450
- style: {
451
- cursor: "pointer"
452
- },
453
- className: "ui-rc-table-row-expand"
454
- }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
455
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
456
- }) : /*#__PURE__*/_react.default.createElement("span", {
457
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
458
- })) : /*#__PURE__*/_react.default.createElement("span", {
459
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
460
- }))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())));
424
+ }, (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext()));
461
425
  };
462
426
  var _default = exports.default = TableBodyCell;
@@ -25,13 +25,19 @@ var _constant = require("../hook/constant");
25
25
  const renderCellIndex = props => {
26
26
  const {
27
27
  parrents,
28
- cell
28
+ cell,
29
+ pagination
29
30
  } = props;
31
+ if (parrents && parrents.length > 0) {
32
+ return /*#__PURE__*/_react.default.createElement("span", {
33
+ className: "ui-rc_cell-content"
34
+ }, parrents.map(pr => {
35
+ return `${pr.index + 1}.`;
36
+ }), cell.row.index + 1);
37
+ }
30
38
  return /*#__PURE__*/_react.default.createElement("span", {
31
39
  className: "ui-rc_cell-content"
32
- }, parrents.map(pr => {
33
- return `${pr.index + 1}.`;
34
- }), cell.row.index + 1);
40
+ }, cell.row.index + (pagination ? (pagination.currentPage ?? 1 - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
35
41
  };
36
42
  const renderCommand = args => {
37
43
  const {
@@ -195,7 +201,8 @@ const TableBodyCellEdit = props => {
195
201
  isDataTree,
196
202
  handleCellClick,
197
203
  setIsSelectionChange,
198
- selectionSettings
204
+ selectionSettings,
205
+ pagination
199
206
  } = _react.default.useContext(_useContext.TableContext);
200
207
  const expandIconColumnIndex = expandable?.expandIconColumnIndex;
201
208
  const record = cell.row.original;
@@ -834,7 +841,8 @@ const TableBodyCellEdit = props => {
834
841
  className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
835
842
  }))), renderCellIndex({
836
843
  parrents,
837
- cell
844
+ cell,
845
+ pagination
838
846
  }));
839
847
  }
840
848
  if (cell.column.id === "command") {
@@ -155,7 +155,7 @@ function convertToTanStackColumns({
155
155
  // enableResizing: true,
156
156
  id: field,
157
157
  size: width,
158
- accessorKey: field ?? '',
158
+ accessorKey: field,
159
159
  sortDescFirst: false,
160
160
  minSize: minWidth,
161
161
  // maxSize: maxWidth,
@@ -66,6 +66,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
66
66
 
67
67
  &.#{$prefix}-grid-cell-text-center {
68
68
  text-align: center;
69
+ justify-content: center;
69
70
 
70
71
  }
71
72
 
@@ -268,7 +269,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
268
269
 
269
270
  &:hover {
270
271
  .#{$prefix}-grid-cell:not(.editable) {
271
- background-color: $rowHoverBg;
272
+ // background-color: $rowHoverBg;
272
273
 
273
274
  &.cell-editable, &.#{$prefix}-grid-cell-index, &.#{$prefix}-grid-cell-selection {
274
275
  // background-color: transparent;
@@ -148,7 +148,7 @@ const Grid = props => {
148
148
  const abb = table.getVisibleLeafColumns()?.[0];
149
149
  if (abb && Object.keys(columnSizingInfo).length === 0) {
150
150
  setColumnSizing({
151
- "#": abb.getSize()
151
+ [abb.id]: abb.getSize()
152
152
  });
153
153
  }
154
154
  }
@@ -81,7 +81,7 @@ export type ColumnTemplate<RecordType> = {
81
81
  field: string;
82
82
  };
83
83
  export type ColumnTable<RecordType = AnyObject> = {
84
- field?: string;
84
+ field: string;
85
85
  width?: number;
86
86
  maxWidth?: number;
87
87
  minWidth?: number;
@@ -1,5 +1,5 @@
1
1
  import type { Dispatch, SetStateAction } from 'react';
2
- import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
2
+ import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
3
3
  import type { SubmitHandler } from "react-hook-form";
4
4
  import type { ExpandedState } from '@tanstack/react-table';
5
5
  export type IPositionCell = {
@@ -67,6 +67,7 @@ export interface IContext<T> {
67
67
  dataErrors?: any[];
68
68
  isDataTree: boolean;
69
69
  handleCellClick?: (rowNumber: number, record: T, column: ColumnTable, rowId: string, cellValue: any) => void;
70
+ pagination?: false | PaginationConfig;
70
71
  }
71
72
  export declare const TableContext: import("react").Context<IContext<any>>;
72
73
  export type ContextCellChange = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.8.21",
3
+ "version": "1.8.23",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",