@react-native-ama/forms 1.1.0 → 1.1.3

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.
@@ -41,7 +41,6 @@ const useFormField_1 = require("../hooks/useFormField");
41
41
  const FormField = (_a) => {
42
42
  var { children, wrapInsideAccessibleView = true } = _a, props = __rest(_a, ["children", "wrapInsideAccessibleView"]);
43
43
  const viewRef = React.useRef(null);
44
- // @ts-ignore
45
44
  const formProps = (0, useFormField_1.useFormField)(Object.assign({ hasFocusCallback: false, ref: viewRef }, props));
46
45
  return wrapInsideAccessibleView ? (<react_native_1.TouchableWithoutFeedback {...props} ref={viewRef} {...formProps}>
47
46
  <react_native_1.View accessible>{children}</react_native_1.View>
@@ -1,4 +1,4 @@
1
- import { SwitchListItemProps } from '@react-native-ama/react-native';
1
+ import { type SwitchListItemProps } from '@react-native-ama/react-native';
2
2
  import React from 'react';
3
3
  export type FormSwitchProps = SwitchListItemProps;
4
4
  export declare const FormSwitch: (props: FormSwitchProps) => React.JSX.Element;
@@ -1,26 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { TextInput as RNTextInput, TextInputProps as RNTextInputProps } from 'react-native';
3
- export type TextInputProps = RNTextInputProps & {
3
+ import { UseTextInput } from '../hooks/useTextInput';
4
+ export type TextInputProps = RNTextInputProps & Omit<UseTextInput, 'required' | 'accessibilityLabel'> & {
4
5
  labelComponent: JSX.Element;
5
6
  labelPosition?: 'beforeInput' | 'afterInput';
6
7
  nextFormField?: React.RefObject<RNTextInput>;
7
8
  id?: string;
8
9
  nextFieldId?: string;
9
- hasValidation: boolean;
10
10
  errorComponent?: JSX.Element;
11
- hasError?: boolean;
12
11
  errorPosition?: 'belowLabel' | 'afterInput';
13
- errorMessage?: string;
14
12
  };
15
- export declare const TextInput: React.ForwardRefExoticComponent<RNTextInputProps & {
16
- labelComponent: JSX.Element;
17
- labelPosition?: "beforeInput" | "afterInput" | undefined;
18
- nextFormField?: React.RefObject<RNTextInput> | undefined;
19
- id?: string | undefined;
20
- nextFieldId?: string | undefined;
21
- hasValidation: boolean;
22
- errorComponent?: JSX.Element | undefined;
23
- hasError?: boolean | undefined;
24
- errorPosition?: "afterInput" | "belowLabel" | undefined;
25
- errorMessage?: string | undefined;
26
- } & React.RefAttributes<RNTextInput>>;
13
+ export declare const TextInput: React.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & React.RefAttributes<RNTextInput>>;
@@ -49,12 +49,10 @@ exports.TextInput = React.forwardRef((_a, forwardedRef) => {
49
49
  React.useImperativeHandle(forwardedRef, () => inputRef.current);
50
50
  const showLabelBeforeInput = labelPosition === 'beforeInput';
51
51
  const accessibilityLabel = React.useMemo(() => (0, internal_2.maybeGenerateStringFromElement)(labelComponent, rest.accessibilityLabel), [labelComponent, rest.accessibilityLabel]);
52
- // @ts-ignore
53
- const textInputProps = (0, useTextInput_1.useTextInput)(Object.assign({ required: false, ref: inputRef, id,
52
+ const textInputProps = (0, useTextInput_1.useTextInput)(Object.assign(Object.assign({}, rest), { ref: inputRef, id,
54
53
  nextFieldId, nextFormFieldRef: nextFormField, hasError,
55
54
  hasValidation,
56
- errorMessage,
57
- accessibilityLabel }, rest));
55
+ errorMessage, required: false, accessibilityLabel }));
58
56
  const checks = __DEV__ ? core_2.useChecks === null || core_2.useChecks === void 0 ? void 0 : (0, core_2.useChecks)() : undefined;
59
57
  __DEV__ &&
60
58
  (checks === null || checks === void 0 ? void 0 : checks.noUndefinedProperty({
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { LayoutChangeEvent, NativeSyntheticEvent, ReturnKeyTypeOptions, StyleProp, TextInputSubmitEditingEventData, TextStyle, ViewStyle } from 'react-native';
3
3
  import { UseFormField } from './useFormField';
4
- type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
4
+ export type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
5
5
  onLayout?: (event: LayoutChangeEvent) => void;
6
6
  returnKeyType?: ReturnKeyTypeOptions;
7
7
  onSubmitEditing?: (event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void;
@@ -22,6 +22,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
22
22
  autoCorrect?: boolean | undefined;
23
23
  autoFocus?: boolean | undefined;
24
24
  blurOnSubmit?: boolean | undefined;
25
+ submitBehavior?: import("react-native").SubmitBehavior | undefined;
25
26
  caretHidden?: boolean | undefined;
26
27
  contextMenuHidden?: boolean | undefined;
27
28
  defaultValue?: string | undefined;
@@ -40,7 +41,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
40
41
  onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
41
42
  onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
42
43
  onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
43
- onSubmitEditing?: ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefined;
44
+ onSubmitEditing?: (((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) & ((event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)) | undefined;
44
45
  onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
45
46
  onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
46
47
  placeholder?: string | undefined;
@@ -64,7 +65,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
64
65
  hitSlop?: number | import("react-native").Insets | null | undefined;
65
66
  id?: string | undefined;
66
67
  needsOffscreenAlphaCompositing?: boolean | undefined;
67
- onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
68
+ onLayout?: (((event: LayoutChangeEvent) => void) & ((event: LayoutChangeEvent) => void)) | undefined;
68
69
  pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
69
70
  removeClippedSubviews?: boolean | undefined;
70
71
  nativeID?: string | undefined;
@@ -145,6 +146,8 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
145
146
  onMagicTap?: (() => void) | undefined;
146
147
  accessibilityIgnoresInvertColors?: boolean | undefined;
147
148
  accessibilityLanguage?: string | undefined;
149
+ accessibilityShowsLargeContentViewer?: boolean | undefined;
150
+ accessibilityLargeContentTitle?: string | undefined;
148
151
  clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
149
152
  clearTextOnFocus?: boolean | undefined;
150
153
  dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
@@ -171,20 +174,21 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
171
174
  textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
172
175
  showSoftInputOnFocus?: boolean | undefined;
173
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;
174
185
  labelComponent?: JSX.Element | undefined;
175
186
  labelPosition?: "beforeInput" | "afterInput" | undefined;
176
187
  nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
177
- nextFieldId?: string | undefined;
178
- hasValidation: boolean;
179
188
  errorComponent?: JSX.Element | undefined;
180
- hasError?: boolean | undefined;
181
189
  errorPosition?: "afterInput" | "belowLabel" | undefined;
182
- errorMessage?: string | undefined;
183
190
  focusNextFormField: () => void;
184
191
  isLastField: () => boolean;
185
- ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
186
- suppressError?: boolean | undefined;
187
- nextFormFieldRef?: React.RefObject<any> | undefined;
188
192
  } | {
189
193
  allowFontScaling?: boolean | undefined;
190
194
  autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
@@ -192,6 +196,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
192
196
  autoCorrect?: boolean | undefined;
193
197
  autoFocus?: boolean | undefined;
194
198
  blurOnSubmit?: boolean | undefined;
199
+ submitBehavior?: import("react-native").SubmitBehavior | undefined;
195
200
  caretHidden?: boolean | undefined;
196
201
  contextMenuHidden?: boolean | undefined;
197
202
  defaultValue?: string | undefined;
@@ -210,7 +215,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
210
215
  onPressOut?: ((e: NativeSyntheticEvent<import("react-native").NativeTouchEvent>) => void) | undefined;
211
216
  onFocus?: ((e: NativeSyntheticEvent<import("react-native").TextInputFocusEventData>) => void) | undefined;
212
217
  onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
213
- onSubmitEditing?: ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefined;
218
+ onSubmitEditing?: (((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) & ((event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)) | undefined;
214
219
  onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
215
220
  onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
216
221
  placeholder?: string | undefined;
@@ -225,7 +230,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
225
230
  end?: number | undefined;
226
231
  } | undefined;
227
232
  selectionColor?: import("react-native").ColorValue | undefined;
228
- style?: false | "" | ViewStyle | import("react-native").RegisteredStyle<TextStyle> | import("react-native").RecursiveArray<import("react-native").Falsy | TextStyle | import("react-native").RegisteredStyle<TextStyle>> | null | undefined;
233
+ style?: ViewStyle | undefined;
229
234
  textAlign?: "center" | "left" | "right" | undefined;
230
235
  testID?: string | undefined;
231
236
  inputAccessoryViewID?: string | undefined;
@@ -235,7 +240,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
235
240
  hitSlop?: number | import("react-native").Insets | null | undefined;
236
241
  id?: string | undefined;
237
242
  needsOffscreenAlphaCompositing?: boolean | undefined;
238
- onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
243
+ onLayout?: (((event: LayoutChangeEvent) => void) & ((event: LayoutChangeEvent) => void)) | undefined;
239
244
  pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
240
245
  removeClippedSubviews?: boolean | undefined;
241
246
  nativeID?: string | undefined;
@@ -316,6 +321,8 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
316
321
  onMagicTap?: (() => void) | undefined;
317
322
  accessibilityIgnoresInvertColors?: boolean | undefined;
318
323
  accessibilityLanguage?: string | undefined;
324
+ accessibilityShowsLargeContentViewer?: boolean | undefined;
325
+ accessibilityLargeContentTitle?: string | undefined;
319
326
  clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
320
327
  clearTextOnFocus?: boolean | undefined;
321
328
  dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
@@ -342,19 +349,19 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
342
349
  textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
343
350
  showSoftInputOnFocus?: boolean | undefined;
344
351
  verticalAlign?: "auto" | "top" | "bottom" | "middle" | undefined;
352
+ ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
353
+ suppressError?: boolean | undefined;
354
+ hasValidation: boolean;
355
+ hasError?: boolean | undefined;
356
+ nextFieldId?: string | undefined;
357
+ nextFormFieldRef?: React.RefObject<any> | undefined;
358
+ errorMessage?: string | undefined;
359
+ requiredMessage?: string | undefined;
345
360
  labelComponent?: JSX.Element | undefined;
346
361
  labelPosition?: "beforeInput" | "afterInput" | undefined;
347
362
  nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
348
- nextFieldId?: string | undefined;
349
- hasValidation: boolean;
350
363
  errorComponent?: JSX.Element | undefined;
351
- hasError?: boolean | undefined;
352
364
  errorPosition?: "afterInput" | "belowLabel" | undefined;
353
- errorMessage?: string | undefined;
354
365
  focusNextFormField: () => void;
355
366
  isLastField: () => boolean;
356
- ref?: React.RefObject<any> | React.ForwardedRef<any> | undefined;
357
- suppressError?: boolean | undefined;
358
- nextFormFieldRef?: React.RefObject<any> | undefined;
359
367
  };
360
- export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { isFocused } from '@react-native-ama/internal';
3
- import { FormActions, FormProps } from './components/Form';
3
+ import { FormActions, type FormProps } from './components/Form';
4
4
  import { FormField, FormFieldProps } from './components/FormField';
5
5
  import { FormSubmit, FormSubmitProps } from './components/FormSubmit';
6
6
  import { FormSwitch, FormSwitchProps } from './components/FormSwitch';
@@ -11,8 +11,8 @@ type FormComponent = React.FunctionComponent<FormProps> & {
11
11
  };
12
12
  declare const Form: FormComponent;
13
13
  export { Form, FormField, FormSubmit, FormSwitch };
14
- export { TextInput } from './components/TextInput';
15
- export { useFormField } from './hooks/useFormField';
16
- export { useTextInput } from './hooks/useTextInput';
14
+ export { TextInput, type TextInputProps } from './components/TextInput';
15
+ export { useFormField, type UseFormField } from './hooks/useFormField';
16
+ export { useTextInput, type UseTextInput } from './hooks/useTextInput';
17
17
  export { isFocused };
18
18
  export { type FormProps, type FormActions, type FormFieldProps, type FormSubmitProps, type FormSwitchProps, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ama/forms",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "react-native": "src/index",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  "test": "jest"
24
24
  },
25
25
  "dependencies": {
26
- "@react-native-ama/core": "~1.1.0",
27
- "@react-native-ama/internal": "~1.1.0",
28
- "@react-native-ama/react-native": "~1.1.0"
26
+ "@react-native-ama/core": "~1.1.3",
27
+ "@react-native-ama/internal": "~1.1.3",
28
+ "@react-native-ama/react-native": "~1.1.3"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": "*",
@@ -26,7 +26,6 @@ export const FormField = ({
26
26
  typeof TouchableWithoutFeedback
27
27
  > | null>(null);
28
28
 
29
- // @ts-ignore
30
29
  const formProps = useFormField({
31
30
  hasFocusCallback: false,
32
31
  ref: viewRef,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SwitchListItem,
3
- SwitchListItemProps,
3
+ type SwitchListItemProps,
4
4
  } from '@react-native-ama/react-native';
5
5
  import React from 'react';
6
6
 
@@ -8,20 +8,18 @@ import {
8
8
  TextInputProps as RNTextInputProps,
9
9
  } from 'react-native';
10
10
 
11
- import { useTextInput } from '../hooks/useTextInput';
11
+ import { UseTextInput, useTextInput } from '../hooks/useTextInput';
12
12
 
13
- export type TextInputProps = RNTextInputProps & {
14
- labelComponent: JSX.Element;
15
- labelPosition?: 'beforeInput' | 'afterInput';
16
- nextFormField?: React.RefObject<RNTextInput>;
17
- id?: string;
18
- nextFieldId?: string;
19
- hasValidation: boolean;
20
- errorComponent?: JSX.Element;
21
- hasError?: boolean;
22
- errorPosition?: 'belowLabel' | 'afterInput';
23
- errorMessage?: string;
24
- };
13
+ export type TextInputProps = RNTextInputProps &
14
+ Omit<UseTextInput, 'required' | 'accessibilityLabel'> & {
15
+ labelComponent: JSX.Element;
16
+ labelPosition?: 'beforeInput' | 'afterInput';
17
+ nextFormField?: React.RefObject<RNTextInput>;
18
+ id?: string;
19
+ nextFieldId?: string;
20
+ errorComponent?: JSX.Element;
21
+ errorPosition?: 'belowLabel' | 'afterInput';
22
+ };
25
23
 
26
24
  export const TextInput = React.forwardRef<RNTextInput, TextInputProps>(
27
25
  (
@@ -55,9 +53,8 @@ export const TextInput = React.forwardRef<RNTextInput, TextInputProps>(
55
53
  [labelComponent, rest.accessibilityLabel],
56
54
  );
57
55
 
58
- // @ts-ignore
59
56
  const textInputProps = useTextInput({
60
- required: false,
57
+ ...rest,
61
58
  ref: inputRef,
62
59
  id,
63
60
  nextFieldId,
@@ -65,8 +62,8 @@ export const TextInput = React.forwardRef<RNTextInput, TextInputProps>(
65
62
  hasError,
66
63
  hasValidation,
67
64
  errorMessage,
65
+ required: false,
68
66
  accessibilityLabel,
69
- ...rest,
70
67
  });
71
68
 
72
69
  const checks = __DEV__ ? useChecks?.() : undefined;
@@ -14,7 +14,7 @@ import type {
14
14
  import { TextInputProps } from '../components/TextInput';
15
15
  import { UseFormField, useFormField } from './useFormField';
16
16
 
17
- type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
17
+ export type UseTextInput = Omit<UseFormField, 'hasFocusCallback'> & {
18
18
  onLayout?: (event: LayoutChangeEvent) => void;
19
19
  returnKeyType?: ReturnKeyTypeOptions;
20
20
  onSubmitEditing?: (
package/src/index.ts CHANGED
@@ -4,8 +4,8 @@ import { isFocused } from '@react-native-ama/internal';
4
4
 
5
5
  import {
6
6
  FormActions,
7
- FormProps,
8
7
  Form as FormProvider,
8
+ type FormProps,
9
9
  } from './components/Form';
10
10
  import { FormField, FormFieldProps } from './components/FormField';
11
11
  import { FormSubmit, FormSubmitProps } from './components/FormSubmit';
@@ -26,11 +26,11 @@ Form.Switch = FormSwitch;
26
26
  export { Form, FormField, FormSubmit, FormSwitch };
27
27
 
28
28
  // Components
29
- export { TextInput } from './components/TextInput';
29
+ export { TextInput, type TextInputProps } from './components/TextInput';
30
30
 
31
31
  // Hooks
32
- export { useFormField } from './hooks/useFormField';
33
- export { useTextInput } from './hooks/useTextInput';
32
+ export { useFormField, type UseFormField } from './hooks/useFormField';
33
+ export { useTextInput, type UseTextInput } from './hooks/useTextInput';
34
34
 
35
35
  // utils
36
36
  export { isFocused };