@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
|
@@ -41,7 +41,6 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
41
41
|
valueField,
|
|
42
42
|
textField,
|
|
43
43
|
imageField,
|
|
44
|
-
secondaryField,
|
|
45
44
|
allowValueFallback
|
|
46
45
|
} = props;
|
|
47
46
|
return this.formatOptions({
|
|
@@ -49,7 +48,6 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
49
48
|
valueField,
|
|
50
49
|
textField,
|
|
51
50
|
imageField,
|
|
52
|
-
secondaryField,
|
|
53
51
|
optionType: 'avatar',
|
|
54
52
|
allowValueFallback
|
|
55
53
|
});
|
|
@@ -167,7 +165,6 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
167
165
|
needEffect,
|
|
168
166
|
isLoading,
|
|
169
167
|
dataSelectorId,
|
|
170
|
-
customProps,
|
|
171
168
|
getTargetRef
|
|
172
169
|
} = this.props;
|
|
173
170
|
i18nKeys = Object.assign({}, i18nKeys, {
|
|
@@ -190,11 +187,6 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
190
187
|
} = this.normalizedFormatOptions[selectedId] || {};
|
|
191
188
|
let setAriaId = this.getNextAriaId();
|
|
192
189
|
let ariaErrorId = this.getNextAriaId();
|
|
193
|
-
let {
|
|
194
|
-
TextBoxProps,
|
|
195
|
-
DropdownSearchTextBoxProps,
|
|
196
|
-
SuggestionsProps
|
|
197
|
-
} = customProps;
|
|
198
190
|
return /*#__PURE__*/React.createElement("div", {
|
|
199
191
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''} ${className ? className : ''}`,
|
|
200
192
|
"data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
|
|
@@ -254,8 +246,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
254
246
|
isClickable: isReadOnly || isDisabled ? false : true,
|
|
255
247
|
borderColor: borderColor,
|
|
256
248
|
htmlId: htmlId,
|
|
257
|
-
autoComplete: false
|
|
258
|
-
...TextBoxProps
|
|
249
|
+
autoComplete: false
|
|
259
250
|
}))), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
260
251
|
query: this.responsiveFunc,
|
|
261
252
|
responsiveId: "Helmet"
|
|
@@ -304,8 +295,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
304
295
|
ariaControls: setAriaId,
|
|
305
296
|
ariaDescribedby: ariaErrorId
|
|
306
297
|
},
|
|
307
|
-
autoComplete: false
|
|
308
|
-
...DropdownSearchTextBoxProps
|
|
298
|
+
autoComplete: false
|
|
309
299
|
}))) : null, /*#__PURE__*/React.createElement(CardContent, {
|
|
310
300
|
shrink: true,
|
|
311
301
|
customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
|
|
@@ -333,8 +323,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
333
323
|
a11y: {
|
|
334
324
|
ariaParentRole: 'listbox',
|
|
335
325
|
role: 'option'
|
|
336
|
-
}
|
|
337
|
-
...SuggestionsProps
|
|
326
|
+
}
|
|
338
327
|
}) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
339
328
|
isLoading: isFetchingOptions,
|
|
340
329
|
options: options,
|
|
@@ -328,7 +328,6 @@ class SelectWithIcon extends Component {
|
|
|
328
328
|
targetOffset,
|
|
329
329
|
isRestrictScroll,
|
|
330
330
|
valueKey,
|
|
331
|
-
secondaryValueKey,
|
|
332
331
|
idKey,
|
|
333
332
|
needListBorder,
|
|
334
333
|
needTick,
|
|
@@ -368,8 +367,7 @@ class SelectWithIcon extends Component {
|
|
|
368
367
|
let {
|
|
369
368
|
TextBoxProps = {},
|
|
370
369
|
DropdownSearchTextBoxProps = {},
|
|
371
|
-
TextBoxIconProps = {}
|
|
372
|
-
ListItemProps
|
|
370
|
+
TextBoxIconProps = {}
|
|
373
371
|
} = customProps;
|
|
374
372
|
return /*#__PURE__*/React.createElement("div", {
|
|
375
373
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''}`,
|
|
@@ -512,7 +510,6 @@ class SelectWithIcon extends Component {
|
|
|
512
510
|
return /*#__PURE__*/React.createElement(ListItemWithIcon, {
|
|
513
511
|
key: options[idKey],
|
|
514
512
|
value: options[valueKey],
|
|
515
|
-
secondaryValue: options[secondaryValueKey],
|
|
516
513
|
size: "medium",
|
|
517
514
|
onClick: this.handleChange,
|
|
518
515
|
id: options[idKey],
|
|
@@ -533,8 +530,7 @@ class SelectWithIcon extends Component {
|
|
|
533
530
|
role: 'option',
|
|
534
531
|
ariaSelected: selectedId === options[idKey],
|
|
535
532
|
ariaLabel: options[valueKey]
|
|
536
|
-
}
|
|
537
|
-
...ListItemProps
|
|
533
|
+
}
|
|
538
534
|
});
|
|
539
535
|
})) : /*#__PURE__*/React.createElement(EmptyState, {
|
|
540
536
|
isLoading: isFetchingOptions,
|
|
@@ -64,8 +64,6 @@ export const Select_propTypes = {
|
|
|
64
64
|
searchBoxSize: PropTypes.string,
|
|
65
65
|
searchDebounceTime: PropTypes.number,
|
|
66
66
|
searchEmptyMessage: PropTypes.string,
|
|
67
|
-
searchFields: PropTypes.arrayOf(PropTypes.string),
|
|
68
|
-
secondaryField: PropTypes.string,
|
|
69
67
|
selectedValue: PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.string, PropTypes.number]), PropTypes.shape({
|
|
70
68
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
71
69
|
text: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -123,7 +121,6 @@ export const GroupSelect_propTypes = {
|
|
|
123
121
|
searchBoxPlaceHolder: PropTypes.string,
|
|
124
122
|
needSearch: PropTypes.bool,
|
|
125
123
|
searchEmptyMessage: PropTypes.string,
|
|
126
|
-
secondaryField: PropTypes.string,
|
|
127
124
|
getRef: PropTypes.func,
|
|
128
125
|
isDisabled: PropTypes.bool,
|
|
129
126
|
isReadOnly: PropTypes.bool,
|
|
@@ -285,7 +282,6 @@ export const SelectWithIcon_propTypes = {
|
|
|
285
282
|
removeClose: PropTypes.func,
|
|
286
283
|
searchBoxPlaceHolder: PropTypes.string,
|
|
287
284
|
searchEmptyMessage: PropTypes.string,
|
|
288
|
-
secondaryValueKey: PropTypes.string,
|
|
289
285
|
selectedId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
290
286
|
selectedValue: PropTypes.string,
|
|
291
287
|
size: PropTypes.oneOf(['small', 'medium']),
|
|
@@ -310,7 +306,6 @@ export const SelectWithIcon_propTypes = {
|
|
|
310
306
|
customProps: PropTypes.shape({
|
|
311
307
|
TextBoxProps: PropTypes.object,
|
|
312
308
|
DropdownSearchTextBoxProps: PropTypes.object,
|
|
313
|
-
SuggestionsProps: PropTypes.object,
|
|
314
309
|
TextBoxIconProps: PropTypes.object
|
|
315
310
|
})
|
|
316
311
|
};
|
|
@@ -3,6 +3,7 @@ import { defaultProps } from "./props/defaultProps";
|
|
|
3
3
|
import { propTypes } from "./props/propTypes";
|
|
4
4
|
import cssJSLogic from "./css/cssJSLogic";
|
|
5
5
|
import { mergeStyle } from '@zohodesk/utils';
|
|
6
|
+
import { highlight } from "./highlight";
|
|
6
7
|
import defaultStyle from "./css/Typography.module.css";
|
|
7
8
|
|
|
8
9
|
const Typography = props => {
|
|
@@ -14,8 +15,12 @@ const Typography = props => {
|
|
|
14
15
|
customId,
|
|
15
16
|
$tagAttributes_text,
|
|
16
17
|
$a11yAttributes_text,
|
|
17
|
-
customStyle
|
|
18
|
+
customStyle,
|
|
19
|
+
highlights
|
|
18
20
|
} = props;
|
|
21
|
+
const {
|
|
22
|
+
highlightData = []
|
|
23
|
+
} = highlights;
|
|
19
24
|
const style = mergeStyle(defaultStyle, customStyle);
|
|
20
25
|
const {
|
|
21
26
|
typographyClass
|
|
@@ -30,7 +35,9 @@ const Typography = props => {
|
|
|
30
35
|
'data-test-id': testId,
|
|
31
36
|
...$tagAttributes_text,
|
|
32
37
|
...$a11yAttributes_text
|
|
33
|
-
}, children
|
|
38
|
+
}, highlightData.length > 0 && typeof children === 'string' ? highlight({ ...highlights,
|
|
39
|
+
text: children
|
|
40
|
+
}) : children);
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
Typography.propTypes = propTypes;
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Typography from "../Typography";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import Tag from "../../Tag/Tag";
|
|
5
|
+
describe('Typography component', () => {
|
|
6
|
+
const weights = ['regular', 'light', 'semibold', 'bold'];
|
|
7
|
+
const decorations = ['default', 'underline', 'strike', 'overline'];
|
|
8
|
+
test('should be render with the basic set of default props', () => {
|
|
9
|
+
const {
|
|
10
|
+
asFragment
|
|
11
|
+
} = render( /*#__PURE__*/React.createElement(Typography, null));
|
|
12
|
+
expect(asFragment()).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
test('should be render with text children', () => {
|
|
15
|
+
const {
|
|
16
|
+
asFragment
|
|
17
|
+
} = render( /*#__PURE__*/React.createElement(Typography, null, "Text testing"));
|
|
18
|
+
expect(asFragment()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
test('should render highlighted word', () => {
|
|
21
|
+
const {
|
|
22
|
+
asFragment
|
|
23
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
24
|
+
highlights: {
|
|
25
|
+
highlightData: ['sun'],
|
|
26
|
+
highlightsStyle: {
|
|
27
|
+
weight: 'bold'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky."));
|
|
31
|
+
expect(asFragment()).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
test('should render highlight by Index', () => {
|
|
34
|
+
const {
|
|
35
|
+
asFragment
|
|
36
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
37
|
+
highlights: {
|
|
38
|
+
highlightData: [{
|
|
39
|
+
highlightText: 'sun',
|
|
40
|
+
index: [1, 2]
|
|
41
|
+
}, {
|
|
42
|
+
highlightText: 'under',
|
|
43
|
+
index: 1
|
|
44
|
+
}],
|
|
45
|
+
highlightsStyle: {
|
|
46
|
+
weight: 'bold',
|
|
47
|
+
decoration: 'underline'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun."));
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
test('should render separate Styles per Word', () => {
|
|
54
|
+
const {
|
|
55
|
+
asFragment
|
|
56
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
57
|
+
highlights: {
|
|
58
|
+
highlightData: [{
|
|
59
|
+
highlightText: 'sun',
|
|
60
|
+
highlightsStyle: {
|
|
61
|
+
weight: 'bold'
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
highlightText: 'under',
|
|
65
|
+
highlightsStyle: {
|
|
66
|
+
decoration: 'underline'
|
|
67
|
+
}
|
|
68
|
+
}]
|
|
69
|
+
}
|
|
70
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun."));
|
|
71
|
+
expect(asFragment()).toMatchSnapshot();
|
|
72
|
+
});
|
|
73
|
+
test('should render globally skip highlights at given indexes, with isExcludedIndex', () => {
|
|
74
|
+
const {
|
|
75
|
+
asFragment
|
|
76
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
77
|
+
highlights: {
|
|
78
|
+
highlightData: [{
|
|
79
|
+
highlightText: 'sun',
|
|
80
|
+
index: 1
|
|
81
|
+
}, {
|
|
82
|
+
highlightText: 'moon',
|
|
83
|
+
index: [2, 3]
|
|
84
|
+
}],
|
|
85
|
+
isExcludedIndex: true,
|
|
86
|
+
highlightsStyle: {
|
|
87
|
+
weight: 'bold',
|
|
88
|
+
decoration: 'underline'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky."));
|
|
92
|
+
expect(asFragment()).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
test('should render with separate excluded index option per word', () => {
|
|
95
|
+
const {
|
|
96
|
+
asFragment
|
|
97
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
98
|
+
highlights: {
|
|
99
|
+
highlightData: [{
|
|
100
|
+
highlightText: 'sun',
|
|
101
|
+
index: 1,
|
|
102
|
+
isExcludedIndex: true
|
|
103
|
+
}, {
|
|
104
|
+
highlightText: 'moon',
|
|
105
|
+
index: [2, 3],
|
|
106
|
+
isExcludedIndex: false
|
|
107
|
+
}],
|
|
108
|
+
highlightsStyle: {
|
|
109
|
+
weight: 'bold',
|
|
110
|
+
decoration: 'underline'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, "The sun was bright, the moon was bright, the sun and moon again."));
|
|
114
|
+
expect(asFragment()).toMatchSnapshot();
|
|
115
|
+
});
|
|
116
|
+
test('should render with global tagName applied to all highlights', () => {
|
|
117
|
+
const {
|
|
118
|
+
asFragment
|
|
119
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
120
|
+
highlights: {
|
|
121
|
+
highlightData: [{
|
|
122
|
+
highlightText: 'sun'
|
|
123
|
+
}, {
|
|
124
|
+
highlightText: 'moon'
|
|
125
|
+
}],
|
|
126
|
+
tagName: 'i'
|
|
127
|
+
}
|
|
128
|
+
}, "The sun and moon were bright."));
|
|
129
|
+
expect(asFragment()).toMatchSnapshot();
|
|
130
|
+
});
|
|
131
|
+
test('should render with separate tagName for each highlighted word', () => {
|
|
132
|
+
const {
|
|
133
|
+
asFragment
|
|
134
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
135
|
+
highlights: {
|
|
136
|
+
highlightData: [{
|
|
137
|
+
highlightText: 'sun',
|
|
138
|
+
tagName: 'i'
|
|
139
|
+
}, {
|
|
140
|
+
highlightText: 'moon',
|
|
141
|
+
tagName: 'u'
|
|
142
|
+
}]
|
|
143
|
+
}
|
|
144
|
+
}, "The sun and moon were bright."));
|
|
145
|
+
expect(asFragment()).toMatchSnapshot();
|
|
146
|
+
});
|
|
147
|
+
test('should render with global case-sensitive option', () => {
|
|
148
|
+
const {
|
|
149
|
+
asFragment
|
|
150
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
151
|
+
highlights: {
|
|
152
|
+
highlightData: [{
|
|
153
|
+
highlightText: 'Sun'
|
|
154
|
+
}, {
|
|
155
|
+
highlightText: 'moon'
|
|
156
|
+
}],
|
|
157
|
+
highlightsStyle: {
|
|
158
|
+
weight: 'bold',
|
|
159
|
+
decoration: 'underline'
|
|
160
|
+
},
|
|
161
|
+
isCaseSensitive: true
|
|
162
|
+
}
|
|
163
|
+
}, "The Sun was bright, the moon was bright, the sun was warm."));
|
|
164
|
+
expect(asFragment()).toMatchSnapshot();
|
|
165
|
+
});
|
|
166
|
+
test('should render with separate case-sensitive option per word', () => {
|
|
167
|
+
const {
|
|
168
|
+
asFragment
|
|
169
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
170
|
+
highlights: {
|
|
171
|
+
highlightData: [{
|
|
172
|
+
highlightText: 'Sun',
|
|
173
|
+
isCaseSensitive: true
|
|
174
|
+
}, {
|
|
175
|
+
highlightText: 'Moon',
|
|
176
|
+
isCaseSensitive: false
|
|
177
|
+
}],
|
|
178
|
+
highlightsStyle: {
|
|
179
|
+
weight: 'bold',
|
|
180
|
+
decoration: 'underline'
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}, "The Sun was bright, the Moon was bright, the sun was warm."));
|
|
184
|
+
expect(asFragment()).toMatchSnapshot();
|
|
185
|
+
});
|
|
186
|
+
test('should render with global whole-word match only', () => {
|
|
187
|
+
const {
|
|
188
|
+
asFragment
|
|
189
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
190
|
+
highlights: {
|
|
191
|
+
highlightData: [{
|
|
192
|
+
highlightText: 'Sun'
|
|
193
|
+
}, {
|
|
194
|
+
highlightText: 'moon'
|
|
195
|
+
}],
|
|
196
|
+
highlightsStyle: {
|
|
197
|
+
weight: 'bold',
|
|
198
|
+
decoration: 'underline'
|
|
199
|
+
},
|
|
200
|
+
isWholeWord: true
|
|
201
|
+
}
|
|
202
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright."));
|
|
203
|
+
expect(asFragment()).toMatchSnapshot();
|
|
204
|
+
});
|
|
205
|
+
test('should render with separate whole-word option per word', () => {
|
|
206
|
+
const {
|
|
207
|
+
asFragment
|
|
208
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
209
|
+
highlights: {
|
|
210
|
+
highlightData: [{
|
|
211
|
+
highlightText: 'Sun',
|
|
212
|
+
isWholeWord: true
|
|
213
|
+
}, {
|
|
214
|
+
highlightText: 'moon',
|
|
215
|
+
isWholeWord: false
|
|
216
|
+
}],
|
|
217
|
+
highlightsStyle: {
|
|
218
|
+
weight: 'bold',
|
|
219
|
+
decoration: 'underline'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright."));
|
|
223
|
+
expect(asFragment()).toMatchSnapshot();
|
|
224
|
+
});
|
|
225
|
+
test('should render with global custom style for all highlights', () => {
|
|
226
|
+
const {
|
|
227
|
+
asFragment
|
|
228
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
229
|
+
highlights: {
|
|
230
|
+
highlightData: [{
|
|
231
|
+
highlightText: 'Sun'
|
|
232
|
+
}, {
|
|
233
|
+
highlightText: 'moon'
|
|
234
|
+
}],
|
|
235
|
+
customStyle: {
|
|
236
|
+
backgroundColor: 'lightgreen'
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, "The sun and moon were bright."));
|
|
240
|
+
expect(asFragment()).toMatchSnapshot();
|
|
241
|
+
});
|
|
242
|
+
test('should render with separate custom style per word', () => {
|
|
243
|
+
const {
|
|
244
|
+
asFragment
|
|
245
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
246
|
+
highlights: {
|
|
247
|
+
highlightData: [{
|
|
248
|
+
highlightText: 'Sun',
|
|
249
|
+
customStyle: {
|
|
250
|
+
backgroundColor: 'lightgreen'
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
253
|
+
highlightText: 'moon',
|
|
254
|
+
customStyle: {
|
|
255
|
+
backgroundColor: 'orange'
|
|
256
|
+
}
|
|
257
|
+
}]
|
|
258
|
+
}
|
|
259
|
+
}, "The sun and moon were bright."));
|
|
260
|
+
expect(asFragment()).toMatchSnapshot();
|
|
261
|
+
});
|
|
262
|
+
test('should render with global custom class for all highlights', () => {
|
|
263
|
+
const {
|
|
264
|
+
asFragment
|
|
265
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
266
|
+
highlights: {
|
|
267
|
+
highlightData: [{
|
|
268
|
+
highlightText: 'Sun'
|
|
269
|
+
}, {
|
|
270
|
+
highlightText: 'moon'
|
|
271
|
+
}],
|
|
272
|
+
highlightsStyle: {
|
|
273
|
+
customClass: 'global_custom_class'
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}, "The sun and moon were bright."));
|
|
277
|
+
expect(asFragment()).toMatchSnapshot();
|
|
278
|
+
});
|
|
279
|
+
test('should render with separate custom class for each highlighted word', () => {
|
|
280
|
+
const {
|
|
281
|
+
asFragment
|
|
282
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
283
|
+
highlights: {
|
|
284
|
+
highlightData: [{
|
|
285
|
+
highlightText: 'Sun',
|
|
286
|
+
highlightsStyle: {
|
|
287
|
+
customClass: 'separate_custom_class_sun'
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
highlightText: 'moon',
|
|
291
|
+
highlightsStyle: {
|
|
292
|
+
customClass: 'separate_custom_class_moon'
|
|
293
|
+
}
|
|
294
|
+
}]
|
|
295
|
+
}
|
|
296
|
+
}, "The sun and moon were bright."));
|
|
297
|
+
expect(asFragment()).toMatchSnapshot();
|
|
298
|
+
});
|
|
299
|
+
test('should render customised render the highlight element for all highlighted words', () => {
|
|
300
|
+
const {
|
|
301
|
+
asFragment
|
|
302
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
303
|
+
highlights: {
|
|
304
|
+
highlightData: [{
|
|
305
|
+
highlightText: 'sun'
|
|
306
|
+
}],
|
|
307
|
+
render: /*#__PURE__*/React.createElement(Tag, {
|
|
308
|
+
text: "Sun"
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
}, "The sun was bright."));
|
|
312
|
+
expect(asFragment()).toMatchSnapshot();
|
|
313
|
+
});
|
|
314
|
+
test('should render separate customised render the highlight element for each highlighted word', () => {
|
|
315
|
+
const {
|
|
316
|
+
asFragment
|
|
317
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
318
|
+
highlights: {
|
|
319
|
+
highlightData: [{
|
|
320
|
+
highlightText: 'Sun',
|
|
321
|
+
render: /*#__PURE__*/React.createElement(Tag, {
|
|
322
|
+
text: "Sun"
|
|
323
|
+
})
|
|
324
|
+
}, {
|
|
325
|
+
highlightText: 'moon',
|
|
326
|
+
render: /*#__PURE__*/React.createElement(Tag, {
|
|
327
|
+
text: "Moon"
|
|
328
|
+
})
|
|
329
|
+
}]
|
|
330
|
+
}
|
|
331
|
+
}, "The sun and moon were bright."));
|
|
332
|
+
expect(asFragment()).toMatchSnapshot();
|
|
333
|
+
});
|
|
334
|
+
});
|