@megha-ui/react 1.2.163 → 1.2.165

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.
@@ -43,7 +43,7 @@ const file_saver_1 = require("file-saver");
43
43
  const pagination_1 = __importDefault(require("./utils/pagination"));
44
44
  const gridRow_1 = __importDefault(require("./utils/gridRow"));
45
45
  const pagination_2 = require("./utils/pagination");
46
- const gridHeader_1 = __importDefault(require("./utils/gridHeader"));
46
+ const gridHeader_1 = __importStar(require("./utils/gridHeader"));
47
47
  const useSort_1 = require("./hooks/useSort");
48
48
  const usePagination_1 = require("./hooks/usePagination");
49
49
  const useBulkSelect_1 = require("./hooks/useBulkSelect");
@@ -349,22 +349,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
349
349
  : "";
350
350
  return value.toLowerCase().includes(query.toLowerCase());
351
351
  }));
352
- setUniqueSearch((prev) => {
353
- filterColumns.forEach((column) => {
354
- if (prev[column.key] &&
355
- Array.isArray(prev[column.key]) &&
356
- prev[column.key].length > 0) {
357
- _filteredData.forEach((item) => {
358
- console.log(item[column.key], uniqueSearch[column.key]);
359
- if (item[column.key] &&
360
- !prev[column.key].includes(item[column.key].value)) {
361
- prev[column.key].push(item[column.key].value);
362
- }
363
- });
364
- }
365
- });
366
- return prev;
367
- });
368
352
  return _filteredData;
369
353
  }, [
370
354
  data,
@@ -375,6 +359,19 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
375
359
  inputValue,
376
360
  fixedFilterValues,
377
361
  ]);
362
+ // Reset uniqueSearch to reflect the current filteredData
363
+ // Ensures unique filters default to the latest visible values
364
+ (0, react_1.useEffect)(() => {
365
+ const updatedUniqueSearch = {};
366
+ gridColumns.forEach((column) => {
367
+ var _a;
368
+ if (column.uniqueDrop) {
369
+ const columnData = (0, gridHeader_1.getColumnData)(column.key, filteredData, (_a = column.dataType) !== null && _a !== void 0 ? _a : "string");
370
+ updatedUniqueSearch[column.key] = columnData;
371
+ }
372
+ });
373
+ setUniqueSearch(updatedUniqueSearch);
374
+ }, [filteredData, gridColumns]);
378
375
  const recalculate = (_summariseKeys) => {
379
376
  const filteredData = paginate ? paginatedData : sortedData;
380
377
  let newSummariseDetails = summariseDetails;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.163",
3
+ "version": "1.2.165",
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.mjs",