@zohodesk/components 1.6.7 → 1.6.8

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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.6.8
6
+
7
+ - **Typography**
8
+ - `breakSpaces` value supported for the **$ui_whiteSpace** prop.
9
+ - Prefixless prop fallbacks are supported
10
+ - `tagName` config in **highlightText** has been renamed to `as`. (fallback supported)
11
+
12
+
5
13
  # 1.6.7
6
14
 
7
15
  - PX to variable conversion was not applied due to the CBT migration. The issue has now been fixed.
@@ -9,18 +9,20 @@ import defaultStyle from "./css/Typography.module.css";
9
9
  const Typography = props => {
10
10
  const {
11
11
  children,
12
+ as,
12
13
  $ui_tagName,
14
+ dataTitle,
13
15
  $i18n_dataTitle,
14
16
  testId,
15
17
  customId,
18
+ tagAttributes,
16
19
  $tagAttributes_text,
20
+ a11yAttributes,
17
21
  $a11yAttributes_text,
18
22
  customStyle,
23
+ highlightConfig,
19
24
  $ui_highlightConfig
20
25
  } = props;
21
- const {
22
- data: highlightData = []
23
- } = $ui_highlightConfig;
24
26
  const style = mergeStyle(defaultStyle, customStyle);
25
27
  const {
26
28
  typographyClass
@@ -28,14 +30,22 @@ const Typography = props => {
28
30
  props,
29
31
  style
30
32
  });
31
- return /*#__PURE__*/React.createElement($ui_tagName, {
33
+ const finalTagName = as !== undefined ? as : $ui_tagName;
34
+ const finalA11yAttributes = a11yAttributes !== undefined ? a11yAttributes : $a11yAttributes_text;
35
+ const finalTagAttributes = tagAttributes !== undefined ? tagAttributes : $tagAttributes_text;
36
+ const finalDataTitle = dataTitle !== undefined ? dataTitle : $i18n_dataTitle;
37
+ const finalHighlightConfig = highlightConfig !== undefined ? highlightConfig : $ui_highlightConfig;
38
+ const {
39
+ data: highlightData = []
40
+ } = finalHighlightConfig;
41
+ return /*#__PURE__*/React.createElement(finalTagName, {
32
42
  className: typographyClass,
33
- 'data-title': $i18n_dataTitle,
43
+ 'data-title': finalDataTitle,
34
44
  'data-id': customId,
35
45
  'data-test-id': testId,
36
- ...$tagAttributes_text,
37
- ...$a11yAttributes_text
38
- }, highlightData && highlightData.length > 0 && typeof children === 'string' ? highlightText({ ...$ui_highlightConfig,
46
+ ...finalTagAttributes,
47
+ ...finalA11yAttributes
48
+ }, highlightData && highlightData.length > 0 && typeof children === 'string' ? highlightText({ ...finalHighlightConfig,
39
49
  text: children
40
50
  }) : children);
41
51
  };
@@ -15,7 +15,7 @@ describe('Typography', () => {
15
15
  const ui_decoration = ['default', 'underline', 'strike', 'overline'];
16
16
  const ui_wordBreak = ['breakAll', 'keepAll', 'breakWord'];
17
17
  const ui_wordWrap = ['normal', 'break'];
18
- const ui_whiteSpace = ['normal', 'noWrap', 'pre', 'preLine', 'preWrap'];
18
+ const ui_whiteSpace = ['normal', 'noWrap', 'pre', 'preLine', 'preWrap', 'breakSpaces'];
19
19
  test('rendering the defult props', () => {
20
20
  const {
21
21
  asFragment
@@ -36,6 +36,14 @@ describe('Typography', () => {
36
36
  }, "Heading 2 Test"));
37
37
  expect(asFragment()).toMatchSnapshot();
38
38
  });
39
+ test('rendering h2 tag name with using as', () => {
40
+ const {
41
+ asFragment
42
+ } = render( /*#__PURE__*/React.createElement(Typography, {
43
+ as: "h2"
44
+ }, "Heading 2 Test"));
45
+ expect(asFragment()).toMatchSnapshot();
46
+ });
39
47
  test('rendering i18n_dataTitle', () => {
40
48
  const {
41
49
  asFragment
@@ -44,6 +52,14 @@ describe('Typography', () => {
44
52
  }, "Heading 2 Test"));
45
53
  expect(asFragment()).toMatchSnapshot();
46
54
  });
55
+ test('rendering dataTitle', () => {
56
+ const {
57
+ asFragment
58
+ } = render( /*#__PURE__*/React.createElement(Typography, {
59
+ dataTitle: "typoDataTitle"
60
+ }, "Heading 2 Test"));
61
+ expect(asFragment()).toMatchSnapshot();
62
+ });
47
63
  test('rendering testId', () => {
48
64
  const {
49
65
  asFragment
@@ -70,6 +86,16 @@ describe('Typography', () => {
70
86
  }, "Heading 2 Test"));
71
87
  expect(asFragment()).toMatchSnapshot();
72
88
  });
89
+ test('rendering tagAttributes', () => {
90
+ const {
91
+ asFragment
92
+ } = render( /*#__PURE__*/React.createElement(Typography, {
93
+ tagAttributes: {
94
+ id: "TypoCustomId"
95
+ }
96
+ }, "Heading 2 Test"));
97
+ expect(asFragment()).toMatchSnapshot();
98
+ });
73
99
  test('rendering a11yAttributes_text', () => {
74
100
  const {
75
101
  asFragment
@@ -82,6 +108,18 @@ describe('Typography', () => {
82
108
  }, "Heading 2 Test"));
83
109
  expect(asFragment()).toMatchSnapshot();
84
110
  });
111
+ test('rendering a11yAttributes', () => {
112
+ const {
113
+ asFragment
114
+ } = render( /*#__PURE__*/React.createElement(Typography, {
115
+ a11yAttributes: {
116
+ 'aria-haspopup': 'true',
117
+ 'aria-expanded': true,
118
+ 'aria-controls': 'uniqueId'
119
+ }
120
+ }, "Heading 2 Test"));
121
+ expect(asFragment()).toMatchSnapshot();
122
+ });
85
123
  test('rendering flag_reset', () => {
86
124
  const {
87
125
  asFragment
@@ -90,6 +128,14 @@ describe('Typography', () => {
90
128
  }, "Heading 2 Test"));
91
129
  expect(asFragment()).toMatchSnapshot();
92
130
  });
131
+ test('rendering shouldReset', () => {
132
+ const {
133
+ asFragment
134
+ } = render( /*#__PURE__*/React.createElement(Typography, {
135
+ shouldReset: true
136
+ }, "Heading 2 Test"));
137
+ expect(asFragment()).toMatchSnapshot();
138
+ });
93
139
  test('rendering flag_dotted', () => {
94
140
  const {
95
141
  asFragment
@@ -98,6 +144,14 @@ describe('Typography', () => {
98
144
  }, "Heading 2 Test"));
99
145
  expect(asFragment()).toMatchSnapshot();
100
146
  });
147
+ test('rendering isDotted', () => {
148
+ const {
149
+ asFragment
150
+ } = render( /*#__PURE__*/React.createElement(Typography, {
151
+ isDotted: true
152
+ }, "Heading 2 Test"));
153
+ expect(asFragment()).toMatchSnapshot();
154
+ });
101
155
  test.each(ui_size)('Should render ui_size - %s', ui_size => {
102
156
  const {
103
157
  asFragment
@@ -107,6 +161,15 @@ describe('Typography', () => {
107
161
  }, "Heading"));
108
162
  expect(asFragment()).toMatchSnapshot();
109
163
  });
164
+ test.each(ui_size)('Should render size - %s', size => {
165
+ const {
166
+ asFragment
167
+ } = render( /*#__PURE__*/React.createElement(Typography, {
168
+ isScrollAttribute: true,
169
+ size: size
170
+ }, "Heading"));
171
+ expect(asFragment()).toMatchSnapshot();
172
+ });
110
173
  test.each(ui_lineClamp)('Should render ui_lineClamp - %s', ui_lineClamp => {
111
174
  const {
112
175
  asFragment
@@ -116,6 +179,15 @@ describe('Typography', () => {
116
179
  }, "Heading"));
117
180
  expect(asFragment()).toMatchSnapshot();
118
181
  });
182
+ test.each(ui_lineClamp)('Should render lineClamp - %s', lineClamp => {
183
+ const {
184
+ asFragment
185
+ } = render( /*#__PURE__*/React.createElement(Typography, {
186
+ isScrollAttribute: true,
187
+ lineClamp: lineClamp
188
+ }, "Heading"));
189
+ expect(asFragment()).toMatchSnapshot();
190
+ });
119
191
  test.each(ui_lineHeight)('Should render ui_lineHeight - %s', ui_lineHeight => {
120
192
  const {
121
193
  asFragment
@@ -125,6 +197,15 @@ describe('Typography', () => {
125
197
  }, "Heading"));
126
198
  expect(asFragment()).toMatchSnapshot();
127
199
  });
200
+ test.each(ui_lineHeight)('Should render lineHeight - %s', lineHeight => {
201
+ const {
202
+ asFragment
203
+ } = render( /*#__PURE__*/React.createElement(Typography, {
204
+ isScrollAttribute: true,
205
+ lineHeight: lineHeight
206
+ }, "Heading"));
207
+ expect(asFragment()).toMatchSnapshot();
208
+ });
128
209
  test.each(ui_display)('Should render ui_display - %s', ui_display => {
129
210
  const {
130
211
  asFragment
@@ -134,6 +215,15 @@ describe('Typography', () => {
134
215
  }, "Heading"));
135
216
  expect(asFragment()).toMatchSnapshot();
136
217
  });
218
+ test.each(ui_display)('Should render display - %s', display => {
219
+ const {
220
+ asFragment
221
+ } = render( /*#__PURE__*/React.createElement(Typography, {
222
+ isScrollAttribute: true,
223
+ display: display
224
+ }, "Heading"));
225
+ expect(asFragment()).toMatchSnapshot();
226
+ });
137
227
  test.each(ui_weight)('Should render ui_weight - %s', ui_weight => {
138
228
  const {
139
229
  asFragment
@@ -143,6 +233,15 @@ describe('Typography', () => {
143
233
  }, "Heading"));
144
234
  expect(asFragment()).toMatchSnapshot();
145
235
  });
236
+ test.each(ui_weight)('Should render weight - %s', weight => {
237
+ const {
238
+ asFragment
239
+ } = render( /*#__PURE__*/React.createElement(Typography, {
240
+ isScrollAttribute: true,
241
+ weight: weight
242
+ }, "Heading"));
243
+ expect(asFragment()).toMatchSnapshot();
244
+ });
146
245
  test.each(ui_typeFace)('Should render ui_typeFace - %s', ui_typeFace => {
147
246
  const {
148
247
  asFragment
@@ -152,6 +251,15 @@ describe('Typography', () => {
152
251
  }, "Heading"));
153
252
  expect(asFragment()).toMatchSnapshot();
154
253
  });
254
+ test.each(ui_typeFace)('Should render typeFace - %s', typeFace => {
255
+ const {
256
+ asFragment
257
+ } = render( /*#__PURE__*/React.createElement(Typography, {
258
+ isScrollAttribute: true,
259
+ typeFace: typeFace
260
+ }, "Heading"));
261
+ expect(asFragment()).toMatchSnapshot();
262
+ });
155
263
  test.each(ui_textAlign)('Should render ui_textAlign - %s', ui_textAlign => {
156
264
  const {
157
265
  asFragment
@@ -161,6 +269,15 @@ describe('Typography', () => {
161
269
  }, "Heading"));
162
270
  expect(asFragment()).toMatchSnapshot();
163
271
  });
272
+ test.each(ui_textAlign)('Should render textAlign - %s', textAlign => {
273
+ const {
274
+ asFragment
275
+ } = render( /*#__PURE__*/React.createElement(Typography, {
276
+ isScrollAttribute: true,
277
+ textAlign: textAlign
278
+ }, "Heading"));
279
+ expect(asFragment()).toMatchSnapshot();
280
+ });
164
281
  test.each(ui_letterSpacing)('Should render ui_letterSpacing - %s', ui_letterSpacing => {
165
282
  const {
166
283
  asFragment
@@ -170,6 +287,15 @@ describe('Typography', () => {
170
287
  }, "Heading"));
171
288
  expect(asFragment()).toMatchSnapshot();
172
289
  });
290
+ test.each(ui_letterSpacing)('Should render letterSpacing - %s', letterSpacing => {
291
+ const {
292
+ asFragment
293
+ } = render( /*#__PURE__*/React.createElement(Typography, {
294
+ isScrollAttribute: true,
295
+ letterSpacing: letterSpacing
296
+ }, "Heading"));
297
+ expect(asFragment()).toMatchSnapshot();
298
+ });
173
299
  test.each(ui_transform)('Should render ui_transform - %s', ui_transform => {
174
300
  const {
175
301
  asFragment
@@ -179,6 +305,15 @@ describe('Typography', () => {
179
305
  }, "Heading"));
180
306
  expect(asFragment()).toMatchSnapshot();
181
307
  });
308
+ test.each(ui_transform)('Should render transform - %s', transform => {
309
+ const {
310
+ asFragment
311
+ } = render( /*#__PURE__*/React.createElement(Typography, {
312
+ isScrollAttribute: true,
313
+ transform: transform
314
+ }, "Heading"));
315
+ expect(asFragment()).toMatchSnapshot();
316
+ });
182
317
  test.each(ui_decoration)('Should render ui_decoration - %s', ui_decoration => {
183
318
  const {
184
319
  asFragment
@@ -188,6 +323,15 @@ describe('Typography', () => {
188
323
  }, "Heading"));
189
324
  expect(asFragment()).toMatchSnapshot();
190
325
  });
326
+ test.each(ui_decoration)('Should render decoration - %s', decoration => {
327
+ const {
328
+ asFragment
329
+ } = render( /*#__PURE__*/React.createElement(Typography, {
330
+ isScrollAttribute: true,
331
+ decoration: decoration
332
+ }, "Heading"));
333
+ expect(asFragment()).toMatchSnapshot();
334
+ });
191
335
  test('rendering ui_className', () => {
192
336
  const {
193
337
  asFragment
@@ -196,6 +340,14 @@ describe('Typography', () => {
196
340
  }, "Heading 2 Test"));
197
341
  expect(asFragment()).toMatchSnapshot();
198
342
  });
343
+ test('rendering customClass', () => {
344
+ const {
345
+ asFragment
346
+ } = render( /*#__PURE__*/React.createElement(Typography, {
347
+ customClass: "custom-class"
348
+ }, "Heading 2 Test"));
349
+ expect(asFragment()).toMatchSnapshot();
350
+ });
199
351
  test.each(ui_wordBreak)('Should render ui_wordBreak - %s', ui_wordBreak => {
200
352
  const {
201
353
  asFragment
@@ -205,6 +357,15 @@ describe('Typography', () => {
205
357
  }, "Heading"));
206
358
  expect(asFragment()).toMatchSnapshot();
207
359
  });
360
+ test.each(ui_wordBreak)('Should render wordBreak - %s', wordBreak => {
361
+ const {
362
+ asFragment
363
+ } = render( /*#__PURE__*/React.createElement(Typography, {
364
+ isScrollAttribute: true,
365
+ wordBreak: wordBreak
366
+ }, "Heading"));
367
+ expect(asFragment()).toMatchSnapshot();
368
+ });
208
369
  test.each(ui_wordWrap)('Should render ui_wordWrap - %s', ui_wordWrap => {
209
370
  const {
210
371
  asFragment
@@ -214,6 +375,15 @@ describe('Typography', () => {
214
375
  }, "Heading"));
215
376
  expect(asFragment()).toMatchSnapshot();
216
377
  });
378
+ test.each(ui_wordWrap)('Should render wordWrap - %s', wordWrap => {
379
+ const {
380
+ asFragment
381
+ } = render( /*#__PURE__*/React.createElement(Typography, {
382
+ isScrollAttribute: true,
383
+ wordWrap: wordWrap
384
+ }, "Heading"));
385
+ expect(asFragment()).toMatchSnapshot();
386
+ });
217
387
  test.each(ui_whiteSpace)('Should render ui_whiteSpace - %s', ui_whiteSpace => {
218
388
  const {
219
389
  asFragment
@@ -223,6 +393,15 @@ describe('Typography', () => {
223
393
  }, "Heading"));
224
394
  expect(asFragment()).toMatchSnapshot();
225
395
  });
396
+ test.each(ui_whiteSpace)('Should render whiteSpace - %s', whiteSpace => {
397
+ const {
398
+ asFragment
399
+ } = render( /*#__PURE__*/React.createElement(Typography, {
400
+ isScrollAttribute: true,
401
+ whiteSpace: whiteSpace
402
+ }, "Heading"));
403
+ expect(asFragment()).toMatchSnapshot();
404
+ });
226
405
  });
227
406
  describe('Typography with highlight', () => {
228
407
  test('should render highlighted word', () => {
@@ -238,6 +417,19 @@ describe('Typography with highlight', () => {
238
417
  }, "The sun was bright, the sun was warm, the sun was high in the sky."));
239
418
  expect(asFragment()).toMatchSnapshot();
240
419
  });
420
+ test('should render highlighted word with highlightConfig', () => {
421
+ const {
422
+ asFragment
423
+ } = render( /*#__PURE__*/React.createElement(Typography, {
424
+ highlightConfig: {
425
+ data: ['sun'],
426
+ styleConfiguration: {
427
+ $ui_weight: 'bold'
428
+ }
429
+ }
430
+ }, "The sun was bright, the sun was warm, the sun was high in the sky."));
431
+ expect(asFragment()).toMatchSnapshot();
432
+ });
241
433
  test('should render highlight by Index', () => {
242
434
  const {
243
435
  asFragment
@@ -321,7 +513,7 @@ describe('Typography with highlight', () => {
321
513
  }, "The sun was bright, the moon was bright, the sun and moon again."));
322
514
  expect(asFragment()).toMatchSnapshot();
323
515
  });
324
- test('should render with global tagName applied to all highlights', () => {
516
+ test('should render with global tag name applied to all highlights', () => {
325
517
  const {
326
518
  asFragment
327
519
  } = render( /*#__PURE__*/React.createElement(Typography, {
@@ -331,22 +523,22 @@ describe('Typography with highlight', () => {
331
523
  }, {
332
524
  text: 'moon'
333
525
  }],
334
- tagName: 'i'
526
+ as: 'i'
335
527
  }
336
528
  }, "The sun and moon were bright."));
337
529
  expect(asFragment()).toMatchSnapshot();
338
530
  });
339
- test('should render with separate tagName for each highlighted word', () => {
531
+ test('should render with separate tag name for each highlighted word', () => {
340
532
  const {
341
533
  asFragment
342
534
  } = render( /*#__PURE__*/React.createElement(Typography, {
343
535
  $ui_highlightConfig: {
344
536
  data: [{
345
537
  text: 'sun',
346
- tagName: 'i'
538
+ as: 'i'
347
539
  }, {
348
540
  text: 'moon',
349
- tagName: 'u'
541
+ as: 'u'
350
542
  }]
351
543
  }
352
544
  }, "The sun and moon were bright."));