native-pytech 1.0.10 → 1.0.12
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.
|
@@ -2,6 +2,7 @@ import { StyleProp } from 'react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare const addProps: (element: React.ReactElement | null, additionalStyles?: StyleProp<any>, extraProps?: Record<string, any>) => React.ReactElement | null;
|
|
4
4
|
export declare const numberFormat: (value: number) => string;
|
|
5
|
+
export declare const numberFormatInverted: (value: string) => number;
|
|
5
6
|
export declare function applyOpacity(color: string, opacity: number): string;
|
|
6
7
|
export declare function adjustLightness(color: string, percentage: number): string;
|
|
7
8
|
export declare const _getDeviceTier: () => "low" | "medium" | "high";
|
|
@@ -18,6 +18,18 @@ export const numberFormat = (value) => {
|
|
|
18
18
|
const abs = formatter.format(Math.abs(value));
|
|
19
19
|
return value < 0 ? `(${abs})` : abs;
|
|
20
20
|
};
|
|
21
|
+
export const numberFormatInverted = (value) => {
|
|
22
|
+
const trimmed = value.trim();
|
|
23
|
+
const isNegative = /^\(.*\)$/.test(trimmed);
|
|
24
|
+
const normalized = trimmed
|
|
25
|
+
.replace(/[()]/g, '')
|
|
26
|
+
.replace(/\./g, '')
|
|
27
|
+
.replace(',', '.');
|
|
28
|
+
const parsed = Number.parseFloat(normalized);
|
|
29
|
+
if (Number.isNaN(parsed))
|
|
30
|
+
return 0;
|
|
31
|
+
return isNegative ? -parsed : parsed;
|
|
32
|
+
};
|
|
21
33
|
export function applyOpacity(color, opacity) {
|
|
22
34
|
try {
|
|
23
35
|
const [r, g, b] = parseToRgba(color); // ignoro alpha original
|