@eml-payments/ui-kit 1.5.9 → 1.6.0

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.
@@ -127,6 +127,7 @@ const groupingData = Array.from({ length: 5 }).map((_, i) => ({
127
127
  date: dates[i % dates.length],
128
128
  name: `User ${i + 1}`,
129
129
  amount: getRandomInt(1000) + 100,
130
+ status: i % 2 === 0 ? 'settled' : 'pending',
130
131
  }));
131
132
  const formatNumber = (amount) => new Intl.NumberFormat('en-US', {
132
133
  style: 'currency',
@@ -145,6 +146,7 @@ const groupingColumns = [
145
146
  flex: 1,
146
147
  meta: {
147
148
  groupTotalFormatter: (amount) => formatNumber(amount),
149
+ groupTotalFilter: (row) => (row === null || row === void 0 ? void 0 : row.status) === 'settled',
148
150
  },
149
151
  cell: ({ row }) => (_jsx("span", { style: { textAlign: 'right', display: 'block' }, children: formatNumber(row.original.amount) })),
150
152
  },
@@ -11,6 +11,7 @@ declare module '@tanstack/react-table' {
11
11
  groupTotalFormatter?: (value: number, context: {
12
12
  rows: TData[];
13
13
  }) => ReactNode;
14
+ groupTotalFilter?: (row: TData) => boolean;
14
15
  }
15
16
  }
16
17
  export type FlexColumnDef<T> = ColumnDef<T> & {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { classNames } from '../../../utils';
3
3
  import { FaChevronDown, FaChevronRight } from 'react-icons/fa';
4
4
  export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, onToggle, isFirstGroup, }) {
5
- var _a;
5
+ var _a, _b;
6
6
  const columnId = row.groupingColumnId;
7
7
  const groupValue = row.getGroupingValue(columnId);
8
8
  const leafRows = row.getLeafRows();
@@ -16,8 +16,10 @@ export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, on
16
16
  return typeof value === 'number' && Number.isFinite(value);
17
17
  });
18
18
  });
19
+ const groupTotalFilter = (_a = totalColumn === null || totalColumn === void 0 ? void 0 : totalColumn.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.groupTotalFilter;
20
+ const rowsForTotal = groupTotalFilter ? leafRows.filter((leafRow) => groupTotalFilter(leafRow.original)) : leafRows;
19
21
  const groupedTotal = totalColumn
20
- ? leafRows.reduce((sum, leafRow) => {
22
+ ? rowsForTotal.reduce((sum, leafRow) => {
21
23
  const value = leafRow.getValue(totalColumn.column.id);
22
24
  if (typeof value !== 'number' || !Number.isFinite(value)) {
23
25
  return sum;
@@ -25,12 +27,12 @@ export function renderGroupRow({ row, onGroupRowClick, accordion, isExpanded, on
25
27
  return sum + value;
26
28
  }, 0)
27
29
  : null;
28
- const groupTotalFormatter = (_a = totalColumn === null || totalColumn === void 0 ? void 0 : totalColumn.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.groupTotalFormatter;
30
+ const groupTotalFormatter = (_b = totalColumn === null || totalColumn === void 0 ? void 0 : totalColumn.column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.groupTotalFormatter;
29
31
  let formattedGroupedTotal = null;
30
32
  if (groupedTotal !== null) {
31
33
  if (groupTotalFormatter) {
32
34
  formattedGroupedTotal = groupTotalFormatter(groupedTotal, {
33
- rows: leafRows.map((leafRow) => leafRow.original),
35
+ rows: rowsForTotal.map((leafRow) => leafRow.original),
34
36
  });
35
37
  }
36
38
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eml-payments/ui-kit",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "description": "ARLO UIKit",
6
6
  "homepage": "https://github.com/EML-Payments/arlo.npm.uikit#readme",