From 4a3deddc4805168ce51ce434a6a51385b9a41b6d Mon Sep 17 00:00:00 2001 From: Zaighum Ghazali <35923536+zaighumghazali@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:27:54 +0500 Subject: [PATCH 1/5] Update index.js --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 77925dd..3c382d4 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,6 @@ import { Dimensions, TouchableWithoutFeedback, ScrollView, - ViewPropTypes, Platform, } from 'react-native'; import invariant from 'invariant'; @@ -115,7 +114,7 @@ class TagInput extends React.PureComponent, State> { editable: PropTypes.bool, tagColor: PropTypes.string, tagTextColor: PropTypes.string, - tagContainerStyle: ViewPropTypes.style, + tagContainerStyle: PropTypes.object, tagTextStyle: Text.propTypes.style, inputDefaultWidth: PropTypes.number, inputColor: PropTypes.string, @@ -382,8 +381,8 @@ class Tag extends React.PureComponent { removeIndex: PropTypes.func.isRequired, tagColor: PropTypes.string.isRequired, tagTextColor: PropTypes.string.isRequired, - tagContainerStyle: ViewPropTypes.style, - tagTextStyle: Text.propTypes.style, + tagContainerStyle: PropTypes.object, + tagTextStyle: PropTypes.object, showCross: PropTypes.bool.isRequired, }; curPos: ?number = null; From 3c53b469725ffc64364ea558fa26c3b090664791 Mon Sep 17 00:00:00 2001 From: Zaighum Ghazali <35923536+zaighumghazali@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:02:52 +0500 Subject: [PATCH 2/5] Create index.d.ts Added Type Script support --- index.d.ts | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..99206b1 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,93 @@ +declare module 'react-native-tag-input' { + import React, {PureComponent} from 'react' + import {TextInputProps, ScrollView} from 'react-native' + + type StyleObj = Record + + type KeyboardShouldPersistTapsProps = + | 'always' + | 'never' + | 'handled' + | false + | true + + type RequiredProps = { + /** + * An array of tags, which can be any type, as long as labelExtractor below + * can extract a string from it + */ + value: ReadonlyArray + /** + * A handler to be called when array of tags change. The parent should update + * the value prop when this is called if they want to enable removal of tags + */ + onChange: (items: ReadonlyArray) => void + /** + * Function to extract string value for label from item + */ + labelExtractor: (tagData: T) => string | React.ReactNode + /** + * The text currently being displayed in the TextInput following the list of + * tags + */ + text: string + /** + * This callback gets called when the user types in the TextInput. The parent + * should update the text prop when this is called if they want to enable + * input. This is also where any parsing to detect new tags should occur + */ + onChangeText: (text: string) => void + } + + type OptionalProps = { + /** + * If false, text input is not editable and existing tags cannot be removed. + */ + editable: boolean + /** + * Background color of tags + */ + tagColor: string + /** + * Text color of tags + */ + tagTextColor: string + /** + * Styling override for container surrounding tag text + */ + tagContainerStyle?: StyleObj + /** + * Styling override for tag's text component + */ + tagTextStyle?: StyleObj + /** + * Width override for text input's default width when it's empty and showing placeholder + */ + inputDefaultWidth: number + /** + * Color of text input + */ + inputColor: string + /** + * Any misc. TextInput props (autoFocus, placeholder, returnKeyType, etc.) + */ + inputProps?: TextInputProps + /** + * Max height of the tag input on screen (will scroll if max height reached) + */ + maxHeight: number + /** + * Callback that gets passed the new component height when it changes + */ + onHeightChange?: (height: number) => void + /** + * Any ScrollView props (horizontal, showsHorizontalScrollIndicator, etc.) + */ + scrollViewProps?: ScrollView['props'] + } + + type Props = RequiredProps & Partial + + class TagInput extends PureComponent> {} + export default TagInput +} From cde655d2078afdd8efc83929e0cb5cf004bf0947 Mon Sep 17 00:00:00 2001 From: Zaighum Ghazali <35923536+zaighumghazali@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:16:42 +0500 Subject: [PATCH 3/5] Update package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 319f2cd..27f2de7 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,9 @@ ], "license": "MIT", "main": "index.js", + "types": "index.d.ts", "files": [ - "index.js" + "index.js", ], "repository": { "type": "git", From bec5d021292245c0efae32c7b5321d1f3a976776 Mon Sep 17 00:00:00 2001 From: Zaighum Ghazali <35923536+zaighumghazali@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:30:42 +0500 Subject: [PATCH 4/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27f2de7..3c50ab2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "main": "index.js", "types": "index.d.ts", "files": [ - "index.js", + "index.js" ], "repository": { "type": "git", From 9a74379b286c2ee6fa1e5e34676c10c13a1cc40f Mon Sep 17 00:00:00 2001 From: Zaighum Ghazali <35923536+zaighumghazali@users.noreply.github.com> Date: Fri, 18 Aug 2023 17:18:53 +0500 Subject: [PATCH 5/5] Update package.json --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 3c50ab2..462a536 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,6 @@ "license": "MIT", "main": "index.js", "types": "index.d.ts", - "files": [ - "index.js" - ], "repository": { "type": "git", "url": "git@github.com:jwohlfert23/react-native-tag-input.git"