rn-css 1.6.9 → 1.6.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Style, Transform } from '../types';
|
|
2
2
|
/** Parse a css value for border */
|
|
3
|
-
export declare function border(prefixKey: 'border' | 'borderLeft' | 'borderRight' | 'borderTop' | 'borderBottom', value: string): {
|
|
3
|
+
export declare function border(prefixKey: 'border' | 'borderLeft' | 'borderRight' | 'borderTop' | 'borderBottom' | 'outline', value: string): {
|
|
4
4
|
[x: string]: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function shadow(prefix: 'textShadow' | 'shadow', value: string): {
|
|
@@ -29,6 +29,9 @@ export declare function placeContent(value: string): {
|
|
|
29
29
|
alignContent: string;
|
|
30
30
|
justifyContent: string;
|
|
31
31
|
};
|
|
32
|
+
export declare function background(value: string): {
|
|
33
|
+
backgroundColor: string | undefined;
|
|
34
|
+
};
|
|
32
35
|
export declare function textDecoration(value: string): {
|
|
33
36
|
textDecorationLine: string;
|
|
34
37
|
textDecorationStyle: string;
|
package/dist/cssToRN/convert.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cornerValue = exports.sideValue = exports.font = exports.transform = exports.textDecoration = exports.placeContent = exports.flexFlow = exports.flex = exports.shadow = exports.border = void 0;
|
|
3
|
+
exports.cornerValue = exports.sideValue = exports.font = exports.transform = exports.textDecoration = exports.background = exports.placeContent = exports.flexFlow = exports.flex = exports.shadow = exports.border = void 0;
|
|
4
4
|
/** Check if the value is a number. Numbers start with a digit, a decimal point or calc(, max( ou min( */
|
|
5
5
|
function isNumber(value) {
|
|
6
6
|
return value.match(/^[+-]?(\.\d|\d|calc\(|max\(|min\()/mg);
|
|
@@ -87,6 +87,12 @@ function placeContent(value) {
|
|
|
87
87
|
return { alignContent, justifyContent };
|
|
88
88
|
}
|
|
89
89
|
exports.placeContent = placeContent;
|
|
90
|
+
function background(value) {
|
|
91
|
+
const values = value.split(/\s+/mg);
|
|
92
|
+
// The background-color is the only one that we support and it's the last value
|
|
93
|
+
return { backgroundColor: values.pop() };
|
|
94
|
+
}
|
|
95
|
+
exports.background = background;
|
|
90
96
|
function textDecoration(value) {
|
|
91
97
|
const values = value.split(/\s+/mg);
|
|
92
98
|
const result = {
|
package/dist/cssToRN/index.js
CHANGED
|
@@ -69,6 +69,7 @@ function cssChunkToStyle(css) {
|
|
|
69
69
|
const key = kebab2camel(rawKey.trim());
|
|
70
70
|
const value = stripSpaces(rawValue.trim()); // We need this to correctly read calc() values
|
|
71
71
|
switch (key) {
|
|
72
|
+
case 'outline':
|
|
72
73
|
case 'border':
|
|
73
74
|
case 'borderTop':
|
|
74
75
|
case 'borderLeft':
|
|
@@ -80,7 +81,7 @@ function cssChunkToStyle(css) {
|
|
|
80
81
|
Object.assign(result, (0, convert_1.sideValue)('border', value, 'Width'));
|
|
81
82
|
break;
|
|
82
83
|
case 'background':
|
|
83
|
-
Object.assign(result,
|
|
84
|
+
Object.assign(result, (0, convert_1.background)(value));
|
|
84
85
|
break;
|
|
85
86
|
case 'padding':
|
|
86
87
|
case 'margin':
|
package/dist/styleComponent.js
CHANGED
|
@@ -109,10 +109,8 @@ const styled = (Component) => {
|
|
|
109
109
|
return newProps;
|
|
110
110
|
}, [finalStyle.textOverflow, onLayout, onMouseEnter, onMouseLeave, props.style, styleConvertedFromCSS]);
|
|
111
111
|
react_1.default.useEffect(() => () => removeStyle(hash), [hash]);
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
// if (em !== currentFontSize) {
|
|
115
|
-
if (styleConvertedFromCSS.fontSize) {
|
|
112
|
+
// em !== parentEm alone is a bit dangerous as the component would rerender when the font size change
|
|
113
|
+
if (em !== parentEm || finalStyle.fontSize !== undefined) {
|
|
116
114
|
return react_1.default.createElement(exports.FontSizeContext.Provider, { value: em },
|
|
117
115
|
react_1.default.createElement(Component, { ref: ref, ...props, ...newProps }));
|
|
118
116
|
}
|
package/package.json
CHANGED
package/src/cssToRN/convert.ts
CHANGED
|
@@ -23,7 +23,7 @@ function findNumbers (value: string) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Parse a css value for border */
|
|
26
|
-
export function border (prefixKey: 'border' | 'borderLeft' | 'borderRight' | 'borderTop' | 'borderBottom', value: string): { [x:string]: string } {
|
|
26
|
+
export function border (prefixKey: 'border' | 'borderLeft' | 'borderRight' | 'borderTop' | 'borderBottom' | 'outline', value: string): { [x:string]: string } {
|
|
27
27
|
const values = value.split(/\s+/mg)
|
|
28
28
|
const result = {
|
|
29
29
|
[prefixKey + 'Width']: '0',
|
|
@@ -75,6 +75,12 @@ export function placeContent (value: string) {
|
|
|
75
75
|
return { alignContent, justifyContent }
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export function background (value: string) {
|
|
79
|
+
const values = value.split(/\s+/mg)
|
|
80
|
+
// The background-color is the only one that we support and it's the last value
|
|
81
|
+
return { backgroundColor: values.pop() }
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
export function textDecoration (value: string) {
|
|
79
85
|
const values = value.split(/\s+/mg)
|
|
80
86
|
const result = {
|
package/src/cssToRN/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dimensions } from 'react-native'
|
|
2
2
|
import convertStyle from '../convertStyle'
|
|
3
3
|
import type { Context, PartialStyle, Style, Units } from '../types'
|
|
4
|
-
import { sideValue, border, cornerValue, font, textDecoration, shadow, placeContent, flex, flexFlow, transform } from './convert'
|
|
4
|
+
import { sideValue, border, cornerValue, font, textDecoration, shadow, placeContent, flex, flexFlow, transform, background } from './convert'
|
|
5
5
|
import { createMedia } from './mediaQueries'
|
|
6
6
|
|
|
7
7
|
function kebab2camel (string: string) {
|
|
@@ -66,6 +66,7 @@ function cssChunkToStyle (css: string) {
|
|
|
66
66
|
const key = kebab2camel(rawKey.trim())
|
|
67
67
|
const value = stripSpaces(rawValue.trim())// We need this to correctly read calc() values
|
|
68
68
|
switch (key) {
|
|
69
|
+
case 'outline':
|
|
69
70
|
case 'border':
|
|
70
71
|
case 'borderTop':
|
|
71
72
|
case 'borderLeft':
|
|
@@ -77,7 +78,7 @@ function cssChunkToStyle (css: string) {
|
|
|
77
78
|
Object.assign(result, sideValue('border', value, 'Width'))
|
|
78
79
|
break
|
|
79
80
|
case 'background':
|
|
80
|
-
Object.assign(result,
|
|
81
|
+
Object.assign(result, background(value))
|
|
81
82
|
break
|
|
82
83
|
case 'padding':
|
|
83
84
|
case 'margin':
|
package/src/styleComponent.tsx
CHANGED
|
@@ -122,10 +122,8 @@ const styled = <Props, >(Component: React.ComponentType<Props>) => {
|
|
|
122
122
|
|
|
123
123
|
React.useEffect(() => () => removeStyle(hash), [hash])
|
|
124
124
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
// if (em !== currentFontSize) {
|
|
128
|
-
if (styleConvertedFromCSS.fontSize) {
|
|
125
|
+
// em !== parentEm alone is a bit dangerous as the component would rerender when the font size change
|
|
126
|
+
if (em !== parentEm || finalStyle.fontSize !== undefined) {
|
|
129
127
|
return <FontSizeContext.Provider value={em}>
|
|
130
128
|
<Component ref={ref} {...props} {...newProps} />
|
|
131
129
|
</FontSizeContext.Provider>
|