@mailstep/design-system 0.5.0-beta.37 → 0.5.0-beta.39
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/CommonGridContainer.js +5 -6
- package/ui/Blocks/CommonGrid/components/TablePagination/TablePagination.d.ts +2 -1
- package/ui/Blocks/CommonGrid/components/TablePagination/TablePagination.js +4 -2
- package/ui/Blocks/CommonGrid/types.d.ts +2 -0
- package/ui/Blocks/CommonGrid/utils/index.d.ts +1 -0
- package/ui/Blocks/CommonGrid/utils/index.js +1 -0
- package/ui/Elements/Pagination/Pagination.d.ts +3 -2
- package/ui/Elements/Pagination/Pagination.js +6 -2
- package/ui/Elements/Pagination/stories/Pagination.stories.d.ts +1 -1
- package/ui/index.es.js +8663 -8660
- package/ui/index.umd.js +321 -321
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import useGetGridHeight from './hooks/useGetGridHeight';
|
|
25
25
|
import { useEffect, useMemo } from 'react';
|
|
26
|
-
import { getFilters, GRID_MIN_ROWS } from './utils';
|
|
26
|
+
import { getFilters, GRID_MIN_ROWS, rowHeight } from './utils';
|
|
27
27
|
import useEditReadAsColumn from './hooks/useEditReadAsColumn';
|
|
28
28
|
import { useModal } from '../Modal/hooks/useModal';
|
|
29
29
|
import useManageColumn from './hooks/useManageColumn';
|
|
@@ -40,18 +40,17 @@ import Modal from '../Modal';
|
|
|
40
40
|
import ManageColumnForm from './components/ManageColumnForm';
|
|
41
41
|
import { Trans } from '@lingui/react';
|
|
42
42
|
var StyledCommonGrid = function (props) {
|
|
43
|
-
var _a = props.optimizeFilters, optimizeFilters = _a === void 0 ? false : _a, extraControlButtons = props.extraControlButtons, eshopSelect = props.eshopSelect, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, floatingButtonProps = props.floatingButtonProps, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "eshopSelect", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "floatingButtonProps"]);
|
|
43
|
+
var _a = props.optimizeFilters, optimizeFilters = _a === void 0 ? false : _a, extraControlButtons = props.extraControlButtons, eshopSelect = props.eshopSelect, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, floatingButtonProps = props.floatingButtonProps, queryRowsParam = props.queryRowsParam, customPaginationHandler = props.customPaginationHandler, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "eshopSelect", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "floatingButtonProps", "queryRowsParam", "customPaginationHandler"]);
|
|
44
44
|
var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
|
|
45
|
-
var rowHeight = 40;
|
|
46
45
|
var _b = useGetGridHeight(), gridHeight = _b.gridHeight, gridRef = _b.gridRef, paginationRef = _b.paginationRef;
|
|
47
46
|
useEffect(function () {
|
|
48
47
|
var _a;
|
|
49
|
-
if (gridHeight && gridHeight > 0) {
|
|
48
|
+
if (!queryRowsParam && gridHeight && gridHeight > 0) {
|
|
50
49
|
// Only main grids (without form grids on new pages)
|
|
51
50
|
var numberOfRows = Math.max(Math.floor(gridHeight / rowHeight - 2), GRID_MIN_ROWS);
|
|
52
51
|
numberOfRows && ((_a = gridActions.setRowsPerPage) === null || _a === void 0 ? void 0 : _a.call(gridActions, numberOfRows));
|
|
53
52
|
}
|
|
54
|
-
}, [gridHeight, gridActions,
|
|
53
|
+
}, [gridHeight, gridActions, queryRowsParam]);
|
|
55
54
|
var modifiedPassDownProps = useEditReadAsColumn(passDownProps);
|
|
56
55
|
var filters = useMemo(function () { return getFilters(optimizeFilters); }, [optimizeFilters]);
|
|
57
56
|
var columns = modifiedPassDownProps.columnsDefinitions;
|
|
@@ -62,6 +61,6 @@ var StyledCommonGrid = function (props) {
|
|
|
62
61
|
gridSelectors: gridSelectors,
|
|
63
62
|
onClose: onClose,
|
|
64
63
|
}), columnsConfigValues = _d.columnsConfigValues, setColumnsConfigOptions = _d.setColumnsConfigOptions, onConfirmForm = _d.onConfirmForm, resetColumnConfig = _d.resetColumnConfig;
|
|
65
|
-
return (_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsxs(StyledButtonStrip, { className: "buttonsStrip", children: [!hideControlButtons && (_jsx(ControlButtons, { extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, eshopSelect: eshopSelect })), _jsx(StyledColumnButton, { type: "button", appearance: "ghost", icon: _jsx(Rows, {}), onClick: openManageColumnForm, children: _jsx(H6, { children: _jsx(Trans, { id: "manageColumn.title", message: "Manage column" }) }) })] }) }), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { filters: filters, gridRef: gridRef, hasColouredRows: true, floatingButtonProps: floatingButtonProps }))] }), _jsx(HidePrint, { children: _jsxs(BottomWrapper, { ref: paginationRef, isAbsolute: !!gridHeight, children: [processCheckedValues && (_jsx(ActionHead, { rowsData: rowsData, onBatchAction: onBatchAction, gridActions: gridActions, gridSelectors: gridSelectors, actionColumn: actionColumnDefinition, processCheckedValues: processCheckedValues, processCheckedValuesTitle: processCheckedValuesTitle })), _jsxs(x.div, { display: "flex", justifyContent: "center", alignItems: "center", className: "paginatorWrapper", w: "100%", h: window.innerWidth > 1204 ? '60px' : '32px', children: [_jsx(Pagination, { page: gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.page, itemCount: passDownProps === null || passDownProps === void 0 ? void 0 : passDownProps.totalRowsCount, itemPerPage: (gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.rowsPerPage) || 10, onPageChange: gridActions === null || gridActions === void 0 ? void 0 : gridActions.setPage }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors })] })] }) }), manageColumnFormVisible && (_jsx(Modal, { title: _jsx(Trans, { id: "manageColumn.title", message: "Manage columns" }), onClose: onClose, onCancel: onClose, onExtraAction: resetColumnConfig, onConfirm: onConfirmForm, width: "auto", minWidth: "350px", hasFooter: true, extraActionLabel: _jsx(Trans, { id: "dataGrid.buttonClearConfig", message: "Reset config" }), cancelLabel: _jsx(Trans, { id: "form.buttonCancel", message: "Cancel" }), confirmLabel: _jsx(Trans, { id: "form.buttonConfirm", message: "Confirm" }), children: _jsx(ManageColumnForm, { columns: columns, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions }) }))] }));
|
|
64
|
+
return (_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsxs(StyledButtonStrip, { className: "buttonsStrip", children: [!hideControlButtons && (_jsx(ControlButtons, { extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, eshopSelect: eshopSelect })), _jsx(StyledColumnButton, { type: "button", appearance: "ghost", icon: _jsx(Rows, {}), onClick: openManageColumnForm, children: _jsx(H6, { children: _jsx(Trans, { id: "manageColumn.title", message: "Manage column" }) }) })] }) }), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { filters: filters, gridRef: gridRef, hasColouredRows: true, floatingButtonProps: floatingButtonProps }))] }), _jsx(HidePrint, { children: _jsxs(BottomWrapper, { ref: paginationRef, isAbsolute: !!gridHeight, children: [processCheckedValues && (_jsx(ActionHead, { rowsData: rowsData, onBatchAction: onBatchAction, gridActions: gridActions, gridSelectors: gridSelectors, actionColumn: actionColumnDefinition, processCheckedValues: processCheckedValues, processCheckedValuesTitle: processCheckedValuesTitle })), _jsxs(x.div, { display: "flex", justifyContent: "center", alignItems: "center", className: "paginatorWrapper", w: "100%", h: window.innerWidth > 1204 ? '60px' : '32px', children: [_jsx(Pagination, { page: gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.page, itemCount: passDownProps === null || passDownProps === void 0 ? void 0 : passDownProps.totalRowsCount, itemPerPage: (gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.rowsPerPage) || 10, onPageChange: gridActions === null || gridActions === void 0 ? void 0 : gridActions.setPage, customPaginationHandler: customPaginationHandler }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler })] })] }) }), manageColumnFormVisible && (_jsx(Modal, { title: _jsx(Trans, { id: "manageColumn.title", message: "Manage columns" }), onClose: onClose, onCancel: onClose, onExtraAction: resetColumnConfig, onConfirm: onConfirmForm, width: "auto", minWidth: "350px", hasFooter: true, extraActionLabel: _jsx(Trans, { id: "dataGrid.buttonClearConfig", message: "Reset config" }), cancelLabel: _jsx(Trans, { id: "form.buttonCancel", message: "Cancel" }), confirmLabel: _jsx(Trans, { id: "form.buttonConfirm", message: "Confirm" }), children: _jsx(ManageColumnForm, { columns: columns, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions }) }))] }));
|
|
66
65
|
};
|
|
67
66
|
export default StyledCommonGrid;
|
|
@@ -2,6 +2,7 @@ import { GridActionsType, GridSelectorsType } from '../../types';
|
|
|
2
2
|
type Props = {
|
|
3
3
|
gridActions: GridActionsType;
|
|
4
4
|
gridSelectors: GridSelectorsType;
|
|
5
|
+
customPaginationHandler?: (page: number, rows: number) => void;
|
|
5
6
|
};
|
|
6
|
-
declare const TablePagination: ({ gridActions, gridSelectors }: Props) => JSX.Element;
|
|
7
|
+
declare const TablePagination: ({ gridActions, gridSelectors, customPaginationHandler }: Props) => JSX.Element;
|
|
7
8
|
export default TablePagination;
|
|
@@ -14,13 +14,15 @@ var rowsPerPageOptionValues = [10, 20, 50, 100];
|
|
|
14
14
|
var LABEL_VALUE = '_label_';
|
|
15
15
|
var filterRowsOption = function (option) { return option.value !== LABEL_VALUE; };
|
|
16
16
|
var TablePagination = function (_a) {
|
|
17
|
-
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors;
|
|
17
|
+
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, customPaginationHandler = _a.customPaginationHandler;
|
|
18
18
|
var setRowsPerPage = gridActions.setRowsPerPage;
|
|
19
|
+
var page = gridSelectors.page;
|
|
19
20
|
var onSetRowsPerPage = useCallback(function (option) {
|
|
20
21
|
if (option && 'value' in option) {
|
|
21
22
|
setRowsPerPage === null || setRowsPerPage === void 0 ? void 0 : setRowsPerPage(Number(option.value));
|
|
23
|
+
customPaginationHandler === null || customPaginationHandler === void 0 ? void 0 : customPaginationHandler(page !== null && page !== void 0 ? page : 1, Number(option.value));
|
|
22
24
|
}
|
|
23
|
-
}, [setRowsPerPage]);
|
|
25
|
+
}, [setRowsPerPage, page, customPaginationHandler]);
|
|
24
26
|
var rowsPerPageOptions = useMemo(function () {
|
|
25
27
|
return rowsPerPageOptionValues.map(function (value) { return ({ value: value, label: value }); });
|
|
26
28
|
}, []);
|
|
@@ -297,6 +297,8 @@ export type GridProps = Omit<CommonGridProps, 'filters'> & {
|
|
|
297
297
|
processCheckedValues?: () => void;
|
|
298
298
|
processCheckedValuesTitle?: string;
|
|
299
299
|
hideControlButtons?: boolean;
|
|
300
|
+
queryRowsParam?: number | string;
|
|
301
|
+
customPaginationHandler?: (page: number, rows: number) => void;
|
|
300
302
|
};
|
|
301
303
|
export type PageGridProps = Omit<GridProps, 'rowsData' | 'totalRowsCount' | 'columnsDefinitions' | 'actionColumnDefinition' | 'hideColumnConfig' | 'minColumnWidth' | 'columnLayout'>;
|
|
302
304
|
export type Item = {
|
|
@@ -16,4 +16,5 @@ export declare const getGroups: (columns: ColumnDefinition[]) => Group[];
|
|
|
16
16
|
export declare const getGroupClassNames: (group?: Group) => string;
|
|
17
17
|
export declare const getStickyCollClassNames: (sticky: boolean, stickTo?: StickTo) => string;
|
|
18
18
|
export declare const GRID_MIN_ROWS = 6;
|
|
19
|
+
export declare const rowHeight = 40;
|
|
19
20
|
export declare const getFilters: (optimizeFilters: boolean) => FiltersConfig;
|
|
@@ -64,6 +64,7 @@ export var getStickyCollClassNames = function (sticky, stickTo) {
|
|
|
64
64
|
return !sticky ? '' : "".concat(stickTo ? " sticky sticky-".concat(stickTo) : ' sticky sticky-left');
|
|
65
65
|
};
|
|
66
66
|
export var GRID_MIN_ROWS = 6;
|
|
67
|
+
export var rowHeight = 40;
|
|
67
68
|
export var getFilters = function (optimizeFilters) {
|
|
68
69
|
var filters = {
|
|
69
70
|
number: { CellComponent: NumberRange },
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type Props = {
|
|
2
2
|
page?: number;
|
|
3
3
|
itemCount?: number;
|
|
4
|
-
itemPerPage
|
|
4
|
+
itemPerPage: number;
|
|
5
5
|
onPageChange?: (number: number, rows: number) => void;
|
|
6
|
+
customPaginationHandler?: (page: number, rows: number) => void;
|
|
6
7
|
};
|
|
7
|
-
declare const Pagination: ({ onPageChange, itemPerPage, itemCount, page }: Props) => JSX.Element;
|
|
8
|
+
declare const Pagination: ({ onPageChange, itemPerPage, itemCount, page, customPaginationHandler }: Props) => JSX.Element;
|
|
8
9
|
export default Pagination;
|
|
@@ -2,12 +2,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import { Btn, GoIcon, Wrapper, PageBtn, DotsWrapper } from './styled';
|
|
4
4
|
var Pagination = function (_a) {
|
|
5
|
-
var onPageChange = _a.onPageChange, itemPerPage = _a.itemPerPage, itemCount = _a.itemCount, page = _a.page;
|
|
5
|
+
var onPageChange = _a.onPageChange, itemPerPage = _a.itemPerPage, itemCount = _a.itemCount, page = _a.page, customPaginationHandler = _a.customPaginationHandler;
|
|
6
6
|
var setPage = useCallback(function (number) { return function () {
|
|
7
|
+
if (customPaginationHandler) {
|
|
8
|
+
customPaginationHandler(number, itemPerPage);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
7
11
|
if (onPageChange) {
|
|
8
12
|
onPageChange(number, itemPerPage);
|
|
9
13
|
}
|
|
10
|
-
}; }, [itemPerPage, onPageChange]);
|
|
14
|
+
}; }, [itemPerPage, onPageChange, customPaginationHandler]);
|
|
11
15
|
var pageX = page !== null && page !== void 0 ? page : 1;
|
|
12
16
|
var pageCount = Math.max(Math.ceil((itemCount !== null && itemCount !== void 0 ? itemCount : 0) / (itemPerPage !== null && itemPerPage !== void 0 ? itemPerPage : 3)), 1);
|
|
13
17
|
var arrayOfPages = useMemo(function () {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { StoryObj } from '@storybook/react';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ onPageChange, itemPerPage, itemCount, page }: import("../Pagination").Props) => JSX.Element;
|
|
5
|
+
component: ({ onPageChange, itemPerPage, itemCount, page, customPaginationHandler }: import("../Pagination").Props) => JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
argTypes: {};
|
|
8
8
|
};
|