Skip to content

Commit

Permalink
chore: Change AutoCompleteProps to extend SelectProps (ant-design#4565)
Browse files Browse the repository at this point in the history
* Change AutoCompleteProps to extend SelectProps

* Extract common props into AbstractSelectProps
  • Loading branch information
wallverb authored and benjycui committed Jan 12, 2017
1 parent 477fde8 commit c01ee02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
15 changes: 3 additions & 12 deletions components/auto-complete/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Select, { OptionProps, OptGroupProps } from '../select';
import Select, { AbstractSelectProps, OptionProps, OptGroupProps } from '../select';
import { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';

Expand All @@ -11,21 +11,12 @@ export interface SelectedValue {
export interface DataSourceItemObject { value: string; text: string; };
export type DataSourceItemType = string | DataSourceItemObject;

export interface AutoCompleteProps {
size?: 'large' | 'small' | 'default';
className?: string;
notFoundContent?: Element;
export interface AutoCompleteProps extends AbstractSelectProps {
dataSource: DataSourceItemType[];
prefixCls?: string;
transitionName?: string;
optionLabelProp?: string;
choiceTransitionName?: string;
showSearch?: boolean;
defaultValue?: string | Array<any> | SelectedValue | Array<SelectedValue>;
value?: string | Array<any> | SelectedValue | Array<SelectedValue>;
allowClear?: boolean;
onChange?: (value: string | Array<any> | SelectedValue | Array<SelectedValue>) => void;
disabled?: boolean;
onSelect?: (value: string | Array<any> | SelectedValue | Array<SelectedValue>, option: Object) => any;
}

export default class AutoComplete extends React.Component<AutoCompleteProps, any> {
Expand Down
27 changes: 15 additions & 12 deletions components/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@ import classNames from 'classnames';
export type SelectValue = string | any[] | { key: string, label: React.ReactNode } |
Array<{ key: string, label: React.ReactNode }>;

export interface SelectProps {
prefixCls?: string;
className?: string;
value?: SelectValue;
defaultValue?: SelectValue;
export interface AbstractSelectProps {
size?: 'default' | 'large' | 'small';
combobox?: boolean;
className?: string;
notFoundContent?: React.ReactNode | null;
showSearch?: boolean;
prefixCls?: string;
transitionName?: string;
optionLabelProp?: string;
choiceTransitionName?: string;
multiple?: boolean;
showSearch?: boolean;
allowClear?: boolean;
disabled?: boolean;
style?: React.CSSProperties;
placeholder?: string;
}

export interface SelectProps extends AbstractSelectProps {
value?: SelectValue;
defaultValue?: SelectValue;
combobox?: boolean;
multiple?: boolean;
filterOption?: boolean | ((inputValue: string, option: Object) => any);
tags?: boolean;
onSelect?: (value: SelectValue, option: Object) => any;
onDeselect?: (value: SelectValue) => any;
onSearch?: (value: string) => any;
placeholder?: string;
dropdownMatchSelectWidth?: boolean;
optionFilterProp?: string;
optionLabelProp?: string;
disabled?: boolean;
defaultActiveFirstOption?: boolean;
labelInValue?: boolean;
getPopupContainer?: (triggerNode: React.ReactNode) => React.ReactNode | HTMLElement;
style?: React.CSSProperties;
dropdownStyle?: React.CSSProperties;
dropdownMenuStyle?: React.CSSProperties;
onChange?: (value: SelectValue) => void;
Expand Down

0 comments on commit c01ee02

Please sign in to comment.