From 6fdb342362a17e050afad107859a004ad448ef22 Mon Sep 17 00:00:00 2001 From: zkwolf Date: Mon, 28 Jun 2021 11:19:01 +0800 Subject: [PATCH 1/2] fix(input-password): accept global prefixCls --- components/input/Password.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/components/input/Password.jsx b/components/input/Password.jsx index 3625c115a6..f1e6f1f895 100644 --- a/components/input/Password.jsx +++ b/components/input/Password.jsx @@ -5,6 +5,7 @@ import Icon from '../icon'; import inputProps from './inputProps'; import PropTypes from '../_util/vue-types'; import BaseMixin from '../_util/BaseMixin'; +import { ConfigConsumerProps } from '../config-provider/configConsumerProps'; const ActionMap = { click: 'click', @@ -21,11 +22,14 @@ export default { }, props: { ...inputProps, - prefixCls: PropTypes.string.def('ant-input-password'), - inputPrefixCls: PropTypes.string.def('ant-input'), + prefixCls: PropTypes.string, + inputPrefixCls: PropTypes.string, action: PropTypes.string.def('click'), visibilityToggle: PropTypes.bool.def(true), }, + inject: { + configProvider: { default: () => ConfigConsumerProps }, + }, data() { return { visible: false, @@ -74,13 +78,18 @@ export default { }, render() { const { - prefixCls, - inputPrefixCls, + prefixCls: customizePrefixCls, + inputPrefixCls: customizeInputPrefixCls, size, suffix, visibilityToggle, ...restProps } = getOptionProps(this); + + const getPrefixCls = this.configProvider.getPrefixCls; + const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls); + const prefixCls = getPrefixCls('input-password', customizePrefixCls); + const suffixIcon = visibilityToggle && this.getIcon(); const inputClassName = classNames(prefixCls, { [`${prefixCls}-${size}`]: !!size, From 7601c9182e1103c457838d585c3d8cd9fc86116e Mon Sep 17 00:00:00 2001 From: zkwolf Date: Mon, 28 Jun 2021 11:43:19 +0800 Subject: [PATCH 2/2] fix(input-password): suffix icon style --- components/input/Password.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/input/Password.jsx b/components/input/Password.jsx index f1e6f1f895..61006c9e9c 100644 --- a/components/input/Password.jsx +++ b/components/input/Password.jsx @@ -50,8 +50,8 @@ export default { visible: !this.visible, }); }, - getIcon() { - const { prefixCls, action } = this.$props; + getIcon(prefixCls) { + const { action } = this.$props; const iconTrigger = ActionMap[action] || ''; const iconProps = { props: { @@ -90,7 +90,7 @@ export default { const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls); const prefixCls = getPrefixCls('input-password', customizePrefixCls); - const suffixIcon = visibilityToggle && this.getIcon(); + const suffixIcon = visibilityToggle && this.getIcon(prefixCls); const inputClassName = classNames(prefixCls, { [`${prefixCls}-${size}`]: !!size, });