@megha-ui/react 1.2.685 → 1.2.686

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.
@@ -47,8 +47,10 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
47
47
  const [isOpen, setIsOpen] = useState(false);
48
48
  const [filterColumns, setFilterColumn] = useState([]);
49
49
  const modalContent = useRef(null);
50
- const [startIndex, setStartIndex] = useState(0);
50
+ const [startIndex, _setStartIndex] = useState(0);
51
51
  const [endIndex, setEndIndex] = useState(defaultRowsPerPage);
52
+ const [startHoriIndex, _setStartHoriIndex] = useState(0);
53
+ const [endHoriIndex, setEndHoriIndex] = useState(0);
52
54
  const [gridGroupBy, setGridGroupBy] = useState("");
53
55
  const [rowIndex, setRowIndex] = useState(-1);
54
56
  const [columnIndex, setColumnIndex] = useState(-1);
@@ -88,6 +90,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
88
90
  return gridColumns.filter((col) => col.fixedFilter && col.fixedFilter !== "");
89
91
  }, [gridColumns]);
90
92
  const [fixedFilterValues, setFixedFilterValues] = useState({});
93
+ const [columnsPerView, setColumnsPerView] = useState(5);
91
94
  useEffect(() => {
92
95
  setSummariseAvailable(isSummarise);
93
96
  }, [isSummarise]);
@@ -700,6 +703,10 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
700
703
  }
701
704
  return typeof column.width === "string" && column.width === "";
702
705
  });
706
+ const gridWidth = entrieGridRef.current
707
+ ? entrieGridRef.current.getBoundingClientRect().width
708
+ : 0;
709
+ console.log("Grid Width:", gridWidth);
703
710
  if (gridGroupBy === "" &&
704
711
  entrieGridRef.current &&
705
712
  widthMode === "custom" &&
@@ -819,6 +826,16 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
819
826
  const isPaginate = gridGroupBy === "" && paginate;
820
827
  if (headerRef.current) {
821
828
  headerRef.current.scrollLeft = e.currentTarget.scrollLeft;
829
+ let atmostIndex = -1;
830
+ if (gridColumns.length > 0) {
831
+ atmostIndex = gridColumns.length - 1;
832
+ }
833
+ if (atmostIndex >= endHoriIndex + columnsPerView) {
834
+ setEndHoriIndex((prev) => prev + columnsPerView);
835
+ }
836
+ else {
837
+ setEndHoriIndex(atmostIndex);
838
+ }
822
839
  }
823
840
  if (e.currentTarget &&
824
841
  isScrollAlmostAtEnd(e.currentTarget) &&
@@ -1429,7 +1446,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
1429
1446
  whiteSpace: "nowrap",
1430
1447
  height: `calc(100% - ${removalHeight})`,
1431
1448
  position: "relative",
1432
- }, onScroll: onScroll, ref: gridRef, children: [_jsx(GridHeader, { columns: gridColumns, headerRef: headerRef, resizable: resizable, sortable: sortable, search: search, defaultSearchOperation: defaultSearchOperation, showMenu: showMenu, sortQueries: sortQueries, onSort: handleSort, bulkSelect: bulkSelect, cellStyle: cellStyle, widthMode: widthMode, allRowsSelected: allRowsSelected, someRowsSelected: someRowsSelected, toggleSelectAll: () => toggleSelectAll(paginate ? paginatedData : sortedData, allRowsSelected), onSearch: handleSearch, searchQueries: searchQueries, headerBackground: headerBackground, headerTopBorder: headerTopBorder, headerBottomBorder: headerBottomBorder, groupBy: gridGroupBy, setGroupBy: (value) => {
1449
+ }, onScroll: onScroll, ref: gridRef, children: [_jsx(GridHeader, { columns: gridColumns, startHoriIndex: startHoriIndex, endHoriIndex: endHoriIndex, headerRef: headerRef, resizable: resizable, sortable: sortable, search: search, defaultSearchOperation: defaultSearchOperation, showMenu: showMenu, sortQueries: sortQueries, onSort: handleSort, bulkSelect: bulkSelect, cellStyle: cellStyle, widthMode: widthMode, allRowsSelected: allRowsSelected, someRowsSelected: someRowsSelected, toggleSelectAll: () => toggleSelectAll(paginate ? paginatedData : sortedData, allRowsSelected), onSearch: handleSearch, searchQueries: searchQueries, headerBackground: headerBackground, headerTopBorder: headerTopBorder, headerBottomBorder: headerBottomBorder, groupBy: gridGroupBy, setGroupBy: (value) => {
1433
1450
  let _gridGroupBy = gridGroupBy;
1434
1451
  _gridGroupBy = _gridGroupBy.split(",").includes(value)
1435
1452
  ? _gridGroupBy
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import { Column, DataRow } from "../types/grid";
3
3
  interface GridHeaderProps {
4
+ startHoriIndex: number;
5
+ endHoriIndex: number;
4
6
  columns: Column[];
5
7
  sortable: boolean;
6
8
  search?: boolean;
@@ -41,7 +41,7 @@ export const getColumnData = (columnKey, gridData, type) => {
41
41
  return 0;
42
42
  });
43
43
  };
44
- const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resizable = false, defaultSearchOperation, sortQueries, onSort, bulkSelect, allRowsSelected, someRowsSelected, toggleSelectAll, cellStyle, widthMode, rowHeight, headerRef, showMenu, headerBackground, headerTopBorder, headerBottomBorder, groupBy, setGroupBy, updateGridColumns, setGridColumns, headerDropdownIndex, widthUnits, textFilterLabel = "Text Filter", gridData, checkboxWrapper, onFilter, setUniqueSearch, uniqueSearch, hugColumnWidths, menuVisible, setMenuVisible, dropdownVisible, setDropdownVisible, actionsKey = "actions", columnSearchOutside, locale, formatOptions, }) => {
44
+ const GridHeader = ({ startHoriIndex, endHoriIndex, columns, onSearch, searchQueries, sortable, search, resizable = false, defaultSearchOperation, sortQueries, onSort, bulkSelect, allRowsSelected, someRowsSelected, toggleSelectAll, cellStyle, widthMode, rowHeight, headerRef, showMenu, headerBackground, headerTopBorder, headerBottomBorder, groupBy, setGroupBy, updateGridColumns, setGridColumns, headerDropdownIndex, widthUnits, textFilterLabel = "Text Filter", gridData, checkboxWrapper, onFilter, setUniqueSearch, uniqueSearch, hugColumnWidths, menuVisible, setMenuVisible, dropdownVisible, setDropdownVisible, actionsKey = "actions", columnSearchOutside, locale, formatOptions, }) => {
45
45
  const [menuPosition, setMenuPosition] = useState(null);
46
46
  const [searchOpsPosition, setSearchOpsPosition] = useState(null);
47
47
  const [headerColumns, setHeaderColumns] = useState([]);
@@ -509,7 +509,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
509
509
  .filter((column) => !groupByKeys.includes(column.key))
510
510
  .map((column, colIndex) => {
511
511
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
512
- if (!column.hidden) {
512
+ if (!column.hidden && colIndex >= startHoriIndex && colIndex <= endHoriIndex) {
513
513
  const columnData = getColumnData(column.key, gridData, (_a = column.dataType) !== null && _a !== void 0 ? _a : "string");
514
514
  return (_jsx("div", { className: `${sortable && column.sortable ? "sortable" : ""} ${column.showMenu ? "menu-true" : "menu-false"} column index-${column.key}`, style: Object.assign(Object.assign({}, cellStyle), { position: "relative", padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis", width: widthMode === "auto"
515
515
  ? "auto"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.685",
3
+ "version": "1.2.686",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",