@aplus-frontend/ui
Version:
93 lines (92 loc) • 2.92 kB
JavaScript
import { defineComponent as x, ref as B, computed as b, createElementBlock as h, createBlock as I, openBlock as p, normalizeClass as A, unref as e, toDisplayString as C, mergeProps as g } from "vue";
import { isNil as z, omit as T } from "lodash-unified";
import "../../hooks/index.mjs";
import "../../config-provider/index.mjs";
import { Input as k } from "@aplus-frontend/antdv";
import { useDefaultPlaceholder as w } from "../hooks/use-default-placeholder.mjs";
import { useControllableValue as R } from "../../hooks/useControllableValue.mjs";
import { useNamespace as _ } from "../../config-provider/hooks/use-namespace.mjs";
const D = /* @__PURE__ */ x({
name: "ApFieldTextArea",
__name: "index",
props: {
mode: { default: "edit" },
class: {},
style: {},
rows: {},
autoSize: { type: [Boolean, Object] },
onResize: {},
onCompositionstart: {},
onCompositionend: {},
valueModifiers: {},
size: {},
value: {},
name: {},
type: { default: "text" },
onFocus: {},
onBlur: {},
onChange: {},
onInput: {},
onKeydown: {},
onKeyup: {},
onMousedown: {},
focused: { type: Boolean },
hidden: { type: Boolean },
disabled: { type: Boolean, default: void 0 },
prefixCls: {},
id: {},
readonly: { type: Boolean },
autofocus: { type: Boolean },
variant: {},
autocomplete: {},
placeholder: {},
lazy: { type: Boolean, default: !0 },
maxlength: {},
loading: { type: Boolean },
bordered: { type: Boolean, default: !0 },
showCount: { type: [Boolean, Object] },
htmlSize: {},
onPressEnter: {},
onMouseUp: {},
onRawInput: {},
"onUpdate:value": {},
status: {},
defaultValue: {},
inputElement: {},
triggerFocus: {},
handleReset: {},
clearIcon: {},
allowClear: { type: Boolean, default: !0 },
emptyText: { default: "--" },
beforeInput: {}
},
emits: ["update:value"],
setup(s, { expose: i, emit: d }) {
const t = B(), a = s, c = d, { value: l, updateValue: f } = R(a, c), { b: m } = _("field-text-area"), y = w("TextArea", a);
function v(o) {
const n = o.target.value || "", r = a.beforeInput ? a.beforeInput?.(n) : n, u = t.value?.$el?.querySelector("textarea");
u && (u.value = r), f(r);
}
return i({
focus: (o) => {
t.value?.focus(o);
},
blur: () => {
t.value?.blur();
},
resizableTextArea: b(() => t.value?.resizableTextArea)
}), (o, n) => o.mode === "read" ? (p(), h("span", {
key: 0,
class: A(e(m)())
}, C(e(z)(e(l)) || e(l) === "" ? o.emptyText : e(l)), 3)) : (p(), I(e(k).TextArea, g({ key: 1 }, e(T)(a, ["onUpdate:value", "value", "beforeInput"]), {
ref_key: "textAreaRef",
ref: t,
placeholder: e(y),
value: e(l),
onInput: v
}), null, 16, ["placeholder", "value"]));
}
});
export {
D as default
};