@zohodesk/components 1.4.10-exp.1 → 1.4.11
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/es/AppContainer/AppContainer.js +0 -1
- package/es/AppContainer/AppContainer.module.css +2 -3
- package/es/Button/css/Button.module.css +4 -13
- package/es/DateTime/DateTime.module.css +9 -12
- package/es/DateTime/YearView.module.css +1 -1
- package/es/Heading/Heading.module.css +1 -0
- package/es/Label/Label.module.css +8 -8
- package/es/MultiSelect/MultiSelect.js +36 -12
- package/es/MultiSelect/MultiSelect.module.css +1 -1
- 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/Tab/Tabs.module.css +1 -1
- package/es/TextBox/TextBox.module.css +4 -4
- package/es/Textarea/Textarea.module.css +1 -1
- package/es/Tooltip/Tooltip.module.css +1 -1
- package/es/Typography/css/Typography.module.css +4 -4
- package/es/common/basic.module.css +6 -39
- package/es/common/basicReset.module.css +2 -2
- package/es/common/common.module.css +5 -5
- package/es/utils/Common.js +2 -1
- package/es/utils/dropDownUtils.js +3 -1
- package/es/v1/Tab/v1Tabs.module.css +1 -1
- package/es/v1/Typography/css/v1_Typography.module.css +4 -4
- package/lib/AppContainer/AppContainer.js +0 -2
- package/lib/AppContainer/AppContainer.module.css +2 -3
- package/lib/Button/css/Button.module.css +4 -13
- package/lib/DateTime/DateTime.module.css +9 -12
- package/lib/DateTime/YearView.module.css +1 -1
- package/lib/Heading/Heading.module.css +1 -0
- package/lib/Label/Label.module.css +8 -8
- package/lib/MultiSelect/MultiSelect.js +36 -10
- package/lib/MultiSelect/MultiSelect.module.css +1 -1
- 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/Tab/Tabs.module.css +1 -1
- package/lib/TextBox/TextBox.module.css +4 -4
- package/lib/Textarea/Textarea.module.css +1 -1
- package/lib/Tooltip/Tooltip.module.css +1 -1
- package/lib/Typography/css/Typography.module.css +4 -4
- package/lib/common/basic.module.css +6 -39
- package/lib/common/basicReset.module.css +2 -2
- package/lib/common/common.module.css +5 -5
- package/lib/utils/Common.js +4 -2
- package/lib/utils/dropDownUtils.js +3 -1
- package/lib/v1/Tab/v1Tabs.module.css +1 -1
- package/lib/v1/Typography/css/v1_Typography.module.css +4 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,11 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
|
|
4
4
|
|
|
5
|
+
# 1.4.11
|
|
6
|
+
|
|
7
|
+
- `@zohodesk/virtualizer` version updated from **1.0.3** to **1.0.13**
|
|
8
|
+
|
|
9
|
+
- **Select, MultiSelect**
|
|
10
|
+
- `isVirtualizerEnabled` prop supported to manage bulk amount of options rendering
|
|
11
|
+
|
|
12
|
+
- **Suggestions**
|
|
13
|
+
- **Virtualizer** adopted to manage bulk amount of options rendering with `isVirtualizerEnabled` prop support
|
|
14
|
+
|
|
5
15
|
# 1.4.10
|
|
6
16
|
|
|
7
17
|
- **Select, MultiSelect**
|
|
8
18
|
- Searching with leading spaces is not reflected the results correctly. Issue Fixed.
|
|
9
19
|
|
|
20
|
+
- **Select**
|
|
21
|
+
- Fixed performance issue in options formatting caused by unnecessary rendering triggers
|
|
22
|
+
|
|
10
23
|
# 1.4.9
|
|
11
24
|
|
|
12
25
|
- **MultiSelect , MultiSelectWithAvatar, AdvancedMultiSelect, AdvancedGroupMultiSelect**
|
|
@@ -9,7 +9,6 @@ import '@zohodesk/variables/assets/dotVariables.module.css';
|
|
|
9
9
|
import '@zohodesk/variables/assets/sizeVariables.module.css';
|
|
10
10
|
import '@zohodesk/variables/assets/fontsizeVariables.module.css';
|
|
11
11
|
import '@zohodesk/variables/es/fontFamilyVariables.module.css';
|
|
12
|
-
import '@zohodesk/variables/es/fontWeightVariables.module.css';
|
|
13
12
|
import '@zohodesk/variables/assets/transitionVariables.module.css';
|
|
14
13
|
import '@zohodesk/variables/assets/no_transitionVariables.module.css';
|
|
15
14
|
import "../common/a11y.module.css";
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
-moz-box-sizing: border-box;
|
|
9
9
|
-ms-box-sizing: border-box;
|
|
10
10
|
}
|
|
11
|
-
.container
|
|
12
|
-
|
|
13
|
-
font-family: var(--zd-font-family, ZDLato);
|
|
11
|
+
.container {
|
|
12
|
+
font-family: var(--zd_regular);
|
|
14
13
|
}
|
|
15
14
|
.tooltip {
|
|
16
15
|
height: 0 ;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
--button_cursor: pointer;
|
|
6
6
|
--button_font_size: var(--zd_font_size13);
|
|
7
7
|
--button_text_color: var(--zdt_button_default_text);
|
|
8
|
-
--
|
|
8
|
+
--button_font_family: var(--zd_regular);
|
|
9
9
|
--button_text_transform: capitalize;
|
|
10
10
|
--button_bg_color: var(--zdt_button_default_bg);
|
|
11
11
|
--button_border_radius: 4px;
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
position: relative;
|
|
50
50
|
font-size: var(--button_font_size);
|
|
51
51
|
color: var(--button_text_color);
|
|
52
|
-
font-
|
|
52
|
+
font-family: var(--button_font_family);
|
|
53
53
|
text-transform: var(--button_text_transform);
|
|
54
54
|
min-width: var(--button_min_width);
|
|
55
55
|
height: var(--button_height);
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.bold {
|
|
66
|
-
--
|
|
66
|
+
--button_font_family: var(--zd_semibold);
|
|
67
67
|
composes: ftsmooth from '../../common/common.module.css';
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -569,7 +569,7 @@
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
.loader {
|
|
572
|
-
color: var(--dot_mirror)
|
|
572
|
+
color: var(--dot_mirror)
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
[dir=ltr] .strike {
|
|
@@ -579,43 +579,34 @@
|
|
|
579
579
|
[dir=rtl] .strike {
|
|
580
580
|
background-image: repeating-linear-gradient(-120deg, var(--button_strike_color) 0 1px, transparent 1px 8px);
|
|
581
581
|
}
|
|
582
|
-
|
|
583
582
|
.primaryStrike {
|
|
584
583
|
--button_strike_color: var(--zdt_button_primary_strike);
|
|
585
584
|
}
|
|
586
|
-
|
|
587
585
|
.primaryfilledStrike {
|
|
588
586
|
--button_strike_color: var(--zdt_button_primaryFilled_strike);
|
|
589
587
|
--button_border_color: var(--zdt_button_primaryfill_bg);
|
|
590
588
|
}
|
|
591
|
-
|
|
592
589
|
.dangerStrike {
|
|
593
590
|
--button_strike_color: var(--zdt_button_danger_strike);
|
|
594
591
|
}
|
|
595
|
-
|
|
596
592
|
.dangerfilledStrike {
|
|
597
593
|
--button_strike_color: var(--zdt_button_dangerFilled_strike);
|
|
598
594
|
--button_border_color: var(--zdt_button_dangerfill_bg);
|
|
599
595
|
}
|
|
600
|
-
|
|
601
596
|
.secondaryStrike {
|
|
602
597
|
--button_strike_color: var(--zdt_button_secondary_border);
|
|
603
598
|
}
|
|
604
|
-
|
|
605
599
|
.secondaryfilledStrike {
|
|
606
600
|
--button_strike_color: var(--zdt_button_secondaryFilled_strike);
|
|
607
601
|
--button_border_color: var(--zdt_button_secondaryfill_bg);
|
|
608
602
|
}
|
|
609
|
-
|
|
610
603
|
.tertiaryfilledStrike {
|
|
611
604
|
--button_strike_color: var(--zdt_button_tertiaryFilled_strike);
|
|
612
605
|
--button_border_color: var(--zdt_button_tertiaryfill_bg);
|
|
613
606
|
}
|
|
614
|
-
|
|
615
607
|
.successStrike {
|
|
616
608
|
--button_strike_color: var(--zdt_button_success_strike);
|
|
617
609
|
}
|
|
618
|
-
|
|
619
610
|
.successfilledStrike {
|
|
620
611
|
--button_strike_color: var(--zdt_button_successFilled_strike);
|
|
621
612
|
--button_border_color: var(--zdt_button_successfill_bg);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.semibold {
|
|
2
|
-
font-
|
|
2
|
+
font-family: var(--zd_semibold);
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
[dir=ltr] .boxPadding {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.datesStr {
|
|
32
|
-
font-
|
|
32
|
+
font-family: var(--zd_regular);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.grid {
|
|
@@ -122,8 +122,7 @@
|
|
|
122
122
|
color: var(--zdt_datetime_invalid_text);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
.invalidDate.holiday
|
|
126
|
-
.inActiveDate.holiday:hover {
|
|
125
|
+
.invalidDate.holiday,.inActiveDate.holiday:hover {
|
|
127
126
|
color: var(--zdt_datetime_invaliddate_text);
|
|
128
127
|
}
|
|
129
128
|
|
|
@@ -148,17 +147,15 @@
|
|
|
148
147
|
background-color: var(--zdt_datetime_selected_bg);
|
|
149
148
|
border-radius: 50%;
|
|
150
149
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
cursor: no-drop;
|
|
150
|
+
.inActiveDate{
|
|
151
|
+
color: var(--zdt_datetime_invalid_text);
|
|
152
|
+
cursor: no-drop;
|
|
155
153
|
}
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
.inActiveDate:hover
|
|
155
|
+
{
|
|
158
156
|
color: var(--zdt_datetime_invalid_text);
|
|
159
157
|
}
|
|
160
|
-
|
|
161
|
-
.inActiveDate:hover, .inActiveDate.holiday:hover {
|
|
158
|
+
.inActiveDate:hover, .inActiveDate.holiday:hover{
|
|
162
159
|
background-color: var(--zdt_datetime_inactivedate_hover_bg);
|
|
163
160
|
|
|
164
161
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* label default variables */
|
|
3
3
|
--label_font_size: var(--zd_font_size14);
|
|
4
4
|
--label_text_color: var(--zdt_label_default_text);
|
|
5
|
-
--
|
|
5
|
+
--label_font_family: var(--zd_regular);
|
|
6
6
|
--label_cursor: default;
|
|
7
7
|
--label_line_height: 1.286;
|
|
8
8
|
}
|
|
@@ -13,24 +13,24 @@
|
|
|
13
13
|
line-height: var(--label_line_height);
|
|
14
14
|
font-size: var(--label_font_size);
|
|
15
15
|
color: var(--label_text_color);
|
|
16
|
-
font-
|
|
16
|
+
font-family: var(--label_font_family);
|
|
17
17
|
cursor: var(--label_cursor);
|
|
18
18
|
}
|
|
19
19
|
.xsmall {
|
|
20
20
|
--label_font_size: var(--zd_font_size12);
|
|
21
|
-
--label_line_height:
|
|
21
|
+
--label_line_height:1.5;
|
|
22
22
|
}
|
|
23
23
|
.small {
|
|
24
24
|
--label_font_size: var(--zd_font_size13);
|
|
25
|
-
--label_line_height:
|
|
25
|
+
--label_line_height:1.385;
|
|
26
26
|
}
|
|
27
27
|
.medium {
|
|
28
28
|
--label_font_size: var(--zd_font_size14);
|
|
29
|
-
--label_line_height:
|
|
29
|
+
--label_line_height:1.286;
|
|
30
30
|
}
|
|
31
31
|
.large {
|
|
32
32
|
--label_font_size: var(--zd_font_size26);
|
|
33
|
-
--label_line_height:
|
|
33
|
+
--label_line_height:0.6923;
|
|
34
34
|
composes: semibold from '../common/common.module.css';
|
|
35
35
|
}
|
|
36
36
|
.pointer {
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
display: inline-block;
|
|
47
47
|
}
|
|
48
48
|
.font_default {
|
|
49
|
-
--
|
|
49
|
+
--label_font_family: var(--zd_regular);
|
|
50
50
|
}
|
|
51
51
|
.font_primary {
|
|
52
|
-
--
|
|
52
|
+
--label_font_family: var(--zd_semibold);
|
|
53
53
|
composes: ftsmooth from '../common/common.module.css';
|
|
54
54
|
}
|
|
55
55
|
.dotted {
|
|
@@ -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,
|
|
@@ -798,6 +807,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
798
807
|
|
|
799
808
|
suggestionContainerRef(el) {
|
|
800
809
|
this.suggestionContainer = el;
|
|
810
|
+
typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
|
|
801
811
|
}
|
|
802
812
|
|
|
803
813
|
suggestionItemRef(el, index, id) {
|
|
@@ -862,6 +872,15 @@ export class MultiSelectComponent extends React.Component {
|
|
|
862
872
|
});
|
|
863
873
|
}
|
|
864
874
|
|
|
875
|
+
getVirtualizerPublicMethods(methods) {
|
|
876
|
+
this.virtualizerMethods = methods;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
setSuggestionsVirtualizerContainerRefFunction(refFunc) {
|
|
880
|
+
this.setSuggestionsVirtualizerRef = refFunc;
|
|
881
|
+
this.suggestionContainer && refFunc(this.suggestionContainer);
|
|
882
|
+
}
|
|
883
|
+
|
|
865
884
|
getSelectionUI() {
|
|
866
885
|
let isResponsive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
867
886
|
let {
|
|
@@ -1042,6 +1061,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1042
1061
|
isLoading,
|
|
1043
1062
|
selectAllText,
|
|
1044
1063
|
needSelectAll,
|
|
1064
|
+
isVirtualizerEnabled,
|
|
1045
1065
|
limit
|
|
1046
1066
|
} = this.props;
|
|
1047
1067
|
const {
|
|
@@ -1123,7 +1143,11 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1123
1143
|
}, isSearching ? /*#__PURE__*/React.createElement("div", {
|
|
1124
1144
|
className: style[palette]
|
|
1125
1145
|
}, searchText) : suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, {
|
|
1146
|
+
key: searchStr.trim(),
|
|
1126
1147
|
suggestions: suggestions,
|
|
1148
|
+
isVirtualizerEnabled: isVirtualizerEnabled,
|
|
1149
|
+
getVirtualizerPublicMethods: this.getVirtualizerPublicMethods,
|
|
1150
|
+
setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
|
|
1127
1151
|
getRef: this.suggestionItemRef,
|
|
1128
1152
|
hoverOption: hoverOption,
|
|
1129
1153
|
onClick: this.handleSelectOption,
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
.more {
|
|
197
197
|
font-size: var(--zd_font_size14) ;
|
|
198
198
|
color: var(--zdt_multiselect_more_text);
|
|
199
|
-
font-
|
|
199
|
+
font-family: inherit;
|
|
200
200
|
cursor: pointer;
|
|
201
201
|
margin-top: var(--zd_size5) ;
|
|
202
202
|
background-color: var(--zdt_multiselect_delete_bg);
|
|
@@ -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
|
}
|