@mailstep/design-system 0.7.79-beta.1 → 0.7.79-beta.3

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.1",
3
+ "version": "0.7.79-beta.3",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -7,7 +7,7 @@ type Props = {
7
7
  onAsyncLoadFilterOptions?: CommonGridProps['onAsyncLoadFilterOptions'];
8
8
  isMulti?: boolean;
9
9
  options?: Option[];
10
- value?: string | string[];
10
+ value?: string | string[] | Option[];
11
11
  checkAllButton?: boolean;
12
12
  asyncLoadKey?: string;
13
13
  };
@@ -35,18 +35,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import { jsx as _jsx } from "react/jsx-runtime";
38
- import { useCallback, useState } from 'react';
39
- import MultiSelect from '../../../../../Elements/MultiSelect';
38
+ import { useCallback } from 'react';
39
+ import Select from '../../../../../Elements/Select';
40
40
  import SingleSelect from '../../../../../Elements/SingleSelect';
41
41
  import { i18n } from '@lingui/core';
42
42
  import isArray from 'lodash/isArray';
43
- var emptyValue = [];
43
+ import { isOptionArray } from './guards';
44
44
  var SelectFilter = function (_a) {
45
45
  var onChange = _a.onChange, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions;
46
- var _b = useState([]), asyncOptions = _b[0], setAsyncOptions = _b[1];
47
46
  var handleOnMultiChange = useCallback(function (options) {
48
- console.log('options', options);
49
- onChange === null || onChange === void 0 ? void 0 : onChange(!isArray(options) || !(options === null || options === void 0 ? void 0 : options.length) ? null : options.map(function (option) { return option.value; }));
47
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isArray(options) || !(options === null || options === void 0 ? void 0 : options.length) ? null : options);
50
48
  }, [onChange]);
51
49
  var isAsync = !!asyncLoadKey;
52
50
  var handleLoadOptions = useCallback(function (fulltext) { return __awaiter(void 0, void 0, void 0, function () {
@@ -60,15 +58,14 @@ var SelectFilter = function (_a) {
60
58
  case 1:
61
59
  data = (_a.sent()) || [];
62
60
  _a.label = 2;
63
- case 2:
64
- setAsyncOptions(data);
65
- return [2 /*return*/, data];
61
+ case 2: return [2 /*return*/, data];
66
62
  }
67
63
  });
68
64
  }); }, [options]);
65
+ console.log('value', value);
69
66
  if (isMulti) {
70
- return (_jsx(MultiSelect, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: value || emptyValue, options: isAsync ? asyncOptions : options, checkAllButton: !isAsync && checkAllButton, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined }));
67
+ return (_jsx(Select, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: value, options: isAsync && isOptionArray(value) ? value : options, showSelectAllButton: !isAsync && checkAllButton, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined, noOptionsMessage: function () { return i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }); }, optionVariant: "checkbox", multiLabelVariant: "count", isMulti: true }));
71
68
  }
72
- 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 }));
69
+ 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 }));
73
70
  };
74
71
  export default SelectFilter;
@@ -0,0 +1,3 @@
1
+ import { Option } from '../../../../../Elements/Select/types';
2
+
3
+ export declare const isOptionArray: (value: unknown) => value is Option[];
@@ -0,0 +1,3 @@
1
+ export var isOptionArray = function (value) {
2
+ return Array.isArray(value) && value.every(function (v) { return typeof v === 'object' && v !== null && 'label' in v && 'value' in v; });
3
+ };
@@ -1,4 +1,3 @@
1
- import { ComplexCell } from '../components/ComplexCell';
2
1
  import { EnumCellExample } from '../components/EnumCellExample';
3
2
  import { enumValues } from './utils';
4
3
  export var oversizedArrayColumns = 25;
@@ -18,95 +17,99 @@ export var enumColumn = {
18
17
  cellComponent: EnumCellExample
19
18
  };
20
19
  export var columnDefinitions = [
20
+ /*
21
21
  {
22
- name: 'hiddenColumn',
23
- title: 'Hidden column',
24
- flexBasis: 160,
25
- filtering: true,
26
- sorting: true,
27
- defaultHidden: true
22
+ name: 'hiddenColumn',
23
+ title: 'Hidden column',
24
+ flexBasis: 160,
25
+ filtering: true,
26
+ sorting: true,
27
+ defaultHidden: true
28
28
  },
29
29
  {
30
- name: 'textColumn',
31
- title: 'Text column',
32
- flexBasis: 160,
33
- filtering: true,
34
- sorting: true
30
+ name: 'textColumn',
31
+ title: 'Text column',
32
+ flexBasis: 160,
33
+ filtering: true,
34
+ sorting: true
35
35
  },
36
36
  enumColumn,
37
+ */
37
38
  {
38
39
  name: 'enumColumnAsync',
39
40
  title: 'Enum Column Async',
40
41
  flexBasis: 160,
41
- filterExtraProps: { isMulti: false },
42
+ filterExtraProps: { isMulti: true },
42
43
  filtering: true,
43
44
  sorting: true,
44
45
  asyncLoadKey: 'enumColumnAsync'
45
46
  },
47
+ /*
46
48
  {
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
49
+ name: 'numberColumn',
50
+ title: 'Number Column',
51
+ flexBasis: 160,
52
+ filtering: true,
53
+ filteringType: 'number',
54
+ filterExtraProps: {
55
+ decimals: 2
56
+ },
57
+ sorting: true
56
58
  },
57
59
  {
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
- }
60
+ name: 'numberFloatColumn',
61
+ title: 'Number Float Column',
62
+ flexBasis: 160,
63
+ filtering: true,
64
+ filteringType: 'number',
65
+ sorting: true,
66
+ filterExtraProps: {
67
+ isFloat: true
68
+ }
67
69
  },
68
70
  {
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
- }
71
+ name: 'dateColumn',
72
+ title: 'Date Column',
73
+ flexBasis: 160,
74
+ filtering: true,
75
+ filteringType: 'date',
76
+ sorting: true,
77
+ filterExtraProps: {
78
+ filterTime: true
79
+ }
78
80
  },
79
81
  {
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
- }
82
+ name: 'boolColumn',
83
+ title: 'Bool Column',
84
+ flexBasis: 160,
85
+ filtering: true,
86
+ filteringType: 'flag',
87
+ sorting: true,
88
+ formatRowValue: (row: { boolColumn: boolean }): RowValueType => {
89
+ return row.boolColumn ? 'Yes' : 'No'
90
+ }
89
91
  },
90
92
  {
91
- name: 'advancedColumn',
92
- title: 'Advanced Column',
93
- flexBasis: 160,
94
- formatRowValue: function (row) {
95
- return "".concat((row.numberColumn / 4) * row.textColumn.length);
96
- }
93
+ name: 'advancedColumn',
94
+ title: 'Advanced Column',
95
+ flexBasis: 160,
96
+ formatRowValue: (row: { numberColumn: number; textColumn: string }): RowValueType => {
97
+ return `${(row.numberColumn / 4) * row.textColumn.length}`
98
+ }
97
99
  },
98
100
  {
99
- name: 'complexColumn',
100
- title: 'Complex Column',
101
- flexBasis: 350,
102
- cellComponent: ComplexCell
101
+ name: 'complexColumn',
102
+ title: 'Complex Column',
103
+ flexBasis: 350,
104
+ cellComponent: ComplexCell
103
105
  },
104
106
  {
105
- name: 'stickyColumn',
106
- title: 'Sticky Column',
107
- flexBasis: 160,
108
- alwaysOn: true,
109
- sticky: true,
110
- stickTo: 'right'
107
+ name: 'stickyColumn',
108
+ title: 'Sticky Column',
109
+ flexBasis: 160,
110
+ alwaysOn: true,
111
+ sticky: true,
112
+ stickTo: 'right'
111
113
  }
114
+ */
112
115
  ];
@@ -105,6 +105,6 @@ var Select = function (_a) {
105
105
  }
106
106
  }); }); } : undefined;
107
107
  }, [loadOptions]);
108
- return (_jsxs(SpaceAroundWrap, { spaceAround: spaceAround, className: className, children: [_jsxs(Wrapper, { children: [label && _jsx(FieldLabel, { htmlFor: name, children: label }), _jsx(RenderComponent, __assign({ id: name, name: name, options: options, loadOptions: handleLoadOptions, defaultOptions: defaultOptions, value: selectedOption, onChange: onChange, onBlur: onBlur, isDisabled: disabled || isLoading, isLoading: isLoading, isInvalid: isInvalid !== undefined ? isInvalid : !!error, isDarkPlaceholderText: isDarkPlaceholderText, placeholder: placeholder || i18n._({ id: 'components.dropdown.placeholder', message: 'Select...' }), styles: customStyles, theme: customTheme, icon: icon, hideSelectedOptions: !!(isMulti && multiLabelVariant != 'count'), onInputChange: onInputChange, isSearchable: isAsync || isSearchable, isMulti: isMulti, classNamePrefix: "react-select", components: customComponents, closeMenuOnSelect: isMulti ? false : undefined }, passTroughProps, { ref: innerRef, tabIndex: null, systemTheme: theme, resetGrid: resetGrid, onCustomSelectAll: setAllOptions, onCustomDeselectAll: unsetAllOptions, selectAllButton: showSelectAllButton, resetGridButton: showResetGridButton, maxMenuHeight: modifiedMaxMenuHeight, getOptionValue: getOptionValue, noOptionsMessage: noOptionsMessage, loadingMessage: loadingMessage, shortValues: shortValues }))] }), error && _jsx(ErrorMessage, { children: error })] }));
108
+ return (_jsxs(SpaceAroundWrap, { spaceAround: spaceAround, className: className, children: [_jsxs(Wrapper, { children: [label && _jsx(FieldLabel, { htmlFor: name, children: label }), _jsx(RenderComponent, __assign({ id: name, name: name, options: options, loadOptions: handleLoadOptions, defaultOptions: defaultOptions, value: selectedOption, onChange: onChange, onBlur: onBlur, isDisabled: disabled || isLoading, isLoading: isLoading, isInvalid: isInvalid !== undefined ? isInvalid : !!error, isDarkPlaceholderText: isDarkPlaceholderText, placeholder: placeholder || i18n._({ id: 'components.dropdown.placeholder', message: 'Select...' }), styles: customStyles, theme: customTheme, icon: icon, hideSelectedOptions: !!(isMulti && multiLabelVariant != 'count'), onInputChange: onInputChange, isSearchable: isAsync || isSearchable, isMulti: isMulti, classNamePrefix: "react-select", components: customComponents, closeMenuOnSelect: isMulti ? false : undefined, noOptionsMessage: noOptionsMessage }, passTroughProps, { ref: innerRef, tabIndex: null, systemTheme: theme, resetGrid: resetGrid, onCustomSelectAll: setAllOptions, onCustomDeselectAll: unsetAllOptions, selectAllButton: showSelectAllButton, resetGridButton: showResetGridButton, maxMenuHeight: modifiedMaxMenuHeight, getOptionValue: getOptionValue, loadingMessage: loadingMessage, shortValues: shortValues }))] }), error && _jsx(ErrorMessage, { children: error })] }));
109
109
  };
110
110
  export default Select;
@@ -85,12 +85,11 @@ var SingleSelect = function (props) {
85
85
  var _e = useState(false), isCreating = _e[0], setIsCreating = _e[1];
86
86
  var asAsync = !!loadOptions || !!onCreateOption;
87
87
  var noOptionsMessage = useCallback(function (inputValue) {
88
- return loadOptions && inputValue.length < asyncLoadMinChars
89
- ? i18n._({
90
- id: 'components.dropdown.writeMoreChars',
91
- message: 'Write at least ${asyncLoadMinChars} characters.'
92
- })
93
- : i18n._({ id: 'components.dropdown.noOptions', message: 'No options' });
88
+ if (!loadOptions)
89
+ return i18n._({ id: 'components.dropdown.noOptions', message: 'No options' });
90
+ if (inputValue.length < asyncLoadMinChars)
91
+ return i18n._({ id: 'components.dropdown.writeMoreChars', message: 'Write at least ${asyncLoadMinChars} characters.' });
92
+ return i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' });
94
93
  }, [loadOptions, asyncLoadMinChars]);
95
94
  var handleLoadOptions = useCallback(function (inputValue) { return __awaiter(void 0, void 0, void 0, function () {
96
95
  return __generator(this, function (_a) {
package/ui/index.d.ts CHANGED
@@ -27,7 +27,6 @@ import { default as Label } from './Elements/Label';
27
27
  import { default as Line } from './Elements/Line';
28
28
  import { default as Link } from './Elements/Link';
29
29
  import { default as Logo } from './Elements/Logo';
30
- import { default as MultiSelect } from './Elements/MultiSelect';
31
30
  import { default as Pagination } from './Elements/Pagination';
32
31
  import { default as Portal } from './Elements/Portal';
33
32
  import { default as ProgressBar } from './Elements/ProgressBar';
@@ -47,7 +46,7 @@ import { default as TextArea } from './Forms/TextArea';
47
46
  import { default as ThemeProvider } from './ThemeProvider';
48
47
  import { default as utils } from './utils';
49
48
 
50
- export { DropdownSelect, DatePicker, CommonGrid, Popover, SingleSelect, MultiSelect, Select, Card, CornerDialog, ImageList, LightBox, Modal, Tabs, Alert, Avatar, AsyncSelect, Badge, BorderedBox, Button, Dropdown, ErrorMessage, Icon, Image, Label, Line, Link, Logo, Pagination, Portal, ProgressBar, SimpleLink, SpaceAround, Spinner, Tag, Toast, Toggle, Typography, Checkbox, Input, RadioButton, ThemeProvider, utils, TextArea, LoginPage, LanguageSwitch, SideMenu, Stepper, Scheduler };
49
+ export { DropdownSelect, DatePicker, CommonGrid, Popover, SingleSelect, Select, Card, CornerDialog, ImageList, LightBox, Modal, Tabs, Alert, Avatar, AsyncSelect, Badge, BorderedBox, Button, Dropdown, ErrorMessage, Icon, Image, Label, Line, Link, Logo, Pagination, Portal, ProgressBar, SimpleLink, SpaceAround, Spinner, Tag, Toast, Toggle, Typography, Checkbox, Input, RadioButton, ThemeProvider, utils, TextArea, LoginPage, LanguageSwitch, SideMenu, Stepper, Scheduler };
51
50
  export * from './Blocks/CornerDialog';
52
51
  export * from './Blocks/ImageList';
53
52
  export * from './Blocks/LightBox';
@@ -87,7 +86,6 @@ export * from './Elements/DatePicker';
87
86
  export * from './Blocks/CommonGrid';
88
87
  export * from './Blocks/Popover';
89
88
  export * from './Elements/SingleSelect';
90
- export * from './Elements/MultiSelect';
91
89
  export * from './Elements/Select';
92
90
  export * from './Elements/DropdownSelect';
93
91
  export * from './Forms/TextArea';