@bytebrand/fe-ui-core-autobahn 1.0.174 → 1.0.176
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 +10 -47
- package/cards/CarRow.tsx +1 -5
- package/cards/cardParts.tsx +1 -11
- package/compat/CookieModal/CookieModal.tsx +1 -15
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +1 -6
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +3 -4
- package/compat/CookieModal/useModal.ts +1 -5
- package/constants/app.ts +1 -11
- package/constants/core.ts +1 -12
- package/locales/de/autobahn.json +1 -2
- package/locales/en/autobahn.json +1 -2
- package/package.json +30 -30
- package/theme/md3.css +3 -6
- package/ui/Dropdown.tsx +8 -16
- package/ui/index.ts +0 -2
- package/ui/usePortalMenuPosition.ts +12 -14
- package/utils/index.ts +0 -8
- package/ui/scrollFieldIntoView.ts +0 -41
- package/utils/cookieConsent.ts +0 -84
package/cards/CarCard.tsx
CHANGED
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
GalleryActivityPill,
|
|
39
39
|
cardSpec,
|
|
40
40
|
PaymentMode,
|
|
41
|
-
startPaymentMode,
|
|
42
41
|
callDealerSalesPhone,
|
|
43
42
|
DEALER_SALES_PHONE,
|
|
44
43
|
} from './cardParts';
|
|
@@ -99,11 +98,6 @@ export interface CarCardProps {
|
|
|
99
98
|
* (still onOpenRateAdjust).
|
|
100
99
|
*/
|
|
101
100
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
102
|
-
/**
|
|
103
|
-
* Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
|
|
104
|
-
* open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
|
|
105
|
-
*/
|
|
106
|
-
initialMode?: PaymentMode;
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
@@ -119,9 +113,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
119
113
|
onCall,
|
|
120
114
|
onOpenRateAdjust,
|
|
121
115
|
onShowFinancingDetails,
|
|
122
|
-
initialMode,
|
|
123
116
|
}) => {
|
|
124
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
117
|
+
const [mode, setMode] = useState<PaymentMode>('financing');
|
|
125
118
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
126
119
|
const [viewerOpen, setViewerOpen] = useState(false);
|
|
127
120
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -164,8 +157,6 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
164
157
|
// active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
|
|
165
158
|
const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
|
|
166
159
|
const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
|
|
167
|
-
// tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
|
|
168
|
-
const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
|
|
169
160
|
return (
|
|
170
161
|
<article
|
|
171
162
|
className="mcard mcard--interactive cc-card"
|
|
@@ -286,46 +277,18 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
286
277
|
<div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
|
|
287
278
|
<PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
|
|
288
279
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
|
|
289
|
-
{
|
|
290
|
-
visible, bottom-aligned — Kaufen's struck list price sits on its own line above
|
|
291
|
-
the price, so without this the row (and the card) grew/shrank by that line on
|
|
292
|
-
every tab switch. Same trick as .cc-terms-stack below. */}
|
|
293
|
-
<div className="cc-hero-stack">
|
|
294
|
-
{paymentModes.map((m) => (
|
|
295
|
-
<div
|
|
296
|
-
key={m}
|
|
297
|
-
className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
|
|
298
|
-
aria-hidden={m === mode ? undefined : true}
|
|
299
|
-
>
|
|
300
|
-
<PriceHero car={car} mode={m} t={t} alwaysShowUnit />
|
|
301
|
-
</div>
|
|
302
|
-
))}
|
|
303
|
-
</div>
|
|
280
|
+
<PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
|
|
304
281
|
<PriceEvalCol car={car} t={t} />
|
|
305
282
|
</div>
|
|
306
283
|
{/* same fallback CardCtaRow already uses below: pages that haven't wired a real
|
|
307
|
-
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
{
|
|
314
|
-
|
|
315
|
-
key={m}
|
|
316
|
-
className={'cc-terms-slot' + (m === mode ? '' : ' cc-terms-slot--hidden')}
|
|
317
|
-
aria-hidden={m === mode ? undefined : true}
|
|
318
|
-
>
|
|
319
|
-
<PriceTerms
|
|
320
|
-
car={car}
|
|
321
|
-
mode={m}
|
|
322
|
-
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
323
|
-
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
|
|
324
|
-
t={t}
|
|
325
|
-
/>
|
|
326
|
-
</div>
|
|
327
|
-
))}
|
|
328
|
-
</div>
|
|
284
|
+
"Rate anpassen" sheet yet still get a working "Details" link (opens the car). */}
|
|
285
|
+
<PriceTerms
|
|
286
|
+
car={car}
|
|
287
|
+
mode={mode}
|
|
288
|
+
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
289
|
+
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, mode) : undefined}
|
|
290
|
+
t={t}
|
|
291
|
+
/>
|
|
329
292
|
</div>
|
|
330
293
|
{/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
|
|
331
294
|
rendered, with real fallbacks the page can override once it wires its own
|
package/cards/CarRow.tsx
CHANGED
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
ZeroDownChip,
|
|
42
42
|
fmtKm,
|
|
43
43
|
PaymentMode,
|
|
44
|
-
startPaymentMode,
|
|
45
44
|
ratingTone,
|
|
46
45
|
} from './cardParts';
|
|
47
46
|
import { AutobahnCar } from './types';
|
|
@@ -81,8 +80,6 @@ export interface CarRowProps {
|
|
|
81
80
|
* links render as plain text (see PricePaths' own fallback).
|
|
82
81
|
*/
|
|
83
82
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
84
|
-
/** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
|
|
85
|
-
initialMode?: PaymentMode;
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
@@ -95,9 +92,8 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
95
92
|
t,
|
|
96
93
|
adminAction,
|
|
97
94
|
onShowFinancingDetails,
|
|
98
|
-
initialMode,
|
|
99
95
|
}) => {
|
|
100
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
96
|
+
const [mode, setMode] = useState<PaymentMode>('financing');
|
|
101
97
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
102
98
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
103
99
|
// always call the LATEST onMediaEnter without re-arming the observer on every render (the
|
package/cards/cardParts.tsx
CHANGED
|
@@ -489,11 +489,6 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
489
489
|
|
|
490
490
|
export type PaymentMode = 'financing' | 'leasing' | 'buy';
|
|
491
491
|
|
|
492
|
-
/** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
|
|
493
|
-
* without a lease rate — PriceTabs has no Leasing tab for it. */
|
|
494
|
-
export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
|
|
495
|
-
requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
|
|
496
|
-
|
|
497
492
|
export interface PriceTabsProps {
|
|
498
493
|
car: AutobahnCar;
|
|
499
494
|
mode: PaymentMode;
|
|
@@ -715,12 +710,7 @@ export const PriceTerms: React.FunctionComponent<{
|
|
|
715
710
|
onShowDetails?: () => void;
|
|
716
711
|
t: TranslationFunction;
|
|
717
712
|
}> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
|
|
718
|
-
|
|
719
|
-
// here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
|
|
720
|
-
// real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
|
|
721
|
-
// every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
|
|
722
|
-
// FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
|
|
723
|
-
if (mode === 'buy') return <div className="cc-terms" />;
|
|
713
|
+
if (mode === 'buy') return null;
|
|
724
714
|
const finFirstInstallment =
|
|
725
715
|
car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
|
|
726
716
|
const finMonths = car.finMonths ?? _finMonths;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import useModal from './useModal';
|
|
3
3
|
import { updateCookieList } from '../../utils/CommonUtils';
|
|
4
|
-
import { OPEN_COOKIE_SETTINGS_EVENT } from '../../utils/cookieConsent';
|
|
5
4
|
import Modal from './Modal';
|
|
6
5
|
|
|
7
6
|
export interface ICookieModal {
|
|
@@ -9,7 +8,7 @@ export interface ICookieModal {
|
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
|
|
12
|
-
const { isVisible, toggleModal
|
|
11
|
+
const { isVisible, toggleModal } = useModal();
|
|
13
12
|
const [modal, setModal] = useState('');
|
|
14
13
|
|
|
15
14
|
useEffect(
|
|
@@ -23,19 +22,6 @@ const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
|
|
|
23
22
|
[]
|
|
24
23
|
);
|
|
25
24
|
|
|
26
|
-
// ADV-268: "Cookie-Einstellungen ändern" (account page) reopens the settings dialog
|
|
27
|
-
useEffect(
|
|
28
|
-
() => {
|
|
29
|
-
const onOpenSettings = () => {
|
|
30
|
-
setModal('MANAGE_COOKIE_MODAL');
|
|
31
|
-
openModal();
|
|
32
|
-
};
|
|
33
|
-
window.addEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
34
|
-
return () => window.removeEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
35
|
-
},
|
|
36
|
-
[]
|
|
37
|
-
);
|
|
38
|
-
|
|
39
25
|
useEffect(
|
|
40
26
|
() => {
|
|
41
27
|
if (!isVisible) return undefined;
|
|
@@ -8,7 +8,6 @@ import MaterialAccordionGroup from '../../../MdAccordionGroup/MdAccordionGroup';
|
|
|
8
8
|
import MaterialSwitch from '../../../MdSwitch/MdSwitch';
|
|
9
9
|
import { COOKIE_SCHEMA, COOKIE_SCHEMA_LINKS } from '../../../../constants/common';
|
|
10
10
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
11
|
-
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
12
11
|
|
|
13
12
|
import styles from './ManageCookieModal.styl';
|
|
14
13
|
|
|
@@ -45,10 +44,6 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
45
44
|
.reduce((acc, item) => ({ ...acc, [item]: !!savedConfig && !savedDisabledMarketing.includes(item) }), {});
|
|
46
45
|
setAnalyticsSwitches(newAnalyticsSwitches);
|
|
47
46
|
setMarketingSwitches(newMarketingSwitches);
|
|
48
|
-
// ADV-268: reopened from the account page, a category whose cookies are all allowed shows
|
|
49
|
-
// its master switch on (it always started off)
|
|
50
|
-
setAnalyticsMasterSwitch(Object.values(newAnalyticsSwitches).every(Boolean));
|
|
51
|
-
setMarketingMasterSwitch(Object.values(newMarketingSwitches).every(Boolean));
|
|
52
47
|
},
|
|
53
48
|
[]
|
|
54
49
|
);
|
|
@@ -91,7 +86,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
91
86
|
marketing: Object.keys(marketingSwitches).filter(i => !marketingSwitches[i]) || [],
|
|
92
87
|
analytics: Object.keys(analyticsSwitches).filter(i => !analyticsSwitches[i]) || []
|
|
93
88
|
};
|
|
94
|
-
|
|
89
|
+
localStorage.setItem('cookieConfig', JSON.stringify(cookieConfig));
|
|
95
90
|
updateCookieList(handleSentryInit);
|
|
96
91
|
toggleModal();
|
|
97
92
|
};
|
|
@@ -3,7 +3,6 @@ import IconSVG from '../../../../iconsvg/IconSVG';
|
|
|
3
3
|
import Button from '../../../Button/Button';
|
|
4
4
|
import styles from './PreviewCookieModal.styl';
|
|
5
5
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
6
|
-
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
7
6
|
import { COOKIE_SCHEMA } from '../../../../constants/common';
|
|
8
7
|
|
|
9
8
|
interface IPreviewCookieModal {
|
|
@@ -15,16 +14,16 @@ interface IPreviewCookieModal {
|
|
|
15
14
|
const PreviewCookieModal = ({ toggleModal, setModal, handleSentryInit } : IPreviewCookieModal) => {
|
|
16
15
|
const environment = window.location.origin;
|
|
17
16
|
const onAcceptAll = () => {
|
|
18
|
-
|
|
17
|
+
localStorage.setItem('cookieConfig', JSON.stringify({ marketing: [], analytics: [] }));
|
|
19
18
|
updateCookieList(handleSentryInit);
|
|
20
19
|
toggleModal();
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
const onDisableAll = () => {
|
|
24
|
-
|
|
23
|
+
localStorage.setItem('cookieConfig', JSON.stringify({
|
|
25
24
|
marketing: Object.values(COOKIE_SCHEMA.marketing).reduce((acc: string[], val: string[]) => acc.concat(val), []),
|
|
26
25
|
analytics: Object.values(COOKIE_SCHEMA.analytics).reduce((acc: string[], val: string[]) => acc.concat(val), [])
|
|
27
|
-
});
|
|
26
|
+
}));
|
|
28
27
|
updateCookieList(handleSentryInit);
|
|
29
28
|
toggleModal();
|
|
30
29
|
};
|
package/constants/app.ts
CHANGED
|
@@ -40,17 +40,7 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
40
40
|
i18n_KEY: 'i18nLanguage'
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
// SecurityError that took down the whole bundle. Blocked storage behaves like "nothing saved".
|
|
45
|
-
const readStoredLang = (): string | null => {
|
|
46
|
-
try {
|
|
47
|
-
return localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const DEFAULT_LANG: string = typeof window !== 'undefined' ? readStoredLang() : 'de';
|
|
43
|
+
export const DEFAULT_LANG: string = typeof window !== 'undefined' ? localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : 'de';
|
|
54
44
|
|
|
55
45
|
// Default support contact phone
|
|
56
46
|
export const CONTACT_PHONE: string = '+498004030182';
|
package/constants/core.ts
CHANGED
|
@@ -35,18 +35,7 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
35
35
|
i18n_KEY: 'i18nLanguage'
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
// window.localStorage throws a SecurityError, which took down the whole bundle (landing
|
|
40
|
-
// page never rendered). Treat blocked storage like "no language saved".
|
|
41
|
-
const readStoredLang = (): string | null => {
|
|
42
|
-
try {
|
|
43
|
-
return typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null;
|
|
44
|
-
} catch (e) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const DEFAULT_LANG: string = readStoredLang() ?? 'de';
|
|
38
|
+
export const DEFAULT_LANG: string = (typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null) ?? 'de';
|
|
50
39
|
|
|
51
40
|
export const ROW_STYLES = {
|
|
52
41
|
marginBottom: 10
|
package/locales/de/autobahn.json
CHANGED
package/locales/en/autobahn.json
CHANGED
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
|
|
5
|
-
"main": "index.ts",
|
|
6
|
-
"license": "UNLICENSED",
|
|
7
|
-
"peerDependencies": {
|
|
8
|
-
"react": "^18.0.0",
|
|
9
|
-
"react-dom": "^18.0.0"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@bytebrand/car-schema-selectors": "^2.0.7",
|
|
13
|
-
"@bytebrand/fe-financing": "^5.14.20",
|
|
14
|
-
"classnames": "2.2.6",
|
|
15
|
-
"clsx": "^2.1.1",
|
|
16
|
-
"d3-format": "1.4.5",
|
|
17
|
-
"js-cookie": "^2.2.0",
|
|
18
|
-
"lodash": "^4.17.21",
|
|
19
|
-
"lucide-react": "^0.288.0",
|
|
20
|
-
"mobx-react": "^7.6.0",
|
|
21
|
-
"moment": "^2.29.1",
|
|
22
|
-
"qs": "^6.6.0",
|
|
23
|
-
"react-device-detect": "^2.1.2",
|
|
24
|
-
"react-grid-system": "^5.0.2",
|
|
25
|
-
"react-lazyload": "^3.2.0",
|
|
26
|
-
"react-scroll": "^1.9.3",
|
|
27
|
-
"react-slick": "^0.29.0",
|
|
28
|
-
"slick-carousel": "1.8.1"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
+
"version": "1.0.176",
|
|
4
|
+
"description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"react": "^18.0.0",
|
|
9
|
+
"react-dom": "^18.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@bytebrand/car-schema-selectors": "^2.0.7",
|
|
13
|
+
"@bytebrand/fe-financing": "^5.14.20",
|
|
14
|
+
"classnames": "2.2.6",
|
|
15
|
+
"clsx": "^2.1.1",
|
|
16
|
+
"d3-format": "1.4.5",
|
|
17
|
+
"js-cookie": "^2.2.0",
|
|
18
|
+
"lodash": "^4.17.21",
|
|
19
|
+
"lucide-react": "^0.288.0",
|
|
20
|
+
"mobx-react": "^7.6.0",
|
|
21
|
+
"moment": "^2.29.1",
|
|
22
|
+
"qs": "^6.6.0",
|
|
23
|
+
"react-device-detect": "^2.1.2",
|
|
24
|
+
"react-grid-system": "^5.0.2",
|
|
25
|
+
"react-lazyload": "^3.2.0",
|
|
26
|
+
"react-scroll": "^1.9.3",
|
|
27
|
+
"react-slick": "^0.29.0",
|
|
28
|
+
"slick-carousel": "1.8.1"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/theme/md3.css
CHANGED
|
@@ -10100,8 +10100,7 @@ line-height: 31px;
|
|
|
10100
10100
|
z-index: 71;
|
|
10101
10101
|
background: var(--md-surface);
|
|
10102
10102
|
border-radius: var(--md-r-xl) var(--md-r-xl) 0 0;
|
|
10103
|
-
|
|
10104
|
-
max-height: 92%;
|
|
10103
|
+
max-height: 92vh;
|
|
10105
10104
|
display: flex;
|
|
10106
10105
|
flex-direction: column;
|
|
10107
10106
|
box-shadow: 0 -8px 30px rgba(16, 22, 42, 0.22);
|
|
@@ -14252,8 +14251,7 @@ color: #005CFF;
|
|
|
14252
14251
|
flex-direction: column;
|
|
14253
14252
|
width: 100%;
|
|
14254
14253
|
max-width: 560px;
|
|
14255
|
-
|
|
14256
|
-
max-height: 100%;
|
|
14254
|
+
max-height: calc(100vh - 32px);
|
|
14257
14255
|
background: var(--md-sc-lowest, #fff);
|
|
14258
14256
|
color: var(--md-on-surface);
|
|
14259
14257
|
border-radius: var(--md-r-lg);
|
|
@@ -14399,8 +14397,7 @@ color: #005CFF;
|
|
|
14399
14397
|
}
|
|
14400
14398
|
.md3 .mmodal {
|
|
14401
14399
|
max-width: 100%;
|
|
14402
|
-
|
|
14403
|
-
max-height: 92%;
|
|
14400
|
+
max-height: 92vh;
|
|
14404
14401
|
border-radius: var(--md-r-lg) var(--md-r-lg) 0 0;
|
|
14405
14402
|
border-bottom: 0;
|
|
14406
14403
|
animation: mmodal-sheet-up 0.25s ease-out;
|
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;
|
|
@@ -190,22 +189,15 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
190
189
|
if (allowCustomValue) setQuery(value || '');
|
|
191
190
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
192
191
|
|
|
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.
|
|
192
|
+
// when opened searchable, focus the search input instead of leaving focus on the trigger.
|
|
193
|
+
// scrollIntoView first: on mobile the keyboard is about to eat ~40% of the viewport, so the
|
|
194
|
+
// trigger (and the popover below it) needs to already be scrolled above the fold before focus
|
|
195
|
+
// fires, or the popover can end up hidden behind the keyboard with no way to see it open.
|
|
203
196
|
React.useEffect(() => {
|
|
204
|
-
if (!open) return;
|
|
205
|
-
if (rootRef.current
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// <button> already has focus from the click/keypress that opened it.
|
|
197
|
+
if (!open || !searchable) return;
|
|
198
|
+
if (rootRef.current && rootRef.current.scrollIntoView) {
|
|
199
|
+
rootRef.current.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
200
|
+
}
|
|
209
201
|
if (searchRef.current) {
|
|
210
202
|
searchRef.current.focus();
|
|
211
203
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
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
|
|
|
@@ -79,20 +79,6 @@ const ESTIMATED_MENU_HEIGHT = 300;
|
|
|
79
79
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
80
80
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
81
81
|
|
|
82
|
-
// Module-level (not hook-local) so Dropdown.tsx's own searchable-open scroll effect can reuse the
|
|
83
|
-
// exact same measurement — the sticky app header (.topbar, position:sticky/top:0) sits over the
|
|
84
|
-
// top of the viewport on every page that uses it (TopBar's autoHideOnScroll is opt-in, off by
|
|
85
|
-
// default — most pages keep it permanently docked), so anything that scrolls/positions content
|
|
86
|
-
// near the top of the viewport needs to stop at its live bottom edge, not y=0. Reading the
|
|
87
|
-
// header's live bottom edge (0 when absent, e.g. inside a modal, or when autoHideOnScroll has slid
|
|
88
|
-
// it away) gives a correct boundary without hardcoding a pixel height that could drift from the
|
|
89
|
-
// header's own CSS.
|
|
90
|
-
export const getSafeTop = (): number => {
|
|
91
|
-
if (typeof document === 'undefined') return 0;
|
|
92
|
-
const header = document.querySelector('.topbar');
|
|
93
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
82
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
97
83
|
enabled,
|
|
98
84
|
open,
|
|
@@ -135,6 +121,18 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
135
121
|
};
|
|
136
122
|
}, [enabled, open, portalRoot]);
|
|
137
123
|
|
|
124
|
+
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
125
|
+
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
126
|
+
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
127
|
+
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
128
|
+
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
129
|
+
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
130
|
+
const getSafeTop = (): number => {
|
|
131
|
+
if (typeof document === 'undefined') return 0;
|
|
132
|
+
const header = document.querySelector('.topbar');
|
|
133
|
+
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
134
|
+
};
|
|
135
|
+
|
|
138
136
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
139
137
|
|
|
140
138
|
const positionMenu = React.useCallback(() => {
|
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';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — shared "scroll a just-opened/just-focused field to the top of the
|
|
2
|
-
// page" behaviour, used by Dropdown.tsx and by fe-main's DualRange/RateSlider (FilterContent.tsx)
|
|
3
|
-
// text fields on /search/detailed. On mobile, opening a dropdown's menu or focusing a text field
|
|
4
|
-
// brings the on-screen keyboard up and/or needs room for a popover below the field — if the field
|
|
5
|
-
// is sitting mid-page, there may not be enough space left below it once the keyboard/menu takes
|
|
6
|
-
// its share. Scrolling the field to the very top of the page first maximizes what's available.
|
|
7
|
-
//
|
|
8
|
-
// Extracted out of Dropdown.tsx so it can be shared verbatim with fe-main's non-Dropdown form
|
|
9
|
-
// fields (DualRange/RateSlider's text inputs) — same problem, same fix, one place to keep them
|
|
10
|
-
// from drifting apart. See Dropdown.tsx's own call site for the original reasoning this was
|
|
11
|
-
// pulled from.
|
|
12
|
-
export function scrollFieldIntoView(field: HTMLElement): void {
|
|
13
|
-
if (typeof window === 'undefined') return;
|
|
14
|
-
// Mobile-only: the on-screen-keyboard/popover space problem this fixes doesn't exist on
|
|
15
|
-
// desktop, where there's no keyboard pushing the viewport around. Same breakpoint + matchMedia
|
|
16
|
-
// pattern as Modal.tsx/CardCarousel.tsx elsewhere in this lib.
|
|
17
|
-
if (window.matchMedia('(min-width: 601px)').matches) return;
|
|
18
|
-
// Anchor on whichever is higher up: the field itself, or a short field label/caption sitting
|
|
19
|
-
// directly above it (own previous sibling, or — the common "label above a row of controls"
|
|
20
|
-
// shape, e.g. "Marke & Modell" above the Make/Model row on /search/detailed — the wrapping
|
|
21
|
-
// row's previous sibling). Checked by height, not by class name, so this works for ANY
|
|
22
|
-
// caller's label without this needing to know that call site's specific markup.
|
|
23
|
-
const MAX_LABEL_HEIGHT = 30;
|
|
24
|
-
const asLabel = (el: Element | null): HTMLElement | null => {
|
|
25
|
-
if (!(el instanceof HTMLElement)) return null;
|
|
26
|
-
const h = el.getBoundingClientRect().height;
|
|
27
|
-
return h > 0 && h <= MAX_LABEL_HEIGHT ? el : null;
|
|
28
|
-
};
|
|
29
|
-
const anchor =
|
|
30
|
-
asLabel(field.previousElementSibling) ||
|
|
31
|
-
asLabel(field.parentElement && field.parentElement.previousElementSibling) ||
|
|
32
|
-
field;
|
|
33
|
-
// No sticky-header reservation here: every current caller (NewMainPage '/', FilterContent on
|
|
34
|
-
// '/search*') sits on a page where TopBar's own autoHideOnScroll is on (App.tsx: isHomePage ||
|
|
35
|
-
// isSearchPage) — the header slides itself out of the way the instant this scroll starts,
|
|
36
|
-
// independently of this call, so reserving space for it here would double-count.
|
|
37
|
-
const GAP = 8;
|
|
38
|
-
const rect = anchor.getBoundingClientRect();
|
|
39
|
-
const targetY = window.scrollY + rect.top - GAP;
|
|
40
|
-
window.scrollTo({ top: Math.max(0, targetY), behavior: 'smooth' });
|
|
41
|
-
}
|
package/utils/cookieConsent.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// ADV-268 — the cookie consent store (`localStorage['cookieConfig']`: per category the DISABLED
|
|
2
|
-
// vendor-cookie names, see COOKIE_SCHEMA) plus what the account page needs on top of it:
|
|
3
|
-
// - when the choice last changed (`cookieConfigChangedAt`, ISO), written on every save that
|
|
4
|
-
// changes it — the consent dialogs save through saveCookieConfig;
|
|
5
|
-
// - a window event after each save, so a page showing the state can update live;
|
|
6
|
-
// - openCookieSettings(), which makes the mounted CookieModal show its settings dialog again.
|
|
7
|
-
// Storage access is guarded: with site storage blocked every read returns "no choice yet".
|
|
8
|
-
|
|
9
|
-
import { COOKIE_SCHEMA } from '../constants/common';
|
|
10
|
-
|
|
11
|
-
export const COOKIE_CONFIG_KEY = 'cookieConfig';
|
|
12
|
-
export const COOKIE_CONFIG_CHANGED_AT_KEY = 'cookieConfigChangedAt';
|
|
13
|
-
export const COOKIE_CONSENT_CHANGE_EVENT = 'autode:cookie-consent-change';
|
|
14
|
-
export const OPEN_COOKIE_SETTINGS_EVENT = 'autode:open-cookie-settings';
|
|
15
|
-
|
|
16
|
-
export interface ICookieConfig {
|
|
17
|
-
marketing: string[];
|
|
18
|
-
analytics: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type CookieCategoryState = 'on' | 'partial' | 'off';
|
|
22
|
-
|
|
23
|
-
export interface ICookieConsentState {
|
|
24
|
-
/** false until the visitor saved a choice in the cookie dialog */
|
|
25
|
-
decided: boolean;
|
|
26
|
-
/** ISO date of the last change, null when unknown (no choice yet, or saved before it was recorded) */
|
|
27
|
-
changedAt: string | null;
|
|
28
|
-
analytics: CookieCategoryState;
|
|
29
|
-
marketing: CookieCategoryState;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const vendorCookies = (category: 'analytics' | 'marketing'): string[] =>
|
|
33
|
-
Object.values(COOKIE_SCHEMA[category]).reduce((acc: string[], val: string[]) => acc.concat(val), []);
|
|
34
|
-
|
|
35
|
-
const readStorage = (key: string): string | null => {
|
|
36
|
-
try {
|
|
37
|
-
return localStorage.getItem(key);
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const saveCookieConfig = (config: ICookieConfig | Record<string, string[]>) => {
|
|
44
|
-
const next = JSON.stringify(config);
|
|
45
|
-
try {
|
|
46
|
-
const previous = localStorage.getItem(COOKIE_CONFIG_KEY);
|
|
47
|
-
localStorage.setItem(COOKIE_CONFIG_KEY, next);
|
|
48
|
-
if (previous !== next || !localStorage.getItem(COOKIE_CONFIG_CHANGED_AT_KEY)) {
|
|
49
|
-
localStorage.setItem(COOKIE_CONFIG_CHANGED_AT_KEY, new Date().toISOString());
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
window.dispatchEvent(new Event(COOKIE_CONSENT_CHANGE_EVENT));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const getCookieConsentState = (): ICookieConsentState => {
|
|
58
|
-
let config: Partial<ICookieConfig> | null = null;
|
|
59
|
-
try {
|
|
60
|
-
config = JSON.parse(readStorage(COOKIE_CONFIG_KEY));
|
|
61
|
-
} catch (e) {
|
|
62
|
-
config = null;
|
|
63
|
-
}
|
|
64
|
-
if (!config) return { decided: false, changedAt: null, analytics: 'off', marketing: 'off' };
|
|
65
|
-
|
|
66
|
-
const categoryState = (category: 'analytics' | 'marketing'): CookieCategoryState => {
|
|
67
|
-
const disabled = Array.isArray(config[category]) ? config[category] : [];
|
|
68
|
-
const all = vendorCookies(category);
|
|
69
|
-
const allowed = all.filter((cookie) => !disabled.includes(cookie)).length;
|
|
70
|
-
if (allowed === all.length) return 'on';
|
|
71
|
-
return allowed ? 'partial' : 'off';
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
decided: true,
|
|
76
|
-
changedAt: readStorage(COOKIE_CONFIG_CHANGED_AT_KEY),
|
|
77
|
-
analytics: categoryState('analytics'),
|
|
78
|
-
marketing: categoryState('marketing')
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const openCookieSettings = () => {
|
|
83
|
-
window.dispatchEvent(new Event(OPEN_COOKIE_SETTINGS_EVENT));
|
|
84
|
-
};
|