@cck-ui/core 0.41.0 → 0.42.0
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/cjs/components/highlight/highlight.cjs +493 -0
- package/cjs/components/highlight/highlight.cjs.map +1 -0
- package/cjs/components/highlight/highlighter/highlighter.cjs +84 -0
- package/cjs/components/highlight/highlighter/highlighter.cjs.map +1 -0
- package/cjs/components/highlight/index.cjs +13 -0
- package/cjs/components/highlight/index.cjs.map +1 -0
- package/cjs/components/mark/get-mark-color/get-mark-color.cjs +16 -0
- package/cjs/components/mark/get-mark-color/get-mark-color.cjs.map +1 -0
- package/cjs/components/mark/index.cjs +14 -0
- package/cjs/components/mark/index.cjs.map +1 -0
- package/cjs/components/mark/mark.cjs +396 -0
- package/cjs/components/mark/mark.cjs.map +1 -0
- package/cjs/components/mark/mark.module.cjs +7 -0
- package/cjs/components/mark/mark.module.cjs.map +1 -0
- package/cjs/components/mark/mark.utils.cjs +20 -0
- package/cjs/components/mark/mark.utils.cjs.map +1 -0
- package/cjs/index.cjs +47 -41
- package/cjs/index.cjs.map +1 -1
- package/esm/components/highlight/highlight.mjs +493 -0
- package/esm/components/highlight/highlight.mjs.map +1 -0
- package/esm/components/highlight/highlighter/highlighter.mjs +83 -0
- package/esm/components/highlight/highlighter/highlighter.mjs.map +1 -0
- package/esm/components/highlight/index.mjs +10 -0
- package/esm/components/highlight/index.mjs.map +1 -0
- package/esm/components/mark/get-mark-color/get-mark-color.mjs +16 -0
- package/esm/components/mark/get-mark-color/get-mark-color.mjs.map +1 -0
- package/esm/components/mark/index.mjs +11 -0
- package/esm/components/mark/index.mjs.map +1 -0
- package/esm/components/mark/mark.mjs +396 -0
- package/esm/components/mark/mark.mjs.map +1 -0
- package/esm/components/mark/mark.module.mjs +7 -0
- package/esm/components/mark/mark.module.mjs.map +1 -0
- package/esm/components/mark/mark.utils.mjs +20 -0
- package/esm/components/mark/mark.utils.mjs.map +1 -0
- package/esm/index.mjs +5 -1
- package/esm/index.mjs.map +1 -1
- package/lib/components/highlight/highlight.types.d.ts +57 -0
- package/lib/components/highlight/highlighter/highlighter.d.ts +12 -0
- package/lib/components/highlight/index.d.ts +5 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/mark/get-mark-color/get-mark-color.d.ts +8 -0
- package/lib/components/mark/index.d.ts +6 -0
- package/lib/components/mark/mark.types.d.ts +14 -0
- package/lib/components/mark/mark.utils.d.ts +6 -0
- package/package.json +1 -1
- package/styles/mark.css +11 -0
- package/styles/mark.layer.css +12 -0
- package/styles.css +12 -0
- package/styles.layer.css +12 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_config_provider_context = require("../../core/config-provider/config-provider.context.cjs");
|
|
3
|
+
const require_export_helper = require("../../_virtual/_/plugin-vue/export-helper.cjs");
|
|
4
|
+
const require_use_component_props = require("../../core/config-provider/use-component-props/use-component-props.cjs");
|
|
5
|
+
const require_index = require("../text/index.cjs");
|
|
6
|
+
const require_index$1 = require("../mark/index.cjs");
|
|
7
|
+
const require_highlighter = require("./highlighter/highlighter.cjs");
|
|
8
|
+
let vue = require("vue");
|
|
9
|
+
//#region packages/@cck-ui/core/src/components/highlight/highlight.vue
|
|
10
|
+
const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
11
|
+
name: "CHighlight",
|
|
12
|
+
__name: "highlight",
|
|
13
|
+
props: {
|
|
14
|
+
highlight: {
|
|
15
|
+
type: [String, Array],
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
color: {
|
|
19
|
+
type: null,
|
|
20
|
+
required: false
|
|
21
|
+
},
|
|
22
|
+
highlightStyles: {
|
|
23
|
+
type: [Object, Function],
|
|
24
|
+
required: false
|
|
25
|
+
},
|
|
26
|
+
children: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
wholeWorld: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
caseInsensitive: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
accentInsensitive: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
__staticSelector: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
type: null,
|
|
48
|
+
required: false
|
|
49
|
+
},
|
|
50
|
+
lineClamp: {
|
|
51
|
+
type: Number,
|
|
52
|
+
required: false
|
|
53
|
+
},
|
|
54
|
+
truncate: {
|
|
55
|
+
type: [String, Boolean],
|
|
56
|
+
required: false
|
|
57
|
+
},
|
|
58
|
+
inline: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
required: false
|
|
61
|
+
},
|
|
62
|
+
inherit: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
required: false
|
|
65
|
+
},
|
|
66
|
+
gradient: {
|
|
67
|
+
type: Object,
|
|
68
|
+
required: false
|
|
69
|
+
},
|
|
70
|
+
span: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
required: false
|
|
73
|
+
},
|
|
74
|
+
textWrap: {
|
|
75
|
+
type: String,
|
|
76
|
+
required: false
|
|
77
|
+
},
|
|
78
|
+
className: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false
|
|
81
|
+
},
|
|
82
|
+
style: {
|
|
83
|
+
type: [
|
|
84
|
+
Object,
|
|
85
|
+
Function,
|
|
86
|
+
Array
|
|
87
|
+
],
|
|
88
|
+
required: false,
|
|
89
|
+
skipCheck: true
|
|
90
|
+
},
|
|
91
|
+
__vars: {
|
|
92
|
+
type: null,
|
|
93
|
+
required: false
|
|
94
|
+
},
|
|
95
|
+
__size: {
|
|
96
|
+
type: String,
|
|
97
|
+
required: false
|
|
98
|
+
},
|
|
99
|
+
hiddenFrom: {
|
|
100
|
+
type: null,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
visibleFrom: {
|
|
104
|
+
type: null,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
lightHidden: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
required: false
|
|
110
|
+
},
|
|
111
|
+
darkHidden: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
mod: {
|
|
116
|
+
type: [
|
|
117
|
+
Object,
|
|
118
|
+
String,
|
|
119
|
+
Array
|
|
120
|
+
],
|
|
121
|
+
required: false
|
|
122
|
+
},
|
|
123
|
+
m: {
|
|
124
|
+
type: null,
|
|
125
|
+
required: false
|
|
126
|
+
},
|
|
127
|
+
my: {
|
|
128
|
+
type: null,
|
|
129
|
+
required: false
|
|
130
|
+
},
|
|
131
|
+
mx: {
|
|
132
|
+
type: null,
|
|
133
|
+
required: false
|
|
134
|
+
},
|
|
135
|
+
mt: {
|
|
136
|
+
type: null,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
mb: {
|
|
140
|
+
type: null,
|
|
141
|
+
required: false
|
|
142
|
+
},
|
|
143
|
+
ms: {
|
|
144
|
+
type: null,
|
|
145
|
+
required: false
|
|
146
|
+
},
|
|
147
|
+
me: {
|
|
148
|
+
type: null,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
mis: {
|
|
152
|
+
type: null,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
mie: {
|
|
156
|
+
type: null,
|
|
157
|
+
required: false
|
|
158
|
+
},
|
|
159
|
+
ml: {
|
|
160
|
+
type: null,
|
|
161
|
+
required: false
|
|
162
|
+
},
|
|
163
|
+
mr: {
|
|
164
|
+
type: null,
|
|
165
|
+
required: false
|
|
166
|
+
},
|
|
167
|
+
p: {
|
|
168
|
+
type: null,
|
|
169
|
+
required: false
|
|
170
|
+
},
|
|
171
|
+
py: {
|
|
172
|
+
type: null,
|
|
173
|
+
required: false
|
|
174
|
+
},
|
|
175
|
+
px: {
|
|
176
|
+
type: null,
|
|
177
|
+
required: false
|
|
178
|
+
},
|
|
179
|
+
pt: {
|
|
180
|
+
type: null,
|
|
181
|
+
required: false
|
|
182
|
+
},
|
|
183
|
+
pb: {
|
|
184
|
+
type: null,
|
|
185
|
+
required: false
|
|
186
|
+
},
|
|
187
|
+
ps: {
|
|
188
|
+
type: null,
|
|
189
|
+
required: false
|
|
190
|
+
},
|
|
191
|
+
pe: {
|
|
192
|
+
type: null,
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
pis: {
|
|
196
|
+
type: null,
|
|
197
|
+
required: false
|
|
198
|
+
},
|
|
199
|
+
pie: {
|
|
200
|
+
type: null,
|
|
201
|
+
required: false
|
|
202
|
+
},
|
|
203
|
+
pl: {
|
|
204
|
+
type: null,
|
|
205
|
+
required: false
|
|
206
|
+
},
|
|
207
|
+
pr: {
|
|
208
|
+
type: null,
|
|
209
|
+
required: false
|
|
210
|
+
},
|
|
211
|
+
bd: {
|
|
212
|
+
type: null,
|
|
213
|
+
required: false
|
|
214
|
+
},
|
|
215
|
+
bdrs: {
|
|
216
|
+
type: null,
|
|
217
|
+
required: false
|
|
218
|
+
},
|
|
219
|
+
bg: {
|
|
220
|
+
type: null,
|
|
221
|
+
required: false
|
|
222
|
+
},
|
|
223
|
+
c: {
|
|
224
|
+
type: null,
|
|
225
|
+
required: false
|
|
226
|
+
},
|
|
227
|
+
opacity: {
|
|
228
|
+
type: [
|
|
229
|
+
String,
|
|
230
|
+
Object,
|
|
231
|
+
Number
|
|
232
|
+
],
|
|
233
|
+
required: false
|
|
234
|
+
},
|
|
235
|
+
ff: {
|
|
236
|
+
type: [String, Object],
|
|
237
|
+
required: false
|
|
238
|
+
},
|
|
239
|
+
fz: {
|
|
240
|
+
type: null,
|
|
241
|
+
required: false
|
|
242
|
+
},
|
|
243
|
+
fw: {
|
|
244
|
+
type: null,
|
|
245
|
+
required: false
|
|
246
|
+
},
|
|
247
|
+
lts: {
|
|
248
|
+
type: null,
|
|
249
|
+
required: false
|
|
250
|
+
},
|
|
251
|
+
ta: {
|
|
252
|
+
type: [String, Object],
|
|
253
|
+
required: false
|
|
254
|
+
},
|
|
255
|
+
lh: {
|
|
256
|
+
type: null,
|
|
257
|
+
required: false
|
|
258
|
+
},
|
|
259
|
+
fs: {
|
|
260
|
+
type: null,
|
|
261
|
+
required: false
|
|
262
|
+
},
|
|
263
|
+
tt: {
|
|
264
|
+
type: [String, Object],
|
|
265
|
+
required: false
|
|
266
|
+
},
|
|
267
|
+
td: {
|
|
268
|
+
type: null,
|
|
269
|
+
required: false
|
|
270
|
+
},
|
|
271
|
+
w: {
|
|
272
|
+
type: null,
|
|
273
|
+
required: false
|
|
274
|
+
},
|
|
275
|
+
miw: {
|
|
276
|
+
type: null,
|
|
277
|
+
required: false
|
|
278
|
+
},
|
|
279
|
+
maw: {
|
|
280
|
+
type: null,
|
|
281
|
+
required: false
|
|
282
|
+
},
|
|
283
|
+
h: {
|
|
284
|
+
type: null,
|
|
285
|
+
required: false
|
|
286
|
+
},
|
|
287
|
+
mih: {
|
|
288
|
+
type: null,
|
|
289
|
+
required: false
|
|
290
|
+
},
|
|
291
|
+
mah: {
|
|
292
|
+
type: null,
|
|
293
|
+
required: false
|
|
294
|
+
},
|
|
295
|
+
bgsz: {
|
|
296
|
+
type: null,
|
|
297
|
+
required: false
|
|
298
|
+
},
|
|
299
|
+
bgp: {
|
|
300
|
+
type: null,
|
|
301
|
+
required: false
|
|
302
|
+
},
|
|
303
|
+
bgr: {
|
|
304
|
+
type: null,
|
|
305
|
+
required: false
|
|
306
|
+
},
|
|
307
|
+
bga: {
|
|
308
|
+
type: null,
|
|
309
|
+
required: false
|
|
310
|
+
},
|
|
311
|
+
pos: {
|
|
312
|
+
type: [String, Object],
|
|
313
|
+
required: false
|
|
314
|
+
},
|
|
315
|
+
top: {
|
|
316
|
+
type: null,
|
|
317
|
+
required: false
|
|
318
|
+
},
|
|
319
|
+
left: {
|
|
320
|
+
type: null,
|
|
321
|
+
required: false
|
|
322
|
+
},
|
|
323
|
+
bottom: {
|
|
324
|
+
type: null,
|
|
325
|
+
required: false
|
|
326
|
+
},
|
|
327
|
+
right: {
|
|
328
|
+
type: null,
|
|
329
|
+
required: false
|
|
330
|
+
},
|
|
331
|
+
inset: {
|
|
332
|
+
type: null,
|
|
333
|
+
required: false
|
|
334
|
+
},
|
|
335
|
+
display: {
|
|
336
|
+
type: null,
|
|
337
|
+
required: false
|
|
338
|
+
},
|
|
339
|
+
flex: {
|
|
340
|
+
type: null,
|
|
341
|
+
required: false
|
|
342
|
+
},
|
|
343
|
+
unstyled: {
|
|
344
|
+
type: Boolean,
|
|
345
|
+
required: false
|
|
346
|
+
},
|
|
347
|
+
variant: {
|
|
348
|
+
type: null,
|
|
349
|
+
required: false
|
|
350
|
+
},
|
|
351
|
+
classNames: {
|
|
352
|
+
type: null,
|
|
353
|
+
required: false
|
|
354
|
+
},
|
|
355
|
+
styles: {
|
|
356
|
+
type: null,
|
|
357
|
+
required: false
|
|
358
|
+
},
|
|
359
|
+
vars: {
|
|
360
|
+
type: Function,
|
|
361
|
+
required: false
|
|
362
|
+
},
|
|
363
|
+
attributes: {
|
|
364
|
+
type: null,
|
|
365
|
+
required: false
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
setup(__props, { expose: __expose }) {
|
|
369
|
+
const rawProps = __props;
|
|
370
|
+
const _root = (0, vue.ref)(null);
|
|
371
|
+
const theme = require_config_provider_context.useCckTheme();
|
|
372
|
+
const defaultProps = {
|
|
373
|
+
color: "yellow",
|
|
374
|
+
wholeWorld: false,
|
|
375
|
+
caseInsensitive: true,
|
|
376
|
+
accentInsensitive: true
|
|
377
|
+
};
|
|
378
|
+
const props = require_use_component_props.useComponentProps({
|
|
379
|
+
component: "CHighlight",
|
|
380
|
+
defaultProps,
|
|
381
|
+
props: rawProps
|
|
382
|
+
});
|
|
383
|
+
const knownProps = [
|
|
384
|
+
"unstyled",
|
|
385
|
+
"children",
|
|
386
|
+
"highlight",
|
|
387
|
+
"highlightStyles",
|
|
388
|
+
"color",
|
|
389
|
+
"wholeWord",
|
|
390
|
+
"caseInsensitive",
|
|
391
|
+
"accentInsensitive"
|
|
392
|
+
];
|
|
393
|
+
const isTermArray = (0, vue.computed)(() => Array.isArray(props.value.highlight) && typeof props.value.highlight[0] === "object");
|
|
394
|
+
const colorMap = /* @__PURE__ */ new Map();
|
|
395
|
+
const normalizeKey = (s) => {
|
|
396
|
+
let key = s;
|
|
397
|
+
if (props.value.caseInsensitive) key = key.toLocaleLowerCase();
|
|
398
|
+
if (props.value.accentInsensitive) key = require_highlighter.foldAccents(key);
|
|
399
|
+
return key;
|
|
400
|
+
};
|
|
401
|
+
const highlightStrings = (0, vue.computed)(() => {
|
|
402
|
+
let result;
|
|
403
|
+
if (isTermArray.value) result = props.value.highlight.map((term) => {
|
|
404
|
+
if (term.color) colorMap.set(normalizeKey(term.text), term.color);
|
|
405
|
+
return term.text;
|
|
406
|
+
});
|
|
407
|
+
else if (Array.isArray(props.value.highlight)) result = props.value.highlight;
|
|
408
|
+
else result = [props.value.highlight];
|
|
409
|
+
return result;
|
|
410
|
+
});
|
|
411
|
+
const highlightChunks = (0, vue.computed)(() => require_highlighter.highlighter(props.value.children, highlightStrings.value, {
|
|
412
|
+
wholeWord: props.value.wholeWorld,
|
|
413
|
+
caseInsensitive: props.value.caseInsensitive,
|
|
414
|
+
accentInsensitive: props.value.accentInsensitive
|
|
415
|
+
}));
|
|
416
|
+
const resolvedStyle = (0, vue.computed)(() => {
|
|
417
|
+
const style = props.value.style;
|
|
418
|
+
if (typeof style === "function") return style(theme.value);
|
|
419
|
+
return style;
|
|
420
|
+
});
|
|
421
|
+
const mergedAttrs = (0, vue.computed)(() => {
|
|
422
|
+
const others = {};
|
|
423
|
+
const propsValue = props.value;
|
|
424
|
+
Object.keys(propsValue).forEach((key) => {
|
|
425
|
+
if (!knownProps.includes(key)) others[key] = propsValue[key];
|
|
426
|
+
});
|
|
427
|
+
const userMod = props.value.mod;
|
|
428
|
+
const mergedMod = [...Array.isArray(userMod) ? userMod : [userMod].filter(Boolean)];
|
|
429
|
+
return {
|
|
430
|
+
...others,
|
|
431
|
+
mod: mergedMod
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
__expose({ root: (0, vue.computed)(() => _root.value?.root ?? null) });
|
|
435
|
+
const __returned__ = {
|
|
436
|
+
rawProps,
|
|
437
|
+
_root,
|
|
438
|
+
theme,
|
|
439
|
+
defaultProps,
|
|
440
|
+
props,
|
|
441
|
+
knownProps,
|
|
442
|
+
isTermArray,
|
|
443
|
+
colorMap,
|
|
444
|
+
normalizeKey,
|
|
445
|
+
highlightStrings,
|
|
446
|
+
highlightChunks,
|
|
447
|
+
resolvedStyle,
|
|
448
|
+
mergedAttrs,
|
|
449
|
+
get CMark() {
|
|
450
|
+
return require_index$1.CMark;
|
|
451
|
+
},
|
|
452
|
+
get CText() {
|
|
453
|
+
return require_index.CText;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
457
|
+
enumerable: false,
|
|
458
|
+
value: true
|
|
459
|
+
});
|
|
460
|
+
return __returned__;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
464
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)($setup["CText"], (0, vue.mergeProps)({
|
|
465
|
+
"__static-selector": "Highlight",
|
|
466
|
+
ref: "_root"
|
|
467
|
+
}, $setup.mergedAttrs, {
|
|
468
|
+
style: $setup.resolvedStyle,
|
|
469
|
+
unstyled: $setup.props.unstyled
|
|
470
|
+
}), {
|
|
471
|
+
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)($setup.highlightChunks, ({ chunk, highlighted }, i) => {
|
|
472
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [highlighted ? ((0, vue.openBlock)(), (0, vue.createBlock)($setup["CMark"], {
|
|
473
|
+
color: $setup.colorMap.get($setup.normalizeKey(chunk)) || $setup.props.color,
|
|
474
|
+
key: `highlight-mark-${i}`,
|
|
475
|
+
style: (0, vue.normalizeStyle)($setup.props.highlightStyles),
|
|
476
|
+
unstyled: $setup.props.unstyled
|
|
477
|
+
}, {
|
|
478
|
+
default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(chunk), 1)]),
|
|
479
|
+
_: 2
|
|
480
|
+
}, 1032, [
|
|
481
|
+
"color",
|
|
482
|
+
"style",
|
|
483
|
+
"unstyled"
|
|
484
|
+
])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", { key: `highlight-span-${i}` }, (0, vue.toDisplayString)(chunk), 1))], 64);
|
|
485
|
+
}), 256))]),
|
|
486
|
+
_: 1
|
|
487
|
+
}, 16, ["style", "unstyled"]);
|
|
488
|
+
}
|
|
489
|
+
var highlight_default = /*#__PURE__*/ require_export_helper.default(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/cck-ui/cck-ui/packages/@cck-ui/core/src/components/highlight/highlight.vue"]]);
|
|
490
|
+
//#endregion
|
|
491
|
+
exports.default = highlight_default;
|
|
492
|
+
|
|
493
|
+
//# sourceMappingURL=highlight.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.cjs","names":[],"sources":["../../../src/components/highlight/highlight.vue"],"sourcesContent":["<template>\n <c-text\n __static-selector=\"Highlight\"\n ref=\"_root\"\n v-bind=\"mergedAttrs\"\n :style=\"resolvedStyle\"\n :unstyled=\"props.unstyled\"\n >\n <template v-for=\"({ chunk, highlighted }, i) in highlightChunks\">\n <c-mark\n v-if=\"highlighted\"\n :color=\"colorMap.get(normalizeKey(chunk)) || props.color\"\n :key=\"`highlight-mark-${i}`\"\n :style=\"props.highlightStyles\"\n :unstyled=\"props.unstyled\"\n >\n {{ chunk }}\n </c-mark>\n <span v-else :key=\"`highlight-span-${i}`\">{{ chunk }}</span>\n </template>\n </c-text>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from 'vue'\nimport { useCckTheme, useComponentProps } from '../../core'\nimport CMark from '../mark'\nimport CText from '../text'\nimport { HighlightProps, HighlightTerm } from './highlight.types'\nimport { foldAccents, highlighter } from './highlighter/highlighter'\n\ndefineOptions({\n name: 'CHighlight',\n})\n\nconst rawProps = defineProps<HighlightProps>()\n\nconst _root = ref<InstanceType<typeof CText> | null>(null)\n\nconst theme = useCckTheme()\n\nconst defaultProps = {\n color: 'yellow',\n wholeWorld: false,\n caseInsensitive: true,\n accentInsensitive: true,\n} satisfies Partial<HighlightProps>\n\nconst props = useComponentProps({\n component: 'CHighlight',\n defaultProps,\n props: rawProps,\n})\n\nconst knownProps = [\n 'unstyled',\n 'children',\n 'highlight',\n 'highlightStyles',\n 'color',\n 'wholeWord',\n 'caseInsensitive',\n 'accentInsensitive',\n]\n\nconst isTermArray = computed(\n () => Array.isArray(props.value.highlight) && typeof props.value.highlight[0] === 'object'\n)\n\nconst colorMap = new Map<string, string>()\n\nconst normalizeKey = (s: string) => {\n let key = s\n if (props.value.caseInsensitive) {\n key = key.toLocaleLowerCase()\n }\n if (props.value.accentInsensitive) {\n key = foldAccents(key)\n }\n return key\n}\n\nconst highlightStrings = computed(() => {\n let result: string[]\n if (isTermArray.value) {\n result = (props.value.highlight as HighlightTerm[]).map((term) => {\n if (term.color) {\n colorMap.set(normalizeKey(term.text), term.color)\n }\n return term.text\n })\n } else if (Array.isArray(props.value.highlight)) {\n result = props.value.highlight as string[]\n } else {\n result = [props.value.highlight as string]\n }\n return result\n})\n\nconst highlightChunks = computed(() =>\n highlighter(props.value.children, highlightStrings.value, {\n wholeWord: props.value.wholeWorld,\n caseInsensitive: props.value.caseInsensitive,\n accentInsensitive: props.value.accentInsensitive,\n })\n)\n\nconst resolvedStyle = computed(() => {\n const style = props.value.style\n if (typeof style === 'function') {\n return style(theme.value)\n }\n return style\n})\n\nconst mergedAttrs = computed(() => {\n const others: Record<string, any> = {}\n const propsValue = props.value\n Object.keys(propsValue).forEach((key) => {\n if (!knownProps.includes(key)) {\n others[key] = propsValue[key as keyof typeof propsValue]\n }\n })\n const userMod = props.value.mod\n const mergedMod = [...(Array.isArray(userMod) ? userMod : [userMod].filter(Boolean))]\n return { ...others, mod: mergedMod }\n})\n\ndefineExpose({\n root: computed(() => _root.value?.root ?? null),\n})\n</script>\n"],"mappings":"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"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@cck-ui/core/src/components/highlight/highlighter/highlighter.ts
|
|
3
|
+
function escapeRegex(value) {
|
|
4
|
+
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
function foldAccents(text) {
|
|
7
|
+
return text.normalize("NFD").replace(/\p{M}/gu, "");
|
|
8
|
+
}
|
|
9
|
+
function foldAccentsWithMap(text) {
|
|
10
|
+
let folded = "";
|
|
11
|
+
const map = [];
|
|
12
|
+
let i = 0;
|
|
13
|
+
while (i < text.length) {
|
|
14
|
+
const cp = text.codePointAt(i);
|
|
15
|
+
const cpStr = String.fromCodePoint(cp);
|
|
16
|
+
const foldedCp = foldAccents(cpStr);
|
|
17
|
+
for (let j = 0; j < foldedCp.length; j += 1) map.push(i);
|
|
18
|
+
folded += foldedCp;
|
|
19
|
+
i += cpStr.length;
|
|
20
|
+
}
|
|
21
|
+
map.push(text.length);
|
|
22
|
+
return {
|
|
23
|
+
folded,
|
|
24
|
+
map
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function getAccentInsensitiveChunks(value, re) {
|
|
28
|
+
const { folded, map } = foldAccentsWithMap(value);
|
|
29
|
+
const chunks = [];
|
|
30
|
+
let lastOrigEnd = 0;
|
|
31
|
+
let match;
|
|
32
|
+
while ((match = re.exec(folded)) !== null) {
|
|
33
|
+
const foldedStart = match.index;
|
|
34
|
+
const foldedEnd = foldedStart + match[0].length;
|
|
35
|
+
const origStart = map[foldedStart];
|
|
36
|
+
const origEnd = map[foldedEnd];
|
|
37
|
+
if (origStart > lastOrigEnd) chunks.push({
|
|
38
|
+
chunk: value.slice(lastOrigEnd, origStart),
|
|
39
|
+
highlighted: false
|
|
40
|
+
});
|
|
41
|
+
chunks.push({
|
|
42
|
+
chunk: value.slice(origStart, origEnd),
|
|
43
|
+
highlighted: true
|
|
44
|
+
});
|
|
45
|
+
lastOrigEnd = origEnd;
|
|
46
|
+
if (match[0].length === 0) re.lastIndex += 1;
|
|
47
|
+
}
|
|
48
|
+
if (lastOrigEnd < value.length) chunks.push({
|
|
49
|
+
chunk: value.slice(lastOrigEnd),
|
|
50
|
+
highlighted: false
|
|
51
|
+
});
|
|
52
|
+
return chunks.filter(({ chunk }) => chunk);
|
|
53
|
+
}
|
|
54
|
+
function highlighter(value, _highlight, options = {}) {
|
|
55
|
+
if (_highlight == null) return [{
|
|
56
|
+
chunk: value,
|
|
57
|
+
highlighted: false
|
|
58
|
+
}];
|
|
59
|
+
const { wholeWord = false, caseInsensitive = true, accentInsensitive = true } = options;
|
|
60
|
+
const prepareTerm = (term) => accentInsensitive ? foldAccents(escapeRegex(term)) : escapeRegex(term);
|
|
61
|
+
const highlight = Array.isArray(_highlight) ? _highlight.map(prepareTerm) : prepareTerm(_highlight);
|
|
62
|
+
if (!(Array.isArray(highlight) ? highlight.filter((part) => part.trim().length > 0).length > 0 : highlight.trim() !== "")) return [{
|
|
63
|
+
chunk: value,
|
|
64
|
+
highlighted: false
|
|
65
|
+
}];
|
|
66
|
+
const matcher = typeof highlight === "string" ? highlight.trim() : highlight.filter((part) => part.trim().length !== 0).map((part) => part.trim()).sort((a, b) => b.length - a.length).join("|");
|
|
67
|
+
const pattern = wholeWord ? `(?<![\\p{L}\\p{N}_])(${matcher})(?![\\p{L}\\p{N}_])` : `(${matcher})`;
|
|
68
|
+
const flags = [
|
|
69
|
+
"g",
|
|
70
|
+
caseInsensitive ? "i" : "",
|
|
71
|
+
wholeWord ? "u" : ""
|
|
72
|
+
].join("");
|
|
73
|
+
const re = new RegExp(pattern, flags);
|
|
74
|
+
if (accentInsensitive) return getAccentInsensitiveChunks(value, re);
|
|
75
|
+
return value.split(re).map((part, index) => ({
|
|
76
|
+
chunk: part,
|
|
77
|
+
highlighted: index % 2 === 1
|
|
78
|
+
})).filter(({ chunk }) => chunk);
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
exports.foldAccents = foldAccents;
|
|
82
|
+
exports.highlighter = highlighter;
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=highlighter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlighter.cjs","names":[],"sources":["../../../../src/components/highlight/highlighter/highlighter.ts"],"sourcesContent":["function escapeRegex(value: string) {\n return value.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&')\n}\n\nexport function foldAccents(text: string): string {\n return text.normalize('NFD').replace(/\\p{M}/gu, '')\n}\n\nfunction foldAccentsWithMap(text: string): { folded: string; map: number[] } {\n let folded = ''\n const map: number[] = []\n let i = 0\n\n while (i < text.length) {\n const cp = text.codePointAt(i)!\n const cpStr = String.fromCodePoint(cp)\n const foldedCp = foldAccents(cpStr)\n for (let j = 0; j < foldedCp.length; j += 1) {\n map.push(i)\n }\n folded += foldedCp\n i += cpStr.length\n }\n\n map.push(text.length)\n return { folded, map }\n}\n\nfunction getAccentInsensitiveChunks(value: string, re: RegExp): HighlightChunk[] {\n const { folded, map } = foldAccentsWithMap(value)\n const chunks: HighlightChunk[] = []\n let lastOrigEnd = 0\n let match: RegExpExecArray | null\n\n while ((match = re.exec(folded)) !== null) {\n const foldedStart = match.index\n const foldedEnd = foldedStart + match[0].length\n const origStart = map[foldedStart]\n const origEnd = map[foldedEnd]\n\n if (origStart > lastOrigEnd) {\n chunks.push({ chunk: value.slice(lastOrigEnd, origStart), highlighted: false })\n }\n chunks.push({ chunk: value.slice(origStart, origEnd), highlighted: true })\n lastOrigEnd = origEnd\n\n if (match[0].length === 0) {\n re.lastIndex += 1\n }\n }\n\n if (lastOrigEnd < value.length) {\n chunks.push({ chunk: value.slice(lastOrigEnd), highlighted: false })\n }\n\n return chunks.filter(({ chunk }) => chunk)\n}\n\nexport interface HighlightChunk {\n chunk: string\n highlighted: boolean\n color?: string\n}\n\nexport interface HighlighterOptions {\n wholeWord?: boolean\n caseInsensitive?: boolean\n accentInsensitive?: boolean\n}\n\nexport function highlighter(\n value: string,\n _highlight: string | string[],\n options: HighlighterOptions = {}\n): HighlightChunk[] {\n if (_highlight == null) {\n return [{ chunk: value, highlighted: false }]\n }\n\n const { wholeWord = false, caseInsensitive = true, accentInsensitive = true } = options\n\n const prepareTerm = (term: string) =>\n accentInsensitive ? foldAccents(escapeRegex(term)) : escapeRegex(term)\n\n const highlight = Array.isArray(_highlight)\n ? _highlight.map(prepareTerm)\n : prepareTerm(_highlight)\n\n const shouldHighlight = Array.isArray(highlight)\n ? highlight.filter((part) => part.trim().length > 0).length > 0\n : highlight.trim() !== ''\n\n if (!shouldHighlight) {\n return [{ chunk: value, highlighted: false }]\n }\n\n const matcher =\n typeof highlight === 'string'\n ? highlight.trim()\n : highlight\n .filter((part) => part.trim().length !== 0)\n .map((part) => part.trim())\n .sort((a, b) => b.length - a.length)\n .join('|')\n\n const pattern = wholeWord ? `(?<![\\\\p{L}\\\\p{N}_])(${matcher})(?![\\\\p{L}\\\\p{N}_])` : `(${matcher})`\n const flags = ['g', caseInsensitive ? 'i' : '', wholeWord ? 'u' : ''].join('')\n const re = new RegExp(pattern, flags)\n\n if (accentInsensitive) {\n return getAccentInsensitiveChunks(value, re)\n }\n\n return value\n .split(re)\n .map((part, index) => ({ chunk: part, highlighted: index % 2 === 1 }))\n .filter(({ chunk }) => chunk)\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_install = require("../../core/utils/vue/install.cjs");
|
|
3
|
+
const require_statics = require("../../core/utils/vue/statics.cjs");
|
|
4
|
+
const require_text_module = require("../text/text.module.cjs");
|
|
5
|
+
const require_highlight = require("./highlight.cjs");
|
|
6
|
+
//#region packages/@cck-ui/core/src/components/highlight/index.ts
|
|
7
|
+
const HighlightWithStatic = require_statics.withPropsFactory(require_statics.withExtend(require_statics.withClasses(require_highlight.default, require_text_module.default)));
|
|
8
|
+
const CHighlight = require_install.withInstall(HighlightWithStatic);
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.CHighlight = CHighlight;
|
|
11
|
+
exports.default = CHighlight;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["withPropsFactory","withExtend","withClasses","Highlight","classes","withInstall"],"sources":["../../../src/components/highlight/index.ts"],"sourcesContent":["import { SFCWithInstall, withClasses, withExtend, withInstall, withPropsFactory } from '../../core'\nimport Highlight from './highlight.vue'\nimport classes from '../text/text.module.css'\n\nconst HighlightWithStatic = withPropsFactory(withExtend(withClasses(Highlight, classes)))\n\nexport const CHighlight: SFCWithInstall<typeof Highlight> = withInstall(HighlightWithStatic)\n\nexport default CHighlight\n\nexport * from './highlight.types'\n"],"mappings":";;;;;;AAIA,MAAM,sBAAsBA,gBAAAA,iBAAiBC,gBAAAA,WAAWC,gBAAAA,YAAYC,kBAAAA,SAAWC,oBAAAA,OAAO,CAAC,CAAC;AAExF,MAAa,aAA+CC,gBAAAA,YAAY,mBAAmB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_parse_theme_color = require("../../../core/config-provider/color-functions/parse-theme-color/parse-theme-color.cjs");
|
|
3
|
+
//#region packages/@cck-ui/core/src/components/mark/get-mark-color/get-mark-color.ts
|
|
4
|
+
function getMarkColor({ color, theme, defaultShade }) {
|
|
5
|
+
const parsed = require_parse_theme_color.parseThemeColor({
|
|
6
|
+
color,
|
|
7
|
+
theme
|
|
8
|
+
});
|
|
9
|
+
if (!parsed.isThemeColor) return color;
|
|
10
|
+
if (parsed.shade === void 0) return `var(--c-color-${parsed.color}-${defaultShade})`;
|
|
11
|
+
return `var(${parsed.variable})`;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.getMarkColor = getMarkColor;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=get-mark-color.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-mark-color.cjs","names":["parseThemeColor"],"sources":["../../../../src/components/mark/get-mark-color/get-mark-color.ts"],"sourcesContent":["import { CColor, CTheme, parseThemeColor } from '../../../core'\n\ninterface GetMarkColorInput {\n color: CColor | string | undefined\n theme: CTheme\n defaultShade: number\n}\n\nexport function getMarkColor({ color, theme, defaultShade }: GetMarkColorInput) {\n const parsed = parseThemeColor({ color, theme })\n\n if (!parsed.isThemeColor) {\n return color\n }\n\n if (parsed.shade === undefined) {\n return `var(--c-color-${parsed.color}-${defaultShade})`\n }\n\n return `var(${parsed.variable})`\n}\n"],"mappings":";;;AAQA,SAAgB,aAAa,EAAE,OAAO,OAAO,gBAAmC;CAC9E,MAAM,SAASA,0BAAAA,gBAAgB;EAAE;EAAO;CAAM,CAAC;CAE/C,IAAI,CAAC,OAAO,cACV,OAAO;CAGT,IAAI,OAAO,UAAU,KAAA,GACnB,OAAO,iBAAiB,OAAO,MAAM,GAAG,aAAa;CAGvD,OAAO,OAAO,OAAO,SAAS;AAChC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_install = require("../../core/utils/vue/install.cjs");
|
|
3
|
+
const require_statics = require("../../core/utils/vue/statics.cjs");
|
|
4
|
+
const require_mark_module = require("./mark.module.cjs");
|
|
5
|
+
const require_mark_utils = require("./mark.utils.cjs");
|
|
6
|
+
const require_mark = require("./mark.cjs");
|
|
7
|
+
//#region packages/@cck-ui/core/src/components/mark/index.ts
|
|
8
|
+
const MarkWithStatic = require_statics.withPropsFactory(require_statics.withExtend(require_statics.withVarsResolver(require_statics.withClasses(require_mark.default, require_mark_module.default), require_mark_utils.varsResolver)));
|
|
9
|
+
const CMark = require_install.withInstall(MarkWithStatic);
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.CMark = CMark;
|
|
12
|
+
exports.default = CMark;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["withPropsFactory","withExtend","withVarsResolver","withClasses","Mark","classes","varsResolver","withInstall"],"sources":["../../../src/components/mark/index.ts"],"sourcesContent":["import {\n SFCWithInstallAndClasses,\n withClasses,\n withExtend,\n withInstall,\n withPropsFactory,\n withVarsResolver,\n} from '../../core'\nimport classes from './mark.module.css'\nimport { varsResolver } from './mark.utils'\nimport Mark from './mark.vue'\n\nconst MarkWithStatic = withPropsFactory(\n withExtend(withVarsResolver(withClasses(Mark, classes), varsResolver))\n)\n\nexport const CMark: SFCWithInstallAndClasses<typeof Mark, typeof classes> =\n withInstall(MarkWithStatic)\n\nexport default CMark\n\nexport * from './mark.types'\n"],"mappings":";;;;;;;AAYA,MAAM,iBAAiBA,gBAAAA,iBACrBC,gBAAAA,WAAWC,gBAAAA,iBAAiBC,gBAAAA,YAAYC,aAAAA,SAAMC,oBAAAA,OAAO,GAAGC,mBAAAA,YAAY,CAAC,CACvE;AAEA,MAAa,QACXC,gBAAAA,YAAY,cAAc"}
|