UNPKG

tdesign-vue

Version:
73 lines (69 loc) 2.17 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import { defineComponent, computed } from '@vue/composition-api'; import { escapeRegExp } from 'lodash-es'; import { usePrefixClass } from '../hooks/useConfig.js'; import '../config-provider/useConfig.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-c44a474d.js'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-d639fbd7.js'; import 'dayjs'; import '../_chunks/dep-3c66615e.js'; import '../config-provider/type.js'; import '../_common/js/global-config/t.js'; import '@babel/runtime/helpers/slicedToArray'; 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 (typeof content !== "string" || !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 { words: words, classPrefix: classPrefix }; }, render: function render() { var _this = this; var h = arguments[0]; var _this$words = this.words, list = _this$words.list, keyword = _this$words.keyword; return h("div", { "class": "".concat(this.classPrefix, "-select-option__highlight-item") }, [list.map(function (item, index) { if (!index) return item; return [h("b", { "class": "".concat(_this.classPrefix, "-is-highlight"), "key": item + keyword }, [keyword]), item]; })]); } }); export { _HighlightOption as default }; //# sourceMappingURL=highlight-option.js.map