vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
75 lines (74 loc) • 2.65 kB
JavaScript
import { defineComponent as V, useTemplateRef as C, createElementBlock as a, openBlock as n, normalizeClass as E, unref as e, createVNode as b, withCtx as I, withDirectives as N, createCommentVNode as f, Fragment as T, renderList as D, createElementVNode as F, createBlock as K, toDisplayString as R, withKeys as c, isRef as h, vModelText as z } from "vue";
import { Space as S } from "../../Space/index.mjs";
import { useInputTag as $ } from "./hook/useInputTag.mjs";
import { Icon as L } from "@vuux/icons";
const M = ["disabled", "placeholder"], J = /* @__PURE__ */ V({
name: "InputTag",
__name: "index",
props: {
modelValue: {},
readonly: { type: Boolean },
placeholder: { default: "请输入" },
max: { default: 0 },
limit: { default: 10 },
gap: { default: 5 },
disabled: { type: Boolean }
},
emits: ["update:modelValue", "delete", "save"],
setup(u, { emit: y }) {
const o = u, g = y, d = C("inputEl"), { onFocus: v, tagValue: r, show: k, classNames: w, values: x, handleRemove: B, onDelete: s, onEnter: i, onBlur: p } = $(o, d, g);
return (U, t) => (n(), a("div", {
class: E(["app-input-tag", e(w)])
}, [
b(e(S), {
wrap: "",
gap: o.gap,
"full-width": ""
}, {
default: I(() => [
(n(!0), a(T, null, D(e(x), (l, m) => (n(), a("div", {
key: m,
class: "tag-item"
}, [
F("span", null, R(l), 1),
o.readonly ? f("", !0) : (n(), K(e(L), {
key: 0,
name: "Icon9176904",
size: 13,
color: "#fff",
onClick: (j) => e(B)(m)
}, null, 8, ["onClick"]))
]))), 128)),
!o.readonly && e(k) ? N((n(), a("input", {
key: 0,
ref_key: "inputEl",
ref: d,
"onUpdate:modelValue": t[0] || (t[0] = (l) => h(r) ? r.value = l : null),
type: "text",
disabled: o.disabled,
placeholder: u.placeholder,
onFocus: t[1] || (t[1] = (l) => v.value = !0),
onBlur: t[2] || (t[2] = //@ts-ignore
(...l) => e(p) && e(p)(...l)),
onKeyup: t[3] || (t[3] = c(
//@ts-ignore
(...l) => e(i) && e(i)(...l),
["enter"]
)),
onKeydown: t[4] || (t[4] = c(
//@ts-ignore
(...l) => e(s) && e(s)(...l),
["delete"]
))
}, null, 40, M)), [
[z, e(r)]
]) : f("", !0)
]),
_: 1
}, 8, ["gap"])
], 2));
}
});
export {
J as default
};