rn-css 1.11.9 → 1.11.10
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/dist/convertUnits.js +3 -3
- package/package.json +1 -1
- package/src/convertUnits.ts +3 -3
package/dist/convertUnits.js
CHANGED
|
@@ -26,9 +26,9 @@ function convertValue(key, value, units) {
|
|
|
26
26
|
if (react_native_1.Platform.OS === 'web' && (!key.toLowerCase().includes('border') || key.toLowerCase().includes('radius')))
|
|
27
27
|
return value;
|
|
28
28
|
if (['marginTop', 'marginBottom', 'translateY'].includes(key) || key.startsWith('borderTop') || key.startsWith('borderBottom'))
|
|
29
|
-
finalUnits['%'] = units.height / 100;
|
|
29
|
+
finalUnits['%'] = (units.height || 0) / 100;
|
|
30
30
|
else if (['marginLeft', 'marginRight', 'translateX'].includes(key) || key.startsWith('borderLeft') || key.startsWith('borderRight'))
|
|
31
|
-
finalUnits['%'] = units.width / 100;
|
|
31
|
+
finalUnits['%'] = (units.width || 0) / 100;
|
|
32
32
|
else if (key.startsWith('border') && key.endsWith('Radius'))
|
|
33
33
|
finalUnits['%'] = ((units.width || 0) + (units.height || 0)) / 200;
|
|
34
34
|
else if (['width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'top', 'left', 'bottom', 'right', 'flexBasis', 'rotate3d'].includes(key)) {
|
|
@@ -53,7 +53,7 @@ function convertValue(key, value, units) {
|
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
54
|
if (['deg', 'rad', 'turn', 's'].includes(unit))
|
|
55
55
|
return occ; // We don't want to convert deg, rad, turn, second units
|
|
56
|
-
return val * (finalUnits[unit || 'px']
|
|
56
|
+
return val * (finalUnits[unit || 'px'] ?? 1) + '';
|
|
57
57
|
});
|
|
58
58
|
// We handle extra calculations (calc, min, max, parsing...)
|
|
59
59
|
if (convertedValue.startsWith('calc('))
|
package/package.json
CHANGED
package/src/convertUnits.ts
CHANGED
|
@@ -23,8 +23,8 @@ export function convertValue (key: keyof PartialStyle | keyof Transform, value:
|
|
|
23
23
|
if (value.includes('%')) {
|
|
24
24
|
// Percentage is not supported on borders in web
|
|
25
25
|
if (Platform.OS === 'web' && (!key.toLowerCase().includes('border') || key.toLowerCase().includes('radius'))) return value
|
|
26
|
-
if (['marginTop', 'marginBottom', 'translateY'].includes(key) || key.startsWith('borderTop') || key.startsWith('borderBottom')) finalUnits['%'] = units.height
|
|
27
|
-
else if (['marginLeft', 'marginRight', 'translateX'].includes(key) || key.startsWith('borderLeft') || key.startsWith('borderRight')) finalUnits['%'] = units.width
|
|
26
|
+
if (['marginTop', 'marginBottom', 'translateY'].includes(key) || key.startsWith('borderTop') || key.startsWith('borderBottom')) finalUnits['%'] = (units.height || 0) / 100
|
|
27
|
+
else if (['marginLeft', 'marginRight', 'translateX'].includes(key) || key.startsWith('borderLeft') || key.startsWith('borderRight')) finalUnits['%'] = (units.width || 0) / 100
|
|
28
28
|
else if (key.startsWith('border') && key.endsWith('Radius')) finalUnits['%'] = ((units.width || 0) + (units.height || 0)) / 200
|
|
29
29
|
else if (['width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'top', 'left', 'bottom', 'right', 'flexBasis', 'rotate3d'].includes(key)) {
|
|
30
30
|
if (value.startsWith('calc') || value.startsWith('max') || value.startsWith('min')) {
|
|
@@ -43,7 +43,7 @@ export function convertValue (key: keyof PartialStyle | keyof Transform, value:
|
|
|
43
43
|
const [val, unit] = parseValue(occ)
|
|
44
44
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
45
|
if (['deg', 'rad', 'turn', 's'].includes(unit!)) return occ // We don't want to convert deg, rad, turn, second units
|
|
46
|
-
return val * (finalUnits[unit as keyof Units || 'px']
|
|
46
|
+
return val * (finalUnits[unit as keyof Units || 'px'] ?? 1) + ''
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
// We handle extra calculations (calc, min, max, parsing...)
|