@mailstep/design-system 0.5.0-beta.38 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.5.0-beta.38",
3
+ "version": "0.5.0-beta.39",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -39,23 +39,18 @@ import TablePagination from './components/TablePagination';
39
39
  import Modal from '../Modal';
40
40
  import ManageColumnForm from './components/ManageColumnForm';
41
41
  import { Trans } from '@lingui/react';
42
- import { useLocation } from 'react-router';
43
42
  var StyledCommonGrid = function (props) {
44
- 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"]);
45
44
  var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
46
- var location = useLocation();
47
- var useQuery = function () { return new URLSearchParams(location.search); };
48
- var query = useQuery();
49
- var queryRowsPerPage = query.get('rows');
50
45
  var _b = useGetGridHeight(), gridHeight = _b.gridHeight, gridRef = _b.gridRef, paginationRef = _b.paginationRef;
51
46
  useEffect(function () {
52
47
  var _a;
53
- if (!queryRowsPerPage && gridHeight && gridHeight > 0) {
48
+ if (!queryRowsParam && gridHeight && gridHeight > 0) {
54
49
  // Only main grids (without form grids on new pages)
55
50
  var numberOfRows = Math.max(Math.floor(gridHeight / rowHeight - 2), GRID_MIN_ROWS);
56
51
  numberOfRows && ((_a = gridActions.setRowsPerPage) === null || _a === void 0 ? void 0 : _a.call(gridActions, numberOfRows));
57
52
  }
58
- }, [gridHeight, gridActions, queryRowsPerPage]);
53
+ }, [gridHeight, gridActions, queryRowsParam]);
59
54
  var modifiedPassDownProps = useEditReadAsColumn(passDownProps);
60
55
  var filters = useMemo(function () { return getFilters(optimizeFilters); }, [optimizeFilters]);
61
56
  var columns = modifiedPassDownProps.columnsDefinitions;
@@ -66,6 +61,6 @@ var StyledCommonGrid = function (props) {
66
61
  gridSelectors: gridSelectors,
67
62
  onClose: onClose,
68
63
  }), columnsConfigValues = _d.columnsConfigValues, setColumnsConfigOptions = _d.setColumnsConfigOptions, onConfirmForm = _d.onConfirmForm, resetColumnConfig = _d.resetColumnConfig;
69
- 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 }) }))] }));
70
65
  };
71
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 = {
@@ -1,8 +1,9 @@
1
1
  export type Props = {
2
2
  page?: number;
3
3
  itemCount?: number;
4
- itemPerPage?: number;
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
  };