@wix/headless-forms 0.0.20 → 0.0.21

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.
@@ -38,6 +38,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
38
38
  const react_1 = __importStar(require("react"));
39
39
  const react_2 = require("@wix/headless-utils/react");
40
40
  const form_public_1 = require("@wix/form-public");
41
+ const essentials_1 = require("@wix/essentials");
41
42
  const Form_js_1 = require("./core/Form.js");
42
43
  const FieldContext_js_1 = require("./context/FieldContext.js");
43
44
  const FieldLayoutContext_js_1 = require("./context/FieldLayoutContext.js");
@@ -525,13 +526,15 @@ exports.Submitted = react_1.default.forwardRef((props, ref) => {
525
526
  */
526
527
  exports.Fields = react_1.default.forwardRef((props, ref) => {
527
528
  const [formErrors, setFormErrors] = (0, react_1.useState)([]);
529
+ const currentLocale = essentials_1.i18n.getLocale();
530
+ const currentLanguage = essentials_1.i18n.getLanguage();
528
531
  const handleFormValidate = (0, react_1.useCallback)((errors) => {
529
532
  setFormErrors(errors);
530
533
  }, []);
531
- return ((0, jsx_runtime_1.jsx)(Form_js_1.Fields, { children: ({ form, formValues, submitForm, handleForm }) => {
534
+ return ((0, jsx_runtime_1.jsx)(Form_js_1.Fields, { children: ({ form, formValues, submitForm, handleForm, addressTemplates }) => {
532
535
  if (!form)
533
536
  return null;
534
- return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsx)(form_public_1.FormProvider, { currency: 'USD', locale: 'en', 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 }) }) }));
537
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsx)(form_public_1.FormProvider, { currency: 'USD', 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 }) }) }) }));
535
538
  } }));
536
539
  });
537
540
  const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, }) => {
@@ -229,6 +229,7 @@ export interface FieldsRenderProps {
229
229
  /** Function to submit the form with values */
230
230
  submitForm: () => Promise<void>;
231
231
  handleForm: (formValues: FormValues) => Promise<void>;
232
+ addressTemplates: any[];
232
233
  }
233
234
  /**
234
235
  * Props for Fields headless component
@@ -230,14 +230,16 @@ function Submitted(props) {
230
230
  * ```
231
231
  */
232
232
  function Fields(props) {
233
- const { formSignal, submitForm, handleForm, formValuesSignal } = (0, services_manager_react_1.useService)(form_service_js_1.FormServiceDefinition);
233
+ const { formSignal, submitForm, handleForm, formValuesSignal, addressTemplatesSignal, } = (0, services_manager_react_1.useService)(form_service_js_1.FormServiceDefinition);
234
234
  const form = formSignal.get();
235
235
  const formValues = formValuesSignal.get();
236
+ const addressTemplates = addressTemplatesSignal.get();
236
237
  return props.children({
237
238
  form,
238
239
  formValues,
239
240
  submitForm,
240
241
  handleForm,
242
+ addressTemplates,
241
243
  });
242
244
  }
243
245
  /**
@@ -1,3 +1,3 @@
1
1
  export * as Form from './Form.js';
2
2
  export * from './types.js';
3
- export { PhoneField, FileUpload } from '@wix/form-public';
3
+ export { Checkbox, CheckboxGroup, DateInput, DatePicker, DateTimeInput, Dropdown, FileUpload, MultilineAddress, NumberInput, PhoneInput, RadioGroup, RatingInput, Tags, TextArea, TextInput, TimeInput, LoginBar, SubmitButton, FormProvider, } from '@wix/form-public';
@@ -36,9 +36,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.FileUpload = exports.PhoneField = exports.Form = void 0;
39
+ exports.FormProvider = exports.SubmitButton = exports.LoginBar = exports.TimeInput = exports.TextInput = exports.TextArea = exports.Tags = exports.RatingInput = exports.RadioGroup = exports.PhoneInput = exports.NumberInput = exports.MultilineAddress = exports.FileUpload = exports.Dropdown = exports.DateTimeInput = exports.DatePicker = exports.DateInput = exports.CheckboxGroup = exports.Checkbox = exports.Form = void 0;
40
40
  exports.Form = __importStar(require("./Form.js"));
41
41
  __exportStar(require("./types.js"), exports);
42
42
  var form_public_1 = require("@wix/form-public");
43
- Object.defineProperty(exports, "PhoneField", { enumerable: true, get: function () { return form_public_1.PhoneField; } });
43
+ Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return form_public_1.Checkbox; } });
44
+ Object.defineProperty(exports, "CheckboxGroup", { enumerable: true, get: function () { return form_public_1.CheckboxGroup; } });
45
+ Object.defineProperty(exports, "DateInput", { enumerable: true, get: function () { return form_public_1.DateInput; } });
46
+ Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return form_public_1.DatePicker; } });
47
+ Object.defineProperty(exports, "DateTimeInput", { enumerable: true, get: function () { return form_public_1.DateTimeInput; } });
48
+ Object.defineProperty(exports, "Dropdown", { enumerable: true, get: function () { return form_public_1.Dropdown; } });
44
49
  Object.defineProperty(exports, "FileUpload", { enumerable: true, get: function () { return form_public_1.FileUpload; } });
50
+ Object.defineProperty(exports, "MultilineAddress", { enumerable: true, get: function () { return form_public_1.MultilineAddress; } });
51
+ Object.defineProperty(exports, "NumberInput", { enumerable: true, get: function () { return form_public_1.NumberInput; } });
52
+ Object.defineProperty(exports, "PhoneInput", { enumerable: true, get: function () { return form_public_1.PhoneInput; } });
53
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return form_public_1.RadioGroup; } });
54
+ Object.defineProperty(exports, "RatingInput", { enumerable: true, get: function () { return form_public_1.RatingInput; } });
55
+ Object.defineProperty(exports, "Tags", { enumerable: true, get: function () { return form_public_1.Tags; } });
56
+ Object.defineProperty(exports, "TextArea", { enumerable: true, get: function () { return form_public_1.TextArea; } });
57
+ Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return form_public_1.TextInput; } });
58
+ Object.defineProperty(exports, "TimeInput", { enumerable: true, get: function () { return form_public_1.TimeInput; } });
59
+ Object.defineProperty(exports, "LoginBar", { enumerable: true, get: function () { return form_public_1.LoginBar; } });
60
+ Object.defineProperty(exports, "SubmitButton", { enumerable: true, get: function () { return form_public_1.SubmitButton; } });
61
+ Object.defineProperty(exports, "FormProvider", { enumerable: true, get: function () { return form_public_1.FormProvider; } });
@@ -26,6 +26,8 @@ export type SubmitResponse = {
26
26
  export interface FormServiceAPI {
27
27
  /** Reactive signal containing the current form data */
28
28
  formSignal: ReadOnlySignal<forms.Form | null>;
29
+ /** Reactive signal containing the address templates */
30
+ addressTemplatesSignal: ReadOnlySignal<any[]>;
29
31
  /** Reactive signal indicating if a form is currently being loaded */
30
32
  isLoadingSignal: ReadOnlySignal<boolean>;
31
33
  /** Reactive signal containing any error message, or null if no error */
@@ -69,6 +71,7 @@ export type FormServiceConfig = {
69
71
  } | {
70
72
  form: forms.Form;
71
73
  onSubmit?: OnSubmit;
74
+ addressTemplates?: any[];
72
75
  };
73
76
  /**
74
77
  * Implementation of the Form service that manages reactive form data and submissions.
@@ -6,6 +6,7 @@ const forms_1 = require("@wix/forms");
6
6
  const services_definitions_1 = require("@wix/services-definitions");
7
7
  const signals_1 = require("@wix/services-definitions/core-services/signals");
8
8
  const essentials_1 = require("@wix/essentials");
9
+ const address_forms_js_1 = require("./utils/address-forms.js");
9
10
  /**
10
11
  * Service definition for the Form service.
11
12
  * This defines the contract that the FormService must implement.
@@ -47,17 +48,20 @@ exports.FormService = services_definitions_1.implementService.withConfig()(expor
47
48
  });
48
49
  const hasSchema = 'form' in config;
49
50
  const formSignal = signalsService.signal(hasSchema ? config.form : null);
51
+ const hasAddressTemplates = 'addressTemplates' in config;
52
+ const addressTemplatesSignal = signalsService.signal(hasAddressTemplates ? config.addressTemplates : null);
50
53
  const formValuesSignal = signalsService.signal({});
51
54
  if (!hasSchema) {
52
55
  loadForm(config.formId, config.namespace, config.additionalMetadata);
53
56
  }
54
57
  async function loadForm(id, namespace, additionalMetadata) {
58
+ let form;
55
59
  isLoadingSignal.set(true);
56
60
  errorSignal.set(null);
57
61
  try {
58
- const result = await fetchForm({ id, namespace, additionalMetadata });
59
- if (result) {
60
- formSignal.set(result);
62
+ form = await fetchForm({ id, namespace, additionalMetadata });
63
+ if (form) {
64
+ formSignal.set(form);
61
65
  }
62
66
  else {
63
67
  errorSignal.set('Form not found');
@@ -65,10 +69,32 @@ exports.FormService = services_definitions_1.implementService.withConfig()(expor
65
69
  }
66
70
  catch (err) {
67
71
  errorSignal.set('Failed to load form');
72
+ isLoadingSignal.set(false);
68
73
  throw err;
69
74
  }
70
- finally {
75
+ if (!hasAddressTemplates && (0, address_forms_js_1.hasMultilineAddressField)(form)) {
76
+ loadAddressTemplates();
77
+ }
78
+ isLoadingSignal.set(false);
79
+ }
80
+ async function loadAddressTemplates() {
81
+ const form = formSignal.get();
82
+ if (!form || !(0, address_forms_js_1.hasMultilineAddressField)(form)) {
83
+ return;
84
+ }
85
+ try {
86
+ const addressTemplates = await (0, address_forms_js_1.fetchAddressForms)();
87
+ if (addressTemplates) {
88
+ addressTemplatesSignal.set(addressTemplates);
89
+ }
90
+ else {
91
+ errorSignal.set('Address templates not found');
92
+ }
93
+ }
94
+ catch (err) {
95
+ errorSignal.set('Failed to address templates');
71
96
  isLoadingSignal.set(false);
97
+ throw err;
72
98
  }
73
99
  }
74
100
  async function defaultSubmitHandler(formId, formValues) {
@@ -120,6 +146,7 @@ exports.FormService = services_definitions_1.implementService.withConfig()(expor
120
146
  errorSignal,
121
147
  submitResponseSignal,
122
148
  formValuesSignal,
149
+ addressTemplatesSignal,
123
150
  submitForm,
124
151
  handleForm,
125
152
  };
@@ -185,5 +212,9 @@ async function fetchForm({ id, namespace, additionalMetadata, }) {
185
212
  */
186
213
  async function loadFormServiceConfig(formId, namespace, additionalMetadata) {
187
214
  const form = await fetchForm({ id: formId, namespace, additionalMetadata });
188
- return { form };
215
+ let addressTemplates;
216
+ if ((0, address_forms_js_1.hasMultilineAddressField)(form)) {
217
+ addressTemplates = await (0, address_forms_js_1.fetchAddressForms)();
218
+ }
219
+ return { form, addressTemplates };
189
220
  }
@@ -0,0 +1,95 @@
1
+ import { forms } from '@wix/forms';
2
+ export declare const ADDRESS_FORM_ID_BY_COUNTRY: {
3
+ COMMON: string;
4
+ US: string;
5
+ UY: string;
6
+ TH: string;
7
+ TR: string;
8
+ SZ: string;
9
+ ZA: string;
10
+ SE: string;
11
+ SI: string;
12
+ SK: string;
13
+ RS: string;
14
+ SB: string;
15
+ SG: string;
16
+ SN: string;
17
+ SD: string;
18
+ RU: string;
19
+ RO: string;
20
+ PY: string;
21
+ PT: string;
22
+ PL: string;
23
+ PH: string;
24
+ PE: string;
25
+ PA: string;
26
+ PK: string;
27
+ NZ: string;
28
+ NO: string;
29
+ NG: string;
30
+ NL: string;
31
+ MY: string;
32
+ MH: string;
33
+ MX: string;
34
+ KR: string;
35
+ JP: string;
36
+ IT: string;
37
+ IS: string;
38
+ IE: string;
39
+ IN: string;
40
+ IL: string;
41
+ ID: string;
42
+ HU: string;
43
+ HR: string;
44
+ GR: string;
45
+ GB: string;
46
+ FR: string;
47
+ ES: string;
48
+ EG: string;
49
+ DO: string;
50
+ DK: string;
51
+ DE: string;
52
+ CZ: string;
53
+ CY: string;
54
+ CR: string;
55
+ CO: string;
56
+ CI: string;
57
+ CN: string;
58
+ CL: string;
59
+ CH: string;
60
+ CA: string;
61
+ CF: string;
62
+ BR: string;
63
+ BS: string;
64
+ BE: string;
65
+ BG: string;
66
+ AT: string;
67
+ AU: string;
68
+ AR: string;
69
+ AE: string;
70
+ };
71
+ export declare const DEFAULT_COUNTRY = "COMMON";
72
+ /**
73
+ * Checks if a form has multiline address fields
74
+ *
75
+ * @param form - The form to check
76
+ * @param options - Optional configuration
77
+ * @param options.excludeEcomAddress - If true, excludes ecom-specific address fields
78
+ * @returns true if the form contains multiline address fields
79
+ */
80
+ export declare function hasMultilineAddressField(form: forms.Form): boolean;
81
+ /**
82
+ * Fetches address form templates for all supported countries.
83
+ * These templates are needed for rendering multiline address fields
84
+ * with country-specific address formats.
85
+ *
86
+ * @returns Array of address templates indexed by country, or undefined if fetch fails
87
+ * @throws {Error} When the API request fails
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * const addressTemplates = await fetchAddressForms();
92
+ * // Returns: [{ country: 'US', id: '...', template: {...} }, ...]
93
+ * ```
94
+ */
95
+ export declare function fetchAddressForms(): Promise<any>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_COUNTRY = exports.ADDRESS_FORM_ID_BY_COUNTRY = void 0;
4
+ exports.hasMultilineAddressField = hasMultilineAddressField;
5
+ exports.fetchAddressForms = fetchAddressForms;
6
+ const essentials_1 = require("@wix/essentials");
7
+ const forms_1 = require("@wix/forms");
8
+ exports.ADDRESS_FORM_ID_BY_COUNTRY = {
9
+ COMMON: '0d5dcb6d-1403-4b80-b73e-6d90a2245561',
10
+ US: 'ebe1c447-8fd5-4c7a-8cf1-75b94db68698',
11
+ UY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
12
+ TH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
13
+ TR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
14
+ SZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
15
+ ZA: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
16
+ SE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
17
+ SI: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
18
+ SK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
19
+ RS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
20
+ SB: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
21
+ SG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
22
+ SN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
23
+ SD: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
24
+ RU: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
25
+ RO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
26
+ PY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
27
+ PT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
28
+ PL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
29
+ PH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
30
+ PE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
31
+ PA: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
32
+ PK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
33
+ NZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
34
+ NO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
35
+ NG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
36
+ NL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
37
+ MY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
38
+ MH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
39
+ MX: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
40
+ KR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
41
+ JP: 'e51fc7b5-0c29-40c6-b2e8-58d9fa5e3c29',
42
+ IT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
43
+ IS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
44
+ IE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
45
+ IN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
46
+ IL: 'bc7a8d54-8df3-47cb-bb9b-3338fd6246e5',
47
+ ID: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
48
+ HU: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
49
+ HR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
50
+ GR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
51
+ GB: '3d059d26-8ce8-48ce-9779-b23e42014454',
52
+ FR: 'fbc1fb24-37bc-4c0f-afa4-35e88a43127d',
53
+ ES: 'f0e74759-d378-4ae7-9db7-42b4c7d02094',
54
+ EG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
55
+ DO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
56
+ DK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
57
+ DE: 'c7bde0e2-187e-44e7-8f51-14162259eb2b',
58
+ CZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
59
+ CY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
60
+ CR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
61
+ CO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
62
+ CI: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
63
+ CN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
64
+ CL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
65
+ CH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
66
+ CA: '2b942888-7d93-41ee-b85c-5705263f9eea',
67
+ CF: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
68
+ BR: '3160f799-1ade-455b-87f9-128875ec874e',
69
+ BS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
70
+ BE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
71
+ BG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
72
+ AT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
73
+ AU: '76f1a42e-b609-4c8b-b41a-7ebf2fbb5a56',
74
+ AR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
75
+ AE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
76
+ };
77
+ exports.DEFAULT_COUNTRY = 'COMMON';
78
+ const addressCountryToFormMap = Object.entries(exports.ADDRESS_FORM_ID_BY_COUNTRY).map(([country, id]) => ({ country, id }));
79
+ /**
80
+ * Checks if a form has multiline address fields
81
+ *
82
+ * @param form - The form to check
83
+ * @param options - Optional configuration
84
+ * @param options.excludeEcomAddress - If true, excludes ecom-specific address fields
85
+ * @returns true if the form contains multiline address fields
86
+ */
87
+ function hasMultilineAddressField(form) {
88
+ return (form.formFields?.some((field) => field.inputOptions?.inputType === forms_1.forms.InputType.ADDRESS) ?? false);
89
+ }
90
+ /**
91
+ * Overrides template field IDs if needed
92
+ * This can be customized based on specific requirements
93
+ */
94
+ function overrideTemplateFieldIds(templates) {
95
+ // Default implementation - no overrides
96
+ // Override this if you need custom field ID mappings
97
+ return templates;
98
+ }
99
+ /**
100
+ * Fetches address form templates for all supported countries.
101
+ * These templates are needed for rendering multiline address fields
102
+ * with country-specific address formats.
103
+ *
104
+ * @returns Array of address templates indexed by country, or undefined if fetch fails
105
+ * @throws {Error} When the API request fails
106
+ *
107
+ * @example
108
+ * ```tsx
109
+ * const addressTemplates = await fetchAddressForms();
110
+ * // Returns: [{ country: 'US', id: '...', template: {...} }, ...]
111
+ * ```
112
+ */
113
+ async function fetchAddressForms() {
114
+ try {
115
+ const url = `https://www.wixapis.com/form-template-service/v1/templates?templateIds=0d5dcb6d-1403-4b80-b73e-6d90a2245561&templateIds=ebe1c447-8fd5-4c7a-8cf1-75b94db68698&templateIds=b7b59987-e5c6-4ec7-a4af-f48318a68a5d&templateIds=e51fc7b5-0c29-40c6-b2e8-58d9fa5e3c29&templateIds=bc7a8d54-8df3-47cb-bb9b-3338fd6246e5&templateIds=3d059d26-8ce8-48ce-9779-b23e42014454&templateIds=fbc1fb24-37bc-4c0f-afa4-35e88a43127d&templateIds=f0e74759-d378-4ae7-9db7-42b4c7d02094&templateIds=c7bde0e2-187e-44e7-8f51-14162259eb2b&templateIds=2b942888-7d93-41ee-b85c-5705263f9eea&templateIds=3160f799-1ade-455b-87f9-128875ec874e&templateIds=76f1a42e-b609-4c8b-b41a-7ebf2fbb5a56&namespace=wix.form_platform.form`;
116
+ const response = await essentials_1.httpClient.fetchWithAuth(url);
117
+ if (!response.ok) {
118
+ throw new Error(`Failed to fetch form: ${response.status} ${response.statusText}`);
119
+ }
120
+ const data = await response.json();
121
+ const templatesWithOverrides = data.templates && overrideTemplateFieldIds(data.templates);
122
+ return addressCountryToFormMap
123
+ .map((addressCountryToForm) => ({
124
+ ...addressCountryToForm,
125
+ template: templatesWithOverrides?.find((_form) => {
126
+ return _form.id === addressCountryToForm.id;
127
+ }),
128
+ }))
129
+ .filter((addressCountryToForm) => Boolean(addressCountryToForm.template));
130
+ }
131
+ catch (error) {
132
+ console.error('Failed to fetch address forms:', error);
133
+ throw error;
134
+ }
135
+ }
@@ -1 +1,2 @@
1
1
  export { getUploadUrl, uploadFile } from './file-upload-utils';
2
+ export { hasMultilineAddressField, fetchAddressForms } from './address-forms';
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadFile = exports.getUploadUrl = void 0;
3
+ exports.fetchAddressForms = exports.hasMultilineAddressField = exports.uploadFile = exports.getUploadUrl = void 0;
4
4
  var file_upload_utils_1 = require("./file-upload-utils");
5
5
  Object.defineProperty(exports, "getUploadUrl", { enumerable: true, get: function () { return file_upload_utils_1.getUploadUrl; } });
6
6
  Object.defineProperty(exports, "uploadFile", { enumerable: true, get: function () { return file_upload_utils_1.uploadFile; } });
7
+ var address_forms_1 = require("./address-forms");
8
+ Object.defineProperty(exports, "hasMultilineAddressField", { enumerable: true, get: function () { return address_forms_1.hasMultilineAddressField; } });
9
+ Object.defineProperty(exports, "fetchAddressForms", { enumerable: true, get: function () { return address_forms_1.fetchAddressForms; } });
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useState, useCallback } from 'react';
3
3
  import { AsChildSlot } from '@wix/headless-utils/react';
4
- import { useForm, FormProvider, } from '@wix/form-public';
4
+ import { useForm, FormProvider, UniqueFieldSuffixContextProvider, } from '@wix/form-public';
5
+ import { i18n } from '@wix/essentials';
5
6
  import { Root as CoreRoot, Loading as CoreLoading, LoadingError as CoreLoadingError, Error as CoreError, Submitted as CoreSubmitted, Fields as CoreFields, Field as CoreField, } from './core/Form.js';
6
7
  import { FieldContext, useFieldContext, } from './context/FieldContext.js';
7
8
  import { FieldLayoutProvider, useFieldLayout, } from './context/FieldLayoutContext.js';
@@ -489,13 +490,15 @@ export const Submitted = React.forwardRef((props, ref) => {
489
490
  */
490
491
  export const Fields = React.forwardRef((props, ref) => {
491
492
  const [formErrors, setFormErrors] = useState([]);
493
+ const currentLocale = i18n.getLocale();
494
+ const currentLanguage = i18n.getLanguage();
492
495
  const handleFormValidate = useCallback((errors) => {
493
496
  setFormErrors(errors);
494
497
  }, []);
495
- return (_jsx(CoreFields, { children: ({ form, formValues, submitForm, handleForm }) => {
498
+ return (_jsx(CoreFields, { children: ({ form, formValues, submitForm, handleForm, addressTemplates }) => {
496
499
  if (!form)
497
500
  return null;
498
- return (_jsx("div", { ref: ref, children: _jsx(FormProvider, { currency: 'USD', locale: 'en', children: _jsx(FieldsWithForm, { form: form, values: formValues, onChange: handleForm, errors: formErrors, onValidate: handleFormValidate, fields: props.fieldMap, submitForm: submitForm, rowGapClassname: props.rowGapClassname, columnGapClassname: props.columnGapClassname }) }) }));
501
+ return (_jsx("div", { ref: ref, children: _jsx(FormProvider, { currency: 'USD', 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 }) }) }) }));
499
502
  } }));
500
503
  });
501
504
  const FieldsWithForm = ({ form, submitForm, values, onChange, errors, onValidate, fields: fieldMap, rowGapClassname, columnGapClassname, }) => {
@@ -229,6 +229,7 @@ export interface FieldsRenderProps {
229
229
  /** Function to submit the form with values */
230
230
  submitForm: () => Promise<void>;
231
231
  handleForm: (formValues: FormValues) => Promise<void>;
232
+ addressTemplates: any[];
232
233
  }
233
234
  /**
234
235
  * Props for Fields headless component
@@ -221,14 +221,16 @@ export function Submitted(props) {
221
221
  * ```
222
222
  */
223
223
  export function Fields(props) {
224
- const { formSignal, submitForm, handleForm, formValuesSignal } = useService(FormServiceDefinition);
224
+ const { formSignal, submitForm, handleForm, formValuesSignal, addressTemplatesSignal, } = useService(FormServiceDefinition);
225
225
  const form = formSignal.get();
226
226
  const formValues = formValuesSignal.get();
227
+ const addressTemplates = addressTemplatesSignal.get();
227
228
  return props.children({
228
229
  form,
229
230
  formValues,
230
231
  submitForm,
231
232
  handleForm,
233
+ addressTemplates,
232
234
  });
233
235
  }
234
236
  /**
@@ -1,3 +1,3 @@
1
1
  export * as Form from './Form.js';
2
2
  export * from './types.js';
3
- export { PhoneField, FileUpload } from '@wix/form-public';
3
+ export { Checkbox, CheckboxGroup, DateInput, DatePicker, DateTimeInput, Dropdown, FileUpload, MultilineAddress, NumberInput, PhoneInput, RadioGroup, RatingInput, Tags, TextArea, TextInput, TimeInput, LoginBar, SubmitButton, FormProvider, } from '@wix/form-public';
@@ -1,3 +1,3 @@
1
1
  export * as Form from './Form.js';
2
2
  export * from './types.js';
3
- export { PhoneField, FileUpload } from '@wix/form-public';
3
+ export { Checkbox, CheckboxGroup, DateInput, DatePicker, DateTimeInput, Dropdown, FileUpload, MultilineAddress, NumberInput, PhoneInput, RadioGroup, RatingInput, Tags, TextArea, TextInput, TimeInput, LoginBar, SubmitButton, FormProvider, } from '@wix/form-public';
@@ -26,6 +26,8 @@ export type SubmitResponse = {
26
26
  export interface FormServiceAPI {
27
27
  /** Reactive signal containing the current form data */
28
28
  formSignal: ReadOnlySignal<forms.Form | null>;
29
+ /** Reactive signal containing the address templates */
30
+ addressTemplatesSignal: ReadOnlySignal<any[]>;
29
31
  /** Reactive signal indicating if a form is currently being loaded */
30
32
  isLoadingSignal: ReadOnlySignal<boolean>;
31
33
  /** Reactive signal containing any error message, or null if no error */
@@ -69,6 +71,7 @@ export type FormServiceConfig = {
69
71
  } | {
70
72
  form: forms.Form;
71
73
  onSubmit?: OnSubmit;
74
+ addressTemplates?: any[];
72
75
  };
73
76
  /**
74
77
  * Implementation of the Form service that manages reactive form data and submissions.
@@ -2,6 +2,7 @@ import { submissions } from '@wix/forms';
2
2
  import { defineService, implementService } from '@wix/services-definitions';
3
3
  import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
4
4
  import { httpClient } from '@wix/essentials';
5
+ import { fetchAddressForms, hasMultilineAddressField, } from './utils/address-forms.js';
5
6
  /**
6
7
  * Service definition for the Form service.
7
8
  * This defines the contract that the FormService must implement.
@@ -43,17 +44,20 @@ export const FormService = implementService.withConfig()(FormServiceDefinition,
43
44
  });
44
45
  const hasSchema = 'form' in config;
45
46
  const formSignal = signalsService.signal(hasSchema ? config.form : null);
47
+ const hasAddressTemplates = 'addressTemplates' in config;
48
+ const addressTemplatesSignal = signalsService.signal(hasAddressTemplates ? config.addressTemplates : null);
46
49
  const formValuesSignal = signalsService.signal({});
47
50
  if (!hasSchema) {
48
51
  loadForm(config.formId, config.namespace, config.additionalMetadata);
49
52
  }
50
53
  async function loadForm(id, namespace, additionalMetadata) {
54
+ let form;
51
55
  isLoadingSignal.set(true);
52
56
  errorSignal.set(null);
53
57
  try {
54
- const result = await fetchForm({ id, namespace, additionalMetadata });
55
- if (result) {
56
- formSignal.set(result);
58
+ form = await fetchForm({ id, namespace, additionalMetadata });
59
+ if (form) {
60
+ formSignal.set(form);
57
61
  }
58
62
  else {
59
63
  errorSignal.set('Form not found');
@@ -61,10 +65,32 @@ export const FormService = implementService.withConfig()(FormServiceDefinition,
61
65
  }
62
66
  catch (err) {
63
67
  errorSignal.set('Failed to load form');
68
+ isLoadingSignal.set(false);
64
69
  throw err;
65
70
  }
66
- finally {
71
+ if (!hasAddressTemplates && hasMultilineAddressField(form)) {
72
+ loadAddressTemplates();
73
+ }
74
+ isLoadingSignal.set(false);
75
+ }
76
+ async function loadAddressTemplates() {
77
+ const form = formSignal.get();
78
+ if (!form || !hasMultilineAddressField(form)) {
79
+ return;
80
+ }
81
+ try {
82
+ const addressTemplates = await fetchAddressForms();
83
+ if (addressTemplates) {
84
+ addressTemplatesSignal.set(addressTemplates);
85
+ }
86
+ else {
87
+ errorSignal.set('Address templates not found');
88
+ }
89
+ }
90
+ catch (err) {
91
+ errorSignal.set('Failed to address templates');
67
92
  isLoadingSignal.set(false);
93
+ throw err;
68
94
  }
69
95
  }
70
96
  async function defaultSubmitHandler(formId, formValues) {
@@ -116,6 +142,7 @@ export const FormService = implementService.withConfig()(FormServiceDefinition,
116
142
  errorSignal,
117
143
  submitResponseSignal,
118
144
  formValuesSignal,
145
+ addressTemplatesSignal,
119
146
  submitForm,
120
147
  handleForm,
121
148
  };
@@ -181,5 +208,9 @@ async function fetchForm({ id, namespace, additionalMetadata, }) {
181
208
  */
182
209
  export async function loadFormServiceConfig(formId, namespace, additionalMetadata) {
183
210
  const form = await fetchForm({ id: formId, namespace, additionalMetadata });
184
- return { form };
211
+ let addressTemplates;
212
+ if (hasMultilineAddressField(form)) {
213
+ addressTemplates = await fetchAddressForms();
214
+ }
215
+ return { form, addressTemplates };
185
216
  }
@@ -0,0 +1,95 @@
1
+ import { forms } from '@wix/forms';
2
+ export declare const ADDRESS_FORM_ID_BY_COUNTRY: {
3
+ COMMON: string;
4
+ US: string;
5
+ UY: string;
6
+ TH: string;
7
+ TR: string;
8
+ SZ: string;
9
+ ZA: string;
10
+ SE: string;
11
+ SI: string;
12
+ SK: string;
13
+ RS: string;
14
+ SB: string;
15
+ SG: string;
16
+ SN: string;
17
+ SD: string;
18
+ RU: string;
19
+ RO: string;
20
+ PY: string;
21
+ PT: string;
22
+ PL: string;
23
+ PH: string;
24
+ PE: string;
25
+ PA: string;
26
+ PK: string;
27
+ NZ: string;
28
+ NO: string;
29
+ NG: string;
30
+ NL: string;
31
+ MY: string;
32
+ MH: string;
33
+ MX: string;
34
+ KR: string;
35
+ JP: string;
36
+ IT: string;
37
+ IS: string;
38
+ IE: string;
39
+ IN: string;
40
+ IL: string;
41
+ ID: string;
42
+ HU: string;
43
+ HR: string;
44
+ GR: string;
45
+ GB: string;
46
+ FR: string;
47
+ ES: string;
48
+ EG: string;
49
+ DO: string;
50
+ DK: string;
51
+ DE: string;
52
+ CZ: string;
53
+ CY: string;
54
+ CR: string;
55
+ CO: string;
56
+ CI: string;
57
+ CN: string;
58
+ CL: string;
59
+ CH: string;
60
+ CA: string;
61
+ CF: string;
62
+ BR: string;
63
+ BS: string;
64
+ BE: string;
65
+ BG: string;
66
+ AT: string;
67
+ AU: string;
68
+ AR: string;
69
+ AE: string;
70
+ };
71
+ export declare const DEFAULT_COUNTRY = "COMMON";
72
+ /**
73
+ * Checks if a form has multiline address fields
74
+ *
75
+ * @param form - The form to check
76
+ * @param options - Optional configuration
77
+ * @param options.excludeEcomAddress - If true, excludes ecom-specific address fields
78
+ * @returns true if the form contains multiline address fields
79
+ */
80
+ export declare function hasMultilineAddressField(form: forms.Form): boolean;
81
+ /**
82
+ * Fetches address form templates for all supported countries.
83
+ * These templates are needed for rendering multiline address fields
84
+ * with country-specific address formats.
85
+ *
86
+ * @returns Array of address templates indexed by country, or undefined if fetch fails
87
+ * @throws {Error} When the API request fails
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * const addressTemplates = await fetchAddressForms();
92
+ * // Returns: [{ country: 'US', id: '...', template: {...} }, ...]
93
+ * ```
94
+ */
95
+ export declare function fetchAddressForms(): Promise<any>;
@@ -0,0 +1,130 @@
1
+ import { httpClient } from '@wix/essentials';
2
+ import { forms } from '@wix/forms';
3
+ export const ADDRESS_FORM_ID_BY_COUNTRY = {
4
+ COMMON: '0d5dcb6d-1403-4b80-b73e-6d90a2245561',
5
+ US: 'ebe1c447-8fd5-4c7a-8cf1-75b94db68698',
6
+ UY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
7
+ TH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
8
+ TR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
9
+ SZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
10
+ ZA: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
11
+ SE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
12
+ SI: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
13
+ SK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
14
+ RS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
15
+ SB: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
16
+ SG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
17
+ SN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
18
+ SD: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
19
+ RU: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
20
+ RO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
21
+ PY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
22
+ PT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
23
+ PL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
24
+ PH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
25
+ PE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
26
+ PA: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
27
+ PK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
28
+ NZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
29
+ NO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
30
+ NG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
31
+ NL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
32
+ MY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
33
+ MH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
34
+ MX: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
35
+ KR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
36
+ JP: 'e51fc7b5-0c29-40c6-b2e8-58d9fa5e3c29',
37
+ IT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
38
+ IS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
39
+ IE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
40
+ IN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
41
+ IL: 'bc7a8d54-8df3-47cb-bb9b-3338fd6246e5',
42
+ ID: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
43
+ HU: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
44
+ HR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
45
+ GR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
46
+ GB: '3d059d26-8ce8-48ce-9779-b23e42014454',
47
+ FR: 'fbc1fb24-37bc-4c0f-afa4-35e88a43127d',
48
+ ES: 'f0e74759-d378-4ae7-9db7-42b4c7d02094',
49
+ EG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
50
+ DO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
51
+ DK: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
52
+ DE: 'c7bde0e2-187e-44e7-8f51-14162259eb2b',
53
+ CZ: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
54
+ CY: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
55
+ CR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
56
+ CO: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
57
+ CI: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
58
+ CN: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
59
+ CL: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
60
+ CH: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
61
+ CA: '2b942888-7d93-41ee-b85c-5705263f9eea',
62
+ CF: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
63
+ BR: '3160f799-1ade-455b-87f9-128875ec874e',
64
+ BS: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
65
+ BE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
66
+ BG: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
67
+ AT: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
68
+ AU: '76f1a42e-b609-4c8b-b41a-7ebf2fbb5a56',
69
+ AR: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
70
+ AE: 'b7b59987-e5c6-4ec7-a4af-f48318a68a5d',
71
+ };
72
+ export const DEFAULT_COUNTRY = 'COMMON';
73
+ const addressCountryToFormMap = Object.entries(ADDRESS_FORM_ID_BY_COUNTRY).map(([country, id]) => ({ country, id }));
74
+ /**
75
+ * Checks if a form has multiline address fields
76
+ *
77
+ * @param form - The form to check
78
+ * @param options - Optional configuration
79
+ * @param options.excludeEcomAddress - If true, excludes ecom-specific address fields
80
+ * @returns true if the form contains multiline address fields
81
+ */
82
+ export function hasMultilineAddressField(form) {
83
+ return (form.formFields?.some((field) => field.inputOptions?.inputType === forms.InputType.ADDRESS) ?? false);
84
+ }
85
+ /**
86
+ * Overrides template field IDs if needed
87
+ * This can be customized based on specific requirements
88
+ */
89
+ function overrideTemplateFieldIds(templates) {
90
+ // Default implementation - no overrides
91
+ // Override this if you need custom field ID mappings
92
+ return templates;
93
+ }
94
+ /**
95
+ * Fetches address form templates for all supported countries.
96
+ * These templates are needed for rendering multiline address fields
97
+ * with country-specific address formats.
98
+ *
99
+ * @returns Array of address templates indexed by country, or undefined if fetch fails
100
+ * @throws {Error} When the API request fails
101
+ *
102
+ * @example
103
+ * ```tsx
104
+ * const addressTemplates = await fetchAddressForms();
105
+ * // Returns: [{ country: 'US', id: '...', template: {...} }, ...]
106
+ * ```
107
+ */
108
+ export async function fetchAddressForms() {
109
+ try {
110
+ const url = `https://www.wixapis.com/form-template-service/v1/templates?templateIds=0d5dcb6d-1403-4b80-b73e-6d90a2245561&templateIds=ebe1c447-8fd5-4c7a-8cf1-75b94db68698&templateIds=b7b59987-e5c6-4ec7-a4af-f48318a68a5d&templateIds=e51fc7b5-0c29-40c6-b2e8-58d9fa5e3c29&templateIds=bc7a8d54-8df3-47cb-bb9b-3338fd6246e5&templateIds=3d059d26-8ce8-48ce-9779-b23e42014454&templateIds=fbc1fb24-37bc-4c0f-afa4-35e88a43127d&templateIds=f0e74759-d378-4ae7-9db7-42b4c7d02094&templateIds=c7bde0e2-187e-44e7-8f51-14162259eb2b&templateIds=2b942888-7d93-41ee-b85c-5705263f9eea&templateIds=3160f799-1ade-455b-87f9-128875ec874e&templateIds=76f1a42e-b609-4c8b-b41a-7ebf2fbb5a56&namespace=wix.form_platform.form`;
111
+ const response = await httpClient.fetchWithAuth(url);
112
+ if (!response.ok) {
113
+ throw new Error(`Failed to fetch form: ${response.status} ${response.statusText}`);
114
+ }
115
+ const data = await response.json();
116
+ const templatesWithOverrides = data.templates && overrideTemplateFieldIds(data.templates);
117
+ return addressCountryToFormMap
118
+ .map((addressCountryToForm) => ({
119
+ ...addressCountryToForm,
120
+ template: templatesWithOverrides?.find((_form) => {
121
+ return _form.id === addressCountryToForm.id;
122
+ }),
123
+ }))
124
+ .filter((addressCountryToForm) => Boolean(addressCountryToForm.template));
125
+ }
126
+ catch (error) {
127
+ console.error('Failed to fetch address forms:', error);
128
+ throw error;
129
+ }
130
+ }
@@ -1 +1,2 @@
1
1
  export { getUploadUrl, uploadFile } from './file-upload-utils';
2
+ export { hasMultilineAddressField, fetchAddressForms } from './address-forms';
@@ -1 +1,2 @@
1
1
  export { getUploadUrl, uploadFile } from './file-upload-utils';
2
+ export { hasMultilineAddressField, fetchAddressForms } from './address-forms';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-forms",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
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.68.0",
45
+ "@wix/form-public": "^0.95.0",
46
46
  "@wix/forms": "^1.0.331",
47
47
  "@wix/headless-utils": "0.0.8",
48
48
  "@wix/services-definitions": "^0.1.4",
@@ -59,5 +59,5 @@
59
59
  "groupId": "com.wixpress.headless-components"
60
60
  }
61
61
  },
62
- "falconPackageHash": "4cc244b64113d6b53fa1ed4d4a8d082fece7978b89d43da73d1dae9f"
62
+ "falconPackageHash": "7a802b3af894bd379d396ecadf0577e0d20335ee486354273b550919"
63
63
  }