@bytebrand/fe-ui-core 4.2.44 → 4.2.46
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
|
@@ -48,6 +48,24 @@ export const getPowerLabel = (powerKW: number, powerPS: number): string => {
|
|
|
48
48
|
|
|
49
49
|
return powerKWpowerPS;
|
|
50
50
|
};
|
|
51
|
+
const wrapValue = (value:string): React.ReactNode => {
|
|
52
|
+
const regex = /-?\d+(\,\d+)?/; // match any digit
|
|
53
|
+
const matches = value.match(regex); // get an array of all digits found
|
|
54
|
+
|
|
55
|
+
if (matches && matches.length > 0) { // If at least one number is found in the input string
|
|
56
|
+
const index = value.indexOf(matches[0]) + matches[0].length;
|
|
57
|
+
const beforeText = value.slice(0, index);
|
|
58
|
+
const afterText = value.slice(index);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{beforeText}
|
|
63
|
+
<span className='smallText'>{afterText}</span>
|
|
64
|
+
</>
|
|
65
|
+
); // Return a JSX element with a span wrapper around the text after the number
|
|
66
|
+
}
|
|
67
|
+
return <>{value}</>; // If no numbers are found in the input string, return the original string without any modification
|
|
68
|
+
};
|
|
51
69
|
|
|
52
70
|
const getDecoratedProps = (
|
|
53
71
|
car: ICar, // @TODO should have a proper interface
|
|
@@ -750,15 +768,13 @@ const getDecoratedProps = (
|
|
|
750
768
|
const co2Value = Number.isFinite(co2)
|
|
751
769
|
? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
|
|
752
770
|
: t('vehicleProps:value.na');
|
|
753
|
-
|
|
754
771
|
const hybridPlugin = car.engineData.hybridPlugin;
|
|
755
|
-
|
|
756
772
|
return Number.isFinite(consumptionCombined) && Number.isFinite(consumptionPowerCombined)
|
|
757
773
|
? <React.Fragment>
|
|
758
|
-
{consumptionPowerCombined && hybridPlugin ? consumptionPowerCombinedContent : ''}
|
|
774
|
+
{consumptionPowerCombined && hybridPlugin ? wrapValue(consumptionPowerCombinedContent) : ''}
|
|
759
775
|
{consumptionPowerCombined && hybridPlugin ? <br /> : ''}
|
|
760
|
-
{consumptionCombinedContent} <br />
|
|
761
|
-
{co2Value}
|
|
776
|
+
{wrapValue(consumptionCombinedContent)} <br />
|
|
777
|
+
{wrapValue(co2Value)}
|
|
762
778
|
</React.Fragment>
|
|
763
779
|
: t('vehicleProps:value.na');
|
|
764
780
|
}
|