From 2b528693c27dc9d86e6282dc35b797e74cb48d87 Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Sun, 7 Oct 2018 22:54:16 +0530 Subject: [PATCH 1/6] add typings to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index be8a1d1..5e9bcad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "material-ui-chip-input", "version": "1.0.0-beta.7", + "typings": "typings/index.d.ts", "description": "A chip input field using Material-UI.", "main": "lib/ChipInput.js", "files": [ From b23dc41a6b31e29ae1d3f5824db29782a6c43e7d Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Sun, 7 Oct 2018 22:58:55 +0530 Subject: [PATCH 2/6] add typings --- typings/index.d.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 typings/index.d.ts diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 0000000..031cf2c --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,34 @@ +import * as React from 'react'; + +interface Props { + allowDuplicates?: boolean; + blurBehavior?: 'clear' | 'add' | 'ignore'; + chipRenderer?: (...args: any[]) => any; + clearInputValueOnChange?: boolean; + dataSource?: any[]; + dataSourceConfig?: { + text: string; + value: string; + }; + defaultValue?: any[]; + disabled?: boolean; + FormHelperTextProps?: object; + fullWidth?: boolean; + fullWidthInput?: boolean; + helperText?: React.ReactNode; + InputLabelProps?: object; + InputProps?: object; + inputRef?: (...args: any[]) => any; + label?: React.ReactNode; + newChipKeyCodes?: number[]; + onAdd?: (...args: any[]) => any; + onBeforeAdd?: (...args: any[]) => any; + onChange?: (...args: any[]) => any; + onDelete?: (...args: any[]) => any; + onUpdateInput?: (...args: any[]) => any; + placeholder?: string; + value?: any[]; +} + +declare const ChipInput: React.Component; +export default ChipInput; From e2be07927f6c35c976a09cbcf4a2f115507cf8d4 Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Sun, 7 Oct 2018 23:12:48 +0530 Subject: [PATCH 3/6] add typing on publish --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 5e9bcad..1bfdbba 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "lib/ChipInput.js", "files": [ "lib/**/*.js", + "typings/*.d.ts", "README.md", "LICENSE", "demo.gif" From 50aeb3825be5473d476d6335715e70b59e8d05fc Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Sun, 7 Oct 2018 23:19:04 +0530 Subject: [PATCH 4/6] change component to componentType --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 031cf2c..f374bb0 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -30,5 +30,5 @@ interface Props { value?: any[]; } -declare const ChipInput: React.Component; +declare const ChipInput: React.ComponentType; export default ChipInput; From 68e186451207035ed360ff08b66ba53f64fdd7f2 Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Sun, 7 Oct 2018 23:34:10 +0530 Subject: [PATCH 5/6] add error to types --- typings/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typings/index.d.ts b/typings/index.d.ts index f374bb0..ccf5aa4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -28,6 +28,7 @@ interface Props { onUpdateInput?: (...args: any[]) => any; placeholder?: string; value?: any[]; + error?: boolean; } declare const ChipInput: React.ComponentType; From 64c8c5696268627f38e0968c8572f7231985b49a Mon Sep 17 00:00:00 2001 From: Harshit Pant Date: Mon, 8 Oct 2018 00:28:04 +0530 Subject: [PATCH 6/6] update typings --- typings/index.d.ts | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index ccf5aa4..28009a7 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,9 +1,26 @@ import * as React from 'react'; +import { FormHelperTextProps } from '@material-ui/core/FormHelperText' -interface Props { +export interface ChipRendererArgs { + value: string; + text: string; + chip: string; + isFocused: boolean; + isDisabled: boolean; + handleClick: React.EventHandler; + handleDelete: React.EventHandler; + className: string; +} + +export type ChipRenderer = ( + args: ChipRendererArgs, + key: number +) => React.ReactNode; + +export interface Props { allowDuplicates?: boolean; blurBehavior?: 'clear' | 'add' | 'ignore'; - chipRenderer?: (...args: any[]) => any; + chipRenderer?: ChipRenderer; clearInputValueOnChange?: boolean; dataSource?: any[]; dataSourceConfig?: { @@ -12,20 +29,20 @@ interface Props { }; defaultValue?: any[]; disabled?: boolean; - FormHelperTextProps?: object; + FormHelperTextProps?: FormHelperTextProps; fullWidth?: boolean; fullWidthInput?: boolean; helperText?: React.ReactNode; InputLabelProps?: object; InputProps?: object; - inputRef?: (...args: any[]) => any; + inputRef?: (ref: React.Ref) => any; label?: React.ReactNode; newChipKeyCodes?: number[]; - onAdd?: (...args: any[]) => any; - onBeforeAdd?: (...args: any[]) => any; - onChange?: (...args: any[]) => any; - onDelete?: (...args: any[]) => any; - onUpdateInput?: (...args: any[]) => any; + onAdd?: (chip: string) => any; + onBeforeAdd?: (chip: string) => boolean; + onChange?: (chips: string[]) => any; + onDelete?: (chip:string, index: number) => any; + onUpdateInput?: React.EventHandler placeholder?: string; value?: any[]; error?: boolean;