xdesign-vue-next
Version:
XDesign Component for vue-next
73 lines (65 loc) • 2.24 kB
JavaScript
/**
* xdesign v1.0.6
* (c) 2023 xdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var hooks_useConfig = require('../hooks/useConfig.js');
var isString = require('lodash/isString');
require('../config-provider/useConfig.js');
require('lodash/isFunction');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/en_US.js');
require('../_chunks/dep-8d10b59f.js');
require('lodash/isArray');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
var _HighlightOption = vue.defineComponent({
name: "XHighlightOption",
props: {
content: String,
keyword: String
},
setup: function setup(props) {
var classPrefix = hooks_useConfig.usePrefixClass();
var words = vue.computed(function () {
var _content$match;
var content = props.content,
keyword = props.keyword;
if (!content) return {
list: []
};
if (!isString__default["default"](content) || !keyword) return {
list: [content]
};
var regExp = new RegExp(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 vue.createVNode("div", {
"class": "".concat(classPrefix.value, "-select-option__highlight-item")
}, [list.map(function (item, index) {
if (!index) return item;
return [vue.createVNode("b", {
"class": "".concat(classPrefix.value, "-is-highlight"),
"key": item + keyword
}, [keyword]), item];
})]);
};
}
});
exports["default"] = _HighlightOption;
//# sourceMappingURL=highlight-option.js.map