@netlib/widerrufsbutton 1.1.2 → 2.1.1
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/README.md +4 -4
- package/dist/fallback.cjs.js +389 -0
- package/dist/fallback.d.ts +21 -4
- package/dist/fallback.es.js +412 -0
- package/dist/index.cjs.js +133 -71
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +325 -228
- package/dist/styles.d.ts +1 -1
- package/dist/types.d.ts +10 -5
- package/dist/widerruf.html +27 -33
- package/dist/widerrufsbutton.iife.js +17 -9
- package/package.json +8 -3
package/dist/index.es.js
CHANGED
|
@@ -1,218 +1,245 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
async function O(e,
|
|
5
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as c, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as q, useEffect as C } from "react";
|
|
3
|
+
import { createPortal as F } from "react-dom";
|
|
4
|
+
async function O(e, r) {
|
|
5
|
+
const t = {
|
|
6
6
|
"Content-Type": "application/json"
|
|
7
7
|
};
|
|
8
|
-
e.authToken && (
|
|
9
|
-
const
|
|
8
|
+
e.authToken && (t.Authorization = `Bearer ${e.authToken}`);
|
|
9
|
+
const o = {
|
|
10
10
|
action: e.action,
|
|
11
11
|
payload: {
|
|
12
|
-
...
|
|
13
|
-
|
|
12
|
+
...r,
|
|
13
|
+
...e.companyName ? { companyName: e.companyName } : {},
|
|
14
|
+
...e.senderEmail ? { senderEmail: e.senderEmail } : {}
|
|
14
15
|
}
|
|
15
|
-
},
|
|
16
|
+
}, l = await fetch(e.apiUrl, {
|
|
16
17
|
method: "PATCH",
|
|
17
|
-
headers:
|
|
18
|
-
body: JSON.stringify(
|
|
18
|
+
headers: t,
|
|
19
|
+
body: JSON.stringify(o)
|
|
19
20
|
});
|
|
20
|
-
let
|
|
21
|
+
let d;
|
|
21
22
|
try {
|
|
22
|
-
|
|
23
|
+
d = await l.json();
|
|
23
24
|
} catch {
|
|
24
|
-
if (!
|
|
25
|
+
if (!l.ok) throw new Error(`Server antwortete mit Status ${l.status}`);
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
throw new Error(typeof
|
|
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 ${l.status}`);
|
|
30
31
|
}
|
|
31
|
-
if (!
|
|
32
|
-
throw new Error(`Server antwortete mit Status ${
|
|
33
|
-
}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
year: "numeric"
|
|
38
|
-
}), D = {
|
|
39
|
-
name: "",
|
|
32
|
+
if (!l.ok)
|
|
33
|
+
throw new Error(`Server antwortete mit Status ${l.status}`);
|
|
34
|
+
}
|
|
35
|
+
const I = {
|
|
36
|
+
firstName: "",
|
|
37
|
+
lastName: "",
|
|
40
38
|
email: "",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
orderNumber: "",
|
|
40
|
+
reason: "",
|
|
41
|
+
userMessage: ""
|
|
44
42
|
};
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
return e.
|
|
48
|
-
}
|
|
49
|
-
function
|
|
50
|
-
const [
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
(
|
|
54
|
-
const
|
|
55
|
-
return document.addEventListener("keydown",
|
|
56
|
-
}, [
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
if (b
|
|
60
|
-
const
|
|
61
|
-
|
|
43
|
+
function k(e) {
|
|
44
|
+
const r = {};
|
|
45
|
+
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;
|
|
46
|
+
}
|
|
47
|
+
function U({ config: e, onClose: r }) {
|
|
48
|
+
const [t, o] = w(I), [l, d] = w({}), [s, S] = w({}), [h, N] = w("idle"), [E, z] = w(""), W = q(null);
|
|
49
|
+
C(() => {
|
|
50
|
+
var u;
|
|
51
|
+
(u = W.current) == null || u.focus();
|
|
52
|
+
const n = (b) => b.key === "Escape" && r();
|
|
53
|
+
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
54
|
+
}, [r]);
|
|
55
|
+
function m(n, u) {
|
|
56
|
+
const b = { ...t, [n]: u };
|
|
57
|
+
if (o(b), s[n]) {
|
|
58
|
+
const g = k(b);
|
|
59
|
+
d((x) => ({ ...x, [n]: g[n] }));
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
62
|
+
function f(n) {
|
|
63
|
+
S((b) => ({ ...b, [n]: !0 }));
|
|
64
|
+
const u = k(t);
|
|
65
|
+
d((b) => ({ ...b, [n]: u[n] }));
|
|
68
66
|
}
|
|
69
|
-
async function
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
Object.keys(
|
|
67
|
+
async function T(n) {
|
|
68
|
+
var g, x;
|
|
69
|
+
n.preventDefault();
|
|
70
|
+
const u = Object.fromEntries(
|
|
71
|
+
Object.keys(t).map((v) => [v, !0])
|
|
74
72
|
);
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
73
|
+
S(u);
|
|
74
|
+
const b = k(t);
|
|
75
|
+
if (d(b), !(Object.keys(b).length > 0)) {
|
|
76
|
+
N("loading"), z("");
|
|
79
77
|
try {
|
|
80
|
-
await O(e,
|
|
81
|
-
} catch (
|
|
82
|
-
const
|
|
83
|
-
|
|
78
|
+
await O(e, t), N("success"), (g = e.onSuccess) == null || g.call(e);
|
|
79
|
+
} catch (v) {
|
|
80
|
+
const B = v instanceof Error ? v : new Error("Ein unbekannter Fehler ist aufgetreten.");
|
|
81
|
+
z(B.message), N("error"), (x = e.onError) == null || x.call(e, B);
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
|
-
const
|
|
88
|
-
return /* @__PURE__ */
|
|
85
|
+
const j = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
|
|
86
|
+
return /* @__PURE__ */ a(
|
|
89
87
|
"div",
|
|
90
88
|
{
|
|
91
89
|
className: "wrb-overlay",
|
|
92
90
|
role: "dialog",
|
|
93
91
|
"aria-modal": "true",
|
|
94
92
|
"aria-labelledby": "wrb-title",
|
|
95
|
-
onClick: (
|
|
96
|
-
children: /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
93
|
+
onClick: (n) => n.target === n.currentTarget && r(),
|
|
94
|
+
children: /* @__PURE__ */ c("div", { className: "wrb-modal", children: [
|
|
95
|
+
/* @__PURE__ */ c("div", { className: "wrb-modal-header", children: [
|
|
96
|
+
/* @__PURE__ */ a("h2", { className: "wrb-modal-title", id: "wrb-title", children: j }),
|
|
97
|
+
/* @__PURE__ */ a(
|
|
100
98
|
"button",
|
|
101
99
|
{
|
|
102
100
|
className: "wrb-close-btn",
|
|
103
|
-
onClick:
|
|
101
|
+
onClick: r,
|
|
104
102
|
"aria-label": "Schließen",
|
|
105
103
|
type: "button",
|
|
106
104
|
children: "✕"
|
|
107
105
|
}
|
|
108
106
|
)
|
|
109
107
|
] }),
|
|
110
|
-
h === "success" ? /* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */
|
|
108
|
+
h === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
109
|
+
/* @__PURE__ */ c("div", { className: "wrb-success", children: [
|
|
110
|
+
/* @__PURE__ */ a("span", { className: "wrb-success-icon", children: "✓" }),
|
|
111
|
+
/* @__PURE__ */ a("h3", { children: "Widerruf eingegangen" }),
|
|
112
|
+
/* @__PURE__ */ c("p", { children: [
|
|
115
113
|
"Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine Bestätigung an ",
|
|
116
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ a("strong", { children: t.email }),
|
|
117
115
|
"."
|
|
118
116
|
] })
|
|
119
117
|
] }),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
] }) : /* @__PURE__ */
|
|
122
|
-
e.introText && /* @__PURE__ */
|
|
123
|
-
h === "error" && E && /* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
|
|
118
|
+
/* @__PURE__ */ a(A, { links: e.legalLinks })
|
|
119
|
+
] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
120
|
+
e.introText && /* @__PURE__ */ a("p", { className: "wrb-intro", children: e.introText }),
|
|
121
|
+
h === "error" && E && /* @__PURE__ */ a("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: E }),
|
|
122
|
+
/* @__PURE__ */ c("form", { onSubmit: T, noValidate: !0, children: [
|
|
123
|
+
/* @__PURE__ */ a(
|
|
124
|
+
p,
|
|
125
|
+
{
|
|
126
|
+
label: "Vorname",
|
|
127
|
+
required: !0,
|
|
128
|
+
error: s.firstName ? l.firstName : void 0,
|
|
129
|
+
children: /* @__PURE__ */ a(
|
|
130
|
+
"input",
|
|
131
|
+
{
|
|
132
|
+
ref: W,
|
|
133
|
+
className: `wrb-input${s.firstName && l.firstName ? " wrb-error" : ""}`,
|
|
134
|
+
type: "text",
|
|
135
|
+
autoComplete: "given-name",
|
|
136
|
+
value: t.firstName,
|
|
137
|
+
onChange: (n) => m("firstName", n.target.value),
|
|
138
|
+
onBlur: () => f("firstName"),
|
|
139
|
+
placeholder: "Max"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ a(
|
|
145
|
+
p,
|
|
127
146
|
{
|
|
128
|
-
label: "
|
|
147
|
+
label: "Nachname",
|
|
129
148
|
required: !0,
|
|
130
|
-
error:
|
|
131
|
-
children: /* @__PURE__ */
|
|
149
|
+
error: s.lastName ? l.lastName : void 0,
|
|
150
|
+
children: /* @__PURE__ */ a(
|
|
132
151
|
"input",
|
|
133
152
|
{
|
|
134
|
-
|
|
135
|
-
className: `wrb-input${l.name && i.name ? " wrb-error" : ""}`,
|
|
153
|
+
className: `wrb-input${s.lastName && l.lastName ? " wrb-error" : ""}`,
|
|
136
154
|
type: "text",
|
|
137
|
-
autoComplete: "name",
|
|
138
|
-
value:
|
|
139
|
-
onChange: (
|
|
140
|
-
onBlur: () =>
|
|
141
|
-
placeholder: "
|
|
155
|
+
autoComplete: "family-name",
|
|
156
|
+
value: t.lastName,
|
|
157
|
+
onChange: (n) => m("lastName", n.target.value),
|
|
158
|
+
onBlur: () => f("lastName"),
|
|
159
|
+
placeholder: "Mustermann"
|
|
142
160
|
}
|
|
143
161
|
)
|
|
144
162
|
}
|
|
145
163
|
),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
164
|
+
/* @__PURE__ */ a(
|
|
165
|
+
p,
|
|
148
166
|
{
|
|
149
167
|
label: "E-Mail-Adresse",
|
|
150
168
|
required: !0,
|
|
151
169
|
hint: "Hierüber erhalten Sie die Eingangsbestätigung.",
|
|
152
|
-
error:
|
|
153
|
-
children: /* @__PURE__ */
|
|
170
|
+
error: s.email ? l.email : void 0,
|
|
171
|
+
children: /* @__PURE__ */ a(
|
|
154
172
|
"input",
|
|
155
173
|
{
|
|
156
|
-
className: `wrb-input${
|
|
174
|
+
className: `wrb-input${s.email && l.email ? " wrb-error" : ""}`,
|
|
157
175
|
type: "email",
|
|
158
176
|
autoComplete: "email",
|
|
159
|
-
value:
|
|
160
|
-
onChange: (
|
|
161
|
-
onBlur: () =>
|
|
177
|
+
value: t.email,
|
|
178
|
+
onChange: (n) => m("email", n.target.value),
|
|
179
|
+
onBlur: () => f("email"),
|
|
162
180
|
placeholder: "name@beispiel.de"
|
|
163
181
|
}
|
|
164
182
|
)
|
|
165
183
|
}
|
|
166
184
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
|
|
185
|
+
/* @__PURE__ */ a(
|
|
186
|
+
p,
|
|
169
187
|
{
|
|
170
188
|
label: "Bestell- / Auftrags- / Vertragsnummer",
|
|
171
189
|
required: !0,
|
|
172
190
|
hint: "Zu finden in Ihrer Bestellbestätigung.",
|
|
173
|
-
error:
|
|
174
|
-
children: /* @__PURE__ */
|
|
191
|
+
error: s.orderNumber ? l.orderNumber : void 0,
|
|
192
|
+
children: /* @__PURE__ */ a(
|
|
175
193
|
"input",
|
|
176
194
|
{
|
|
177
|
-
className: `wrb-input${
|
|
195
|
+
className: `wrb-input${s.orderNumber && l.orderNumber ? " wrb-error" : ""}`,
|
|
178
196
|
type: "text",
|
|
179
|
-
value:
|
|
180
|
-
onChange: (
|
|
181
|
-
onBlur: () =>
|
|
197
|
+
value: t.orderNumber,
|
|
198
|
+
onChange: (n) => m("orderNumber", n.target.value),
|
|
199
|
+
onBlur: () => f("orderNumber"),
|
|
182
200
|
placeholder: "z.B. 10045678"
|
|
183
201
|
}
|
|
184
202
|
)
|
|
185
203
|
}
|
|
186
204
|
),
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
205
|
+
/* @__PURE__ */ a(
|
|
206
|
+
p,
|
|
189
207
|
{
|
|
190
208
|
label: "Widerrufsgrund",
|
|
191
209
|
hint: "Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",
|
|
192
|
-
children: /* @__PURE__ */
|
|
210
|
+
children: /* @__PURE__ */ a(
|
|
193
211
|
"textarea",
|
|
194
212
|
{
|
|
195
213
|
className: "wrb-textarea",
|
|
196
|
-
value:
|
|
197
|
-
onChange: (
|
|
214
|
+
value: t.reason,
|
|
215
|
+
onChange: (n) => m("reason", n.target.value),
|
|
198
216
|
placeholder: "Optional",
|
|
199
|
-
rows:
|
|
217
|
+
rows: 2
|
|
200
218
|
}
|
|
201
219
|
)
|
|
202
220
|
}
|
|
203
221
|
),
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
|
|
206
|
-
|
|
222
|
+
/* @__PURE__ */ a(p, { label: "Nachricht", children: /* @__PURE__ */ a(
|
|
223
|
+
"textarea",
|
|
224
|
+
{
|
|
225
|
+
className: "wrb-textarea",
|
|
226
|
+
value: t.userMessage,
|
|
227
|
+
onChange: (n) => m("userMessage", n.target.value),
|
|
228
|
+
placeholder: "Optional",
|
|
229
|
+
rows: 3
|
|
230
|
+
}
|
|
231
|
+
) }),
|
|
232
|
+
/* @__PURE__ */ c("div", { className: "wrb-actions", children: [
|
|
233
|
+
/* @__PURE__ */ a(
|
|
207
234
|
"button",
|
|
208
235
|
{
|
|
209
236
|
type: "button",
|
|
210
237
|
className: "wrb-cancel-btn",
|
|
211
|
-
onClick:
|
|
238
|
+
onClick: r,
|
|
212
239
|
children: e.cancelLabel ?? "Abbrechen"
|
|
213
240
|
}
|
|
214
241
|
),
|
|
215
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ a(
|
|
216
243
|
"button",
|
|
217
244
|
{
|
|
218
245
|
type: "submit",
|
|
@@ -223,37 +250,37 @@ function F({ config: e, onClose: t }) {
|
|
|
223
250
|
)
|
|
224
251
|
] })
|
|
225
252
|
] }),
|
|
226
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ a(A, { links: e.legalLinks })
|
|
227
254
|
] })
|
|
228
255
|
] })
|
|
229
256
|
}
|
|
230
257
|
);
|
|
231
258
|
}
|
|
232
|
-
function
|
|
233
|
-
return /* @__PURE__ */
|
|
234
|
-
/* @__PURE__ */
|
|
259
|
+
function p({ label: e, required: r, hint: t, error: o, children: l }) {
|
|
260
|
+
return /* @__PURE__ */ c("div", { className: "wrb-field", children: [
|
|
261
|
+
/* @__PURE__ */ c("label", { className: "wrb-label", children: [
|
|
235
262
|
e,
|
|
236
|
-
|
|
263
|
+
r && /* @__PURE__ */ a("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
237
264
|
] }),
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
265
|
+
l,
|
|
266
|
+
t && !o && /* @__PURE__ */ a("p", { className: "wrb-hint", children: t }),
|
|
267
|
+
o && /* @__PURE__ */ a("p", { className: "wrb-field-error", role: "alert", children: o })
|
|
241
268
|
] });
|
|
242
269
|
}
|
|
243
|
-
function
|
|
244
|
-
return e != null && e.length ? /* @__PURE__ */
|
|
270
|
+
function A({ links: e }) {
|
|
271
|
+
return e != null && e.length ? /* @__PURE__ */ a("div", { className: "wrb-legal-links", children: e.map((r) => /* @__PURE__ */ a(
|
|
245
272
|
"a",
|
|
246
273
|
{
|
|
247
|
-
href:
|
|
274
|
+
href: r.href,
|
|
248
275
|
className: "wrb-legal-link",
|
|
249
276
|
target: "_blank",
|
|
250
277
|
rel: "noopener noreferrer",
|
|
251
|
-
children:
|
|
278
|
+
children: r.name
|
|
252
279
|
},
|
|
253
|
-
|
|
280
|
+
r.href
|
|
254
281
|
)) }) : null;
|
|
255
282
|
}
|
|
256
|
-
const
|
|
283
|
+
const $ = `
|
|
257
284
|
/* Widerrufsbutton widget — prefix: wrb- */
|
|
258
285
|
.wrb-btn {
|
|
259
286
|
display: inline-flex;
|
|
@@ -413,6 +440,10 @@ const A = `
|
|
|
413
440
|
border-top: 1px solid #e5e7eb;
|
|
414
441
|
}
|
|
415
442
|
.wrb-submit-btn {
|
|
443
|
+
display: inline-flex;
|
|
444
|
+
align-items: center;
|
|
445
|
+
justify-content: center;
|
|
446
|
+
text-decoration: none;
|
|
416
447
|
padding: 10px 22px;
|
|
417
448
|
background: #c0392b;
|
|
418
449
|
color: #fff;
|
|
@@ -427,6 +458,10 @@ const A = `
|
|
|
427
458
|
.wrb-submit-btn:hover:not(:disabled) { background: #a93226; }
|
|
428
459
|
.wrb-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
429
460
|
.wrb-cancel-btn {
|
|
461
|
+
display: inline-flex;
|
|
462
|
+
align-items: center;
|
|
463
|
+
justify-content: center;
|
|
464
|
+
text-decoration: none;
|
|
430
465
|
padding: 10px 18px;
|
|
431
466
|
background: transparent;
|
|
432
467
|
color: #374151;
|
|
@@ -475,101 +510,66 @@ const A = `
|
|
|
475
510
|
text-decoration: underline;
|
|
476
511
|
}
|
|
477
512
|
`;
|
|
478
|
-
function
|
|
513
|
+
function V() {
|
|
479
514
|
const e = "wrb-styles";
|
|
480
515
|
if (document.getElementById(e)) return;
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
function
|
|
485
|
-
const [
|
|
486
|
-
return
|
|
487
|
-
|
|
488
|
-
}, []), /* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
516
|
+
const r = document.createElement("style");
|
|
517
|
+
r.id = e, r.textContent = $, document.head.appendChild(r);
|
|
518
|
+
}
|
|
519
|
+
function K({ config: e }) {
|
|
520
|
+
const [r, t] = w(!1);
|
|
521
|
+
return C(() => {
|
|
522
|
+
V();
|
|
523
|
+
}, []), /* @__PURE__ */ c(L, { children: [
|
|
524
|
+
/* @__PURE__ */ a(
|
|
490
525
|
"button",
|
|
491
526
|
{
|
|
492
527
|
type: "button",
|
|
493
528
|
className: `wrb-btn${e.buttonClass ? ` ${e.buttonClass}` : ""}`,
|
|
494
|
-
onClick: () =>
|
|
529
|
+
onClick: () => t(!0),
|
|
495
530
|
children: e.buttonLabel ?? "Vertrag widerrufen"
|
|
496
531
|
}
|
|
497
532
|
),
|
|
498
|
-
|
|
499
|
-
/* @__PURE__ */
|
|
533
|
+
r && F(
|
|
534
|
+
/* @__PURE__ */ a(U, { config: e, onClose: () => t(!1) }),
|
|
500
535
|
document.body
|
|
501
536
|
)
|
|
502
537
|
] });
|
|
503
538
|
}
|
|
504
|
-
function
|
|
539
|
+
function i(e) {
|
|
505
540
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
506
541
|
}
|
|
507
|
-
function
|
|
508
|
-
var
|
|
509
|
-
|
|
510
|
-
day: "2-digit",
|
|
511
|
-
month: "2-digit",
|
|
512
|
-
year: "numeric"
|
|
513
|
-
}), n = e.companyName ? `Widerruf – ${u(e.companyName)}` : "Widerrufsformular", b = u(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), i = e.introText ? `<p class="wrb-intro">${u(e.introText)}</p>` : "", o = (l = e.legalLinks) != null && l.length ? `
|
|
542
|
+
function y(e) {
|
|
543
|
+
var r;
|
|
544
|
+
return (r = e.legalLinks) != null && r.length ? `
|
|
514
545
|
<div class="wrb-legal-links">
|
|
515
|
-
${e.legalLinks.map((
|
|
546
|
+
${e.legalLinks.map((t) => `<a href="${i(t.href)}" class="wrb-legal-link" rel="noopener noreferrer">${i(t.name)}</a>`).join(`
|
|
516
547
|
`)}
|
|
517
548
|
</div>` : "";
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
523
|
-
<title>${n}</title>
|
|
524
|
-
<style>
|
|
525
|
-
*, *::before, *::after { box-sizing: border-box; }
|
|
526
|
-
body { margin: 0; background: #f9fafb; }
|
|
527
|
-
.wrb-page {
|
|
528
|
-
min-height: 100vh;
|
|
529
|
-
display: flex;
|
|
530
|
-
align-items: flex-start;
|
|
531
|
-
justify-content: center;
|
|
532
|
-
padding: 40px 16px;
|
|
533
|
-
}
|
|
534
|
-
.wrb-page .wrb-modal { max-height: none; }
|
|
535
|
-
.wrb-page .wrb-modal-title { font-size: 20px; }
|
|
536
|
-
${A}
|
|
537
|
-
</style>
|
|
538
|
-
</head>
|
|
539
|
-
<body>
|
|
540
|
-
<div class="wrb-page">
|
|
541
|
-
<div class="wrb-modal">
|
|
542
|
-
<div class="wrb-modal-header">
|
|
543
|
-
<h1 class="wrb-modal-title">${n}</h1>
|
|
544
|
-
</div>
|
|
545
|
-
<div class="wrb-modal-body">
|
|
546
|
-
${i}
|
|
547
|
-
<form method="POST" action="${b}" novalidate>
|
|
549
|
+
}
|
|
550
|
+
function M(e, r = "", t = "") {
|
|
551
|
+
const o = i(e.successUrl ?? r), l = i(e.errorUrl ?? t);
|
|
552
|
+
return `
|
|
548
553
|
<div class="wrb-field">
|
|
549
554
|
<label class="wrb-label">
|
|
550
|
-
|
|
555
|
+
Vorname <span class="wrb-required" aria-hidden="true">*</span>
|
|
551
556
|
</label>
|
|
552
|
-
<input
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
557
|
+
<input class="wrb-input" type="text" name="firstName" autocomplete="given-name"
|
|
558
|
+
placeholder="Max" required>
|
|
559
|
+
</div>
|
|
560
|
+
<div class="wrb-field">
|
|
561
|
+
<label class="wrb-label">
|
|
562
|
+
Nachname <span class="wrb-required" aria-hidden="true">*</span>
|
|
563
|
+
</label>
|
|
564
|
+
<input class="wrb-input" type="text" name="lastName" autocomplete="family-name"
|
|
565
|
+
placeholder="Mustermann" required>
|
|
560
566
|
</div>
|
|
561
567
|
<div class="wrb-field">
|
|
562
568
|
<label class="wrb-label">
|
|
563
569
|
E-Mail-Adresse <span class="wrb-required" aria-hidden="true">*</span>
|
|
564
570
|
</label>
|
|
565
|
-
<input
|
|
566
|
-
|
|
567
|
-
type="email"
|
|
568
|
-
name="email"
|
|
569
|
-
autocomplete="email"
|
|
570
|
-
placeholder="name@beispiel.de"
|
|
571
|
-
required
|
|
572
|
-
>
|
|
571
|
+
<input class="wrb-input" type="email" name="email" autocomplete="email"
|
|
572
|
+
placeholder="name@beispiel.de" required>
|
|
573
573
|
<p class="wrb-hint">Hierüber erhalten Sie die Eingangsbestätigung.</p>
|
|
574
574
|
</div>
|
|
575
575
|
<div class="wrb-field">
|
|
@@ -577,49 +577,146 @@ function R(e) {
|
|
|
577
577
|
Bestell- / Auftrags- / Vertragsnummer
|
|
578
578
|
<span class="wrb-required" aria-hidden="true">*</span>
|
|
579
579
|
</label>
|
|
580
|
-
<input
|
|
581
|
-
|
|
582
|
-
type="text"
|
|
583
|
-
name="vertragId"
|
|
584
|
-
placeholder="z.B. 10045678"
|
|
585
|
-
required
|
|
586
|
-
>
|
|
580
|
+
<input class="wrb-input" type="text" name="orderNumber"
|
|
581
|
+
placeholder="z.B. 10045678" required>
|
|
587
582
|
<p class="wrb-hint">Zu finden in Ihrer Bestellbestätigung.</p>
|
|
588
583
|
</div>
|
|
589
584
|
<div class="wrb-field">
|
|
590
585
|
<label class="wrb-label">Widerrufsgrund</label>
|
|
591
|
-
<textarea
|
|
592
|
-
class="wrb-textarea"
|
|
593
|
-
name="widerrufsgrund"
|
|
594
|
-
placeholder="Optional"
|
|
595
|
-
rows="3"
|
|
596
|
-
></textarea>
|
|
586
|
+
<textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="2"></textarea>
|
|
597
587
|
<p class="wrb-hint">
|
|
598
588
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
599
589
|
</p>
|
|
600
590
|
</div>
|
|
601
591
|
<div class="wrb-field">
|
|
602
|
-
<label class="wrb-label">
|
|
603
|
-
<
|
|
604
|
-
<input type="hidden" name="datum" value="${t}">
|
|
592
|
+
<label class="wrb-label">Nachricht</label>
|
|
593
|
+
<textarea class="wrb-textarea" name="userMessage" placeholder="Optional" rows="3"></textarea>
|
|
605
594
|
</div>
|
|
606
|
-
<input type="hidden" name="action" value="${
|
|
607
|
-
${
|
|
595
|
+
<input type="hidden" name="action" value="${i(e.action)}">
|
|
596
|
+
${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
|
|
597
|
+
${l ? `<input type="hidden" name="errorUrl" value="${l}">` : ""}`;
|
|
598
|
+
}
|
|
599
|
+
function Y(e) {
|
|
600
|
+
const r = e.companyName ? `Widerruf – ${i(e.companyName)}` : "Widerrufsformular", t = i(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
|
|
601
|
+
return `<!DOCTYPE html>
|
|
602
|
+
<html lang="de">
|
|
603
|
+
<head>
|
|
604
|
+
<meta charset="UTF-8">
|
|
605
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
606
|
+
<title>${r}</title>
|
|
607
|
+
<style>
|
|
608
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
609
|
+
body { margin: 0; background: #f9fafb; }
|
|
610
|
+
.wrb-page {
|
|
611
|
+
min-height: 100vh;
|
|
612
|
+
display: flex;
|
|
613
|
+
align-items: flex-start;
|
|
614
|
+
justify-content: center;
|
|
615
|
+
padding: 40px 16px;
|
|
616
|
+
}
|
|
617
|
+
.wrb-page .wrb-modal { max-height: none; }
|
|
618
|
+
.wrb-page .wrb-modal-title { font-size: 20px; }
|
|
619
|
+
${$}
|
|
620
|
+
</style>
|
|
621
|
+
</head>
|
|
622
|
+
<body>
|
|
623
|
+
<div class="wrb-page">
|
|
624
|
+
<div class="wrb-modal">
|
|
625
|
+
<div class="wrb-modal-header">
|
|
626
|
+
<h1 class="wrb-modal-title">${r}</h1>
|
|
627
|
+
</div>
|
|
628
|
+
<div class="wrb-modal-body">
|
|
629
|
+
${e.introText ? `<p class="wrb-intro">${i(e.introText)}</p>` : ""}
|
|
630
|
+
<form method="POST" action="${t}" novalidate>
|
|
631
|
+
${M(e)}
|
|
608
632
|
<div class="wrb-actions">
|
|
609
633
|
<button type="submit" class="wrb-submit-btn">
|
|
610
|
-
${
|
|
634
|
+
${i(e.submitLabel ?? "Absenden")}
|
|
611
635
|
</button>
|
|
612
636
|
</div>
|
|
613
637
|
</form>
|
|
614
|
-
${
|
|
638
|
+
${y(e)}
|
|
615
639
|
</div>
|
|
616
640
|
</div>
|
|
617
641
|
</div>
|
|
618
642
|
</body>
|
|
619
643
|
</html>`;
|
|
620
644
|
}
|
|
645
|
+
function _(e, { inlineStyles: r = !0 } = {}) {
|
|
646
|
+
const t = e.companyName ? `Widerruf – ${i(e.companyName)}` : "Widerrufsformular", o = i(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), l = `
|
|
647
|
+
#wrb-modal, #wrb-success, #wrb-error { display: none; }
|
|
648
|
+
#wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
|
|
649
|
+
return `${r ? `<style>${l}
|
|
650
|
+
${$}</style>` : `<style>${l}</style>`}
|
|
651
|
+
|
|
652
|
+
<!-- Widerruf: Form-Modal -->
|
|
653
|
+
<div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
|
|
654
|
+
<div class="wrb-modal">
|
|
655
|
+
<div class="wrb-modal-header">
|
|
656
|
+
<h2 class="wrb-modal-title" id="wrb-modal-title">${t}</h2>
|
|
657
|
+
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
658
|
+
</div>
|
|
659
|
+
<div class="wrb-modal-body">
|
|
660
|
+
${e.introText ? `<p class="wrb-intro">${i(e.introText)}</p>` : ""}
|
|
661
|
+
<form method="POST" action="${o}" novalidate>
|
|
662
|
+
${M(e, "#wrb-success", "#wrb-error")}
|
|
663
|
+
<div class="wrb-actions">
|
|
664
|
+
<a href="#" class="wrb-cancel-btn">${i(e.cancelLabel ?? "Abbrechen")}</a>
|
|
665
|
+
<button type="submit" class="wrb-submit-btn">
|
|
666
|
+
${i(e.submitLabel ?? "Absenden")}
|
|
667
|
+
</button>
|
|
668
|
+
</div>
|
|
669
|
+
</form>
|
|
670
|
+
${y(e)}
|
|
671
|
+
</div>
|
|
672
|
+
</div>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<!-- Widerruf: Success-Modal -->
|
|
676
|
+
<div id="wrb-success" class="wrb-overlay" role="dialog" aria-modal="true">
|
|
677
|
+
<div class="wrb-modal">
|
|
678
|
+
<div class="wrb-modal-header">
|
|
679
|
+
<h2 class="wrb-modal-title">Widerruf eingegangen</h2>
|
|
680
|
+
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
681
|
+
</div>
|
|
682
|
+
<div class="wrb-modal-body">
|
|
683
|
+
<div class="wrb-success">
|
|
684
|
+
<span class="wrb-success-icon">✓</span>
|
|
685
|
+
<h3>Widerruf eingegangen</h3>
|
|
686
|
+
<p>
|
|
687
|
+
Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine
|
|
688
|
+
Bestätigung per E-Mail.
|
|
689
|
+
</p>
|
|
690
|
+
</div>
|
|
691
|
+
${y(e)}
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
</div>
|
|
695
|
+
|
|
696
|
+
<!-- Widerruf: Error-Modal -->
|
|
697
|
+
<div id="wrb-error" class="wrb-overlay" role="alertdialog" aria-modal="true">
|
|
698
|
+
<div class="wrb-modal">
|
|
699
|
+
<div class="wrb-modal-header">
|
|
700
|
+
<h2 class="wrb-modal-title">Fehler beim Senden</h2>
|
|
701
|
+
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
702
|
+
</div>
|
|
703
|
+
<div class="wrb-modal-body">
|
|
704
|
+
<div class="wrb-alert wrb-alert-error" role="alert">
|
|
705
|
+
Ihr Widerruf konnte leider nicht übermittelt werden. Bitte versuchen Sie es
|
|
706
|
+
erneut oder kontaktieren Sie uns direkt.
|
|
707
|
+
</div>
|
|
708
|
+
<div class="wrb-actions">
|
|
709
|
+
<a href="#" class="wrb-cancel-btn">Schließen</a>
|
|
710
|
+
<a href="#wrb-modal" class="wrb-submit-btn">Erneut versuchen</a>
|
|
711
|
+
</div>
|
|
712
|
+
${y(e)}
|
|
713
|
+
</div>
|
|
714
|
+
</div>
|
|
715
|
+
</div>`;
|
|
716
|
+
}
|
|
621
717
|
export {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
718
|
+
U as WiderrufsModal,
|
|
719
|
+
K as WiderrufsWidget,
|
|
720
|
+
Y as generateFallbackHtml,
|
|
721
|
+
_ as generateModalHtml
|
|
625
722
|
};
|