@aplus-frontend/ui
Version:
142 lines (141 loc) • 3.28 kB
JavaScript
import { isVNode as g, defineComponent as C, useSlots as R, shallowRef as S, createVNode as i, mergeProps as _, unref as r, computed as w, createBlock as V, openBlock as T } from "vue";
import { Input as j } from "@aplus-frontend/antdv";
import { omit as U } from "lodash-unified";
import "../../render/index.mjs";
import "../../hooks/index.mjs";
import { useDefaultPlaceholder as z } from "../hooks/use-default-placeholder.mjs";
import { useControllableValue as F } from "../../hooks/useControllableValue.mjs";
import M from "../../render/render.mjs";
function N(n) {
return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !g(n);
}
const $ = /* @__PURE__ */ C({
name: "ApFieldText",
__name: "index",
props: {
mode: {
default: "edit"
},
class: {},
style: {},
variant: {},
size: {},
value: {},
name: {},
type: {
default: "text"
},
onCompositionend: {},
onCompositionstart: {},
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
},
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": {},
valueModifiers: {},
status: {},
defaultValue: {},
inputElement: {},
triggerFocus: {},
handleReset: {},
addonBefore: {},
addonAfter: {},
prefix: {},
suffix: {},
clearIcon: {},
allowClear: {
type: Boolean,
default: !0
},
emptyText: {
default: "--"
},
beforeInput: {}
},
emits: ["update:value"],
setup(n, {
expose: d,
emit: f
}) {
const l = R(), e = n, c = f, {
value: p,
updateValue: m
} = F(e, c), y = z("Text", e), t = S(), x = (o) => {
t.value?.focus(o);
}, v = () => {
t.value?.blur();
}, B = (o, u, a) => {
t.value?.setSelectionRange(o, u, a);
}, b = () => {
t.value?.select();
};
function h(o) {
const u = o.target.value || "", a = e.beforeInput ? e.beforeInput?.(u) : u, s = t.value?.$el?.querySelector("input");
s && (s.value = a), m(a);
}
function I() {
return e.mode === "edit" ? i(j, _(U(e, ["mode", "emptyText", "value", "onUpdate:value", "beforeInput"]), {
placeholder: r(y),
value: r(p),
onInput: h,
ref: t
}), N(l) ? l : {
default: () => [l]
}) : i("span", null, [e.prefix || l?.prefix?.(), r(p) || e.emptyText, e.suffix || l?.suffix?.()]);
}
return d({
focus: x,
blur: v,
setSelectionRange: B,
select: b,
input: w(() => t.value?.input)
}), (o, u) => (T(), V(r(M), {
renderer: I
}));
}
});
export {
$ as default
};