@wix/form-public 0.57.0 → 0.58.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.
@@ -43,10 +43,10 @@ declare interface AppointmentSubmitData {
43
43
 
44
44
  export declare function createI18n(locale: string): Promise<i18n>;
45
45
 
46
- declare type Currency = {
46
+ declare interface Currency {
47
47
  sign?: string;
48
48
  code?: string;
49
- };
49
+ }
50
50
  export { Currency }
51
51
  export { Currency as Currency_alias_1 }
52
52
 
@@ -84,6 +84,13 @@ export { FieldMap as FieldMap_alias_1 }
84
84
 
85
85
  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';
86
86
 
87
+ export declare interface FileDescriptor {
88
+ id?: string;
89
+ displayName?: string;
90
+ url?: string;
91
+ isPrivate: boolean;
92
+ }
93
+
87
94
  export declare const FORM_VIEWER_NAMESPACE = "form-viewer";
88
95
 
89
96
  declare interface FormError {
@@ -218,9 +225,17 @@ export { PublicTimeInputProps as TimeInputProps_alias_1 }
218
225
 
219
226
  export { SchemaFieldType }
220
227
 
228
+ export declare type UploadFile = (params: UploadFileParams) => Promise<FileDescriptor>;
229
+
230
+ export declare interface UploadFileParams {
231
+ file: File;
232
+ formId: any;
233
+ uploadTarget: string;
234
+ }
235
+
221
236
  export { useFieldProps }
222
237
 
223
- declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, fieldMap: fields, }: UseFormProps) => UseFormReturn;
238
+ declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, uploadFile, fieldMap: fields, }: UseFormProps) => UseFormReturn;
224
239
  export { useForm }
225
240
  export { useForm as useForm_alias_1 }
226
241
 
@@ -231,6 +246,7 @@ export declare type UseFormProps = {
231
246
  errors: FormError[];
232
247
  onValidate: (errors: FormError[]) => void;
233
248
  submitForm: () => void;
249
+ uploadFile?: UploadFile;
234
250
  fieldMap: FieldMap;
235
251
  };
236
252
 
@@ -43,10 +43,10 @@ declare interface AppointmentSubmitData {
43
43
 
44
44
  export declare function createI18n(locale: string): Promise<i18n>;
45
45
 
46
- declare type Currency = {
46
+ declare interface Currency {
47
47
  sign?: string;
48
48
  code?: string;
49
- };
49
+ }
50
50
  export { Currency }
51
51
  export { Currency as Currency_alias_1 }
52
52
 
@@ -84,6 +84,13 @@ export { FieldMap as FieldMap_alias_1 }
84
84
 
85
85
  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';
86
86
 
87
+ export declare interface FileDescriptor {
88
+ id?: string;
89
+ displayName?: string;
90
+ url?: string;
91
+ isPrivate: boolean;
92
+ }
93
+
87
94
  export declare const FORM_VIEWER_NAMESPACE = "form-viewer";
88
95
 
89
96
  declare interface FormError {
@@ -218,9 +225,17 @@ export { PublicTimeInputProps as TimeInputProps_alias_1 }
218
225
 
219
226
  export { SchemaFieldType }
220
227
 
228
+ export declare type UploadFile = (params: UploadFileParams) => Promise<FileDescriptor>;
229
+
230
+ export declare interface UploadFileParams {
231
+ file: File;
232
+ formId: any;
233
+ uploadTarget: string;
234
+ }
235
+
221
236
  export { useFieldProps }
222
237
 
223
- declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, fieldMap: fields, }: UseFormProps) => UseFormReturn;
238
+ declare const useForm: ({ form: unformattedForm, values, onChange, errors, onValidate, submitForm, uploadFile, fieldMap: fields, }: UseFormProps) => UseFormReturn;
224
239
  export { useForm }
225
240
  export { useForm as useForm_alias_1 }
226
241
 
@@ -231,6 +246,7 @@ export declare type UseFormProps = {
231
246
  errors: FormError[];
232
247
  onValidate: (errors: FormError[]) => void;
233
248
  submitForm: () => void;
249
+ uploadFile?: UploadFile;
234
250
  fieldMap: FieldMap;
235
251
  };
236
252
 
package/dist/index.cjs CHANGED
@@ -22533,15 +22533,14 @@ var useForm3 = ({
22533
22533
  errors,
22534
22534
  onValidate,
22535
22535
  submitForm,
22536
+ uploadFile,
22536
22537
  fieldMap: fields
22537
22538
  }) => {
22538
22539
  const form = normalizeSchema(unformattedForm);
22539
22540
  const [stepId, setStepId] = React14.useState();
22540
22541
  const actions = {
22541
22542
  submitForm,
22542
- uploadFile: () => {
22543
- console.log("upload file not implemented");
22544
- }
22543
+ uploadFile
22545
22544
  };
22546
22545
  const mappedFieldTypes = React14.useMemo(
22547
22546
  () => mapFieldTypes(fields, FIELD_TYPE_MAP),