@megha-ui/react 1.2.419 → 1.2.421
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.
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
2
|
import { useState, useEffect, useRef, useMemo, } from "react";
|
|
14
3
|
import * as XLSX from "xlsx";
|
|
@@ -30,6 +19,7 @@ import { MdFullscreen, MdFullscreenExit } from "react-icons/md";
|
|
|
30
19
|
import Dropdown from "../dropdown";
|
|
31
20
|
import Loader from "../loader";
|
|
32
21
|
import Button from "../button";
|
|
22
|
+
import Card from "../card";
|
|
33
23
|
import { TbAntennaBarsOff, TbCalculator, TbCalculatorFilled, TbCalculatorOff, } from "react-icons/tb";
|
|
34
24
|
import { TbCopy, TbCopyOff } from "react-icons/tb";
|
|
35
25
|
import { formatValue } from "../../services/commonService";
|
|
@@ -37,7 +27,9 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
37
27
|
borderLeft: "0.5rem solid #d9d9d9",
|
|
38
28
|
}, defaultSort, noKeyEvents = true, customOperation, hasCustomOperation, globalSearch, headerDropdownIndex, draggable = false, resizable = false, updateGridData, widthUnits, checkboxWrapper, ignoreHugContent = false, isSummarise = false, isHideDups = 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) => {
|
|
39
29
|
console.log("Update fixed filter values not implemented", fixedFilterValues);
|
|
40
|
-
}, locale, formatOptions, exportOptions,
|
|
30
|
+
}, locale, formatOptions, exportOptions,
|
|
31
|
+
// Card wrapper props
|
|
32
|
+
withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, subHeader, cardFooter, }) => {
|
|
41
33
|
var _a, _b, _c, _d;
|
|
42
34
|
const [searchQueries, setSearchQueries] = useState({});
|
|
43
35
|
const [chips, setChips] = useState([]);
|
|
@@ -146,6 +138,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
146
138
|
return filterValue.includes(cellValue);
|
|
147
139
|
})
|
|
148
140
|
: true);
|
|
141
|
+
console.log(searchQueries, "searchQueries");
|
|
142
|
+
console.log(filterColumns);
|
|
149
143
|
_filteredData = _filteredData.filter((item) => searchOp === "and"
|
|
150
144
|
? filterColumns.every((column) => {
|
|
151
145
|
var _a, _b, _c;
|
|
@@ -158,7 +152,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
158
152
|
const regex = createRegexFromWildcard(query);
|
|
159
153
|
return regex.test(value);
|
|
160
154
|
}
|
|
161
|
-
console.log(
|
|
155
|
+
console.log({ query, value, column, searchQueries });
|
|
162
156
|
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
163
157
|
case "contains":
|
|
164
158
|
return value.toLowerCase().includes(query.toLowerCase());
|
|
@@ -236,13 +230,14 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
236
230
|
const regex = createRegexFromWildcard(query);
|
|
237
231
|
return regex.test(value);
|
|
238
232
|
}
|
|
233
|
+
console.log({ query, value, column, searchQueries });
|
|
239
234
|
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
240
235
|
case "contains":
|
|
241
236
|
return value.toLowerCase().includes(query.toLowerCase());
|
|
242
237
|
case "doesNotContain":
|
|
243
238
|
return !value.toLowerCase().includes(query.toLowerCase());
|
|
244
239
|
case "equals":
|
|
245
|
-
return queryData.includes(value.toLowerCase());
|
|
240
|
+
return !queryData.includes(value.toLowerCase());
|
|
246
241
|
case "gt":
|
|
247
242
|
if (!isNaN(parseFloat(query))) {
|
|
248
243
|
return parseFloat(value) > parseFloat(query);
|
|
@@ -353,8 +348,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
353
348
|
fixedFilterValues,
|
|
354
349
|
hideDuplicates,
|
|
355
350
|
actionsKey,
|
|
356
|
-
fixedColumns,
|
|
357
|
-
searchOp,
|
|
358
351
|
]);
|
|
359
352
|
const recalculate = (_summariseKeys) => {
|
|
360
353
|
const filteredData = paginate ? paginatedData : sortedData;
|
|
@@ -806,8 +799,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
806
799
|
const handleSearch = (key, value, type) => {
|
|
807
800
|
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), { [key]: { text: value, type, operation: "and" } })));
|
|
808
801
|
setUniqueSearch((prev) => {
|
|
809
|
-
|
|
810
|
-
return
|
|
802
|
+
delete prev[key];
|
|
803
|
+
return prev;
|
|
811
804
|
});
|
|
812
805
|
};
|
|
813
806
|
useEffect(() => {
|
|
@@ -1260,8 +1253,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1260
1253
|
// setGridGroupBy(groupBy);
|
|
1261
1254
|
// }
|
|
1262
1255
|
// };
|
|
1263
|
-
|
|
1264
|
-
height,
|
|
1256
|
+
const gridBody = (_jsxs("div", { style: {
|
|
1257
|
+
height: withCard ? "100%" : height,
|
|
1265
1258
|
backgroundColor: isFullScreen ? "var(--background)" : "transparent",
|
|
1266
1259
|
}, className: wrapperClass, ref: entrieGridRef, children: [isOpen && (_jsx("div", { style: {
|
|
1267
1260
|
position: "fixed",
|
|
@@ -1536,5 +1529,15 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1536
1529
|
paddingRight: 10,
|
|
1537
1530
|
fontSize: "inherit",
|
|
1538
1531
|
}, children: ["Showing ", sortedData.length, " results", " ", paginate && (_jsxs("span", { children: ["(", currentPage, " of ", totalPages, " pages)"] }))] }), _jsx("div", { style: { marginLeft: "auto" }, children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, handleChangePage: handleChangePage, rowsPerPage: rowsPerPage, handleChangeRowsPerPage: handleChangeRowsPerPage, rowsPerPageOptions: rowsPerPageOptions }) })] }))] }));
|
|
1532
|
+
if (withCard) {
|
|
1533
|
+
const headerNode = cardHeader !== null && cardHeader !== void 0 ? cardHeader : (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [_jsxs("div", { style: {
|
|
1534
|
+
display: "flex",
|
|
1535
|
+
alignItems: "center",
|
|
1536
|
+
justifyContent: "space-between",
|
|
1537
|
+
width: "100%",
|
|
1538
|
+
}, children: [_jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [headerLeft, title && _jsx("div", { children: title })] }), _jsx("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: headerRight })] }), subHeader && _jsx("div", { children: subHeader })] }));
|
|
1539
|
+
return (_jsx(Card, { className: cardClassName, header: headerNode, content: gridBody, footer: cardFooter, height: height }));
|
|
1540
|
+
}
|
|
1541
|
+
return gridBody;
|
|
1539
1542
|
};
|
|
1540
1543
|
export default Grid;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DragEvent, JSX } from "react";
|
|
1
|
+
import { DragEvent, JSX, ReactNode } from "react";
|
|
2
2
|
import { Calculate } from "..";
|
|
3
3
|
export interface Column {
|
|
4
4
|
render?: any;
|
|
@@ -158,6 +158,14 @@ export interface OjasGridProps {
|
|
|
158
158
|
locale?: string;
|
|
159
159
|
formatOptions?: any;
|
|
160
160
|
exportOptions?: any;
|
|
161
|
+
withCard?: boolean;
|
|
162
|
+
cardClassName?: string;
|
|
163
|
+
cardHeader?: ReactNode;
|
|
164
|
+
title?: ReactNode;
|
|
165
|
+
headerLeft?: ReactNode;
|
|
166
|
+
headerRight?: ReactNode;
|
|
167
|
+
subHeader?: ReactNode;
|
|
168
|
+
cardFooter?: ReactNode;
|
|
161
169
|
}
|
|
162
170
|
export interface GroupedRowProps {
|
|
163
171
|
item: any;
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { isValidDateFormat } from "../components/grid/utils/regexUtils";
|
|
2
2
|
// Function to format numbers
|
|
3
3
|
const formatNumber = (value, locale = "sv-SE", options) => {
|
|
4
|
-
var _a;
|
|
5
4
|
const { compactDisplay, notation, signDisplay, unit, unitDisplay, currencySign, minimumFractionDigits, maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, } = options !== null && options !== void 0 ? options : {};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
signDisplay,
|
|
11
|
-
unit,
|
|
12
|
-
unitDisplay,
|
|
13
|
-
currencySign,
|
|
5
|
+
// Base options restricted to fields guaranteed in NumberFormatOptions
|
|
6
|
+
const base = {
|
|
7
|
+
// Retain custom field name if provided by callers
|
|
8
|
+
style: (options && options.Numberstyle) || "decimal",
|
|
14
9
|
minimumFractionDigits,
|
|
15
10
|
maximumFractionDigits,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
11
|
+
};
|
|
12
|
+
// Extend with newer fields in a type-safe, conditional way
|
|
13
|
+
const extended = Object.assign({}, base);
|
|
14
|
+
if (notation)
|
|
15
|
+
extended.notation = notation;
|
|
16
|
+
if (typeof compactDisplay !== "undefined")
|
|
17
|
+
extended.compactDisplay = compactDisplay;
|
|
18
|
+
if (typeof minimumSignificantDigits !== "undefined")
|
|
19
|
+
extended.minimumSignificantDigits = minimumSignificantDigits;
|
|
20
|
+
if (typeof maximumSignificantDigits !== "undefined")
|
|
21
|
+
extended.maximumSignificantDigits = maximumSignificantDigits;
|
|
22
|
+
if (signDisplay)
|
|
23
|
+
extended.signDisplay = signDisplay;
|
|
24
|
+
if (unit) {
|
|
25
|
+
extended.style = "unit";
|
|
26
|
+
extended.unit = unit;
|
|
27
|
+
if (unitDisplay)
|
|
28
|
+
extended.unitDisplay = unitDisplay;
|
|
29
|
+
}
|
|
30
|
+
if (currencySign)
|
|
31
|
+
extended.currencySign = currencySign;
|
|
32
|
+
const formatter = new Intl.NumberFormat(locale, extended);
|
|
19
33
|
return formatter.format(value);
|
|
20
34
|
};
|
|
21
35
|
// ISO-like string including local time (no timezone)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megha-ui/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.421",
|
|
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",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
|
-
"test": "jest",
|
|
12
11
|
"publish:patch": "npm version patch && npm publish --access public",
|
|
13
12
|
"publish:minor": "npm version minor && npm publish --access public",
|
|
14
13
|
"publish:major": "npm version major && npm publish --access public"
|
|
@@ -29,11 +28,8 @@
|
|
|
29
28
|
"homepage": "https://github.com/nrg-tools/nrg-text-input#readme",
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"@types/file-saver": "^2.0.7",
|
|
32
|
-
"@types/jest": "^27.5.2",
|
|
33
31
|
"@types/react": "^19.1.8",
|
|
34
32
|
"@types/react-dom": "^19.1.6",
|
|
35
|
-
"jest": "^27.5.1",
|
|
36
|
-
"ts-jest": "^29.4.0",
|
|
37
33
|
"typescript": "^5.8.3"
|
|
38
34
|
},
|
|
39
35
|
"peerDependencies": {
|