@zohodesk/components 1.2.4 → 1.2.6
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 +8 -0
- package/coverage/Button/Button.js.html +1 -1
- package/coverage/Button/css/Button.module.css.html +1 -1
- package/coverage/Button/css/cssJSLogic.js.html +1 -1
- package/coverage/Button/css/index.html +1 -1
- package/coverage/Button/index.html +1 -1
- package/coverage/Button/props/defaultProps.js.html +1 -1
- package/coverage/Button/props/index.html +1 -1
- package/coverage/Button/props/propTypes.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
- package/coverage/Buttongroup/index.html +1 -1
- package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
- package/coverage/Buttongroup/props/index.html +1 -1
- package/coverage/Buttongroup/props/propTypes.js.html +1 -1
- package/coverage/index.html +1 -1
- package/coverage/utils/dummyFunction.js.html +1 -1
- package/coverage/utils/index.html +1 -1
- package/es/AppContainer/AppContainer.js +3 -0
- package/es/v1/Accordion/Accordion.js +65 -0
- package/es/v1/Accordion/AccordionItem.js +57 -0
- package/es/v1/Accordion/index.js +2 -0
- package/es/v1/Animation/Animation.js +127 -0
- package/es/v1/AppContainer/AppContainer.js +137 -0
- package/es/v1/Avatar/Avatar.js +189 -0
- package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
- package/es/v1/Button/Button.js +68 -0
- package/es/v1/Buttongroup/Buttongroup.js +31 -0
- package/es/v1/Card/Card.js +271 -0
- package/es/v1/CheckBox/CheckBox.js +155 -0
- package/es/v1/DateTime/CalendarView.js +218 -0
- package/es/v1/DateTime/DateTime.js +783 -0
- package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
- package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
- package/es/v1/DateTime/DateWidget.js +1098 -0
- package/es/v1/DateTime/DaysRow.js +31 -0
- package/es/v1/DateTime/Time.js +166 -0
- package/es/v1/DateTime/YearView.js +264 -0
- package/es/v1/DateTime/index.js +1 -0
- package/es/v1/DropBox/DropBox.js +91 -0
- package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
- package/es/v1/DropDown/DropDown.js +73 -0
- package/es/v1/DropDown/DropDownHeading.js +44 -0
- package/es/v1/DropDown/DropDownItem.js +76 -0
- package/es/v1/DropDown/DropDownSearch.js +63 -0
- package/es/v1/DropDown/DropDownSeparator.js +15 -0
- package/es/v1/Heading/Heading.js +32 -0
- package/es/v1/Label/Label.js +40 -0
- package/es/v1/Layout/Box.js +115 -0
- package/es/v1/Layout/Container.js +132 -0
- package/es/v1/Layout/index.js +2 -0
- package/es/v1/ListItem/ListContainer.js +102 -0
- package/es/v1/ListItem/ListItem.js +124 -0
- package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
- package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
- package/es/v1/ListItem/ListItemWithIcon.js +127 -0
- package/es/v1/ListItem/ListItemWithRadio.js +105 -0
- package/es/v1/ListItem/index.js +6 -0
- package/es/v1/Modal/Modal.js +154 -0
- package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
- package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
- package/es/v1/MultiSelect/EmptyState.js +64 -0
- package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
- package/es/v1/MultiSelect/MultiSelect.js +1120 -0
- package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
- package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
- package/es/v1/MultiSelect/SelectedOptions.js +82 -0
- package/es/v1/MultiSelect/Suggestions.js +142 -0
- package/es/v1/MultiSelect/index.js +4 -0
- package/es/v1/PopOver/PopOver.js +211 -0
- package/es/v1/Popup/Popup.js +645 -0
- package/es/v1/Radio/Radio.js +115 -0
- package/es/v1/Responsive/CustomResponsive.js +195 -0
- package/es/v1/Responsive/RefWrapper.js +39 -0
- package/es/v1/Responsive/ResizeComponent.js +197 -0
- package/es/v1/Responsive/ResizeObserver.js +140 -0
- package/es/v1/Responsive/Responsive.js +194 -0
- package/es/v1/Responsive/index.js +9 -0
- package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
- package/es/v1/Ribbon/Ribbon.js +33 -0
- package/es/v1/RippleEffect/RippleEffect.js +24 -0
- package/es/v1/Select/GroupSelect.js +803 -0
- package/es/v1/Select/Select.js +969 -0
- package/es/v1/Select/SelectWithAvatar.js +344 -0
- package/es/v1/Select/SelectWithIcon.js +535 -0
- package/es/v1/Select/index.js +4 -0
- package/es/v1/Stencils/Stencils.js +26 -0
- package/es/v1/Switch/Switch.js +94 -0
- package/es/v1/Tab/Tab.js +108 -0
- package/es/v1/Tab/TabContent.js +30 -0
- package/es/v1/Tab/TabContentWrapper.js +29 -0
- package/es/v1/Tab/TabWrapper.js +57 -0
- package/es/v1/Tab/Tabs.js +612 -0
- package/es/v1/Tab/index.js +5 -0
- package/es/v1/Tag/Tag.js +134 -0
- package/es/v1/TextBox/TextBox.js +154 -0
- package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
- package/es/v1/Textarea/Textarea.js +102 -0
- package/es/v1/Tooltip/Tooltip.js +518 -0
- package/es/v1/Typography/Typography.js +38 -0
- package/es/v1/Typography/css/Typography.module.css +376 -0
- package/es/v1/Typography/css/cssJSLogic.js +46 -0
- package/es/v1/Typography/css/letterSpacingMap.js +12 -0
- package/es/v1/Typography/props/defaultProps.js +8 -0
- package/es/v1/Typography/props/propTypes.js +24 -0
- package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
- package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
- package/es/v1/semantic/Button/Button.js +53 -0
- package/es/v1/semantic/index.js +1 -0
- package/lib/AppContainer/AppContainer.js +5 -0
- package/lib/v1/Accordion/Accordion.js +96 -0
- package/lib/v1/Accordion/AccordionItem.js +68 -0
- package/lib/v1/Accordion/index.js +23 -0
- package/lib/v1/Animation/Animation.js +143 -0
- package/lib/v1/AppContainer/AppContainer.js +209 -0
- package/lib/v1/Avatar/Avatar.js +246 -0
- package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
- package/lib/v1/Button/Button.js +82 -0
- package/lib/v1/Buttongroup/Buttongroup.js +44 -0
- package/lib/v1/Card/Card.js +365 -0
- package/lib/v1/CheckBox/CheckBox.js +166 -0
- package/lib/v1/DateTime/CalendarView.js +285 -0
- package/lib/v1/DateTime/DateTime.js +872 -0
- package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
- package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
- package/lib/v1/DateTime/DateWidget.js +1125 -0
- package/lib/v1/DateTime/DaysRow.js +80 -0
- package/lib/v1/DateTime/Time.js +254 -0
- package/lib/v1/DateTime/YearView.js +325 -0
- package/lib/v1/DateTime/index.js +15 -0
- package/lib/v1/DropBox/DropBox.js +119 -0
- package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
- package/lib/v1/DropDown/DropDown.js +170 -0
- package/lib/v1/DropDown/DropDownHeading.js +93 -0
- package/lib/v1/DropDown/DropDownItem.js +127 -0
- package/lib/v1/DropDown/DropDownSearch.js +113 -0
- package/lib/v1/DropDown/DropDownSeparator.js +64 -0
- package/lib/v1/Heading/Heading.js +49 -0
- package/lib/v1/Label/Label.js +51 -0
- package/lib/v1/Layout/Box.js +128 -0
- package/lib/v1/Layout/Container.js +145 -0
- package/lib/v1/Layout/index.js +23 -0
- package/lib/v1/ListItem/ListContainer.js +120 -0
- package/lib/v1/ListItem/ListItem.js +138 -0
- package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
- package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
- package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
- package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
- package/lib/v1/ListItem/index.js +55 -0
- package/lib/v1/Modal/Modal.js +212 -0
- package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
- package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
- package/lib/v1/MultiSelect/EmptyState.js +112 -0
- package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
- package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
- package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
- package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
- package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
- package/lib/v1/MultiSelect/Suggestions.js +195 -0
- package/lib/v1/MultiSelect/index.js +39 -0
- package/lib/v1/PopOver/PopOver.js +293 -0
- package/lib/v1/Popup/Popup.js +715 -0
- package/lib/v1/Radio/Radio.js +126 -0
- package/lib/v1/Responsive/CustomResponsive.js +242 -0
- package/lib/v1/Responsive/RefWrapper.js +57 -0
- package/lib/v1/Responsive/ResizeComponent.js +268 -0
- package/lib/v1/Responsive/ResizeObserver.js +168 -0
- package/lib/v1/Responsive/Responsive.js +274 -0
- package/lib/v1/Responsive/index.js +55 -0
- package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
- package/lib/v1/Ribbon/Ribbon.js +44 -0
- package/lib/v1/RippleEffect/RippleEffect.js +39 -0
- package/lib/v1/Select/GroupSelect.js +877 -0
- package/lib/v1/Select/Select.js +1013 -0
- package/lib/v1/Select/SelectWithAvatar.js +394 -0
- package/lib/v1/Select/SelectWithIcon.js +597 -0
- package/lib/v1/Select/index.js +39 -0
- package/lib/v1/Stencils/Stencils.js +43 -0
- package/lib/v1/Switch/Switch.js +108 -0
- package/lib/v1/Tab/Tab.js +132 -0
- package/lib/v1/Tab/TabContent.js +42 -0
- package/lib/v1/Tab/TabContentWrapper.js +42 -0
- package/lib/v1/Tab/TabWrapper.js +89 -0
- package/lib/v1/Tab/Tabs.js +680 -0
- package/lib/v1/Tab/index.js +47 -0
- package/lib/v1/Tag/Tag.js +154 -0
- package/lib/v1/TextBox/TextBox.js +168 -0
- package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
- package/lib/v1/Textarea/Textarea.js +118 -0
- package/lib/v1/Tooltip/Tooltip.js +586 -0
- package/lib/v1/Typography/Typography.js +56 -0
- package/lib/v1/Typography/css/Typography.module.css +376 -0
- package/lib/v1/Typography/css/cssJSLogic.js +41 -0
- package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
- package/lib/v1/Typography/props/defaultProps.js +15 -0
- package/lib/v1/Typography/props/propTypes.js +35 -0
- package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
- package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
- package/lib/v1/semantic/Button/Button.js +63 -0
- package/lib/v1/semantic/index.js +15 -0
- package/package.json +1 -1
- package/result.json +1 -1
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/**** Libraries ****/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { AdvancedMultiSelect_propTypes } from '../../MultiSelect/props/propTypes';
|
|
6
|
+
import { AdvancedMultiSelect_defaultProps } from '../../MultiSelect/props/defaultProps';
|
|
7
|
+
/**** Components ****/
|
|
8
|
+
|
|
9
|
+
import { MultiSelectComponent } from './MultiSelect';
|
|
10
|
+
import SelectedOptions from './SelectedOptions';
|
|
11
|
+
import Suggestions from './Suggestions';
|
|
12
|
+
import EmptyState from './EmptyState';
|
|
13
|
+
import MultiSelectHeader from './MultiSelectHeader';
|
|
14
|
+
import Popup from '../Popup/Popup';
|
|
15
|
+
import TextBoxIcon from '../TextBoxIcon/TextBoxIcon';
|
|
16
|
+
import { Container, Box } from '../Layout';
|
|
17
|
+
import Card, { CardContent, CardHeader, CardFooter } from '../Card/Card';
|
|
18
|
+
import { Icon } from '@zohodesk/icons';
|
|
19
|
+
import { getUniqueId } from '../../Provider/IdProvider';
|
|
20
|
+
import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
21
|
+
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
22
|
+
import Loader from '@zohodesk/svg/lib/Loader/Loader';
|
|
23
|
+
/**** CSS ****/
|
|
24
|
+
|
|
25
|
+
import style from '../../MultiSelect/MultiSelect.module.css';
|
|
26
|
+
/**** Methods ****/
|
|
27
|
+
|
|
28
|
+
import { getIsEmptyValue, getSearchString } from '../../utils/Common.js';
|
|
29
|
+
import { filterSelectedOptions, makeGetIsShowClearIcon } from '../../utils/dropDownUtils';
|
|
30
|
+
/* eslint-disable react/sort-prop-types */
|
|
31
|
+
|
|
32
|
+
/* eslint-disable react/no-unused-prop-types */
|
|
33
|
+
|
|
34
|
+
/* eslint-disable react/forbid-component-props */
|
|
35
|
+
|
|
36
|
+
const dummyArray = [];
|
|
37
|
+
export class AdvancedMultiSelectComponent extends MultiSelectComponent {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props);
|
|
40
|
+
const {
|
|
41
|
+
state: oldState
|
|
42
|
+
} = this;
|
|
43
|
+
const {
|
|
44
|
+
selectedOptionsLimit,
|
|
45
|
+
selectedOptions
|
|
46
|
+
} = this.props;
|
|
47
|
+
const selectedOptionsLen = selectedOptions.length;
|
|
48
|
+
this.state = Object.assign({}, oldState, {
|
|
49
|
+
showedSelectedOptionsCount: !getIsEmptyValue(selectedOptionsLimit) && selectedOptionsLen > selectedOptionsLimit ? selectedOptionsLimit : selectedOptionsLen
|
|
50
|
+
});
|
|
51
|
+
this.getIsShowClearIcon = makeGetIsShowClearIcon();
|
|
52
|
+
this.handleFilterSuggestions = this.handleFilterSuggestions.bind(this);
|
|
53
|
+
this.handleChange = this.handleChange.bind(this);
|
|
54
|
+
this.handleSelectOption = this.handleSelectOption.bind(this);
|
|
55
|
+
this.handleGetSelectedOptions = this.handleGetSelectedOptions.bind(this);
|
|
56
|
+
this.handleFormatSelectedOptions = this.handleFormatSelectedOptions.bind(this);
|
|
57
|
+
this.handleComponentDidUpdate = this.handleComponentDidUpdate.bind(this);
|
|
58
|
+
this.handleMoreClick = this.handleMoreClick.bind(this);
|
|
59
|
+
this.getNextAriaId = getUniqueId(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
handleFilterSuggestions() {
|
|
63
|
+
const {
|
|
64
|
+
options = dummyArray,
|
|
65
|
+
searchStr
|
|
66
|
+
} = this.state;
|
|
67
|
+
const {
|
|
68
|
+
needLocalSearch
|
|
69
|
+
} = this.props;
|
|
70
|
+
const {
|
|
71
|
+
suggestions,
|
|
72
|
+
suggestionIds
|
|
73
|
+
} = this.getFilterSuggestions({
|
|
74
|
+
options,
|
|
75
|
+
selectedOptions: dummyArray,
|
|
76
|
+
searchStr: getSearchString(searchStr),
|
|
77
|
+
needSearch: needLocalSearch
|
|
78
|
+
});
|
|
79
|
+
this.suggestionsOrder = suggestionIds;
|
|
80
|
+
return suggestions;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
handleChange() {
|
|
84
|
+
let selectedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
85
|
+
let e = arguments.length > 1 ? arguments[1] : undefined;
|
|
86
|
+
const {
|
|
87
|
+
optionsNormalize,
|
|
88
|
+
searchStr
|
|
89
|
+
} = this.state;
|
|
90
|
+
const {
|
|
91
|
+
onChange,
|
|
92
|
+
needToCloseOnSelect = false,
|
|
93
|
+
togglePopup,
|
|
94
|
+
isSearchClearOnSelect,
|
|
95
|
+
selectedOptions: propSelectedOptions,
|
|
96
|
+
disabledOptions
|
|
97
|
+
} = this.props;
|
|
98
|
+
const {
|
|
99
|
+
newSelectedOptions
|
|
100
|
+
} = filterSelectedOptions({
|
|
101
|
+
selectedOptions,
|
|
102
|
+
propSelectedOptions,
|
|
103
|
+
disabledOptions
|
|
104
|
+
});
|
|
105
|
+
const selectedOptionsLen = newSelectedOptions.length;
|
|
106
|
+
const allSelectedOptionsDetails = [];
|
|
107
|
+
|
|
108
|
+
for (let i = 0; i < selectedOptionsLen; i++) {
|
|
109
|
+
const id = newSelectedOptions[i];
|
|
110
|
+
allSelectedOptionsDetails.push(optionsNormalize[id]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onChange && onChange(newSelectedOptions, allSelectedOptionsDetails);
|
|
114
|
+
|
|
115
|
+
if (searchStr.trim() !== '' && isSearchClearOnSelect) {
|
|
116
|
+
this.handleSearch('');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.searchInput && this.searchInput.focus({
|
|
120
|
+
preventScroll: true
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
if (needToCloseOnSelect) {
|
|
124
|
+
e && togglePopup(e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
handleSelectOption(option, value, index, e) {
|
|
129
|
+
const {
|
|
130
|
+
selectedOptions
|
|
131
|
+
} = this.props;
|
|
132
|
+
|
|
133
|
+
if (selectedOptions.indexOf(option) >= 0) {
|
|
134
|
+
//toggle select option
|
|
135
|
+
this.handleRemoveOption(option);
|
|
136
|
+
} else {
|
|
137
|
+
this.handleChange([...selectedOptions, option], e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
handleFormatOptions(props) {
|
|
142
|
+
const {
|
|
143
|
+
options,
|
|
144
|
+
valueField,
|
|
145
|
+
textField,
|
|
146
|
+
imageField,
|
|
147
|
+
iconName,
|
|
148
|
+
iconSize,
|
|
149
|
+
prefixText,
|
|
150
|
+
optionType,
|
|
151
|
+
disabledOptions
|
|
152
|
+
} = props;
|
|
153
|
+
return this.formatOptions({
|
|
154
|
+
options,
|
|
155
|
+
valueField,
|
|
156
|
+
textField,
|
|
157
|
+
imageField,
|
|
158
|
+
iconName,
|
|
159
|
+
prefixText,
|
|
160
|
+
optionType,
|
|
161
|
+
iconSize,
|
|
162
|
+
disabledOptions
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
handleGetSelectedOptions(selectedOptions, normalizedFormatOptions, props) {
|
|
167
|
+
//handle selectedoptions length
|
|
168
|
+
let {
|
|
169
|
+
showedSelectedOptionsCount
|
|
170
|
+
} = this.state || {};
|
|
171
|
+
const {
|
|
172
|
+
selectedOptionsLimit,
|
|
173
|
+
selectedOptionDetails
|
|
174
|
+
} = props;
|
|
175
|
+
showedSelectedOptionsCount = getIsEmptyValue(showedSelectedOptionsCount) ? selectedOptionsLimit : showedSelectedOptionsCount;
|
|
176
|
+
const {
|
|
177
|
+
normalizedFormatOptions: normalizedSelectedOptions
|
|
178
|
+
} = this.handleFormatSelectedOptions(selectedOptionDetails, props);
|
|
179
|
+
const formatOptions = this.objectConcat({
|
|
180
|
+
obj1: normalizedFormatOptions,
|
|
181
|
+
obj2: normalizedSelectedOptions
|
|
182
|
+
});
|
|
183
|
+
return this.getSelectedOptions({
|
|
184
|
+
selectedOptions,
|
|
185
|
+
normalizedFormatOptions: formatOptions,
|
|
186
|
+
selectedOptionsLength: showedSelectedOptionsCount
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
handleFormatSelectedOptions(selectedOptionDetails, props) {
|
|
191
|
+
const {
|
|
192
|
+
valueField,
|
|
193
|
+
textField,
|
|
194
|
+
imageField,
|
|
195
|
+
optionType,
|
|
196
|
+
iconName,
|
|
197
|
+
iconSize,
|
|
198
|
+
disabledOptions
|
|
199
|
+
} = props;
|
|
200
|
+
return this.formatSelectedOptions({
|
|
201
|
+
options: selectedOptionDetails,
|
|
202
|
+
valueField,
|
|
203
|
+
textField,
|
|
204
|
+
imageField,
|
|
205
|
+
optionType,
|
|
206
|
+
iconName,
|
|
207
|
+
iconSize,
|
|
208
|
+
disabledOptions
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
handleComponentDidUpdate(prevProps, prevState) {
|
|
213
|
+
const {
|
|
214
|
+
allSelectedOptionsDetails: oldAllSelectedOptionsDetails
|
|
215
|
+
} = this;
|
|
216
|
+
const {
|
|
217
|
+
selectedOptions,
|
|
218
|
+
selectedOptionsLimit,
|
|
219
|
+
id,
|
|
220
|
+
selectedOptionDetails
|
|
221
|
+
} = this.props;
|
|
222
|
+
const {
|
|
223
|
+
selectedOptions: oldSelectedOptions,
|
|
224
|
+
selectedOptionsLimit: oldSelectedOptionsLimit
|
|
225
|
+
} = prevProps;
|
|
226
|
+
const {
|
|
227
|
+
showedSelectedOptionsCount: oldCount
|
|
228
|
+
} = this.state;
|
|
229
|
+
const selectedOptionsLen = selectedOptions.length;
|
|
230
|
+
const oldSelectedOptionsLen = oldSelectedOptions.length;
|
|
231
|
+
|
|
232
|
+
if (id !== prevProps.id || selectedOptionsLimit !== oldSelectedOptionsLimit) {
|
|
233
|
+
//handle component update case (New set of options or new selectedOptionsLimit update)
|
|
234
|
+
this.setState({
|
|
235
|
+
showedSelectedOptionsCount: !getIsEmptyValue(selectedOptionsLimit) && selectedOptionsLen > selectedOptionsLimit ? selectedOptionsLimit : selectedOptionsLen
|
|
236
|
+
});
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (oldCount !== prevState.showedSelectedOptionsCount || selectedOptionDetails !== prevProps.selectedOptionDetails) {
|
|
241
|
+
//When showedSelectedOptionsCount update, setState the updated selected option details
|
|
242
|
+
const {
|
|
243
|
+
normalizedFormatOptions
|
|
244
|
+
} = this.handleFormatOptions(this.props);
|
|
245
|
+
const optionsDetails = Object.assign({}, oldAllSelectedOptionsDetails, normalizedFormatOptions);
|
|
246
|
+
const {
|
|
247
|
+
formatSelectedOptions,
|
|
248
|
+
normalizedSelectedOptions,
|
|
249
|
+
selectedOptionIds
|
|
250
|
+
} = this.handleGetSelectedOptions(selectedOptions, optionsDetails, this.props);
|
|
251
|
+
this.allSelectedOptionsDetails = Object.assign(oldAllSelectedOptionsDetails, normalizedSelectedOptions);
|
|
252
|
+
this.setState({
|
|
253
|
+
selectedOptions: formatSelectedOptions,
|
|
254
|
+
selectedOptionIds
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (getIsEmptyValue(oldCount) || oldSelectedOptionsLen <= oldCount) {
|
|
259
|
+
//handle not more options case
|
|
260
|
+
if (selectedOptionsLen > oldCount) {
|
|
261
|
+
this.setState({
|
|
262
|
+
showedSelectedOptionsCount: selectedOptionsLen
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
} else if (oldSelectedOptionsLen > selectedOptionsLen) {
|
|
266
|
+
//handle more case and option remove case
|
|
267
|
+
const showedSelectedOptions = oldSelectedOptions.slice(0, oldCount);
|
|
268
|
+
let removeSelectedOption = oldCount;
|
|
269
|
+
selectedOptions.forEach(option => {
|
|
270
|
+
if (showedSelectedOptions.indexOf(option) >= 0) {
|
|
271
|
+
removeSelectedOption -= 1;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
const newCount = oldCount - removeSelectedOption;
|
|
275
|
+
this.setState({
|
|
276
|
+
showedSelectedOptionsCount: newCount
|
|
277
|
+
}, () => {
|
|
278
|
+
const {
|
|
279
|
+
showedSelectedOptionsCount
|
|
280
|
+
} = this.state;
|
|
281
|
+
|
|
282
|
+
if (showedSelectedOptionsCount === 0) {
|
|
283
|
+
this.handleMoreClick();
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
handleMoreClick(e) {
|
|
290
|
+
const {
|
|
291
|
+
showedSelectedOptionsCount
|
|
292
|
+
} = this.state;
|
|
293
|
+
const {
|
|
294
|
+
selectedOptionsLimit,
|
|
295
|
+
selectedOptions,
|
|
296
|
+
getSelectedOptionDetails,
|
|
297
|
+
removeClose
|
|
298
|
+
} = this.props;
|
|
299
|
+
removeClose(e);
|
|
300
|
+
const selectedOptionsLen = selectedOptions.length;
|
|
301
|
+
|
|
302
|
+
if (showedSelectedOptionsCount < selectedOptionsLen) {
|
|
303
|
+
const newCount = showedSelectedOptionsCount + selectedOptionsLimit;
|
|
304
|
+
const newSelectedOptionIds = selectedOptions.slice(showedSelectedOptionsCount, newCount);
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
getSelectedOptionDetails(newSelectedOptionIds).then(() => {
|
|
308
|
+
this.setState({
|
|
309
|
+
showedSelectedOptionsCount: showedSelectedOptionsCount + newSelectedOptionIds.length
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
} catch (e) {//console.error('getSelectedOptionDetails is not a promise function.');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
this.searchInput && this.searchInput.focus({
|
|
317
|
+
preventScroll: true
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
responsiveFunc(_ref) {
|
|
322
|
+
let {
|
|
323
|
+
mediaQueryOR
|
|
324
|
+
} = _ref;
|
|
325
|
+
return {
|
|
326
|
+
tabletMode: mediaQueryOR([{
|
|
327
|
+
maxWidth: 700
|
|
328
|
+
}])
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
render() {
|
|
333
|
+
let {
|
|
334
|
+
isReadOnly,
|
|
335
|
+
needSelectAll,
|
|
336
|
+
searchEmptyMessage,
|
|
337
|
+
emptyMessage,
|
|
338
|
+
noMoreOptionsMessage,
|
|
339
|
+
dropBoxSize,
|
|
340
|
+
placeHolder,
|
|
341
|
+
isPopupOpen,
|
|
342
|
+
isPopupReady,
|
|
343
|
+
position,
|
|
344
|
+
defaultDropBoxPosition,
|
|
345
|
+
selectAllText,
|
|
346
|
+
getContainerRef,
|
|
347
|
+
removeClose,
|
|
348
|
+
isAnimate,
|
|
349
|
+
animationStyle,
|
|
350
|
+
textBoxSize,
|
|
351
|
+
variant,
|
|
352
|
+
size,
|
|
353
|
+
isDisabled,
|
|
354
|
+
title,
|
|
355
|
+
dataIdMultiSelectComp,
|
|
356
|
+
dataIdClearIcon,
|
|
357
|
+
dataIdSelectAllEle,
|
|
358
|
+
dataIdLoading,
|
|
359
|
+
selectedOptions: allselectedOptionIds = [],
|
|
360
|
+
listItemSize,
|
|
361
|
+
needBorder,
|
|
362
|
+
i18nKeys,
|
|
363
|
+
htmlId,
|
|
364
|
+
a11y,
|
|
365
|
+
borderColor,
|
|
366
|
+
isBoxPaddingNeed,
|
|
367
|
+
getFooter,
|
|
368
|
+
customProps,
|
|
369
|
+
needEffect,
|
|
370
|
+
disabledOptions,
|
|
371
|
+
isLoading,
|
|
372
|
+
dataSelectorId
|
|
373
|
+
} = this.props;
|
|
374
|
+
let {
|
|
375
|
+
SuggestionsProps = {},
|
|
376
|
+
DropBoxProps = {}
|
|
377
|
+
} = customProps;
|
|
378
|
+
const {
|
|
379
|
+
clearText = 'Clear all'
|
|
380
|
+
} = i18nKeys;
|
|
381
|
+
const {
|
|
382
|
+
clearLabel = 'Clear all'
|
|
383
|
+
} = a11y;
|
|
384
|
+
i18nKeys = Object.assign({}, i18nKeys, {
|
|
385
|
+
emptyText: i18nKeys.emptyText || emptyMessage,
|
|
386
|
+
noMoreText: i18nKeys.noMoreText || noMoreOptionsMessage,
|
|
387
|
+
searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage
|
|
388
|
+
});
|
|
389
|
+
const {
|
|
390
|
+
selectedOptions,
|
|
391
|
+
searchStr,
|
|
392
|
+
hoverOption,
|
|
393
|
+
highLightedSelectOptions,
|
|
394
|
+
isFetchingOptions,
|
|
395
|
+
isActive,
|
|
396
|
+
showedSelectedOptionsCount,
|
|
397
|
+
options
|
|
398
|
+
} = this.state;
|
|
399
|
+
const suggestions = this.handleFilterSuggestions();
|
|
400
|
+
const allselectedOptionIdsLen = allselectedOptionIds.length;
|
|
401
|
+
const moreCount = allselectedOptionIdsLen - showedSelectedOptionsCount;
|
|
402
|
+
const setAriaId = this.getNextAriaId();
|
|
403
|
+
const ariaErrorId = this.getNextAriaId();
|
|
404
|
+
let {
|
|
405
|
+
isShowClearIcon: isShowClear
|
|
406
|
+
} = this.getIsShowClearIcon({
|
|
407
|
+
selectedOptions,
|
|
408
|
+
disabledOptions
|
|
409
|
+
});
|
|
410
|
+
let isShowClearIcon = !isReadOnly && !isDisabled && isShowClear;
|
|
411
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
412
|
+
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''}`,
|
|
413
|
+
"data-id": dataIdMultiSelectComp,
|
|
414
|
+
"data-test-id": dataIdMultiSelectComp,
|
|
415
|
+
"data-title": isDisabled ? title : null,
|
|
416
|
+
onClick: this.handleInputFocus,
|
|
417
|
+
"data-selector-id": dataSelectorId
|
|
418
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
419
|
+
align: "vertical",
|
|
420
|
+
alignBox: "row",
|
|
421
|
+
className: `${style.container} ${style[size]} ${isActive && needBorder ? style.active : ''} ${needBorder ? style.hasBorder : ''} ${needBorder ? !isDisabled ? style[`borderColor_${borderColor}`] : style.borderColor_transparent : ''}`,
|
|
422
|
+
eleRef: this.selectedOptionContainerRef,
|
|
423
|
+
wrap: "wrap"
|
|
424
|
+
}, /*#__PURE__*/React.createElement(SelectedOptions, {
|
|
425
|
+
selectedOptions: selectedOptions,
|
|
426
|
+
highLightedSelectOptions: highLightedSelectOptions,
|
|
427
|
+
isReadOnly: isReadOnly,
|
|
428
|
+
getRef: this.selectedOptionRef,
|
|
429
|
+
onRemove: this.handleRemoveOption,
|
|
430
|
+
onSelect: this.handleClickSelectedOption
|
|
431
|
+
}), moreCount > 0 ? /*#__PURE__*/React.createElement(Box, {
|
|
432
|
+
className: style.more,
|
|
433
|
+
onClick: this.handleMoreClick,
|
|
434
|
+
tagName: "button"
|
|
435
|
+
}, `+ ${moreCount} More`) : null, /*#__PURE__*/React.createElement(Box, {
|
|
436
|
+
flexible: true,
|
|
437
|
+
className: style.wrapper,
|
|
438
|
+
adjust: true,
|
|
439
|
+
shrink: true
|
|
440
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
441
|
+
className: ` ${style.custmSpan} ${textBoxSize === 'xmedium' ? style.custmSpanXmedium : style.custmSpanMedium} ${isShowClearIcon ? style.clearIconSpace : ''}
|
|
442
|
+
`
|
|
443
|
+
}, searchStr), /*#__PURE__*/React.createElement(TextBoxIcon, {
|
|
444
|
+
isDisabled: isDisabled,
|
|
445
|
+
inputRef: this.searchInputRef,
|
|
446
|
+
needBorder: false,
|
|
447
|
+
onBlur: this.handleInactive,
|
|
448
|
+
onChange: this.handleSearch,
|
|
449
|
+
onClick: this.handleInputCick,
|
|
450
|
+
onFocus: this.handleActive,
|
|
451
|
+
onKeyDown: this.handleKeyDown,
|
|
452
|
+
placeHolder: selectedOptions.length >= 1 ? '' : placeHolder,
|
|
453
|
+
size: textBoxSize,
|
|
454
|
+
value: searchStr,
|
|
455
|
+
variant: variant,
|
|
456
|
+
isReadOnly: isReadOnly,
|
|
457
|
+
tabindex: isDisabled && '-1',
|
|
458
|
+
customClass: {
|
|
459
|
+
customTBoxWrap: style.custmInputWrapper
|
|
460
|
+
},
|
|
461
|
+
htmlId: htmlId,
|
|
462
|
+
a11y: {
|
|
463
|
+
role: 'combobox',
|
|
464
|
+
ariaOwns: setAriaId,
|
|
465
|
+
ariaControls: setAriaId,
|
|
466
|
+
ariaExpanded: !isReadOnly && !isDisabled && isPopupOpen ? true : false,
|
|
467
|
+
ariaHaspopup: true,
|
|
468
|
+
ariaDescribedby: ariaErrorId
|
|
469
|
+
},
|
|
470
|
+
autoComplete: false
|
|
471
|
+
}, isShowClearIcon ? /*#__PURE__*/React.createElement(Container, {
|
|
472
|
+
alignBox: "row",
|
|
473
|
+
align: "vertical"
|
|
474
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
475
|
+
className: `${style.delete}`,
|
|
476
|
+
dataId: dataIdClearIcon,
|
|
477
|
+
"data-title": clearText,
|
|
478
|
+
onClick: this.handleDeselectAll,
|
|
479
|
+
tagName: "button",
|
|
480
|
+
"aria-label": clearLabel
|
|
481
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
482
|
+
name: "ZD-delete",
|
|
483
|
+
size: "15"
|
|
484
|
+
}))) : null))), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
485
|
+
query: this.responsiveFunc,
|
|
486
|
+
responsiveId: "Helmet"
|
|
487
|
+
}, _ref2 => {
|
|
488
|
+
let {
|
|
489
|
+
tabletMode
|
|
490
|
+
} = _ref2;
|
|
491
|
+
return /*#__PURE__*/React.createElement(ResponsiveDropBox, _extends({
|
|
492
|
+
animationStyle: animationStyle,
|
|
493
|
+
boxPosition: position || `${defaultDropBoxPosition}Center`,
|
|
494
|
+
getRef: getContainerRef,
|
|
495
|
+
isActive: isPopupReady,
|
|
496
|
+
isAnimate: isAnimate,
|
|
497
|
+
isArrow: false,
|
|
498
|
+
onClick: removeClose,
|
|
499
|
+
isPadding: false,
|
|
500
|
+
isBoxPaddingNeed: isBoxPaddingNeed,
|
|
501
|
+
htmlId: setAriaId,
|
|
502
|
+
a11y: {
|
|
503
|
+
role: 'listbox',
|
|
504
|
+
ariaMultiselectable: true
|
|
505
|
+
}
|
|
506
|
+
}, DropBoxProps, {
|
|
507
|
+
alignBox: "row",
|
|
508
|
+
isResponsivePadding: getFooter ? false : true
|
|
509
|
+
}), isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
510
|
+
align: "both",
|
|
511
|
+
className: style.loader
|
|
512
|
+
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
513
|
+
flexible: true
|
|
514
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
515
|
+
customClass: style.box,
|
|
516
|
+
onScroll: this.handleScroll
|
|
517
|
+
}, needSelectAll ? /*#__PURE__*/React.createElement(CardHeader, null, /*#__PURE__*/React.createElement(MultiSelectHeader, {
|
|
518
|
+
onSelect: this.handleSelectAll,
|
|
519
|
+
selectAllText: selectAllText,
|
|
520
|
+
suggestions: suggestions,
|
|
521
|
+
dataId: dataIdSelectAllEle
|
|
522
|
+
})) : null, /*#__PURE__*/React.createElement(CardContent, {
|
|
523
|
+
shrink: true,
|
|
524
|
+
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
525
|
+
eleRef: this.suggestionContainerRef
|
|
526
|
+
}, suggestions.length ? /*#__PURE__*/React.createElement(Suggestions, _extends({
|
|
527
|
+
suggestions: suggestions,
|
|
528
|
+
selectedOptions: allselectedOptionIds,
|
|
529
|
+
getRef: this.suggestionItemRef,
|
|
530
|
+
hoverOption: hoverOption,
|
|
531
|
+
onClick: this.handleSelectOption,
|
|
532
|
+
onMouseEnter: this.handleMouseEnter,
|
|
533
|
+
needTick: true,
|
|
534
|
+
listItemSize: listItemSize,
|
|
535
|
+
a11y: {
|
|
536
|
+
role: 'option'
|
|
537
|
+
}
|
|
538
|
+
}, SuggestionsProps)) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
539
|
+
isLoading: isFetchingOptions,
|
|
540
|
+
options: options,
|
|
541
|
+
searchString: searchStr,
|
|
542
|
+
suggestions: suggestions,
|
|
543
|
+
dataId: dataIdLoading,
|
|
544
|
+
i18nKeys: i18nKeys,
|
|
545
|
+
htmlId: ariaErrorId
|
|
546
|
+
}), isFetchingOptions && /*#__PURE__*/React.createElement(Container, {
|
|
547
|
+
isCover: false,
|
|
548
|
+
align: "both"
|
|
549
|
+
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : null)));
|
|
550
|
+
}) : null);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
}
|
|
554
|
+
AdvancedMultiSelectComponent.propTypes = AdvancedMultiSelect_propTypes;
|
|
555
|
+
AdvancedMultiSelectComponent.defaultProps = AdvancedMultiSelect_defaultProps;
|
|
556
|
+
AdvancedMultiSelectComponent.displayName = 'AdvancedMultiSelect';
|
|
557
|
+
const AdvancedMultiSelect = Popup(AdvancedMultiSelectComponent);
|
|
558
|
+
AdvancedMultiSelect.defaultProps = AdvancedMultiSelectComponent.defaultProps;
|
|
559
|
+
AdvancedMultiSelect.propTypes = AdvancedMultiSelectComponent.propTypes; // if (__DOCS__) {
|
|
560
|
+
// AdvancedMultiSelectComponent.docs = {
|
|
561
|
+
// componentGroup: 'Form Elements',
|
|
562
|
+
// folderName: 'Style Guide'
|
|
563
|
+
// };
|
|
564
|
+
// // eslint-disable-next-line react/forbid-foreign-prop-types
|
|
565
|
+
// AdvancedMultiSelect.propTypes = AdvancedMultiSelectComponent.propTypes;
|
|
566
|
+
// }
|
|
567
|
+
|
|
568
|
+
export default AdvancedMultiSelect;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**** Libraries ****/
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { EmptyState_propTypes } from '../../MultiSelect/props/propTypes';
|
|
4
|
+
import { EmptyState_defaultProps } from '../../MultiSelect/props/defaultProps';
|
|
5
|
+
/**** CSS ****/
|
|
6
|
+
|
|
7
|
+
import style from '../../MultiSelect/MultiSelect.module.css';
|
|
8
|
+
export default class EmptyState extends React.PureComponent {
|
|
9
|
+
render() {
|
|
10
|
+
let {
|
|
11
|
+
emptyMessage,
|
|
12
|
+
isLoading,
|
|
13
|
+
noMoreOptionsMessage,
|
|
14
|
+
options,
|
|
15
|
+
searchEmptyMessage,
|
|
16
|
+
searchString,
|
|
17
|
+
suggestions,
|
|
18
|
+
dataId,
|
|
19
|
+
getCustomEmptyState,
|
|
20
|
+
palette,
|
|
21
|
+
i18nKeys,
|
|
22
|
+
htmlId,
|
|
23
|
+
a11y
|
|
24
|
+
} = this.props;
|
|
25
|
+
let {
|
|
26
|
+
loadingText = 'Loading',
|
|
27
|
+
emptyText = emptyMessage,
|
|
28
|
+
noMoreText = noMoreOptionsMessage,
|
|
29
|
+
searchEmptyText = searchEmptyMessage
|
|
30
|
+
} = i18nKeys;
|
|
31
|
+
let className = ` ${style[palette]}`;
|
|
32
|
+
let {
|
|
33
|
+
role = 'alert'
|
|
34
|
+
} = a11y;
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isLoading ? /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: className,
|
|
37
|
+
"data-id": `${dataId}_Loading`,
|
|
38
|
+
"data-test-id": `${dataId}_Loading`,
|
|
39
|
+
role: role,
|
|
40
|
+
id: htmlId
|
|
41
|
+
}, loadingText) : searchString.length && suggestions.length === 0 ? getCustomEmptyState ? getCustomEmptyState() : /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: className,
|
|
43
|
+
"data-id": `${dataId}_srchEmptyMsg`,
|
|
44
|
+
"data-test-id": `${dataId}_srchEmptyMsg`,
|
|
45
|
+
role: role,
|
|
46
|
+
id: htmlId
|
|
47
|
+
}, searchEmptyText || emptyText) : options.length === 0 ? /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: className,
|
|
49
|
+
"data-id": `${dataId}_noOptnsMsg`,
|
|
50
|
+
"data-test-id": `${dataId}_noOptnsMsg`,
|
|
51
|
+
role: role,
|
|
52
|
+
id: htmlId
|
|
53
|
+
}, emptyText) : /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: className,
|
|
55
|
+
"data-id": `${dataId}_NoMoreOptionMsg`,
|
|
56
|
+
"data-test-id": `${dataId}_NoMoreOptionMsg`,
|
|
57
|
+
role: role,
|
|
58
|
+
id: htmlId
|
|
59
|
+
}, noMoreText || emptyText));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
EmptyState.propTypes = EmptyState_propTypes;
|
|
64
|
+
EmptyState.defaultProps = EmptyState_defaultProps;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from '../../Button/Button';
|
|
3
|
+
import { Container, Box } from '../../Layout';
|
|
4
|
+
import { defaultProps } from '../../../MultiSelect/MobileHeader/props/defaultProps';
|
|
5
|
+
import { propTypes } from '../../../MultiSelect/MobileHeader/props/propTypes';
|
|
6
|
+
import style from '../../../MultiSelect/MobileHeader/MobileHeader.module.css';
|
|
7
|
+
export default function MobileHeader(props) {
|
|
8
|
+
let {
|
|
9
|
+
i18nKeys,
|
|
10
|
+
onClick,
|
|
11
|
+
selectedOptions,
|
|
12
|
+
children
|
|
13
|
+
} = props;
|
|
14
|
+
const i18nText = Object.assign({}, i18nKeys, {
|
|
15
|
+
mobileHeaderText: i18nKeys.mobileHeaderText ? `${i18nKeys.mobileHeaderText}` : `${selectedOptions.length} Selected`
|
|
16
|
+
});
|
|
17
|
+
let {
|
|
18
|
+
mobilePrimaryButtonText,
|
|
19
|
+
mobileSecondaryButtonText,
|
|
20
|
+
mobileHeaderText
|
|
21
|
+
} = i18nText;
|
|
22
|
+
const showMobileHeader = i18nKeys.mobileHeaderText || !i18nKeys.mobileHeaderText && selectedOptions.length >= 1;
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: style.container
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
26
|
+
isCover: false,
|
|
27
|
+
align: "vertical",
|
|
28
|
+
alignContent: "between",
|
|
29
|
+
alignBox: "row",
|
|
30
|
+
className: style.header
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
32
|
+
className: style.cardHeading,
|
|
33
|
+
"data-title": showMobileHeader ? mobileHeaderText : null,
|
|
34
|
+
flexible: true
|
|
35
|
+
}, showMobileHeader && mobileHeaderText), /*#__PURE__*/React.createElement(Box, {
|
|
36
|
+
shrink: true
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
38
|
+
onClick: onClick,
|
|
39
|
+
isBold: true,
|
|
40
|
+
size: "medium",
|
|
41
|
+
text: selectedOptions.length >= 1 ? mobilePrimaryButtonText : mobileSecondaryButtonText,
|
|
42
|
+
palette: "plainPrimary",
|
|
43
|
+
customClass: {
|
|
44
|
+
customButton: style.buttonText
|
|
45
|
+
},
|
|
46
|
+
"data-title": mobilePrimaryButtonText
|
|
47
|
+
}))), children);
|
|
48
|
+
}
|
|
49
|
+
MobileHeader.defaultProps = defaultProps;
|
|
50
|
+
MobileHeader.propTypes = propTypes;
|