vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
109 lines (108 loc) • 3.66 kB
JavaScript
import { defineComponent as P, useSlots as $, createElementBlock as n, openBlock as t, normalizeClass as i, createCommentVNode as s, createElementVNode as D, createBlock as u, unref as e, renderSlot as w, withModifiers as m, Fragment as g, createTextVNode as V, toDisplayString as c } from "vue";
import { useInput as F } from "./hook/useInput.mjs";
import { Icon as y } from "@vuux/icons";
const M = {
key: 0,
class: "is-prepend"
}, U = ["rows", "id", "name", "value", "placeholder", "maxlength", "disabled", "readonly"], j = ["type", "id", "name", "value", "placeholder", "maxlength", "disabled", "readonly"], q = {
key: 4,
ref: "countEl",
class: "input-text"
}, A = {
key: 5,
class: "is-append"
}, K = /* @__PURE__ */ P({
name: "UInput",
__name: "index",
props: {
modelValue: { default: "" },
placeholder: { default: "" },
clear: { type: Boolean, default: !1 },
count: { type: Boolean, default: !1 },
maxCount: {},
disabled: { type: Boolean },
type: { default: "text" },
rows: { default: 5 },
readonly: { type: Boolean }
},
emits: ["update:modelValue", "blur", "input"],
setup(_, { emit: N }) {
const o = _, z = N, f = $(), { inputId: k, inputName: x, localValue: p, show: C, isTextarea: E, isPassword: h, className: b, currentType: S, textCount: B, onInput: d, onBlur: r, onClear: T, onPassword: I } = F(o, z);
return (v, l) => (t(), n("div", {
class: i(["app-input", { "is-disabled": o.disabled }])
}, [
e(f).prepend ? (t(), n("div", M, [
w(v.$slots, "prepend")
])) : s("", !0),
D("form", null, [
e(E) ? (t(), n("textarea", {
key: 0,
rows: o.rows,
id: e(k),
name: e(x),
class: i(e(b)),
value: e(p),
placeholder: o.placeholder,
maxlength: o.maxCount,
disabled: o.disabled,
readonly: o.readonly,
autocomplete: "off",
onInput: l[0] || (l[0] = //@ts-ignore
(...a) => e(d) && e(d)(...a)),
onBlur: l[1] || (l[1] = //@ts-ignore
(...a) => e(r) && e(r)(...a))
}, null, 42, U)) : (t(), n("input", {
key: 1,
type: e(S),
id: e(k),
name: e(x),
class: i(e(b)),
value: e(p),
placeholder: o.placeholder,
maxlength: o.maxCount,
disabled: o.disabled,
readonly: o.readonly,
autocomplete: "off",
onInput: l[2] || (l[2] = //@ts-ignore
(...a) => e(d) && e(d)(...a)),
onBlur: l[3] || (l[3] = //@ts-ignore
(...a) => e(r) && e(r)(...a))
}, null, 42, j))
]),
o.clear && e(p) ? (t(), u(e(y), {
key: 1,
name: "Icon9176914",
size: 14,
opacity: 0.8,
onClick: m(e(T), ["stop"])
}, null, 8, ["onClick"])) : s("", !0),
e(h) && !e(C) ? (t(), u(e(y), {
key: 2,
name: "Icon9900314",
size: 14,
opacity: 0.8,
onClick: m(e(I), ["stop"])
}, null, 8, ["onClick"])) : s("", !0),
e(h) && e(C) ? (t(), u(e(y), {
key: 3,
name: "Icon9900324",
size: 14,
opacity: 0.8,
onClick: m(e(I), ["stop"])
}, null, 8, ["onClick"])) : s("", !0),
o.count ? (t(), n("div", q, [
o.maxCount ? (t(), n(g, { key: 0 }, [
V(c(e(B)) + " / " + c(o.maxCount), 1)
], 64)) : (t(), n(g, { key: 1 }, [
V(c(e(B)), 1)
], 64))
], 512)) : s("", !0),
e(f).append ? (t(), n("div", A, [
w(v.$slots, "append")
])) : s("", !0)
], 2));
}
});
export {
K as default
};