@nestledjs/forms-native 0.1.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 (37) hide show
  1. package/index.d.ts +38 -0
  2. package/index.js +4077 -0
  3. package/lib/fields/button-field.d.ts +4 -0
  4. package/lib/fields/button.d.ts +16 -0
  5. package/lib/fields/checkbox-field.d.ts +12 -0
  6. package/lib/fields/checkbox-group.d.ts +7 -0
  7. package/lib/fields/content-field.d.ts +6 -0
  8. package/lib/fields/custom-checkbox-field.d.ts +8 -0
  9. package/lib/fields/custom-field.d.ts +12 -0
  10. package/lib/fields/datepicker-field.d.ts +8 -0
  11. package/lib/fields/datetimepicker-field.d.ts +8 -0
  12. package/lib/fields/email-field.d.ts +7 -0
  13. package/lib/fields/label.d.ts +15 -0
  14. package/lib/fields/markdown-editor.d.ts +7 -0
  15. package/lib/fields/money-field.d.ts +7 -0
  16. package/lib/fields/number-field.d.ts +7 -0
  17. package/lib/fields/password-field.d.ts +7 -0
  18. package/lib/fields/phone-field.d.ts +14 -0
  19. package/lib/fields/radio-field.d.ts +7 -0
  20. package/lib/fields/select-field-enum.d.ts +7 -0
  21. package/lib/fields/select-field-multi-search-apollo.d.ts +16 -0
  22. package/lib/fields/select-field-multi-search.d.ts +7 -0
  23. package/lib/fields/select-field-multi.d.ts +7 -0
  24. package/lib/fields/select-field-search-apollo.d.ts +10 -0
  25. package/lib/fields/select-field-search.d.ts +7 -0
  26. package/lib/fields/select-field.d.ts +7 -0
  27. package/lib/fields/switch-field.d.ts +7 -0
  28. package/lib/fields/text-field.d.ts +7 -0
  29. package/lib/fields/textarea-field.d.ts +7 -0
  30. package/lib/fields/timepicker-field.d.ts +11 -0
  31. package/lib/fields/url-field.d.ts +7 -0
  32. package/lib/form.d.ts +32 -0
  33. package/lib/native-theme-context.d.ts +928 -0
  34. package/lib/render-form-field.d.ts +10 -0
  35. package/lib/themes/default.d.ts +933 -0
  36. package/lib/utils/resolve-theme.d.ts +11 -0
  37. package/package.json +62 -0
@@ -0,0 +1,4 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function ButtonField({ field, form, hasError, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Button;
4
+ }>>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+ export interface ButtonProps {
4
+ children?: React.ReactNode;
5
+ variant?: 'primary' | 'secondary' | 'danger';
6
+ disabled?: boolean;
7
+ loading?: boolean;
8
+ fullWidth?: boolean;
9
+ onPress?: () => void;
10
+ style?: ViewStyle;
11
+ textStyle?: TextStyle;
12
+ className?: string;
13
+ type?: 'button' | 'submit' | 'reset';
14
+ accessibilityLabel?: string;
15
+ }
16
+ export declare function Button({ children, variant, disabled, loading, fullWidth, onPress, style, textStyle, className, accessibilityLabel, }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ type CheckboxFieldType = Extract<FormField, {
3
+ type: FormFieldType.Checkbox;
4
+ }>;
5
+ interface CheckboxFieldProps extends Omit<FormFieldProps<CheckboxFieldType>, 'hasError'> {
6
+ hasError?: boolean;
7
+ errorMessage?: string;
8
+ formReadOnly?: boolean;
9
+ formReadOnlyStyle?: 'value' | 'disabled';
10
+ }
11
+ export declare function CheckboxField(props: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function CheckboxGroupField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.CheckboxGroup;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { FormField, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function ContentField({ field, }: {
3
+ field: Extract<FormField, {
4
+ type: FormFieldType.Content;
5
+ }>;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function CustomCheckboxField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.CustomCheckbox;
4
+ }>> & {
5
+ hasError?: boolean;
6
+ formReadOnly?: boolean;
7
+ formReadOnlyStyle?: 'value' | 'disabled';
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
3
+ export declare function CustomField<T = unknown>({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
4
+ type: FormFieldType.Custom;
5
+ }>> & {
6
+ hasError?: boolean;
7
+ formReadOnly?: boolean;
8
+ formReadOnlyStyle?: 'value' | 'disabled';
9
+ }): React.JSX.Element;
10
+ export declare namespace CustomField {
11
+ var displayName: string;
12
+ }
@@ -0,0 +1,8 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function DatePickerField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.DatePicker;
4
+ }>> & {
5
+ hasError?: boolean;
6
+ formReadOnly?: boolean;
7
+ formReadOnlyStyle?: 'value' | 'disabled';
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function DateTimePickerField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.DateTimePicker;
4
+ }>> & {
5
+ hasError?: boolean;
6
+ formReadOnly?: boolean;
7
+ formReadOnlyStyle?: 'value' | 'disabled';
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function EmailField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Email;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ViewStyle, TextStyle } from 'react-native';
2
+ interface FormLabelProps {
3
+ fieldKey: string;
4
+ label: string;
5
+ required?: boolean;
6
+ unstyled?: boolean;
7
+ containerStyle?: ViewStyle;
8
+ labelStyle?: TextStyle;
9
+ requiredIndicatorStyle?: TextStyle;
10
+ containerClassName?: string;
11
+ labelClassName?: string;
12
+ requiredIndicatorClassName?: string;
13
+ }
14
+ export declare function FormLabel({ fieldKey, label, required, unstyled, containerStyle, labelStyle, requiredIndicatorStyle, containerClassName, labelClassName, requiredIndicatorClassName, }: FormLabelProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function MarkdownEditor({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.MarkdownEditor;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldType, FormFieldProps } from '../../../../forms-core/src/index.ts';
2
+ export declare function MoneyField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Currency;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function NumberField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Number;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function PasswordField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Password;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ /**
3
+ * Phone field using a basic TextInput with phone-pad keyboard.
4
+ * For full country-picker support, consumers should install
5
+ * `react-native-phone-number-input` and use a CustomField.
6
+ * This basic implementation handles phone input with validation
7
+ * delegated to forms-core.
8
+ */
9
+ export declare function PhoneField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
10
+ type: FormFieldType.Phone;
11
+ }>> & {
12
+ formReadOnly?: boolean;
13
+ formReadOnlyStyle?: 'value' | 'disabled';
14
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormFieldProps, FormField, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function RadioField(props: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Radio;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectFieldEnum({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.EnumSelect;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function multiSelectSubmitTransform(value: any): string[];
3
+ export declare const apolloMultiSelectSubmitTransform: typeof multiSelectSubmitTransform;
4
+ type RequiredItemShape = {
5
+ id: string;
6
+ name?: string;
7
+ firstName?: string;
8
+ lastName?: string;
9
+ };
10
+ export declare function SelectFieldMultiSearchApollo<TDataItem extends RequiredItemShape>({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
11
+ type: FormFieldType.SearchSelectMultiApollo;
12
+ }>> & {
13
+ formReadOnly?: boolean;
14
+ formReadOnlyStyle?: 'value' | 'disabled';
15
+ }): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectFieldMultiSearch({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.SearchSelectMulti;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectFieldMulti({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.MultiSelect;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectFieldSearchApollo<TDataItem extends {
3
+ id: string;
4
+ name?: string;
5
+ }>({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
6
+ type: FormFieldType.SearchSelectApollo;
7
+ }>> & {
8
+ formReadOnly?: boolean;
9
+ formReadOnlyStyle?: 'value' | 'disabled';
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectFieldSearch({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.SearchSelect;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SelectField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Select;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function SwitchField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Switch;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function TextField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Text;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function TextAreaField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.TextArea;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { FormFieldProps, FormFieldType, BaseFieldOptions } from '../../../../forms-core/src/index.ts';
2
+ interface TimePickerFieldType {
3
+ key: string;
4
+ type: FormFieldType.TimePicker;
5
+ options: BaseFieldOptions;
6
+ }
7
+ export declare function TimePickerField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<TimePickerFieldType> & {
8
+ formReadOnly?: boolean;
9
+ formReadOnlyStyle?: 'value' | 'disabled';
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FormField, FormFieldProps, FormFieldType } from '../../../../forms-core/src/index.ts';
2
+ export declare function UrlField({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
3
+ type: FormFieldType.Url;
4
+ }>> & {
5
+ formReadOnly?: boolean;
6
+ formReadOnlyStyle?: 'value' | 'disabled';
7
+ }): import("react/jsx-runtime").JSX.Element;
package/lib/form.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { default as React } from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ import { UseFormProps, FieldValues } from 'react-hook-form';
4
+ import { FormField } from '../../../forms-core/src/index.ts';
5
+ import { ZodTypeAny } from 'zod';
6
+ import { NativeTheme } from './themes/default';
7
+ type DeepPartial<T> = {
8
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
9
+ };
10
+ export interface NativeFormProps<T extends FieldValues = Record<string, unknown>> extends UseFormProps<T> {
11
+ id: string;
12
+ fields?: (FormField | null)[];
13
+ children?: React.ReactNode;
14
+ submit: (values: T) => void | Promise<unknown>;
15
+ style?: ViewStyle;
16
+ className?: string;
17
+ readOnly?: boolean;
18
+ readOnlyStyle?: 'value' | 'disabled';
19
+ nativeTheme?: DeepPartial<NativeTheme>;
20
+ labelDisplay?: 'all' | 'default' | 'none';
21
+ schema?: ZodTypeAny;
22
+ validationGroup?: string;
23
+ validationGroups?: string[];
24
+ }
25
+ /**
26
+ * React Native Form component. Wraps fields in a View (no <form> element in RN).
27
+ * Provides FormContext, ThemeContext, FormConfigContext, and NativeThemeContext.
28
+ * Submission is handled via form.handleSubmit() — consumers typically wire a
29
+ * ButtonField with type="submit" that calls form.handleSubmit().
30
+ */
31
+ export declare function NativeForm<T extends FieldValues = Record<string, unknown>>({ id, fields, children, submit, defaultValues, style, className, readOnly, readOnlyStyle: formReadOnlyStyle, nativeTheme: userNativeTheme, labelDisplay, schema, validationGroup, validationGroups, }: Readonly<NativeFormProps<T>>): import("react/jsx-runtime").JSX.Element;
32
+ export {};