@netlib/widerrufsbutton 2.1.9 → 2.1.11

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/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as a, jsxs as c, Fragment as F } from "react/jsx-runtime";
2
- import { useState as m, useRef as L, useEffect as T } from "react";
3
- import { createPortal as O } from "react-dom";
4
- async function U(e, r) {
1
+ import { jsx as n, jsxs as u, Fragment as M } from "react/jsx-runtime";
2
+ import { useState as f, useRef as U, useEffect as T } from "react";
3
+ import { createPortal as L } from "react-dom";
4
+ async function O(e, r) {
5
5
  const t = {
6
6
  "Content-Type": "application/json"
7
7
  };
@@ -13,24 +13,24 @@ async function U(e, r) {
13
13
  ...e.companyName ? { companyName: e.companyName } : {},
14
14
  ...e.senderEmail ? { senderEmail: e.senderEmail } : {}
15
15
  }
16
- }, i = await fetch(e.apiUrl, {
16
+ }, a = await fetch(e.apiUrl, {
17
17
  method: "PATCH",
18
18
  headers: t,
19
19
  body: JSON.stringify(o)
20
20
  });
21
- let d;
21
+ let b;
22
22
  try {
23
- d = await i.json();
23
+ b = await a.json();
24
24
  } catch {
25
- if (!i.ok) throw new Error(`Server antwortete mit Status ${i.status}`);
25
+ if (!a.ok) throw new Error(`Server antwortete mit Status ${a.status}`);
26
26
  return;
27
27
  }
28
- if (d !== null && typeof d == "object" && "ok" in d && d.ok === !1) {
29
- const s = d.message;
30
- throw new Error(typeof s == "string" && s ? s : `Server antwortete mit Status ${i.status}`);
28
+ if (b !== null && typeof b == "object" && "ok" in b && b.ok === !1) {
29
+ const s = b.message;
30
+ throw new Error(typeof s == "string" && s ? s : `Server antwortete mit Status ${a.status}`);
31
31
  }
32
- if (!i.ok)
33
- throw new Error(`Server antwortete mit Status ${i.status}`);
32
+ if (!a.ok)
33
+ throw new Error(`Server antwortete mit Status ${a.status}`);
34
34
  }
35
35
  const I = {
36
36
  firstName: "",
@@ -39,61 +39,61 @@ const I = {
39
39
  orderNumber: "",
40
40
  reason: ""
41
41
  };
42
- function k(e) {
42
+ function z(e) {
43
43
  const r = {};
44
44
  return e.firstName.trim() || (r.firstName = "Bitte geben Sie Ihren Vornamen an."), e.lastName.trim() || (r.lastName = "Bitte geben Sie Ihren Nachnamen an."), e.email.trim() ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email) || (r.email = "Bitte geben Sie eine gültige E-Mail-Adresse an.") : r.email = "Bitte geben Sie Ihre E-Mail-Adresse an.", e.orderNumber.trim() || (r.orderNumber = "Bitte geben Sie die Bestellnummer oder Vertragsnummer an."), r;
45
45
  }
46
46
  function P({ config: e, onClose: r }) {
47
- const [t, o] = m(I), [i, d] = m({}), [s, E] = m({}), [h, N] = m("idle"), [S, z] = m(""), W = L(null);
47
+ const [t, o] = f(I), [a, b] = f({}), [s, g] = f({}), [w, m] = f("idle"), [d, h] = f(""), v = U(null);
48
48
  T(() => {
49
- var u;
50
- (u = W.current) == null || u.focus();
51
- const n = (b) => b.key === "Escape" && r();
52
- return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
49
+ var p;
50
+ (p = v.current) == null || p.focus();
51
+ const i = (c) => c.key === "Escape" && r();
52
+ return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
53
53
  }, [r]);
54
- function p(n, u) {
55
- const b = { ...t, [n]: u };
56
- if (o(b), s[n]) {
57
- const x = k(b);
58
- d((v) => ({ ...v, [n]: x[n] }));
54
+ function x(i, p) {
55
+ const c = { ...t, [i]: p };
56
+ if (o(c), s[i]) {
57
+ const k = z(c);
58
+ b((S) => ({ ...S, [i]: k[i] }));
59
59
  }
60
60
  }
61
- function f(n) {
62
- E((b) => ({ ...b, [n]: !0 }));
63
- const u = k(t);
64
- d((b) => ({ ...b, [n]: u[n] }));
61
+ function N(i) {
62
+ g((c) => ({ ...c, [i]: !0 }));
63
+ const p = z(t);
64
+ b((c) => ({ ...c, [i]: p[i] }));
65
65
  }
66
- async function M(n) {
67
- var x, v;
68
- n.preventDefault();
69
- const u = Object.fromEntries(
70
- Object.keys(t).map((g) => [g, !0])
66
+ async function q(i) {
67
+ var k, S;
68
+ i.preventDefault();
69
+ const p = Object.fromEntries(
70
+ Object.keys(t).map(($) => [$, !0])
71
71
  );
72
- E(u);
73
- const b = k(t);
74
- if (d(b), !(Object.keys(b).length > 0)) {
75
- N("loading"), z("");
72
+ g(p);
73
+ const c = z(t);
74
+ if (b(c), !(Object.keys(c).length > 0)) {
75
+ m("loading"), h("");
76
76
  try {
77
- await U(e, t), N("success"), (x = e.onSuccess) == null || x.call(e);
78
- } catch (g) {
79
- const A = g instanceof Error ? g : new Error("Ein unbekannter Fehler ist aufgetreten.");
80
- z(A.message), N("error"), (v = e.onError) == null || v.call(e, A);
77
+ await O(e, t), m("success"), (k = e.onSuccess) == null || k.call(e);
78
+ } catch ($) {
79
+ const C = $ instanceof Error ? $ : new Error("Ein unbekannter Fehler ist aufgetreten.");
80
+ h(C.message), m("error"), (S = e.onError) == null || S.call(e, C);
81
81
  }
82
82
  }
83
83
  }
84
- const q = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
85
- return /* @__PURE__ */ a(
84
+ const F = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
85
+ return /* @__PURE__ */ n(
86
86
  "div",
87
87
  {
88
88
  className: "wrb-overlay",
89
89
  role: "dialog",
90
90
  "aria-modal": "true",
91
91
  "aria-labelledby": "wrb-title",
92
- onClick: (n) => n.target === n.currentTarget && r(),
93
- children: /* @__PURE__ */ c("div", { className: "wrb-modal", children: [
94
- /* @__PURE__ */ c("div", { className: "wrb-modal-header", children: [
95
- /* @__PURE__ */ a("h2", { className: "wrb-modal-title", id: "wrb-title", children: q }),
96
- /* @__PURE__ */ a(
92
+ onClick: (i) => i.target === i.currentTarget && r(),
93
+ children: /* @__PURE__ */ u("div", { className: "wrb-modal", children: [
94
+ /* @__PURE__ */ u("div", { className: "wrb-modal-header", children: [
95
+ /* @__PURE__ */ n("h2", { className: "wrb-modal-title", id: "wrb-title", children: F }),
96
+ /* @__PURE__ */ n(
97
97
  "button",
98
98
  {
99
99
  className: "wrb-close-btn",
@@ -104,122 +104,122 @@ function P({ config: e, onClose: r }) {
104
104
  }
105
105
  )
106
106
  ] }),
107
- h === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
108
- /* @__PURE__ */ c("div", { className: "wrb-success", children: [
109
- /* @__PURE__ */ a("span", { className: "wrb-success-icon", children: "✓" }),
110
- /* @__PURE__ */ a("h3", { children: "Widerruf eingegangen" }),
111
- /* @__PURE__ */ c("p", { children: [
107
+ w === "success" ? /* @__PURE__ */ u("div", { className: "wrb-modal-body", children: [
108
+ /* @__PURE__ */ u("div", { className: "wrb-success", children: [
109
+ /* @__PURE__ */ n("span", { className: "wrb-success-icon", children: "✓" }),
110
+ /* @__PURE__ */ n("h3", { children: "Widerruf eingegangen" }),
111
+ /* @__PURE__ */ u("p", { children: [
112
112
  "Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine Bestätigung an ",
113
- /* @__PURE__ */ a("strong", { children: t.email }),
113
+ /* @__PURE__ */ n("strong", { children: t.email }),
114
114
  "."
115
115
  ] })
116
116
  ] }),
117
- /* @__PURE__ */ a(B, { config: e })
118
- ] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
119
- e.introText && /* @__PURE__ */ a("p", { className: "wrb-intro", children: e.introText }),
120
- h === "error" && S && /* @__PURE__ */ a("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: S }),
121
- /* @__PURE__ */ c("form", { onSubmit: M, noValidate: !0, children: [
122
- /* @__PURE__ */ a(
123
- w,
117
+ /* @__PURE__ */ n(W, { config: e })
118
+ ] }) : /* @__PURE__ */ u("div", { className: "wrb-modal-body", children: [
119
+ e.introText && /* @__PURE__ */ n("p", { className: "wrb-intro", children: e.introText }),
120
+ w === "error" && d && /* @__PURE__ */ n("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: d }),
121
+ /* @__PURE__ */ u("form", { onSubmit: q, noValidate: !0, children: [
122
+ /* @__PURE__ */ n(
123
+ y,
124
124
  {
125
125
  label: "Vorname",
126
126
  required: !0,
127
- error: s.firstName ? i.firstName : void 0,
128
- children: /* @__PURE__ */ a(
127
+ error: s.firstName ? a.firstName : void 0,
128
+ children: /* @__PURE__ */ n(
129
129
  "input",
130
130
  {
131
- ref: W,
132
- className: `wrb-input${s.firstName && i.firstName ? " wrb-error" : ""}`,
131
+ ref: v,
132
+ className: `wrb-input${s.firstName && a.firstName ? " wrb-error" : ""}`,
133
133
  type: "text",
134
134
  autoComplete: "given-name",
135
135
  value: t.firstName,
136
- onChange: (n) => p("firstName", n.target.value),
137
- onBlur: () => f("firstName"),
136
+ onChange: (i) => x("firstName", i.target.value),
137
+ onBlur: () => N("firstName"),
138
138
  placeholder: "Max"
139
139
  }
140
140
  )
141
141
  }
142
142
  ),
143
- /* @__PURE__ */ a(
144
- w,
143
+ /* @__PURE__ */ n(
144
+ y,
145
145
  {
146
146
  label: "Nachname",
147
147
  required: !0,
148
- error: s.lastName ? i.lastName : void 0,
149
- children: /* @__PURE__ */ a(
148
+ error: s.lastName ? a.lastName : void 0,
149
+ children: /* @__PURE__ */ n(
150
150
  "input",
151
151
  {
152
- className: `wrb-input${s.lastName && i.lastName ? " wrb-error" : ""}`,
152
+ className: `wrb-input${s.lastName && a.lastName ? " wrb-error" : ""}`,
153
153
  type: "text",
154
154
  autoComplete: "family-name",
155
155
  value: t.lastName,
156
- onChange: (n) => p("lastName", n.target.value),
157
- onBlur: () => f("lastName"),
156
+ onChange: (i) => x("lastName", i.target.value),
157
+ onBlur: () => N("lastName"),
158
158
  placeholder: "Mustermann"
159
159
  }
160
160
  )
161
161
  }
162
162
  ),
163
- /* @__PURE__ */ a(
164
- w,
163
+ /* @__PURE__ */ n(
164
+ y,
165
165
  {
166
166
  label: "E-Mail-Adresse",
167
167
  required: !0,
168
168
  hint: "Hierüber erhalten Sie die Eingangsbestätigung.",
169
- error: s.email ? i.email : void 0,
170
- children: /* @__PURE__ */ a(
169
+ error: s.email ? a.email : void 0,
170
+ children: /* @__PURE__ */ n(
171
171
  "input",
172
172
  {
173
- className: `wrb-input${s.email && i.email ? " wrb-error" : ""}`,
173
+ className: `wrb-input${s.email && a.email ? " wrb-error" : ""}`,
174
174
  type: "email",
175
175
  autoComplete: "email",
176
176
  value: t.email,
177
- onChange: (n) => p("email", n.target.value),
178
- onBlur: () => f("email"),
177
+ onChange: (i) => x("email", i.target.value),
178
+ onBlur: () => N("email"),
179
179
  placeholder: "name@beispiel.de"
180
180
  }
181
181
  )
182
182
  }
183
183
  ),
184
- /* @__PURE__ */ a(
185
- w,
184
+ /* @__PURE__ */ n(
185
+ y,
186
186
  {
187
187
  label: "Bestell- / Auftrags- / Vertragsnummer",
188
188
  required: !0,
189
189
  hint: "Zu finden in Ihrer Bestellbestätigung.",
190
- error: s.orderNumber ? i.orderNumber : void 0,
191
- children: /* @__PURE__ */ a(
190
+ error: s.orderNumber ? a.orderNumber : void 0,
191
+ children: /* @__PURE__ */ n(
192
192
  "input",
193
193
  {
194
- className: `wrb-input${s.orderNumber && i.orderNumber ? " wrb-error" : ""}`,
194
+ className: `wrb-input${s.orderNumber && a.orderNumber ? " wrb-error" : ""}`,
195
195
  type: "text",
196
196
  value: t.orderNumber,
197
- onChange: (n) => p("orderNumber", n.target.value),
198
- onBlur: () => f("orderNumber"),
197
+ onChange: (i) => x("orderNumber", i.target.value),
198
+ onBlur: () => N("orderNumber"),
199
199
  placeholder: "z.B. 10045678"
200
200
  }
201
201
  )
202
202
  }
203
203
  ),
204
- /* @__PURE__ */ a(
205
- w,
204
+ /* @__PURE__ */ n(
205
+ y,
206
206
  {
207
207
  label: "Widerrufsgrund",
208
208
  hint: "Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",
209
- children: /* @__PURE__ */ a(
209
+ children: /* @__PURE__ */ n(
210
210
  "textarea",
211
211
  {
212
212
  className: "wrb-textarea",
213
213
  value: t.reason,
214
- onChange: (n) => p("reason", n.target.value),
214
+ onChange: (i) => x("reason", i.target.value),
215
215
  placeholder: "Optional",
216
216
  rows: 2
217
217
  }
218
218
  )
219
219
  }
220
220
  ),
221
- /* @__PURE__ */ c("div", { className: "wrb-actions", children: [
222
- /* @__PURE__ */ a(
221
+ /* @__PURE__ */ u("div", { className: "wrb-actions", children: [
222
+ /* @__PURE__ */ n(
223
223
  "button",
224
224
  {
225
225
  type: "button",
@@ -228,36 +228,36 @@ function P({ config: e, onClose: r }) {
228
228
  children: e.cancelLabel ?? "Abbrechen"
229
229
  }
230
230
  ),
231
- /* @__PURE__ */ a(
231
+ /* @__PURE__ */ n(
232
232
  "button",
233
233
  {
234
234
  type: "submit",
235
235
  className: "wrb-submit-btn",
236
- disabled: h === "loading",
237
- children: h === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
236
+ disabled: w === "loading",
237
+ children: w === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
238
238
  }
239
239
  )
240
240
  ] })
241
241
  ] }),
242
- /* @__PURE__ */ a(B, { config: e })
242
+ /* @__PURE__ */ n(W, { config: e })
243
243
  ] })
244
244
  ] })
245
245
  }
246
246
  );
247
247
  }
248
- function w({ label: e, required: r, hint: t, error: o, children: i }) {
249
- return /* @__PURE__ */ c("div", { className: "wrb-field", children: [
250
- /* @__PURE__ */ c("label", { className: "wrb-label", children: [
248
+ function y({ label: e, required: r, hint: t, error: o, children: a }) {
249
+ return /* @__PURE__ */ u("div", { className: "wrb-field", children: [
250
+ /* @__PURE__ */ u("label", { className: "wrb-label", children: [
251
251
  e,
252
- r && /* @__PURE__ */ a("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
252
+ r && /* @__PURE__ */ n("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
253
253
  ] }),
254
- i,
255
- t && !o && /* @__PURE__ */ a("p", { className: "wrb-hint", children: t }),
256
- o && /* @__PURE__ */ a("p", { className: "wrb-field-error", role: "alert", children: o })
254
+ a,
255
+ t && !o && /* @__PURE__ */ n("p", { className: "wrb-hint", children: t }),
256
+ o && /* @__PURE__ */ n("p", { className: "wrb-field-error", role: "alert", children: o })
257
257
  ] });
258
258
  }
259
- function B({ config: e }) {
260
- return e.privacyUrl ? /* @__PURE__ */ a("div", { className: "wrb-legal-links", children: /* @__PURE__ */ a(
259
+ function W({ config: e }) {
260
+ return e.privacyUrl ? /* @__PURE__ */ n("div", { className: "wrb-legal-links", children: /* @__PURE__ */ n(
261
261
  "a",
262
262
  {
263
263
  href: e.privacyUrl,
@@ -268,7 +268,7 @@ function B({ config: e }) {
268
268
  }
269
269
  ) }) : null;
270
270
  }
271
- const $ = `
271
+ const A = `
272
272
  /* Widerrufsbutton widget — prefix: wrb- */
273
273
  .wrb-btn {
274
274
  display: inline-flex;
@@ -502,14 +502,57 @@ function V() {
502
502
  const e = "wrb-styles";
503
503
  if (document.getElementById(e)) return;
504
504
  const r = document.createElement("style");
505
- r.id = e, r.textContent = $, document.head.appendChild(r);
505
+ r.id = e, r.textContent = A, document.head.appendChild(r);
506
+ }
507
+ function D(e) {
508
+ e.dataset.wrbUpgraded || (e.dataset.wrbUpgraded = "true", e.addEventListener("submit", async (r) => {
509
+ r.preventDefault();
510
+ const t = e.querySelector('.wrb-submit-btn, button[type="submit"]'), o = (t == null ? void 0 : t.textContent) ?? "";
511
+ t && (t.disabled = !0, t.textContent = "Wird gesendet…");
512
+ const a = new FormData(e), b = String(a.get("action") ?? ""), s = {
513
+ firstName: String(a.get("firstName") ?? ""),
514
+ lastName: String(a.get("lastName") ?? ""),
515
+ email: String(a.get("email") ?? ""),
516
+ orderNumber: String(a.get("orderNumber") ?? ""),
517
+ reason: String(a.get("reason") ?? "")
518
+ };
519
+ e.dataset.companyName && (s.companyName = e.dataset.companyName), e.dataset.senderEmail && (s.senderEmail = e.dataset.senderEmail);
520
+ const g = { "Content-Type": "application/json" };
521
+ e.dataset.authToken && (g.Authorization = `Bearer ${e.dataset.authToken}`);
522
+ const w = e.getAttribute("action") ?? "";
523
+ try {
524
+ const m = await fetch(w, {
525
+ method: "PATCH",
526
+ headers: g,
527
+ body: JSON.stringify({ action: b, payload: s })
528
+ });
529
+ let d = null;
530
+ try {
531
+ d = await m.json();
532
+ } catch {
533
+ }
534
+ if (!(d && typeof d == "object" && "ok" in d ? d.ok !== !1 : m.ok)) {
535
+ const v = d && typeof d == "object" && "message" in d ? String(d.message ?? "") : "";
536
+ throw new Error(v || `Server antwortete mit Status ${m.status}`);
537
+ }
538
+ e.reset(), location.hash = "#wrb-success";
539
+ } catch (m) {
540
+ const d = m instanceof Error ? m : new Error("Unbekannter Fehler"), h = document.querySelector("#wrb-error .wrb-alert");
541
+ h && (h.textContent = d.message), location.hash = "#wrb-error";
542
+ } finally {
543
+ t && (t.disabled = !1, t.textContent = o);
544
+ }
545
+ }));
546
+ }
547
+ function H() {
548
+ typeof document > "u" || document.querySelectorAll("#wrb-modal form").forEach(D);
506
549
  }
507
- function K({ config: e }) {
508
- const [r, t] = m(!1);
550
+ function _({ config: e }) {
551
+ const [r, t] = f(!1);
509
552
  return T(() => {
510
- V();
511
- }, []), /* @__PURE__ */ c(F, { children: [
512
- /* @__PURE__ */ a(
553
+ V(), H();
554
+ }, []), /* @__PURE__ */ u(M, { children: [
555
+ /* @__PURE__ */ n(
513
556
  "button",
514
557
  {
515
558
  type: "button",
@@ -518,8 +561,8 @@ function K({ config: e }) {
518
561
  children: e.buttonLabel ?? "Vertrag widerrufen"
519
562
  }
520
563
  ),
521
- r && O(
522
- /* @__PURE__ */ a(P, { config: e, onClose: () => t(!1) }),
564
+ r && L(
565
+ /* @__PURE__ */ n(P, { config: e, onClose: () => t(!1) }),
523
566
  document.body
524
567
  )
525
568
  ] });
@@ -527,7 +570,7 @@ function K({ config: e }) {
527
570
  function l(e) {
528
571
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
529
572
  }
530
- function y(e) {
573
+ function E(e) {
531
574
  if (!e.privacyUrl) return "";
532
575
  const r = l(e.privacyLabel ?? "Datenschutz");
533
576
  return `
@@ -535,12 +578,12 @@ function y(e) {
535
578
  <a href="${l(e.privacyUrl)}" class="wrb-legal-link" rel="noopener noreferrer">${r}</a>
536
579
  </div>`;
537
580
  }
538
- function C(e) {
581
+ function B(e) {
539
582
  const r = [];
540
583
  return e.companyName && r.push(`data-company-name="${l(e.companyName)}"`), e.senderEmail && r.push(`data-sender-email="${l(e.senderEmail)}"`), e.authToken && r.push(`data-auth-token="${l(e.authToken)}"`), r.length ? " " + r.join(" ") : "";
541
584
  }
542
585
  function j(e, r = "", t = "") {
543
- const o = l(e.successUrl ?? r), i = l(e.errorUrl ?? t);
586
+ const o = l(e.successUrl ?? r), a = l(e.errorUrl ?? t);
544
587
  return `
545
588
  <div class="wrb-field">
546
589
  <label class="wrb-label">
@@ -582,9 +625,9 @@ function j(e, r = "", t = "") {
582
625
  </div>
583
626
  <input type="hidden" name="action" value="${l(e.action)}">
584
627
  ${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
585
- ${i ? `<input type="hidden" name="errorUrl" value="${i}">` : ""}`;
628
+ ${a ? `<input type="hidden" name="errorUrl" value="${a}">` : ""}`;
586
629
  }
587
- function Y(e) {
630
+ function G(e) {
588
631
  const r = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", t = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
589
632
  return `<!DOCTYPE html>
590
633
  <html lang="de">
@@ -604,7 +647,7 @@ function Y(e) {
604
647
  }
605
648
  .wrb-page .wrb-modal { max-height: none; }
606
649
  .wrb-page .wrb-modal-title { font-size: 20px; }
607
- ${$}
650
+ ${A}
608
651
  </style>
609
652
  </head>
610
653
  <body>
@@ -615,7 +658,7 @@ function Y(e) {
615
658
  </div>
616
659
  <div class="wrb-modal-body">
617
660
  ${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
618
- <form method="POST" action="${t}"${C(e)}>
661
+ <form method="POST" action="${t}"${B(e)}>
619
662
  ${j(e)}
620
663
  <div class="wrb-actions">
621
664
  <button type="submit" class="wrb-submit-btn">
@@ -623,19 +666,19 @@ function Y(e) {
623
666
  </button>
624
667
  </div>
625
668
  </form>
626
- ${y(e)}
669
+ ${E(e)}
627
670
  </div>
628
671
  </div>
629
672
  </div>
630
673
  </body>
631
674
  </html>`;
632
675
  }
633
- function _(e, { inlineStyles: r = !0 } = {}) {
634
- const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), i = `
676
+ function J(e, { inlineStyles: r = !0 } = {}) {
677
+ const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), a = `
635
678
  #wrb-modal, #wrb-success, #wrb-error { display: none; }
636
679
  #wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
637
- return `${r ? `<style>${i}
638
- ${$}</style>` : `<style>${i}</style>`}
680
+ return `${r ? `<style>${a}
681
+ ${A}</style>` : `<style>${a}</style>`}
639
682
 
640
683
  <!-- Widerruf: Form-Modal -->
641
684
  <div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
@@ -646,7 +689,7 @@ ${$}</style>` : `<style>${i}</style>`}
646
689
  </div>
647
690
  <div class="wrb-modal-body">
648
691
  ${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
649
- <form method="POST" action="${o}"${C(e)}>
692
+ <form method="POST" action="${o}"${B(e)}>
650
693
  ${j(e, "#wrb-success", "#wrb-error")}
651
694
  <div class="wrb-actions">
652
695
  <a href="#" class="wrb-cancel-btn">${l(e.cancelLabel ?? "Abbrechen")}</a>
@@ -655,7 +698,7 @@ ${$}</style>` : `<style>${i}</style>`}
655
698
  </button>
656
699
  </div>
657
700
  </form>
658
- ${y(e)}
701
+ ${E(e)}
659
702
  </div>
660
703
  </div>
661
704
  </div>
@@ -676,7 +719,7 @@ ${$}</style>` : `<style>${i}</style>`}
676
719
  Bestätigung per E-Mail.
677
720
  </p>
678
721
  </div>
679
- ${y(e)}
722
+ ${E(e)}
680
723
  </div>
681
724
  </div>
682
725
  </div>
@@ -697,14 +740,16 @@ ${$}</style>` : `<style>${i}</style>`}
697
740
  <a href="#" class="wrb-cancel-btn">Schließen</a>
698
741
  <a href="#wrb-modal" class="wrb-submit-btn">Erneut versuchen</a>
699
742
  </div>
700
- ${y(e)}
743
+ ${E(e)}
701
744
  </div>
702
745
  </div>
703
746
  </div>`;
704
747
  }
705
748
  export {
706
749
  P as WiderrufsModal,
707
- K as WiderrufsWidget,
708
- Y as generateFallbackHtml,
709
- _ as generateModalHtml
750
+ _ as WiderrufsWidget,
751
+ G as generateFallbackHtml,
752
+ J as generateModalHtml,
753
+ H as upgradeAllStaticForms,
754
+ D as upgradeStaticForm
710
755
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Progressive enhancement of the static fallback modal generated by
3
+ * `generateModalHtml()`. Hooks the form's submit event so it sends
4
+ * PATCH/JSON instead of a classic browser POST. Idempotent.
5
+ */
6
+ export declare function upgradeStaticForm(form: HTMLFormElement): void;
7
+ export declare function upgradeAllStaticForms(): void;