@verbb/formie-browser 1.0.14 → 1.0.15
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.
- package/CHANGELOG.md +30 -0
- package/dist/chunks/{address-country-Dn71jroa.js → address-country-BcEQKw0T.js} +1 -1
- package/dist/chunks/{address-finder-O49uDRoR.js → address-finder-BWGINCSA.js} +1 -1
- package/dist/chunks/{address-state-ByYatUur.js → address-state-DI3ndhMU.js} +98 -88
- package/dist/chunks/{api-DYYsVIub.js → api-BK9b340y.js} +16 -16
- package/dist/chunks/{api-D6kJ7kXZ.js → api-Dxl_CKw-.js} +30 -25
- package/dist/chunks/{async-nPFRNQ06.js → async-2GdXNFCE.js} +18 -1
- package/dist/chunks/{bpoint-D0RKFM4F.js → bpoint-BwtuyN_O.js} +1 -1
- package/dist/chunks/{captcha-eu-DERJbXnH.js → captcha-eu-DWLoQFKB.js} +2 -2
- package/dist/chunks/{combobox-CWNdx4Fk.js → combobox-Ba08_cHL.js} +259 -258
- package/dist/chunks/{conditions-DqNHLTbN.js → conditions-Ceeg6ReZ.js} +113 -110
- package/dist/chunks/{date-picker-RUnevF7l.js → date-picker-DaPvMrop.js} +12 -11
- package/dist/chunks/{eway-or6dtjoT.js → eway-uw0DzU-L.js} +3 -3
- package/dist/chunks/{file-upload-Bm-TXyNB.js → file-upload-B8_mH012.js} +28 -16
- package/dist/chunks/{friendly-captcha-v1-GFqCt1Mh.js → friendly-captcha-v1-CVXaXgDO.js} +1 -1
- package/dist/chunks/{friendly-captcha-v2-WoW246JG.js → friendly-captcha-v2-DkeIVTKI.js} +1 -1
- package/dist/chunks/{go-cardless-DzJ-0FKg.js → go-cardless-c4wLJdOt.js} +1 -1
- package/dist/chunks/{google-address-C1P1nTDM.js → google-address-JHYvjwgN.js} +13 -8
- package/dist/chunks/{hcaptcha-D0T8aIHz.js → hcaptcha-Dt3ELLlP.js} +2 -2
- package/dist/chunks/{loqate-DD1S7PY9.js → loqate-m51iPyO1.js} +1 -1
- package/dist/chunks/{mollie-DG8Ju83x.js → mollie-Bn0PX173.js} +1 -1
- package/dist/chunks/{moneris-C8m3Fvqu.js → moneris-BRbUvI4t.js} +1 -1
- package/dist/chunks/{opayo-B3EvrVxw.js → opayo-BwWdInEP.js} +2 -2
- package/dist/chunks/{paddle-BIYR9Um3.js → paddle-CympHVvd.js} +2 -2
- package/dist/chunks/{paypal-B_yxIo2d.js → paypal-h75h6wae.js} +2 -2
- package/dist/chunks/{payway-CeOzS0sL.js → payway-C9rHTCC_.js} +2 -2
- package/dist/chunks/{phone-country-bAqje17P.js → phone-country-B8fv-L5_.js} +1 -1
- package/dist/chunks/{place-kit-BE5gi3vo.js → place-kit-BnZGQ-L1.js} +8 -8
- package/dist/chunks/{recaptcha-enterprise-CruXddZq.js → recaptcha-enterprise-CUs8BO6V.js} +2 -2
- package/dist/chunks/{recaptcha-shared-AQRMDMme.js → recaptcha-shared-DTbTw-MF.js} +2 -2
- package/dist/chunks/{recaptcha-v2-checkbox-CCnJYCnG.js → recaptcha-v2-checkbox-P1McW4Pv.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-BuVqRRYn.js → recaptcha-v2-invisible-FGDqozSP.js} +2 -2
- package/dist/chunks/{recaptcha-v3-CloqhO2A.js → recaptcha-v3-CflUHeZD.js} +2 -2
- package/dist/chunks/{repeater-DwE27jI1.js → repeater-CyhDbozO.js} +47 -33
- package/dist/chunks/{scripts-CbQ7agX3.js → scripts-DrccjrFv.js} +1 -1
- package/dist/chunks/skip-CEW89ExY.js +7 -0
- package/dist/chunks/{snaptcha-C04kNGYQ.js → snaptcha-C3QLYxFT.js} +1 -1
- package/dist/chunks/{square-DEzxv9D9.js → square-C1z5DPVw.js} +2 -2
- package/dist/chunks/{stripe-CVPQGDz3.js → stripe-Dmkdkq1y.js} +2 -2
- package/dist/chunks/{summary-BF_8mrXI.js → summary-Bn-g5SDx.js} +1 -1
- package/dist/chunks/{table-DnIBdeKF.js → table-j7MlLLCc.js} +1 -1
- package/dist/chunks/{turnstile-n9DNyPxi.js → turnstile-ptihQfLl.js} +2 -2
- package/dist/chunks/{upload-manager-BbiUosZq.js → upload-manager-BW7l-BhF.js} +248 -236
- package/dist/index.js +548 -535
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts +3 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/modules/address/google-address.d.ts +10 -0
- package/dist/js/modules/address/google-address.d.ts.map +1 -1
- package/dist/js/modules/address/place-kit.d.ts.map +1 -1
- package/dist/js/modules/fields/address-state.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions.d.ts.map +1 -1
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
- package/dist/js/modules/fields/repeater.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
- package/dist/js/utils/async.d.ts +1 -0
- package/dist/js/utils/async.d.ts.map +1 -1
- package/dist/js/validation/rules/required.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/js/core/create-formie-client.ts +17 -10
- package/src/js/core/submit-result-state.ts +17 -0
- package/src/js/core/submit-result-ui.ts +4 -3
- package/src/js/modules/address/google-address.ts +95 -37
- package/src/js/modules/address/place-kit.ts +13 -7
- package/src/js/modules/fields/address-country.ts +5 -5
- package/src/js/modules/fields/address-state.ts +74 -23
- package/src/js/modules/fields/combobox.ts +3 -0
- package/src/js/modules/fields/conditions/effects.ts +4 -5
- package/src/js/modules/fields/conditions.ts +6 -0
- package/src/js/modules/fields/date-picker.ts +6 -3
- package/src/js/modules/fields/file-upload.ts +44 -14
- package/src/js/modules/fields/phone-country.ts +2 -2
- package/src/js/modules/fields/repeater.ts +55 -4
- package/src/js/modules/fields/upload-manager.ts +54 -18
- package/src/js/utils/async.ts +34 -0
- package/src/js/validation/rules/required.ts +12 -0
- package/src/js/validation/validator.ts +14 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-formie-client.d.ts","sourceRoot":"","sources":["../../../src/js/core/create-formie-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,YAAY,EAGf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-formie-client.d.ts","sourceRoot":"","sources":["../../../src/js/core/create-formie-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,YAAY,EAGf,MAAM,mBAAmB,CAAC;AA03B3B,wBAAgB,kBAAkB,IAAI,YAAY,CAguBjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-result-state.d.ts","sourceRoot":"","sources":["../../../src/js/core/submit-result-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwH1D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAqB/E;AA4GD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CA0B5F;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAwB9D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAkE9E;
|
|
1
|
+
{"version":3,"file":"submit-result-state.d.ts","sourceRoot":"","sources":["../../../src/js/core/submit-result-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwH1D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAqB/E;AA4GD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CA0B5F;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAwB9D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAkE9E;AA2KD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA4GhH"}
|
|
@@ -6,6 +6,8 @@ export declare function clearAriaInvalid(form: HTMLFormElement): void;
|
|
|
6
6
|
export declare function renderFieldErrors(form: HTMLFormElement, fieldErrors: Record<string, string[]>): void;
|
|
7
7
|
export declare function renderFormErrors(form: HTMLFormElement, formErrors: string[]): void;
|
|
8
8
|
export declare function renderFormNotice(form: HTMLFormElement, message: string): void;
|
|
9
|
-
export declare function renderFormSuccess(form: HTMLFormElement, message: string
|
|
9
|
+
export declare function renderFormSuccess(form: HTMLFormElement, message: string, options?: {
|
|
10
|
+
hideForm?: boolean;
|
|
11
|
+
}): void;
|
|
10
12
|
export declare function applySubmitResultUi(form: HTMLFormElement, result: FormSubmitResult): void;
|
|
11
13
|
//# sourceMappingURL=submit-result-ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-result-ui.d.ts","sourceRoot":"","sources":["../../../src/js/core/submit-result-ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAuK1D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAA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,IAAI,CAclF;AAYD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAY7E;AAgBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,IAAI,CAmCpH;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAsCzF"}
|
|
@@ -4,6 +4,16 @@ type GoogleAddressProviderOptions = {
|
|
|
4
4
|
options?: Record<string, unknown>;
|
|
5
5
|
countryDefaultValue?: string;
|
|
6
6
|
};
|
|
7
|
+
type GooglePostalAddress = {
|
|
8
|
+
addressLines?: unknown[];
|
|
9
|
+
};
|
|
10
|
+
export declare function buildAddressFromComponents(formData: Record<string, string>, postalAddress?: GooglePostalAddress): {
|
|
11
|
+
address1: string;
|
|
12
|
+
city: string;
|
|
13
|
+
state: string;
|
|
14
|
+
zip: string;
|
|
15
|
+
country: string;
|
|
16
|
+
};
|
|
7
17
|
export declare function buildGoogleAutocompleteOptions(provider: GoogleAddressProviderOptions): Record<string, unknown>;
|
|
8
18
|
export declare const googleAddressModule: import("../../..").BrowserModuleDefinition;
|
|
9
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-address.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/address/google-address.ts"],"names":[],"mappings":"AAUA,KAAK,4BAA4B,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"google-address.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/address/google-address.ts"],"names":[],"mappings":"AAUA,KAAK,4BAA4B,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AA8IF,KAAK,mBAAmB,GAAG;IACvB,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;CAC5B,CAAC;AA0BF,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,aAAa,CAAC,EAAE,mBAAmB,GACpC;IACC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB,CAwBA;AAmBD,wBAAgB,8BAA8B,CAC1C,QAAQ,EAAE,4BAA4B,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB;AAED,eAAO,MAAM,mBAAmB,4CAwL9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-kit.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/address/place-kit.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"place-kit.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/address/place-kit.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,cAAc,4CA0EzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-state.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/address-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"address-state.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/address-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAo9BlE,eAAO,MAAM,kBAAkB,EAAE,uBAsBhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/combobox.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4CAA4C,CAAC;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/combobox.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4CAA4C,CAAC;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAmBlE,MAAM,MAAM,qBAAqB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,KAAK,iBAAiB,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG;IACtD,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,KAAK,aAAa,GAAG,iBAAiB,GAAG;IACrC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;CACxC,CAAC;AA6CF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,IAAI,CAuFzG;AAED,eAAO,MAAM,cAAc,EAAE,uBAuC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../../../src/js/modules/fields/conditions/effects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../../../src/js/modules/fields/conditions/effects.ts"],"names":[],"mappings":"AA6MA,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,OAAO,EACpB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACzE,OAAO,CA+BT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AA6BlE,eAAO,MAAM,gBAAgB,EAAE,uBAgS9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/date-picker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/date-picker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAqWlE,eAAO,MAAM,gBAAgB,EAAE,uBA0C9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/file-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/file-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAsrBlE,eAAO,MAAM,gBAAgB,EAAE,uBAiE9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeater.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/repeater.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"repeater.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/repeater.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AA+OlE,eAAO,MAAM,cAAc,EAAE,uBA0C5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-manager.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/upload-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"upload-manager.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/upload-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAm1ClE,eAAO,MAAM,mBAAmB,EAAE,uBAqFjC,CAAC"}
|
package/dist/js/utils/async.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export declare function waitFor<T>(callback: () => T | null | undefined | false,
|
|
|
5
5
|
}): Promise<T>;
|
|
6
6
|
export declare function debounce<TArgs extends unknown[]>(callback: (...args: TArgs) => void, delayMs: number): (...args: TArgs) => void;
|
|
7
7
|
export declare function waitForElement(selector: string, root?: ParentNode): Promise<Element>;
|
|
8
|
+
export declare function waitForElementRemoval(selector: string, root?: ParentNode, timeoutMs?: number): Promise<void>;
|
|
8
9
|
//# sourceMappingURL=async.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/js/utils/async.ts"],"names":[],"mappings":"AAAA,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrD;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC3B,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAC5C,EACI,SAAgB,EAChB,UAAe,GAClB,GAAE;IACC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAClB,GACP,OAAO,CAAC,CAAC,CAAC,CAgBZ;AAED,wBAAgB,QAAQ,CAAC,KAAK,SAAS,OAAO,EAAE,EAC5C,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,EAClC,OAAO,EAAE,MAAM,GAChB,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,CAY1B;AAED,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,UAAqB,GAC5B,OAAO,CAAC,OAAO,CAAC,CA2BlB"}
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/js/utils/async.ts"],"names":[],"mappings":"AAAA,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrD;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC3B,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAC5C,EACI,SAAgB,EAChB,UAAe,GAClB,GAAE;IACC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAClB,GACP,OAAO,CAAC,CAAC,CAAC,CAgBZ;AAED,wBAAgB,QAAQ,CAAC,KAAK,SAAS,OAAO,EAAE,EAC5C,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,EAClC,OAAO,EAAE,MAAM,GAChB,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,CAY1B;AAED,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,UAAqB,GAC5B,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,UAAqB,EAC3B,SAAS,SAAQ,GAClB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required.d.ts","sourceRoot":"","sources":["../../../../src/js/validation/rules/required.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,QAAA,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"required.d.ts","sourceRoot":"","sources":["../../../../src/js/validation/rules/required.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,QAAA,MAAM,QAAQ,EAAE,wBAqCf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/js/validation/validator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EAClB,MAAM,mBAAmB,CAAC;AAM3B,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC;IAC9C,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAC;CACrD,CAAC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AAY,CACR,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,EACtD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,GAClD,IAAI;IAOP,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAGtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbb/formie-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@placekit/autocomplete-js": "^2.2.1",
|
|
102
102
|
"@uppy/core": "^5.2.0",
|
|
103
103
|
"@uppy/xhr-upload": "^5.2.0",
|
|
104
|
-
"@verbb/formie-core": "1.0.
|
|
104
|
+
"@verbb/formie-core": "1.0.15",
|
|
105
105
|
"expression-language": "^2.5.4",
|
|
106
106
|
"flatpickr": "^4.6.13",
|
|
107
107
|
"friendly-challenge": "^0.9.19",
|
|
@@ -32,6 +32,7 @@ import { runSubmitPipeline } from '#submit/pipeline';
|
|
|
32
32
|
import { clearSubmissionOnUnload, requestGraphqlRender, requestRefreshTokens, requestRender, requestSetPage } from '#transport/forms-api';
|
|
33
33
|
import { ensureFormStartedAt } from '#utils/form-started-at';
|
|
34
34
|
import { createDebug } from '#utils/debug';
|
|
35
|
+
import { waitForElementRemoval } from '#utils/async';
|
|
35
36
|
import { createFormUnloadWarningGuard } from '#utils/unload-warning';
|
|
36
37
|
import { getValidationScope } from '#validation/scope';
|
|
37
38
|
import { FormieValidator } from '#validation/validator';
|
|
@@ -212,7 +213,7 @@ function mergeSearchParams(sourceUrl: string | null, destinationUrl: string): st
|
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
function
|
|
216
|
+
function normalizeServerRenderedUrls(target: Element, form: HTMLFormElement, options: FormMountOptions): void {
|
|
216
217
|
const baseEndpoint = options.endpoint || (target as HTMLElement).dataset.formieEndpoint;
|
|
217
218
|
const submitAction = resolveHeadlessEndpoint(baseEndpoint, DEFAULT_HEADLESS_SUBMIT_ACTION);
|
|
218
219
|
const existingAction = form.getAttribute('action');
|
|
@@ -991,11 +992,15 @@ export function createFormieClient(): FormieClient {
|
|
|
991
992
|
mode: normalizeMode(options.mode ?? mergedFromDom.mode),
|
|
992
993
|
transport: normalizeTransport(options.transport ?? mergedFromDom.transport),
|
|
993
994
|
};
|
|
994
|
-
const compatibilityOptions = resolveLegacyCompatibilityOptions(normalizedOptions.compatibility);
|
|
995
|
-
|
|
996
|
-
|
|
997
995
|
const renderPayload = await ensureHtmlRender(target, normalizedOptions);
|
|
998
996
|
const form = getFormFromTarget(target);
|
|
997
|
+
|
|
998
|
+
// Fetched HTML carries the plugin setting on the form, not its mount wrapper.
|
|
999
|
+
if (options.compatibility === undefined && form?.hasAttribute('data-formie-compatibility')) {
|
|
1000
|
+
normalizedOptions.compatibility = inferOptionsFromElement(form).compatibility;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
const compatibilityOptions = resolveLegacyCompatibilityOptions(normalizedOptions.compatibility);
|
|
999
1004
|
if (form) setFormBrowserRequestOptions(form, normalizedOptions);
|
|
1000
1005
|
normalizedOptions.staticCache =
|
|
1001
1006
|
options.staticCache ??
|
|
@@ -1066,13 +1071,8 @@ export function createFormieClient(): FormieClient {
|
|
|
1066
1071
|
if (form) {
|
|
1067
1072
|
ensureFormStartedAt(form);
|
|
1068
1073
|
|
|
1069
|
-
|
|
1070
|
-
if (normalizedOptions.theme && normalizedOptions.theme !== 'formie') {
|
|
1071
|
-
form.setAttribute('data-formie-frontend-theme', normalizedOptions.theme);
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
1074
|
if (renderPayload || normalizedOptions.endpoint || (target as HTMLElement).dataset.formieEndpoint) {
|
|
1075
|
-
|
|
1075
|
+
normalizeServerRenderedUrls(target, form, normalizedOptions);
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
1078
|
if (normalizedOptions.mode === 'server-rendered' && hasServerRenderedValidationErrors(form)) {
|
|
@@ -1089,6 +1089,13 @@ export function createFormieClient(): FormieClient {
|
|
|
1089
1089
|
});
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
+
// Craft's async CSRF element initializes the session. Let it finish before
|
|
1093
|
+
// captcha modules request session-bound tokens, otherwise the concurrent
|
|
1094
|
+
// responses can race and replace each other's session cookie.
|
|
1095
|
+
if (form?.querySelector('craft-csrf-input')) {
|
|
1096
|
+
await waitForElementRemoval('craft-csrf-input', form);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1092
1099
|
// Modules run against the mounted DOM surface, not against server payload
|
|
1093
1100
|
// objects, so the loader resolves real targets before calling setup().
|
|
1094
1101
|
const modules = await loadModulesFromManifest(moduleManifest, {
|
|
@@ -371,6 +371,17 @@ export function applyPageState(form: HTMLFormElement, nextPageId: string): void
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
function syncSubmissionIdentity(form: HTMLFormElement, result: FormSubmitResult): void {
|
|
374
|
+
if (result.meta?.resetSubmissionIdentity === true) {
|
|
375
|
+
// Saved spam is terminal. Preserve the entered values for correction,
|
|
376
|
+
// but do not try to continue the rejected record on the next submit.
|
|
377
|
+
removeHiddenInput(form, 'submissionId');
|
|
378
|
+
removeHiddenInput(form, 'submissionUid');
|
|
379
|
+
removeHiddenInput(form, 'progressId');
|
|
380
|
+
setHiddenInputValue(form, 'expectedVersion', '0');
|
|
381
|
+
clearResumeTokenState(form);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
374
385
|
const session = result.meta?.session as { version?: number } | undefined;
|
|
375
386
|
const version = session?.version ?? result.meta?.version;
|
|
376
387
|
if (typeof version === 'number') {
|
|
@@ -542,6 +553,12 @@ export function applySubmitResultState(form: HTMLFormElement, result: FormSubmit
|
|
|
542
553
|
return;
|
|
543
554
|
}
|
|
544
555
|
|
|
556
|
+
// Provider handlers may navigate as soon as their action event is dispatched.
|
|
557
|
+
// Treat checkout navigation like the generic redirect before invoking them.
|
|
558
|
+
if (result.payment?.action?.type === 'redirect' && result.payment.action.url) {
|
|
559
|
+
markInternalNavigation(form, 'payment-redirect');
|
|
560
|
+
}
|
|
561
|
+
|
|
545
562
|
// Dispatch payment/redirect events from submitData (e.g. formie:payment:mollie:redirect)
|
|
546
563
|
const eventDispatchResult = dispatchSubmitDataEvents(form, result);
|
|
547
564
|
|
|
@@ -363,7 +363,7 @@ function shouldRenderSuccessMessage(form: HTMLFormElement, result: FormSubmitRes
|
|
|
363
363
|
return getConfiguredCompletionBehavior(form) === 'message' && getSuccessMessagePosition(form) !== '';
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
export function renderFormSuccess(form: HTMLFormElement, message: string): void {
|
|
366
|
+
export function renderFormSuccess(form: HTMLFormElement, message: string, options: { hideForm?: boolean } = {}): void {
|
|
367
367
|
const position = getSuccessMessagePosition(form);
|
|
368
368
|
|
|
369
369
|
if (!position) {
|
|
@@ -384,7 +384,7 @@ export function renderFormSuccess(form: HTMLFormElement, message: string): void
|
|
|
384
384
|
successNode.innerHTML = message;
|
|
385
385
|
container.appendChild(successNode);
|
|
386
386
|
|
|
387
|
-
if (shouldHideFormOnSuccess(form)) {
|
|
387
|
+
if (options.hideForm !== false && shouldHideFormOnSuccess(form)) {
|
|
388
388
|
setFormHiddenState(form, true);
|
|
389
389
|
}
|
|
390
390
|
|
|
@@ -408,7 +408,8 @@ export function applySubmitResultUi(form: HTMLFormElement, result: FormSubmitRes
|
|
|
408
408
|
|
|
409
409
|
if (result.ok) {
|
|
410
410
|
if (shouldRenderSuccessMessage(form, result)) {
|
|
411
|
-
|
|
411
|
+
// Saving progress acknowledges persistence without completing the form.
|
|
412
|
+
renderFormSuccess(form, result.message || '', { hideForm: result.action !== 'save' });
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
return;
|
|
@@ -30,7 +30,8 @@ async function loadGoogleMapsScript(apiKey: string): Promise<GoogleMaps> {
|
|
|
30
30
|
if (maps?.places?.PlaceAutocompleteElement) {
|
|
31
31
|
return existing as GoogleMaps;
|
|
32
32
|
}
|
|
33
|
-
const imp = maps as
|
|
33
|
+
const imp = maps as
|
|
34
|
+
{ importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
34
35
|
if (typeof imp?.importLibrary === 'function') {
|
|
35
36
|
await imp.importLibrary('places');
|
|
36
37
|
}
|
|
@@ -44,7 +45,8 @@ async function loadGoogleMapsScript(apiKey: string): Promise<GoogleMaps> {
|
|
|
44
45
|
const existingScript = document.getElementById(SCRIPT_ID);
|
|
45
46
|
if (existingScript) {
|
|
46
47
|
const google = await ensureGlobal<GoogleMaps>('google', 10000);
|
|
47
|
-
const maps = google?.maps as
|
|
48
|
+
const maps = google?.maps as
|
|
49
|
+
{ importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
48
50
|
if (typeof maps?.importLibrary === 'function') {
|
|
49
51
|
await maps.importLibrary('places');
|
|
50
52
|
}
|
|
@@ -80,7 +82,8 @@ async function loadGoogleMapsScript(apiKey: string): Promise<GoogleMaps> {
|
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
const google = await ready;
|
|
83
|
-
const maps = google?.maps as
|
|
85
|
+
const maps = google?.maps as
|
|
86
|
+
{ importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
84
87
|
if (typeof maps?.importLibrary === 'function') {
|
|
85
88
|
await maps.importLibrary('places');
|
|
86
89
|
}
|
|
@@ -152,7 +155,13 @@ type AddressComponent = {
|
|
|
152
155
|
long_text?: string;
|
|
153
156
|
};
|
|
154
157
|
|
|
155
|
-
|
|
158
|
+
type GooglePostalAddress = {
|
|
159
|
+
addressLines?: unknown[];
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
function parseAddressComponents(
|
|
163
|
+
components: AddressComponent[],
|
|
164
|
+
): Record<string, string> {
|
|
156
165
|
const map = componentMap();
|
|
157
166
|
const out: Record<string, string> = {};
|
|
158
167
|
|
|
@@ -162,10 +171,11 @@ function parseAddressComponents(components: AddressComponent[]): Record<string,
|
|
|
162
171
|
if (!type || !map[type as keyof typeof map]) continue;
|
|
163
172
|
|
|
164
173
|
const fieldKey = map[type as keyof typeof map];
|
|
165
|
-
const val =
|
|
166
|
-
??
|
|
167
|
-
|
|
168
|
-
??
|
|
174
|
+
const val =
|
|
175
|
+
(comp as unknown as Record<string, string>)[fieldKey] ??
|
|
176
|
+
comp.short_text ??
|
|
177
|
+
comp.long_text ??
|
|
178
|
+
'';
|
|
169
179
|
|
|
170
180
|
out[type] = val;
|
|
171
181
|
}
|
|
@@ -173,17 +183,26 @@ function parseAddressComponents(components: AddressComponent[]): Record<string,
|
|
|
173
183
|
return out;
|
|
174
184
|
}
|
|
175
185
|
|
|
176
|
-
function buildAddressFromComponents(
|
|
186
|
+
export function buildAddressFromComponents(
|
|
187
|
+
formData: Record<string, string>,
|
|
188
|
+
postalAddress?: GooglePostalAddress,
|
|
189
|
+
): {
|
|
177
190
|
address1: string;
|
|
178
191
|
city: string;
|
|
179
192
|
state: string;
|
|
180
193
|
zip: string;
|
|
181
194
|
country: string;
|
|
182
195
|
} {
|
|
183
|
-
|
|
196
|
+
const postalAddressLines = postalAddress?.addressLines?.filter(
|
|
197
|
+
(line): line is string =>
|
|
198
|
+
typeof line === 'string' && line.trim() !== '',
|
|
199
|
+
);
|
|
200
|
+
let address1 = postalAddressLines?.join(', ') || '';
|
|
184
201
|
|
|
185
|
-
if (formData.street_number || formData.route) {
|
|
186
|
-
address1 = [formData.street_number, formData.route]
|
|
202
|
+
if (!address1 && (formData.street_number || formData.route)) {
|
|
203
|
+
address1 = [formData.street_number, formData.route]
|
|
204
|
+
.filter(Boolean)
|
|
205
|
+
.join(' ');
|
|
187
206
|
|
|
188
207
|
if (formData.subpremise) {
|
|
189
208
|
address1 = `${formData.subpremise}/${address1}`;
|
|
@@ -203,7 +222,8 @@ function hasCountryRestriction(options: Record<string, unknown>): boolean {
|
|
|
203
222
|
const componentRestrictions = options.componentRestrictions;
|
|
204
223
|
|
|
205
224
|
if (componentRestrictions && typeof componentRestrictions === 'object') {
|
|
206
|
-
const country = (componentRestrictions as { country?: unknown })
|
|
225
|
+
const country = (componentRestrictions as { country?: unknown })
|
|
226
|
+
.country;
|
|
207
227
|
|
|
208
228
|
if (Array.isArray(country) ? country.length > 0 : Boolean(country)) {
|
|
209
229
|
return true;
|
|
@@ -215,7 +235,9 @@ function hasCountryRestriction(options: Record<string, unknown>): boolean {
|
|
|
215
235
|
return Array.isArray(includedRegionCodes) && includedRegionCodes.length > 0;
|
|
216
236
|
}
|
|
217
237
|
|
|
218
|
-
export function buildGoogleAutocompleteOptions(
|
|
238
|
+
export function buildGoogleAutocompleteOptions(
|
|
239
|
+
provider: GoogleAddressProviderOptions,
|
|
240
|
+
): Record<string, unknown> {
|
|
219
241
|
const options = { types: ['geocode'], ...(provider.options || {}) };
|
|
220
242
|
const country = provider.countryDefaultValue?.trim().toLowerCase();
|
|
221
243
|
|
|
@@ -247,10 +269,13 @@ export const googleAddressModule = defineAddressModule<
|
|
|
247
269
|
},
|
|
248
270
|
mount: async ({ api, field, services, provider }) => {
|
|
249
271
|
const input = services.input.getAutocomplete();
|
|
250
|
-
const PlaceAutocompleteElement =
|
|
272
|
+
const PlaceAutocompleteElement =
|
|
273
|
+
api?.maps?.places?.PlaceAutocompleteElement;
|
|
251
274
|
|
|
252
275
|
if (!input || typeof PlaceAutocompleteElement !== 'function') {
|
|
253
|
-
console.warn(
|
|
276
|
+
console.warn(
|
|
277
|
+
'[formie] Google Places API not ready; address autocomplete skipped.',
|
|
278
|
+
);
|
|
254
279
|
return null;
|
|
255
280
|
}
|
|
256
281
|
|
|
@@ -303,20 +328,40 @@ export const googleAddressModule = defineAddressModule<
|
|
|
303
328
|
wrapper.appendChild(input);
|
|
304
329
|
|
|
305
330
|
const onSelect = async (ev: Event): Promise<void> => {
|
|
306
|
-
const e = ev as unknown as {
|
|
331
|
+
const e = ev as unknown as {
|
|
332
|
+
placePrediction?: {
|
|
333
|
+
toPlace: () => Promise<{
|
|
334
|
+
addressComponents?: unknown[];
|
|
335
|
+
formattedAddress?: string;
|
|
336
|
+
postalAddress?: GooglePostalAddress;
|
|
337
|
+
fetchFields: (opts: {
|
|
338
|
+
fields: string[];
|
|
339
|
+
}) => Promise<void>;
|
|
340
|
+
}>;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
307
343
|
const pred = e.placePrediction;
|
|
308
344
|
|
|
309
345
|
if (!pred) return;
|
|
310
346
|
|
|
311
347
|
const place = await pred.toPlace();
|
|
312
|
-
await place.fetchFields({
|
|
348
|
+
await place.fetchFields({
|
|
349
|
+
fields: [
|
|
350
|
+
'addressComponents',
|
|
351
|
+
'formattedAddress',
|
|
352
|
+
'postalAddress',
|
|
353
|
+
],
|
|
354
|
+
});
|
|
313
355
|
|
|
314
356
|
if (!place.addressComponents) return;
|
|
315
357
|
|
|
316
358
|
const formData = parseAddressComponents(
|
|
317
359
|
place.addressComponents as AddressComponent[],
|
|
318
360
|
);
|
|
319
|
-
const address = buildAddressFromComponents(
|
|
361
|
+
const address = buildAddressFromComponents(
|
|
362
|
+
formData,
|
|
363
|
+
place.postalAddress,
|
|
364
|
+
);
|
|
320
365
|
|
|
321
366
|
setFieldValues(services, {
|
|
322
367
|
...address,
|
|
@@ -324,15 +369,19 @@ export const googleAddressModule = defineAddressModule<
|
|
|
324
369
|
});
|
|
325
370
|
|
|
326
371
|
field.dispatchEvent(
|
|
327
|
-
new CustomEvent(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
372
|
+
new CustomEvent(
|
|
373
|
+
getAddressProviderEventName('google', 'populate'),
|
|
374
|
+
{
|
|
375
|
+
bubbles: true,
|
|
376
|
+
detail: {
|
|
377
|
+
addressProvider: 'google',
|
|
378
|
+
place,
|
|
379
|
+
formattedAddress: place.formattedAddress,
|
|
380
|
+
addressComponents: place.addressComponents,
|
|
381
|
+
postalAddress: place.postalAddress,
|
|
382
|
+
},
|
|
334
383
|
},
|
|
335
|
-
|
|
384
|
+
),
|
|
336
385
|
);
|
|
337
386
|
};
|
|
338
387
|
autocomplete.addEventListener('gmp-select', onSelect as EventListener);
|
|
@@ -342,9 +391,14 @@ export const googleAddressModule = defineAddressModule<
|
|
|
342
391
|
onCurrentLocation: async (position, { field, services, provider }) => {
|
|
343
392
|
const { latitude, longitude } = position.coords;
|
|
344
393
|
const form = services.form;
|
|
345
|
-
const actionUrl =
|
|
346
|
-
|
|
347
|
-
const
|
|
394
|
+
const actionUrl =
|
|
395
|
+
provider.geocodeEndpoint || form?.action || window.location.href;
|
|
396
|
+
const fieldHandle = field
|
|
397
|
+
.getAttribute('data-formie-field-handle')
|
|
398
|
+
?.trim();
|
|
399
|
+
const formHandle = (
|
|
400
|
+
form?.querySelector('[name="handle"]') as HTMLInputElement | null
|
|
401
|
+
)?.value?.trim();
|
|
348
402
|
|
|
349
403
|
if (!formHandle || !fieldHandle) return;
|
|
350
404
|
|
|
@@ -356,14 +410,18 @@ export const googleAddressModule = defineAddressModule<
|
|
|
356
410
|
formData.append('handle', formHandle);
|
|
357
411
|
formData.append('fieldHandle', fieldHandle);
|
|
358
412
|
|
|
359
|
-
const response = await browserRequest(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
413
|
+
const response = await browserRequest(
|
|
414
|
+
actionUrl,
|
|
415
|
+
{
|
|
416
|
+
method: 'POST',
|
|
417
|
+
body: formData,
|
|
418
|
+
headers: {
|
|
419
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
420
|
+
Accept: 'application/json',
|
|
421
|
+
},
|
|
365
422
|
},
|
|
366
|
-
|
|
423
|
+
getFormBrowserRequestOptions(form),
|
|
424
|
+
);
|
|
367
425
|
|
|
368
426
|
const data = await response.json();
|
|
369
427
|
|
|
@@ -58,13 +58,6 @@ export const placeKitModule = defineAddressModule<
|
|
|
58
58
|
const picker = api(provider.apiKey, options as { target: HTMLInputElement });
|
|
59
59
|
|
|
60
60
|
picker.on('pick', (value, item: PlaceKitItem) => {
|
|
61
|
-
field.dispatchEvent(
|
|
62
|
-
new CustomEvent(getAddressProviderEventName('place-kit', 'populate'), {
|
|
63
|
-
bubbles: true,
|
|
64
|
-
detail: { addressProvider: 'place-kit', addressComponents: item },
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
61
|
let address1 = '';
|
|
69
62
|
|
|
70
63
|
if (item.street) {
|
|
@@ -87,6 +80,19 @@ export const placeKitModule = defineAddressModule<
|
|
|
87
80
|
services.input.setValue('state', item.administrative || '');
|
|
88
81
|
services.input.setValue('zip', typeof zip === 'string' ? zip : '');
|
|
89
82
|
services.input.setValue('country', countryValue || item.country || '');
|
|
83
|
+
|
|
84
|
+
// Notify dependent state controls after all address values are applied.
|
|
85
|
+
// Keep the provider value available while country options are loading.
|
|
86
|
+
field.dispatchEvent(
|
|
87
|
+
new CustomEvent(getAddressProviderEventName('place-kit', 'populate'), {
|
|
88
|
+
bubbles: true,
|
|
89
|
+
detail: {
|
|
90
|
+
addressProvider: 'place-kit',
|
|
91
|
+
addressComponents: item,
|
|
92
|
+
state: item.administrative || '',
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
90
96
|
});
|
|
91
97
|
|
|
92
98
|
return picker;
|
|
@@ -16,7 +16,7 @@ type ComboboxSelect = HTMLSelectElement & {
|
|
|
16
16
|
|
|
17
17
|
type AddressCountryOptions = {
|
|
18
18
|
countryPreselectFromIp?: boolean;
|
|
19
|
-
|
|
19
|
+
allowedCountryCodes?: string[];
|
|
20
20
|
countryOptionValue?: 'short' | 'full';
|
|
21
21
|
countryFromIpAction?: string;
|
|
22
22
|
};
|
|
@@ -33,14 +33,14 @@ function resolveCountrySelectValue(
|
|
|
33
33
|
return countryCode.toUpperCase();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function isCountryAllowed(countryCode: string,
|
|
37
|
-
if (!
|
|
36
|
+
function isCountryAllowed(countryCode: string, allowedCountryCodes: string[] = []): boolean {
|
|
37
|
+
if (!allowedCountryCodes.length) {
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const upperCode = countryCode.toUpperCase();
|
|
42
42
|
|
|
43
|
-
return
|
|
43
|
+
return allowedCountryCodes.some((allowed) => allowed.toUpperCase() === upperCode);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function optionExists(select: HTMLSelectElement, value: string): boolean {
|
|
@@ -91,7 +91,7 @@ async function preselectCountry(
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
if (!isCountryAllowed(response.countryCode, options.
|
|
94
|
+
if (!isCountryAllowed(response.countryCode, options.allowedCountryCodes)) {
|
|
95
95
|
debug.log('Detected country is not in the allowed list; skipping preselect.', {
|
|
96
96
|
countryCode: response.countryCode,
|
|
97
97
|
});
|