@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/fallback.cjs.js +16 -16
- package/dist/fallback.es.js +21 -17
- package/dist/index.cjs.js +27 -27
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +190 -141
- package/dist/upgrade.d.ts +7 -0
- package/dist/widerrufsbutton.iife.js +10 -10
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
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
|
-
},
|
|
16
|
+
}, a = await fetch(e.apiUrl, {
|
|
17
17
|
method: "PATCH",
|
|
18
18
|
headers: t,
|
|
19
19
|
body: JSON.stringify(o)
|
|
20
20
|
});
|
|
21
|
-
let
|
|
21
|
+
let b;
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
b = await a.json();
|
|
24
24
|
} catch {
|
|
25
|
-
if (!
|
|
25
|
+
if (!a.ok) throw new Error(`Server antwortete mit Status ${a.status}`);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
29
|
-
const s =
|
|
30
|
-
throw new Error(typeof s == "string" && s ? s : `Server antwortete mit 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 (!
|
|
33
|
-
throw new Error(`Server antwortete mit Status ${
|
|
32
|
+
if (!a.ok)
|
|
33
|
+
throw new Error(`Server antwortete mit Status ${a.status}`);
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const I = {
|
|
36
36
|
firstName: "",
|
|
37
37
|
lastName: "",
|
|
38
38
|
email: "",
|
|
39
39
|
orderNumber: "",
|
|
40
40
|
reason: ""
|
|
41
41
|
};
|
|
42
|
-
function
|
|
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
|
|
47
|
-
const [t, o] =
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
(
|
|
51
|
-
const
|
|
52
|
-
return document.addEventListener("keydown",
|
|
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
|
|
55
|
-
const
|
|
56
|
-
if (o(
|
|
57
|
-
const
|
|
58
|
-
|
|
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
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
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
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
Object.keys(t).map((
|
|
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
|
-
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
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),
|
|
78
|
-
} catch (
|
|
79
|
-
const
|
|
80
|
-
|
|
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
|
|
85
|
-
return /* @__PURE__ */
|
|
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: (
|
|
93
|
-
children: /* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
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__ */
|
|
113
|
+
/* @__PURE__ */ n("strong", { children: t.email }),
|
|
114
114
|
"."
|
|
115
115
|
] })
|
|
116
116
|
] }),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
] }) : /* @__PURE__ */
|
|
119
|
-
e.introText && /* @__PURE__ */
|
|
120
|
-
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
|
|
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 ?
|
|
128
|
-
children: /* @__PURE__ */
|
|
127
|
+
error: s.firstName ? a.firstName : void 0,
|
|
128
|
+
children: /* @__PURE__ */ n(
|
|
129
129
|
"input",
|
|
130
130
|
{
|
|
131
|
-
ref:
|
|
132
|
-
className: `wrb-input${s.firstName &&
|
|
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: (
|
|
137
|
-
onBlur: () =>
|
|
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__ */
|
|
144
|
-
|
|
143
|
+
/* @__PURE__ */ n(
|
|
144
|
+
y,
|
|
145
145
|
{
|
|
146
146
|
label: "Nachname",
|
|
147
147
|
required: !0,
|
|
148
|
-
error: s.lastName ?
|
|
149
|
-
children: /* @__PURE__ */
|
|
148
|
+
error: s.lastName ? a.lastName : void 0,
|
|
149
|
+
children: /* @__PURE__ */ n(
|
|
150
150
|
"input",
|
|
151
151
|
{
|
|
152
|
-
className: `wrb-input${s.lastName &&
|
|
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: (
|
|
157
|
-
onBlur: () =>
|
|
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__ */
|
|
164
|
-
|
|
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 ?
|
|
170
|
-
children: /* @__PURE__ */
|
|
169
|
+
error: s.email ? a.email : void 0,
|
|
170
|
+
children: /* @__PURE__ */ n(
|
|
171
171
|
"input",
|
|
172
172
|
{
|
|
173
|
-
className: `wrb-input${s.email &&
|
|
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: (
|
|
178
|
-
onBlur: () =>
|
|
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__ */
|
|
185
|
-
|
|
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 ?
|
|
191
|
-
children: /* @__PURE__ */
|
|
190
|
+
error: s.orderNumber ? a.orderNumber : void 0,
|
|
191
|
+
children: /* @__PURE__ */ n(
|
|
192
192
|
"input",
|
|
193
193
|
{
|
|
194
|
-
className: `wrb-input${s.orderNumber &&
|
|
194
|
+
className: `wrb-input${s.orderNumber && a.orderNumber ? " wrb-error" : ""}`,
|
|
195
195
|
type: "text",
|
|
196
196
|
value: t.orderNumber,
|
|
197
|
-
onChange: (
|
|
198
|
-
onBlur: () =>
|
|
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__ */
|
|
205
|
-
|
|
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__ */
|
|
209
|
+
children: /* @__PURE__ */ n(
|
|
210
210
|
"textarea",
|
|
211
211
|
{
|
|
212
212
|
className: "wrb-textarea",
|
|
213
213
|
value: t.reason,
|
|
214
|
-
onChange: (
|
|
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__ */
|
|
222
|
-
/* @__PURE__ */
|
|
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__ */
|
|
231
|
+
/* @__PURE__ */ n(
|
|
232
232
|
"button",
|
|
233
233
|
{
|
|
234
234
|
type: "submit",
|
|
235
235
|
className: "wrb-submit-btn",
|
|
236
|
-
disabled:
|
|
237
|
-
children:
|
|
236
|
+
disabled: w === "loading",
|
|
237
|
+
children: w === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
|
|
238
238
|
}
|
|
239
239
|
)
|
|
240
240
|
] })
|
|
241
241
|
] }),
|
|
242
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ n(W, { config: e })
|
|
243
243
|
] })
|
|
244
244
|
] })
|
|
245
245
|
}
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
return /* @__PURE__ */
|
|
250
|
-
/* @__PURE__ */
|
|
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__ */
|
|
252
|
+
r && /* @__PURE__ */ n("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
253
253
|
] }),
|
|
254
|
-
|
|
255
|
-
t && !o && /* @__PURE__ */
|
|
256
|
-
o && /* @__PURE__ */
|
|
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
|
|
260
|
-
return e.privacyUrl ? /* @__PURE__ */
|
|
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
|
|
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 =
|
|
506
|
-
}
|
|
507
|
-
function
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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__ */
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
529
572
|
}
|
|
530
|
-
function
|
|
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
|
|
539
|
-
const
|
|
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
|
-
${
|
|
628
|
+
${a ? `<input type="hidden" name="errorUrl" value="${a}">` : ""}`;
|
|
582
629
|
}
|
|
583
|
-
function
|
|
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
|
-
${
|
|
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
|
-
${
|
|
669
|
+
${E(e)}
|
|
623
670
|
</div>
|
|
624
671
|
</div>
|
|
625
672
|
</div>
|
|
626
673
|
</body>
|
|
627
674
|
</html>`;
|
|
628
675
|
}
|
|
629
|
-
function
|
|
630
|
-
const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"),
|
|
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>${
|
|
634
|
-
${
|
|
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
|
-
${
|
|
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
|
-
${
|
|
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
|
-
${
|
|
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
|
-
${
|
|
743
|
+
${E(e)}
|
|
697
744
|
</div>
|
|
698
745
|
</div>
|
|
699
746
|
</div>`;
|
|
700
747
|
}
|
|
701
748
|
export {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
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;
|