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