refactor: autoFocus to autofocus

pull/2682/head
tanjinzhou 2020-07-17 17:36:58 +08:00
parent 00069605c0
commit 566bbb4873
46 changed files with 70 additions and 70 deletions

@ -1 +1 @@
Subproject commit fe4a4e29aebe7cc1a5bbacf43c2b34671b00c880
Subproject commit 43f89955b59abfd51bdfd4d9dcbc3b4fc4c481b0

View File

@ -45,7 +45,7 @@ const AutoComplete = {
showSearch: PropTypes.bool.def(false),
transitionName: PropTypes.string.def('slide-up'),
choiceTransitionName: PropTypes.string.def('zoom'),
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
backfill: PropTypes.bool,
optionLabelProp: PropTypes.string.def('children'),
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]).def(false),

View File

@ -90,7 +90,7 @@ const CascaderProps = {
getPopupContainer: PropTypes.func,
popupVisible: PropTypes.bool,
fieldNames: FieldNamesType,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
suffixIcon: PropTypes.any,
};
@ -167,7 +167,7 @@ const Cascader = {
},
// mounted() {
// this.$nextTick(() => {
// if (this.autoFocus && !this.showSearch && !this.disabled) {
// if (this.autofocus && !this.showSearch && !this.disabled) {
// this.$refs.picker.focus();
// }
// });

View File

@ -22,7 +22,7 @@ export default {
id: PropTypes.string,
indeterminate: PropTypes.bool,
type: PropTypes.string.def('checkbox'),
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
},
setup() {

View File

@ -25,7 +25,7 @@ export const PickerProps = () => ({
pickerClass: PropTypes.string,
pickerInputClass: PropTypes.string,
timePicker: PropTypes.any,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
tagPrefixCls: PropTypes.string,
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
align: PropTypes.object.def(() => ({})),

View File

@ -59,10 +59,10 @@ export default function wrapPicker(Picker, props, pickerType) {
};
},
mounted() {
const { autoFocus, disabled, value, defaultValue, valueFormat } = this;
const { autofocus, disabled, value, defaultValue, valueFormat } = this;
checkValidate('DatePicker', defaultValue, 'defaultValue', valueFormat);
checkValidate('DatePicker', value, 'value', valueFormat);
if (autoFocus && !disabled) {
if (autofocus && !disabled) {
this.$nextTick(() => {
this.focus();
});

View File

@ -24,7 +24,7 @@ export const InputNumberProps = {
name: PropTypes.string,
id: PropTypes.string,
precision: PropTypes.number,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
};
const InputNumber = {

View File

@ -157,8 +157,8 @@ export default {
onInput: handleChange,
onChange: noop,
};
if (!inputProps.autoFocus) {
delete inputProps.autoFocus;
if (!inputProps.autofocus) {
delete inputProps.autofocus;
}
return <input {...inputProps} />;
},

View File

@ -142,8 +142,8 @@ const ResizableTextArea = {
// },
// ],
};
if (!textareaProps.autoFocus) {
delete textareaProps.autoFocus;
if (!textareaProps.autofocus) {
delete textareaProps.autofocus;
}
return (
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize)}>

View File

@ -24,7 +24,7 @@ export default {
prefix: PropTypes.any,
suffix: PropTypes.any,
// spellCheck: Boolean,
autoFocus: Boolean,
autofocus: Boolean,
allowClear: Boolean,
lazy: {
default: true,

View File

@ -66,7 +66,7 @@ const Mentions = {
},
mounted() {
this.$nextTick(() => {
if (this.autoFocus) {
if (this.autofocus) {
this.focus();
}
});

View File

@ -8,7 +8,7 @@ const ActionButtonProps = {
type: ButtonType,
actionFn: PropTypes.func,
closeModal: PropTypes.func,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
buttonProps: PropTypes.object,
};
@ -21,7 +21,7 @@ export default {
};
},
mounted() {
if (this.autoFocus) {
if (this.autofocus) {
this.timeoutId = setTimeout(() => this.$el.focus());
}
},

View File

@ -48,7 +48,7 @@ const ConfirmDialog = (_, { attrs }) => {
<ActionButton
actionFn={onCancel}
closeModal={close}
autoFocus={autoFocusButton === 'cancel'}
autofocus={autoFocusButton === 'cancel'}
buttonProps={cancelButtonProps}
>
{cancelText}
@ -94,7 +94,7 @@ const ConfirmDialog = (_, { attrs }) => {
type={okType}
actionFn={onOk}
closeModal={close}
autoFocus={autoFocusButton === 'ok'}
autofocus={autoFocusButton === 'ok'}
buttonProps={okButtonProps}
>
{okText}

View File

@ -19,7 +19,7 @@ export default {
value: PropTypes.any,
name: String,
id: String,
autoFocus: Boolean,
autofocus: Boolean,
type: PropTypes.string.def('radio'),
onChange: PropTypes.func,
},

View File

@ -17,7 +17,7 @@ export const RateProps = {
tooltips: PropTypes.arrayOf(PropTypes.string),
disabled: PropTypes.bool,
character: PropTypes.any,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
};
const Rate = {

View File

@ -37,7 +37,7 @@ const AbstractSelectProps = () => ({
dropdownMatchSelectWidth: PropTypes.bool,
// onSearch: (value: string) => any,
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
backfill: PropTypes.bool,
showArrow: PropTypes.bool,
getPopupContainer: PropTypes.func,

View File

@ -21,7 +21,7 @@ const Switch = {
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
checked: PropTypes.bool,
defaultChecked: PropTypes.bool,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
loading: PropTypes.bool,
},
setup() {

View File

@ -64,7 +64,7 @@ export const TimePickerProps = () => ({
align: PropTypes.object,
placement: PropTypes.any,
transitionName: PropTypes.string,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
addon: PropTypes.any,
clearIcon: PropTypes.any,
locale: PropTypes.object,

View File

@ -11,7 +11,7 @@ export const TreeData = PropTypes.shape({
export const TreeSelectProps = () => ({
...AbstractSelectProps(),
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
dropdownStyle: PropTypes.object,
filterTreeNode: PropTypes.oneOfType([Function, Boolean]),
getPopupContainer: PropTypes.func,

View File

@ -23,7 +23,7 @@ export default {
// onClick: PropTypes.func,
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
readonly: PropTypes.bool,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
value: PropTypes.any,
},
{
@ -45,7 +45,7 @@ export default {
},
mounted() {
nextTick(() => {
if (this.autoFocus) {
if (this.autofocus) {
this.$refs.input && this.$refs.input.focus();
}
});
@ -102,7 +102,7 @@ export default {
disabled,
readonly,
tabindex,
autoFocus,
autofocus,
onFocus,
onBlur,
value,
@ -130,7 +130,7 @@ export default {
tabindex,
class: `${prefixCls}-input`,
checked: !!sChecked,
autoFocus,
autofocus,
value,
...globalProps,
onChange: this.handleChange,

View File

@ -45,7 +45,7 @@ const inputNumberProps = {
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
focusOnUpDown: PropTypes.bool,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
// onChange: PropTypes.func,
// onKeyDown: PropTypes.func,
// onKeyUp: PropTypes.func,
@ -110,12 +110,12 @@ export default {
return {
inputValue: this.toPrecisionAsStep(validValue),
sValue: validValue,
focused: this.autoFocus,
focused: this.autofocus,
};
},
mounted() {
this.$nextTick(() => {
if (this.autoFocus && !this.disabled) {
if (this.autofocus && !this.disabled) {
this.focus();
}
this.updatedFunc();
@ -540,8 +540,8 @@ export default {
);
},
toNumber(num) {
const { precision, autoFocus } = this.$props;
const { focused = autoFocus } = this;
const { precision, autofocus } = this.$props;
const { focused = autofocus } = this;
// num.length > 16 => This is to prevent input of large numbers
const numberIsTooLarge = num && num.length > 16 && focused;
if (this.isNotCompleteNumber(num) || numberIsTooLarge) {

View File

@ -249,7 +249,7 @@ const Mentions = {
prefixCls,
placement,
transitionName,
autoFocus,
autofocus,
notFoundContent,
getPopupContainer,
...restProps

View File

@ -7,7 +7,7 @@ import {
import { PlaceMent } from './placement';
export const mentionsProps = {
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
prefix: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
prefixCls: PropTypes.string,
value: PropTypes.string,

View File

@ -17,7 +17,7 @@ const rateProps = {
character: PropTypes.any,
characterRender: PropTypes.func,
tabindex: PropTypes.number,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
};
function noop() {}
@ -56,7 +56,7 @@ export default {
},
mounted() {
this.$nextTick(() => {
if (this.autoFocus && !this.disabled) {
if (this.autofocus && !this.disabled) {
this.focus();
}
});

View File

@ -42,7 +42,7 @@ export const SelectPropTypes = {
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
getInputElement: PropTypes.func,
showAction: PropTypes.arrayOf(PropTypes.string),
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
getPopupContainer: PropTypes.func,
clearIcon: PropTypes.any,
inputIcon: PropTypes.any,

View File

@ -158,7 +158,7 @@ const Select = {
this.$nextTick(() => {
// when defaultOpen is true, we should auto focus search input
// https://github.com/ant-design/ant-design/issues/14254
if (this.autoFocus || this._open) {
if (this.autofocus || this._open) {
this.focus();
}
// this.setState({

View File

@ -34,7 +34,7 @@ const rangeProps = {
prefixCls: PropTypes.string,
min: PropTypes.number,
max: PropTypes.number,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
};
const Range = {
name: 'Range',

View File

@ -13,7 +13,7 @@ const Slider = {
defaultValue: PropTypes.number,
value: PropTypes.number,
disabled: PropTypes.bool,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
tabindex: PropTypes.number,
reverse: PropTypes.bool,
min: PropTypes.number,

View File

@ -31,7 +31,7 @@ export default function createSlider(Component) {
railStyle: PropTypes.object,
dotStyle: PropTypes.object,
activeDotStyle: PropTypes.object,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
};
return {
name: 'createSlider',
@ -75,8 +75,8 @@ export default function createSlider(Component) {
// Snapshot testing cannot handle refs, so be sure to null-check this.
this.document = this.$refs.sliderRef && this.$refs.sliderRef.ownerDocument;
// this.setHandleRefs()
const { autoFocus, disabled } = this;
if (autoFocus && !disabled) {
const { autofocus, disabled } = this;
if (autofocus && !disabled) {
this.focus();
}
});

View File

@ -11,6 +11,6 @@ export const switchPropTypes = {
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
checked: PropTypes.bool,
defaultChecked: PropTypes.bool.def(false),
autoFocus: PropTypes.bool.def(false),
autofocus: PropTypes.bool.def(false),
loadingIcon: PropTypes.any,
};

View File

@ -32,8 +32,8 @@ export default {
},
mounted() {
this.$nextTick(() => {
const { autoFocus, disabled } = this;
if (autoFocus && !disabled) {
const { autofocus, disabled } = this;
if (autofocus && !disabled) {
this.focus();
}
});
@ -84,7 +84,7 @@ export default {
disabled,
loadingIcon,
defaultChecked,
autoFocus,
autofocus,
...restProps
} = getOptionProps(this);
const checked = this.stateChecked;

View File

@ -65,7 +65,7 @@ export default {
secondStep: PropTypes.number,
focusOnOpen: PropTypes.bool,
// onKeyDown: PropTypes.func,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
id: PropTypes.string,
inputIcon: PropTypes.any,
clearIcon: PropTypes.any,
@ -116,7 +116,7 @@ export default {
},
mounted() {
this.$nextTick(() => {
if (this.autoFocus) {
if (this.autofocus) {
this.focus();
}
});
@ -335,7 +335,7 @@ export default {
getPopupContainer,
name,
autocomplete,
autoFocus,
autofocus,
inputReadOnly,
sOpen,
sValue,
@ -374,7 +374,7 @@ export default {
autocomplete={autocomplete}
onFocus={onFocus}
onBlur={onBlur}
autoFocus={autoFocus}
autofocus={autofocus}
readonly={!!inputReadOnly}
id={id}
/>

View File

@ -81,7 +81,7 @@ const Select = {
open: PropTypes.bool,
value: PropTypes.any,
autoFocus: PropTypes.bool,
autofocus: PropTypes.bool,
defaultOpen: PropTypes.bool,
defaultValue: PropTypes.any,
@ -258,8 +258,8 @@ const Select = {
},
mounted() {
this.$nextTick(() => {
const { autoFocus, disabled } = this.$props;
if (autoFocus && !disabled) {
const { autofocus, disabled } = this.$props;
if (autofocus && !disabled) {
this.focus();
}
});

View File

@ -44,13 +44,13 @@ export default function focusTest(Component) {
});
});
it('autoFocus', done => {
it('autofocus', done => {
jest.useRealTimers();
const handleFocus = jest.fn();
mount(
{
render(h) {
return <Component autoFocus onFocus={handleFocus} />;
return <Component autofocus onFocus={handleFocus} />;
},
},
{ attachToDocument: true, sync: false },

View File

@ -22,7 +22,7 @@ export declare class AutoComplete extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* backfill selected item the input when using keyboard

2
types/cascader.d.ts vendored
View File

@ -59,7 +59,7 @@ export declare class Cascader extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* change value on each selection if set to true.

View File

@ -13,7 +13,7 @@ export declare class Checkbox extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* Specifies whether the checkbox is selected.

View File

@ -18,7 +18,7 @@ export declare class DatepickerCommon extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* custom rendering function for date cells by setting a scoped slot

View File

@ -10,7 +10,7 @@ export declare class InputNumber extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* initial value

View File

@ -11,7 +11,7 @@ export declare class Mentions extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* Default value

View File

@ -15,7 +15,7 @@ export declare class Radio extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* Specifies whether the radio is selected.

2
types/rate.d.ts vendored
View File

@ -24,7 +24,7 @@ export declare class Rate extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* custom character of rate

View File

@ -30,7 +30,7 @@ export declare class Select extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* Whether active first option by default

2
types/slider.d.ts vendored
View File

@ -11,7 +11,7 @@ export declare class Slider extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* The default value of slider. When range is false, use number, otherwise, use [number, number]

2
types/switch.d.ts vendored
View File

@ -10,7 +10,7 @@ export declare class Switch extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* determine whether the Switch is checked

View File

@ -24,7 +24,7 @@ export declare class TimePicker extends AntdComponent {
* @default false
* @type boolean
*/
autoFocus: boolean;
autofocus: boolean;
/**
* clear tooltip of icon