tdesign-pro-component
Version:
ProComponents tdesign-vue-next + Vue3 + TS
83 lines (82 loc) • 2.3 kB
JavaScript
import "lodash-es";
import { g as t, w as x } from "./utils-CIySOLoe.js";
import { defineComponent as I, ref as S, watch as h, createVNode as a, mergeProps as g, resolveComponent as y } from "vue";
import { FormItem as F, Input as O } from "tdesign-vue-next";
const P = /* @__PURE__ */ I({
name: "ProFormText",
props: {
// about form
name: {
required: !0,
type: String
},
label: [String, Function, Object],
rules: Array,
formItemProps: Object,
// about input
modelValue: [String, Number, Boolean, Array],
placeholder: {
type: String,
default: "请输入"
},
type: String,
prepend: [String, Function, Object],
append: [String, Function, Object],
inputLabel: [String, Function, Object],
suffix: [String, Function, Object],
suffixIcon: [String, Function, Object],
clearable: Boolean,
readonly: Boolean,
disabled: Boolean,
borderless: Boolean,
inputProps: Object
},
emits: ["update:modelValue", "change"],
setup(e, {
slots: l,
emit: u
}) {
const r = S(e.modelValue || "");
h(() => e.modelValue, (n) => {
n !== r.value && (r.value = n || "");
});
const p = (n) => {
u("update:modelValue", n), u("change", n);
}, o = t("label", l, e), d = t("suffix", l, e), i = t("inputLabel", l, e), c = t("append", l, e), m = t("prepend", l, e), f = t("suffixIcon", l, e), b = () => a(O, g({
modelValue: r.value,
"onUpdate:modelValue": (n) => r.value = n,
borderless: e.borderless,
disabled: e.disabled,
readonly: e.readonly,
clearable: e.clearable,
type: e.type,
placeholder: e.placeholder,
onChange: p
}, e.inputProps), {
suffix: d() ? d : null,
label: i() ? i : null,
suffixIcon: f() ? f : null
});
function s() {
return !e.append && !e.prepend ? a(b, null, null) : a(y("t-input-adornment"), {
style: {
width: "100%"
}
}, {
default: () => a(b, null, null),
prepend: m() ? m : null,
append: c() ? c : null
});
}
return () => a(F, g({
rules: e.rules,
name: e.name
}, e.formItemProps), {
default: s,
label: o() ? o : null
});
}
}), v = x(P);
export {
v as P
};