@zohodesk/components 1.0.0-temp-199.18 → 1.0.0-temp-246
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 +15 -1
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +2 -0
- package/assets/Appearance/light/mode/Component_LightMode.module.css +2 -0
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +2 -0
- package/es/CheckBox/CheckBox.js +21 -10
- package/es/CheckBox/CheckBox.module.css +21 -6
- package/es/CheckBox/__tests__/CheckBox.spec.js +9 -0
- package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
- package/es/CheckBox/props/propTypes.js +4 -1
- package/es/ColorSelect/ColorSingleSelect.js +0 -1
- package/es/ColorSelect/__tests__/ColorMultiSelect.spec.js +15 -3
- package/es/ColorSelect/__tests__/ColorSingleSelect.spec.js +15 -3
- package/es/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +2 -2
- package/es/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +8 -8
- package/es/ColorSelect/_shared/ColorIndicator/ColorIndicator.js +7 -3
- package/es/ColorSelect/_shared/ColorIndicator/__tests__/ColorIndicator.spec.js +17 -4
- package/es/ColorSelect/_shared/ColorIndicator/__tests__/__snapshots__/ColorIndicator.spec.js.snap +3 -3
- package/es/ColorSelect/_shared/ColorIndicator/props/propTypes.js +1 -1
- package/es/ColorSelect/_shared/ColoredTag/props/propTypes.js +1 -0
- package/es/ColorSelect/_shared/helpers/renderHelpers.js +14 -10
- package/es/ColorSelect/props/propTypes.js +1 -0
- package/es/Label/Label.js +19 -1
- package/es/Label/__tests__/Label.spec.js +58 -0
- package/es/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
- package/es/Label/props/defaultProps.js +1 -0
- package/es/Label/props/propTypes.js +7 -1
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +2 -6
- package/es/MultiSelect/MultiSelect.js +2 -2
- package/es/MultiSelect/Suggestions.js +2 -7
- package/es/MultiSelect/props/defaultProps.js +0 -2
- package/es/MultiSelect/props/propTypes.js +3 -11
- package/es/Radio/Radio.js +20 -9
- package/es/Radio/Radio.module.css +38 -5
- package/es/Radio/__tests__/Radio.spec.js +10 -0
- package/es/Radio/__tests__/__snapshots__/Radio.spec.js.snap +238 -81
- package/es/Radio/props/propTypes.js +4 -1
- package/es/Select/GroupSelect.js +1 -1
- package/es/Select/SelectWithAvatar.js +3 -3
- package/es/Select/SelectWithIcon.js +3 -10
- package/es/Select/props/defaultProps.js +2 -4
- package/es/Select/props/propTypes.js +3 -11
- package/es/Typography/Typography.js +9 -2
- package/es/Typography/__tests__/Typography.spec.js +427 -0
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +506 -0
- package/es/Typography/props/defaultProps.js +2 -1
- package/es/Typography/props/propTypes.js +24 -5
- package/es/Typography/utils/textHighlighter.js +139 -0
- package/es/common/common.module.css +1 -1
- package/es/shared/ArrowIcon/ArrowIcon.js +6 -3
- package/es/shared/ArrowIcon/ArrowIcon.module.css +9 -0
- package/es/shared/ArrowIcon/__tests__/ArrowIcon.spec.js +24 -0
- package/es/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +70 -7
- package/es/shared/ArrowIcon/props/defaultProps.js +2 -0
- package/es/shared/ArrowIcon/props/propTypes.js +3 -1
- package/es/utils/dropDownUtils.js +3 -3
- package/lib/CheckBox/CheckBox.js +23 -9
- package/lib/CheckBox/CheckBox.module.css +21 -6
- package/lib/CheckBox/__tests__/CheckBox.spec.js +21 -12
- package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
- package/lib/CheckBox/props/propTypes.js +5 -1
- package/lib/ColorSelect/ColorSingleSelect.js +1 -2
- package/lib/ColorSelect/__tests__/ColorMultiSelect.spec.js +15 -3
- package/lib/ColorSelect/__tests__/ColorSingleSelect.spec.js +15 -3
- package/lib/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +2 -2
- package/lib/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +8 -8
- package/lib/ColorSelect/_shared/ColorIndicator/ColorIndicator.js +10 -4
- package/lib/ColorSelect/_shared/ColorIndicator/__tests__/ColorIndicator.spec.js +17 -4
- package/lib/ColorSelect/_shared/ColorIndicator/__tests__/__snapshots__/ColorIndicator.spec.js.snap +3 -3
- package/lib/ColorSelect/_shared/ColorIndicator/props/propTypes.js +1 -1
- package/lib/ColorSelect/_shared/ColoredTag/props/propTypes.js +1 -0
- package/lib/ColorSelect/_shared/helpers/renderHelpers.js +19 -13
- package/lib/ColorSelect/props/propTypes.js +1 -0
- package/lib/Label/Label.js +21 -1
- package/lib/Label/__tests__/Label.spec.js +58 -0
- package/lib/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
- package/lib/Label/props/defaultProps.js +1 -0
- package/lib/Label/props/propTypes.js +8 -1
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +3 -8
- package/lib/MultiSelect/MultiSelect.js +2 -2
- package/lib/MultiSelect/Suggestions.js +2 -6
- package/lib/MultiSelect/props/defaultProps.js +0 -2
- package/lib/MultiSelect/props/propTypes.js +5 -13
- package/lib/Radio/Radio.js +22 -8
- package/lib/Radio/Radio.module.css +38 -5
- package/lib/Radio/__tests__/Radio.spec.js +10 -0
- package/lib/Radio/__tests__/__snapshots__/Radio.spec.js.snap +238 -81
- package/lib/Radio/props/propTypes.js +5 -1
- package/lib/Select/GroupSelect.js +1 -2
- package/lib/Select/SelectWithAvatar.js +3 -4
- package/lib/Select/SelectWithIcon.js +3 -10
- package/lib/Select/props/defaultProps.js +3 -5
- package/lib/Select/props/propTypes.js +3 -11
- package/lib/Typography/Typography.js +9 -2
- package/lib/Typography/__tests__/Typography.spec.js +436 -0
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +506 -0
- package/lib/Typography/props/defaultProps.js +2 -1
- package/lib/Typography/props/propTypes.js +31 -6
- package/lib/Typography/utils/textHighlighter.js +160 -0
- package/lib/common/common.module.css +1 -1
- package/lib/shared/ArrowIcon/ArrowIcon.js +6 -3
- package/lib/shared/ArrowIcon/ArrowIcon.module.css +9 -0
- package/lib/shared/ArrowIcon/__tests__/ArrowIcon.spec.js +34 -10
- package/lib/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +70 -7
- package/lib/shared/ArrowIcon/props/defaultProps.js +2 -0
- package/lib/shared/ArrowIcon/props/propTypes.js +3 -1
- package/lib/utils/dropDownUtils.js +3 -3
- package/package.json +2 -2
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import { propTypes as TypographyPropTypes } from "../../Typography/props/propTypes";
|
|
2
3
|
export const propTypes = {
|
|
3
4
|
active: PropTypes.bool,
|
|
4
5
|
checked: PropTypes.bool,
|
|
5
6
|
disabled: PropTypes.bool,
|
|
7
|
+
secondaryText: PropTypes.string,
|
|
6
8
|
disabledTitle: PropTypes.string,
|
|
7
9
|
getRef: PropTypes.func,
|
|
8
10
|
id: PropTypes.string,
|
|
@@ -23,7 +25,8 @@ export const propTypes = {
|
|
|
23
25
|
}),
|
|
24
26
|
customProps: PropTypes.exact({
|
|
25
27
|
ContainerProps: PropTypes.object,
|
|
26
|
-
LabelProps: PropTypes.object
|
|
28
|
+
LabelProps: PropTypes.object,
|
|
29
|
+
secondaryTextProps: PropTypes.exact(TypographyPropTypes)
|
|
27
30
|
}),
|
|
28
31
|
a11y: PropTypes.shape({
|
|
29
32
|
ariaChecked: PropTypes.bool,
|
package/es/Select/GroupSelect.js
CHANGED
|
@@ -623,7 +623,7 @@ export class GroupSelectComponent extends PureComponent {
|
|
|
623
623
|
let {
|
|
624
624
|
TextBoxIconProps = {},
|
|
625
625
|
TextBoxProps = {},
|
|
626
|
-
SuggestionsProps
|
|
626
|
+
SuggestionsProps
|
|
627
627
|
} = customProps;
|
|
628
628
|
return /*#__PURE__*/React.createElement("div", {
|
|
629
629
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''} ${iconOnHover && (isReadOnly || isDisabled) ? style.iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? style.iconOnHoverStyle : ''}`,
|
|
@@ -169,8 +169,8 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
169
169
|
needEffect,
|
|
170
170
|
isLoading,
|
|
171
171
|
dataSelectorId,
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
customProps,
|
|
173
|
+
getTargetRef
|
|
174
174
|
} = this.props;
|
|
175
175
|
i18nKeys = Object.assign({}, i18nKeys, {
|
|
176
176
|
emptyText: i18nKeys.emptyText || emptyMessage,
|
|
@@ -195,7 +195,7 @@ class SelectWithAvatarComponent extends SelectComponent {
|
|
|
195
195
|
let {
|
|
196
196
|
TextBoxProps,
|
|
197
197
|
DropdownSearchTextBoxProps,
|
|
198
|
-
SuggestionsProps
|
|
198
|
+
SuggestionsProps
|
|
199
199
|
} = customProps;
|
|
200
200
|
return /*#__PURE__*/React.createElement("div", {
|
|
201
201
|
className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${isReadOnly ? style.readOnly : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''} ${className ? className : ''}`,
|
|
@@ -357,8 +357,7 @@ class SelectWithIcon extends Component {
|
|
|
357
357
|
htmlId,
|
|
358
358
|
isLoading,
|
|
359
359
|
dataSelectorId,
|
|
360
|
-
customProps
|
|
361
|
-
customClass
|
|
360
|
+
customProps
|
|
362
361
|
} = this.props;
|
|
363
362
|
i18nKeys = Object.assign({}, i18nKeys, {
|
|
364
363
|
emptyText: i18nKeys.emptyText || emptyMessage,
|
|
@@ -376,11 +375,8 @@ class SelectWithIcon extends Component {
|
|
|
376
375
|
TextBoxProps = {},
|
|
377
376
|
DropdownSearchTextBoxProps = {},
|
|
378
377
|
TextBoxIconProps = {},
|
|
379
|
-
ListItemProps
|
|
378
|
+
ListItemProps
|
|
380
379
|
} = customProps;
|
|
381
|
-
const {
|
|
382
|
-
dropBoxClass = ''
|
|
383
|
-
} = customClass;
|
|
384
380
|
return /*#__PURE__*/React.createElement("div", {
|
|
385
381
|
className: `${style.container} ${style[`box_${size}`]} ${isReadOnly ? style.readonly : ''} ${borderColor === 'transparent' ? style.transparentContainer : ''}`,
|
|
386
382
|
"data-title": isDisabled ? title : null,
|
|
@@ -477,10 +473,7 @@ class SelectWithIcon extends Component {
|
|
|
477
473
|
size: boxSize,
|
|
478
474
|
isPadding: false,
|
|
479
475
|
isResponsivePadding: true,
|
|
480
|
-
alignBox: "row"
|
|
481
|
-
customClass: {
|
|
482
|
-
customDropBox: dropBoxClass
|
|
483
|
-
}
|
|
476
|
+
alignBox: "row"
|
|
484
477
|
}, isLoading ? /*#__PURE__*/React.createElement(Container, {
|
|
485
478
|
align: "both",
|
|
486
479
|
className: style.loader
|
|
@@ -102,8 +102,7 @@ export const SelectWithAvatar_defaultProps = {
|
|
|
102
102
|
i18nKeys: {},
|
|
103
103
|
customProps: {},
|
|
104
104
|
needEffect: true,
|
|
105
|
-
isLoading: false
|
|
106
|
-
customProps: {}
|
|
105
|
+
isLoading: false
|
|
107
106
|
};
|
|
108
107
|
export const SelectWithIcon_defaultProps = {
|
|
109
108
|
isReadOnly: false,
|
|
@@ -132,6 +131,5 @@ export const SelectWithIcon_defaultProps = {
|
|
|
132
131
|
isLoading: false,
|
|
133
132
|
isAbsolutePositioningNeeded: true,
|
|
134
133
|
isRestrictScroll: false,
|
|
135
|
-
customProps: {}
|
|
136
|
-
customClass: {}
|
|
134
|
+
customProps: {}
|
|
137
135
|
};
|
|
@@ -186,8 +186,7 @@ export const GroupSelect_propTypes = {
|
|
|
186
186
|
isDefaultSelectValue: PropTypes.bool,
|
|
187
187
|
customProps: PropTypes.shape({
|
|
188
188
|
TextBoxProps: PropTypes.object,
|
|
189
|
-
TextBoxIconProps: PropTypes.object
|
|
190
|
-
SuggestionsProps: PropTypes.object
|
|
189
|
+
TextBoxIconProps: PropTypes.object
|
|
191
190
|
}),
|
|
192
191
|
allowValueFallback: PropTypes.bool
|
|
193
192
|
};
|
|
@@ -250,10 +249,7 @@ export const SelectWithAvatar_propTypes = { ...Select_propTypes,
|
|
|
250
249
|
htmlId: PropTypes.string,
|
|
251
250
|
needEffect: PropTypes.bool,
|
|
252
251
|
isLoading: PropTypes.bool,
|
|
253
|
-
dataSelectorId: PropTypes.string
|
|
254
|
-
customProps: PropTypes.shape({
|
|
255
|
-
SuggestionsProps: PropTypes.object
|
|
256
|
-
})
|
|
252
|
+
dataSelectorId: PropTypes.string
|
|
257
253
|
};
|
|
258
254
|
export const SelectWithIcon_propTypes = {
|
|
259
255
|
animationStyle: PropTypes.oneOf(['default', 'bounce']),
|
|
@@ -318,10 +314,6 @@ export const SelectWithIcon_propTypes = {
|
|
|
318
314
|
TextBoxProps: PropTypes.object,
|
|
319
315
|
DropdownSearchTextBoxProps: PropTypes.object,
|
|
320
316
|
SuggestionsProps: PropTypes.object,
|
|
321
|
-
TextBoxIconProps: PropTypes.object
|
|
322
|
-
ListItemProps: PropTypes.object
|
|
323
|
-
}),
|
|
324
|
-
customClass: PropTypes.shape({
|
|
325
|
-
dropBoxClass: PropTypes.string
|
|
317
|
+
TextBoxIconProps: PropTypes.object
|
|
326
318
|
})
|
|
327
319
|
};
|
|
@@ -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 { highlightText } from "./utils/textHighlighter";
|
|
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
|
+
$ui_highlightConfig
|
|
18
20
|
} = props;
|
|
21
|
+
const {
|
|
22
|
+
data: highlightData = []
|
|
23
|
+
} = $ui_highlightConfig;
|
|
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 && highlightData.length > 0 && typeof children === 'string' ? highlightText({ ...$ui_highlightConfig,
|
|
39
|
+
text: children
|
|
40
|
+
}) : children);
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
Typography.propTypes = propTypes;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import Typography from "../Typography";
|
|
4
|
+
import Tag from "../../Tag/Tag";
|
|
4
5
|
describe('Typography', () => {
|
|
5
6
|
const ui_size = ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '24', '25', '26', '28', '29', '30', '32', '34', '35', '36', '40', '50', 'inherit'];
|
|
6
7
|
const ui_lineClamp = ['1', '2', '3', '4', '5'];
|
|
@@ -222,4 +223,430 @@ describe('Typography', () => {
|
|
|
222
223
|
}, "Heading"));
|
|
223
224
|
expect(asFragment()).toMatchSnapshot();
|
|
224
225
|
});
|
|
226
|
+
});
|
|
227
|
+
describe('Typography with highlight', () => {
|
|
228
|
+
test('should render highlighted word', () => {
|
|
229
|
+
const {
|
|
230
|
+
asFragment
|
|
231
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
232
|
+
$ui_highlightConfig: {
|
|
233
|
+
data: ['sun'],
|
|
234
|
+
styleConfiguration: {
|
|
235
|
+
$ui_weight: 'bold'
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky."));
|
|
239
|
+
expect(asFragment()).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
test('should render highlight by Index', () => {
|
|
242
|
+
const {
|
|
243
|
+
asFragment
|
|
244
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
245
|
+
$ui_highlightConfig: {
|
|
246
|
+
data: [{
|
|
247
|
+
text: 'sun',
|
|
248
|
+
index: [1, 2]
|
|
249
|
+
}, {
|
|
250
|
+
text: 'under',
|
|
251
|
+
index: 1
|
|
252
|
+
}],
|
|
253
|
+
styleConfiguration: {
|
|
254
|
+
$ui_weight: 'bold',
|
|
255
|
+
$ui_decoration: 'underline'
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun."));
|
|
259
|
+
expect(asFragment()).toMatchSnapshot();
|
|
260
|
+
});
|
|
261
|
+
test('should render separate Styles per Word', () => {
|
|
262
|
+
const {
|
|
263
|
+
asFragment
|
|
264
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
265
|
+
$ui_highlightConfig: {
|
|
266
|
+
data: [{
|
|
267
|
+
text: 'sun',
|
|
268
|
+
styleConfiguration: {
|
|
269
|
+
$ui_weight: 'bold'
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
text: 'under',
|
|
273
|
+
styleConfiguration: {
|
|
274
|
+
$ui_decoration: 'underline'
|
|
275
|
+
}
|
|
276
|
+
}]
|
|
277
|
+
}
|
|
278
|
+
}, "The sun was bright, I walked under the sun, I talked under the sun."));
|
|
279
|
+
expect(asFragment()).toMatchSnapshot();
|
|
280
|
+
});
|
|
281
|
+
test('should render globally skip highlights at given indexes, with shouldExcludeIndices', () => {
|
|
282
|
+
const {
|
|
283
|
+
asFragment
|
|
284
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
285
|
+
$ui_highlightConfig: {
|
|
286
|
+
data: [{
|
|
287
|
+
text: 'sun',
|
|
288
|
+
index: 1
|
|
289
|
+
}, {
|
|
290
|
+
text: 'moon',
|
|
291
|
+
index: [2, 3]
|
|
292
|
+
}],
|
|
293
|
+
shouldExcludeIndices: true,
|
|
294
|
+
styleConfiguration: {
|
|
295
|
+
$ui_weight: 'bold',
|
|
296
|
+
$ui_decoration: 'underline'
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, "The sun was bright, the sun was warm, the sun was high in the sky."));
|
|
300
|
+
expect(asFragment()).toMatchSnapshot();
|
|
301
|
+
});
|
|
302
|
+
test('should render with separate excluded index option per word', () => {
|
|
303
|
+
const {
|
|
304
|
+
asFragment
|
|
305
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
306
|
+
$ui_highlightConfig: {
|
|
307
|
+
data: [{
|
|
308
|
+
text: 'sun',
|
|
309
|
+
index: 1,
|
|
310
|
+
shouldExcludeIndices: true
|
|
311
|
+
}, {
|
|
312
|
+
text: 'moon',
|
|
313
|
+
index: [2, 3],
|
|
314
|
+
shouldExcludeIndices: false
|
|
315
|
+
}],
|
|
316
|
+
styleConfiguration: {
|
|
317
|
+
$ui_weight: 'bold',
|
|
318
|
+
$ui_decoration: 'underline'
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, "The sun was bright, the moon was bright, the sun and moon again."));
|
|
322
|
+
expect(asFragment()).toMatchSnapshot();
|
|
323
|
+
});
|
|
324
|
+
test('should render with global tagName applied to all highlights', () => {
|
|
325
|
+
const {
|
|
326
|
+
asFragment
|
|
327
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
328
|
+
$ui_highlightConfig: {
|
|
329
|
+
data: [{
|
|
330
|
+
text: 'sun'
|
|
331
|
+
}, {
|
|
332
|
+
text: 'moon'
|
|
333
|
+
}],
|
|
334
|
+
tagName: 'i'
|
|
335
|
+
}
|
|
336
|
+
}, "The sun and moon were bright."));
|
|
337
|
+
expect(asFragment()).toMatchSnapshot();
|
|
338
|
+
});
|
|
339
|
+
test('should render with separate tagName for each highlighted word', () => {
|
|
340
|
+
const {
|
|
341
|
+
asFragment
|
|
342
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
343
|
+
$ui_highlightConfig: {
|
|
344
|
+
data: [{
|
|
345
|
+
text: 'sun',
|
|
346
|
+
tagName: 'i'
|
|
347
|
+
}, {
|
|
348
|
+
text: 'moon',
|
|
349
|
+
tagName: 'u'
|
|
350
|
+
}]
|
|
351
|
+
}
|
|
352
|
+
}, "The sun and moon were bright."));
|
|
353
|
+
expect(asFragment()).toMatchSnapshot();
|
|
354
|
+
});
|
|
355
|
+
test('should render with global case-sensitive option', () => {
|
|
356
|
+
const {
|
|
357
|
+
asFragment
|
|
358
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
359
|
+
$ui_highlightConfig: {
|
|
360
|
+
data: [{
|
|
361
|
+
text: 'Sun'
|
|
362
|
+
}, {
|
|
363
|
+
text: 'moon'
|
|
364
|
+
}],
|
|
365
|
+
styleConfiguration: {
|
|
366
|
+
$ui_weight: 'bold',
|
|
367
|
+
$ui_decoration: 'underline'
|
|
368
|
+
},
|
|
369
|
+
isCaseSensitive: true
|
|
370
|
+
}
|
|
371
|
+
}, "The Sun was bright, the moon was bright, the sun was warm."));
|
|
372
|
+
expect(asFragment()).toMatchSnapshot();
|
|
373
|
+
});
|
|
374
|
+
test('should render with separate case-sensitive option per word', () => {
|
|
375
|
+
const {
|
|
376
|
+
asFragment
|
|
377
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
378
|
+
$ui_highlightConfig: {
|
|
379
|
+
data: [{
|
|
380
|
+
text: 'Sun',
|
|
381
|
+
isCaseSensitive: true
|
|
382
|
+
}, {
|
|
383
|
+
text: 'Moon',
|
|
384
|
+
isCaseSensitive: false
|
|
385
|
+
}],
|
|
386
|
+
styleConfiguration: {
|
|
387
|
+
$ui_weight: 'bold',
|
|
388
|
+
$ui_decoration: 'underline'
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}, "The Sun was bright, the Moon was bright, the sun was warm."));
|
|
392
|
+
expect(asFragment()).toMatchSnapshot();
|
|
393
|
+
});
|
|
394
|
+
test('should render with global whole-word match only', () => {
|
|
395
|
+
const {
|
|
396
|
+
asFragment
|
|
397
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
398
|
+
$ui_highlightConfig: {
|
|
399
|
+
data: [{
|
|
400
|
+
text: 'Sun'
|
|
401
|
+
}, {
|
|
402
|
+
text: 'moon'
|
|
403
|
+
}],
|
|
404
|
+
styleConfiguration: {
|
|
405
|
+
$ui_weight: 'bold',
|
|
406
|
+
$ui_decoration: 'underline'
|
|
407
|
+
},
|
|
408
|
+
isWholeWord: true
|
|
409
|
+
}
|
|
410
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright."));
|
|
411
|
+
expect(asFragment()).toMatchSnapshot();
|
|
412
|
+
});
|
|
413
|
+
test('should render with separate whole-word option per word', () => {
|
|
414
|
+
const {
|
|
415
|
+
asFragment
|
|
416
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
417
|
+
$ui_highlightConfig: {
|
|
418
|
+
data: [{
|
|
419
|
+
text: 'Sun',
|
|
420
|
+
isWholeWord: true
|
|
421
|
+
}, {
|
|
422
|
+
text: 'moon',
|
|
423
|
+
isWholeWord: false
|
|
424
|
+
}],
|
|
425
|
+
styleConfiguration: {
|
|
426
|
+
$ui_weight: 'bold',
|
|
427
|
+
$ui_decoration: 'underline'
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}, "Sunflower is a flower. The Sun was bright, the moonlight was bright."));
|
|
431
|
+
expect(asFragment()).toMatchSnapshot();
|
|
432
|
+
});
|
|
433
|
+
test('should render with global custom style for all highlights', () => {
|
|
434
|
+
const {
|
|
435
|
+
asFragment
|
|
436
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
437
|
+
$ui_highlightConfig: {
|
|
438
|
+
data: [{
|
|
439
|
+
text: 'Sun'
|
|
440
|
+
}, {
|
|
441
|
+
text: 'moon'
|
|
442
|
+
}],
|
|
443
|
+
styleConfiguration: {
|
|
444
|
+
customStyle: {
|
|
445
|
+
backgroundColor: 'lightgreen'
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}, "The sun and moon were bright."));
|
|
450
|
+
expect(asFragment()).toMatchSnapshot();
|
|
451
|
+
});
|
|
452
|
+
test('should render with separate custom style per word', () => {
|
|
453
|
+
const {
|
|
454
|
+
asFragment
|
|
455
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
456
|
+
$ui_highlightConfig: {
|
|
457
|
+
data: [{
|
|
458
|
+
text: 'Sun',
|
|
459
|
+
styleConfiguration: {
|
|
460
|
+
customStyle: {
|
|
461
|
+
backgroundColor: 'lightgreen'
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}, {
|
|
465
|
+
text: 'moon',
|
|
466
|
+
styleConfiguration: {
|
|
467
|
+
customStyle: {
|
|
468
|
+
backgroundColor: 'orange'
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}]
|
|
472
|
+
}
|
|
473
|
+
}, "The sun and moon were bright."));
|
|
474
|
+
expect(asFragment()).toMatchSnapshot();
|
|
475
|
+
});
|
|
476
|
+
test('should render with global custom class for all highlights', () => {
|
|
477
|
+
const {
|
|
478
|
+
asFragment
|
|
479
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
480
|
+
$ui_highlightConfig: {
|
|
481
|
+
data: [{
|
|
482
|
+
text: 'Sun'
|
|
483
|
+
}, {
|
|
484
|
+
text: 'moon'
|
|
485
|
+
}],
|
|
486
|
+
styleConfiguration: {
|
|
487
|
+
$ui_className: 'global_custom_class'
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}, "The sun and moon were bright."));
|
|
491
|
+
expect(asFragment()).toMatchSnapshot();
|
|
492
|
+
});
|
|
493
|
+
test('should render with separate custom class for each highlighted word', () => {
|
|
494
|
+
const {
|
|
495
|
+
asFragment
|
|
496
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
497
|
+
$ui_highlightConfig: {
|
|
498
|
+
data: [{
|
|
499
|
+
text: 'Sun',
|
|
500
|
+
styleConfiguration: {
|
|
501
|
+
$ui_className: 'separate_custom_class_sun'
|
|
502
|
+
}
|
|
503
|
+
}, {
|
|
504
|
+
text: 'moon',
|
|
505
|
+
styleConfiguration: {
|
|
506
|
+
$ui_className: 'separate_custom_class_moon'
|
|
507
|
+
}
|
|
508
|
+
}]
|
|
509
|
+
}
|
|
510
|
+
}, "The sun and moon were bright."));
|
|
511
|
+
expect(asFragment()).toMatchSnapshot();
|
|
512
|
+
});
|
|
513
|
+
test('should render customised render the highlight element for all highlighted words', () => {
|
|
514
|
+
const {
|
|
515
|
+
asFragment
|
|
516
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
517
|
+
$ui_highlightConfig: {
|
|
518
|
+
data: [{
|
|
519
|
+
text: 'sun'
|
|
520
|
+
}],
|
|
521
|
+
renderHighlight: /*#__PURE__*/React.createElement(Tag, {
|
|
522
|
+
text: "Sun"
|
|
523
|
+
})
|
|
524
|
+
}
|
|
525
|
+
}, "The sun was bright."));
|
|
526
|
+
expect(asFragment()).toMatchSnapshot();
|
|
527
|
+
});
|
|
528
|
+
test('should render separate customised render the highlight element for each highlighted word', () => {
|
|
529
|
+
const {
|
|
530
|
+
asFragment
|
|
531
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
532
|
+
$ui_highlightConfig: {
|
|
533
|
+
data: [{
|
|
534
|
+
text: 'Sun',
|
|
535
|
+
renderHighlight: /*#__PURE__*/React.createElement(Tag, {
|
|
536
|
+
text: "Sun"
|
|
537
|
+
})
|
|
538
|
+
}, {
|
|
539
|
+
text: 'moon',
|
|
540
|
+
renderHighlight: /*#__PURE__*/React.createElement(Tag, {
|
|
541
|
+
text: "Moon"
|
|
542
|
+
})
|
|
543
|
+
}]
|
|
544
|
+
}
|
|
545
|
+
}, "The sun and moon were bright."));
|
|
546
|
+
expect(asFragment()).toMatchSnapshot();
|
|
547
|
+
});
|
|
548
|
+
test('should render for RegEx Characters check', () => {
|
|
549
|
+
const {
|
|
550
|
+
asFragment
|
|
551
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
552
|
+
$ui_highlightConfig: {
|
|
553
|
+
data: [{
|
|
554
|
+
text: '$un'
|
|
555
|
+
}, {
|
|
556
|
+
text: 'm**n'
|
|
557
|
+
}],
|
|
558
|
+
styleConfiguration: {
|
|
559
|
+
customStyle: {
|
|
560
|
+
backgroundColor: 'lightgreen'
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}, "The sun and moon were bright. and the m**n get sunlight from the $un, The Sun provides light to its nearby stars"));
|
|
565
|
+
expect(asFragment()).toMatchSnapshot();
|
|
566
|
+
});
|
|
567
|
+
test('should render for combination of configuration check', () => {
|
|
568
|
+
const {
|
|
569
|
+
asFragment
|
|
570
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
571
|
+
$ui_highlightConfig: {
|
|
572
|
+
data: [{
|
|
573
|
+
text: 'Sun',
|
|
574
|
+
index: 1,
|
|
575
|
+
shouldExcludeIndices: true,
|
|
576
|
+
isWholeWord: true,
|
|
577
|
+
isCaseSensitive: true
|
|
578
|
+
}],
|
|
579
|
+
styleConfiguration: {
|
|
580
|
+
customStyle: {
|
|
581
|
+
backgroundColor: 'lightgreen'
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}, "The sun and moon were bright. and the moon get sunlight from the Sun, The Sun provides light to its nearby stars"));
|
|
586
|
+
expect(asFragment()).toMatchSnapshot();
|
|
587
|
+
});
|
|
588
|
+
test('should render for priority based check - it priorities the global renderHighlight over the style configurations from the global', () => {
|
|
589
|
+
const {
|
|
590
|
+
asFragment
|
|
591
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
592
|
+
$ui_highlightConfig: {
|
|
593
|
+
data: ['sunlight'],
|
|
594
|
+
styleConfiguration: {
|
|
595
|
+
$ui_decoration: 'underline'
|
|
596
|
+
},
|
|
597
|
+
renderHighlight: text => /*#__PURE__*/React.createElement("a", {
|
|
598
|
+
href: "https://www.zoho.com",
|
|
599
|
+
target: "_blank",
|
|
600
|
+
rel: "noopener noreferrer"
|
|
601
|
+
}, " ", text, " ")
|
|
602
|
+
}
|
|
603
|
+
}, "1 Sun Moon 2 sun moon 3 sunmoon 4 SUN MOON 5 sun moon 6 sunlight moonlight"));
|
|
604
|
+
expect(asFragment()).toMatchSnapshot();
|
|
605
|
+
});
|
|
606
|
+
test('should render for priority based check - it priorities the style configurations from the data object over the global renderHighlight', () => {
|
|
607
|
+
const {
|
|
608
|
+
asFragment
|
|
609
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
610
|
+
$ui_highlightConfig: {
|
|
611
|
+
data: [{
|
|
612
|
+
text: 'sunlight',
|
|
613
|
+
styleConfiguration: {
|
|
614
|
+
$ui_decoration: 'underline'
|
|
615
|
+
}
|
|
616
|
+
}],
|
|
617
|
+
renderHighlight: text => /*#__PURE__*/React.createElement("a", {
|
|
618
|
+
href: "https://www.zoho.com",
|
|
619
|
+
target: "_blank",
|
|
620
|
+
rel: "noopener noreferrer"
|
|
621
|
+
}, " ", text, " ")
|
|
622
|
+
}
|
|
623
|
+
}, "1 Sun Moon 2 sun moon 3 sunmoon 4 SUN MOON 5 sun moon 6 sunlight moonlight"));
|
|
624
|
+
expect(asFragment()).toMatchSnapshot();
|
|
625
|
+
});
|
|
626
|
+
test('should render for priority based check - it priorities the renderHighlight from the data object over the global renderHighlight, global style configuration and style configuration from the data object', () => {
|
|
627
|
+
const {
|
|
628
|
+
asFragment
|
|
629
|
+
} = render( /*#__PURE__*/React.createElement(Typography, {
|
|
630
|
+
$ui_highlightConfig: {
|
|
631
|
+
data: [{
|
|
632
|
+
text: 'sunlight',
|
|
633
|
+
styleConfiguration: {
|
|
634
|
+
$ui_decoration: 'underline'
|
|
635
|
+
},
|
|
636
|
+
renderHighlight: text => /*#__PURE__*/React.createElement("b", null, " ", text, " ")
|
|
637
|
+
}],
|
|
638
|
+
styleConfiguration: {
|
|
639
|
+
customStyle: {
|
|
640
|
+
backgroundColor: 'lightgreen'
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
renderHighlight: text => /*#__PURE__*/React.createElement("a", {
|
|
644
|
+
href: "https://www.zoho.com",
|
|
645
|
+
target: "_blank",
|
|
646
|
+
rel: "noopener noreferrer"
|
|
647
|
+
}, " ", text, " ")
|
|
648
|
+
}
|
|
649
|
+
}, "1 Sun Moon 2 sun moon 3 sunmoon 4 SUN MOON 5 sun moon 6 sunlight moonlight"));
|
|
650
|
+
expect(asFragment()).toMatchSnapshot();
|
|
651
|
+
});
|
|
225
652
|
});
|