@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/index.es.js CHANGED
@@ -1,91 +1,89 @@
1
- import { jsx as t, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
- import { useState as m, useRef as q, useEffect as T } from "react";
3
- import { createPortal as D } from "react-dom";
4
- async function I(e, r) {
5
- const a = {
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 && (a.Authorization = `Bearer ${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
- datum: (/* @__PURE__ */ new Date()).toISOString()
13
+ ...e.companyName ? { companyName: e.companyName } : {},
14
+ ...e.senderEmail ? { senderEmail: e.senderEmail } : {}
14
15
  }
15
- }, i = await fetch(e.apiUrl, {
16
+ }, l = await fetch(e.apiUrl, {
16
17
  method: "PATCH",
17
- headers: a,
18
+ headers: t,
18
19
  body: JSON.stringify(o)
19
20
  });
20
- let l;
21
+ let d;
21
22
  try {
22
- l = await i.json();
23
+ d = await l.json();
23
24
  } catch {
24
- if (!i.ok) throw new Error(`Server antwortete mit Status ${i.status}`);
25
+ if (!l.ok) throw new Error(`Server antwortete mit Status ${l.status}`);
25
26
  return;
26
27
  }
27
- if (l !== null && typeof l == "object" && "ok" in l && l.ok === !1) {
28
- const d = l.message;
29
- throw new Error(typeof d == "string" && d ? d : `Server antwortete mit Status ${i.status}`);
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 (!i.ok)
32
- throw new Error(`Server antwortete mit Status ${i.status}`);
33
- }
34
- const C = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE", {
35
- day: "2-digit",
36
- month: "2-digit",
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
- datum: C
41
+ userMessage: ""
44
42
  };
45
- function N(e) {
43
+ function k(e) {
46
44
  const r = {};
47
- return e.name.trim() || (r.name = "Bitte geben Sie Ihren Namen 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
+ 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 V({ config: e, onClose: r }) {
50
- const [a, o] = m(U), [i, l] = m({}), [d, S] = m({}), [w, y] = m("idle"), [E, z] = m(""), W = q(null);
51
- T(() => {
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 h(n, u) {
58
- const b = { ...a, [n]: u };
59
- if (o(b), d[n]) {
60
- const f = N(b);
61
- l((g) => ({ ...g, [n]: f[n] }));
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 k(n) {
62
+ function f(n) {
65
63
  S((b) => ({ ...b, [n]: !0 }));
66
- const u = N(a);
67
- l((b) => ({ ...b, [n]: u[n] }));
64
+ const u = k(t);
65
+ d((b) => ({ ...b, [n]: u[n] }));
68
66
  }
69
- async function F(n) {
70
- var f, g;
67
+ async function T(n) {
68
+ var g, x;
71
69
  n.preventDefault();
72
70
  const u = Object.fromEntries(
73
- Object.keys(a).map((x) => [x, !0])
71
+ Object.keys(t).map((v) => [v, !0])
74
72
  );
75
73
  S(u);
76
- const b = N(a);
77
- if (l(b), !(Object.keys(b).length > 0)) {
78
- y("loading"), z("");
74
+ const b = k(t);
75
+ if (d(b), !(Object.keys(b).length > 0)) {
76
+ N("loading"), z("");
79
77
  try {
80
- await I(e, a), y("success"), (f = e.onSuccess) == null || f.call(e);
81
- } catch (x) {
82
- const A = x instanceof Error ? x : new Error("Ein unbekannter Fehler ist aufgetreten.");
83
- z(A.message), y("error"), (g = e.onError) == null || g.call(e, A);
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 M = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
88
- return /* @__PURE__ */ t(
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__ */ t("h2", { className: "wrb-modal-title", id: "wrb-title", children: M }),
99
- /* @__PURE__ */ t(
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
- w === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
108
+ h === "success" ? /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
111
109
  /* @__PURE__ */ c("div", { className: "wrb-success", children: [
112
- /* @__PURE__ */ t("span", { className: "wrb-success-icon", children: "✓" }),
113
- /* @__PURE__ */ t("h3", { children: "Widerruf eingegangen" }),
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__ */ t("strong", { children: a.email }),
114
+ /* @__PURE__ */ a("strong", { children: t.email }),
117
115
  "."
118
116
  ] })
119
117
  ] }),
120
- /* @__PURE__ */ t(B, { links: e.legalLinks })
118
+ /* @__PURE__ */ a(A, { links: e.legalLinks })
121
119
  ] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
122
- e.introText && /* @__PURE__ */ t("p", { className: "wrb-intro", children: e.introText }),
123
- w === "error" && E && /* @__PURE__ */ t("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: E }),
124
- /* @__PURE__ */ c("form", { onSubmit: F, noValidate: !0, children: [
125
- /* @__PURE__ */ t(
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: "Name",
126
+ label: "Vorname",
129
127
  required: !0,
130
- error: d.name ? i.name : void 0,
131
- children: /* @__PURE__ */ t(
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${d.name && i.name ? " wrb-error" : ""}`,
133
+ className: `wrb-input${s.firstName && l.firstName ? " wrb-error" : ""}`,
136
134
  type: "text",
137
- autoComplete: "name",
138
- value: a.name,
139
- onChange: (n) => h("name", n.target.value),
140
- onBlur: () => k("name"),
141
- placeholder: "Vor- und Nachname"
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__ */ t(
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: d.email ? i.email : void 0,
153
- children: /* @__PURE__ */ t(
170
+ error: s.email ? l.email : void 0,
171
+ children: /* @__PURE__ */ a(
154
172
  "input",
155
173
  {
156
- className: `wrb-input${d.email && i.email ? " wrb-error" : ""}`,
174
+ className: `wrb-input${s.email && l.email ? " wrb-error" : ""}`,
157
175
  type: "email",
158
176
  autoComplete: "email",
159
- value: a.email,
160
- onChange: (n) => h("email", n.target.value),
161
- onBlur: () => k("email"),
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__ */ t(
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: d.orderNumber ? i.orderNumber : void 0,
174
- children: /* @__PURE__ */ t(
191
+ error: s.orderNumber ? l.orderNumber : void 0,
192
+ children: /* @__PURE__ */ a(
175
193
  "input",
176
194
  {
177
- className: `wrb-input${d.orderNumber && i.orderNumber ? " wrb-error" : ""}`,
195
+ className: `wrb-input${s.orderNumber && l.orderNumber ? " wrb-error" : ""}`,
178
196
  type: "text",
179
- value: a.orderNumber,
180
- onChange: (n) => h("orderNumber", n.target.value),
181
- onBlur: () => k("orderNumber"),
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__ */ t(
205
+ /* @__PURE__ */ a(
188
206
  p,
189
207
  {
190
- label: "reason",
208
+ label: "Widerrufsgrund",
191
209
  hint: "Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",
192
- children: /* @__PURE__ */ t(
210
+ children: /* @__PURE__ */ a(
193
211
  "textarea",
194
212
  {
195
213
  className: "wrb-textarea",
196
- value: a.reason,
197
- onChange: (n) => h("reason", n.target.value),
214
+ value: t.reason,
215
+ onChange: (n) => m("reason", n.target.value),
198
216
  placeholder: "Optional",
199
- rows: 3
217
+ rows: 2
200
218
  }
201
219
  )
202
220
  }
203
221
  ),
204
- /* @__PURE__ */ t(p, { label: "Datum der Widerrufserklärung", children: /* @__PURE__ */ t("div", { className: "wrb-date-display", children: C }) }),
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__ */ t(
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__ */ t(
242
+ /* @__PURE__ */ a(
216
243
  "button",
217
244
  {
218
245
  type: "submit",
219
246
  className: "wrb-submit-btn",
220
- disabled: w === "loading",
221
- children: w === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
247
+ disabled: h === "loading",
248
+ children: h === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
222
249
  }
223
250
  )
224
251
  ] })
225
252
  ] }),
226
- /* @__PURE__ */ t(B, { links: e.legalLinks })
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: a, error: o, children: i }) {
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__ */ t("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
263
+ r && /* @__PURE__ */ a("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
237
264
  ] }),
238
- i,
239
- a && !o && /* @__PURE__ */ t("p", { className: "wrb-hint", children: a }),
240
- o && /* @__PURE__ */ t("p", { className: "wrb-field-error", role: "alert", children: o })
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 B({ links: e }) {
244
- return e != null && e.length ? /* @__PURE__ */ t("div", { className: "wrb-legal-links", children: e.map((r) => /* @__PURE__ */ t(
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 P() {
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 Y({ config: e }) {
493
- const [r, a] = m(!1);
494
- return T(() => {
495
- P();
496
- }, []), /* @__PURE__ */ c(O, { children: [
497
- /* @__PURE__ */ t(
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: () => a(!0),
529
+ onClick: () => t(!0),
503
530
  children: e.buttonLabel ?? "Vertrag widerrufen"
504
531
  }
505
532
  ),
506
- r && D(
507
- /* @__PURE__ */ t(V, { config: e, onClose: () => a(!1) }),
533
+ r && F(
534
+ /* @__PURE__ */ a(U, { config: e, onClose: () => t(!1) }),
508
535
  document.body
509
536
  )
510
537
  ] });
511
538
  }
512
- function s(e) {
539
+ function i(e) {
513
540
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
514
541
  }
515
- function L() {
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((a) => `<a href="${s(a.href)}" class="wrb-legal-link" rel="noopener noreferrer">${s(a.name)}</a>`).join(`
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 j(e, r, a = "", o = "") {
531
- const i = s(e.successUrl ?? a), l = s(e.errorUrl ?? o);
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
- Name <span class="wrb-required" aria-hidden="true">*</span>
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="name" autocomplete="name"
538
- placeholder="Vor- und Nachname" required>
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">reason</label>
559
- <textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="3"></textarea>
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">Datum der Widerrufserklärung</label>
566
- <div class="wrb-date-display">${r}</div>
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="${s(e.action)}">
570
- ${i ? `<input type="hidden" name="successUrl" value="${i}">` : ""}
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 _(e) {
574
- const r = L(), a = e.companyName ? `Widerruf – ${s(e.companyName)}` : "Widerrufsformular", o = s(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
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>${a}</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">${a}</h1>
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">${s(e.introText)}</p>` : ""}
604
- <form method="POST" action="${o}" novalidate>
605
- ${j(e, r)}
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
- ${s(e.submitLabel ?? "Absenden")}
634
+ ${i(e.submitLabel ?? "Absenden")}
609
635
  </button>
610
636
  </div>
611
637
  </form>
612
- ${v(e)}
638
+ ${y(e)}
613
639
  </div>
614
640
  </div>
615
641
  </div>
616
642
  </body>
617
643
  </html>`;
618
644
  }
619
- function G(e, { inlineStyles: r = !0 } = {}) {
620
- const a = L(), o = e.companyName ? `Widerruf – ${s(e.companyName)}` : "Widerrufsformular", i = s(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), l = `
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">${o}</h2>
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">${s(e.introText)}</p>` : ""}
635
- <form method="POST" action="${i}" novalidate>
636
- ${j(e, a, "#wrb-success", "#wrb-error")}
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">${s(e.cancelLabel ?? "Abbrechen")}</a>
664
+ <a href="#" class="wrb-cancel-btn">${i(e.cancelLabel ?? "Abbrechen")}</a>
639
665
  <button type="submit" class="wrb-submit-btn">
640
- ${s(e.submitLabel ?? "Absenden")}
666
+ ${i(e.submitLabel ?? "Absenden")}
641
667
  </button>
642
668
  </div>
643
669
  </form>
644
- ${v(e)}
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
- ${v(e)}
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
- ${v(e)}
712
+ ${y(e)}
687
713
  </div>
688
714
  </div>
689
715
  </div>`;
690
716
  }
691
717
  export {
692
- V as WiderrufsModal,
693
- Y as WiderrufsWidget,
694
- _ as generateFallbackHtml,
695
- G as generateModalHtml
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
- name: string;
40
+ firstName: string;
41
+ lastName: string;
39
42
  email: string;
40
43
  orderNumber: string;
41
44
  reason: string;
42
- datum: string;
45
+ userMessage: string;
43
46
  }
44
47
  export type SubmitStatus = 'idle' | 'loading' | 'success' | 'error';