Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,25 @@ type CategorizedGroup = {

type CategorizedGroupOrOption = CategorizedGroup | CategorizedOption;

type CommonProps = {
cx(...args: any): string,
clearValue(): void,
getStyles(key: string, props: {}): {},
getValue(): OptionsType,
hasValue: boolean,
isMulti: boolean,
isRtl: boolean,
options: OptionsType,
selectOption(newValue: OptionType): void,
setValue(
newValue: ValueType,
action?: ActionTypes,
option?: OptionType
): void,
selectProps: Props,
theme: typeof defaultTheme,
};

function toCategorizedOption(
props: Props,
option: OptionType,
Expand Down Expand Up @@ -488,7 +507,7 @@ export default class Select extends Component<Props, State> {

blockOptionHover: boolean = false;
isComposing: boolean = false;
commonProps: any; // TODO
commonProps: CommonProps;
initialTouchX: number = 0;
initialTouchY: number = 0;
instancePrefix: string = '';
Expand Down Expand Up @@ -929,7 +948,7 @@ export default class Select extends Component<Props, State> {

cx = (...args: any) => classNames(this.props.classNamePrefix, ...args);

getCommonProps() {
getCommonProps(): $Exact<CommonProps> {
const {
clearValue,
cx,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/src/components/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ComponentProps = {
/** Props to pass to Heading. */
headingProps: any,
/** Props to be passed to the group element. */
innerProps: {},
innerProps?: {},
/** Label to be displayed in the heading component. */
label: Node,
};
Expand Down
12 changes: 6 additions & 6 deletions packages/react-select/src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ export function getMenuPlacement({

export type MenuAndPlacerCommon = CommonProps & {
/** Callback to update the portal after possible flip. */
getPortalPlacement: MenuState => void,
getPortalPlacement?: MenuState => void,
/** Props to be passed to the menu wrapper. */
innerProps: {},
innerProps?: {},
/** Set the maximum height of the menu. */
maxMenuHeight: number,
/** Set whether the menu should be at the top, at the bottom. The auto options sets it to bottom. */
Expand All @@ -231,7 +231,7 @@ export type MenuProps = MenuAndPlacerCommon & {
};
export type MenuPlacerProps = MenuAndPlacerCommon & {
/** The children to be rendered. */
children: ({}) => Node,
children: ({ ref: any, placerProps: any }) => Node,
};

function alignToControl(placement) {
Expand Down Expand Up @@ -351,7 +351,7 @@ export type MenuListProps = {
/** Inner ref to DOM Node */
innerRef: InnerRef,
/** Props to be passed to the menu-list wrapper. */
innerProps: {},
innerProps?: {},
};
export type MenuListComponentProps = CommonProps &
MenuListProps &
Expand Down Expand Up @@ -418,7 +418,7 @@ export type NoticeProps = CommonProps & {
/** The children to be rendered. */
children: Node,
/** Props to be passed on to the wrapper. */
innerProps: {},
innerProps?: {},
};

export const NoOptionsMessage = (props: NoticeProps) => {
Expand Down Expand Up @@ -473,7 +473,7 @@ export type MenuPortalProps = CommonProps & {
appendTo: HTMLElement,
children: Node, // ideally Menu<MenuProps>
controlElement: HTMLElement,
innerProps: {},
innerProps?: {},
menuPlacement: MenuPlacement,
menuPosition: MenuPosition,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/react-select/src/components/MultiValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { CommonProps } from '../types';
export type MultiValueProps = CommonProps & {
children: Node,
components: any,
cropWithEllipsis: boolean,
cropWithEllipsis?: boolean,
data: any,
innerProps: any,
innerProps?: {},
isFocused: boolean,
isDisabled: boolean,
removeProps: {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-select/src/components/Option.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type State = {
};
type InnerProps = {
id: string,
key: string,
onClick: MouseEventHandler,
onMouseOver: MouseEventHandler,
key?: string,
onClick?: MouseEventHandler,
onMouseOver?: MouseEventHandler,
tabIndex: number,
};
export type OptionProps = PropsWithStyles &
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/src/components/Placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type PlaceholderProps = CommonProps & {
/** The children to be rendered. */
children: Node,
/** props passed to the wrapping element for the group. */
innerProps: { [string]: any },
innerProps?: {},
};

export const placeholderCSS = ({
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/src/components/SingleValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ValueProps = {
/* The data of the selected option rendered in the Single Value component. */
data: any,
/** Props passed to the wrapping element for the group. */
innerProps: any,
innerProps?: {},
};
export type SingleValueProps = CommonProps & ValueProps & State;

Expand Down
6 changes: 3 additions & 3 deletions packages/react-select/src/components/indicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export const DownChevron = (props: any) => (

export type IndicatorProps = CommonProps & {
/** The children to be rendered inside the indicator. */
children: Node,
children?: Node,
/** Props that will be passed on to the children. */
innerProps: any,
innerProps?: {},
/** The focused state of the select. */
isFocused: boolean,
/** Whether the text is right to left */
Expand Down Expand Up @@ -202,7 +202,7 @@ export type LoadingIconProps = {
isRtl: boolean,
} & CommonProps & {
/** Set size of the container. */
size: number,
size?: number,
};
export const LoadingIndicator = (props: LoadingIconProps) => {
const { className, cx, getStyles, innerProps, isRtl } = props;
Expand Down