Merge branch 'master' into feature-3.7.0

This commit is contained in:
afc163 2018-06-15 11:32:11 +08:00
commit 4bf9114ee9
7 changed files with 47 additions and 31 deletions

View File

@ -26,6 +26,7 @@ export interface AutoCompleteProps extends AbstractSelectProps {
value?: SelectValue;
defaultValue?: SelectValue;
dataSource?: DataSourceItemType[];
backfill?: boolean;
optionLabelProp?: string;
onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => any;

View File

@ -2,7 +2,6 @@ import * as React from 'react';
import { findDOMNode } from 'react-dom';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import omit from 'omit.js';
import Icon from '../icon';
import Group from './button-group';
@ -37,10 +36,10 @@ function insertSpace(child: React.ReactChild, needInserted: boolean) {
export type ButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'danger';
export type ButtonShape = 'circle' | 'circle-outline';
export type ButtonSize = 'small' | 'default' | 'large';
export type ButtonHTMLType = 'submit' | 'button' | 'reset';
export interface BaseButtonProps {
type?: ButtonType;
htmlType?: string;
icon?: string;
shape?: ButtonShape;
size?: ButtonSize;
@ -50,9 +49,16 @@ export interface BaseButtonProps {
ghost?: boolean;
}
export type AnchorButtonProps = BaseButtonProps & React.AnchorHTMLAttributes<HTMLAnchorElement>;
export type AnchorButtonProps = {
href: string;
target?: string;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
} & BaseButtonProps & React.AnchorHTMLAttributes<HTMLAnchorElement>;
export type NativeButtonProps = BaseButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;
export type NativeButtonProps = {
htmlType?: ButtonHTMLType;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
} & BaseButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;
export type ButtonProps = AnchorButtonProps | NativeButtonProps;
@ -138,7 +144,7 @@ export default class Button extends React.Component<ButtonProps, any> {
}
}
handleClick = (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {
handleClick: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement> = e => {
// Add click effect
this.setState({ clicked: true });
clearTimeout(this.timeout);
@ -146,7 +152,7 @@ export default class Button extends React.Component<ButtonProps, any> {
const onClick = this.props.onClick;
if (onClick) {
(onClick as (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void)(e);
(onClick as React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>)(e);
}
}
@ -157,7 +163,7 @@ export default class Button extends React.Component<ButtonProps, any> {
render() {
const {
type, shape, size, className, htmlType, children, icon, prefixCls, ghost, ...others
type, shape, size, className, children, icon, prefixCls, ghost, loading: _loadingProp, ...rest
} = this.props;
const { loading, clicked, hasTwoCNChar } = this.state;
@ -175,8 +181,6 @@ export default class Button extends React.Component<ButtonProps, any> {
break;
}
const ComponentProp = (others as AnchorButtonProps).href ? 'a' : 'button';
const classes = classNames(prefixCls, className, {
[`${prefixCls}-${type}`]: type,
[`${prefixCls}-${shape}`]: shape,
@ -193,15 +197,30 @@ export default class Button extends React.Component<ButtonProps, any> {
const kids = (children || children === 0)
? React.Children.map(children, child => insertSpace(child, this.isNeedInserted())) : null;
return (
<ComponentProp
{...omit(others, ['loading'])}
type={(others as AnchorButtonProps).href ? undefined : (htmlType || 'button')}
className={classes}
onClick={this.handleClick}
>
{iconNode}{kids}
</ComponentProp>
);
if ('href' in rest) {
return (
<a
{...rest}
className={classes}
onClick={this.handleClick}
>
{iconNode}{kids}
</a>
);
} else {
// React does not recognize the `htmlType` prop on a DOM element. Here we pick it out of `rest`.
const { htmlType, ...otherProps } = rest;
return (
<button
{...otherProps}
type={htmlType || 'button'}
className={classes}
onClick={this.handleClick}
>
{iconNode}{kids}
</button>
);
}
}
}

View File

@ -2417,6 +2417,8 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
<input
autocomplete="off"
class="ant-input-number-input"
data-__field="[object Object]"
data-__meta="[object Object]"
id="input-number"
max="10"
min="1"

View File

@ -60,7 +60,6 @@
.disabled();
.@{input-number-prefix-cls}-input {
cursor: not-allowed;
background-color: @disabled-bg;
}
.@{input-number-prefix-cls}-handler-wrap {
display: none;
@ -74,17 +73,12 @@
-moz-appearance: textfield;
height: @input-height-base - 2px;
transition: all 0.3s linear;
color: @input-color;
background-color: @input-bg;
background-color: transparent;
border: 0;
border-radius: @border-radius-base;
padding: 0 @control-padding-horizontal - 1px;
display: block;
.placeholder();
&[disabled] {
.disabled();
}
}
&-lg {
@ -109,7 +103,7 @@
border-left: @border-width-base @border-style-base @border-color-base;
width: 22px;
height: 100%;
background: @component-background;
background: transparent;
position: absolute;
top: 0;
right: 0;

View File

@ -29,7 +29,7 @@ Select component to select value from options.
| defaultValue | Initial selected option. | string\|number\|string\[]\|number\[] | - |
| disabled | Whether disabled select | boolean | false |
| dropdownClassName | className of dropdown menu | string | - |
| dropdownMatchSelectWidth | Whether dropdown's with is same with select. | boolean | true |
| dropdownMatchSelectWidth | Whether dropdown's width is same with select. | boolean | true |
| dropdownStyle | style of dropdown menu | object | - |
| filterOption | If true, filter options by input, if function, filter options against it. The function will receive two arguments, `inputValue` and `option`, if the function returns `true`, the option will be included in the filtered set; Otherwise, it will be excluded. | boolean or function(inputValue, option) | true |
| firstActiveValue | Value of action option by default | string\|string\[] | - |

View File

@ -5,8 +5,8 @@ export interface TransferOperationProps {
className?: string;
leftArrowText?: string;
rightArrowText?: string;
moveToLeft?: React.FormEventHandler<HTMLButtonElement>;
moveToRight?: React.FormEventHandler<HTMLButtonElement>;
moveToLeft?: React.MouseEventHandler<HTMLButtonElement>;
moveToRight?: React.MouseEventHandler<HTMLButtonElement>;
leftActive?: boolean;
rightActive?: boolean;
style?: React.CSSProperties;

View File

@ -145,7 +145,7 @@
"rc-drawer-menu": "^0.5.3",
"rc-queue-anim": "^1.4.1",
"rc-scroll-anim": "^2.2.1",
"rc-tween-one": "^1.7.2",
"rc-tween-one": "^2.0.1",
"react": "^16.3.2",
"react-color": "^2.11.7",
"react-copy-to-clipboard": "^5.0.0",