@netlib/widerrufsbutton 1.1.1 → 1.2.0
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 +383 -0
- package/dist/fallback.d.ts +21 -4
- package/dist/fallback.es.js +413 -0
- package/dist/index.cjs.js +124 -68
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +279 -208
- package/dist/styles.d.ts +1 -1
- package/dist/types.d.ts +5 -3
- package/dist/widerruf.html +18 -30
- 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
|
@@ -25,8 +25,10 @@ export interface WiderrufsConfig {
|
|
|
25
25
|
legalLinks?: LegalLink[];
|
|
26
26
|
/** POST action URL for the static HTML fallback form (defaults to apiUrl) */
|
|
27
27
|
formAction?: string;
|
|
28
|
-
/** Redirect URL after successful submit
|
|
28
|
+
/** Redirect URL after successful form submit (static fallback / no-JS modal) */
|
|
29
29
|
successUrl?: string;
|
|
30
|
+
/** Redirect URL after failed form submit (static fallback / no-JS modal, defaults to #wrb-error) */
|
|
31
|
+
errorUrl?: string;
|
|
30
32
|
/** Called after a successful submit in the modal */
|
|
31
33
|
onSuccess?: () => void;
|
|
32
34
|
/** Called after a failed submit in the modal */
|
|
@@ -35,8 +37,8 @@ export interface WiderrufsConfig {
|
|
|
35
37
|
export interface WiderrufsFormData {
|
|
36
38
|
name: string;
|
|
37
39
|
email: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
orderNumber: string;
|
|
41
|
+
reason: string;
|
|
40
42
|
datum: string;
|
|
41
43
|
}
|
|
42
44
|
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,20 @@
|
|
|
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
|
Name <span class="wrb-required" aria-hidden="true">*</span>
|
|
255
264
|
</label>
|
|
256
|
-
<input
|
|
257
|
-
|
|
258
|
-
type="text"
|
|
259
|
-
name="name"
|
|
260
|
-
autocomplete="name"
|
|
261
|
-
placeholder="Vor- und Nachname"
|
|
262
|
-
required
|
|
263
|
-
>
|
|
265
|
+
<input class="wrb-input" type="text" name="name" autocomplete="name"
|
|
266
|
+
placeholder="Vor- und Nachname" required>
|
|
264
267
|
</div>
|
|
265
268
|
<div class="wrb-field">
|
|
266
269
|
<label class="wrb-label">
|
|
267
270
|
E-Mail-Adresse <span class="wrb-required" aria-hidden="true">*</span>
|
|
268
271
|
</label>
|
|
269
|
-
<input
|
|
270
|
-
|
|
271
|
-
type="email"
|
|
272
|
-
name="email"
|
|
273
|
-
autocomplete="email"
|
|
274
|
-
placeholder="name@beispiel.de"
|
|
275
|
-
required
|
|
276
|
-
>
|
|
272
|
+
<input class="wrb-input" type="email" name="email" autocomplete="email"
|
|
273
|
+
placeholder="name@beispiel.de" required>
|
|
277
274
|
<p class="wrb-hint">Hierüber erhalten Sie die Eingangsbestätigung.</p>
|
|
278
275
|
</div>
|
|
279
276
|
<div class="wrb-field">
|
|
@@ -281,23 +278,13 @@
|
|
|
281
278
|
Bestell- / Auftrags- / Vertragsnummer
|
|
282
279
|
<span class="wrb-required" aria-hidden="true">*</span>
|
|
283
280
|
</label>
|
|
284
|
-
<input
|
|
285
|
-
|
|
286
|
-
type="text"
|
|
287
|
-
name="vertragId"
|
|
288
|
-
placeholder="z.B. 10045678"
|
|
289
|
-
required
|
|
290
|
-
>
|
|
281
|
+
<input class="wrb-input" type="text" name="orderNumber"
|
|
282
|
+
placeholder="z.B. 10045678" required>
|
|
291
283
|
<p class="wrb-hint">Zu finden in Ihrer Bestellbestätigung.</p>
|
|
292
284
|
</div>
|
|
293
285
|
<div class="wrb-field">
|
|
294
|
-
<label class="wrb-label">
|
|
295
|
-
<textarea
|
|
296
|
-
class="wrb-textarea"
|
|
297
|
-
name="widerrufsgrund"
|
|
298
|
-
placeholder="Optional"
|
|
299
|
-
rows="3"
|
|
300
|
-
></textarea>
|
|
286
|
+
<label class="wrb-label">reason</label>
|
|
287
|
+
<textarea class="wrb-textarea" name="reason" placeholder="Optional" rows="3"></textarea>
|
|
301
288
|
<p class="wrb-hint">
|
|
302
289
|
Freiwillige Angabe – ein Widerruf ist ohne Angabe von Gründen möglich.
|
|
303
290
|
</p>
|
|
@@ -309,6 +296,7 @@
|
|
|
309
296
|
</div>
|
|
310
297
|
<input type="hidden" name="action" value="widerruf_submit">
|
|
311
298
|
|
|
299
|
+
|
|
312
300
|
<div class="wrb-actions">
|
|
313
301
|
<button type="submit" class="wrb-submit-btn">
|
|
314
302
|
Absenden
|