@aplus-frontend/ui
Version:
158 lines (157 loc) • 3.62 kB
JavaScript
import { isVNode as x, defineComponent as h, useSlots as C, ref as g, unref as i, createVNode as e, mergeProps as w, Fragment as P, createBlock as U, openBlock as V, resolveDynamicComponent as _ } from "vue";
import { Input as S, Space as T } from "@aplus-frontend/antdv";
import "../../hooks/index.mjs";
import { omit as I } from "lodash-unified";
import { EyeOutlined as O, EyeInvisibleOutlined as j } from "@ant-design/icons-vue";
import { useDefaultPlaceholder as k } from "../hooks/use-default-placeholder.mjs";
import { useControllableValue as d } from "../../hooks/useControllableValue.mjs";
function E(t) {
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !x(t);
}
const G = /* @__PURE__ */ h({
name: "ApFieldTextPassword",
__name: "password",
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
},
inputPrefixCls: {},
action: {
default: "click"
},
visibilityToggle: {
type: Boolean,
default: !0
},
visible: {
type: Boolean,
default: void 0
},
"onUpdate:visible": {},
emptyText: {
default: "--"
}
},
emits: ["update:value", "update:visible"],
setup(t, {
expose: c,
emit: f
}) {
const s = f, o = t, a = C(), u = g(), {
value: m,
updateValue: v
} = d(o, s), y = k("TextPassword", o), {
value: b,
updateValue: r
} = d(o, s, {
valuePropName: "visible"
});
function B() {
const n = i(m), l = i(b);
if (o.mode === "edit")
return e(S.Password, w(I(o, ["mode", "emptyText", "value", "onUpdate:value", "visible", "onUpdate:visible"]), {
placeholder: i(y),
value: n,
"onUpdate:value": v,
visible: l,
"onUpdate:visible": r,
ref: u
}), E(a) ? a : {
default: () => [a]
});
let p = e(P, null, [o.emptyText]);
return n && (p = e(T, null, {
default: () => [e("span", null, [l ? n : "********"]), e("span", {
style: {
cursor: "pointer"
},
onClick: () => r(!l)
}, [l ? e(O, null, null) : e(j, null, null)])]
})), p;
}
return c({
focus: () => {
u.value?.focus();
},
blur: () => {
u.value?.blur();
}
}), (n, l) => (V(), U(_(B())));
}
});
export {
G as default
};