Skip to content

Commit c52194a

Browse files
committed
chore: docs
1 parent 4d4ec65 commit c52194a

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

docs/docusaurus.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ const config = {
170170
TextInputAffix: 'TextInput/Adornment/TextInputAffix',
171171
TextInputIcon: 'TextInput/Adornment/TextInputIcon',
172172
},
173-
TextField: 'TextField/TextField',
173+
TextField: {
174+
TextField: 'TextField/TextField',
175+
TextFieldIcon: 'TextField/TextFieldIcon',
176+
},
174177
ToggleButton: {
175178
ToggleButton: 'ToggleButton/ToggleButton',
176179
ToggleButtonGroup: 'ToggleButton/ToggleButtonGroup',

docs/src/components/PropTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ const typeDefinitions = {
1212
ThemeProp:
1313
'https://callstack.github.io/react-native-paper/docs/guides/theming#theme-properties',
1414
'ComponentType<TextFieldAccessoryProps>':
15-
'https://github.com/callstack/react-native-paper/blob/main/src/components/TextField/TextField.tsx#L21',
15+
'https://github.com/callstack/react-native-paper/blob/main/src/components/TextField/TextField.tsx#L20',
1616
AccessibilityState:
1717
'https://reactnative.dev/docs/accessibility#accessibilitystate',
1818
'StyleProp<ViewStyle>': 'https://reactnative.dev/docs/view-style-props',
1919
'StyleProp<TextStyle>': 'https://reactnative.dev/docs/text-style-props',
2020
TextProps: 'https://reactnative.dev/docs/text#props',
21+
AccessibilityProps:
22+
'https://reactnative.dev/docs/accessibility#accessibilityprops',
2123
};
2224

2325
const renderBadge = (annotation: string) => {

src/components/TextField/TextField.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ export interface TextFieldProps extends TextInputProps {
128128
* <TextField.Icon {...props} icon="magnify" />
129129
* );
130130
*
131-
* const ClearIcon = (props) => (
132-
* <TextField.Icon {...props} icon="close" onPress={() => setText('')} />
131+
* const ClearAccessory = ({ style, editable }) => (
132+
* <Pressable
133+
* style={style}
134+
* disabled={!editable}
135+
* onPress={() => setText('')}
136+
* accessibilityRole="button"
137+
* accessibilityLabel="Clear text"
138+
* >
139+
* <Icon source="close" size={24} />
140+
* </Pressable>
133141
* );
134142
*
135143
* return (
@@ -138,7 +146,7 @@ export interface TextFieldProps extends TextInputProps {
138146
* value={text}
139147
* onChangeText={setText}
140148
* StartAccessory={SearchIcon}
141-
* EndAccessory={ClearIcon}
149+
* EndAccessory={ClearAccessory}
142150
* />
143151
* );
144152
* };

src/components/TextField/TextFieldIcon.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ export interface TextFieldIconProps extends TextFieldAccessoryProps {
3131
/**
3232
* Function to execute on press.
3333
*/
34-
onPress?: (e: GestureResponderEvent) => void;
34+
onPress?: (event: GestureResponderEvent) => void;
3535
}
3636

3737
/**
38-
* A pre-built accessory component that renders an icon button inside a TextField.
39-
* Accepts all `TextFieldAccessoryProps` (passed automatically by the parent) plus
40-
* icon-specific props.
38+
* A component to render a leading / trailing icon in the TextField
39+
* (inside `StartAccessory` or `EndAccessory`). Accepts icon-specific props as well as
40+
* `TextFieldAccessoryProps`, which TextField forwards automatically.
4141
*
4242
* ## Usage
4343
* ```js
@@ -72,7 +72,7 @@ export interface TextFieldIconProps extends TextFieldAccessoryProps {
7272
const TextFieldIcon = ({
7373
icon,
7474
color,
75-
size = ACCESSORY_SIZE,
75+
size,
7676
style,
7777
status,
7878
editable,
@@ -82,6 +82,8 @@ const TextFieldIcon = ({
8282
}: TextFieldIconProps) => {
8383
const theme = useInternalTheme(themeOverride);
8484

85+
const iconSize = size ?? ACCESSORY_SIZE;
86+
8587
const iconColor = getIconColor({
8688
theme,
8789
color,
@@ -95,7 +97,7 @@ const TextFieldIcon = ({
9597
<IconButton
9698
icon={icon}
9799
iconColor={iconColor}
98-
size={size}
100+
size={iconSize}
99101
style={$iconStyle}
100102
onPress={onPressHandler}
101103
{...accessibility}

0 commit comments

Comments
 (0)