@zohodesk/components 1.2.39 → 1.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cli/propValidation_report.html +1 -1
- package/README.md +9 -0
- package/es/Radio/Radio.js +3 -2
- package/es/Radio/props/propTypes.js +2 -1
- package/es/Tab/Tabs.js +119 -21
- package/es/Tab/Tabs.module.css +32 -2
- package/es/Tab/props/defaultProps.js +4 -1
- package/es/Tab/props/propTypes.js +6 -1
- package/es/v1/Card/props/propTypes.js +1 -1
- package/es/v1/DateTime/props/propTypes.js +1 -1
- package/es/v1/ResponsiveDropBox/props/propTypes.js +1 -1
- package/es/v1/Ribbon/props/propTypes.js +1 -1
- package/es/v1/Tab/Tabs.js +99 -16
- package/es/v1/Tab/props/defaultProps.js +4 -1
- package/es/v1/Tab/props/propTypes.js +6 -1
- package/es/v1/Tab/v1Tabs.module.css +32 -2
- package/lib/Radio/Radio.js +3 -2
- package/lib/Radio/props/propTypes.js +2 -1
- package/lib/Tab/Tabs.js +167 -74
- package/lib/Tab/Tabs.module.css +32 -2
- package/lib/Tab/props/defaultProps.js +4 -1
- package/lib/Tab/props/propTypes.js +6 -1
- package/lib/v1/Card/props/propTypes.js +1 -1
- package/lib/v1/DateTime/props/propTypes.js +1 -1
- package/lib/v1/ResponsiveDropBox/props/propTypes.js +1 -1
- package/lib/v1/Ribbon/props/propTypes.js +1 -1
- package/lib/v1/Tab/Tabs.js +107 -23
- package/lib/v1/Tab/props/defaultProps.js +4 -1
- package/lib/v1/Tab/props/propTypes.js +6 -1
- package/lib/v1/Tab/v1Tabs.module.css +32 -2
- package/package.json +12 -11
- package/result.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,15 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
# 1.2.41
|
|
36
|
+
|
|
37
|
+
- **Tabs**
|
|
38
|
+
- Search implemented in more popup (v0& v1)
|
|
39
|
+
|
|
40
|
+
# 1.2.40
|
|
41
|
+
|
|
42
|
+
- **Radio** - renderRightPlaceholderNode prop supported
|
|
43
|
+
|
|
35
44
|
# 1.2.39
|
|
36
45
|
|
|
37
46
|
- **LibraryContext** - coloredTagVariant, hasTagColorInheritedToText properties added
|
package/es/Radio/Radio.js
CHANGED
|
@@ -49,7 +49,8 @@ export default class Radio extends React.Component {
|
|
|
49
49
|
customClass,
|
|
50
50
|
customProps,
|
|
51
51
|
children,
|
|
52
|
-
a11y
|
|
52
|
+
a11y,
|
|
53
|
+
renderRightPlaceholderNode
|
|
53
54
|
} = this.props;
|
|
54
55
|
let {
|
|
55
56
|
customRadioWrap = '',
|
|
@@ -127,7 +128,7 @@ export default class Radio extends React.Component {
|
|
|
127
128
|
customClass: `${checked && active ? `${style[`${palette}checkedActive`]}` : ''}
|
|
128
129
|
${style[`${palette}Label`]} ${accessMode} ${customLabel}`,
|
|
129
130
|
...LabelProps
|
|
130
|
-
})), children);
|
|
131
|
+
})), children, renderRightPlaceholderNode ? renderRightPlaceholderNode : null);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
}
|
package/es/Tab/Tabs.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
}]
|
|
9
9
|
*/
|
|
10
10
|
import React from 'react';
|
|
11
|
+
import EmptySearch from '@zohodesk/svg/lib/emptystate/version3/EmptySearch';
|
|
11
12
|
import Tab from './Tab';
|
|
12
13
|
import { Tabs_defaultProps } from './props/defaultProps';
|
|
13
14
|
import { Tabs_propTypes } from './props/propTypes';
|
|
@@ -18,6 +19,7 @@ import ListItem from '../ListItem/ListItem';
|
|
|
18
19
|
import { Icon } from '@zohodesk/icons';
|
|
19
20
|
import tabsStyle from './Tabs.module.css';
|
|
20
21
|
import Popup from '../Popup/Popup';
|
|
22
|
+
import TextBoxIcon from '../TextBoxIcon/TextBoxIcon';
|
|
21
23
|
import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
22
24
|
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
23
25
|
import btnstyle from '../semantic/Button/semanticButton.module.css';
|
|
@@ -30,9 +32,10 @@ class Tabs extends React.Component {
|
|
|
30
32
|
tabDimensions: {},
|
|
31
33
|
highlightInitialDimension: null,
|
|
32
34
|
renderVirtualTabs: true,
|
|
33
|
-
tabKeys: []
|
|
35
|
+
tabKeys: [],
|
|
36
|
+
searchValue: ''
|
|
34
37
|
};
|
|
35
|
-
bind.apply(this, ['moreTabSelect', 'onResize', 'onTabResize', 'getHighlightRef', 'getTabsRef', 'getTabRef', 'getHighlightDim', 'onSizeChange', 'onScroll', 'togglePopup', 'setMaxDim']);
|
|
38
|
+
bind.apply(this, ['moreTabSelect', 'onResize', 'onTabResize', 'getHighlightRef', 'getTabsRef', 'getTabRef', 'getHighlightDim', 'onSizeChange', 'onScroll', 'togglePopup', 'setMaxDim', 'handleChange', 'handleSearchValueClear', 'getMoreList', 'renderEmptyState']);
|
|
36
39
|
this.tabsObserver = new ResizeObserver(this.onResize);
|
|
37
40
|
this.tabObserver = {};
|
|
38
41
|
}
|
|
@@ -130,12 +133,14 @@ class Tabs extends React.Component {
|
|
|
130
133
|
let {
|
|
131
134
|
children,
|
|
132
135
|
selectedTab,
|
|
133
|
-
childType
|
|
136
|
+
childType,
|
|
137
|
+
isPopupOpen
|
|
134
138
|
} = this.props;
|
|
135
139
|
let {
|
|
136
140
|
tabDimensions,
|
|
137
141
|
totalDimension,
|
|
138
|
-
tabKeys
|
|
142
|
+
tabKeys,
|
|
143
|
+
searchValue
|
|
139
144
|
} = this.state;
|
|
140
145
|
|
|
141
146
|
if (prevProps.children && children) {
|
|
@@ -169,6 +174,10 @@ class Tabs extends React.Component {
|
|
|
169
174
|
if (prevProps.selectedTab !== selectedTab || newTabKeys.length === 1) {
|
|
170
175
|
this.moveHighlight();
|
|
171
176
|
}
|
|
177
|
+
|
|
178
|
+
if (prevProps.isPopupOpen != isPopupOpen && searchValue.length) {
|
|
179
|
+
this.handleSearchValueClear();
|
|
180
|
+
}
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
183
|
|
|
@@ -363,7 +372,8 @@ class Tabs extends React.Component {
|
|
|
363
372
|
|
|
364
373
|
moreTabSelect(tab, value, index, e) {
|
|
365
374
|
let {
|
|
366
|
-
onSelect
|
|
375
|
+
onSelect,
|
|
376
|
+
closePopupOnly
|
|
367
377
|
} = this.props;
|
|
368
378
|
|
|
369
379
|
if (e && e.target && e.target.parentElement.tagName === 'A' && (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)) {
|
|
@@ -373,6 +383,7 @@ class Tabs extends React.Component {
|
|
|
373
383
|
|
|
374
384
|
e.preventDefault();
|
|
375
385
|
onSelect(tab);
|
|
386
|
+
closePopupOnly();
|
|
376
387
|
}
|
|
377
388
|
|
|
378
389
|
onScroll(e) {
|
|
@@ -407,6 +418,70 @@ class Tabs extends React.Component {
|
|
|
407
418
|
};
|
|
408
419
|
}
|
|
409
420
|
|
|
421
|
+
handleChange(value, e) {
|
|
422
|
+
this.setState({
|
|
423
|
+
searchValue: value
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
handleSearchValueClear(e) {
|
|
428
|
+
this.setState({
|
|
429
|
+
searchValue: ''
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
getMoreList(_ref2) {
|
|
434
|
+
let {
|
|
435
|
+
moreTabs
|
|
436
|
+
} = _ref2;
|
|
437
|
+
const validElements = [];
|
|
438
|
+
React.Children.map(moreTabs, child => {
|
|
439
|
+
const isValidElement = /*#__PURE__*/React.isValidElement(child);
|
|
440
|
+
|
|
441
|
+
if (isValidElement) {
|
|
442
|
+
validElements.push(child.props);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
return validElements;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
handleFilterSuggestions(_ref3) {
|
|
449
|
+
let {
|
|
450
|
+
moreTabs
|
|
451
|
+
} = _ref3;
|
|
452
|
+
const {
|
|
453
|
+
showTitleInMoreOptions
|
|
454
|
+
} = this.props;
|
|
455
|
+
const {
|
|
456
|
+
searchValue
|
|
457
|
+
} = this.state;
|
|
458
|
+
const options = this.getMoreList({
|
|
459
|
+
moreTabs
|
|
460
|
+
});
|
|
461
|
+
const filteredOptions = options.filter(list => {
|
|
462
|
+
const {
|
|
463
|
+
text,
|
|
464
|
+
title
|
|
465
|
+
} = list;
|
|
466
|
+
const value = text ? text : showTitleInMoreOptions ? title : '';
|
|
467
|
+
return value.toLowerCase().includes(searchValue.toLowerCase());
|
|
468
|
+
});
|
|
469
|
+
return filteredOptions;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
renderEmptyState() {
|
|
473
|
+
const {
|
|
474
|
+
searchErrorText
|
|
475
|
+
} = this.props;
|
|
476
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
477
|
+
className: tabsStyle.emptyStateContainer
|
|
478
|
+
}, /*#__PURE__*/React.createElement(EmptySearch, {
|
|
479
|
+
size: "small"
|
|
480
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
481
|
+
className: tabsStyle.emptyStateTitle
|
|
482
|
+
}, searchErrorText));
|
|
483
|
+
}
|
|
484
|
+
|
|
410
485
|
renderTabs(mainTabs, moreTabs, isVirtual) {
|
|
411
486
|
let {
|
|
412
487
|
selectedTab,
|
|
@@ -434,14 +509,25 @@ class Tabs extends React.Component {
|
|
|
434
509
|
customProps,
|
|
435
510
|
getCustomDropBoxHeaderPlaceHolder,
|
|
436
511
|
dataSelectorId,
|
|
437
|
-
dataId
|
|
512
|
+
dataId,
|
|
513
|
+
placeHolderText,
|
|
514
|
+
searchBoxSize,
|
|
515
|
+
removeClose
|
|
438
516
|
} = this.props;
|
|
517
|
+
const {
|
|
518
|
+
searchValue
|
|
519
|
+
} = this.state;
|
|
439
520
|
let {
|
|
440
521
|
DropBoxProps = {},
|
|
441
522
|
ListItemProps = {},
|
|
442
|
-
MoreButtonProps = {}
|
|
523
|
+
MoreButtonProps = {},
|
|
524
|
+
TextBoxIconProps = {}
|
|
443
525
|
} = customProps;
|
|
444
526
|
let popupClass = align === 'vertical' ? tabsStyle[position] ? tabsStyle[position] : '' : '';
|
|
527
|
+
const moreTabsListItems = this.handleFilterSuggestions({
|
|
528
|
+
moreTabs
|
|
529
|
+
});
|
|
530
|
+
const hasSearch = moreTabs.length > 4;
|
|
445
531
|
return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(mainTabs, child => {
|
|
446
532
|
if (!child) {
|
|
447
533
|
return null;
|
|
@@ -491,10 +577,10 @@ class Tabs extends React.Component {
|
|
|
491
577
|
})), isPopupOpen && /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
492
578
|
query: this.responsiveFunc,
|
|
493
579
|
responsiveId: "Helmet"
|
|
494
|
-
},
|
|
580
|
+
}, _ref4 => {
|
|
495
581
|
let {
|
|
496
582
|
tabletMode
|
|
497
|
-
} =
|
|
583
|
+
} = _ref4;
|
|
498
584
|
return /*#__PURE__*/React.createElement(ResponsiveDropBox, {
|
|
499
585
|
isActive: isPopupReady,
|
|
500
586
|
isAnimate: true,
|
|
@@ -509,20 +595,32 @@ class Tabs extends React.Component {
|
|
|
509
595
|
...DropBoxProps,
|
|
510
596
|
isResponsivePadding: true,
|
|
511
597
|
needFocusScope: true,
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
598
|
+
dataId: `${dataId}_dropbox`,
|
|
599
|
+
onClick: removeClose,
|
|
600
|
+
onClose: this.togglePopup
|
|
601
|
+
}, getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(this.props), hasSearch ? /*#__PURE__*/React.createElement(Box, {
|
|
602
|
+
className: tabsStyle.search
|
|
603
|
+
}, /*#__PURE__*/React.createElement(TextBoxIcon, {
|
|
604
|
+
placeHolder: placeHolderText,
|
|
605
|
+
onChange: this.handleChange,
|
|
606
|
+
value: searchValue,
|
|
607
|
+
onClear: this.handleSearchValueClear,
|
|
608
|
+
size: searchBoxSize,
|
|
609
|
+
customProps: {
|
|
610
|
+
TextBoxProps: {
|
|
611
|
+
'data-a11y-autofocus': true
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
dataId: `${dataId}_search`,
|
|
615
|
+
...TextBoxIconProps
|
|
616
|
+
})) : null, /*#__PURE__*/React.createElement(Box, {
|
|
515
617
|
flexible: true,
|
|
516
618
|
shrink: true,
|
|
517
619
|
scroll: "vertical",
|
|
518
|
-
className: `${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
620
|
+
className: `${tabsStyle.listWrapper} ${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
519
621
|
onScroll: this.onScroll,
|
|
520
622
|
dataId: `${dataId}_Tabs`
|
|
521
|
-
},
|
|
522
|
-
if (!child) {
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
|
|
623
|
+
}, moreTabsListItems.length ? moreTabsListItems.map(data => {
|
|
526
624
|
let {
|
|
527
625
|
text,
|
|
528
626
|
id,
|
|
@@ -531,9 +629,9 @@ class Tabs extends React.Component {
|
|
|
531
629
|
href,
|
|
532
630
|
children,
|
|
533
631
|
dataId
|
|
534
|
-
} =
|
|
632
|
+
} = data;
|
|
535
633
|
const value = text ? text : showTitleInMoreOptions ? title : null;
|
|
536
|
-
return /*#__PURE__*/React.
|
|
634
|
+
return /*#__PURE__*/React.createElement(ListItem, {
|
|
537
635
|
key: id,
|
|
538
636
|
value: value,
|
|
539
637
|
onClick: this.moreTabSelect,
|
|
@@ -549,7 +647,7 @@ class Tabs extends React.Component {
|
|
|
549
647
|
dataId: `${dataId}_Tab`,
|
|
550
648
|
...ListItemProps
|
|
551
649
|
}, !showTitleInMoreOptions ? children : null);
|
|
552
|
-
})));
|
|
650
|
+
}) : this.renderEmptyState()));
|
|
553
651
|
})) : null);
|
|
554
652
|
}
|
|
555
653
|
|
package/es/Tab/Tabs.module.css
CHANGED
|
@@ -123,15 +123,45 @@
|
|
|
123
123
|
.bottomRightToLeft,
|
|
124
124
|
.topRightToLeft,
|
|
125
125
|
.bottomCenterToLeft {
|
|
126
|
-
right: calc(var(--tab_position_gap) * -1);
|
|
126
|
+
right: calc(var(--tab_position_gap) * -1);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.bottomLeftToRight,
|
|
130
130
|
.topLeftToRight,
|
|
131
131
|
.bottomCenterToRight {
|
|
132
|
-
left: calc(var(--tab_position_gap) * -1);
|
|
132
|
+
left: calc(var(--tab_position_gap) * -1);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
.hidden {
|
|
136
136
|
visibility: hidden;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.search {
|
|
140
|
+
padding: 0 var(--zd_size20) 0 ;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.emptyStateContainer {
|
|
144
|
+
padding-bottom: var(--zd_size15) ;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.emptyStateTitle {
|
|
148
|
+
font-family: var(--zd_semibold);
|
|
149
|
+
word-wrap: break-word;
|
|
150
|
+
font-size: var(--zd_font_size16) ;
|
|
151
|
+
max-width: var(--zd_size430) ;
|
|
152
|
+
text-align: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[dir=ltr] .emptyStateTitle {
|
|
156
|
+
margin-left: auto ;
|
|
157
|
+
margin-right: auto ;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[dir=rtl] .emptyStateTitle {
|
|
161
|
+
margin-right: auto ;
|
|
162
|
+
margin-left: auto ;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.listWrapper {
|
|
166
|
+
padding-top: var(--zd_size10) ;
|
|
137
167
|
}
|
|
@@ -30,7 +30,10 @@ export const Tabs_defaultProps = {
|
|
|
30
30
|
iconSize: '7',
|
|
31
31
|
containerClass: '',
|
|
32
32
|
customProps: {},
|
|
33
|
-
dataSelectorId: 'tabs'
|
|
33
|
+
dataSelectorId: 'tabs',
|
|
34
|
+
searchBoxSize: 'small',
|
|
35
|
+
searchErrorText: 'No results',
|
|
36
|
+
placeHolderText: 'Search'
|
|
34
37
|
};
|
|
35
38
|
export const TabWrapper_defaultProps = {
|
|
36
39
|
hookToDisableInternalState: false,
|
|
@@ -84,12 +84,17 @@ export const Tabs_propTypes = {
|
|
|
84
84
|
getTargetRef: PropTypes.func,
|
|
85
85
|
containerClass: PropTypes.string,
|
|
86
86
|
customProps: PropTypes.shape({
|
|
87
|
+
TextBoxIconProps: PropTypes.object,
|
|
87
88
|
DropBoxProps: PropTypes.object,
|
|
88
89
|
ListItemProps: PropTypes.object,
|
|
89
90
|
MoreButtonProps: PropTypes.object
|
|
90
91
|
}),
|
|
91
92
|
getCustomDropBoxHeaderPlaceHolder: PropTypes.func,
|
|
92
|
-
dataSelectorId: PropTypes.string
|
|
93
|
+
dataSelectorId: PropTypes.string,
|
|
94
|
+
placeHolderText: PropTypes.string,
|
|
95
|
+
searchBoxSize: PropTypes.string,
|
|
96
|
+
searchErrorText: PropTypes.string,
|
|
97
|
+
closePopupOnly: PropTypes.func
|
|
93
98
|
};
|
|
94
99
|
export const TabWrapper_propTypes = {
|
|
95
100
|
align: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
@@ -84,7 +84,7 @@ export const DateTime_propTypes = {
|
|
|
84
84
|
export const DateWidget_propTypes = {
|
|
85
85
|
borderColor: PropTypes.oneOf(['transparent', 'default']),
|
|
86
86
|
cantEditOnPopupOpen: PropTypes.bool,
|
|
87
|
-
children: PropTypes.
|
|
87
|
+
children: PropTypes.node,
|
|
88
88
|
className: PropTypes.string,
|
|
89
89
|
closePopupOnly: PropTypes.func,
|
|
90
90
|
dataId: PropTypes.string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import { DropBoxPropTypes } from './../../DropBox/props/propTypes';
|
|
3
3
|
export const propTypes = { ...DropBoxPropTypes,
|
|
4
|
-
children: PropTypes.
|
|
4
|
+
children: PropTypes.node,
|
|
5
5
|
customClass: PropTypes.object,
|
|
6
6
|
isResponsivePadding: PropTypes.bool,
|
|
7
7
|
alignBox: PropTypes.oneOf(['column', 'row'])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
export const propTypes = {
|
|
3
|
-
children: PropTypes.
|
|
3
|
+
children: PropTypes.node,
|
|
4
4
|
dataId: PropTypes.string,
|
|
5
5
|
palette: PropTypes.oneOf(['default', 'danger', 'primary', 'secondary', 'info', 'dark']),
|
|
6
6
|
size: PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']),
|
package/es/v1/Tab/Tabs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
import useEffectCallOnlyAfterState from '@zohodesk/hooks/es/utils/useEffectCallOnlyAfterState';
|
|
3
|
+
import TextBoxIcon from '../TextBoxIcon/TextBoxIcon';
|
|
4
|
+
import EmptySearch from '@zohodesk/svg/lib/emptystate/version3/EmptySearch';
|
|
3
5
|
import Tab from './Tab';
|
|
4
6
|
import { Tabs_defaultProps } from './props/defaultProps';
|
|
5
7
|
import { Tabs_propTypes } from './props/propTypes';
|
|
@@ -20,6 +22,7 @@ const Tabs = props => {
|
|
|
20
22
|
const highlightInitialDimension = useRef(null);
|
|
21
23
|
const [renderVirtualTabs, setRenderVirtualTabs] = useState(true);
|
|
22
24
|
const [tabKeys, setTabKeys] = useState([]);
|
|
25
|
+
const [searchValue, setSearchValue] = useState('');
|
|
23
26
|
const tabsObserver = useRef(new ResizeObserver(onResize));
|
|
24
27
|
const tabObserver = useRef({});
|
|
25
28
|
const highlight = useRef(null);
|
|
@@ -49,9 +52,66 @@ const Tabs = props => {
|
|
|
49
52
|
childType,
|
|
50
53
|
containerClass,
|
|
51
54
|
dataSelectorId,
|
|
52
|
-
selectedTab
|
|
55
|
+
selectedTab,
|
|
56
|
+
showTitleInMoreOptions,
|
|
57
|
+
searchErrorText,
|
|
58
|
+
placeHolderText,
|
|
59
|
+
searchBoxSize,
|
|
60
|
+
isPopupOpen,
|
|
61
|
+
closePopupOnly
|
|
53
62
|
} = props;
|
|
54
63
|
|
|
64
|
+
function handleChange(value, e) {
|
|
65
|
+
setSearchValue(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function handleSearchValueClear(e) {
|
|
69
|
+
setSearchValue('');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getMoreList(_ref) {
|
|
73
|
+
let {
|
|
74
|
+
moreTabs
|
|
75
|
+
} = _ref;
|
|
76
|
+
const validElements = [];
|
|
77
|
+
React.Children.map(moreTabs, child => {
|
|
78
|
+
const isValidElement = /*#__PURE__*/React.isValidElement(child);
|
|
79
|
+
|
|
80
|
+
if (isValidElement) {
|
|
81
|
+
validElements.push(child.props);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return validElements;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleFilterSuggestions(_ref2) {
|
|
88
|
+
let {
|
|
89
|
+
moreTabs
|
|
90
|
+
} = _ref2;
|
|
91
|
+
const options = getMoreList({
|
|
92
|
+
moreTabs
|
|
93
|
+
});
|
|
94
|
+
const filteredOptions = options.filter(list => {
|
|
95
|
+
const {
|
|
96
|
+
text,
|
|
97
|
+
title
|
|
98
|
+
} = list;
|
|
99
|
+
const value = text ? text : showTitleInMoreOptions ? title : '';
|
|
100
|
+
return value.toLowerCase().includes(searchValue.toLowerCase());
|
|
101
|
+
});
|
|
102
|
+
return filteredOptions;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function renderEmptyState() {
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: tabsStyle.emptyStateContainer
|
|
108
|
+
}, /*#__PURE__*/React.createElement(EmptySearch, {
|
|
109
|
+
size: "small"
|
|
110
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: tabsStyle.emptyStateTitle
|
|
112
|
+
}, searchErrorText));
|
|
113
|
+
}
|
|
114
|
+
|
|
55
115
|
function onTabResize(size, target) {
|
|
56
116
|
let newDim = Object.assign({}, tabDimensions);
|
|
57
117
|
let elemDim = getTotalDimension(target, align);
|
|
@@ -101,6 +161,11 @@ const Tabs = props => {
|
|
|
101
161
|
}
|
|
102
162
|
};
|
|
103
163
|
}, []);
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (searchValue.length) {
|
|
166
|
+
handleSearchValueClear();
|
|
167
|
+
}
|
|
168
|
+
}, [isPopupOpen]);
|
|
104
169
|
|
|
105
170
|
function setMaxDim() {
|
|
106
171
|
let totalDimension = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
@@ -320,6 +385,7 @@ const Tabs = props => {
|
|
|
320
385
|
|
|
321
386
|
e.preventDefault();
|
|
322
387
|
onSelect(tab);
|
|
388
|
+
closePopupOnly();
|
|
323
389
|
}
|
|
324
390
|
|
|
325
391
|
function onScrollLocal(e) {
|
|
@@ -334,10 +400,10 @@ const Tabs = props => {
|
|
|
334
400
|
togglePopup(e, boxPosition);
|
|
335
401
|
}
|
|
336
402
|
|
|
337
|
-
function responsiveFunc(
|
|
403
|
+
function responsiveFunc(_ref3) {
|
|
338
404
|
let {
|
|
339
405
|
mediaQueryOR
|
|
340
|
-
} =
|
|
406
|
+
} = _ref3;
|
|
341
407
|
return {
|
|
342
408
|
tabletMode: mediaQueryOR([{
|
|
343
409
|
maxWidth: 700
|
|
@@ -374,9 +440,14 @@ const Tabs = props => {
|
|
|
374
440
|
let {
|
|
375
441
|
DropBoxProps = {},
|
|
376
442
|
ListItemProps = {},
|
|
377
|
-
MoreButtonProps = {}
|
|
443
|
+
MoreButtonProps = {},
|
|
444
|
+
TextBoxIconProps = {}
|
|
378
445
|
} = customProps;
|
|
379
446
|
let popupClass = align === 'vertical' ? tabsStyle[position] ? tabsStyle[position] : '' : '';
|
|
447
|
+
const moreTabsListItems = handleFilterSuggestions({
|
|
448
|
+
moreTabs
|
|
449
|
+
});
|
|
450
|
+
const hasSearch = moreTabs.length > 4;
|
|
380
451
|
return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(mainTabs, child => {
|
|
381
452
|
if (!child) {
|
|
382
453
|
return null;
|
|
@@ -426,10 +497,10 @@ const Tabs = props => {
|
|
|
426
497
|
})), isPopupOpen && /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
427
498
|
query: responsiveFunc,
|
|
428
499
|
responsiveId: "Helmet"
|
|
429
|
-
},
|
|
500
|
+
}, _ref4 => {
|
|
430
501
|
let {
|
|
431
502
|
tabletMode
|
|
432
|
-
} =
|
|
503
|
+
} = _ref4;
|
|
433
504
|
return /*#__PURE__*/React.createElement(ResponsiveDropBox, {
|
|
434
505
|
isActive: isPopupReady,
|
|
435
506
|
isAnimate: true,
|
|
@@ -445,19 +516,31 @@ const Tabs = props => {
|
|
|
445
516
|
isResponsivePadding: true,
|
|
446
517
|
needFocusScope: true,
|
|
447
518
|
onClose: togglePopupLocal,
|
|
519
|
+
onClick: removeClose,
|
|
448
520
|
dataId: `${dataId}_dropbox`
|
|
449
|
-
}, getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(props), /*#__PURE__*/React.createElement(Box, {
|
|
521
|
+
}, getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(props), hasSearch ? /*#__PURE__*/React.createElement(Box, {
|
|
522
|
+
className: tabsStyle.search
|
|
523
|
+
}, /*#__PURE__*/React.createElement(TextBoxIcon, {
|
|
524
|
+
placeHolder: placeHolderText,
|
|
525
|
+
onChange: handleChange,
|
|
526
|
+
value: searchValue,
|
|
527
|
+
onClear: handleSearchValueClear,
|
|
528
|
+
size: searchBoxSize,
|
|
529
|
+
customProps: {
|
|
530
|
+
TextBoxProps: {
|
|
531
|
+
'data-a11y-autofocus': true
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
dataId: `${dataId}_search`,
|
|
535
|
+
...TextBoxIconProps
|
|
536
|
+
})) : null, /*#__PURE__*/React.createElement(Box, {
|
|
450
537
|
flexible: true,
|
|
451
538
|
shrink: true,
|
|
452
539
|
scroll: "vertical",
|
|
453
|
-
className: `${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
540
|
+
className: `${tabsStyle.listWrapper} ${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
454
541
|
onScroll: onScrollLocal,
|
|
455
542
|
dataId: `${dataId}_Tabs`
|
|
456
|
-
},
|
|
457
|
-
if (!child) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
|
|
543
|
+
}, moreTabsListItems.length ? moreTabsListItems.map(data => {
|
|
461
544
|
let {
|
|
462
545
|
text,
|
|
463
546
|
id,
|
|
@@ -466,9 +549,9 @@ const Tabs = props => {
|
|
|
466
549
|
href,
|
|
467
550
|
children,
|
|
468
551
|
dataId
|
|
469
|
-
} =
|
|
552
|
+
} = data;
|
|
470
553
|
const value = text ? text : showTitleInMoreOptions ? title : null;
|
|
471
|
-
return /*#__PURE__*/React.
|
|
554
|
+
return /*#__PURE__*/React.createElement(ListItem, {
|
|
472
555
|
key: id,
|
|
473
556
|
value: value,
|
|
474
557
|
onClick: moreTabSelect,
|
|
@@ -484,7 +567,7 @@ const Tabs = props => {
|
|
|
484
567
|
dataId: `${dataId}_Tab`,
|
|
485
568
|
...ListItemProps
|
|
486
569
|
}, !showTitleInMoreOptions ? children : null);
|
|
487
|
-
})));
|
|
570
|
+
}) : renderEmptyState()));
|
|
488
571
|
})) : null);
|
|
489
572
|
}
|
|
490
573
|
|
|
@@ -30,7 +30,10 @@ export const Tabs_defaultProps = {
|
|
|
30
30
|
iconSize: '7',
|
|
31
31
|
containerClass: '',
|
|
32
32
|
customProps: {},
|
|
33
|
-
dataSelectorId: 'tabs'
|
|
33
|
+
dataSelectorId: 'tabs',
|
|
34
|
+
searchBoxSize: 'small',
|
|
35
|
+
searchErrorText: 'No results',
|
|
36
|
+
placeHolderText: 'Search'
|
|
34
37
|
};
|
|
35
38
|
export const TabWrapper_defaultProps = {
|
|
36
39
|
hookToDisableInternalState: false,
|
|
@@ -84,12 +84,17 @@ export const Tabs_propTypes = {
|
|
|
84
84
|
getTargetRef: PropTypes.func,
|
|
85
85
|
containerClass: PropTypes.string,
|
|
86
86
|
customProps: PropTypes.shape({
|
|
87
|
+
TextBoxIconProps: PropTypes.object,
|
|
87
88
|
DropBoxProps: PropTypes.object,
|
|
88
89
|
ListItemProps: PropTypes.object,
|
|
89
90
|
MoreButtonProps: PropTypes.object
|
|
90
91
|
}),
|
|
91
92
|
getCustomDropBoxHeaderPlaceHolder: PropTypes.func,
|
|
92
|
-
dataSelectorId: PropTypes.string
|
|
93
|
+
dataSelectorId: PropTypes.string,
|
|
94
|
+
placeHolderText: PropTypes.string,
|
|
95
|
+
searchBoxSize: PropTypes.string,
|
|
96
|
+
searchErrorText: PropTypes.string,
|
|
97
|
+
closePopupOnly: PropTypes.func
|
|
93
98
|
};
|
|
94
99
|
export const TabWrapper_propTypes = {
|
|
95
100
|
align: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
@@ -123,15 +123,45 @@
|
|
|
123
123
|
.bottomRightToLeft,
|
|
124
124
|
.topRightToLeft,
|
|
125
125
|
.bottomCenterToLeft {
|
|
126
|
-
right: calc(var(--tab_position_gap) * -1);
|
|
126
|
+
right: calc(var(--tab_position_gap) * -1);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.bottomLeftToRight,
|
|
130
130
|
.topLeftToRight,
|
|
131
131
|
.bottomCenterToRight {
|
|
132
|
-
left: calc(var(--tab_position_gap) * -1);
|
|
132
|
+
left: calc(var(--tab_position_gap) * -1);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
.hidden {
|
|
136
136
|
visibility: hidden;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.search {
|
|
140
|
+
padding: 0 var(--zd_size20) 0 ;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.emptyStateContainer {
|
|
144
|
+
padding-bottom: var(--zd_size15) ;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.emptyStateTitle {
|
|
148
|
+
font-family: var(--zd_semibold);
|
|
149
|
+
word-wrap: break-word;
|
|
150
|
+
font-size: var(--zd_font_size16) ;
|
|
151
|
+
max-width: var(--zd_size430) ;
|
|
152
|
+
text-align: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[dir=ltr] .emptyStateTitle {
|
|
156
|
+
margin-left: auto ;
|
|
157
|
+
margin-right: auto ;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[dir=rtl] .emptyStateTitle {
|
|
161
|
+
margin-right: auto ;
|
|
162
|
+
margin-left: auto ;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.listWrapper {
|
|
166
|
+
padding-top: var(--zd_size10) ;
|
|
137
167
|
}
|