@netlib/widerrufsbutton 1.0.5
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/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/api.d.ts +2 -0
- package/dist/components/WiderrufsModal.d.ts +7 -0
- package/dist/components/WiderrufsWidget.d.ts +6 -0
- package/dist/index.cjs.js +203 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +459 -0
- package/dist/styles.d.ts +2 -0
- package/dist/types.d.ts +28 -0
- package/dist/widerrufsbutton.iife.js +242 -0
- package/package.json +52 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { jsx as r, jsxs as s, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as W, useEffect as E } from "react";
|
|
3
|
+
import { createPortal as A } from "react-dom";
|
|
4
|
+
async function j(e, a) {
|
|
5
|
+
const n = {
|
|
6
|
+
"Content-Type": "application/json"
|
|
7
|
+
};
|
|
8
|
+
e.authToken && (n.Authorization = `Bearer ${e.authToken}`);
|
|
9
|
+
const d = {
|
|
10
|
+
action: e.action,
|
|
11
|
+
payload: {
|
|
12
|
+
...a,
|
|
13
|
+
datum: (/* @__PURE__ */ new Date()).toISOString()
|
|
14
|
+
}
|
|
15
|
+
}, i = await fetch(e.apiUrl, {
|
|
16
|
+
method: "PATCH",
|
|
17
|
+
headers: n,
|
|
18
|
+
body: JSON.stringify(d)
|
|
19
|
+
});
|
|
20
|
+
if (!i.ok)
|
|
21
|
+
throw new Error(`Server antwortete mit Status ${i.status}`);
|
|
22
|
+
}
|
|
23
|
+
const z = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE", {
|
|
24
|
+
day: "2-digit",
|
|
25
|
+
month: "2-digit",
|
|
26
|
+
year: "numeric"
|
|
27
|
+
}), T = {
|
|
28
|
+
name: "",
|
|
29
|
+
email: "",
|
|
30
|
+
vertragId: "",
|
|
31
|
+
widerrufsgrund: "",
|
|
32
|
+
datum: z
|
|
33
|
+
};
|
|
34
|
+
function x(e) {
|
|
35
|
+
const a = {};
|
|
36
|
+
return e.name.trim() || (a.name = "Bitte geben Sie Ihren Namen 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.vertragId.trim() || (a.vertragId = "Bitte geben Sie die Bestellnummer oder Vertragsnummer an."), a;
|
|
37
|
+
}
|
|
38
|
+
function O({ config: e, onClose: a }) {
|
|
39
|
+
const [n, d] = u(T), [i, g] = u({}), [c, y] = u({}), [m, h] = u("idle"), [v, k] = u(""), N = W(null);
|
|
40
|
+
E(() => {
|
|
41
|
+
var l;
|
|
42
|
+
(l = N.current) == null || l.focus();
|
|
43
|
+
const t = (o) => o.key === "Escape" && a();
|
|
44
|
+
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
45
|
+
}, [a]);
|
|
46
|
+
function f(t, l) {
|
|
47
|
+
const o = { ...n, [t]: l };
|
|
48
|
+
if (d(o), c[t]) {
|
|
49
|
+
const b = x(o);
|
|
50
|
+
g((B) => ({ ...B, [t]: b[t] }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function w(t) {
|
|
54
|
+
y((o) => ({ ...o, [t]: !0 }));
|
|
55
|
+
const l = x(n);
|
|
56
|
+
g((o) => ({ ...o, [t]: l[t] }));
|
|
57
|
+
}
|
|
58
|
+
async function S(t) {
|
|
59
|
+
t.preventDefault();
|
|
60
|
+
const l = Object.fromEntries(
|
|
61
|
+
Object.keys(n).map((b) => [b, !0])
|
|
62
|
+
);
|
|
63
|
+
y(l);
|
|
64
|
+
const o = x(n);
|
|
65
|
+
if (g(o), !(Object.keys(o).length > 0)) {
|
|
66
|
+
h("loading"), k("");
|
|
67
|
+
try {
|
|
68
|
+
await j(e, n), h("success");
|
|
69
|
+
} catch (b) {
|
|
70
|
+
k(
|
|
71
|
+
b instanceof Error ? b.message : "Ein unbekannter Fehler ist aufgetreten."
|
|
72
|
+
), h("error");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const I = e.companyName ? `Widerruf – ${e.companyName}` : "Widerrufsformular";
|
|
77
|
+
return /* @__PURE__ */ r(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: "wrb-overlay",
|
|
81
|
+
role: "dialog",
|
|
82
|
+
"aria-modal": "true",
|
|
83
|
+
"aria-labelledby": "wrb-title",
|
|
84
|
+
onClick: (t) => t.target === t.currentTarget && a(),
|
|
85
|
+
children: /* @__PURE__ */ s("div", { className: "wrb-modal", children: [
|
|
86
|
+
/* @__PURE__ */ s("div", { className: "wrb-modal-header", children: [
|
|
87
|
+
/* @__PURE__ */ r("h2", { className: "wrb-modal-title", id: "wrb-title", children: I }),
|
|
88
|
+
/* @__PURE__ */ r(
|
|
89
|
+
"button",
|
|
90
|
+
{
|
|
91
|
+
className: "wrb-close-btn",
|
|
92
|
+
onClick: a,
|
|
93
|
+
"aria-label": "Schließen",
|
|
94
|
+
type: "button",
|
|
95
|
+
children: "✕"
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }),
|
|
99
|
+
m === "success" ? /* @__PURE__ */ s("div", { className: "wrb-success", children: [
|
|
100
|
+
/* @__PURE__ */ r("span", { className: "wrb-success-icon", children: "✓" }),
|
|
101
|
+
/* @__PURE__ */ r("h3", { children: "Widerruf eingegangen" }),
|
|
102
|
+
/* @__PURE__ */ s("p", { children: [
|
|
103
|
+
"Ihr Widerruf wurde erfolgreich übermittelt. Sie erhalten in Kürze eine Bestätigung an ",
|
|
104
|
+
/* @__PURE__ */ r("strong", { children: n.email }),
|
|
105
|
+
"."
|
|
106
|
+
] })
|
|
107
|
+
] }) : /* @__PURE__ */ s("div", { className: "wrb-modal-body", children: [
|
|
108
|
+
e.introText && /* @__PURE__ */ r("p", { className: "wrb-intro", children: e.introText }),
|
|
109
|
+
m === "error" && v && /* @__PURE__ */ r("div", { className: "wrb-alert wrb-alert-error", role: "alert", children: v }),
|
|
110
|
+
/* @__PURE__ */ s("form", { onSubmit: S, noValidate: !0, children: [
|
|
111
|
+
/* @__PURE__ */ r(
|
|
112
|
+
p,
|
|
113
|
+
{
|
|
114
|
+
label: "Name",
|
|
115
|
+
required: !0,
|
|
116
|
+
error: c.name ? i.name : void 0,
|
|
117
|
+
children: /* @__PURE__ */ r(
|
|
118
|
+
"input",
|
|
119
|
+
{
|
|
120
|
+
ref: N,
|
|
121
|
+
className: `wrb-input${c.name && i.name ? " wrb-error" : ""}`,
|
|
122
|
+
type: "text",
|
|
123
|
+
autoComplete: "name",
|
|
124
|
+
value: n.name,
|
|
125
|
+
onChange: (t) => f("name", t.target.value),
|
|
126
|
+
onBlur: () => w("name"),
|
|
127
|
+
placeholder: "Vor- und Nachname"
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ r(
|
|
133
|
+
p,
|
|
134
|
+
{
|
|
135
|
+
label: "E-Mail-Adresse",
|
|
136
|
+
required: !0,
|
|
137
|
+
hint: "Hierüber erhalten Sie die Eingangsbestätigung.",
|
|
138
|
+
error: c.email ? i.email : void 0,
|
|
139
|
+
children: /* @__PURE__ */ r(
|
|
140
|
+
"input",
|
|
141
|
+
{
|
|
142
|
+
className: `wrb-input${c.email && i.email ? " wrb-error" : ""}`,
|
|
143
|
+
type: "email",
|
|
144
|
+
autoComplete: "email",
|
|
145
|
+
value: n.email,
|
|
146
|
+
onChange: (t) => f("email", t.target.value),
|
|
147
|
+
onBlur: () => w("email"),
|
|
148
|
+
placeholder: "name@beispiel.de"
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ r(
|
|
154
|
+
p,
|
|
155
|
+
{
|
|
156
|
+
label: "Bestell- / Auftrags- / Vertragsnummer",
|
|
157
|
+
required: !0,
|
|
158
|
+
hint: "Zu finden in Ihrer Bestellbestätigung.",
|
|
159
|
+
error: c.vertragId ? i.vertragId : void 0,
|
|
160
|
+
children: /* @__PURE__ */ r(
|
|
161
|
+
"input",
|
|
162
|
+
{
|
|
163
|
+
className: `wrb-input${c.vertragId && i.vertragId ? " wrb-error" : ""}`,
|
|
164
|
+
type: "text",
|
|
165
|
+
value: n.vertragId,
|
|
166
|
+
onChange: (t) => f("vertragId", t.target.value),
|
|
167
|
+
onBlur: () => w("vertragId"),
|
|
168
|
+
placeholder: "z.B. 10045678"
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
/* @__PURE__ */ r(
|
|
174
|
+
p,
|
|
175
|
+
{
|
|
176
|
+
label: "Widerrufsgrund",
|
|
177
|
+
hint: "Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.",
|
|
178
|
+
children: /* @__PURE__ */ r(
|
|
179
|
+
"textarea",
|
|
180
|
+
{
|
|
181
|
+
className: "wrb-textarea",
|
|
182
|
+
value: n.widerrufsgrund,
|
|
183
|
+
onChange: (t) => f("widerrufsgrund", t.target.value),
|
|
184
|
+
placeholder: "Optional",
|
|
185
|
+
rows: 3
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
/* @__PURE__ */ r(p, { label: "Datum der Widerrufserklärung", children: /* @__PURE__ */ r("div", { className: "wrb-date-display", children: z }) }),
|
|
191
|
+
/* @__PURE__ */ s("div", { className: "wrb-actions", children: [
|
|
192
|
+
/* @__PURE__ */ r(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
type: "button",
|
|
196
|
+
className: "wrb-cancel-btn",
|
|
197
|
+
onClick: a,
|
|
198
|
+
children: e.cancelLabel ?? "Abbrechen"
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ r(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
type: "submit",
|
|
205
|
+
className: "wrb-submit-btn",
|
|
206
|
+
disabled: m === "loading",
|
|
207
|
+
children: m === "loading" ? "Wird gesendet…" : e.submitLabel ?? "Absenden"
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
] })
|
|
211
|
+
] })
|
|
212
|
+
] })
|
|
213
|
+
] })
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function p({ label: e, required: a, hint: n, error: d, children: i }) {
|
|
218
|
+
return /* @__PURE__ */ s("div", { className: "wrb-field", children: [
|
|
219
|
+
/* @__PURE__ */ s("label", { className: "wrb-label", children: [
|
|
220
|
+
e,
|
|
221
|
+
a && /* @__PURE__ */ r("span", { className: "wrb-required", "aria-hidden": "true", children: "*" })
|
|
222
|
+
] }),
|
|
223
|
+
i,
|
|
224
|
+
n && !d && /* @__PURE__ */ r("p", { className: "wrb-hint", children: n }),
|
|
225
|
+
d && /* @__PURE__ */ r("p", { className: "wrb-field-error", role: "alert", children: d })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
function $() {
|
|
229
|
+
const e = "wrb-styles";
|
|
230
|
+
if (document.getElementById(e)) return;
|
|
231
|
+
const a = `
|
|
232
|
+
/* Widerrufsbutton widget — prefix: wrb- */
|
|
233
|
+
.wrb-btn {
|
|
234
|
+
display: inline-flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
gap: 6px;
|
|
237
|
+
padding: 10px 20px;
|
|
238
|
+
background: #c0392b;
|
|
239
|
+
color: #fff;
|
|
240
|
+
border: none;
|
|
241
|
+
border-radius: 6px;
|
|
242
|
+
font-size: 15px;
|
|
243
|
+
font-weight: 600;
|
|
244
|
+
cursor: pointer;
|
|
245
|
+
font-family: inherit;
|
|
246
|
+
transition: background 0.2s;
|
|
247
|
+
text-decoration: none;
|
|
248
|
+
}
|
|
249
|
+
.wrb-btn:hover { background: #a93226; }
|
|
250
|
+
.wrb-btn:focus-visible { outline: 3px solid #e74c3c; outline-offset: 2px; }
|
|
251
|
+
|
|
252
|
+
/* Overlay */
|
|
253
|
+
.wrb-overlay {
|
|
254
|
+
position: fixed;
|
|
255
|
+
inset: 0;
|
|
256
|
+
background: rgba(0,0,0,0.55);
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
z-index: 99999;
|
|
261
|
+
padding: 16px;
|
|
262
|
+
animation: wrb-fade-in 0.15s ease;
|
|
263
|
+
}
|
|
264
|
+
@keyframes wrb-fade-in { from { opacity: 0 } to { opacity: 1 } }
|
|
265
|
+
|
|
266
|
+
/* Modal box */
|
|
267
|
+
.wrb-modal {
|
|
268
|
+
background: #fff;
|
|
269
|
+
border-radius: 10px;
|
|
270
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
271
|
+
width: 100%;
|
|
272
|
+
max-width: 540px;
|
|
273
|
+
max-height: 90vh;
|
|
274
|
+
overflow-y: auto;
|
|
275
|
+
animation: wrb-slide-up 0.2s ease;
|
|
276
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
277
|
+
font-size: 15px;
|
|
278
|
+
color: #1a1a1a;
|
|
279
|
+
}
|
|
280
|
+
@keyframes wrb-slide-up { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }
|
|
281
|
+
|
|
282
|
+
.wrb-modal-header {
|
|
283
|
+
display: flex;
|
|
284
|
+
align-items: flex-start;
|
|
285
|
+
justify-content: space-between;
|
|
286
|
+
padding: 20px 24px 16px;
|
|
287
|
+
border-bottom: 1px solid #e5e7eb;
|
|
288
|
+
gap: 12px;
|
|
289
|
+
}
|
|
290
|
+
.wrb-modal-title {
|
|
291
|
+
margin: 0;
|
|
292
|
+
font-size: 18px;
|
|
293
|
+
font-weight: 700;
|
|
294
|
+
color: #111;
|
|
295
|
+
line-height: 1.3;
|
|
296
|
+
}
|
|
297
|
+
.wrb-close-btn {
|
|
298
|
+
background: none;
|
|
299
|
+
border: none;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
color: #6b7280;
|
|
302
|
+
padding: 4px;
|
|
303
|
+
border-radius: 4px;
|
|
304
|
+
font-size: 20px;
|
|
305
|
+
line-height: 1;
|
|
306
|
+
flex-shrink: 0;
|
|
307
|
+
}
|
|
308
|
+
.wrb-close-btn:hover { color: #111; background: #f3f4f6; }
|
|
309
|
+
|
|
310
|
+
.wrb-modal-body {
|
|
311
|
+
padding: 20px 24px 24px;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.wrb-intro {
|
|
315
|
+
margin: 0 0 20px;
|
|
316
|
+
color: #4b5563;
|
|
317
|
+
line-height: 1.6;
|
|
318
|
+
font-size: 14px;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/* Form */
|
|
322
|
+
.wrb-field {
|
|
323
|
+
margin-bottom: 16px;
|
|
324
|
+
}
|
|
325
|
+
.wrb-label {
|
|
326
|
+
display: block;
|
|
327
|
+
font-size: 13px;
|
|
328
|
+
font-weight: 600;
|
|
329
|
+
color: #374151;
|
|
330
|
+
margin-bottom: 5px;
|
|
331
|
+
}
|
|
332
|
+
.wrb-required {
|
|
333
|
+
color: #c0392b;
|
|
334
|
+
margin-left: 2px;
|
|
335
|
+
}
|
|
336
|
+
.wrb-input,
|
|
337
|
+
.wrb-textarea {
|
|
338
|
+
width: 100%;
|
|
339
|
+
padding: 9px 12px;
|
|
340
|
+
border: 1.5px solid #d1d5db;
|
|
341
|
+
border-radius: 6px;
|
|
342
|
+
font-size: 15px;
|
|
343
|
+
font-family: inherit;
|
|
344
|
+
color: #111;
|
|
345
|
+
background: #fff;
|
|
346
|
+
box-sizing: border-box;
|
|
347
|
+
transition: border-color 0.15s;
|
|
348
|
+
}
|
|
349
|
+
.wrb-input:focus,
|
|
350
|
+
.wrb-textarea:focus {
|
|
351
|
+
outline: none;
|
|
352
|
+
border-color: #c0392b;
|
|
353
|
+
box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
|
|
354
|
+
}
|
|
355
|
+
.wrb-input.wrb-error,
|
|
356
|
+
.wrb-textarea.wrb-error {
|
|
357
|
+
border-color: #c0392b;
|
|
358
|
+
}
|
|
359
|
+
.wrb-field-error {
|
|
360
|
+
color: #c0392b;
|
|
361
|
+
font-size: 12px;
|
|
362
|
+
margin-top: 4px;
|
|
363
|
+
}
|
|
364
|
+
.wrb-textarea { resize: vertical; min-height: 80px; }
|
|
365
|
+
|
|
366
|
+
.wrb-hint {
|
|
367
|
+
font-size: 12px;
|
|
368
|
+
color: #6b7280;
|
|
369
|
+
margin-top: 4px;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.wrb-date-display {
|
|
373
|
+
padding: 9px 12px;
|
|
374
|
+
background: #f9fafb;
|
|
375
|
+
border: 1.5px solid #e5e7eb;
|
|
376
|
+
border-radius: 6px;
|
|
377
|
+
color: #6b7280;
|
|
378
|
+
font-size: 15px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* Actions */
|
|
382
|
+
.wrb-actions {
|
|
383
|
+
display: flex;
|
|
384
|
+
gap: 10px;
|
|
385
|
+
justify-content: flex-end;
|
|
386
|
+
margin-top: 24px;
|
|
387
|
+
padding-top: 16px;
|
|
388
|
+
border-top: 1px solid #e5e7eb;
|
|
389
|
+
}
|
|
390
|
+
.wrb-submit-btn {
|
|
391
|
+
padding: 10px 22px;
|
|
392
|
+
background: #c0392b;
|
|
393
|
+
color: #fff;
|
|
394
|
+
border: none;
|
|
395
|
+
border-radius: 6px;
|
|
396
|
+
font-size: 15px;
|
|
397
|
+
font-weight: 600;
|
|
398
|
+
cursor: pointer;
|
|
399
|
+
font-family: inherit;
|
|
400
|
+
transition: background 0.2s;
|
|
401
|
+
}
|
|
402
|
+
.wrb-submit-btn:hover:not(:disabled) { background: #a93226; }
|
|
403
|
+
.wrb-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
404
|
+
.wrb-cancel-btn {
|
|
405
|
+
padding: 10px 18px;
|
|
406
|
+
background: transparent;
|
|
407
|
+
color: #374151;
|
|
408
|
+
border: 1.5px solid #d1d5db;
|
|
409
|
+
border-radius: 6px;
|
|
410
|
+
font-size: 15px;
|
|
411
|
+
cursor: pointer;
|
|
412
|
+
font-family: inherit;
|
|
413
|
+
transition: background 0.15s;
|
|
414
|
+
}
|
|
415
|
+
.wrb-cancel-btn:hover { background: #f3f4f6; }
|
|
416
|
+
|
|
417
|
+
/* Success / Error states */
|
|
418
|
+
.wrb-success {
|
|
419
|
+
text-align: center;
|
|
420
|
+
padding: 32px 24px;
|
|
421
|
+
}
|
|
422
|
+
.wrb-success-icon { font-size: 48px; display: block; margin-bottom: 12px; }
|
|
423
|
+
.wrb-success h3 { margin: 0 0 8px; font-size: 20px; color: #111; }
|
|
424
|
+
.wrb-success p { margin: 0; color: #4b5563; line-height: 1.6; }
|
|
425
|
+
|
|
426
|
+
.wrb-alert {
|
|
427
|
+
padding: 12px 16px;
|
|
428
|
+
border-radius: 6px;
|
|
429
|
+
margin-bottom: 16px;
|
|
430
|
+
font-size: 14px;
|
|
431
|
+
}
|
|
432
|
+
.wrb-alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
|
|
433
|
+
`, n = document.createElement("style");
|
|
434
|
+
n.id = e, n.textContent = a, document.head.appendChild(n);
|
|
435
|
+
}
|
|
436
|
+
function L({ config: e }) {
|
|
437
|
+
const [a, n] = u(!1);
|
|
438
|
+
return E(() => {
|
|
439
|
+
$();
|
|
440
|
+
}, []), /* @__PURE__ */ s(C, { children: [
|
|
441
|
+
/* @__PURE__ */ r(
|
|
442
|
+
"button",
|
|
443
|
+
{
|
|
444
|
+
type: "button",
|
|
445
|
+
className: `wrb-btn${e.buttonClass ? ` ${e.buttonClass}` : ""}`,
|
|
446
|
+
onClick: () => n(!0),
|
|
447
|
+
children: e.buttonLabel ?? "Vertrag widerrufen"
|
|
448
|
+
}
|
|
449
|
+
),
|
|
450
|
+
a && A(
|
|
451
|
+
/* @__PURE__ */ r(O, { config: e, onClose: () => n(!1) }),
|
|
452
|
+
document.body
|
|
453
|
+
)
|
|
454
|
+
] });
|
|
455
|
+
}
|
|
456
|
+
export {
|
|
457
|
+
O as WiderrufsModal,
|
|
458
|
+
L as WiderrufsWidget
|
|
459
|
+
};
|
package/dist/styles.d.ts
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WiderrufsConfig {
|
|
2
|
+
/** PATCH endpoint, e.g. /rest/v1/systemLog */
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
/** action name sent as {"action": "..."} */
|
|
5
|
+
action: string;
|
|
6
|
+
/** Introductory text shown at the top of the modal */
|
|
7
|
+
introText?: string;
|
|
8
|
+
/** Label for the trigger button (default: "Vertrag widerrufen") */
|
|
9
|
+
buttonLabel?: string;
|
|
10
|
+
/** CSS classes appended to the trigger button */
|
|
11
|
+
buttonClass?: string;
|
|
12
|
+
/** Name of the company/shop shown in the modal header */
|
|
13
|
+
companyName?: string;
|
|
14
|
+
/** Bearer token or API key for Authorization header */
|
|
15
|
+
authToken?: string;
|
|
16
|
+
/** Label for the cancel button (default: "Abbrechen") */
|
|
17
|
+
cancelLabel?: string;
|
|
18
|
+
/** Label for the submit button (default: "Widerruf bestätigen") */
|
|
19
|
+
submitLabel?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface WiderrufsFormData {
|
|
22
|
+
name: string;
|
|
23
|
+
email: string;
|
|
24
|
+
vertragId: string;
|
|
25
|
+
widerrufsgrund: string;
|
|
26
|
+
datum: string;
|
|
27
|
+
}
|
|
28
|
+
export type SubmitStatus = 'idle' | 'loading' | 'success' | 'error';
|