UNPKG

tdesign-vue-next

Version:
72 lines (68 loc) 2.34 kB
/** * tdesign v1.20.0 * (c) 2026 tdesign * @license MIT */ import { defineComponent, computed, createVNode } from 'vue'; import { u as usePrefixClass } from '../../_chunks/dep-6e1ec500.mjs'; import { isString, escapeRegExp } from 'lodash-es'; import '../../_chunks/dep-3a6b2289.mjs'; import '../../_chunks/dep-1e8a6a5e.mjs'; import '../../_chunks/dep-7e80b480.mjs'; import '../../_chunks/dep-98b885ec.mjs'; import '../../_chunks/dep-c53b1c81.mjs'; import '../../config-provider/hooks/useConfig.mjs'; import '../../config-provider/utils/context.mjs'; import '../../_chunks/dep-fc168c9c.mjs'; import '../../_chunks/dep-2242b0fd.mjs'; import '../../_chunks/dep-b9ecb840.mjs'; import '../../_chunks/dep-a1cffe73.mjs'; import '../../_chunks/dep-67ace303.mjs'; import '../../_chunks/dep-8768d1f1.mjs'; import '../../_chunks/dep-68c88886.mjs'; import '../../_chunks/dep-dfce43be.mjs'; import '../../_chunks/dep-e25ecc4b.mjs'; import '../../_chunks/dep-d9965fa1.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