@mailstep/design-system 0.10.0 → 0.10.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -6,12 +6,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region packages/ui/Blocks/CommonGrid/components/GridAggregation/GridAggregation.tsx
7
7
  const GridAggregation = ({ rowsData, columns, activeColumnName }) => {
8
8
  const [operation, setOperation] = useState("sum");
9
- const { column, numericValues, operationOptions, selectedOption } = useGridAggregation({
9
+ const { column, isNumberFilter, numericValues, operationOptions, selectedOption } = useGridAggregation({
10
10
  rowsData,
11
11
  columns,
12
12
  activeColumnName,
13
13
  operation
14
14
  });
15
+ const handleChange = useCallback((option) => {
16
+ if (option && "value" in option) setOperation(option.value);
17
+ }, []);
18
+ if (!isNumberFilter) return null;
15
19
  return /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs(StyledSelect, { children: [/* @__PURE__ */ jsx(Select, {
16
20
  name: "aggregationOperation",
17
21
  menuPlacement: "top",
@@ -19,9 +23,7 @@ const GridAggregation = ({ rowsData, columns, activeColumnName }) => {
19
23
  options: operationOptions,
20
24
  value: operation,
21
25
  isDarkPlaceholderText: true,
22
- onChange: useCallback((option) => {
23
- if (option && "value" in option) setOperation(option.value);
24
- }, []),
26
+ onChange: handleChange,
25
27
  title: selectedOption?.label,
26
28
  disabled: !numericValues?.length,
27
29
  isSearchable: false
@@ -12,6 +12,7 @@ type Props = {
12
12
  };
13
13
  type UseGridAggregationType = (props: Props) => {
14
14
  column: ColumnDefinition | null;
15
+ isNumberFilter: boolean;
15
16
  numericValues: number[];
16
17
  operationOptions: OperationOptionType[];
17
18
  selectedOption: OperationOptionType | undefined;
@@ -13,11 +13,12 @@ const useGridAggregation = ({ rowsData, columns, activeColumnName, operation })
13
13
  activeColumnName,
14
14
  rowsData
15
15
  ]);
16
+ const isNumberFilter = column?.filteringType === "number";
16
17
  const numericValues = useMemo(() => {
17
18
  return rowsData?.map((row) => {
18
19
  const value = get(activeColumnName || "", row);
19
- const rowValue = column?.formatRowValue?.(row) || value;
20
- return Number(rowValue);
20
+ const formatRowValue = column?.formatRowValue?.(row);
21
+ return Number(typeof formatRowValue === "string" || typeof formatRowValue === "number" ? formatRowValue : value);
21
22
  }).filter((n) => Number.isFinite(n));
22
23
  }, [
23
24
  rowsData,
@@ -43,6 +44,7 @@ const useGridAggregation = ({ rowsData, columns, activeColumnName, operation })
43
44
  }, [numericValues]);
44
45
  return {
45
46
  column,
47
+ isNumberFilter,
46
48
  numericValues,
47
49
  operationOptions,
48
50
  selectedOption: useMemo(() => operationOptions.find((o) => o.value === operation), [operationOptions, operation])