@mailstep/design-system 0.8.31 → 0.8.32-beta.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 +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +1 -0
- package/ui/Blocks/CommonGrid/CommonGrid.js +2 -1
- package/ui/Blocks/CommonGrid/CommonGridContainer.js +40 -28
- package/ui/Blocks/CommonGrid/components/DataCell.js +3 -1
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/DataRow.js +4 -1
- package/ui/Blocks/CommonGrid/components/GridAggregation/GridAggregation.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/GridAggregation.js +34 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/hooks/useGridAggregation.d.ts +20 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/hooks/useGridAggregation.js +52 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/index.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/index.js +2 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/styles.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/styles.js +28 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/utils/aggregate.d.ts +4 -0
- package/ui/Blocks/CommonGrid/components/GridAggregation/utils/aggregate.js +11 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterModal.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/TablePagination/TablePagination.js +21 -21
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +2 -2
- package/ui/Blocks/CommonGrid/styles.d.ts +2 -1
- package/ui/Blocks/CommonGrid/styles.js +3 -3
- package/ui/Blocks/CommonGrid/types.d.ts +1 -0
- package/ui/Blocks/CommonGrid/utils/constants.d.ts +1 -1
- package/ui/Blocks/CommonGrid/utils/constants.js +9 -1
- package/ui/Blocks/CommonGrid/utils/getRowsPerPage.js +1 -1
- package/ui/Elements/Select/Select.js +2 -1
- package/ui/Elements/Select/types.d.ts +1 -0
- package/ui/Elements/SpaceAround/types.d.ts +1 -0
- package/ui/utils/translations.js +2 -2
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ const rowsStyles = { outline: "none" };
|
|
|
18
18
|
const defaultVoidFunction = (...args) => null;
|
|
19
19
|
const defaultUxState = initialState.uxState;
|
|
20
20
|
const defaultColumnsWidth = {};
|
|
21
|
-
const CommonGrid = ({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowClick, onAsyncLoadFilterOptions, columnLayout = "normal", displayColumnsDefinitions, className, minColumnWidth, errorMessage, floatingButtonProps, hasGroups, hasFilters, isSortTerminated }) => {
|
|
21
|
+
const CommonGrid = ({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowClick, onAsyncLoadFilterOptions, columnLayout = "normal", displayColumnsDefinitions, className, minColumnWidth, errorMessage, floatingButtonProps, hasGroups, hasFilters, isSortTerminated, onCellClick }) => {
|
|
22
22
|
const { uxState = defaultUxState, columnsWidth = defaultColumnsWidth, columnsWidthVariant, page = 1, filter, sorting, rowsPerPage = 10 } = gridSelectors;
|
|
23
23
|
const { clearUxState, handleUxChange, addFilter = defaultVoidFunction, addSorting = defaultVoidFunction, setColumnWidth = defaultVoidFunction } = gridActions;
|
|
24
24
|
const handleRowsKeyDown = useRowsKeyControls(rowsData, uxState, handleUxChange);
|
|
@@ -94,6 +94,7 @@ const CommonGrid = ({ filters, comparators, handleDragEnd, gridSelectors, gridAc
|
|
|
94
94
|
onRowAction,
|
|
95
95
|
onUxChange: handleUxChange,
|
|
96
96
|
onRowClick,
|
|
97
|
+
onCellClick,
|
|
97
98
|
columns: displayColumnsDefinitions,
|
|
98
99
|
displayColumnsWidth,
|
|
99
100
|
groups
|
|
@@ -6,6 +6,8 @@ import { useModal } from "../Modal/hooks/useModal.js";
|
|
|
6
6
|
import ActionHead_default from "./components/ActionHead/index.js";
|
|
7
7
|
import { getFilters } from "./utils/index.js";
|
|
8
8
|
import ControlButtons_default from "./components/ControlButtons/index.js";
|
|
9
|
+
import { GridAggregation } from "./components/GridAggregation/GridAggregation.js";
|
|
10
|
+
import "./components/GridAggregation/index.js";
|
|
9
11
|
import { GridInfo } from "./components/GridInfo/index.js";
|
|
10
12
|
import { GridModals } from "./components/GridModals/index.js";
|
|
11
13
|
import MobileFilterModal from "./components/MobileFilterModal.js";
|
|
@@ -24,10 +26,11 @@ import { x } from "@xstyled/styled-components";
|
|
|
24
26
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
27
|
//#region packages/ui/Blocks/CommonGrid/CommonGridContainer.tsx
|
|
26
28
|
const CommonGridContainer = (props) => {
|
|
27
|
-
const { optimizeFilters = false, extraControlButtons, onBatchAction, processCheckedValues, processCheckedValuesTitle, hideControlButtons, quickFilter, floatingButtonProps, queryRowsParam, customPaginationHandler, autoHeight = true, gridName, withPresets = true, withManageColumnButton = true, withPagination = true, allowSortingOnlyUnderTotalRows, onReload, ...passDownProps } = props;
|
|
29
|
+
const { optimizeFilters = false, extraControlButtons, onBatchAction, processCheckedValues, processCheckedValuesTitle, hideControlButtons, quickFilter, floatingButtonProps, queryRowsParam, customPaginationHandler, autoHeight = true, gridName, withPresets = true, withManageColumnButton = true, withPagination = true, withAggregation = true, allowSortingOnlyUnderTotalRows, onReload, ...passDownProps } = props;
|
|
28
30
|
const { gridActions, gridSelectors, rowsData, actionColumnDefinition } = passDownProps;
|
|
29
31
|
const extendedExtraControlButtons = useMemo(() => getExtendedExtraControlButtons(extraControlButtons, onReload), [extraControlButtons, onReload]);
|
|
30
32
|
const [displayManageColumnButton, setDisplayManageColumnButton] = useState(false);
|
|
33
|
+
const [activeColumnName, setActiveColumnName] = useState(null);
|
|
31
34
|
const gridRef = useRef(null);
|
|
32
35
|
const withButtonStrip = !!extendedExtraControlButtons?.length || !hideControlButtons || !!withPresets || !!withManageColumnButton;
|
|
33
36
|
const hasGroups = !!props.columnsDefinitions.find((col) => col.group);
|
|
@@ -98,10 +101,11 @@ const CommonGridContainer = (props) => {
|
|
|
98
101
|
hasFilters,
|
|
99
102
|
hasGroups,
|
|
100
103
|
isSortTerminated,
|
|
104
|
+
onCellClick: setActiveColumnName,
|
|
101
105
|
hasColouredRows: true
|
|
102
106
|
})]
|
|
103
107
|
}), /* @__PURE__ */ jsxs(BottomWrapper, {
|
|
104
|
-
withPagination,
|
|
108
|
+
hasContent: withPagination || withAggregation,
|
|
105
109
|
children: [(processCheckedValues || !!actionColumnDefinition?.actionOptions?.length) && /* @__PURE__ */ jsx(ActionHead_default, {
|
|
106
110
|
rowsData,
|
|
107
111
|
onBatchAction,
|
|
@@ -115,31 +119,39 @@ const CommonGridContainer = (props) => {
|
|
|
115
119
|
justifyContent: "space-between",
|
|
116
120
|
alignItems: "center",
|
|
117
121
|
w: "100%",
|
|
118
|
-
children: [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
122
|
+
children: [
|
|
123
|
+
!isMobile && /* @__PURE__ */ jsx(GridInfo, {
|
|
124
|
+
isSortTerminatedAppeal,
|
|
125
|
+
isSortTerminated
|
|
126
|
+
}),
|
|
127
|
+
withPagination && /* @__PURE__ */ jsxs(x.div, {
|
|
128
|
+
display: "flex",
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
className: "paginatorWrapper",
|
|
131
|
+
w: "100%",
|
|
132
|
+
justifyContent: "flex-end",
|
|
133
|
+
gap: "16px",
|
|
134
|
+
children: [/* @__PURE__ */ jsx(Pagination, {
|
|
135
|
+
page: gridSelectors?.page,
|
|
136
|
+
itemCount: passDownProps?.totalRowsCount,
|
|
137
|
+
itemPerPage: gridSelectors?.rowsPerPage || 10,
|
|
138
|
+
onPageChange: gridActions?.setPage,
|
|
139
|
+
customPaginationHandler,
|
|
140
|
+
radius: isMobile ? 3 : 5,
|
|
141
|
+
rate: isMobile ? 1 : 4
|
|
142
|
+
}), /* @__PURE__ */ jsx(TablePagination_default, {
|
|
143
|
+
gridActions,
|
|
144
|
+
gridSelectors,
|
|
145
|
+
customPaginationHandler,
|
|
146
|
+
autoRowsPerPage
|
|
147
|
+
})]
|
|
148
|
+
}),
|
|
149
|
+
withAggregation && /* @__PURE__ */ jsx(GridAggregation, {
|
|
150
|
+
rowsData,
|
|
151
|
+
columns: displayColumnsDefinitions,
|
|
152
|
+
activeColumnName
|
|
153
|
+
})
|
|
154
|
+
]
|
|
143
155
|
})]
|
|
144
156
|
})]
|
|
145
157
|
}),
|
|
@@ -169,7 +181,7 @@ const CommonGridContainer = (props) => {
|
|
|
169
181
|
filterValues: gridSelectors.filter,
|
|
170
182
|
setFilters: gridActions.setFilters,
|
|
171
183
|
rowsData,
|
|
172
|
-
uxState: gridSelectors.uxState
|
|
184
|
+
uxState: gridSelectors.uxState,
|
|
173
185
|
handleUxChange: gridActions.handleUxChange,
|
|
174
186
|
onAsyncLoadFilterOptions: passDownProps.onAsyncLoadFilterOptions,
|
|
175
187
|
actionColumn: actionColumnDefinition,
|
|
@@ -14,6 +14,7 @@ const DataCell = ({ column, group, rowData, onRowAction, displayColumnWidth, row
|
|
|
14
14
|
if (column.cellComponent) return /* @__PURE__ */ jsx(Wrapper, {
|
|
15
15
|
className: cellClassName,
|
|
16
16
|
...wrapperBaseProps,
|
|
17
|
+
"data-column-name": column.name,
|
|
17
18
|
children: /* @__PURE__ */ jsx(column.cellComponent, {
|
|
18
19
|
rowData,
|
|
19
20
|
onRowAction,
|
|
@@ -24,11 +25,12 @@ const DataCell = ({ column, group, rowData, onRowAction, displayColumnWidth, row
|
|
|
24
25
|
else return /* @__PURE__ */ jsx(Wrapper, {
|
|
25
26
|
className: cellClassName,
|
|
26
27
|
...wrapperBaseProps,
|
|
28
|
+
"data-column-name": column.name,
|
|
27
29
|
children: column.formatRowValue ? column.formatRowValue(rowData) : get(column.name, rowData)
|
|
28
30
|
});
|
|
29
31
|
};
|
|
30
32
|
const MemoDataCell = React.memo(DataCell, (prevProps, newProps) => {
|
|
31
|
-
if (prevProps.rowData !== newProps.rowData || prevProps.displayColumnWidth !== newProps.displayColumnWidth || prevProps.column?.fixedSize
|
|
33
|
+
if (prevProps.rowData !== newProps.rowData || prevProps.displayColumnWidth !== newProps.displayColumnWidth || prevProps.column?.fixedSize !== newProps.column?.fixedSize || prevProps.column?.flexGrow !== newProps.column?.flexGrow || prevProps.column?.flexShrink !== newProps.column?.flexShrink || prevProps.group?.start !== newProps.group?.start || prevProps.group?.end !== newProps.group?.end) return false;
|
|
32
34
|
if ((prevProps.column?.formatRowValue || newProps.column?.formatRowValue) && prevProps.column?.formatRowValue !== newProps.column?.formatRowValue) return false;
|
|
33
35
|
if ((prevProps.column?.cellComponent || newProps.column?.cellComponent) && (prevProps.column?.cellComponent !== newProps.column?.cellComponent || prevProps.onRowAction !== newProps.onRowAction)) return false;
|
|
34
36
|
return true;
|
|
@@ -10,6 +10,7 @@ type DataRowProps = {
|
|
|
10
10
|
onUxChange?: (uxKey: keyof UxState, uxValue: any) => void;
|
|
11
11
|
onRowClick?: (id: string, props: RowProps) => void;
|
|
12
12
|
onRowAction?: (id: string, field: string, value: any, rowData?: RowProps) => void;
|
|
13
|
+
onCellClick?: (columnName: string) => void;
|
|
13
14
|
createLink?: (params?: object) => string;
|
|
14
15
|
displayColumnsWidth: Required<GridSelectorsType>['columnsWidth'];
|
|
15
16
|
groups: Group[];
|
|
@@ -5,7 +5,7 @@ import { useTimeMeasurement } from "./utils.js";
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region packages/ui/Blocks/CommonGrid/components/DataRow.tsx
|
|
8
|
-
const DataRow = ({ columns, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowClick, onRowAction, displayColumnsWidth, groups, isEven }) => {
|
|
8
|
+
const DataRow = ({ columns, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowClick, onRowAction, onCellClick, displayColumnsWidth, groups, isEven }) => {
|
|
9
9
|
const isChecked = !!uxState.checkedRows?.[rowData.id];
|
|
10
10
|
const handleRowAction = React.useCallback((id, field, value, rowData) => {
|
|
11
11
|
onRowAction?.(id, field, value, rowData);
|
|
@@ -24,11 +24,14 @@ const DataRow = ({ columns, rowData, rowIndex, uxState, allowRowSelect, allowRow
|
|
|
24
24
|
child = child.parentElement;
|
|
25
25
|
canPropagation = child?.dataset?.propagation === "true";
|
|
26
26
|
}
|
|
27
|
+
const columnName = parent?.dataset?.columnName;
|
|
28
|
+
if (columnName && onCellClick) onCellClick(columnName);
|
|
27
29
|
if (!classes.includes("dataRow") && !classes.includes("cell") && !canPropagation) return;
|
|
28
30
|
if (onUxChange && allowRowSelect) onUxChange("selectedRow", rowData.id);
|
|
29
31
|
if (onRowClick) onRowClick(rowData.id, rowData);
|
|
30
32
|
}, [
|
|
31
33
|
onRowClick,
|
|
34
|
+
onCellClick,
|
|
32
35
|
onUxChange,
|
|
33
36
|
rowData
|
|
34
37
|
]) });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type ColumnDefinition, type RowProps } from '../../types';
|
|
3
|
+
type GridAggregationProps = {
|
|
4
|
+
rowsData: RowProps[];
|
|
5
|
+
columns: ColumnDefinition[];
|
|
6
|
+
activeColumnName: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare const GridAggregation: FC<GridAggregationProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Select from "../../../../Elements/Select/Select.js";
|
|
2
|
+
import { useGridAggregation } from "./hooks/useGridAggregation.js";
|
|
3
|
+
import { ColumnTitle, StyledSelect, Wrapper } from "./styles.js";
|
|
4
|
+
import { useCallback, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/ui/Blocks/CommonGrid/components/GridAggregation/GridAggregation.tsx
|
|
7
|
+
const GridAggregation = ({ rowsData, columns, activeColumnName }) => {
|
|
8
|
+
const [operation, setOperation] = useState("sum");
|
|
9
|
+
const { column, numericValues, operationOptions, selectedOption } = useGridAggregation({
|
|
10
|
+
rowsData,
|
|
11
|
+
columns,
|
|
12
|
+
activeColumnName,
|
|
13
|
+
operation
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs(StyledSelect, { children: [/* @__PURE__ */ jsx(Select, {
|
|
16
|
+
name: "aggregationOperation",
|
|
17
|
+
menuPlacement: "top",
|
|
18
|
+
style: "gridFilter",
|
|
19
|
+
options: operationOptions,
|
|
20
|
+
value: operation,
|
|
21
|
+
isDarkPlaceholderText: true,
|
|
22
|
+
onChange: useCallback((option) => {
|
|
23
|
+
if (option && "value" in option) setOperation(option.value);
|
|
24
|
+
}, []),
|
|
25
|
+
title: selectedOption?.label,
|
|
26
|
+
disabled: !numericValues?.length,
|
|
27
|
+
isSearchable: false
|
|
28
|
+
}), /* @__PURE__ */ jsx(ColumnTitle, {
|
|
29
|
+
title: column?.title,
|
|
30
|
+
children: column?.title
|
|
31
|
+
})] }) });
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { GridAggregation };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ColumnDefinition, type RowProps } from '../../../types';
|
|
2
|
+
import { type OperationType } from '../utils/aggregate';
|
|
3
|
+
type OperationOptionType = {
|
|
4
|
+
value: OperationType;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
type Props = {
|
|
8
|
+
rowsData: RowProps[];
|
|
9
|
+
columns: ColumnDefinition[];
|
|
10
|
+
activeColumnName: string | null;
|
|
11
|
+
operation: OperationType;
|
|
12
|
+
};
|
|
13
|
+
type UseGridAggregationType = (props: Props) => {
|
|
14
|
+
column: ColumnDefinition | null;
|
|
15
|
+
numericValues: number[];
|
|
16
|
+
operationOptions: OperationOptionType[];
|
|
17
|
+
selectedOption: OperationOptionType | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const useGridAggregation: UseGridAggregationType;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { aggregate } from "../utils/aggregate.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import get from "lodash/fp/get";
|
|
4
|
+
//#region packages/ui/Blocks/CommonGrid/components/GridAggregation/hooks/useGridAggregation.ts
|
|
5
|
+
const useGridAggregation = ({ rowsData, columns, activeColumnName, operation }) => {
|
|
6
|
+
const column = useMemo(() => {
|
|
7
|
+
if (!activeColumnName || !rowsData?.length) return null;
|
|
8
|
+
const column = columns.find((c) => c.name === activeColumnName);
|
|
9
|
+
if (!column) return null;
|
|
10
|
+
return column;
|
|
11
|
+
}, [
|
|
12
|
+
columns,
|
|
13
|
+
activeColumnName,
|
|
14
|
+
rowsData
|
|
15
|
+
]);
|
|
16
|
+
const numericValues = useMemo(() => {
|
|
17
|
+
return rowsData.map((row) => {
|
|
18
|
+
const value = get(activeColumnName || "", row);
|
|
19
|
+
const rowValue = column?.formatRowValue?.(row) || value;
|
|
20
|
+
return Number(rowValue);
|
|
21
|
+
}).filter((n) => Number.isFinite(n));
|
|
22
|
+
}, [
|
|
23
|
+
rowsData,
|
|
24
|
+
activeColumnName,
|
|
25
|
+
column
|
|
26
|
+
]);
|
|
27
|
+
const operationOptions = useMemo(() => {
|
|
28
|
+
const formatter = new Intl.NumberFormat("cs-CZ");
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
value: "sum",
|
|
32
|
+
label: `Sum${numericValues ? ` (${formatter.format(aggregate(numericValues, "sum"))})` : ""}`
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: "min",
|
|
36
|
+
label: `Min${numericValues ? ` (${formatter.format(aggregate(numericValues, "min"))})` : ""}`
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: "max",
|
|
40
|
+
label: `Max${numericValues ? ` (${formatter.format(aggregate(numericValues, "max"))})` : ""}`
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}, [numericValues]);
|
|
44
|
+
return {
|
|
45
|
+
column,
|
|
46
|
+
numericValues,
|
|
47
|
+
operationOptions,
|
|
48
|
+
selectedOption: useMemo(() => operationOptions.find((o) => o.value === operation), [operationOptions, operation])
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { useGridAggregation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GridAggregation } from './GridAggregation';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const Wrapper: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme>, "color">;
|
|
2
|
+
export declare const StyledSelect: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme>, "color">;
|
|
3
|
+
export declare const ColumnTitle: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme>, "color">;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import styled$1, { x } from "@xstyled/styled-components";
|
|
2
|
+
//#region packages/ui/Blocks/CommonGrid/components/GridAggregation/styles.ts
|
|
3
|
+
const Wrapper = styled$1(x.div)`
|
|
4
|
+
display: none;
|
|
5
|
+
@media (min-width: 768px) {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 8px;
|
|
9
|
+
margin-right: 4px;
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
const StyledSelect = styled$1(x.div)`
|
|
14
|
+
width: 150px;
|
|
15
|
+
`;
|
|
16
|
+
const ColumnTitle = styled$1(x.span)`
|
|
17
|
+
font-size: 8px;
|
|
18
|
+
color: gray1;
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: -10px;
|
|
21
|
+
left: 1px;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
width: 100%;
|
|
26
|
+
`;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ColumnTitle, StyledSelect, Wrapper };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region packages/ui/Blocks/CommonGrid/components/GridAggregation/utils/aggregate.ts
|
|
2
|
+
const aggregate = (values, operation) => {
|
|
3
|
+
if (values.length === 0) return 0;
|
|
4
|
+
switch (operation) {
|
|
5
|
+
case "sum": return values.reduce((acc, v) => acc + v, 0);
|
|
6
|
+
case "min": return Math.min(...values);
|
|
7
|
+
case "max": return Math.max(...values);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { aggregate };
|
|
@@ -10,7 +10,7 @@ type Props = {
|
|
|
10
10
|
filterValues?: GridSelectorsType['filter'];
|
|
11
11
|
setFilters: Required<GridActionsType>['setFilters'];
|
|
12
12
|
rowsData: RowProps[];
|
|
13
|
-
uxState
|
|
13
|
+
uxState?: UxState;
|
|
14
14
|
handleUxChange?: GridActionsType['handleUxChange'];
|
|
15
15
|
onAsyncLoadFilterOptions?: (key: string, value: string) => void;
|
|
16
16
|
onClearSettings?: () => void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Paragraph4 } from "../../../../Elements/Typography/Typography.js";
|
|
2
1
|
import Select from "../../../../Elements/Select/Select.js";
|
|
3
2
|
import { rowsPerPageOptions } from "../../utils/constants.js";
|
|
4
3
|
import { useCallback, useMemo } from "react";
|
|
@@ -17,7 +16,14 @@ const Wrapper = styled$1.span`
|
|
|
17
16
|
}
|
|
18
17
|
`;
|
|
19
18
|
const StyledSelect = styled$1(x.div)`
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 8px;
|
|
20
22
|
margin-right: 15px;
|
|
23
|
+
width: 135px;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
color: gray1;
|
|
21
27
|
@media (min-width: 1024px) {
|
|
22
28
|
margin-right: 8px;
|
|
23
29
|
}
|
|
@@ -41,26 +47,20 @@ const TablePagination = ({ gridActions, gridSelectors, autoRowsPerPage, customPa
|
|
|
41
47
|
page,
|
|
42
48
|
customPaginationHandler
|
|
43
49
|
]);
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
mr: "20px",
|
|
59
|
-
children: /* @__PURE__ */ jsx(Trans, {
|
|
60
|
-
id: "dataGrid.resultsPerPage",
|
|
61
|
-
message: "Results per page"
|
|
62
|
-
})
|
|
63
|
-
})] });
|
|
50
|
+
return /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs(StyledSelect, { children: [/* @__PURE__ */ jsx(Trans, {
|
|
51
|
+
id: "dataGrid.perPage",
|
|
52
|
+
message: "Per page"
|
|
53
|
+
}), /* @__PURE__ */ jsx(Select, {
|
|
54
|
+
name: "rowsPerPage",
|
|
55
|
+
menuPlacement: "top",
|
|
56
|
+
style: "gridFilter",
|
|
57
|
+
placeholder: `${rowsPerPage}`,
|
|
58
|
+
options,
|
|
59
|
+
value: rowsPerPage,
|
|
60
|
+
isDarkPlaceholderText: true,
|
|
61
|
+
onChange: onSetRowsPerPage,
|
|
62
|
+
isSearchable: false
|
|
63
|
+
})] }) });
|
|
64
64
|
};
|
|
65
65
|
//#endregion
|
|
66
66
|
export { TablePagination as default };
|
|
@@ -92,8 +92,8 @@ const columnDefinitions = [
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
name: "
|
|
96
|
-
title: "
|
|
95
|
+
name: "formatedRowValue",
|
|
96
|
+
title: "Formated Row Value",
|
|
97
97
|
flexBasis: 160,
|
|
98
98
|
formatRowValue: (row) => {
|
|
99
99
|
return `${row.numberColumn / 4 * row.textColumn.length}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const BottomWrapper: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme> & {
|
|
2
|
-
|
|
2
|
+
hasContent: boolean;
|
|
3
3
|
}, "color">;
|
|
4
4
|
export declare const ContentContainer: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme>, "color">;
|
|
5
5
|
export declare const CommonGridWrap: import("styled-components").StyledComponent<(props: Omit<JSX.IntrinsicElements[string], "color">) => import("react").ReactElement<any, string>, import("@xstyled/styled-components").Theme, import("@xstyled/styled-components").SystemProps<import("@xstyled/styled-components").Theme> & {
|
|
@@ -12,6 +12,7 @@ export declare const CommonGridWithStyles: import("styled-components").StyledCom
|
|
|
12
12
|
displayColumnsDefinitions: import("./types").ColumnDefinition[];
|
|
13
13
|
hasGroups: boolean;
|
|
14
14
|
hasFilters: boolean;
|
|
15
|
+
onCellClick?: (columnName: string) => void;
|
|
15
16
|
}>, import("@xstyled/styled-components").Theme, {
|
|
16
17
|
withButtonStrip: boolean;
|
|
17
18
|
hasGroupsOrFilters: boolean;
|
|
@@ -7,9 +7,9 @@ const BottomWrapper = styled$1(x.div)`
|
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 2;
|
|
9
9
|
flex-shrink: 0;
|
|
10
|
-
padding: ${({
|
|
10
|
+
padding-top: ${({ hasContent }) => hasContent ? "15px" : "0px"};
|
|
11
11
|
width: 100%;
|
|
12
|
-
height: ${({
|
|
12
|
+
height: ${({ hasContent }) => hasContent ? 65 : 0}px;
|
|
13
13
|
background-color: bgLightGray;
|
|
14
14
|
border-bottom-left-radius: 4px;
|
|
15
15
|
border-bottom-right-radius: 4px;
|
|
@@ -43,7 +43,7 @@ const CommonGridWrap = styled$1(x.div)`
|
|
|
43
43
|
|
|
44
44
|
@media (min-width: 1024px) {
|
|
45
45
|
display: block;
|
|
46
|
-
height: calc(100% - ${({ withPagination }) => withPagination ?
|
|
46
|
+
height: calc(100% - ${({ withPagination }) => withPagination ? 65 : 0}px);
|
|
47
47
|
flex: unset;
|
|
48
48
|
min-height: unset;
|
|
49
49
|
overflow: visible;
|
|
@@ -313,6 +313,7 @@ export type GridProps = CommonGridProps & {
|
|
|
313
313
|
withPresets?: boolean;
|
|
314
314
|
withManageColumnButton?: boolean;
|
|
315
315
|
withPagination?: boolean;
|
|
316
|
+
withAggregation?: boolean;
|
|
316
317
|
allowSortingOnlyUnderTotalRows?: [number, number];
|
|
317
318
|
onReload?: () => void;
|
|
318
319
|
};
|
|
@@ -5,5 +5,5 @@ export declare const rowsPerPageOptions: {
|
|
|
5
5
|
export declare const gridButtonStripHeight = 75;
|
|
6
6
|
export declare const gridHeadHeight = 40;
|
|
7
7
|
export declare const gridFilterHeight = 39;
|
|
8
|
-
export declare const gridFooterHeight =
|
|
8
|
+
export declare const gridFooterHeight = 65;
|
|
9
9
|
export declare const gridRowHeight = 40;
|
|
@@ -15,12 +15,20 @@ const rowsPerPageOptions = [
|
|
|
15
15
|
{
|
|
16
16
|
value: 100,
|
|
17
17
|
label: 100
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: 200,
|
|
21
|
+
label: 200
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: 300,
|
|
25
|
+
label: 300
|
|
18
26
|
}
|
|
19
27
|
];
|
|
20
28
|
const gridButtonStripHeight = 75;
|
|
21
29
|
const gridHeadHeight = 40;
|
|
22
30
|
const gridFilterHeight = 39;
|
|
23
|
-
const gridFooterHeight =
|
|
31
|
+
const gridFooterHeight = 65;
|
|
24
32
|
const gridRowHeight = 40;
|
|
25
33
|
//#endregion
|
|
26
34
|
export { gridButtonStripHeight, gridFilterHeight, gridFooterHeight, gridHeadHeight, gridRowHeight, rowsPerPageOptions };
|
|
@@ -3,7 +3,7 @@ import "./constants.js";
|
|
|
3
3
|
const getRowsPerPage = (ref, withPagination, withButtonStrip, hasGroupsOrFilters) => {
|
|
4
4
|
const containerHeight = ref?.current?.clientHeight;
|
|
5
5
|
const gridHeaderHeight = 40 + (hasGroupsOrFilters ? 39 : 0) + (withButtonStrip ? 75 : 0);
|
|
6
|
-
if (containerHeight) return Math.floor((containerHeight - gridHeaderHeight - (withPagination ?
|
|
6
|
+
if (containerHeight) return Math.floor((containerHeight - gridHeaderHeight - (withPagination ? 65 : 0)) / 40);
|
|
7
7
|
return 0;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -19,7 +19,7 @@ const loadingMessage = () => i18n._({
|
|
|
19
19
|
id: "components.dropdown.loading",
|
|
20
20
|
message: "Loading..."
|
|
21
21
|
});
|
|
22
|
-
const Select = ({ label, name, value = "", options = emptyOptions, defaultOptions, loadOptions, onChange, onBlur, error, isInvalid, isLoading, isDarkPlaceholderText, spaceAround = false, disabled, onInputChange, isSearchable, isMulti, className, useSimplifiedOptions = false, showSelectAllButton = false, shortValues = true, shortVariant = "block", style, optionVariant, multiLabelVariant, containerVariant, placeholder, placeholderIcon, innerRef, maxMenuHeight, getOptionValue, onIconClick, ...passTroughProps }) => {
|
|
22
|
+
const Select = ({ label, name, value = "", options = emptyOptions, defaultOptions, loadOptions, onChange, onBlur, error, isInvalid, isLoading, isDarkPlaceholderText, spaceAround = false, disabled, onInputChange, isSearchable, isMulti, className, useSimplifiedOptions = false, showSelectAllButton = false, shortValues = true, shortVariant = "block", style, optionVariant, multiLabelVariant, containerVariant, placeholder, placeholderIcon, innerRef, maxMenuHeight, getOptionValue, onIconClick, title, ...passTroughProps }) => {
|
|
23
23
|
const isAsync = !!loadOptions;
|
|
24
24
|
if (showSelectAllButton && !isMulti) console.error("CheckboxSelect incompatible props");
|
|
25
25
|
const setAllOptions = useCallback(({ options }) => {
|
|
@@ -45,6 +45,7 @@ const Select = ({ label, name, value = "", options = emptyOptions, defaultOption
|
|
|
45
45
|
return /* @__PURE__ */ jsxs(SpaceAround_default, {
|
|
46
46
|
spaceAround,
|
|
47
47
|
className,
|
|
48
|
+
title,
|
|
48
49
|
children: [/* @__PURE__ */ jsxs(Wrapper, { children: [label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
49
50
|
htmlFor: name,
|
|
50
51
|
children: label
|
|
@@ -15,6 +15,7 @@ export type ValueType = Option | Option[] | null;
|
|
|
15
15
|
export type SelectProps = {
|
|
16
16
|
label?: string;
|
|
17
17
|
name?: string;
|
|
18
|
+
title?: string;
|
|
18
19
|
value?: number | string | string[] | Option | Option[];
|
|
19
20
|
placeholder?: string;
|
|
20
21
|
loadingMessage?: (inputValue: string) => string | ReactNode;
|
package/ui/utils/translations.js
CHANGED
|
@@ -33,8 +33,8 @@ const Translations = () => {
|
|
|
33
33
|
message: "Reset all"
|
|
34
34
|
}),
|
|
35
35
|
/* @__PURE__ */ jsx(Trans, {
|
|
36
|
-
id: "dataGrid.
|
|
37
|
-
message: "
|
|
36
|
+
id: "dataGrid.perPage",
|
|
37
|
+
message: "Per page"
|
|
38
38
|
}),
|
|
39
39
|
/* @__PURE__ */ jsx(Trans, {
|
|
40
40
|
id: "manageColumn.title",
|