@bytebrand/fe-ui-core-autobahn 1.0.175 → 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/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.175",
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
- /* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
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
- /* % of the scrim (fixed, inset 0, 16px padding) instead of calc(100vh - 32px): see the iOS note on the mobile .mmodal below */
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
- /* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
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
- // Scroll the trigger (searchable or not) to the top of the page on open, THEN — searchable
194
- // only — focus the search input instead of leaving focus on the trigger. Every Dropdown shares
195
- // this, not just searchable ones: on mobile a trigger sitting mid-page can open a menu that
196
- // runs off the bottom of the viewport with no way to see the rest of it, same underlying
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) scrollFieldIntoView(rootRef.current);
206
- // searchRef is only ever attached in the searchable+open (editing) render branch, so this
207
- // naturally no-ops for a non-searchable dropdown — nothing else to focus there, the trigger
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
 
@@ -76,26 +76,9 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
76
76
  // reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
77
77
  // clamped to the space actually available (see `maxHeight` above), not just guessed at.
78
78
  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
79
  // a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
83
80
  const SELF_SCROLL_GRACE_MS = 500;
84
81
 
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
82
  export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
100
83
  enabled,
101
84
  open,
@@ -138,6 +121,18 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
138
121
  };
139
122
  }, [enabled, open, portalRoot]);
140
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
+
141
136
  const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
142
137
 
143
138
  const positionMenu = React.useCallback(() => {
@@ -161,8 +156,7 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
161
156
  // cap can still be taller than what's really available, which is what let the menu paint over
162
157
  // the header in the first place. The consumer's own overflow-y:auto takes it from there once
163
158
  // content exceeds this.
164
- // `available` is the LIST's height: the box (list + MENU_CHROME) must end inside the viewport.
165
- const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, (openAbove ? spaceAbove : spaceBelow) - MENU_CHROME));
159
+ const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, openAbove ? spaceAbove : spaceBelow));
166
160
  setMenuPos({
167
161
  width: rect.width,
168
162
  left: menuAlign === 'right' ? 'auto' : rect.left,
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
- }
@@ -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
- };