@zohodesk/components 1.0.0-temp-139 → 1.0.0-temp-140
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/README.md +9 -3
- package/es/ListItem/ListItem.module.css +13 -11
- package/es/MultiSelect/MultiSelect.js +18 -5
- package/es/MultiSelect/MultiSelectWithAvatar.js +18 -5
- package/es/MultiSelect/props/defaultProps.js +5 -2
- package/es/MultiSelect/props/propTypes.js +7 -1
- package/es/utils/dropDownUtils.js +3 -2
- package/lib/ListItem/ListItem.module.css +13 -11
- package/lib/MultiSelect/MultiSelect.js +18 -5
- package/lib/MultiSelect/MultiSelectWithAvatar.js +18 -5
- package/lib/MultiSelect/props/defaultProps.js +5 -2
- package/lib/MultiSelect/props/propTypes.js +7 -1
- package/lib/utils/dropDownUtils.js +5 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,13 +34,19 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
34
34
|
|
|
35
35
|
# 1.0.0-alpha-262
|
|
36
36
|
|
|
37
|
-
- **
|
|
37
|
+
- **ListItem, ListItemWithAvatar, ListItemWithCheckbox, ListItemWithIcon, ListItemWithRadio** - Added New Prop `needMultiLineText`
|
|
38
|
+
|
|
39
|
+
- **MultiSelect, MultiSelectWithAvatar** - `keepSelectedOptions` prop added. When this prop is true, it won't remove selected items from the dropdown instead it highlights each selected item with tick mark.
|
|
40
|
+
|
|
41
|
+
- **MultiSelectWithAvatar** - `customProps` support.
|
|
38
42
|
|
|
39
43
|
# 1.0.0-alpha-261
|
|
40
44
|
|
|
41
45
|
- **Tab,Tabs** - Removed offsection property from css.
|
|
42
|
-
|
|
43
|
-
-
|
|
46
|
+
|
|
47
|
+
- compileClassNames , mergeStyle utils added.
|
|
48
|
+
|
|
49
|
+
- index export object fixed.
|
|
44
50
|
|
|
45
51
|
# 1.0.0-alpha-260
|
|
46
52
|
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
--listitem_border_color: var(--zdt_listitem_active_border);
|
|
49
49
|
}
|
|
50
50
|
[dir=ltr] .small {
|
|
51
|
-
--listitem_padding: var(--
|
|
51
|
+
--listitem_padding: var(--zd_size7) var(--zd_size3) var(--zd_size7)
|
|
52
52
|
var(--zd_size5)
|
|
53
|
-
/*rtl: var(--
|
|
53
|
+
/*rtl: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size3)*/;
|
|
54
54
|
}
|
|
55
55
|
[dir=rtl] .small {
|
|
56
|
-
--listitem_padding: var(--
|
|
56
|
+
--listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size3);
|
|
57
57
|
}
|
|
58
58
|
.medium {
|
|
59
|
-
--listitem_padding: var(--
|
|
59
|
+
--listitem_padding: var(--zd_size7) var(--zd_size20);
|
|
60
60
|
--listitem_min_height: var(--zd_size35);
|
|
61
61
|
}
|
|
62
62
|
.large {
|
|
@@ -74,9 +74,11 @@
|
|
|
74
74
|
.children {
|
|
75
75
|
composes: dotted from '../common/common.module.css';
|
|
76
76
|
}
|
|
77
|
+
.value, .multiLineValue {
|
|
78
|
+
line-height: var(--zd_size20);
|
|
79
|
+
}
|
|
77
80
|
.multiLineValue{
|
|
78
81
|
word-break: break-word;
|
|
79
|
-
line-height: var(--zd_size18);
|
|
80
82
|
composes: clamp from '../common/common.module.css'
|
|
81
83
|
}
|
|
82
84
|
.iconBox {
|
|
@@ -183,20 +185,20 @@
|
|
|
183
185
|
display: block;
|
|
184
186
|
}
|
|
185
187
|
[dir=ltr] .smallwithTick {
|
|
186
|
-
--listitem_padding: var(--
|
|
188
|
+
--listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7)
|
|
187
189
|
var(--zd_size5)
|
|
188
|
-
/*rtl: var(--
|
|
190
|
+
/*rtl: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size39)*/;
|
|
189
191
|
}
|
|
190
192
|
[dir=rtl] .smallwithTick {
|
|
191
|
-
--listitem_padding: var(--
|
|
193
|
+
--listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size39);
|
|
192
194
|
}
|
|
193
195
|
[dir=ltr] .mediumwithTick {
|
|
194
|
-
--listitem_padding: var(--
|
|
196
|
+
--listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7)
|
|
195
197
|
var(--zd_size20)
|
|
196
|
-
/*rtl: var(--
|
|
198
|
+
/*rtl: var(--zd_size7) var(--zd_size20) var(--zd_size7) var(--zd_size39)*/;
|
|
197
199
|
}
|
|
198
200
|
[dir=rtl] .mediumwithTick {
|
|
199
|
-
--listitem_padding: var(--
|
|
201
|
+
--listitem_padding: var(--zd_size7) var(--zd_size20) var(--zd_size7) var(--zd_size39);
|
|
200
202
|
}
|
|
201
203
|
[dir=ltr] .largewithTick {
|
|
202
204
|
--listitem_padding: var(--zd_size10) var(--zd_size39) var(--zd_size10)
|
|
@@ -249,7 +249,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
249
249
|
} = this.state;
|
|
250
250
|
const {
|
|
251
251
|
selectedOptions,
|
|
252
|
-
needLocalSearch
|
|
252
|
+
needLocalSearch,
|
|
253
|
+
keepSelectedOptions
|
|
253
254
|
} = this.props;
|
|
254
255
|
const {
|
|
255
256
|
suggestions,
|
|
@@ -258,7 +259,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
258
259
|
options,
|
|
259
260
|
selectedOptions,
|
|
260
261
|
searchStr: getSearchString(searchStr),
|
|
261
|
-
needSearch: needLocalSearch
|
|
262
|
+
needSearch: needLocalSearch,
|
|
263
|
+
keepSelectedOptions
|
|
262
264
|
});
|
|
263
265
|
this.suggestionsOrder = suggestionIds;
|
|
264
266
|
return suggestions;
|
|
@@ -450,7 +452,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
450
452
|
handleSelectOption(option, value, index, e) {
|
|
451
453
|
const {
|
|
452
454
|
selectedOptions,
|
|
453
|
-
isSearchClearOnSelect
|
|
455
|
+
isSearchClearOnSelect,
|
|
456
|
+
keepSelectedOptions
|
|
454
457
|
} = this.props;
|
|
455
458
|
const {
|
|
456
459
|
searchStr
|
|
@@ -458,7 +461,15 @@ export class MultiSelectComponent extends React.Component {
|
|
|
458
461
|
if (searchStr.trim() != '' && isSearchClearOnSelect) {
|
|
459
462
|
this.handleSearch('');
|
|
460
463
|
}
|
|
461
|
-
|
|
464
|
+
if (keepSelectedOptions && selectedOptions.indexOf(option) != -1) {
|
|
465
|
+
let newSelectedOptions = selectedOptions.filter(id => {
|
|
466
|
+
return id != option;
|
|
467
|
+
});
|
|
468
|
+
this.handleChange(newSelectedOptions, e);
|
|
469
|
+
} else {
|
|
470
|
+
this.handleChange([...selectedOptions, option], e);
|
|
471
|
+
}
|
|
472
|
+
|
|
462
473
|
// e && e.stopPropagation && this.handlePopupClose(e);
|
|
463
474
|
}
|
|
464
475
|
|
|
@@ -841,7 +852,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
841
852
|
highLightedSelectOptions,
|
|
842
853
|
options,
|
|
843
854
|
isFetchingOptions,
|
|
844
|
-
isActive
|
|
855
|
+
isActive,
|
|
856
|
+
selectedOptionIds
|
|
845
857
|
} = this.state;
|
|
846
858
|
const suggestions = this.handleFilterSuggestions();
|
|
847
859
|
const setAriaId = this.getNextAriaId();
|
|
@@ -985,6 +997,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
985
997
|
needBorder: false,
|
|
986
998
|
dataId: `${dataId}_Options`,
|
|
987
999
|
palette: palette,
|
|
1000
|
+
selectedOptions: selectedOptionIds,
|
|
988
1001
|
a11y: {
|
|
989
1002
|
role: 'option'
|
|
990
1003
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
2
|
/**** Libraries ****/
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { MultiSelectWithAvatar_propTypes } from './props/propTypes';
|
|
@@ -99,8 +100,14 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
99
100
|
customChildrenClass,
|
|
100
101
|
isBoxPaddingNeed,
|
|
101
102
|
needEffect,
|
|
102
|
-
isLoading
|
|
103
|
+
isLoading,
|
|
104
|
+
keepSelectedOptions,
|
|
105
|
+
customProps
|
|
103
106
|
} = this.props;
|
|
107
|
+
let {
|
|
108
|
+
TextBoxProps = {},
|
|
109
|
+
SuggestionsProps = {}
|
|
110
|
+
} = customProps;
|
|
104
111
|
const {
|
|
105
112
|
clearText = 'Clear all'
|
|
106
113
|
} = i18nKeys;
|
|
@@ -119,7 +126,8 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
119
126
|
highLightedSelectOptions,
|
|
120
127
|
options,
|
|
121
128
|
isFetchingOptions,
|
|
122
|
-
isActive
|
|
129
|
+
isActive,
|
|
130
|
+
selectedOptionIds
|
|
123
131
|
} = this.state;
|
|
124
132
|
const suggestions = this.handleFilterSuggestions();
|
|
125
133
|
const setAriaId = this.getNextAriaId();
|
|
@@ -183,7 +191,10 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
183
191
|
customClass: {
|
|
184
192
|
customTBoxWrap: style.custmInputWrapper
|
|
185
193
|
},
|
|
186
|
-
autoComplete: false
|
|
194
|
+
autoComplete: false,
|
|
195
|
+
customProps: {
|
|
196
|
+
TextBoxProps: TextBoxProps
|
|
197
|
+
}
|
|
187
198
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
188
199
|
isCover: false,
|
|
189
200
|
alignBox: "row",
|
|
@@ -245,7 +256,8 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
245
256
|
shrink: true,
|
|
246
257
|
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
247
258
|
eleRef: this.suggestionContainerRef
|
|
248
|
-
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
259
|
+
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, _extends({
|
|
260
|
+
needTick: keepSelectedOptions,
|
|
249
261
|
suggestions: suggestions,
|
|
250
262
|
getRef: this.suggestionItemRef,
|
|
251
263
|
hoverOption: hoverOption,
|
|
@@ -254,10 +266,11 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
254
266
|
needBorder: false,
|
|
255
267
|
dataId: `${dataId}_Options`,
|
|
256
268
|
palette: palette,
|
|
269
|
+
selectedOptions: selectedOptionIds,
|
|
257
270
|
a11y: {
|
|
258
271
|
role: 'option'
|
|
259
272
|
}
|
|
260
|
-
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
273
|
+
}, SuggestionsProps)) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
261
274
|
isLoading: isFetchingOptions,
|
|
262
275
|
options: options,
|
|
263
276
|
searchString: searchStr,
|
|
@@ -106,7 +106,8 @@ export const MultiSelect_defaultProps = {
|
|
|
106
106
|
needEffect: true,
|
|
107
107
|
boxSize: 'default',
|
|
108
108
|
isLoading: false,
|
|
109
|
-
dataSelectorId: 'multiSelect'
|
|
109
|
+
dataSelectorId: 'multiSelect',
|
|
110
|
+
keepSelectedOptions: false
|
|
110
111
|
};
|
|
111
112
|
export const MultiSelectHeader_defaultProps = {
|
|
112
113
|
dataId: 'MultiSelectHeader'
|
|
@@ -138,7 +139,9 @@ export const MultiSelectWithAvatar_defaultProps = {
|
|
|
138
139
|
isSearchClearOnSelect: true,
|
|
139
140
|
needEffect: true,
|
|
140
141
|
isLoading: false,
|
|
141
|
-
dataSelectorId: 'multiSelectWithAvatar'
|
|
142
|
+
dataSelectorId: 'multiSelectWithAvatar',
|
|
143
|
+
keepSelectedOptions: false,
|
|
144
|
+
customProps: {}
|
|
142
145
|
};
|
|
143
146
|
export const SelectedOptions_defaultProps = {
|
|
144
147
|
size: 'medium'
|
|
@@ -239,7 +239,8 @@ export const MultiSelect_propTypes = {
|
|
|
239
239
|
needEffect: PropTypes.bool,
|
|
240
240
|
boxSize: PropTypes.string,
|
|
241
241
|
isLoading: PropTypes.bool,
|
|
242
|
-
dataSelectorId: PropTypes.string
|
|
242
|
+
dataSelectorId: PropTypes.string,
|
|
243
|
+
keepSelectedOptions: PropTypes.bool
|
|
243
244
|
};
|
|
244
245
|
export const MultiSelectHeader_propTypes = {
|
|
245
246
|
dataId: PropTypes.string,
|
|
@@ -294,6 +295,11 @@ export const MultiSelectWithAvatar_propTypes = {
|
|
|
294
295
|
htmlId: PropTypes.string,
|
|
295
296
|
isBoxPaddingNeed: PropTypes.bool,
|
|
296
297
|
needEffect: PropTypes.bool,
|
|
298
|
+
keepSelectedOptions: PropTypes.bool,
|
|
299
|
+
customProps: PropTypes.shape({
|
|
300
|
+
SuggestionsProps: PropTypes.object,
|
|
301
|
+
DropBoxProps: PropTypes.object
|
|
302
|
+
}),
|
|
297
303
|
/**** Popup props ****/
|
|
298
304
|
isPopupOpen: PropTypes.bool,
|
|
299
305
|
isPopupReady: PropTypes.bool,
|
|
@@ -21,9 +21,10 @@ const getSelectedValue = props => getIsEmptyValue(props.selectedValue) ? '' : pr
|
|
|
21
21
|
const getSelectedFormatOptions = props => props.selectedFormatOptions || dummyObj;
|
|
22
22
|
export const getPrefixText = props => props.prefixText || '';
|
|
23
23
|
const getIsStartWithSearch = props => props.isStartsWithSearch;
|
|
24
|
+
const getKeepSelectedOptions = props => props.keepSelectedOptions;
|
|
24
25
|
const getDisabledOptions = props => props.disabledOptions || dummyArray;
|
|
25
26
|
const getListItemProps = props => props.listItemProps || '';
|
|
26
|
-
export const makeGetMultiSelectFilterSuggestions = () => createSelector([getOptions, getSelectedOptionsSel, getSearchStr, getNeedSearch, getIsStartWithSearch], (options, selectedOptions, searchStr, needSearch, isStartsWithSearch) => {
|
|
27
|
+
export const makeGetMultiSelectFilterSuggestions = () => createSelector([getOptions, getSelectedOptionsSel, getSearchStr, getNeedSearch, getIsStartWithSearch, getKeepSelectedOptions], (options, selectedOptions, searchStr, needSearch, isStartsWithSearch, keepSelectedOptions) => {
|
|
27
28
|
const suggestions = [];
|
|
28
29
|
const suggestionIds = [];
|
|
29
30
|
options.forEach(option => {
|
|
@@ -34,7 +35,7 @@ export const makeGetMultiSelectFilterSuggestions = () => createSelector([getOpti
|
|
|
34
35
|
const valueString = getSearchString(value);
|
|
35
36
|
const searchString = getSearchString(searchStr);
|
|
36
37
|
const isMatch = needSearch ? isStartsWithSearch ? valueString.startsWith(searchString) : valueString.indexOf(searchString) !== -1 : true;
|
|
37
|
-
if (selectedOptions.indexOf(id) === -1 && isMatch) {
|
|
38
|
+
if (selectedOptions.indexOf(id) === -1 && isMatch || keepSelectedOptions) {
|
|
38
39
|
suggestions.push(option);
|
|
39
40
|
suggestionIds.push(id);
|
|
40
41
|
}
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
--listitem_border_color: var(--zdt_listitem_active_border);
|
|
49
49
|
}
|
|
50
50
|
[dir=ltr] .small {
|
|
51
|
-
--listitem_padding: var(--
|
|
51
|
+
--listitem_padding: var(--zd_size7) var(--zd_size3) var(--zd_size7)
|
|
52
52
|
var(--zd_size5)
|
|
53
|
-
/*rtl: var(--
|
|
53
|
+
/*rtl: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size3)*/;
|
|
54
54
|
}
|
|
55
55
|
[dir=rtl] .small {
|
|
56
|
-
--listitem_padding: var(--
|
|
56
|
+
--listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size3);
|
|
57
57
|
}
|
|
58
58
|
.medium {
|
|
59
|
-
--listitem_padding: var(--
|
|
59
|
+
--listitem_padding: var(--zd_size7) var(--zd_size20);
|
|
60
60
|
--listitem_min_height: var(--zd_size35);
|
|
61
61
|
}
|
|
62
62
|
.large {
|
|
@@ -74,9 +74,11 @@
|
|
|
74
74
|
.children {
|
|
75
75
|
composes: dotted from '../common/common.module.css';
|
|
76
76
|
}
|
|
77
|
+
.value, .multiLineValue {
|
|
78
|
+
line-height: var(--zd_size20);
|
|
79
|
+
}
|
|
77
80
|
.multiLineValue{
|
|
78
81
|
word-break: break-word;
|
|
79
|
-
line-height: var(--zd_size18);
|
|
80
82
|
composes: clamp from '../common/common.module.css'
|
|
81
83
|
}
|
|
82
84
|
.iconBox {
|
|
@@ -183,20 +185,20 @@
|
|
|
183
185
|
display: block;
|
|
184
186
|
}
|
|
185
187
|
[dir=ltr] .smallwithTick {
|
|
186
|
-
--listitem_padding: var(--
|
|
188
|
+
--listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7)
|
|
187
189
|
var(--zd_size5)
|
|
188
|
-
/*rtl: var(--
|
|
190
|
+
/*rtl: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size39)*/;
|
|
189
191
|
}
|
|
190
192
|
[dir=rtl] .smallwithTick {
|
|
191
|
-
--listitem_padding: var(--
|
|
193
|
+
--listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size39);
|
|
192
194
|
}
|
|
193
195
|
[dir=ltr] .mediumwithTick {
|
|
194
|
-
--listitem_padding: var(--
|
|
196
|
+
--listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7)
|
|
195
197
|
var(--zd_size20)
|
|
196
|
-
/*rtl: var(--
|
|
198
|
+
/*rtl: var(--zd_size7) var(--zd_size20) var(--zd_size7) var(--zd_size39)*/;
|
|
197
199
|
}
|
|
198
200
|
[dir=rtl] .mediumwithTick {
|
|
199
|
-
--listitem_padding: var(--
|
|
201
|
+
--listitem_padding: var(--zd_size7) var(--zd_size20) var(--zd_size7) var(--zd_size39);
|
|
200
202
|
}
|
|
201
203
|
[dir=ltr] .largewithTick {
|
|
202
204
|
--listitem_padding: var(--zd_size10) var(--zd_size39) var(--zd_size10)
|
|
@@ -276,12 +276,14 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
276
276
|
searchStr = _this$state3$searchSt === void 0 ? '' : _this$state3$searchSt;
|
|
277
277
|
var _this$props4 = this.props,
|
|
278
278
|
selectedOptions = _this$props4.selectedOptions,
|
|
279
|
-
needLocalSearch = _this$props4.needLocalSearch
|
|
279
|
+
needLocalSearch = _this$props4.needLocalSearch,
|
|
280
|
+
keepSelectedOptions = _this$props4.keepSelectedOptions;
|
|
280
281
|
var _this$getFilterSugges = this.getFilterSuggestions({
|
|
281
282
|
options: options,
|
|
282
283
|
selectedOptions: selectedOptions,
|
|
283
284
|
searchStr: (0, _Common.getSearchString)(searchStr),
|
|
284
|
-
needSearch: needLocalSearch
|
|
285
|
+
needSearch: needLocalSearch,
|
|
286
|
+
keepSelectedOptions: keepSelectedOptions
|
|
285
287
|
}),
|
|
286
288
|
suggestions = _this$getFilterSugges.suggestions,
|
|
287
289
|
suggestionIds = _this$getFilterSugges.suggestionIds;
|
|
@@ -476,12 +478,21 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
476
478
|
value: function handleSelectOption(option, value, index, e) {
|
|
477
479
|
var _this$props6 = this.props,
|
|
478
480
|
selectedOptions = _this$props6.selectedOptions,
|
|
479
|
-
isSearchClearOnSelect = _this$props6.isSearchClearOnSelect
|
|
481
|
+
isSearchClearOnSelect = _this$props6.isSearchClearOnSelect,
|
|
482
|
+
keepSelectedOptions = _this$props6.keepSelectedOptions;
|
|
480
483
|
var searchStr = this.state.searchStr;
|
|
481
484
|
if (searchStr.trim() != '' && isSearchClearOnSelect) {
|
|
482
485
|
this.handleSearch('');
|
|
483
486
|
}
|
|
484
|
-
|
|
487
|
+
if (keepSelectedOptions && selectedOptions.indexOf(option) != -1) {
|
|
488
|
+
var newSelectedOptions = selectedOptions.filter(function (id) {
|
|
489
|
+
return id != option;
|
|
490
|
+
});
|
|
491
|
+
this.handleChange(newSelectedOptions, e);
|
|
492
|
+
} else {
|
|
493
|
+
this.handleChange([].concat(_toConsumableArray(selectedOptions), [option]), e);
|
|
494
|
+
}
|
|
495
|
+
|
|
485
496
|
// e && e.stopPropagation && this.handlePopupClose(e);
|
|
486
497
|
}
|
|
487
498
|
}, {
|
|
@@ -873,7 +884,8 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
873
884
|
highLightedSelectOptions = _this$state8.highLightedSelectOptions,
|
|
874
885
|
options = _this$state8.options,
|
|
875
886
|
isFetchingOptions = _this$state8.isFetchingOptions,
|
|
876
|
-
isActive = _this$state8.isActive
|
|
887
|
+
isActive = _this$state8.isActive,
|
|
888
|
+
selectedOptionIds = _this$state8.selectedOptionIds;
|
|
877
889
|
var suggestions = this.handleFilterSuggestions();
|
|
878
890
|
var setAriaId = this.getNextAriaId();
|
|
879
891
|
var ariaErrorId = this.getNextAriaId();
|
|
@@ -1012,6 +1024,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1012
1024
|
needBorder: false,
|
|
1013
1025
|
dataId: "".concat(dataId, "_Options"),
|
|
1014
1026
|
palette: palette,
|
|
1027
|
+
selectedOptions: selectedOptionIds,
|
|
1015
1028
|
a11y: {
|
|
1016
1029
|
role: 'option'
|
|
1017
1030
|
}
|
|
@@ -27,6 +27,7 @@ var _MultiSelectModule = _interopRequireDefault(require("./MultiSelect.module.cs
|
|
|
27
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
30
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
30
31
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
32
33
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -121,7 +122,13 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
121
122
|
customChildrenClass = _this$props.customChildrenClass,
|
|
122
123
|
isBoxPaddingNeed = _this$props.isBoxPaddingNeed,
|
|
123
124
|
needEffect = _this$props.needEffect,
|
|
124
|
-
isLoading = _this$props.isLoading
|
|
125
|
+
isLoading = _this$props.isLoading,
|
|
126
|
+
keepSelectedOptions = _this$props.keepSelectedOptions,
|
|
127
|
+
customProps = _this$props.customProps;
|
|
128
|
+
var _customProps$TextBoxP = customProps.TextBoxProps,
|
|
129
|
+
TextBoxProps = _customProps$TextBoxP === void 0 ? {} : _customProps$TextBoxP,
|
|
130
|
+
_customProps$Suggesti = customProps.SuggestionsProps,
|
|
131
|
+
SuggestionsProps = _customProps$Suggesti === void 0 ? {} : _customProps$Suggesti;
|
|
125
132
|
var _i18nKeys = i18nKeys,
|
|
126
133
|
_i18nKeys$clearText = _i18nKeys.clearText,
|
|
127
134
|
clearText = _i18nKeys$clearText === void 0 ? 'Clear all' : _i18nKeys$clearText;
|
|
@@ -139,7 +146,8 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
139
146
|
highLightedSelectOptions = _this$state.highLightedSelectOptions,
|
|
140
147
|
options = _this$state.options,
|
|
141
148
|
isFetchingOptions = _this$state.isFetchingOptions,
|
|
142
|
-
isActive = _this$state.isActive
|
|
149
|
+
isActive = _this$state.isActive,
|
|
150
|
+
selectedOptionIds = _this$state.selectedOptionIds;
|
|
143
151
|
var suggestions = this.handleFilterSuggestions();
|
|
144
152
|
var setAriaId = this.getNextAriaId();
|
|
145
153
|
var ariaErrorId = this.getNextAriaId();
|
|
@@ -201,7 +209,10 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
201
209
|
customClass: {
|
|
202
210
|
customTBoxWrap: _MultiSelectModule["default"].custmInputWrapper
|
|
203
211
|
},
|
|
204
|
-
autoComplete: false
|
|
212
|
+
autoComplete: false,
|
|
213
|
+
customProps: {
|
|
214
|
+
TextBoxProps: TextBoxProps
|
|
215
|
+
}
|
|
205
216
|
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
206
217
|
isCover: false,
|
|
207
218
|
alignBox: "row",
|
|
@@ -261,7 +272,8 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
261
272
|
shrink: true,
|
|
262
273
|
customClass: !tabletMode && dropBoxSize ? _MultiSelectModule["default"][dropBoxSize] : '',
|
|
263
274
|
eleRef: _this2.suggestionContainerRef
|
|
264
|
-
}, suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
275
|
+
}, suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], _extends({
|
|
276
|
+
needTick: keepSelectedOptions,
|
|
265
277
|
suggestions: suggestions,
|
|
266
278
|
getRef: _this2.suggestionItemRef,
|
|
267
279
|
hoverOption: hoverOption,
|
|
@@ -270,10 +282,11 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
270
282
|
needBorder: false,
|
|
271
283
|
dataId: "".concat(dataId, "_Options"),
|
|
272
284
|
palette: palette,
|
|
285
|
+
selectedOptions: selectedOptionIds,
|
|
273
286
|
a11y: {
|
|
274
287
|
role: 'option'
|
|
275
288
|
}
|
|
276
|
-
}) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
|
|
289
|
+
}, SuggestionsProps)) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
|
|
277
290
|
isLoading: isFetchingOptions,
|
|
278
291
|
options: options,
|
|
279
292
|
searchString: searchStr,
|
|
@@ -115,7 +115,8 @@ var MultiSelect_defaultProps = {
|
|
|
115
115
|
needEffect: true,
|
|
116
116
|
boxSize: 'default',
|
|
117
117
|
isLoading: false,
|
|
118
|
-
dataSelectorId: 'multiSelect'
|
|
118
|
+
dataSelectorId: 'multiSelect',
|
|
119
|
+
keepSelectedOptions: false
|
|
119
120
|
};
|
|
120
121
|
exports.MultiSelect_defaultProps = MultiSelect_defaultProps;
|
|
121
122
|
var MultiSelectHeader_defaultProps = {
|
|
@@ -149,7 +150,9 @@ var MultiSelectWithAvatar_defaultProps = {
|
|
|
149
150
|
isSearchClearOnSelect: true,
|
|
150
151
|
needEffect: true,
|
|
151
152
|
isLoading: false,
|
|
152
|
-
dataSelectorId: 'multiSelectWithAvatar'
|
|
153
|
+
dataSelectorId: 'multiSelectWithAvatar',
|
|
154
|
+
keepSelectedOptions: false,
|
|
155
|
+
customProps: {}
|
|
153
156
|
};
|
|
154
157
|
exports.MultiSelectWithAvatar_defaultProps = MultiSelectWithAvatar_defaultProps;
|
|
155
158
|
var SelectedOptions_defaultProps = {
|
|
@@ -249,7 +249,8 @@ var MultiSelect_propTypes = {
|
|
|
249
249
|
needEffect: _propTypes["default"].bool,
|
|
250
250
|
boxSize: _propTypes["default"].string,
|
|
251
251
|
isLoading: _propTypes["default"].bool,
|
|
252
|
-
dataSelectorId: _propTypes["default"].string
|
|
252
|
+
dataSelectorId: _propTypes["default"].string,
|
|
253
|
+
keepSelectedOptions: _propTypes["default"].bool
|
|
253
254
|
};
|
|
254
255
|
exports.MultiSelect_propTypes = MultiSelect_propTypes;
|
|
255
256
|
var MultiSelectHeader_propTypes = {
|
|
@@ -306,6 +307,11 @@ var MultiSelectWithAvatar_propTypes = {
|
|
|
306
307
|
htmlId: _propTypes["default"].string,
|
|
307
308
|
isBoxPaddingNeed: _propTypes["default"].bool,
|
|
308
309
|
needEffect: _propTypes["default"].bool,
|
|
310
|
+
keepSelectedOptions: _propTypes["default"].bool,
|
|
311
|
+
customProps: _propTypes["default"].shape({
|
|
312
|
+
SuggestionsProps: _propTypes["default"].object,
|
|
313
|
+
DropBoxProps: _propTypes["default"].object
|
|
314
|
+
}),
|
|
309
315
|
/**** Popup props ****/
|
|
310
316
|
isPopupOpen: _propTypes["default"].bool,
|
|
311
317
|
isPopupReady: _propTypes["default"].bool,
|
|
@@ -86,6 +86,9 @@ exports.getPrefixText = getPrefixText;
|
|
|
86
86
|
var getIsStartWithSearch = function getIsStartWithSearch(props) {
|
|
87
87
|
return props.isStartsWithSearch;
|
|
88
88
|
};
|
|
89
|
+
var getKeepSelectedOptions = function getKeepSelectedOptions(props) {
|
|
90
|
+
return props.keepSelectedOptions;
|
|
91
|
+
};
|
|
89
92
|
var getDisabledOptions = function getDisabledOptions(props) {
|
|
90
93
|
return props.disabledOptions || dummyArray;
|
|
91
94
|
};
|
|
@@ -93,7 +96,7 @@ var getListItemProps = function getListItemProps(props) {
|
|
|
93
96
|
return props.listItemProps || '';
|
|
94
97
|
};
|
|
95
98
|
var makeGetMultiSelectFilterSuggestions = function makeGetMultiSelectFilterSuggestions() {
|
|
96
|
-
return (0, _reselect.createSelector)([getOptions, getSelectedOptionsSel, getSearchStr, getNeedSearch, getIsStartWithSearch], function (options, selectedOptions, searchStr, needSearch, isStartsWithSearch) {
|
|
99
|
+
return (0, _reselect.createSelector)([getOptions, getSelectedOptionsSel, getSearchStr, getNeedSearch, getIsStartWithSearch, getKeepSelectedOptions], function (options, selectedOptions, searchStr, needSearch, isStartsWithSearch, keepSelectedOptions) {
|
|
97
100
|
var suggestions = [];
|
|
98
101
|
var suggestionIds = [];
|
|
99
102
|
options.forEach(function (option) {
|
|
@@ -103,7 +106,7 @@ var makeGetMultiSelectFilterSuggestions = function makeGetMultiSelectFilterSugge
|
|
|
103
106
|
var valueString = (0, _Common.getSearchString)(value);
|
|
104
107
|
var searchString = (0, _Common.getSearchString)(searchStr);
|
|
105
108
|
var isMatch = needSearch ? isStartsWithSearch ? valueString.startsWith(searchString) : valueString.indexOf(searchString) !== -1 : true;
|
|
106
|
-
if (selectedOptions.indexOf(id) === -1 && isMatch) {
|
|
109
|
+
if (selectedOptions.indexOf(id) === -1 && isMatch || keepSelectedOptions) {
|
|
107
110
|
suggestions.push(option);
|
|
108
111
|
suggestionIds.push(id);
|
|
109
112
|
}
|
package/package.json
CHANGED