@zohodesk/components 1.2.62 → 1.2.63
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/.cli/propValidation_report.html +1 -1
- package/README.md +5 -0
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +12 -4
- package/es/MultiSelect/AdvancedMultiSelect.js +12 -6
- package/es/MultiSelect/MultiSelect.js +10 -4
- package/es/MultiSelect/MultiSelectWithAvatar.js +4 -2
- package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +28 -0
- package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +390 -0
- package/es/MultiSelect/props/defaultProps.js +8 -4
- package/es/MultiSelect/props/propTypes.js +4 -2
- package/es/Select/GroupSelect.js +4 -2
- package/es/Select/Select.js +3 -1
- package/es/Select/SelectWithAvatar.js +4 -2
- package/es/Select/props/defaultProps.js +4 -2
- package/es/Select/props/propTypes.js +4 -2
- package/es/utils/dropDownUtils.js +10 -6
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +11 -5
- package/lib/MultiSelect/AdvancedMultiSelect.js +12 -6
- package/lib/MultiSelect/MultiSelect.js +8 -4
- package/lib/MultiSelect/MultiSelectWithAvatar.js +4 -2
- package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +28 -0
- package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +390 -0
- package/lib/MultiSelect/props/defaultProps.js +8 -4
- package/lib/MultiSelect/props/propTypes.js +3 -2
- package/lib/Select/GroupSelect.js +4 -2
- package/lib/Select/Select.js +3 -1
- package/lib/Select/SelectWithAvatar.js +4 -2
- package/lib/Select/props/defaultProps.js +4 -2
- package/lib/Select/props/propTypes.js +4 -2
- package/lib/utils/dropDownUtils.js +12 -6
- package/package.json +1 -1
- package/result.json +1 -1
|
@@ -40,14 +40,16 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
40
40
|
options,
|
|
41
41
|
valueField,
|
|
42
42
|
textField,
|
|
43
|
-
imageField
|
|
43
|
+
imageField,
|
|
44
|
+
allowValueFallback
|
|
44
45
|
} = props;
|
|
45
46
|
return this.formatOptions({
|
|
46
47
|
options,
|
|
47
48
|
valueField,
|
|
48
49
|
textField,
|
|
49
50
|
imageField,
|
|
50
|
-
optionType: 'avatar'
|
|
51
|
+
optionType: 'avatar',
|
|
52
|
+
allowValueFallback
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -33,7 +33,8 @@ export const Select_defaultProps = {
|
|
|
33
33
|
iconOnHover: false,
|
|
34
34
|
customProps: {},
|
|
35
35
|
isLoading: false,
|
|
36
|
-
isAbsolutePositioningNeeded: true
|
|
36
|
+
isAbsolutePositioningNeeded: true,
|
|
37
|
+
allowValueFallback: true
|
|
37
38
|
};
|
|
38
39
|
export const GroupSelect_defaultProps = {
|
|
39
40
|
animationStyle: 'bounce',
|
|
@@ -70,7 +71,8 @@ export const GroupSelect_defaultProps = {
|
|
|
70
71
|
i18nKeys: {},
|
|
71
72
|
iconOnHover: false,
|
|
72
73
|
isLoading: false,
|
|
73
|
-
customProps: {}
|
|
74
|
+
customProps: {},
|
|
75
|
+
allowValueFallback: true
|
|
74
76
|
};
|
|
75
77
|
export const SelectWithAvatar_defaultProps = {
|
|
76
78
|
animationStyle: 'bounce',
|
|
@@ -93,7 +93,8 @@ export const Select_propTypes = {
|
|
|
93
93
|
positionsOffset: PropTypes.object,
|
|
94
94
|
targetOffset: PropTypes.object,
|
|
95
95
|
isRestrictScroll: PropTypes.bool,
|
|
96
|
-
dropBoxPortalId: PropTypes.string
|
|
96
|
+
dropBoxPortalId: PropTypes.string,
|
|
97
|
+
allowValueFallback: PropTypes.bool
|
|
97
98
|
};
|
|
98
99
|
export const GroupSelect_propTypes = {
|
|
99
100
|
groupedOptions: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -178,7 +179,8 @@ export const GroupSelect_propTypes = {
|
|
|
178
179
|
customProps: PropTypes.shape({
|
|
179
180
|
TextBoxProps: PropTypes.object,
|
|
180
181
|
TextBoxIconProps: PropTypes.object
|
|
181
|
-
})
|
|
182
|
+
}),
|
|
183
|
+
allowValueFallback: PropTypes.bool
|
|
182
184
|
};
|
|
183
185
|
export const SelectWithAvatar_propTypes = { ...Select_propTypes,
|
|
184
186
|
textBoxClass: PropTypes.string,
|
|
@@ -40,6 +40,8 @@ const getDisabledOptions = props => props.disabledOptions || dummyArray;
|
|
|
40
40
|
|
|
41
41
|
const getListItemProps = props => props.listItemProps || '';
|
|
42
42
|
|
|
43
|
+
const getAllowValueFallback = props => props.allowValueFallback !== false;
|
|
44
|
+
|
|
43
45
|
export const makeGetMultiSelectFilterSuggestions = () => createSelector([getOptions, getSelectedOptionsSel, getSearchStr, getNeedSearch, getIsStartWithSearch, getKeepSelectedOptions], (options, selectedOptions, searchStr, needSearch, isStartsWithSearch, keepSelectedOptions) => {
|
|
44
46
|
const suggestions = [];
|
|
45
47
|
const suggestionIds = [];
|
|
@@ -105,7 +107,7 @@ export const extractOptionId = id => {
|
|
|
105
107
|
}
|
|
106
108
|
};
|
|
107
109
|
export const extractOptionIdFromJson = (id, localData) => localData[id] || {};
|
|
108
|
-
export const makeFormatOptions = () => createSelector([getOptions, getValueField, getTextField, getImageField, getPrefixText, getIconName, getIconSize, getOptionType, getDisabledOptions, getListItemProps], (options, valueField, textField, imageField, prefixText, iconName, iconSize, optionType, disabledOptions, listItemProps) => {
|
|
110
|
+
export const makeFormatOptions = () => createSelector([getOptions, getValueField, getTextField, getImageField, getPrefixText, getIconName, getIconSize, getOptionType, getDisabledOptions, getListItemProps, getAllowValueFallback], (options, valueField, textField, imageField, prefixText, iconName, iconSize, optionType, disabledOptions, listItemProps, allowValueFallback) => {
|
|
109
111
|
const revampOptions = [];
|
|
110
112
|
const remvampOptionIds = [];
|
|
111
113
|
const normalizedAllOptions = {};
|
|
@@ -123,7 +125,7 @@ export const makeFormatOptions = () => createSelector([getOptions, getValueField
|
|
|
123
125
|
listItemProps: listStyle
|
|
124
126
|
} = option;
|
|
125
127
|
let id = typeof option === 'object' ? option[impValueField || valueField] : option;
|
|
126
|
-
const value = typeof option === 'object' ? option[impTextField || textField] : option;
|
|
128
|
+
const value = typeof option === 'object' ? option[impTextField || textField] : allowValueFallback ? option : '';
|
|
127
129
|
const photoURL = typeof option === 'object' ? option[impImageField || imageField] : ''; // grouping options (group select/MultiSelect)
|
|
128
130
|
|
|
129
131
|
id = !getIsEmptyValue(id) ? optionIdGrouping(id, prefixText) : '';
|
|
@@ -171,7 +173,7 @@ export const makeFormatOptions = () => createSelector([getOptions, getValueField
|
|
|
171
173
|
optionsOrder: remvampOptionIds
|
|
172
174
|
};
|
|
173
175
|
});
|
|
174
|
-
export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelectedOptionsSel, getNormalizedFormatOptions, getSelectedOptionsLength], (selectedOptions, normalizedFormatOptions, selectedOptionsLength) => {
|
|
176
|
+
export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelectedOptionsSel, getNormalizedFormatOptions, getSelectedOptionsLength, getAllowValueFallback], (selectedOptions, normalizedFormatOptions, selectedOptionsLength, allowValueFallback) => {
|
|
175
177
|
const output = [];
|
|
176
178
|
const revampSelectedOptions = [];
|
|
177
179
|
const normalizedSelectedOptions = {};
|
|
@@ -187,7 +189,8 @@ export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelect
|
|
|
187
189
|
revampSelectedOptions.push(id);
|
|
188
190
|
output.push(normalizedFormatOptions[option]);
|
|
189
191
|
normalizedSelectedOptions[id] = normalizedFormatOptions[option];
|
|
190
|
-
} else if (getIsEmptyValue(id) && !getIsEmptyValue(option) && revampSelectedOptions.indexOf(option) === -1) {
|
|
192
|
+
} else if (allowValueFallback && getIsEmptyValue(id) && !getIsEmptyValue(option) && revampSelectedOptions.indexOf(option) === -1) {
|
|
193
|
+
//fallback case
|
|
191
194
|
const newObj = {
|
|
192
195
|
id: option,
|
|
193
196
|
value: option
|
|
@@ -261,7 +264,7 @@ export const makeObjectConcat = () => createSelector([getObj1, getObj2], (obj1,
|
|
|
261
264
|
const getGroupedOptions = props => props.groupedOptions || dummyArray;
|
|
262
265
|
|
|
263
266
|
const getFormatOptions = makeFormatOptions();
|
|
264
|
-
export const makeGetGroupSelectOptions = () => createSelector([getGroupedOptions], groupedOptions => {
|
|
267
|
+
export const makeGetGroupSelectOptions = () => createSelector([getGroupedOptions, getAllowValueFallback], (groupedOptions, allowValueFallback) => {
|
|
265
268
|
const revampedGroups = [];
|
|
266
269
|
let allOptionIds = [];
|
|
267
270
|
let allNormalizedOptions = {}; //all group normalized options
|
|
@@ -290,7 +293,8 @@ export const makeGetGroupSelectOptions = () => createSelector([getGroupedOptions
|
|
|
290
293
|
options,
|
|
291
294
|
valueField,
|
|
292
295
|
textField,
|
|
293
|
-
prefixText: groupId
|
|
296
|
+
prefixText: groupId,
|
|
297
|
+
allowValueFallback
|
|
294
298
|
});
|
|
295
299
|
|
|
296
300
|
if (optionsOrder.length) {
|
|
@@ -199,11 +199,13 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
|
|
|
199
199
|
key: "handleFormatSelectedOptions",
|
|
200
200
|
value: function handleFormatSelectedOptions(selectedOptionDetails, props) {
|
|
201
201
|
var valueField = props.valueField,
|
|
202
|
-
textField = props.textField
|
|
202
|
+
textField = props.textField,
|
|
203
|
+
allowValueFallback = props.allowValueFallback;
|
|
203
204
|
return this.formatSelectedOptions({
|
|
204
205
|
options: selectedOptionDetails,
|
|
205
206
|
valueField: valueField,
|
|
206
|
-
textField: textField
|
|
207
|
+
textField: textField,
|
|
208
|
+
allowValueFallback: allowValueFallback
|
|
207
209
|
});
|
|
208
210
|
}
|
|
209
211
|
}, {
|
|
@@ -264,6 +266,7 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
|
|
|
264
266
|
}, {
|
|
265
267
|
key: "handleSelectedOptionIdChange",
|
|
266
268
|
value: function handleSelectedOptionIdChange(selectedGroupOptions, normalizedFormatOptions, normalizedSelectedOptions) {
|
|
269
|
+
var allowValueFallback = this.props.allowValueFallback;
|
|
267
270
|
var newSelectedOptions = selectedGroupOptions.map(function (option) {
|
|
268
271
|
return (0, _dropDownUtils.optionIdGrouping)(option.id, option.groupId);
|
|
269
272
|
});
|
|
@@ -275,7 +278,8 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
|
|
|
275
278
|
return this.getSelectedOptions({
|
|
276
279
|
selectedOptions: newSelectedOptions,
|
|
277
280
|
normalizedFormatOptions: formatOptions,
|
|
278
|
-
selectedOptionsLength: selectedOptionsLength
|
|
281
|
+
selectedOptionsLength: selectedOptionsLength,
|
|
282
|
+
allowValueFallback: allowValueFallback
|
|
279
283
|
});
|
|
280
284
|
}
|
|
281
285
|
}, {
|
|
@@ -322,10 +326,12 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
|
|
|
322
326
|
}, {
|
|
323
327
|
key: "handleGetGroupSelectOptions",
|
|
324
328
|
value: function handleGetGroupSelectOptions(props) {
|
|
325
|
-
var
|
|
329
|
+
var allowValueFallback = props.allowValueFallback,
|
|
330
|
+
_props$groupedOptions = props.groupedOptions,
|
|
326
331
|
groupedOptions = _props$groupedOptions === void 0 ? [] : _props$groupedOptions;
|
|
327
332
|
return this.getGroupSelectOptions({
|
|
328
|
-
groupedOptions: groupedOptions
|
|
333
|
+
groupedOptions: groupedOptions,
|
|
334
|
+
allowValueFallback: allowValueFallback
|
|
329
335
|
});
|
|
330
336
|
}
|
|
331
337
|
}, {
|
|
@@ -218,7 +218,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
218
218
|
iconSize = props.iconSize,
|
|
219
219
|
prefixText = props.prefixText,
|
|
220
220
|
optionType = props.optionType,
|
|
221
|
-
disabledOptions = props.disabledOptions
|
|
221
|
+
disabledOptions = props.disabledOptions,
|
|
222
|
+
allowValueFallback = props.allowValueFallback;
|
|
222
223
|
return this.formatOptions({
|
|
223
224
|
options: options,
|
|
224
225
|
valueField: valueField,
|
|
@@ -228,7 +229,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
228
229
|
prefixText: prefixText,
|
|
229
230
|
optionType: optionType,
|
|
230
231
|
iconSize: iconSize,
|
|
231
|
-
disabledOptions: disabledOptions
|
|
232
|
+
disabledOptions: disabledOptions,
|
|
233
|
+
allowValueFallback: allowValueFallback
|
|
232
234
|
});
|
|
233
235
|
}
|
|
234
236
|
}, {
|
|
@@ -239,7 +241,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
239
241
|
showedSelectedOptionsCount = _ref.showedSelectedOptionsCount;
|
|
240
242
|
|
|
241
243
|
var selectedOptionsLimit = props.selectedOptionsLimit,
|
|
242
|
-
selectedOptionDetails = props.selectedOptionDetails
|
|
244
|
+
selectedOptionDetails = props.selectedOptionDetails,
|
|
245
|
+
allowValueFallback = props.allowValueFallback;
|
|
243
246
|
showedSelectedOptionsCount = (0, _Common.getIsEmptyValue)(showedSelectedOptionsCount) ? selectedOptionsLimit : showedSelectedOptionsCount;
|
|
244
247
|
|
|
245
248
|
var _this$handleFormatSel = this.handleFormatSelectedOptions(selectedOptionDetails, props),
|
|
@@ -252,7 +255,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
252
255
|
return this.getSelectedOptions({
|
|
253
256
|
selectedOptions: selectedOptions,
|
|
254
257
|
normalizedFormatOptions: formatOptions,
|
|
255
|
-
selectedOptionsLength: showedSelectedOptionsCount
|
|
258
|
+
selectedOptionsLength: showedSelectedOptionsCount,
|
|
259
|
+
allowValueFallback: allowValueFallback
|
|
256
260
|
});
|
|
257
261
|
}
|
|
258
262
|
}, {
|
|
@@ -264,7 +268,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
264
268
|
optionType = props.optionType,
|
|
265
269
|
iconName = props.iconName,
|
|
266
270
|
iconSize = props.iconSize,
|
|
267
|
-
disabledOptions = props.disabledOptions
|
|
271
|
+
disabledOptions = props.disabledOptions,
|
|
272
|
+
allowValueFallback = props.allowValueFallback;
|
|
268
273
|
return this.formatSelectedOptions({
|
|
269
274
|
options: selectedOptionDetails,
|
|
270
275
|
valueField: valueField,
|
|
@@ -273,7 +278,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
273
278
|
optionType: optionType,
|
|
274
279
|
iconName: iconName,
|
|
275
280
|
iconSize: iconSize,
|
|
276
|
-
disabledOptions: disabledOptions
|
|
281
|
+
disabledOptions: disabledOptions,
|
|
282
|
+
allowValueFallback: allowValueFallback
|
|
277
283
|
});
|
|
278
284
|
}
|
|
279
285
|
}, {
|
|
@@ -299,22 +299,26 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
299
299
|
valueField = props.valueField,
|
|
300
300
|
textField = props.textField,
|
|
301
301
|
prefixText = props.prefixText,
|
|
302
|
-
disabledOptions = props.disabledOptions
|
|
302
|
+
disabledOptions = props.disabledOptions,
|
|
303
|
+
allowValueFallback = props.allowValueFallback;
|
|
303
304
|
return this.formatOptions({
|
|
304
305
|
options: options,
|
|
305
306
|
valueField: valueField,
|
|
306
307
|
textField: textField,
|
|
307
308
|
prefixText: prefixText,
|
|
308
309
|
optionType: 'default',
|
|
309
|
-
disabledOptions: disabledOptions
|
|
310
|
+
disabledOptions: disabledOptions,
|
|
311
|
+
allowValueFallback: allowValueFallback
|
|
310
312
|
});
|
|
311
313
|
}
|
|
312
314
|
}, {
|
|
313
315
|
key: "handleGetSelectedOptions",
|
|
314
|
-
value: function handleGetSelectedOptions(selectedOptions, normalizedFormatOptions) {
|
|
316
|
+
value: function handleGetSelectedOptions(selectedOptions, normalizedFormatOptions, props) {
|
|
317
|
+
var allowValueFallback = props.allowValueFallback;
|
|
315
318
|
return this.getSelectedOptions({
|
|
316
319
|
selectedOptions: selectedOptions,
|
|
317
|
-
normalizedFormatOptions: normalizedFormatOptions
|
|
320
|
+
normalizedFormatOptions: normalizedFormatOptions,
|
|
321
|
+
allowValueFallback: allowValueFallback
|
|
318
322
|
});
|
|
319
323
|
}
|
|
320
324
|
}, {
|
|
@@ -99,14 +99,16 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
99
99
|
valueField = props.valueField,
|
|
100
100
|
textField = props.textField,
|
|
101
101
|
imageField = props.imageField,
|
|
102
|
-
disabledOptions = props.disabledOptions
|
|
102
|
+
disabledOptions = props.disabledOptions,
|
|
103
|
+
allowValueFallback = props.allowValueFallback;
|
|
103
104
|
return this.formatOptions({
|
|
104
105
|
options: options,
|
|
105
106
|
valueField: valueField,
|
|
106
107
|
textField: textField,
|
|
107
108
|
imageField: imageField,
|
|
108
109
|
optionType: 'avatar',
|
|
109
|
-
disabledOptions: disabledOptions
|
|
110
|
+
disabledOptions: disabledOptions,
|
|
111
|
+
allowValueFallback: allowValueFallback
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
}, {
|
|
@@ -17,4 +17,32 @@ describe('AdvancedMultiSelect', function () {
|
|
|
17
17
|
|
|
18
18
|
expect(asFragment()).toMatchSnapshot();
|
|
19
19
|
});
|
|
20
|
+
var options = [{
|
|
21
|
+
id: 1,
|
|
22
|
+
text: 'Apple'
|
|
23
|
+
}, {
|
|
24
|
+
id: 2,
|
|
25
|
+
text: 'Orange'
|
|
26
|
+
}, 'string test'];
|
|
27
|
+
test('rendering the options array with objects and string', function () {
|
|
28
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AdvancedMultiSelect["default"], {
|
|
29
|
+
isPopupOpen: true,
|
|
30
|
+
isPopupReady: true,
|
|
31
|
+
options: options
|
|
32
|
+
})),
|
|
33
|
+
asFragment = _render2.asFragment;
|
|
34
|
+
|
|
35
|
+
expect(asFragment()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
test('rendering the options array with only objects using allowValueFallback', function () {
|
|
38
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AdvancedMultiSelect["default"], {
|
|
39
|
+
isPopupOpen: true,
|
|
40
|
+
isPopupReady: true,
|
|
41
|
+
options: options,
|
|
42
|
+
allowValueFallback: false
|
|
43
|
+
})),
|
|
44
|
+
asFragment = _render3.asFragment;
|
|
45
|
+
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
20
48
|
});
|