Skip to content

Commit 5409ce5

Browse files
authored
feat(input-password): accept global prefixCls (#4430)
1 parent 903ac35 commit 5409ce5

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

components/input/Password.tsx

+15-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import EyeInvisibleOutlined from '@ant-design/icons-vue/EyeInvisibleOutlined';
77
import inputProps from './inputProps';
88
import PropTypes from '../_util/vue-types';
99
import BaseMixin from '../_util/BaseMixin';
10-
import { defineComponent } from 'vue';
10+
import { defineComponent, inject } from 'vue';
11+
import { defaultConfigProvider } from '../config-provider';
1112

1213
const ActionMap = {
1314
click: 'onClick',
@@ -20,8 +21,8 @@ export default defineComponent({
2021
inheritAttrs: false,
2122
props: {
2223
...inputProps,
23-
prefixCls: PropTypes.string.def('ant-input-password'),
24-
inputPrefixCls: PropTypes.string.def('ant-input'),
24+
prefixCls: PropTypes.string,
25+
inputPrefixCls: PropTypes.string,
2526
action: PropTypes.string.def('click'),
2627
visibilityToggle: PropTypes.looseBool.def(true),
2728
iconRender: PropTypes.func.def((visible: boolean) =>
@@ -31,6 +32,7 @@ export default defineComponent({
3132
setup() {
3233
return {
3334
input: null,
35+
configProvider: inject('configProvider', defaultConfigProvider),
3436
};
3537
},
3638
data() {
@@ -56,8 +58,8 @@ export default defineComponent({
5658
visible: !this.visible,
5759
});
5860
},
59-
getIcon() {
60-
const { prefixCls, action } = this.$props;
61+
getIcon(prefixCls) {
62+
const { action } = this.$props;
6163
const iconTrigger = ActionMap[action] || '';
6264
const iconRender = this.$slots.iconRender || this.$props.iconRender;
6365
const icon = iconRender(this.visible);
@@ -81,8 +83,8 @@ export default defineComponent({
8183
},
8284
render() {
8385
const {
84-
prefixCls,
85-
inputPrefixCls,
86+
prefixCls: customizePrefixCls,
87+
inputPrefixCls: customizeInputPrefixCls,
8688
size,
8789
suffix,
8890
action,
@@ -91,7 +93,12 @@ export default defineComponent({
9193
...restProps
9294
} = getOptionProps(this);
9395
const { class: className } = this.$attrs;
94-
const suffixIcon = visibilityToggle && this.getIcon();
96+
97+
const getPrefixCls = this.configProvider.getPrefixCls;
98+
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
99+
const prefixCls = getPrefixCls('input-password', customizePrefixCls);
100+
101+
const suffixIcon = visibilityToggle && this.getIcon(prefixCls);
95102
const inputClassName = classNames(prefixCls, className, {
96103
[`${prefixCls}-${size}`]: !!size,
97104
});

0 commit comments

Comments
 (0)