@bytebrand/fe-ui-core-autobahn 1.0.210 → 1.0.212

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.
Files changed (45) hide show
  1. package/cards/CarCard.tsx +8 -1
  2. package/cards/CarCardSkeleton.tsx +103 -0
  3. package/cards/CarRow.tsx +5 -1
  4. package/cards/CarRowSkeleton.tsx +152 -0
  5. package/cards/cardParts.tsx +1368 -1363
  6. package/cards/index.ts +6 -0
  7. package/cards/types.ts +182 -182
  8. package/chrome/AccountMenuIcon.tsx +109 -0
  9. package/chrome/Footer.tsx +16 -3
  10. package/chrome/TopBar.tsx +139 -266
  11. package/compat/CookieModal/CookieModal.tsx +20 -6
  12. package/compat/CookieModal/Modal.tsx +6 -3
  13. package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +43 -15
  14. package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +4 -3
  15. package/compat/CookieModal/useModal.ts +5 -1
  16. package/compat/Loader/Loader.tsx +1 -7
  17. package/compat/MdField/MdField.tsx +28 -4
  18. package/compat/TimePicker/TimePicker.tsx +12 -2
  19. package/data/toAutobahnCar.ts +600 -586
  20. package/iconsvg/IconSVG.tsx +1 -5
  21. package/locales/de/autobahn.json +891 -857
  22. package/locales/en/autobahn.json +891 -857
  23. package/package.json +2 -2
  24. package/theme/md3.css +15678 -11743
  25. package/ui/CreditCostNotice.tsx +44 -44
  26. package/ui/CreditKeyFigures.tsx +244 -244
  27. package/ui/Dropdown.tsx +29 -10
  28. package/ui/FormCheckbox.tsx +22 -2
  29. package/ui/FormField.tsx +2 -1
  30. package/ui/Icon.tsx +6 -0
  31. package/ui/MfieldCheckIcon.tsx +13 -0
  32. package/ui/Modal.tsx +84 -6
  33. package/ui/Skeleton.tsx +79 -20
  34. package/ui/index.ts +96 -94
  35. package/ui/scrollFieldIntoView.ts +41 -0
  36. package/ui/usePortalMenuPosition.ts +27 -15
  37. package/utils/cookieConsent.ts +84 -0
  38. package/utils/index.ts +10 -0
  39. package/vdp/FinanceCalculator.tsx +1148 -1134
  40. package/vdp/VdpModules.tsx +3869 -4437
  41. package/vdp/index.ts +0 -3
  42. package/vdp/types.ts +7 -17
  43. package/vehiclesProps/accidentDisclosure.ts +25 -0
  44. package/vehiclesProps/decoratedLightProps.tsx +4 -0
  45. package/vehiclesProps/decoratedProps.tsx +4 -0
package/ui/index.ts CHANGED
@@ -1,94 +1,96 @@
1
- // Autobahn (auto.de redesign) — presentational UI primitives.
2
- //
3
- // Typed, pure React 18 + TS port of the design kit's primitives from
4
- // docs/redesign/design-source/ui_kits/website/ui.jsx. The original kit exported
5
- // everything via `Object.assign(window, {...})`; here each primitive is a real
6
- // ES module with an explicit props interface, re-exported below.
7
- //
8
- // SCOPING — IMPORTANT:
9
- // These components rely on the scoped CSS layer at
10
- // services/fe-main/source/theme/autobahn/ (md3.css)
11
- // where EVERY utility class is scoped under `.md3` (e.g. `.md3 .mbtn`,
12
- // `.md3 .chip`, `.md3 .statchip--good`, `.md3 .segmented .on`, `.md3 .mfield`,
13
- // `.md3 .num`, `.md3 .car-arrow`, `.md3 .imglabel`, `.md3 .md-title`, …).
14
- // They therefore ONLY render correctly inside a `<div className="md3">` subtree.
15
- //
16
- // All components are pure/presentational: no store, no API, no window access.
17
-
18
- export { default as Icon } from './Icon';
19
- export type { IconProps } from './Icon';
20
-
21
- export { default as Button } from './Button';
22
- export type { ButtonProps, ButtonVariant, ButtonSize } from './Button';
23
-
24
- export { default as IconButton } from './IconButton';
25
- export type { IconButtonProps } from './IconButton';
26
-
27
- export { default as Chip } from './Chip';
28
- export type { ChipProps } from './Chip';
29
-
30
- export { default as StatChip } from './StatChip';
31
- export type { StatChipProps, StatChipTone } from './StatChip';
32
-
33
- export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
34
- export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
35
-
36
- export { default as CreditKeyFigures, creditKeyFigureLines, hasCreditKeyFigures, leasingKeyFigures } from './CreditKeyFigures';
37
- export type { CreditKeyFiguresProps, CreditKeyFiguresData, LeasingKeyFigureInputs } from './CreditKeyFigures';
38
-
39
- export { default as Segmented } from './Segmented';
40
- export type { SegmentedProps, SegmentedOption } from './Segmented';
41
-
42
- export { default as FormField } from './FormField';
43
- export type { FormFieldProps } from './FormField';
44
-
45
- export { default as Dropdown } from './Dropdown';
46
- export type { DropdownProps, DropdownOption } from './Dropdown';
47
-
48
- export { default as Spec } from './Spec';
49
- export type { SpecProps } from './Spec';
50
-
51
- export { default as Price } from './Price';
52
- export type { PriceProps } from './Price';
53
-
54
- export { default as Stars } from './Stars';
55
- export type { StarsProps } from './Stars';
56
-
57
- export { default as PriceEvalBar } from './PriceEvalBar';
58
- export type { PriceEvalBarProps } from './PriceEvalBar';
59
-
60
- export { default as SaveChip } from './SaveChip';
61
- export type { SaveChipProps } from './SaveChip';
62
-
63
- export { default as CardCarousel } from './CardCarousel';
64
- export type { CardCarouselProps } from './CardCarousel';
65
-
66
- // ── md3 kit (Group-B in-place rebuild) — form-bound + layout + overlay primitives ──
67
- export { default as FormDropdown } from './FormDropdown';
68
- export type { FormDropdownProps } from './FormDropdown';
69
- export { default as FormCheckbox } from './FormCheckbox';
70
- export type { FormCheckboxProps } from './FormCheckbox';
71
- export { default as FormRadioGroup } from './FormRadioGroup';
72
- export type { FormRadioGroupProps } from './FormRadioGroup';
73
- export { default as FormRadio } from './FormRadio';
74
- export type { FormRadioProps } from './FormRadio';
75
- export { default as Accordion } from './Accordion';
76
- export type { AccordionProps } from './Accordion';
77
- export { default as Modal } from './Modal';
78
- export type { ModalProps, ModalSize } from './Modal';
79
- export { default as DatePicker } from './DatePicker';
80
- export type { DatePickerProps } from './DatePicker';
81
- export { default as Table, Thead, Tbody, Tr, Th, Td } from './Table';
82
- export type { TableProps, TheadProps, TbodyProps, TrProps, ThProps, TdProps, TableAlign } from './Table';
83
- export { default as Switch } from './Switch';
84
- export type { SwitchProps } from './Switch';
85
- export { default as Textarea } from './Textarea';
86
- export type { TextareaProps } from './Textarea';
87
- export { default as Pagination } from './Pagination';
88
- export type { PaginationProps } from './Pagination';
89
- export { default as Stepper } from './Stepper';
90
- export type { StepperProps, StepperStep, StepStatus } from './Stepper';
91
- export { default as FileUpload } from './FileUpload';
92
- export type { FileUploadProps } from './FileUpload';
93
- export { default as Skeleton } from './Skeleton';
94
- export type { SkeletonProps } from './Skeleton';
1
+ // Autobahn (auto.de redesign) — presentational UI primitives.
2
+ //
3
+ // Typed, pure React 18 + TS port of the design kit's primitives from
4
+ // docs/redesign/design-source/ui_kits/website/ui.jsx. The original kit exported
5
+ // everything via `Object.assign(window, {...})`; here each primitive is a real
6
+ // ES module with an explicit props interface, re-exported below.
7
+ //
8
+ // SCOPING — IMPORTANT:
9
+ // These components rely on the scoped CSS layer at
10
+ // services/fe-main/source/theme/autobahn/ (md3.css)
11
+ // where EVERY utility class is scoped under `.md3` (e.g. `.md3 .mbtn`,
12
+ // `.md3 .chip`, `.md3 .statchip--good`, `.md3 .segmented .on`, `.md3 .mfield`,
13
+ // `.md3 .num`, `.md3 .car-arrow`, `.md3 .imglabel`, `.md3 .md-title`, …).
14
+ // They therefore ONLY render correctly inside a `<div className="md3">` subtree.
15
+ //
16
+ // All components are pure/presentational: no store, no API, no window access.
17
+
18
+ export { default as Icon } from './Icon';
19
+ export type { IconProps } from './Icon';
20
+
21
+ export { default as Button } from './Button';
22
+ export type { ButtonProps, ButtonVariant, ButtonSize } from './Button';
23
+
24
+ export { default as IconButton } from './IconButton';
25
+ export type { IconButtonProps } from './IconButton';
26
+
27
+ export { default as Chip } from './Chip';
28
+ export type { ChipProps } from './Chip';
29
+
30
+ export { default as StatChip } from './StatChip';
31
+ export type { StatChipProps, StatChipTone } from './StatChip';
32
+
33
+ export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
34
+ export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
35
+
36
+ export { default as CreditKeyFigures, creditKeyFigureLines, hasCreditKeyFigures, leasingKeyFigures } from './CreditKeyFigures';
37
+ export type { CreditKeyFiguresProps, CreditKeyFiguresData, LeasingKeyFigureInputs } from './CreditKeyFigures';
38
+
39
+ export { default as Segmented } from './Segmented';
40
+ export type { SegmentedProps, SegmentedOption } from './Segmented';
41
+
42
+ export { default as FormField } from './FormField';
43
+ export type { FormFieldProps } from './FormField';
44
+
45
+ export { default as Dropdown } from './Dropdown';
46
+ export type { DropdownProps, DropdownOption } from './Dropdown';
47
+
48
+ export { scrollFieldIntoView } from './scrollFieldIntoView';
49
+
50
+ export { default as Spec } from './Spec';
51
+ export type { SpecProps } from './Spec';
52
+
53
+ export { default as Price } from './Price';
54
+ export type { PriceProps } from './Price';
55
+
56
+ export { default as Stars } from './Stars';
57
+ export type { StarsProps } from './Stars';
58
+
59
+ export { default as PriceEvalBar } from './PriceEvalBar';
60
+ export type { PriceEvalBarProps } from './PriceEvalBar';
61
+
62
+ export { default as SaveChip } from './SaveChip';
63
+ export type { SaveChipProps } from './SaveChip';
64
+
65
+ export { default as CardCarousel } from './CardCarousel';
66
+ export type { CardCarouselProps } from './CardCarousel';
67
+
68
+ // ── md3 kit (Group-B in-place rebuild) — form-bound + layout + overlay primitives ──
69
+ export { default as FormDropdown } from './FormDropdown';
70
+ export type { FormDropdownProps } from './FormDropdown';
71
+ export { default as FormCheckbox } from './FormCheckbox';
72
+ export type { FormCheckboxProps } from './FormCheckbox';
73
+ export { default as FormRadioGroup } from './FormRadioGroup';
74
+ export type { FormRadioGroupProps } from './FormRadioGroup';
75
+ export { default as FormRadio } from './FormRadio';
76
+ export type { FormRadioProps } from './FormRadio';
77
+ export { default as Accordion } from './Accordion';
78
+ export type { AccordionProps } from './Accordion';
79
+ export { default as Modal } from './Modal';
80
+ export type { ModalProps, ModalSize } from './Modal';
81
+ export { default as DatePicker } from './DatePicker';
82
+ export type { DatePickerProps } from './DatePicker';
83
+ export { default as Table, Thead, Tbody, Tr, Th, Td } from './Table';
84
+ export type { TableProps, TheadProps, TbodyProps, TrProps, ThProps, TdProps, TableAlign } from './Table';
85
+ export { default as Switch } from './Switch';
86
+ export type { SwitchProps } from './Switch';
87
+ export { default as Textarea } from './Textarea';
88
+ export type { TextareaProps } from './Textarea';
89
+ export { default as Pagination } from './Pagination';
90
+ export type { PaginationProps } from './Pagination';
91
+ export { default as Stepper } from './Stepper';
92
+ export type { StepperProps, StepperStep, StepStatus } from './Stepper';
93
+ export { default as FileUpload } from './FileUpload';
94
+ export type { FileUploadProps } from './FileUpload';
95
+ export { default as Skeleton } from './Skeleton';
96
+ export type { SkeletonProps } from './Skeleton';
@@ -0,0 +1,41 @@
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
+ }
@@ -45,6 +45,11 @@ 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';
48
53
  /** called when the trigger scrolls out of view entirely, or a real user scroll happens after
49
54
  * the post-open grace window — the menu has nothing sensible left to anchor to or chase. */
50
55
  onCloseAway: () => void;
@@ -71,14 +76,32 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
71
76
  // reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
72
77
  // clamped to the space actually available (see `maxHeight` above), not just guessed at.
73
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;
74
82
  // a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
75
83
  const SELF_SCROLL_GRACE_MS = 500;
76
84
 
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
+
77
99
  export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
78
100
  enabled,
79
101
  open,
80
102
  rootRef,
81
103
  menuAlign = 'left',
104
+ openDirection = 'auto',
82
105
  onCloseAway,
83
106
  }: UsePortalMenuPositionArgs): UsePortalMenuPositionResult<TMenuEl> {
84
107
  const menuElRef = React.useRef<TMenuEl | null>(null);
@@ -115,18 +138,6 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
115
138
  };
116
139
  }, [enabled, open, portalRoot]);
117
140
 
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
-
130
141
  const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
131
142
 
132
143
  const positionMenu = React.useCallback(() => {
@@ -144,13 +155,14 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
144
155
  }
145
156
  const spaceBelow = window.innerHeight - rect.bottom - GAP;
146
157
  const spaceAbove = rect.top - safeTop - GAP;
147
- const openAbove = spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow;
158
+ const openAbove = openDirection === 'down' ? false : (spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow);
148
159
  // cap the menu to the space it ACTUALLY has in whichever direction it opens, instead of
149
160
  // trusting a static CSS max-height on its own — near the header or viewport edge that static
150
161
  // cap can still be taller than what's really available, which is what let the menu paint over
151
162
  // the header in the first place. The consumer's own overflow-y:auto takes it from there once
152
163
  // content exceeds this.
153
- const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, openAbove ? spaceAbove : spaceBelow));
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));
154
166
  setMenuPos({
155
167
  width: rect.width,
156
168
  left: menuAlign === 'right' ? 'auto' : rect.left,
@@ -159,7 +171,7 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
159
171
  bottom: openAbove ? window.innerHeight - rect.top + GAP : 'auto',
160
172
  maxHeight: available,
161
173
  });
162
- }, [enabled, menuAlign, onCloseAway, rootRef]);
174
+ }, [enabled, menuAlign, openDirection, onCloseAway, rootRef]);
163
175
 
164
176
  // Synchronous (pre-paint) position computation. useLayoutEffect — not useEffect — matters here:
165
177
  // it runs right after the DOM mutation that mounted the portal but BEFORE the browser paints, so
@@ -0,0 +1,84 @@
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
+ };
package/utils/index.ts CHANGED
@@ -62,6 +62,14 @@ 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
+
65
73
  export { getEquipment, getEquipmentCount } from '../vehiclesProps/equipment';
66
74
 
67
75
  export type { IDecoratedProps, IEquipmentProps, ICarPropElement } from '../types/types';
@@ -83,3 +91,5 @@ export type { IValues, IFilters, IQuery } from './query';
83
91
  // Decorated car props (renders React UI; lives in vehiclesProps/ with its
84
92
  // IconContainer + Co2Widget dependencies under compat/).
85
93
  export { default as getDecoratedProps } from '../vehiclesProps/decoratedProps';
94
+ export { setStrictConditionOwners, isStrictConditionOwner, strictAccidentStatus } from '../vehiclesProps/accidentDisclosure';
95
+ export type { AccidentStatus } from '../vehiclesProps/accidentDisclosure';