From ea6491783dcc79e610534632a05b2894ded97494 Mon Sep 17 00:00:00 2001 From: doom-9 <429664046@qq.com> Date: Thu, 17 Jun 2021 17:42:23 +0800 Subject: [PATCH 01/10] feat:n-input Support hidden password --- CHANGELOG.zh-CN.md | 4 ++ src/_internal/eye/index.ts | 1 + src/_internal/eye/src/Eye.tsx | 70 +++++++++++++++++++ src/_internal/eye/src/styles/index.cssr.ts | 58 +++++++++++++++ src/_internal/icons/Eye.tsx | 12 ++++ src/_internal/icons/EyeInvisible.tsx | 16 +++++ src/_internal/icons/index.ts | 2 + src/_internal/index.ts | 1 + src/config-provider/src/internal-interface.ts | 2 + src/input/src/Input.tsx | 23 ++++-- 10 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 src/_internal/eye/index.ts create mode 100644 src/_internal/eye/src/Eye.tsx create mode 100644 src/_internal/eye/src/styles/index.cssr.ts create mode 100644 src/_internal/icons/Eye.tsx create mode 100644 src/_internal/icons/EyeInvisible.tsx diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 92a71597d81..bb75a75fb5d 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -2,6 +2,10 @@ ## 2.12.0 (2020-06-16) +### Feats + +- `n-input` 的 password 属性支持查看隐藏特性 + ### Breaking Changes - 移除了 `n-a` 的 `to` 属性。现在如果你需要把 `n-a` 用作 router-link,你可以参考文档网站。 diff --git a/src/_internal/eye/index.ts b/src/_internal/eye/index.ts new file mode 100644 index 00000000000..fc3190e24af --- /dev/null +++ b/src/_internal/eye/index.ts @@ -0,0 +1 @@ +export { default } from './src/Eye' diff --git a/src/_internal/eye/src/Eye.tsx b/src/_internal/eye/src/Eye.tsx new file mode 100644 index 00000000000..23a501a0e5e --- /dev/null +++ b/src/_internal/eye/src/Eye.tsx @@ -0,0 +1,70 @@ +import { h, defineComponent, PropType, toRef, ref } from 'vue' +import { useStyle, useConfig } from '../../../_mixins' +import { EyeIcon, EyeInvisibleIcon } from '../../icons' +import NBaseIcon from '../../icon' +import NIconSwitchTransition from '../../icon-switch-transition' +import style from './styles/index.cssr' + +export default defineComponent({ + name: 'BaseClear', + props: { + clsPrefix: { + type: String, + required: true + }, + onClick: { + type: Function as PropType<() => void>, + required: true + } + }, + setup (props) { + useStyle('BaseClear', style, toRef(props, 'clsPrefix')) + const { NConfigProvider } = useConfig() + const showPassWord = ref(false) + return { + NConfigProvider, + handleMouseDown (e: MouseEvent) { + e.preventDefault() + }, + showPassWord, + handleShowPassWord () { + showPassWord.value = !showPassWord.value + } + } + }, + render () { + const { clsPrefix, showPassWord, handleShowPassWord, onClick } = this + return ( +