@netlib/widerrufsbutton 1.2.0 → 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/dist/fallback.cjs.js +35 -29
- package/dist/fallback.es.js +40 -41
- package/dist/index.cjs.js +40 -34
- package/dist/index.es.js +185 -159
- package/dist/types.d.ts +5 -2
- package/dist/widerruf.html +14 -8
- package/dist/widerrufsbutton.iife.js +10 -10
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,91 +1,89 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
async function
|
|
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 && (
|
|
8
|
+
e.authToken && (t.Authorization = `Bearer ${e.authToken}`);
|
|
9
9
|
const o = {
|
|
10
10
|
action: e.action,
|
|
11
11
|
payload: {
|
|
12
12
|
...r,
|
|
13
|
-
|
|
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
|
+
headers: t,
|
|
18
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
|
-
}), U = {
|
|
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
39
|
orderNumber: "",
|
|
42
40
|
reason: "",
|
|
43
|
-
|
|
41
|
+
userMessage: ""
|
|
44
42
|
};
|
|
45
|
-
function
|
|
43
|
+
function k(e) {
|
|
46
44
|
const r = {};
|
|
47
|
-
return e.
|
|
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;
|
|
48
46
|
}
|
|
49
|
-
function
|
|
50
|
-
const [
|
|
51
|
-
|
|
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(() => {
|
|
52
50
|
var u;
|
|
53
51
|
(u = W.current) == null || u.focus();
|
|
54
52
|
const n = (b) => b.key === "Escape" && r();
|
|
55
53
|
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
56
54
|
}, [r]);
|
|
57
|
-
function
|
|
58
|
-
const b = { ...
|
|
59
|
-
if (o(b),
|
|
60
|
-
const
|
|
61
|
-
|
|
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
|
|
62
|
+
function f(n) {
|
|
65
63
|
S((b) => ({ ...b, [n]: !0 }));
|
|
66
|
-
const u =
|
|
67
|
-
|
|
64
|
+
const u = k(t);
|
|
65
|
+
d((b) => ({ ...b, [n]: u[n] }));
|
|
68
66
|
}
|
|
69
|
-
async function
|
|
70
|
-
var
|
|
67
|
+
async function T(n) {
|
|
68
|
+
var g, x;
|
|
71
69
|
n.preventDefault();
|
|
72
70
|
const u = Object.fromEntries(
|
|
73
|
-
Object.keys(
|
|
71
|
+
Object.keys(t).map((v) => [v, !0])
|
|
74
72
|
);
|
|
75
73
|
S(u);
|
|
76
|
-
const b =
|
|
77
|
-
if (
|
|
78
|
-
|
|
74
|
+
const b = k(t);
|
|
75
|
+
if (d(b), !(Object.keys(b).length > 0)) {
|
|
76
|
+
N("loading"), z("");
|
|
79
77
|
try {
|
|
80
|
-
await
|
|
81
|
-
} catch (
|
|
82
|
-
const
|
|
83
|
-
z(
|
|
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",
|
|
@@ -95,8 +93,8 @@ function V({ config: e, onClose: r }) {
|
|
|
95
93
|
onClick: (n) => n.target === n.currentTarget && r(),
|
|
96
94
|
children: /* @__PURE__ */ c("div", { className: "wrb-modal", children: [
|
|
97
95
|
/* @__PURE__ */ c("div", { className: "wrb-modal-header", children: [
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
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",
|
|
@@ -107,103 +105,132 @@ function V({ config: e, onClose: r }) {
|
|
|
107
105
|
}
|
|
108
106
|
)
|
|
109
107
|
] }),
|
|
110
|
-
|
|
108
|
+
h === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
111
109
|
/* @__PURE__ */ c("div", { className: "wrb-success", children: [
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ a("span", { className: "wrb-success-icon", children: "✓" }),
|
|
111
|
+
/* @__PURE__ */ a("h3", { children: "Widerruf eingegangen" }),
|
|
114
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__ */
|
|
118
|
+
/* @__PURE__ */ a(A, { links: e.legalLinks })
|
|
121
119
|
] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
122
|
-
e.introText && /* @__PURE__ */
|
|
123
|
-
|
|
124
|
-
/* @__PURE__ */ c("form", { onSubmit:
|
|
125
|
-
/* @__PURE__ */
|
|
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(
|
|
126
124
|
p,
|
|
127
125
|
{
|
|
128
|
-
label: "
|
|
126
|
+
label: "Vorname",
|
|
129
127
|
required: !0,
|
|
130
|
-
error:
|
|
131
|
-
children: /* @__PURE__ */
|
|
128
|
+
error: s.firstName ? l.firstName : void 0,
|
|
129
|
+
children: /* @__PURE__ */ a(
|
|
132
130
|
"input",
|
|
133
131
|
{
|
|
134
132
|
ref: W,
|
|
135
|
-
className: `wrb-input${
|
|
133
|
+
className: `wrb-input${s.firstName && l.firstName ? " wrb-error" : ""}`,
|
|
136
134
|
type: "text",
|
|
137
|
-
autoComplete: "name",
|
|
138
|
-
value:
|
|
139
|
-
onChange: (n) =>
|
|
140
|
-
onBlur: () =>
|
|
141
|
-
placeholder: "
|
|
135
|
+
autoComplete: "given-name",
|
|
136
|
+
value: t.firstName,
|
|
137
|
+
onChange: (n) => m("firstName", n.target.value),
|
|
138
|
+
onBlur: () => f("firstName"),
|
|
139
|
+
placeholder: "Max"
|
|
142
140
|
}
|
|
143
141
|
)
|
|
144
142
|
}
|
|
145
143
|
),
|
|
146
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ a(
|
|
145
|
+
p,
|
|
146
|
+
{
|
|
147
|
+
label: "Nachname",
|
|
148
|
+
required: !0,
|
|
149
|
+
error: s.lastName ? l.lastName : void 0,
|
|
150
|
+
children: /* @__PURE__ */ a(
|
|
151
|
+
"input",
|
|
152
|
+
{
|
|
153
|
+
className: `wrb-input${s.lastName && l.lastName ? " wrb-error" : ""}`,
|
|
154
|
+
type: "text",
|
|
155
|
+
autoComplete: "family-name",
|
|
156
|
+
value: t.lastName,
|
|
157
|
+
onChange: (n) => m("lastName", n.target.value),
|
|
158
|
+
onBlur: () => f("lastName"),
|
|
159
|
+
placeholder: "Mustermann"
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ a(
|
|
147
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: (n) =>
|
|
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__ */
|
|
185
|
+
/* @__PURE__ */ a(
|
|
168
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: (n) =>
|
|
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__ */
|
|
205
|
+
/* @__PURE__ */ a(
|
|
188
206
|
p,
|
|
189
207
|
{
|
|
190
|
-
label: "
|
|
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: (n) =>
|
|
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__ */
|
|
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
|
+
) }),
|
|
205
232
|
/* @__PURE__ */ c("div", { className: "wrb-actions", children: [
|
|
206
|
-
/* @__PURE__ */
|
|
233
|
+
/* @__PURE__ */ a(
|
|
207
234
|
"button",
|
|
208
235
|
{
|
|
209
236
|
type: "button",
|
|
@@ -212,36 +239,36 @@ function V({ config: e, onClose: 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",
|
|
219
246
|
className: "wrb-submit-btn",
|
|
220
|
-
disabled:
|
|
221
|
-
children:
|
|
247
|
+
disabled: h === "loading",
|
|
248
|
+
children: h === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
|
|
222
249
|
}
|
|
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 p({ label: e, required: r, hint:
|
|
259
|
+
function p({ label: e, required: r, hint: t, error: o, children: l }) {
|
|
233
260
|
return /* @__PURE__ */ c("div", { className: "wrb-field", children: [
|
|
234
261
|
/* @__PURE__ */ c("label", { className: "wrb-label", children: [
|
|
235
262
|
e,
|
|
236
|
-
r && /* @__PURE__ */
|
|
263
|
+
r && /* @__PURE__ */ a("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
237
264
|
] }),
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
o && /* @__PURE__ */
|
|
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
274
|
href: r.href,
|
|
@@ -483,59 +510,59 @@ const $ = `
|
|
|
483
510
|
text-decoration: underline;
|
|
484
511
|
}
|
|
485
512
|
`;
|
|
486
|
-
function
|
|
513
|
+
function V() {
|
|
487
514
|
const e = "wrb-styles";
|
|
488
515
|
if (document.getElementById(e)) return;
|
|
489
516
|
const r = document.createElement("style");
|
|
490
517
|
r.id = e, r.textContent = $, document.head.appendChild(r);
|
|
491
518
|
}
|
|
492
|
-
function
|
|
493
|
-
const [r,
|
|
494
|
-
return
|
|
495
|
-
|
|
496
|
-
}, []), /* @__PURE__ */ c(
|
|
497
|
-
/* @__PURE__ */
|
|
519
|
+
function K({ config: e }) {
|
|
520
|
+
const [r, t] = w(!1);
|
|
521
|
+
return C(() => {
|
|
522
|
+
V();
|
|
523
|
+
}, []), /* @__PURE__ */ c(L, { children: [
|
|
524
|
+
/* @__PURE__ */ a(
|
|
498
525
|
"button",
|
|
499
526
|
{
|
|
500
527
|
type: "button",
|
|
501
528
|
className: `wrb-btn${e.buttonClass ? ` ${e.buttonClass}` : ""}`,
|
|
502
|
-
onClick: () =>
|
|
529
|
+
onClick: () => t(!0),
|
|
503
530
|
children: e.buttonLabel ?? "Vertrag widerrufen"
|
|
504
531
|
}
|
|
505
532
|
),
|
|
506
|
-
r &&
|
|
507
|
-
/* @__PURE__ */
|
|
533
|
+
r && F(
|
|
534
|
+
/* @__PURE__ */ a(U, { config: e, onClose: () => t(!1) }),
|
|
508
535
|
document.body
|
|
509
536
|
)
|
|
510
537
|
] });
|
|
511
538
|
}
|
|
512
|
-
function
|
|
539
|
+
function i(e) {
|
|
513
540
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
514
541
|
}
|
|
515
|
-
function
|
|
516
|
-
return (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE", {
|
|
517
|
-
day: "2-digit",
|
|
518
|
-
month: "2-digit",
|
|
519
|
-
year: "numeric"
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
function v(e) {
|
|
542
|
+
function y(e) {
|
|
523
543
|
var r;
|
|
524
544
|
return (r = e.legalLinks) != null && r.length ? `
|
|
525
545
|
<div class="wrb-legal-links">
|
|
526
|
-
${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(`
|
|
527
547
|
`)}
|
|
528
548
|
</div>` : "";
|
|
529
549
|
}
|
|
530
|
-
function
|
|
531
|
-
const
|
|
550
|
+
function M(e, r = "", t = "") {
|
|
551
|
+
const o = i(e.successUrl ?? r), l = i(e.errorUrl ?? t);
|
|
532
552
|
return `
|
|
533
553
|
<div class="wrb-field">
|
|
534
554
|
<label class="wrb-label">
|
|
535
|
-
|
|
555
|
+
Vorname <span class="wrb-required" aria-hidden="true">*</span>
|
|
556
|
+
</label>
|
|
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>
|
|
536
563
|
</label>
|
|
537
|
-
<input class="wrb-input" type="text" name="
|
|
538
|
-
placeholder="
|
|
564
|
+
<input class="wrb-input" type="text" name="lastName" autocomplete="family-name"
|
|
565
|
+
placeholder="Mustermann" required>
|
|
539
566
|
</div>
|
|
540
567
|
<div class="wrb-field">
|
|
541
568
|
<label class="wrb-label">
|
|
@@ -555,29 +582,28 @@ function j(e, r, a = "", o = "") {
|
|
|
555
582
|
<p class="wrb-hint">Zu finden in Ihrer Bestellbestätigung.</p>
|
|
556
583
|
</div>
|
|
557
584
|
<div class="wrb-field">
|
|
558
|
-
<label class="wrb-label">
|
|
559
|
-
<textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="
|
|
585
|
+
<label class="wrb-label">Widerrufsgrund</label>
|
|
586
|
+
<textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="2"></textarea>
|
|
560
587
|
<p class="wrb-hint">
|
|
561
588
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
562
589
|
</p>
|
|
563
590
|
</div>
|
|
564
591
|
<div class="wrb-field">
|
|
565
|
-
<label class="wrb-label">
|
|
566
|
-
<
|
|
567
|
-
<input type="hidden" name="datum" value="${r}">
|
|
592
|
+
<label class="wrb-label">Nachricht</label>
|
|
593
|
+
<textarea class="wrb-textarea" name="userMessage" placeholder="Optional" rows="3"></textarea>
|
|
568
594
|
</div>
|
|
569
|
-
<input type="hidden" name="action" value="${
|
|
570
|
-
${
|
|
595
|
+
<input type="hidden" name="action" value="${i(e.action)}">
|
|
596
|
+
${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
|
|
571
597
|
${l ? `<input type="hidden" name="errorUrl" value="${l}">` : ""}`;
|
|
572
598
|
}
|
|
573
|
-
function
|
|
574
|
-
const r =
|
|
599
|
+
function Y(e) {
|
|
600
|
+
const r = e.companyName ? `Widerruf – ${i(e.companyName)}` : "Widerrufsformular", t = i(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
|
|
575
601
|
return `<!DOCTYPE html>
|
|
576
602
|
<html lang="de">
|
|
577
603
|
<head>
|
|
578
604
|
<meta charset="UTF-8">
|
|
579
605
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
580
|
-
<title>${
|
|
606
|
+
<title>${r}</title>
|
|
581
607
|
<style>
|
|
582
608
|
*, *::before, *::after { box-sizing: border-box; }
|
|
583
609
|
body { margin: 0; background: #f9fafb; }
|
|
@@ -597,27 +623,27 @@ function _(e) {
|
|
|
597
623
|
<div class="wrb-page">
|
|
598
624
|
<div class="wrb-modal">
|
|
599
625
|
<div class="wrb-modal-header">
|
|
600
|
-
<h1 class="wrb-modal-title">${
|
|
626
|
+
<h1 class="wrb-modal-title">${r}</h1>
|
|
601
627
|
</div>
|
|
602
628
|
<div class="wrb-modal-body">
|
|
603
|
-
${e.introText ? `<p class="wrb-intro">${
|
|
604
|
-
<form method="POST" action="${
|
|
605
|
-
${
|
|
629
|
+
${e.introText ? `<p class="wrb-intro">${i(e.introText)}</p>` : ""}
|
|
630
|
+
<form method="POST" action="${t}" novalidate>
|
|
631
|
+
${M(e)}
|
|
606
632
|
<div class="wrb-actions">
|
|
607
633
|
<button type="submit" class="wrb-submit-btn">
|
|
608
|
-
${
|
|
634
|
+
${i(e.submitLabel ?? "Absenden")}
|
|
609
635
|
</button>
|
|
610
636
|
</div>
|
|
611
637
|
</form>
|
|
612
|
-
${
|
|
638
|
+
${y(e)}
|
|
613
639
|
</div>
|
|
614
640
|
</div>
|
|
615
641
|
</div>
|
|
616
642
|
</body>
|
|
617
643
|
</html>`;
|
|
618
644
|
}
|
|
619
|
-
function
|
|
620
|
-
const
|
|
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 = `
|
|
621
647
|
#wrb-modal, #wrb-success, #wrb-error { display: none; }
|
|
622
648
|
#wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
|
|
623
649
|
return `${r ? `<style>${l}
|
|
@@ -627,21 +653,21 @@ ${$}</style>` : `<style>${l}</style>`}
|
|
|
627
653
|
<div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
|
|
628
654
|
<div class="wrb-modal">
|
|
629
655
|
<div class="wrb-modal-header">
|
|
630
|
-
<h2 class="wrb-modal-title" id="wrb-modal-title">${
|
|
656
|
+
<h2 class="wrb-modal-title" id="wrb-modal-title">${t}</h2>
|
|
631
657
|
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
632
658
|
</div>
|
|
633
659
|
<div class="wrb-modal-body">
|
|
634
|
-
${e.introText ? `<p class="wrb-intro">${
|
|
635
|
-
<form method="POST" action="${
|
|
636
|
-
${
|
|
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")}
|
|
637
663
|
<div class="wrb-actions">
|
|
638
|
-
<a href="#" class="wrb-cancel-btn">${
|
|
664
|
+
<a href="#" class="wrb-cancel-btn">${i(e.cancelLabel ?? "Abbrechen")}</a>
|
|
639
665
|
<button type="submit" class="wrb-submit-btn">
|
|
640
|
-
${
|
|
666
|
+
${i(e.submitLabel ?? "Absenden")}
|
|
641
667
|
</button>
|
|
642
668
|
</div>
|
|
643
669
|
</form>
|
|
644
|
-
${
|
|
670
|
+
${y(e)}
|
|
645
671
|
</div>
|
|
646
672
|
</div>
|
|
647
673
|
</div>
|
|
@@ -662,7 +688,7 @@ ${$}</style>` : `<style>${l}</style>`}
|
|
|
662
688
|
Bestätigung per E-Mail.
|
|
663
689
|
</p>
|
|
664
690
|
</div>
|
|
665
|
-
${
|
|
691
|
+
${y(e)}
|
|
666
692
|
</div>
|
|
667
693
|
</div>
|
|
668
694
|
</div>
|
|
@@ -683,14 +709,14 @@ ${$}</style>` : `<style>${l}</style>`}
|
|
|
683
709
|
<a href="#" class="wrb-cancel-btn">Schließen</a>
|
|
684
710
|
<a href="#wrb-modal" class="wrb-submit-btn">Erneut versuchen</a>
|
|
685
711
|
</div>
|
|
686
|
-
${
|
|
712
|
+
${y(e)}
|
|
687
713
|
</div>
|
|
688
714
|
</div>
|
|
689
715
|
</div>`;
|
|
690
716
|
}
|
|
691
717
|
export {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
718
|
+
U as WiderrufsModal,
|
|
719
|
+
K as WiderrufsWidget,
|
|
720
|
+
Y as generateFallbackHtml,
|
|
721
|
+
_ as generateModalHtml
|
|
696
722
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface WiderrufsConfig {
|
|
|
15
15
|
buttonClass?: string;
|
|
16
16
|
/** Name of the company/shop shown in the modal header */
|
|
17
17
|
companyName?: string;
|
|
18
|
+
/** Sender/reply-to e-mail address for confirmation mails */
|
|
19
|
+
senderEmail?: string;
|
|
18
20
|
/** Bearer token or API key for Authorization header */
|
|
19
21
|
authToken?: string;
|
|
20
22
|
/** Label for the cancel button (default: "Abbrechen") */
|
|
@@ -35,10 +37,11 @@ export interface WiderrufsConfig {
|
|
|
35
37
|
onError?: (error: Error) => void;
|
|
36
38
|
}
|
|
37
39
|
export interface WiderrufsFormData {
|
|
38
|
-
|
|
40
|
+
firstName: string;
|
|
41
|
+
lastName: string;
|
|
39
42
|
email: string;
|
|
40
43
|
orderNumber: string;
|
|
41
44
|
reason: string;
|
|
42
|
-
|
|
45
|
+
userMessage: string;
|
|
43
46
|
}
|
|
44
47
|
export type SubmitStatus = 'idle' | 'loading' | 'success' | 'error';
|