@mailstep/design-system 0.7.6 → 0.7.8-beta.0

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.7.6",
3
+ "version": "0.7.8-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -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, GRID_MIN_ROWS, rowHeight } from './utils';
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
- // Only main grids (without form grids on new pages)
49
- var numberOfRows = Math.max(Math.floor(gridHeight / rowHeight - 2), GRID_MIN_ROWS);
50
- if (autoHeight) {
51
- numberOfRows && ((_a = gridActions.setRowsPerPage) === null || _a === void 0 ? void 0 : _a.call(gridActions, numberOfRows));
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]);
@@ -2,17 +2,24 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
6
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
7
+ if (ar || !(i in from)) {
8
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9
+ ar[i] = from[i];
10
+ }
11
+ }
12
+ return to.concat(ar || Array.prototype.slice.call(from));
13
+ };
5
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- import styled, { x } from '@xstyled/styled-components';
7
- import { Trans } from '@lingui/react';
8
15
  import { useCallback, useMemo } from 'react';
9
16
  import Select from '../../../../Elements/Select/Select';
10
17
  import { Paragraph4 } from '../../../../Elements/Typography/Typography';
18
+ import { Trans } from '@lingui/react';
19
+ import styled, { x } from '@xstyled/styled-components';
11
20
  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
21
  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
22
  var rowsPerPageOptionValues = [10, 20, 50, 100];
14
- var LABEL_VALUE = '_label_';
15
- var filterRowsOption = function (option) { return option.value !== LABEL_VALUE; };
16
23
  var TablePagination = function (_a) {
17
24
  var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, customPaginationHandler = _a.customPaginationHandler;
18
25
  var setRowsPerPage = gridActions.setRowsPerPage;
@@ -24,9 +31,9 @@ var TablePagination = function (_a) {
24
31
  }
25
32
  }, [setRowsPerPage, page, customPaginationHandler]);
26
33
  var rowsPerPageOptions = useMemo(function () {
27
- return rowsPerPageOptionValues.map(function (value) { return ({ value: value, label: value }); });
34
+ return __spreadArray(__spreadArray([], rowsPerPageOptionValues.map(function (value) { return ({ value: value, label: value }); }), true), [{ value: '', label: 'auto' }], false);
28
35
  }, []);
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" }) })] }));
36
+ 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
37
  };
31
38
  export default TablePagination;
32
39
  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;