@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/chunks/{address-country-Dn71jroa.js → address-country-BcEQKw0T.js} +1 -1
  3. package/dist/chunks/{address-finder-O49uDRoR.js → address-finder-BWGINCSA.js} +1 -1
  4. package/dist/chunks/{address-state-ByYatUur.js → address-state-DI3ndhMU.js} +98 -88
  5. package/dist/chunks/{api-DYYsVIub.js → api-BK9b340y.js} +16 -16
  6. package/dist/chunks/{api-D6kJ7kXZ.js → api-Dxl_CKw-.js} +30 -25
  7. package/dist/chunks/{async-nPFRNQ06.js → async-2GdXNFCE.js} +18 -1
  8. package/dist/chunks/{bpoint-D0RKFM4F.js → bpoint-BwtuyN_O.js} +1 -1
  9. package/dist/chunks/{captcha-eu-DERJbXnH.js → captcha-eu-DWLoQFKB.js} +2 -2
  10. package/dist/chunks/{combobox-CWNdx4Fk.js → combobox-Ba08_cHL.js} +259 -258
  11. package/dist/chunks/{conditions-DqNHLTbN.js → conditions-Ceeg6ReZ.js} +113 -110
  12. package/dist/chunks/{date-picker-RUnevF7l.js → date-picker-DaPvMrop.js} +12 -11
  13. package/dist/chunks/{eway-or6dtjoT.js → eway-uw0DzU-L.js} +3 -3
  14. package/dist/chunks/{file-upload-Bm-TXyNB.js → file-upload-B8_mH012.js} +28 -16
  15. package/dist/chunks/{friendly-captcha-v1-GFqCt1Mh.js → friendly-captcha-v1-CVXaXgDO.js} +1 -1
  16. package/dist/chunks/{friendly-captcha-v2-WoW246JG.js → friendly-captcha-v2-DkeIVTKI.js} +1 -1
  17. package/dist/chunks/{go-cardless-DzJ-0FKg.js → go-cardless-c4wLJdOt.js} +1 -1
  18. package/dist/chunks/{google-address-C1P1nTDM.js → google-address-JHYvjwgN.js} +13 -8
  19. package/dist/chunks/{hcaptcha-D0T8aIHz.js → hcaptcha-Dt3ELLlP.js} +2 -2
  20. package/dist/chunks/{loqate-DD1S7PY9.js → loqate-m51iPyO1.js} +1 -1
  21. package/dist/chunks/{mollie-DG8Ju83x.js → mollie-Bn0PX173.js} +1 -1
  22. package/dist/chunks/{moneris-C8m3Fvqu.js → moneris-BRbUvI4t.js} +1 -1
  23. package/dist/chunks/{opayo-B3EvrVxw.js → opayo-BwWdInEP.js} +2 -2
  24. package/dist/chunks/{paddle-BIYR9Um3.js → paddle-CympHVvd.js} +2 -2
  25. package/dist/chunks/{paypal-B_yxIo2d.js → paypal-h75h6wae.js} +2 -2
  26. package/dist/chunks/{payway-CeOzS0sL.js → payway-C9rHTCC_.js} +2 -2
  27. package/dist/chunks/{phone-country-bAqje17P.js → phone-country-B8fv-L5_.js} +1 -1
  28. package/dist/chunks/{place-kit-BE5gi3vo.js → place-kit-BnZGQ-L1.js} +8 -8
  29. package/dist/chunks/{recaptcha-enterprise-CruXddZq.js → recaptcha-enterprise-CUs8BO6V.js} +2 -2
  30. package/dist/chunks/{recaptcha-shared-AQRMDMme.js → recaptcha-shared-DTbTw-MF.js} +2 -2
  31. package/dist/chunks/{recaptcha-v2-checkbox-CCnJYCnG.js → recaptcha-v2-checkbox-P1McW4Pv.js} +2 -2
  32. package/dist/chunks/{recaptcha-v2-invisible-BuVqRRYn.js → recaptcha-v2-invisible-FGDqozSP.js} +2 -2
  33. package/dist/chunks/{recaptcha-v3-CloqhO2A.js → recaptcha-v3-CflUHeZD.js} +2 -2
  34. package/dist/chunks/{repeater-DwE27jI1.js → repeater-CyhDbozO.js} +47 -33
  35. package/dist/chunks/{scripts-CbQ7agX3.js → scripts-DrccjrFv.js} +1 -1
  36. package/dist/chunks/skip-CEW89ExY.js +7 -0
  37. package/dist/chunks/{snaptcha-C04kNGYQ.js → snaptcha-C3QLYxFT.js} +1 -1
  38. package/dist/chunks/{square-DEzxv9D9.js → square-C1z5DPVw.js} +2 -2
  39. package/dist/chunks/{stripe-CVPQGDz3.js → stripe-Dmkdkq1y.js} +2 -2
  40. package/dist/chunks/{summary-BF_8mrXI.js → summary-Bn-g5SDx.js} +1 -1
  41. package/dist/chunks/{table-DnIBdeKF.js → table-j7MlLLCc.js} +1 -1
  42. package/dist/chunks/{turnstile-n9DNyPxi.js → turnstile-ptihQfLl.js} +2 -2
  43. package/dist/chunks/{upload-manager-BbiUosZq.js → upload-manager-BW7l-BhF.js} +248 -236
  44. package/dist/index.js +548 -535
  45. package/dist/js/core/create-formie-client.d.ts.map +1 -1
  46. package/dist/js/core/submit-result-state.d.ts.map +1 -1
  47. package/dist/js/core/submit-result-ui.d.ts +3 -1
  48. package/dist/js/core/submit-result-ui.d.ts.map +1 -1
  49. package/dist/js/modules/address/google-address.d.ts +10 -0
  50. package/dist/js/modules/address/google-address.d.ts.map +1 -1
  51. package/dist/js/modules/address/place-kit.d.ts.map +1 -1
  52. package/dist/js/modules/fields/address-state.d.ts.map +1 -1
  53. package/dist/js/modules/fields/combobox.d.ts.map +1 -1
  54. package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
  55. package/dist/js/modules/fields/conditions.d.ts.map +1 -1
  56. package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
  57. package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
  58. package/dist/js/modules/fields/repeater.d.ts.map +1 -1
  59. package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
  60. package/dist/js/utils/async.d.ts +1 -0
  61. package/dist/js/utils/async.d.ts.map +1 -1
  62. package/dist/js/validation/rules/required.d.ts.map +1 -1
  63. package/dist/js/validation/validator.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/src/js/core/create-formie-client.ts +17 -10
  66. package/src/js/core/submit-result-state.ts +17 -0
  67. package/src/js/core/submit-result-ui.ts +4 -3
  68. package/src/js/modules/address/google-address.ts +95 -37
  69. package/src/js/modules/address/place-kit.ts +13 -7
  70. package/src/js/modules/fields/address-country.ts +5 -5
  71. package/src/js/modules/fields/address-state.ts +74 -23
  72. package/src/js/modules/fields/combobox.ts +3 -0
  73. package/src/js/modules/fields/conditions/effects.ts +4 -5
  74. package/src/js/modules/fields/conditions.ts +6 -0
  75. package/src/js/modules/fields/date-picker.ts +6 -3
  76. package/src/js/modules/fields/file-upload.ts +44 -14
  77. package/src/js/modules/fields/phone-country.ts +2 -2
  78. package/src/js/modules/fields/repeater.ts +55 -4
  79. package/src/js/modules/fields/upload-manager.ts +54 -18
  80. package/src/js/utils/async.ts +34 -0
  81. package/src/js/validation/rules/required.ts +12 -0
  82. package/src/js/validation/validator.ts +14 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.15 - 2026-10-15
6
+
7
+ ### Changed
8
+ - Rename field module settings to `allowedCountryCodes`, `maxFiles`, `minFileSize` and `maxFileSize` to match the PHP field API.
9
+ - Remove the unused legacy frontend-theme attribute from mounted forms.
10
+
11
+ ### Fixed
12
+ - Fixed adding or removing repeater rows with the mouse automatically focusing fields in the submission editor, and keyboard focus targeting field wrappers instead of controls.
13
+ - Fixed hiding an unused state field triggering an unsaved-changes warning when opening a submission.
14
+ - Fixed PlaceKit autocomplete clearing the selected state when using a dynamic State / Province dropdown.
15
+ - Fixed dynamic state dropdowns using control-panel markup, including country changes and preservation of historical saved values.
16
+ - Fixed browser event compatibility not inheriting the setting from forms loaded into a wrapper through REST or GraphQL.
17
+ - Fixed resetting forms leaving added repeater rows or failing to restore removed rows and dynamic address state values.
18
+ - Fixed dynamic address state fields failing to reappear after selecting a country that uses states.
19
+ - Fixed dynamic address state fields remaining visible before a country was selected.
20
+ - Fixed required searchable dropdowns rejecting selected values during browser validation.
21
+ - Fixed address state fields becoming unresponsive when changing countries after selecting a state.
22
+ - Fixed date pickers displaying prefilled dates and date ranges one day early in time zones west of UTC.
23
+ - Fixed live validation error descriptions referencing another form when multiple forms used the same field handles.
24
+ - Fixed keyboard focus skipping newly added repeater rows and being lost when removing the focused row.
25
+ - Fixed correcting a spam-rejected submission causing a stale-session error and clearing entered values.
26
+ - Fixed payment checkout redirects showing an unsaved-changes warning and leaving forms disabled when cancelled.
27
+ - Fixed completed forms with conditional fields showing an unsaved-changes warning when leaving the page.
28
+ - Fixed required simple upload fields rejecting retained files when returning to an earlier page.
29
+ - Fixed simple file uploads losing attachment capabilities after a failed submission.
30
+ - Fixed Upload Manager silently rejecting files that exceed file type, size, or count restrictions.
31
+ - Fixed failed uploads continuing to display an active processing status.
32
+ - Fixed saving progress hiding unfinished forms when Hide Form was enabled for completion.
33
+ - Fixed matching page conditions revealing inactive pages in multi-page forms.
34
+
5
35
  ## 1.0.14 - 2026-10-08
6
36
 
7
37
  ### Added
@@ -37,7 +37,7 @@ async function f(e, n) {
37
37
  if (r.value.trim()) return;
38
38
  let a = await i(n.countryFromIpAction, e.closest("form"));
39
39
  if (!a?.countryCode) return;
40
- if (!l(a.countryCode, n.countryAllowed)) {
40
+ if (!l(a.countryCode, n.allowedCountryCodes)) {
41
41
  s.log("Detected country is not in the allowed list; skipping preselect.", { countryCode: a.countryCode });
42
42
  return;
43
43
  }
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./event-names-BCI2FLD8.js";
2
2
  import { t } from "./api-ghNr2uxX.js";
3
- import { r as n } from "./scripts-CbQ7agX3.js";
3
+ import { r as n } from "./scripts-DrccjrFv.js";
4
4
  //#region src/js/modules/address/address-finder.ts
5
5
  var r = "FORMIE_ADDRESS_FINDER_SCRIPT", i = t({
6
6
  moduleId: "formie:address-finder",
@@ -4,7 +4,7 @@ import { t as n } from "./debug-BV0DvdHx.js";
4
4
  import { a as r, n as i } from "./theme-classes-DAQuEqdP.js";
5
5
  import { n as a } from "./constants-DVcJAvc5.js";
6
6
  import { i as o, n as s } from "./shared-OKhSay59.js";
7
- import { initFormieCombobox as c } from "./combobox-CWNdx4Fk.js";
7
+ import { initFormieCombobox as c } from "./combobox-Ba08_cHL.js";
8
8
  //#region src/js/modules/fields/address-state.ts
9
9
  var l = "[data-formie-address-state-dynamic]", u = "[data-formie-address-state-input]", d = "[data-formie-address-state-autofill-anchor]", f = "formie-address-autofill-start", p = a.country, m = "address-state", h = "formie/address/subdivisions", g = ["formie-select", "formie-dropdown-input"], _ = [
10
10
  0,
@@ -23,7 +23,7 @@ function C(e) {
23
23
  return t instanceof HTMLInputElement || t instanceof HTMLSelectElement ? t : null;
24
24
  }
25
25
  function w(e) {
26
- return e.querySelector("[data-formie-field-label]");
26
+ return e.querySelector("[data-formie-field-label]") || (e.querySelector("[data-formie-address-state-cp]") ? e.querySelector(":scope > .heading > label") : null);
27
27
  }
28
28
  function T(e) {
29
29
  e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
@@ -34,11 +34,8 @@ function E(e, t) {
34
34
  n && n.getValue() !== t && n.setValue(t, !0);
35
35
  }
36
36
  function D(e, t) {
37
- if (e.value !== t) {
38
- e.value = t, T(e);
39
- return;
40
- }
41
- E(e, t);
37
+ let n = e.value;
38
+ e.value = t, E(e, e.value), e.value !== n && T(e);
42
39
  }
43
40
  function O(e, t) {
44
41
  e.autofillAnchor && (e.autofillAnchor.value = t);
@@ -50,28 +47,28 @@ function k(e) {
50
47
  function A(e) {
51
48
  return e.pendingStateValue?.trim() || e.autofillAnchor?.value?.trim() || e.stateControl.value?.trim() || "";
52
49
  }
53
- function j(e) {
50
+ function ee(e) {
54
51
  if (e.autofillAnchor) return e.autofillAnchor;
55
52
  let t = e.addressRoot.querySelector(d);
56
53
  if (t instanceof HTMLInputElement) e.autofillAnchor = t;
57
54
  else {
58
55
  let t = document.createElement("input");
59
- t.type = "text", t.setAttribute("data-formie-address-state-autofill-anchor", "true"), t.setAttribute("autocomplete", "address-level1"), t.setAttribute("tabindex", "-1"), t.setAttribute("aria-hidden", "true"), t.className = "formie-sr-only", e.addressRoot.appendChild(t), e.autofillAnchor = t;
56
+ t.type = "text", t.setAttribute("data-formie-address-state-autofill-anchor", "true"), t.setAttribute("autocomplete", "address-level1"), t.setAttribute("tabindex", "-1"), t.setAttribute("aria-hidden", "true"), t.className = "formie-sr-only", t.hidden = e.isCpEdit, e.addressRoot.appendChild(t), e.autofillAnchor = t;
60
57
  }
61
58
  return e.stateControl.setAttribute("autocomplete", "off"), e.stateControl.value && !e.autofillAnchor.value && (e.autofillAnchor.value = e.stateControl.value), e.autofillAnchor;
62
59
  }
63
- function M(e) {
60
+ function j(e) {
64
61
  k(e);
65
62
  let t = A(e);
66
63
  if (!t) return;
67
- let n = e.lastSubdivisions, r = n.length > 0 && L(t, n) || t;
68
- D(e.stateControl, r), E(e.stateControl, r), O(e, r), e.pendingStateValue = r;
64
+ let n = e.lastSubdivisions, r = e.stateControl instanceof HTMLSelectElement ? I(t, n) || "" : t;
65
+ O(e, r), e.pendingStateValue = r, D(e.stateControl, r);
69
66
  }
70
- function N(e, t, n, r) {
67
+ function M(e, t, n, r) {
71
68
  let i = new URL(/^https?:\/\//.test(e) || e.startsWith("/") ? e : `/actions/${e}`, window.location.origin);
72
69
  return i.searchParams.set("country", t), i.searchParams.set("optionLabel", n), i.searchParams.set("optionValue", r), i.toString();
73
70
  }
74
- function P(e, t, n, r) {
71
+ function N(e, t, n, r) {
75
72
  return [
76
73
  e,
77
74
  t,
@@ -79,14 +76,14 @@ function P(e, t, n, r) {
79
76
  r
80
77
  ].join("|");
81
78
  }
82
- function F(e) {
79
+ function P(e) {
83
80
  return y.has(e);
84
81
  }
85
- async function I(e, n, r, i, a) {
86
- let o = P(e, n, r, i);
82
+ async function F(e, n, r, i, a) {
83
+ let o = N(e, n, r, i);
87
84
  return y.has(o) ? y.get(o) || null : (b.has(o) || b.set(o, (async () => {
88
85
  try {
89
- let s = await t(N(i, e, n, r), { headers: { Accept: "application/json" } }, a);
86
+ let s = await t(M(i, e, n, r), { headers: { Accept: "application/json" } }, a);
90
87
  if (!s.ok) return y.set(o, null), null;
91
88
  let c = await s.json();
92
89
  return y.set(o, c), c;
@@ -100,13 +97,13 @@ async function I(e, n, r, i, a) {
100
97
  }
101
98
  })()), b.get(o) || null);
102
99
  }
103
- function L(e, t) {
100
+ function I(e, t) {
104
101
  let n = e.trim().toLowerCase();
105
102
  if (!n) return null;
106
103
  for (let e of t) if (e.value.toLowerCase() === n || (e.name || "").toLowerCase() === n || (e.short || "").toLowerCase() === n || e.label.toLowerCase() === n) return e.value;
107
104
  return null;
108
105
  }
109
- function R(e, t) {
106
+ function L(e, t) {
110
107
  [
111
108
  "id",
112
109
  "name",
@@ -118,6 +115,7 @@ function R(e, t) {
118
115
  "data-formie-input-type",
119
116
  "data-formie-input-error-state",
120
117
  "data-formie-address-state-dynamic",
118
+ "data-formie-address-state-cp",
121
119
  "data-formie-address-state-hide-when-unused",
122
120
  "data-formie-address-state-use-searchable",
123
121
  "data-formie-address-state-use-datalist",
@@ -132,35 +130,35 @@ function R(e, t) {
132
130
  t.setAttribute(n, r);
133
131
  });
134
132
  }
135
- function z(e, t) {
136
- t.className = e.className;
133
+ function R(e, t) {
134
+ t.className = e.hasAttribute("data-formie-address-state-cp") ? "text fullwidth" : e.className;
137
135
  }
138
- function B(e, t) {
136
+ function z(e, t) {
139
137
  let n = [...g];
140
138
  i(e, "fieldControlError").forEach((t) => {
141
139
  e.classList.contains(t) && n.push(t);
142
140
  }), t.className = n.join(" ");
143
141
  }
144
- function V(e, t) {
142
+ function B(e, t) {
145
143
  return e.parentNode?.replaceChild(t, e), t;
146
144
  }
147
- function H(e, t) {
145
+ function V(e, t) {
148
146
  let n = document.createElement("input");
149
- return n.type = "text", R(e, n), z(e, n), n.setAttribute("data-formie-input-type", "text"), n.setAttribute("data-formie-address-state-input", "true"), n.setAttribute("data-formie-single-line-text-input", "true"), n.setAttribute("autocomplete", "off"), n.removeAttribute("data-formie-combobox-input"), n.value = t, n;
147
+ return n.type = "text", L(e, n), R(e, n), n.setAttribute("data-formie-input-type", "text"), n.setAttribute("data-formie-address-state-input", "true"), n.setAttribute("data-formie-single-line-text-input", "true"), n.setAttribute("autocomplete", "off"), n.removeAttribute("data-formie-combobox-input"), n.value = t, n;
150
148
  }
151
- function U(e, t, n, r = "") {
149
+ function H(e, t, n, r = "") {
152
150
  e.innerHTML = "";
153
151
  let i = document.createElement("option");
154
152
  i.value = "", i.textContent = n || "", e.appendChild(i), t.forEach((t) => {
155
153
  let n = document.createElement("option");
156
154
  n.value = t.value, n.textContent = t.label, e.appendChild(n);
157
- }), e.value = L(r, t) || r;
155
+ }), e.value = I(r, t) || r;
158
156
  }
159
- function W(e, t, n, r) {
157
+ function U(e, t, n, r) {
160
158
  let i = document.createElement("select");
161
- return R(e, i), B(e, i), i.setAttribute("data-formie-input-type", "select"), i.setAttribute("data-formie-address-state-input", "true"), i.setAttribute("data-formie-select", "true"), i.setAttribute("data-formie-dropdown-input", "true"), i.removeAttribute("data-formie-single-line-text-input"), i.setAttribute("autocomplete", "off"), U(i, n, r, t), i;
159
+ return L(e, i), z(e, i), i.setAttribute("data-formie-input-type", "select"), i.setAttribute("data-formie-address-state-input", "true"), i.setAttribute("data-formie-select", "true"), i.setAttribute("data-formie-dropdown-input", "true"), i.removeAttribute("data-formie-single-line-text-input"), i.setAttribute("autocomplete", "off"), H(i, n, r, t), i;
162
160
  }
163
- function G(e, t, n, r) {
161
+ function W(e, t, n, r) {
164
162
  let i = e.list;
165
163
  if (!r || n.length === 0) {
166
164
  e.removeAttribute("list"), i && i.remove();
@@ -172,40 +170,40 @@ function G(e, t, n, r) {
172
170
  n.value = t.label, a?.appendChild(n);
173
171
  }), e.setAttribute("list", t);
174
172
  }
175
- function K(e, t) {
173
+ function G(e, t) {
176
174
  let { stateField: n, stateControl: i, required: a } = e;
177
- if (r(n, n, "conditionalHidden", !t), n.toggleAttribute("data-formie-conditionally-hidden", !t), !t) {
178
- i.required = !1, i.disabled = !0;
175
+ if (r(n, n, "conditionalHidden", !t), n.toggleAttribute("data-formie-address-state-hidden", !t), !t) {
176
+ i.required = !1, i.disabled = !e.isCpEdit;
179
177
  return;
180
178
  }
181
179
  i.disabled = !1, i.required = a;
182
180
  }
183
- function q(e) {
181
+ function K(e) {
184
182
  if (e.fetchingAnnouncementEl) return e.fetchingAnnouncementEl;
185
183
  let t = document.createElement("div");
186
- return t.className = "formie-sr-only", t.setAttribute("data-formie-address-state-fetching-announce", "true"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "true"), e.addressRoot.appendChild(t), e.fetchingAnnouncementEl = t, t;
184
+ return t.className = e.isCpEdit ? "visually-hidden" : "formie-sr-only", t.setAttribute("data-formie-address-state-fetching-announce", "true"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "true"), e.addressRoot.appendChild(t), e.fetchingAnnouncementEl = t, t;
187
185
  }
188
- function J() {
186
+ function q() {
189
187
  let e = document.createElement("div");
190
188
  e.className = "formie-address-state-skeleton", e.setAttribute("data-formie-address-state-skeleton", "true"), e.setAttribute("aria-hidden", "true");
191
189
  let t = document.createElement("div");
192
190
  return t.className = "formie-address-state-skeleton-input", e.appendChild(t), e;
193
191
  }
194
- function Y(e) {
195
- e.addressRoot.setAttribute("data-formie-address-state-fetching", "true"), e.countryControl?.setAttribute("aria-busy", "true"), e.stateControl.setAttribute("aria-hidden", "true"), e.stateControl.setAttribute("tabindex", "-1"), r(e.stateField, e.stateField, "conditionalHidden", !1), e.stateField.removeAttribute("data-formie-conditionally-hidden"), e.stateField.setAttribute("data-formie-address-state-skeleton-active", "true");
192
+ function J(e) {
193
+ e.addressRoot.setAttribute("data-formie-address-state-fetching", "true"), e.countryControl?.setAttribute("aria-busy", "true"), e.stateControl.setAttribute("aria-hidden", "true"), e.stateControl.setAttribute("tabindex", "-1"), r(e.stateField, e.stateField, "conditionalHidden", !1), e.stateField.removeAttribute("data-formie-address-state-hidden"), e.stateField.setAttribute("data-formie-address-state-skeleton-active", "true");
196
194
  let t = e.stateField.querySelector("[data-formie-field-control]");
197
- t instanceof HTMLElement && (e.skeletonEl || (e.skeletonEl = J(), t.appendChild(e.skeletonEl)), e.skeletonEl.removeAttribute("hidden")), q(e).textContent = "Loading state or province options for the selected country.";
195
+ t instanceof HTMLElement && (e.skeletonEl || (e.skeletonEl = q(), t.appendChild(e.skeletonEl)), e.skeletonEl.removeAttribute("hidden")), K(e).textContent = "Loading state or province options for the selected country.";
198
196
  }
199
- function X(e) {
197
+ function Y(e) {
200
198
  e.addressRoot.removeAttribute("data-formie-address-state-fetching"), e.countryControl?.removeAttribute("aria-busy"), e.stateControl.removeAttribute("aria-hidden"), e.stateControl.removeAttribute("tabindex"), e.stateField.removeAttribute("data-formie-address-state-skeleton-active"), e.skeletonEl?.setAttribute("hidden", "hidden"), e.fetchingAnnouncementEl && (e.fetchingAnnouncementEl.textContent = "");
201
199
  }
202
- function Z(e, t) {
200
+ function X(e, t) {
203
201
  let n = w(e);
204
202
  if (!n) return;
205
- let r = n.querySelector("[data-formie-field-required]");
203
+ let r = n.querySelector("[data-formie-field-required], .required");
206
204
  n.textContent = t, r && n.appendChild(r);
207
205
  }
208
- function Q(e, t) {
206
+ function Z(e, t) {
209
207
  e.setAttribute("data-formie-combobox-input", "true"), s(e, "combobox", "before-init", {
210
208
  select: e,
211
209
  options: { placeholder: t }
@@ -216,42 +214,47 @@ function Q(e, t) {
216
214
  options: { placeholder: t }
217
215
  }), n;
218
216
  }
219
- async function $(t, n) {
217
+ async function Q(t, n) {
220
218
  let { hideWhenUnused: r = !0, useSearchable: i = !0, useDatalist: a = !0, optionLabel: o = "name", optionValue: s = "name", placeholder: c = null, subdivisionsAction: l = h } = n, u = t.countryControl?.value?.trim() || "";
221
219
  k(t);
222
- let d = A(t), f = ++t.fetchGeneration;
220
+ let d = A(t), f = t.isCpEdit && !!d && u === t.initialCountry && d === t.initialValue, p = ++t.fetchGeneration;
223
221
  if (t.comboboxCleanup?.(), t.comboboxCleanup = null, !u) {
224
- if (Z(t.stateField, t.stateField.dataset.formieAddressStateDefaultLabel || "State / Province"), X(t), r) {
225
- K(t, !1), D(t.stateControl, ""), O(t, ""), t.pendingStateValue = "", t.lastSubdivisions = [];
222
+ if (X(t.stateField, t.stateField.dataset.formieAddressStateDefaultLabel || "State / Province"), Y(t), r && !f) {
223
+ G(t, !1), D(t.stateControl, ""), O(t, ""), t.pendingStateValue = "", t.lastSubdivisions = [];
226
224
  return;
227
225
  }
228
- if (K(t, !0), t.stateControl instanceof HTMLSelectElement) {
229
- let e = H(t.stateControl, d);
230
- t.stateControl = V(t.stateControl, e);
231
- } else t.stateControl.disabled = !0, t.stateControl.placeholder = c || t.stateControl.placeholder;
226
+ if (G(t, !0), t.stateControl instanceof HTMLSelectElement) {
227
+ let e = V(t.stateControl, d);
228
+ t.stateControl = B(t.stateControl, e);
229
+ } else t.stateControl.disabled = !t.isCpEdit && !f, t.stateControl.placeholder = c || t.stateControl.placeholder;
232
230
  t.lastSubdivisions = [];
233
231
  return;
234
232
  }
235
- F(P(u, o, s, l)) || Y(t);
236
- let p = await I(u, o, s, l, e(t.addressRoot.closest("form")));
237
- if (f !== t.fetchGeneration) return;
238
- let m = p?.subdivisions || [], g = p?.administrativeAreaUsed ?? !0, _ = p?.administrativeAreaLabel || "State / Province";
239
- if (t.lastSubdivisions = m, X(t), r && !g) {
240
- K(t, !1), D(t.stateControl, ""), O(t, ""), t.pendingStateValue = "";
233
+ P(N(u, o, s, l)) || J(t);
234
+ let m = await F(u, o, s, l, e(t.addressRoot.closest("form")));
235
+ if (p !== t.fetchGeneration) return;
236
+ let g = [...m?.subdivisions || []];
237
+ f && g.length && !I(d, g) && g.push({
238
+ label: d,
239
+ value: d
240
+ });
241
+ let _ = m?.administrativeAreaUsed ?? !0, v = m?.administrativeAreaLabel || "State / Province";
242
+ if (t.lastSubdivisions = g, Y(t), r && !_ && !f) {
243
+ G(t, !1), D(t.stateControl, ""), O(t, ""), t.pendingStateValue = "";
241
244
  return;
242
245
  }
243
- if (K(t, !0), Z(t.stateField, _), m.length > 0) {
244
- let e = t.stateControl instanceof HTMLSelectElement ? t.stateControl : W(t.stateControl, d, m, c);
245
- t.stateControl === e ? (B(t.stateControl, e), U(e, m, c, e.value)) : t.stateControl = V(t.stateControl, e), i ? t.comboboxCleanup = Q(e, c) : e.removeAttribute("data-formie-combobox-input"), D(e, L(d, m) || d), M(t);
246
+ if (G(t, !0), X(t.stateField, v), g.length > 0) {
247
+ let e = t.stateControl instanceof HTMLSelectElement ? t.stateControl : U(t.stateControl, d, g, c);
248
+ t.stateControl === e ? (z(t.stateControl, e), H(e, g, c, e.value)) : t.stateControl = B(t.stateControl, e), i ? t.comboboxCleanup = Z(e, c) : e.removeAttribute("data-formie-combobox-input"), D(e, I(d, g) || d), j(t);
246
249
  return;
247
250
  }
248
- let v = t.stateControl instanceof HTMLInputElement ? t.stateControl : H(t.stateControl, d);
249
- t.stateControl !== v && (t.stateControl = V(t.stateControl, v)), v.disabled = !1, G(v, t.datalistId, m, a), D(v, d), M(t);
251
+ let y = t.stateControl instanceof HTMLInputElement ? t.stateControl : V(t.stateControl, d);
252
+ t.stateControl !== y && (t.stateControl = B(t.stateControl, y)), y.disabled = !1, W(y, t.datalistId, g, a), D(y, d), j(t);
250
253
  }
251
- function ee(e, t) {
254
+ function te(e, t) {
252
255
  let n = () => {
253
- k(e), e.countryControl?.value?.trim() && (e.lastCountry = "", $(e, t).then(() => {
254
- M(e);
256
+ k(e), e.countryControl?.value?.trim() && (e.lastCountry = "", Q(e, t).then(() => {
257
+ j(e);
255
258
  }));
256
259
  };
257
260
  _.forEach((t) => {
@@ -259,7 +262,7 @@ function ee(e, t) {
259
262
  e.autofillSweepTimers.push(r);
260
263
  });
261
264
  }
262
- function te(e) {
265
+ function $(e) {
263
266
  e.countryChangeTimer !== null && (window.clearTimeout(e.countryChangeTimer), e.countryChangeTimer = null), e.autofillSweepTimers.forEach((e) => {
264
267
  window.clearTimeout(e);
265
268
  }), e.autofillSweepTimers = [];
@@ -273,6 +276,9 @@ function ne(e, t) {
273
276
  i && !e.dataset.formieAddressStateDefaultLabel && (e.dataset.formieAddressStateDefaultLabel = i.textContent?.trim() || "State / Province");
274
277
  let a = {
275
278
  addressRoot: n,
279
+ isCpEdit: r.hasAttribute("data-formie-address-state-cp"),
280
+ initialCountry: S(n)?.value?.trim() || "",
281
+ initialValue: r.value?.trim() || "",
276
282
  stateField: e,
277
283
  stateControl: r,
278
284
  countryControl: S(n),
@@ -288,50 +294,54 @@ function ne(e, t) {
288
294
  fetchGeneration: 0,
289
295
  required: r.required,
290
296
  lastSubdivisions: []
291
- };
292
- j(a);
293
- let o = (e = !1) => {
297
+ }, o = r.value, s = e.closest("form"), c = !1, d = null;
298
+ ee(a);
299
+ let p = (e = !1) => {
294
300
  let n = a.countryControl?.value?.trim() || "";
295
301
  if (!e && n === a.lastCountry) return;
296
302
  let r = a.lastCountry, i = A(a);
297
- a.lastCountry = n, $(a, t).then(() => {
298
- M(a), r && n && r !== n && !L(i, a.lastSubdivisions) && !A(a) && (D(a.stateControl, ""), O(a, ""));
303
+ a.lastCountry = n, Q(a, t).then(() => {
304
+ j(a), r && n && r !== n && !I(i, a.lastSubdivisions) && !A(a) && (D(a.stateControl, ""), O(a, ""));
299
305
  });
300
- }, s = () => {
306
+ }, m = () => {
301
307
  a.countryChangeTimer !== null && window.clearTimeout(a.countryChangeTimer), a.countryChangeTimer = window.setTimeout(() => {
302
- a.countryChangeTimer = null, k(a), o(!0);
308
+ a.countryChangeTimer = null, k(a), p(!0);
303
309
  }, 50);
304
- }, c = (e) => {
310
+ }, h = (e) => {
305
311
  let n = e.target;
306
312
  if (!(n instanceof HTMLInputElement || n instanceof HTMLSelectElement)) return;
307
313
  let r = n === a.autofillAnchor, i = n.matches(l) || n.matches(u);
308
- if ((r || i) && (i && !r && O(a, n.value), k(a), a.countryControl?.value?.trim())) {
314
+ if ((r || i) && (i && !r && (O(a, n.value), a.pendingStateValue = n.value), k(a), a.countryControl?.value?.trim())) {
309
315
  if (a.lastSubdivisions.length > 0) {
310
- M(a);
316
+ j(a);
311
317
  return;
312
318
  }
313
- a.lastCountry = "", $(a, t).then(() => {
314
- M(a);
319
+ a.lastCountry = "", Q(a, t).then(() => {
320
+ j(a);
315
321
  });
316
322
  }
317
- }, d = (e) => {
323
+ }, g = (e) => {
318
324
  if (e.animationName !== f) return;
319
325
  let r = e.target;
320
- (r instanceof HTMLInputElement || r instanceof HTMLSelectElement) && n.contains(r) && (k(a), a.countryControl?.value?.trim() && (a.lastCountry = "", $(a, t).then(() => {
321
- M(a);
326
+ (r instanceof HTMLInputElement || r instanceof HTMLSelectElement) && n.contains(r) && (k(a), a.countryControl?.value?.trim() && (a.lastCountry = "", Q(a, t).then(() => {
327
+ j(a);
322
328
  })));
323
- }, p = (e) => {
329
+ }, _ = (e) => {
324
330
  let n = e.detail?.state?.trim();
325
331
  if (!n) {
326
- o();
332
+ p();
327
333
  return;
328
334
  }
329
- a.pendingStateValue = n, O(a, n), $(a, t).then(() => {
330
- D(a.stateControl, n), E(a.stateControl, n), a.lastCountry = a.countryControl?.value?.trim() || "";
335
+ a.pendingStateValue = n, O(a, n), Q(a, t).then(() => {
336
+ j(a), a.lastCountry = a.countryControl?.value?.trim() || "";
331
337
  });
338
+ }, y = (e) => {
339
+ d !== null && window.clearTimeout(d), d = window.setTimeout(() => {
340
+ d = null, !(e.defaultPrevented || c) && ($(a), a.stateControl.value = "", a.pendingStateValue = o, O(a, o), p(!0));
341
+ }, 0);
332
342
  };
333
- return a.countryControl?.addEventListener("change", s), a.countryControl?.addEventListener("input", s), n.addEventListener("input", c), n.addEventListener("change", c), n.addEventListener("animationstart", d), n.addEventListener("formie:address:google:populate", p), n.addEventListener("formie:address:address-finder:populate", p), n.addEventListener("formie:address:loqate:populate", p), n.addEventListener("formie:address:place-kit:populate", p), o(), ee(a, t), () => {
334
- te(a), X(a), a.skeletonEl?.remove(), a.fetchingAnnouncementEl?.remove(), a.autofillAnchor?.remove(), a.comboboxCleanup?.(), a.countryControl?.removeEventListener("change", s), a.countryControl?.removeEventListener("input", s), n.removeEventListener("input", c), n.removeEventListener("change", c), n.removeEventListener("animationstart", d), n.removeEventListener("formie:address:google:populate", p), n.removeEventListener("formie:address:address-finder:populate", p), n.removeEventListener("formie:address:loqate:populate", p), n.removeEventListener("formie:address:place-kit:populate", p);
343
+ return s?.addEventListener("reset", y), a.countryControl?.addEventListener("change", m), a.countryControl?.addEventListener("input", m), n.addEventListener("input", h), n.addEventListener("change", h), n.addEventListener("animationstart", g), n.addEventListener("formie:address:google:populate", _), n.addEventListener("formie:address:address-finder:populate", _), n.addEventListener("formie:address:loqate:populate", _), n.addEventListener("formie:address:place-kit:populate", _), p(!0), te(a, t), () => {
344
+ c = !0, d !== null && window.clearTimeout(d), a.fetchGeneration++, s?.removeEventListener("reset", y), $(a), Y(a), a.skeletonEl?.remove(), a.fetchingAnnouncementEl?.remove(), a.autofillAnchor?.remove(), a.comboboxCleanup?.(), a.countryControl?.removeEventListener("change", m), a.countryControl?.removeEventListener("input", m), n.removeEventListener("input", h), n.removeEventListener("change", h), n.removeEventListener("animationstart", g), n.removeEventListener("formie:address:google:populate", _), n.removeEventListener("formie:address:address-finder:populate", _), n.removeEventListener("formie:address:loqate:populate", _), n.removeEventListener("formie:address:place-kit:populate", _);
335
345
  };
336
346
  }
337
347
  var re = {
@@ -1,8 +1,8 @@
1
1
  import { a as e } from "./event-names-BCI2FLD8.js";
2
2
  import { t } from "./debug-BV0DvdHx.js";
3
3
  import { t as n } from "./theme-classes-DAQuEqdP.js";
4
- import { i as r } from "./i18n-BY1ds1BL.js";
5
- import { n as i, t as a } from "./async-nPFRNQ06.js";
4
+ import { n as r, t as i } from "./async-2GdXNFCE.js";
5
+ import { i as a } from "./i18n-BY1ds1BL.js";
6
6
  //#region src/js/modules/captchas/constants.ts
7
7
  var o = 2e3, s = 5e3, c = 5e3, l = 12e4;
8
8
  //#endregion
@@ -38,8 +38,8 @@ function m(e, t, { value: n = "", container: r } = {}) {
38
38
  }
39
39
  async function h(e, t, n) {
40
40
  if (f(e, t)) return !0;
41
- let r = Date.now() + Math.max(n, 0);
42
- for (; Date.now() < r;) if (await i(120), f(e, t)) return !0;
41
+ let i = Date.now() + Math.max(n, 0);
42
+ for (; Date.now() < i;) if (await r(120), f(e, t)) return !0;
43
43
  return !1;
44
44
  }
45
45
  //#endregion
@@ -98,14 +98,14 @@ function O(e, t) {
98
98
  return !n || typeof n != "object" ? null : n;
99
99
  }
100
100
  function k(e, t, n, r) {
101
- let i = /* @__PURE__ */ new Set(), o = () => {
102
- let a = x(e, t), o = new Set(a.filter((e) => S(e)));
103
- a.forEach((e) => {
104
- o.has(e) && !i.has(e) && (i.add(e), n(e));
105
- }), Array.from(i).forEach((e) => {
106
- o.has(e) || (i.delete(e), r(e));
101
+ let a = /* @__PURE__ */ new Set(), o = () => {
102
+ let i = x(e, t), o = new Set(i.filter((e) => S(e)));
103
+ i.forEach((e) => {
104
+ o.has(e) && !a.has(e) && (a.add(e), n(e));
105
+ }), Array.from(a).forEach((e) => {
106
+ o.has(e) || (a.delete(e), r(e));
107
107
  });
108
- }, s = a(o, 20), c = new MutationObserver(() => {
108
+ }, s = i(o, 20), c = new MutationObserver(() => {
109
109
  s();
110
110
  });
111
111
  c.observe(e, {
@@ -133,9 +133,9 @@ function k(e, t, n, r) {
133
133
  cleanup: () => {
134
134
  c.disconnect(), l.forEach((e) => {
135
135
  e();
136
- }), Array.from(i).forEach((e) => {
136
+ }), Array.from(a).forEach((e) => {
137
137
  r(e);
138
- }), i.clear();
138
+ }), a.clear();
139
139
  },
140
140
  reconcile: s,
141
141
  reconcileImmediate: o,
@@ -145,8 +145,8 @@ function k(e, t, n, r) {
145
145
  function A(e, t) {
146
146
  return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
147
147
  }
148
- function j(e, t, { defaultPlaceholderSelector: n, defaultTokenFieldNames: i = [], defaultWaitForValueMs: a = o }) {
149
- let s = t || {}, c = Object.entries(s).reduce((e, [t, n]) => (g.has(t) || (e[t] = n), e), {}), l = i.map(String).filter(Boolean), u = Number(a), d = typeof s.placeholderSelector == "string" && s.placeholderSelector.trim() !== "" ? s.placeholderSelector.trim() : n, f = typeof s.errorMessage == "string" && s.errorMessage.trim() !== "" ? s.errorMessage.trim() : r("Captcha challenge must be completed."), p = typeof s.sessionKey == "string" && s.sessionKey.trim() !== "" ? s.sessionKey.trim() : null, m = typeof s.value == "string" ? s.value : null;
148
+ function j(e, t, { defaultPlaceholderSelector: n, defaultTokenFieldNames: r = [], defaultWaitForValueMs: i = o }) {
149
+ let s = t || {}, c = Object.entries(s).reduce((e, [t, n]) => (g.has(t) || (e[t] = n), e), {}), l = r.map(String).filter(Boolean), u = Number(i), d = typeof s.placeholderSelector == "string" && s.placeholderSelector.trim() !== "" ? s.placeholderSelector.trim() : n, f = typeof s.errorMessage == "string" && s.errorMessage.trim() !== "" ? s.errorMessage.trim() : a("Captcha challenge must be completed."), p = typeof s.sessionKey == "string" && s.sessionKey.trim() !== "" ? s.sessionKey.trim() : null, m = typeof s.value == "string" ? s.value : null;
150
150
  return {
151
151
  handle: A(e, s),
152
152
  ui: {
@@ -155,7 +155,7 @@ function j(e, t, { defaultPlaceholderSelector: n, defaultTokenFieldNames: i = []
155
155
  },
156
156
  transport: {
157
157
  tokenFieldNames: l,
158
- waitForValueMs: Number.isFinite(u) ? u : a,
158
+ waitForValueMs: Number.isFinite(u) ? u : i,
159
159
  sessionKey: p,
160
160
  value: m
161
161
  },