@cck-ui/core 0.42.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.
@@ -23,10 +23,6 @@ const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
23
23
  type: [Object, Function],
24
24
  required: false
25
25
  },
26
- children: {
27
- type: String,
28
- required: true
29
- },
30
26
  wholeWorld: {
31
27
  type: Boolean,
32
28
  required: false
@@ -369,6 +365,7 @@ const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
369
365
  const rawProps = __props;
370
366
  const _root = (0, vue.ref)(null);
371
367
  const theme = require_config_provider_context.useCckTheme();
368
+ const slots = (0, vue.useSlots)();
372
369
  const defaultProps = {
373
370
  color: "yellow",
374
371
  wholeWorld: false,
@@ -382,7 +379,6 @@ const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
382
379
  });
383
380
  const knownProps = [
384
381
  "unstyled",
385
- "children",
386
382
  "highlight",
387
383
  "highlightStyles",
388
384
  "color",
@@ -408,11 +404,18 @@ const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
408
404
  else result = [props.value.highlight];
409
405
  return result;
410
406
  });
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
- }));
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
+ });
416
419
  const resolvedStyle = (0, vue.computed)(() => {
417
420
  const style = props.value.style;
418
421
  if (typeof style === "function") return style(theme.value);
@@ -436,6 +439,7 @@ const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
436
439
  rawProps,
437
440
  _root,
438
441
  theme,
442
+ slots,
439
443
  defaultProps,
440
444
  props,
441
445
  knownProps,
@@ -1 +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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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"}
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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,IAAA,GAAA,IAAA,mBAAA,CAWrD,IAAA,UAAA,OAAA,GAAA,IAAA,WAAA,CAXqC,OAAA,kBAAe,EAA3C,OAAO,eAAe,MAAC;iFAEjC,gBAAA,GAAA,IAAA,UAAA,CAAA,IAAA,GAAA,IAAA,YAAA,CAOC,OAAA,UAAA;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"}
@@ -5,7 +5,7 @@ import { useComponentProps } from "../../core/config-provider/use-component-prop
5
5
  import { CText } from "../text/index.mjs";
6
6
  import { CMark } from "../mark/index.mjs";
7
7
  import { foldAccents, highlighter } from "./highlighter/highlighter.mjs";
8
- import { Fragment, computed, createBlock, createElementBlock, createTextVNode, defineComponent, mergeProps, normalizeStyle, openBlock, ref, renderList, toDisplayString, withCtx } from "vue";
8
+ import { Fragment, computed, createBlock, createElementBlock, createTextVNode, defineComponent, mergeProps, normalizeStyle, openBlock, ref, renderList, toDisplayString, useSlots, withCtx } from "vue";
9
9
  //#region packages/@cck-ui/core/src/components/highlight/highlight.vue
10
10
  const _sfc_main = /*@__PURE__*/ defineComponent({
11
11
  name: "CHighlight",
@@ -23,10 +23,6 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
23
23
  type: [Object, Function],
24
24
  required: false
25
25
  },
26
- children: {
27
- type: String,
28
- required: true
29
- },
30
26
  wholeWorld: {
31
27
  type: Boolean,
32
28
  required: false
@@ -369,6 +365,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
369
365
  const rawProps = __props;
370
366
  const _root = ref(null);
371
367
  const theme = useCckTheme();
368
+ const slots = useSlots();
372
369
  const defaultProps = {
373
370
  color: "yellow",
374
371
  wholeWorld: false,
@@ -382,7 +379,6 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
382
379
  });
383
380
  const knownProps = [
384
381
  "unstyled",
385
- "children",
386
382
  "highlight",
387
383
  "highlightStyles",
388
384
  "color",
@@ -408,11 +404,18 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
408
404
  else result = [props.value.highlight];
409
405
  return result;
410
406
  });
411
- const highlightChunks = computed(() => highlighter(props.value.children, highlightStrings.value, {
412
- wholeWord: props.value.wholeWorld,
413
- caseInsensitive: props.value.caseInsensitive,
414
- accentInsensitive: props.value.accentInsensitive
415
- }));
407
+ const highlightChunks = 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(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
+ });
416
419
  const resolvedStyle = computed(() => {
417
420
  const style = props.value.style;
418
421
  if (typeof style === "function") return style(theme.value);
@@ -436,6 +439,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
436
439
  rawProps,
437
440
  _root,
438
441
  theme,
442
+ slots,
439
443
  defaultProps,
440
444
  props,
441
445
  knownProps,
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.mjs","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,WAAW;EAEjB,MAAM,QAAQ,IAAuC,IAAI;EAEzD,MAAM,QAAQ,YAAY;EAE1B,MAAM,eAAe;GACnB,OAAO;GACP,YAAY;GACZ,iBAAiB;GACjB,mBAAmB;EACrB;EAEA,MAAM,QAAQ,kBAAkB;GAC9B,WAAW;GACX;GACA,OAAO;EACT,CAAC;EAED,MAAM,aAAa;GACjB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EAEA,MAAM,cAAc,eACZ,MAAM,QAAQ,MAAM,MAAM,SAAS,KAAK,OAAO,MAAM,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SAAa,EACX,MAAM,eAAe,MAAM,OAAO,QAAQ,IAAI,EAChD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAjIC,YAmBS,OAAA,UAnBT,WAmBS;EAlBP,qBAAkB;EAClB,KAAI;IACI,OAAA,aAAW;EAClB,OAAO,OAAA;EACP,UAAU,OAAA,MAAM;;yBAE+C,EAAA,UAAA,IAAA,GAAhE,mBAWW,UAAA,MAAA,WAXqC,OAAA,kBAAe,EAA3C,OAAO,eAAe,MAAC;2DAEjC,eAAA,UAAA,GADR,YAQS,OAAA,UAAA;IANN,OAAO,OAAA,SAAS,IAAI,OAAA,aAAa,KAAK,CAAA,KAAM,OAAA,MAAM;IAClD,KAAG,kBAAoB;IACvB,OAAK,eAAE,OAAA,MAAM,eAAe;IAC5B,UAAU,OAAA,MAAM;;2BAEN,CAAA,gBAAA,gBAAR,KAAK,GAAA,CAAA,CAAA,CAAA;;;;;;uBAEV,mBAA4D,QAAA,EAA9C,KAAG,kBAAoB,IAAA,GAAA,gBAAQ,KAAK,GAAA,CAAA,EAAA,GAAA,EAAA"}
1
+ {"version":3,"file":"highlight.mjs","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,WAAW;EAEjB,MAAM,QAAQ,IAAuC,IAAI;EAEzD,MAAM,QAAQ,YAAY;EAE1B,MAAM,QAAQ,SAAS;EAEvB,MAAM,eAAe;GACnB,OAAO;GACP,YAAY;GACZ,iBAAiB;GACjB,mBAAmB;EACrB;EAEA,MAAM,QAAQ,kBAAkB;GAC9B,WAAW;GACX;GACA,OAAO;EACT,CAAC;EAED,MAAM,aAAa;GACjB;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EAEA,MAAM,cAAc,eACZ,MAAM,QAAQ,MAAM,MAAM,SAAS,KAAK,OAAO,MAAM,MAAM,UAAU,OAAO,QACpF;EAEA,MAAM,2BAAW,IAAI,IAAoB;EAEzC,MAAM,gBAAgB,MAAc;GAClC,IAAI,MAAM;GACV,IAAI,MAAM,MAAM,iBACd,MAAM,IAAI,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GAAG;IAAQ,KAAK;GAAU;EACrC,CAAC;EAED,SAAa,EACX,MAAM,eAAe,MAAM,OAAO,QAAQ,IAAI,EAChD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA7IC,YAmBS,OAAA,UAnBT,WAmBS;EAlBP,qBAAkB;EAClB,KAAI;IACI,OAAA,aAAW;EAClB,OAAO,OAAA;EACP,UAAU,OAAA,MAAM;;yBAE+C,EAAA,UAAA,IAAA,GAAhE,mBAWW,UAAA,MAAA,WAXqC,OAAA,kBAAe,EAA3C,OAAO,eAAe,MAAC;2DAEjC,eAAA,UAAA,GADR,YAQS,OAAA,UAAA;IANN,OAAO,OAAA,SAAS,IAAI,OAAA,aAAa,KAAK,CAAA,KAAM,OAAA,MAAM;IAClD,KAAG,kBAAoB;IACvB,OAAK,eAAE,OAAA,MAAM,eAAe;IAC5B,UAAU,OAAA,MAAM;;2BAEN,CAAA,gBAAA,gBAAR,KAAK,GAAA,CAAA,CAAA,CAAA;;;;;;uBAEV,mBAA4D,QAAA,EAA9C,KAAG,kBAAoB,IAAA,GAAA,gBAAQ,KAAK,GAAA,CAAA,EAAA,GAAA,EAAA"}
@@ -29,8 +29,6 @@ export interface HighlightProps extends Omit<TextProps, 'color'> {
29
29
  color?: CColor | string;
30
30
  /** Styles applied to `mark` elements */
31
31
  highlightStyles?: Properties | ((theme: CTheme) => Properties);
32
- /** String in which to highlight substrings */
33
- children: string;
34
32
  /**
35
33
  * Only match whole words (adds word boundaries to regex).
36
34
  * When enabled, 'the' will not match 'there'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cck-ui/core",
3
- "version": "0.42.0",
3
+ "version": "0.42.1",
4
4
  "description": "Vue component library focused on usability, accessibility and developer experience",
5
5
  "homepage": "https://cck-ui.jackatlas.xyz",
6
6
  "license": "ISC",