@react-native-ama/forms 1.2.1 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/components/Form.d.ts +5 -2
  2. package/dist/components/Form.js +14 -31
  3. package/dist/components/FormSubmit.d.ts +7 -9
  4. package/dist/components/FormSubmit.js +2 -14
  5. package/dist/components/TextInput.d.ts +36 -4
  6. package/dist/components/TextInput.js +20 -73
  7. package/dist/hooks/useFocus.d.ts +4 -0
  8. package/dist/hooks/useFocus.js +69 -0
  9. package/dist/hooks/useFormField.d.ts +1 -7
  10. package/dist/hooks/useFormField.js +32 -25
  11. package/dist/hooks/useFormSubmit.d.ts +4 -0
  12. package/dist/hooks/useFormSubmit.js +14 -0
  13. package/dist/hooks/useTextInput.d.ts +59 -231
  14. package/dist/hooks/useTextInput.js +2 -37
  15. package/dist/index.d.ts +9 -12
  16. package/dist/index.js +3 -8
  17. package/dist/utils/checkFocusTrap.d.ts +8 -0
  18. package/dist/utils/checkFocusTrap.js +30 -0
  19. package/package.json +59 -18
  20. package/src/components/Form.test.tsx +63 -70
  21. package/src/components/Form.tsx +28 -52
  22. package/src/components/FormField.test.tsx +32 -16
  23. package/src/components/FormField.tsx +0 -1
  24. package/src/components/FormSubmit.test.tsx +17 -55
  25. package/src/components/FormSubmit.tsx +9 -36
  26. package/src/components/TextInput.test.tsx +83 -397
  27. package/src/components/TextInput.tsx +41 -109
  28. package/src/hooks/useFocus.test.ts +130 -0
  29. package/src/hooks/useFocus.ts +62 -0
  30. package/src/hooks/useFormField.test.tsx +183 -78
  31. package/src/hooks/useFormField.ts +36 -28
  32. package/src/hooks/useFormSubmit.test.tsx +18 -0
  33. package/src/hooks/useFormSubmit.ts +17 -0
  34. package/src/hooks/useTextInput.ts +10 -55
  35. package/src/index.ts +14 -19
  36. package/src/utils/checkFocusTrap.test.ts +80 -0
  37. package/src/utils/checkFocusTrap.ts +40 -0
  38. package/dist/components/FormSwitch.d.ts +0 -4
  39. package/dist/components/FormSwitch.js +0 -15
  40. package/src/components/FormSwitch.tsx +0 -17
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import type { LayoutChangeEvent, NativeSyntheticEvent, ReturnKeyTypeOptions, StyleProp, TextInputSubmitEditingEventData, TextStyle, ViewStyle } from 'react-native';
3
+ import { TextInputProps } from '../components/TextInput';
3
4
  import { UseFormField } from './useFormField';
4
5
  export type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
5
6
  onLayout?: (event: LayoutChangeEvent) => void;
6
7
  returnKeyType?: ReturnKeyTypeOptions;
7
8
  onSubmitEditing?: (event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void;
8
- accessibilityLabel: string;
9
+ accessibilityLabel?: string;
9
10
  editable?: boolean;
10
11
  style?: ViewStyle | StyleProp<TextStyle> | null;
11
12
  required: boolean;
@@ -15,108 +16,27 @@ export type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
15
16
  errorMessage?: string;
16
17
  };
17
18
  export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing, accessibilityLabel, requiredMessage, required, ...rest }: UseTextInput) => {
18
- style: any;
19
- allowFontScaling?: boolean | undefined;
20
- autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
21
- autoComplete?: "off" | "additional-name" | "address-line1" | "address-line2" | "birthdate-day" | "birthdate-full" | "birthdate-month" | "birthdate-year" | "cc-csc" | "cc-exp" | "cc-exp-day" | "cc-exp-month" | "cc-exp-year" | "cc-number" | "cc-name" | "cc-given-name" | "cc-middle-name" | "cc-family-name" | "cc-type" | "country" | "current-password" | "email" | "family-name" | "gender" | "given-name" | "honorific-prefix" | "honorific-suffix" | "name" | "name-family" | "name-given" | "name-middle" | "name-middle-initial" | "name-prefix" | "name-suffix" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "password" | "password-new" | "postal-address" | "postal-address-country" | "postal-address-extended" | "postal-address-extended-postal-code" | "postal-address-locality" | "postal-address-region" | "postal-code" | "street-address" | "sms-otp" | "tel" | "tel-country-code" | "tel-national" | "tel-device" | "url" | "username" | "username-new" | undefined;
22
- autoCorrect?: boolean | undefined;
23
- autoFocus?: boolean | undefined;
24
- blurOnSubmit?: boolean | undefined;
25
- submitBehavior?: import("react-native").SubmitBehavior | undefined;
26
- caretHidden?: boolean | undefined;
27
- contextMenuHidden?: boolean | undefined;
28
- defaultValue?: string | undefined;
19
+ children?: React.ReactNode;
20
+ style?: ViewStyle | undefined;
21
+ value?: string | undefined;
22
+ id?: string | undefined;
23
+ accessibilityHint: string;
29
24
  editable?: boolean | undefined;
30
- keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
31
- inputMode?: import("react-native").InputModeOptions | undefined;
32
- maxLength?: number | undefined;
33
- multiline?: boolean | undefined;
25
+ rejectResponderTermination?: boolean | null | undefined;
26
+ focusable?: boolean | undefined;
27
+ hitSlop?: number | import("react-native").Insets | null | undefined;
34
28
  onBlur?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
35
- onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
36
- onChangeText?: ((text: string) => void) | undefined;
37
- onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
38
- onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
29
+ onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
30
+ onLayout?: (((event: LayoutChangeEvent) => void) & ((event: LayoutChangeEvent) => void)) | undefined;
39
31
  onPress?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
40
32
  onPressIn?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
41
33
  onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
42
- onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
43
- onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
44
- onSubmitEditing?: (((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) & ((event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)) | undefined;
45
- onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
46
- onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
47
- placeholder?: string | undefined;
48
- placeholderTextColor?: import("react-native").ColorValue | undefined;
49
- readOnly?: boolean | undefined;
50
- returnKeyType?: ReturnKeyTypeOptions | undefined;
51
- enterKeyHint?: import("react-native").EnterKeyHintTypeOptions | undefined;
52
- secureTextEntry?: boolean | undefined;
53
- selectTextOnFocus?: boolean | undefined;
54
- selection?: {
55
- start: number;
56
- end?: number | undefined;
57
- } | undefined;
58
- selectionColor?: import("react-native").ColorValue | undefined;
59
- textAlign?: "center" | "left" | "right" | undefined;
60
34
  testID?: string | undefined;
61
- inputAccessoryViewID?: string | undefined;
62
- value?: string | undefined;
63
- maxFontSizeMultiplier?: number | null | undefined;
64
- children?: React.ReactNode;
65
- hitSlop?: number | import("react-native").Insets | null | undefined;
66
- id?: string | undefined;
67
- needsOffscreenAlphaCompositing?: boolean | undefined;
68
- onLayout?: (((event: LayoutChangeEvent) => void) & ((event: LayoutChangeEvent) => void)) | undefined;
69
- pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
70
- removeClippedSubviews?: boolean | undefined;
71
- nativeID?: string | undefined;
72
- collapsable?: boolean | undefined;
73
- collapsableChildren?: boolean | undefined;
74
- renderToHardwareTextureAndroid?: boolean | undefined;
75
- focusable?: boolean | undefined;
76
- tabIndex?: 0 | -1 | undefined;
77
- shouldRasterizeIOS?: boolean | undefined;
78
- isTVSelectable?: boolean | undefined;
79
- hasTVPreferredFocus?: boolean | undefined;
80
- tvParallaxShiftDistanceX?: number | undefined;
81
- tvParallaxShiftDistanceY?: number | undefined;
82
- tvParallaxTiltAngle?: number | undefined;
83
- tvParallaxMagnification?: number | undefined;
84
- onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
85
- onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
86
- onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
87
- onResponderGrant?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
88
- onResponderReject?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
89
- onResponderMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
90
- onResponderRelease?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
91
- onResponderStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
92
- onResponderTerminationRequest?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
93
- onResponderTerminate?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
94
- onStartShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
95
- onMoveShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
96
- onTouchStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
97
- onTouchMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
98
- onTouchEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
99
- onTouchCancel?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
100
- onTouchEndCapture?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
101
- onPointerEnter?: ((event: import("react-native").PointerEvent) => void) | undefined;
102
- onPointerEnterCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
103
- onPointerLeave?: ((event: import("react-native").PointerEvent) => void) | undefined;
104
- onPointerLeaveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
105
- onPointerMove?: ((event: import("react-native").PointerEvent) => void) | undefined;
106
- onPointerMoveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
107
- onPointerCancel?: ((event: import("react-native").PointerEvent) => void) | undefined;
108
- onPointerCancelCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
109
- onPointerDown?: ((event: import("react-native").PointerEvent) => void) | undefined;
110
- onPointerDownCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
111
- onPointerUp?: ((event: import("react-native").PointerEvent) => void) | undefined;
112
- onPointerUpCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
113
35
  accessible?: boolean | undefined;
114
36
  accessibilityActions?: readonly Readonly<{
115
37
  name: string;
116
38
  label?: string | undefined;
117
39
  }>[] | undefined;
118
- accessibilityLabel?: string | undefined;
119
- 'aria-label'?: string | undefined;
120
40
  accessibilityRole?: import("react-native").AccessibilityRole | undefined;
121
41
  accessibilityState?: import("react-native").AccessibilityState | undefined;
122
42
  'aria-busy'?: boolean | undefined;
@@ -124,7 +44,6 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
124
44
  'aria-disabled'?: boolean | undefined;
125
45
  'aria-expanded'?: boolean | undefined;
126
46
  'aria-selected'?: boolean | undefined;
127
- accessibilityHint: string;
128
47
  accessibilityValue?: import("react-native").AccessibilityValue | undefined;
129
48
  'aria-valuemax'?: number | undefined;
130
49
  'aria-valuemin'?: number | undefined;
@@ -148,106 +67,13 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
148
67
  accessibilityLanguage?: string | undefined;
149
68
  accessibilityShowsLargeContentViewer?: boolean | undefined;
150
69
  accessibilityLargeContentTitle?: string | undefined;
151
- clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
152
- clearTextOnFocus?: boolean | undefined;
153
- dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
154
- enablesReturnKeyAutomatically?: boolean | undefined;
155
- keyboardAppearance?: "default" | "light" | "dark" | undefined;
156
- passwordRules?: string | null | undefined;
157
- rejectResponderTermination?: boolean | null | undefined;
158
- selectionState?: import("react-native").DocumentSelectionState | undefined;
159
- spellCheck?: boolean | undefined;
160
- textContentType?: "none" | "name" | "nickname" | "password" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "creditCardExpiration" | "creditCardExpirationMonth" | "creditCardExpirationYear" | "creditCardSecurityCode" | "creditCardType" | "creditCardName" | "creditCardGivenName" | "creditCardMiddleName" | "creditCardFamilyName" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "location" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "newPassword" | "oneTimeCode" | "birthdate" | "birthdateDay" | "birthdateMonth" | "birthdateYear" | undefined;
161
- scrollEnabled?: boolean | undefined;
162
- lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined;
163
- smartInsertDelete?: boolean | undefined;
164
- cursorColor?: import("react-native").ColorValue | null | undefined;
165
- selectionHandleColor?: import("react-native").ColorValue | null | undefined;
166
- importantForAutofill?: "auto" | "yes" | "no" | "noExcludeDescendants" | "yesExcludeDescendants" | undefined;
167
- disableFullscreenUI?: boolean | undefined;
168
- inlineImageLeft?: string | undefined;
169
- inlineImagePadding?: number | undefined;
170
- numberOfLines?: number | undefined;
171
- returnKeyLabel?: string | undefined;
172
- textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
173
- underlineColorAndroid?: import("react-native").ColorValue | undefined;
174
- textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
175
- showSoftInputOnFocus?: boolean | undefined;
176
- verticalAlign?: "auto" | "top" | "bottom" | "middle" | undefined;
177
- ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
178
- suppressError?: boolean | undefined;
179
- hasValidation: boolean;
180
- hasError?: boolean | undefined;
181
- nextFieldId?: string | undefined;
182
- nextFormFieldRef?: React.RefObject<any> | undefined;
183
- errorMessage?: string | undefined;
184
- requiredMessage?: string | undefined;
185
- labelComponent?: JSX.Element | undefined;
186
- labelPosition?: "beforeInput" | "afterInput" | undefined;
187
- nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
188
- errorComponent?: JSX.Element | undefined;
189
- errorPosition?: "afterInput" | "belowLabel" | undefined;
190
- focusNextFormField: () => void;
191
- isLastField: () => boolean;
192
- } | {
193
- allowFontScaling?: boolean | undefined;
194
- autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
195
- autoComplete?: "off" | "additional-name" | "address-line1" | "address-line2" | "birthdate-day" | "birthdate-full" | "birthdate-month" | "birthdate-year" | "cc-csc" | "cc-exp" | "cc-exp-day" | "cc-exp-month" | "cc-exp-year" | "cc-number" | "cc-name" | "cc-given-name" | "cc-middle-name" | "cc-family-name" | "cc-type" | "country" | "current-password" | "email" | "family-name" | "gender" | "given-name" | "honorific-prefix" | "honorific-suffix" | "name" | "name-family" | "name-given" | "name-middle" | "name-middle-initial" | "name-prefix" | "name-suffix" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "password" | "password-new" | "postal-address" | "postal-address-country" | "postal-address-extended" | "postal-address-extended-postal-code" | "postal-address-locality" | "postal-address-region" | "postal-code" | "street-address" | "sms-otp" | "tel" | "tel-country-code" | "tel-national" | "tel-device" | "url" | "username" | "username-new" | undefined;
196
- autoCorrect?: boolean | undefined;
197
- autoFocus?: boolean | undefined;
198
- blurOnSubmit?: boolean | undefined;
199
- submitBehavior?: import("react-native").SubmitBehavior | undefined;
200
- caretHidden?: boolean | undefined;
201
- contextMenuHidden?: boolean | undefined;
202
- defaultValue?: string | undefined;
203
- editable?: boolean | undefined;
204
- keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
205
- inputMode?: import("react-native").InputModeOptions | undefined;
206
- maxLength?: number | undefined;
207
- multiline?: boolean | undefined;
208
- onBlur?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
209
- onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
210
- onChangeText?: ((text: string) => void) | undefined;
211
- onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
212
- onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
213
- onPress?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
214
- onPressIn?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
215
- onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
216
- onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
217
- onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
218
- onSubmitEditing?: (((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) & ((event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)) | undefined;
219
- onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
220
- onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
221
- placeholder?: string | undefined;
222
- placeholderTextColor?: import("react-native").ColorValue | undefined;
223
- readOnly?: boolean | undefined;
224
- returnKeyType?: ReturnKeyTypeOptions | undefined;
225
- enterKeyHint?: import("react-native").EnterKeyHintTypeOptions | undefined;
226
- secureTextEntry?: boolean | undefined;
227
- selectTextOnFocus?: boolean | undefined;
228
- selection?: {
229
- start: number;
230
- end?: number | undefined;
231
- } | undefined;
232
- selectionColor?: import("react-native").ColorValue | undefined;
233
- style?: ViewStyle | undefined;
234
- textAlign?: "center" | "left" | "right" | undefined;
235
- testID?: string | undefined;
236
- inputAccessoryViewID?: string | undefined;
237
- value?: string | undefined;
238
- maxFontSizeMultiplier?: number | null | undefined;
239
- children?: React.ReactNode;
240
- hitSlop?: number | import("react-native").Insets | null | undefined;
241
- id?: string | undefined;
242
70
  needsOffscreenAlphaCompositing?: boolean | undefined;
243
- onLayout?: (((event: LayoutChangeEvent) => void) & ((event: LayoutChangeEvent) => void)) | undefined;
244
- pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
71
+ pointerEvents?: "none" | "auto" | "box-none" | "box-only" | undefined;
245
72
  removeClippedSubviews?: boolean | undefined;
246
73
  nativeID?: string | undefined;
247
74
  collapsable?: boolean | undefined;
248
75
  collapsableChildren?: boolean | undefined;
249
76
  renderToHardwareTextureAndroid?: boolean | undefined;
250
- focusable?: boolean | undefined;
251
77
  tabIndex?: 0 | -1 | undefined;
252
78
  shouldRasterizeIOS?: boolean | undefined;
253
79
  isTVSelectable?: boolean | undefined;
@@ -285,56 +111,56 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
285
111
  onPointerDownCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
286
112
  onPointerUp?: ((event: import("react-native").PointerEvent) => void) | undefined;
287
113
  onPointerUpCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
288
- accessible?: boolean | undefined;
289
- accessibilityActions?: readonly Readonly<{
290
- name: string;
291
- label?: string | undefined;
292
- }>[] | undefined;
293
- accessibilityLabel?: string | undefined;
294
- 'aria-label'?: string | undefined;
295
- accessibilityRole?: import("react-native").AccessibilityRole | undefined;
296
- accessibilityState?: import("react-native").AccessibilityState | undefined;
297
- 'aria-busy'?: boolean | undefined;
298
- 'aria-checked'?: boolean | "mixed" | undefined;
299
- 'aria-disabled'?: boolean | undefined;
300
- 'aria-expanded'?: boolean | undefined;
301
- 'aria-selected'?: boolean | undefined;
302
- accessibilityHint: string;
303
- accessibilityValue?: import("react-native").AccessibilityValue | undefined;
304
- 'aria-valuemax'?: number | undefined;
305
- 'aria-valuemin'?: number | undefined;
306
- 'aria-valuenow'?: number | undefined;
307
- 'aria-valuetext'?: string | undefined;
308
- onAccessibilityAction?: ((event: import("react-native").AccessibilityActionEvent) => void) | undefined;
309
- importantForAccessibility?: "auto" | "yes" | "no" | "no-hide-descendants" | undefined;
310
- 'aria-hidden'?: boolean | undefined;
311
- 'aria-modal'?: boolean | undefined;
312
- role?: import("react-native").Role | undefined;
313
- accessibilityLabelledBy?: string | string[] | undefined;
314
- 'aria-labelledby'?: string | undefined;
315
- accessibilityLiveRegion?: "none" | "polite" | "assertive" | undefined;
316
- 'aria-live'?: "polite" | "assertive" | "off" | undefined;
317
- accessibilityElementsHidden?: boolean | undefined;
318
- accessibilityViewIsModal?: boolean | undefined;
319
- onAccessibilityEscape?: (() => void) | undefined;
320
- onAccessibilityTap?: (() => void) | undefined;
321
- onMagicTap?: (() => void) | undefined;
322
- accessibilityIgnoresInvertColors?: boolean | undefined;
323
- accessibilityLanguage?: string | undefined;
324
- accessibilityShowsLargeContentViewer?: boolean | undefined;
325
- accessibilityLargeContentTitle?: string | undefined;
114
+ returnKeyType?: ReturnKeyTypeOptions | undefined;
115
+ onSubmitEditing?: (((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) & ((event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)) | undefined;
116
+ allowFontScaling?: boolean | undefined;
117
+ autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
118
+ autoComplete?: "off" | "additional-name" | "address-line1" | "address-line2" | "birthdate-day" | "birthdate-full" | "birthdate-month" | "birthdate-year" | "cc-csc" | "cc-exp" | "cc-exp-day" | "cc-exp-month" | "cc-exp-year" | "cc-number" | "cc-name" | "cc-given-name" | "cc-middle-name" | "cc-family-name" | "cc-type" | "country" | "current-password" | "email" | "family-name" | "gender" | "given-name" | "honorific-prefix" | "honorific-suffix" | "name" | "name-family" | "name-given" | "name-middle" | "name-middle-initial" | "name-prefix" | "name-suffix" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "password" | "password-new" | "postal-address" | "postal-address-country" | "postal-address-extended" | "postal-address-extended-postal-code" | "postal-address-locality" | "postal-address-region" | "postal-code" | "street-address" | "sms-otp" | "tel" | "tel-country-code" | "tel-national" | "tel-device" | "url" | "username" | "username-new" | undefined;
119
+ autoCorrect?: boolean | undefined;
120
+ autoFocus?: boolean | undefined;
121
+ blurOnSubmit?: boolean | undefined;
122
+ submitBehavior?: import("react-native").SubmitBehavior | undefined;
123
+ caretHidden?: boolean | undefined;
124
+ contextMenuHidden?: boolean | undefined;
125
+ defaultValue?: string | undefined;
126
+ keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
127
+ inputMode?: import("react-native").InputModeOptions | undefined;
128
+ maxLength?: number | undefined;
129
+ multiline?: boolean | undefined;
130
+ onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
131
+ onChangeText?: ((text: string) => void) | undefined;
132
+ onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
133
+ onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
134
+ onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
135
+ onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
136
+ onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
137
+ placeholder?: string | undefined;
138
+ placeholderTextColor?: import("react-native").ColorValue | undefined;
139
+ readOnly?: boolean | undefined;
140
+ enterKeyHint?: import("react-native").EnterKeyHintTypeOptions | undefined;
141
+ secureTextEntry?: boolean | undefined;
142
+ selectTextOnFocus?: boolean | undefined;
143
+ selection?: {
144
+ start: number;
145
+ end?: number | undefined;
146
+ } | undefined;
147
+ selectionColor?: import("react-native").ColorValue | undefined;
148
+ textAlign?: "center" | "left" | "right" | undefined;
149
+ inputAccessoryViewID?: string | undefined;
150
+ maxFontSizeMultiplier?: number | null | undefined;
151
+ disableKeyboardShortcuts?: boolean | undefined;
326
152
  clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
327
153
  clearTextOnFocus?: boolean | undefined;
328
154
  dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
329
155
  enablesReturnKeyAutomatically?: boolean | undefined;
330
156
  keyboardAppearance?: "default" | "light" | "dark" | undefined;
331
157
  passwordRules?: string | null | undefined;
332
- rejectResponderTermination?: boolean | null | undefined;
333
158
  selectionState?: import("react-native").DocumentSelectionState | undefined;
334
159
  spellCheck?: boolean | undefined;
335
- textContentType?: "none" | "name" | "nickname" | "password" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "creditCardExpiration" | "creditCardExpirationMonth" | "creditCardExpirationYear" | "creditCardSecurityCode" | "creditCardType" | "creditCardName" | "creditCardGivenName" | "creditCardMiddleName" | "creditCardFamilyName" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "location" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "newPassword" | "oneTimeCode" | "birthdate" | "birthdateDay" | "birthdateMonth" | "birthdateYear" | undefined;
160
+ textContentType?: "none" | "name" | "nickname" | "password" | "username" | "flightNumber" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "creditCardExpiration" | "creditCardExpirationMonth" | "creditCardExpirationYear" | "creditCardSecurityCode" | "creditCardType" | "creditCardName" | "creditCardGivenName" | "creditCardMiddleName" | "creditCardFamilyName" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "location" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "newPassword" | "oneTimeCode" | "birthdate" | "birthdateDay" | "birthdateMonth" | "birthdateYear" | "cellularEID" | "cellularIMEI" | "dateTime" | "shipmentTrackingNumber" | undefined;
336
161
  scrollEnabled?: boolean | undefined;
337
162
  lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined;
163
+ lineBreakModeIOS?: "head" | "wordWrapping" | "char" | "clip" | "middle" | "tail" | undefined;
338
164
  smartInsertDelete?: boolean | undefined;
339
165
  cursorColor?: import("react-native").ColorValue | null | undefined;
340
166
  selectionHandleColor?: import("react-native").ColorValue | null | undefined;
@@ -348,8 +174,8 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
348
174
  underlineColorAndroid?: import("react-native").ColorValue | undefined;
349
175
  textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
350
176
  showSoftInputOnFocus?: boolean | undefined;
351
- verticalAlign?: "auto" | "top" | "bottom" | "middle" | undefined;
352
- ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
177
+ verticalAlign?: "auto" | "middle" | "top" | "bottom" | undefined;
178
+ ref?: React.ForwardedRef<any> | undefined;
353
179
  suppressError?: boolean | undefined;
354
180
  hasValidation: boolean;
355
181
  hasError?: boolean | undefined;
@@ -357,11 +183,13 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
357
183
  nextFormFieldRef?: React.RefObject<any> | undefined;
358
184
  errorMessage?: string | undefined;
359
185
  requiredMessage?: string | undefined;
360
- labelComponent?: JSX.Element | undefined;
361
186
  labelPosition?: "beforeInput" | "afterInput" | undefined;
362
187
  nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
363
- errorComponent?: JSX.Element | undefined;
364
188
  errorPosition?: "afterInput" | "belowLabel" | undefined;
189
+ renderLabel?: ((a11yProps: Pick<TextInputProps, "importantForAccessibility" | "accessibilityElementsHidden">) => React.ReactNode) | undefined;
190
+ renderError?: ((a11yProps: Pick<TextInputProps, "importantForAccessibility" | "accessibilityElementsHidden">) => React.ReactNode) | undefined;
191
+ accessibilityLabel?: string | undefined;
192
+ 'aria-label'?: undefined;
365
193
  focusNextFormField: () => void;
366
194
  isLastField: () => boolean;
367
195
  };
@@ -35,14 +35,12 @@ var __rest = (this && this.__rest) || function (s, e) {
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.useTextInput = void 0;
38
- const core_1 = require("@react-native-ama/core");
39
- const internal_1 = require("@react-native-ama/internal");
40
38
  const React = __importStar(require("react"));
41
39
  const useFormField_1 = require("./useFormField");
42
40
  const useTextInput = (_a) => {
43
41
  var { onLayout, returnKeyType, onSubmitEditing, accessibilityLabel, requiredMessage, required } = _a, rest = __rest(_a, ["onLayout", "returnKeyType", "onSubmitEditing", "accessibilityLabel", "requiredMessage", "required"]);
44
42
  const [theReturnKeyType, setTheReturnKeyType] = React.useState(returnKeyType || 'next');
45
- const _b = (0, useFormField_1.useFormField)(Object.assign({ hasFocusCallback: true }, rest)), { style: formFieldStyle } = _b, formField = __rest(_b, ["style"]);
43
+ const formField = (0, useFormField_1.useFormField)(Object.assign({ hasFocusCallback: true }, rest));
46
44
  const handleOnSubmitEditing = (event) => {
47
45
  onSubmitEditing === null || onSubmitEditing === void 0 ? void 0 : onSubmitEditing(event);
48
46
  formField.focusNextFormField();
@@ -54,34 +52,6 @@ const useTextInput = (_a) => {
54
52
  }
55
53
  onLayout === null || onLayout === void 0 ? void 0 : onLayout(event);
56
54
  };
57
- const checks = __DEV__ ? core_1.useChecks === null || core_1.useChecks === void 0 ? void 0 : (0, core_1.useChecks)() : undefined;
58
- __DEV__ &&
59
- (checks === null || checks === void 0 ? void 0 : checks.noUndefinedProperty({
60
- properties: { accessibilityLabel },
61
- property: 'accessibilityLabel',
62
- rule: 'NO_FORM_LABEL',
63
- }));
64
- __DEV__ &&
65
- (checks === null || checks === void 0 ? void 0 : checks.noUppercaseStringChecker({
66
- text: accessibilityLabel,
67
- }));
68
- __DEV__ &&
69
- (checks === null || checks === void 0 ? void 0 : checks.noUppercaseStringChecker({
70
- text: rest.accessibilityHint,
71
- }));
72
- __DEV__ &&
73
- (accessibilityLabel === null || accessibilityLabel === void 0 ? void 0 : accessibilityLabel.trim().slice(-1)) === '*' &&
74
- (checks === null || checks === void 0 ? void 0 : checks.logResult('NO_FORM_LABEL_ENDING_WITH_ASTERISK', {
75
- rule: 'NO_FORM_LABEL_ENDING_WITH_ASTERISK',
76
- message: 'Form labels should not end with an asterisk. Please remove it and provide a required message instead.',
77
- }));
78
- __DEV__ &&
79
- required &&
80
- (checks === null || checks === void 0 ? void 0 : checks.noUndefinedProperty({
81
- properties: { requiredMessage },
82
- property: 'requiredMessage',
83
- rule: 'NO_FORM_LABEL_ENDING_WITH_ASTERISK',
84
- }));
85
55
  const fullAccessibilityLabel = required
86
56
  ? `${accessibilityLabel}, ${requiredMessage}`
87
57
  : accessibilityLabel;
@@ -92,11 +62,6 @@ const useTextInput = (_a) => {
92
62
  onLayout: checkReturnKeyType,
93
63
  blurOnSubmit: theReturnKeyType === 'done',
94
64
  };
95
- return __DEV__
96
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, rest), formField), advancedProps), { style: internal_1.applyStyle === null || internal_1.applyStyle === void 0 ? void 0 : (0, internal_1.applyStyle)({
97
- // @ts-ignore
98
- style: formFieldStyle,
99
- debugStyle: checks === null || checks === void 0 ? void 0 : checks.debugStyle,
100
- }) }) : Object.assign(Object.assign(Object.assign({}, rest), formField), advancedProps);
65
+ return Object.assign(Object.assign(Object.assign({}, rest), formField), advancedProps);
101
66
  };
102
67
  exports.useTextInput = useTextInput;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,15 @@
1
- /// <reference types="react" />
2
- import { isFocused } from '@react-native-ama/internal';
3
- import { type FormActions, type FormProps } from './components/Form';
1
+ import React from 'react';
2
+ import { Form as FormProvider, type FormActions, type FormProps } from './components/Form';
4
3
  import { FormField, type FormFieldProps } from './components/FormField';
5
- import { FormSubmit, type FormSubmitProps } from './components/FormSubmit';
6
- import { FormSwitch, type FormSwitchProps } from './components/FormSwitch';
7
- type FormComponent = React.FunctionComponent<FormProps> & {
8
- Submit: (props: FormSubmitProps) => JSX.Element;
9
- Field: React.FunctionComponent<FormFieldProps>;
10
- Switch: (props: FormSwitchProps) => JSX.Element;
4
+ import { FormSubmit, type FormSubmitProps, type FormSubmitRenderProps } from './components/FormSubmit';
5
+ type FormComponent = typeof FormProvider & {
6
+ Submit: (props: FormSubmitProps) => React.ReactElement;
7
+ Field: typeof FormField;
11
8
  };
12
9
  declare const Form: FormComponent;
13
- export { Form, FormField, FormSubmit, FormSwitch };
10
+ export { Form, FormField, FormSubmit };
14
11
  export { TextInput, type TextInputProps } from './components/TextInput';
15
12
  export { useFormField, type UseFormField } from './hooks/useFormField';
13
+ export { useFormSubmit, type UseFormSubmit } from './hooks/useFormSubmit';
16
14
  export { useTextInput, type UseTextInput } from './hooks/useTextInput';
17
- export { isFocused };
18
- export { type FormProps, type FormActions, type FormFieldProps, type FormSubmitProps, type FormSwitchProps, };
15
+ export { type FormProps, type FormActions, type FormFieldProps, type FormSubmitProps, type FormSubmitRenderProps, };
package/dist/index.js CHANGED
@@ -1,27 +1,22 @@
1
1
  "use strict";
2
- // Components
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isFocused = exports.useTextInput = exports.useFormField = exports.TextInput = exports.FormSwitch = exports.FormSubmit = exports.FormField = exports.Form = void 0;
5
- const internal_1 = require("@react-native-ama/internal");
6
- Object.defineProperty(exports, "isFocused", { enumerable: true, get: function () { return internal_1.isFocused; } });
3
+ exports.useTextInput = exports.useFormSubmit = exports.useFormField = exports.TextInput = exports.FormSubmit = exports.FormField = exports.Form = void 0;
7
4
  const Form_1 = require("./components/Form");
8
5
  const FormField_1 = require("./components/FormField");
9
6
  Object.defineProperty(exports, "FormField", { enumerable: true, get: function () { return FormField_1.FormField; } });
10
7
  const FormSubmit_1 = require("./components/FormSubmit");
11
8
  Object.defineProperty(exports, "FormSubmit", { enumerable: true, get: function () { return FormSubmit_1.FormSubmit; } });
12
- const FormSwitch_1 = require("./components/FormSwitch");
13
- Object.defineProperty(exports, "FormSwitch", { enumerable: true, get: function () { return FormSwitch_1.FormSwitch; } });
14
- // @ts-ignore
15
9
  const Form = Form_1.Form;
16
10
  exports.Form = Form;
17
11
  Form.Submit = FormSubmit_1.FormSubmit;
18
12
  Form.Field = FormField_1.FormField;
19
- Form.Switch = FormSwitch_1.FormSwitch;
20
13
  // Components
21
14
  var TextInput_1 = require("./components/TextInput");
22
15
  Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return TextInput_1.TextInput; } });
23
16
  // Hooks
24
17
  var useFormField_1 = require("./hooks/useFormField");
25
18
  Object.defineProperty(exports, "useFormField", { enumerable: true, get: function () { return useFormField_1.useFormField; } });
19
+ var useFormSubmit_1 = require("./hooks/useFormSubmit");
20
+ Object.defineProperty(exports, "useFormSubmit", { enumerable: true, get: function () { return useFormSubmit_1.useFormSubmit; } });
26
21
  var useTextInput_1 = require("./hooks/useTextInput");
27
22
  Object.defineProperty(exports, "useTextInput", { enumerable: true, get: function () { return useTextInput_1.useTextInput; } });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { TextInput } from 'react-native';
3
+ export type CheckFocusTrap = {
4
+ ref: React.RefObject<TextInput>;
5
+ shouldHaveFocus: boolean;
6
+ trackError?: ((rule: 'NO_KEYBOARD_TRAP', ref: React.RefObject<any>) => void) | null;
7
+ };
8
+ export declare const checkFocusTrap: (({ ref, shouldHaveFocus, trackError }: CheckFocusTrap) => Promise<void>) | null;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkFocusTrap = void 0;
4
+ const CHECK_FOCUS_TRAP_DELAY_MS = 100;
5
+ const isFocused = (ref) => {
6
+ var _a, _b;
7
+ return (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.isFocused) === null || _a === void 0 ? void 0 : _a.call(ref)) !== null && _b !== void 0 ? _b : false;
8
+ };
9
+ exports.checkFocusTrap = __DEV__
10
+ ? ({ ref, shouldHaveFocus, trackError }) => {
11
+ return new Promise((resolve) => {
12
+ setTimeout(() => {
13
+ var _a;
14
+ const hasFocus = isFocused((_a = ref === null || ref === void 0 ? void 0 : ref.current) !== null && _a !== void 0 ? _a : null) === shouldHaveFocus;
15
+ if (!hasFocus) {
16
+ const message = shouldHaveFocus
17
+ ? 'The component did not receive the focus'
18
+ : 'The component did trap the focus';
19
+ if (trackError) {
20
+ trackError('NO_KEYBOARD_TRAP', ref);
21
+ }
22
+ else {
23
+ console.error(message);
24
+ }
25
+ }
26
+ resolve();
27
+ }, CHECK_FOCUS_TRAP_DELAY_MS);
28
+ });
29
+ }
30
+ : null;