@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/dist/index.es.js CHANGED
@@ -1,218 +1,245 @@
1
- import { jsx as r, jsxs as d, Fragment as j } from "react/jsx-runtime";
2
- import { useState as p, useRef as T, useEffect as I } from "react";
3
- import { createPortal as q } from "react-dom";
4
- async function O(e, t) {
5
- const n = {
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 && (n.Authorization = `Bearer ${e.authToken}`);
9
- const b = {
8
+ e.authToken && (t.Authorization = `Bearer ${e.authToken}`);
9
+ const o = {
10
10
  action: e.action,
11
11
  payload: {
12
- ...t,
13
- datum: (/* @__PURE__ */ new Date()).toISOString()
12
+ ...r,
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: n,
18
- body: JSON.stringify(b)
18
+ headers: t,
19
+ body: JSON.stringify(o)
19
20
  });
20
- let o;
21
+ let d;
21
22
  try {
22
- o = 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 (o !== null && typeof o == "object" && "ok" in o && o.ok === !1) {
28
- const l = o.message;
29
- throw new Error(typeof l == "string" && l ? l : `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 W = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE", {
35
- day: "2-digit",
36
- month: "2-digit",
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
- vertragId: "",
42
- widerrufsgrund: "",
43
- datum: W
39
+ orderNumber: "",
40
+ reason: "",
41
+ userMessage: ""
44
42
  };
45
- function N(e) {
46
- const t = {};
47
- return e.name.trim() || (t.name = "Bitte geben Sie Ihren Namen an."), e.email.trim() ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email) || (t.email = "Bitte geben Sie eine gültige E-Mail-Adresse an.") : t.email = "Bitte geben Sie Ihre E-Mail-Adresse an.", e.vertragId.trim() || (t.vertragId = "Bitte geben Sie die Bestellnummer oder Vertragsnummer an."), t;
48
- }
49
- function F({ config: e, onClose: t }) {
50
- const [n, b] = p(D), [i, o] = p({}), [l, m] = p({}), [h, v] = p("idle"), [E, S] = p(""), $ = T(null);
51
- I(() => {
52
- var c;
53
- (c = $.current) == null || c.focus();
54
- const a = (s) => s.key === "Escape" && t();
55
- return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
56
- }, [t]);
57
- function g(a, c) {
58
- const s = { ...n, [a]: c };
59
- if (b(s), l[a]) {
60
- const f = N(s);
61
- o((x) => ({ ...x, [a]: f[a] }));
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 k(a) {
65
- m((s) => ({ ...s, [a]: !0 }));
66
- const c = N(n);
67
- o((s) => ({ ...s, [a]: c[a] }));
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 C(a) {
70
- var f, x;
71
- a.preventDefault();
72
- const c = Object.fromEntries(
73
- Object.keys(n).map((y) => [y, !0])
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
- m(c);
76
- const s = N(n);
77
- if (o(s), !(Object.keys(s).length > 0)) {
78
- v("loading"), S("");
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, n), v("success"), (f = e.onSuccess) == null || f.call(e);
81
- } catch (y) {
82
- const z = y instanceof Error ? y : new Error("Ein unbekannter Fehler ist aufgetreten.");
83
- S(z.message), v("error"), (x = e.onError) == null || x.call(e, 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 L = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
88
- return /* @__PURE__ */ r(
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: (a) => a.target === a.currentTarget && t(),
96
- children: /* @__PURE__ */ d("div", { className: "wrb-modal", children: [
97
- /* @__PURE__ */ d("div", { className: "wrb-modal-header", children: [
98
- /* @__PURE__ */ r("h2", { className: "wrb-modal-title", id: "wrb-title", children: L }),
99
- /* @__PURE__ */ r(
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: t,
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__ */ d("div", { className: "wrb-modal-body", children: [
111
- /* @__PURE__ */ d("div", { className: "wrb-success", children: [
112
- /* @__PURE__ */ r("span", { className: "wrb-success-icon", children: "✓" }),
113
- /* @__PURE__ */ r("h3", { children: "Widerruf eingegangen" }),
114
- /* @__PURE__ */ d("p", { children: [
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__ */ r("strong", { children: n.email }),
114
+ /* @__PURE__ */ a("strong", { children: t.email }),
117
115
  "."
118
116
  ] })
119
117
  ] }),
120
- /* @__PURE__ */ r(B, { links: e.legalLinks })
121
- ] }) : /* @__PURE__ */ d("div", { className: "wrb-modal-body", children: [
122
- e.introText && /* @__PURE__ */ r("p", { className: "wrb-intro", children: e.introText }),
123
- h === "error" && E && /* @__PURE__ */ r("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: E }),
124
- /* @__PURE__ */ d("form", { onSubmit: C, noValidate: !0, children: [
125
- /* @__PURE__ */ r(
126
- w,
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: "Name",
147
+ label: "Nachname",
129
148
  required: !0,
130
- error: l.name ? i.name : void 0,
131
- children: /* @__PURE__ */ r(
149
+ error: s.lastName ? l.lastName : void 0,
150
+ children: /* @__PURE__ */ a(
132
151
  "input",
133
152
  {
134
- ref: $,
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: n.name,
139
- onChange: (a) => g("name", a.target.value),
140
- onBlur: () => k("name"),
141
- placeholder: "Vor- und Nachname"
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__ */ r(
147
- w,
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: l.email ? i.email : void 0,
153
- children: /* @__PURE__ */ r(
170
+ error: s.email ? l.email : void 0,
171
+ children: /* @__PURE__ */ a(
154
172
  "input",
155
173
  {
156
- className: `wrb-input${l.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: n.email,
160
- onChange: (a) => g("email", a.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__ */ r(
168
- w,
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: l.vertragId ? i.vertragId : void 0,
174
- children: /* @__PURE__ */ r(
191
+ error: s.orderNumber ? l.orderNumber : void 0,
192
+ children: /* @__PURE__ */ a(
175
193
  "input",
176
194
  {
177
- className: `wrb-input${l.vertragId && i.vertragId ? " wrb-error" : ""}`,
195
+ className: `wrb-input${s.orderNumber && l.orderNumber ? " wrb-error" : ""}`,
178
196
  type: "text",
179
- value: n.vertragId,
180
- onChange: (a) => g("vertragId", a.target.value),
181
- onBlur: () => k("vertragId"),
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__ */ r(
188
- w,
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__ */ r(
210
+ children: /* @__PURE__ */ a(
193
211
  "textarea",
194
212
  {
195
213
  className: "wrb-textarea",
196
- value: n.widerrufsgrund,
197
- onChange: (a) => g("widerrufsgrund", a.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__ */ r(w, { label: "Datum der Widerrufserklärung", children: /* @__PURE__ */ r("div", { className: "wrb-date-display", children: W }) }),
205
- /* @__PURE__ */ d("div", { className: "wrb-actions", children: [
206
- /* @__PURE__ */ r(
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: t,
238
+ onClick: r,
212
239
  children: e.cancelLabel ?? "Abbrechen"
213
240
  }
214
241
  ),
215
- /* @__PURE__ */ r(
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__ */ r(B, { links: e.legalLinks })
253
+ /* @__PURE__ */ a(A, { links: e.legalLinks })
227
254
  ] })
228
255
  ] })
229
256
  }
230
257
  );
231
258
  }
232
- function w({ label: e, required: t, hint: n, error: b, children: i }) {
233
- return /* @__PURE__ */ d("div", { className: "wrb-field", children: [
234
- /* @__PURE__ */ d("label", { className: "wrb-label", children: [
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
- t && /* @__PURE__ */ r("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
- n && !b && /* @__PURE__ */ r("p", { className: "wrb-hint", children: n }),
240
- b && /* @__PURE__ */ r("p", { className: "wrb-field-error", role: "alert", children: b })
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__ */ r("div", { className: "wrb-legal-links", children: e.map((t) => /* @__PURE__ */ r(
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: t.href,
274
+ href: r.href,
248
275
  className: "wrb-legal-link",
249
276
  target: "_blank",
250
277
  rel: "noopener noreferrer",
251
- children: t.name
278
+ children: r.name
252
279
  },
253
- t.href
280
+ r.href
254
281
  )) }) : null;
255
282
  }
256
- const A = `
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 M() {
513
+ function V() {
479
514
  const e = "wrb-styles";
480
515
  if (document.getElementById(e)) return;
481
- const t = document.createElement("style");
482
- t.id = e, t.textContent = A, document.head.appendChild(t);
483
- }
484
- function P({ config: e }) {
485
- const [t, n] = p(!1);
486
- return I(() => {
487
- M();
488
- }, []), /* @__PURE__ */ d(j, { children: [
489
- /* @__PURE__ */ r(
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: () => n(!0),
529
+ onClick: () => t(!0),
495
530
  children: e.buttonLabel ?? "Vertrag widerrufen"
496
531
  }
497
532
  ),
498
- t && q(
499
- /* @__PURE__ */ r(F, { config: e, onClose: () => n(!1) }),
533
+ r && F(
534
+ /* @__PURE__ */ a(U, { config: e, onClose: () => t(!1) }),
500
535
  document.body
501
536
  )
502
537
  ] });
503
538
  }
504
- function u(e) {
539
+ function i(e) {
505
540
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
506
541
  }
507
- function R(e) {
508
- var l;
509
- const t = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE", {
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((m) => `<a href="${u(m.href)}" class="wrb-legal-link" rel="noopener noreferrer">${u(m.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(`
516
547
  `)}
517
548
  </div>` : "";
518
- return `<!DOCTYPE html>
519
- <html lang="de">
520
- <head>
521
- <meta charset="UTF-8">
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
- Name <span class="wrb-required" aria-hidden="true">*</span>
555
+ Vorname <span class="wrb-required" aria-hidden="true">*</span>
551
556
  </label>
552
- <input
553
- class="wrb-input"
554
- type="text"
555
- name="name"
556
- autocomplete="name"
557
- placeholder="Vor- und Nachname"
558
- required
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
- class="wrb-input"
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
- class="wrb-input"
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">Datum der Widerrufserklärung</label>
603
- <div class="wrb-date-display">${t}</div>
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="${u(e.action)}">
607
- ${e.successUrl ? `<input type="hidden" name="successUrl" value="${u(e.successUrl)}">` : ""}
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
- ${u(e.submitLabel ?? "Absenden")}
634
+ ${i(e.submitLabel ?? "Absenden")}
611
635
  </button>
612
636
  </div>
613
637
  </form>
614
- ${o}
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
- F as WiderrufsModal,
623
- P as WiderrufsWidget,
624
- R as generateFallbackHtml
718
+ U as WiderrufsModal,
719
+ K as WiderrufsWidget,
720
+ Y as generateFallbackHtml,
721
+ _ as generateModalHtml
625
722
  };