@netlib/widerrufsbutton 2.1.9 → 2.1.13
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 +22 -7
- package/dist/fallback.es.js +33 -18
- package/dist/index.cjs.js +46 -31
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +222 -141
- package/dist/styles.d.ts +1 -1
- package/dist/upgrade.d.ts +7 -0
- package/dist/widerruf.html +19 -4
- package/dist/widerrufsbutton.iife.js +25 -13
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
async function
|
|
1
|
+
import { jsx as n, jsxs as c, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as j, useEffect as q } from "react";
|
|
3
|
+
import { createPortal as I } from "react-dom";
|
|
4
|
+
async function R(e, r) {
|
|
5
5
|
const t = {
|
|
6
6
|
"Content-Type": "application/json"
|
|
7
7
|
};
|
|
@@ -13,87 +13,90 @@ async function U(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 P = {
|
|
36
36
|
firstName: "",
|
|
37
37
|
lastName: "",
|
|
38
38
|
email: "",
|
|
39
39
|
orderNumber: "",
|
|
40
40
|
reason: ""
|
|
41
41
|
};
|
|
42
|
-
function
|
|
42
|
+
function A(e) {
|
|
43
43
|
const r = {};
|
|
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
|
|
45
|
-
}
|
|
46
|
-
function
|
|
47
|
-
const [t, o] =
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
(
|
|
51
|
-
const
|
|
52
|
-
return document.addEventListener("keydown",
|
|
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 Rechnungs-, Lieferschein- oder Auftragsnummer an."), r;
|
|
45
|
+
}
|
|
46
|
+
function D({ config: e, onClose: r }) {
|
|
47
|
+
const [t, o] = f(P), [a, b] = f({}), [s, x] = f({}), [h, u] = f("idle"), [d, w] = f(""), v = j(null), z = j(null);
|
|
48
|
+
q(() => {
|
|
49
|
+
var p;
|
|
50
|
+
(p = v.current) == null || p.focus();
|
|
51
|
+
const i = (m) => m.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 g(i, p) {
|
|
55
|
+
const m = { ...t, [i]: p };
|
|
56
|
+
if (o(m), s[i]) {
|
|
57
|
+
const k = A(m);
|
|
58
|
+
b((S) => ({ ...S, [i]: k[i] }));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
61
|
+
function N(i) {
|
|
62
|
+
x((m) => ({ ...m, [i]: !0 }));
|
|
63
|
+
const p = A(t);
|
|
64
|
+
b((m) => ({ ...m, [i]: p[i] }));
|
|
65
65
|
}
|
|
66
|
-
async function M(
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
async function M(i) {
|
|
67
|
+
var k, S, C;
|
|
68
|
+
if (i.preventDefault(), (((k = z.current) == null ? void 0 : k.value) ?? "").trim() !== "") {
|
|
69
|
+
u("success");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const p = Object.fromEntries(
|
|
73
|
+
Object.keys(t).map(($) => [$, !0])
|
|
71
74
|
);
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
75
|
+
x(p);
|
|
76
|
+
const m = A(t);
|
|
77
|
+
if (b(m), !(Object.keys(m).length > 0)) {
|
|
78
|
+
u("loading"), w("");
|
|
76
79
|
try {
|
|
77
|
-
await
|
|
78
|
-
} catch (
|
|
79
|
-
const
|
|
80
|
-
|
|
80
|
+
await R(e, t), u("success"), (S = e.onSuccess) == null || S.call(e);
|
|
81
|
+
} catch ($) {
|
|
82
|
+
const T = $ instanceof Error ? $ : new Error("Ein unbekannter Fehler ist aufgetreten.");
|
|
83
|
+
w(T.message), u("error"), (C = e.onError) == null || C.call(e, T);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
|
-
const
|
|
85
|
-
return /* @__PURE__ */
|
|
87
|
+
const U = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
|
|
88
|
+
return /* @__PURE__ */ n(
|
|
86
89
|
"div",
|
|
87
90
|
{
|
|
88
91
|
className: "wrb-overlay",
|
|
89
92
|
role: "dialog",
|
|
90
93
|
"aria-modal": "true",
|
|
91
94
|
"aria-labelledby": "wrb-title",
|
|
92
|
-
onClick: (
|
|
95
|
+
onClick: (i) => i.target === i.currentTarget && r(),
|
|
93
96
|
children: /* @__PURE__ */ c("div", { className: "wrb-modal", children: [
|
|
94
97
|
/* @__PURE__ */ c("div", { className: "wrb-modal-header", children: [
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ n("h2", { className: "wrb-modal-title", id: "wrb-title", children: U }),
|
|
99
|
+
/* @__PURE__ */ n(
|
|
97
100
|
"button",
|
|
98
101
|
{
|
|
99
102
|
className: "wrb-close-btn",
|
|
@@ -106,120 +109,133 @@ function P({ config: e, onClose: r }) {
|
|
|
106
109
|
] }),
|
|
107
110
|
h === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
108
111
|
/* @__PURE__ */ c("div", { className: "wrb-success", children: [
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ n("span", { className: "wrb-success-icon", children: "✓" }),
|
|
113
|
+
/* @__PURE__ */ n("h3", { children: "Widerruf eingegangen" }),
|
|
111
114
|
/* @__PURE__ */ c("p", { children: [
|
|
112
115
|
"Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine Bestätigung an ",
|
|
113
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ n("strong", { children: t.email }),
|
|
114
117
|
"."
|
|
115
118
|
] })
|
|
116
119
|
] }),
|
|
117
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ n(B, { config: e })
|
|
118
121
|
] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
119
|
-
e.introText && /* @__PURE__ */
|
|
120
|
-
h === "error" &&
|
|
122
|
+
e.introText && /* @__PURE__ */ n("p", { className: "wrb-intro", children: e.introText }),
|
|
123
|
+
h === "error" && d && /* @__PURE__ */ n("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: d }),
|
|
121
124
|
/* @__PURE__ */ c("form", { onSubmit: M, noValidate: !0, children: [
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
|
|
125
|
+
/* @__PURE__ */ n(
|
|
126
|
+
y,
|
|
124
127
|
{
|
|
125
128
|
label: "Vorname",
|
|
126
129
|
required: !0,
|
|
127
|
-
error: s.firstName ?
|
|
128
|
-
children: /* @__PURE__ */
|
|
130
|
+
error: s.firstName ? a.firstName : void 0,
|
|
131
|
+
children: /* @__PURE__ */ n(
|
|
129
132
|
"input",
|
|
130
133
|
{
|
|
131
|
-
ref:
|
|
132
|
-
className: `wrb-input${s.firstName &&
|
|
134
|
+
ref: v,
|
|
135
|
+
className: `wrb-input${s.firstName && a.firstName ? " wrb-error" : ""}`,
|
|
133
136
|
type: "text",
|
|
134
137
|
autoComplete: "given-name",
|
|
135
138
|
value: t.firstName,
|
|
136
|
-
onChange: (
|
|
137
|
-
onBlur: () =>
|
|
139
|
+
onChange: (i) => g("firstName", i.target.value),
|
|
140
|
+
onBlur: () => N("firstName"),
|
|
138
141
|
placeholder: "Max"
|
|
139
142
|
}
|
|
140
143
|
)
|
|
141
144
|
}
|
|
142
145
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
|
|
146
|
+
/* @__PURE__ */ n(
|
|
147
|
+
y,
|
|
145
148
|
{
|
|
146
149
|
label: "Nachname",
|
|
147
150
|
required: !0,
|
|
148
|
-
error: s.lastName ?
|
|
149
|
-
children: /* @__PURE__ */
|
|
151
|
+
error: s.lastName ? a.lastName : void 0,
|
|
152
|
+
children: /* @__PURE__ */ n(
|
|
150
153
|
"input",
|
|
151
154
|
{
|
|
152
|
-
className: `wrb-input${s.lastName &&
|
|
155
|
+
className: `wrb-input${s.lastName && a.lastName ? " wrb-error" : ""}`,
|
|
153
156
|
type: "text",
|
|
154
157
|
autoComplete: "family-name",
|
|
155
158
|
value: t.lastName,
|
|
156
|
-
onChange: (
|
|
157
|
-
onBlur: () =>
|
|
159
|
+
onChange: (i) => g("lastName", i.target.value),
|
|
160
|
+
onBlur: () => N("lastName"),
|
|
158
161
|
placeholder: "Mustermann"
|
|
159
162
|
}
|
|
160
163
|
)
|
|
161
164
|
}
|
|
162
165
|
),
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
|
|
166
|
+
/* @__PURE__ */ n(
|
|
167
|
+
y,
|
|
165
168
|
{
|
|
166
169
|
label: "E-Mail-Adresse",
|
|
167
170
|
required: !0,
|
|
168
|
-
hint: "
|
|
169
|
-
error: s.email ?
|
|
170
|
-
children: /* @__PURE__ */
|
|
171
|
+
hint: "An diese Adresse senden wir Ihnen die Eingangsbestätigung.",
|
|
172
|
+
error: s.email ? a.email : void 0,
|
|
173
|
+
children: /* @__PURE__ */ n(
|
|
171
174
|
"input",
|
|
172
175
|
{
|
|
173
|
-
className: `wrb-input${s.email &&
|
|
176
|
+
className: `wrb-input${s.email && a.email ? " wrb-error" : ""}`,
|
|
174
177
|
type: "email",
|
|
175
178
|
autoComplete: "email",
|
|
176
179
|
value: t.email,
|
|
177
|
-
onChange: (
|
|
178
|
-
onBlur: () =>
|
|
180
|
+
onChange: (i) => g("email", i.target.value),
|
|
181
|
+
onBlur: () => N("email"),
|
|
179
182
|
placeholder: "name@beispiel.de"
|
|
180
183
|
}
|
|
181
184
|
)
|
|
182
185
|
}
|
|
183
186
|
),
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
|
|
187
|
+
/* @__PURE__ */ n(
|
|
188
|
+
y,
|
|
186
189
|
{
|
|
187
|
-
label: "
|
|
190
|
+
label: "Rechnungs- / Lieferschein- / Auftragsnummer",
|
|
188
191
|
required: !0,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
children: /* @__PURE__ */ a(
|
|
192
|
+
error: s.orderNumber ? a.orderNumber : void 0,
|
|
193
|
+
children: /* @__PURE__ */ n(
|
|
192
194
|
"input",
|
|
193
195
|
{
|
|
194
|
-
className: `wrb-input${s.orderNumber &&
|
|
196
|
+
className: `wrb-input${s.orderNumber && a.orderNumber ? " wrb-error" : ""}`,
|
|
195
197
|
type: "text",
|
|
196
198
|
value: t.orderNumber,
|
|
197
|
-
onChange: (
|
|
198
|
-
onBlur: () =>
|
|
199
|
-
placeholder: "z.B.
|
|
199
|
+
onChange: (i) => g("orderNumber", i.target.value),
|
|
200
|
+
onBlur: () => N("orderNumber"),
|
|
201
|
+
placeholder: "z.B. RE123456"
|
|
200
202
|
}
|
|
201
203
|
)
|
|
202
204
|
}
|
|
203
205
|
),
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
|
|
206
|
+
/* @__PURE__ */ n(
|
|
207
|
+
y,
|
|
206
208
|
{
|
|
207
209
|
label: "Widerrufsgrund",
|
|
208
210
|
hint: "Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",
|
|
209
|
-
children: /* @__PURE__ */
|
|
211
|
+
children: /* @__PURE__ */ n(
|
|
210
212
|
"textarea",
|
|
211
213
|
{
|
|
212
214
|
className: "wrb-textarea",
|
|
213
215
|
value: t.reason,
|
|
214
|
-
onChange: (
|
|
216
|
+
onChange: (i) => g("reason", i.target.value),
|
|
215
217
|
placeholder: "Optional",
|
|
216
218
|
rows: 2
|
|
217
219
|
}
|
|
218
220
|
)
|
|
219
221
|
}
|
|
220
222
|
),
|
|
223
|
+
/* @__PURE__ */ c("div", { className: "wrb-hp", "aria-hidden": "true", children: [
|
|
224
|
+
/* @__PURE__ */ n("label", { children: "Website (leer lassen)" }),
|
|
225
|
+
/* @__PURE__ */ n(
|
|
226
|
+
"input",
|
|
227
|
+
{
|
|
228
|
+
ref: z,
|
|
229
|
+
type: "text",
|
|
230
|
+
name: "wrbWebsite",
|
|
231
|
+
tabIndex: -1,
|
|
232
|
+
autoComplete: "off",
|
|
233
|
+
defaultValue: ""
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
] }),
|
|
221
237
|
/* @__PURE__ */ c("div", { className: "wrb-actions", children: [
|
|
222
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ n(
|
|
223
239
|
"button",
|
|
224
240
|
{
|
|
225
241
|
type: "button",
|
|
@@ -228,7 +244,7 @@ function P({ config: e, onClose: r }) {
|
|
|
228
244
|
children: e.cancelLabel ?? "Abbrechen"
|
|
229
245
|
}
|
|
230
246
|
),
|
|
231
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ n(
|
|
232
248
|
"button",
|
|
233
249
|
{
|
|
234
250
|
type: "submit",
|
|
@@ -239,25 +255,25 @@ function P({ config: e, onClose: r }) {
|
|
|
239
255
|
)
|
|
240
256
|
] })
|
|
241
257
|
] }),
|
|
242
|
-
/* @__PURE__ */
|
|
258
|
+
/* @__PURE__ */ n(B, { config: e })
|
|
243
259
|
] })
|
|
244
260
|
] })
|
|
245
261
|
}
|
|
246
262
|
);
|
|
247
263
|
}
|
|
248
|
-
function
|
|
264
|
+
function y({ label: e, required: r, hint: t, error: o, children: a }) {
|
|
249
265
|
return /* @__PURE__ */ c("div", { className: "wrb-field", children: [
|
|
250
266
|
/* @__PURE__ */ c("label", { className: "wrb-label", children: [
|
|
251
267
|
e,
|
|
252
|
-
r && /* @__PURE__ */
|
|
268
|
+
r && /* @__PURE__ */ n("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
253
269
|
] }),
|
|
254
|
-
|
|
255
|
-
t && !o && /* @__PURE__ */
|
|
256
|
-
o && /* @__PURE__ */
|
|
270
|
+
a,
|
|
271
|
+
t && !o && /* @__PURE__ */ n("p", { className: "wrb-hint", children: t }),
|
|
272
|
+
o && /* @__PURE__ */ n("p", { className: "wrb-field-error", role: "alert", children: o })
|
|
257
273
|
] });
|
|
258
274
|
}
|
|
259
275
|
function B({ config: e }) {
|
|
260
|
-
return e.privacyUrl ? /* @__PURE__ */
|
|
276
|
+
return e.privacyUrl ? /* @__PURE__ */ n("div", { className: "wrb-legal-links", children: /* @__PURE__ */ n(
|
|
261
277
|
"a",
|
|
262
278
|
{
|
|
263
279
|
href: e.privacyUrl,
|
|
@@ -268,7 +284,7 @@ function B({ config: e }) {
|
|
|
268
284
|
}
|
|
269
285
|
) }) : null;
|
|
270
286
|
}
|
|
271
|
-
const
|
|
287
|
+
const W = `
|
|
272
288
|
/* Widerrufsbutton widget — prefix: wrb- */
|
|
273
289
|
.wrb-btn {
|
|
274
290
|
display: inline-flex;
|
|
@@ -497,19 +513,79 @@ const $ = `
|
|
|
497
513
|
color: #374151;
|
|
498
514
|
text-decoration: underline;
|
|
499
515
|
}
|
|
516
|
+
|
|
517
|
+
/* Honeypot — off-screen, never visible, not tabbable */
|
|
518
|
+
.wrb-hp {
|
|
519
|
+
position: absolute !important;
|
|
520
|
+
left: -10000px !important;
|
|
521
|
+
top: auto !important;
|
|
522
|
+
width: 1px !important;
|
|
523
|
+
height: 1px !important;
|
|
524
|
+
overflow: hidden !important;
|
|
525
|
+
opacity: 0 !important;
|
|
526
|
+
pointer-events: none !important;
|
|
527
|
+
}
|
|
500
528
|
`;
|
|
501
529
|
function V() {
|
|
502
530
|
const e = "wrb-styles";
|
|
503
531
|
if (document.getElementById(e)) return;
|
|
504
532
|
const r = document.createElement("style");
|
|
505
|
-
r.id = e, r.textContent =
|
|
506
|
-
}
|
|
507
|
-
function
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
533
|
+
r.id = e, r.textContent = W, document.head.appendChild(r);
|
|
534
|
+
}
|
|
535
|
+
function H(e) {
|
|
536
|
+
e.dataset.wrbUpgraded || (e.dataset.wrbUpgraded = "true", e.addEventListener("submit", async (r) => {
|
|
537
|
+
r.preventDefault();
|
|
538
|
+
const t = e.querySelector('.wrb-submit-btn, button[type="submit"]'), o = (t == null ? void 0 : t.textContent) ?? "";
|
|
539
|
+
t && (t.disabled = !0, t.textContent = "Wird gesendet…");
|
|
540
|
+
const a = new FormData(e);
|
|
541
|
+
if (String(a.get("wrbWebsite") ?? "").trim() !== "") {
|
|
542
|
+
e.reset(), location.hash = "#wrb-success", t && (t.disabled = !1, t.textContent = o);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const b = String(a.get("action") ?? ""), s = {
|
|
546
|
+
firstName: String(a.get("firstName") ?? ""),
|
|
547
|
+
lastName: String(a.get("lastName") ?? ""),
|
|
548
|
+
email: String(a.get("email") ?? ""),
|
|
549
|
+
orderNumber: String(a.get("orderNumber") ?? ""),
|
|
550
|
+
reason: String(a.get("reason") ?? "")
|
|
551
|
+
};
|
|
552
|
+
e.dataset.companyName && (s.companyName = e.dataset.companyName), e.dataset.senderEmail && (s.senderEmail = e.dataset.senderEmail);
|
|
553
|
+
const x = { "Content-Type": "application/json" };
|
|
554
|
+
e.dataset.authToken && (x.Authorization = `Bearer ${e.dataset.authToken}`);
|
|
555
|
+
const h = e.getAttribute("action") ?? "";
|
|
556
|
+
try {
|
|
557
|
+
const u = await fetch(h, {
|
|
558
|
+
method: "PATCH",
|
|
559
|
+
headers: x,
|
|
560
|
+
body: JSON.stringify({ action: b, payload: s })
|
|
561
|
+
});
|
|
562
|
+
let d = null;
|
|
563
|
+
try {
|
|
564
|
+
d = await u.json();
|
|
565
|
+
} catch {
|
|
566
|
+
}
|
|
567
|
+
if (!(d && typeof d == "object" && "ok" in d ? d.ok !== !1 : u.ok)) {
|
|
568
|
+
const v = d && typeof d == "object" && "message" in d ? String(d.message ?? "") : "";
|
|
569
|
+
throw new Error(v || `Server antwortete mit Status ${u.status}`);
|
|
570
|
+
}
|
|
571
|
+
e.reset(), location.hash = "#wrb-success";
|
|
572
|
+
} catch (u) {
|
|
573
|
+
const d = u instanceof Error ? u : new Error("Unbekannter Fehler"), w = document.querySelector("#wrb-error .wrb-alert");
|
|
574
|
+
w && (w.textContent = d.message), location.hash = "#wrb-error";
|
|
575
|
+
} finally {
|
|
576
|
+
t && (t.disabled = !1, t.textContent = o);
|
|
577
|
+
}
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
580
|
+
function K() {
|
|
581
|
+
typeof document > "u" || document.querySelectorAll("#wrb-modal form").forEach(H);
|
|
582
|
+
}
|
|
583
|
+
function J({ config: e }) {
|
|
584
|
+
const [r, t] = f(!1);
|
|
585
|
+
return q(() => {
|
|
586
|
+
V(), K();
|
|
587
|
+
}, []), /* @__PURE__ */ c(O, { children: [
|
|
588
|
+
/* @__PURE__ */ n(
|
|
513
589
|
"button",
|
|
514
590
|
{
|
|
515
591
|
type: "button",
|
|
@@ -518,8 +594,8 @@ function K({ config: e }) {
|
|
|
518
594
|
children: e.buttonLabel ?? "Vertrag widerrufen"
|
|
519
595
|
}
|
|
520
596
|
),
|
|
521
|
-
r &&
|
|
522
|
-
/* @__PURE__ */
|
|
597
|
+
r && I(
|
|
598
|
+
/* @__PURE__ */ n(D, { config: e, onClose: () => t(!1) }),
|
|
523
599
|
document.body
|
|
524
600
|
)
|
|
525
601
|
] });
|
|
@@ -527,7 +603,7 @@ function K({ config: e }) {
|
|
|
527
603
|
function l(e) {
|
|
528
604
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
529
605
|
}
|
|
530
|
-
function
|
|
606
|
+
function E(e) {
|
|
531
607
|
if (!e.privacyUrl) return "";
|
|
532
608
|
const r = l(e.privacyLabel ?? "Datenschutz");
|
|
533
609
|
return `
|
|
@@ -535,12 +611,12 @@ function y(e) {
|
|
|
535
611
|
<a href="${l(e.privacyUrl)}" class="wrb-legal-link" rel="noopener noreferrer">${r}</a>
|
|
536
612
|
</div>`;
|
|
537
613
|
}
|
|
538
|
-
function
|
|
614
|
+
function F(e) {
|
|
539
615
|
const r = [];
|
|
540
616
|
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
617
|
}
|
|
542
|
-
function
|
|
543
|
-
const o = l(e.successUrl ?? r),
|
|
618
|
+
function L(e, r = "", t = "") {
|
|
619
|
+
const o = l(e.successUrl ?? r), a = l(e.errorUrl ?? t);
|
|
544
620
|
return `
|
|
545
621
|
<div class="wrb-field">
|
|
546
622
|
<label class="wrb-label">
|
|
@@ -562,16 +638,15 @@ function j(e, r = "", t = "") {
|
|
|
562
638
|
</label>
|
|
563
639
|
<input class="wrb-input" type="email" name="email" autocomplete="email"
|
|
564
640
|
placeholder="name@beispiel.de" required>
|
|
565
|
-
<p class="wrb-hint"
|
|
641
|
+
<p class="wrb-hint"An diese Adresse senden wir Ihnen die Eingangsbestätigung.</p>
|
|
566
642
|
</div>
|
|
567
643
|
<div class="wrb-field">
|
|
568
644
|
<label class="wrb-label">
|
|
569
|
-
|
|
645
|
+
Rechnungs- / Lieferschein- / Auftragsnummer
|
|
570
646
|
<span class="wrb-required" aria-hidden="true">*</span>
|
|
571
647
|
</label>
|
|
572
648
|
<input class="wrb-input" type="text" name="orderNumber"
|
|
573
|
-
placeholder="z.B.
|
|
574
|
-
<p class="wrb-hint">Zu finden in Ihrer Bestellbestätigung.</p>
|
|
649
|
+
placeholder="z.B. RE123456" required>
|
|
575
650
|
</div>
|
|
576
651
|
<div class="wrb-field">
|
|
577
652
|
<label class="wrb-label">Widerrufsgrund</label>
|
|
@@ -582,9 +657,13 @@ function j(e, r = "", t = "") {
|
|
|
582
657
|
</div>
|
|
583
658
|
<input type="hidden" name="action" value="${l(e.action)}">
|
|
584
659
|
${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
|
|
585
|
-
${
|
|
660
|
+
${a ? `<input type="hidden" name="errorUrl" value="${a}">` : ""}
|
|
661
|
+
<div class="wrb-hp" aria-hidden="true">
|
|
662
|
+
<label>Website (leer lassen)</label>
|
|
663
|
+
<input type="text" name="wrbWebsite" tabindex="-1" autocomplete="off" value="">
|
|
664
|
+
</div>`;
|
|
586
665
|
}
|
|
587
|
-
function
|
|
666
|
+
function Q(e) {
|
|
588
667
|
const r = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", t = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
|
|
589
668
|
return `<!DOCTYPE html>
|
|
590
669
|
<html lang="de">
|
|
@@ -604,7 +683,7 @@ function Y(e) {
|
|
|
604
683
|
}
|
|
605
684
|
.wrb-page .wrb-modal { max-height: none; }
|
|
606
685
|
.wrb-page .wrb-modal-title { font-size: 20px; }
|
|
607
|
-
${
|
|
686
|
+
${W}
|
|
608
687
|
</style>
|
|
609
688
|
</head>
|
|
610
689
|
<body>
|
|
@@ -615,27 +694,27 @@ function Y(e) {
|
|
|
615
694
|
</div>
|
|
616
695
|
<div class="wrb-modal-body">
|
|
617
696
|
${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
|
|
618
|
-
<form method="POST" action="${t}"${
|
|
619
|
-
${
|
|
697
|
+
<form method="POST" action="${t}"${F(e)}>
|
|
698
|
+
${L(e)}
|
|
620
699
|
<div class="wrb-actions">
|
|
621
700
|
<button type="submit" class="wrb-submit-btn">
|
|
622
701
|
${l(e.submitLabel ?? "Absenden")}
|
|
623
702
|
</button>
|
|
624
703
|
</div>
|
|
625
704
|
</form>
|
|
626
|
-
${
|
|
705
|
+
${E(e)}
|
|
627
706
|
</div>
|
|
628
707
|
</div>
|
|
629
708
|
</div>
|
|
630
709
|
</body>
|
|
631
710
|
</html>`;
|
|
632
711
|
}
|
|
633
|
-
function
|
|
634
|
-
const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"),
|
|
712
|
+
function X(e, { inlineStyles: r = !0 } = {}) {
|
|
713
|
+
const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), a = `
|
|
635
714
|
#wrb-modal, #wrb-success, #wrb-error { display: none; }
|
|
636
715
|
#wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
|
|
637
|
-
return `${r ? `<style>${
|
|
638
|
-
${
|
|
716
|
+
return `${r ? `<style>${a}
|
|
717
|
+
${W}</style>` : `<style>${a}</style>`}
|
|
639
718
|
|
|
640
719
|
<!-- Widerruf: Form-Modal -->
|
|
641
720
|
<div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
|
|
@@ -646,8 +725,8 @@ ${$}</style>` : `<style>${i}</style>`}
|
|
|
646
725
|
</div>
|
|
647
726
|
<div class="wrb-modal-body">
|
|
648
727
|
${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
|
|
649
|
-
<form method="POST" action="${o}"${
|
|
650
|
-
${
|
|
728
|
+
<form method="POST" action="${o}"${F(e)}>
|
|
729
|
+
${L(e, "#wrb-success", "#wrb-error")}
|
|
651
730
|
<div class="wrb-actions">
|
|
652
731
|
<a href="#" class="wrb-cancel-btn">${l(e.cancelLabel ?? "Abbrechen")}</a>
|
|
653
732
|
<button type="submit" class="wrb-submit-btn">
|
|
@@ -655,7 +734,7 @@ ${$}</style>` : `<style>${i}</style>`}
|
|
|
655
734
|
</button>
|
|
656
735
|
</div>
|
|
657
736
|
</form>
|
|
658
|
-
${
|
|
737
|
+
${E(e)}
|
|
659
738
|
</div>
|
|
660
739
|
</div>
|
|
661
740
|
</div>
|
|
@@ -676,7 +755,7 @@ ${$}</style>` : `<style>${i}</style>`}
|
|
|
676
755
|
Bestätigung per E-Mail.
|
|
677
756
|
</p>
|
|
678
757
|
</div>
|
|
679
|
-
${
|
|
758
|
+
${E(e)}
|
|
680
759
|
</div>
|
|
681
760
|
</div>
|
|
682
761
|
</div>
|
|
@@ -697,14 +776,16 @@ ${$}</style>` : `<style>${i}</style>`}
|
|
|
697
776
|
<a href="#" class="wrb-cancel-btn">Schließen</a>
|
|
698
777
|
<a href="#wrb-modal" class="wrb-submit-btn">Erneut versuchen</a>
|
|
699
778
|
</div>
|
|
700
|
-
${
|
|
779
|
+
${E(e)}
|
|
701
780
|
</div>
|
|
702
781
|
</div>
|
|
703
782
|
</div>`;
|
|
704
783
|
}
|
|
705
784
|
export {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
785
|
+
D as WiderrufsModal,
|
|
786
|
+
J as WiderrufsWidget,
|
|
787
|
+
Q as generateFallbackHtml,
|
|
788
|
+
X as generateModalHtml,
|
|
789
|
+
K as upgradeAllStaticForms,
|
|
790
|
+
H as upgradeStaticForm
|
|
710
791
|
};
|