@bytebrand/fe-ui-core-autobahn 1.0.180 → 1.0.181
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/cards/CarCard.tsx +39 -9
- package/cards/cardParts.tsx +6 -1
- package/chrome/Footer.tsx +3 -16
- package/chrome/TopBar.tsx +266 -139
- package/compat/CookieModal/CookieModal.tsx +6 -20
- package/compat/CookieModal/Modal.tsx +3 -6
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +15 -43
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +3 -4
- package/compat/CookieModal/useModal.ts +1 -5
- package/compat/Loader/Loader.tsx +7 -1
- package/compat/MdField/MdField.tsx +4 -28
- package/constants/app.ts +11 -1
- package/constants/core.ts +12 -1
- package/iconsvg/IconSVG.tsx +5 -1
- package/locales/de/autobahn.json +5 -37
- package/locales/en/autobahn.json +4 -36
- package/package.json +1 -1
- package/theme/md3.css +1232 -5346
- package/ui/Dropdown.tsx +10 -29
- package/ui/FormCheckbox.tsx +2 -22
- package/ui/FormField.tsx +1 -2
- package/ui/Icon.tsx +0 -6
- package/ui/Modal.tsx +6 -84
- package/ui/index.ts +0 -2
- package/ui/usePortalMenuPosition.ts +15 -27
- package/utils/index.ts +0 -10
- package/vdp/FinanceCalculator.tsx +5 -19
- package/vdp/VdpModules.tsx +6 -36
- package/vdp/types.ts +5 -5
- package/vehiclesProps/decoratedLightProps.tsx +0 -4
- package/vehiclesProps/decoratedProps.tsx +0 -4
- package/chrome/AccountMenuIcon.tsx +0 -109
- package/ui/MfieldCheckIcon.tsx +0 -13
- package/ui/scrollFieldIntoView.ts +0 -41
- package/utils/cookieConsent.ts +0 -84
- package/vehiclesProps/accidentDisclosure.ts +0 -25
package/ui/Dropdown.tsx
CHANGED
|
@@ -22,7 +22,6 @@ import * as ReactDOM from 'react-dom';
|
|
|
22
22
|
|
|
23
23
|
import Icon from './Icon';
|
|
24
24
|
import { usePortalMenuPosition } from './usePortalMenuPosition';
|
|
25
|
-
import { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
26
25
|
|
|
27
26
|
export interface DropdownOption {
|
|
28
27
|
value: string;
|
|
@@ -60,16 +59,8 @@ export interface DropdownProps {
|
|
|
60
59
|
ariaDescribedBy?: string;
|
|
61
60
|
/** extra class on the wrapper (e.g. 'srp-sort' for width rules). */
|
|
62
61
|
className?: string;
|
|
63
|
-
/** extra class on the popover menu itself (`.mselect-menu`) — separate from `className` since
|
|
64
|
-
* with `menuPortal` the menu renders at document.body, outside the trigger wrapper's subtree,
|
|
65
|
-
* so a caller that needs to style its OWN options (`.mselect-opt`) needs this to scope there. */
|
|
66
|
-
menuClassName?: string;
|
|
67
62
|
/** align the popover to the right edge of the trigger (default left). */
|
|
68
63
|
menuAlign?: 'left' | 'right';
|
|
69
|
-
/** with `menuPortal`: 'auto' (default) flips the popover above the trigger when there's no
|
|
70
|
-
* room below; 'down' always opens below, never flips — for a trigger where an upward flip
|
|
71
|
-
* would overlap unrelated content above it. */
|
|
72
|
-
menuOpenDirection?: 'auto' | 'down';
|
|
73
64
|
/** show a text input at the top of the popover that filters `options` by label (substring, case-insensitive). */
|
|
74
65
|
searchable?: boolean;
|
|
75
66
|
/** placeholder for the search input (only used when `searchable`). */
|
|
@@ -106,9 +97,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
106
97
|
ariaInvalid,
|
|
107
98
|
ariaDescribedBy,
|
|
108
99
|
className,
|
|
109
|
-
menuClassName,
|
|
110
100
|
menuAlign = 'left',
|
|
111
|
-
menuOpenDirection = 'auto',
|
|
112
101
|
searchable = false,
|
|
113
102
|
searchPlaceholder,
|
|
114
103
|
numeric = false,
|
|
@@ -190,22 +179,15 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
190
179
|
if (allowCustomValue) setQuery(value || '');
|
|
191
180
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
192
181
|
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
// problem a searchable trigger has with the keyboard eating the space below it. A plain
|
|
198
|
-
// `scrollIntoView({block:'center'})` used to run here (searchable-only) — "center" only moves
|
|
199
|
-
// the trigger when it's already near a viewport edge, so on a trigger that's roughly mid-page
|
|
200
|
-
// already (the common case) it was a near no-op, leaving a few hundred px of dead space above
|
|
201
|
-
// the trigger that the keyboard (searchable) or the menu's own bottom edge (any dropdown) then
|
|
202
|
-
// ran into.
|
|
182
|
+
// when opened searchable, focus the search input instead of leaving focus on the trigger.
|
|
183
|
+
// scrollIntoView first: on mobile the keyboard is about to eat ~40% of the viewport, so the
|
|
184
|
+
// trigger (and the popover below it) needs to already be scrolled above the fold before focus
|
|
185
|
+
// fires, or the popover can end up hidden behind the keyboard with no way to see it open.
|
|
203
186
|
React.useEffect(() => {
|
|
204
|
-
if (!open) return;
|
|
205
|
-
if (rootRef.current
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// <button> already has focus from the click/keypress that opened it.
|
|
187
|
+
if (!open || !searchable) return;
|
|
188
|
+
if (rootRef.current && rootRef.current.scrollIntoView) {
|
|
189
|
+
rootRef.current.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
190
|
+
}
|
|
209
191
|
if (searchRef.current) {
|
|
210
192
|
searchRef.current.focus();
|
|
211
193
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
|
@@ -239,7 +221,6 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
239
221
|
open,
|
|
240
222
|
rootRef,
|
|
241
223
|
menuAlign,
|
|
242
|
-
openDirection: menuOpenDirection,
|
|
243
224
|
onCloseAway,
|
|
244
225
|
});
|
|
245
226
|
|
|
@@ -419,7 +400,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
419
400
|
? ReactDOM.createPortal(
|
|
420
401
|
<div
|
|
421
402
|
ref={menuElRef}
|
|
422
|
-
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '')
|
|
403
|
+
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '')}
|
|
423
404
|
// menuPos is null for one frame on open, before the position effect has measured
|
|
424
405
|
// the trigger — stay invisible (not just visually, via `visibility`) rather than
|
|
425
406
|
// flash at (0,0)/full-width. `position: fixed` is set UNCONDITIONALLY, in both
|
|
@@ -472,7 +453,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
472
453
|
: (
|
|
473
454
|
<div
|
|
474
455
|
ref={menuElRef}
|
|
475
|
-
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '')
|
|
456
|
+
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '')}
|
|
476
457
|
>
|
|
477
458
|
{renderMenuList()}
|
|
478
459
|
</div>
|
package/ui/FormCheckbox.tsx
CHANGED
|
@@ -36,23 +36,12 @@ export interface FormCheckboxProps {
|
|
|
36
36
|
/** override the field's own disabled flag. */
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
id?: string;
|
|
39
|
-
/** show a small alert-circle glyph before the error text (Figma 64670:106293's "Fehlermeldung"
|
|
40
|
-
* row) — opt-in, defaults off so every other FormCheckbox caller keeps its plain text-only
|
|
41
|
-
* error message unchanged. */
|
|
42
|
-
errorIcon?: boolean;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
46
|
-
({ field, t, label, children, disabled, id
|
|
42
|
+
({ field, t, label, children, disabled, id }) => {
|
|
47
43
|
const isChecked = !!field.checked;
|
|
48
44
|
const isDisabled = disabled != null ? disabled : !!field.disabled;
|
|
49
|
-
// field.hasError alone is a LIVE check (mobx-react-form's Field#hasError getter re-evaluates
|
|
50
|
-
// the rule against the current value on every read) — true for an unchecked required field
|
|
51
|
-
// from initial render, before the user ever interacts. field.error is what's actually gated
|
|
52
|
-
// behind the field's showError flag (Field#error getter), which only flips true once
|
|
53
|
-
// showErrors()/an explicit validate({showErrors:true}) runs — the real "has this been
|
|
54
|
-
// submitted/touched" signal. Keep requiring both, or every required checkbox on the site
|
|
55
|
-
// renders red on page load.
|
|
56
45
|
const hasError = !!field.hasError && !!field.error;
|
|
57
46
|
|
|
58
47
|
// children (rich) > explicit label > translated field.label (legacy CheckboxMaterial behaviour).
|
|
@@ -81,16 +70,7 @@ const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
|
81
70
|
</span>
|
|
82
71
|
{content != null ? <span className="mcheck-label">{content}</span> : null}
|
|
83
72
|
</label>
|
|
84
|
-
{hasError ?
|
|
85
|
-
errorIcon ? (
|
|
86
|
-
<span className="mcheck-error-text mcheck-error-text--icon">
|
|
87
|
-
<Icon name="alert-circle" size={16} stroke={2} cls="mcheck-error-icon" />
|
|
88
|
-
<span className="mcheck-error-msg">{field.error}</span>
|
|
89
|
-
</span>
|
|
90
|
-
) : (
|
|
91
|
-
<span className="mcheck-error-text">{field.error}</span>
|
|
92
|
-
)
|
|
93
|
-
) : null}
|
|
73
|
+
{hasError ? <span className="mcheck-error-text">{field.error}</span> : null}
|
|
94
74
|
</div>
|
|
95
75
|
);
|
|
96
76
|
},
|
package/ui/FormField.tsx
CHANGED
|
@@ -12,7 +12,6 @@ import * as React from 'react';
|
|
|
12
12
|
import { observer } from 'mobx-react';
|
|
13
13
|
|
|
14
14
|
import Icon from './Icon';
|
|
15
|
-
import MfieldCheckIcon from './MfieldCheckIcon';
|
|
16
15
|
|
|
17
16
|
export interface FormFieldProps {
|
|
18
17
|
/** mobx-react-form field (LoginForm.$('email') etc.). Typed any — the lib ships no TS types. */
|
|
@@ -83,7 +82,7 @@ const FormField: React.FunctionComponent<FormFieldProps> = observer(
|
|
|
83
82
|
<Icon name={reveal ? 'eye-off' : 'eye'} size={18} />
|
|
84
83
|
</button>
|
|
85
84
|
) : null}
|
|
86
|
-
{isValid ? <span className="mfield-ok"><
|
|
85
|
+
{isValid ? <span className="mfield-ok"><Icon name="check" size={18} /></span> : null}
|
|
87
86
|
</div>
|
|
88
87
|
{hasError ? <span className="mfield-error-text">{field.error}</span> : null}
|
|
89
88
|
</div>
|
package/ui/Icon.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Activity,
|
|
4
|
-
AlertCircle,
|
|
5
4
|
Apple,
|
|
6
5
|
Armchair,
|
|
7
6
|
ArrowLeft,
|
|
@@ -52,13 +51,11 @@ import {
|
|
|
52
51
|
DoorOpen,
|
|
53
52
|
Droplet,
|
|
54
53
|
Euro,
|
|
55
|
-
ExternalLink,
|
|
56
54
|
Eye,
|
|
57
55
|
EyeOff,
|
|
58
56
|
Facebook,
|
|
59
57
|
File,
|
|
60
58
|
FileCheck,
|
|
61
|
-
FileSignature,
|
|
62
59
|
FileText,
|
|
63
60
|
Flame,
|
|
64
61
|
Fuel,
|
|
@@ -201,7 +198,6 @@ function toPascalCase(name: string): string {
|
|
|
201
198
|
*/
|
|
202
199
|
const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
203
200
|
Activity,
|
|
204
|
-
AlertCircle,
|
|
205
201
|
Apple,
|
|
206
202
|
Armchair,
|
|
207
203
|
ArrowLeft,
|
|
@@ -253,13 +249,11 @@ const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
|
253
249
|
DoorOpen,
|
|
254
250
|
Droplet,
|
|
255
251
|
Euro,
|
|
256
|
-
ExternalLink,
|
|
257
252
|
Eye,
|
|
258
253
|
EyeOff,
|
|
259
254
|
Facebook,
|
|
260
255
|
File,
|
|
261
256
|
FileCheck,
|
|
262
|
-
FileSignature,
|
|
263
257
|
FileText,
|
|
264
258
|
Flame,
|
|
265
259
|
Fuel,
|
package/ui/Modal.tsx
CHANGED
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
// - scrim ~50% black; body scroll-locked while open; basic focus trap (Tab/Shift+Tab
|
|
16
16
|
// cycle within the surface, focus moves into the dialog on open and is restored to the
|
|
17
17
|
// previously-focused element on close).
|
|
18
|
-
// - mobile bottom sheet (≤560px): swipe down on the head row to dismiss (mirrors fe-main's
|
|
19
|
-
// BaseModal.tsx sheet), when dismissOnScrim is true.
|
|
20
18
|
// - a11y: role=dialog, aria-modal, aria-labelledby wired to the title when present.
|
|
21
19
|
//
|
|
22
20
|
// Pure/presentational — no store/API access beyond document/body (all SSR-guarded). The
|
|
@@ -46,13 +44,6 @@ export interface ModalProps {
|
|
|
46
44
|
dismissOnScrim?: boolean;
|
|
47
45
|
/** extra class(es) appended on the surface (layout hooks). */
|
|
48
46
|
className?: string;
|
|
49
|
-
/** custom close-button content, replacing the default IconButton(name="x"). When set, it
|
|
50
|
-
* renders as a plain button.mmodal-close instead (own CSS handles sizing/position — see
|
|
51
|
-
* md3.css), so callers with a specific close-icon spec (exact asset, absolute position
|
|
52
|
-
* independent of title height) aren't stuck fighting the default's flex layout. */
|
|
53
|
-
closeIcon?: React.ReactNode;
|
|
54
|
-
/** optional extra header button rendered before the close button (e.g. a download action). */
|
|
55
|
-
headerAction?: React.ReactNode;
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
// focusable descendants used by the basic focus trap.
|
|
@@ -68,48 +59,10 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
68
59
|
size = 'md',
|
|
69
60
|
dismissOnScrim = true,
|
|
70
61
|
className,
|
|
71
|
-
closeIcon,
|
|
72
|
-
headerAction,
|
|
73
62
|
}) => {
|
|
74
63
|
const surfaceRef = React.useRef<HTMLDivElement | null>(null);
|
|
75
64
|
// the element focused before the dialog opened, so focus can be restored on close.
|
|
76
65
|
const prevFocusRef = React.useRef<HTMLElement | null>(null);
|
|
77
|
-
// swipe-down-to-dismiss on the mobile bottom sheet (≤560px, matching the .mmodal-scrim/
|
|
78
|
-
// .mmodal breakpoint in md3.css) — same imperative-transform pattern as fe-main's
|
|
79
|
-
// BaseModal.tsx (checkout's own bottom sheet): follows the finger directly via
|
|
80
|
-
// style.transform while dragging (no re-renders), released past 90px slides out and closes,
|
|
81
|
-
// otherwise springs back. No-ops above the breakpoint and when dismissOnScrim is false (a
|
|
82
|
-
// modal that can't be scrim-dismissed shouldn't be swipe-dismissable either).
|
|
83
|
-
const dragStartY = React.useRef<number | null>(null);
|
|
84
|
-
|
|
85
|
-
const onGrabStart = (event: React.TouchEvent) => {
|
|
86
|
-
if (!dismissOnScrim) return;
|
|
87
|
-
if (typeof window !== 'undefined' && window.matchMedia('(min-width: 561px)').matches) return;
|
|
88
|
-
dragStartY.current = event.touches[0].clientY;
|
|
89
|
-
if (surfaceRef.current) surfaceRef.current.style.transition = 'none';
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const onGrabMove = (event: React.TouchEvent) => {
|
|
93
|
-
if (dragStartY.current == null || !surfaceRef.current) return;
|
|
94
|
-
const dy = event.touches[0].clientY - dragStartY.current;
|
|
95
|
-
// only follow downward drags — the sheet is already flush with the bottom of the
|
|
96
|
-
// viewport, so upward has nowhere to go.
|
|
97
|
-
surfaceRef.current.style.transform = dy > 0 ? `translateY(${dy}px)` : '';
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const onGrabEnd = (event: React.TouchEvent) => {
|
|
101
|
-
if (dragStartY.current == null || !surfaceRef.current) return;
|
|
102
|
-
const dy = event.changedTouches[0].clientY - dragStartY.current;
|
|
103
|
-
dragStartY.current = null;
|
|
104
|
-
const el = surfaceRef.current;
|
|
105
|
-
el.style.transition = 'transform 0.2s ease-out';
|
|
106
|
-
if (dy > 90) {
|
|
107
|
-
el.style.transform = 'translateY(100%)';
|
|
108
|
-
window.setTimeout(onClose, 200);
|
|
109
|
-
} else {
|
|
110
|
-
el.style.transform = '';
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
66
|
// stable id for aria-labelledby (avoids Math.random/Date.now, unavailable in this env).
|
|
114
67
|
const titleId = React.useMemo(
|
|
115
68
|
() => (title ? `mmodal-title-${Math.round((surfaceRef.current ? 1 : 0))}-${size}` : undefined),
|
|
@@ -136,26 +89,11 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
136
89
|
const prevOverflow = document.body.style.overflow;
|
|
137
90
|
document.body.style.overflow = 'hidden';
|
|
138
91
|
|
|
139
|
-
// move focus
|
|
140
|
-
// ready to type into and browser autofill can offer itself; the head row (close + headerAction
|
|
141
|
-
// icons) is skipped so a header icon never takes the :focus-visible ring on open. Falls back to
|
|
142
|
-
// the surface itself when the body has nothing focusable.
|
|
143
|
-
// { preventScroll: true }: this runs at the very first animation frame of the mobile
|
|
144
|
-
// sheet's own mmodal-sheet-up entrance (md3.css) — at that instant the surface's actual
|
|
145
|
-
// computed transform is still the keyframe's `from` state (translateY(100%), pushed
|
|
146
|
-
// off-screen below the viewport), not its settled position yet. A plain .focus() on an
|
|
147
|
-
// element the browser currently considers off-screen makes it auto-scroll the nearest
|
|
148
|
-
// scrollable ancestor (.mmodal-scrim, itself overflow-y:auto) to bring it into view —
|
|
149
|
-
// fighting the CSS slide-in transform animating at the same time, which is exactly what
|
|
150
|
-
// produces a double-motion "jumps up, then settles back down" glitch on open. preventScroll
|
|
151
|
-
// skips that native auto-scroll entirely, so the CSS animation alone moves the sheet
|
|
152
|
-
// (same fix as fe-main's BaseModal.tsx, which hit this same glitch first).
|
|
92
|
+
// move focus into the dialog (first focusable, else the surface itself).
|
|
153
93
|
const surface = surfaceRef.current;
|
|
154
94
|
if (surface) {
|
|
155
|
-
const first =
|
|
156
|
-
|
|
157
|
-
.find((el: HTMLElement) => !el.closest('.mmodal-head'));
|
|
158
|
-
(first || surface).focus({ preventScroll: true });
|
|
95
|
+
const first = surface.querySelector<HTMLElement>(FOCUSABLE);
|
|
96
|
+
(first || surface).focus();
|
|
159
97
|
}
|
|
160
98
|
|
|
161
99
|
return () => {
|
|
@@ -227,17 +165,8 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
227
165
|
tabIndex={-1}
|
|
228
166
|
onMouseDown={(e) => e.stopPropagation()}
|
|
229
167
|
>
|
|
230
|
-
{/* head row always renders so the close button is always present.
|
|
231
|
-
|
|
232
|
-
never crosses the 90px threshold and nothing here calls preventDefault, so the
|
|
233
|
-
close button's own onClick still fires normally after touchend. */}
|
|
234
|
-
<div
|
|
235
|
-
className="mmodal-head"
|
|
236
|
-
onTouchStart={onGrabStart}
|
|
237
|
-
onTouchMove={onGrabMove}
|
|
238
|
-
onTouchEnd={onGrabEnd}
|
|
239
|
-
style={{ touchAction: 'none' }}
|
|
240
|
-
>
|
|
168
|
+
{/* head row always renders so the close button is always present. */}
|
|
169
|
+
<div className="mmodal-head">
|
|
241
170
|
{title ? (
|
|
242
171
|
<h2 id={titleId} className="mmodal-title md-headline-sm">
|
|
243
172
|
{title}
|
|
@@ -245,14 +174,7 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
245
174
|
) : (
|
|
246
175
|
<span className="mmodal-title" aria-hidden="true" />
|
|
247
176
|
)}
|
|
248
|
-
{
|
|
249
|
-
{closeIcon ? (
|
|
250
|
-
<button type="button" className="mmodal-close" aria-label="Schließen" onClick={onClose}>
|
|
251
|
-
{closeIcon}
|
|
252
|
-
</button>
|
|
253
|
-
) : (
|
|
254
|
-
<IconButton name="x" label="Schließen" onClick={onClose} />
|
|
255
|
-
)}
|
|
177
|
+
<IconButton name="x" label="Schließen" onClick={onClose} />
|
|
256
178
|
</div>
|
|
257
179
|
<div className="mmodal-body">{children}</div>
|
|
258
180
|
{footer ? <div className="mmodal-foot">{footer}</div> : null}
|
package/ui/index.ts
CHANGED
|
@@ -39,8 +39,6 @@ export type { FormFieldProps } from './FormField';
|
|
|
39
39
|
export { default as Dropdown } from './Dropdown';
|
|
40
40
|
export type { DropdownProps, DropdownOption } from './Dropdown';
|
|
41
41
|
|
|
42
|
-
export { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
43
|
-
|
|
44
42
|
export { default as Spec } from './Spec';
|
|
45
43
|
export type { SpecProps } from './Spec';
|
|
46
44
|
|
|
@@ -45,11 +45,6 @@ export interface UsePortalMenuPositionArgs {
|
|
|
45
45
|
/** the trigger's wrapping element — always rendered (regardless of `open`), measured for position. */
|
|
46
46
|
rootRef: React.RefObject<HTMLElement>;
|
|
47
47
|
menuAlign?: 'left' | 'right';
|
|
48
|
-
/** 'auto' (default): flips ABOVE the trigger when there isn't room below (see ESTIMATED_MENU_HEIGHT
|
|
49
|
-
* below). 'down': always opens below, never flips — for a trigger where the caller knows the
|
|
50
|
-
* page has room below and an upward flip would overlap unrelated content above it (e.g. a
|
|
51
|
-
* trigger sitting right under a sticky/close heading). */
|
|
52
|
-
openDirection?: 'auto' | 'down';
|
|
53
48
|
/** called when the trigger scrolls out of view entirely, or a real user scroll happens after
|
|
54
49
|
* the post-open grace window — the menu has nothing sensible left to anchor to or chase. */
|
|
55
50
|
onCloseAway: () => void;
|
|
@@ -76,32 +71,14 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
|
|
|
76
71
|
// reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
|
|
77
72
|
// clamped to the space actually available (see `maxHeight` above), not just guessed at.
|
|
78
73
|
const ESTIMATED_MENU_HEIGHT = 300;
|
|
79
|
-
// .mselect-menu's own padding + border (6px*2 + 1px*2) — the consumers add it back on top of
|
|
80
|
-
// `maxHeight` for the box, so the space it fits into has to leave room for it.
|
|
81
|
-
const MENU_CHROME = 14;
|
|
82
74
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
83
75
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
84
76
|
|
|
85
|
-
// Module-level (not hook-local) so Dropdown.tsx's own searchable-open scroll effect can reuse the
|
|
86
|
-
// exact same measurement — the sticky app header (.topbar, position:sticky/top:0) sits over the
|
|
87
|
-
// top of the viewport on every page that uses it (TopBar's autoHideOnScroll is opt-in, off by
|
|
88
|
-
// default — most pages keep it permanently docked), so anything that scrolls/positions content
|
|
89
|
-
// near the top of the viewport needs to stop at its live bottom edge, not y=0. Reading the
|
|
90
|
-
// header's live bottom edge (0 when absent, e.g. inside a modal, or when autoHideOnScroll has slid
|
|
91
|
-
// it away) gives a correct boundary without hardcoding a pixel height that could drift from the
|
|
92
|
-
// header's own CSS.
|
|
93
|
-
export const getSafeTop = (): number => {
|
|
94
|
-
if (typeof document === 'undefined') return 0;
|
|
95
|
-
const header = document.querySelector('.topbar');
|
|
96
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
77
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
100
78
|
enabled,
|
|
101
79
|
open,
|
|
102
80
|
rootRef,
|
|
103
81
|
menuAlign = 'left',
|
|
104
|
-
openDirection = 'auto',
|
|
105
82
|
onCloseAway,
|
|
106
83
|
}: UsePortalMenuPositionArgs): UsePortalMenuPositionResult<TMenuEl> {
|
|
107
84
|
const menuElRef = React.useRef<TMenuEl | null>(null);
|
|
@@ -138,6 +115,18 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
138
115
|
};
|
|
139
116
|
}, [enabled, open, portalRoot]);
|
|
140
117
|
|
|
118
|
+
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
119
|
+
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
120
|
+
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
121
|
+
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
122
|
+
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
123
|
+
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
124
|
+
const getSafeTop = (): number => {
|
|
125
|
+
if (typeof document === 'undefined') return 0;
|
|
126
|
+
const header = document.querySelector('.topbar');
|
|
127
|
+
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
128
|
+
};
|
|
129
|
+
|
|
141
130
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
142
131
|
|
|
143
132
|
const positionMenu = React.useCallback(() => {
|
|
@@ -155,14 +144,13 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
155
144
|
}
|
|
156
145
|
const spaceBelow = window.innerHeight - rect.bottom - GAP;
|
|
157
146
|
const spaceAbove = rect.top - safeTop - GAP;
|
|
158
|
-
const openAbove =
|
|
147
|
+
const openAbove = spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow;
|
|
159
148
|
// cap the menu to the space it ACTUALLY has in whichever direction it opens, instead of
|
|
160
149
|
// trusting a static CSS max-height on its own — near the header or viewport edge that static
|
|
161
150
|
// cap can still be taller than what's really available, which is what let the menu paint over
|
|
162
151
|
// the header in the first place. The consumer's own overflow-y:auto takes it from there once
|
|
163
152
|
// content exceeds this.
|
|
164
|
-
|
|
165
|
-
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, (openAbove ? spaceAbove : spaceBelow) - MENU_CHROME));
|
|
153
|
+
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, openAbove ? spaceAbove : spaceBelow));
|
|
166
154
|
setMenuPos({
|
|
167
155
|
width: rect.width,
|
|
168
156
|
left: menuAlign === 'right' ? 'auto' : rect.left,
|
|
@@ -171,7 +159,7 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
171
159
|
bottom: openAbove ? window.innerHeight - rect.top + GAP : 'auto',
|
|
172
160
|
maxHeight: available,
|
|
173
161
|
});
|
|
174
|
-
}, [enabled, menuAlign,
|
|
162
|
+
}, [enabled, menuAlign, onCloseAway, rootRef]);
|
|
175
163
|
|
|
176
164
|
// Synchronous (pre-paint) position computation. useLayoutEffect — not useEffect — matters here:
|
|
177
165
|
// it runs right after the DOM mutation that mounted the portal but BEFORE the browser paints, so
|
package/utils/index.ts
CHANGED
|
@@ -62,14 +62,6 @@ export {
|
|
|
62
62
|
updateCookieList
|
|
63
63
|
} from './CommonUtils';
|
|
64
64
|
|
|
65
|
-
export {
|
|
66
|
-
COOKIE_CONSENT_CHANGE_EVENT,
|
|
67
|
-
getCookieConsentState,
|
|
68
|
-
openCookieSettings,
|
|
69
|
-
saveCookieConfig
|
|
70
|
-
} from './cookieConsent';
|
|
71
|
-
export type { CookieCategoryState, ICookieConsentState } from './cookieConsent';
|
|
72
|
-
|
|
73
65
|
export { getEquipment, getEquipmentCount } from '../vehiclesProps/equipment';
|
|
74
66
|
|
|
75
67
|
export type { IDecoratedProps, IEquipmentProps, ICarPropElement } from '../types/types';
|
|
@@ -91,5 +83,3 @@ export type { IValues, IFilters, IQuery } from './query';
|
|
|
91
83
|
// Decorated car props (renders React UI; lives in vehiclesProps/ with its
|
|
92
84
|
// IconContainer + Co2Widget dependencies under compat/).
|
|
93
85
|
export { default as getDecoratedProps } from '../vehiclesProps/decoratedProps';
|
|
94
|
-
export { setStrictConditionOwners, isStrictConditionOwner, strictAccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
95
|
-
export type { AccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
15
15
|
|
|
16
|
-
import React, { useState
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
17
|
import { TranslationFunction } from '../types';
|
|
18
18
|
|
|
19
19
|
import { Button, Icon, Switch } from '../ui';
|
|
@@ -52,18 +52,8 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
52
52
|
bubble,
|
|
53
53
|
bubblePaddingBottom = 34,
|
|
54
54
|
}) => {
|
|
55
|
-
// Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
|
|
56
|
-
// debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
|
|
57
|
-
// which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
|
|
58
|
-
// thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
|
|
59
|
-
// bubble label are driven by the `value` PROP, which only catches up once the debounced commit
|
|
60
|
-
// finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
|
|
61
|
-
// back to the prop via useEffect for externally-driven changes (e.g. a reset button).
|
|
62
|
-
const [localValue, setLocalValue] = useState(value);
|
|
63
|
-
useEffect(() => { setLocalValue(value); }, [value]);
|
|
64
|
-
|
|
65
55
|
const span = max - min;
|
|
66
|
-
const pct = span > 0 ? ((
|
|
56
|
+
const pct = span > 0 ? ((value - min) / span) * 100 : 0;
|
|
67
57
|
return (
|
|
68
58
|
<div>
|
|
69
59
|
<div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
|
|
@@ -71,7 +61,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
71
61
|
// thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
|
|
72
62
|
// tracks the thumb center (a plain pct% drifts at the rail ends)
|
|
73
63
|
<span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
|
|
74
|
-
{fmt(
|
|
64
|
+
{fmt(value)}
|
|
75
65
|
</span>
|
|
76
66
|
)}
|
|
77
67
|
<input
|
|
@@ -80,12 +70,8 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
80
70
|
min={min}
|
|
81
71
|
max={max}
|
|
82
72
|
step={step}
|
|
83
|
-
value={
|
|
84
|
-
onChange={(e) =>
|
|
85
|
-
const v = Number(e.target.value);
|
|
86
|
-
setLocalValue(v);
|
|
87
|
-
onChange(v);
|
|
88
|
-
}}
|
|
73
|
+
value={value}
|
|
74
|
+
onChange={(e) => onChange(Number(e.target.value))}
|
|
89
75
|
style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
|
|
90
76
|
/>
|
|
91
77
|
</div>
|
package/vdp/VdpModules.tsx
CHANGED
|
@@ -92,7 +92,7 @@ export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({
|
|
|
92
92
|
['zap', extractPS(vehicle.power)],
|
|
93
93
|
['fuel', stripParen(vehicle.fuel)],
|
|
94
94
|
['cog', vehicle.gear],
|
|
95
|
-
|
|
95
|
+
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
96
96
|
];
|
|
97
97
|
return (
|
|
98
98
|
<>
|
|
@@ -142,7 +142,7 @@ export const VdpFactsGrid: React.FunctionComponent<VdpHeaderCardProps> = ({ vehi
|
|
|
142
142
|
['calendar', vehicle.reg],
|
|
143
143
|
['cog', vehicle.gear],
|
|
144
144
|
['fuel', stripParen(vehicle.fuel)],
|
|
145
|
-
|
|
145
|
+
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
146
146
|
...(vehicle.body ? ([['car-front', vehicle.body]] as const) : []),
|
|
147
147
|
];
|
|
148
148
|
return (
|
|
@@ -216,7 +216,7 @@ export const VdpHeaderCondition: React.FunctionComponent<VdpHeaderCardProps> = (
|
|
|
216
216
|
// only the Garantie tile has one, linking out to auto.de's warranty policy page.
|
|
217
217
|
const tiles: ReadonlyArray<readonly [string, string, string, string?]> = [
|
|
218
218
|
['wrench', t('autobahn:header.huLabel'), condition.hu === 'Neu' ? t('autobahn:header.huNew') : t('autobahn:header.huUntil', { date: condition.hu })],
|
|
219
|
-
['shield-check', t('autobahn:header.accidentFree'), condition.unfallfrei
|
|
219
|
+
['shield-check', t('autobahn:header.accidentFree'), condition.unfallfrei ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
220
220
|
['clipboard-check', t('autobahn:header.serviceHistory'), condition.scheckheft ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
221
221
|
['award', t('autobahn:header.warranty'), condition.garantie, 'https://www.auto.de/garantie/'],
|
|
222
222
|
];
|
|
@@ -2126,12 +2126,6 @@ export interface FinanceDetailsModalProps {
|
|
|
2126
2126
|
/** opened directly via the page's Finanzierungs-/Leasingdetails link — the sheet opens
|
|
2127
2127
|
* scrolled to the breakdown instead of the "Rate anpassen" controls at its top. */
|
|
2128
2128
|
initialShowBreakdown?: boolean;
|
|
2129
|
-
/** skips the smooth scrollIntoView/scrollSheetToBreakdown animation initialShowBreakdown
|
|
2130
|
-
* otherwise triggers on open (still sets showBreakdown itself) — for a consumer whose sheet
|
|
2131
|
-
* has nothing ABOVE the breakdown to scroll past (e.g. checkout's stripped-down instance,
|
|
2132
|
-
* with the rate hero/sliders/toggles above it hidden), that animation has nowhere real to go
|
|
2133
|
-
* and only reads as a stray jump. */
|
|
2134
|
-
skipInitialScroll?: boolean;
|
|
2135
2129
|
/** mobile only — price-rating label, drives the eval pill/bar (same as the collapsed card). */
|
|
2136
2130
|
ratingLabel?: string;
|
|
2137
2131
|
/** Kaufen tab only — real carStore.isAvailable (same source as VdpTrustRow's "Sofort
|
|
@@ -2160,10 +2154,6 @@ export interface FinanceDetailsModalProps {
|
|
|
2160
2154
|
leasingAvailable?: boolean;
|
|
2161
2155
|
/** i18n function (drilled from the page). */
|
|
2162
2156
|
t: TranslationFunction;
|
|
2163
|
-
/** overrides the desktop dialog heading (default: the mode's own, shorter "Details" text) —
|
|
2164
|
-
* a consumer whose own trigger already carries a specific label (e.g. checkout's cf-details
|
|
2165
|
-
* button, "Finanzierungsdetails"/"Leasingdetails") can pass that same text through here. */
|
|
2166
|
-
titleOverride?: string;
|
|
2167
2157
|
}
|
|
2168
2158
|
|
|
2169
2159
|
/**
|
|
@@ -2207,7 +2197,6 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2207
2197
|
onAnnualMileageChange,
|
|
2208
2198
|
onClose,
|
|
2209
2199
|
initialShowBreakdown,
|
|
2210
|
-
skipInitialScroll,
|
|
2211
2200
|
ratingLabel,
|
|
2212
2201
|
available,
|
|
2213
2202
|
onModeChange,
|
|
@@ -2222,7 +2211,6 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2222
2211
|
onToggleAddServices,
|
|
2223
2212
|
leasingAvailable = true,
|
|
2224
2213
|
t,
|
|
2225
|
-
titleOverride,
|
|
2226
2214
|
}) => {
|
|
2227
2215
|
// same "UVP-Rate"/list-price footnote badge + popover as FinanceCalculator's own hero — this
|
|
2228
2216
|
// modal's mobile "Rate anpassen" sheet renders its own separate copy of that hero row, so it
|
|
@@ -2326,14 +2314,14 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2326
2314
|
React.useEffect(() => {
|
|
2327
2315
|
if (!open) return;
|
|
2328
2316
|
setShowBreakdown(!!initialShowBreakdown);
|
|
2329
|
-
if (!initialShowBreakdown
|
|
2317
|
+
if (!initialShowBreakdown) return;
|
|
2330
2318
|
const timer = window.setTimeout(() => {
|
|
2331
2319
|
if (mobileBreakdownRef.current?.offsetParent) scrollSheetToBreakdown();
|
|
2332
2320
|
else desktopBreakdownRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
2333
2321
|
}, 50);
|
|
2334
2322
|
return () => window.clearTimeout(timer);
|
|
2335
2323
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2336
|
-
}, [open, initialShowBreakdown
|
|
2324
|
+
}, [open, initialShowBreakdown]);
|
|
2337
2325
|
// in-sheet details link: expanding scrolls down to the breakdown, collapsing back to the top.
|
|
2338
2326
|
const revealBreakdownRef = React.useRef(false);
|
|
2339
2327
|
React.useEffect(() => {
|
|
@@ -2343,24 +2331,6 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2343
2331
|
else animateSheetScroll(() => 0);
|
|
2344
2332
|
}, [showBreakdown, scrollSheetToBreakdown, animateSheetScroll]);
|
|
2345
2333
|
|
|
2346
|
-
// iOS Safari (26+, "Allow Website Tinting") paints its bottom toolbar area with the page's
|
|
2347
|
-
// <meta name="theme-color"> (site-wide blue #005CCB) — under the open white sheet that showed
|
|
2348
|
-
// as a solid blue band right below the CTA. While the sheet is open, theme-color is white;
|
|
2349
|
-
// on close the previous value(s) are restored. Other pages/states are untouched.
|
|
2350
|
-
React.useEffect(() => {
|
|
2351
|
-
if (!open || typeof document === 'undefined') return;
|
|
2352
|
-
const metas = Array.from(document.querySelectorAll<HTMLMetaElement>('meta[name="theme-color"]'));
|
|
2353
|
-
const prev = metas.map((m) => m.getAttribute('content'));
|
|
2354
|
-
metas.forEach((m) => m.setAttribute('content', '#FFFFFF'));
|
|
2355
|
-
return () => {
|
|
2356
|
-
metas.forEach((m, i) => {
|
|
2357
|
-
const v = prev[i];
|
|
2358
|
-
if (v == null) m.removeAttribute('content');
|
|
2359
|
-
else m.setAttribute('content', v);
|
|
2360
|
-
});
|
|
2361
|
-
};
|
|
2362
|
-
}, [open]);
|
|
2363
|
-
|
|
2364
2334
|
// mobile-only: swipe-down-to-dismiss on the grabber/header (the mockup's drag handle).
|
|
2365
2335
|
// The sheet follows the finger (imperative transform — no re-renders while dragging);
|
|
2366
2336
|
// released past 90px it slides out and closes, otherwise it springs back. The element
|
|
@@ -2401,7 +2371,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2401
2371
|
if (!open) return null;
|
|
2402
2372
|
const isLease = mode === 'leasing';
|
|
2403
2373
|
const isCash = mode === 'cash';
|
|
2404
|
-
const title =
|
|
2374
|
+
const title = isLease ? t('autobahn:modal.leasingDetails') : t('autobahn:modal.financingDetails');
|
|
2405
2375
|
const mobileTitle = isCash
|
|
2406
2376
|
? t('autobahn:modal.sheetTitleCash')
|
|
2407
2377
|
: isLease
|