@mailstep/design-system 0.7.79-beta.7 → 0.7.79-beta.9

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.79-beta.7",
3
+ "version": "0.7.79-beta.9",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -44,18 +44,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
44
44
  return to.concat(ar || Array.prototype.slice.call(from));
45
45
  };
46
46
  import { jsx as _jsx } from "react/jsx-runtime";
47
- import { useCallback, useState } from 'react';
47
+ import { useCallback, useState, useMemo } from 'react';
48
48
  import Select from '../../../../../Elements/Select';
49
49
  import SingleSelect from '../../../../../Elements/SingleSelect';
50
50
  import { i18n } from '@lingui/core';
51
51
  import isArray from 'lodash/isArray';
52
- import { isOptionArray } from './guards';
53
52
  import uniqBy from 'lodash/uniqBy';
53
+ import { isOptionArray } from './guards';
54
54
  var SelectFilter = function (_a) {
55
55
  var onChange = _a.onChange, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions;
56
56
  var _b = useState([]), loadedOptions = _b[0], setLoadedOptions = _b[1];
57
57
  var handleOnMultiChange = useCallback(function (options) {
58
- console.log('handleOnMultiChange', options);
59
58
  onChange === null || onChange === void 0 ? void 0 : onChange(!isArray(options) || !(options === null || options === void 0 ? void 0 : options.length) ? null : options);
60
59
  }, [onChange]);
61
60
  var isAsync = !!asyncLoadKey;
@@ -75,9 +74,9 @@ var SelectFilter = function (_a) {
75
74
  return [2 /*return*/, data];
76
75
  }
77
76
  });
78
- }); }, [options]);
77
+ }); }, [asyncLoadKey, onAsyncLoadFilterOptions]);
78
+ var defaultOptions = useMemo(function () { return (isMulti && isAsync && isOptionArray(value) ? uniqBy(__spreadArray(__spreadArray([], loadedOptions, true), value, true), 'value') : undefined); }, [isAsync, value, loadedOptions]);
79
79
  if (isMulti) {
80
- var defaultOptions = isAsync && isOptionArray(value) ? uniqBy(__spreadArray(__spreadArray([], loadedOptions, true), value, true), 'value') : undefined;
81
80
  return (_jsx(Select, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: isOptionArray(value) ? value.map(function (option) { return String(option.value); }) : value, options: defaultOptions || options, showSelectAllButton: checkAllButton, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, defaultOptions: defaultOptions, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined, noOptionsMessage: function () { return null; }, containerVariant: isAsync ? 'search' : undefined, optionVariant: "checkbox", multiLabelVariant: "count", isMulti: true }));
82
81
  }
83
82
  return (_jsx(SingleSelect, { maxMenuHeight: 250, onChange: onChange, value: value, options: options, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined, isClearable: true }));
@@ -1,3 +1,4 @@
1
+ import { ComplexCell } from '../components/ComplexCell';
1
2
  import { EnumCellExample } from '../components/EnumCellExample';
2
3
  import { enumValues } from './utils';
3
4
  export var oversizedArrayColumns = 25;
@@ -42,72 +43,70 @@ export var columnDefinitions = [
42
43
  sorting: true,
43
44
  asyncLoadKey: 'enumColumnAsync'
44
45
  },
45
- /*
46
46
  {
47
- name: 'numberColumn',
48
- title: 'Number Column',
49
- flexBasis: 160,
50
- filtering: true,
51
- filteringType: 'number',
52
- filterExtraProps: {
53
- decimals: 2
54
- },
55
- sorting: true
47
+ name: 'numberColumn',
48
+ title: 'Number Column',
49
+ flexBasis: 160,
50
+ filtering: true,
51
+ filteringType: 'number',
52
+ filterExtraProps: {
53
+ decimals: 2
54
+ },
55
+ sorting: true
56
56
  },
57
57
  {
58
- name: 'numberFloatColumn',
59
- title: 'Number Float Column',
60
- flexBasis: 160,
61
- filtering: true,
62
- filteringType: 'number',
63
- sorting: true,
64
- filterExtraProps: {
65
- isFloat: true
66
- }
58
+ name: 'numberFloatColumn',
59
+ title: 'Number Float Column',
60
+ flexBasis: 160,
61
+ filtering: true,
62
+ filteringType: 'number',
63
+ sorting: true,
64
+ filterExtraProps: {
65
+ isFloat: true
66
+ }
67
67
  },
68
68
  {
69
- name: 'dateColumn',
70
- title: 'Date Column',
71
- flexBasis: 160,
72
- filtering: true,
73
- filteringType: 'date',
74
- sorting: true,
75
- filterExtraProps: {
76
- filterTime: true
77
- }
69
+ name: 'dateColumn',
70
+ title: 'Date Column',
71
+ flexBasis: 160,
72
+ filtering: true,
73
+ filteringType: 'date',
74
+ sorting: true,
75
+ filterExtraProps: {
76
+ filterTime: true
77
+ }
78
78
  },
79
79
  {
80
- name: 'boolColumn',
81
- title: 'Bool Column',
82
- flexBasis: 160,
83
- filtering: true,
84
- filteringType: 'flag',
85
- sorting: true,
86
- formatRowValue: (row: { boolColumn: boolean }): RowValueType => {
87
- return row.boolColumn ? 'Yes' : 'No'
88
- }
80
+ name: 'boolColumn',
81
+ title: 'Bool Column',
82
+ flexBasis: 160,
83
+ filtering: true,
84
+ filteringType: 'flag',
85
+ sorting: true,
86
+ formatRowValue: function (row) {
87
+ return row.boolColumn ? 'Yes' : 'No';
88
+ }
89
89
  },
90
90
  {
91
- name: 'advancedColumn',
92
- title: 'Advanced Column',
93
- flexBasis: 160,
94
- formatRowValue: (row: { numberColumn: number; textColumn: string }): RowValueType => {
95
- return `${(row.numberColumn / 4) * row.textColumn.length}`
96
- }
91
+ name: 'advancedColumn',
92
+ title: 'Advanced Column',
93
+ flexBasis: 160,
94
+ formatRowValue: function (row) {
95
+ return "".concat((row.numberColumn / 4) * row.textColumn.length);
96
+ }
97
97
  },
98
98
  {
99
- name: 'complexColumn',
100
- title: 'Complex Column',
101
- flexBasis: 350,
102
- cellComponent: ComplexCell
99
+ name: 'complexColumn',
100
+ title: 'Complex Column',
101
+ flexBasis: 350,
102
+ cellComponent: ComplexCell
103
103
  },
104
104
  {
105
- name: 'stickyColumn',
106
- title: 'Sticky Column',
107
- flexBasis: 160,
108
- alwaysOn: true,
109
- sticky: true,
110
- stickTo: 'right'
105
+ name: 'stickyColumn',
106
+ title: 'Sticky Column',
107
+ flexBasis: 160,
108
+ alwaysOn: true,
109
+ sticky: true,
110
+ stickTo: 'right'
111
111
  }
112
- */
113
112
  ];
@@ -74,8 +74,8 @@ var Select = function (_a) {
74
74
  if (showSelectAllButton && !isMulti) {
75
75
  console.error('CheckboxSelect incompatible props');
76
76
  }
77
- var setAllOptions = useCallback(function () {
78
- console.log('setAllOptions', options);
77
+ var setAllOptions = useCallback(function (_a) {
78
+ var options = _a.options;
79
79
  onChange === null || onChange === void 0 ? void 0 : onChange((options || []));
80
80
  }, [onChange, options]);
81
81
  var unsetAllOptions = useCallback(function () {
@@ -10,12 +10,19 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useMemo } from 'react';
13
14
  import { components as selectComponents } from 'react-select';
14
- import SelectAll from '../components/SelectAll';
15
15
  import ResetAll from '../components/ResetAll';
16
+ import SelectAll from '../components/SelectAll';
16
17
  var ConnectedMenu = function (props) {
17
18
  var theme = props.theme;
18
- var _a = props.selectProps, resetGrid = _a.resetGrid, onCustomSelectAll = _a.onCustomSelectAll, onCustomDeselectAll = _a.onCustomDeselectAll, value = _a.value, options = _a.options, resetGridButton = _a.resetGridButton, selectAllButton = _a.selectAllButton, maxMenuHeight = _a.maxMenuHeight, isLoading = _a.isLoading;
19
- return (_jsxs(selectComponents.MenuList, __assign({}, props, { children: [selectAllButton && !isLoading && (_jsx(SelectAll, { theme: theme, onCustomSelectAll: onCustomSelectAll, onCustomDeselectAll: onCustomDeselectAll, value: value, options: options, maxMenuHeight: maxMenuHeight })), props.children, resetGridButton && _jsx(ResetAll, { onReset: resetGrid })] })));
19
+ var _a = props.selectProps, resetGrid = _a.resetGrid, onCustomSelectAll = _a.onCustomSelectAll, onCustomDeselectAll = _a.onCustomDeselectAll, value = _a.value, resetGridButton = _a.resetGridButton, selectAllButton = _a.selectAllButton, maxMenuHeight = _a.maxMenuHeight, isLoading = _a.isLoading;
20
+ // because the filterd options (filterd by the search input) are not passed to the menu list (there are all options),
21
+ // we need to specify them here by children
22
+ var filteredOptions = useMemo(function () { var _a, _b; return (_b = (_a = props.children) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, function (_a) {
23
+ var _b = _a.props, value = _b.value, label = _b.label;
24
+ return ({ label: label, value: value });
25
+ }); }, [props.children]);
26
+ return (_jsxs(selectComponents.MenuList, __assign({}, props, { children: [selectAllButton && !isLoading && (_jsx(SelectAll, { theme: theme, onCustomSelectAll: onCustomSelectAll, onCustomDeselectAll: onCustomDeselectAll, value: value, options: filteredOptions, maxMenuHeight: maxMenuHeight })), props.children, resetGridButton && _jsx(ResetAll, { onReset: resetGrid })] })));
20
27
  };
21
28
  export default ConnectedMenu;
@@ -1,12 +1,14 @@
1
- import { SelectProps, CustomTheme } from '../types';
1
+ import { SelectProps, CustomTheme, Option } from '../types';
2
2
 
3
3
  type Props = {
4
- onCustomSelectAll: () => void;
4
+ onCustomSelectAll: ({ options }: {
5
+ options?: Option[];
6
+ }) => void;
5
7
  onCustomDeselectAll: () => void;
6
8
  value: SelectProps['value'];
7
9
  options: SelectProps['options'];
8
10
  maxMenuHeight: number;
9
11
  theme: CustomTheme;
10
12
  };
11
- declare const SelectAll: ({ onCustomSelectAll, onCustomDeselectAll, value, options, maxMenuHeight, theme }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ declare const SelectAll: ({ onCustomSelectAll, onCustomDeselectAll, value, options, maxMenuHeight, theme }: Props) => import("react/jsx-runtime").JSX.Element | null;
12
14
  export default SelectAll;
@@ -4,11 +4,11 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { useCallback, useState, useEffect, useRef } from 'react';
7
- import styled, { th } from '@xstyled/styled-components';
8
- import { Trans } from '@lingui/react';
9
7
  import Checkbox from '../../../Forms/Checkbox/Checkbox';
10
8
  import Toggle from '../../Toggle/Toggle';
11
9
  import SelectedIndicator from '../components/SelectedIndicator';
10
+ import { Trans } from '@lingui/react';
11
+ import styled, { th } from '@xstyled/styled-components';
12
12
  var SelectAllWrap = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n margin: 0px 2px 1px 0px;\n padding: ", ";\n font-weight: 400;\n background-color: ", ";\n color: ", ";\n border-radius: 6px;\n height: 36px;\n cursor: pointer;\n\n :hover {\n background-color: ", ";\n }\n"], ["\n display: flex;\n margin: 0px 2px 1px 0px;\n padding: ", ";\n font-weight: 400;\n background-color: ", ";\n color: ", ";\n border-radius: 6px;\n height: 36px;\n cursor: pointer;\n\n :hover {\n background-color: ", ";\n }\n"])), function (_a) {
13
13
  var additionalPadding = _a.additionalPadding;
14
14
  return (additionalPadding ? '8px 27px 8px 10px' : '10px 10px');
@@ -32,13 +32,13 @@ var SelectAll = function (_a) {
32
32
  var handleSelectAll = useCallback(function () {
33
33
  if (!isSelected) {
34
34
  setIsSelected(true);
35
- onCustomSelectAll();
35
+ onCustomSelectAll({ options: options });
36
36
  }
37
37
  else if (isSelected) {
38
38
  setIsSelected(false);
39
39
  onCustomDeselectAll();
40
40
  }
41
- }, [isSelected, onCustomDeselectAll, onCustomSelectAll]);
41
+ }, [isSelected, onCustomDeselectAll, onCustomSelectAll, options]);
42
42
  useEffect(function () {
43
43
  var _a;
44
44
  // if the height of all options is higher than maxMenuHeight and the slider is displayed => the indentation needs to be increased
@@ -50,7 +50,10 @@ var SelectAll = function (_a) {
50
50
  (options === null || options === void 0 ? void 0 : options.length) !== value.length && setIsSelected(false);
51
51
  }
52
52
  }, [maxMenuHeight, options === null || options === void 0 ? void 0 : options.length, value]);
53
- return (_jsxs(SelectAllWrap, { isSelected: isSelected, onClick: handleSelectAll, ref: ref, additionalPadding: additionalPadding, children: [(showCheckbox || showToggle) && (_jsxs(SelectedIndicator, { children: [showCheckbox && _jsx(Checkbox, { checked: isSelected, size: 2, readOnly: true }), showToggle && _jsx(Toggle, { name: "", checked: isSelected, spaceAround: false, variant: 'grid' })] })), _jsx(Trans, { id: "datagrid.filterCell.selectAllLabel", message: 'select all' })] }));
53
+ if (!(options === null || options === void 0 ? void 0 : options.length)) {
54
+ return null;
55
+ }
56
+ return (_jsxs(SelectAllWrap, { isSelected: isSelected, onClick: handleSelectAll, ref: ref, additionalPadding: additionalPadding, children: [(showCheckbox || showToggle) && (_jsxs(SelectedIndicator, { children: [showCheckbox && _jsx(Checkbox, { checked: isSelected, size: 2, readOnly: true }), showToggle && _jsx(Toggle, { name: "", checked: isSelected, spaceAround: false, variant: 'grid' })] })), _jsx(Trans, { id: "datagrid.filterCell.selectAllLabel", message: 'select all' }), " (", options === null || options === void 0 ? void 0 : options.length, ")"] }));
54
57
  };
55
58
  export default SelectAll;
56
59
  var templateObject_1;