@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 3.39 kB
Source Map (JSON)
{"version":3,"file":"highlight.vue2.mjs","sources":["../../../components/highlight/highlight.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport { computed } from 'vue'\r\n\r\nimport { useNameHelper, useProps } from '@vexip-ui/config'\r\nimport { highlightProps } from './props'\r\n\r\ndefineOptions({ name: 'Highlight' })\r\n\r\nconst _props = defineProps(highlightProps)\r\nconst props = useProps('highlight', _props, {\r\n content: {\r\n default: '',\r\n static: true,\r\n },\r\n keyWords: {\r\n default: () => [],\r\n static: true,\r\n },\r\n ignoreCase: false,\r\n})\r\n\r\nconst nh = useNameHelper('highlight')\r\n\r\nconst splitRE = computed(() => {\r\n const keyWords = props.keyWords?.filter(Boolean)\r\n\r\n if (!keyWords?.length) {\r\n return null\r\n }\r\n\r\n return new RegExp(\r\n `(${keyWords.sort((p, n) => n.length - p.length).join('|')})`,\r\n `${props.ignoreCase ? 'i' : ''}g`,\r\n )\r\n})\r\nconst renderTexts = computed(() => {\r\n if (!splitRE.value || !props.content) {\r\n return [{ isKey: false, text: props.content }]\r\n }\r\n\r\n return props.content.split(splitRE.value).map(text => {\r\n return { isKey: splitRE.value!.test(text), text }\r\n })\r\n})\r\n</script>\r\n\r\n<template>\r\n <div :class=\"[nh.b(), nh.bs('vars'), props.inherit && nh.bm('inherit')]\">\r\n <template v-for=\"(item, index) in renderTexts\" :key=\"index\">\r\n <span v-if=\"item.isKey\" :class=\"nh.be('key-word')\">\r\n <slot name=\"light\" :text=\"item.text\">\r\n {{ item.text }}\r\n </slot>\r\n </span>\r\n <span v-else>\r\n <slot :text=\"item.text\">\r\n {{ item.text }}\r\n </slot>\r\n </span>\r\n </template>\r\n </div>\r\n</template>\r\n"],"names":["props","useProps","__props","nh","useNameHelper","splitRE","computed","keyWords","_a","p","n","renderTexts","text","_createElementBlock","_normalizeClass","_unref","_openBlock","_Fragment","_renderList","item","index","_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