zent
Version:
一套前端设计语言和基于React的实现
19 lines (18 loc) • 847 B
JavaScript
import { __assign, __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import Input from './Input';
import { useState, useCallback } from 'react';
export var Password = function (props) {
var _a = useState(false), visible = _a[0], setVisible = _a[1];
var icon = props.icon, type = props.type, onIconClick = props.onIconClick, restProps = __rest(props, ["icon", "type", "onIconClick"]);
var disabled = props.disabled;
var onVisibleChange = useCallback(function () {
if (disabled) {
return;
}
setVisible(!visible);
}, [visible, disabled]);
return (_jsx(Input, __assign({ type: visible ? 'text' : 'password', icon: visible ? 'eye-o' : 'closed-eye', onIconClick: onVisibleChange }, restProps), void 0));
};
Password.displayName = 'ZentPassword';
export default Password;