tdesign-pro-component
Version:
ProComponents tdesign-vue-next + Vue3 + TS
231 lines (230 loc) • 7.02 kB
JavaScript
import { a as T, w as S } from "./utils-DU1amZow.js";
import { defineComponent as U, ref as N, useSlots as O, onMounted as j, resolveComponent as c, openBlock as m, createBlock as y, mergeProps as b, withCtx as t, createSlots as h, createVNode as q, unref as F, isRef as W, renderSlot as r } from "vue";
import { u as D } from "./hooks-9GWkbKry.js";
const E = /* @__PURE__ */ U({
name: "ProFormText",
__name: "ProFormText",
props: {
name: {},
modelValue: {},
label: {},
placeholder: {},
autofocus: { type: Boolean },
borderless: { type: Boolean },
clearable: { type: Boolean },
disabled: { type: Boolean },
readonly: { type: Boolean },
size: {},
type: {},
align: {},
append: {},
prepend: {},
inputProps: {},
labelWidth: {},
labelAlign: { default: "left" },
rules: {},
formItemProps: {}
},
emits: ["update:modelValue", "change", "input", "blur", "focus", "clear", "click", "keydown", "keypress", "keyup", "mouseenter", "mouseleave", "paste", "validate", "wheel"],
setup(d, { expose: i, emit: p }) {
const o = d, u = N(), l = p, s = D(o, "modelValue", l, o.modelValue || ""), a = O();
j(() => {
o.name || T("name is empty");
});
function v(e) {
l("input", e);
}
function k(e, n) {
l("change", e, n);
}
function g(e, n) {
l("blur", e, n);
}
function I(e, n) {
l("focus", e, n);
}
function x(e) {
l("clear", e);
}
function V(e) {
l("click", e);
}
function _(e, n) {
l("keydown", e, n);
}
function P(e, n) {
l("keypress", e, n);
}
function C(e, n) {
l("keyup", e, n);
}
function w(e) {
l("mouseenter", e);
}
function B(e) {
l("mouseleave", e);
}
function $(e) {
l("paste", e);
}
function K(e) {
l("validate", e);
}
function M(e) {
l("wheel", e);
}
return i({
blur: () => u.value.blur(),
focus: () => u.value.focus(),
getValue: () => s.value,
clear: () => s.value = "",
getRef: () => u.value
}), (e, n) => {
const z = c("t-input"), R = c("t-input-adornment"), A = c("t-form-item");
return m(), y(A, b({
label: o.label,
name: o.name,
rules: o.rules,
labelWidth: o.labelWidth,
labelAlign: o.labelAlign
}, o.formItemProps), {
default: t(() => [
a.prepend || a.append || o.prepend || o.append ? (m(), y(R, {
key: 0,
prepend: o.prepend,
append: o.append
}, h({
default: t(() => [
q(z, b({
ref_key: "inputRef",
ref: u,
readonly: o.readonly,
autofocus: o.autofocus,
borderless: o.borderless,
clearable: o.clearable,
disabled: o.disabled,
size: o.size,
type: o.type,
align: o.align,
modelValue: F(s),
"onUpdate:modelValue": n[0] || (n[0] = (f) => W(s) ? s.value = f : null),
onInput: v,
onChange: k,
onBlur: g,
onFocus: I,
onClear: x,
onClick: V,
onKeydown: _,
onKeypress: P,
onKeyup: C,
onMouseenter: w,
onMouseleave: B,
onPaste: $,
onValidate: K,
onWheel: M,
placeholder: o.placeholder || `请输入${e.label || "数据"}`
}, o.inputProps), h({ _: 2 }, [
a.suffixIcon ? {
name: "suffixIcon",
fn: t(() => [
r(e.$slots, "suffixIcon", {}, void 0, !0)
]),
key: "0"
} : void 0,
a.suffix ? {
name: "suffix",
fn: t(() => [
r(e.$slots, "suffix", {}, void 0, !0)
]),
key: "1"
} : void 0,
a.prefixIcon ? {
name: "prefixIcon",
fn: t(() => [
r(e.$slots, "prefixIcon", {}, void 0, !0)
]),
key: "2"
} : void 0
]), 1040, ["readonly", "autofocus", "borderless", "clearable", "disabled", "size", "type", "align", "modelValue", "placeholder"])
]),
_: 2
}, [
a.prepend ? {
name: "prepend",
fn: t(() => [
r(e.$slots, "prepend", {}, void 0, !0)
]),
key: "0"
} : void 0,
a.append ? {
name: "append",
fn: t(() => [
r(e.$slots, "append", {}, void 0, !0)
]),
key: "1"
} : void 0
]), 1032, ["prepend", "append"])) : (m(), y(z, b({
key: 1,
ref: "tInputRef",
readonly: o.readonly,
autofocus: o.autofocus,
borderless: o.borderless,
clearable: o.clearable,
disabled: o.disabled,
size: o.size,
type: o.type,
align: o.align,
onInput: v,
modelValue: F(s),
"onUpdate:modelValue": n[1] || (n[1] = (f) => W(s) ? s.value = f : null),
onChange: k,
onBlur: g,
onFocus: I,
onClear: x,
onClick: V,
onKeydown: _,
onKeypress: P,
onKeyup: C,
onMouseenter: w,
onMouseleave: B,
onPaste: $,
onValidate: K,
onWheel: M,
placeholder: o.placeholder || `请输入${e.label || "数据"}`
}, o.inputProps), h({ _: 2 }, [
a.suffixIcon ? {
name: "suffixIcon",
fn: t(() => [
r(e.$slots, "suffixIcon", {}, void 0, !0)
]),
key: "0"
} : void 0,
a.suffix ? {
name: "suffix",
fn: t(() => [
r(e.$slots, "suffix", {}, void 0, !0)
]),
key: "1"
} : void 0,
a.prefixIcon ? {
name: "prefixIcon",
fn: t(() => [
r(e.$slots, "prefixIcon", {}, void 0, !0)
]),
key: "2"
} : void 0
]), 1040, ["readonly", "autofocus", "borderless", "clearable", "disabled", "size", "type", "align", "modelValue", "placeholder"]))
]),
_: 3
}, 16, ["label", "name", "rules", "labelWidth", "labelAlign"]);
};
}
}), G = (d, i) => {
const p = d.__vccOpts || d;
for (const [o, u] of i)
p[o] = u;
return p;
}, H = /* @__PURE__ */ G(E, [["__scopeId", "data-v-0841641a"]]), X = S(H);
export {
X as P
};