@cck-ui/core 0.41.0 → 0.42.1

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.
Files changed (49) hide show
  1. package/cjs/components/highlight/highlight.cjs +497 -0
  2. package/cjs/components/highlight/highlight.cjs.map +1 -0
  3. package/cjs/components/highlight/highlighter/highlighter.cjs +84 -0
  4. package/cjs/components/highlight/highlighter/highlighter.cjs.map +1 -0
  5. package/cjs/components/highlight/index.cjs +13 -0
  6. package/cjs/components/highlight/index.cjs.map +1 -0
  7. package/cjs/components/mark/get-mark-color/get-mark-color.cjs +16 -0
  8. package/cjs/components/mark/get-mark-color/get-mark-color.cjs.map +1 -0
  9. package/cjs/components/mark/index.cjs +14 -0
  10. package/cjs/components/mark/index.cjs.map +1 -0
  11. package/cjs/components/mark/mark.cjs +396 -0
  12. package/cjs/components/mark/mark.cjs.map +1 -0
  13. package/cjs/components/mark/mark.module.cjs +7 -0
  14. package/cjs/components/mark/mark.module.cjs.map +1 -0
  15. package/cjs/components/mark/mark.utils.cjs +20 -0
  16. package/cjs/components/mark/mark.utils.cjs.map +1 -0
  17. package/cjs/index.cjs +47 -41
  18. package/cjs/index.cjs.map +1 -1
  19. package/esm/components/highlight/highlight.mjs +497 -0
  20. package/esm/components/highlight/highlight.mjs.map +1 -0
  21. package/esm/components/highlight/highlighter/highlighter.mjs +83 -0
  22. package/esm/components/highlight/highlighter/highlighter.mjs.map +1 -0
  23. package/esm/components/highlight/index.mjs +10 -0
  24. package/esm/components/highlight/index.mjs.map +1 -0
  25. package/esm/components/mark/get-mark-color/get-mark-color.mjs +16 -0
  26. package/esm/components/mark/get-mark-color/get-mark-color.mjs.map +1 -0
  27. package/esm/components/mark/index.mjs +11 -0
  28. package/esm/components/mark/index.mjs.map +1 -0
  29. package/esm/components/mark/mark.mjs +396 -0
  30. package/esm/components/mark/mark.mjs.map +1 -0
  31. package/esm/components/mark/mark.module.mjs +7 -0
  32. package/esm/components/mark/mark.module.mjs.map +1 -0
  33. package/esm/components/mark/mark.utils.mjs +20 -0
  34. package/esm/components/mark/mark.utils.mjs.map +1 -0
  35. package/esm/index.mjs +5 -1
  36. package/esm/index.mjs.map +1 -1
  37. package/lib/components/highlight/highlight.types.d.ts +55 -0
  38. package/lib/components/highlight/highlighter/highlighter.d.ts +12 -0
  39. package/lib/components/highlight/index.d.ts +5 -0
  40. package/lib/components/index.d.ts +2 -0
  41. package/lib/components/mark/get-mark-color/get-mark-color.d.ts +8 -0
  42. package/lib/components/mark/index.d.ts +6 -0
  43. package/lib/components/mark/mark.types.d.ts +14 -0
  44. package/lib/components/mark/mark.utils.d.ts +6 -0
  45. package/package.json +1 -1
  46. package/styles/mark.css +11 -0
  47. package/styles/mark.layer.css +12 -0
  48. package/styles.css +12 -0
  49. package/styles.layer.css +12 -0
@@ -0,0 +1,497 @@
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
+ wholeWorld: {
27
+ type: Boolean,
28
+ required: false
29
+ },
30
+ caseInsensitive: {
31
+ type: Boolean,
32
+ required: false
33
+ },
34
+ accentInsensitive: {
35
+ type: Boolean,
36
+ required: false
37
+ },
38
+ __staticSelector: {
39
+ type: String,
40
+ required: false
41
+ },
42
+ size: {
43
+ type: null,
44
+ required: false
45
+ },
46
+ lineClamp: {
47
+ type: Number,
48
+ required: false
49
+ },
50
+ truncate: {
51
+ type: [String, Boolean],
52
+ required: false
53
+ },
54
+ inline: {
55
+ type: Boolean,
56
+ required: false
57
+ },
58
+ inherit: {
59
+ type: Boolean,
60
+ required: false
61
+ },
62
+ gradient: {
63
+ type: Object,
64
+ required: false
65
+ },
66
+ span: {
67
+ type: Boolean,
68
+ required: false
69
+ },
70
+ textWrap: {
71
+ type: String,
72
+ required: false
73
+ },
74
+ className: {
75
+ type: String,
76
+ required: false
77
+ },
78
+ style: {
79
+ type: [
80
+ Object,
81
+ Function,
82
+ Array
83
+ ],
84
+ required: false,
85
+ skipCheck: true
86
+ },
87
+ __vars: {
88
+ type: null,
89
+ required: false
90
+ },
91
+ __size: {
92
+ type: String,
93
+ required: false
94
+ },
95
+ hiddenFrom: {
96
+ type: null,
97
+ required: false
98
+ },
99
+ visibleFrom: {
100
+ type: null,
101
+ required: false
102
+ },
103
+ lightHidden: {
104
+ type: Boolean,
105
+ required: false
106
+ },
107
+ darkHidden: {
108
+ type: Boolean,
109
+ required: false
110
+ },
111
+ mod: {
112
+ type: [
113
+ Object,
114
+ String,
115
+ Array
116
+ ],
117
+ required: false
118
+ },
119
+ m: {
120
+ type: null,
121
+ required: false
122
+ },
123
+ my: {
124
+ type: null,
125
+ required: false
126
+ },
127
+ mx: {
128
+ type: null,
129
+ required: false
130
+ },
131
+ mt: {
132
+ type: null,
133
+ required: false
134
+ },
135
+ mb: {
136
+ type: null,
137
+ required: false
138
+ },
139
+ ms: {
140
+ type: null,
141
+ required: false
142
+ },
143
+ me: {
144
+ type: null,
145
+ required: false
146
+ },
147
+ mis: {
148
+ type: null,
149
+ required: false
150
+ },
151
+ mie: {
152
+ type: null,
153
+ required: false
154
+ },
155
+ ml: {
156
+ type: null,
157
+ required: false
158
+ },
159
+ mr: {
160
+ type: null,
161
+ required: false
162
+ },
163
+ p: {
164
+ type: null,
165
+ required: false
166
+ },
167
+ py: {
168
+ type: null,
169
+ required: false
170
+ },
171
+ px: {
172
+ type: null,
173
+ required: false
174
+ },
175
+ pt: {
176
+ type: null,
177
+ required: false
178
+ },
179
+ pb: {
180
+ type: null,
181
+ required: false
182
+ },
183
+ ps: {
184
+ type: null,
185
+ required: false
186
+ },
187
+ pe: {
188
+ type: null,
189
+ required: false
190
+ },
191
+ pis: {
192
+ type: null,
193
+ required: false
194
+ },
195
+ pie: {
196
+ type: null,
197
+ required: false
198
+ },
199
+ pl: {
200
+ type: null,
201
+ required: false
202
+ },
203
+ pr: {
204
+ type: null,
205
+ required: false
206
+ },
207
+ bd: {
208
+ type: null,
209
+ required: false
210
+ },
211
+ bdrs: {
212
+ type: null,
213
+ required: false
214
+ },
215
+ bg: {
216
+ type: null,
217
+ required: false
218
+ },
219
+ c: {
220
+ type: null,
221
+ required: false
222
+ },
223
+ opacity: {
224
+ type: [
225
+ String,
226
+ Object,
227
+ Number
228
+ ],
229
+ required: false
230
+ },
231
+ ff: {
232
+ type: [String, Object],
233
+ required: false
234
+ },
235
+ fz: {
236
+ type: null,
237
+ required: false
238
+ },
239
+ fw: {
240
+ type: null,
241
+ required: false
242
+ },
243
+ lts: {
244
+ type: null,
245
+ required: false
246
+ },
247
+ ta: {
248
+ type: [String, Object],
249
+ required: false
250
+ },
251
+ lh: {
252
+ type: null,
253
+ required: false
254
+ },
255
+ fs: {
256
+ type: null,
257
+ required: false
258
+ },
259
+ tt: {
260
+ type: [String, Object],
261
+ required: false
262
+ },
263
+ td: {
264
+ type: null,
265
+ required: false
266
+ },
267
+ w: {
268
+ type: null,
269
+ required: false
270
+ },
271
+ miw: {
272
+ type: null,
273
+ required: false
274
+ },
275
+ maw: {
276
+ type: null,
277
+ required: false
278
+ },
279
+ h: {
280
+ type: null,
281
+ required: false
282
+ },
283
+ mih: {
284
+ type: null,
285
+ required: false
286
+ },
287
+ mah: {
288
+ type: null,
289
+ required: false
290
+ },
291
+ bgsz: {
292
+ type: null,
293
+ required: false
294
+ },
295
+ bgp: {
296
+ type: null,
297
+ required: false
298
+ },
299
+ bgr: {
300
+ type: null,
301
+ required: false
302
+ },
303
+ bga: {
304
+ type: null,
305
+ required: false
306
+ },
307
+ pos: {
308
+ type: [String, Object],
309
+ required: false
310
+ },
311
+ top: {
312
+ type: null,
313
+ required: false
314
+ },
315
+ left: {
316
+ type: null,
317
+ required: false
318
+ },
319
+ bottom: {
320
+ type: null,
321
+ required: false
322
+ },
323
+ right: {
324
+ type: null,
325
+ required: false
326
+ },
327
+ inset: {
328
+ type: null,
329
+ required: false
330
+ },
331
+ display: {
332
+ type: null,
333
+ required: false
334
+ },
335
+ flex: {
336
+ type: null,
337
+ required: false
338
+ },
339
+ unstyled: {
340
+ type: Boolean,
341
+ required: false
342
+ },
343
+ variant: {
344
+ type: null,
345
+ required: false
346
+ },
347
+ classNames: {
348
+ type: null,
349
+ required: false
350
+ },
351
+ styles: {
352
+ type: null,
353
+ required: false
354
+ },
355
+ vars: {
356
+ type: Function,
357
+ required: false
358
+ },
359
+ attributes: {
360
+ type: null,
361
+ required: false
362
+ }
363
+ },
364
+ setup(__props, { expose: __expose }) {
365
+ const rawProps = __props;
366
+ const _root = (0, vue.ref)(null);
367
+ const theme = require_config_provider_context.useCckTheme();
368
+ const slots = (0, vue.useSlots)();
369
+ const defaultProps = {
370
+ color: "yellow",
371
+ wholeWorld: false,
372
+ caseInsensitive: true,
373
+ accentInsensitive: true
374
+ };
375
+ const props = require_use_component_props.useComponentProps({
376
+ component: "CHighlight",
377
+ defaultProps,
378
+ props: rawProps
379
+ });
380
+ const knownProps = [
381
+ "unstyled",
382
+ "highlight",
383
+ "highlightStyles",
384
+ "color",
385
+ "wholeWord",
386
+ "caseInsensitive",
387
+ "accentInsensitive"
388
+ ];
389
+ const isTermArray = (0, vue.computed)(() => Array.isArray(props.value.highlight) && typeof props.value.highlight[0] === "object");
390
+ const colorMap = /* @__PURE__ */ new Map();
391
+ const normalizeKey = (s) => {
392
+ let key = s;
393
+ if (props.value.caseInsensitive) key = key.toLocaleLowerCase();
394
+ if (props.value.accentInsensitive) key = require_highlighter.foldAccents(key);
395
+ return key;
396
+ };
397
+ const highlightStrings = (0, vue.computed)(() => {
398
+ let result;
399
+ if (isTermArray.value) result = props.value.highlight.map((term) => {
400
+ if (term.color) colorMap.set(normalizeKey(term.text), term.color);
401
+ return term.text;
402
+ });
403
+ else if (Array.isArray(props.value.highlight)) result = props.value.highlight;
404
+ else result = [props.value.highlight];
405
+ return result;
406
+ });
407
+ const highlightChunks = (0, vue.computed)(() => {
408
+ let result = [];
409
+ if (slots.default) {
410
+ const defaultSlotContent = slots.default();
411
+ for (const content of defaultSlotContent) if (typeof content.children === "string") result = result.concat(require_highlighter.highlighter(content.children, highlightStrings.value, {
412
+ wholeWord: props.value.wholeWorld,
413
+ caseInsensitive: props.value.caseInsensitive,
414
+ accentInsensitive: props.value.accentInsensitive
415
+ }));
416
+ }
417
+ return result;
418
+ });
419
+ const resolvedStyle = (0, vue.computed)(() => {
420
+ const style = props.value.style;
421
+ if (typeof style === "function") return style(theme.value);
422
+ return style;
423
+ });
424
+ const mergedAttrs = (0, vue.computed)(() => {
425
+ const others = {};
426
+ const propsValue = props.value;
427
+ Object.keys(propsValue).forEach((key) => {
428
+ if (!knownProps.includes(key)) others[key] = propsValue[key];
429
+ });
430
+ const userMod = props.value.mod;
431
+ const mergedMod = [...Array.isArray(userMod) ? userMod : [userMod].filter(Boolean)];
432
+ return {
433
+ ...others,
434
+ mod: mergedMod
435
+ };
436
+ });
437
+ __expose({ root: (0, vue.computed)(() => _root.value?.root ?? null) });
438
+ const __returned__ = {
439
+ rawProps,
440
+ _root,
441
+ theme,
442
+ slots,
443
+ defaultProps,
444
+ props,
445
+ knownProps,
446
+ isTermArray,
447
+ colorMap,
448
+ normalizeKey,
449
+ highlightStrings,
450
+ highlightChunks,
451
+ resolvedStyle,
452
+ mergedAttrs,
453
+ get CMark() {
454
+ return require_index$1.CMark;
455
+ },
456
+ get CText() {
457
+ return require_index.CText;
458
+ }
459
+ };
460
+ Object.defineProperty(__returned__, "__isScriptSetup", {
461
+ enumerable: false,
462
+ value: true
463
+ });
464
+ return __returned__;
465
+ }
466
+ });
467
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
468
+ return (0, vue.openBlock)(), (0, vue.createBlock)($setup["CText"], (0, vue.mergeProps)({
469
+ "__static-selector": "Highlight",
470
+ ref: "_root"
471
+ }, $setup.mergedAttrs, {
472
+ style: $setup.resolvedStyle,
473
+ unstyled: $setup.props.unstyled
474
+ }), {
475
+ default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)($setup.highlightChunks, ({ chunk, highlighted }, i) => {
476
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [highlighted ? ((0, vue.openBlock)(), (0, vue.createBlock)($setup["CMark"], {
477
+ color: $setup.colorMap.get($setup.normalizeKey(chunk)) || $setup.props.color,
478
+ key: `highlight-mark-${i}`,
479
+ style: (0, vue.normalizeStyle)($setup.props.highlightStyles),
480
+ unstyled: $setup.props.unstyled
481
+ }, {
482
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(chunk), 1)]),
483
+ _: 2
484
+ }, 1032, [
485
+ "color",
486
+ "style",
487
+ "unstyled"
488
+ ])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", { key: `highlight-span-${i}` }, (0, vue.toDisplayString)(chunk), 1))], 64);
489
+ }), 256))]),
490
+ _: 1
491
+ }, 16, ["style", "unstyled"]);
492
+ }
493
+ 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"]]);
494
+ //#endregion
495
+ exports.default = highlight_default;
496
+
497
+ //# 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, useSlots } from 'vue'\nimport { useCckTheme, useComponentProps } from '../../core'\nimport CMark from '../mark'\nimport CText from '../text'\nimport { HighlightProps, HighlightTerm } from './highlight.types'\nimport { foldAccents, HighlightChunk, 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 slots = useSlots()\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 '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 let result: HighlightChunk[] = []\n if (slots.default) {\n const defaultSlotContent = slots.default()\n for (const content of defaultSlotContent) {\n if (typeof content.children === 'string') {\n result = result.concat(\n highlighter(content.children, highlightStrings.value, {\n wholeWord: props.value.wholeWorld,\n caseInsensitive: props.value.caseInsensitive,\n accentInsensitive: props.value.accentInsensitive,\n })\n )\n }\n }\n }\n return result\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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;IANN,OAAO,OAAA,SAAS,IAAI,OAAA,aAAa,KAAK,CAAA,KAAM,OAAA,MAAM;IAClD,KAAG,kBAAoB;IACvB,QAAA,GAAA,IAAA,eAAA,CAAO,OAAA,MAAM,eAAe;IAC5B,UAAU,OAAA,MAAM;;oCAEN,EAAA,GAAA,IAAA,gBAAA,EAAA,GAAA,IAAA,gBAAA,CAAR,KAAK,GAAA,CAAA,CAAA,CAAA;;;;;;4DAEkD,QAAA,EAA9C,KAAG,kBAAoB,IAAA,IAAA,GAAA,IAAA,gBAAA,CAAQ,KAAK,GAAA,CAAA,EAAA,GAAA,EAAA"}
@@ -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":";;AAAA,SAAS,YAAY,OAAe;CAClC,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AAEA,SAAgB,YAAY,MAAsB;CAChD,OAAO,KAAK,UAAU,KAAK,CAAC,CAAC,QAAQ,WAAW,EAAE;AACpD;AAEA,SAAS,mBAAmB,MAAiD;CAC3E,IAAI,SAAS;CACb,MAAM,MAAgB,CAAC;CACvB,IAAI,IAAI;CAER,OAAO,IAAI,KAAK,QAAQ;EACtB,MAAM,KAAK,KAAK,YAAY,CAAC;EAC7B,MAAM,QAAQ,OAAO,cAAc,EAAE;EACrC,MAAM,WAAW,YAAY,KAAK;EAClC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK,GACxC,IAAI,KAAK,CAAC;EAEZ,UAAU;EACV,KAAK,MAAM;CACb;CAEA,IAAI,KAAK,KAAK,MAAM;CACpB,OAAO;EAAE;EAAQ;CAAI;AACvB;AAEA,SAAS,2BAA2B,OAAe,IAA8B;CAC/E,MAAM,EAAE,QAAQ,QAA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,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAC1C,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CACnC,KAAK,GAAG;CAEjB,MAAM,UAAU,YAAY,wBAAwB,QAAQ,wBAAwB,IAAI,QAAQ;CAChG,MAAM,QAAQ;EAAC;EAAK,kBAAkB,MAAM;EAAI,YAAY,MAAM;CAAE,CAAC,CAAC,KAAK,EAAE;CAC7E,MAAM,KAAK,IAAI,OAAO,SAAS,KAAK;CAEpC,IAAI,mBACF,OAAO,2BAA2B,OAAO,EAAE;CAG7C,OAAO,MACJ,MAAM,EAAE,CAAC,CACT,KAAK,MAAM,WAAW;EAAE,OAAO;EAAM,aAAa,QAAQ,MAAM;CAAE,EAAE,CAAC,CACrE,QAAQ,EAAE,YAAY,KAAK;AAChC"}
@@ -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"}