Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
Fix ClassKey inference for outlined and filled variants (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotros authored and leMaik committed Oct 6, 2019
1 parent 0374100 commit 93c79e0
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import { FormControlProps } from '@material-ui/core/FormControl';
import { FormHelperTextProps } from '@material-ui/core/FormHelperText';
import { InputProps } from '@material-ui/core/Input';
import { InputProps as StandardInputProps } from '@material-ui/core/Input';
import { FilledInputProps } from '@material-ui/core/FilledInput';
import { OutlinedInputProps } from '@material-ui/core/OutlinedInput';
import { InputLabelProps } from '@material-ui/core/InputLabel';

export interface ChipRendererArgs {
Expand All @@ -25,7 +27,7 @@ export type ChipRenderer = (
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;

// omitting onChange from FormControlProps as we use a custom onChange
export interface Props extends Omit<FormControlProps, 'onChange'> {
export interface BaseTextFieldProps extends Omit<FormControlProps, 'onChange'> {
allowDuplicates?: boolean;
alwaysShowPlaceholder?: boolean;
blurBehavior?: 'clear' | 'add' | 'ignore';
Expand All @@ -45,21 +47,37 @@ export interface Props extends Omit<FormControlProps, 'onChange'> {
fullWidthInput?: boolean;
helperText?: React.ReactNode;
InputLabelProps?: InputLabelProps;
InputProps?: InputProps;
inputRef?: (ref: React.Ref<HTMLInputElement>) => any;
inputValue?: string;
label?: React.ReactNode;
newChipKeyCodes?: number[];
onAdd?: (chip: any) => any;
onBeforeAdd?: (chip: any) => boolean;
onChange?: (chips: any[]) => any;
onDelete?: (chip:any, index: number) => any;
onDelete?: (chip: any, index: number) => any;
onUpdateInput?: React.EventHandler<any>;
placeholder?: string;
readOnly?: boolean;
value?: any[];
variant?: 'outlined' | 'standard' | 'filled';
}

export interface StandardTextFieldProps extends BaseTextFieldProps {
variant?: 'standard';
InputProps?: Partial<StandardInputProps>;
}

export interface FilledTextFieldProps extends BaseTextFieldProps {
variant: 'filled';
InputProps?: Partial<FilledInputProps>;
}

export interface OutlinedTextFieldProps extends BaseTextFieldProps {
variant: 'outlined';
InputProps?: Partial<OutlinedInputProps>;
}

export type Props = StandardTextFieldProps | FilledTextFieldProps | OutlinedTextFieldProps;

declare const ChipInput: React.ComponentType<Props>;
export default ChipInput;

0 comments on commit 93c79e0

Please sign in to comment.