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; value?: SelectValue;
defaultValue?: SelectValue; defaultValue?: SelectValue;
dataSource?: DataSourceItemType[]; dataSource?: DataSourceItemType[];
backfill?: boolean;
optionLabelProp?: string; optionLabelProp?: string;
onChange?: (value: SelectValue) => void; onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => any; onSelect?: (value: SelectValue, option: Object) => any;

View File

@ -2,7 +2,6 @@ import * as React from 'react';
import { findDOMNode } from 'react-dom'; import { findDOMNode } from 'react-dom';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames'; import classNames from 'classnames';
import omit from 'omit.js';
import Icon from '../icon'; import Icon from '../icon';
import Group from './button-group'; 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 ButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'danger';
export type ButtonShape = 'circle' | 'circle-outline'; export type ButtonShape = 'circle' | 'circle-outline';
export type ButtonSize = 'small' | 'default' | 'large'; export type ButtonSize = 'small' | 'default' | 'large';
export type ButtonHTMLType = 'submit' | 'button' | 'reset';
export interface BaseButtonProps { export interface BaseButtonProps {
type?: ButtonType; type?: ButtonType;
htmlType?: string;
icon?: string; icon?: string;
shape?: ButtonShape; shape?: ButtonShape;
size?: ButtonSize; size?: ButtonSize;
@ -50,9 +49,16 @@ export interface BaseButtonProps {
ghost?: boolean; 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; 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 // Add click effect
this.setState({ clicked: true }); this.setState({ clicked: true });
clearTimeout(this.timeout); clearTimeout(this.timeout);
@ -146,7 +152,7 @@ export default class Button extends React.Component<ButtonProps, any> {
const onClick = this.props.onClick; const onClick = this.props.onClick;
if (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() { render() {
const { const {
type, shape, size, className, htmlType, children, icon, prefixCls, ghost, ...others type, shape, size, className, children, icon, prefixCls, ghost, loading: _loadingProp, ...rest
} = this.props; } = this.props;
const { loading, clicked, hasTwoCNChar } = this.state; const { loading, clicked, hasTwoCNChar } = this.state;
@ -175,8 +181,6 @@ export default class Button extends React.Component<ButtonProps, any> {
break; break;
} }
const ComponentProp = (others as AnchorButtonProps).href ? 'a' : 'button';
const classes = classNames(prefixCls, className, { const classes = classNames(prefixCls, className, {
[`${prefixCls}-${type}`]: type, [`${prefixCls}-${type}`]: type,
[`${prefixCls}-${shape}`]: shape, [`${prefixCls}-${shape}`]: shape,
@ -193,15 +197,30 @@ export default class Button extends React.Component<ButtonProps, any> {
const kids = (children || children === 0) const kids = (children || children === 0)
? React.Children.map(children, child => insertSpace(child, this.isNeedInserted())) : null; ? React.Children.map(children, child => insertSpace(child, this.isNeedInserted())) : null;
return ( if ('href' in rest) {
<ComponentProp return (
{...omit(others, ['loading'])} <a
type={(others as AnchorButtonProps).href ? undefined : (htmlType || 'button')} {...rest}
className={classes} className={classes}
onClick={this.handleClick} onClick={this.handleClick}
> >
{iconNode}{kids} {iconNode}{kids}
</ComponentProp> </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 <input
autocomplete="off" autocomplete="off"
class="ant-input-number-input" class="ant-input-number-input"
data-__field="[object Object]"
data-__meta="[object Object]"
id="input-number" id="input-number"
max="10" max="10"
min="1" min="1"

View File

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

View File

@ -29,7 +29,7 @@ Select component to select value from options.
| defaultValue | Initial selected option. | string\|number\|string\[]\|number\[] | - | | defaultValue | Initial selected option. | string\|number\|string\[]\|number\[] | - |
| disabled | Whether disabled select | boolean | false | | disabled | Whether disabled select | boolean | false |
| dropdownClassName | className of dropdown menu | string | - | | 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 | - | | 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 | | 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\[] | - | | firstActiveValue | Value of action option by default | string\|string\[] | - |

View File

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

View File

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