Skip to content

Commit 4eb26ea

Browse files
authored
feat(input-password): accept global prefixCls (#4280)
* fix(input-password): accept global prefixCls * fix(input-password): suffix icon style
1 parent 5c8b82c commit 4eb26ea

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Diff for: components/input/Password.jsx

+16-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Icon from '../icon';
55
import inputProps from './inputProps';
66
import PropTypes from '../_util/vue-types';
77
import BaseMixin from '../_util/BaseMixin';
8+
import { ConfigConsumerProps } from '../config-provider/configConsumerProps';
89

910
const ActionMap = {
1011
click: 'click',
@@ -21,11 +22,14 @@ export default {
2122
},
2223
props: {
2324
...inputProps,
24-
prefixCls: PropTypes.string.def('ant-input-password'),
25-
inputPrefixCls: PropTypes.string.def('ant-input'),
25+
prefixCls: PropTypes.string,
26+
inputPrefixCls: PropTypes.string,
2627
action: PropTypes.string.def('click'),
2728
visibilityToggle: PropTypes.bool.def(true),
2829
},
30+
inject: {
31+
configProvider: { default: () => ConfigConsumerProps },
32+
},
2933
data() {
3034
return {
3135
visible: false,
@@ -46,8 +50,8 @@ export default {
4650
visible: !this.visible,
4751
});
4852
},
49-
getIcon() {
50-
const { prefixCls, action } = this.$props;
53+
getIcon(prefixCls) {
54+
const { action } = this.$props;
5155
const iconTrigger = ActionMap[action] || '';
5256
const iconProps = {
5357
props: {
@@ -74,14 +78,19 @@ export default {
7478
},
7579
render() {
7680
const {
77-
prefixCls,
78-
inputPrefixCls,
81+
prefixCls: customizePrefixCls,
82+
inputPrefixCls: customizeInputPrefixCls,
7983
size,
8084
suffix,
8185
visibilityToggle,
8286
...restProps
8387
} = getOptionProps(this);
84-
const suffixIcon = visibilityToggle && this.getIcon();
88+
89+
const getPrefixCls = this.configProvider.getPrefixCls;
90+
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
91+
const prefixCls = getPrefixCls('input-password', customizePrefixCls);
92+
93+
const suffixIcon = visibilityToggle && this.getIcon(prefixCls);
8594
const inputClassName = classNames(prefixCls, {
8695
[`${prefixCls}-${size}`]: !!size,
8796
});

0 commit comments

Comments
 (0)