@bytebrand/fe-ui-core-autobahn 1.0.53 → 1.0.55

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.
@@ -1,32 +0,0 @@
1
- /** Monetary figure → de-DE grouped string (e.g. 47400 → "47.400"). Feed rounded integers —
2
- * toLocaleString on a fractional value prints a bogus 3-decimal grouping. */
3
- export declare function formatEur(n: number): string;
4
- /** Rate → de-DE percent string (e.g. 6.49 → "6,49 %"). */
5
- export declare function formatPct(n: number): string;
6
- export interface FinanceExampleFields {
7
- price: number;
8
- apr: number;
9
- down: number;
10
- /** Real config figure — falls back to price-down ONLY when genuinely absent. */
11
- netLoanAmount?: number;
12
- nominalRate?: number;
13
- finalInstallment?: number;
14
- grossAmount?: number;
15
- }
16
- export interface FinanceExampleLabels {
17
- vehiclePrice: string;
18
- priceSuffix: string;
19
- apr: string;
20
- nominal: string;
21
- net: string;
22
- down: string;
23
- final: string;
24
- gross: string;
25
- }
26
- /**
27
- * The "Repräsentatives Beispiel" disclaimer line (PAngV). Only fields with a genuine value are
28
- * included — nominalRate/finalInstallment/grossAmount are optional real config figures, never
29
- * derived (see fields doc). Matches production wording/format exactly (VdpModules.tsx's
30
- * `exampleLine`, byte-for-byte).
31
- */
32
- export declare function buildFinanceExampleLine(fields: FinanceExampleFields, labels: FinanceExampleLabels, footnoteMarker?: string): string;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- // Autobahn (auto.de redesign) — shared financing-number formatting.
3
- //
4
- // Extracted from vdp/VdpModules.tsx's FinanceDetailsModal so non-React consumers (e.g. the
5
- // Meta AIA marketing-image renderer) format the SAME real numbers the same way, instead of a
6
- // second copy drifting from the VDP's. Pure TS, no React/JSX — safe to import from a plain
7
- // Node service.
8
- //
9
- // The "only real figures, never a fabricated total" rule is load-bearing (legal: balloon
10
- // financing means monthly×term is NOT the total) and lives here once, not per-caller.
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.formatEur = formatEur;
13
- exports.formatPct = formatPct;
14
- exports.buildFinanceExampleLine = buildFinanceExampleLine;
15
- /** Monetary figure → de-DE grouped string (e.g. 47400 → "47.400"). Feed rounded integers —
16
- * toLocaleString on a fractional value prints a bogus 3-decimal grouping. */
17
- function formatEur(n) {
18
- return n.toLocaleString('de-DE');
19
- }
20
- /** Rate → de-DE percent string (e.g. 6.49 → "6,49 %"). */
21
- function formatPct(n) {
22
- return `${n.toFixed(2).replace('.', ',')} %`;
23
- }
24
- /**
25
- * The "Repräsentatives Beispiel" disclaimer line (PAngV). Only fields with a genuine value are
26
- * included — nominalRate/finalInstallment/grossAmount are optional real config figures, never
27
- * derived (see fields doc). Matches production wording/format exactly (VdpModules.tsx's
28
- * `exampleLine`, byte-for-byte).
29
- */
30
- function buildFinanceExampleLine(fields, labels, footnoteMarker = '³') {
31
- const netto = fields.netLoanAmount != null ? fields.netLoanAmount : Math.max(0, fields.price - fields.down);
32
- const parts = [
33
- `${labels.vehiclePrice}: ${formatEur(fields.price)} € ${labels.priceSuffix}`,
34
- ...(fields.apr > 0 ? [`${labels.apr}: ${formatPct(fields.apr)}`] : []),
35
- ...(fields.nominalRate != null && fields.nominalRate > 0 ? [`${labels.nominal}: ${formatPct(fields.nominalRate)}`] : []),
36
- `${labels.net}: ${formatEur(netto)} €`,
37
- `${labels.down}: ${formatEur(fields.down)} €`,
38
- ...(fields.finalInstallment != null && fields.finalInstallment > 0 ? [`${labels.final}: ${formatEur(fields.finalInstallment)} €`] : []),
39
- ...(fields.grossAmount != null && fields.grossAmount > 0 ? [`${labels.gross}: ${formatEur(fields.grossAmount)} €`] : []),
40
- ];
41
- return `${footnoteMarker} ${parts.join('; ')};`;
42
- }
package/utils/power.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const getPowerLabel: (powerKW: number, powerPS: number) => string;
package/utils/power.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPowerLabel = void 0;
4
- // Pure power-label formatter, extracted from fe-ui-core's
5
- // source/framework/vehiclesProps/decoratedProps.tsx (which stays in fe-ui-core
6
- // because it drags React UI). Exactly one implementation lives here;
7
- // decoratedProps re-exports it for backwards compatibility.
8
- const getPowerLabel = (powerKW, powerPS) => {
9
- const powerKWlabel = !!powerKW ? `${powerKW} kW ` : '';
10
- const powerPSlabel = !!powerPS ? `${!!powerKW ? '(' : ''}${powerPS} PS${!!powerKW ? ')' : ''}` : '';
11
- const powerKWpowerPS = `${powerKWlabel}${powerPSlabel}`;
12
- return powerKWpowerPS;
13
- };
14
- exports.getPowerLabel = getPowerLabel;
@@ -1,3 +0,0 @@
1
- export declare const getPriceRatingConfig: (currentPrice: number, pricePredicted: number) => any;
2
- export declare const getPredictablePrice: (currentSalesPrice: number, predictablePrice: number) => number;
3
- export declare const getPriceRating: (currentSalesPrice: number, predictablePrice: number) => number;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPriceRating = exports.getPredictablePrice = exports.getPriceRatingConfig = void 0;
4
- // Autobahn (auto.de redesign) — Preisbewertung rating math, extracted from CommonUtils.ts.
5
- //
6
- // Pulled out on purpose: CommonUtils.ts transitively imports `../constants/Search`, which
7
- // `require()`s image assets (webpack-only — breaks any plain Node `require`/`tsc` consumer).
8
- // This file only imports `../constants/price` (zero further imports), so the Meta AIA
9
- // marketing-image renderer (a plain Node backend, see ../data/toAutobahnCar.ts's `mapRating`)
10
- // can import real Preisbewertung math without dragging in frontend-only asset requires.
11
- // CommonUtils.ts re-exports these for existing consumers — one implementation, not a fork.
12
- const price_1 = require("../constants/price");
13
- const core_1 = require("../constants/core");
14
- const getPriceRatingConfig = (currentPrice, pricePredicted) => {
15
- const round = (value) => {
16
- return Number.isFinite(pricePredicted)
17
- ? Math.round((pricePredicted * (1 + (value / 100))) / 100) * 100 // tslint:disable-line
18
- : '???';
19
- };
20
- if (currentPrice === 0) {
21
- console.log('Empty current price');
22
- }
23
- return Object.keys(price_1.priceRatingConfig).reduce((acc, key) => {
24
- const { min, max } = price_1.priceRatingConfig[key];
25
- return { ...acc, [key]: { min: round(min), max: round(max) } };
26
- }, {}); // tslint:disable-line
27
- };
28
- exports.getPriceRatingConfig = getPriceRatingConfig;
29
- const getPredictablePrice = (currentSalesPrice, predictablePrice) => {
30
- if (Number.isFinite(Number.parseFloat(`${predictablePrice}`))) {
31
- return predictablePrice;
32
- }
33
- return currentSalesPrice * core_1.PREDICTABLE_PRICE_INDEX;
34
- };
35
- exports.getPredictablePrice = getPredictablePrice;
36
- const getPriceRating = (currentSalesPrice, predictablePrice) => {
37
- const isCorrectCurrentSalesPrice = Number.isFinite(Number.parseFloat(`${currentSalesPrice}`));
38
- // const isCorrectPredictablePrice = Number.isFinite(Number.parseFloat(`${predictablePrice}`));
39
- if (!isCorrectCurrentSalesPrice)
40
- return 0;
41
- const validatedPredictablePrice = (0, exports.getPredictablePrice)(currentSalesPrice, predictablePrice);
42
- const ratingConfig = (0, exports.getPriceRatingConfig)(currentSalesPrice, validatedPredictablePrice);
43
- for (const key of Object.keys(ratingConfig)) {
44
- const { min, max } = ratingConfig[key];
45
- const TOP_PRICE = 5;
46
- if (key === 'highPrice' && currentSalesPrice === max)
47
- return 1;
48
- if (key === 'topPrice' && currentSalesPrice <= min)
49
- return TOP_PRICE;
50
- if (currentSalesPrice >= min && currentSalesPrice < max)
51
- return price_1.priceRatings.indexOf(key);
52
- }
53
- return 0;
54
- };
55
- exports.getPriceRating = getPriceRating;