@zohodesk/components 1.0.0-temp-240 → 1.0.0-temp-242
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 +51 -1
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +4 -0
- package/assets/Appearance/dark/themes/blue/blue_ComponentTheme_DarkTheme.module.css +3 -0
- package/assets/Appearance/dark/themes/green/green_ComponentTheme_DarkTheme.module.css +3 -0
- package/assets/Appearance/dark/themes/orange/orange_ComponentTheme_DarkTheme.module.css +3 -0
- package/assets/Appearance/dark/themes/red/red_ComponentTheme_DarkTheme.module.css +3 -0
- package/assets/Appearance/dark/themes/yellow/yellow_ComponentTheme_DarkTheme.module.css +3 -0
- package/assets/Appearance/light/mode/Component_LightMode.module.css +4 -0
- package/assets/Appearance/light/themes/blue/blue_ComponentTheme_LightTheme.module.css +3 -0
- package/assets/Appearance/light/themes/green/green_ComponentTheme_LightTheme.module.css +3 -0
- package/assets/Appearance/light/themes/orange/orange_ComponentTheme_LightTheme.module.css +3 -0
- package/assets/Appearance/light/themes/red/red_ComponentTheme_LightTheme.module.css +3 -0
- package/assets/Appearance/light/themes/yellow/yellow_ComponentTheme_LightTheme.module.css +3 -0
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +4 -0
- package/assets/Appearance/pureDark/themes/blue/blue_ComponentTheme_PureDarkTheme.module.css +3 -0
- package/assets/Appearance/pureDark/themes/green/green_ComponentTheme_PureDarkTheme.module.css +3 -0
- package/assets/Appearance/pureDark/themes/orange/orange_ComponentTheme_PureDarkTheme.module.css +3 -0
- package/assets/Appearance/pureDark/themes/red/red_ComponentTheme_PureDarkTheme.module.css +3 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_ComponentTheme_PureDarkTheme.module.css +3 -0
- package/es/Button/__tests__/__snapshots__/Button.spec.js.snap +2 -2
- package/es/Button/css/Button.module.css +60 -6
- package/es/Button/css/cssJSLogic.js +2 -2
- package/es/Card/__tests__/Card.spec.js +48 -0
- package/es/Card/__tests__/CardContent.spec.js +61 -0
- package/es/Card/__tests__/CardHeader.spec.js +33 -0
- package/es/Card/__tests__/__snapshots__/Card.spec.js.snap +125 -0
- package/es/Card/__tests__/__snapshots__/CardContent.spec.js.snap +177 -0
- package/es/Card/__tests__/__snapshots__/CardHeader.spec.js.snap +51 -0
- package/es/ListItem/ListItem.js +10 -3
- package/es/ListItem/ListItemWithAvatar.js +15 -6
- package/es/ListItem/ListItemWithCheckBox.js +13 -6
- package/es/ListItem/ListItemWithIcon.js +14 -5
- package/es/ListItem/ListItemWithRadio.js +13 -6
- package/es/ListItem/__tests__/ListItem.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +19 -0
- package/es/ListItem/__tests__/ListItemWithIcon.spec.js +17 -0
- package/es/ListItem/__tests__/ListItemWithRadio.spec.js +19 -0
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +78 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +140 -46
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +251 -49
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +144 -50
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +252 -52
- package/es/ListItem/props/propTypes.js +15 -5
- package/es/MultiSelect/MultiSelect.js +55 -23
- package/es/MultiSelect/Suggestions.js +2 -1
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +6 -6
- package/es/MultiSelect/props/propTypes.js +2 -3
- package/es/Popup/Popup.js +21 -1041
- package/es/Select/GroupSelect.js +4 -2
- package/es/Select/Select.js +50 -22
- package/es/Select/SelectWithAvatar.js +17 -4
- package/es/Select/SelectWithIcon.js +15 -5
- package/es/Select/props/defaultProps.js +3 -0
- package/es/Select/props/propTypes.js +6 -0
- package/es/Typography/__tests__/Typography.spec.js +225 -0
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1226 -0
- package/es/common/common.module.css +1 -1
- package/es/utils/Common.js +1 -1
- package/es/utils/dropDownUtils.js +13 -4
- package/es/v1/Popup/Popup.js +1 -1
- package/es/v1/Switch/__tests__/Switch.spec.js +41 -6
- package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +176 -5
- package/lib/Button/__tests__/__snapshots__/Button.spec.js.snap +2 -2
- package/lib/Button/css/Button.module.css +60 -6
- package/lib/Button/css/cssJSLogic.js +1 -1
- package/lib/Card/__tests__/Card.spec.js +54 -6
- package/lib/Card/__tests__/CardContent.spec.js +68 -0
- package/lib/Card/__tests__/CardHeader.spec.js +40 -0
- package/lib/Card/__tests__/__snapshots__/Card.spec.js.snap +125 -0
- package/lib/Card/__tests__/__snapshots__/CardContent.spec.js.snap +177 -0
- package/lib/Card/__tests__/__snapshots__/CardHeader.spec.js.snap +51 -0
- package/lib/ListItem/ListItem.js +10 -3
- package/lib/ListItem/ListItemWithAvatar.js +15 -6
- package/lib/ListItem/ListItemWithCheckBox.js +15 -6
- package/lib/ListItem/ListItemWithIcon.js +13 -5
- package/lib/ListItem/ListItemWithRadio.js +15 -6
- package/lib/ListItem/__tests__/ListItem.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +23 -0
- package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +21 -0
- package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +23 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +78 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +140 -46
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +251 -49
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +144 -50
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +252 -52
- package/lib/ListItem/props/propTypes.js +15 -6
- package/lib/MultiSelect/MultiSelect.js +50 -24
- package/lib/MultiSelect/Suggestions.js +2 -1
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +6 -6
- package/lib/MultiSelect/props/propTypes.js +3 -4
- package/lib/Popup/Popup.js +25 -1149
- package/lib/Select/GroupSelect.js +4 -3
- package/lib/Select/Select.js +45 -20
- package/lib/Select/SelectWithAvatar.js +17 -7
- package/lib/Select/SelectWithIcon.js +15 -5
- package/lib/Select/props/defaultProps.js +3 -1
- package/lib/Select/props/propTypes.js +6 -0
- package/lib/Typography/__tests__/Typography.spec.js +232 -0
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1226 -0
- package/lib/common/common.module.css +1 -1
- package/lib/utils/Common.js +1 -1
- package/lib/utils/dropDownUtils.js +17 -4
- package/lib/v1/Popup/Popup.js +1 -1
- package/lib/v1/Switch/__tests__/Switch.spec.js +41 -6
- package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +176 -5
- package/package.json +13 -18
- package/es/Popup/PositionMapping.js +0 -72
- package/es/Popup/Registry.js +0 -36
- package/es/Popup/intersectionObserver.js +0 -49
- package/es/Popup/viewPort.js +0 -373
- package/lib/Popup/PositionMapping.js +0 -81
- package/lib/Popup/Registry.js +0 -46
- package/lib/Popup/intersectionObserver.js +0 -72
- package/lib/Popup/viewPort.js +0 -367
package/es/Select/GroupSelect.js
CHANGED
|
@@ -622,7 +622,8 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
622
622
|
let ariaErrorId = this.getNextAriaId();
|
|
623
623
|
let {
|
|
624
624
|
TextBoxIconProps = {},
|
|
625
|
-
TextBoxProps = {}
|
|
625
|
+
TextBoxProps = {},
|
|
626
|
+
SuggestionsProps
|
|
626
627
|
} = customProps;
|
|
627
628
|
return /*#__PURE__*/React.createElement("div", {
|
|
628
629
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${iconOnHover && (isReadOnly || isDisabled) ? style.iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? style.iconOnHoverStyle : ''}`,
|
|
@@ -791,7 +792,8 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
791
792
|
ariaParentRole: 'listbox',
|
|
792
793
|
role: 'option'
|
|
793
794
|
},
|
|
794
|
-
dataId: `${dataId}_Options
|
|
795
|
+
dataId: `${dataId}_Options`,
|
|
796
|
+
...SuggestionsProps
|
|
795
797
|
}));
|
|
796
798
|
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
797
799
|
options: revampedGroups,
|
package/es/Select/Select.js
CHANGED
|
@@ -107,6 +107,7 @@ export class SelectComponent extends Component {
|
|
|
107
107
|
this.handleExposePopupHandlers = this.handleExposePopupHandlers.bind(this);
|
|
108
108
|
this.handleGetAddNewOptionText = this.handleGetAddNewOptionText.bind(this);
|
|
109
109
|
this.getVirtualizerPublicMethods = this.getVirtualizerPublicMethods.bind(this);
|
|
110
|
+
this.scrollToHighlightedIndex = this.scrollToHighlightedIndex.bind(this);
|
|
110
111
|
this.setSuggestionsVirtualizerContainerRefFunction = this.setSuggestionsVirtualizerContainerRefFunction.bind(this);
|
|
111
112
|
this.valueInputTypeString = '';
|
|
112
113
|
this.valueInputSearchString = '';
|
|
@@ -175,9 +176,43 @@ export class SelectComponent extends Component {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
scrollToHighlightedIndex() {
|
|
180
|
+
let {
|
|
181
|
+
suggestionContainer,
|
|
182
|
+
optionsOrder
|
|
183
|
+
} = this;
|
|
184
|
+
|
|
185
|
+
if (!suggestionContainer) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let {
|
|
190
|
+
hoverIndex
|
|
191
|
+
} = this.state;
|
|
192
|
+
let {
|
|
193
|
+
isVirtualizerEnabled
|
|
194
|
+
} = this.props;
|
|
195
|
+
let hoverId = getIsEmptyValue(optionsOrder[hoverIndex]) ? '' : optionsOrder[hoverIndex];
|
|
196
|
+
let selSuggestion = this[`suggestion_${hoverId}`];
|
|
197
|
+
|
|
198
|
+
if (selSuggestion) {
|
|
199
|
+
scrollTo(suggestionContainer, selSuggestion);
|
|
200
|
+
} else {
|
|
201
|
+
// Hack: Virtualizer not having options order properly all the time, so scrollToIndex method used here.
|
|
202
|
+
if (isVirtualizerEnabled && !!this.virtualizerMethods) {
|
|
203
|
+
this.virtualizerMethods.scrollToIndex(hoverIndex, 'auto', {
|
|
204
|
+
speed: 0,
|
|
205
|
+
duration: 0,
|
|
206
|
+
onComplete: () => {
|
|
207
|
+
scrollTo(suggestionContainer, selSuggestion);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
componentDidUpdate(prevProps) {
|
|
179
215
|
let {
|
|
180
|
-
hoverIndex,
|
|
181
216
|
searchStr,
|
|
182
217
|
selectedValueIndex
|
|
183
218
|
} = this.state;
|
|
@@ -188,31 +223,16 @@ export class SelectComponent extends Component {
|
|
|
188
223
|
needSearch,
|
|
189
224
|
onSearch,
|
|
190
225
|
isPopupOpen,
|
|
191
|
-
isSearchClearOnClose
|
|
192
|
-
isVirtualizerEnabled
|
|
226
|
+
isSearchClearOnClose
|
|
193
227
|
} = this.props;
|
|
194
228
|
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
this.virtualizerMethods.getElementVisiblePercentage(hoverIndex) < 50 && this.virtualizerMethods.scrollToIndex(hoverIndex, position);
|
|
198
|
-
} else {
|
|
199
|
-
let {
|
|
200
|
-
suggestionContainer,
|
|
201
|
-
optionsOrder
|
|
202
|
-
} = this;
|
|
203
|
-
let hoverId = getIsEmptyValue(optionsOrder[hoverIndex]) ? '' : optionsOrder[hoverIndex];
|
|
204
|
-
let selSuggestion = this[`suggestion_${hoverId}`];
|
|
205
|
-
isPopupOpen && scrollTo(suggestionContainer, selSuggestion);
|
|
229
|
+
if (isPopupOpen) {
|
|
230
|
+
this.scrollToHighlightedIndex();
|
|
206
231
|
}
|
|
207
232
|
|
|
208
233
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
209
234
|
if (isPopupOpen) {
|
|
210
235
|
onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
211
|
-
|
|
212
|
-
if (isVirtualizerEnabled && !!this.virtualizerMethods) {
|
|
213
|
-
this.virtualizerMethods.getElementVisiblePercentage(hoverIndex) < 50 && this.virtualizerMethods.scrollToIndex(hoverIndex);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
236
|
setTimeout(() => {
|
|
217
237
|
this.searchInput && this.searchInput.focus({
|
|
218
238
|
preventScroll: true
|
|
@@ -265,7 +285,9 @@ export class SelectComponent extends Component {
|
|
|
265
285
|
valueField,
|
|
266
286
|
textField,
|
|
267
287
|
allowValueFallback,
|
|
268
|
-
customProps = dummyObj
|
|
288
|
+
customProps = dummyObj,
|
|
289
|
+
searchFields,
|
|
290
|
+
secondaryField
|
|
269
291
|
} = props;
|
|
270
292
|
let {
|
|
271
293
|
listItemProps = dummyObj
|
|
@@ -274,6 +296,8 @@ export class SelectComponent extends Component {
|
|
|
274
296
|
options,
|
|
275
297
|
valueField,
|
|
276
298
|
textField,
|
|
299
|
+
secondaryField,
|
|
300
|
+
searchFields,
|
|
277
301
|
listItemProps,
|
|
278
302
|
allowValueFallback
|
|
279
303
|
});
|
|
@@ -443,6 +467,7 @@ export class SelectComponent extends Component {
|
|
|
443
467
|
handleFilterSuggestions() {
|
|
444
468
|
let {
|
|
445
469
|
needLocalSearch,
|
|
470
|
+
searchFields,
|
|
446
471
|
excludeOptions = dummyArray // needSearch
|
|
447
472
|
|
|
448
473
|
} = this.props;
|
|
@@ -462,6 +487,7 @@ export class SelectComponent extends Component {
|
|
|
462
487
|
options,
|
|
463
488
|
selectedOptions: excludeOptions,
|
|
464
489
|
searchStr,
|
|
490
|
+
searchFields,
|
|
465
491
|
needSearch: needLocalSearch
|
|
466
492
|
});
|
|
467
493
|
this.optionsOrder = suggestionIds;
|
|
@@ -713,6 +739,7 @@ export class SelectComponent extends Component {
|
|
|
713
739
|
getTargetRef,
|
|
714
740
|
getContainerRef,
|
|
715
741
|
removeClose,
|
|
742
|
+
isAnimate,
|
|
716
743
|
isPopupOpen,
|
|
717
744
|
isPopupReady,
|
|
718
745
|
animationStyle,
|
|
@@ -907,7 +934,8 @@ export class SelectComponent extends Component {
|
|
|
907
934
|
boxPosition: position || `${defaultDropBoxPosition}`,
|
|
908
935
|
getRef: getContainerRef,
|
|
909
936
|
isActive: isPopupReady,
|
|
910
|
-
isAnimate:
|
|
937
|
+
isAnimate: isAnimate && !isVirtualizerEnabled // Note: Virtualizer gets element height at mount itself which causes issue with options height
|
|
938
|
+
,
|
|
911
939
|
isArrow: false,
|
|
912
940
|
onClick: removeClose,
|
|
913
941
|
needResponsive: needResponsive,
|
|
@@ -41,14 +41,18 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
41
41
|
valueField,
|
|
42
42
|
textField,
|
|
43
43
|
imageField,
|
|
44
|
-
|
|
44
|
+
secondaryField,
|
|
45
|
+
allowValueFallback,
|
|
46
|
+
searchFields
|
|
45
47
|
} = props;
|
|
46
48
|
return this.formatOptions({
|
|
47
49
|
options,
|
|
48
50
|
valueField,
|
|
49
51
|
textField,
|
|
50
52
|
imageField,
|
|
53
|
+
secondaryField,
|
|
51
54
|
optionType: 'avatar',
|
|
55
|
+
searchFields,
|
|
52
56
|
allowValueFallback
|
|
53
57
|
});
|
|
54
58
|
}
|
|
@@ -165,6 +169,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
165
169
|
needEffect,
|
|
166
170
|
isLoading,
|
|
167
171
|
dataSelectorId,
|
|
172
|
+
customProps,
|
|
168
173
|
getTargetRef
|
|
169
174
|
} = this.props;
|
|
170
175
|
i18nKeys = Object.assign({}, i18nKeys, {
|
|
@@ -187,6 +192,11 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
187
192
|
} = this.normalizedFormatOptions[selectedId] || {};
|
|
188
193
|
let setAriaId = this.getNextAriaId();
|
|
189
194
|
let ariaErrorId = this.getNextAriaId();
|
|
195
|
+
let {
|
|
196
|
+
TextBoxProps,
|
|
197
|
+
DropdownSearchTextBoxProps,
|
|
198
|
+
SuggestionsProps
|
|
199
|
+
} = customProps;
|
|
190
200
|
return /*#__PURE__*/React.createElement("div", {
|
|
191
201
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''} ${className ? className : ''}`,
|
|
192
202
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -246,7 +256,8 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
246
256
|
isClickable: isReadOnly || isDisabled ? false : true,
|
|
247
257
|
borderColor: borderColor,
|
|
248
258
|
htmlId: htmlId,
|
|
249
|
-
autoComplete: false
|
|
259
|
+
autoComplete: false,
|
|
260
|
+
...TextBoxProps
|
|
250
261
|
}))), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
251
262
|
query: this.responsiveFunc,
|
|
252
263
|
responsiveId: "Helmet"
|
|
@@ -295,7 +306,8 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
295
306
|
ariaControls: setAriaId,
|
|
296
307
|
ariaDescribedby: ariaErrorId
|
|
297
308
|
},
|
|
298
|
-
autoComplete: false
|
|
309
|
+
autoComplete: false,
|
|
310
|
+
...DropdownSearchTextBoxProps
|
|
299
311
|
}))) : null, /*#__PURE__*/React.createElement(CardContent, {
|
|
300
312
|
shrink: true,
|
|
301
313
|
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
@@ -323,7 +335,8 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
323
335
|
a11y: {
|
|
324
336
|
ariaParentRole: 'listbox',
|
|
325
337
|
role: 'option'
|
|
326
|
-
}
|
|
338
|
+
},
|
|
339
|
+
...SuggestionsProps
|
|
327
340
|
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
328
341
|
isLoading: isFetchingOptions,
|
|
329
342
|
options: options,
|
|
@@ -16,7 +16,8 @@ import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
|
|
|
16
16
|
import Loader from '@zohodesk/svg/lib/Loader/Loader';
|
|
17
17
|
/**** Methods ****/
|
|
18
18
|
|
|
19
|
-
import { scrollTo, findScrollEnd } from "../utils/Common.js";
|
|
19
|
+
import { scrollTo, findScrollEnd, getSearchString } from "../utils/Common.js";
|
|
20
|
+
import { isObjectContainsSearchString } from "../utils/dropDownUtils.js";
|
|
20
21
|
/**** CSS ****/
|
|
21
22
|
|
|
22
23
|
import style from "./Select.module.css";
|
|
@@ -189,11 +190,16 @@ class SelectWithIcon extends Component {
|
|
|
189
190
|
let datas = [];
|
|
190
191
|
let {
|
|
191
192
|
options,
|
|
192
|
-
valueKey
|
|
193
|
+
valueKey,
|
|
194
|
+
searchFields
|
|
193
195
|
} = this.props;
|
|
194
196
|
|
|
195
197
|
if (options.length) {
|
|
196
|
-
|
|
198
|
+
if (!searchFields.includes(valueKey)) {
|
|
199
|
+
searchFields.push(valueKey);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
datas = options.filter(obj => isObjectContainsSearchString(searchFields, getSearchString(searchValue), obj));
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
return datas;
|
|
@@ -328,6 +334,7 @@ class SelectWithIcon extends Component {
|
|
|
328
334
|
targetOffset,
|
|
329
335
|
isRestrictScroll,
|
|
330
336
|
valueKey,
|
|
337
|
+
secondaryValueKey,
|
|
331
338
|
idKey,
|
|
332
339
|
needListBorder,
|
|
333
340
|
needTick,
|
|
@@ -367,7 +374,8 @@ class SelectWithIcon extends Component {
|
|
|
367
374
|
let {
|
|
368
375
|
TextBoxProps = {},
|
|
369
376
|
DropdownSearchTextBoxProps = {},
|
|
370
|
-
TextBoxIconProps = {}
|
|
377
|
+
TextBoxIconProps = {},
|
|
378
|
+
ListItemProps
|
|
371
379
|
} = customProps;
|
|
372
380
|
return /*#__PURE__*/React.createElement("div", {
|
|
373
381
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''}`,
|
|
@@ -510,6 +518,7 @@ class SelectWithIcon extends Component {
|
|
|
510
518
|
return /*#__PURE__*/React.createElement(ListItemWithIcon, {
|
|
511
519
|
key: options[idKey],
|
|
512
520
|
value: options[valueKey],
|
|
521
|
+
secondaryValue: options[secondaryValueKey],
|
|
513
522
|
size: "medium",
|
|
514
523
|
onClick: this.handleChange,
|
|
515
524
|
id: options[idKey],
|
|
@@ -530,7 +539,8 @@ class SelectWithIcon extends Component {
|
|
|
530
539
|
role: 'option',
|
|
531
540
|
ariaSelected: selectedId === options[idKey],
|
|
532
541
|
ariaLabel: options[valueKey]
|
|
533
|
-
}
|
|
542
|
+
},
|
|
543
|
+
...ListItemProps
|
|
534
544
|
});
|
|
535
545
|
})) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
536
546
|
isLoading: isFetchingOptions,
|
|
@@ -28,6 +28,7 @@ export const Select_defaultProps = {
|
|
|
28
28
|
boxSize: 'default',
|
|
29
29
|
needListBorder: false,
|
|
30
30
|
needCloseOnSelect: true,
|
|
31
|
+
isAnimate: true,
|
|
31
32
|
isParentBased: true,
|
|
32
33
|
isSearchClearOnClose: true,
|
|
33
34
|
i18nKeys: {},
|
|
@@ -98,6 +99,7 @@ export const SelectWithAvatar_defaultProps = {
|
|
|
98
99
|
isAbsolutePositioningNeeded: true,
|
|
99
100
|
isRestrictScroll: false,
|
|
100
101
|
i18nKeys: {},
|
|
102
|
+
customProps: {},
|
|
101
103
|
needEffect: true,
|
|
102
104
|
isLoading: false
|
|
103
105
|
};
|
|
@@ -116,6 +118,7 @@ export const SelectWithIcon_defaultProps = {
|
|
|
116
118
|
needTick: true,
|
|
117
119
|
searchBoxSize: 'small',
|
|
118
120
|
size: 'medium',
|
|
121
|
+
searchFields: [],
|
|
119
122
|
textBoxSize: 'medium',
|
|
120
123
|
textBoxVariant: 'default',
|
|
121
124
|
dataId: 'selectWithIcon',
|
|
@@ -28,6 +28,7 @@ export const Select_propTypes = {
|
|
|
28
28
|
noMoreText: PropTypes.string,
|
|
29
29
|
searchEmptyText: PropTypes.string
|
|
30
30
|
}),
|
|
31
|
+
isAnimate: PropTypes.bool,
|
|
31
32
|
isDefaultSelectValue: PropTypes.bool,
|
|
32
33
|
isDisabled: PropTypes.bool,
|
|
33
34
|
isNextOptions: PropTypes.bool,
|
|
@@ -64,6 +65,8 @@ export const Select_propTypes = {
|
|
|
64
65
|
searchBoxSize: PropTypes.string,
|
|
65
66
|
searchDebounceTime: PropTypes.number,
|
|
66
67
|
searchEmptyMessage: PropTypes.string,
|
|
68
|
+
searchFields: PropTypes.arrayOf(PropTypes.string),
|
|
69
|
+
secondaryField: PropTypes.string,
|
|
67
70
|
selectedValue: PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.string, PropTypes.number]), PropTypes.shape({
|
|
68
71
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
69
72
|
text: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -282,6 +285,7 @@ export const SelectWithIcon_propTypes = {
|
|
|
282
285
|
removeClose: PropTypes.func,
|
|
283
286
|
searchBoxPlaceHolder: PropTypes.string,
|
|
284
287
|
searchEmptyMessage: PropTypes.string,
|
|
288
|
+
secondaryValueKey: PropTypes.string,
|
|
285
289
|
selectedId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
286
290
|
selectedValue: PropTypes.string,
|
|
287
291
|
size: PropTypes.oneOf(['small', 'medium']),
|
|
@@ -296,6 +300,7 @@ export const SelectWithIcon_propTypes = {
|
|
|
296
300
|
className: PropTypes.string,
|
|
297
301
|
needBorder: PropTypes.bool,
|
|
298
302
|
searchBoxSize: PropTypes.string,
|
|
303
|
+
searchFields: PropTypes.arrayOf(PropTypes.string),
|
|
299
304
|
needResponsive: PropTypes.bool,
|
|
300
305
|
boxSize: PropTypes.string,
|
|
301
306
|
emptyMessage: PropTypes.string,
|
|
@@ -306,6 +311,7 @@ export const SelectWithIcon_propTypes = {
|
|
|
306
311
|
customProps: PropTypes.shape({
|
|
307
312
|
TextBoxProps: PropTypes.object,
|
|
308
313
|
DropdownSearchTextBoxProps: PropTypes.object,
|
|
314
|
+
SuggestionsProps: PropTypes.object,
|
|
309
315
|
TextBoxIconProps: PropTypes.object
|
|
310
316
|
})
|
|
311
317
|
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import Typography from "../Typography";
|
|
4
|
+
describe('Typography', () => {
|
|
5
|
+
const ui_size = ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '24', '25', '26', '28', '29', '30', '32', '34', '35', '36', '40', '50', 'inherit'];
|
|
6
|
+
const ui_lineClamp = ['1', '2', '3', '4', '5'];
|
|
7
|
+
const ui_lineHeight = ['0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '2', 'normal', 'initial', 'inherit'];
|
|
8
|
+
const ui_display = ['block', 'inlineBlock', 'inline', 'initial'];
|
|
9
|
+
const ui_weight = ['regular', 'light', 'semibold', 'bold'];
|
|
10
|
+
const ui_typeFace = ['normal', 'italic'];
|
|
11
|
+
const ui_textAlign = ['left', 'center', 'right', 'justify'];
|
|
12
|
+
const ui_letterSpacing = ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '2', 'inherit'];
|
|
13
|
+
const ui_transform = ['default', 'upper', 'lower', 'capital'];
|
|
14
|
+
const ui_decoration = ['default', 'underline', 'strike', 'overline'];
|
|
15
|
+
const ui_wordBreak = ['breakAll', 'keepAll', 'breakWord'];
|
|
16
|
+
const ui_wordWrap = ['normal', 'break'];
|
|
17
|
+
const ui_whiteSpace = ['normal', 'noWrap', 'pre', 'preLine', 'preWrap'];
|
|
18
|
+
test('rendering the defult props', () => {
|
|
19
|
+
const {
|
|
20
|
+
asFragment
|
|
21
|
+
} = render( /*#__PURE__*/React.createElement(Typography, null));
|
|
22
|
+
expect(asFragment()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
test('rendering the children ', () => {
|
|
25
|
+
const {
|
|
26
|
+
asFragment
|
|
27
|
+
} = render( /*#__PURE__*/React.createElement(Typography, null, "Test"));
|
|
28
|
+
expect(asFragment()).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
test('rendering ui_tagName as h2', () => {
|
|
31
|
+
const {
|
|
32
|
+
asFragment
|
|
33
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
34
|
+
$ui_tagName: "h2"
|
|
35
|
+
}, "Heading 2 Test"));
|
|
36
|
+
expect(asFragment()).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
test('rendering i18n_dataTitle', () => {
|
|
39
|
+
const {
|
|
40
|
+
asFragment
|
|
41
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
42
|
+
$i18n_dataTitle: "typoDataTitle"
|
|
43
|
+
}, "Heading 2 Test"));
|
|
44
|
+
expect(asFragment()).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
test('rendering testId', () => {
|
|
47
|
+
const {
|
|
48
|
+
asFragment
|
|
49
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
50
|
+
testId: "TypoTestId"
|
|
51
|
+
}, "Heading 2 Test"));
|
|
52
|
+
expect(asFragment()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
test('rendering customId', () => {
|
|
55
|
+
const {
|
|
56
|
+
asFragment
|
|
57
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
58
|
+
customId: "TypoCustomId"
|
|
59
|
+
}, "Heading 2 Test"));
|
|
60
|
+
expect(asFragment()).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
test('rendering tagAttributes_text', () => {
|
|
63
|
+
const {
|
|
64
|
+
asFragment
|
|
65
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
66
|
+
$tagAttributes_text: {
|
|
67
|
+
id: "TypoCustomId"
|
|
68
|
+
}
|
|
69
|
+
}, "Heading 2 Test"));
|
|
70
|
+
expect(asFragment()).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
test('rendering a11yAttributes_text', () => {
|
|
73
|
+
const {
|
|
74
|
+
asFragment
|
|
75
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
76
|
+
$a11yAttributes_text: {
|
|
77
|
+
'aria-haspopup': 'true',
|
|
78
|
+
'aria-expanded': true,
|
|
79
|
+
'aria-controls': 'uniqueId'
|
|
80
|
+
}
|
|
81
|
+
}, "Heading 2 Test"));
|
|
82
|
+
expect(asFragment()).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
test('rendering flag_reset', () => {
|
|
85
|
+
const {
|
|
86
|
+
asFragment
|
|
87
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
88
|
+
$flag_reset: true
|
|
89
|
+
}, "Heading 2 Test"));
|
|
90
|
+
expect(asFragment()).toMatchSnapshot();
|
|
91
|
+
});
|
|
92
|
+
test('rendering flag_dotted', () => {
|
|
93
|
+
const {
|
|
94
|
+
asFragment
|
|
95
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
96
|
+
$flag_dotted: true
|
|
97
|
+
}, "Heading 2 Test"));
|
|
98
|
+
expect(asFragment()).toMatchSnapshot();
|
|
99
|
+
});
|
|
100
|
+
test.each(ui_size)('Should render ui_size - %s', ui_size => {
|
|
101
|
+
const {
|
|
102
|
+
asFragment
|
|
103
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
104
|
+
isScrollAttribute: true,
|
|
105
|
+
$ui_size: ui_size
|
|
106
|
+
}, "Heading"));
|
|
107
|
+
expect(asFragment()).toMatchSnapshot();
|
|
108
|
+
});
|
|
109
|
+
test.each(ui_lineClamp)('Should render ui_lineClamp - %s', ui_lineClamp => {
|
|
110
|
+
const {
|
|
111
|
+
asFragment
|
|
112
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
113
|
+
isScrollAttribute: true,
|
|
114
|
+
$ui_lineClamp: ui_lineClamp
|
|
115
|
+
}, "Heading"));
|
|
116
|
+
expect(asFragment()).toMatchSnapshot();
|
|
117
|
+
});
|
|
118
|
+
test.each(ui_lineHeight)('Should render ui_lineHeight - %s', ui_lineHeight => {
|
|
119
|
+
const {
|
|
120
|
+
asFragment
|
|
121
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
122
|
+
isScrollAttribute: true,
|
|
123
|
+
$ui_lineHeight: ui_lineHeight
|
|
124
|
+
}, "Heading"));
|
|
125
|
+
expect(asFragment()).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
test.each(ui_display)('Should render ui_display - %s', ui_display => {
|
|
128
|
+
const {
|
|
129
|
+
asFragment
|
|
130
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
131
|
+
isScrollAttribute: true,
|
|
132
|
+
$ui_display: ui_display
|
|
133
|
+
}, "Heading"));
|
|
134
|
+
expect(asFragment()).toMatchSnapshot();
|
|
135
|
+
});
|
|
136
|
+
test.each(ui_weight)('Should render ui_weight - %s', ui_weight => {
|
|
137
|
+
const {
|
|
138
|
+
asFragment
|
|
139
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
140
|
+
isScrollAttribute: true,
|
|
141
|
+
$ui_weight: ui_weight
|
|
142
|
+
}, "Heading"));
|
|
143
|
+
expect(asFragment()).toMatchSnapshot();
|
|
144
|
+
});
|
|
145
|
+
test.each(ui_typeFace)('Should render ui_typeFace - %s', ui_typeFace => {
|
|
146
|
+
const {
|
|
147
|
+
asFragment
|
|
148
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
149
|
+
isScrollAttribute: true,
|
|
150
|
+
$ui_typeFace: ui_typeFace
|
|
151
|
+
}, "Heading"));
|
|
152
|
+
expect(asFragment()).toMatchSnapshot();
|
|
153
|
+
});
|
|
154
|
+
test.each(ui_textAlign)('Should render ui_textAlign - %s', ui_textAlign => {
|
|
155
|
+
const {
|
|
156
|
+
asFragment
|
|
157
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
158
|
+
isScrollAttribute: true,
|
|
159
|
+
$ui_textAlign: ui_textAlign
|
|
160
|
+
}, "Heading"));
|
|
161
|
+
expect(asFragment()).toMatchSnapshot();
|
|
162
|
+
});
|
|
163
|
+
test.each(ui_letterSpacing)('Should render ui_letterSpacing - %s', ui_letterSpacing => {
|
|
164
|
+
const {
|
|
165
|
+
asFragment
|
|
166
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
167
|
+
isScrollAttribute: true,
|
|
168
|
+
$ui_letterSpacing: ui_letterSpacing
|
|
169
|
+
}, "Heading"));
|
|
170
|
+
expect(asFragment()).toMatchSnapshot();
|
|
171
|
+
});
|
|
172
|
+
test.each(ui_transform)('Should render ui_transform - %s', ui_transform => {
|
|
173
|
+
const {
|
|
174
|
+
asFragment
|
|
175
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
176
|
+
isScrollAttribute: true,
|
|
177
|
+
$ui_transform: ui_transform
|
|
178
|
+
}, "Heading"));
|
|
179
|
+
expect(asFragment()).toMatchSnapshot();
|
|
180
|
+
});
|
|
181
|
+
test.each(ui_decoration)('Should render ui_decoration - %s', ui_decoration => {
|
|
182
|
+
const {
|
|
183
|
+
asFragment
|
|
184
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
185
|
+
isScrollAttribute: true,
|
|
186
|
+
$ui_decoration: ui_decoration
|
|
187
|
+
}, "Heading"));
|
|
188
|
+
expect(asFragment()).toMatchSnapshot();
|
|
189
|
+
});
|
|
190
|
+
test('rendering ui_className', () => {
|
|
191
|
+
const {
|
|
192
|
+
asFragment
|
|
193
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
194
|
+
$ui_className: "custom-class"
|
|
195
|
+
}, "Heading 2 Test"));
|
|
196
|
+
expect(asFragment()).toMatchSnapshot();
|
|
197
|
+
});
|
|
198
|
+
test.each(ui_wordBreak)('Should render ui_wordBreak - %s', ui_wordBreak => {
|
|
199
|
+
const {
|
|
200
|
+
asFragment
|
|
201
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
202
|
+
isScrollAttribute: true,
|
|
203
|
+
$ui_wordBreak: ui_wordBreak
|
|
204
|
+
}, "Heading"));
|
|
205
|
+
expect(asFragment()).toMatchSnapshot();
|
|
206
|
+
});
|
|
207
|
+
test.each(ui_wordWrap)('Should render ui_wordWrap - %s', ui_wordWrap => {
|
|
208
|
+
const {
|
|
209
|
+
asFragment
|
|
210
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
211
|
+
isScrollAttribute: true,
|
|
212
|
+
$ui_wordWrap: ui_wordWrap
|
|
213
|
+
}, "Heading"));
|
|
214
|
+
expect(asFragment()).toMatchSnapshot();
|
|
215
|
+
});
|
|
216
|
+
test.each(ui_whiteSpace)('Should render ui_whiteSpace - %s', ui_whiteSpace => {
|
|
217
|
+
const {
|
|
218
|
+
asFragment
|
|
219
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
220
|
+
isScrollAttribute: true,
|
|
221
|
+
$ui_whiteSpace: ui_whiteSpace
|
|
222
|
+
}, "Heading"));
|
|
223
|
+
expect(asFragment()).toMatchSnapshot();
|
|
224
|
+
});
|
|
225
|
+
});
|