Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rendering a bottomAccessory in TextField #1737

Merged
merged 1 commit into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ export default class TextFieldScreen extends Component {
placeholder="Enter text..."
multiline
showCharCounter
bottomAccessory={
<Text text100>
{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}
</Text>
}
charCounterStyle={{color: Colors.blue30}}
maxLength={20}
fieldStyle={styles.withFrame}
Expand Down
4 changes: 4 additions & 0 deletions generatedTypes/src/incubator/TextField/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export declare type TextFieldProps = MarginModifiers & PaddingModifiers & Typogr
* Pass to render a trailing element
*/
trailingAccessory?: ReactElement;
/**
* Pass to render a bottom element below the input
*/
bottomAccessory?: ReactElement;
/**
* Pass to add floating placeholder support
*/
Expand Down
3 changes: 3 additions & 0 deletions generatedTypes/src/incubator/TextField/usePreset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
charCounterStyle?: import("react-native").TextStyle | undefined;
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
validateOnStart?: boolean | undefined;
validateOnChange?: boolean | undefined;
validateOnBlur?: boolean | undefined;
Expand Down Expand Up @@ -486,6 +487,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
charCounterStyle?: import("react-native").TextStyle | undefined;
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
validateOnStart?: boolean | undefined;
validateOnChange?: boolean | undefined;
validateOnBlur?: boolean | undefined;
Expand Down Expand Up @@ -1048,6 +1050,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
charCounterStyle?: import("react-native").TextStyle | undefined;
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
validateOnStart?: boolean | undefined;
validateOnChange?: boolean | undefined;
validateOnBlur: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/incubator/TextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export type TextFieldProps = MarginModifiers &
* Pass to render a trailing element
*/
trailingAccessory?: ReactElement;
/**
* Pass to render a bottom element below the input
*/
bottomAccessory?: ReactElement;
/**
* Pass to add floating placeholder support
*/
Expand Down Expand Up @@ -140,6 +144,7 @@ const TextField = (props: InternalTextFieldProps) => {
// Accessory Buttons
leadingAccessory,
trailingAccessory,
bottomAccessory,
// Validation
enableErrors, // TODO: rename to enableValidation
validationMessageStyle,
Expand Down Expand Up @@ -236,6 +241,7 @@ const TextField = (props: InternalTextFieldProps) => {
testID={`${props.testID}.validationMessage`}
/>
)}
{bottomAccessory}
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle}/>}
</View>
</View>
Expand Down