Skip to content

Commit 07d17d6

Browse files
committed
Include all Incubator.TextField internal components in docs
1 parent 8e572e4 commit 07d17d6

File tree

8 files changed

+85
-5
lines changed

8 files changed

+85
-5
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React from 'react';
22
import Button, {ButtonPropTypes} from '../../components/button';
33

4-
export default (props: ButtonPropTypes) => {
4+
const AccessoryButton = (props: ButtonPropTypes) => {
55
return (
66
<Button link grey10 activeOpacity={props.onPress ? 0.6 : 1} {...props} />
77
);
88
};
9+
10+
AccessoryButton.displayName = 'Incubator.TextField';
11+
export default AccessoryButton;

src/incubator/TextField/CharCounter.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ import Text from '../../components/text';
55
import FieldContext from './FieldContext';
66

77
export interface CharCounterProps {
8+
/**
9+
* Should show a character counter (works only with maxLength)
10+
*/
811
showCharCounter?: boolean;
912
maxLength?: number;
13+
/**
14+
* Pass custom style to character counter text
15+
*/
1016
charCounterStyle?: TextStyle;
1117
}
1218

13-
export default ({maxLength, charCounterStyle}: CharCounterProps) => {
19+
const CharCounter = ({maxLength, charCounterStyle}: CharCounterProps) => {
1420
const {value} = useContext(FieldContext);
1521

1622
if (_.isUndefined(maxLength)) {
@@ -30,3 +36,6 @@ const styles = StyleSheet.create({
3036
textAlign: 'right'
3137
}
3238
});
39+
40+
CharCounter.displayName = 'Incubator.TextField';
41+
export default CharCounter;

src/incubator/TextField/FloatingPlaceholder.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@ import Text from '../../components/text';
1616
import FieldContext from './FieldContext';
1717

1818
export interface FloatingPlaceholderProps {
19+
/**
20+
* The placeholder for the field
21+
*/
1922
placeholder?: string;
23+
/**
24+
* The floating placeholder color
25+
*/
2026
floatingPlaceholderColor?: ColorType;
27+
/**
28+
* Custom style to pass to the floating placeholder
29+
*/
2130
floatingPlaceholderStyle?: TextStyle;
2231
}
2332

2433
const FLOATING_PLACEHOLDER_SCALE = 0.875;
2534

26-
export default ({placeholder, floatingPlaceholderColor = Colors.grey40, floatingPlaceholderStyle}: FloatingPlaceholderProps) => {
35+
const FloatingPlaceholder = ({placeholder, floatingPlaceholderColor = Colors.grey40, floatingPlaceholderStyle}: FloatingPlaceholderProps) => {
2736
const context = useContext(FieldContext);
2837
const [placeholderOffset, setPlaceholderOffset] = useState({
2938
top: 0,
@@ -97,3 +106,6 @@ function interpolateValue(
97106
outputRange
98107
});
99108
}
109+
110+
FloatingPlaceholder.displayName = 'Incubator.TextField';
111+
export default FloatingPlaceholder;

src/incubator/TextField/Input.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {Constants} from '../../helpers'
55
import FieldContext from './FieldContext';
66

77
export interface InputProps extends TextInputProps, React.ComponentPropsWithRef<typeof TextInput> {
8+
/**
9+
* A hint text to display when focusing the field
10+
*/
811
hint?: string;
912
}
1013

@@ -23,7 +26,6 @@ const Input = ({style, hint, forwardedRef, ...props}: InputProps & ForwardRefInj
2326
);
2427
};
2528

26-
export default Input;
2729

2830
const styles = StyleSheet.create({
2931
input: {
@@ -40,3 +42,6 @@ const styles = StyleSheet.create({
4042
})
4143
}
4244
});
45+
46+
Input.displayName = 'Incubator.TextField';
47+
export default Input;

src/incubator/TextField/Label.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@ import {getColorByState} from './Presenter';
77
import FieldContext from './FieldContext';
88

99
export interface LabelProps {
10+
/**
11+
* Field label
12+
*/
1013
label?: string;
14+
/**
15+
* Field label color. Either a string or color by state map ({default, focus, error, disabled})
16+
*/
1117
labelColor?: ColorType;
18+
/**
19+
* Custom style for the field label
20+
*/
1221
labelStyle?: TextStyle;
22+
/**
23+
* Pass extra props to the label Text element
24+
*/
1325
labelProps?: TextPropTypes;
1426
validationMessagePosition?: ValidationMessagePosition;
1527
}
1628

17-
export default ({
29+
const Label = ({
1830
label,
1931
labelColor = Colors.grey10,
2032
labelStyle,
@@ -41,3 +53,6 @@ export default ({
4153

4254
return null;
4355
};
56+
57+
Label.displayName = 'Incubator.TextField';
58+
export default Label;

src/incubator/TextField/ValidationMessage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import Text from '../../components/text';
44
import FieldContext from './FieldContext';
55

66
export interface ValidationMessageProps {
7+
/**
8+
* Should support showing validation error message
9+
*/
710
enableErrors?: boolean;
11+
/**
12+
* The validation message to display when field is invalid (depends on validate)
13+
*/
814
validationMessage?: string;
915
validationMessageStyle?: TextStyle;
1016
retainSpace?: boolean;

src/incubator/TextField/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,33 @@ interface TextFieldProps
3030
FieldStateProps,
3131
ValidationMessageProps,
3232
Omit<CharCounterProps, 'maxLength'> {
33+
/**
34+
* Pass to render a leading button/icon
35+
*/
3336
leadingButton?: ButtonPropTypes;
37+
/**
38+
* Pass to render a trailing button/icon
39+
*/
3440
trailingButton?: ButtonPropTypes;
41+
/**
42+
* Pass to add floating placeholder support
43+
*/
3544
floatingPlaceholder?: boolean;
45+
/**
46+
* Custom style for the floating placeholder
47+
*/
3648
floatingPlaceholderStyle?: TextStyle;
49+
/**
50+
* The position of the validation message (top/bottom)
51+
*/
3752
validationMessagePosition?: ValidationMessagePosition;
53+
/**
54+
* Internal style for the field container
55+
*/
3856
fieldStyle?: ViewStyle;
57+
/**
58+
* Container style of the whole component
59+
*/
3960
containerStyle?: ViewStyle;
4061
}
4162

@@ -48,6 +69,12 @@ interface StaticMembers {
4869
validationMessagePositions: typeof ValidationMessagePosition;
4970
}
5071

72+
/**
73+
* @description: TextField component with validation and customization API
74+
* @extends: TextInput
75+
* @extendslink: https://reactnative.dev/docs/textinput
76+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/IncubatorTextFieldScreen.tsx
77+
*/
5178
const TextField = (
5279
{
5380
// General

src/incubator/TextField/withFieldState.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export interface FieldStateProps extends TextInputProps {
2525
validateOnStart?: boolean;
2626
validateOnChange?: boolean;
2727
validateOnBlur?: boolean;
28+
/**
29+
* A single or multiple validator. Can be a string (required, email) or custom function.
30+
*/
2831
validate?: Validator | Validator[];
2932
}
3033

0 commit comments

Comments
 (0)