UNPKG

tdesign-vue-next

Version:
68 lines (64 loc) 2.17 kB
/** * tdesign v1.19.2 * (c) 2026 tdesign * @license MIT */ import { defineComponent, computed, createVNode } from 'vue'; import { isString, escapeRegExp } from 'lodash-es'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/typeof'; import '../../_chunks/dep-c68ea098.js'; import { u as usePrefixClass } from '../../_chunks/dep-e8dd47a9.js'; import '@babel/runtime/helpers/slicedToArray'; import '../../_chunks/dep-91fc762d.js'; import '@babel/runtime/helpers/defineProperty'; import '../../_chunks/dep-f0f392fb.js'; import '../../config-provider/hooks/useConfig.js'; import '../../config-provider/utils/context.js'; import '../../_chunks/dep-509ddbe3.js'; import 'dayjs'; import '@babel/runtime/helpers/createClass'; import '@babel/runtime/helpers/classCallCheck'; 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.js.map