Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 2be0b76

Browse files
committed
Allow text input container to be styled.
1 parent d8d1d6d commit 2be0b76

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ const UselessComponent = () => (
4040

4141
## Props
4242

43-
| PropName | Description | Default |
44-
| ----------------- | ------------------------------------------ | -------- |
45-
| initialText | The input element's text | |
46-
| initialTags | ['the', 'initial', 'tags'] | |
47-
| onChangeTags | Fires when tags are added or removed | |
48-
| maxNumberOfTags | The max number of tags that can be entered | infinity |
49-
| onTagPress | Fires when tags are pressed | |
50-
| readonly | Tags cannot be modified | false |
51-
| deleteTagOnPress | Remove the tag when pressed | true |
52-
| containerStyle | Style | |
53-
| style | Style (`containerStyle` alias) | |
54-
| inputStyle | Style | |
55-
| tagContainerStyle | Style | |
56-
| tagTextStyle | Style | |
43+
| PropName | Description | Default |
44+
| ------------------- | ------------------------------------------ | -------- |
45+
| initialText | The input element's text | |
46+
| initialTags | ['the', 'initial', 'tags'] | |
47+
| onChangeTags | Fires when tags are added or removed | |
48+
| maxNumberOfTags | The max number of tags that can be entered | infinity |
49+
| onTagPress | Fires when tags are pressed | |
50+
| readonly | Tags cannot be modified | false |
51+
| deleteTagOnPress | Remove the tag when pressed | true |
52+
| containerStyle | Style | |
53+
| style | Style (`containerStyle` alias) | |
54+
| inputContainerStyle | Style | |
55+
| inputStyle | Style | |
56+
| tagContainerStyle | Style | |
57+
| tagTextStyle | Style | |

Tags/__tests__/__snapshots__/Tags-tests.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ exports[`Tags should render props correctly 1`] = `
172172
"margin": 4,
173173
"minWidth": 100,
174174
},
175+
undefined,
175176
]
176177
}
177178
>

Tags/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import PropTypes from "prop-types";
3-
import { View, Text, TextInput, TouchableOpacity } from "react-native";
3+
import { View, TextInput, ViewPropTypes } from "react-native";
44

55
import Tag from "./Tag";
66
import styles from "./styles";
@@ -65,7 +65,8 @@ class Tags extends React.Component {
6565
onTagPress,
6666
readonly,
6767
maxNumberOfTags,
68-
inputStyle
68+
inputStyle,
69+
inputContainerStyle
6970
} = this.props;
7071

7172
return (
@@ -101,7 +102,7 @@ class Tags extends React.Component {
101102

102103
{!readonly &&
103104
maxNumberOfTags > this.state.tags.length && (
104-
<View style={[styles.textInputContainer]}>
105+
<View style={[styles.textInputContainer, inputContainerStyle]}>
105106
<TextInput
106107
value={this.state.text}
107108
style={[styles.textInput, inputStyle]}
@@ -127,14 +128,15 @@ Tags.propTypes = {
127128
initialText: PropTypes.string,
128129
initialTags: PropTypes.arrayOf(PropTypes.string),
129130
onChangeTags: PropTypes.func,
130-
containerStyle: PropTypes.object,
131-
style: PropTypes.object,
132-
inputStyle: PropTypes.object,
133-
tagContainerStyle: PropTypes.object,
134-
tagTextStyle: PropTypes.object,
135131
readonly: PropTypes.bool,
136132
maxNumberOfTags: PropTypes.number,
137-
deleteOnTagPress: PropTypes.bool
133+
deleteOnTagPress: PropTypes.bool,
134+
containerStyle: ViewPropTypes.style,
135+
style: ViewPropTypes.style,
136+
inputContainerStyle: ViewPropTypes.style,
137+
inputStyle: ViewPropTypes.style,
138+
tagContainerStyle: ViewPropTypes.style,
139+
tagTextStyle: ViewPropTypes.style
138140
};
139141

140142
export { Tag };

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"author": "Peter Pistorius <peter.pistorius@gmail.com> (http://github.com/peterp/)",
1515
"license": "MIT",
1616
"peerDependencies": {
17-
"react": "*",
18-
"react-native": "*"
17+
"react": ">= 16.0",
18+
"react-native": ">= 0.44"
1919
},
2020
"devDependencies": {
2121
"babel-jest": "^22.4.3",

0 commit comments

Comments
 (0)