@wix/form-public 0.39.0 → 0.41.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.
@@ -1,9 +1,13 @@
1
1
  import { ErrorType } from '@wix/ambassador-forms-v1-validation-result/types';
2
- import { FieldType } from '@wix/form-fields';
3
- import { Form as Form_2 } from '@wix/ambassador-forms-v4-form/types';
2
+ import { Form } from '@wix/ambassador-forms-v4-form/types';
3
+ import { FormFields } from '@wix/form-fields';
4
4
  import { JSX as JSX_2 } from 'react/jsx-runtime';
5
+ import { Layout } from '@wix/form-fields';
6
+ import { default as React_2 } from 'react';
7
+ import { ReactElement } from 'react';
5
8
  import { requests } from '@wix/ambassador-forms-v4-submission/build/cjs/proto/client/proto-generated';
6
9
  import { RichContent } from '@wix/ricos';
10
+ import { FieldType as SchemaFieldType } from '@wix/form-fields';
7
11
 
8
12
  export declare const AppointmentMapper: PropsMapper;
9
13
 
@@ -688,9 +692,43 @@ export declare const ErrorMapper: PropsMapper;
688
692
 
689
693
  export declare const FIELD_PROP_MAP: FieldMappers;
690
694
 
691
- export declare const FIELD_TYPE_MAP: Record<FieldType, string>;
695
+ export declare const FIELD_TYPE_MAP: Record<SchemaFieldType, FieldType>;
692
696
 
693
- export declare type FieldMappers = Record<string, PropsMapper>;
697
+ declare type FieldMap = {
698
+ TEXT_INPUT: React.ComponentType<TextInputProps>;
699
+ TEXT_AREA: React.ComponentType<TextAreaProps>;
700
+ PHONE_INPUT: React.ComponentType<PhoneInputProps>;
701
+ MULTILINE_ADDRESS: React.ComponentType<MultilineAddressProps>;
702
+ DATE_INPUT: React.ComponentType<DateInputProps>;
703
+ DATE_PICKER: React.ComponentType<DatePickerProps>;
704
+ DATE_TIME_INPUT: React.ComponentType<DateTimeInputProps>;
705
+ FILE_UPLOAD: React.ComponentType<FileUploadProps>;
706
+ NUMBER_INPUT: React.ComponentType<NumberInputProps>;
707
+ CHECKBOX: React.ComponentType<CheckboxProps>;
708
+ SIGNATURE: React.ComponentType<SignatureProps>;
709
+ RATING_INPUT: React.ComponentType<RatingInputProps>;
710
+ RADIO_GROUP: React.ComponentType<RadioGroupProps>;
711
+ CHECKBOX_GROUP: React.ComponentType<CheckboxGroupProps>;
712
+ DROPDOWN: React.ComponentType<DropdownProps>;
713
+ TAGS: React.ComponentType<TagsProps>;
714
+ TIME_INPUT: React.ComponentType<TimeInputProps>;
715
+ TEXT: React.ComponentType<RichTextProps>;
716
+ SUBMIT_BUTTON: React.ComponentType<SubmitButtonProps>;
717
+ PRODUCT_LIST: React.ComponentType<ProductListProps>;
718
+ FIXED_PAYMENT: React.ComponentType<FixedPaymentProps>;
719
+ PAYMENT_INPUT: React.ComponentType<PaymentInputProps>;
720
+ DONATION: React.ComponentType<DonationProps>;
721
+ APPOINTMENT: React.ComponentType<AppointmentProps>;
722
+ IMAGE_CHOICE: React.ComponentType<ImageChoiceProps>;
723
+ };
724
+ export { FieldMap }
725
+ export { FieldMap as FieldMap_alias_1 }
726
+
727
+ export declare type FieldMappers = Record<FieldType, PropsMapper>;
728
+
729
+ export declare type FieldProps = TextInputProps | TextAreaProps | PhoneInputProps | MultilineAddressProps | DateInputProps | DatePickerProps | DateTimeInputProps | FileUploadProps | NumberInputProps | CheckboxProps | SignatureProps | RatingInputProps | RadioGroupProps | CheckboxGroupProps | DropdownProps | TagsProps | TimeInputProps | RichTextProps | SubmitButtonProps | ProductListProps | FixedPaymentProps | PaymentInputProps | DonationProps | AppointmentProps | ImageChoiceProps;
730
+
731
+ export declare type FieldType = 'TEXT_INPUT' | 'TEXT_AREA' | 'PHONE_INPUT' | 'MULTILINE_ADDRESS' | 'DATE_INPUT' | 'DATE_PICKER' | 'DATE_TIME_INPUT' | 'TIME_INPUT' | 'FILE_UPLOAD' | 'NUMBER_INPUT' | 'CHECKBOX' | 'SIGNATURE' | 'RATING_INPUT' | 'RADIO_GROUP' | 'CHECKBOX_GROUP' | 'DROPDOWN' | 'TAGS' | 'SUBMIT_BUTTON' | 'PRODUCT_LIST' | 'FIXED_PAYMENT' | 'PAYMENT_INPUT' | 'DONATION' | 'APPOINTMENT' | 'IMAGE_CHOICE' | 'TEXT' | '';
694
732
 
695
733
  /**
696
734
  * Data structure for uploaded file information.
@@ -814,10 +852,6 @@ declare interface FixedPaymentProps {
814
852
  export { FixedPaymentProps }
815
853
  export { FixedPaymentProps as FixedPaymentProps_alias_1 }
816
854
 
817
- declare const Form: ({ form: unformattedForm, fields, values, onChange, errors, onValidate, submitForm, }: FormProps) => JSX_2.Element;
818
- export { Form }
819
- export { Form as Form_alias_1 }
820
-
821
855
  declare interface FormError {
822
856
  errorPath: string;
823
857
  errorType: ErrorType;
@@ -828,47 +862,9 @@ declare interface FormError {
828
862
  export { FormError }
829
863
  export { FormError as FormError_alias_1 }
830
864
 
831
- declare type FormFields = {
832
- TEXT_INPUT: React.ComponentType<TextInputProps>;
833
- TEXT_AREA: React.ComponentType<TextAreaProps>;
834
- PHONE_INPUT: React.ComponentType<PhoneInputProps>;
835
- MULTILINE_ADDRESS: React.ComponentType<MultilineAddressProps>;
836
- DATE_INPUT: React.ComponentType<DateInputProps>;
837
- DATE_PICKER: React.ComponentType<DatePickerProps>;
838
- DATE_TIME_INPUT: React.ComponentType<DateTimeInputProps>;
839
- FILE_UPLOAD: React.ComponentType<FileUploadProps>;
840
- NUMBER_INPUT: React.ComponentType<NumberInputProps>;
841
- CHECKBOX: React.ComponentType<CheckboxProps>;
842
- SIGNATURE: React.ComponentType<SignatureProps>;
843
- RATING_INPUT: React.ComponentType<RatingInputProps>;
844
- RADIO_GROUP: React.ComponentType<RadioGroupProps>;
845
- CHECKBOX_GROUP: React.ComponentType<CheckboxGroupProps>;
846
- DROPDOWN: React.ComponentType<DropdownProps>;
847
- TAGS: React.ComponentType<TagsProps>;
848
- TIME_INPUT: React.ComponentType<TimeInputProps>;
849
- TEXT: React.ComponentType<RichTextProps>;
850
- SUBMIT_BUTTON: React.ComponentType<SubmitButtonProps>;
851
- PRODUCT_LIST: React.ComponentType<ProductListProps>;
852
- FIXED_PAYMENT: React.ComponentType<FixedPaymentProps>;
853
- PAYMENT_INPUT: React.ComponentType<PaymentInputProps>;
854
- DONATION: React.ComponentType<DonationProps>;
855
- APPOINTMENT: React.ComponentType<AppointmentProps>;
856
- IMAGE_CHOICE: React.ComponentType<ImageChoiceProps>;
857
- };
858
- export { FormFields }
859
- export { FormFields as FormFields_alias_1 }
860
-
861
- declare type FormProps = {
862
- form?: Form_2;
863
- values: FormValues;
864
- onChange: OnChange;
865
- errors: FormError[];
866
- onValidate: (errors: FormError[]) => void;
867
- fields: FormFields;
868
- submitForm: () => void;
869
- };
870
- export { FormProps }
871
- export { FormProps as FormProps_alias_1 }
865
+ declare const FormProvider: ({ children }: Props) => JSX_2.Element;
866
+ export { FormProvider }
867
+ export { FormProvider as FormProvider_alias_1 }
872
868
 
873
869
  declare type FormValues = {
874
870
  [target: string]: PossibleValues;
@@ -1053,6 +1049,10 @@ declare interface ImageChoiceProps extends BaseFieldProps {
1053
1049
  export { ImageChoiceProps }
1054
1050
  export { ImageChoiceProps as ImageChoiceProps_alias_1 }
1055
1051
 
1052
+ export declare const mapFieldProps: (fields: FieldMap, mappers: FieldMappers) => FormFields;
1053
+
1054
+ export declare const mapFieldTypes: (fields: FormFields, typeMap: Record<SchemaFieldType, string>) => Record<string, React_2.ComponentType<any>>;
1055
+
1056
1056
  declare interface MinMaxLengthProps {
1057
1057
  minLength: number | undefined;
1058
1058
  maxLength: number | undefined;
@@ -1352,7 +1352,7 @@ export declare const ProductListMapper: PropsMapper;
1352
1352
  * ```
1353
1353
  */
1354
1354
  declare interface ProductListProps extends BaseFieldProps {
1355
- value: ProductValue_2 | null | undefined;
1355
+ value: ProductValue | null | undefined;
1356
1356
  label: string;
1357
1357
  showLabel: boolean;
1358
1358
  description?: RichContent;
@@ -1382,13 +1382,11 @@ export declare type ProductValue = {
1382
1382
  quantity: number;
1383
1383
  };
1384
1384
 
1385
- declare interface ProductValue_2 {
1386
- productId: string;
1387
- price: string | number;
1388
- quantity: number;
1389
- }
1385
+ declare type Props = {
1386
+ children: React_2.ReactNode;
1387
+ };
1390
1388
 
1391
- export declare type PropsMapper = (props: any) => any;
1389
+ export declare type PropsMapper = (props: any) => FieldProps;
1392
1390
 
1393
1391
  export declare const RadioGroupMapper: PropsMapper;
1394
1392
 
@@ -1489,10 +1487,13 @@ export { RatingInputProps as RatingInputProps_alias_1 }
1489
1487
  declare interface RichTextProps {
1490
1488
  content: RichContent;
1491
1489
  maxShownParagraphs: number;
1490
+ id: string;
1492
1491
  }
1493
1492
  export { RichTextProps }
1494
1493
  export { RichTextProps as RichTextProps_alias_1 }
1495
1494
 
1495
+ export { SchemaFieldType }
1496
+
1496
1497
  export declare const SignatureMapper: PropsMapper;
1497
1498
 
1498
1499
  /**
@@ -1778,6 +1779,26 @@ declare interface TimeInputProps extends BaseFieldProps {
1778
1779
  export { TimeInputProps }
1779
1780
  export { TimeInputProps as TimeInputProps_alias_1 }
1780
1781
 
1782
+ declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, fieldMap: fields, }: UseFormProps) => UseFormReturn;
1783
+ export { useForm }
1784
+ export { useForm as useForm_alias_1 }
1785
+
1786
+ export declare type UseFormProps = {
1787
+ form: Form;
1788
+ values: FormValues;
1789
+ onChange: OnChange;
1790
+ errors: FormError[];
1791
+ onValidate: (errors: FormError[]) => void;
1792
+ submitForm: () => void;
1793
+ fieldMap: FieldMap;
1794
+ };
1795
+
1796
+ declare type UseFormReturn = {
1797
+ columnCount: number;
1798
+ fieldElements: ReactElement[][];
1799
+ fieldsLayout: Record<string, Layout>;
1800
+ } | null;
1801
+
1781
1802
  export declare type ValueType = string | number | boolean | string[] | null | undefined | VatIDValue | ProductListValue | WixFile[] | MultilineAddressSubmission | AppointmentSubmitData;
1782
1803
 
1783
1804
  export declare type VatIDValue = {
@@ -1,9 +1,13 @@
1
1
  import { ErrorType } from '@wix/ambassador-forms-v1-validation-result/types';
2
- import { FieldType } from '@wix/form-fields';
3
- import { Form as Form_2 } from '@wix/ambassador-forms-v4-form/types';
2
+ import { Form } from '@wix/ambassador-forms-v4-form/types';
3
+ import { FormFields } from '@wix/form-fields';
4
4
  import { JSX as JSX_2 } from 'react/jsx-runtime';
5
+ import { Layout } from '@wix/form-fields';
6
+ import { default as React_2 } from 'react';
7
+ import { ReactElement } from 'react';
5
8
  import { requests } from '@wix/ambassador-forms-v4-submission/build/cjs/proto/client/proto-generated';
6
9
  import { RichContent } from '@wix/ricos';
10
+ import { FieldType as SchemaFieldType } from '@wix/form-fields';
7
11
 
8
12
  export declare const AppointmentMapper: PropsMapper;
9
13
 
@@ -688,9 +692,43 @@ export declare const ErrorMapper: PropsMapper;
688
692
 
689
693
  export declare const FIELD_PROP_MAP: FieldMappers;
690
694
 
691
- export declare const FIELD_TYPE_MAP: Record<FieldType, string>;
695
+ export declare const FIELD_TYPE_MAP: Record<SchemaFieldType, FieldType>;
692
696
 
693
- export declare type FieldMappers = Record<string, PropsMapper>;
697
+ declare type FieldMap = {
698
+ TEXT_INPUT: React.ComponentType<TextInputProps>;
699
+ TEXT_AREA: React.ComponentType<TextAreaProps>;
700
+ PHONE_INPUT: React.ComponentType<PhoneInputProps>;
701
+ MULTILINE_ADDRESS: React.ComponentType<MultilineAddressProps>;
702
+ DATE_INPUT: React.ComponentType<DateInputProps>;
703
+ DATE_PICKER: React.ComponentType<DatePickerProps>;
704
+ DATE_TIME_INPUT: React.ComponentType<DateTimeInputProps>;
705
+ FILE_UPLOAD: React.ComponentType<FileUploadProps>;
706
+ NUMBER_INPUT: React.ComponentType<NumberInputProps>;
707
+ CHECKBOX: React.ComponentType<CheckboxProps>;
708
+ SIGNATURE: React.ComponentType<SignatureProps>;
709
+ RATING_INPUT: React.ComponentType<RatingInputProps>;
710
+ RADIO_GROUP: React.ComponentType<RadioGroupProps>;
711
+ CHECKBOX_GROUP: React.ComponentType<CheckboxGroupProps>;
712
+ DROPDOWN: React.ComponentType<DropdownProps>;
713
+ TAGS: React.ComponentType<TagsProps>;
714
+ TIME_INPUT: React.ComponentType<TimeInputProps>;
715
+ TEXT: React.ComponentType<RichTextProps>;
716
+ SUBMIT_BUTTON: React.ComponentType<SubmitButtonProps>;
717
+ PRODUCT_LIST: React.ComponentType<ProductListProps>;
718
+ FIXED_PAYMENT: React.ComponentType<FixedPaymentProps>;
719
+ PAYMENT_INPUT: React.ComponentType<PaymentInputProps>;
720
+ DONATION: React.ComponentType<DonationProps>;
721
+ APPOINTMENT: React.ComponentType<AppointmentProps>;
722
+ IMAGE_CHOICE: React.ComponentType<ImageChoiceProps>;
723
+ };
724
+ export { FieldMap }
725
+ export { FieldMap as FieldMap_alias_1 }
726
+
727
+ export declare type FieldMappers = Record<FieldType, PropsMapper>;
728
+
729
+ export declare type FieldProps = TextInputProps | TextAreaProps | PhoneInputProps | MultilineAddressProps | DateInputProps | DatePickerProps | DateTimeInputProps | FileUploadProps | NumberInputProps | CheckboxProps | SignatureProps | RatingInputProps | RadioGroupProps | CheckboxGroupProps | DropdownProps | TagsProps | TimeInputProps | RichTextProps | SubmitButtonProps | ProductListProps | FixedPaymentProps | PaymentInputProps | DonationProps | AppointmentProps | ImageChoiceProps;
730
+
731
+ export declare type FieldType = 'TEXT_INPUT' | 'TEXT_AREA' | 'PHONE_INPUT' | 'MULTILINE_ADDRESS' | 'DATE_INPUT' | 'DATE_PICKER' | 'DATE_TIME_INPUT' | 'TIME_INPUT' | 'FILE_UPLOAD' | 'NUMBER_INPUT' | 'CHECKBOX' | 'SIGNATURE' | 'RATING_INPUT' | 'RADIO_GROUP' | 'CHECKBOX_GROUP' | 'DROPDOWN' | 'TAGS' | 'SUBMIT_BUTTON' | 'PRODUCT_LIST' | 'FIXED_PAYMENT' | 'PAYMENT_INPUT' | 'DONATION' | 'APPOINTMENT' | 'IMAGE_CHOICE' | 'TEXT' | '';
694
732
 
695
733
  /**
696
734
  * Data structure for uploaded file information.
@@ -814,10 +852,6 @@ declare interface FixedPaymentProps {
814
852
  export { FixedPaymentProps }
815
853
  export { FixedPaymentProps as FixedPaymentProps_alias_1 }
816
854
 
817
- declare const Form: ({ form: unformattedForm, fields, values, onChange, errors, onValidate, submitForm, }: FormProps) => JSX_2.Element;
818
- export { Form }
819
- export { Form as Form_alias_1 }
820
-
821
855
  declare interface FormError {
822
856
  errorPath: string;
823
857
  errorType: ErrorType;
@@ -828,47 +862,9 @@ declare interface FormError {
828
862
  export { FormError }
829
863
  export { FormError as FormError_alias_1 }
830
864
 
831
- declare type FormFields = {
832
- TEXT_INPUT: React.ComponentType<TextInputProps>;
833
- TEXT_AREA: React.ComponentType<TextAreaProps>;
834
- PHONE_INPUT: React.ComponentType<PhoneInputProps>;
835
- MULTILINE_ADDRESS: React.ComponentType<MultilineAddressProps>;
836
- DATE_INPUT: React.ComponentType<DateInputProps>;
837
- DATE_PICKER: React.ComponentType<DatePickerProps>;
838
- DATE_TIME_INPUT: React.ComponentType<DateTimeInputProps>;
839
- FILE_UPLOAD: React.ComponentType<FileUploadProps>;
840
- NUMBER_INPUT: React.ComponentType<NumberInputProps>;
841
- CHECKBOX: React.ComponentType<CheckboxProps>;
842
- SIGNATURE: React.ComponentType<SignatureProps>;
843
- RATING_INPUT: React.ComponentType<RatingInputProps>;
844
- RADIO_GROUP: React.ComponentType<RadioGroupProps>;
845
- CHECKBOX_GROUP: React.ComponentType<CheckboxGroupProps>;
846
- DROPDOWN: React.ComponentType<DropdownProps>;
847
- TAGS: React.ComponentType<TagsProps>;
848
- TIME_INPUT: React.ComponentType<TimeInputProps>;
849
- TEXT: React.ComponentType<RichTextProps>;
850
- SUBMIT_BUTTON: React.ComponentType<SubmitButtonProps>;
851
- PRODUCT_LIST: React.ComponentType<ProductListProps>;
852
- FIXED_PAYMENT: React.ComponentType<FixedPaymentProps>;
853
- PAYMENT_INPUT: React.ComponentType<PaymentInputProps>;
854
- DONATION: React.ComponentType<DonationProps>;
855
- APPOINTMENT: React.ComponentType<AppointmentProps>;
856
- IMAGE_CHOICE: React.ComponentType<ImageChoiceProps>;
857
- };
858
- export { FormFields }
859
- export { FormFields as FormFields_alias_1 }
860
-
861
- declare type FormProps = {
862
- form?: Form_2;
863
- values: FormValues;
864
- onChange: OnChange;
865
- errors: FormError[];
866
- onValidate: (errors: FormError[]) => void;
867
- fields: FormFields;
868
- submitForm: () => void;
869
- };
870
- export { FormProps }
871
- export { FormProps as FormProps_alias_1 }
865
+ declare const FormProvider: ({ children }: Props) => JSX_2.Element;
866
+ export { FormProvider }
867
+ export { FormProvider as FormProvider_alias_1 }
872
868
 
873
869
  declare type FormValues = {
874
870
  [target: string]: PossibleValues;
@@ -1053,6 +1049,10 @@ declare interface ImageChoiceProps extends BaseFieldProps {
1053
1049
  export { ImageChoiceProps }
1054
1050
  export { ImageChoiceProps as ImageChoiceProps_alias_1 }
1055
1051
 
1052
+ export declare const mapFieldProps: (fields: FieldMap, mappers: FieldMappers) => FormFields;
1053
+
1054
+ export declare const mapFieldTypes: (fields: FormFields, typeMap: Record<SchemaFieldType, string>) => Record<string, React_2.ComponentType<any>>;
1055
+
1056
1056
  declare interface MinMaxLengthProps {
1057
1057
  minLength: number | undefined;
1058
1058
  maxLength: number | undefined;
@@ -1352,7 +1352,7 @@ export declare const ProductListMapper: PropsMapper;
1352
1352
  * ```
1353
1353
  */
1354
1354
  declare interface ProductListProps extends BaseFieldProps {
1355
- value: ProductValue_2 | null | undefined;
1355
+ value: ProductValue | null | undefined;
1356
1356
  label: string;
1357
1357
  showLabel: boolean;
1358
1358
  description?: RichContent;
@@ -1382,13 +1382,11 @@ export declare type ProductValue = {
1382
1382
  quantity: number;
1383
1383
  };
1384
1384
 
1385
- declare interface ProductValue_2 {
1386
- productId: string;
1387
- price: string | number;
1388
- quantity: number;
1389
- }
1385
+ declare type Props = {
1386
+ children: React_2.ReactNode;
1387
+ };
1390
1388
 
1391
- export declare type PropsMapper = (props: any) => any;
1389
+ export declare type PropsMapper = (props: any) => FieldProps;
1392
1390
 
1393
1391
  export declare const RadioGroupMapper: PropsMapper;
1394
1392
 
@@ -1489,10 +1487,13 @@ export { RatingInputProps as RatingInputProps_alias_1 }
1489
1487
  declare interface RichTextProps {
1490
1488
  content: RichContent;
1491
1489
  maxShownParagraphs: number;
1490
+ id: string;
1492
1491
  }
1493
1492
  export { RichTextProps }
1494
1493
  export { RichTextProps as RichTextProps_alias_1 }
1495
1494
 
1495
+ export { SchemaFieldType }
1496
+
1496
1497
  export declare const SignatureMapper: PropsMapper;
1497
1498
 
1498
1499
  /**
@@ -1778,6 +1779,26 @@ declare interface TimeInputProps extends BaseFieldProps {
1778
1779
  export { TimeInputProps }
1779
1780
  export { TimeInputProps as TimeInputProps_alias_1 }
1780
1781
 
1782
+ declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, fieldMap: fields, }: UseFormProps) => UseFormReturn;
1783
+ export { useForm }
1784
+ export { useForm as useForm_alias_1 }
1785
+
1786
+ export declare type UseFormProps = {
1787
+ form: Form;
1788
+ values: FormValues;
1789
+ onChange: OnChange;
1790
+ errors: FormError[];
1791
+ onValidate: (errors: FormError[]) => void;
1792
+ submitForm: () => void;
1793
+ fieldMap: FieldMap;
1794
+ };
1795
+
1796
+ declare type UseFormReturn = {
1797
+ columnCount: number;
1798
+ fieldElements: ReactElement[][];
1799
+ fieldsLayout: Record<string, Layout>;
1800
+ } | null;
1801
+
1781
1802
  export declare type ValueType = string | number | boolean | string[] | null | undefined | VatIDValue | ProductListValue | WixFile[] | MultilineAddressSubmission | AppointmentSubmitData;
1782
1803
 
1783
1804
  export declare type VatIDValue = {