@zohodesk/components 1.0.0-temp-234 → 1.0.0-temp-235
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 +0 -22
- package/es/ListItem/ListItem.js +3 -7
- package/es/ListItem/ListItemWithAvatar.js +6 -12
- package/es/ListItem/ListItemWithCheckBox.js +6 -12
- package/es/ListItem/ListItemWithIcon.js +5 -11
- package/es/ListItem/ListItemWithRadio.js +6 -12
- package/es/ListItem/__tests__/ListItem.spec.js +0 -19
- package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +0 -19
- package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +0 -19
- package/es/ListItem/__tests__/ListItemWithIcon.spec.js +0 -17
- package/es/ListItem/__tests__/ListItemWithRadio.spec.js +0 -19
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +0 -78
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +46 -140
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +49 -251
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +50 -144
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +52 -252
- package/es/ListItem/props/propTypes.js +5 -15
- package/es/MultiSelect/MultiSelect.js +1 -8
- package/es/Select/GroupSelect.js +2 -4
- package/es/Select/Select.js +1 -7
- package/es/Select/SelectWithAvatar.js +3 -14
- package/es/Select/SelectWithIcon.js +2 -6
- package/es/Select/props/defaultProps.js +0 -1
- package/es/Select/props/propTypes.js +0 -5
- package/es/Typography/Typography.js +9 -2
- package/es/Typography/__tests__/Typography.spec.js +334 -0
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +451 -0
- package/es/Typography/highlight.js +144 -0
- package/es/Typography/props/defaultProps.js +2 -1
- package/es/Typography/props/propTypes.js +26 -1
- package/es/utils/dropDownUtils.js +3 -12
- package/lib/ListItem/ListItem.js +3 -8
- package/lib/ListItem/ListItemWithAvatar.js +6 -13
- package/lib/ListItem/ListItemWithCheckBox.js +6 -13
- package/lib/ListItem/ListItemWithIcon.js +5 -11
- package/lib/ListItem/ListItemWithRadio.js +6 -13
- package/lib/ListItem/__tests__/ListItem.spec.js +0 -23
- package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +0 -23
- package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +0 -23
- package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +0 -21
- package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +0 -23
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +0 -78
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +46 -140
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +49 -251
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +50 -144
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +52 -252
- package/lib/ListItem/props/propTypes.js +6 -15
- package/lib/MultiSelect/MultiSelect.js +2 -6
- package/lib/Select/GroupSelect.js +3 -4
- package/lib/Select/Select.js +1 -7
- package/lib/Select/SelectWithAvatar.js +6 -14
- package/lib/Select/SelectWithIcon.js +3 -6
- package/lib/Select/props/defaultProps.js +0 -1
- package/lib/Select/props/propTypes.js +0 -5
- package/lib/Typography/Typography.js +9 -2
- package/lib/Typography/__tests__/Typography.spec.js +342 -0
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +451 -0
- package/lib/Typography/highlight.js +151 -0
- package/lib/Typography/props/defaultProps.js +2 -1
- package/lib/Typography/props/propTypes.js +31 -1
- package/lib/utils/dropDownUtils.js +3 -14
- package/package.json +1 -1
package/lib/Select/Select.js
CHANGED
|
@@ -323,17 +323,13 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
323
323
|
textField = props.textField,
|
|
324
324
|
allowValueFallback = props.allowValueFallback,
|
|
325
325
|
_props$customProps = props.customProps,
|
|
326
|
-
customProps = _props$customProps === void 0 ? _dropDownUtils.dummyObj : _props$customProps
|
|
327
|
-
searchFields = props.searchFields,
|
|
328
|
-
secondaryField = props.secondaryField;
|
|
326
|
+
customProps = _props$customProps === void 0 ? _dropDownUtils.dummyObj : _props$customProps;
|
|
329
327
|
var _customProps$listItem = customProps.listItemProps,
|
|
330
328
|
listItemProps = _customProps$listItem === void 0 ? _dropDownUtils.dummyObj : _customProps$listItem;
|
|
331
329
|
return this.formatOptions({
|
|
332
330
|
options: options,
|
|
333
331
|
valueField: valueField,
|
|
334
332
|
textField: textField,
|
|
335
|
-
secondaryField: secondaryField,
|
|
336
|
-
searchFields: searchFields,
|
|
337
333
|
listItemProps: listItemProps,
|
|
338
334
|
allowValueFallback: allowValueFallback
|
|
339
335
|
});
|
|
@@ -492,7 +488,6 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
492
488
|
value: function handleFilterSuggestions() {
|
|
493
489
|
var _this$props5 = this.props,
|
|
494
490
|
needLocalSearch = _this$props5.needLocalSearch,
|
|
495
|
-
searchFields = _this$props5.searchFields,
|
|
496
491
|
_this$props5$excludeO = _this$props5.excludeOptions,
|
|
497
492
|
excludeOptions = _this$props5$excludeO === void 0 ? dummyArray : _this$props5$excludeO;
|
|
498
493
|
var _this$state3 = this.state,
|
|
@@ -510,7 +505,6 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
|
|
|
510
505
|
options: options,
|
|
511
506
|
selectedOptions: excludeOptions,
|
|
512
507
|
searchStr: searchStr,
|
|
513
|
-
searchFields: searchFields,
|
|
514
508
|
needSearch: needLocalSearch
|
|
515
509
|
}),
|
|
516
510
|
suggestions = _this$getFilterSugges.suggestions,
|
|
@@ -51,8 +51,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
51
51
|
|
|
52
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
53
53
|
|
|
54
|
-
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); }
|
|
55
|
-
|
|
56
54
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
57
55
|
|
|
58
56
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -101,14 +99,12 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
101
99
|
valueField = props.valueField,
|
|
102
100
|
textField = props.textField,
|
|
103
101
|
imageField = props.imageField,
|
|
104
|
-
secondaryField = props.secondaryField,
|
|
105
102
|
allowValueFallback = props.allowValueFallback;
|
|
106
103
|
return this.formatOptions({
|
|
107
104
|
options: options,
|
|
108
105
|
valueField: valueField,
|
|
109
106
|
textField: textField,
|
|
110
107
|
imageField: imageField,
|
|
111
|
-
secondaryField: secondaryField,
|
|
112
108
|
optionType: 'avatar',
|
|
113
109
|
allowValueFallback: allowValueFallback
|
|
114
110
|
});
|
|
@@ -219,7 +215,6 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
219
215
|
needEffect = _this$props.needEffect,
|
|
220
216
|
isLoading = _this$props.isLoading,
|
|
221
217
|
dataSelectorId = _this$props.dataSelectorId,
|
|
222
|
-
customProps = _this$props.customProps,
|
|
223
218
|
getTargetRef = _this$props.getTargetRef;
|
|
224
219
|
i18nKeys = Object.assign({}, i18nKeys, {
|
|
225
220
|
emptyText: i18nKeys.emptyText || emptyMessage,
|
|
@@ -241,9 +236,6 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
241
236
|
|
|
242
237
|
var setAriaId = this.getNextAriaId();
|
|
243
238
|
var ariaErrorId = this.getNextAriaId();
|
|
244
|
-
var TextBoxProps = customProps.TextBoxProps,
|
|
245
|
-
DropdownSearchTextBoxProps = customProps.DropdownSearchTextBoxProps,
|
|
246
|
-
SuggestionsProps = customProps.SuggestionsProps;
|
|
247
239
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
248
240
|
className: "".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(isReadOnly ? _MultiSelectModule["default"].readOnly : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : '', " ").concat(className ? className : ''),
|
|
249
241
|
"data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
|
|
@@ -275,7 +267,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
275
267
|
flexible: true,
|
|
276
268
|
className: _MultiSelectModule["default"].textBox,
|
|
277
269
|
dataId: "".concat(dataId, "_textBox")
|
|
278
|
-
}, /*#__PURE__*/_react["default"].createElement(_TextBox["default"],
|
|
270
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextBox["default"], {
|
|
279
271
|
a11y: {
|
|
280
272
|
ariaActivedescendant: selectedId,
|
|
281
273
|
role: 'combobox',
|
|
@@ -304,7 +296,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
304
296
|
borderColor: borderColor,
|
|
305
297
|
htmlId: htmlId,
|
|
306
298
|
autoComplete: false
|
|
307
|
-
}
|
|
299
|
+
}))), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/_react["default"].createElement(_CustomResponsive.ResponsiveReceiver, {
|
|
308
300
|
query: this.responsiveFunc,
|
|
309
301
|
responsiveId: "Helmet"
|
|
310
302
|
}, function (_ref4) {
|
|
@@ -335,7 +327,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
335
327
|
onScroll: _this2.handleScroll
|
|
336
328
|
}, needSearch ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
337
329
|
className: "".concat(_SelectModule["default"].search, " ").concat(_SelectModule["default"][size])
|
|
338
|
-
}, /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"],
|
|
330
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"], {
|
|
339
331
|
inputRef: _this2.searchInputRef,
|
|
340
332
|
maxLength: maxLength,
|
|
341
333
|
onChange: _this2.handleSearch,
|
|
@@ -351,7 +343,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
351
343
|
ariaDescribedby: ariaErrorId
|
|
352
344
|
},
|
|
353
345
|
autoComplete: false
|
|
354
|
-
}
|
|
346
|
+
}))) : null, /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
|
|
355
347
|
shrink: true,
|
|
356
348
|
customClass: !tabletMode && dropBoxSize ? _MultiSelectModule["default"][dropBoxSize] : '',
|
|
357
349
|
eleRef: _this2.suggestionContainerRef
|
|
@@ -362,7 +354,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
362
354
|
a11y: {
|
|
363
355
|
role: 'heading'
|
|
364
356
|
}
|
|
365
|
-
})) : null, suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"],
|
|
357
|
+
})) : null, suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
366
358
|
dataId: "".concat(dataId, "_Options"),
|
|
367
359
|
activeId: selectedId,
|
|
368
360
|
suggestions: suggestions,
|
|
@@ -379,7 +371,7 @@ var SelectWithAvatarComponent = /*#__PURE__*/function (_SelectComponent) {
|
|
|
379
371
|
ariaParentRole: 'listbox',
|
|
380
372
|
role: 'option'
|
|
381
373
|
}
|
|
382
|
-
}
|
|
374
|
+
}) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
|
|
383
375
|
isLoading: isFetchingOptions,
|
|
384
376
|
options: options,
|
|
385
377
|
searchString: searchStr,
|
|
@@ -401,7 +401,6 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
401
401
|
targetOffset = _this$props7.targetOffset,
|
|
402
402
|
isRestrictScroll = _this$props7.isRestrictScroll,
|
|
403
403
|
valueKey = _this$props7.valueKey,
|
|
404
|
-
secondaryValueKey = _this$props7.secondaryValueKey,
|
|
405
404
|
idKey = _this$props7.idKey,
|
|
406
405
|
needListBorder = _this$props7.needListBorder,
|
|
407
406
|
needTick = _this$props7.needTick,
|
|
@@ -441,8 +440,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
441
440
|
_customProps$Dropdown = customProps.DropdownSearchTextBoxProps,
|
|
442
441
|
DropdownSearchTextBoxProps = _customProps$Dropdown === void 0 ? {} : _customProps$Dropdown,
|
|
443
442
|
_customProps$TextBoxI = customProps.TextBoxIconProps,
|
|
444
|
-
TextBoxIconProps = _customProps$TextBoxI === void 0 ? {} : _customProps$TextBoxI
|
|
445
|
-
ListItemProps = customProps.ListItemProps;
|
|
443
|
+
TextBoxIconProps = _customProps$TextBoxI === void 0 ? {} : _customProps$TextBoxI;
|
|
446
444
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
447
445
|
className: "".concat(_SelectModule["default"].container, " ").concat(_SelectModule["default"]["box_".concat(size)], " ").concat(isReadOnly ? _SelectModule["default"].readonly : '', " ").concat(borderColor === 'transparent' ? _SelectModule["default"].transparentContainer : ''),
|
|
448
446
|
"data-title": isDisabled ? title : null,
|
|
@@ -575,10 +573,9 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
575
573
|
var iconName = options.iconName,
|
|
576
574
|
iconSize = options.iconSize,
|
|
577
575
|
iconColor = options.iconColor;
|
|
578
|
-
return /*#__PURE__*/_react["default"].createElement(_ListItemWithIcon["default"],
|
|
576
|
+
return /*#__PURE__*/_react["default"].createElement(_ListItemWithIcon["default"], {
|
|
579
577
|
key: options[idKey],
|
|
580
578
|
value: options[valueKey],
|
|
581
|
-
secondaryValue: options[secondaryValueKey],
|
|
582
579
|
size: "medium",
|
|
583
580
|
onClick: _this5.handleChange,
|
|
584
581
|
id: options[idKey],
|
|
@@ -600,7 +597,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
|
|
|
600
597
|
ariaSelected: selectedId === options[idKey],
|
|
601
598
|
ariaLabel: options[valueKey]
|
|
602
599
|
}
|
|
603
|
-
}
|
|
600
|
+
});
|
|
604
601
|
})) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
|
|
605
602
|
isLoading: isFetchingOptions,
|
|
606
603
|
options: options,
|
|
@@ -80,8 +80,6 @@ var Select_propTypes = {
|
|
|
80
80
|
searchBoxSize: _propTypes["default"].string,
|
|
81
81
|
searchDebounceTime: _propTypes["default"].number,
|
|
82
82
|
searchEmptyMessage: _propTypes["default"].string,
|
|
83
|
-
searchFields: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
84
|
-
secondaryField: _propTypes["default"].string,
|
|
85
83
|
selectedValue: _propTypes["default"].oneOfType([_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]), _propTypes["default"].shape({
|
|
86
84
|
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
87
85
|
text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
|
|
@@ -140,7 +138,6 @@ var GroupSelect_propTypes = {
|
|
|
140
138
|
searchBoxPlaceHolder: _propTypes["default"].string,
|
|
141
139
|
needSearch: _propTypes["default"].bool,
|
|
142
140
|
searchEmptyMessage: _propTypes["default"].string,
|
|
143
|
-
secondaryField: _propTypes["default"].string,
|
|
144
141
|
getRef: _propTypes["default"].func,
|
|
145
142
|
isDisabled: _propTypes["default"].bool,
|
|
146
143
|
isReadOnly: _propTypes["default"].bool,
|
|
@@ -306,7 +303,6 @@ var SelectWithIcon_propTypes = {
|
|
|
306
303
|
removeClose: _propTypes["default"].func,
|
|
307
304
|
searchBoxPlaceHolder: _propTypes["default"].string,
|
|
308
305
|
searchEmptyMessage: _propTypes["default"].string,
|
|
309
|
-
secondaryValueKey: _propTypes["default"].string,
|
|
310
306
|
selectedId: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
311
307
|
selectedValue: _propTypes["default"].string,
|
|
312
308
|
size: _propTypes["default"].oneOf(['small', 'medium']),
|
|
@@ -331,7 +327,6 @@ var SelectWithIcon_propTypes = {
|
|
|
331
327
|
customProps: _propTypes["default"].shape({
|
|
332
328
|
TextBoxProps: _propTypes["default"].object,
|
|
333
329
|
DropdownSearchTextBoxProps: _propTypes["default"].object,
|
|
334
|
-
SuggestionsProps: _propTypes["default"].object,
|
|
335
330
|
TextBoxIconProps: _propTypes["default"].object
|
|
336
331
|
})
|
|
337
332
|
};
|
|
@@ -15,6 +15,8 @@ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("@zohodesk/utils");
|
|
17
17
|
|
|
18
|
+
var _highlight = require("./highlight");
|
|
19
|
+
|
|
18
20
|
var _TypographyModule = _interopRequireDefault(require("./css/Typography.module.css"));
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -33,7 +35,10 @@ var Typography = function Typography(props) {
|
|
|
33
35
|
customId = props.customId,
|
|
34
36
|
$tagAttributes_text = props.$tagAttributes_text,
|
|
35
37
|
$a11yAttributes_text = props.$a11yAttributes_text,
|
|
36
|
-
customStyle = props.customStyle
|
|
38
|
+
customStyle = props.customStyle,
|
|
39
|
+
highlights = props.highlights;
|
|
40
|
+
var _highlights$highlight = highlights.highlightData,
|
|
41
|
+
highlightData = _highlights$highlight === void 0 ? [] : _highlights$highlight;
|
|
37
42
|
var style = (0, _utils.mergeStyle)(_TypographyModule["default"], customStyle);
|
|
38
43
|
|
|
39
44
|
var _cssJSLogic = (0, _cssJSLogic2["default"])({
|
|
@@ -47,7 +52,9 @@ var Typography = function Typography(props) {
|
|
|
47
52
|
'data-title': $i18n_dataTitle,
|
|
48
53
|
'data-id': customId,
|
|
49
54
|
'data-test-id': testId
|
|
50
|
-
}, $tagAttributes_text), $a11yAttributes_text), children)
|
|
55
|
+
}, $tagAttributes_text), $a11yAttributes_text), highlightData.length > 0 && typeof children === 'string' ? (0, _highlight.highlight)(_objectSpread(_objectSpread({}, highlights), {}, {
|
|
56
|
+
text: children
|
|
57
|
+
})) : children);
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
Typography.propTypes = _propTypes.propTypes;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _Tag = _interopRequireDefault(require("../../Tag/Tag"));
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
|
|
13
|
+
describe('Typography component', function () {
|
|
14
|
+
var weights = ['regular', 'light', 'semibold', 'bold'];
|
|
15
|
+
var decorations = ['default', 'underline', 'strike', 'overline'];
|
|
16
|
+
test('should be render with the basic set of default props', function () {
|
|
17
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], null)),
|
|
18
|
+
asFragment = _render.asFragment;
|
|
19
|
+
|
|
20
|
+
expect(asFragment()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
test('should be render with text children', function () {
|
|
23
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, "Text testing")),
|
|
24
|
+
asFragment = _render2.asFragment;
|
|
25
|
+
|
|
26
|
+
expect(asFragment()).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
test('should render highlighted word', function () {
|
|
29
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
30
|
+
highlights: {
|
|
31
|
+
highlightData: ['sun'],
|
|
32
|
+
highlightsStyle: {
|
|
33
|
+
weight: 'bold'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky.")),
|
|
37
|
+
asFragment = _render3.asFragment;
|
|
38
|
+
|
|
39
|
+
expect(asFragment()).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
test('should render highlight by Index', function () {
|
|
42
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
43
|
+
highlights: {
|
|
44
|
+
highlightData: [{
|
|
45
|
+
highlightText: 'sun',
|
|
46
|
+
index: [1, 2]
|
|
47
|
+
}, {
|
|
48
|
+
highlightText: 'under',
|
|
49
|
+
index: 1
|
|
50
|
+
}],
|
|
51
|
+
highlightsStyle: {
|
|
52
|
+
weight: 'bold',
|
|
53
|
+
decoration: 'underline'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun.")),
|
|
57
|
+
asFragment = _render4.asFragment;
|
|
58
|
+
|
|
59
|
+
expect(asFragment()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
test('should render separate Styles per Word', function () {
|
|
62
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
63
|
+
highlights: {
|
|
64
|
+
highlightData: [{
|
|
65
|
+
highlightText: 'sun',
|
|
66
|
+
highlightsStyle: {
|
|
67
|
+
weight: 'bold'
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
highlightText: 'under',
|
|
71
|
+
highlightsStyle: {
|
|
72
|
+
decoration: 'underline'
|
|
73
|
+
}
|
|
74
|
+
}]
|
|
75
|
+
}
|
|
76
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun.")),
|
|
77
|
+
asFragment = _render5.asFragment;
|
|
78
|
+
|
|
79
|
+
expect(asFragment()).toMatchSnapshot();
|
|
80
|
+
});
|
|
81
|
+
test('should render globally skip highlights at given indexes, with isExcludedIndex', function () {
|
|
82
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
83
|
+
highlights: {
|
|
84
|
+
highlightData: [{
|
|
85
|
+
highlightText: 'sun',
|
|
86
|
+
index: 1
|
|
87
|
+
}, {
|
|
88
|
+
highlightText: 'moon',
|
|
89
|
+
index: [2, 3]
|
|
90
|
+
}],
|
|
91
|
+
isExcludedIndex: true,
|
|
92
|
+
highlightsStyle: {
|
|
93
|
+
weight: 'bold',
|
|
94
|
+
decoration: 'underline'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky.")),
|
|
98
|
+
asFragment = _render6.asFragment;
|
|
99
|
+
|
|
100
|
+
expect(asFragment()).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
test('should render with separate excluded index option per word', function () {
|
|
103
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
104
|
+
highlights: {
|
|
105
|
+
highlightData: [{
|
|
106
|
+
highlightText: 'sun',
|
|
107
|
+
index: 1,
|
|
108
|
+
isExcludedIndex: true
|
|
109
|
+
}, {
|
|
110
|
+
highlightText: 'moon',
|
|
111
|
+
index: [2, 3],
|
|
112
|
+
isExcludedIndex: false
|
|
113
|
+
}],
|
|
114
|
+
highlightsStyle: {
|
|
115
|
+
weight: 'bold',
|
|
116
|
+
decoration: 'underline'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, "The sun was bright, the moon was bright, the sun and moon again.")),
|
|
120
|
+
asFragment = _render7.asFragment;
|
|
121
|
+
|
|
122
|
+
expect(asFragment()).toMatchSnapshot();
|
|
123
|
+
});
|
|
124
|
+
test('should render with global tagName applied to all highlights', function () {
|
|
125
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
126
|
+
highlights: {
|
|
127
|
+
highlightData: [{
|
|
128
|
+
highlightText: 'sun'
|
|
129
|
+
}, {
|
|
130
|
+
highlightText: 'moon'
|
|
131
|
+
}],
|
|
132
|
+
tagName: 'i'
|
|
133
|
+
}
|
|
134
|
+
}, "The sun and moon were bright.")),
|
|
135
|
+
asFragment = _render8.asFragment;
|
|
136
|
+
|
|
137
|
+
expect(asFragment()).toMatchSnapshot();
|
|
138
|
+
});
|
|
139
|
+
test('should render with separate tagName for each highlighted word', function () {
|
|
140
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
141
|
+
highlights: {
|
|
142
|
+
highlightData: [{
|
|
143
|
+
highlightText: 'sun',
|
|
144
|
+
tagName: 'i'
|
|
145
|
+
}, {
|
|
146
|
+
highlightText: 'moon',
|
|
147
|
+
tagName: 'u'
|
|
148
|
+
}]
|
|
149
|
+
}
|
|
150
|
+
}, "The sun and moon were bright.")),
|
|
151
|
+
asFragment = _render9.asFragment;
|
|
152
|
+
|
|
153
|
+
expect(asFragment()).toMatchSnapshot();
|
|
154
|
+
});
|
|
155
|
+
test('should render with global case-sensitive option', function () {
|
|
156
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
157
|
+
highlights: {
|
|
158
|
+
highlightData: [{
|
|
159
|
+
highlightText: 'Sun'
|
|
160
|
+
}, {
|
|
161
|
+
highlightText: 'moon'
|
|
162
|
+
}],
|
|
163
|
+
highlightsStyle: {
|
|
164
|
+
weight: 'bold',
|
|
165
|
+
decoration: 'underline'
|
|
166
|
+
},
|
|
167
|
+
isCaseSensitive: true
|
|
168
|
+
}
|
|
169
|
+
}, "The Sun was bright, the moon was bright, the sun was warm.")),
|
|
170
|
+
asFragment = _render10.asFragment;
|
|
171
|
+
|
|
172
|
+
expect(asFragment()).toMatchSnapshot();
|
|
173
|
+
});
|
|
174
|
+
test('should render with separate case-sensitive option per word', function () {
|
|
175
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
176
|
+
highlights: {
|
|
177
|
+
highlightData: [{
|
|
178
|
+
highlightText: 'Sun',
|
|
179
|
+
isCaseSensitive: true
|
|
180
|
+
}, {
|
|
181
|
+
highlightText: 'Moon',
|
|
182
|
+
isCaseSensitive: false
|
|
183
|
+
}],
|
|
184
|
+
highlightsStyle: {
|
|
185
|
+
weight: 'bold',
|
|
186
|
+
decoration: 'underline'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}, "The Sun was bright, the Moon was bright, the sun was warm.")),
|
|
190
|
+
asFragment = _render11.asFragment;
|
|
191
|
+
|
|
192
|
+
expect(asFragment()).toMatchSnapshot();
|
|
193
|
+
});
|
|
194
|
+
test('should render with global whole-word match only', function () {
|
|
195
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
196
|
+
highlights: {
|
|
197
|
+
highlightData: [{
|
|
198
|
+
highlightText: 'Sun'
|
|
199
|
+
}, {
|
|
200
|
+
highlightText: 'moon'
|
|
201
|
+
}],
|
|
202
|
+
highlightsStyle: {
|
|
203
|
+
weight: 'bold',
|
|
204
|
+
decoration: 'underline'
|
|
205
|
+
},
|
|
206
|
+
isWholeWord: true
|
|
207
|
+
}
|
|
208
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright.")),
|
|
209
|
+
asFragment = _render12.asFragment;
|
|
210
|
+
|
|
211
|
+
expect(asFragment()).toMatchSnapshot();
|
|
212
|
+
});
|
|
213
|
+
test('should render with separate whole-word option per word', function () {
|
|
214
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
215
|
+
highlights: {
|
|
216
|
+
highlightData: [{
|
|
217
|
+
highlightText: 'Sun',
|
|
218
|
+
isWholeWord: true
|
|
219
|
+
}, {
|
|
220
|
+
highlightText: 'moon',
|
|
221
|
+
isWholeWord: false
|
|
222
|
+
}],
|
|
223
|
+
highlightsStyle: {
|
|
224
|
+
weight: 'bold',
|
|
225
|
+
decoration: 'underline'
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright.")),
|
|
229
|
+
asFragment = _render13.asFragment;
|
|
230
|
+
|
|
231
|
+
expect(asFragment()).toMatchSnapshot();
|
|
232
|
+
});
|
|
233
|
+
test('should render with global custom style for all highlights', function () {
|
|
234
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
235
|
+
highlights: {
|
|
236
|
+
highlightData: [{
|
|
237
|
+
highlightText: 'Sun'
|
|
238
|
+
}, {
|
|
239
|
+
highlightText: 'moon'
|
|
240
|
+
}],
|
|
241
|
+
customStyle: {
|
|
242
|
+
backgroundColor: 'lightgreen'
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, "The sun and moon were bright.")),
|
|
246
|
+
asFragment = _render14.asFragment;
|
|
247
|
+
|
|
248
|
+
expect(asFragment()).toMatchSnapshot();
|
|
249
|
+
});
|
|
250
|
+
test('should render with separate custom style per word', function () {
|
|
251
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
252
|
+
highlights: {
|
|
253
|
+
highlightData: [{
|
|
254
|
+
highlightText: 'Sun',
|
|
255
|
+
customStyle: {
|
|
256
|
+
backgroundColor: 'lightgreen'
|
|
257
|
+
}
|
|
258
|
+
}, {
|
|
259
|
+
highlightText: 'moon',
|
|
260
|
+
customStyle: {
|
|
261
|
+
backgroundColor: 'orange'
|
|
262
|
+
}
|
|
263
|
+
}]
|
|
264
|
+
}
|
|
265
|
+
}, "The sun and moon were bright.")),
|
|
266
|
+
asFragment = _render15.asFragment;
|
|
267
|
+
|
|
268
|
+
expect(asFragment()).toMatchSnapshot();
|
|
269
|
+
});
|
|
270
|
+
test('should render with global custom class for all highlights', function () {
|
|
271
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
272
|
+
highlights: {
|
|
273
|
+
highlightData: [{
|
|
274
|
+
highlightText: 'Sun'
|
|
275
|
+
}, {
|
|
276
|
+
highlightText: 'moon'
|
|
277
|
+
}],
|
|
278
|
+
highlightsStyle: {
|
|
279
|
+
customClass: 'global_custom_class'
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, "The sun and moon were bright.")),
|
|
283
|
+
asFragment = _render16.asFragment;
|
|
284
|
+
|
|
285
|
+
expect(asFragment()).toMatchSnapshot();
|
|
286
|
+
});
|
|
287
|
+
test('should render with separate custom class for each highlighted word', function () {
|
|
288
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
289
|
+
highlights: {
|
|
290
|
+
highlightData: [{
|
|
291
|
+
highlightText: 'Sun',
|
|
292
|
+
highlightsStyle: {
|
|
293
|
+
customClass: 'separate_custom_class_sun'
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
highlightText: 'moon',
|
|
297
|
+
highlightsStyle: {
|
|
298
|
+
customClass: 'separate_custom_class_moon'
|
|
299
|
+
}
|
|
300
|
+
}]
|
|
301
|
+
}
|
|
302
|
+
}, "The sun and moon were bright.")),
|
|
303
|
+
asFragment = _render17.asFragment;
|
|
304
|
+
|
|
305
|
+
expect(asFragment()).toMatchSnapshot();
|
|
306
|
+
});
|
|
307
|
+
test('should render customised render the highlight element for all highlighted words', function () {
|
|
308
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
309
|
+
highlights: {
|
|
310
|
+
highlightData: [{
|
|
311
|
+
highlightText: 'sun'
|
|
312
|
+
}],
|
|
313
|
+
render: /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
314
|
+
text: "Sun"
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
}, "The sun was bright.")),
|
|
318
|
+
asFragment = _render18.asFragment;
|
|
319
|
+
|
|
320
|
+
expect(asFragment()).toMatchSnapshot();
|
|
321
|
+
});
|
|
322
|
+
test('should render separate customised render the highlight element for each highlighted word', function () {
|
|
323
|
+
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
324
|
+
highlights: {
|
|
325
|
+
highlightData: [{
|
|
326
|
+
highlightText: 'Sun',
|
|
327
|
+
render: /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
328
|
+
text: "Sun"
|
|
329
|
+
})
|
|
330
|
+
}, {
|
|
331
|
+
highlightText: 'moon',
|
|
332
|
+
render: /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
333
|
+
text: "Moon"
|
|
334
|
+
})
|
|
335
|
+
}]
|
|
336
|
+
}
|
|
337
|
+
}, "The sun and moon were bright.")),
|
|
338
|
+
asFragment = _render19.asFragment;
|
|
339
|
+
|
|
340
|
+
expect(asFragment()).toMatchSnapshot();
|
|
341
|
+
});
|
|
342
|
+
});
|