@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/README.md +4 -4
- package/dist/fallback.cjs.js +389 -0
- package/dist/fallback.d.ts +21 -4
- package/dist/fallback.es.js +412 -0
- package/dist/index.cjs.js +133 -71
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +325 -228
- package/dist/styles.d.ts +1 -1
- package/dist/types.d.ts +10 -5
- package/dist/widerruf.html +27 -33
- package/dist/widerrufsbutton.iife.js +17 -9
- package/package.json +8 -3
package/dist/styles.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const WRB_CSS = "\n/* Widerrufsbutton widget \u2014 prefix: wrb- */\n.wrb-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 10px 20px;\n background: #c0392b;\n color: #fff;\n border: none;\n border-radius: 6px;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.2s;\n text-decoration: none;\n}\n.wrb-btn:hover { background: #a93226; }\n.wrb-btn:focus-visible { outline: 3px solid #e74c3c; outline-offset: 2px; }\n\n/* Overlay */\n.wrb-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0,0,0,0.55);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n padding: 16px;\n animation: wrb-fade-in 0.15s ease;\n}\n@keyframes wrb-fade-in { from { opacity: 0 } to { opacity: 1 } }\n\n/* Modal box */\n.wrb-modal {\n background: #fff;\n border-radius: 10px;\n box-shadow: 0 20px 60px rgba(0,0,0,0.3);\n width: 100%;\n max-width: 540px;\n max-height: 90vh;\n overflow-y: auto;\n animation: wrb-slide-up 0.2s ease;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 15px;\n color: #1a1a1a;\n}\n@keyframes wrb-slide-up { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }\n\n.wrb-modal-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 24px 16px;\n border-bottom: 1px solid #e5e7eb;\n gap: 12px;\n}\n.wrb-modal-title {\n margin: 0;\n font-size: 18px;\n font-weight: 700;\n color: #111;\n line-height: 1.3;\n}\n.wrb-close-btn {\n background: none;\n border: none;\n cursor: pointer;\n color: #6b7280;\n padding: 4px;\n border-radius: 4px;\n font-size: 20px;\n line-height: 1;\n flex-shrink: 0;\n}\n.wrb-close-btn:hover { color: #111; background: #f3f4f6; }\n\n.wrb-modal-body {\n padding: 20px 24px 24px;\n}\n\n.wrb-intro {\n margin: 0 0 20px;\n color: #4b5563;\n line-height: 1.6;\n font-size: 14px;\n}\n\n/* Form */\n.wrb-field {\n margin-bottom: 16px;\n}\n.wrb-label {\n display: block;\n font-size: 13px;\n font-weight: 600;\n color: #374151;\n margin-bottom: 5px;\n}\n.wrb-required {\n color: #c0392b;\n margin-left: 2px;\n}\n.wrb-input,\n.wrb-textarea {\n width: 100%;\n padding: 9px 12px;\n border: 1.5px solid #d1d5db;\n border-radius: 6px;\n font-size: 15px;\n font-family: inherit;\n color: #111;\n background: #fff;\n box-sizing: border-box;\n transition: border-color 0.15s;\n}\n.wrb-input:focus,\n.wrb-textarea:focus {\n outline: none;\n border-color: #c0392b;\n box-shadow: 0 0 0 3px rgba(192,57,43,0.12);\n}\n.wrb-input.wrb-error,\n.wrb-textarea.wrb-error {\n border-color: #c0392b;\n}\n.wrb-field-error {\n color: #c0392b;\n font-size: 12px;\n margin-top: 4px;\n}\n.wrb-textarea { resize: vertical; min-height: 80px; }\n\n.wrb-hint {\n font-size: 12px;\n color: #6b7280;\n margin-top: 4px;\n}\n\n.wrb-date-display {\n padding: 9px 12px;\n background: #f9fafb;\n border: 1.5px solid #e5e7eb;\n border-radius: 6px;\n color: #6b7280;\n font-size: 15px;\n}\n\n/* Actions */\n.wrb-actions {\n display: flex;\n gap: 10px;\n justify-content: flex-end;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n}\n.wrb-submit-btn {\n padding: 10px 22px;\n background: #c0392b;\n color: #fff;\n border: none;\n border-radius: 6px;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.2s;\n}\n.wrb-submit-btn:hover:not(:disabled) { background: #a93226; }\n.wrb-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }\n.wrb-cancel-btn {\n padding: 10px 18px;\n background: transparent;\n color: #374151;\n border: 1.5px solid #d1d5db;\n border-radius: 6px;\n font-size: 15px;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.15s;\n}\n.wrb-cancel-btn:hover { background: #f3f4f6; }\n\n/* Success / Error states */\n.wrb-success {\n text-align: center;\n padding: 32px 24px;\n}\n.wrb-success-icon { font-size: 48px; display: block; margin-bottom: 12px; }\n.wrb-success h3 { margin: 0 0 8px; font-size: 20px; color: #111; }\n.wrb-success p { margin: 0; color: #4b5563; line-height: 1.6; }\n\n.wrb-alert {\n padding: 12px 16px;\n border-radius: 6px;\n margin-bottom: 16px;\n font-size: 14px;\n}\n.wrb-alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }\n\n/* Legal links */\n.wrb-legal-links {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 16px;\n margin-top: 16px;\n padding-top: 12px;\n border-top: 1px solid #e5e7eb;\n}\n.wrb-legal-link {\n font-size: 12px;\n color: #6b7280;\n text-decoration: none;\n}\n.wrb-legal-link:hover {\n color: #374151;\n text-decoration: underline;\n}\n";
|
|
1
|
+
export declare const WRB_CSS = "\n/* Widerrufsbutton widget \u2014 prefix: wrb- */\n.wrb-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 10px 20px;\n background: #c0392b;\n color: #fff;\n border: none;\n border-radius: 6px;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.2s;\n text-decoration: none;\n}\n.wrb-btn:hover { background: #a93226; }\n.wrb-btn:focus-visible { outline: 3px solid #e74c3c; outline-offset: 2px; }\n\n/* Overlay */\n.wrb-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0,0,0,0.55);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n padding: 16px;\n animation: wrb-fade-in 0.15s ease;\n}\n@keyframes wrb-fade-in { from { opacity: 0 } to { opacity: 1 } }\n\n/* Modal box */\n.wrb-modal {\n background: #fff;\n border-radius: 10px;\n box-shadow: 0 20px 60px rgba(0,0,0,0.3);\n width: 100%;\n max-width: 540px;\n max-height: 90vh;\n overflow-y: auto;\n animation: wrb-slide-up 0.2s ease;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 15px;\n color: #1a1a1a;\n}\n@keyframes wrb-slide-up { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }\n\n.wrb-modal-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 24px 16px;\n border-bottom: 1px solid #e5e7eb;\n gap: 12px;\n}\n.wrb-modal-title {\n margin: 0;\n font-size: 18px;\n font-weight: 700;\n color: #111;\n line-height: 1.3;\n}\n.wrb-close-btn {\n background: none;\n border: none;\n cursor: pointer;\n color: #6b7280;\n padding: 4px;\n border-radius: 4px;\n font-size: 20px;\n line-height: 1;\n flex-shrink: 0;\n}\n.wrb-close-btn:hover { color: #111; background: #f3f4f6; }\n\n.wrb-modal-body {\n padding: 20px 24px 24px;\n}\n\n.wrb-intro {\n margin: 0 0 20px;\n color: #4b5563;\n line-height: 1.6;\n font-size: 14px;\n}\n\n/* Form */\n.wrb-field {\n margin-bottom: 16px;\n}\n.wrb-label {\n display: block;\n font-size: 13px;\n font-weight: 600;\n color: #374151;\n margin-bottom: 5px;\n}\n.wrb-required {\n color: #c0392b;\n margin-left: 2px;\n}\n.wrb-input,\n.wrb-textarea {\n width: 100%;\n padding: 9px 12px;\n border: 1.5px solid #d1d5db;\n border-radius: 6px;\n font-size: 15px;\n font-family: inherit;\n color: #111;\n background: #fff;\n box-sizing: border-box;\n transition: border-color 0.15s;\n}\n.wrb-input:focus,\n.wrb-textarea:focus {\n outline: none;\n border-color: #c0392b;\n box-shadow: 0 0 0 3px rgba(192,57,43,0.12);\n}\n.wrb-input.wrb-error,\n.wrb-textarea.wrb-error {\n border-color: #c0392b;\n}\n.wrb-field-error {\n color: #c0392b;\n font-size: 12px;\n margin-top: 4px;\n}\n.wrb-textarea { resize: vertical; min-height: 80px; }\n\n.wrb-hint {\n font-size: 12px;\n color: #6b7280;\n margin-top: 4px;\n}\n\n.wrb-date-display {\n padding: 9px 12px;\n background: #f9fafb;\n border: 1.5px solid #e5e7eb;\n border-radius: 6px;\n color: #6b7280;\n font-size: 15px;\n}\n\n/* Actions */\n.wrb-actions {\n display: flex;\n gap: 10px;\n justify-content: flex-end;\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid #e5e7eb;\n}\n.wrb-submit-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-decoration: none;\n padding: 10px 22px;\n background: #c0392b;\n color: #fff;\n border: none;\n border-radius: 6px;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.2s;\n}\n.wrb-submit-btn:hover:not(:disabled) { background: #a93226; }\n.wrb-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }\n.wrb-cancel-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-decoration: none;\n padding: 10px 18px;\n background: transparent;\n color: #374151;\n border: 1.5px solid #d1d5db;\n border-radius: 6px;\n font-size: 15px;\n cursor: pointer;\n font-family: inherit;\n transition: background 0.15s;\n}\n.wrb-cancel-btn:hover { background: #f3f4f6; }\n\n/* Success / Error states */\n.wrb-success {\n text-align: center;\n padding: 32px 24px;\n}\n.wrb-success-icon { font-size: 48px; display: block; margin-bottom: 12px; }\n.wrb-success h3 { margin: 0 0 8px; font-size: 20px; color: #111; }\n.wrb-success p { margin: 0; color: #4b5563; line-height: 1.6; }\n\n.wrb-alert {\n padding: 12px 16px;\n border-radius: 6px;\n margin-bottom: 16px;\n font-size: 14px;\n}\n.wrb-alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }\n\n/* Legal links */\n.wrb-legal-links {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 16px;\n margin-top: 16px;\n padding-top: 12px;\n border-top: 1px solid #e5e7eb;\n}\n.wrb-legal-link {\n font-size: 12px;\n color: #6b7280;\n text-decoration: none;\n}\n.wrb-legal-link:hover {\n color: #374151;\n text-decoration: underline;\n}\n";
|
|
2
2
|
/** Injects scoped CSS once into the document head */
|
|
3
3
|
export declare function injectStyles(): void;
|
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") */
|
|
@@ -25,18 +27,21 @@ export interface WiderrufsConfig {
|
|
|
25
27
|
legalLinks?: LegalLink[];
|
|
26
28
|
/** POST action URL for the static HTML fallback form (defaults to apiUrl) */
|
|
27
29
|
formAction?: string;
|
|
28
|
-
/** Redirect URL after successful submit
|
|
30
|
+
/** Redirect URL after successful form submit (static fallback / no-JS modal) */
|
|
29
31
|
successUrl?: string;
|
|
32
|
+
/** Redirect URL after failed form submit (static fallback / no-JS modal, defaults to #wrb-error) */
|
|
33
|
+
errorUrl?: string;
|
|
30
34
|
/** Called after a successful submit in the modal */
|
|
31
35
|
onSuccess?: () => void;
|
|
32
36
|
/** Called after a failed submit in the modal */
|
|
33
37
|
onError?: (error: Error) => void;
|
|
34
38
|
}
|
|
35
39
|
export interface WiderrufsFormData {
|
|
36
|
-
|
|
40
|
+
firstName: string;
|
|
41
|
+
lastName: string;
|
|
37
42
|
email: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
orderNumber: string;
|
|
44
|
+
reason: string;
|
|
45
|
+
userMessage: string;
|
|
41
46
|
}
|
|
42
47
|
export type SubmitStatus = 'idle' | 'loading' | 'success' | 'error';
|
package/dist/widerruf.html
CHANGED
|
@@ -176,6 +176,10 @@
|
|
|
176
176
|
border-top: 1px solid #e5e7eb;
|
|
177
177
|
}
|
|
178
178
|
.wrb-submit-btn {
|
|
179
|
+
display: inline-flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
text-decoration: none;
|
|
179
183
|
padding: 10px 22px;
|
|
180
184
|
background: #c0392b;
|
|
181
185
|
color: #fff;
|
|
@@ -190,6 +194,10 @@
|
|
|
190
194
|
.wrb-submit-btn:hover:not(:disabled) { background: #a93226; }
|
|
191
195
|
.wrb-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
192
196
|
.wrb-cancel-btn {
|
|
197
|
+
display: inline-flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: center;
|
|
200
|
+
text-decoration: none;
|
|
193
201
|
padding: 10px 18px;
|
|
194
202
|
background: transparent;
|
|
195
203
|
color: #374151;
|
|
@@ -249,31 +257,27 @@
|
|
|
249
257
|
<div class="wrb-modal-body">
|
|
250
258
|
|
|
251
259
|
<form method="POST" action="/rest/v1/apiCancellation" novalidate>
|
|
260
|
+
|
|
252
261
|
<div class="wrb-field">
|
|
253
262
|
<label class="wrb-label">
|
|
254
|
-
|
|
263
|
+
Vorname <span class="wrb-required" aria-hidden="true">*</span>
|
|
255
264
|
</label>
|
|
256
|
-
<input
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
<input class="wrb-input" type="text" name="firstName" autocomplete="given-name"
|
|
266
|
+
placeholder="Max" required>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="wrb-field">
|
|
269
|
+
<label class="wrb-label">
|
|
270
|
+
Nachname <span class="wrb-required" aria-hidden="true">*</span>
|
|
271
|
+
</label>
|
|
272
|
+
<input class="wrb-input" type="text" name="lastName" autocomplete="family-name"
|
|
273
|
+
placeholder="Mustermann" required>
|
|
264
274
|
</div>
|
|
265
275
|
<div class="wrb-field">
|
|
266
276
|
<label class="wrb-label">
|
|
267
277
|
E-Mail-Adresse <span class="wrb-required" aria-hidden="true">*</span>
|
|
268
278
|
</label>
|
|
269
|
-
<input
|
|
270
|
-
|
|
271
|
-
type="email"
|
|
272
|
-
name="email"
|
|
273
|
-
autocomplete="email"
|
|
274
|
-
placeholder="name@beispiel.de"
|
|
275
|
-
required
|
|
276
|
-
>
|
|
279
|
+
<input class="wrb-input" type="email" name="email" autocomplete="email"
|
|
280
|
+
placeholder="name@beispiel.de" required>
|
|
277
281
|
<p class="wrb-hint">Hierüber erhalten Sie die Eingangsbestätigung.</p>
|
|
278
282
|
</div>
|
|
279
283
|
<div class="wrb-field">
|
|
@@ -281,34 +285,24 @@
|
|
|
281
285
|
Bestell- / Auftrags- / Vertragsnummer
|
|
282
286
|
<span class="wrb-required" aria-hidden="true">*</span>
|
|
283
287
|
</label>
|
|
284
|
-
<input
|
|
285
|
-
|
|
286
|
-
type="text"
|
|
287
|
-
name="vertragId"
|
|
288
|
-
placeholder="z.B. 10045678"
|
|
289
|
-
required
|
|
290
|
-
>
|
|
288
|
+
<input class="wrb-input" type="text" name="orderNumber"
|
|
289
|
+
placeholder="z.B. 10045678" required>
|
|
291
290
|
<p class="wrb-hint">Zu finden in Ihrer Bestellbestätigung.</p>
|
|
292
291
|
</div>
|
|
293
292
|
<div class="wrb-field">
|
|
294
293
|
<label class="wrb-label">Widerrufsgrund</label>
|
|
295
|
-
<textarea
|
|
296
|
-
class="wrb-textarea"
|
|
297
|
-
name="widerrufsgrund"
|
|
298
|
-
placeholder="Optional"
|
|
299
|
-
rows="3"
|
|
300
|
-
></textarea>
|
|
294
|
+
<textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="2"></textarea>
|
|
301
295
|
<p class="wrb-hint">
|
|
302
296
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
303
297
|
</p>
|
|
304
298
|
</div>
|
|
305
299
|
<div class="wrb-field">
|
|
306
|
-
<label class="wrb-label">
|
|
307
|
-
<
|
|
308
|
-
<input type="hidden" name="datum" value="08.06.2026">
|
|
300
|
+
<label class="wrb-label">Nachricht</label>
|
|
301
|
+
<textarea class="wrb-textarea" name="userMessage" placeholder="Optional" rows="3"></textarea>
|
|
309
302
|
</div>
|
|
310
303
|
<input type="hidden" name="action" value="widerruf_submit">
|
|
311
304
|
|
|
305
|
+
|
|
312
306
|
<div class="wrb-actions">
|
|
313
307
|
<button type="submit" class="wrb-submit-btn">
|
|
314
308
|
Absenden
|