@zohodesk/components 1.0.0-temp-233 → 1.0.0-temp-235
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 +13 -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/MultiSelect/MultiSelect.js +36 -12
- 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/Select.js +41 -12
- package/es/Select/props/defaultProps.js +1 -0
- package/es/Select/props/propTypes.js +1 -0
- package/es/Typography/Typography.js +9 -2
- package/es/Typography/__tests__/Typography.spec.js +334 -0
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +451 -0
- package/es/Typography/highlight.js +144 -0
- package/es/Typography/props/defaultProps.js +2 -1
- package/es/Typography/props/propTypes.js +26 -1
- package/es/utils/Common.js +2 -1
- package/es/utils/dropDownUtils.js +3 -1
- package/lib/MultiSelect/MultiSelect.js +36 -10
- 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/Select.js +40 -9
- package/lib/Select/props/defaultProps.js +1 -0
- package/lib/Select/props/propTypes.js +1 -0
- package/lib/Typography/Typography.js +9 -2
- package/lib/Typography/__tests__/Typography.spec.js +342 -0
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +451 -0
- package/lib/Typography/highlight.js +151 -0
- package/lib/Typography/props/defaultProps.js +2 -1
- package/lib/Typography/props/propTypes.js +31 -1
- package/lib/utils/Common.js +4 -2
- package/lib/utils/dropDownUtils.js +3 -1
- package/package.json +6 -6
|
@@ -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/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,10 +265,10 @@ export class SelectComponent extends Component {
|
|
|
251
265
|
valueField,
|
|
252
266
|
textField,
|
|
253
267
|
allowValueFallback,
|
|
254
|
-
customProps =
|
|
268
|
+
customProps = dummyObj
|
|
255
269
|
} = props;
|
|
256
270
|
let {
|
|
257
|
-
listItemProps =
|
|
271
|
+
listItemProps = dummyObj
|
|
258
272
|
} = customProps;
|
|
259
273
|
return this.formatOptions({
|
|
260
274
|
options,
|
|
@@ -529,6 +543,7 @@ export class SelectComponent extends Component {
|
|
|
529
543
|
|
|
530
544
|
suggestionContainerRef(el) {
|
|
531
545
|
this.suggestionContainer = el;
|
|
546
|
+
typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
|
|
532
547
|
}
|
|
533
548
|
|
|
534
549
|
suggestionItemRef(el, index, id) {
|
|
@@ -676,6 +691,15 @@ export class SelectComponent extends Component {
|
|
|
676
691
|
});
|
|
677
692
|
}
|
|
678
693
|
|
|
694
|
+
getVirtualizerPublicMethods(methods) {
|
|
695
|
+
this.virtualizerMethods = methods;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
setSuggestionsVirtualizerContainerRefFunction(refFunc) {
|
|
699
|
+
this.setSuggestionsVirtualizerRef = refFunc;
|
|
700
|
+
this.suggestionContainer && refFunc(this.suggestionContainer);
|
|
701
|
+
}
|
|
702
|
+
|
|
679
703
|
render() {
|
|
680
704
|
let {
|
|
681
705
|
needSearch,
|
|
@@ -728,6 +752,7 @@ export class SelectComponent extends Component {
|
|
|
728
752
|
targetOffset,
|
|
729
753
|
isRestrictScroll,
|
|
730
754
|
dropBoxPortalId,
|
|
755
|
+
isVirtualizerEnabled,
|
|
731
756
|
renderCustomToggleIndicator,
|
|
732
757
|
renderCustomSearchClearComponent
|
|
733
758
|
} = this.props;
|
|
@@ -931,7 +956,11 @@ export class SelectComponent extends Component {
|
|
|
931
956
|
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
932
957
|
eleRef: this.suggestionContainerRef
|
|
933
958
|
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
959
|
+
key: searchStr.trim(),
|
|
934
960
|
activeId: selectedId,
|
|
961
|
+
isVirtualizerEnabled: isVirtualizerEnabled,
|
|
962
|
+
getVirtualizerPublicMethods: this.getVirtualizerPublicMethods,
|
|
963
|
+
setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
|
|
935
964
|
suggestions: suggestions,
|
|
936
965
|
getRef: this.suggestionItemRef,
|
|
937
966
|
hoverOption: hoverIndex,
|
|
@@ -12,6 +12,7 @@ export const Select_propTypes = {
|
|
|
12
12
|
defaultDropBoxPosition: PropTypes.string,
|
|
13
13
|
dropBoxSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
14
14
|
emptyMessage: PropTypes.string,
|
|
15
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
15
16
|
excludeOptions: PropTypes.array,
|
|
16
17
|
getChildren: PropTypes.func,
|
|
17
18
|
getContainerRef: PropTypes.func,
|
|
@@ -3,6 +3,7 @@ import { defaultProps } from "./props/defaultProps";
|
|
|
3
3
|
import { propTypes } from "./props/propTypes";
|
|
4
4
|
import cssJSLogic from "./css/cssJSLogic";
|
|
5
5
|
import { mergeStyle } from '@zohodesk/utils';
|
|
6
|
+
import { highlight } from "./highlight";
|
|
6
7
|
import defaultStyle from "./css/Typography.module.css";
|
|
7
8
|
|
|
8
9
|
const Typography = props => {
|
|
@@ -14,8 +15,12 @@ const Typography = props => {
|
|
|
14
15
|
customId,
|
|
15
16
|
$tagAttributes_text,
|
|
16
17
|
$a11yAttributes_text,
|
|
17
|
-
customStyle
|
|
18
|
+
customStyle,
|
|
19
|
+
highlights
|
|
18
20
|
} = props;
|
|
21
|
+
const {
|
|
22
|
+
highlightData = []
|
|
23
|
+
} = highlights;
|
|
19
24
|
const style = mergeStyle(defaultStyle, customStyle);
|
|
20
25
|
const {
|
|
21
26
|
typographyClass
|
|
@@ -30,7 +35,9 @@ const Typography = props => {
|
|
|
30
35
|
'data-test-id': testId,
|
|
31
36
|
...$tagAttributes_text,
|
|
32
37
|
...$a11yAttributes_text
|
|
33
|
-
}, children
|
|
38
|
+
}, highlightData.length > 0 && typeof children === 'string' ? highlight({ ...highlights,
|
|
39
|
+
text: children
|
|
40
|
+
}) : children);
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
Typography.propTypes = propTypes;
|