@megha-ui/react 1.2.687 → 1.2.689
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.
|
@@ -34,7 +34,7 @@ import Card from "../card";
|
|
|
34
34
|
import { TbAntennaBarsOff, TbCalculator, TbCalculatorFilled, TbCalculatorOff, } from "react-icons/tb";
|
|
35
35
|
import { TbCopy, TbCopyOff } from "react-icons/tb";
|
|
36
36
|
import { formatValue } from "../../services/commonService";
|
|
37
|
-
const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable = true, paginate, rowsPerPageOptions = [10, 20, 50, 100], defaultRowsPerPage = 100, widthMode = "custom", bulkSelect = false, cellBorder = false, rowHeight = 38, onRowClick, rowCount = false, rowBorder = true, showMenu = false, search = false, defaultSearchOperation = "contains", gridBorder = false, isLoading = false, rowTopBorder, rowBottomBorder, rowLeftBorder, rowRightBorder, headerBackground = "var(--row-header-bg)", headerTopBorder = "none", headerBottomBorder = "none", SettingIcon, ExportIcon, ignoredExportItems = ["action", "actions"], borderColor = "#dbdfe9", updateColumns, showHideAvailable = false, columnSearchOutside = false, multiSorting = false, exportAvailable = false, exportableFileName = "", groupBy, updateGroupBy, rowKey = "id", hlBorderColor = "black", selectedRow, selectedRowStyle = {
|
|
37
|
+
const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable = true, paginate, rowsPerPageOptions = [10, 20, 50, 100], defaultRowsPerPage = 100, defaultColumnsPerView = 200, widthMode = "custom", bulkSelect = false, cellBorder = false, rowHeight = 38, onRowClick, rowCount = false, rowBorder = true, showMenu = false, search = false, defaultSearchOperation = "contains", gridBorder = false, isLoading = false, rowTopBorder, rowBottomBorder, rowLeftBorder, rowRightBorder, headerBackground = "var(--row-header-bg)", headerTopBorder = "none", headerBottomBorder = "none", SettingIcon, ExportIcon, ignoredExportItems = ["action", "actions"], borderColor = "#dbdfe9", updateColumns, showHideAvailable = false, columnSearchOutside = false, multiSorting = false, exportAvailable = false, exportableFileName = "", groupBy, updateGroupBy, rowKey = "id", hlBorderColor = "black", selectedRow, selectedRowStyle = {
|
|
38
38
|
borderLeft: "0.5rem solid #d9d9d9",
|
|
39
39
|
}, defaultSort, noKeyEvents = true, customOperation, hasCustomOperation, globalSearch, headerDropdownIndex, draggable = false, resizable = false, updateGridData, widthUnits, checkboxWrapper, ignoreHugContent = false, isSummarise = false, isHideDups = false, isMultipleChips = false, fullScreenAvailable = true, defaultGroupOpen, alternateRowColor = true, activeCalculateColor = "#2377BA", calculatetextColor = "#fff", actionsKey = "actions", saveAsNewView = false, handleSaveAsView, saveAsViewIcon, filterData, chipColor = "#ccc", withAscii = false, propSummariseKeys, SummariseIcon, summarizeColor = "black", isExpandable = false, expandedRow, extraRow, selectedCheckBox, setSelectedCheckbox, ignoreRowSelect, setOpenedRows, openedRows, getLoadingState, globalSearchOpen = false, updateFixedFilterValues = (fixedFilterValues) => {
|
|
40
40
|
console.log("Update fixed filter values not implemented", fixedFilterValues);
|
|
@@ -50,7 +50,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
50
50
|
const [startIndex, _setStartIndex] = useState(0);
|
|
51
51
|
const [endIndex, setEndIndex] = useState(defaultRowsPerPage);
|
|
52
52
|
const [startHoriIndex, _setStartHoriIndex] = useState(0);
|
|
53
|
-
const [endHoriIndex, setEndHoriIndex] = useState(
|
|
53
|
+
const [endHoriIndex, setEndHoriIndex] = useState(defaultColumnsPerView);
|
|
54
54
|
const [gridGroupBy, setGridGroupBy] = useState("");
|
|
55
55
|
const [rowIndex, setRowIndex] = useState(-1);
|
|
56
56
|
const [columnIndex, setColumnIndex] = useState(-1);
|
|
@@ -90,7 +90,6 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
90
90
|
return gridColumns.filter((col) => col.fixedFilter && col.fixedFilter !== "");
|
|
91
91
|
}, [gridColumns]);
|
|
92
92
|
const [fixedFilterValues, setFixedFilterValues] = useState({});
|
|
93
|
-
const [columnsPerView, setColumnsPerView] = useState(5);
|
|
94
93
|
useEffect(() => {
|
|
95
94
|
setSummariseAvailable(isSummarise);
|
|
96
95
|
}, [isSummarise]);
|
|
@@ -126,7 +125,11 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
126
125
|
acc[item.key] = type;
|
|
127
126
|
return acc;
|
|
128
127
|
}, {});
|
|
129
|
-
_columns =
|
|
128
|
+
_columns = [
|
|
129
|
+
...(startHoriIndex > 0 && endHoriIndex > 0
|
|
130
|
+
? _columns.filter((_, index) => index >= startHoriIndex && index <= endHoriIndex)
|
|
131
|
+
: _columns),
|
|
132
|
+
].map((col) => {
|
|
130
133
|
var _a, _b;
|
|
131
134
|
let isArrayString = false;
|
|
132
135
|
if (typeof col.isArrayString !== "undefined") {
|
|
@@ -706,7 +709,6 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
706
709
|
const gridWidth = entrieGridRef.current
|
|
707
710
|
? entrieGridRef.current.getBoundingClientRect().width
|
|
708
711
|
: 0;
|
|
709
|
-
console.log("Grid Width:", gridWidth);
|
|
710
712
|
if (gridGroupBy === "" &&
|
|
711
713
|
entrieGridRef.current &&
|
|
712
714
|
widthMode === "custom" &&
|
|
@@ -822,19 +824,24 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
822
824
|
return (element.scrollHeight - element.scrollTop - element.clientHeight <
|
|
823
825
|
threshold);
|
|
824
826
|
};
|
|
827
|
+
const isScrollAlmostAtLeft = (element, threshold = 100) => {
|
|
828
|
+
return (element.scrollWidth - element.scrollLeft - element.clientWidth < threshold);
|
|
829
|
+
};
|
|
825
830
|
const onScroll = (e) => {
|
|
826
831
|
const isPaginate = gridGroupBy === "" && paginate;
|
|
827
832
|
if (headerRef.current) {
|
|
828
833
|
headerRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
834
|
+
if (isScrollAlmostAtLeft(e.currentTarget)) {
|
|
835
|
+
let atmostIndex = -1;
|
|
836
|
+
if (gridColumns.length > 0) {
|
|
837
|
+
atmostIndex = gridColumns.length - 1;
|
|
838
|
+
}
|
|
839
|
+
if (atmostIndex >= endHoriIndex + defaultColumnsPerView) {
|
|
840
|
+
setEndHoriIndex((prev) => prev + defaultColumnsPerView);
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
setEndHoriIndex(atmostIndex);
|
|
844
|
+
}
|
|
838
845
|
}
|
|
839
846
|
}
|
|
840
847
|
if (e.currentTarget &&
|
package/package.json
CHANGED