@zohodesk/components 1.0.0-temp-233 → 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/.cli/propValidation_report.html +1 -1
- package/README.md +13 -0
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +4 -4
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/light/mode/Component_LightMode.module.css +6 -6
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +3 -3
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +461 -8
- package/es/MultiSelect/MultiSelect.js +36 -12
- package/es/MultiSelect/Suggestions.js +171 -100
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +4 -0
- package/es/Select/Select.js +41 -12
- package/es/Select/props/defaultProps.js +1 -0
- package/es/Select/props/propTypes.js +1 -0
- 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/Common.js +2 -1
- package/es/utils/dropDownUtils.js +3 -1
- package/lib/MultiSelect/MultiSelect.js +36 -10
- package/lib/MultiSelect/Suggestions.js +174 -104
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +4 -0
- package/lib/Select/Select.js +40 -9
- package/lib/Select/props/defaultProps.js +1 -0
- package/lib/Select/props/propTypes.js +1 -0
- 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/Common.js +4 -2
- package/lib/utils/dropDownUtils.js +3 -1
- package/package.json +6 -6
|
@@ -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
|
+
});
|