@zohodesk/components 1.6.18 → 1.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/es/DropBox/DropBox.js +10 -3
- package/es/DropBox/DropBoxElement/DropBoxElement.js +15 -3
- package/es/DropBox/DropBoxElement/props/propTypes.js +2 -1
- package/es/MultiSelect/AdvancedMultiSelect.js +4 -2
- package/es/MultiSelect/MultiSelect.js +11 -7
- package/es/MultiSelect/MultiSelectWithAvatar.js +4 -2
- package/es/MultiSelect/props/defaultProps.js +3 -0
- package/es/MultiSelect/props/propTypes.js +1 -0
- package/es/Select/GroupSelect.js +4 -2
- package/es/Select/Select.js +9 -5
- package/es/Select/SelectWithAvatar.js +4 -2
- package/es/Select/SelectWithIcon.js +4 -2
- package/es/Select/__tests__/SelectWithIcon.spec.js +3 -1
- package/es/Select/props/defaultProps.js +4 -0
- package/es/Select/props/propTypes.js +3 -0
- package/lib/DropBox/DropBox.js +10 -3
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +21 -3
- package/lib/DropBox/DropBoxElement/props/propTypes.js +2 -1
- package/lib/MultiSelect/AdvancedMultiSelect.js +4 -2
- package/lib/MultiSelect/MultiSelect.js +50 -45
- package/lib/MultiSelect/MultiSelectWithAvatar.js +4 -2
- package/lib/MultiSelect/props/defaultProps.js +3 -0
- package/lib/MultiSelect/props/propTypes.js +1 -0
- package/lib/Select/GroupSelect.js +4 -2
- package/lib/Select/Select.js +9 -5
- package/lib/Select/SelectWithAvatar.js +4 -2
- package/lib/Select/SelectWithIcon.js +4 -2
- package/lib/Select/__tests__/SelectWithIcon.spec.js +3 -1
- package/lib/Select/props/defaultProps.js +5 -2
- package/lib/Select/props/propTypes.js +3 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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.6.20
|
|
6
|
+
|
|
7
|
+
**Select**, **MultiSelect**, **GroupSelect**, **SelectWithAvatar**, **SelectWithIcon**, **MultiSelectWithAvatar**, **AdvancedMultiSelect**
|
|
8
|
+
- `shouldUseInternalLoader` prop introduced
|
|
9
|
+
- It controls whether the component manages fetch-more loading visibility internally via `isFetchingOptions` state, or delegates it to the external `isLoading` prop
|
|
10
|
+
|
|
11
|
+
**Select**, **MultiSelect**
|
|
12
|
+
- Unwanted scroll to highlighted option function excution stopped - Performance fix
|
|
13
|
+
|
|
14
|
+
# 1.6.19
|
|
15
|
+
|
|
16
|
+
- **DropBoxElement**
|
|
17
|
+
- `getSubContainerRef` prop supported to get the sub-container element reference.
|
|
18
|
+
- **Popup**
|
|
19
|
+
- Popup Unmount Memory Leak Issue Resolved .
|
|
20
|
+
|
|
5
21
|
# 1.6.18
|
|
6
22
|
|
|
7
23
|
- buttonComponentVersion temproary support given in LibraryContext , will remove once app is migrated
|
|
@@ -21,7 +37,6 @@ Dot UI is a customizable React component library built to deliver a clean, acces
|
|
|
21
37
|
- **Select**
|
|
22
38
|
- Added `closePopup` callback support to `getFooter` prop, allowing footer actions to close the popup programmatically.
|
|
23
39
|
|
|
24
|
-
|
|
25
40
|
# 1.6.14
|
|
26
41
|
|
|
27
42
|
- **v1/Button**
|
package/es/DropBox/DropBox.js
CHANGED
|
@@ -23,8 +23,15 @@ export default function DropBox(props) {
|
|
|
23
23
|
isRestrictScroll,
|
|
24
24
|
needFocusScope,
|
|
25
25
|
onClose,
|
|
26
|
-
customProps
|
|
26
|
+
customProps,
|
|
27
|
+
getSubContainerRef
|
|
27
28
|
} = props;
|
|
29
|
+
|
|
30
|
+
const setDropBoxRef = ele => {
|
|
31
|
+
getSubContainerRef && getSubContainerRef(ele);
|
|
32
|
+
dropBoxRef.current = ele;
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
const {
|
|
29
36
|
focusScopeProps = {}
|
|
30
37
|
} = customProps;
|
|
@@ -55,10 +62,10 @@ export default function DropBox(props) {
|
|
|
55
62
|
direction: direction
|
|
56
63
|
}, props, {
|
|
57
64
|
zIndexStyle: zIndexStyle,
|
|
58
|
-
|
|
65
|
+
getSubContainerRef: setDropBoxRef
|
|
59
66
|
}))) : /*#__PURE__*/React.createElement(DropBoxElement, _extends({
|
|
60
67
|
isModel: isModel,
|
|
61
|
-
|
|
68
|
+
getSubContainerRef: setDropBoxRef,
|
|
62
69
|
direction: direction
|
|
63
70
|
}, props, {
|
|
64
71
|
zIndexStyle: zIndexStyle
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/no-unknown-property */
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useRef, useCallback } from 'react';
|
|
3
3
|
import useDropboxPosCalc from "./useDropboxPosCalc";
|
|
4
4
|
import cssJSLogic from "./css/cssJSLogic";
|
|
5
5
|
import { positionMapping } from '@zohodesk/dotkit/es/react/components/Popup/utils/positioning';
|
|
@@ -27,13 +27,15 @@ export default function DropBoxElement(props) {
|
|
|
27
27
|
tabIndex,
|
|
28
28
|
palette,
|
|
29
29
|
subContainerRef,
|
|
30
|
+
getSubContainerRef,
|
|
30
31
|
customStyle,
|
|
31
32
|
animationStyle
|
|
32
33
|
} = props;
|
|
33
34
|
let isAbsolute = isAbsolutePositioningNeeded;
|
|
35
|
+
const internalSubContainerRef = useRef(null);
|
|
34
36
|
|
|
35
37
|
const FireOnAnimationEnd = () => {
|
|
36
|
-
let eleClassList =
|
|
38
|
+
let eleClassList = internalSubContainerRef.current && internalSubContainerRef.current.classList;
|
|
37
39
|
let animationStyles = animationStyle == 'default' ? style.fadeInScale : style[animationStyle];
|
|
38
40
|
animationStyles.split(' ').map(rmStyle => {
|
|
39
41
|
if (eleClassList && eleClassList.contains(rmStyle)) {
|
|
@@ -54,6 +56,16 @@ export default function DropBoxElement(props) {
|
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
const setSubContainerRef = useCallback(ele => {
|
|
60
|
+
internalSubContainerRef.current = ele; // Backward compatability: legacy `subContainerRef`.
|
|
61
|
+
|
|
62
|
+
if (subContainerRef) {
|
|
63
|
+
subContainerRef.current = ele;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getSubContainerRef && getSubContainerRef(ele);
|
|
67
|
+
}, [subContainerRef, getSubContainerRef]);
|
|
68
|
+
|
|
57
69
|
if (!isAbsolutePositioningNeeded && size === 'default' && !isActive) {
|
|
58
70
|
isAbsolute = true;
|
|
59
71
|
}
|
|
@@ -120,7 +132,7 @@ export default function DropBoxElement(props) {
|
|
|
120
132
|
"data-id": `${dataId}_subcontainer`,
|
|
121
133
|
"data-test-id": `${dataId}_subcontainer`,
|
|
122
134
|
"data-selector-id": `${dataSelectorId}_subcontainer`,
|
|
123
|
-
ref:
|
|
135
|
+
ref: setSubContainerRef
|
|
124
136
|
}, isModel ? /*#__PURE__*/React.createElement("div", {
|
|
125
137
|
className: style.closeBar
|
|
126
138
|
}) : null, isArrow && !isModel && /*#__PURE__*/React.createElement("div", {
|
|
@@ -382,6 +382,7 @@ export class AdvancedMultiSelectComponent extends MultiSelectComponent {
|
|
|
382
382
|
needEffect,
|
|
383
383
|
disabledOptions,
|
|
384
384
|
isLoading,
|
|
385
|
+
shouldUseInternalLoader,
|
|
385
386
|
dataSelectorId,
|
|
386
387
|
customClass,
|
|
387
388
|
isAbsolutePositioningNeeded,
|
|
@@ -433,6 +434,7 @@ export class AdvancedMultiSelectComponent extends MultiSelectComponent {
|
|
|
433
434
|
});
|
|
434
435
|
let isShowClearIcon = !isReadOnly && !isDisabled && isShowClear;
|
|
435
436
|
const isEditable = !(isReadOnly || isDisabled);
|
|
437
|
+
const isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
436
438
|
return /*#__PURE__*/React.createElement("div", {
|
|
437
439
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''} ${containerClass}`,
|
|
438
440
|
"data-id": dataIdMultiSelectComp,
|
|
@@ -536,7 +538,7 @@ export class AdvancedMultiSelectComponent extends MultiSelectComponent {
|
|
|
536
538
|
}, DropBoxProps, {
|
|
537
539
|
alignBox: "row",
|
|
538
540
|
isResponsivePadding: getFooter ? false : true
|
|
539
|
-
}), isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
541
|
+
}), (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
540
542
|
align: "both",
|
|
541
543
|
className: style.loader
|
|
542
544
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
@@ -577,7 +579,7 @@ export class AdvancedMultiSelectComponent extends MultiSelectComponent {
|
|
|
577
579
|
dataId: dataIdLoading,
|
|
578
580
|
i18nKeys: i18nKeys,
|
|
579
581
|
htmlId: ariaErrorId
|
|
580
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
582
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
581
583
|
isCover: false,
|
|
582
584
|
align: "both"
|
|
583
585
|
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : null)))) : null);
|
|
@@ -190,7 +190,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
190
190
|
|
|
191
191
|
componentDidUpdate(prevProps, prevState) {
|
|
192
192
|
const {
|
|
193
|
-
searchStr
|
|
193
|
+
searchStr,
|
|
194
|
+
hoverOption
|
|
194
195
|
} = this.state;
|
|
195
196
|
const {
|
|
196
197
|
needLocalSearch,
|
|
@@ -201,9 +202,10 @@ export class MultiSelectComponent extends React.Component {
|
|
|
201
202
|
} = this.props; //handle dropbox open & close
|
|
202
203
|
|
|
203
204
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
if (isPopupOpen) {
|
|
206
|
+
this.scrollToHighlightedIndex();
|
|
207
|
+
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
208
|
+
} else {
|
|
207
209
|
this.setState({
|
|
208
210
|
hoverOption: 0
|
|
209
211
|
});
|
|
@@ -212,7 +214,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
216
|
|
|
215
|
-
if (isPopupOpen) {
|
|
217
|
+
if (prevState.hoverOption !== hoverOption && isPopupOpen) {
|
|
216
218
|
this.scrollToHighlightedIndex();
|
|
217
219
|
} //When suggestions length less than 5, getNextOptions function call
|
|
218
220
|
|
|
@@ -1086,6 +1088,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1086
1088
|
needEffect,
|
|
1087
1089
|
boxSize,
|
|
1088
1090
|
isLoading,
|
|
1091
|
+
shouldUseInternalLoader,
|
|
1089
1092
|
selectAllText,
|
|
1090
1093
|
needSelectAll,
|
|
1091
1094
|
isVirtualizerEnabled,
|
|
@@ -1116,6 +1119,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1116
1119
|
let {
|
|
1117
1120
|
SuggestionsProps
|
|
1118
1121
|
} = customProps;
|
|
1122
|
+
const isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
1119
1123
|
return /*#__PURE__*/React.createElement("div", {
|
|
1120
1124
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${disableAction ? CssProvider('isBlock') : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''}`,
|
|
1121
1125
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -1165,7 +1169,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1165
1169
|
selectAllText: selectAllText,
|
|
1166
1170
|
suggestions: suggestions,
|
|
1167
1171
|
dataId: dataId
|
|
1168
|
-
})) : null, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
1172
|
+
})) : null, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
1169
1173
|
align: "both",
|
|
1170
1174
|
className: style.loader
|
|
1171
1175
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(CardContent, {
|
|
@@ -1201,7 +1205,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1201
1205
|
palette: palette,
|
|
1202
1206
|
i18nKeys: i18nKeys,
|
|
1203
1207
|
htmlId: ariaErrorId
|
|
1204
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
1208
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
1205
1209
|
isCover: false,
|
|
1206
1210
|
align: "both"
|
|
1207
1211
|
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : null))) : null);
|
|
@@ -96,6 +96,7 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
96
96
|
isBoxPaddingNeed,
|
|
97
97
|
needEffect,
|
|
98
98
|
isLoading,
|
|
99
|
+
shouldUseInternalLoader,
|
|
99
100
|
keepSelectedOptions,
|
|
100
101
|
customProps,
|
|
101
102
|
limit
|
|
@@ -124,6 +125,7 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
124
125
|
const ariaErrorId = this.getNextAriaId();
|
|
125
126
|
const popUpState = !isReadOnly && !isDisabled && !disableAction && isPopupOpen;
|
|
126
127
|
let isModel = isMobilePopover(needResponsive);
|
|
128
|
+
const isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
127
129
|
return /*#__PURE__*/React.createElement("div", {
|
|
128
130
|
className: ` ${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${disableAction ? CssProvider('isBlock') : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''}`,
|
|
129
131
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -171,7 +173,7 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
171
173
|
selectAllText: selectAllText,
|
|
172
174
|
suggestions: suggestions,
|
|
173
175
|
dataId: dataId
|
|
174
|
-
})) : null, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
176
|
+
})) : null, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
175
177
|
align: "both",
|
|
176
178
|
className: style.loader
|
|
177
179
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(CardContent, {
|
|
@@ -204,7 +206,7 @@ class MultiSelectWithAvatarComponent extends MultiSelectComponent {
|
|
|
204
206
|
palette: palette,
|
|
205
207
|
i18nKeys: i18nKeys,
|
|
206
208
|
htmlId: ariaErrorId
|
|
207
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
209
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
208
210
|
isCover: false,
|
|
209
211
|
align: "both"
|
|
210
212
|
}, /*#__PURE__*/React.createElement(Loader, null)))))) : null);
|
|
@@ -70,6 +70,7 @@ export const AdvancedMultiSelect_defaultProps = {
|
|
|
70
70
|
customProps: {},
|
|
71
71
|
needEffect: true,
|
|
72
72
|
isLoading: false,
|
|
73
|
+
shouldUseInternalLoader: true,
|
|
73
74
|
dataSelectorId: 'advancedMultiSelect',
|
|
74
75
|
customClass: {},
|
|
75
76
|
isAbsolutePositioningNeeded: true,
|
|
@@ -117,6 +118,7 @@ export const MultiSelect_defaultProps = {
|
|
|
117
118
|
needEffect: true,
|
|
118
119
|
boxSize: 'default',
|
|
119
120
|
isLoading: false,
|
|
121
|
+
shouldUseInternalLoader: true,
|
|
120
122
|
dataSelectorId: 'multiSelect',
|
|
121
123
|
keepSelectedOptions: false,
|
|
122
124
|
selectedOptionsCount: 0,
|
|
@@ -157,6 +159,7 @@ export const MultiSelectWithAvatar_defaultProps = {
|
|
|
157
159
|
isRestrictScroll: false,
|
|
158
160
|
needEffect: true,
|
|
159
161
|
isLoading: false,
|
|
162
|
+
shouldUseInternalLoader: true,
|
|
160
163
|
dataSelectorId: 'multiSelectWithAvatar',
|
|
161
164
|
keepSelectedOptions: false,
|
|
162
165
|
customProps: {},
|
|
@@ -109,6 +109,7 @@ export const MultiSelect_propTypes = {
|
|
|
109
109
|
positionsOffset: PropTypes.object,
|
|
110
110
|
targetOffset: PropTypes.object,
|
|
111
111
|
isLoading: PropTypes.bool,
|
|
112
|
+
shouldUseInternalLoader: PropTypes.bool,
|
|
112
113
|
dataSelectorId: PropTypes.string,
|
|
113
114
|
keepSelectedOptions: PropTypes.bool,
|
|
114
115
|
needSelectAll: PropTypes.bool,
|
package/es/Select/GroupSelect.js
CHANGED
|
@@ -591,6 +591,7 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
591
591
|
htmlId,
|
|
592
592
|
iconOnHover,
|
|
593
593
|
isLoading,
|
|
594
|
+
shouldUseInternalLoader,
|
|
594
595
|
dataSelectorId,
|
|
595
596
|
customProps,
|
|
596
597
|
customClass
|
|
@@ -631,6 +632,7 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
631
632
|
dropBox: dropBoxClass = '',
|
|
632
633
|
cardContent: cardContentClass = ''
|
|
633
634
|
} = customClass;
|
|
635
|
+
const isInitialEmptyOptions = searchStr.length === 0 && revampedGroups.length === 0;
|
|
634
636
|
return /*#__PURE__*/React.createElement("div", {
|
|
635
637
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${iconOnHover && (isReadOnly || isDisabled) ? style.iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? style.iconOnHoverStyle : ''}`,
|
|
636
638
|
"data-id": dataIdSlctComp,
|
|
@@ -736,7 +738,7 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
736
738
|
customClass: {
|
|
737
739
|
customDropBox: dropBoxClass
|
|
738
740
|
}
|
|
739
|
-
}, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
741
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
740
742
|
align: "both",
|
|
741
743
|
className: style.loader
|
|
742
744
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
@@ -808,7 +810,7 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
808
810
|
isLoading: isFetchingOptions,
|
|
809
811
|
i18nKeys: i18nKeys,
|
|
810
812
|
htmlId: ariaErrorId
|
|
811
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
813
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
812
814
|
isCover: false,
|
|
813
815
|
align: "both"
|
|
814
816
|
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : null)))) : null);
|
package/es/Select/Select.js
CHANGED
|
@@ -218,10 +218,11 @@ export class SelectComponent extends Component {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
componentDidUpdate(prevProps) {
|
|
221
|
+
componentDidUpdate(prevProps, prevState) {
|
|
222
222
|
let {
|
|
223
223
|
searchStr,
|
|
224
|
-
selectedValueIndex
|
|
224
|
+
selectedValueIndex,
|
|
225
|
+
hoverIndex
|
|
225
226
|
} = this.state;
|
|
226
227
|
let {
|
|
227
228
|
needLocalSearch,
|
|
@@ -233,12 +234,13 @@ export class SelectComponent extends Component {
|
|
|
233
234
|
isSearchClearOnClose
|
|
234
235
|
} = this.props;
|
|
235
236
|
|
|
236
|
-
if (isPopupOpen) {
|
|
237
|
+
if ((prevState.hoverIndex !== hoverIndex || prevState.selectedValueIndex !== selectedValueIndex) && isPopupOpen) {
|
|
237
238
|
this.scrollToHighlightedIndex();
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
241
242
|
if (isPopupOpen) {
|
|
243
|
+
this.scrollToHighlightedIndex();
|
|
242
244
|
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
243
245
|
setTimeout(() => {
|
|
244
246
|
this.searchInput && this.searchInput.focus({
|
|
@@ -799,6 +801,7 @@ export class SelectComponent extends Component {
|
|
|
799
801
|
autoComplete,
|
|
800
802
|
ariaLabelledby,
|
|
801
803
|
isLoading,
|
|
804
|
+
shouldUseInternalLoader,
|
|
802
805
|
dataSelectorId,
|
|
803
806
|
isAbsolutePositioningNeeded,
|
|
804
807
|
positionsOffset,
|
|
@@ -843,6 +846,7 @@ export class SelectComponent extends Component {
|
|
|
843
846
|
dropBox: dropBoxClass = '',
|
|
844
847
|
cardContent: cardContentClass = ''
|
|
845
848
|
} = customClass;
|
|
849
|
+
const isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
846
850
|
const inputFieldLineA11yAttributes = this.getInputFieldLineA11y({
|
|
847
851
|
setAriaId,
|
|
848
852
|
isReadOnly,
|
|
@@ -1018,7 +1022,7 @@ export class SelectComponent extends Component {
|
|
|
1018
1022
|
customClass: {
|
|
1019
1023
|
customDropBox: dropBoxClass
|
|
1020
1024
|
}
|
|
1021
|
-
}, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
1025
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
1022
1026
|
align: "both",
|
|
1023
1027
|
className: style.loader
|
|
1024
1028
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(React.Fragment, null, !getChildren ? /*#__PURE__*/React.createElement(Box, {
|
|
@@ -1085,7 +1089,7 @@ export class SelectComponent extends Component {
|
|
|
1085
1089
|
getCustomEmptyState: getCustomEmptyState ? this.handleGetAddNewOptionText : null,
|
|
1086
1090
|
i18nKeys: i18nKeys,
|
|
1087
1091
|
htmlId: ariaErrorId
|
|
1088
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
1092
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
1089
1093
|
isCover: false,
|
|
1090
1094
|
align: "both"
|
|
1091
1095
|
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter({
|
|
@@ -170,6 +170,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
170
170
|
htmlId,
|
|
171
171
|
needEffect,
|
|
172
172
|
isLoading,
|
|
173
|
+
shouldUseInternalLoader,
|
|
173
174
|
dataSelectorId,
|
|
174
175
|
getTargetRef,
|
|
175
176
|
customProps,
|
|
@@ -204,6 +205,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
204
205
|
dropBox: dropBoxClass = '',
|
|
205
206
|
cardContent: cardContentClass = ''
|
|
206
207
|
} = customClass;
|
|
208
|
+
const isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
207
209
|
return /*#__PURE__*/React.createElement("div", {
|
|
208
210
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''} ${className ? className : ''}`,
|
|
209
211
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -289,7 +291,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
289
291
|
customClass: {
|
|
290
292
|
customDropBox: dropBoxClass
|
|
291
293
|
}
|
|
292
|
-
}, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
294
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
293
295
|
align: "both",
|
|
294
296
|
className: style.loader
|
|
295
297
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
@@ -351,7 +353,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
351
353
|
dataId: dataId,
|
|
352
354
|
i18nKeys: i18nKeys,
|
|
353
355
|
htmlId: ariaErrorId
|
|
354
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
356
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
355
357
|
isCover: false,
|
|
356
358
|
align: "both"
|
|
357
359
|
}, /*#__PURE__*/React.createElement(Loader, null))))))) : null);
|
|
@@ -357,6 +357,7 @@ class SelectWithIcon extends Component {
|
|
|
357
357
|
i18nKeys,
|
|
358
358
|
htmlId,
|
|
359
359
|
isLoading,
|
|
360
|
+
shouldUseInternalLoader,
|
|
360
361
|
dataSelectorId,
|
|
361
362
|
customProps,
|
|
362
363
|
customClass
|
|
@@ -383,6 +384,7 @@ class SelectWithIcon extends Component {
|
|
|
383
384
|
dropBox: dropBoxClass = '',
|
|
384
385
|
cardContent: cardContentClass = ''
|
|
385
386
|
} = customClass;
|
|
387
|
+
const isInitialEmptyOptions = searchValue.length === 0 && options.length === 0;
|
|
386
388
|
return /*#__PURE__*/React.createElement("div", {
|
|
387
389
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''}`,
|
|
388
390
|
"data-title": isDisabled ? title : null,
|
|
@@ -480,7 +482,7 @@ class SelectWithIcon extends Component {
|
|
|
480
482
|
customClass: {
|
|
481
483
|
customDropBox: dropBoxClass
|
|
482
484
|
}
|
|
483
|
-
}, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
485
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/React.createElement(Container, {
|
|
484
486
|
align: "both",
|
|
485
487
|
className: style.loader
|
|
486
488
|
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
@@ -556,7 +558,7 @@ class SelectWithIcon extends Component {
|
|
|
556
558
|
dataId: dataId,
|
|
557
559
|
i18nKeys: i18nKeys,
|
|
558
560
|
htmlId: ariaErrorId
|
|
559
|
-
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
561
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/React.createElement(Container, {
|
|
560
562
|
isCover: false,
|
|
561
563
|
align: "both"
|
|
562
564
|
}, /*#__PURE__*/React.createElement(Loader, null))))))) : null);
|
|
@@ -6,7 +6,9 @@ describe('SelectWithIcon', () => {
|
|
|
6
6
|
const mockOnChange = jest.fn();
|
|
7
7
|
const {
|
|
8
8
|
asFragment
|
|
9
|
-
} = render( /*#__PURE__*/React.createElement(SelectWithIcon,
|
|
9
|
+
} = render( /*#__PURE__*/React.createElement(SelectWithIcon, {
|
|
10
|
+
options: []
|
|
11
|
+
}));
|
|
10
12
|
expect(asFragment()).toMatchSnapshot();
|
|
11
13
|
});
|
|
12
14
|
});
|
|
@@ -35,6 +35,7 @@ export const Select_defaultProps = {
|
|
|
35
35
|
iconOnHover: false,
|
|
36
36
|
customProps: {},
|
|
37
37
|
isLoading: false,
|
|
38
|
+
shouldUseInternalLoader: true,
|
|
38
39
|
isAbsolutePositioningNeeded: true,
|
|
39
40
|
allowValueFallback: true,
|
|
40
41
|
inputFieldLineA11y: {},
|
|
@@ -75,6 +76,7 @@ export const GroupSelect_defaultProps = {
|
|
|
75
76
|
i18nKeys: {},
|
|
76
77
|
iconOnHover: false,
|
|
77
78
|
isLoading: false,
|
|
79
|
+
shouldUseInternalLoader: true,
|
|
78
80
|
customProps: {},
|
|
79
81
|
allowValueFallback: true,
|
|
80
82
|
customClass: {}
|
|
@@ -105,6 +107,7 @@ export const SelectWithAvatar_defaultProps = {
|
|
|
105
107
|
customProps: {},
|
|
106
108
|
needEffect: true,
|
|
107
109
|
isLoading: false,
|
|
110
|
+
shouldUseInternalLoader: true,
|
|
108
111
|
customProps: {},
|
|
109
112
|
customClass: {}
|
|
110
113
|
};
|
|
@@ -133,6 +136,7 @@ export const SelectWithIcon_defaultProps = {
|
|
|
133
136
|
iconSize: '14',
|
|
134
137
|
i18nKeys: {},
|
|
135
138
|
isLoading: false,
|
|
139
|
+
shouldUseInternalLoader: true,
|
|
136
140
|
isAbsolutePositioningNeeded: true,
|
|
137
141
|
isRestrictScroll: false,
|
|
138
142
|
customProps: {},
|
|
@@ -92,6 +92,7 @@ export const Select_propTypes = {
|
|
|
92
92
|
InputFieldLineProps: PropTypes.object
|
|
93
93
|
}),
|
|
94
94
|
isLoading: PropTypes.bool,
|
|
95
|
+
shouldUseInternalLoader: PropTypes.bool,
|
|
95
96
|
dataSelectorId: PropTypes.string,
|
|
96
97
|
isAbsolutePositioningNeeded: PropTypes.bool,
|
|
97
98
|
openPopupOnly: PropTypes.bool,
|
|
@@ -189,6 +190,7 @@ export const GroupSelect_propTypes = {
|
|
|
189
190
|
searchEmptyText: PropTypes.string
|
|
190
191
|
}),
|
|
191
192
|
isLoading: PropTypes.bool,
|
|
193
|
+
shouldUseInternalLoader: PropTypes.bool,
|
|
192
194
|
dataSelectorId: PropTypes.string,
|
|
193
195
|
isDefaultSelectValue: PropTypes.bool,
|
|
194
196
|
customProps: PropTypes.shape({
|
|
@@ -316,6 +318,7 @@ export const SelectWithIcon_propTypes = {
|
|
|
316
318
|
valueKey: PropTypes.string,
|
|
317
319
|
htmlId: PropTypes.string,
|
|
318
320
|
isLoading: PropTypes.bool,
|
|
321
|
+
shouldUseInternalLoader: PropTypes.bool,
|
|
319
322
|
dataSelectorId: PropTypes.string,
|
|
320
323
|
title: PropTypes.string,
|
|
321
324
|
className: PropTypes.string,
|
package/lib/DropBox/DropBox.js
CHANGED
|
@@ -47,7 +47,14 @@ function DropBox(props) {
|
|
|
47
47
|
isRestrictScroll = props.isRestrictScroll,
|
|
48
48
|
needFocusScope = props.needFocusScope,
|
|
49
49
|
onClose = props.onClose,
|
|
50
|
-
customProps = props.customProps
|
|
50
|
+
customProps = props.customProps,
|
|
51
|
+
getSubContainerRef = props.getSubContainerRef;
|
|
52
|
+
|
|
53
|
+
var setDropBoxRef = function setDropBoxRef(ele) {
|
|
54
|
+
getSubContainerRef && getSubContainerRef(ele);
|
|
55
|
+
dropBoxRef.current = ele;
|
|
56
|
+
};
|
|
57
|
+
|
|
51
58
|
var _customProps$focusSco = customProps.focusScopeProps,
|
|
52
59
|
focusScopeProps = _customProps$focusSco === void 0 ? {} : _customProps$focusSco;
|
|
53
60
|
var _focusScopeProps$need = focusScopeProps.needAutoFocus,
|
|
@@ -82,10 +89,10 @@ function DropBox(props) {
|
|
|
82
89
|
direction: direction
|
|
83
90
|
}, props, {
|
|
84
91
|
zIndexStyle: zIndexStyle,
|
|
85
|
-
|
|
92
|
+
getSubContainerRef: setDropBoxRef
|
|
86
93
|
}))) : /*#__PURE__*/_react["default"].createElement(_DropBoxElement["default"], _extends({
|
|
87
94
|
isModel: isModel,
|
|
88
|
-
|
|
95
|
+
getSubContainerRef: setDropBoxRef,
|
|
89
96
|
direction: direction
|
|
90
97
|
}, props, {
|
|
91
98
|
zIndexStyle: zIndexStyle
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = DropBoxElement;
|
|
7
9
|
|
|
8
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
12
|
var _useDropboxPosCalc2 = _interopRequireDefault(require("./useDropboxPosCalc"));
|
|
11
13
|
|
|
@@ -23,6 +25,10 @@ var _DropBoxElementModule = _interopRequireDefault(require("./css/DropBoxElement
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
26
32
|
/* eslint-disable react/no-unknown-property */
|
|
27
33
|
function DropBoxElement(props) {
|
|
28
34
|
var children = props.children,
|
|
@@ -43,12 +49,14 @@ function DropBoxElement(props) {
|
|
|
43
49
|
tabIndex = props.tabIndex,
|
|
44
50
|
palette = props.palette,
|
|
45
51
|
subContainerRef = props.subContainerRef,
|
|
52
|
+
getSubContainerRef = props.getSubContainerRef,
|
|
46
53
|
customStyle = props.customStyle,
|
|
47
54
|
animationStyle = props.animationStyle;
|
|
48
55
|
var isAbsolute = isAbsolutePositioningNeeded;
|
|
56
|
+
var internalSubContainerRef = (0, _react.useRef)(null);
|
|
49
57
|
|
|
50
58
|
var FireOnAnimationEnd = function FireOnAnimationEnd() {
|
|
51
|
-
var eleClassList =
|
|
59
|
+
var eleClassList = internalSubContainerRef.current && internalSubContainerRef.current.classList;
|
|
52
60
|
var animationStyles = animationStyle == 'default' ? _DropBoxElementModule["default"].fadeInScale : _DropBoxElementModule["default"][animationStyle];
|
|
53
61
|
animationStyles.split(' ').map(function (rmStyle) {
|
|
54
62
|
if (eleClassList && eleClassList.contains(rmStyle)) {
|
|
@@ -67,6 +75,16 @@ function DropBoxElement(props) {
|
|
|
67
75
|
}
|
|
68
76
|
};
|
|
69
77
|
|
|
78
|
+
var setSubContainerRef = (0, _react.useCallback)(function (ele) {
|
|
79
|
+
internalSubContainerRef.current = ele; // Backward compatability: legacy `subContainerRef`.
|
|
80
|
+
|
|
81
|
+
if (subContainerRef) {
|
|
82
|
+
subContainerRef.current = ele;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getSubContainerRef && getSubContainerRef(ele);
|
|
86
|
+
}, [subContainerRef, getSubContainerRef]);
|
|
87
|
+
|
|
70
88
|
if (!isAbsolutePositioningNeeded && size === 'default' && !isActive) {
|
|
71
89
|
isAbsolute = true;
|
|
72
90
|
}
|
|
@@ -132,7 +150,7 @@ function DropBoxElement(props) {
|
|
|
132
150
|
"data-id": "".concat(dataId, "_subcontainer"),
|
|
133
151
|
"data-test-id": "".concat(dataId, "_subcontainer"),
|
|
134
152
|
"data-selector-id": "".concat(dataSelectorId, "_subcontainer"),
|
|
135
|
-
ref:
|
|
153
|
+
ref: setSubContainerRef
|
|
136
154
|
}, isModel ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
137
155
|
className: _DropBoxElementModule["default"].closeBar
|
|
138
156
|
}) : null, isArrow && !isModel && /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -57,6 +57,7 @@ var DropBoxElementPropTypes = {
|
|
|
57
57
|
positionsOffset: _propTypes["default"].object,
|
|
58
58
|
targetOffset: _propTypes["default"].object,
|
|
59
59
|
zIndexStyle: _propTypes["default"].object,
|
|
60
|
-
subContainerRef: _propTypes["default"].func
|
|
60
|
+
subContainerRef: _propTypes["default"].func,
|
|
61
|
+
getSubContainerRef: _propTypes["default"].func
|
|
61
62
|
};
|
|
62
63
|
exports.DropBoxElementPropTypes = DropBoxElementPropTypes;
|
|
@@ -453,6 +453,7 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
453
453
|
needEffect = _this$props6.needEffect,
|
|
454
454
|
disabledOptions = _this$props6.disabledOptions,
|
|
455
455
|
isLoading = _this$props6.isLoading,
|
|
456
|
+
shouldUseInternalLoader = _this$props6.shouldUseInternalLoader,
|
|
456
457
|
dataSelectorId = _this$props6.dataSelectorId,
|
|
457
458
|
customClass = _this$props6.customClass,
|
|
458
459
|
isAbsolutePositioningNeeded = _this$props6.isAbsolutePositioningNeeded,
|
|
@@ -502,6 +503,7 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
502
503
|
|
|
503
504
|
var isShowClearIcon = !isReadOnly && !isDisabled && isShowClear;
|
|
504
505
|
var isEditable = !(isReadOnly || isDisabled);
|
|
506
|
+
var isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
505
507
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
506
508
|
className: "".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(borderColor === 'transparent' ? _MultiSelectModule["default"].transparentContainer : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : '', " ").concat(containerClass),
|
|
507
509
|
"data-id": dataIdMultiSelectComp,
|
|
@@ -604,7 +606,7 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
604
606
|
}, DropBoxProps, {
|
|
605
607
|
alignBox: "row",
|
|
606
608
|
isResponsivePadding: getFooter ? false : true
|
|
607
|
-
}), isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
609
|
+
}), (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
608
610
|
align: "both",
|
|
609
611
|
className: _MultiSelectModule["default"].loader
|
|
610
612
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
@@ -645,7 +647,7 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
|
|
|
645
647
|
dataId: dataIdLoading,
|
|
646
648
|
i18nKeys: i18nKeys,
|
|
647
649
|
htmlId: ariaErrorId
|
|
648
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
650
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
649
651
|
isCover: false,
|
|
650
652
|
align: "both"
|
|
651
653
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter()) : null)));
|
|
@@ -270,7 +270,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
270
270
|
}, {
|
|
271
271
|
key: "componentDidUpdate",
|
|
272
272
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
273
|
-
var
|
|
273
|
+
var _this$state2 = this.state,
|
|
274
|
+
searchStr = _this$state2.searchStr,
|
|
275
|
+
hoverOption = _this$state2.hoverOption;
|
|
274
276
|
var _this$props2 = this.props,
|
|
275
277
|
needLocalSearch = _this$props2.needLocalSearch,
|
|
276
278
|
isPopupOpen = _this$props2.isPopupOpen,
|
|
@@ -279,9 +281,10 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
279
281
|
isSearchClearOnClose = _this$props2.isSearchClearOnClose; //handle dropbox open & close
|
|
280
282
|
|
|
281
283
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
284
|
+
if (isPopupOpen) {
|
|
285
|
+
this.scrollToHighlightedIndex();
|
|
286
|
+
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
287
|
+
} else {
|
|
285
288
|
this.setState({
|
|
286
289
|
hoverOption: 0
|
|
287
290
|
});
|
|
@@ -290,7 +293,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
290
293
|
}
|
|
291
294
|
}
|
|
292
295
|
|
|
293
|
-
if (isPopupOpen) {
|
|
296
|
+
if (prevState.hoverOption !== hoverOption && isPopupOpen) {
|
|
294
297
|
this.scrollToHighlightedIndex();
|
|
295
298
|
} //When suggestions length less than 5, getNextOptions function call
|
|
296
299
|
|
|
@@ -366,10 +369,10 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
366
369
|
key: "handleInputCick",
|
|
367
370
|
value: function handleInputCick(e) {
|
|
368
371
|
var removeClose = this.props.removeClose;
|
|
369
|
-
var _this$
|
|
370
|
-
highLightedSelectOptions = _this$
|
|
371
|
-
_this$
|
|
372
|
-
searchStr = _this$
|
|
372
|
+
var _this$state3 = this.state,
|
|
373
|
+
highLightedSelectOptions = _this$state3.highLightedSelectOptions,
|
|
374
|
+
_this$state3$searchSt = _this$state3.searchStr,
|
|
375
|
+
searchStr = _this$state3$searchSt === void 0 ? '' : _this$state3$searchSt;
|
|
373
376
|
|
|
374
377
|
if (highLightedSelectOptions.length) {
|
|
375
378
|
this.setState({
|
|
@@ -387,11 +390,11 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
387
390
|
}, {
|
|
388
391
|
key: "handleFilterSuggestions",
|
|
389
392
|
value: function handleFilterSuggestions() {
|
|
390
|
-
var _this$
|
|
391
|
-
_this$
|
|
392
|
-
options = _this$
|
|
393
|
-
_this$
|
|
394
|
-
searchStr = _this$
|
|
393
|
+
var _this$state4 = this.state,
|
|
394
|
+
_this$state4$options = _this$state4.options,
|
|
395
|
+
options = _this$state4$options === void 0 ? dummyArray : _this$state4$options,
|
|
396
|
+
_this$state4$searchSt = _this$state4.searchStr,
|
|
397
|
+
searchStr = _this$state4$searchSt === void 0 ? '' : _this$state4$searchSt;
|
|
395
398
|
var _this$props4 = this.props,
|
|
396
399
|
selectedOptions = _this$props4.selectedOptions,
|
|
397
400
|
needLocalSearch = _this$props4.needLocalSearch,
|
|
@@ -420,13 +423,13 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
420
423
|
metaKey = e.metaKey,
|
|
421
424
|
shiftKey = e.shiftKey;
|
|
422
425
|
var suggestions = [];
|
|
423
|
-
var _this$
|
|
424
|
-
hoverOption = _this$
|
|
425
|
-
searchStr = _this$
|
|
426
|
-
highLightedSelectOptions = _this$
|
|
427
|
-
lastHighLightedSelectOption = _this$
|
|
428
|
-
shiftKeyPressHighLighted = _this$
|
|
429
|
-
selectedOptions = _this$
|
|
426
|
+
var _this$state5 = this.state,
|
|
427
|
+
hoverOption = _this$state5.hoverOption,
|
|
428
|
+
searchStr = _this$state5.searchStr,
|
|
429
|
+
highLightedSelectOptions = _this$state5.highLightedSelectOptions,
|
|
430
|
+
lastHighLightedSelectOption = _this$state5.lastHighLightedSelectOption,
|
|
431
|
+
shiftKeyPressHighLighted = _this$state5.shiftKeyPressHighLighted,
|
|
432
|
+
selectedOptions = _this$state5.selectedOptionIds;
|
|
430
433
|
var _this$props5 = this.props,
|
|
431
434
|
isNextOptions = _this$props5.isNextOptions,
|
|
432
435
|
getNextOptions = _this$props5.getNextOptions,
|
|
@@ -646,10 +649,10 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
646
649
|
var _this$props7 = this.props,
|
|
647
650
|
selectedOptions = _this$props7.selectedOptions,
|
|
648
651
|
isReadOnly = _this$props7.isReadOnly;
|
|
649
|
-
var _this$
|
|
650
|
-
highLightedSelectOptions = _this$
|
|
651
|
-
lastHighLightedSelectOption = _this$
|
|
652
|
-
shiftKeyPressHighLighted = _this$
|
|
652
|
+
var _this$state6 = this.state,
|
|
653
|
+
highLightedSelectOptions = _this$state6.highLightedSelectOptions,
|
|
654
|
+
lastHighLightedSelectOption = _this$state6.lastHighLightedSelectOption,
|
|
655
|
+
shiftKeyPressHighLighted = _this$state6.shiftKeyPressHighLighted;
|
|
653
656
|
|
|
654
657
|
if (newOptions.length && !isReadOnly) {
|
|
655
658
|
var newSelectedOptions = selectedOptions.filter(function (option) {
|
|
@@ -768,9 +771,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
768
771
|
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
769
772
|
var e = arguments.length > 1 ? arguments[1] : undefined;
|
|
770
773
|
var selectedOptions = this.props.selectedOptions;
|
|
771
|
-
var _this$
|
|
772
|
-
highLightedSelectOptions = _this$
|
|
773
|
-
lastHighLightedSelectOption = _this$
|
|
774
|
+
var _this$state7 = this.state,
|
|
775
|
+
highLightedSelectOptions = _this$state7.highLightedSelectOptions,
|
|
776
|
+
lastHighLightedSelectOption = _this$state7.lastHighLightedSelectOption;
|
|
774
777
|
var metaKey = e.metaKey,
|
|
775
778
|
ctrlKey = e.ctrlKey,
|
|
776
779
|
shiftKey = e.shiftKey;
|
|
@@ -925,9 +928,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
925
928
|
}, {
|
|
926
929
|
key: "handleActive",
|
|
927
930
|
value: function handleActive(e) {
|
|
928
|
-
var _this$
|
|
929
|
-
searchStr = _this$
|
|
930
|
-
isActive = _this$
|
|
931
|
+
var _this$state8 = this.state,
|
|
932
|
+
searchStr = _this$state8.searchStr,
|
|
933
|
+
isActive = _this$state8.isActive;
|
|
931
934
|
|
|
932
935
|
if (!isActive) {
|
|
933
936
|
this.setState({
|
|
@@ -1023,11 +1026,11 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1023
1026
|
isPopupReady = _this$props14.isPopupReady,
|
|
1024
1027
|
renderCustomClearComponent = _this$props14.renderCustomClearComponent,
|
|
1025
1028
|
renderCustomToggleIndicator = _this$props14.renderCustomToggleIndicator;
|
|
1026
|
-
var _this$
|
|
1027
|
-
isActive = _this$
|
|
1028
|
-
selectedOptions = _this$
|
|
1029
|
-
highLightedSelectOptions = _this$
|
|
1030
|
-
searchStr = _this$
|
|
1029
|
+
var _this$state9 = this.state,
|
|
1030
|
+
isActive = _this$state9.isActive,
|
|
1031
|
+
selectedOptions = _this$state9.selectedOptions,
|
|
1032
|
+
highLightedSelectOptions = _this$state9.highLightedSelectOptions,
|
|
1033
|
+
searchStr = _this$state9.searchStr;
|
|
1031
1034
|
var _i18nKeys$clearText = i18nKeys.clearText,
|
|
1032
1035
|
clearText = _i18nKeys$clearText === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _i18nKeys$clearText;
|
|
1033
1036
|
var _a11y$clearLabel = a11y.clearLabel,
|
|
@@ -1170,18 +1173,19 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1170
1173
|
needEffect = _this$props15.needEffect,
|
|
1171
1174
|
boxSize = _this$props15.boxSize,
|
|
1172
1175
|
isLoading = _this$props15.isLoading,
|
|
1176
|
+
shouldUseInternalLoader = _this$props15.shouldUseInternalLoader,
|
|
1173
1177
|
selectAllText = _this$props15.selectAllText,
|
|
1174
1178
|
needSelectAll = _this$props15.needSelectAll,
|
|
1175
1179
|
isVirtualizerEnabled = _this$props15.isVirtualizerEnabled,
|
|
1176
1180
|
limit = _this$props15.limit,
|
|
1177
1181
|
customProps = _this$props15.customProps;
|
|
1178
|
-
var _this$
|
|
1179
|
-
selectedOptions = _this$
|
|
1180
|
-
searchStr = _this$
|
|
1181
|
-
hoverOption = _this$
|
|
1182
|
-
options = _this$
|
|
1183
|
-
isFetchingOptions = _this$
|
|
1184
|
-
selectedOptionIds = _this$
|
|
1182
|
+
var _this$state10 = this.state,
|
|
1183
|
+
selectedOptions = _this$state10.selectedOptions,
|
|
1184
|
+
searchStr = _this$state10.searchStr,
|
|
1185
|
+
hoverOption = _this$state10.hoverOption,
|
|
1186
|
+
options = _this$state10.options,
|
|
1187
|
+
isFetchingOptions = _this$state10.isFetchingOptions,
|
|
1188
|
+
selectedOptionIds = _this$state10.selectedOptionIds;
|
|
1185
1189
|
var _i18nKeys = i18nKeys,
|
|
1186
1190
|
_i18nKeys$searchText = _i18nKeys.searchText,
|
|
1187
1191
|
searchText = _i18nKeys$searchText === void 0 ? _constants.MULTISELECT_I18N_KEYS.searchText : _i18nKeys$searchText,
|
|
@@ -1197,6 +1201,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1197
1201
|
});
|
|
1198
1202
|
var isModel = (0, _isMobilePopover["default"])(needResponsive);
|
|
1199
1203
|
var SuggestionsProps = customProps.SuggestionsProps;
|
|
1204
|
+
var isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
1200
1205
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
1201
1206
|
className: "".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(isReadOnly ? _MultiSelectModule["default"].readOnly : '', " ").concat(disableAction ? (0, _CssProvider["default"])('isBlock') : '', " ").concat(borderColor === 'transparent' ? _MultiSelectModule["default"].transparentContainer : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : ''),
|
|
1202
1207
|
"data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
|
|
@@ -1246,7 +1251,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1246
1251
|
selectAllText: selectAllText,
|
|
1247
1252
|
suggestions: suggestions,
|
|
1248
1253
|
dataId: dataId
|
|
1249
|
-
})) : null, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1254
|
+
})) : null, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1250
1255
|
align: "both",
|
|
1251
1256
|
className: _MultiSelectModule["default"].loader
|
|
1252
1257
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
|
|
@@ -1282,7 +1287,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1282
1287
|
palette: palette,
|
|
1283
1288
|
i18nKeys: i18nKeys,
|
|
1284
1289
|
htmlId: ariaErrorId
|
|
1285
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1290
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1286
1291
|
isCover: false,
|
|
1287
1292
|
align: "both"
|
|
1288
1293
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter()) : null))) : null);
|
|
@@ -153,6 +153,7 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
153
153
|
isBoxPaddingNeed = _this$props.isBoxPaddingNeed,
|
|
154
154
|
needEffect = _this$props.needEffect,
|
|
155
155
|
isLoading = _this$props.isLoading,
|
|
156
|
+
shouldUseInternalLoader = _this$props.shouldUseInternalLoader,
|
|
156
157
|
keepSelectedOptions = _this$props.keepSelectedOptions,
|
|
157
158
|
customProps = _this$props.customProps,
|
|
158
159
|
limit = _this$props.limit;
|
|
@@ -178,6 +179,7 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
178
179
|
var ariaErrorId = this.getNextAriaId();
|
|
179
180
|
var popUpState = !isReadOnly && !isDisabled && !disableAction && isPopupOpen;
|
|
180
181
|
var isModel = (0, _isMobilePopover["default"])(needResponsive);
|
|
182
|
+
var isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
181
183
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
182
184
|
className: " ".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(isReadOnly ? _MultiSelectModule["default"].readOnly : '', " ").concat(disableAction ? (0, _CssProvider["default"])('isBlock') : '', " ").concat(borderColor === 'transparent' ? _MultiSelectModule["default"].transparentContainer : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : ''),
|
|
183
185
|
"data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
|
|
@@ -225,7 +227,7 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
225
227
|
selectAllText: selectAllText,
|
|
226
228
|
suggestions: suggestions,
|
|
227
229
|
dataId: dataId
|
|
228
|
-
})) : null, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
230
|
+
})) : null, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
229
231
|
align: "both",
|
|
230
232
|
className: _MultiSelectModule["default"].loader
|
|
231
233
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
|
|
@@ -258,7 +260,7 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
|
|
|
258
260
|
palette: palette,
|
|
259
261
|
i18nKeys: i18nKeys,
|
|
260
262
|
htmlId: ariaErrorId
|
|
261
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
263
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
262
264
|
isCover: false,
|
|
263
265
|
align: "both"
|
|
264
266
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)))))) : null);
|
|
@@ -79,6 +79,7 @@ var AdvancedMultiSelect_defaultProps = {
|
|
|
79
79
|
customProps: {},
|
|
80
80
|
needEffect: true,
|
|
81
81
|
isLoading: false,
|
|
82
|
+
shouldUseInternalLoader: true,
|
|
82
83
|
dataSelectorId: 'advancedMultiSelect',
|
|
83
84
|
customClass: {},
|
|
84
85
|
isAbsolutePositioningNeeded: true,
|
|
@@ -128,6 +129,7 @@ var MultiSelect_defaultProps = {
|
|
|
128
129
|
needEffect: true,
|
|
129
130
|
boxSize: 'default',
|
|
130
131
|
isLoading: false,
|
|
132
|
+
shouldUseInternalLoader: true,
|
|
131
133
|
dataSelectorId: 'multiSelect',
|
|
132
134
|
keepSelectedOptions: false,
|
|
133
135
|
selectedOptionsCount: 0,
|
|
@@ -170,6 +172,7 @@ var MultiSelectWithAvatar_defaultProps = {
|
|
|
170
172
|
isRestrictScroll: false,
|
|
171
173
|
needEffect: true,
|
|
172
174
|
isLoading: false,
|
|
175
|
+
shouldUseInternalLoader: true,
|
|
173
176
|
dataSelectorId: 'multiSelectWithAvatar',
|
|
174
177
|
keepSelectedOptions: false,
|
|
175
178
|
customProps: {},
|
|
@@ -128,6 +128,7 @@ var MultiSelect_propTypes = {
|
|
|
128
128
|
positionsOffset: _propTypes["default"].object,
|
|
129
129
|
targetOffset: _propTypes["default"].object,
|
|
130
130
|
isLoading: _propTypes["default"].bool,
|
|
131
|
+
shouldUseInternalLoader: _propTypes["default"].bool,
|
|
131
132
|
dataSelectorId: _propTypes["default"].string,
|
|
132
133
|
keepSelectedOptions: _propTypes["default"].bool,
|
|
133
134
|
needSelectAll: _propTypes["default"].bool,
|
|
@@ -669,6 +669,7 @@ var GroupSelectComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
669
669
|
htmlId = _this$props9.htmlId,
|
|
670
670
|
iconOnHover = _this$props9.iconOnHover,
|
|
671
671
|
isLoading = _this$props9.isLoading,
|
|
672
|
+
shouldUseInternalLoader = _this$props9.shouldUseInternalLoader,
|
|
672
673
|
dataSelectorId = _this$props9.dataSelectorId,
|
|
673
674
|
customProps = _this$props9.customProps,
|
|
674
675
|
customClass = _this$props9.customClass;
|
|
@@ -708,6 +709,7 @@ var GroupSelectComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
708
709
|
dropBoxClass = _customClass$dropBox === void 0 ? '' : _customClass$dropBox,
|
|
709
710
|
_customClass$cardCont = customClass.cardContent,
|
|
710
711
|
cardContentClass = _customClass$cardCont === void 0 ? '' : _customClass$cardCont;
|
|
712
|
+
var isInitialEmptyOptions = searchStr.length === 0 && revampedGroups.length === 0;
|
|
711
713
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
712
714
|
className: "".concat(_SelectModule["default"].container, " ").concat(_SelectModule["default"]["box_".concat(size)], " ").concat(isReadOnly ? _SelectModule["default"].readonly : '', " ").concat(borderColor === 'transparent' ? _SelectModule["default"].transparentContainer : '', " ").concat(iconOnHover && (isReadOnly || isDisabled) ? _SelectModule["default"].iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? _SelectModule["default"].iconOnHoverStyle : ''),
|
|
713
715
|
"data-id": dataIdSlctComp,
|
|
@@ -813,7 +815,7 @@ var GroupSelectComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
813
815
|
customClass: {
|
|
814
816
|
customDropBox: dropBoxClass
|
|
815
817
|
}
|
|
816
|
-
}, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
818
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
817
819
|
align: "both",
|
|
818
820
|
className: _SelectModule["default"].loader
|
|
819
821
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
@@ -883,7 +885,7 @@ var GroupSelectComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
883
885
|
isLoading: isFetchingOptions,
|
|
884
886
|
i18nKeys: i18nKeys,
|
|
885
887
|
htmlId: ariaErrorId
|
|
886
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
888
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
887
889
|
isCover: false,
|
|
888
890
|
align: "both"
|
|
889
891
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter()) : null)));
|
package/lib/Select/Select.js
CHANGED
|
@@ -274,12 +274,13 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
274
274
|
}
|
|
275
275
|
}, {
|
|
276
276
|
key: "componentDidUpdate",
|
|
277
|
-
value: function componentDidUpdate(prevProps) {
|
|
277
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
278
278
|
var _this2 = this;
|
|
279
279
|
|
|
280
280
|
var _this$state = this.state,
|
|
281
281
|
searchStr = _this$state.searchStr,
|
|
282
|
-
selectedValueIndex = _this$state.selectedValueIndex
|
|
282
|
+
selectedValueIndex = _this$state.selectedValueIndex,
|
|
283
|
+
hoverIndex = _this$state.hoverIndex;
|
|
283
284
|
var _this$props = this.props,
|
|
284
285
|
needLocalSearch = _this$props.needLocalSearch,
|
|
285
286
|
onDropBoxClose = _this$props.onDropBoxClose,
|
|
@@ -289,12 +290,13 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
289
290
|
isPopupOpen = _this$props.isPopupOpen,
|
|
290
291
|
isSearchClearOnClose = _this$props.isSearchClearOnClose;
|
|
291
292
|
|
|
292
|
-
if (isPopupOpen) {
|
|
293
|
+
if ((prevState.hoverIndex !== hoverIndex || prevState.selectedValueIndex !== selectedValueIndex) && isPopupOpen) {
|
|
293
294
|
this.scrollToHighlightedIndex();
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
297
298
|
if (isPopupOpen) {
|
|
299
|
+
this.scrollToHighlightedIndex();
|
|
298
300
|
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
299
301
|
setTimeout(function () {
|
|
300
302
|
_this2.searchInput && _this2.searchInput.focus({
|
|
@@ -849,6 +851,7 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
849
851
|
autoComplete = _this$props11.autoComplete,
|
|
850
852
|
ariaLabelledby = _this$props11.ariaLabelledby,
|
|
851
853
|
isLoading = _this$props11.isLoading,
|
|
854
|
+
shouldUseInternalLoader = _this$props11.shouldUseInternalLoader,
|
|
852
855
|
dataSelectorId = _this$props11.dataSelectorId,
|
|
853
856
|
isAbsolutePositioningNeeded = _this$props11.isAbsolutePositioningNeeded,
|
|
854
857
|
positionsOffset = _this$props11.positionsOffset,
|
|
@@ -894,6 +897,7 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
894
897
|
dropBoxClass = _customClass$dropBox === void 0 ? '' : _customClass$dropBox,
|
|
895
898
|
_customClass$cardCont = customClass.cardContent,
|
|
896
899
|
cardContentClass = _customClass$cardCont === void 0 ? '' : _customClass$cardCont;
|
|
900
|
+
var isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
897
901
|
var inputFieldLineA11yAttributes = this.getInputFieldLineA11y({
|
|
898
902
|
setAriaId: setAriaId,
|
|
899
903
|
isReadOnly: isReadOnly,
|
|
@@ -1067,7 +1071,7 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
1067
1071
|
customClass: {
|
|
1068
1072
|
customDropBox: dropBoxClass
|
|
1069
1073
|
}
|
|
1070
|
-
}, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1074
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1071
1075
|
align: "both",
|
|
1072
1076
|
className: _SelectModule["default"].loader
|
|
1073
1077
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !getChildren ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
@@ -1133,7 +1137,7 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
1133
1137
|
getCustomEmptyState: getCustomEmptyState ? _this7.handleGetAddNewOptionText : null,
|
|
1134
1138
|
i18nKeys: i18nKeys,
|
|
1135
1139
|
htmlId: ariaErrorId
|
|
1136
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1140
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1137
1141
|
isCover: false,
|
|
1138
1142
|
align: "both"
|
|
1139
1143
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter({
|
|
@@ -221,6 +221,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
221
221
|
htmlId = _this$props.htmlId,
|
|
222
222
|
needEffect = _this$props.needEffect,
|
|
223
223
|
isLoading = _this$props.isLoading,
|
|
224
|
+
shouldUseInternalLoader = _this$props.shouldUseInternalLoader,
|
|
224
225
|
dataSelectorId = _this$props.dataSelectorId,
|
|
225
226
|
getTargetRef = _this$props.getTargetRef,
|
|
226
227
|
customProps = _this$props.customProps,
|
|
@@ -253,6 +254,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
253
254
|
dropBoxClass = _customClass$dropBox === void 0 ? '' : _customClass$dropBox,
|
|
254
255
|
_customClass$cardCont = customClass.cardContent,
|
|
255
256
|
cardContentClass = _customClass$cardCont === void 0 ? '' : _customClass$cardCont;
|
|
257
|
+
var isInitialEmptyOptions = searchStr.length === 0 && options.length === 0;
|
|
256
258
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
257
259
|
className: "".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(isReadOnly ? _MultiSelectModule["default"].readOnly : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : '', " ").concat(className ? className : ''),
|
|
258
260
|
"data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
|
|
@@ -338,7 +340,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
338
340
|
customClass: {
|
|
339
341
|
customDropBox: dropBoxClass
|
|
340
342
|
}
|
|
341
|
-
}, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
343
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
342
344
|
align: "both",
|
|
343
345
|
className: _MultiSelectModule["default"].loader
|
|
344
346
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
@@ -400,7 +402,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
400
402
|
dataId: dataId,
|
|
401
403
|
i18nKeys: i18nKeys,
|
|
402
404
|
htmlId: ariaErrorId
|
|
403
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
405
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
404
406
|
isCover: false,
|
|
405
407
|
align: "both"
|
|
406
408
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))))));
|
|
@@ -431,6 +431,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
431
431
|
i18nKeys = _this$props7.i18nKeys,
|
|
432
432
|
htmlId = _this$props7.htmlId,
|
|
433
433
|
isLoading = _this$props7.isLoading,
|
|
434
|
+
shouldUseInternalLoader = _this$props7.shouldUseInternalLoader,
|
|
434
435
|
dataSelectorId = _this$props7.dataSelectorId,
|
|
435
436
|
customProps = _this$props7.customProps,
|
|
436
437
|
customClass = _this$props7.customClass;
|
|
@@ -457,6 +458,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
457
458
|
dropBoxClass = _customClass$dropBox === void 0 ? '' : _customClass$dropBox,
|
|
458
459
|
_customClass$cardCont = customClass.cardContent,
|
|
459
460
|
cardContentClass = _customClass$cardCont === void 0 ? '' : _customClass$cardCont;
|
|
461
|
+
var isInitialEmptyOptions = searchValue.length === 0 && options.length === 0;
|
|
460
462
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
461
463
|
className: "".concat(_SelectModule["default"].container, " ").concat(_SelectModule["default"]["box_".concat(size)], " ").concat(isReadOnly ? _SelectModule["default"].readonly : '', " ").concat(borderColor === 'transparent' ? _SelectModule["default"].transparentContainer : ''),
|
|
462
464
|
"data-title": isDisabled ? title : null,
|
|
@@ -553,7 +555,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
553
555
|
customClass: {
|
|
554
556
|
customDropBox: dropBoxClass
|
|
555
557
|
}
|
|
556
|
-
}, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
558
|
+
}, (shouldUseInternalLoader ? isLoading : isLoading && isInitialEmptyOptions) ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
557
559
|
align: "both",
|
|
558
560
|
className: _SelectModule["default"].loader
|
|
559
561
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
@@ -627,7 +629,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
627
629
|
dataId: dataId,
|
|
628
630
|
i18nKeys: i18nKeys,
|
|
629
631
|
htmlId: ariaErrorId
|
|
630
|
-
}), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
632
|
+
}), (shouldUseInternalLoader ? isFetchingOptions : isLoading && !isInitialEmptyOptions) && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
631
633
|
isCover: false,
|
|
632
634
|
align: "both"
|
|
633
635
|
}, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))))));
|
|
@@ -12,7 +12,9 @@ describe('SelectWithIcon', function () {
|
|
|
12
12
|
test('rendering the defult props', function () {
|
|
13
13
|
var mockOnChange = jest.fn();
|
|
14
14
|
|
|
15
|
-
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_SelectWithIcon["default"],
|
|
15
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_SelectWithIcon["default"], {
|
|
16
|
+
options: []
|
|
17
|
+
})),
|
|
16
18
|
asFragment = _render.asFragment;
|
|
17
19
|
|
|
18
20
|
expect(asFragment()).toMatchSnapshot();
|
|
@@ -47,6 +47,7 @@ var Select_defaultProps = {
|
|
|
47
47
|
iconOnHover: false,
|
|
48
48
|
customProps: {},
|
|
49
49
|
isLoading: false,
|
|
50
|
+
shouldUseInternalLoader: true,
|
|
50
51
|
isAbsolutePositioningNeeded: true,
|
|
51
52
|
allowValueFallback: true,
|
|
52
53
|
inputFieldLineA11y: {},
|
|
@@ -88,6 +89,7 @@ var GroupSelect_defaultProps = {
|
|
|
88
89
|
i18nKeys: {},
|
|
89
90
|
iconOnHover: false,
|
|
90
91
|
isLoading: false,
|
|
92
|
+
shouldUseInternalLoader: true,
|
|
91
93
|
customProps: {},
|
|
92
94
|
allowValueFallback: true,
|
|
93
95
|
customClass: {}
|
|
@@ -118,7 +120,8 @@ var SelectWithAvatar_defaultProps = (_SelectWithAvatar_def = {
|
|
|
118
120
|
i18nKeys: {},
|
|
119
121
|
customProps: {},
|
|
120
122
|
needEffect: true,
|
|
121
|
-
isLoading: false
|
|
123
|
+
isLoading: false,
|
|
124
|
+
shouldUseInternalLoader: true
|
|
122
125
|
}, _defineProperty(_SelectWithAvatar_def, "customProps", {}), _defineProperty(_SelectWithAvatar_def, "customClass", {}), _SelectWithAvatar_def);
|
|
123
126
|
exports.SelectWithAvatar_defaultProps = SelectWithAvatar_defaultProps;
|
|
124
127
|
var SelectWithIcon_defaultProps = (_SelectWithIcon_defau = {
|
|
@@ -130,5 +133,5 @@ var SelectWithIcon_defaultProps = (_SelectWithIcon_defau = {
|
|
|
130
133
|
needListBorder: false,
|
|
131
134
|
needSearch: false,
|
|
132
135
|
boxSize: 'default'
|
|
133
|
-
}, _defineProperty(_SelectWithIcon_defau, "needListBorder", false), _defineProperty(_SelectWithIcon_defau, "needCloseOnSelect", true), _defineProperty(_SelectWithIcon_defau, "borderColor", 'default'), _defineProperty(_SelectWithIcon_defau, "needTick", true), _defineProperty(_SelectWithIcon_defau, "searchBoxSize", 'small'), _defineProperty(_SelectWithIcon_defau, "size", 'medium'), _defineProperty(_SelectWithIcon_defau, "searchFields", []), _defineProperty(_SelectWithIcon_defau, "textBoxSize", 'medium'), _defineProperty(_SelectWithIcon_defau, "textBoxVariant", 'default'), _defineProperty(_SelectWithIcon_defau, "dataId", 'selectWithIcon'), _defineProperty(_SelectWithIcon_defau, "dataSelectorId", 'selectWithIcon'), _defineProperty(_SelectWithIcon_defau, "dropBoxSize", 'small'), _defineProperty(_SelectWithIcon_defau, "needIcon", true), _defineProperty(_SelectWithIcon_defau, "iconSize", '14'), _defineProperty(_SelectWithIcon_defau, "i18nKeys", {}), _defineProperty(_SelectWithIcon_defau, "isLoading", false), _defineProperty(_SelectWithIcon_defau, "isAbsolutePositioningNeeded", true), _defineProperty(_SelectWithIcon_defau, "isRestrictScroll", false), _defineProperty(_SelectWithIcon_defau, "customProps", {}), _defineProperty(_SelectWithIcon_defau, "customClass", {}), _SelectWithIcon_defau);
|
|
136
|
+
}, _defineProperty(_SelectWithIcon_defau, "needListBorder", false), _defineProperty(_SelectWithIcon_defau, "needCloseOnSelect", true), _defineProperty(_SelectWithIcon_defau, "borderColor", 'default'), _defineProperty(_SelectWithIcon_defau, "needTick", true), _defineProperty(_SelectWithIcon_defau, "searchBoxSize", 'small'), _defineProperty(_SelectWithIcon_defau, "size", 'medium'), _defineProperty(_SelectWithIcon_defau, "searchFields", []), _defineProperty(_SelectWithIcon_defau, "textBoxSize", 'medium'), _defineProperty(_SelectWithIcon_defau, "textBoxVariant", 'default'), _defineProperty(_SelectWithIcon_defau, "dataId", 'selectWithIcon'), _defineProperty(_SelectWithIcon_defau, "dataSelectorId", 'selectWithIcon'), _defineProperty(_SelectWithIcon_defau, "dropBoxSize", 'small'), _defineProperty(_SelectWithIcon_defau, "needIcon", true), _defineProperty(_SelectWithIcon_defau, "iconSize", '14'), _defineProperty(_SelectWithIcon_defau, "i18nKeys", {}), _defineProperty(_SelectWithIcon_defau, "isLoading", false), _defineProperty(_SelectWithIcon_defau, "shouldUseInternalLoader", true), _defineProperty(_SelectWithIcon_defau, "isAbsolutePositioningNeeded", true), _defineProperty(_SelectWithIcon_defau, "isRestrictScroll", false), _defineProperty(_SelectWithIcon_defau, "customProps", {}), _defineProperty(_SelectWithIcon_defau, "customClass", {}), _SelectWithIcon_defau);
|
|
134
137
|
exports.SelectWithIcon_defaultProps = SelectWithIcon_defaultProps;
|
|
@@ -108,6 +108,7 @@ var Select_propTypes = {
|
|
|
108
108
|
InputFieldLineProps: _propTypes["default"].object
|
|
109
109
|
}),
|
|
110
110
|
isLoading: _propTypes["default"].bool,
|
|
111
|
+
shouldUseInternalLoader: _propTypes["default"].bool,
|
|
111
112
|
dataSelectorId: _propTypes["default"].string,
|
|
112
113
|
isAbsolutePositioningNeeded: _propTypes["default"].bool,
|
|
113
114
|
openPopupOnly: _propTypes["default"].bool,
|
|
@@ -206,6 +207,7 @@ var GroupSelect_propTypes = {
|
|
|
206
207
|
searchEmptyText: _propTypes["default"].string
|
|
207
208
|
}),
|
|
208
209
|
isLoading: _propTypes["default"].bool,
|
|
210
|
+
shouldUseInternalLoader: _propTypes["default"].bool,
|
|
209
211
|
dataSelectorId: _propTypes["default"].string,
|
|
210
212
|
isDefaultSelectValue: _propTypes["default"].bool,
|
|
211
213
|
customProps: _propTypes["default"].shape({
|
|
@@ -337,6 +339,7 @@ var SelectWithIcon_propTypes = {
|
|
|
337
339
|
valueKey: _propTypes["default"].string,
|
|
338
340
|
htmlId: _propTypes["default"].string,
|
|
339
341
|
isLoading: _propTypes["default"].bool,
|
|
342
|
+
shouldUseInternalLoader: _propTypes["default"].bool,
|
|
340
343
|
dataSelectorId: _propTypes["default"].string,
|
|
341
344
|
title: _propTypes["default"].string,
|
|
342
345
|
className: _propTypes["default"].string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.20",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"@dot-system/css-audit-tool": "1.0.0",
|
|
77
77
|
"@zohodesk-private/color-variable-preprocessor": "1.3.3",
|
|
78
78
|
"@zohodesk-private/css-variable-migrator": "1.0.11",
|
|
79
|
-
"@zohodesk-private/node-plugins": "1.1.
|
|
79
|
+
"@zohodesk-private/node-plugins": "1.1.15",
|
|
80
80
|
"@zohodesk-private/react-prop-validator": "1.2.3",
|
|
81
81
|
"@zohodesk/a11y": "2.3.9",
|
|
82
82
|
"@zohodesk/docstool": "1.0.0-alpha-2",
|
|
83
|
-
"@zohodesk/dotkit": "1.0.
|
|
83
|
+
"@zohodesk/dotkit": "1.0.10",
|
|
84
84
|
"@zohodesk/hooks": "2.0.8",
|
|
85
|
-
"@zohodesk/icons": "1.3.
|
|
85
|
+
"@zohodesk/icons": "1.3.6",
|
|
86
86
|
"@zohodesk/layout": "3.2.0",
|
|
87
87
|
"@zohodesk/svg": "1.3.8",
|
|
88
88
|
"@zohodesk/utils": "1.3.16",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"selectn": "1.1.2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@zohodesk/icons": "1.3.
|
|
106
|
+
"@zohodesk/icons": "1.3.6",
|
|
107
107
|
"@zohodesk/variables": "1.3.2",
|
|
108
108
|
"@zohodesk/svg": "1.3.8",
|
|
109
109
|
"@zohodesk/virtualizer": "1.0.13",
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"@zohodesk/utils": "1.3.16",
|
|
114
114
|
"@zohodesk/a11y": "2.3.9",
|
|
115
115
|
"@zohodesk/layout": "3.2.0",
|
|
116
|
-
"@zohodesk/dotkit": "1.0.
|
|
116
|
+
"@zohodesk/dotkit": "1.0.10",
|
|
117
117
|
"color": "4.2.3",
|
|
118
118
|
"@dot-system/css-utility": "0.1.1"
|
|
119
119
|
}
|
|
120
|
-
}
|
|
120
|
+
}
|