@zohodesk/components 1.4.21 → 1.4.23

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.
Files changed (153) hide show
  1. package/README.md +34 -0
  2. package/assets/Appearance/dark/mode/Component_DarkMode.module.css +15 -0
  3. package/assets/Appearance/light/mode/Component_LightMode.module.css +15 -0
  4. package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +15 -0
  5. package/es/ColorSelect/ColorMultiSelect.js +38 -0
  6. package/es/ColorSelect/ColorSelect.module.css +3 -0
  7. package/es/ColorSelect/ColorSingleSelect.js +83 -0
  8. package/es/ColorSelect/__tests__/ColorMultiSelect.spec.js +71 -0
  9. package/es/ColorSelect/__tests__/ColorSingleSelect.spec.js +80 -0
  10. package/es/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +536 -0
  11. package/es/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +422 -0
  12. package/es/ColorSelect/_shared/ColorIndicator/ColorIndicator.js +33 -0
  13. package/es/ColorSelect/_shared/ColorIndicator/ColorIndicator.module.css +19 -0
  14. package/es/ColorSelect/_shared/ColorIndicator/__tests__/ColorIndicator.spec.js +79 -0
  15. package/es/ColorSelect/_shared/ColorIndicator/__tests__/__snapshots__/ColorIndicator.spec.js.snap +106 -0
  16. package/es/ColorSelect/_shared/ColorIndicator/props/defaultProps.js +8 -0
  17. package/es/ColorSelect/_shared/ColorIndicator/props/propTypes.js +10 -0
  18. package/es/ColorSelect/_shared/ColoredTag/ColoredTag.js +33 -0
  19. package/es/ColorSelect/_shared/ColoredTag/__tests__/ColoredTag.spec.js +50 -0
  20. package/es/ColorSelect/_shared/ColoredTag/__tests__/__snapshots__/ColoredTag.spec.js.snap +101 -0
  21. package/es/ColorSelect/_shared/ColoredTag/props/propTypes.js +10 -0
  22. package/es/ColorSelect/_shared/helpers/renderHelpers.js +43 -0
  23. package/es/ColorSelect/props/defaultProps.js +12 -0
  24. package/es/ColorSelect/props/propTypes.js +17 -0
  25. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +3 -18
  26. package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -6
  27. package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -18
  28. package/es/ListItem/ListItem.js +6 -1
  29. package/es/ListItem/ListItem.module.css +6 -0
  30. package/es/ListItem/__tests__/ListItem.spec.js +8 -0
  31. package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +47 -0
  32. package/es/ListItem/props/propTypes.js +1 -0
  33. package/es/MultiSelect/MultiSelect.js +11 -5
  34. package/es/MultiSelect/SelectedOptions.js +24 -1
  35. package/es/MultiSelect/Suggestions.js +4 -1
  36. package/es/MultiSelect/__tests__/MultiSelect.spec.js +38 -0
  37. package/es/MultiSelect/__tests__/SelectedOptions.spec.js +13 -0
  38. package/es/MultiSelect/__tests__/Suggestions.spec.js +12 -0
  39. package/es/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +1 -3
  40. package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +3 -9
  41. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +91 -12
  42. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +1 -3
  43. package/es/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +15 -0
  44. package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +66 -0
  45. package/es/MultiSelect/props/propTypes.js +6 -0
  46. package/es/Select/Select.js +67 -5
  47. package/es/Select/__tests__/Select.spec.js +10 -0
  48. package/es/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -6
  49. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +111 -441
  50. package/es/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -6
  51. package/es/Select/props/defaultProps.js +2 -1
  52. package/es/Select/props/propTypes.js +3 -1
  53. package/es/TextBox/__tests__/TextBox.spec.js +1 -1
  54. package/es/TextBoxIcon/TextBoxIcon.js +17 -12
  55. package/es/TextBoxIcon/TextBoxIcon.module.css +3 -38
  56. package/es/TextBoxIcon/__tests__/TextBoxIcon.spec.js +9 -2
  57. package/es/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +78 -224
  58. package/es/TextBoxIcon/props/propTypes.js +1 -2
  59. package/es/Typography/Typography.js +9 -2
  60. package/es/Typography/__tests__/Typography.spec.js +427 -0
  61. package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +506 -0
  62. package/es/Typography/props/defaultProps.js +2 -1
  63. package/es/Typography/props/propTypes.js +24 -5
  64. package/es/Typography/utils/textHighlighter.js +139 -0
  65. package/es/shared/ArrowIcon/ArrowIcon.js +51 -0
  66. package/es/shared/ArrowIcon/ArrowIcon.module.css +43 -0
  67. package/es/shared/ArrowIcon/__tests__/ArrowIcon.spec.js +100 -0
  68. package/es/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +221 -0
  69. package/es/shared/ArrowIcon/props/defaultProps.js +11 -0
  70. package/es/shared/ArrowIcon/props/propTypes.js +17 -0
  71. package/es/shared/InputFieldLine/InputFieldLine.js +45 -0
  72. package/es/shared/InputFieldLine/InputFieldLine.module.css +88 -0
  73. package/es/shared/InputFieldLine/__tests__/InputFieldLine.spec.js +114 -0
  74. package/es/shared/InputFieldLine/__tests__/__snapshots__/InputFieldLine.spec.js.snap +194 -0
  75. package/es/shared/InputFieldLine/props/defaultProps.js +16 -0
  76. package/es/shared/InputFieldLine/props/propTypes.js +22 -0
  77. package/es/utils/Common.js +3 -2
  78. package/es/utils/dropDownUtils.js +7 -1
  79. package/lib/ColorSelect/ColorMultiSelect.js +71 -0
  80. package/lib/ColorSelect/ColorSelect.module.css +3 -0
  81. package/lib/ColorSelect/ColorSingleSelect.js +111 -0
  82. package/lib/ColorSelect/__tests__/ColorMultiSelect.spec.js +82 -0
  83. package/lib/ColorSelect/__tests__/ColorSingleSelect.spec.js +91 -0
  84. package/lib/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +536 -0
  85. package/lib/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +422 -0
  86. package/lib/ColorSelect/_shared/ColorIndicator/ColorIndicator.js +47 -0
  87. package/lib/ColorSelect/_shared/ColorIndicator/ColorIndicator.module.css +19 -0
  88. package/lib/ColorSelect/_shared/ColorIndicator/__tests__/ColorIndicator.spec.js +86 -0
  89. package/lib/ColorSelect/_shared/ColorIndicator/__tests__/__snapshots__/ColorIndicator.spec.js.snap +106 -0
  90. package/lib/ColorSelect/_shared/ColorIndicator/props/defaultProps.js +15 -0
  91. package/lib/ColorSelect/_shared/ColorIndicator/props/propTypes.js +21 -0
  92. package/lib/ColorSelect/_shared/ColoredTag/ColoredTag.js +69 -0
  93. package/lib/ColorSelect/_shared/ColoredTag/__tests__/ColoredTag.spec.js +58 -0
  94. package/lib/ColorSelect/_shared/ColoredTag/__tests__/__snapshots__/ColoredTag.spec.js.snap +101 -0
  95. package/lib/ColorSelect/_shared/ColoredTag/props/propTypes.js +29 -0
  96. package/lib/ColorSelect/_shared/helpers/renderHelpers.js +63 -0
  97. package/lib/ColorSelect/props/defaultProps.js +32 -0
  98. package/lib/ColorSelect/props/propTypes.js +39 -0
  99. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +3 -18
  100. package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -6
  101. package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -18
  102. package/lib/ListItem/ListItem.js +6 -1
  103. package/lib/ListItem/ListItem.module.css +6 -0
  104. package/lib/ListItem/__tests__/ListItem.spec.js +12 -4
  105. package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +47 -0
  106. package/lib/ListItem/props/propTypes.js +1 -0
  107. package/lib/MultiSelect/MultiSelect.js +11 -5
  108. package/lib/MultiSelect/SelectedOptions.js +24 -1
  109. package/lib/MultiSelect/Suggestions.js +5 -1
  110. package/lib/MultiSelect/__tests__/MultiSelect.spec.js +42 -2
  111. package/lib/MultiSelect/__tests__/SelectedOptions.spec.js +15 -0
  112. package/lib/MultiSelect/__tests__/Suggestions.spec.js +16 -2
  113. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +1 -3
  114. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +3 -9
  115. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +91 -12
  116. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +1 -3
  117. package/lib/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +15 -0
  118. package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +66 -0
  119. package/lib/MultiSelect/props/propTypes.js +6 -0
  120. package/lib/Select/Select.js +67 -4
  121. package/lib/Select/__tests__/Select.spec.js +12 -0
  122. package/lib/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -6
  123. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +111 -441
  124. package/lib/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -6
  125. package/lib/Select/props/defaultProps.js +2 -1
  126. package/lib/Select/props/propTypes.js +3 -1
  127. package/lib/TextBox/__tests__/TextBox.spec.js +36 -36
  128. package/lib/TextBoxIcon/TextBoxIcon.js +18 -13
  129. package/lib/TextBoxIcon/TextBoxIcon.module.css +3 -38
  130. package/lib/TextBoxIcon/__tests__/TextBoxIcon.spec.js +9 -2
  131. package/lib/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +78 -224
  132. package/lib/TextBoxIcon/props/propTypes.js +1 -2
  133. package/lib/Typography/Typography.js +9 -2
  134. package/lib/Typography/__tests__/Typography.spec.js +436 -0
  135. package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +506 -0
  136. package/lib/Typography/props/defaultProps.js +2 -1
  137. package/lib/Typography/props/propTypes.js +31 -6
  138. package/lib/Typography/utils/textHighlighter.js +160 -0
  139. package/lib/shared/ArrowIcon/ArrowIcon.js +65 -0
  140. package/lib/shared/ArrowIcon/ArrowIcon.module.css +43 -0
  141. package/lib/shared/ArrowIcon/__tests__/ArrowIcon.spec.js +107 -0
  142. package/lib/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +221 -0
  143. package/lib/shared/ArrowIcon/props/defaultProps.js +18 -0
  144. package/lib/shared/ArrowIcon/props/propTypes.js +28 -0
  145. package/lib/shared/InputFieldLine/InputFieldLine.js +57 -0
  146. package/lib/shared/InputFieldLine/InputFieldLine.module.css +88 -0
  147. package/lib/shared/InputFieldLine/__tests__/InputFieldLine.spec.js +122 -0
  148. package/lib/shared/InputFieldLine/__tests__/__snapshots__/InputFieldLine.spec.js.snap +194 -0
  149. package/lib/shared/InputFieldLine/props/defaultProps.js +23 -0
  150. package/lib/shared/InputFieldLine/props/propTypes.js +39 -0
  151. package/lib/utils/Common.js +8 -4
  152. package/lib/utils/dropDownUtils.js +10 -1
  153. package/package.json +9 -7
@@ -40,8 +40,7 @@ export const propTypes = { ...TextBox_propTypes,
40
40
  customClass: PropTypes.shape({
41
41
  customTBoxWrap: PropTypes.string,
42
42
  customTextBox: PropTypes.string,
43
- customTBoxIcon: PropTypes.string,
44
- customTBoxLine: PropTypes.string
43
+ customTBoxIcon: PropTypes.string
45
44
  }),
46
45
  iconOnHover: PropTypes.bool,
47
46
  isFocus: PropTypes.bool,
@@ -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
  });