Merge branch 'master' into feature-2.9

This commit is contained in:
afc163 2017-03-28 20:42:36 +08:00
commit 035e28f75e
6 changed files with 51 additions and 62 deletions

View File

@ -0,0 +1,19 @@
import React from 'react';
import { findDOMNode } from 'react-dom';
export default class InputElement extends React.Component<any, any> {
private ele: HTMLInputElement;
focus = () => {
this.ele.focus ? this.ele.focus() : (findDOMNode(this.ele) as HTMLInputElement).focus();
}
blur = () => {
this.ele.blur ? this.ele.blur() : (findDOMNode(this.ele) as HTMLInputElement).blur();
}
render() {
return React.cloneElement(this.props.children, {
...this.props,
ref: ele => this.ele = (ele as HTMLInputElement),
}, null);
}
}

View File

@ -1,14 +1,9 @@
import React from 'react';
import { findDOMNode } from 'react-dom';
import Select, { AbstractSelectProps, OptionProps, OptGroupProps } from '../select';
import Input from '../input';
import { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';
export interface SelectedValue {
key: string;
label: React.ReactNode;
}
import Select, { AbstractSelectProps, SelectValue, OptionProps, OptGroupProps } from '../select';
import Input from '../input';
import InputElement from './InputElement';
export interface DataSourceItemObject { value: string; text: string; };
export type DataSourceItemType = string | DataSourceItemObject;
@ -24,37 +19,18 @@ export type ValidInputElement =
React.ReactElement<InputProps>;
export interface AutoCompleteProps extends AbstractSelectProps {
size?: 'large' | 'small' | 'default';
className?: string;
notFoundContent?: Element;
value?: SelectValue;
defaultValue?: SelectValue;
dataSource: DataSourceItemType[];
defaultValue?: string | Array<any> | SelectedValue | Array<SelectedValue>;
value?: string | Array<any> | SelectedValue | Array<SelectedValue>;
onChange?: (value: string | Array<any> | SelectedValue | Array<SelectedValue>) => void;
onSelect?: (value: string | Array<any> | SelectedValue | Array<SelectedValue>, option: Object) => any;
disabled?: boolean;
optionLabelProp?: string;
filterOption?: boolean | ((inputValue: string, option: Object) => any);
onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => any;
children?: ValidInputElement |
React.ReactElement<OptionProps> |
Array<React.ReactElement<OptionProps>>;
}
class InputElement extends React.Component<any, any> {
private ele: HTMLInputElement;
focus = () => {
this.ele.focus ? this.ele.focus() : (findDOMNode(this.ele) as HTMLInputElement).focus();
}
blur = () => {
this.ele.blur ? this.ele.blur() : (findDOMNode(this.ele) as HTMLInputElement).blur();
}
render() {
return React.cloneElement(this.props.children, {
...this.props,
ref: ele => this.ele = (ele as HTMLInputElement),
}, null);
}
}
function isSelectOptionOrSelectOptGroup(child: any): Boolean {
return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup);
}

View File

@ -61,7 +61,7 @@ describe('Menu', () => {
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
});
it.only('should accept openKeys in mode inline', () => {
it('should accept openKeys in mode inline', () => {
const wrapper = mount(
<Menu openKeys={['1']} mode="inline" openAnimation="">
<SubMenu key="1" title="submenu1">

View File

@ -1,33 +1,37 @@
import React from 'react';
import { PropTypes } from 'react';
import React, { PropTypes } from 'react';
import RcSelect, { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';
export type SelectValue = string | any[] | { key: string, label: React.ReactNode } |
Array<{ key: string, label: React.ReactNode }>;
export interface AbstractSelectProps {
size?: 'default' | 'large' | 'small';
className?: string;
notFoundContent?: React.ReactNode | null;
prefixCls?: string;
className?: string;
size?: 'default' | 'large' | 'small';
notFoundContent?: React.ReactNode | null;
transitionName?: string;
optionLabelProp?: string;
choiceTransitionName?: string;
showSearch?: boolean;
allowClear?: boolean;
disabled?: boolean;
style?: React.CSSProperties;
placeholder?: string;
filterOption?: boolean | ((inputValue: string, option: Object) => any);
}
export interface LabeledValue {
key: string;
label: React.ReactNode;
}
export type SelectValue = string | any[] | LabeledValue | LabeledValue[];
export interface SelectProps extends AbstractSelectProps {
value?: SelectValue;
defaultValue?: SelectValue;
combobox?: boolean;
multiple?: boolean;
tags?: boolean;
optionLabelProp?: string;
filterOption?: boolean | ((inputValue: string, option: Object) => any);
onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => any;
onDeselect?: (value: SelectValue) => any;
onSearch?: (value: string) => any;
@ -38,7 +42,6 @@ export interface SelectProps extends AbstractSelectProps {
getPopupContainer?: (triggerNode: Element) => HTMLElement;
dropdownStyle?: React.CSSProperties;
dropdownMenuStyle?: React.CSSProperties;
onChange?: (value: SelectValue) => void;
tokenSeparators?: string[];
getInputElement?: () => React.ReactElement<any>;
}

View File

@ -24,13 +24,13 @@ abstract class TreeSelect extends React.Component<TreeSelectProps, any> {
render() {
const locale = this.getLocale();
const { props } = this;
const {
prefixCls,
className,
size,
notFoundContent = locale.notFoundContent,
dropdownStyle,
...restProps,
} = this.props;
const cls = classNames({
@ -38,17 +38,18 @@ abstract class TreeSelect extends React.Component<TreeSelectProps, any> {
[`${prefixCls}-sm`]: size === 'small',
}, className);
let checkable = props.treeCheckable;
let checkable = restProps.treeCheckable;
if (checkable) {
checkable = <span className={`${prefixCls}-tree-checkbox-inner`} />;
}
return (
<RcTreeSelect
{...props}
{...restProps}
prefixCls={prefixCls}
className={cls}
dropdownStyle={{ maxHeight: '100vh', overflow: 'auto', ...dropdownStyle }}
treeCheckable={checkable}
className={cls}
notFoundContent={notFoundContent}
/>
);

View File

@ -1,30 +1,23 @@
import React from 'react';
import { AbstractSelectProps } from '../select';
export interface TreeData {
key: string;
value: string;
label: React.ReactNode;
children?: Array<TreeData>;
children?: TreeData[];
}
export interface TreeSelectProps {
style?: React.CSSProperties;
export interface TreeSelectProps extends AbstractSelectProps {
value?: string | Array<any>;
defaultValue?: string | Array<any>;
multiple?: boolean;
tags?: boolean;
onSelect?: (value: any) => void;
onChange?: (value: any, label: any) => void;
allowClear?: boolean;
onSearch?: (value: any) => void;
placeholder?: string;
searchPlaceholder?: string;
dropdownStyle?: React.CSSProperties;
dropdownMatchSelectWidth?: boolean;
combobox?: boolean;
size?: 'large' | 'small';
showSearch?: boolean;
disabled?: boolean;
treeDefaultExpandAll?: boolean;
treeCheckable?: boolean | React.ReactNode;
treeDefaultExpandedKeys?: Array<string>;
@ -35,9 +28,6 @@ export interface TreeSelectProps {
treeDataSimpleMode?: boolean | Object;
loadData?: (node: any) => void;
showCheckedStrategy?: 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
className?: string;
prefixCls?: string;
notFoundContent?: React.ReactNode;
labelInValue?: boolean;
treeCheckStrictly?: boolean;
getPopupContainer?: (triggerNode: Element) => HTMLElement;