@wix/headless-forms 0.0.27 → 0.0.29

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,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type FormError } from '@wix/form-public';
2
+ import { type FormError, type UseFormProps } from '@wix/form-public';
3
3
  import { type CheckboxGroupProps, type CheckboxProps, type PhoneInputProps, type DateInputProps, type DatePickerProps, type DateTimeInputProps, type DropdownProps, type FileUploadProps, type MultilineAddressProps, type NumberInputProps, type RadioGroupProps, type RatingInputProps, type RichTextProps, type SignatureProps, type SubmitButtonProps, type TagsProps, type TextAreaProps, type TextInputProps, type TimeInputProps, type ProductListProps, type FixedPaymentProps, type PaymentInputProps, type DonationProps, type AppointmentProps, type ImageChoiceProps, type LoginBarProps } from './types.js';
4
4
  import { type FormServiceConfig } from '../services/form-service.js';
5
5
  /**
@@ -13,6 +13,8 @@ export interface RootProps {
13
13
  asChild?: boolean;
14
14
  /** CSS classes to apply to the root element */
15
15
  className?: string;
16
+ /** Ref to access form handle */
17
+ formRef?: React.Ref<UseFormProps['forwardedRef']>;
16
18
  }
17
19
  /**
18
20
  * Root component that provides all necessary service contexts for a complete form experience.
@@ -129,8 +129,8 @@ var TestIds;
129
129
  * ```
130
130
  */
131
131
  exports.Root = react_1.default.forwardRef((props, ref) => {
132
- const { children, formServiceConfig, asChild, ...otherProps } = props;
133
- return ((0, jsx_runtime_1.jsx)(Form_js_1.Root, { formServiceConfig: formServiceConfig, formRef: ref, children: (0, jsx_runtime_1.jsx)(RootContent, { asChild: asChild, ref: ref, ...otherProps, children: children }) }));
132
+ const { children, formServiceConfig, asChild, formRef, ...otherProps } = props;
133
+ return ((0, jsx_runtime_1.jsx)(Form_js_1.Root, { formServiceConfig: formServiceConfig, formRef: formRef, children: (0, jsx_runtime_1.jsx)(RootContent, { asChild: asChild, ref: ref, ...otherProps, children: children }) }));
134
134
  });
135
135
  /**
136
136
  * Internal component to handle the Root content with service access.
@@ -556,10 +556,10 @@ exports.Fields = react_1.default.forwardRef((props, ref) => {
556
556
  return ((0, jsx_runtime_1.jsx)(Form_js_1.Fields, { children: ({ form, formValues, submitForm, handleForm, addressTemplates, siteConfig, }) => {
557
557
  if (!form)
558
558
  return null;
559
- return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsx)(form_public_1.FormProvider, { currency: siteConfig?.currency ?? index_js_1.DEFAULT_CURRENCY, locale: currentLanguage, regionalFormat: currentLocale, addressTemplates: addressTemplates, children: (0, jsx_runtime_1.jsx)(form_public_1.UniqueFieldSuffixContextProvider, { parentId: form._id ?? '', children: (0, jsx_runtime_1.jsx)(FieldsWithForm, { form: form, values: formValues, onChange: handleForm, errors: formErrors, onValidate: handleFormValidate, fields: props.fieldMap, submitForm: submitForm, rowGapClassname: props.rowGapClassname, columnGapClassname: props.columnGapClassname, formRef: formRef }) }) }) }));
559
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsx)(form_public_1.FormProvider, { currency: siteConfig?.currency ?? index_js_1.DEFAULT_CURRENCY, locale: currentLanguage, regionalFormat: currentLocale, addressTemplates: addressTemplates, children: (0, jsx_runtime_1.jsx)(form_public_1.UniqueFieldSuffixContextProvider, { parentId: form._id ?? '', children: (0, jsx_runtime_1.jsx)(FieldsWithForm, { addressTemplates: addressTemplates, form: form, values: formValues, onChange: handleForm, errors: formErrors, onValidate: handleFormValidate, fields: props.fieldMap, submitForm: submitForm, rowGapClassname: props.rowGapClassname, columnGapClassname: props.columnGapClassname, formRef: formRef }) }) }) }));
560
560
  } }));
561
561
  });
562
- const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, formRef, }) => {
562
+ const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, formRef, addressTemplates, }) => {
563
563
  const coreUploadFile = async ({ file, formId, }) => {
564
564
  const uploadUrl = await (0, index_js_1.getUploadUrl)(formId, file);
565
565
  if (uploadUrl === undefined) {
@@ -583,6 +583,7 @@ const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate
583
583
  uploadFile: coreUploadFile,
584
584
  fieldMap,
585
585
  forwardedRef: formRef,
586
+ addressTemplates,
586
587
  });
587
588
  if (!formData)
588
589
  return null;
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import { forms } from '@wix/forms';
3
3
  import { SiteConfig } from '../../services/utils';
4
4
  import { FormServiceConfig } from '../../services/form-service.js';
5
- import { FormValues } from '../types.js';
5
+ import { FormValues, UseFormProps } from '../types.js';
6
6
  /**
7
7
  * Hook to access the form ref from context
8
8
  */
9
- export declare function useFormRef(): React.Ref<any> | undefined;
9
+ export declare function useFormRef(): React.Ref<UseFormProps['forwardedRef']> | undefined;
10
10
  /**
11
11
  * Props for Root headless component
12
12
  */
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type FormError } from '@wix/form-public';
2
+ import { type FormError, type UseFormProps } from '@wix/form-public';
3
3
  import { type CheckboxGroupProps, type CheckboxProps, type PhoneInputProps, type DateInputProps, type DatePickerProps, type DateTimeInputProps, type DropdownProps, type FileUploadProps, type MultilineAddressProps, type NumberInputProps, type RadioGroupProps, type RatingInputProps, type RichTextProps, type SignatureProps, type SubmitButtonProps, type TagsProps, type TextAreaProps, type TextInputProps, type TimeInputProps, type ProductListProps, type FixedPaymentProps, type PaymentInputProps, type DonationProps, type AppointmentProps, type ImageChoiceProps, type LoginBarProps } from './types.js';
4
4
  import { type FormServiceConfig } from '../services/form-service.js';
5
5
  /**
@@ -13,6 +13,8 @@ export interface RootProps {
13
13
  asChild?: boolean;
14
14
  /** CSS classes to apply to the root element */
15
15
  className?: string;
16
+ /** Ref to access form handle */
17
+ formRef?: React.Ref<UseFormProps['forwardedRef']>;
16
18
  }
17
19
  /**
18
20
  * Root component that provides all necessary service contexts for a complete form experience.
@@ -93,8 +93,8 @@ var TestIds;
93
93
  * ```
94
94
  */
95
95
  export const Root = React.forwardRef((props, ref) => {
96
- const { children, formServiceConfig, asChild, ...otherProps } = props;
97
- return (_jsx(CoreRoot, { formServiceConfig: formServiceConfig, formRef: ref, children: _jsx(RootContent, { asChild: asChild, ref: ref, ...otherProps, children: children }) }));
96
+ const { children, formServiceConfig, asChild, formRef, ...otherProps } = props;
97
+ return (_jsx(CoreRoot, { formServiceConfig: formServiceConfig, formRef: formRef, children: _jsx(RootContent, { asChild: asChild, ref: ref, ...otherProps, children: children }) }));
98
98
  });
99
99
  /**
100
100
  * Internal component to handle the Root content with service access.
@@ -520,10 +520,10 @@ export const Fields = React.forwardRef((props, ref) => {
520
520
  return (_jsx(CoreFields, { children: ({ form, formValues, submitForm, handleForm, addressTemplates, siteConfig, }) => {
521
521
  if (!form)
522
522
  return null;
523
- return (_jsx("div", { ref: ref, children: _jsx(FormProvider, { currency: siteConfig?.currency ?? DEFAULT_CURRENCY, locale: currentLanguage, regionalFormat: currentLocale, addressTemplates: addressTemplates, children: _jsx(UniqueFieldSuffixContextProvider, { parentId: form._id ?? '', children: _jsx(FieldsWithForm, { form: form, values: formValues, onChange: handleForm, errors: formErrors, onValidate: handleFormValidate, fields: props.fieldMap, submitForm: submitForm, rowGapClassname: props.rowGapClassname, columnGapClassname: props.columnGapClassname, formRef: formRef }) }) }) }));
523
+ return (_jsx("div", { ref: ref, children: _jsx(FormProvider, { currency: siteConfig?.currency ?? DEFAULT_CURRENCY, locale: currentLanguage, regionalFormat: currentLocale, addressTemplates: addressTemplates, children: _jsx(UniqueFieldSuffixContextProvider, { parentId: form._id ?? '', children: _jsx(FieldsWithForm, { addressTemplates: addressTemplates, form: form, values: formValues, onChange: handleForm, errors: formErrors, onValidate: handleFormValidate, fields: props.fieldMap, submitForm: submitForm, rowGapClassname: props.rowGapClassname, columnGapClassname: props.columnGapClassname, formRef: formRef }) }) }) }));
524
524
  } }));
525
525
  });
526
- const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, formRef, }) => {
526
+ const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, formRef, addressTemplates, }) => {
527
527
  const coreUploadFile = async ({ file, formId, }) => {
528
528
  const uploadUrl = await getUploadUrl(formId, file);
529
529
  if (uploadUrl === undefined) {
@@ -547,6 +547,7 @@ const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate
547
547
  uploadFile: coreUploadFile,
548
548
  fieldMap,
549
549
  forwardedRef: formRef,
550
+ addressTemplates,
550
551
  });
551
552
  if (!formData)
552
553
  return null;
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import { forms } from '@wix/forms';
3
3
  import { SiteConfig } from '../../services/utils';
4
4
  import { FormServiceConfig } from '../../services/form-service.js';
5
- import { FormValues } from '../types.js';
5
+ import { FormValues, UseFormProps } from '../types.js';
6
6
  /**
7
7
  * Hook to access the form ref from context
8
8
  */
9
- export declare function useFormRef(): React.Ref<any> | undefined;
9
+ export declare function useFormRef(): React.Ref<UseFormProps['forwardedRef']> | undefined;
10
10
  /**
11
11
  * Props for Root headless component
12
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-forms",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -42,7 +42,7 @@
42
42
  "vitest": "^3.1.4"
43
43
  },
44
44
  "dependencies": {
45
- "@wix/form-public": "^0.104.0",
45
+ "@wix/form-public": "^0.118.0",
46
46
  "@wix/forms": "^1.0.373",
47
47
  "@wix/headless-utils": "0.0.8",
48
48
  "@wix/locale-dataset-javascript": "^2.3.0",
@@ -60,5 +60,5 @@
60
60
  "groupId": "com.wixpress.headless-components"
61
61
  }
62
62
  },
63
- "falconPackageHash": "cbfd4ba39f7b47810179421ff23ef3c58d21cbc002f70636b6d1b312"
63
+ "falconPackageHash": "03e64994e9a255b7cb74eaa44f63bd943b9d49cf757e3891490aec32"
64
64
  }