@zohodesk/components 1.0.0-temp-233 → 1.0.0-temp-234
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 +35 -0
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +4 -4
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/light/mode/Component_LightMode.module.css +6 -6
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +3 -3
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +461 -8
- package/es/ListItem/ListItem.js +7 -3
- package/es/ListItem/ListItemWithAvatar.js +12 -6
- package/es/ListItem/ListItemWithCheckBox.js +12 -6
- package/es/ListItem/ListItemWithIcon.js +11 -5
- package/es/ListItem/ListItemWithRadio.js +12 -6
- package/es/ListItem/__tests__/ListItem.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithIcon.spec.js +17 -0
- package/es/ListItem/__tests__/ListItemWithRadio.spec.js +19 -0
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +78 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +140 -46
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +251 -49
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +144 -50
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +252 -52
- package/es/ListItem/props/propTypes.js +15 -5
- package/es/MultiSelect/MultiSelect.js +44 -13
- package/es/MultiSelect/Suggestions.js +171 -100
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +4 -0
- package/es/Select/GroupSelect.js +4 -2
- package/es/Select/Select.js +47 -12
- package/es/Select/SelectWithAvatar.js +14 -3
- package/es/Select/SelectWithIcon.js +6 -2
- package/es/Select/props/defaultProps.js +2 -0
- package/es/Select/props/propTypes.js +6 -0
- package/es/utils/Common.js +2 -1
- package/es/utils/dropDownUtils.js +15 -4
- package/lib/ListItem/ListItem.js +8 -3
- package/lib/ListItem/ListItemWithAvatar.js +13 -6
- package/lib/ListItem/ListItemWithCheckBox.js +13 -6
- package/lib/ListItem/ListItemWithIcon.js +11 -5
- package/lib/ListItem/ListItemWithRadio.js +13 -6
- package/lib/ListItem/__tests__/ListItem.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +21 -0
- package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +23 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +78 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +140 -46
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +251 -49
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +144 -50
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +252 -52
- package/lib/ListItem/props/propTypes.js +15 -6
- package/lib/MultiSelect/MultiSelect.js +42 -12
- package/lib/MultiSelect/Suggestions.js +174 -104
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +4 -0
- package/lib/Select/GroupSelect.js +4 -3
- package/lib/Select/Select.js +46 -9
- package/lib/Select/SelectWithAvatar.js +14 -6
- package/lib/Select/SelectWithIcon.js +6 -3
- package/lib/Select/props/defaultProps.js +2 -0
- package/lib/Select/props/propTypes.js +6 -0
- package/lib/utils/Common.js +4 -2
- package/lib/utils/dropDownUtils.js +17 -4
- package/package.json +6 -6
|
@@ -81,6 +81,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
81
81
|
this.handleSearchOptions = debounce(this.handleSearchOptions.bind(this), searchDebounceTime);
|
|
82
82
|
this.handleScroll = this.handleScroll.bind(this);
|
|
83
83
|
this.handleScrollFuncCall = debounce(this.handleScrollFuncCall.bind(this), 500);
|
|
84
|
+
this.getVirtualizerPublicMethods = this.getVirtualizerPublicMethods.bind(this);
|
|
85
|
+
this.setSuggestionsVirtualizerContainerRefFunction = this.setSuggestionsVirtualizerContainerRefFunction.bind(this);
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
componentDidMount() {
|
|
@@ -140,11 +142,6 @@ export class MultiSelectComponent extends React.Component {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
componentDidUpdate(prevProps, prevState) {
|
|
143
|
-
const {
|
|
144
|
-
suggestionContainer,
|
|
145
|
-
selectedOptionContainer,
|
|
146
|
-
suggestionsOrder
|
|
147
|
-
} = this;
|
|
148
145
|
const {
|
|
149
146
|
hoverOption,
|
|
150
147
|
highLightedSelectOptions,
|
|
@@ -156,7 +153,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
156
153
|
isPopupOpen,
|
|
157
154
|
onDropBoxClose,
|
|
158
155
|
onDropBoxOpen,
|
|
159
|
-
isSearchClearOnClose
|
|
156
|
+
isSearchClearOnClose,
|
|
157
|
+
isVirtualizerEnabled
|
|
160
158
|
} = this.props; //handle dropbox open & close
|
|
161
159
|
|
|
162
160
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
@@ -172,12 +170,23 @@ export class MultiSelectComponent extends React.Component {
|
|
|
172
170
|
} //scrollTo handling
|
|
173
171
|
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
if (isVirtualizerEnabled && !!this.virtualizerMethods) {
|
|
174
|
+
let position = prevState.hoverOption > hoverOption ? 'top' : 'bottom';
|
|
175
|
+
this.virtualizerMethods.getElementVisiblePercentage(hoverOption) < 50 && this.virtualizerMethods.scrollToIndex(hoverOption, position);
|
|
176
|
+
} else {
|
|
177
|
+
const {
|
|
178
|
+
suggestionContainer,
|
|
179
|
+
selectedOptionContainer,
|
|
180
|
+
suggestionsOrder
|
|
181
|
+
} = this;
|
|
182
|
+
const hoverId = suggestionsOrder[hoverOption] || '';
|
|
183
|
+
const selectedSuggestion = this[`suggestion_${hoverId}`];
|
|
184
|
+
const lastHighLightedSelectOption = highLightedSelectOptions.slice(-1).length ? highLightedSelectOptions.slice(-1)[0] : null;
|
|
185
|
+
const selectedOption = this[`selectedOption_${lastHighLightedSelectOption}`];
|
|
186
|
+
isPopupOpen && scrollTo(suggestionContainer, selectedSuggestion);
|
|
187
|
+
selectedOptions.length && selectedOption && scrollTo(selectedOptionContainer, selectedOption);
|
|
188
|
+
} //When suggestions length less than 5, getNextOptions function call
|
|
189
|
+
|
|
181
190
|
|
|
182
191
|
const {
|
|
183
192
|
isNextOptions,
|
|
@@ -216,6 +225,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
216
225
|
options,
|
|
217
226
|
valueField,
|
|
218
227
|
textField,
|
|
228
|
+
secondaryField,
|
|
219
229
|
prefixText,
|
|
220
230
|
disabledOptions,
|
|
221
231
|
allowValueFallback,
|
|
@@ -229,6 +239,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
229
239
|
optionType: 'default',
|
|
230
240
|
disabledOptions,
|
|
231
241
|
allowValueFallback,
|
|
242
|
+
secondaryField,
|
|
232
243
|
searchFields
|
|
233
244
|
});
|
|
234
245
|
}
|
|
@@ -798,6 +809,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
798
809
|
|
|
799
810
|
suggestionContainerRef(el) {
|
|
800
811
|
this.suggestionContainer = el;
|
|
812
|
+
typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
|
|
801
813
|
}
|
|
802
814
|
|
|
803
815
|
suggestionItemRef(el, index, id) {
|
|
@@ -862,6 +874,15 @@ export class MultiSelectComponent extends React.Component {
|
|
|
862
874
|
});
|
|
863
875
|
}
|
|
864
876
|
|
|
877
|
+
getVirtualizerPublicMethods(methods) {
|
|
878
|
+
this.virtualizerMethods = methods;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
setSuggestionsVirtualizerContainerRefFunction(refFunc) {
|
|
882
|
+
this.setSuggestionsVirtualizerRef = refFunc;
|
|
883
|
+
this.suggestionContainer && refFunc(this.suggestionContainer);
|
|
884
|
+
}
|
|
885
|
+
|
|
865
886
|
getSelectionUI() {
|
|
866
887
|
let isResponsive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
867
888
|
let {
|
|
@@ -1042,6 +1063,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1042
1063
|
isLoading,
|
|
1043
1064
|
selectAllText,
|
|
1044
1065
|
needSelectAll,
|
|
1066
|
+
customProps,
|
|
1067
|
+
isVirtualizerEnabled,
|
|
1045
1068
|
limit
|
|
1046
1069
|
} = this.props;
|
|
1047
1070
|
const {
|
|
@@ -1065,6 +1088,9 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1065
1088
|
noMoreText: i18nKeys.noMoreText || noMoreOptionsMessage
|
|
1066
1089
|
});
|
|
1067
1090
|
let isModel = isMobilePopover(needResponsive);
|
|
1091
|
+
let {
|
|
1092
|
+
SuggestionsProps
|
|
1093
|
+
} = customProps;
|
|
1068
1094
|
return /*#__PURE__*/React.createElement("div", {
|
|
1069
1095
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${disableAction ? CssProvider('isBlock') : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''}`,
|
|
1070
1096
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -1123,7 +1149,11 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1123
1149
|
}, isSearching ? /*#__PURE__*/React.createElement("div", {
|
|
1124
1150
|
className: style[palette]
|
|
1125
1151
|
}, searchText) : suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
1152
|
+
key: searchStr.trim(),
|
|
1126
1153
|
suggestions: suggestions,
|
|
1154
|
+
isVirtualizerEnabled: isVirtualizerEnabled,
|
|
1155
|
+
getVirtualizerPublicMethods: this.getVirtualizerPublicMethods,
|
|
1156
|
+
setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
|
|
1127
1157
|
getRef: this.suggestionItemRef,
|
|
1128
1158
|
hoverOption: hoverOption,
|
|
1129
1159
|
onClick: this.handleSelectOption,
|
|
@@ -1136,7 +1166,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1136
1166
|
role: 'option'
|
|
1137
1167
|
},
|
|
1138
1168
|
limit: limit,
|
|
1139
|
-
limitReachedMessage: limitReachedMessage
|
|
1169
|
+
limitReachedMessage: limitReachedMessage,
|
|
1170
|
+
...SuggestionsProps
|
|
1140
1171
|
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
1141
1172
|
isLoading: isFetchingOptions,
|
|
1142
1173
|
options: options,
|
|
@@ -1,140 +1,114 @@
|
|
|
1
1
|
/**** Libraries ****/
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import { Suggestions_propTypes } from "./props/propTypes";
|
|
4
4
|
import { Suggestions_defaultProps } from "./props/defaultProps";
|
|
5
|
+
import { Virtualizer } from '@zohodesk/virtualizer';
|
|
5
6
|
/**** Components ****/
|
|
6
7
|
|
|
7
8
|
import ListItem from "../ListItem/ListItem";
|
|
8
9
|
import ListItemWithAvatar from "../ListItem/ListItemWithAvatar";
|
|
9
10
|
import ListItemWithIcon from "../ListItem/ListItemWithIcon";
|
|
10
11
|
import { Container, Box } from "../Layout";
|
|
12
|
+
import { DUMMY_OBJECT, DUMMY_ARRAY } from "../utils/Common";
|
|
13
|
+
|
|
14
|
+
function SuggestionsVirtualizerContainer(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
eleRef,
|
|
17
|
+
children,
|
|
18
|
+
setVirtualizerContainerRefFunction
|
|
19
|
+
} = _ref;
|
|
20
|
+
useMemo(() => {
|
|
21
|
+
typeof setVirtualizerContainerRefFunction === 'function' && setVirtualizerContainerRefFunction(eleRef);
|
|
22
|
+
}, [eleRef, setVirtualizerContainerRefFunction]);
|
|
23
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
export default class Suggestions extends React.PureComponent {
|
|
12
|
-
|
|
27
|
+
constructor(props) {
|
|
28
|
+
super(props);
|
|
29
|
+
this.renderSuggestionList = this.renderSuggestionList.bind(this);
|
|
30
|
+
this.renderVirtualizerSuggestionListItem = this.renderVirtualizerSuggestionListItem.bind(this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
renderSuggestionList(_ref2) {
|
|
34
|
+
let {
|
|
35
|
+
suggestion,
|
|
36
|
+
index,
|
|
37
|
+
ref
|
|
38
|
+
} = _ref2;
|
|
13
39
|
const {
|
|
14
|
-
suggestions,
|
|
15
40
|
getRef,
|
|
16
41
|
hoverOption,
|
|
17
42
|
onClick,
|
|
18
43
|
onMouseEnter,
|
|
19
44
|
needTick,
|
|
20
45
|
needBorder,
|
|
21
|
-
selectedOptions =
|
|
46
|
+
selectedOptions = DUMMY_ARRAY,
|
|
22
47
|
activeId,
|
|
23
48
|
hoverId,
|
|
24
|
-
dataId,
|
|
25
49
|
listItemSize,
|
|
26
|
-
className,
|
|
27
50
|
avatarPalette,
|
|
28
51
|
palette,
|
|
29
|
-
htmlId,
|
|
30
52
|
a11y,
|
|
31
53
|
needMultiLineText,
|
|
32
54
|
limit,
|
|
33
55
|
limitReachedMessage
|
|
34
56
|
} = this.props;
|
|
35
57
|
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
id,
|
|
59
|
+
value,
|
|
60
|
+
secondaryValue,
|
|
61
|
+
photoURL,
|
|
62
|
+
icon,
|
|
63
|
+
optionType,
|
|
64
|
+
iconSize,
|
|
65
|
+
isDisabled,
|
|
66
|
+
listItemProps,
|
|
67
|
+
listItemCustomProps = DUMMY_OBJECT
|
|
68
|
+
} = suggestion;
|
|
69
|
+
const isActive = activeId === id || selectedOptions.indexOf(id) >= 0;
|
|
70
|
+
const isHighlight = hoverOption === index || id === hoverId ? true : false;
|
|
39
71
|
const selectedOptionsLength = selectedOptions.length;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
optionType,
|
|
57
|
-
iconSize,
|
|
58
|
-
isDisabled,
|
|
59
|
-
listItemProps,
|
|
60
|
-
listItemCustomProps = {}
|
|
61
|
-
} = suggestion;
|
|
62
|
-
const isActive = activeId === id || selectedOptions.indexOf(id) >= 0;
|
|
63
|
-
const isHighlight = hoverOption === index || id === hoverId ? true : false;
|
|
64
|
-
const isLimitReached = selectedOptionsLength >= limit && !isActive;
|
|
65
|
-
const list_a11y = Object.assign({}, a11y, {
|
|
66
|
-
ariaSelected: isActive,
|
|
67
|
-
ariaLabel: value,
|
|
68
|
-
'data-a11y-list-active': isHighlight
|
|
69
|
-
});
|
|
70
|
-
const commonProps = {
|
|
71
|
-
isDisabled: isDisabled ? isDisabled : isLimitReached,
|
|
72
|
-
needMultiLineText,
|
|
73
|
-
...listItemCustomProps
|
|
72
|
+
const isLimitReached = selectedOptionsLength >= limit && !isActive;
|
|
73
|
+
const list_a11y = Object.assign({}, a11y, {
|
|
74
|
+
ariaSelected: isActive,
|
|
75
|
+
ariaLabel: value,
|
|
76
|
+
'data-a11y-list-active': isHighlight
|
|
77
|
+
});
|
|
78
|
+
const commonProps = {
|
|
79
|
+
isDisabled: isDisabled ? isDisabled : isLimitReached,
|
|
80
|
+
needMultiLineText,
|
|
81
|
+
...listItemCustomProps
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (listItemProps) {
|
|
85
|
+
commonProps.customProps = {
|
|
86
|
+
ListItemProps: { ...listItemProps
|
|
87
|
+
}
|
|
74
88
|
};
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
91
|
+
if (isLimitReached) {
|
|
92
|
+
commonProps.disableTitle = limitReachedMessage;
|
|
93
|
+
}
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
95
|
+
function getListItemRef(ele, index, id) {
|
|
96
|
+
ref && ref(ele);
|
|
86
97
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
autoHover: false,
|
|
90
|
-
getRef: getRef,
|
|
91
|
-
highlight: isHighlight,
|
|
92
|
-
id: id,
|
|
93
|
-
imgSrc: photoURL,
|
|
94
|
-
key: `${id}avatarListItem`,
|
|
95
|
-
name: value,
|
|
96
|
-
onClick: onClick,
|
|
97
|
-
onMouseEnter: onMouseEnter,
|
|
98
|
-
value: value,
|
|
99
|
-
title: value,
|
|
100
|
-
needTick: needTick,
|
|
101
|
-
needBorder: needBorder,
|
|
102
|
-
active: isActive,
|
|
103
|
-
size: listItemSize,
|
|
104
|
-
avatarPalette: avatarPalette,
|
|
105
|
-
palette: palette,
|
|
106
|
-
a11y: list_a11y,
|
|
107
|
-
secondaryValue: secondaryValue
|
|
108
|
-
});
|
|
109
|
-
} else if (optionType === 'icon') {
|
|
110
|
-
return /*#__PURE__*/React.createElement(ListItemWithIcon, { ...commonProps,
|
|
111
|
-
autoHover: false,
|
|
112
|
-
getRef: getRef,
|
|
113
|
-
highlight: isHighlight,
|
|
114
|
-
id: id,
|
|
115
|
-
key: `${id}iconListItem`,
|
|
116
|
-
onClick: onClick,
|
|
117
|
-
onMouseEnter: onMouseEnter,
|
|
118
|
-
value: value,
|
|
119
|
-
title: value,
|
|
120
|
-
iconName: icon,
|
|
121
|
-
needTick: needTick,
|
|
122
|
-
needBorder: needBorder,
|
|
123
|
-
active: isActive,
|
|
124
|
-
iconSize: iconSize,
|
|
125
|
-
size: listItemSize,
|
|
126
|
-
palette: palette,
|
|
127
|
-
a11y: list_a11y,
|
|
128
|
-
secondaryValue: secondaryValue
|
|
129
|
-
});
|
|
98
|
+
if (typeof getRef === 'function') {
|
|
99
|
+
getRef(ele, index, id);
|
|
130
100
|
}
|
|
101
|
+
}
|
|
131
102
|
|
|
132
|
-
|
|
103
|
+
if (optionType === 'avatar') {
|
|
104
|
+
return /*#__PURE__*/React.createElement(ListItemWithAvatar, { ...commonProps,
|
|
133
105
|
autoHover: false,
|
|
134
|
-
getRef:
|
|
106
|
+
getRef: getListItemRef,
|
|
135
107
|
highlight: isHighlight,
|
|
136
108
|
id: id,
|
|
137
|
-
|
|
109
|
+
imgSrc: photoURL,
|
|
110
|
+
key: `${id}avatarListItem`,
|
|
111
|
+
name: value,
|
|
138
112
|
onClick: onClick,
|
|
139
113
|
onMouseEnter: onMouseEnter,
|
|
140
114
|
value: value,
|
|
@@ -143,8 +117,105 @@ export default class Suggestions extends React.PureComponent {
|
|
|
143
117
|
needBorder: needBorder,
|
|
144
118
|
active: isActive,
|
|
145
119
|
size: listItemSize,
|
|
120
|
+
avatarPalette: avatarPalette,
|
|
146
121
|
palette: palette,
|
|
147
|
-
a11y: list_a11y
|
|
122
|
+
a11y: list_a11y,
|
|
123
|
+
secondaryValue: secondaryValue
|
|
124
|
+
});
|
|
125
|
+
} else if (optionType === 'icon') {
|
|
126
|
+
return /*#__PURE__*/React.createElement(ListItemWithIcon, { ...commonProps,
|
|
127
|
+
autoHover: false,
|
|
128
|
+
getRef: getListItemRef,
|
|
129
|
+
highlight: isHighlight,
|
|
130
|
+
id: id,
|
|
131
|
+
key: `${id}iconListItem`,
|
|
132
|
+
onClick: onClick,
|
|
133
|
+
onMouseEnter: onMouseEnter,
|
|
134
|
+
value: value,
|
|
135
|
+
title: value,
|
|
136
|
+
iconName: icon,
|
|
137
|
+
needTick: needTick,
|
|
138
|
+
needBorder: needBorder,
|
|
139
|
+
active: isActive,
|
|
140
|
+
iconSize: iconSize,
|
|
141
|
+
size: listItemSize,
|
|
142
|
+
palette: palette,
|
|
143
|
+
a11y: list_a11y,
|
|
144
|
+
secondaryValue: secondaryValue
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return /*#__PURE__*/React.createElement(ListItem, { ...commonProps,
|
|
149
|
+
autoHover: false,
|
|
150
|
+
getRef: getListItemRef,
|
|
151
|
+
highlight: isHighlight,
|
|
152
|
+
id: id,
|
|
153
|
+
key: `${id}listItem`,
|
|
154
|
+
onClick: onClick,
|
|
155
|
+
onMouseEnter: onMouseEnter,
|
|
156
|
+
value: value,
|
|
157
|
+
title: value,
|
|
158
|
+
needTick: needTick,
|
|
159
|
+
needBorder: needBorder,
|
|
160
|
+
active: isActive,
|
|
161
|
+
size: listItemSize,
|
|
162
|
+
palette: palette,
|
|
163
|
+
a11y: list_a11y
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
renderVirtualizerSuggestionListItem(_ref3) {
|
|
168
|
+
let {
|
|
169
|
+
index,
|
|
170
|
+
ref
|
|
171
|
+
} = _ref3;
|
|
172
|
+
const {
|
|
173
|
+
suggestions
|
|
174
|
+
} = this.props;
|
|
175
|
+
const suggestion = suggestions[index];
|
|
176
|
+
return this.renderSuggestionList({
|
|
177
|
+
suggestion,
|
|
178
|
+
index,
|
|
179
|
+
ref
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
render() {
|
|
184
|
+
const {
|
|
185
|
+
suggestions,
|
|
186
|
+
dataId,
|
|
187
|
+
className,
|
|
188
|
+
isVirtualizerEnabled,
|
|
189
|
+
htmlId,
|
|
190
|
+
a11y,
|
|
191
|
+
getVirtualizerPublicMethods,
|
|
192
|
+
setVirtualizerContainerRefFunction
|
|
193
|
+
} = this.props;
|
|
194
|
+
const {
|
|
195
|
+
ariaParentRole,
|
|
196
|
+
ariaMultiselectable
|
|
197
|
+
} = a11y;
|
|
198
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
199
|
+
isCover: false,
|
|
200
|
+
role: ariaParentRole,
|
|
201
|
+
id: htmlId,
|
|
202
|
+
tabindex: "0",
|
|
203
|
+
"aria-multiselectable": ariaMultiselectable
|
|
204
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
205
|
+
dataId: `${dataId}`,
|
|
206
|
+
className: className ? className : ''
|
|
207
|
+
}, isVirtualizerEnabled ? /*#__PURE__*/React.createElement(Virtualizer, {
|
|
208
|
+
containerType: SuggestionsVirtualizerContainer,
|
|
209
|
+
elementRenderer: this.renderVirtualizerSuggestionListItem,
|
|
210
|
+
getExposedPublicMethods: getVirtualizerPublicMethods,
|
|
211
|
+
elementsCount: suggestions.length,
|
|
212
|
+
isElementsFixedHeight: false,
|
|
213
|
+
dataId: `${dataId}_virtualizer`,
|
|
214
|
+
setVirtualizerContainerRefFunction: setVirtualizerContainerRefFunction
|
|
215
|
+
}) : suggestions.map((suggestion, index) => {
|
|
216
|
+
return this.renderSuggestionList({
|
|
217
|
+
suggestion,
|
|
218
|
+
index
|
|
148
219
|
});
|
|
149
220
|
})));
|
|
150
221
|
}
|
|
@@ -86,6 +86,7 @@ export const MultiSelect_defaultProps = {
|
|
|
86
86
|
autoComplete: getLibraryConfig('autoComplete'),
|
|
87
87
|
dataId: 'multiSelect',
|
|
88
88
|
dropBoxSize: 'small',
|
|
89
|
+
isVirtualizerEnabled: false,
|
|
89
90
|
isAnimate: true,
|
|
90
91
|
isDisabled: false,
|
|
91
92
|
isPopupOpenOnEnter: false,
|
|
@@ -167,5 +168,6 @@ export const SelectedOptions_defaultProps = {
|
|
|
167
168
|
};
|
|
168
169
|
export const Suggestions_defaultProps = {
|
|
169
170
|
a11y: {},
|
|
171
|
+
isVirtualizerEnabled: false,
|
|
170
172
|
needMultiLineText: false
|
|
171
173
|
};
|
|
@@ -31,6 +31,7 @@ export const MultiSelect_propTypes = {
|
|
|
31
31
|
disableAction: PropTypes.bool,
|
|
32
32
|
dropBoxSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
33
33
|
emptyMessage: PropTypes.string.isRequired,
|
|
34
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
34
35
|
getContainerRef: PropTypes.func,
|
|
35
36
|
getNextOptions: PropTypes.func,
|
|
36
37
|
getPublicMethods: PropTypes.func,
|
|
@@ -168,6 +169,9 @@ export const Suggestions_propTypes = {
|
|
|
168
169
|
avatarPalette: PropTypes.string,
|
|
169
170
|
className: PropTypes.string,
|
|
170
171
|
dataId: PropTypes.string,
|
|
172
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
173
|
+
setVirtualizerContainerRefFunction: PropTypes.func,
|
|
174
|
+
getVirtualizerPublicMethods: PropTypes.func,
|
|
171
175
|
getRef: PropTypes.func,
|
|
172
176
|
hoverId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
173
177
|
hoverOption: PropTypes.number,
|
package/es/Select/GroupSelect.js
CHANGED
|
@@ -622,7 +622,8 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
622
622
|
let ariaErrorId = this.getNextAriaId();
|
|
623
623
|
let {
|
|
624
624
|
TextBoxIconProps = {},
|
|
625
|
-
TextBoxProps = {}
|
|
625
|
+
TextBoxProps = {},
|
|
626
|
+
SuggestionsProps
|
|
626
627
|
} = customProps;
|
|
627
628
|
return /*#__PURE__*/React.createElement("div", {
|
|
628
629
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${iconOnHover && (isReadOnly || isDisabled) ? style.iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? style.iconOnHoverStyle : ''}`,
|
|
@@ -791,7 +792,8 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
791
792
|
ariaParentRole: 'listbox',
|
|
792
793
|
role: 'option'
|
|
793
794
|
},
|
|
794
|
-
dataId: `${dataId}_Options
|
|
795
|
+
dataId: `${dataId}_Options`,
|
|
796
|
+
...SuggestionsProps
|
|
795
797
|
}));
|
|
796
798
|
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
797
799
|
options: revampedGroups,
|
package/es/Select/Select.js
CHANGED
|
@@ -18,7 +18,7 @@ import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
|
|
|
18
18
|
import Loader from '@zohodesk/svg/lib/Loader/Loader';
|
|
19
19
|
/**** Methods ****/
|
|
20
20
|
|
|
21
|
-
import { makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
|
|
21
|
+
import { dummyObj, makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
|
|
22
22
|
import { debounce, scrollTo, getIsEmptyValue, getSearchString, findScrollEnd, getKeyValue } from "../utils/Common.js";
|
|
23
23
|
/**** CSS ****/
|
|
24
24
|
|
|
@@ -106,6 +106,8 @@ export class SelectComponent extends Component {
|
|
|
106
106
|
this.handleAddNewOption = this.handleAddNewOption.bind(this);
|
|
107
107
|
this.handleExposePopupHandlers = this.handleExposePopupHandlers.bind(this);
|
|
108
108
|
this.handleGetAddNewOptionText = this.handleGetAddNewOptionText.bind(this);
|
|
109
|
+
this.getVirtualizerPublicMethods = this.getVirtualizerPublicMethods.bind(this);
|
|
110
|
+
this.setSuggestionsVirtualizerContainerRefFunction = this.setSuggestionsVirtualizerContainerRefFunction.bind(this);
|
|
109
111
|
this.valueInputTypeString = '';
|
|
110
112
|
this.valueInputSearchString = '';
|
|
111
113
|
this.autoSelectSuggestions = [];
|
|
@@ -173,11 +175,7 @@ export class SelectComponent extends Component {
|
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
componentDidUpdate(prevProps) {
|
|
177
|
-
let {
|
|
178
|
-
suggestionContainer,
|
|
179
|
-
optionsOrder
|
|
180
|
-
} = this;
|
|
178
|
+
componentDidUpdate(prevProps, prevState) {
|
|
181
179
|
let {
|
|
182
180
|
hoverIndex,
|
|
183
181
|
searchStr,
|
|
@@ -190,15 +188,31 @@ export class SelectComponent extends Component {
|
|
|
190
188
|
needSearch,
|
|
191
189
|
onSearch,
|
|
192
190
|
isPopupOpen,
|
|
193
|
-
isSearchClearOnClose
|
|
191
|
+
isSearchClearOnClose,
|
|
192
|
+
isVirtualizerEnabled
|
|
194
193
|
} = this.props;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
|
|
195
|
+
if (isVirtualizerEnabled && !!this.virtualizerMethods) {
|
|
196
|
+
let position = prevState.hoverIndex > hoverIndex ? 'top' : 'bottom';
|
|
197
|
+
this.virtualizerMethods.getElementVisiblePercentage(hoverIndex) < 50 && this.virtualizerMethods.scrollToIndex(hoverIndex, position);
|
|
198
|
+
} else {
|
|
199
|
+
let {
|
|
200
|
+
suggestionContainer,
|
|
201
|
+
optionsOrder
|
|
202
|
+
} = this;
|
|
203
|
+
let hoverId = getIsEmptyValue(optionsOrder[hoverIndex]) ? '' : optionsOrder[hoverIndex];
|
|
204
|
+
let selSuggestion = this[`suggestion_${hoverId}`];
|
|
205
|
+
isPopupOpen && scrollTo(suggestionContainer, selSuggestion);
|
|
206
|
+
}
|
|
198
207
|
|
|
199
208
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
200
209
|
if (isPopupOpen) {
|
|
201
210
|
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
211
|
+
|
|
212
|
+
if (isVirtualizerEnabled && !!this.virtualizerMethods) {
|
|
213
|
+
this.virtualizerMethods.getElementVisiblePercentage(hoverIndex) < 50 && this.virtualizerMethods.scrollToIndex(hoverIndex);
|
|
214
|
+
}
|
|
215
|
+
|
|
202
216
|
setTimeout(() => {
|
|
203
217
|
this.searchInput && this.searchInput.focus({
|
|
204
218
|
preventScroll: true
|
|
@@ -251,15 +265,19 @@ export class SelectComponent extends Component {
|
|
|
251
265
|
valueField,
|
|
252
266
|
textField,
|
|
253
267
|
allowValueFallback,
|
|
254
|
-
customProps =
|
|
268
|
+
customProps = dummyObj,
|
|
269
|
+
searchFields,
|
|
270
|
+
secondaryField
|
|
255
271
|
} = props;
|
|
256
272
|
let {
|
|
257
|
-
listItemProps =
|
|
273
|
+
listItemProps = dummyObj
|
|
258
274
|
} = customProps;
|
|
259
275
|
return this.formatOptions({
|
|
260
276
|
options,
|
|
261
277
|
valueField,
|
|
262
278
|
textField,
|
|
279
|
+
secondaryField,
|
|
280
|
+
searchFields,
|
|
263
281
|
listItemProps,
|
|
264
282
|
allowValueFallback
|
|
265
283
|
});
|
|
@@ -429,6 +447,7 @@ export class SelectComponent extends Component {
|
|
|
429
447
|
handleFilterSuggestions() {
|
|
430
448
|
let {
|
|
431
449
|
needLocalSearch,
|
|
450
|
+
searchFields,
|
|
432
451
|
excludeOptions = dummyArray // needSearch
|
|
433
452
|
|
|
434
453
|
} = this.props;
|
|
@@ -448,6 +467,7 @@ export class SelectComponent extends Component {
|
|
|
448
467
|
options,
|
|
449
468
|
selectedOptions: excludeOptions,
|
|
450
469
|
searchStr,
|
|
470
|
+
searchFields,
|
|
451
471
|
needSearch: needLocalSearch
|
|
452
472
|
});
|
|
453
473
|
this.optionsOrder = suggestionIds;
|
|
@@ -529,6 +549,7 @@ export class SelectComponent extends Component {
|
|
|
529
549
|
|
|
530
550
|
suggestionContainerRef(el) {
|
|
531
551
|
this.suggestionContainer = el;
|
|
552
|
+
typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
|
|
532
553
|
}
|
|
533
554
|
|
|
534
555
|
suggestionItemRef(el, index, id) {
|
|
@@ -676,6 +697,15 @@ export class SelectComponent extends Component {
|
|
|
676
697
|
});
|
|
677
698
|
}
|
|
678
699
|
|
|
700
|
+
getVirtualizerPublicMethods(methods) {
|
|
701
|
+
this.virtualizerMethods = methods;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
setSuggestionsVirtualizerContainerRefFunction(refFunc) {
|
|
705
|
+
this.setSuggestionsVirtualizerRef = refFunc;
|
|
706
|
+
this.suggestionContainer && refFunc(this.suggestionContainer);
|
|
707
|
+
}
|
|
708
|
+
|
|
679
709
|
render() {
|
|
680
710
|
let {
|
|
681
711
|
needSearch,
|
|
@@ -728,6 +758,7 @@ export class SelectComponent extends Component {
|
|
|
728
758
|
targetOffset,
|
|
729
759
|
isRestrictScroll,
|
|
730
760
|
dropBoxPortalId,
|
|
761
|
+
isVirtualizerEnabled,
|
|
731
762
|
renderCustomToggleIndicator,
|
|
732
763
|
renderCustomSearchClearComponent
|
|
733
764
|
} = this.props;
|
|
@@ -931,7 +962,11 @@ export class SelectComponent extends Component {
|
|
|
931
962
|
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
932
963
|
eleRef: this.suggestionContainerRef
|
|
933
964
|
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
965
|
+
key: searchStr.trim(),
|
|
934
966
|
activeId: selectedId,
|
|
967
|
+
isVirtualizerEnabled: isVirtualizerEnabled,
|
|
968
|
+
getVirtualizerPublicMethods: this.getVirtualizerPublicMethods,
|
|
969
|
+
setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
|
|
935
970
|
suggestions: suggestions,
|
|
936
971
|
getRef: this.suggestionItemRef,
|
|
937
972
|
hoverOption: hoverIndex,
|