@mailstep/design-system 0.7.79-beta.4 → 0.7.79-beta.5
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/components/Filters/GridSelect/GridSelect.js +17 -3
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +12 -14
- package/ui/Blocks/CommonGrid/storybook/utils/utils.d.ts +1 -4
- package/ui/Blocks/CommonGrid/storybook/utils/utils.js +17 -6
- package/ui/Elements/Select/Select.js +1 -1
- package/ui/Elements/Select/components/ConnectedMenu.js +2 -2
- package/ui/Elements/Select/themes/index.js +1 -1
- package/ui/index.es.js +13968 -13302
- package/ui/index.umd.js +437 -437
package/package.json
CHANGED
|
@@ -34,15 +34,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
37
46
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
-
import { useCallback } from 'react';
|
|
47
|
+
import { useCallback, useState } from 'react';
|
|
39
48
|
import Select from '../../../../../Elements/Select';
|
|
40
49
|
import SingleSelect from '../../../../../Elements/SingleSelect';
|
|
41
50
|
import { i18n } from '@lingui/core';
|
|
42
51
|
import isArray from 'lodash/isArray';
|
|
43
52
|
import { isOptionArray } from './guards';
|
|
53
|
+
import uniqBy from 'lodash/uniqBy';
|
|
44
54
|
var SelectFilter = function (_a) {
|
|
45
55
|
var onChange = _a.onChange, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions;
|
|
56
|
+
var _b = useState([]), loadedOptions = _b[0], setLoadedOptions = _b[1];
|
|
46
57
|
var handleOnMultiChange = useCallback(function (options) {
|
|
47
58
|
onChange === null || onChange === void 0 ? void 0 : onChange(!isArray(options) || !(options === null || options === void 0 ? void 0 : options.length) ? null : options);
|
|
48
59
|
}, [onChange]);
|
|
@@ -58,12 +69,15 @@ var SelectFilter = function (_a) {
|
|
|
58
69
|
case 1:
|
|
59
70
|
data = (_a.sent()) || [];
|
|
60
71
|
_a.label = 2;
|
|
61
|
-
case 2:
|
|
72
|
+
case 2:
|
|
73
|
+
setLoadedOptions(data);
|
|
74
|
+
return [2 /*return*/, data];
|
|
62
75
|
}
|
|
63
76
|
});
|
|
64
77
|
}); }, [options]);
|
|
65
78
|
if (isMulti) {
|
|
66
|
-
|
|
79
|
+
var defaultOptions = isAsync && isOptionArray(value) ? uniqBy(__spreadArray(__spreadArray([], loadedOptions, true), value, true), 'value') : undefined;
|
|
80
|
+
return (_jsx(Select, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: isOptionArray(value) ? value.map(function (option) { return String(option.value); }) : value, options: isAsync && isOptionArray(value) ? 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 }));
|
|
67
81
|
}
|
|
68
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 }));
|
|
69
83
|
};
|
|
@@ -17,29 +17,27 @@ export var enumColumn = {
|
|
|
17
17
|
cellComponent: EnumCellExample
|
|
18
18
|
};
|
|
19
19
|
export var columnDefinitions = [
|
|
20
|
-
/*
|
|
21
20
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
name: 'hiddenColumn',
|
|
22
|
+
title: 'Hidden column',
|
|
23
|
+
flexBasis: 160,
|
|
24
|
+
filtering: true,
|
|
25
|
+
sorting: true,
|
|
26
|
+
defaultHidden: true
|
|
28
27
|
},
|
|
29
28
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
name: 'textColumn',
|
|
30
|
+
title: 'Text column',
|
|
31
|
+
flexBasis: 160,
|
|
32
|
+
filtering: true,
|
|
33
|
+
sorting: true
|
|
35
34
|
},
|
|
36
35
|
enumColumn,
|
|
37
|
-
*/
|
|
38
36
|
{
|
|
39
37
|
name: 'enumColumnAsync',
|
|
40
38
|
title: 'Enum Column Async',
|
|
41
39
|
flexBasis: 160,
|
|
42
|
-
filterExtraProps: { isMulti: true },
|
|
40
|
+
filterExtraProps: { isMulti: true, checkAllButton: true },
|
|
43
41
|
filtering: true,
|
|
44
42
|
sorting: true,
|
|
45
43
|
asyncLoadKey: 'enumColumnAsync'
|
|
@@ -18,7 +18,4 @@ export declare const gridDummyActions: Required<GridActionsType>;
|
|
|
18
18
|
export declare const createOversizedRandomData: (count: number) => any[];
|
|
19
19
|
export declare const ReduxGrid: FC<any>;
|
|
20
20
|
export declare const extraControlButtons: ExtraControlButton[];
|
|
21
|
-
export declare const onAsyncLoadFilterOptions: (key: string, value: string) => Promise<
|
|
22
|
-
label: string;
|
|
23
|
-
value: string;
|
|
24
|
-
}[]>;
|
|
21
|
+
export declare const onAsyncLoadFilterOptions: (key: string, value: string) => Promise<unknown>;
|
|
@@ -73,10 +73,21 @@ export var extraControlButtons = [
|
|
|
73
73
|
{ label: 'Export all', position: ExtraControlButtonPosition.TopRight }
|
|
74
74
|
];
|
|
75
75
|
export var onAsyncLoadFilterOptions = function (key, value) {
|
|
76
|
-
return Promise
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
return new Promise(function (resolve) {
|
|
77
|
+
setTimeout(function () {
|
|
78
|
+
resolve([
|
|
79
|
+
{ label: 'Apple', value: 'apple' },
|
|
80
|
+
{ label: 'Banana', value: 'banana' },
|
|
81
|
+
{ label: 'Cherry', value: 'cherry' },
|
|
82
|
+
{ label: 'Date', value: 'date' },
|
|
83
|
+
{ label: 'Elderberry', value: 'elderberry' },
|
|
84
|
+
{ label: 'Fig', value: 'fig' },
|
|
85
|
+
{ label: 'Grape', value: 'grape' },
|
|
86
|
+
{ label: 'Honeydew', value: 'honeydew' },
|
|
87
|
+
{ label: 'Kiwi', value: 'kiwi' },
|
|
88
|
+
{ label: 'Lemon', value: 'lemon' },
|
|
89
|
+
{ label: 'Lime', value: 'lime' },
|
|
90
|
+
]);
|
|
91
|
+
}, 1000);
|
|
92
|
+
});
|
|
82
93
|
};
|
|
@@ -71,7 +71,7 @@ var loadingMessage = function () { return i18n._({ id: 'components.dropdown.load
|
|
|
71
71
|
var Select = function (_a) {
|
|
72
72
|
var label = _a.label, name = _a.name, _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.options, options = _c === void 0 ? emptyOptions : _c, defaultOptions = _a.defaultOptions, loadOptions = _a.loadOptions, onChange = _a.onChange, onBlur = _a.onBlur, error = _a.error, isInvalid = _a.isInvalid, isLoading = _a.isLoading, isDarkPlaceholderText = _a.isDarkPlaceholderText, _d = _a.spaceAround, spaceAround = _d === void 0 ? false : _d, disabled = _a.disabled, onInputChange = _a.onInputChange, isSearchable = _a.isSearchable, isMulti = _a.isMulti, className = _a.className, _e = _a.useSimplifiedOptions, useSimplifiedOptions = _e === void 0 ? false : _e, _f = _a.showSelectAllButton, showSelectAllButton = _f === void 0 ? false : _f, _g = _a.showResetGridButton, showResetGridButton = _g === void 0 ? false : _g, _h = _a.shortValues, shortValues = _h === void 0 ? true : _h, style = _a.style, optionVariant = _a.optionVariant, multiLabelVariant = _a.multiLabelVariant, containerVariant = _a.containerVariant, placeholder = _a.placeholder, placeholderIcon = _a.placeholderIcon, innerRef = _a.innerRef, maxMenuHeight = _a.maxMenuHeight, getOptionValue = _a.getOptionValue, resetGrid = _a.resetGrid, passTroughProps = __rest(_a, ["label", "name", "value", "options", "defaultOptions", "loadOptions", "onChange", "onBlur", "error", "isInvalid", "isLoading", "isDarkPlaceholderText", "spaceAround", "disabled", "onInputChange", "isSearchable", "isMulti", "className", "useSimplifiedOptions", "showSelectAllButton", "showResetGridButton", "shortValues", "style", "optionVariant", "multiLabelVariant", "containerVariant", "placeholder", "placeholderIcon", "innerRef", "maxMenuHeight", "getOptionValue", "resetGrid"]);
|
|
73
73
|
var isAsync = !!loadOptions;
|
|
74
|
-
if (showSelectAllButton &&
|
|
74
|
+
if (showSelectAllButton && !isMulti) {
|
|
75
75
|
console.error('CheckboxSelect incompatible props');
|
|
76
76
|
}
|
|
77
77
|
var setAllOptions = useCallback(function () {
|
|
@@ -15,7 +15,7 @@ import SelectAll from '../components/SelectAll';
|
|
|
15
15
|
import ResetAll from '../components/ResetAll';
|
|
16
16
|
var ConnectedMenu = function (props) {
|
|
17
17
|
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;
|
|
19
|
-
return (_jsxs(selectComponents.MenuList, __assign({}, props, { children: [selectAllButton && (_jsx(SelectAll, { theme: theme, onCustomSelectAll: onCustomSelectAll, onCustomDeselectAll: onCustomDeselectAll, value: value, options: options, maxMenuHeight: maxMenuHeight })), props.children, resetGridButton && _jsx(ResetAll, { onReset: resetGrid })] })));
|
|
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 })] })));
|
|
20
20
|
};
|
|
21
21
|
export default ConnectedMenu;
|
|
@@ -21,6 +21,7 @@ export var useStylesAndComponents = function (style, optionVariant, multiLabelVa
|
|
|
21
21
|
var components = {
|
|
22
22
|
ValueContainer: IconValueContainer
|
|
23
23
|
};
|
|
24
|
+
components.DropdownIndicator = DropdownIndicator;
|
|
24
25
|
if (multiLabelVariant === 'count') {
|
|
25
26
|
components.MultiValue = CountMultiValue;
|
|
26
27
|
}
|
|
@@ -34,7 +35,6 @@ export var useStylesAndComponents = function (style, optionVariant, multiLabelVa
|
|
|
34
35
|
var themes = getFormCustomTheme(systemTheme, optionVariant, style == 'gridFilter');
|
|
35
36
|
var styles = SelectCustomStyles;
|
|
36
37
|
components.Option = ChevronOption;
|
|
37
|
-
components.DropdownIndicator = DropdownIndicator;
|
|
38
38
|
// performance reasons
|
|
39
39
|
if (useSimplifiedOptions)
|
|
40
40
|
components.Option = SimplifiedOption;
|