@mailstep/design-system 0.7.79-beta.2 → 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.2",
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';
38
+ import { useCallback } from 'react';
39
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,14 +58,13 @@ 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(Select, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: value || emptyValue, options: isAsync ? asyncOptions : 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 }));
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
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
  };
@@ -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
+ };
@@ -39,7 +39,7 @@ export var columnDefinitions = [
39
39
  name: 'enumColumnAsync',
40
40
  title: 'Enum Column Async',
41
41
  flexBasis: 160,
42
- filterExtraProps: { isMulti: false },
42
+ filterExtraProps: { isMulti: true },
43
43
  filtering: true,
44
44
  sorting: true,
45
45
  asyncLoadKey: 'enumColumnAsync'