@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
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Typography component should be render with text children 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class=""
|
|
7
|
+
>
|
|
8
|
+
Text testing
|
|
9
|
+
</div>
|
|
10
|
+
</DocumentFragment>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`Typography component should be render with the basic set of default props 1`] = `
|
|
14
|
+
<DocumentFragment>
|
|
15
|
+
<div
|
|
16
|
+
class=""
|
|
17
|
+
/>
|
|
18
|
+
</DocumentFragment>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`Typography component should render customised render the highlight element for all highlighted words 1`] = `
|
|
22
|
+
<DocumentFragment>
|
|
23
|
+
<div
|
|
24
|
+
class=""
|
|
25
|
+
>
|
|
26
|
+
The
|
|
27
|
+
<div
|
|
28
|
+
aria-labelledby="1"
|
|
29
|
+
class="container effect medium lgRadius default "
|
|
30
|
+
data-id="tag_Tag"
|
|
31
|
+
data-selector-id="tag"
|
|
32
|
+
data-test-id="tag_Tag"
|
|
33
|
+
data-title="Sun"
|
|
34
|
+
tabindex="0"
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
class="text mediumtext"
|
|
39
|
+
id="1"
|
|
40
|
+
>
|
|
41
|
+
Sun
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
was bright.
|
|
45
|
+
</div>
|
|
46
|
+
</DocumentFragment>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
exports[`Typography component should render globally skip highlights at given indexes, with isExcludedIndex 1`] = `
|
|
50
|
+
<DocumentFragment>
|
|
51
|
+
<div
|
|
52
|
+
class=""
|
|
53
|
+
>
|
|
54
|
+
The sun was bright, the
|
|
55
|
+
<span
|
|
56
|
+
class="font_bold decoration_underline"
|
|
57
|
+
>
|
|
58
|
+
sun
|
|
59
|
+
</span>
|
|
60
|
+
was warm, the
|
|
61
|
+
<span
|
|
62
|
+
class="font_bold decoration_underline"
|
|
63
|
+
>
|
|
64
|
+
sun
|
|
65
|
+
</span>
|
|
66
|
+
was high in the sky.
|
|
67
|
+
</div>
|
|
68
|
+
</DocumentFragment>
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
exports[`Typography component should render highlight by Index 1`] = `
|
|
72
|
+
<DocumentFragment>
|
|
73
|
+
<div
|
|
74
|
+
class=""
|
|
75
|
+
>
|
|
76
|
+
The
|
|
77
|
+
<span
|
|
78
|
+
class="font_bold decoration_underline"
|
|
79
|
+
>
|
|
80
|
+
sun
|
|
81
|
+
</span>
|
|
82
|
+
was bright, I walked
|
|
83
|
+
<span
|
|
84
|
+
class="font_bold decoration_underline"
|
|
85
|
+
>
|
|
86
|
+
under
|
|
87
|
+
</span>
|
|
88
|
+
the
|
|
89
|
+
<span
|
|
90
|
+
class="font_bold decoration_underline"
|
|
91
|
+
>
|
|
92
|
+
sun
|
|
93
|
+
</span>
|
|
94
|
+
, I talked under the sun.
|
|
95
|
+
</div>
|
|
96
|
+
</DocumentFragment>
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
exports[`Typography component should render highlighted word 1`] = `
|
|
100
|
+
<DocumentFragment>
|
|
101
|
+
<div
|
|
102
|
+
class=""
|
|
103
|
+
>
|
|
104
|
+
The
|
|
105
|
+
<span
|
|
106
|
+
class="font_bold"
|
|
107
|
+
>
|
|
108
|
+
sun
|
|
109
|
+
</span>
|
|
110
|
+
was bright, the
|
|
111
|
+
<span
|
|
112
|
+
class="font_bold"
|
|
113
|
+
>
|
|
114
|
+
sun
|
|
115
|
+
</span>
|
|
116
|
+
was warm, the
|
|
117
|
+
<span
|
|
118
|
+
class="font_bold"
|
|
119
|
+
>
|
|
120
|
+
sun
|
|
121
|
+
</span>
|
|
122
|
+
was high in the sky.
|
|
123
|
+
</div>
|
|
124
|
+
</DocumentFragment>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`Typography component should render separate Styles per Word 1`] = `
|
|
128
|
+
<DocumentFragment>
|
|
129
|
+
<div
|
|
130
|
+
class=""
|
|
131
|
+
>
|
|
132
|
+
The
|
|
133
|
+
<span
|
|
134
|
+
class="font_bold"
|
|
135
|
+
>
|
|
136
|
+
sun
|
|
137
|
+
</span>
|
|
138
|
+
was bright, I walked
|
|
139
|
+
<span
|
|
140
|
+
class="decoration_underline"
|
|
141
|
+
>
|
|
142
|
+
under
|
|
143
|
+
</span>
|
|
144
|
+
the
|
|
145
|
+
<span
|
|
146
|
+
class="font_bold"
|
|
147
|
+
>
|
|
148
|
+
sun
|
|
149
|
+
</span>
|
|
150
|
+
, I talked
|
|
151
|
+
<span
|
|
152
|
+
class="decoration_underline"
|
|
153
|
+
>
|
|
154
|
+
under
|
|
155
|
+
</span>
|
|
156
|
+
the
|
|
157
|
+
<span
|
|
158
|
+
class="font_bold"
|
|
159
|
+
>
|
|
160
|
+
sun
|
|
161
|
+
</span>
|
|
162
|
+
.
|
|
163
|
+
</div>
|
|
164
|
+
</DocumentFragment>
|
|
165
|
+
`;
|
|
166
|
+
|
|
167
|
+
exports[`Typography component should render separate customised render the highlight element for each highlighted word 1`] = `
|
|
168
|
+
<DocumentFragment>
|
|
169
|
+
<div
|
|
170
|
+
class=""
|
|
171
|
+
>
|
|
172
|
+
The
|
|
173
|
+
<div
|
|
174
|
+
aria-labelledby="2"
|
|
175
|
+
class="container effect medium lgRadius default "
|
|
176
|
+
data-id="tag_Tag"
|
|
177
|
+
data-selector-id="tag"
|
|
178
|
+
data-test-id="tag_Tag"
|
|
179
|
+
data-title="Sun"
|
|
180
|
+
tabindex="0"
|
|
181
|
+
>
|
|
182
|
+
<div
|
|
183
|
+
aria-hidden="true"
|
|
184
|
+
class="text mediumtext"
|
|
185
|
+
id="2"
|
|
186
|
+
>
|
|
187
|
+
Sun
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
and
|
|
191
|
+
<div
|
|
192
|
+
aria-labelledby="3"
|
|
193
|
+
class="container effect medium lgRadius default "
|
|
194
|
+
data-id="tag_Tag"
|
|
195
|
+
data-selector-id="tag"
|
|
196
|
+
data-test-id="tag_Tag"
|
|
197
|
+
data-title="Moon"
|
|
198
|
+
tabindex="0"
|
|
199
|
+
>
|
|
200
|
+
<div
|
|
201
|
+
aria-hidden="true"
|
|
202
|
+
class="text mediumtext"
|
|
203
|
+
id="3"
|
|
204
|
+
>
|
|
205
|
+
Moon
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
were bright.
|
|
209
|
+
</div>
|
|
210
|
+
</DocumentFragment>
|
|
211
|
+
`;
|
|
212
|
+
|
|
213
|
+
exports[`Typography component should render with global case-sensitive option 1`] = `
|
|
214
|
+
<DocumentFragment>
|
|
215
|
+
<div
|
|
216
|
+
class=""
|
|
217
|
+
>
|
|
218
|
+
The
|
|
219
|
+
<span
|
|
220
|
+
class="font_bold decoration_underline"
|
|
221
|
+
>
|
|
222
|
+
Sun
|
|
223
|
+
</span>
|
|
224
|
+
was bright, the
|
|
225
|
+
<span
|
|
226
|
+
class="font_bold decoration_underline"
|
|
227
|
+
>
|
|
228
|
+
moon
|
|
229
|
+
</span>
|
|
230
|
+
was bright, the sun was warm.
|
|
231
|
+
</div>
|
|
232
|
+
</DocumentFragment>
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
exports[`Typography component should render with global custom class for all highlights 1`] = `
|
|
236
|
+
<DocumentFragment>
|
|
237
|
+
<div
|
|
238
|
+
class=""
|
|
239
|
+
>
|
|
240
|
+
The
|
|
241
|
+
<span
|
|
242
|
+
class="global_custom_class"
|
|
243
|
+
>
|
|
244
|
+
sun
|
|
245
|
+
</span>
|
|
246
|
+
and
|
|
247
|
+
<span
|
|
248
|
+
class="global_custom_class"
|
|
249
|
+
>
|
|
250
|
+
moon
|
|
251
|
+
</span>
|
|
252
|
+
were bright.
|
|
253
|
+
</div>
|
|
254
|
+
</DocumentFragment>
|
|
255
|
+
`;
|
|
256
|
+
|
|
257
|
+
exports[`Typography component should render with global custom style for all highlights 1`] = `
|
|
258
|
+
<DocumentFragment>
|
|
259
|
+
<div
|
|
260
|
+
class=""
|
|
261
|
+
>
|
|
262
|
+
The
|
|
263
|
+
<span
|
|
264
|
+
class=""
|
|
265
|
+
style="background-color: lightgreen;"
|
|
266
|
+
>
|
|
267
|
+
sun
|
|
268
|
+
</span>
|
|
269
|
+
and
|
|
270
|
+
<span
|
|
271
|
+
class=""
|
|
272
|
+
style="background-color: lightgreen;"
|
|
273
|
+
>
|
|
274
|
+
moon
|
|
275
|
+
</span>
|
|
276
|
+
were bright.
|
|
277
|
+
</div>
|
|
278
|
+
</DocumentFragment>
|
|
279
|
+
`;
|
|
280
|
+
|
|
281
|
+
exports[`Typography component should render with global tagName applied to all highlights 1`] = `
|
|
282
|
+
<DocumentFragment>
|
|
283
|
+
<div
|
|
284
|
+
class=""
|
|
285
|
+
>
|
|
286
|
+
The
|
|
287
|
+
<i
|
|
288
|
+
class=""
|
|
289
|
+
>
|
|
290
|
+
sun
|
|
291
|
+
</i>
|
|
292
|
+
and
|
|
293
|
+
<i
|
|
294
|
+
class=""
|
|
295
|
+
>
|
|
296
|
+
moon
|
|
297
|
+
</i>
|
|
298
|
+
were bright.
|
|
299
|
+
</div>
|
|
300
|
+
</DocumentFragment>
|
|
301
|
+
`;
|
|
302
|
+
|
|
303
|
+
exports[`Typography component should render with global whole-word match only 1`] = `
|
|
304
|
+
<DocumentFragment>
|
|
305
|
+
<div
|
|
306
|
+
class=""
|
|
307
|
+
>
|
|
308
|
+
Sunflower is a flower. The
|
|
309
|
+
<span
|
|
310
|
+
class="font_bold decoration_underline"
|
|
311
|
+
>
|
|
312
|
+
Sun
|
|
313
|
+
</span>
|
|
314
|
+
was bright, the moonlight was bright.
|
|
315
|
+
</div>
|
|
316
|
+
</DocumentFragment>
|
|
317
|
+
`;
|
|
318
|
+
|
|
319
|
+
exports[`Typography component should render with separate case-sensitive option per word 1`] = `
|
|
320
|
+
<DocumentFragment>
|
|
321
|
+
<div
|
|
322
|
+
class=""
|
|
323
|
+
>
|
|
324
|
+
The
|
|
325
|
+
<span
|
|
326
|
+
class="font_bold decoration_underline"
|
|
327
|
+
>
|
|
328
|
+
Sun
|
|
329
|
+
</span>
|
|
330
|
+
was bright, the
|
|
331
|
+
<span
|
|
332
|
+
class="font_bold decoration_underline"
|
|
333
|
+
>
|
|
334
|
+
Moon
|
|
335
|
+
</span>
|
|
336
|
+
was bright, the sun was warm.
|
|
337
|
+
</div>
|
|
338
|
+
</DocumentFragment>
|
|
339
|
+
`;
|
|
340
|
+
|
|
341
|
+
exports[`Typography component should render with separate custom class for each highlighted word 1`] = `
|
|
342
|
+
<DocumentFragment>
|
|
343
|
+
<div
|
|
344
|
+
class=""
|
|
345
|
+
>
|
|
346
|
+
The
|
|
347
|
+
<span
|
|
348
|
+
class="separate_custom_class_sun"
|
|
349
|
+
>
|
|
350
|
+
sun
|
|
351
|
+
</span>
|
|
352
|
+
and
|
|
353
|
+
<span
|
|
354
|
+
class="separate_custom_class_moon"
|
|
355
|
+
>
|
|
356
|
+
moon
|
|
357
|
+
</span>
|
|
358
|
+
were bright.
|
|
359
|
+
</div>
|
|
360
|
+
</DocumentFragment>
|
|
361
|
+
`;
|
|
362
|
+
|
|
363
|
+
exports[`Typography component should render with separate custom style per word 1`] = `
|
|
364
|
+
<DocumentFragment>
|
|
365
|
+
<div
|
|
366
|
+
class=""
|
|
367
|
+
>
|
|
368
|
+
The
|
|
369
|
+
<span
|
|
370
|
+
class=""
|
|
371
|
+
style="background-color: lightgreen;"
|
|
372
|
+
>
|
|
373
|
+
sun
|
|
374
|
+
</span>
|
|
375
|
+
and
|
|
376
|
+
<span
|
|
377
|
+
class=""
|
|
378
|
+
style="background-color: orange;"
|
|
379
|
+
>
|
|
380
|
+
moon
|
|
381
|
+
</span>
|
|
382
|
+
were bright.
|
|
383
|
+
</div>
|
|
384
|
+
</DocumentFragment>
|
|
385
|
+
`;
|
|
386
|
+
|
|
387
|
+
exports[`Typography component should render with separate excluded index option per word 1`] = `
|
|
388
|
+
<DocumentFragment>
|
|
389
|
+
<div
|
|
390
|
+
class=""
|
|
391
|
+
>
|
|
392
|
+
The sun was bright, the moon was bright, the
|
|
393
|
+
<span
|
|
394
|
+
class="font_bold decoration_underline"
|
|
395
|
+
>
|
|
396
|
+
sun
|
|
397
|
+
</span>
|
|
398
|
+
and
|
|
399
|
+
<span
|
|
400
|
+
class="font_bold decoration_underline"
|
|
401
|
+
>
|
|
402
|
+
moon
|
|
403
|
+
</span>
|
|
404
|
+
again.
|
|
405
|
+
</div>
|
|
406
|
+
</DocumentFragment>
|
|
407
|
+
`;
|
|
408
|
+
|
|
409
|
+
exports[`Typography component should render with separate tagName for each highlighted word 1`] = `
|
|
410
|
+
<DocumentFragment>
|
|
411
|
+
<div
|
|
412
|
+
class=""
|
|
413
|
+
>
|
|
414
|
+
The
|
|
415
|
+
<i
|
|
416
|
+
class=""
|
|
417
|
+
>
|
|
418
|
+
sun
|
|
419
|
+
</i>
|
|
420
|
+
and
|
|
421
|
+
<u
|
|
422
|
+
class=""
|
|
423
|
+
>
|
|
424
|
+
moon
|
|
425
|
+
</u>
|
|
426
|
+
were bright.
|
|
427
|
+
</div>
|
|
428
|
+
</DocumentFragment>
|
|
429
|
+
`;
|
|
430
|
+
|
|
431
|
+
exports[`Typography component should render with separate whole-word option per word 1`] = `
|
|
432
|
+
<DocumentFragment>
|
|
433
|
+
<div
|
|
434
|
+
class=""
|
|
435
|
+
>
|
|
436
|
+
Sunflower is a flower. The
|
|
437
|
+
<span
|
|
438
|
+
class="font_bold decoration_underline"
|
|
439
|
+
>
|
|
440
|
+
Sun
|
|
441
|
+
</span>
|
|
442
|
+
was bright, the
|
|
443
|
+
<span
|
|
444
|
+
class="font_bold decoration_underline"
|
|
445
|
+
>
|
|
446
|
+
moon
|
|
447
|
+
</span>
|
|
448
|
+
light was bright.
|
|
449
|
+
</div>
|
|
450
|
+
</DocumentFragment>
|
|
451
|
+
`;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
3
|
+
import style from "./css/Typography.module.css";
|
|
4
|
+
export function highlight(data) {
|
|
5
|
+
const {
|
|
6
|
+
text,
|
|
7
|
+
highlightData,
|
|
8
|
+
customStyle: globalCustomStyle = {},
|
|
9
|
+
highlightsStyle: globalHighlightsStyle = {},
|
|
10
|
+
isExcludedIndex: hasGlobalExcludedIndex = false,
|
|
11
|
+
isCaseSensitive: hasGlobalCaseSensitive = false,
|
|
12
|
+
isWholeWord: hasGlobalWholeWord = false,
|
|
13
|
+
tagName: globalTagName = 'span',
|
|
14
|
+
render: globalRender
|
|
15
|
+
} = data;
|
|
16
|
+
let patternParts = [];
|
|
17
|
+
let highlightTextList = [];
|
|
18
|
+
const highlightListArray = highlightData.map(item => {
|
|
19
|
+
const {
|
|
20
|
+
highlightText,
|
|
21
|
+
index,
|
|
22
|
+
isExcludedIndex,
|
|
23
|
+
isCaseSensitive,
|
|
24
|
+
highlightsStyle,
|
|
25
|
+
customStyle,
|
|
26
|
+
isWholeWord,
|
|
27
|
+
tagName,
|
|
28
|
+
render
|
|
29
|
+
} = item || {};
|
|
30
|
+
let selectedHighlightText = '';
|
|
31
|
+
let selectedIndex = [];
|
|
32
|
+
let selectedExcludedIndex = hasGlobalExcludedIndex;
|
|
33
|
+
let selectedCaseSensitive = hasGlobalCaseSensitive;
|
|
34
|
+
let selectedHighlightsStyle = globalHighlightsStyle;
|
|
35
|
+
let selectedCustomStyle = globalCustomStyle;
|
|
36
|
+
let selectedWholeWord = hasGlobalWholeWord;
|
|
37
|
+
let selectedTagName = globalTagName;
|
|
38
|
+
let selectedRender = globalRender;
|
|
39
|
+
|
|
40
|
+
if (typeof item === 'string') {
|
|
41
|
+
selectedHighlightText = item;
|
|
42
|
+
} else if (item && typeof highlightText === 'string') {
|
|
43
|
+
selectedHighlightText = highlightText;
|
|
44
|
+
selectedIndex = index !== undefined ? index : [];
|
|
45
|
+
selectedExcludedIndex = isExcludedIndex !== undefined ? isExcludedIndex : hasGlobalExcludedIndex;
|
|
46
|
+
selectedCaseSensitive = isCaseSensitive !== undefined ? isCaseSensitive : hasGlobalCaseSensitive;
|
|
47
|
+
selectedCustomStyle = customStyle !== undefined ? customStyle : globalCustomStyle;
|
|
48
|
+
selectedHighlightsStyle = highlightsStyle !== undefined ? highlightsStyle : globalHighlightsStyle;
|
|
49
|
+
selectedWholeWord = isWholeWord !== undefined ? isWholeWord : hasGlobalWholeWord;
|
|
50
|
+
selectedTagName = tagName !== undefined ? tagName : globalTagName;
|
|
51
|
+
selectedRender = render !== undefined ? render : globalRender;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
highlightsClass
|
|
56
|
+
} = getClassFromStyle(selectedHighlightsStyle);
|
|
57
|
+
|
|
58
|
+
if (selectedHighlightText.trim() !== '') {
|
|
59
|
+
const escaped = selectedHighlightText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
60
|
+
patternParts.push(selectedWholeWord ? `\\b${escaped}\\b` : escaped);
|
|
61
|
+
highlightTextList.push(isCaseSensitive ? selectedHighlightText : selectedHighlightText.toLowerCase());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
highlightText: selectedHighlightText,
|
|
66
|
+
index: selectedIndex,
|
|
67
|
+
isExcludedIndex: selectedExcludedIndex,
|
|
68
|
+
isCaseSensitive: selectedCaseSensitive,
|
|
69
|
+
highlightsClass,
|
|
70
|
+
customStyle: selectedCustomStyle,
|
|
71
|
+
tagName: selectedTagName,
|
|
72
|
+
render: selectedRender
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
const pattern = patternParts.join('|');
|
|
76
|
+
|
|
77
|
+
if (!pattern) {
|
|
78
|
+
return text;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const splittedChild = text.split(new RegExp(`(${pattern})`, 'gi'));
|
|
82
|
+
const indexCount = {};
|
|
83
|
+
return splittedChild.map((part, i) => {
|
|
84
|
+
let Tag = 'span';
|
|
85
|
+
const match = highlightListArray.find(_ref => {
|
|
86
|
+
let {
|
|
87
|
+
highlightText,
|
|
88
|
+
isCaseSensitive
|
|
89
|
+
} = _ref;
|
|
90
|
+
const inputText = isCaseSensitive ? part : part.toLowerCase();
|
|
91
|
+
const target = isCaseSensitive ? highlightText : highlightText.toLowerCase();
|
|
92
|
+
return inputText === target;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (!match) {
|
|
96
|
+
return part;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const key = match.highlightText;
|
|
100
|
+
indexCount[key] = (indexCount[key] || 0) + 1;
|
|
101
|
+
const {
|
|
102
|
+
tagName,
|
|
103
|
+
index,
|
|
104
|
+
isExcludedIndex,
|
|
105
|
+
render,
|
|
106
|
+
highlightsClass,
|
|
107
|
+
customStyle
|
|
108
|
+
} = match;
|
|
109
|
+
Tag = tagName;
|
|
110
|
+
const currentIndex = indexCount[key];
|
|
111
|
+
const isArrayIndex = Array.isArray(index);
|
|
112
|
+
const isMatch = isArrayIndex ? (index.length === 0 || index.includes(currentIndex)) !== isExcludedIndex : (index === 0 || index === currentIndex) !== isExcludedIndex;
|
|
113
|
+
|
|
114
|
+
if (!isMatch) {
|
|
115
|
+
return part;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return render || /*#__PURE__*/React.createElement(Tag, {
|
|
119
|
+
key: i,
|
|
120
|
+
style: customStyle,
|
|
121
|
+
className: highlightsClass
|
|
122
|
+
}, part);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getClassFromStyle(styleObj) {
|
|
127
|
+
const {
|
|
128
|
+
weight,
|
|
129
|
+
typeFace,
|
|
130
|
+
transform,
|
|
131
|
+
decoration,
|
|
132
|
+
customClass
|
|
133
|
+
} = styleObj;
|
|
134
|
+
const highlightsClass = compileClassNames({
|
|
135
|
+
[style[`font_${weight}`]]: !!weight,
|
|
136
|
+
[style[`fontStyles_${typeFace}`]]: !!typeFace,
|
|
137
|
+
[style[`transform_${transform}`]]: !!transform,
|
|
138
|
+
[style[`decoration_${decoration}`]]: !!decoration,
|
|
139
|
+
[customClass]: !!customClass
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
highlightsClass
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
const highlightsStyleShape = PropTypes.shape({
|
|
3
|
+
weight: PropTypes.oneOf(['regular', 'light', 'semibold', 'bold']),
|
|
4
|
+
transform: PropTypes.oneOf(['default', 'upper', 'lower', 'capital']),
|
|
5
|
+
decoration: PropTypes.oneOf(['default', 'underline', 'strike', 'overline']),
|
|
6
|
+
typeFace: PropTypes.oneOf(['normal', 'italic']),
|
|
7
|
+
customClass: PropTypes.object
|
|
8
|
+
});
|
|
9
|
+
const commonHighlightProps = {
|
|
10
|
+
customStyle: PropTypes.object,
|
|
11
|
+
isExcludedIndex: PropTypes.bool,
|
|
12
|
+
isCaseSensitive: PropTypes.bool,
|
|
13
|
+
isWholeWord: PropTypes.bool,
|
|
14
|
+
tagName: PropTypes.string,
|
|
15
|
+
render: PropTypes.element,
|
|
16
|
+
highlightsStyle: PropTypes.objectOf(highlightsStyleShape)
|
|
17
|
+
};
|
|
2
18
|
export const propTypes = {
|
|
3
19
|
children: PropTypes.node,
|
|
4
20
|
$ui_className: PropTypes.string,
|
|
@@ -23,5 +39,14 @@ export const propTypes = {
|
|
|
23
39
|
customId: PropTypes.string,
|
|
24
40
|
customStyle: PropTypes.object,
|
|
25
41
|
$a11yAttributes_text: PropTypes.object,
|
|
26
|
-
$tagAttributes_text: PropTypes.object
|
|
42
|
+
$tagAttributes_text: PropTypes.object,
|
|
43
|
+
highlights: PropTypes.objectOf(PropTypes.shape({
|
|
44
|
+
text: PropTypes.string,
|
|
45
|
+
highlightData: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
46
|
+
highlightText: PropTypes.string,
|
|
47
|
+
index: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
|
|
48
|
+
...commonHighlightProps
|
|
49
|
+
})])),
|
|
50
|
+
...commonHighlightProps
|
|
51
|
+
}))
|
|
27
52
|
};
|
|
@@ -43,8 +43,6 @@ const getDisabledOptions = props => props.disabledOptions || dummyArray;
|
|
|
43
43
|
|
|
44
44
|
const getListItemProps = props => props.listItemProps || '';
|
|
45
45
|
|
|
46
|
-
const getlistItemCustomProps = props => props.listItemCustomProps || dummyObj;
|
|
47
|
-
|
|
48
46
|
const defaultSearchFields = ['value'];
|
|
49
47
|
|
|
50
48
|
const getSearchFields = props => {
|
|
@@ -135,7 +133,7 @@ export const extractOptionId = id => {
|
|
|
135
133
|
}
|
|
136
134
|
};
|
|
137
135
|
export const extractOptionIdFromJson = (id, localData) => localData[id] || {};
|
|
138
|
-
export const makeFormatOptions = () => createSelector([getOptions, getValueField, getTextField, getImageField, getPrefixText, getIconName, getIconSize, getOptionType, getDisabledOptions, getListItemProps,
|
|
136
|
+
export const makeFormatOptions = () => createSelector([getOptions, getValueField, getTextField, getImageField, getPrefixText, getIconName, getIconSize, getOptionType, getDisabledOptions, getListItemProps, getAllowValueFallback, getSearchFields, getSecondaryField], (options, valueField, textField, imageField, prefixText, iconName, iconSize, optionType, disabledOptions, listItemProps, allowValueFallback, searchFields, secondaryField) => {
|
|
139
137
|
const revampOptions = [];
|
|
140
138
|
const remvampOptionIds = [];
|
|
141
139
|
const normalizedAllOptions = {};
|
|
@@ -151,8 +149,7 @@ export const makeFormatOptions = () => createSelector([getOptions, getValueField
|
|
|
151
149
|
optionType: impOptionType,
|
|
152
150
|
iconName: impIconName,
|
|
153
151
|
iconSize: impIconSize,
|
|
154
|
-
listItemProps: listStyle
|
|
155
|
-
listItemCustomProps: listStyleCustomProps
|
|
152
|
+
listItemProps: listStyle
|
|
156
153
|
} = option;
|
|
157
154
|
let id = typeof option === 'object' ? option[impValueField || valueField] : option;
|
|
158
155
|
const value = typeof option === 'object' ? option[impTextField || textField] : allowValueFallback ? option : '';
|
|
@@ -198,10 +195,6 @@ export const makeFormatOptions = () => createSelector([getOptions, getValueField
|
|
|
198
195
|
optionDetails.listItemProps = listStyle || listItemProps;
|
|
199
196
|
}
|
|
200
197
|
|
|
201
|
-
if (listStyleCustomProps || listItemCustomProps) {
|
|
202
|
-
optionDetails.listItemCustomProps = listStyleCustomProps || listItemCustomProps;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
198
|
normalizedFormatOptions[id] = optionDetails;
|
|
206
199
|
normalizedAllOptions[id] = { ...option,
|
|
207
200
|
groupId: prefixText
|
|
@@ -328,8 +321,7 @@ export const makeGetGroupSelectOptions = () => createSelector([getGroupedOptions
|
|
|
328
321
|
id: groupId,
|
|
329
322
|
name,
|
|
330
323
|
valueField,
|
|
331
|
-
textField
|
|
332
|
-
secondaryField
|
|
324
|
+
textField
|
|
333
325
|
} = group;
|
|
334
326
|
|
|
335
327
|
if (!getIsEmptyValue(groupId) && groupIds.indexOf(groupId) === -1) {
|
|
@@ -344,7 +336,6 @@ export const makeGetGroupSelectOptions = () => createSelector([getGroupedOptions
|
|
|
344
336
|
options,
|
|
345
337
|
valueField,
|
|
346
338
|
textField,
|
|
347
|
-
secondaryField,
|
|
348
339
|
prefixText: groupId,
|
|
349
340
|
allowValueFallback
|
|
350
341
|
});
|