@netlib/widerrufsbutton 2.1.8 → 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,5 +1,5 @@
1
- import { jsx as a, jsxs as c, Fragment as q } from "react/jsx-runtime";
2
- import { useState as m, useRef as F, useEffect as C } from "react";
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
3
  import { createPortal as L } from "react-dom";
4
4
  async function O(e, r) {
5
5
  const t = {
@@ -13,87 +13,87 @@ async function O(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
- const U = {
35
+ const I = {
36
36
  firstName: "",
37
37
  lastName: "",
38
38
  email: "",
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
- function I({ config: e, onClose: r }) {
47
- const [t, o] = m(U), [i, d] = m({}), [s, S] = m({}), [h, N] = m("idle"), [E, z] = m(""), W = F(null);
48
- C(() => {
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);
46
+ function P({ config: e, onClose: r }) {
47
+ const [t, o] = f(I), [a, b] = f({}), [s, g] = f({}), [w, m] = f("idle"), [d, h] = f(""), v = U(null);
48
+ T(() => {
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((g) => ({ ...g, [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
- S((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, g;
68
- n.preventDefault();
69
- const u = Object.fromEntries(
70
- Object.keys(t).map((v) => [v, !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
- S(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 O(e, t), N("success"), (x = e.onSuccess) == null || x.call(e);
78
- } catch (v) {
79
- const B = v instanceof Error ? v : new Error("Ein unbekannter Fehler ist aufgetreten.");
80
- z(B.message), N("error"), (g = e.onError) == null || g.call(e, B);
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 j = 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: j }),
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 I({ 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(A, { 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" && E && /* @__PURE__ */ a("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: E }),
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 I({ 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(A, { 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 A({ 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 A({ 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;
@@ -498,18 +498,61 @@ const $ = `
498
498
  text-decoration: underline;
499
499
  }
500
500
  `;
501
- function P() {
501
+ 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);
506
- }
507
- function R({ config: e }) {
508
- const [r, t] = m(!1);
509
- return C(() => {
510
- P();
511
- }, []), /* @__PURE__ */ c(q, { children: [
512
- /* @__PURE__ */ a(
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);
549
+ }
550
+ function _({ config: e }) {
551
+ const [r, t] = f(!1);
552
+ return T(() => {
553
+ V(), H();
554
+ }, []), /* @__PURE__ */ u(M, { children: [
555
+ /* @__PURE__ */ n(
513
556
  "button",
514
557
  {
515
558
  type: "button",
@@ -519,7 +562,7 @@ function R({ config: e }) {
519
562
  }
520
563
  ),
521
564
  r && L(
522
- /* @__PURE__ */ a(I, { config: e, onClose: () => t(!1) }),
565
+ /* @__PURE__ */ n(P, { config: e, onClose: () => t(!1) }),
523
566
  document.body
524
567
  )
525
568
  ] });
@@ -527,7 +570,7 @@ function R({ 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,8 +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 T(e, r = "", t = "") {
539
- const o = l(e.successUrl ?? r), i = l(e.errorUrl ?? t);
581
+ function B(e) {
582
+ const r = [];
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(" ") : "";
584
+ }
585
+ function j(e, r = "", t = "") {
586
+ const o = l(e.successUrl ?? r), a = l(e.errorUrl ?? t);
540
587
  return `
541
588
  <div class="wrb-field">
542
589
  <label class="wrb-label">
@@ -578,9 +625,9 @@ function T(e, r = "", t = "") {
578
625
  </div>
579
626
  <input type="hidden" name="action" value="${l(e.action)}">
580
627
  ${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
581
- ${i ? `<input type="hidden" name="errorUrl" value="${i}">` : ""}`;
628
+ ${a ? `<input type="hidden" name="errorUrl" value="${a}">` : ""}`;
582
629
  }
583
- function K(e) {
630
+ function G(e) {
584
631
  const r = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", t = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
585
632
  return `<!DOCTYPE html>
586
633
  <html lang="de">
@@ -600,7 +647,7 @@ function K(e) {
600
647
  }
601
648
  .wrb-page .wrb-modal { max-height: none; }
602
649
  .wrb-page .wrb-modal-title { font-size: 20px; }
603
- ${$}
650
+ ${A}
604
651
  </style>
605
652
  </head>
606
653
  <body>
@@ -611,27 +658,27 @@ function K(e) {
611
658
  </div>
612
659
  <div class="wrb-modal-body">
613
660
  ${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
614
- <form method="POST" action="${t}">
615
- ${T(e)}
661
+ <form method="POST" action="${t}"${B(e)}>
662
+ ${j(e)}
616
663
  <div class="wrb-actions">
617
664
  <button type="submit" class="wrb-submit-btn">
618
665
  ${l(e.submitLabel ?? "Absenden")}
619
666
  </button>
620
667
  </div>
621
668
  </form>
622
- ${y(e)}
669
+ ${E(e)}
623
670
  </div>
624
671
  </div>
625
672
  </div>
626
673
  </body>
627
674
  </html>`;
628
675
  }
629
- function Y(e, { inlineStyles: r = !0 } = {}) {
630
- 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 = `
631
678
  #wrb-modal, #wrb-success, #wrb-error { display: none; }
632
679
  #wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
633
- return `${r ? `<style>${i}
634
- ${$}</style>` : `<style>${i}</style>`}
680
+ return `${r ? `<style>${a}
681
+ ${A}</style>` : `<style>${a}</style>`}
635
682
 
636
683
  <!-- Widerruf: Form-Modal -->
637
684
  <div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
@@ -642,8 +689,8 @@ ${$}</style>` : `<style>${i}</style>`}
642
689
  </div>
643
690
  <div class="wrb-modal-body">
644
691
  ${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
645
- <form method="POST" action="${o}">
646
- ${T(e, "#wrb-success", "#wrb-error")}
692
+ <form method="POST" action="${o}"${B(e)}>
693
+ ${j(e, "#wrb-success", "#wrb-error")}
647
694
  <div class="wrb-actions">
648
695
  <a href="#" class="wrb-cancel-btn">${l(e.cancelLabel ?? "Abbrechen")}</a>
649
696
  <button type="submit" class="wrb-submit-btn">
@@ -651,7 +698,7 @@ ${$}</style>` : `<style>${i}</style>`}
651
698
  </button>
652
699
  </div>
653
700
  </form>
654
- ${y(e)}
701
+ ${E(e)}
655
702
  </div>
656
703
  </div>
657
704
  </div>
@@ -672,7 +719,7 @@ ${$}</style>` : `<style>${i}</style>`}
672
719
  Bestätigung per E-Mail.
673
720
  </p>
674
721
  </div>
675
- ${y(e)}
722
+ ${E(e)}
676
723
  </div>
677
724
  </div>
678
725
  </div>
@@ -693,14 +740,16 @@ ${$}</style>` : `<style>${i}</style>`}
693
740
  <a href="#" class="wrb-cancel-btn">Schließen</a>
694
741
  <a href="#wrb-modal" class="wrb-submit-btn">Erneut versuchen</a>
695
742
  </div>
696
- ${y(e)}
743
+ ${E(e)}
697
744
  </div>
698
745
  </div>
699
746
  </div>`;
700
747
  }
701
748
  export {
702
- I as WiderrufsModal,
703
- R as WiderrufsWidget,
704
- K as generateFallbackHtml,
705
- Y as generateModalHtml
749
+ P as WiderrufsModal,
750
+ _ as WiderrufsWidget,
751
+ G as generateFallbackHtml,
752
+ J as generateModalHtml,
753
+ H as upgradeAllStaticForms,
754
+ D as upgradeStaticForm
706
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;