@zohodesk/components 1.4.8 → 1.4.10-exp-0
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 +22 -0
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +16 -8
- package/es/MultiSelect/AdvancedMultiSelect.js +13 -6
- package/es/MultiSelect/EmptyState.js +2 -1
- package/es/MultiSelect/MultiSelect.js +36 -15
- package/es/MultiSelect/MultiSelectWithAvatar.js +9 -2
- package/es/MultiSelect/SelectedOptions.js +4 -2
- package/es/MultiSelect/Suggestions.js +174 -97
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/es/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/es/MultiSelect/constants.js +6 -0
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +18 -55
- package/es/Select/Select.js +13 -3
- package/es/Select/SelectWithIcon.js +1 -1
- package/es/Select/__tests__/Select.spec.js +16 -8
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/es/Select/props/defaultProps.js +1 -0
- package/es/Select/props/propTypes.js +1 -0
- package/es/utils/Common.js +3 -2
- package/es/utils/dropDownUtils.js +28 -7
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +94 -83
- package/lib/MultiSelect/AdvancedMultiSelect.js +16 -7
- package/lib/MultiSelect/EmptyState.js +3 -1
- package/lib/MultiSelect/MultiSelect.js +39 -15
- package/lib/MultiSelect/MultiSelectWithAvatar.js +11 -3
- package/lib/MultiSelect/SelectedOptions.js +4 -2
- package/lib/MultiSelect/Suggestions.js +176 -100
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/lib/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/lib/MultiSelect/constants.js +13 -0
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +17 -55
- package/lib/Select/Select.js +13 -2
- package/lib/Select/SelectWithIcon.js +1 -1
- package/lib/Select/__tests__/Select.spec.js +165 -155
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/lib/Select/props/defaultProps.js +1 -0
- package/lib/Select/props/propTypes.js +1 -0
- package/lib/utils/Common.js +5 -3
- package/lib/utils/dropDownUtils.js +27 -4
- package/package.json +9 -8
|
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _propTypes = require("./props/propTypes");
|
|
13
13
|
|
|
14
14
|
var _defaultProps = require("./props/defaultProps");
|
|
15
15
|
|
|
16
|
+
var _virtualizer = require("@zohodesk/virtualizer");
|
|
17
|
+
|
|
16
18
|
var _ListItem = _interopRequireDefault(require("../ListItem/ListItem"));
|
|
17
19
|
|
|
18
20
|
var _ListItemWithAvatar = _interopRequireDefault(require("../ListItem/ListItemWithAvatar"));
|
|
@@ -21,8 +23,14 @@ var _ListItemWithIcon = _interopRequireDefault(require("../ListItem/ListItemWith
|
|
|
21
23
|
|
|
22
24
|
var _Layout = require("../Layout");
|
|
23
25
|
|
|
26
|
+
var _Common = require("../utils/Common");
|
|
27
|
+
|
|
24
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
29
|
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
26
34
|
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); }
|
|
27
35
|
|
|
28
36
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -51,22 +59,39 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
51
59
|
|
|
52
60
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
61
|
|
|
62
|
+
function SuggestionsVirtualizerContainer(_ref) {
|
|
63
|
+
var eleRef = _ref.eleRef,
|
|
64
|
+
children = _ref.children,
|
|
65
|
+
setVirtualizerContainerRefFunction = _ref.setVirtualizerContainerRefFunction;
|
|
66
|
+
(0, _react.useMemo)(function () {
|
|
67
|
+
typeof setVirtualizerContainerRefFunction === 'function' && setVirtualizerContainerRefFunction(eleRef);
|
|
68
|
+
}, [eleRef, setVirtualizerContainerRefFunction]);
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
var Suggestions = /*#__PURE__*/function (_React$PureComponent) {
|
|
55
73
|
_inherits(Suggestions, _React$PureComponent);
|
|
56
74
|
|
|
57
75
|
var _super = _createSuper(Suggestions);
|
|
58
76
|
|
|
59
|
-
function Suggestions() {
|
|
77
|
+
function Suggestions(props) {
|
|
78
|
+
var _this;
|
|
79
|
+
|
|
60
80
|
_classCallCheck(this, Suggestions);
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
_this = _super.call(this, props);
|
|
83
|
+
_this.renderSuggestionList = _this.renderSuggestionList.bind(_assertThisInitialized(_this));
|
|
84
|
+
_this.renderVirtualizerSuggestionListItem = _this.renderVirtualizerSuggestionListItem.bind(_assertThisInitialized(_this));
|
|
85
|
+
return _this;
|
|
63
86
|
}
|
|
64
87
|
|
|
65
88
|
_createClass(Suggestions, [{
|
|
66
|
-
key: "
|
|
67
|
-
value: function
|
|
89
|
+
key: "renderSuggestionList",
|
|
90
|
+
value: function renderSuggestionList(_ref2) {
|
|
91
|
+
var suggestion = _ref2.suggestion,
|
|
92
|
+
index = _ref2.index,
|
|
93
|
+
ref = _ref2.ref;
|
|
68
94
|
var _this$props = this.props,
|
|
69
|
-
suggestions = _this$props.suggestions,
|
|
70
95
|
getRef = _this$props.getRef,
|
|
71
96
|
hoverOption = _this$props.hoverOption,
|
|
72
97
|
onClick = _this$props.onClick,
|
|
@@ -74,110 +99,69 @@ var Suggestions = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
74
99
|
needTick = _this$props.needTick,
|
|
75
100
|
needBorder = _this$props.needBorder,
|
|
76
101
|
_this$props$selectedO = _this$props.selectedOptions,
|
|
77
|
-
selectedOptions = _this$props$selectedO === void 0 ?
|
|
102
|
+
selectedOptions = _this$props$selectedO === void 0 ? _Common.DUMMY_ARRAY : _this$props$selectedO,
|
|
78
103
|
activeId = _this$props.activeId,
|
|
79
104
|
hoverId = _this$props.hoverId,
|
|
80
|
-
dataId = _this$props.dataId,
|
|
81
105
|
listItemSize = _this$props.listItemSize,
|
|
82
|
-
className = _this$props.className,
|
|
83
106
|
avatarPalette = _this$props.avatarPalette,
|
|
84
107
|
palette = _this$props.palette,
|
|
85
|
-
htmlId = _this$props.htmlId,
|
|
86
108
|
a11y = _this$props.a11y,
|
|
87
|
-
needMultiLineText = _this$props.needMultiLineText
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return /*#__PURE__*/_react["default"].createElement(_ListItemWithAvatar["default"], _extends({}, commonProps, {
|
|
132
|
-
autoHover: false,
|
|
133
|
-
getRef: getRef,
|
|
134
|
-
highlight: isHighlight,
|
|
135
|
-
id: id,
|
|
136
|
-
imgSrc: photoURL,
|
|
137
|
-
key: "".concat(id, "avatarListItem"),
|
|
138
|
-
name: value,
|
|
139
|
-
onClick: onClick,
|
|
140
|
-
onMouseEnter: onMouseEnter,
|
|
141
|
-
value: value,
|
|
142
|
-
title: value,
|
|
143
|
-
needTick: needTick,
|
|
144
|
-
needBorder: needBorder,
|
|
145
|
-
active: isActive,
|
|
146
|
-
size: listItemSize,
|
|
147
|
-
avatarPalette: avatarPalette,
|
|
148
|
-
palette: palette,
|
|
149
|
-
a11y: list_a11y,
|
|
150
|
-
secondaryValue: secondaryValue
|
|
151
|
-
}));
|
|
152
|
-
} else if (optionType === 'icon') {
|
|
153
|
-
return /*#__PURE__*/_react["default"].createElement(_ListItemWithIcon["default"], _extends({}, commonProps, {
|
|
154
|
-
autoHover: false,
|
|
155
|
-
getRef: getRef,
|
|
156
|
-
highlight: isHighlight,
|
|
157
|
-
id: id,
|
|
158
|
-
key: "".concat(id, "iconListItem"),
|
|
159
|
-
onClick: onClick,
|
|
160
|
-
onMouseEnter: onMouseEnter,
|
|
161
|
-
value: value,
|
|
162
|
-
title: value,
|
|
163
|
-
iconName: icon,
|
|
164
|
-
needTick: needTick,
|
|
165
|
-
needBorder: needBorder,
|
|
166
|
-
active: isActive,
|
|
167
|
-
iconSize: iconSize,
|
|
168
|
-
size: listItemSize,
|
|
169
|
-
palette: palette,
|
|
170
|
-
a11y: list_a11y,
|
|
171
|
-
secondaryValue: secondaryValue
|
|
172
|
-
}));
|
|
109
|
+
needMultiLineText = _this$props.needMultiLineText,
|
|
110
|
+
limit = _this$props.limit,
|
|
111
|
+
limitReachedMessage = _this$props.limitReachedMessage;
|
|
112
|
+
var id = suggestion.id,
|
|
113
|
+
value = suggestion.value,
|
|
114
|
+
secondaryValue = suggestion.secondaryValue,
|
|
115
|
+
photoURL = suggestion.photoURL,
|
|
116
|
+
icon = suggestion.icon,
|
|
117
|
+
optionType = suggestion.optionType,
|
|
118
|
+
iconSize = suggestion.iconSize,
|
|
119
|
+
isDisabled = suggestion.isDisabled,
|
|
120
|
+
listItemProps = suggestion.listItemProps,
|
|
121
|
+
_suggestion$listItemC = suggestion.listItemCustomProps,
|
|
122
|
+
listItemCustomProps = _suggestion$listItemC === void 0 ? _Common.DUMMY_OBJECT : _suggestion$listItemC;
|
|
123
|
+
var isActive = activeId === id || selectedOptions.indexOf(id) >= 0;
|
|
124
|
+
var isHighlight = hoverOption === index || id === hoverId ? true : false;
|
|
125
|
+
var selectedOptionsLength = selectedOptions.length;
|
|
126
|
+
var isLimitReached = selectedOptionsLength >= limit && !isActive;
|
|
127
|
+
var list_a11y = Object.assign({}, a11y, {
|
|
128
|
+
ariaSelected: isActive,
|
|
129
|
+
ariaLabel: value,
|
|
130
|
+
'data-a11y-list-active': isHighlight
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
var commonProps = _objectSpread({
|
|
134
|
+
isDisabled: isDisabled ? isDisabled : isLimitReached,
|
|
135
|
+
needMultiLineText: needMultiLineText
|
|
136
|
+
}, listItemCustomProps);
|
|
137
|
+
|
|
138
|
+
if (listItemProps) {
|
|
139
|
+
commonProps.customProps = {
|
|
140
|
+
ListItemProps: _objectSpread({}, listItemProps)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (isLimitReached) {
|
|
145
|
+
commonProps.disableTitle = limitReachedMessage;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getListItemRef(ele, index, id) {
|
|
149
|
+
ref && ref(ele);
|
|
150
|
+
|
|
151
|
+
if (typeof getRef === 'function') {
|
|
152
|
+
getRef(ele, index, id);
|
|
173
153
|
}
|
|
154
|
+
}
|
|
174
155
|
|
|
175
|
-
|
|
156
|
+
if (optionType === 'avatar') {
|
|
157
|
+
return /*#__PURE__*/_react["default"].createElement(_ListItemWithAvatar["default"], _extends({}, commonProps, {
|
|
176
158
|
autoHover: false,
|
|
177
|
-
getRef:
|
|
159
|
+
getRef: getListItemRef,
|
|
178
160
|
highlight: isHighlight,
|
|
179
161
|
id: id,
|
|
180
|
-
|
|
162
|
+
imgSrc: photoURL,
|
|
163
|
+
key: "".concat(id, "avatarListItem"),
|
|
164
|
+
name: value,
|
|
181
165
|
onClick: onClick,
|
|
182
166
|
onMouseEnter: onMouseEnter,
|
|
183
167
|
value: value,
|
|
@@ -186,9 +170,101 @@ var Suggestions = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
186
170
|
needBorder: needBorder,
|
|
187
171
|
active: isActive,
|
|
188
172
|
size: listItemSize,
|
|
173
|
+
avatarPalette: avatarPalette,
|
|
189
174
|
palette: palette,
|
|
190
|
-
a11y: list_a11y
|
|
175
|
+
a11y: list_a11y,
|
|
176
|
+
secondaryValue: secondaryValue
|
|
191
177
|
}));
|
|
178
|
+
} else if (optionType === 'icon') {
|
|
179
|
+
return /*#__PURE__*/_react["default"].createElement(_ListItemWithIcon["default"], _extends({}, commonProps, {
|
|
180
|
+
autoHover: false,
|
|
181
|
+
getRef: getListItemRef,
|
|
182
|
+
highlight: isHighlight,
|
|
183
|
+
id: id,
|
|
184
|
+
key: "".concat(id, "iconListItem"),
|
|
185
|
+
onClick: onClick,
|
|
186
|
+
onMouseEnter: onMouseEnter,
|
|
187
|
+
value: value,
|
|
188
|
+
title: value,
|
|
189
|
+
iconName: icon,
|
|
190
|
+
needTick: needTick,
|
|
191
|
+
needBorder: needBorder,
|
|
192
|
+
active: isActive,
|
|
193
|
+
iconSize: iconSize,
|
|
194
|
+
size: listItemSize,
|
|
195
|
+
palette: palette,
|
|
196
|
+
a11y: list_a11y,
|
|
197
|
+
secondaryValue: secondaryValue
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return /*#__PURE__*/_react["default"].createElement(_ListItem["default"], _extends({}, commonProps, {
|
|
202
|
+
autoHover: false,
|
|
203
|
+
getRef: getListItemRef,
|
|
204
|
+
highlight: isHighlight,
|
|
205
|
+
id: id,
|
|
206
|
+
key: "".concat(id, "listItem"),
|
|
207
|
+
onClick: onClick,
|
|
208
|
+
onMouseEnter: onMouseEnter,
|
|
209
|
+
value: value,
|
|
210
|
+
title: value,
|
|
211
|
+
needTick: needTick,
|
|
212
|
+
needBorder: needBorder,
|
|
213
|
+
active: isActive,
|
|
214
|
+
size: listItemSize,
|
|
215
|
+
palette: palette,
|
|
216
|
+
a11y: list_a11y
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "renderVirtualizerSuggestionListItem",
|
|
221
|
+
value: function renderVirtualizerSuggestionListItem(_ref3) {
|
|
222
|
+
var index = _ref3.index,
|
|
223
|
+
ref = _ref3.ref;
|
|
224
|
+
var suggestions = this.props.suggestions;
|
|
225
|
+
var suggestion = suggestions[index];
|
|
226
|
+
return this.renderSuggestionList({
|
|
227
|
+
suggestion: suggestion,
|
|
228
|
+
index: index,
|
|
229
|
+
ref: ref
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "render",
|
|
234
|
+
value: function render() {
|
|
235
|
+
var _this2 = this;
|
|
236
|
+
|
|
237
|
+
var _this$props2 = this.props,
|
|
238
|
+
suggestions = _this$props2.suggestions,
|
|
239
|
+
dataId = _this$props2.dataId,
|
|
240
|
+
className = _this$props2.className,
|
|
241
|
+
isVirtualizerEnabled = _this$props2.isVirtualizerEnabled,
|
|
242
|
+
htmlId = _this$props2.htmlId,
|
|
243
|
+
a11y = _this$props2.a11y,
|
|
244
|
+
setVirtualizerContainerRefFunction = _this$props2.setVirtualizerContainerRefFunction;
|
|
245
|
+
var ariaParentRole = a11y.ariaParentRole,
|
|
246
|
+
ariaMultiselectable = a11y.ariaMultiselectable;
|
|
247
|
+
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
248
|
+
isCover: false,
|
|
249
|
+
role: ariaParentRole,
|
|
250
|
+
id: htmlId,
|
|
251
|
+
tabindex: "0",
|
|
252
|
+
"aria-multiselectable": ariaMultiselectable
|
|
253
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
254
|
+
dataId: "".concat(dataId),
|
|
255
|
+
className: className ? className : ''
|
|
256
|
+
}, isVirtualizerEnabled ? /*#__PURE__*/_react["default"].createElement(_virtualizer.Virtualizer, {
|
|
257
|
+
containerType: SuggestionsVirtualizerContainer,
|
|
258
|
+
elementRenderer: this.renderVirtualizerSuggestionListItem,
|
|
259
|
+
elementsCount: suggestions.length,
|
|
260
|
+
isElementsFixedHeight: false,
|
|
261
|
+
dataId: "".concat(dataId, "_virtualizer"),
|
|
262
|
+
setVirtualizerContainerRefFunction: setVirtualizerContainerRefFunction
|
|
263
|
+
}) : suggestions.map(function (suggestion, index) {
|
|
264
|
+
return _this2.renderSuggestionList({
|
|
265
|
+
suggestion: suggestion,
|
|
266
|
+
index: index
|
|
267
|
+
});
|
|
192
268
|
})));
|
|
193
269
|
}
|
|
194
270
|
}]);
|
|
@@ -8,6 +8,8 @@ var _MultiSelect = _interopRequireDefault(require("../MultiSelect"));
|
|
|
8
8
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
|
|
11
|
+
var testData = ['text1', 'text2', 'text3', 'text4', 'text5', 'text6', 'text7', 'text8', 'text9', 'text10'];
|
|
12
|
+
var testSelectedData = ['text1', 'text2', 'text3'];
|
|
11
13
|
describe('MultiSelect', function () {
|
|
12
14
|
test('rendering the defult props', function () {
|
|
13
15
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_MultiSelect["default"], null)),
|
|
@@ -15,4 +17,27 @@ describe('MultiSelect', function () {
|
|
|
15
17
|
|
|
16
18
|
expect(asFragment()).toMatchSnapshot();
|
|
17
19
|
});
|
|
20
|
+
test('rendering with limit feature', function () {
|
|
21
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_MultiSelect["default"], {
|
|
22
|
+
valueField: "id",
|
|
23
|
+
textField: "text",
|
|
24
|
+
options: testData,
|
|
25
|
+
selectedOptions: testSelectedData,
|
|
26
|
+
needSelectAll: true,
|
|
27
|
+
selectAllText: "Select All",
|
|
28
|
+
placeHolder: "Select Text",
|
|
29
|
+
i18nKeys: {
|
|
30
|
+
clearText: 'Clear Selected Items',
|
|
31
|
+
loadingText: 'Fetching...',
|
|
32
|
+
emptyText: 'No Options .',
|
|
33
|
+
noMoreText: 'No More Options .',
|
|
34
|
+
searchEmptyText: 'No Matches Found .'
|
|
35
|
+
},
|
|
36
|
+
needResponsive: true,
|
|
37
|
+
limit: 3
|
|
38
|
+
})),
|
|
39
|
+
asFragment = _render2.asFragment;
|
|
40
|
+
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
});
|
|
18
43
|
});
|
|
@@ -8,6 +8,53 @@ var _Suggestions = _interopRequireDefault(require("../Suggestions"));
|
|
|
8
8
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
|
|
11
|
+
var sampleData = [{
|
|
12
|
+
"id": 2,
|
|
13
|
+
"value": "text2",
|
|
14
|
+
"optionType": "default",
|
|
15
|
+
"listItemProps": {
|
|
16
|
+
"style": {
|
|
17
|
+
"color": "red"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
"id": 3,
|
|
22
|
+
"value": "text3",
|
|
23
|
+
"optionType": "default",
|
|
24
|
+
"listItemProps": {
|
|
25
|
+
"style": {
|
|
26
|
+
"color": "blue"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
"id": 4,
|
|
31
|
+
"value": "text4",
|
|
32
|
+
"optionType": "default"
|
|
33
|
+
}, {
|
|
34
|
+
"id": 5,
|
|
35
|
+
"value": "text5",
|
|
36
|
+
"optionType": "default"
|
|
37
|
+
}, {
|
|
38
|
+
"id": 6,
|
|
39
|
+
"value": "text6",
|
|
40
|
+
"optionType": "default"
|
|
41
|
+
}, {
|
|
42
|
+
"id": 7,
|
|
43
|
+
"value": "text7",
|
|
44
|
+
"optionType": "default"
|
|
45
|
+
}, {
|
|
46
|
+
"id": 8,
|
|
47
|
+
"value": "text8",
|
|
48
|
+
"optionType": "default"
|
|
49
|
+
}, {
|
|
50
|
+
"id": 9,
|
|
51
|
+
"value": "text9",
|
|
52
|
+
"optionType": "default"
|
|
53
|
+
}, {
|
|
54
|
+
"id": 10,
|
|
55
|
+
"value": "text10",
|
|
56
|
+
"optionType": "default"
|
|
57
|
+
}];
|
|
11
58
|
describe('Suggestions', function () {
|
|
12
59
|
test('rendering the defult props', function () {
|
|
13
60
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
@@ -17,4 +64,15 @@ describe('Suggestions', function () {
|
|
|
17
64
|
|
|
18
65
|
expect(asFragment()).toMatchSnapshot();
|
|
19
66
|
});
|
|
67
|
+
test('rendering with limit props', function () {
|
|
68
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
69
|
+
selectedOptions: [1, 2, 3, 4],
|
|
70
|
+
suggestions: sampleData,
|
|
71
|
+
limit: 3,
|
|
72
|
+
limitReachedMessage: "Limit Reached"
|
|
73
|
+
})),
|
|
74
|
+
asFragment = _render2.asFragment;
|
|
75
|
+
|
|
76
|
+
expect(asFragment()).toMatchSnapshot();
|
|
77
|
+
});
|
|
20
78
|
});
|