UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

55 lines (54 loc) 1.82 kB
import { defineComponent as y, computed as u, createElementBlock as r, openBlock as s, normalizeClass as c, unref as o, Fragment as h, renderList as _, renderSlot as g, createTextVNode as f, toDisplayString as d } from "vue"; import { useProps as k, useNameHelper as v } from "@vexip-ui/config"; import { highlightProps as b } from "./props.mjs"; const C = { key: 1 }, w = /* @__PURE__ */ y({ name: "Highlight", __name: "highlight", props: b, setup(m) { const n = k("highlight", m, { content: { default: "", static: !0 }, keyWords: { default: () => [], static: !0 }, ignoreCase: !1 }), l = v("highlight"), i = u(() => { var a; const e = (a = n.keyWords) == null ? void 0 : a.filter(Boolean); return e != null && e.length ? new RegExp( `(${e.sort((t, p) => p.length - t.length).join("|")})`, `${n.ignoreCase ? "i" : ""}g` ) : null; }), x = u(() => !i.value || !n.content ? [{ isKey: !1, text: n.content }] : n.content.split(i.value).map((e) => ({ isKey: i.value.test(e), text: e }))); return (e, a) => (s(), r("div", { class: c([o(l).b(), o(l).bs("vars"), o(n).inherit && o(l).bm("inherit")]) }, [ (s(!0), r(h, null, _(x.value, (t, p) => (s(), r(h, { key: p }, [ t.isKey ? (s(), r("span", { key: 0, class: c(o(l).be("key-word")) }, [ g(e.$slots, "light", { text: t.text }, () => [ f(d(t.text), 1) ]) ], 2)) : (s(), r("span", C, [ g(e.$slots, "default", { text: t.text }, () => [ f(d(t.text), 1) ]) ])) ], 64))), 128)) ], 2)); } }); export { w as default }; //# sourceMappingURL=highlight.vue2.mjs.map