@mailstep/design-system 0.8.8 → 0.8.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.8.8",
3
+ "version": "0.8.9",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -35,6 +35,6 @@ var ColumnFilterCell = function (_a) {
35
35
  console.error("ERROR, using unknown filter type ".concat(filterType));
36
36
  return (_jsx(x.div, { children: _jsx("span", { children: "".concat(filterType, " filter") }) }));
37
37
  }
38
- return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ asyncLoadKey: columnDefinition.asyncLoadKey, "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
38
+ return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ asyncLoadKey: columnDefinition.asyncLoadKey, "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }), { columnWidth: cellSizeProps === null || cellSizeProps === void 0 ? void 0 : cellSizeProps.flexBasis })) }) })));
39
39
  };
40
40
  export default ColumnFilterCell;
@@ -11,7 +11,11 @@ type Props = {
11
11
  checkAllButton?: boolean;
12
12
  asyncLoadKey?: string;
13
13
  isClearable?: boolean;
14
- withNotEqComparator?: boolean;
14
+ onlyInComparator?: boolean;
15
+ disabled?: boolean;
16
+ placeholder?: string;
17
+ showValue?: boolean;
18
+ columnWidth?: number;
15
19
  };
16
20
  declare const SelectFilter: FC<Props>;
17
21
  export default SelectFilter;
@@ -62,10 +62,11 @@ import { i18n } from '@lingui/core';
62
62
  import isArray from 'lodash/isArray';
63
63
  import uniqBy from 'lodash/uniqBy';
64
64
  import { isOptionArray } from './guards';
65
+ var minColumnWidth = 120;
65
66
  var SelectFilter = function (_a) {
66
- var onChange = _a.onChange, _b = _a.isClearable, isClearable = _b === void 0 ? true : _b, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions, _c = _a.withNotEqComparator, withNotEqComparator = _c === void 0 ? true : _c;
67
- var _d = useState([]), loadedOptions = _d[0], setLoadedOptions = _d[1];
68
- var _e = useState(false), isNotEqNoValue = _e[0], setIsNotEqNoValue = _e[1];
67
+ var onChange = _a.onChange, _b = _a.isClearable, isClearable = _b === void 0 ? true : _b, disabled = _a.disabled, placeholder = _a.placeholder, _c = _a.showValue, showValue = _c === void 0 ? true : _c, columnWidth = _a.columnWidth, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions, _d = _a.onlyInComparator, onlyInComparator = _d === void 0 ? false : _d;
68
+ var _e = useState([]), loadedOptions = _e[0], setLoadedOptions = _e[1];
69
+ var _f = useState(false), isNotEqNoValue = _f[0], setIsNotEqNoValue = _f[1];
69
70
  var isAsync = !!asyncLoadKey;
70
71
  var isNotEq = useMemo(function () { return (isOptionArray(value) ? value.some(function (option) { return option.isNotEq; }) : isNotEqNoValue); }, [value, isNotEqNoValue]);
71
72
  var handleOnMultiChange = useCallback(function (options) {
@@ -99,9 +100,14 @@ var SelectFilter = function (_a) {
99
100
  onChange(newOptions);
100
101
  }, [value, isNotEq, onChange]);
101
102
  var defaultOptions = useMemo(function () { return (isMulti && isAsync && isOptionArray(value) ? uniqBy(__spreadArray(__spreadArray([], loadedOptions, true), value, true), 'value') : undefined); }, [isAsync, value, loadedOptions]);
103
+ var isWide = columnWidth && columnWidth > minColumnWidth;
104
+ var isSelectClearable = isWide ? isClearable : false;
105
+ var placeholderValue = placeholder || (isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined);
102
106
  if (isMulti) {
103
- 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, placeholderIcon: isNotEq ? 'notEqual' : 'equals', onIconClick: withNotEqComparator ? handleIconClick : undefined, optionVariant: "checkbox", multiLabelVariant: "count", isMulti: true }));
107
+ var placeholderIcon = isWide ? (isNotEq ? 'notEqual' : 'equals') : null;
108
+ var selectValue = showValue ? (isOptionArray(value) ? value.map(function (option) { return String(option.value); }) : value) : undefined;
109
+ return (_jsx(Select, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: selectValue, options: defaultOptions || options, showSelectAllButton: checkAllButton, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, defaultOptions: defaultOptions, placeholder: placeholderValue, noOptionsMessage: function () { return null; }, containerVariant: isAsync ? 'search' : undefined, placeholderIcon: placeholderIcon, onIconClick: !onlyInComparator ? handleIconClick : undefined, optionVariant: "checkbox", multiLabelVariant: "count", isMulti: true, disabled: disabled, isClearable: isSelectClearable }));
104
110
  }
105
- 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: isClearable }));
111
+ return (_jsx(SingleSelect, { maxMenuHeight: 250, onChange: onChange, value: showValue ? value : undefined, options: options, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: placeholderValue, placeholderIcon: isWide ? undefined : null, isClearable: isSelectClearable, disabled: disabled }));
106
112
  };
107
113
  export default SelectFilter;
@@ -106,6 +106,9 @@ export type ColumnDefinition<ColumnName extends string = string> = ColumnBasePro
106
106
  disableRowTouch?: boolean;
107
107
  filterExtraProps?: {
108
108
  isMulti?: boolean;
109
+ disabled?: boolean;
110
+ placeholder?: string;
111
+ showValue?: boolean;
109
112
  comparators?: Comparator[];
110
113
  filterTime?: boolean;
111
114
  decimals?: number;
@@ -114,7 +117,7 @@ export type ColumnDefinition<ColumnName extends string = string> = ColumnBasePro
114
117
  isUuid?: boolean;
115
118
  defaultComparator?: string;
116
119
  checkAllButton?: boolean;
117
- withNotEqComparator?: boolean;
120
+ onlyInComparator?: boolean;
118
121
  };
119
122
  getFilterCriteria?: (value: string) => Record<string, any> | null;
120
123
  filterOptions?: Option[];
@@ -1,6 +1,12 @@
1
1
  import { ColumnDefinition, ColumnConfig, FilterProps, Group, StickTo, FiltersConfig } from '../types';
2
2
 
3
- export declare const getCellSizeProps: (column: ColumnDefinition, columnWidth: number) => object;
3
+ type CellSizePropsResult = {
4
+ flexBasis?: number;
5
+ flexGrow?: number;
6
+ flexShrink?: number;
7
+ maxWidth?: string | number;
8
+ };
9
+ export declare const getCellSizeProps: (column: ColumnDefinition, columnWidth: number) => CellSizePropsResult;
4
10
  export declare const getSortName: (column: ColumnDefinition) => string;
5
11
  export declare const getFilterName: (column: ColumnDefinition) => string;
6
12
  export declare const isColumnOn: (column: ColumnDefinition, columnConfig?: ColumnConfig) => boolean;
@@ -14,3 +20,4 @@ export declare const getGroupClassNames: (group?: Group) => string;
14
20
  export declare const getStickyCollClassNames: (sticky: boolean, stickTo?: StickTo) => string;
15
21
  export declare const getFilters: (optimizeFilters: boolean) => FiltersConfig;
16
22
  export declare const checksColumnsOrder: (colsOrder: string[], columnsDefinitions: ColumnDefinition[]) => void;
23
+ export {};
@@ -83,7 +83,7 @@ var Select = function (_a) {
83
83
  onChange === null || onChange === void 0 ? void 0 : onChange(emptyOptions);
84
84
  }
85
85
  }, [onChange]);
86
- var icon = containerVariant === 'search' && !placeholderIcon ? 'search' : placeholderIcon || undefined;
86
+ var icon = containerVariant === 'search' && !placeholderIcon && placeholderIcon !== null ? 'search' : placeholderIcon || undefined;
87
87
  var modifiedMaxMenuHeight = showResetGridButton && showSelectAllButton && maxMenuHeight ? maxMenuHeight - 30 : maxMenuHeight;
88
88
  var _j = useStylesAndComponents(style, optionVariant, multiLabelVariant, containerVariant, useSimplifiedOptions, showSelectAllButton, showResetGridButton), customComponents = _j[0], customTheme = _j[1], customStyles = _j[2];
89
89
  var RenderComponent = isAsync ? StyledAsyncSelect : StyledReactSelect;
@@ -47,7 +47,7 @@ export type SelectProps = {
47
47
  optionVariant?: 'default' | 'checkbox' | 'toggle';
48
48
  multiLabelVariant?: 'default' | 'count';
49
49
  containerVariant?: 'default' | 'search';
50
- placeholderIcon?: string;
50
+ placeholderIcon?: string | null;
51
51
  innerRef?: RefObject<HTMLElement>;
52
52
  className?: string;
53
53
  maxMenuHeight?: number;