@megha-ui/react 1.2.186 → 1.2.188

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.
@@ -20,6 +20,7 @@ import Dropdown from "../dropdown";
20
20
  import Loader from "../loader";
21
21
  import Button from "../button";
22
22
  import { TbAntennaBarsOff, TbCalculator, TbCalculatorFilled, TbCalculatorOff, } from "react-icons/tb";
23
+ import { TbCopy, TbCopyOff } from "react-icons/tb";
23
24
  import { formatValue } from "../../services/commonService";
24
25
  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 = {
25
26
  borderLeft: "0.5rem solid #d9d9d9",
@@ -65,6 +66,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
65
66
  const prevData = useRef(data);
66
67
  const [isFullScreen, setIsFullScreen] = useState(false);
67
68
  const [fullScreen, setFullScreen] = useState(false);
69
+ const [hideDuplicates, setHideDuplicates] = useState(false);
68
70
  const [isCollapsed, setIsCollapsed] = useState(false);
69
71
  const prevColumns = useRef(null);
70
72
  const [inputValue, setInputValue] = useState("");
@@ -311,6 +313,21 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
311
313
  : "";
312
314
  return value.toLowerCase().includes(query.toLowerCase());
313
315
  }));
316
+ if (hideDuplicates) {
317
+ const visibleColumns = filterColumns.filter((col) => !col.hidden && col.key !== actionsKey);
318
+ if (visibleColumns.length > 0) {
319
+ const seen = new Set();
320
+ _filteredData = _filteredData.filter((row) => {
321
+ const key = visibleColumns
322
+ .map((col) => { var _a, _b; return ((_b = (_a = row[col.key]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "").toString(); })
323
+ .join("|~|");
324
+ if (seen.has(key))
325
+ return false;
326
+ seen.add(key);
327
+ return true;
328
+ });
329
+ }
330
+ }
314
331
  return _filteredData;
315
332
  }, [
316
333
  data,
@@ -320,6 +337,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
320
337
  globalSearchOp,
321
338
  inputValue,
322
339
  fixedFilterValues,
340
+ hideDuplicates,
341
+ actionsKey,
323
342
  ]);
324
343
  const recalculate = (_summariseKeys) => {
325
344
  const filteredData = paginate ? paginatedData : sortedData;
@@ -1252,7 +1271,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
1252
1271
  }, children: _jsx(TbCalculatorOff, {}) }))] }), _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
1253
1272
  cursor: "pointer",
1254
1273
  marginLeft: 10,
1255
- }, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: 10 }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: 10 }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: 10 }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: 10 }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
1274
+ }, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: 10 }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: 10 }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), _jsx("div", { onClick: () => setHideDuplicates((prev) => !prev), style: { cursor: "pointer", marginLeft: 10 }, title: hideDuplicates ? "Show Duplicates" : "Hide Duplicates", children: hideDuplicates ? (_jsx(TbCopyOff, { size: 18 })) : (_jsx(TbCopy, { size: 18 })) }), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: 10 }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: 10 }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
1256
1275
  sortDetails.sortUpdated ||
1257
1276
  summarise.summariseUpdated ||
1258
1277
  gridGroupBy !== (groupBy || "")) &&
@@ -1,7 +1,21 @@
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
- const formatter = new Intl.NumberFormat(locale, options);
4
+ var _a;
5
+ const { compactDisplay, notation, signDisplay, unit, unitDisplay, currencySign, minimumFractionDigits, maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, } = options !== null && options !== void 0 ? options : {};
6
+ const formatter = new Intl.NumberFormat(locale, {
7
+ style: (_a = options.Numberstyle) !== null && _a !== void 0 ? _a : "decimal",
8
+ compactDisplay,
9
+ notation,
10
+ signDisplay,
11
+ unit,
12
+ unitDisplay,
13
+ currencySign,
14
+ minimumFractionDigits,
15
+ maximumFractionDigits,
16
+ minimumSignificantDigits,
17
+ maximumSignificantDigits,
18
+ });
5
19
  return formatter.format(value);
6
20
  };
7
21
  // ISO-like string including local time (no timezone)
@@ -150,7 +164,10 @@ const formatCurrency = (value, locale = "sv-SE", currency = "SEK", options) => {
150
164
  }
151
165
  catch (_a) {
152
166
  // 3) Final fallback: minimal currency formatting
153
- const fmt = new Intl.NumberFormat(locale, { style: "currency", currency: code });
167
+ const fmt = new Intl.NumberFormat(locale, {
168
+ style: "currency",
169
+ currency: code,
170
+ });
154
171
  return fmt.format(value);
155
172
  }
156
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.186",
3
+ "version": "1.2.188",
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",