@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,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,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.highlight = highlight;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _utils = require("@zohodesk/utils");
|
|
11
|
+
|
|
12
|
+
var _TypographyModule = _interopRequireDefault(require("./css/Typography.module.css"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
|
|
18
|
+
function highlight(data) {
|
|
19
|
+
var text = data.text,
|
|
20
|
+
highlightData = data.highlightData,
|
|
21
|
+
_data$customStyle = data.customStyle,
|
|
22
|
+
globalCustomStyle = _data$customStyle === void 0 ? {} : _data$customStyle,
|
|
23
|
+
_data$highlightsStyle = data.highlightsStyle,
|
|
24
|
+
globalHighlightsStyle = _data$highlightsStyle === void 0 ? {} : _data$highlightsStyle,
|
|
25
|
+
_data$isExcludedIndex = data.isExcludedIndex,
|
|
26
|
+
hasGlobalExcludedIndex = _data$isExcludedIndex === void 0 ? false : _data$isExcludedIndex,
|
|
27
|
+
_data$isCaseSensitive = data.isCaseSensitive,
|
|
28
|
+
hasGlobalCaseSensitive = _data$isCaseSensitive === void 0 ? false : _data$isCaseSensitive,
|
|
29
|
+
_data$isWholeWord = data.isWholeWord,
|
|
30
|
+
hasGlobalWholeWord = _data$isWholeWord === void 0 ? false : _data$isWholeWord,
|
|
31
|
+
_data$tagName = data.tagName,
|
|
32
|
+
globalTagName = _data$tagName === void 0 ? 'span' : _data$tagName,
|
|
33
|
+
globalRender = data.render;
|
|
34
|
+
var patternParts = [];
|
|
35
|
+
var highlightTextList = [];
|
|
36
|
+
var highlightListArray = highlightData.map(function (item) {
|
|
37
|
+
var _ref = item || {},
|
|
38
|
+
highlightText = _ref.highlightText,
|
|
39
|
+
index = _ref.index,
|
|
40
|
+
isExcludedIndex = _ref.isExcludedIndex,
|
|
41
|
+
isCaseSensitive = _ref.isCaseSensitive,
|
|
42
|
+
highlightsStyle = _ref.highlightsStyle,
|
|
43
|
+
customStyle = _ref.customStyle,
|
|
44
|
+
isWholeWord = _ref.isWholeWord,
|
|
45
|
+
tagName = _ref.tagName,
|
|
46
|
+
render = _ref.render;
|
|
47
|
+
|
|
48
|
+
var selectedHighlightText = '';
|
|
49
|
+
var selectedIndex = [];
|
|
50
|
+
var selectedExcludedIndex = hasGlobalExcludedIndex;
|
|
51
|
+
var selectedCaseSensitive = hasGlobalCaseSensitive;
|
|
52
|
+
var selectedHighlightsStyle = globalHighlightsStyle;
|
|
53
|
+
var selectedCustomStyle = globalCustomStyle;
|
|
54
|
+
var selectedWholeWord = hasGlobalWholeWord;
|
|
55
|
+
var selectedTagName = globalTagName;
|
|
56
|
+
var selectedRender = globalRender;
|
|
57
|
+
|
|
58
|
+
if (typeof item === 'string') {
|
|
59
|
+
selectedHighlightText = item;
|
|
60
|
+
} else if (item && typeof highlightText === 'string') {
|
|
61
|
+
selectedHighlightText = highlightText;
|
|
62
|
+
selectedIndex = index !== undefined ? index : [];
|
|
63
|
+
selectedExcludedIndex = isExcludedIndex !== undefined ? isExcludedIndex : hasGlobalExcludedIndex;
|
|
64
|
+
selectedCaseSensitive = isCaseSensitive !== undefined ? isCaseSensitive : hasGlobalCaseSensitive;
|
|
65
|
+
selectedCustomStyle = customStyle !== undefined ? customStyle : globalCustomStyle;
|
|
66
|
+
selectedHighlightsStyle = highlightsStyle !== undefined ? highlightsStyle : globalHighlightsStyle;
|
|
67
|
+
selectedWholeWord = isWholeWord !== undefined ? isWholeWord : hasGlobalWholeWord;
|
|
68
|
+
selectedTagName = tagName !== undefined ? tagName : globalTagName;
|
|
69
|
+
selectedRender = render !== undefined ? render : globalRender;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var _getClassFromStyle = getClassFromStyle(selectedHighlightsStyle),
|
|
73
|
+
highlightsClass = _getClassFromStyle.highlightsClass;
|
|
74
|
+
|
|
75
|
+
if (selectedHighlightText.trim() !== '') {
|
|
76
|
+
var escaped = selectedHighlightText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
77
|
+
patternParts.push(selectedWholeWord ? "\\b".concat(escaped, "\\b") : escaped);
|
|
78
|
+
highlightTextList.push(isCaseSensitive ? selectedHighlightText : selectedHighlightText.toLowerCase());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
highlightText: selectedHighlightText,
|
|
83
|
+
index: selectedIndex,
|
|
84
|
+
isExcludedIndex: selectedExcludedIndex,
|
|
85
|
+
isCaseSensitive: selectedCaseSensitive,
|
|
86
|
+
highlightsClass: highlightsClass,
|
|
87
|
+
customStyle: selectedCustomStyle,
|
|
88
|
+
tagName: selectedTagName,
|
|
89
|
+
render: selectedRender
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
var pattern = patternParts.join('|');
|
|
93
|
+
|
|
94
|
+
if (!pattern) {
|
|
95
|
+
return text;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var splittedChild = text.split(new RegExp("(".concat(pattern, ")"), 'gi'));
|
|
99
|
+
var indexCount = {};
|
|
100
|
+
return splittedChild.map(function (part, i) {
|
|
101
|
+
var Tag = 'span';
|
|
102
|
+
var match = highlightListArray.find(function (_ref2) {
|
|
103
|
+
var highlightText = _ref2.highlightText,
|
|
104
|
+
isCaseSensitive = _ref2.isCaseSensitive;
|
|
105
|
+
var inputText = isCaseSensitive ? part : part.toLowerCase();
|
|
106
|
+
var target = isCaseSensitive ? highlightText : highlightText.toLowerCase();
|
|
107
|
+
return inputText === target;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (!match) {
|
|
111
|
+
return part;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var key = match.highlightText;
|
|
115
|
+
indexCount[key] = (indexCount[key] || 0) + 1;
|
|
116
|
+
var tagName = match.tagName,
|
|
117
|
+
index = match.index,
|
|
118
|
+
isExcludedIndex = match.isExcludedIndex,
|
|
119
|
+
render = match.render,
|
|
120
|
+
highlightsClass = match.highlightsClass,
|
|
121
|
+
customStyle = match.customStyle;
|
|
122
|
+
Tag = tagName;
|
|
123
|
+
var currentIndex = indexCount[key];
|
|
124
|
+
var isArrayIndex = Array.isArray(index);
|
|
125
|
+
var isMatch = isArrayIndex ? (index.length === 0 || index.includes(currentIndex)) !== isExcludedIndex : (index === 0 || index === currentIndex) !== isExcludedIndex;
|
|
126
|
+
|
|
127
|
+
if (!isMatch) {
|
|
128
|
+
return part;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return render || /*#__PURE__*/_react["default"].createElement(Tag, {
|
|
132
|
+
key: i,
|
|
133
|
+
style: customStyle,
|
|
134
|
+
className: highlightsClass
|
|
135
|
+
}, part);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function getClassFromStyle(styleObj) {
|
|
140
|
+
var _compileClassNames;
|
|
141
|
+
|
|
142
|
+
var weight = styleObj.weight,
|
|
143
|
+
typeFace = styleObj.typeFace,
|
|
144
|
+
transform = styleObj.transform,
|
|
145
|
+
decoration = styleObj.decoration,
|
|
146
|
+
customClass = styleObj.customClass;
|
|
147
|
+
var highlightsClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, _TypographyModule["default"]["font_".concat(weight)], !!weight), _defineProperty(_compileClassNames, _TypographyModule["default"]["fontStyles_".concat(typeFace)], !!typeFace), _defineProperty(_compileClassNames, _TypographyModule["default"]["transform_".concat(transform)], !!transform), _defineProperty(_compileClassNames, _TypographyModule["default"]["decoration_".concat(decoration)], !!decoration), _defineProperty(_compileClassNames, customClass, !!customClass), _compileClassNames));
|
|
148
|
+
return {
|
|
149
|
+
highlightsClass: highlightsClass
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -9,6 +9,29 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
|
|
16
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
|
|
18
|
+
var highlightsStyleShape = _propTypes["default"].shape({
|
|
19
|
+
weight: _propTypes["default"].oneOf(['regular', 'light', 'semibold', 'bold']),
|
|
20
|
+
transform: _propTypes["default"].oneOf(['default', 'upper', 'lower', 'capital']),
|
|
21
|
+
decoration: _propTypes["default"].oneOf(['default', 'underline', 'strike', 'overline']),
|
|
22
|
+
typeFace: _propTypes["default"].oneOf(['normal', 'italic']),
|
|
23
|
+
customClass: _propTypes["default"].object
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
var commonHighlightProps = {
|
|
27
|
+
customStyle: _propTypes["default"].object,
|
|
28
|
+
isExcludedIndex: _propTypes["default"].bool,
|
|
29
|
+
isCaseSensitive: _propTypes["default"].bool,
|
|
30
|
+
isWholeWord: _propTypes["default"].bool,
|
|
31
|
+
tagName: _propTypes["default"].string,
|
|
32
|
+
render: _propTypes["default"].element,
|
|
33
|
+
highlightsStyle: _propTypes["default"].objectOf(highlightsStyleShape)
|
|
34
|
+
};
|
|
12
35
|
var propTypes = {
|
|
13
36
|
children: _propTypes["default"].node,
|
|
14
37
|
$ui_className: _propTypes["default"].string,
|
|
@@ -33,6 +56,13 @@ var propTypes = {
|
|
|
33
56
|
customId: _propTypes["default"].string,
|
|
34
57
|
customStyle: _propTypes["default"].object,
|
|
35
58
|
$a11yAttributes_text: _propTypes["default"].object,
|
|
36
|
-
$tagAttributes_text: _propTypes["default"].object
|
|
59
|
+
$tagAttributes_text: _propTypes["default"].object,
|
|
60
|
+
highlights: _propTypes["default"].objectOf(_propTypes["default"].shape(_objectSpread({
|
|
61
|
+
text: _propTypes["default"].string,
|
|
62
|
+
highlightData: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape(_objectSpread({
|
|
63
|
+
highlightText: _propTypes["default"].string,
|
|
64
|
+
index: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].number), _propTypes["default"].number])
|
|
65
|
+
}, commonHighlightProps))]))
|
|
66
|
+
}, commonHighlightProps)))
|
|
37
67
|
};
|
|
38
68
|
exports.propTypes = propTypes;
|
package/lib/utils/Common.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DUMMY_OBJECT = void 0;
|
|
6
|
+
exports.DUMMY_OBJECT = exports.DUMMY_ARRAY = void 0;
|
|
7
7
|
exports.bind = bind;
|
|
8
8
|
exports.bytesToSize = bytesToSize;
|
|
9
9
|
exports.cancelBubblingEffect = cancelBubblingEffect;
|
|
@@ -516,4 +516,6 @@ function isTextSelected() {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
var DUMMY_OBJECT = {};
|
|
519
|
-
exports.DUMMY_OBJECT = DUMMY_OBJECT;
|
|
519
|
+
exports.DUMMY_OBJECT = DUMMY_OBJECT;
|
|
520
|
+
var DUMMY_ARRAY = [];
|
|
521
|
+
exports.DUMMY_ARRAY = DUMMY_ARRAY;
|
|
@@ -152,8 +152,10 @@ var getListItemProps = function getListItemProps(props) {
|
|
|
152
152
|
return props.listItemProps || '';
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
+
var defaultSearchFields = ['value'];
|
|
156
|
+
|
|
155
157
|
var getSearchFields = function getSearchFields(props) {
|
|
156
|
-
return props.searchFields ||
|
|
158
|
+
return props.searchFields || defaultSearchFields;
|
|
157
159
|
}; // const isObjectContainsSearchString = (searchFields = [], searchStr = '', obj) => {
|
|
158
160
|
// const matchedFields = searchFields.filter(element => {
|
|
159
161
|
// return getSearchString(obj[element]).indexOf(searchStr) !== -1
|