@react-native-ama/forms 1.0.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 (110) hide show
  1. package/dist/core/src/components/AMAProvider.d.ts +26 -0
  2. package/dist/core/src/components/AMAProvider.js +147 -0
  3. package/dist/core/src/components/AutofocusContainer.d.ts +9 -0
  4. package/dist/core/src/components/AutofocusContainer.js +58 -0
  5. package/dist/core/src/components/HideChildrenFromAccessibilityTree.d.ts +6 -0
  6. package/dist/core/src/components/HideChildrenFromAccessibilityTree.js +40 -0
  7. package/dist/core/src/hooks/useButtonChecks.d.ts +6 -0
  8. package/dist/core/src/hooks/useButtonChecks.js +51 -0
  9. package/dist/core/src/hooks/useChecks.d.ts +15 -0
  10. package/dist/core/src/hooks/useChecks.js +152 -0
  11. package/dist/core/src/hooks/useFocus.d.ts +4 -0
  12. package/dist/core/src/hooks/useFocus.js +55 -0
  13. package/dist/core/src/hooks/useTimedAction.d.ts +3 -0
  14. package/dist/core/src/hooks/useTimedAction.js +63 -0
  15. package/dist/core/src/index.d.ts +7 -0
  16. package/dist/core/src/index.js +20 -0
  17. package/dist/forms/src/components/Form.d.ts +24 -0
  18. package/dist/forms/src/components/Form.js +122 -0
  19. package/dist/forms/src/components/FormField.d.ts +7 -0
  20. package/dist/forms/src/components/FormField.js +52 -0
  21. package/dist/forms/src/components/FormSubmit.d.ts +10 -0
  22. package/dist/forms/src/components/FormSubmit.js +25 -0
  23. package/dist/forms/src/components/FormSwitch.d.ts +4 -0
  24. package/dist/forms/src/components/FormSwitch.js +15 -0
  25. package/dist/forms/src/components/TextInput.d.ts +26 -0
  26. package/dist/forms/src/components/TextInput.js +123 -0
  27. package/dist/forms/src/hooks/useFormField.d.ts +26 -0
  28. package/dist/forms/src/hooks/useFormField.js +92 -0
  29. package/dist/forms/src/hooks/useTextInput.d.ts +350 -0
  30. package/dist/forms/src/hooks/useTextInput.js +102 -0
  31. package/dist/forms/src/index.d.ts +16 -0
  32. package/dist/forms/src/index.js +24 -0
  33. package/dist/internal/src/checks/checkAccessibilityRole.d.ts +3 -0
  34. package/dist/internal/src/checks/checkAccessibilityRole.js +32 -0
  35. package/dist/internal/src/checks/checkFocusTrap.d.ts +8 -0
  36. package/dist/internal/src/checks/checkFocusTrap.js +34 -0
  37. package/dist/internal/src/checks/checkForAccessibilityState.d.ts +7 -0
  38. package/dist/internal/src/checks/checkForAccessibilityState.js +48 -0
  39. package/dist/internal/src/checks/checkMinimumSize.d.ts +3 -0
  40. package/dist/internal/src/checks/checkMinimumSize.js +29 -0
  41. package/dist/internal/src/checks/contrastChecker.d.ts +8 -0
  42. package/dist/internal/src/checks/contrastChecker.js +77 -0
  43. package/dist/internal/src/checks/noUndefinedProperty.d.ts +8 -0
  44. package/dist/internal/src/checks/noUndefinedProperty.js +14 -0
  45. package/dist/internal/src/checks/uppercaseChecker.d.ts +8 -0
  46. package/dist/internal/src/checks/uppercaseChecker.js +18 -0
  47. package/dist/internal/src/checks/uppercaseStringChecker.d.ts +8 -0
  48. package/dist/internal/src/checks/uppercaseStringChecker.js +29 -0
  49. package/dist/internal/src/index.d.ts +20 -0
  50. package/dist/internal/src/index.js +56 -0
  51. package/dist/internal/src/types.d.ts +17 -0
  52. package/dist/internal/src/types.js +2 -0
  53. package/dist/internal/src/utils/applyStyle.d.ts +9 -0
  54. package/dist/internal/src/utils/applyStyle.js +33 -0
  55. package/dist/internal/src/utils/constants.d.ts +3 -0
  56. package/dist/internal/src/utils/constants.js +32 -0
  57. package/dist/internal/src/utils/error.style.d.ts +6 -0
  58. package/dist/internal/src/utils/error.style.js +11 -0
  59. package/dist/internal/src/utils/generateAccessibilityStateFromProp.d.ts +9 -0
  60. package/dist/internal/src/utils/generateAccessibilityStateFromProp.js +35 -0
  61. package/dist/internal/src/utils/getPropertyFromStyle.d.ts +2 -0
  62. package/dist/internal/src/utils/getPropertyFromStyle.js +10 -0
  63. package/dist/internal/src/utils/interpolateAnimationStates.d.ts +2 -0
  64. package/dist/internal/src/utils/interpolateAnimationStates.js +43 -0
  65. package/dist/internal/src/utils/isFocused.d.ts +2 -0
  66. package/dist/internal/src/utils/isFocused.js +7 -0
  67. package/dist/internal/src/utils/logger.d.ts +16 -0
  68. package/dist/internal/src/utils/logger.js +53 -0
  69. package/dist/internal/src/utils/logger.rules.d.ts +15 -0
  70. package/dist/internal/src/utils/logger.rules.js +74 -0
  71. package/dist/internal/src/utils/maybeGenerateStringFromElement.d.ts +2 -0
  72. package/dist/internal/src/utils/maybeGenerateStringFromElement.js +51 -0
  73. package/dist/internal/src/utils/minimumTouchableSize.d.ts +3 -0
  74. package/dist/internal/src/utils/minimumTouchableSize.js +9 -0
  75. package/dist/react-native/src/components/ExpandablePressable.d.ts +6 -0
  76. package/dist/react-native/src/components/ExpandablePressable.js +26 -0
  77. package/dist/react-native/src/components/Pressable.d.ts +5 -0
  78. package/dist/react-native/src/components/Pressable.js +49 -0
  79. package/dist/react-native/src/components/SwitchListItem.d.ts +12 -0
  80. package/dist/react-native/src/components/SwitchListItem.js +44 -0
  81. package/dist/react-native/src/components/SwitchWrapper.d.ts +11 -0
  82. package/dist/react-native/src/components/SwitchWrapper.js +36 -0
  83. package/dist/react-native/src/components/Text.d.ts +6 -0
  84. package/dist/react-native/src/components/Text.js +77 -0
  85. package/dist/react-native/src/components/TouchableOpacity.d.ts +6 -0
  86. package/dist/react-native/src/components/TouchableOpacity.js +48 -0
  87. package/dist/react-native/src/components/TouchableWithoutFeedback.d.ts +5 -0
  88. package/dist/react-native/src/components/TouchableWithoutFeedback.js +48 -0
  89. package/dist/react-native/src/hooks/useExpandable.d.ts +13 -0
  90. package/dist/react-native/src/hooks/useExpandable.js +31 -0
  91. package/dist/react-native/src/hooks/usePressable.d.ts +16 -0
  92. package/dist/react-native/src/hooks/usePressable.js +44 -0
  93. package/dist/react-native/src/hooks/useSwitch.d.ts +10 -0
  94. package/dist/react-native/src/hooks/useSwitch.js +25 -0
  95. package/dist/react-native/src/index.d.ts +10 -0
  96. package/dist/react-native/src/index.js +25 -0
  97. package/package.json +82 -0
  98. package/src/components/Form.test.tsx +262 -0
  99. package/src/components/Form.tsx +138 -0
  100. package/src/components/FormField.test.tsx +54 -0
  101. package/src/components/FormField.tsx +45 -0
  102. package/src/components/FormSubmit.test.tsx +71 -0
  103. package/src/components/FormSubmit.tsx +43 -0
  104. package/src/components/FormSwitch.tsx +17 -0
  105. package/src/components/TextInput.test.tsx +540 -0
  106. package/src/components/TextInput.tsx +168 -0
  107. package/src/hooks/useFormField.test.tsx +183 -0
  108. package/src/hooks/useFormField.ts +133 -0
  109. package/src/hooks/useTextInput.ts +128 -0
  110. package/src/index.ts +39 -0
@@ -0,0 +1,350 @@
1
+ import * as React from 'react';
2
+ import type { LayoutChangeEvent, NativeSyntheticEvent, ReturnKeyTypeOptions, StyleProp, TextInputSubmitEditingEventData, TextStyle, ViewStyle } from 'react-native';
3
+ import { UseFormField } from './useFormField';
4
+ type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
5
+ onLayout?: (event: LayoutChangeEvent) => void;
6
+ returnKeyType?: ReturnKeyTypeOptions;
7
+ onSubmitEditing?: (event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void;
8
+ accessibilityLabel: string;
9
+ editable?: boolean;
10
+ style?: ViewStyle | StyleProp<TextStyle> | null;
11
+ required: boolean;
12
+ requiredMessage?: string;
13
+ hasValidation: boolean;
14
+ hasError?: boolean;
15
+ errorMessage?: string;
16
+ };
17
+ 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" | "email" | "password" | "tel" | "url" | "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" | "country" | "current-password" | "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-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-country-code" | "tel-national" | "tel-device" | "username" | "username-new" | undefined;
22
+ autoCorrect?: boolean | undefined;
23
+ autoFocus?: boolean | undefined;
24
+ blurOnSubmit?: boolean | undefined;
25
+ caretHidden?: boolean | undefined;
26
+ contextMenuHidden?: boolean | undefined;
27
+ defaultValue?: string | undefined;
28
+ editable?: boolean | undefined;
29
+ keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
30
+ inputMode?: import("react-native").InputModeOptions | undefined;
31
+ maxLength?: number | undefined;
32
+ multiline?: boolean | undefined;
33
+ onBlur?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
34
+ onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
35
+ onChangeText?: ((text: string) => void) | undefined;
36
+ onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
37
+ onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
38
+ onPressIn?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
39
+ onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
40
+ onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
41
+ onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
42
+ onSubmitEditing?: ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefined;
43
+ onTextInput?: ((e: NativeSyntheticEvent<import("react-native").TextInputTextInputEventData>) => void) | undefined;
44
+ onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
45
+ onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
46
+ placeholder?: string | undefined;
47
+ placeholderTextColor?: import("react-native").ColorValue | undefined;
48
+ returnKeyType?: ReturnKeyTypeOptions | undefined;
49
+ enterKeyHint?: import("react-native").EnterKeyHintTypeOptions | undefined;
50
+ secureTextEntry?: boolean | undefined;
51
+ selectTextOnFocus?: boolean | undefined;
52
+ selection?: {
53
+ start: number;
54
+ end?: number | undefined;
55
+ } | undefined;
56
+ selectionColor?: import("react-native").ColorValue | undefined;
57
+ textAlign?: "left" | "right" | "center" | undefined;
58
+ testID?: string | undefined;
59
+ inputAccessoryViewID?: string | undefined;
60
+ value?: string | undefined;
61
+ maxFontSizeMultiplier?: number | null | undefined;
62
+ children?: React.ReactNode;
63
+ hitSlop?: import("react-native").Insets | undefined;
64
+ id?: string | undefined;
65
+ onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
66
+ pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
67
+ removeClippedSubviews?: boolean | undefined;
68
+ nativeID?: string | undefined;
69
+ collapsable?: boolean | undefined;
70
+ needsOffscreenAlphaCompositing?: boolean | undefined;
71
+ renderToHardwareTextureAndroid?: boolean | undefined;
72
+ focusable?: boolean | undefined;
73
+ shouldRasterizeIOS?: boolean | undefined;
74
+ isTVSelectable?: boolean | undefined;
75
+ hasTVPreferredFocus?: boolean | undefined;
76
+ tvParallaxProperties?: import("react-native").TVParallaxProperties | undefined;
77
+ tvParallaxShiftDistanceX?: number | undefined;
78
+ tvParallaxShiftDistanceY?: number | undefined;
79
+ tvParallaxTiltAngle?: number | undefined;
80
+ tvParallaxMagnification?: number | undefined;
81
+ onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
82
+ onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
83
+ onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
84
+ onResponderGrant?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
85
+ onResponderReject?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
86
+ onResponderMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
87
+ onResponderRelease?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
88
+ onResponderStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
89
+ onResponderTerminationRequest?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
90
+ onResponderTerminate?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
91
+ onStartShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
92
+ onMoveShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
93
+ onTouchStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
94
+ onTouchMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
95
+ onTouchEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
96
+ onTouchCancel?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
97
+ onTouchEndCapture?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
98
+ onPointerEnter?: ((event: import("react-native").PointerEvent) => void) | undefined;
99
+ onPointerEnterCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
100
+ onPointerLeave?: ((event: import("react-native").PointerEvent) => void) | undefined;
101
+ onPointerLeaveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
102
+ onPointerMove?: ((event: import("react-native").PointerEvent) => void) | undefined;
103
+ onPointerMoveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
104
+ onPointerCancel?: ((event: import("react-native").PointerEvent) => void) | undefined;
105
+ onPointerCancelCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
106
+ onPointerDown?: ((event: import("react-native").PointerEvent) => void) | undefined;
107
+ onPointerDownCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
108
+ onPointerUp?: ((event: import("react-native").PointerEvent) => void) | undefined;
109
+ onPointerUpCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
110
+ accessible?: boolean | undefined;
111
+ accessibilityActions?: readonly Readonly<{
112
+ name: string;
113
+ label?: string | undefined;
114
+ }>[] | undefined;
115
+ accessibilityLabel?: string | undefined;
116
+ 'aria-label'?: string | undefined;
117
+ accessibilityRole?: import("react-native").AccessibilityRole | undefined;
118
+ accessibilityState?: import("react-native").AccessibilityState | undefined;
119
+ 'aria-busy'?: boolean | undefined;
120
+ 'aria-checked'?: boolean | "mixed" | undefined;
121
+ 'aria-disabled'?: boolean | undefined;
122
+ 'aria-expanded'?: boolean | undefined;
123
+ 'aria-selected'?: boolean | undefined;
124
+ 'aria-labelledby'?: string | undefined;
125
+ accessibilityHint: string;
126
+ accessibilityValue?: import("react-native").AccessibilityValue | undefined;
127
+ 'aria-valuemax'?: number | undefined;
128
+ 'aria-valuemin'?: number | undefined;
129
+ 'aria-valuenow'?: number | undefined;
130
+ 'aria-valuetext'?: string | undefined;
131
+ onAccessibilityAction?: ((event: import("react-native").AccessibilityActionEvent) => void) | undefined;
132
+ importantForAccessibility?: "auto" | "yes" | "no" | "no-hide-descendants" | undefined;
133
+ 'aria-hidden'?: boolean | undefined;
134
+ 'aria-live'?: "polite" | "assertive" | "off" | undefined;
135
+ 'aria-modal'?: boolean | undefined;
136
+ role?: import("react-native").Role | undefined;
137
+ accessibilityLiveRegion?: "none" | "polite" | "assertive" | undefined;
138
+ accessibilityLabelledBy?: string | string[] | undefined;
139
+ accessibilityElementsHidden?: boolean | undefined;
140
+ accessibilityViewIsModal?: boolean | undefined;
141
+ onAccessibilityEscape?: (() => void) | undefined;
142
+ onAccessibilityTap?: (() => void) | undefined;
143
+ onMagicTap?: (() => void) | undefined;
144
+ accessibilityIgnoresInvertColors?: boolean | undefined;
145
+ accessibilityLanguage?: string | undefined;
146
+ clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
147
+ clearTextOnFocus?: boolean | undefined;
148
+ dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
149
+ enablesReturnKeyAutomatically?: boolean | undefined;
150
+ keyboardAppearance?: "default" | "light" | "dark" | undefined;
151
+ passwordRules?: string | null | undefined;
152
+ rejectResponderTermination?: boolean | null | undefined;
153
+ selectionState?: import("react-native").DocumentSelectionState | undefined;
154
+ spellCheck?: boolean | undefined;
155
+ textContentType?: "none" | "password" | "name" | "nickname" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "location" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "newPassword" | "oneTimeCode" | undefined;
156
+ scrollEnabled?: boolean | undefined;
157
+ lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined;
158
+ cursorColor?: import("react-native").ColorValue | null | undefined;
159
+ importantForAutofill?: "auto" | "yes" | "no" | "noExcludeDescendants" | "yesExcludeDescendants" | undefined;
160
+ disableFullscreenUI?: boolean | undefined;
161
+ inlineImageLeft?: string | undefined;
162
+ inlineImagePadding?: number | undefined;
163
+ numberOfLines?: number | undefined;
164
+ returnKeyLabel?: string | undefined;
165
+ textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
166
+ underlineColorAndroid?: import("react-native").ColorValue | undefined;
167
+ textAlignVertical?: "bottom" | "top" | "auto" | "center" | undefined;
168
+ showSoftInputOnFocus?: boolean | undefined;
169
+ verticalAlign?: "bottom" | "top" | "auto" | "middle" | undefined;
170
+ labelComponent?: JSX.Element | undefined;
171
+ labelPosition?: "beforeInput" | "afterInput" | undefined;
172
+ nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
173
+ nextFieldId?: string | undefined;
174
+ hasValidation: boolean;
175
+ errorComponent?: JSX.Element | undefined;
176
+ hasError?: boolean | undefined;
177
+ errorPosition?: "afterInput" | "belowLabel" | undefined;
178
+ errorMessage?: string | undefined;
179
+ focusNextFormField: () => void;
180
+ isLastField: () => boolean;
181
+ ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
182
+ nextFormFieldRef?: React.RefObject<any> | undefined;
183
+ } | {
184
+ allowFontScaling?: boolean | undefined;
185
+ autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
186
+ autoComplete?: "off" | "email" | "password" | "tel" | "url" | "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" | "country" | "current-password" | "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-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-country-code" | "tel-national" | "tel-device" | "username" | "username-new" | undefined;
187
+ autoCorrect?: boolean | undefined;
188
+ autoFocus?: boolean | undefined;
189
+ blurOnSubmit?: boolean | undefined;
190
+ caretHidden?: boolean | undefined;
191
+ contextMenuHidden?: boolean | undefined;
192
+ defaultValue?: string | undefined;
193
+ editable?: boolean | undefined;
194
+ keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
195
+ inputMode?: import("react-native").InputModeOptions | undefined;
196
+ maxLength?: number | undefined;
197
+ multiline?: boolean | undefined;
198
+ onBlur?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
199
+ onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
200
+ onChangeText?: ((text: string) => void) | undefined;
201
+ onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
202
+ onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
203
+ onPressIn?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
204
+ onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
205
+ onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
206
+ onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
207
+ onSubmitEditing?: ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefined;
208
+ onTextInput?: ((e: NativeSyntheticEvent<import("react-native").TextInputTextInputEventData>) => void) | undefined;
209
+ onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
210
+ onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
211
+ placeholder?: string | undefined;
212
+ placeholderTextColor?: import("react-native").ColorValue | undefined;
213
+ returnKeyType?: ReturnKeyTypeOptions | undefined;
214
+ enterKeyHint?: import("react-native").EnterKeyHintTypeOptions | undefined;
215
+ secureTextEntry?: boolean | undefined;
216
+ selectTextOnFocus?: boolean | undefined;
217
+ selection?: {
218
+ start: number;
219
+ end?: number | undefined;
220
+ } | undefined;
221
+ selectionColor?: import("react-native").ColorValue | undefined;
222
+ style?: false | ViewStyle | import("react-native").RegisteredStyle<TextStyle> | import("react-native").RecursiveArray<import("react-native").Falsy | TextStyle | import("react-native").RegisteredStyle<TextStyle>> | null | undefined;
223
+ textAlign?: "left" | "right" | "center" | undefined;
224
+ testID?: string | undefined;
225
+ inputAccessoryViewID?: string | undefined;
226
+ value?: string | undefined;
227
+ maxFontSizeMultiplier?: number | null | undefined;
228
+ children?: React.ReactNode;
229
+ hitSlop?: import("react-native").Insets | undefined;
230
+ id?: string | undefined;
231
+ onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
232
+ pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
233
+ removeClippedSubviews?: boolean | undefined;
234
+ nativeID?: string | undefined;
235
+ collapsable?: boolean | undefined;
236
+ needsOffscreenAlphaCompositing?: boolean | undefined;
237
+ renderToHardwareTextureAndroid?: boolean | undefined;
238
+ focusable?: boolean | undefined;
239
+ shouldRasterizeIOS?: boolean | undefined;
240
+ isTVSelectable?: boolean | undefined;
241
+ hasTVPreferredFocus?: boolean | undefined;
242
+ tvParallaxProperties?: import("react-native").TVParallaxProperties | undefined;
243
+ tvParallaxShiftDistanceX?: number | undefined;
244
+ tvParallaxShiftDistanceY?: number | undefined;
245
+ tvParallaxTiltAngle?: number | undefined;
246
+ tvParallaxMagnification?: number | undefined;
247
+ onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
248
+ onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
249
+ onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
250
+ onResponderGrant?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
251
+ onResponderReject?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
252
+ onResponderMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
253
+ onResponderRelease?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
254
+ onResponderStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
255
+ onResponderTerminationRequest?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
256
+ onResponderTerminate?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
257
+ onStartShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
258
+ onMoveShouldSetResponderCapture?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
259
+ onTouchStart?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
260
+ onTouchMove?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
261
+ onTouchEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
262
+ onTouchCancel?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
263
+ onTouchEndCapture?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
264
+ onPointerEnter?: ((event: import("react-native").PointerEvent) => void) | undefined;
265
+ onPointerEnterCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
266
+ onPointerLeave?: ((event: import("react-native").PointerEvent) => void) | undefined;
267
+ onPointerLeaveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
268
+ onPointerMove?: ((event: import("react-native").PointerEvent) => void) | undefined;
269
+ onPointerMoveCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
270
+ onPointerCancel?: ((event: import("react-native").PointerEvent) => void) | undefined;
271
+ onPointerCancelCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
272
+ onPointerDown?: ((event: import("react-native").PointerEvent) => void) | undefined;
273
+ onPointerDownCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
274
+ onPointerUp?: ((event: import("react-native").PointerEvent) => void) | undefined;
275
+ onPointerUpCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
276
+ accessible?: boolean | undefined;
277
+ accessibilityActions?: readonly Readonly<{
278
+ name: string;
279
+ label?: string | undefined;
280
+ }>[] | undefined;
281
+ accessibilityLabel?: string | undefined;
282
+ 'aria-label'?: string | undefined;
283
+ accessibilityRole?: import("react-native").AccessibilityRole | undefined;
284
+ accessibilityState?: import("react-native").AccessibilityState | undefined;
285
+ 'aria-busy'?: boolean | undefined;
286
+ 'aria-checked'?: boolean | "mixed" | undefined;
287
+ 'aria-disabled'?: boolean | undefined;
288
+ 'aria-expanded'?: boolean | undefined;
289
+ 'aria-selected'?: boolean | undefined;
290
+ 'aria-labelledby'?: string | undefined;
291
+ accessibilityHint: string;
292
+ accessibilityValue?: import("react-native").AccessibilityValue | undefined;
293
+ 'aria-valuemax'?: number | undefined;
294
+ 'aria-valuemin'?: number | undefined;
295
+ 'aria-valuenow'?: number | undefined;
296
+ 'aria-valuetext'?: string | undefined;
297
+ onAccessibilityAction?: ((event: import("react-native").AccessibilityActionEvent) => void) | undefined;
298
+ importantForAccessibility?: "auto" | "yes" | "no" | "no-hide-descendants" | undefined;
299
+ 'aria-hidden'?: boolean | undefined;
300
+ 'aria-live'?: "polite" | "assertive" | "off" | undefined;
301
+ 'aria-modal'?: boolean | undefined;
302
+ role?: import("react-native").Role | undefined;
303
+ accessibilityLiveRegion?: "none" | "polite" | "assertive" | undefined;
304
+ accessibilityLabelledBy?: string | string[] | undefined;
305
+ accessibilityElementsHidden?: boolean | undefined;
306
+ accessibilityViewIsModal?: boolean | undefined;
307
+ onAccessibilityEscape?: (() => void) | undefined;
308
+ onAccessibilityTap?: (() => void) | undefined;
309
+ onMagicTap?: (() => void) | undefined;
310
+ accessibilityIgnoresInvertColors?: boolean | undefined;
311
+ accessibilityLanguage?: string | undefined;
312
+ clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
313
+ clearTextOnFocus?: boolean | undefined;
314
+ dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
315
+ enablesReturnKeyAutomatically?: boolean | undefined;
316
+ keyboardAppearance?: "default" | "light" | "dark" | undefined;
317
+ passwordRules?: string | null | undefined;
318
+ rejectResponderTermination?: boolean | null | undefined;
319
+ selectionState?: import("react-native").DocumentSelectionState | undefined;
320
+ spellCheck?: boolean | undefined;
321
+ textContentType?: "none" | "password" | "name" | "nickname" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "location" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "newPassword" | "oneTimeCode" | undefined;
322
+ scrollEnabled?: boolean | undefined;
323
+ lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined;
324
+ cursorColor?: import("react-native").ColorValue | null | undefined;
325
+ importantForAutofill?: "auto" | "yes" | "no" | "noExcludeDescendants" | "yesExcludeDescendants" | undefined;
326
+ disableFullscreenUI?: boolean | undefined;
327
+ inlineImageLeft?: string | undefined;
328
+ inlineImagePadding?: number | undefined;
329
+ numberOfLines?: number | undefined;
330
+ returnKeyLabel?: string | undefined;
331
+ textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
332
+ underlineColorAndroid?: import("react-native").ColorValue | undefined;
333
+ textAlignVertical?: "bottom" | "top" | "auto" | "center" | undefined;
334
+ showSoftInputOnFocus?: boolean | undefined;
335
+ verticalAlign?: "bottom" | "top" | "auto" | "middle" | undefined;
336
+ labelComponent?: JSX.Element | undefined;
337
+ labelPosition?: "beforeInput" | "afterInput" | undefined;
338
+ nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
339
+ nextFieldId?: string | undefined;
340
+ hasValidation: boolean;
341
+ errorComponent?: JSX.Element | undefined;
342
+ hasError?: boolean | undefined;
343
+ errorPosition?: "afterInput" | "belowLabel" | undefined;
344
+ errorMessage?: string | undefined;
345
+ focusNextFormField: () => void;
346
+ isLastField: () => boolean;
347
+ ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
348
+ nextFormFieldRef?: React.RefObject<any> | undefined;
349
+ };
350
+ export {};
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.useTextInput = void 0;
38
+ const core_1 = require("@react-native-ama/core");
39
+ const internal_1 = require("@react-native-ama/internal");
40
+ const React = __importStar(require("react"));
41
+ const useFormField_1 = require("./useFormField");
42
+ const useTextInput = (_a) => {
43
+ var { onLayout, returnKeyType, onSubmitEditing, accessibilityLabel, requiredMessage, required } = _a, rest = __rest(_a, ["onLayout", "returnKeyType", "onSubmitEditing", "accessibilityLabel", "requiredMessage", "required"]);
44
+ 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"]);
46
+ const handleOnSubmitEditing = (event) => {
47
+ onSubmitEditing === null || onSubmitEditing === void 0 ? void 0 : onSubmitEditing(event);
48
+ formField.focusNextFormField();
49
+ };
50
+ const checkReturnKeyType = (event) => {
51
+ const setReturnKeyTypeAsDone = formField.isLastField() && returnKeyType == null;
52
+ if (setReturnKeyTypeAsDone) {
53
+ setTheReturnKeyType('done');
54
+ }
55
+ onLayout === null || onLayout === void 0 ? void 0 : onLayout(event);
56
+ };
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
+ const fullAccessibilityLabel = required
86
+ ? `${accessibilityLabel}, ${requiredMessage}`
87
+ : accessibilityLabel;
88
+ const advancedProps = {
89
+ accessibilityLabel: fullAccessibilityLabel,
90
+ returnKeyType: theReturnKeyType,
91
+ onSubmitEditing: handleOnSubmitEditing,
92
+ onLayout: checkReturnKeyType,
93
+ blurOnSubmit: theReturnKeyType === 'done',
94
+ };
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);
101
+ };
102
+ exports.useTextInput = useTextInput;
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { FormActions, FormProps } from './components/Form';
3
+ import { FormField, FormFieldProps } from './components/FormField';
4
+ import { FormSubmit, FormSubmitProps } from './components/FormSubmit';
5
+ import { FormSwitchProps } from './components/FormSwitch';
6
+ type FormComponent = React.FunctionComponent<FormProps> & {
7
+ Submit: (props: FormSubmitProps) => JSX.Element;
8
+ Field: React.FunctionComponent<FormFieldProps>;
9
+ Switch: (props: FormSwitchProps) => JSX.Element;
10
+ };
11
+ declare const Form: FormComponent;
12
+ export { Form, FormField, FormSubmit };
13
+ export { TextInput } from './components/TextInput';
14
+ export { useFormField } from './hooks/useFormField';
15
+ export { useTextInput } from './hooks/useTextInput';
16
+ export { type FormProps, type FormActions, type FormFieldProps, type FormSubmitProps, type FormSwitchProps, };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTextInput = exports.useFormField = exports.TextInput = exports.FormSubmit = exports.FormField = exports.Form = void 0;
4
+ // Components
5
+ const Form_1 = require("./components/Form");
6
+ const FormField_1 = require("./components/FormField");
7
+ Object.defineProperty(exports, "FormField", { enumerable: true, get: function () { return FormField_1.FormField; } });
8
+ const FormSubmit_1 = require("./components/FormSubmit");
9
+ Object.defineProperty(exports, "FormSubmit", { enumerable: true, get: function () { return FormSubmit_1.FormSubmit; } });
10
+ const FormSwitch_1 = require("./components/FormSwitch");
11
+ // @ts-ignore
12
+ const Form = Form_1.Form;
13
+ exports.Form = Form;
14
+ Form.Submit = FormSubmit_1.FormSubmit;
15
+ Form.Field = FormField_1.FormField;
16
+ Form.Switch = FormSwitch_1.FormSwitch;
17
+ // Components
18
+ var TextInput_1 = require("./components/TextInput");
19
+ Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return TextInput_1.TextInput; } });
20
+ // Hooks
21
+ var useFormField_1 = require("./hooks/useFormField");
22
+ Object.defineProperty(exports, "useFormField", { enumerable: true, get: function () { return useFormField_1.useFormField; } });
23
+ var useTextInput_1 = require("./hooks/useTextInput");
24
+ Object.defineProperty(exports, "useTextInput", { enumerable: true, get: function () { return useTextInput_1.useTextInput; } });
@@ -0,0 +1,3 @@
1
+ import type { AccessibilityRole } from 'react-native';
2
+ import type { LogParams } from '../utils/logger';
3
+ export declare const checkAccessibilityRole: (accessibilityRole: AccessibilityRole) => LogParams | null;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkAccessibilityRole = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const checkAccessibilityRole = (accessibilityRole) => {
6
+ if (!checkPlatformSupportsRole(accessibilityRole, react_native_1.Platform.OS)) {
7
+ return {
8
+ message: `"${accessibilityRole}" is not a native element for "${react_native_1.Platform.OS}"`,
9
+ rule: 'INCOMPATIBLE_ACCESSIBILITY_ROLE',
10
+ };
11
+ }
12
+ return null;
13
+ };
14
+ exports.checkAccessibilityRole = checkAccessibilityRole;
15
+ const checkPlatformSupportsRole = (role, platform) => {
16
+ const supportedPlatforms = MAPPED_ROLE_CHECKS[role] || [];
17
+ return supportedPlatforms.includes(platform);
18
+ };
19
+ // @ts-ignore
20
+ const MAPPED_ROLE_CHECKS = {
21
+ none: ['ios', 'android'],
22
+ button: ['ios', 'android'],
23
+ switch: ['ios', 'android'],
24
+ checkbox: ['android'],
25
+ tab: ['android', 'ios'],
26
+ togglebutton: ['android'],
27
+ radio: ['android'],
28
+ adjustable: ['ios'],
29
+ link: ['ios', 'android'],
30
+ search: ['ios', 'android'],
31
+ header: ['ios', 'android'],
32
+ };
@@ -0,0 +1,8 @@
1
+ import type React from 'react';
2
+ import type { TextInput } from 'react-native';
3
+ import type { LogParams } from '../utils/logger';
4
+ export type CheckFocusTrap = {
5
+ ref: React.RefObject<TextInput>;
6
+ shouldHaveFocus: boolean;
7
+ };
8
+ export declare const checkFocusTrap: ({ ref, shouldHaveFocus, }: CheckFocusTrap) => Promise<LogParams | null>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.checkFocusTrap = void 0;
13
+ const isFocused_1 = require("../utils/isFocused");
14
+ const checkFocusTrap = ({ ref, shouldHaveFocus, }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ return new Promise(resolve => {
16
+ setTimeout(() => {
17
+ var _a, _b;
18
+ const hasFocus = (0, isFocused_1.isFocused)(ref === null || ref === void 0 ? void 0 : ref.current) === shouldHaveFocus;
19
+ if (!hasFocus) {
20
+ const message = shouldHaveFocus
21
+ ? 'The component did not receive the focus'
22
+ : 'The component did trap the focus';
23
+ resolve({
24
+ rule: 'NO_KEYBOARD_TRAP',
25
+ message,
26
+ // @ts-ignore
27
+ extra: (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a._internalFiberInstanceHandleDEV) === null || _b === void 0 ? void 0 : _b.memoizedProps,
28
+ });
29
+ }
30
+ resolve(null);
31
+ }, 100);
32
+ });
33
+ });
34
+ exports.checkFocusTrap = checkFocusTrap;
@@ -0,0 +1,7 @@
1
+ import type { AccessibilityState } from 'react-native';
2
+ import type { AMAAccessibilityState, AccessibilityRoles } from '../types';
3
+ import type { LogParams } from '../utils/logger';
4
+ export type CheckForAccessibilityState = AMAAccessibilityState & {
5
+ accessibilityState?: AccessibilityState;
6
+ } & AccessibilityRoles;
7
+ export declare const checkForAccessibilityState: ({ accessibilityState, accessibilityRole, ...rest }: CheckForAccessibilityState) => LogParams | null;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.checkForAccessibilityState = void 0;
15
+ const checkForAccessibilityState = (_a) => {
16
+ var { accessibilityState, accessibilityRole } = _a, rest = __rest(_a, ["accessibilityState", "accessibilityRole"]);
17
+ const expectedState = MAPPED_ROLE_CHECKS[accessibilityRole] || {
18
+ accessibilityStates: [],
19
+ };
20
+ const allStates = [
21
+ ...Object.keys(rest || {}),
22
+ ...Object.keys(accessibilityState || {}),
23
+ ].filter(state => state !== 'busy' && state !== 'disabled');
24
+ for (const state of allStates) {
25
+ // @ts-ignore
26
+ const stateValue = rest === null || rest === void 0 ? void 0 : rest[state];
27
+ if (allStates.length > 1 && stateValue === undefined) {
28
+ continue;
29
+ }
30
+ if (!expectedState.accessibilityStates.includes(state)) {
31
+ return {
32
+ message: `The accessibilityState "${state} = ${stateValue}" and the role "${accessibilityRole}" are not compatible.\nCompatible states are: [${expectedState.accessibilityStates.join(', ')}]\nReceived: [${allStates.join(', ')}]`,
33
+ rule: 'INCOMPATIBLE_ACCESSIBILITY_STATE',
34
+ };
35
+ }
36
+ }
37
+ return null;
38
+ };
39
+ exports.checkForAccessibilityState = checkForAccessibilityState;
40
+ // @ts-ignore
41
+ const MAPPED_ROLE_CHECKS = {
42
+ button: { accessibilityStates: ['expanded', 'selected'], required: false },
43
+ togglebutton: { accessibilityStates: ['checked'], required: true },
44
+ switch: { accessibilityStates: ['checked'], required: true },
45
+ checkbox: { accessibilityStates: ['checked'], required: true },
46
+ tab: { accessibilityStates: ['selected'], required: true },
47
+ radio: { accessibilityStates: ['selected'], required: true },
48
+ };