@netlib/widerrufsbutton 2.1.5 → 2.1.6
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.cjs.js +14 -14
- package/dist/index.es.js +51 -56
- package/dist/widerrufsbutton.iife.js +9 -9
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react"),M=require("react-dom");async function q(e,a){const t={"Content-Type":"application/json"};e.authToken&&(t.Authorization=`Bearer ${e.authToken}`);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react"),M=require("react-dom");async function q(e,a){const t={"Content-Type":"application/json"};e.authToken&&(t.Authorization=`Bearer ${e.authToken}`);const o={action:e.action,payload:{...a,...e.companyName?{companyName:e.companyName}:{},...e.senderEmail?{senderEmail:e.senderEmail}:{}}},n=await fetch(e.apiUrl,{method:"PATCH",headers:t,body:JSON.stringify(o)});let d;try{d=await n.json()}catch{if(!n.ok)throw new Error(`Server antwortete mit Status ${n.status}`);return}if(d!==null&&typeof d=="object"&&"ok"in d&&d.ok===!1){const l=d.message;throw new Error(typeof l=="string"&&l?l:`Server antwortete mit Status ${n.status}`)}if(!n.ok)throw new Error(`Server antwortete mit Status ${n.status}`)}const F={firstName:"",lastName:"",email:"",orderNumber:"",reason:""};function N(e){const a={};return e.firstName.trim()||(a.firstName="Bitte geben Sie Ihren Vornamen an."),e.lastName.trim()||(a.lastName="Bitte geben Sie Ihren Nachnamen an."),e.email.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email)||(a.email="Bitte geben Sie eine gültige E-Mail-Adresse an."):a.email="Bitte geben Sie Ihre E-Mail-Adresse an.",e.orderNumber.trim()||(a.orderNumber="Bitte geben Sie die Bestellnummer oder Vertragsnummer an."),a}function B({config:e,onClose:a}){const[t,o]=c.useState(F),[n,d]=c.useState({}),[l,k]=c.useState({}),[w,y]=c.useState("idle"),[S,$]=c.useState(""),E=c.useRef(null);c.useEffect(()=>{var u;(u=E.current)==null||u.focus();const s=b=>b.key==="Escape"&&a();return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[a]);function m(s,u){const b={...t,[s]:u};if(o(b),l[s]){const x=N(b);d(f=>({...f,[s]:x[s]}))}}function h(s){k(b=>({...b,[s]:!0}));const u=N(t);d(b=>({...b,[s]:u[s]}))}async function C(s){var x,f;s.preventDefault();const u=Object.fromEntries(Object.keys(t).map(g=>[g,!0]));k(u);const b=N(t);if(d(b),!(Object.keys(b).length>0)){y("loading"),$("");try{await q(e,t),y("success"),(x=e.onSuccess)==null||x.call(e)}catch(g){const W=g instanceof Error?g:new Error("Ein unbekannter Fehler ist aufgetreten.");$(W.message),y("error"),(f=e.onError)==null||f.call(e,W)}}}const T=e.companyName?`Widerruf – ${e.companyName}`:"Widerrufsformular";return r.jsx("div",{className:"wrb-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"wrb-title",onClick:s=>s.target===s.currentTarget&&a(),children:r.jsxs("div",{className:"wrb-modal",children:[r.jsxs("div",{className:"wrb-modal-header",children:[r.jsx("h2",{className:"wrb-modal-title",id:"wrb-title",children:T}),r.jsx("button",{className:"wrb-close-btn",onClick:a,"aria-label":"Schließen",type:"button",children:"✕"})]}),w==="success"?r.jsxs("div",{className:"wrb-modal-body",children:[r.jsxs("div",{className:"wrb-success",children:[r.jsx("span",{className:"wrb-success-icon",children:"✓"}),r.jsx("h3",{children:"Widerruf eingegangen"}),r.jsxs("p",{children:["Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine Bestätigung an ",r.jsx("strong",{children:t.email}),"."]})]}),r.jsx(z,{config:e})]}):r.jsxs("div",{className:"wrb-modal-body",children:[e.introText&&r.jsx("p",{className:"wrb-intro",children:e.introText}),w==="error"&&S&&r.jsx("div",{className:"wrb-alert wrb-alert-error",role:"alert",children:S}),r.jsxs("form",{onSubmit:C,noValidate:!0,children:[r.jsx(p,{label:"Vorname",required:!0,error:l.firstName?n.firstName:void 0,children:r.jsx("input",{ref:E,className:`wrb-input${l.firstName&&n.firstName?" wrb-error":""}`,type:"text",autoComplete:"given-name",value:t.firstName,onChange:s=>m("firstName",s.target.value),onBlur:()=>h("firstName"),placeholder:"Max"})}),r.jsx(p,{label:"Nachname",required:!0,error:l.lastName?n.lastName:void 0,children:r.jsx("input",{className:`wrb-input${l.lastName&&n.lastName?" wrb-error":""}`,type:"text",autoComplete:"family-name",value:t.lastName,onChange:s=>m("lastName",s.target.value),onBlur:()=>h("lastName"),placeholder:"Mustermann"})}),r.jsx(p,{label:"E-Mail-Adresse",required:!0,hint:"Hierüber erhalten Sie die Eingangsbestätigung.",error:l.email?n.email:void 0,children:r.jsx("input",{className:`wrb-input${l.email&&n.email?" wrb-error":""}`,type:"email",autoComplete:"email",value:t.email,onChange:s=>m("email",s.target.value),onBlur:()=>h("email"),placeholder:"name@beispiel.de"})}),r.jsx(p,{label:"Bestell- / Auftrags- / Vertragsnummer",required:!0,hint:"Zu finden in Ihrer Bestellbestätigung.",error:l.orderNumber?n.orderNumber:void 0,children:r.jsx("input",{className:`wrb-input${l.orderNumber&&n.orderNumber?" wrb-error":""}`,type:"text",value:t.orderNumber,onChange:s=>m("orderNumber",s.target.value),onBlur:()=>h("orderNumber"),placeholder:"z.B. 10045678"})}),r.jsx(p,{label:"Widerrufsgrund",hint:"Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",children:r.jsx("textarea",{className:"wrb-textarea",value:t.reason,onChange:s=>m("reason",s.target.value),placeholder:"Optional",rows:2})}),r.jsxs("div",{className:"wrb-actions",children:[r.jsx("button",{type:"button",className:"wrb-cancel-btn",onClick:a,children:e.cancelLabel??"Abbrechen"}),r.jsx("button",{type:"submit",className:"wrb-submit-btn",disabled:w==="loading",children:w==="loading"?"Wird gesendet…":e.submitLabel??"Absenden"})]})]}),r.jsx(z,{config:e})]})]})})}function p({label:e,required:a,hint:t,error:o,children:n}){return r.jsxs("div",{className:"wrb-field",children:[r.jsxs("label",{className:"wrb-label",children:[e,a&&r.jsx("span",{className:"wrb-required","aria-hidden":"true",children:"*"})]}),n,t&&!o&&r.jsx("p",{className:"wrb-hint",children:t}),o&&r.jsx("p",{className:"wrb-field-error",role:"alert",children:o})]})}function z({config:e}){return e.privacyUrl?r.jsx("div",{className:"wrb-legal-links",children:r.jsx("a",{href:e.privacyUrl,className:"wrb-legal-link",target:"_blank",rel:"noopener noreferrer",children:e.privacyLabel??"Datenschutz"})}):null}const j=`
|
|
2
2
|
/* Widerrufsbutton widget — prefix: wrb- */
|
|
3
3
|
.wrb-btn {
|
|
4
4
|
display: inline-flex;
|
|
@@ -227,10 +227,10 @@
|
|
|
227
227
|
color: #374151;
|
|
228
228
|
text-decoration: underline;
|
|
229
229
|
}
|
|
230
|
-
`;function L(){const e="wrb-styles";if(document.getElementById(e))return;const a=document.createElement("style");a.id=e,a.textContent=j,document.head.appendChild(a)}function O({config:e}){const[a,t]=c.useState(!1);return c.useEffect(()=>{L()},[]),
|
|
230
|
+
`;function L(){const e="wrb-styles";if(document.getElementById(e))return;const a=document.createElement("style");a.id=e,a.textContent=j,document.head.appendChild(a)}function O({config:e}){const[a,t]=c.useState(!1);return c.useEffect(()=>{L()},[]),r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:`wrb-btn${e.buttonClass?` ${e.buttonClass}`:""}`,onClick:()=>t(!0),children:e.buttonLabel??"Vertrag widerrufen"}),a&&M.createPortal(r.jsx(B,{config:e,onClose:()=>t(!1)}),document.body)]})}function i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function v(e){if(!e.privacyUrl)return"";const a=i(e.privacyLabel??"Datenschutz");return`
|
|
231
231
|
<div class="wrb-legal-links">
|
|
232
|
-
<a href="${
|
|
233
|
-
</div>`}function A(e,a="",t=""){const i
|
|
232
|
+
<a href="${i(e.privacyUrl)}" class="wrb-legal-link" rel="noopener noreferrer">${a}</a>
|
|
233
|
+
</div>`}function A(e,a="",t=""){const o=i(e.successUrl??a),n=i(e.errorUrl??t);return`
|
|
234
234
|
<div class="wrb-field">
|
|
235
235
|
<label class="wrb-label">
|
|
236
236
|
Vorname <span class="wrb-required" aria-hidden="true">*</span>
|
|
@@ -269,9 +269,9 @@
|
|
|
269
269
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
270
270
|
</p>
|
|
271
271
|
</div>
|
|
272
|
-
<input type="hidden" name="action" value="${
|
|
273
|
-
${
|
|
274
|
-
${n?`<input type="hidden" name="errorUrl" value="${n}">`:""}`}function U(e){const a=e.companyName?`Widerruf – ${
|
|
272
|
+
<input type="hidden" name="action" value="${i(e.action)}">
|
|
273
|
+
${o?`<input type="hidden" name="successUrl" value="${o}">`:""}
|
|
274
|
+
${n?`<input type="hidden" name="errorUrl" value="${n}">`:""}`}function U(e){const a=e.companyName?`Widerruf – ${i(e.companyName)}`:"Widerrufsformular",t=i(e.formAction??e.apiUrl??"/rest/v1/apiCancellation");return`<!DOCTYPE html>
|
|
275
275
|
<html lang="de">
|
|
276
276
|
<head>
|
|
277
277
|
<meta charset="UTF-8">
|
|
@@ -299,12 +299,12 @@
|
|
|
299
299
|
<h1 class="wrb-modal-title">${a}</h1>
|
|
300
300
|
</div>
|
|
301
301
|
<div class="wrb-modal-body">
|
|
302
|
-
${e.introText?`<p class="wrb-intro">${
|
|
302
|
+
${e.introText?`<p class="wrb-intro">${i(e.introText)}</p>`:""}
|
|
303
303
|
<form method="POST" action="${t}" novalidate>
|
|
304
304
|
${A(e)}
|
|
305
305
|
<div class="wrb-actions">
|
|
306
306
|
<button type="submit" class="wrb-submit-btn">
|
|
307
|
-
${
|
|
307
|
+
${i(e.submitLabel??"Absenden")}
|
|
308
308
|
</button>
|
|
309
309
|
</div>
|
|
310
310
|
</form>
|
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
</div>
|
|
314
314
|
</div>
|
|
315
315
|
</body>
|
|
316
|
-
</html>`}function I(e,{inlineStyles:a=!0}={}){const t=e.companyName?`Widerruf – ${
|
|
316
|
+
</html>`}function I(e,{inlineStyles:a=!0}={}){const t=e.companyName?`Widerruf – ${i(e.companyName)}`:"Widerrufsformular",o=i(e.formAction??e.apiUrl??"/rest/v1/apiCancellation"),n=`
|
|
317
317
|
#wrb-modal, #wrb-success, #wrb-error { display: none; }
|
|
318
318
|
#wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;return`${a?`<style>${n}
|
|
319
319
|
${j}</style>`:`<style>${n}</style>`}
|
|
@@ -326,13 +326,13 @@ ${j}</style>`:`<style>${n}</style>`}
|
|
|
326
326
|
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
327
327
|
</div>
|
|
328
328
|
<div class="wrb-modal-body">
|
|
329
|
-
${e.introText?`<p class="wrb-intro">${
|
|
330
|
-
<form method="POST" action="${
|
|
329
|
+
${e.introText?`<p class="wrb-intro">${i(e.introText)}</p>`:""}
|
|
330
|
+
<form method="POST" action="${o}" novalidate>
|
|
331
331
|
${A(e,"#wrb-success","#wrb-error")}
|
|
332
332
|
<div class="wrb-actions">
|
|
333
|
-
<a href="#" class="wrb-cancel-btn">${
|
|
333
|
+
<a href="#" class="wrb-cancel-btn">${i(e.cancelLabel??"Abbrechen")}</a>
|
|
334
334
|
<button type="submit" class="wrb-submit-btn">
|
|
335
|
-
${
|
|
335
|
+
${i(e.submitLabel??"Absenden")}
|
|
336
336
|
</button>
|
|
337
337
|
</div>
|
|
338
338
|
</form>
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as a, jsxs as c, Fragment as q } from "react/jsx-runtime";
|
|
2
|
-
import { useState as m, useRef as
|
|
3
|
-
import { createPortal as
|
|
2
|
+
import { useState as m, useRef as F, useEffect as C } from "react";
|
|
3
|
+
import { createPortal as L } from "react-dom";
|
|
4
4
|
async function O(e, r) {
|
|
5
5
|
const t = {
|
|
6
6
|
"Content-Type": "application/json"
|
|
7
7
|
};
|
|
8
8
|
e.authToken && (t.Authorization = `Bearer ${e.authToken}`);
|
|
9
|
-
const
|
|
9
|
+
const o = {
|
|
10
10
|
action: e.action,
|
|
11
11
|
payload: {
|
|
12
12
|
...r,
|
|
@@ -16,7 +16,7 @@ async function O(e, r) {
|
|
|
16
16
|
}, i = await fetch(e.apiUrl, {
|
|
17
17
|
method: "PATCH",
|
|
18
18
|
headers: t,
|
|
19
|
-
body: JSON.stringify(
|
|
19
|
+
body: JSON.stringify(o)
|
|
20
20
|
});
|
|
21
21
|
let d;
|
|
22
22
|
try {
|
|
@@ -26,8 +26,8 @@ async function O(e, r) {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
if (d !== null && typeof d == "object" && "ok" in d && d.ok === !1) {
|
|
29
|
-
const
|
|
30
|
-
throw new Error(typeof
|
|
29
|
+
const s = d.message;
|
|
30
|
+
throw new Error(typeof s == "string" && s ? s : `Server antwortete mit Status ${i.status}`);
|
|
31
31
|
}
|
|
32
32
|
if (!i.ok)
|
|
33
33
|
throw new Error(`Server antwortete mit Status ${i.status}`);
|
|
@@ -44,22 +44,22 @@ function k(e) {
|
|
|
44
44
|
return e.firstName.trim() || (r.firstName = "Bitte geben Sie Ihren Vornamen an."), e.lastName.trim() || (r.lastName = "Bitte geben Sie Ihren Nachnamen an."), e.email.trim() ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email) || (r.email = "Bitte geben Sie eine gültige E-Mail-Adresse an.") : r.email = "Bitte geben Sie Ihre E-Mail-Adresse an.", e.orderNumber.trim() || (r.orderNumber = "Bitte geben Sie die Bestellnummer oder Vertragsnummer an."), r;
|
|
45
45
|
}
|
|
46
46
|
function I({ config: e, onClose: r }) {
|
|
47
|
-
const [t,
|
|
48
|
-
|
|
47
|
+
const [t, o] = m(U), [i, d] = m({}), [s, S] = m({}), [h, N] = m("idle"), [E, z] = m(""), W = F(null);
|
|
48
|
+
C(() => {
|
|
49
49
|
var u;
|
|
50
|
-
(u =
|
|
50
|
+
(u = W.current) == null || u.focus();
|
|
51
51
|
const n = (b) => b.key === "Escape" && r();
|
|
52
52
|
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
53
53
|
}, [r]);
|
|
54
54
|
function p(n, u) {
|
|
55
55
|
const b = { ...t, [n]: u };
|
|
56
|
-
if (
|
|
56
|
+
if (o(b), s[n]) {
|
|
57
57
|
const x = k(b);
|
|
58
58
|
d((g) => ({ ...g, [n]: x[n] }));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function f(n) {
|
|
62
|
-
|
|
62
|
+
S((b) => ({ ...b, [n]: !0 }));
|
|
63
63
|
const u = k(t);
|
|
64
64
|
d((b) => ({ ...b, [n]: u[n] }));
|
|
65
65
|
}
|
|
@@ -69,15 +69,15 @@ function I({ config: e, onClose: r }) {
|
|
|
69
69
|
const u = Object.fromEntries(
|
|
70
70
|
Object.keys(t).map((v) => [v, !0])
|
|
71
71
|
);
|
|
72
|
-
|
|
72
|
+
S(u);
|
|
73
73
|
const b = k(t);
|
|
74
74
|
if (d(b), !(Object.keys(b).length > 0)) {
|
|
75
|
-
N("loading"),
|
|
75
|
+
N("loading"), z("");
|
|
76
76
|
try {
|
|
77
77
|
await O(e, t), N("success"), (x = e.onSuccess) == null || x.call(e);
|
|
78
78
|
} catch (v) {
|
|
79
|
-
const
|
|
80
|
-
|
|
79
|
+
const B = v instanceof Error ? v : new Error("Ein unbekannter Fehler ist aufgetreten.");
|
|
80
|
+
z(B.message), N("error"), (g = e.onError) == null || g.call(e, B);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -114,22 +114,22 @@ function I({ config: e, onClose: r }) {
|
|
|
114
114
|
"."
|
|
115
115
|
] })
|
|
116
116
|
] }),
|
|
117
|
-
/* @__PURE__ */ a(
|
|
117
|
+
/* @__PURE__ */ a(A, { config: e })
|
|
118
118
|
] }) : /* @__PURE__ */ c("div", { className: "wrb-modal-body", children: [
|
|
119
119
|
e.introText && /* @__PURE__ */ a("p", { className: "wrb-intro", children: e.introText }),
|
|
120
|
-
h === "error" &&
|
|
120
|
+
h === "error" && E && /* @__PURE__ */ a("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: E }),
|
|
121
121
|
/* @__PURE__ */ c("form", { onSubmit: M, noValidate: !0, children: [
|
|
122
122
|
/* @__PURE__ */ a(
|
|
123
123
|
w,
|
|
124
124
|
{
|
|
125
125
|
label: "Vorname",
|
|
126
126
|
required: !0,
|
|
127
|
-
error:
|
|
127
|
+
error: s.firstName ? i.firstName : void 0,
|
|
128
128
|
children: /* @__PURE__ */ a(
|
|
129
129
|
"input",
|
|
130
130
|
{
|
|
131
|
-
ref:
|
|
132
|
-
className: `wrb-input${
|
|
131
|
+
ref: W,
|
|
132
|
+
className: `wrb-input${s.firstName && i.firstName ? " wrb-error" : ""}`,
|
|
133
133
|
type: "text",
|
|
134
134
|
autoComplete: "given-name",
|
|
135
135
|
value: t.firstName,
|
|
@@ -145,11 +145,11 @@ function I({ config: e, onClose: r }) {
|
|
|
145
145
|
{
|
|
146
146
|
label: "Nachname",
|
|
147
147
|
required: !0,
|
|
148
|
-
error:
|
|
148
|
+
error: s.lastName ? i.lastName : void 0,
|
|
149
149
|
children: /* @__PURE__ */ a(
|
|
150
150
|
"input",
|
|
151
151
|
{
|
|
152
|
-
className: `wrb-input${
|
|
152
|
+
className: `wrb-input${s.lastName && i.lastName ? " wrb-error" : ""}`,
|
|
153
153
|
type: "text",
|
|
154
154
|
autoComplete: "family-name",
|
|
155
155
|
value: t.lastName,
|
|
@@ -166,11 +166,11 @@ function I({ config: e, onClose: r }) {
|
|
|
166
166
|
label: "E-Mail-Adresse",
|
|
167
167
|
required: !0,
|
|
168
168
|
hint: "Hierüber erhalten Sie die Eingangsbestätigung.",
|
|
169
|
-
error:
|
|
169
|
+
error: s.email ? i.email : void 0,
|
|
170
170
|
children: /* @__PURE__ */ a(
|
|
171
171
|
"input",
|
|
172
172
|
{
|
|
173
|
-
className: `wrb-input${
|
|
173
|
+
className: `wrb-input${s.email && i.email ? " wrb-error" : ""}`,
|
|
174
174
|
type: "email",
|
|
175
175
|
autoComplete: "email",
|
|
176
176
|
value: t.email,
|
|
@@ -187,11 +187,11 @@ function I({ config: e, onClose: r }) {
|
|
|
187
187
|
label: "Bestell- / Auftrags- / Vertragsnummer",
|
|
188
188
|
required: !0,
|
|
189
189
|
hint: "Zu finden in Ihrer Bestellbestätigung.",
|
|
190
|
-
error:
|
|
190
|
+
error: s.orderNumber ? i.orderNumber : void 0,
|
|
191
191
|
children: /* @__PURE__ */ a(
|
|
192
192
|
"input",
|
|
193
193
|
{
|
|
194
|
-
className: `wrb-input${
|
|
194
|
+
className: `wrb-input${s.orderNumber && i.orderNumber ? " wrb-error" : ""}`,
|
|
195
195
|
type: "text",
|
|
196
196
|
value: t.orderNumber,
|
|
197
197
|
onChange: (n) => p("orderNumber", n.target.value),
|
|
@@ -239,24 +239,24 @@ function I({ config: e, onClose: r }) {
|
|
|
239
239
|
)
|
|
240
240
|
] })
|
|
241
241
|
] }),
|
|
242
|
-
/* @__PURE__ */ a(
|
|
242
|
+
/* @__PURE__ */ a(A, { config: e })
|
|
243
243
|
] })
|
|
244
244
|
] })
|
|
245
245
|
}
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
|
-
function w({ label: e, required: r, hint: t, error:
|
|
248
|
+
function w({ label: e, required: r, hint: t, error: o, children: i }) {
|
|
249
249
|
return /* @__PURE__ */ c("div", { className: "wrb-field", children: [
|
|
250
250
|
/* @__PURE__ */ c("label", { className: "wrb-label", children: [
|
|
251
251
|
e,
|
|
252
252
|
r && /* @__PURE__ */ a("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
253
253
|
] }),
|
|
254
254
|
i,
|
|
255
|
-
t && !
|
|
256
|
-
|
|
255
|
+
t && !o && /* @__PURE__ */ a("p", { className: "wrb-hint", children: t }),
|
|
256
|
+
o && /* @__PURE__ */ a("p", { className: "wrb-field-error", role: "alert", children: o })
|
|
257
257
|
] });
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function A({ config: e }) {
|
|
260
260
|
return e.privacyUrl ? /* @__PURE__ */ a("div", { className: "wrb-legal-links", children: /* @__PURE__ */ a(
|
|
261
261
|
"a",
|
|
262
262
|
{
|
|
@@ -268,7 +268,7 @@ function C({ config: e }) {
|
|
|
268
268
|
}
|
|
269
269
|
) }) : null;
|
|
270
270
|
}
|
|
271
|
-
const
|
|
271
|
+
const $ = `
|
|
272
272
|
/* Widerrufsbutton widget — prefix: wrb- */
|
|
273
273
|
.wrb-btn {
|
|
274
274
|
display: inline-flex;
|
|
@@ -502,17 +502,12 @@ function P() {
|
|
|
502
502
|
const e = "wrb-styles";
|
|
503
503
|
if (document.getElementById(e)) return;
|
|
504
504
|
const r = document.createElement("style");
|
|
505
|
-
r.id = e, r.textContent =
|
|
505
|
+
r.id = e, r.textContent = $, document.head.appendChild(r);
|
|
506
506
|
}
|
|
507
507
|
function R({ config: e }) {
|
|
508
508
|
const [r, t] = m(!1);
|
|
509
|
-
return
|
|
509
|
+
return C(() => {
|
|
510
510
|
P();
|
|
511
|
-
}, []), $(() => {
|
|
512
|
-
const l = () => {
|
|
513
|
-
window.location.hash === "#wrb-modal" && (history.replaceState(null, "", window.location.pathname + window.location.search), t(!0));
|
|
514
|
-
};
|
|
515
|
-
return l(), window.addEventListener("hashchange", l), () => window.removeEventListener("hashchange", l);
|
|
516
511
|
}, []), /* @__PURE__ */ c(q, { children: [
|
|
517
512
|
/* @__PURE__ */ a(
|
|
518
513
|
"button",
|
|
@@ -523,25 +518,25 @@ function R({ config: e }) {
|
|
|
523
518
|
children: e.buttonLabel ?? "Vertrag widerrufen"
|
|
524
519
|
}
|
|
525
520
|
),
|
|
526
|
-
r &&
|
|
521
|
+
r && L(
|
|
527
522
|
/* @__PURE__ */ a(I, { config: e, onClose: () => t(!1) }),
|
|
528
523
|
document.body
|
|
529
524
|
)
|
|
530
525
|
] });
|
|
531
526
|
}
|
|
532
|
-
function
|
|
527
|
+
function l(e) {
|
|
533
528
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
534
529
|
}
|
|
535
530
|
function y(e) {
|
|
536
531
|
if (!e.privacyUrl) return "";
|
|
537
|
-
const r =
|
|
532
|
+
const r = l(e.privacyLabel ?? "Datenschutz");
|
|
538
533
|
return `
|
|
539
534
|
<div class="wrb-legal-links">
|
|
540
|
-
<a href="${
|
|
535
|
+
<a href="${l(e.privacyUrl)}" class="wrb-legal-link" rel="noopener noreferrer">${r}</a>
|
|
541
536
|
</div>`;
|
|
542
537
|
}
|
|
543
538
|
function T(e, r = "", t = "") {
|
|
544
|
-
const
|
|
539
|
+
const o = l(e.successUrl ?? r), i = l(e.errorUrl ?? t);
|
|
545
540
|
return `
|
|
546
541
|
<div class="wrb-field">
|
|
547
542
|
<label class="wrb-label">
|
|
@@ -581,12 +576,12 @@ function T(e, r = "", t = "") {
|
|
|
581
576
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
582
577
|
</p>
|
|
583
578
|
</div>
|
|
584
|
-
<input type="hidden" name="action" value="${
|
|
585
|
-
${
|
|
579
|
+
<input type="hidden" name="action" value="${l(e.action)}">
|
|
580
|
+
${o ? `<input type="hidden" name="successUrl" value="${o}">` : ""}
|
|
586
581
|
${i ? `<input type="hidden" name="errorUrl" value="${i}">` : ""}`;
|
|
587
582
|
}
|
|
588
583
|
function K(e) {
|
|
589
|
-
const r = e.companyName ? `Widerruf – ${
|
|
584
|
+
const r = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", t = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation");
|
|
590
585
|
return `<!DOCTYPE html>
|
|
591
586
|
<html lang="de">
|
|
592
587
|
<head>
|
|
@@ -605,7 +600,7 @@ function K(e) {
|
|
|
605
600
|
}
|
|
606
601
|
.wrb-page .wrb-modal { max-height: none; }
|
|
607
602
|
.wrb-page .wrb-modal-title { font-size: 20px; }
|
|
608
|
-
${
|
|
603
|
+
${$}
|
|
609
604
|
</style>
|
|
610
605
|
</head>
|
|
611
606
|
<body>
|
|
@@ -615,12 +610,12 @@ function K(e) {
|
|
|
615
610
|
<h1 class="wrb-modal-title">${r}</h1>
|
|
616
611
|
</div>
|
|
617
612
|
<div class="wrb-modal-body">
|
|
618
|
-
${e.introText ? `<p class="wrb-intro">${
|
|
613
|
+
${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
|
|
619
614
|
<form method="POST" action="${t}" novalidate>
|
|
620
615
|
${T(e)}
|
|
621
616
|
<div class="wrb-actions">
|
|
622
617
|
<button type="submit" class="wrb-submit-btn">
|
|
623
|
-
${
|
|
618
|
+
${l(e.submitLabel ?? "Absenden")}
|
|
624
619
|
</button>
|
|
625
620
|
</div>
|
|
626
621
|
</form>
|
|
@@ -632,11 +627,11 @@ function K(e) {
|
|
|
632
627
|
</html>`;
|
|
633
628
|
}
|
|
634
629
|
function Y(e, { inlineStyles: r = !0 } = {}) {
|
|
635
|
-
const t = e.companyName ? `Widerruf – ${
|
|
630
|
+
const t = e.companyName ? `Widerruf – ${l(e.companyName)}` : "Widerrufsformular", o = l(e.formAction ?? e.apiUrl ?? "/rest/v1/apiCancellation"), i = `
|
|
636
631
|
#wrb-modal, #wrb-success, #wrb-error { display: none; }
|
|
637
632
|
#wrb-modal:target, #wrb-success:target, #wrb-error:target { display: flex; }`;
|
|
638
633
|
return `${r ? `<style>${i}
|
|
639
|
-
${
|
|
634
|
+
${$}</style>` : `<style>${i}</style>`}
|
|
640
635
|
|
|
641
636
|
<!-- Widerruf: Form-Modal -->
|
|
642
637
|
<div id="wrb-modal" class="wrb-overlay" role="dialog" aria-modal="true" aria-labelledby="wrb-modal-title">
|
|
@@ -646,13 +641,13 @@ ${S}</style>` : `<style>${i}</style>`}
|
|
|
646
641
|
<a href="#" class="wrb-close-btn" aria-label="Schließen">✕</a>
|
|
647
642
|
</div>
|
|
648
643
|
<div class="wrb-modal-body">
|
|
649
|
-
${e.introText ? `<p class="wrb-intro">${
|
|
650
|
-
<form method="POST" action="${
|
|
644
|
+
${e.introText ? `<p class="wrb-intro">${l(e.introText)}</p>` : ""}
|
|
645
|
+
<form method="POST" action="${o}" novalidate>
|
|
651
646
|
${T(e, "#wrb-success", "#wrb-error")}
|
|
652
647
|
<div class="wrb-actions">
|
|
653
|
-
<a href="#" class="wrb-cancel-btn">${
|
|
648
|
+
<a href="#" class="wrb-cancel-btn">${l(e.cancelLabel ?? "Abbrechen")}</a>
|
|
654
649
|
<button type="submit" class="wrb-submit-btn">
|
|
655
|
-
${
|
|
650
|
+
${l(e.submitLabel ?? "Absenden")}
|
|
656
651
|
</button>
|
|
657
652
|
</div>
|
|
658
653
|
</form>
|