Skip to content

Commit f7a439d

Browse files
authored
TextField and Switch/ forward id prop (#2608)
* TextField: forward containerId prop * code-review * code-review
1 parent c3b931f commit f7a439d

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

src/components/switch/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export type SwitchProps = {
5656
thumbStyle?: StyleProp<ViewStyle>;
5757
style?: StyleProp<ViewStyle>;
5858
testID?: string;
59+
id?: string;
5960
}
6061

6162
/**

src/components/switch/switch.api.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
{"name": "thumbSize", "type": "number", "description": "The Switch's thumb size (width & height)"},
2626
{"name": "thumbStyle", "type": "ViewStyle", "description": "The Switch's thumb style"},
2727
{"name": "style", "type": "ViewStyle", "description": "Custom style"},
28-
{"name": "testID", "type": "string", "description": "Component test id"}
28+
{"name": "testID", "type": "string", "description": "Component test id"},
29+
{"name": "id", "type": "string", "description": "Component id"}
2930
],
3031
"snippet": [
3132
"<Switch value={false$1} onValueChange={() => console.log('value changed')$2}/>"

src/incubator/TextField/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const TextField = (props: InternalTextFieldProps) => {
4646
const {
4747
modifiers,
4848
// General
49+
containerProps,
4950
fieldStyle: fieldStyleProp,
5051
dynamicFieldStyle,
5152
containerStyle,
@@ -123,7 +124,7 @@ const TextField = (props: InternalTextFieldProps) => {
123124

124125
return (
125126
<FieldContext.Provider value={context}>
126-
<View style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
127+
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
127128
<Label
128129
label={label}
129130
labelColor={labelColor}

src/incubator/TextField/textField.api.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"type": "ViewStyle | (context: FieldContextType, props) => ViewStyle",
5757
"description": "Internal style for the field container to style the field underline, outline and fill color"
5858
},
59+
{"name": "containerProps", "type": "Omit<ViewProps, 'style'>", "description": "Container props of the whole component"},
5960
{"name": "containerStyle", "type": "ViewStyle", "description": "Container style of the whole component"},
6061
{
6162
"name": "preset",

src/incubator/TextField/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '../../commons/new';
1111
import {TextProps} from '../../components/text';
1212
import {PropsWithChildren, ReactElement} from 'react';
13+
import {ViewProps} from '../../components/view';
1314

1415
export type ColorType =
1516
| string
@@ -216,6 +217,10 @@ export type TextFieldProps = MarginModifiers &
216217
* Internal dynamic style callback for the field container
217218
*/
218219
dynamicFieldStyle?: (context: FieldContextType, props: {preset: TextFieldProps['preset']}) => StyleProp<ViewStyle>;
220+
/**
221+
* Pass props to the container
222+
*/
223+
containerProps?: Omit<ViewProps, 'style'>;
219224
/**
220225
* Container style of the whole component
221226
*/

0 commit comments

Comments
 (0)