@mailstep/design-system 0.7.6 → 0.7.8-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/CommonGridContainer.js +8 -7
- package/ui/Blocks/CommonGrid/components/TablePagination/TablePagination.d.ts +3 -1
- package/ui/Blocks/CommonGrid/components/TablePagination/TablePagination.js +13 -11
- package/ui/Blocks/CommonGrid/types.d.ts +1 -0
- package/ui/index.es.js +12782 -13247
- package/ui/index.umd.js +580 -580
package/package.json
CHANGED
|
@@ -35,20 +35,21 @@ import useManageColumn from './hooks/useManageColumn';
|
|
|
35
35
|
import { usePresetState } from './hooks/usePresetsState';
|
|
36
36
|
import { x } from '@xstyled/styled-components';
|
|
37
37
|
import { CommonGridWithStyles, BottomWrapper, CommonGridWrap, ContentContainer, StyledButtonStrip } from './styles';
|
|
38
|
-
import { getFilters
|
|
38
|
+
import { getFilters } from './utils';
|
|
39
39
|
var CommonGridContainer = function (props) {
|
|
40
40
|
var _a;
|
|
41
|
-
var _b = props.optimizeFilters, optimizeFilters = _b === void 0 ? false : _b, extraControlButtons = props.extraControlButtons, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, quickFilter = props.quickFilter, floatingButtonProps = props.floatingButtonProps, queryRowsParam = props.queryRowsParam, customPaginationHandler = props.customPaginationHandler, _c = props.autoHeight, autoHeight = _c === void 0 ? true : _c, gridName = props.gridName, _d = props.withPresets, withPresets = _d === void 0 ? true : _d, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "quickFilter", "floatingButtonProps", "queryRowsParam", "customPaginationHandler", "autoHeight", "gridName", "withPresets"]);
|
|
41
|
+
var _b = props.optimizeFilters, optimizeFilters = _b === void 0 ? false : _b, extraControlButtons = props.extraControlButtons, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, quickFilter = props.quickFilter, floatingButtonProps = props.floatingButtonProps, queryRowsParam = props.queryRowsParam, customPaginationHandler = props.customPaginationHandler, _c = props.autoHeight, autoHeight = _c === void 0 ? true : _c, gridName = props.gridName, _d = props.withPresets, withPresets = _d === void 0 ? true : _d, getRowsPerPage = props.getRowsPerPage, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "quickFilter", "floatingButtonProps", "queryRowsParam", "customPaginationHandler", "autoHeight", "gridName", "withPresets", "getRowsPerPage"]);
|
|
42
42
|
var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
|
|
43
43
|
var _e = useState(false), displayManageColumnButton = _e[0], setDisplayManageColumnButton = _e[1];
|
|
44
44
|
var _f = useGetGridHeight(), gridHeight = _f.gridHeight, gridRef = _f.gridRef, paginationRef = _f.paginationRef;
|
|
45
45
|
useEffect(function () {
|
|
46
46
|
var _a;
|
|
47
47
|
if (!queryRowsParam && gridHeight && gridHeight > 0) {
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// @TODO this move to mailship
|
|
49
|
+
// const numberOfRows = Math.max(Math.floor(gridHeight / rowHeight - 2), GRID_MIN_ROWS)
|
|
50
|
+
var numberOfRows = getRowsPerPage === null || getRowsPerPage === void 0 ? void 0 : getRowsPerPage(gridHeight);
|
|
51
|
+
if (autoHeight && numberOfRows) {
|
|
52
|
+
(_a = gridActions.setRowsPerPage) === null || _a === void 0 ? void 0 : _a.call(gridActions, numberOfRows);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}, [gridHeight, gridActions, queryRowsParam]);
|
|
@@ -63,6 +64,6 @@ var CommonGridContainer = function (props) {
|
|
|
63
64
|
onClose: onClose
|
|
64
65
|
}), columnsConfigValues = _h.columnsConfigValues, setColumnsConfigOptions = _h.setColumnsConfigOptions, onConfirmForm = _h.onConfirmForm, resetColumnConfig = _h.resetColumnConfig, handleDragEnd = _h.handleDragEnd, onCloseForm = _h.onCloseForm, displayColumnsDefinitions = _h.displayColumnsDefinitions, manageColumnsFormDefinitions = _h.manageColumnsFormDefinitions;
|
|
65
66
|
var _j = usePresetState(), isPresetsModalOpen = _j.isPresetsModalOpen, onClosePresetsModal = _j.onClosePresetsModal, onOpenPresetsModal = _j.onOpenPresetsModal, setSelectedPresetName = _j.setSelectedPresetName, selectedPresetName = _j.selectedPresetName;
|
|
66
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName }) }) }), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { filters: filters, gridRef: gridRef, height: gridHeight, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasColouredRows: true }))] }), _jsx(HidePrint, { children: _jsxs(BottomWrapper, { ref: paginationRef, isFixed: !!gridHeight, children: [(processCheckedValues || !!((_a = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions) === null || _a === void 0 ? void 0 : _a.length)) && (_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, radius: window.innerWidth < 768 ? 3 : 5, rate: window.innerWidth < 768 ? 1 : 4 }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler })] })] }) })] }), _jsx(GridModals, { manageColumnFormVisible: manageColumnFormVisible, onCloseForm: onCloseForm, resetColumnConfig: resetColumnConfig, onConfirmForm: onConfirmForm, manageColumnsFormDefinitions: manageColumnsFormDefinitions, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, handleDragEnd: handleDragEnd(true), gridName: gridName, gridActions: gridActions, gridSelectors: gridSelectors, onClosePresetsModal: onClosePresetsModal, isPresetsModalOpen: isPresetsModalOpen, selectedPresetName: selectedPresetName, setSelectedPresetName: setSelectedPresetName })] }));
|
|
67
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName }) }) }), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { filters: filters, gridRef: gridRef, height: gridHeight, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasColouredRows: true }))] }), _jsx(HidePrint, { children: _jsxs(BottomWrapper, { ref: paginationRef, isFixed: !!gridHeight, children: [(processCheckedValues || !!((_a = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions) === null || _a === void 0 ? void 0 : _a.length)) && (_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, radius: window.innerWidth < 768 ? 3 : 5, rate: window.innerWidth < 768 ? 1 : 4 }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler, getRowsPerPage: getRowsPerPage, gridHeight: gridHeight })] })] }) })] }), _jsx(GridModals, { manageColumnFormVisible: manageColumnFormVisible, onCloseForm: onCloseForm, resetColumnConfig: resetColumnConfig, onConfirmForm: onConfirmForm, manageColumnsFormDefinitions: manageColumnsFormDefinitions, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, handleDragEnd: handleDragEnd(true), gridName: gridName, gridActions: gridActions, gridSelectors: gridSelectors, onClosePresetsModal: onClosePresetsModal, isPresetsModalOpen: isPresetsModalOpen, selectedPresetName: selectedPresetName, setSelectedPresetName: setSelectedPresetName })] }));
|
|
67
68
|
};
|
|
68
69
|
export default CommonGridContainer;
|
|
@@ -3,6 +3,8 @@ type Props = {
|
|
|
3
3
|
gridActions: GridActionsType;
|
|
4
4
|
gridSelectors: GridSelectorsType;
|
|
5
5
|
customPaginationHandler?: (page: number, rows: number) => void;
|
|
6
|
+
getRowsPerPage?: (height?: number) => number;
|
|
7
|
+
gridHeight?: number;
|
|
6
8
|
};
|
|
7
|
-
declare const TablePagination: ({ gridActions, gridSelectors, customPaginationHandler }: Props) => JSX.Element;
|
|
9
|
+
declare const TablePagination: ({ gridActions, gridSelectors, getRowsPerPage, gridHeight, customPaginationHandler }: Props) => JSX.Element;
|
|
8
10
|
export default TablePagination;
|
|
@@ -3,30 +3,32 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
import
|
|
7
|
-
import { Trans } from '@lingui/react';
|
|
8
|
-
import { useCallback, useMemo } from 'react';
|
|
6
|
+
import { useCallback } from 'react';
|
|
9
7
|
import Select from '../../../../Elements/Select/Select';
|
|
10
8
|
import { Paragraph4 } from '../../../../Elements/Typography/Typography';
|
|
9
|
+
import { Trans } from '@lingui/react';
|
|
10
|
+
import styled, { x } from '@xstyled/styled-components';
|
|
11
11
|
var Wrapper = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n & > :nth-child(2) {\n display: none;\n @media (min-width: 1024px) {\n display: block;\n }\n }\n"], ["\n display: flex;\n align-items: center;\n & > :nth-child(2) {\n display: none;\n @media (min-width: 1024px) {\n display: block;\n }\n }\n"])));
|
|
12
12
|
var StyledSelect = styled(x.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-right: 15px;\n @media (min-width: 1024px) {\n margin-right: 8px;\n }\n"], ["\n margin-right: 15px;\n @media (min-width: 1024px) {\n margin-right: 8px;\n }\n"])));
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var rowsPerPageOptions = [
|
|
14
|
+
{ value: 10, label: 10 },
|
|
15
|
+
{ value: 20, label: 20 },
|
|
16
|
+
{ value: 50, label: 50 },
|
|
17
|
+
{ value: 100, label: 100 },
|
|
18
|
+
{ value: 'auto', label: 'auto' },
|
|
19
|
+
];
|
|
16
20
|
var TablePagination = function (_a) {
|
|
17
|
-
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, customPaginationHandler = _a.customPaginationHandler;
|
|
21
|
+
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, getRowsPerPage = _a.getRowsPerPage, gridHeight = _a.gridHeight, customPaginationHandler = _a.customPaginationHandler;
|
|
18
22
|
var setRowsPerPage = gridActions.setRowsPerPage;
|
|
19
23
|
var page = gridSelectors.page;
|
|
20
24
|
var onSetRowsPerPage = useCallback(function (option) {
|
|
21
25
|
if (option && 'value' in option) {
|
|
26
|
+
var value = option.value !== 'auto' ? Number(option.value) : ((getRowsPerPage === null || getRowsPerPage === void 0 ? void 0 : getRowsPerPage(gridHeight)) || 10); // @TODO use 10 from constants
|
|
22
27
|
setRowsPerPage === null || setRowsPerPage === void 0 ? void 0 : setRowsPerPage(Number(option.value));
|
|
23
28
|
customPaginationHandler === null || customPaginationHandler === void 0 ? void 0 : customPaginationHandler(page !== null && page !== void 0 ? page : 1, Number(option.value));
|
|
24
29
|
}
|
|
25
30
|
}, [setRowsPerPage, page, customPaginationHandler]);
|
|
26
|
-
|
|
27
|
-
return rowsPerPageOptionValues.map(function (value) { return ({ value: value, label: value }); });
|
|
28
|
-
}, []);
|
|
29
|
-
return (_jsxs(Wrapper, { children: [_jsx(StyledSelect, { minWidth: "80px", children: _jsx(Select, { name: "rowsPerPage", menuPlacement: "top", style: "gridFilter", placeholder: "".concat(gridSelectors.rowsPerPage), options: rowsPerPageOptions, value: gridSelectors.rowsPerPage, filterOption: filterRowsOption, isDarkPlaceholderText: true, onChange: onSetRowsPerPage }) }), _jsx(Paragraph4, { variant: "normal", mr: "20px", children: _jsx(Trans, { id: "dataGrid.resultsPerPage", message: "Results per page" }) })] }));
|
|
31
|
+
return (_jsxs(Wrapper, { children: [_jsx(StyledSelect, { minWidth: "80px", children: _jsx(Select, { name: "rowsPerPage", menuPlacement: "top", style: "gridFilter", placeholder: "".concat(gridSelectors.rowsPerPage), options: rowsPerPageOptions, value: gridSelectors.rowsPerPage, isDarkPlaceholderText: true, onChange: onSetRowsPerPage }) }), _jsx(Paragraph4, { variant: "normal", mr: "20px", children: _jsx(Trans, { id: "dataGrid.resultsPerPage", message: "Results per page" }) })] }));
|
|
30
32
|
};
|
|
31
33
|
export default TablePagination;
|
|
32
34
|
var templateObject_1, templateObject_2;
|
|
@@ -260,6 +260,7 @@ export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
|
260
260
|
onRowEditClick?: (id: string, props: TData) => void;
|
|
261
261
|
onRowReadClick?: (id: string, props: TData) => void;
|
|
262
262
|
onRowClick?: (id: string, props: TData) => void;
|
|
263
|
+
getRowsPerPage?: (height?: number) => number;
|
|
263
264
|
onBatchAction?: OnBatchActionFn;
|
|
264
265
|
columnLayout?: ColumnLayout;
|
|
265
266
|
quickFilter?: string;
|