UNPKG

tdesign-vue-next

Version:
72 lines (68 loc) 2.27 kB
/** * tdesign v1.13.2 * (c) 2025 tdesign * @license MIT */ import { defineComponent, computed, createVNode } from 'vue'; import { u as usePrefixClass } from '../_chunks/dep-9c4aef07.mjs'; import { isString, escapeRegExp } from 'lodash-es'; import '../_chunks/dep-b981148e.mjs'; import '../_chunks/dep-f1895f5a.mjs'; import '../_chunks/dep-a81129ec.mjs'; import '../utils/render-tnode.mjs'; import '../config-provider/hooks/useConfig.mjs'; import '../config-provider/utils/context.mjs'; import '../_chunks/dep-466a0666.mjs'; import '../_chunks/dep-24ce1cec.mjs'; import '../_chunks/dep-160caab6.mjs'; import '../_chunks/dep-e497214e.mjs'; import '../_chunks/dep-98cd1e2d.mjs'; import '../_chunks/dep-23a929e8.mjs'; import '../_chunks/dep-48e13ca0.mjs'; import '../_chunks/dep-033df8e6.mjs'; import '../utils/dom.mjs'; import '../_chunks/dep-20550dcc.mjs'; import '../_chunks/dep-0bb39574.mjs'; var _HighlightOption = defineComponent({ name: "HighlightOption", props: { content: String, keyword: String }, setup: function setup(props) { var classPrefix = usePrefixClass(); var words = computed(function () { var _content$match; var content = props.content, keyword = props.keyword; if (!content) return { list: [] }; if (!isString(content) || !keyword) return { list: [content] }; var regExp = new RegExp(escapeRegExp(keyword), "i"); var splitKeyword = (_content$match = content.match(regExp)) === null || _content$match === void 0 ? void 0 : _content$match[0]; return { list: content.split(splitKeyword), keyword: splitKeyword }; }); return function () { var _words$value = words.value, list = _words$value.list, keyword = _words$value.keyword; return createVNode("div", { "class": "".concat(classPrefix.value, "-select-option__highlight-item") }, [list.map(function (item, index) { if (!index) return item; return [createVNode("b", { "class": "".concat(classPrefix.value, "-is-highlight"), "key": item + keyword }, [keyword]), item]; })]); }; } }); export { _HighlightOption as default }; //# sourceMappingURL=highlight-option.mjs.map